From 12b9cfcc00a1ea1ff334f00b2808495a1bb96db7 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 11 Apr 2022 17:23:45 +0300 Subject: [PATCH 01/24] Import ddverify-2009-03-09 From http://www.cprover.org/ddverify/. --- ddverify/awk/convert_satabs_output | 5 + ddverify/awk/get_number_of_iteration | 3 + ddverify/awk/get_time_result | 3 + ddverify/awk/get_too_many_iterations_result | 6 + ddverify/awk/get_verification_result | 6 + ddverify/awk/parse_dd_file | 3 + ddverify/bin/LICENSE | 40 + ddverify/bin/ddverify.c | 965 ++++ ddverify/bin/ddverify.h | 155 + ddverify/case_studies/block/cciss/cciss.c | 3533 +++++++++++++ ddverify/case_studies/block/cciss/cciss.h | 290 ++ ddverify/case_studies/block/cciss/cciss_cmd.h | 298 ++ .../case_studies/block/cciss/cciss_scsi.c | 1535 ++++++ .../case_studies/block/cciss/cciss_scsi.h | 79 + .../case_studies/block/cpqarray/cpqarray.c | 1850 +++++++ .../case_studies/block/cpqarray/cpqarray.h | 126 + .../case_studies/block/cpqarray/ida_cmd.h | 349 ++ .../case_studies/block/cpqarray/ida_ioctl.h | 87 + .../case_studies/block/cpqarray/smart1,2.h | 278 + ddverify/case_studies/block/floppy/floppy.c | 4586 +++++++++++++++++ ddverify/case_studies/block/nbd/nbd.c | 703 +++ ddverify/case_studies/block/nbd/nbd.h | 102 + ddverify/case_studies/block/umem/umem.c | 1244 +++++ ddverify/case_studies/block/umem/umem.h | 138 + ddverify/case_studies/cdrom/aztcd/aztcd.c | 2494 +++++++++ ddverify/case_studies/cdrom/aztcd/aztcd.h | 162 + ddverify/case_studies/cdrom/aztcd/cdrom.h | 1192 +++++ ddverify/case_studies/cdrom/cdu31a/cdu31a.c | 3248 ++++++++++++ ddverify/case_studies/cdrom/cdu31a/cdu31a.h | 411 ++ ddverify/case_studies/cdrom/cm206/cm206.c | 1595 ++++++ ddverify/case_studies/cdrom/cm206/cm206.h | 171 + .../case_studies/char/applicom/applicom.c | 850 +++ .../case_studies/char/applicom/applicom.h | 85 + .../char/cs5535_gpio/cs5535_gpio.c | 251 + ddverify/case_studies/char/ds1286/ds1286.c | 579 +++ ddverify/case_studies/char/ds1286/ds1286.h | 54 + ddverify/case_studies/char/dtlk/dtlk.c | 654 +++ ddverify/case_studies/char/dtlk/dtlk.h | 104 + ddverify/case_studies/char/efirtc/efi.h | 397 ++ ddverify/case_studies/char/efirtc/efirtc.c | 418 ++ .../char/generic_nvram/generic_nvram.c | 150 + ddverify/case_studies/char/genrtc/genrtc.c | 536 ++ .../case_studies/char/nwbutton/nwbutton.c | 247 + .../case_studies/char/nwbutton/nwbutton.h | 40 + ddverify/case_studies/char/toshiba/toshiba.c | 527 ++ ddverify/case_studies/char/toshiba/toshiba.h | 36 + .../char/watchdog/i8xx_tco/i8xx_tco.c | 571 ++ .../char/watchdog/i8xx_tco/i8xx_tco.h | 42 + .../char/watchdog/ib700wdt/ib700wdt.c | 346 ++ .../char/watchdog/machzwd/machzwd.c | 494 ++ .../char/watchdog/mixcomwd/mixcomwd.c | 302 ++ .../case_studies/char/watchdog/pcwd/pcwd.c | 1001 ++++ .../char/watchdog/pcwd_pci/pcwd_pci.c | 810 +++ .../char/watchdog/sbc60xxwdt/sbc60xxwdt.c | 408 ++ .../char/watchdog/sc1200wdt/sc1200wdt.c | 466 ++ .../char/watchdog/sc520_wdt/sc520_wdt.c | 443 ++ .../watchdog/smsc37b787_wdt/smsc37b787_wdt.c | 627 +++ .../char/watchdog/w83877f_wdt/w83877f_wdt.c | 421 ++ .../char/watchdog/w83977f_wdt/w83977f_wdt.c | 542 ++ .../case_studies/char/watchdog/wdt/wd501p.h | 51 + ddverify/case_studies/char/watchdog/wdt/wdt.c | 640 +++ .../char/watchdog/wdt977/wdt977.c | 519 ++ .../char/watchdog/wdt_pci/wd501p.h | 51 + .../char/watchdog/wdt_pci/wdt_pci.c | 756 +++ .../models/con1/include/asm-generic/bug.h | 9 + .../con1/include/asm-generic/errno-base.h | 39 + .../models/con1/include/asm-generic/errno.h | 109 + .../models/con1/include/asm-generic/fcntl.h | 110 + .../models/con1/include/asm-generic/ioctl.h | 80 + .../con1/include/asm-generic/pci-dma-compat.h | 20 + .../models/con1/include/asm-generic/rtc.h | 18 + .../models/con1/include/asm-generic/siginfo.h | 118 + ddverify/models/con1/include/asm/atomic.h | 169 + ddverify/models/con1/include/asm/bitops.h | 13 + ddverify/models/con1/include/asm/bug.h | 7 + ddverify/models/con1/include/asm/byteorder.h | 9 + ddverify/models/con1/include/asm/current.h | 14 + ddverify/models/con1/include/asm/delay.h | 6 + ddverify/models/con1/include/asm/dma.h | 72 + ddverify/models/con1/include/asm/errno.h | 6 + ddverify/models/con1/include/asm/fcntl.h | 1 + ddverify/models/con1/include/asm/floppy.h | 45 + ddverify/models/con1/include/asm/highmem.h | 17 + ddverify/models/con1/include/asm/io.h | 69 + ddverify/models/con1/include/asm/ioctl.h | 1 + ddverify/models/con1/include/asm/ioctls.h | 91 + ddverify/models/con1/include/asm/irq.h | 0 ddverify/models/con1/include/asm/kmap_types.h | 23 + ddverify/models/con1/include/asm/leds.h | 0 ddverify/models/con1/include/asm/mach-types.h | 0 .../models/con1/include/asm/mc146818rtc.h | 34 + ddverify/models/con1/include/asm/msr.h | 10 + ddverify/models/con1/include/asm/page.h | 24 + ddverify/models/con1/include/asm/param.h | 8 + ddverify/models/con1/include/asm/pci.h | 17 + ddverify/models/con1/include/asm/poll.h | 20 + .../models/con1/include/asm/posix_types.h | 32 + ddverify/models/con1/include/asm/processor.h | 6 + ddverify/models/con1/include/asm/ptrace.h | 8 + ddverify/models/con1/include/asm/rtc.h | 7 + .../models/con1/include/asm/scatterlist.h | 21 + ddverify/models/con1/include/asm/semaphore.h | 37 + ddverify/models/con1/include/asm/siginfo.h | 6 + ddverify/models/con1/include/asm/signal.h | 86 + ddverify/models/con1/include/asm/stat.h | 0 ddverify/models/con1/include/asm/string.h | 6 + ddverify/models/con1/include/asm/system.h | 9 + ddverify/models/con1/include/asm/termbits.h | 20 + ddverify/models/con1/include/asm/termios.h | 54 + ddverify/models/con1/include/asm/types.h | 35 + ddverify/models/con1/include/asm/uaccess.h | 55 + .../models/con1/include/ddverify/blkdev.h | 10 + ddverify/models/con1/include/ddverify/cdev.h | 26 + .../models/con1/include/ddverify/ddverify.h | 47 + .../models/con1/include/ddverify/fixed_cdev.h | 15 + ddverify/models/con1/include/ddverify/genhd.h | 29 + .../models/con1/include/ddverify/interrupt.h | 19 + ddverify/models/con1/include/ddverify/ioctl.h | 15 + .../models/con1/include/ddverify/ioport.h | 27 + .../models/con1/include/ddverify/miscdevice.h | 7 + ddverify/models/con1/include/ddverify/pci.h | 22 + .../models/con1/include/ddverify/pthread.h | 253 + .../models/con1/include/ddverify/satabs.h | 69 + .../models/con1/include/ddverify/tasklet.h | 20 + ddverify/models/con1/include/ddverify/timer.h | 17 + ddverify/models/con1/include/ddverify/tty.h | 16 + .../models/con1/include/ddverify/workqueue.h | 12 + .../models/con1/include/linux/backing-dev.h | 37 + ddverify/models/con1/include/linux/bcd.h | 20 + ddverify/models/con1/include/linux/bio.h | 110 + ddverify/models/con1/include/linux/bitops.h | 6 + ddverify/models/con1/include/linux/blkdev.h | 239 + ddverify/models/con1/include/linux/blkpg.h | 0 .../models/con1/include/linux/blktrace_api.h | 141 + .../models/con1/include/linux/buffer_head.h | 0 .../con1/include/linux/byteorder/generic.h | 46 + .../include/linux/byteorder/little_endian.h | 30 + ddverify/models/con1/include/linux/cache.h | 0 .../models/con1/include/linux/capability.h | 244 + ddverify/models/con1/include/linux/cdev.h | 23 + ddverify/models/con1/include/linux/cdrom.h | 1192 +++++ ddverify/models/con1/include/linux/compat.h | 0 ddverify/models/con1/include/linux/compiler.h | 20 + .../models/con1/include/linux/completion.h | 18 + ddverify/models/con1/include/linux/config.h | 0 ddverify/models/con1/include/linux/console.h | 0 ddverify/models/con1/include/linux/cpumask.h | 0 ddverify/models/con1/include/linux/ctype.h | 0 ddverify/models/con1/include/linux/dcache.h | 9 + ddverify/models/con1/include/linux/delay.h | 22 + .../con1/include/linux/devfs_fs_kernel.h | 0 ddverify/models/con1/include/linux/device.h | 112 + .../models/con1/include/linux/dma-mapping.h | 19 + ddverify/models/con1/include/linux/elevator.h | 6 + ddverify/models/con1/include/linux/err.h | 27 + ddverify/models/con1/include/linux/errno.h | 25 + ddverify/models/con1/include/linux/fcntl.h | 6 + ddverify/models/con1/include/linux/fd.h | 373 ++ ddverify/models/con1/include/linux/fdreg.h | 137 + ddverify/models/con1/include/linux/file.h | 14 + ddverify/models/con1/include/linux/firmware.h | 22 + ddverify/models/con1/include/linux/fs.h | 238 + ddverify/models/con1/include/linux/genhd.h | 48 + ddverify/models/con1/include/linux/gfp.h | 74 + ddverify/models/con1/include/linux/hdreg.h | 13 + ddverify/models/con1/include/linux/highmem.h | 9 + ddverify/models/con1/include/linux/if.h | 8 + ddverify/models/con1/include/linux/in.h | 0 ddverify/models/con1/include/linux/init.h | 23 + .../models/con1/include/linux/interrupt.h | 96 + ddverify/models/con1/include/linux/ioctl.h | 6 + ddverify/models/con1/include/linux/ioport.h | 102 + ddverify/models/con1/include/linux/jiffies.h | 84 + ddverify/models/con1/include/linux/kdb_kern.h | 0 ddverify/models/con1/include/linux/kdev_t.h | 11 + ddverify/models/con1/include/linux/kernel.h | 115 + ddverify/models/con1/include/linux/kobject.h | 34 + ddverify/models/con1/include/linux/kthread.h | 0 ddverify/models/con1/include/linux/list.h | 108 + ddverify/models/con1/include/linux/major.h | 169 + .../models/con1/include/linux/mc146818rtc.h | 87 + ddverify/models/con1/include/linux/mempool.h | 11 + .../models/con1/include/linux/miscdevice.h | 43 + ddverify/models/con1/include/linux/mm.h | 17 + ddverify/models/con1/include/linux/mm_types.h | 14 + ddverify/models/con1/include/linux/mman.h | 0 ddverify/models/con1/include/linux/mmzone.h | 16 + .../con1/include/linux/mod_devicetable.h | 18 + ddverify/models/con1/include/linux/module.h | 32 + .../models/con1/include/linux/moduleparam.h | 12 + ddverify/models/con1/include/linux/mutex.h | 38 + ddverify/models/con1/include/linux/net.h | 19 + .../models/con1/include/linux/netdevice.h | 6 + ddverify/models/con1/include/linux/notifier.h | 61 + ddverify/models/con1/include/linux/pagemap.h | 15 + ddverify/models/con1/include/linux/parport.h | 559 ++ .../models/con1/include/linux/parport_pc.h | 42 + ddverify/models/con1/include/linux/pci.h | 176 + ddverify/models/con1/include/linux/pci_ids.h | 2260 ++++++++ ddverify/models/con1/include/linux/pci_regs.h | 449 ++ ddverify/models/con1/include/linux/percpu.h | 10 + .../con1/include/linux/platform_device.h | 25 + ddverify/models/con1/include/linux/pm.h | 12 + ddverify/models/con1/include/linux/pnp.h | 0 ddverify/models/con1/include/linux/poll.h | 16 + .../models/con1/include/linux/posix_types.h | 9 + ddverify/models/con1/include/linux/proc_fs.h | 29 + ddverify/models/con1/include/linux/ptrace.h | 80 + ddverify/models/con1/include/linux/reboot.h | 75 + ddverify/models/con1/include/linux/rtc.h | 219 + .../models/con1/include/linux/scatterlist.h | 24 + ddverify/models/con1/include/linux/sched.h | 62 + ddverify/models/con1/include/linux/seq_file.h | 35 + ddverify/models/con1/include/linux/serial.h | 131 + ddverify/models/con1/include/linux/signal.h | 54 + ddverify/models/con1/include/linux/skbuff.h | 6 + ddverify/models/con1/include/linux/slab.h | 16 + ddverify/models/con1/include/linux/smp_lock.h | 12 + ddverify/models/con1/include/linux/socket.h | 109 + ddverify/models/con1/include/linux/spinlock.h | 20 + .../con1/include/linux/spinlock_types.h | 21 + ddverify/models/con1/include/linux/stat.h | 66 + ddverify/models/con1/include/linux/stddef.h | 20 + ddverify/models/con1/include/linux/string.h | 35 + .../models/con1/include/linux/stringify.h | 12 + ddverify/models/con1/include/linux/suspend.h | 0 ddverify/models/con1/include/linux/swap.h | 0 ddverify/models/con1/include/linux/sysfs.h | 43 + ddverify/models/con1/include/linux/sysrq.h | 0 ddverify/models/con1/include/linux/termios.h | 7 + ddverify/models/con1/include/linux/time.h | 30 + ddverify/models/con1/include/linux/timer.h | 34 + ddverify/models/con1/include/linux/tty.h | 180 + .../models/con1/include/linux/tty_driver.h | 166 + .../models/con1/include/linux/tty_driver.h,v | 187 + ddverify/models/con1/include/linux/tty_flip.h | 13 + .../models/con1/include/linux/tty_ldisc.h | 51 + ddverify/models/con1/include/linux/types.h | 105 + ddverify/models/con1/include/linux/uio.h | 12 + ddverify/models/con1/include/linux/videodev.h | 346 ++ .../models/con1/include/linux/videodev2.h | 1351 +++++ ddverify/models/con1/include/linux/vmalloc.h | 9 + ddverify/models/con1/include/linux/wait.h | 91 + ddverify/models/con1/include/linux/watchdog.h | 52 + .../models/con1/include/linux/workqueue.h | 50 + .../models/con1/include/linux/writeback.h | 0 .../models/con1/include/media/v4l2-common.h | 6 + ddverify/models/con1/include/media/v4l2-dev.h | 255 + ddverify/models/con1/include/net/sock.h | 29 + ddverify/models/con1/src/ddverify/cdev.c | 156 + ddverify/models/con1/src/ddverify/ddverify.c | 116 + ddverify/models/con1/src/ddverify/genhd.c | 120 + ddverify/models/con1/src/ddverify/interrupt.c | 22 + ddverify/models/con1/src/ddverify/ioctl.c | 19 + ddverify/models/con1/src/ddverify/pci.c | 56 + ddverify/models/con1/src/ddverify/tasklet.c | 15 + ddverify/models/con1/src/ddverify/timer.c | 13 + .../con1/src/linux/arch/i386/lib/usercopy.c | 51 + .../models/con1/src/linux/block/elevator.c | 13 + ddverify/models/con1/src/linux/block/genhd.c | 58 + .../models/con1/src/linux/block/ll_rw_blk.c | 72 + .../models/con1/src/linux/drivers/char/misc.c | 36 + .../con1/src/linux/drivers/char/tty_io.c | 40 + ddverify/models/con1/src/linux/fs/char_dev.c | 110 + .../models/con1/src/linux/fs/proc/generic.c | 7 + .../models/con1/src/linux/kernel/irq/manage.c | 21 + ddverify/models/con1/src/linux/kernel/mutex.c | 37 + .../models/con1/src/linux/kernel/resource.c | 115 + ddverify/models/con1/src/linux/kernel/sched.c | 18 + .../models/con1/src/linux/kernel/semaphore.c | 86 + .../models/con1/src/linux/kernel/softirq.c | 38 + .../models/con1/src/linux/kernel/spinlock.c | 100 + ddverify/models/con1/src/linux/kernel/timer.c | 47 + ddverify/models/con1/src/linux/kernel/wait.c | 46 + .../models/con1/src/linux/kernel/workqueue.c | 39 + .../models/con1/src/linux/mm/page_alloc.c | 52 + ddverify/models/con1/src/linux/mm/slab.c | 22 + ddverify/models/con1/src/linux/mm/vmalloc.c | 9 + ddverify/models/con1/src/linux/pci.c | 111 + .../models/con2/include/asm-generic/bug.h | 9 + .../con2/include/asm-generic/errno-base.h | 39 + .../models/con2/include/asm-generic/errno.h | 109 + .../models/con2/include/asm-generic/fcntl.h | 110 + .../models/con2/include/asm-generic/ioctl.h | 80 + .../con2/include/asm-generic/pci-dma-compat.h | 20 + .../models/con2/include/asm-generic/rtc.h | 18 + .../models/con2/include/asm-generic/siginfo.h | 118 + ddverify/models/con2/include/asm/atomic.h | 169 + ddverify/models/con2/include/asm/bitops.h | 13 + ddverify/models/con2/include/asm/bug.h | 7 + ddverify/models/con2/include/asm/byteorder.h | 9 + ddverify/models/con2/include/asm/current.h | 14 + ddverify/models/con2/include/asm/delay.h | 6 + ddverify/models/con2/include/asm/dma.h | 72 + ddverify/models/con2/include/asm/errno.h | 6 + ddverify/models/con2/include/asm/fcntl.h | 1 + ddverify/models/con2/include/asm/floppy.h | 45 + ddverify/models/con2/include/asm/highmem.h | 17 + ddverify/models/con2/include/asm/io.h | 69 + ddverify/models/con2/include/asm/ioctl.h | 1 + ddverify/models/con2/include/asm/ioctls.h | 91 + ddverify/models/con2/include/asm/irq.h | 0 ddverify/models/con2/include/asm/kmap_types.h | 23 + ddverify/models/con2/include/asm/leds.h | 0 ddverify/models/con2/include/asm/mach-types.h | 0 .../models/con2/include/asm/mc146818rtc.h | 34 + ddverify/models/con2/include/asm/msr.h | 10 + ddverify/models/con2/include/asm/page.h | 24 + ddverify/models/con2/include/asm/param.h | 8 + ddverify/models/con2/include/asm/pci.h | 17 + ddverify/models/con2/include/asm/poll.h | 20 + .../models/con2/include/asm/posix_types.h | 32 + ddverify/models/con2/include/asm/processor.h | 6 + ddverify/models/con2/include/asm/ptrace.h | 8 + ddverify/models/con2/include/asm/rtc.h | 7 + .../models/con2/include/asm/scatterlist.h | 21 + ddverify/models/con2/include/asm/semaphore.h | 37 + ddverify/models/con2/include/asm/siginfo.h | 6 + ddverify/models/con2/include/asm/signal.h | 86 + ddverify/models/con2/include/asm/stat.h | 0 ddverify/models/con2/include/asm/string.h | 6 + ddverify/models/con2/include/asm/system.h | 9 + ddverify/models/con2/include/asm/termbits.h | 20 + ddverify/models/con2/include/asm/termios.h | 54 + ddverify/models/con2/include/asm/types.h | 35 + ddverify/models/con2/include/asm/uaccess.h | 55 + .../models/con2/include/ddverify/blkdev.h | 10 + ddverify/models/con2/include/ddverify/cdev.h | 26 + .../models/con2/include/ddverify/ddverify.h | 47 + .../models/con2/include/ddverify/fixed_cdev.h | 15 + ddverify/models/con2/include/ddverify/genhd.h | 29 + .../models/con2/include/ddverify/interrupt.h | 19 + ddverify/models/con2/include/ddverify/ioctl.h | 15 + .../models/con2/include/ddverify/ioport.h | 27 + .../models/con2/include/ddverify/miscdevice.h | 7 + ddverify/models/con2/include/ddverify/pci.h | 22 + .../models/con2/include/ddverify/pthread.h | 253 + .../models/con2/include/ddverify/satabs.h | 69 + .../models/con2/include/ddverify/tasklet.h | 20 + ddverify/models/con2/include/ddverify/timer.h | 17 + ddverify/models/con2/include/ddverify/tty.h | 16 + .../models/con2/include/ddverify/workqueue.h | 12 + .../models/con2/include/linux/backing-dev.h | 37 + ddverify/models/con2/include/linux/bcd.h | 20 + ddverify/models/con2/include/linux/bio.h | 110 + ddverify/models/con2/include/linux/bitops.h | 6 + ddverify/models/con2/include/linux/blkdev.h | 239 + ddverify/models/con2/include/linux/blkpg.h | 0 .../models/con2/include/linux/blktrace_api.h | 141 + .../models/con2/include/linux/buffer_head.h | 0 .../con2/include/linux/byteorder/generic.h | 46 + .../include/linux/byteorder/little_endian.h | 30 + ddverify/models/con2/include/linux/cache.h | 0 .../models/con2/include/linux/capability.h | 244 + ddverify/models/con2/include/linux/cdev.h | 23 + ddverify/models/con2/include/linux/cdrom.h | 1192 +++++ ddverify/models/con2/include/linux/compat.h | 0 ddverify/models/con2/include/linux/compiler.h | 20 + .../models/con2/include/linux/completion.h | 18 + ddverify/models/con2/include/linux/config.h | 0 ddverify/models/con2/include/linux/console.h | 0 ddverify/models/con2/include/linux/cpumask.h | 0 ddverify/models/con2/include/linux/ctype.h | 0 ddverify/models/con2/include/linux/dcache.h | 9 + ddverify/models/con2/include/linux/delay.h | 22 + .../con2/include/linux/devfs_fs_kernel.h | 0 ddverify/models/con2/include/linux/device.h | 112 + .../models/con2/include/linux/dma-mapping.h | 19 + ddverify/models/con2/include/linux/elevator.h | 6 + ddverify/models/con2/include/linux/err.h | 27 + ddverify/models/con2/include/linux/errno.h | 25 + ddverify/models/con2/include/linux/fcntl.h | 6 + ddverify/models/con2/include/linux/fd.h | 373 ++ ddverify/models/con2/include/linux/fdreg.h | 137 + ddverify/models/con2/include/linux/file.h | 14 + ddverify/models/con2/include/linux/firmware.h | 22 + ddverify/models/con2/include/linux/fs.h | 238 + ddverify/models/con2/include/linux/genhd.h | 48 + ddverify/models/con2/include/linux/gfp.h | 74 + ddverify/models/con2/include/linux/hdreg.h | 13 + ddverify/models/con2/include/linux/highmem.h | 9 + ddverify/models/con2/include/linux/if.h | 8 + ddverify/models/con2/include/linux/in.h | 0 ddverify/models/con2/include/linux/init.h | 23 + .../models/con2/include/linux/interrupt.h | 96 + ddverify/models/con2/include/linux/ioctl.h | 6 + ddverify/models/con2/include/linux/ioport.h | 102 + ddverify/models/con2/include/linux/jiffies.h | 84 + ddverify/models/con2/include/linux/kdb_kern.h | 0 ddverify/models/con2/include/linux/kdev_t.h | 11 + ddverify/models/con2/include/linux/kernel.h | 115 + ddverify/models/con2/include/linux/kobject.h | 34 + ddverify/models/con2/include/linux/kthread.h | 0 ddverify/models/con2/include/linux/list.h | 108 + ddverify/models/con2/include/linux/major.h | 169 + .../models/con2/include/linux/mc146818rtc.h | 87 + ddverify/models/con2/include/linux/mempool.h | 11 + .../models/con2/include/linux/miscdevice.h | 43 + ddverify/models/con2/include/linux/mm.h | 17 + ddverify/models/con2/include/linux/mm_types.h | 14 + ddverify/models/con2/include/linux/mman.h | 0 ddverify/models/con2/include/linux/mmzone.h | 16 + .../con2/include/linux/mod_devicetable.h | 18 + ddverify/models/con2/include/linux/module.h | 32 + .../models/con2/include/linux/moduleparam.h | 12 + ddverify/models/con2/include/linux/mutex.h | 38 + ddverify/models/con2/include/linux/net.h | 19 + .../models/con2/include/linux/netdevice.h | 6 + ddverify/models/con2/include/linux/notifier.h | 61 + ddverify/models/con2/include/linux/pagemap.h | 15 + ddverify/models/con2/include/linux/parport.h | 559 ++ .../models/con2/include/linux/parport_pc.h | 42 + ddverify/models/con2/include/linux/pci.h | 176 + ddverify/models/con2/include/linux/pci_ids.h | 2260 ++++++++ ddverify/models/con2/include/linux/pci_regs.h | 449 ++ ddverify/models/con2/include/linux/percpu.h | 10 + .../con2/include/linux/platform_device.h | 25 + ddverify/models/con2/include/linux/pm.h | 12 + ddverify/models/con2/include/linux/pnp.h | 0 ddverify/models/con2/include/linux/poll.h | 16 + .../models/con2/include/linux/posix_types.h | 9 + ddverify/models/con2/include/linux/proc_fs.h | 29 + ddverify/models/con2/include/linux/ptrace.h | 80 + ddverify/models/con2/include/linux/reboot.h | 75 + ddverify/models/con2/include/linux/rtc.h | 219 + .../models/con2/include/linux/scatterlist.h | 24 + ddverify/models/con2/include/linux/sched.h | 62 + ddverify/models/con2/include/linux/seq_file.h | 35 + ddverify/models/con2/include/linux/serial.h | 131 + ddverify/models/con2/include/linux/signal.h | 54 + ddverify/models/con2/include/linux/skbuff.h | 6 + ddverify/models/con2/include/linux/slab.h | 16 + ddverify/models/con2/include/linux/smp_lock.h | 12 + ddverify/models/con2/include/linux/socket.h | 109 + ddverify/models/con2/include/linux/spinlock.h | 20 + .../con2/include/linux/spinlock_types.h | 21 + ddverify/models/con2/include/linux/stat.h | 66 + ddverify/models/con2/include/linux/stddef.h | 20 + ddverify/models/con2/include/linux/string.h | 35 + .../models/con2/include/linux/stringify.h | 12 + ddverify/models/con2/include/linux/suspend.h | 0 ddverify/models/con2/include/linux/swap.h | 0 ddverify/models/con2/include/linux/sysfs.h | 43 + ddverify/models/con2/include/linux/sysrq.h | 0 ddverify/models/con2/include/linux/termios.h | 7 + ddverify/models/con2/include/linux/time.h | 30 + ddverify/models/con2/include/linux/timer.h | 34 + ddverify/models/con2/include/linux/tty.h | 180 + .../models/con2/include/linux/tty_driver.h | 166 + .../models/con2/include/linux/tty_driver.h,v | 187 + ddverify/models/con2/include/linux/tty_flip.h | 13 + .../models/con2/include/linux/tty_ldisc.h | 51 + ddverify/models/con2/include/linux/types.h | 105 + ddverify/models/con2/include/linux/uio.h | 12 + ddverify/models/con2/include/linux/videodev.h | 346 ++ .../models/con2/include/linux/videodev2.h | 1351 +++++ ddverify/models/con2/include/linux/vmalloc.h | 9 + ddverify/models/con2/include/linux/wait.h | 91 + ddverify/models/con2/include/linux/watchdog.h | 52 + .../models/con2/include/linux/workqueue.h | 50 + .../models/con2/include/linux/writeback.h | 0 .../models/con2/include/media/v4l2-common.h | 6 + ddverify/models/con2/include/media/v4l2-dev.h | 255 + ddverify/models/con2/include/net/sock.h | 29 + ddverify/models/con2/src/ddverify/cdev.c | 156 + ddverify/models/con2/src/ddverify/ddverify.c | 116 + ddverify/models/con2/src/ddverify/genhd.c | 120 + ddverify/models/con2/src/ddverify/interrupt.c | 22 + ddverify/models/con2/src/ddverify/ioctl.c | 19 + ddverify/models/con2/src/ddverify/pci.c | 56 + ddverify/models/con2/src/ddverify/tasklet.c | 15 + ddverify/models/con2/src/ddverify/timer.c | 13 + .../con2/src/linux/arch/i386/lib/usercopy.c | 51 + .../models/con2/src/linux/block/elevator.c | 13 + ddverify/models/con2/src/linux/block/genhd.c | 58 + .../models/con2/src/linux/block/ll_rw_blk.c | 72 + .../models/con2/src/linux/drivers/char/misc.c | 36 + .../con2/src/linux/drivers/char/tty_io.c | 40 + ddverify/models/con2/src/linux/fs/char_dev.c | 110 + .../models/con2/src/linux/fs/proc/generic.c | 7 + .../models/con2/src/linux/kernel/irq/manage.c | 21 + ddverify/models/con2/src/linux/kernel/mutex.c | 52 + .../models/con2/src/linux/kernel/resource.c | 115 + ddverify/models/con2/src/linux/kernel/sched.c | 18 + .../models/con2/src/linux/kernel/semaphore.c | 116 + .../models/con2/src/linux/kernel/softirq.c | 39 + .../models/con2/src/linux/kernel/spinlock.c | 150 + ddverify/models/con2/src/linux/kernel/timer.c | 47 + ddverify/models/con2/src/linux/kernel/wait.c | 46 + .../models/con2/src/linux/kernel/workqueue.c | 39 + .../models/con2/src/linux/mm/page_alloc.c | 52 + ddverify/models/con2/src/linux/mm/slab.c | 22 + ddverify/models/con2/src/linux/mm/vmalloc.c | 9 + ddverify/models/con2/src/linux/pci.c | 111 + .../models/seq1/include/asm-generic/bug.h | 9 + .../seq1/include/asm-generic/errno-base.h | 39 + .../models/seq1/include/asm-generic/errno.h | 109 + .../models/seq1/include/asm-generic/fcntl.h | 110 + .../models/seq1/include/asm-generic/ioctl.h | 80 + .../seq1/include/asm-generic/pci-dma-compat.h | 20 + .../models/seq1/include/asm-generic/rtc.h | 18 + .../models/seq1/include/asm-generic/siginfo.h | 118 + ddverify/models/seq1/include/asm/atomic.h | 169 + ddverify/models/seq1/include/asm/bitops.h | 13 + ddverify/models/seq1/include/asm/bug.h | 7 + ddverify/models/seq1/include/asm/byteorder.h | 9 + ddverify/models/seq1/include/asm/current.h | 14 + ddverify/models/seq1/include/asm/delay.h | 6 + ddverify/models/seq1/include/asm/dma.h | 72 + ddverify/models/seq1/include/asm/errno.h | 6 + ddverify/models/seq1/include/asm/fcntl.h | 1 + ddverify/models/seq1/include/asm/floppy.h | 45 + ddverify/models/seq1/include/asm/highmem.h | 17 + ddverify/models/seq1/include/asm/io.h | 69 + ddverify/models/seq1/include/asm/ioctl.h | 1 + ddverify/models/seq1/include/asm/ioctls.h | 91 + ddverify/models/seq1/include/asm/irq.h | 0 ddverify/models/seq1/include/asm/kmap_types.h | 23 + ddverify/models/seq1/include/asm/leds.h | 0 ddverify/models/seq1/include/asm/mach-types.h | 0 .../models/seq1/include/asm/mc146818rtc.h | 34 + ddverify/models/seq1/include/asm/msr.h | 10 + ddverify/models/seq1/include/asm/page.h | 24 + ddverify/models/seq1/include/asm/param.h | 8 + ddverify/models/seq1/include/asm/pci.h | 17 + ddverify/models/seq1/include/asm/poll.h | 20 + .../models/seq1/include/asm/posix_types.h | 32 + ddverify/models/seq1/include/asm/processor.h | 6 + ddverify/models/seq1/include/asm/ptrace.h | 8 + ddverify/models/seq1/include/asm/rtc.h | 7 + .../models/seq1/include/asm/scatterlist.h | 21 + ddverify/models/seq1/include/asm/semaphore.h | 37 + ddverify/models/seq1/include/asm/siginfo.h | 6 + ddverify/models/seq1/include/asm/signal.h | 86 + ddverify/models/seq1/include/asm/stat.h | 0 ddverify/models/seq1/include/asm/string.h | 6 + ddverify/models/seq1/include/asm/system.h | 9 + ddverify/models/seq1/include/asm/termbits.h | 20 + ddverify/models/seq1/include/asm/termios.h | 54 + ddverify/models/seq1/include/asm/types.h | 35 + ddverify/models/seq1/include/asm/uaccess.h | 55 + .../models/seq1/include/ddverify/blkdev.h | 10 + ddverify/models/seq1/include/ddverify/cdev.h | 26 + .../models/seq1/include/ddverify/ddverify.h | 47 + .../models/seq1/include/ddverify/fixed_cdev.h | 15 + ddverify/models/seq1/include/ddverify/genhd.h | 29 + .../models/seq1/include/ddverify/interrupt.h | 19 + ddverify/models/seq1/include/ddverify/ioctl.h | 15 + .../models/seq1/include/ddverify/ioport.h | 24 + .../models/seq1/include/ddverify/miscdevice.h | 7 + ddverify/models/seq1/include/ddverify/pci.h | 22 + .../models/seq1/include/ddverify/pthread.h | 253 + .../models/seq1/include/ddverify/satabs.h | 71 + .../models/seq1/include/ddverify/tasklet.h | 20 + ddverify/models/seq1/include/ddverify/timer.h | 17 + ddverify/models/seq1/include/ddverify/tty.h | 16 + .../models/seq1/include/ddverify/workqueue.h | 12 + .../models/seq1/include/linux/backing-dev.h | 37 + ddverify/models/seq1/include/linux/bcd.h | 20 + ddverify/models/seq1/include/linux/bio.h | 110 + ddverify/models/seq1/include/linux/bitops.h | 6 + ddverify/models/seq1/include/linux/blkdev.h | 239 + ddverify/models/seq1/include/linux/blkpg.h | 0 .../models/seq1/include/linux/blktrace_api.h | 141 + .../models/seq1/include/linux/buffer_head.h | 0 .../seq1/include/linux/byteorder/generic.h | 46 + .../include/linux/byteorder/little_endian.h | 30 + ddverify/models/seq1/include/linux/cache.h | 0 .../models/seq1/include/linux/capability.h | 244 + ddverify/models/seq1/include/linux/cdev.h | 23 + ddverify/models/seq1/include/linux/cdrom.h | 1192 +++++ ddverify/models/seq1/include/linux/compat.h | 0 ddverify/models/seq1/include/linux/compiler.h | 20 + .../models/seq1/include/linux/completion.h | 18 + ddverify/models/seq1/include/linux/config.h | 0 ddverify/models/seq1/include/linux/console.h | 0 ddverify/models/seq1/include/linux/cpumask.h | 0 ddverify/models/seq1/include/linux/ctype.h | 0 ddverify/models/seq1/include/linux/dcache.h | 9 + ddverify/models/seq1/include/linux/delay.h | 22 + .../seq1/include/linux/devfs_fs_kernel.h | 0 ddverify/models/seq1/include/linux/device.h | 112 + .../models/seq1/include/linux/dma-mapping.h | 19 + ddverify/models/seq1/include/linux/elevator.h | 6 + ddverify/models/seq1/include/linux/err.h | 27 + ddverify/models/seq1/include/linux/errno.h | 25 + ddverify/models/seq1/include/linux/fcntl.h | 6 + ddverify/models/seq1/include/linux/fd.h | 373 ++ ddverify/models/seq1/include/linux/fdreg.h | 137 + ddverify/models/seq1/include/linux/file.h | 14 + ddverify/models/seq1/include/linux/firmware.h | 22 + ddverify/models/seq1/include/linux/fs.h | 238 + ddverify/models/seq1/include/linux/genhd.h | 48 + ddverify/models/seq1/include/linux/gfp.h | 74 + ddverify/models/seq1/include/linux/hdreg.h | 13 + ddverify/models/seq1/include/linux/highmem.h | 9 + ddverify/models/seq1/include/linux/if.h | 8 + ddverify/models/seq1/include/linux/in.h | 0 ddverify/models/seq1/include/linux/init.h | 23 + .../models/seq1/include/linux/interrupt.h | 96 + ddverify/models/seq1/include/linux/ioctl.h | 6 + ddverify/models/seq1/include/linux/ioport.h | 102 + ddverify/models/seq1/include/linux/jiffies.h | 84 + ddverify/models/seq1/include/linux/kdb_kern.h | 0 ddverify/models/seq1/include/linux/kdev_t.h | 11 + ddverify/models/seq1/include/linux/kernel.h | 115 + ddverify/models/seq1/include/linux/kobject.h | 34 + ddverify/models/seq1/include/linux/kthread.h | 0 ddverify/models/seq1/include/linux/list.h | 108 + ddverify/models/seq1/include/linux/major.h | 169 + .../models/seq1/include/linux/mc146818rtc.h | 87 + ddverify/models/seq1/include/linux/mempool.h | 11 + .../models/seq1/include/linux/miscdevice.h | 43 + ddverify/models/seq1/include/linux/mm.h | 17 + ddverify/models/seq1/include/linux/mm_types.h | 14 + ddverify/models/seq1/include/linux/mman.h | 0 ddverify/models/seq1/include/linux/mmzone.h | 16 + .../seq1/include/linux/mod_devicetable.h | 18 + ddverify/models/seq1/include/linux/module.h | 32 + .../models/seq1/include/linux/moduleparam.h | 12 + ddverify/models/seq1/include/linux/mutex.h | 38 + ddverify/models/seq1/include/linux/net.h | 19 + .../models/seq1/include/linux/netdevice.h | 6 + ddverify/models/seq1/include/linux/notifier.h | 61 + ddverify/models/seq1/include/linux/pagemap.h | 15 + ddverify/models/seq1/include/linux/parport.h | 559 ++ .../models/seq1/include/linux/parport_pc.h | 42 + ddverify/models/seq1/include/linux/pci.h | 176 + ddverify/models/seq1/include/linux/pci_ids.h | 2260 ++++++++ ddverify/models/seq1/include/linux/pci_regs.h | 449 ++ ddverify/models/seq1/include/linux/percpu.h | 10 + .../seq1/include/linux/platform_device.h | 25 + ddverify/models/seq1/include/linux/pm.h | 12 + ddverify/models/seq1/include/linux/pnp.h | 0 ddverify/models/seq1/include/linux/poll.h | 16 + .../models/seq1/include/linux/posix_types.h | 9 + ddverify/models/seq1/include/linux/proc_fs.h | 29 + ddverify/models/seq1/include/linux/ptrace.h | 80 + ddverify/models/seq1/include/linux/reboot.h | 75 + ddverify/models/seq1/include/linux/rtc.h | 219 + .../models/seq1/include/linux/scatterlist.h | 24 + ddverify/models/seq1/include/linux/sched.h | 62 + ddverify/models/seq1/include/linux/seq_file.h | 35 + ddverify/models/seq1/include/linux/serial.h | 131 + ddverify/models/seq1/include/linux/signal.h | 54 + ddverify/models/seq1/include/linux/skbuff.h | 6 + ddverify/models/seq1/include/linux/slab.h | 16 + ddverify/models/seq1/include/linux/smp_lock.h | 12 + ddverify/models/seq1/include/linux/socket.h | 109 + ddverify/models/seq1/include/linux/spinlock.h | 20 + .../seq1/include/linux/spinlock_types.h | 21 + ddverify/models/seq1/include/linux/stat.h | 66 + ddverify/models/seq1/include/linux/stddef.h | 20 + ddverify/models/seq1/include/linux/string.h | 35 + .../models/seq1/include/linux/stringify.h | 12 + ddverify/models/seq1/include/linux/suspend.h | 0 ddverify/models/seq1/include/linux/swap.h | 0 ddverify/models/seq1/include/linux/sysfs.h | 43 + ddverify/models/seq1/include/linux/sysrq.h | 0 ddverify/models/seq1/include/linux/termios.h | 7 + ddverify/models/seq1/include/linux/threads.h | 4 + ddverify/models/seq1/include/linux/time.h | 30 + ddverify/models/seq1/include/linux/timer.h | 34 + ddverify/models/seq1/include/linux/tty.h | 180 + .../models/seq1/include/linux/tty_driver.h | 166 + .../models/seq1/include/linux/tty_driver.h,v | 187 + ddverify/models/seq1/include/linux/tty_flip.h | 13 + .../models/seq1/include/linux/tty_ldisc.h | 51 + ddverify/models/seq1/include/linux/types.h | 105 + ddverify/models/seq1/include/linux/uio.h | 12 + ddverify/models/seq1/include/linux/videodev.h | 346 ++ .../models/seq1/include/linux/videodev2.h | 1351 +++++ ddverify/models/seq1/include/linux/vmalloc.h | 9 + ddverify/models/seq1/include/linux/wait.h | 89 + ddverify/models/seq1/include/linux/watchdog.h | 52 + .../models/seq1/include/linux/workqueue.h | 50 + .../models/seq1/include/linux/writeback.h | 0 .../models/seq1/include/media/v4l2-common.h | 6 + ddverify/models/seq1/include/media/v4l2-dev.h | 255 + ddverify/models/seq1/include/net/sock.h | 29 + ddverify/models/seq1/src/ddverify/cdev.c | 156 + ddverify/models/seq1/src/ddverify/ddverify.c | 103 + ddverify/models/seq1/src/ddverify/genhd.c | 120 + ddverify/models/seq1/src/ddverify/interrupt.c | 22 + ddverify/models/seq1/src/ddverify/ioctl.c | 19 + ddverify/models/seq1/src/ddverify/pci.c | 56 + ddverify/models/seq1/src/ddverify/tasklet.c | 15 + ddverify/models/seq1/src/ddverify/timer.c | 13 + .../seq1/src/linux/arch/i386/lib/usercopy.c | 51 + .../models/seq1/src/linux/block/elevator.c | 13 + ddverify/models/seq1/src/linux/block/genhd.c | 58 + .../models/seq1/src/linux/block/ll_rw_blk.c | 72 + .../models/seq1/src/linux/drivers/char/misc.c | 36 + .../seq1/src/linux/drivers/char/tty_io.c | 40 + ddverify/models/seq1/src/linux/fs/char_dev.c | 110 + .../models/seq1/src/linux/fs/proc/generic.c | 7 + .../models/seq1/src/linux/fs/read_write.c | 9 + .../models/seq1/src/linux/kernel/irq/manage.c | 21 + ddverify/models/seq1/src/linux/kernel/mutex.c | 35 + .../models/seq1/src/linux/kernel/resource.c | 118 + ddverify/models/seq1/src/linux/kernel/sched.c | 18 + .../models/seq1/src/linux/kernel/semaphore.c | 86 + .../models/seq1/src/linux/kernel/softirq.c | 38 + .../models/seq1/src/linux/kernel/spinlock.c | 93 + ddverify/models/seq1/src/linux/kernel/timer.c | 47 + ddverify/models/seq1/src/linux/kernel/wait.c | 46 + .../models/seq1/src/linux/kernel/workqueue.c | 39 + .../models/seq1/src/linux/mm/page_alloc.c | 52 + ddverify/models/seq1/src/linux/mm/slab.c | 22 + ddverify/models/seq1/src/linux/mm/vmalloc.c | 9 + ddverify/models/seq1/src/linux/pci.c | 111 + ddverify/readme.txt | 35 + 712 files changed, 86645 insertions(+) create mode 100644 ddverify/awk/convert_satabs_output create mode 100644 ddverify/awk/get_number_of_iteration create mode 100644 ddverify/awk/get_time_result create mode 100644 ddverify/awk/get_too_many_iterations_result create mode 100644 ddverify/awk/get_verification_result create mode 100644 ddverify/awk/parse_dd_file create mode 100644 ddverify/bin/LICENSE create mode 100644 ddverify/bin/ddverify.c create mode 100644 ddverify/bin/ddverify.h create mode 100644 ddverify/case_studies/block/cciss/cciss.c create mode 100644 ddverify/case_studies/block/cciss/cciss.h create mode 100644 ddverify/case_studies/block/cciss/cciss_cmd.h create mode 100644 ddverify/case_studies/block/cciss/cciss_scsi.c create mode 100644 ddverify/case_studies/block/cciss/cciss_scsi.h create mode 100644 ddverify/case_studies/block/cpqarray/cpqarray.c create mode 100644 ddverify/case_studies/block/cpqarray/cpqarray.h create mode 100644 ddverify/case_studies/block/cpqarray/ida_cmd.h create mode 100644 ddverify/case_studies/block/cpqarray/ida_ioctl.h create mode 100644 ddverify/case_studies/block/cpqarray/smart1,2.h create mode 100644 ddverify/case_studies/block/floppy/floppy.c create mode 100644 ddverify/case_studies/block/nbd/nbd.c create mode 100644 ddverify/case_studies/block/nbd/nbd.h create mode 100644 ddverify/case_studies/block/umem/umem.c create mode 100644 ddverify/case_studies/block/umem/umem.h create mode 100644 ddverify/case_studies/cdrom/aztcd/aztcd.c create mode 100644 ddverify/case_studies/cdrom/aztcd/aztcd.h create mode 100644 ddverify/case_studies/cdrom/aztcd/cdrom.h create mode 100644 ddverify/case_studies/cdrom/cdu31a/cdu31a.c create mode 100644 ddverify/case_studies/cdrom/cdu31a/cdu31a.h create mode 100644 ddverify/case_studies/cdrom/cm206/cm206.c create mode 100644 ddverify/case_studies/cdrom/cm206/cm206.h create mode 100644 ddverify/case_studies/char/applicom/applicom.c create mode 100644 ddverify/case_studies/char/applicom/applicom.h create mode 100644 ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.c create mode 100644 ddverify/case_studies/char/ds1286/ds1286.c create mode 100644 ddverify/case_studies/char/ds1286/ds1286.h create mode 100644 ddverify/case_studies/char/dtlk/dtlk.c create mode 100644 ddverify/case_studies/char/dtlk/dtlk.h create mode 100644 ddverify/case_studies/char/efirtc/efi.h create mode 100644 ddverify/case_studies/char/efirtc/efirtc.c create mode 100644 ddverify/case_studies/char/generic_nvram/generic_nvram.c create mode 100644 ddverify/case_studies/char/genrtc/genrtc.c create mode 100644 ddverify/case_studies/char/nwbutton/nwbutton.c create mode 100644 ddverify/case_studies/char/nwbutton/nwbutton.h create mode 100644 ddverify/case_studies/char/toshiba/toshiba.c create mode 100644 ddverify/case_studies/char/toshiba/toshiba.h create mode 100644 ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.c create mode 100644 ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.h create mode 100644 ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.c create mode 100644 ddverify/case_studies/char/watchdog/machzwd/machzwd.c create mode 100644 ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.c create mode 100644 ddverify/case_studies/char/watchdog/pcwd/pcwd.c create mode 100644 ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.c create mode 100644 ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c create mode 100644 ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.c create mode 100644 ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.c create mode 100644 ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c create mode 100644 ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c create mode 100644 ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c create mode 100644 ddverify/case_studies/char/watchdog/wdt/wd501p.h create mode 100644 ddverify/case_studies/char/watchdog/wdt/wdt.c create mode 100644 ddverify/case_studies/char/watchdog/wdt977/wdt977.c create mode 100644 ddverify/case_studies/char/watchdog/wdt_pci/wd501p.h create mode 100644 ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.c create mode 100644 ddverify/models/con1/include/asm-generic/bug.h create mode 100644 ddverify/models/con1/include/asm-generic/errno-base.h create mode 100644 ddverify/models/con1/include/asm-generic/errno.h create mode 100644 ddverify/models/con1/include/asm-generic/fcntl.h create mode 100644 ddverify/models/con1/include/asm-generic/ioctl.h create mode 100644 ddverify/models/con1/include/asm-generic/pci-dma-compat.h create mode 100644 ddverify/models/con1/include/asm-generic/rtc.h create mode 100644 ddverify/models/con1/include/asm-generic/siginfo.h create mode 100644 ddverify/models/con1/include/asm/atomic.h create mode 100644 ddverify/models/con1/include/asm/bitops.h create mode 100644 ddverify/models/con1/include/asm/bug.h create mode 100644 ddverify/models/con1/include/asm/byteorder.h create mode 100644 ddverify/models/con1/include/asm/current.h create mode 100644 ddverify/models/con1/include/asm/delay.h create mode 100644 ddverify/models/con1/include/asm/dma.h create mode 100644 ddverify/models/con1/include/asm/errno.h create mode 100644 ddverify/models/con1/include/asm/fcntl.h create mode 100644 ddverify/models/con1/include/asm/floppy.h create mode 100644 ddverify/models/con1/include/asm/highmem.h create mode 100644 ddverify/models/con1/include/asm/io.h create mode 100644 ddverify/models/con1/include/asm/ioctl.h create mode 100644 ddverify/models/con1/include/asm/ioctls.h create mode 100644 ddverify/models/con1/include/asm/irq.h create mode 100644 ddverify/models/con1/include/asm/kmap_types.h create mode 100644 ddverify/models/con1/include/asm/leds.h create mode 100644 ddverify/models/con1/include/asm/mach-types.h create mode 100644 ddverify/models/con1/include/asm/mc146818rtc.h create mode 100644 ddverify/models/con1/include/asm/msr.h create mode 100644 ddverify/models/con1/include/asm/page.h create mode 100644 ddverify/models/con1/include/asm/param.h create mode 100644 ddverify/models/con1/include/asm/pci.h create mode 100644 ddverify/models/con1/include/asm/poll.h create mode 100644 ddverify/models/con1/include/asm/posix_types.h create mode 100644 ddverify/models/con1/include/asm/processor.h create mode 100644 ddverify/models/con1/include/asm/ptrace.h create mode 100644 ddverify/models/con1/include/asm/rtc.h create mode 100644 ddverify/models/con1/include/asm/scatterlist.h create mode 100644 ddverify/models/con1/include/asm/semaphore.h create mode 100644 ddverify/models/con1/include/asm/siginfo.h create mode 100644 ddverify/models/con1/include/asm/signal.h create mode 100644 ddverify/models/con1/include/asm/stat.h create mode 100644 ddverify/models/con1/include/asm/string.h create mode 100644 ddverify/models/con1/include/asm/system.h create mode 100644 ddverify/models/con1/include/asm/termbits.h create mode 100644 ddverify/models/con1/include/asm/termios.h create mode 100644 ddverify/models/con1/include/asm/types.h create mode 100644 ddverify/models/con1/include/asm/uaccess.h create mode 100644 ddverify/models/con1/include/ddverify/blkdev.h create mode 100644 ddverify/models/con1/include/ddverify/cdev.h create mode 100644 ddverify/models/con1/include/ddverify/ddverify.h create mode 100644 ddverify/models/con1/include/ddverify/fixed_cdev.h create mode 100644 ddverify/models/con1/include/ddverify/genhd.h create mode 100644 ddverify/models/con1/include/ddverify/interrupt.h create mode 100644 ddverify/models/con1/include/ddverify/ioctl.h create mode 100644 ddverify/models/con1/include/ddverify/ioport.h create mode 100644 ddverify/models/con1/include/ddverify/miscdevice.h create mode 100644 ddverify/models/con1/include/ddverify/pci.h create mode 100644 ddverify/models/con1/include/ddverify/pthread.h create mode 100644 ddverify/models/con1/include/ddverify/satabs.h create mode 100644 ddverify/models/con1/include/ddverify/tasklet.h create mode 100644 ddverify/models/con1/include/ddverify/timer.h create mode 100644 ddverify/models/con1/include/ddverify/tty.h create mode 100644 ddverify/models/con1/include/ddverify/workqueue.h create mode 100644 ddverify/models/con1/include/linux/backing-dev.h create mode 100644 ddverify/models/con1/include/linux/bcd.h create mode 100644 ddverify/models/con1/include/linux/bio.h create mode 100644 ddverify/models/con1/include/linux/bitops.h create mode 100644 ddverify/models/con1/include/linux/blkdev.h create mode 100644 ddverify/models/con1/include/linux/blkpg.h create mode 100644 ddverify/models/con1/include/linux/blktrace_api.h create mode 100644 ddverify/models/con1/include/linux/buffer_head.h create mode 100644 ddverify/models/con1/include/linux/byteorder/generic.h create mode 100644 ddverify/models/con1/include/linux/byteorder/little_endian.h create mode 100644 ddverify/models/con1/include/linux/cache.h create mode 100644 ddverify/models/con1/include/linux/capability.h create mode 100644 ddverify/models/con1/include/linux/cdev.h create mode 100644 ddverify/models/con1/include/linux/cdrom.h create mode 100644 ddverify/models/con1/include/linux/compat.h create mode 100644 ddverify/models/con1/include/linux/compiler.h create mode 100644 ddverify/models/con1/include/linux/completion.h create mode 100644 ddverify/models/con1/include/linux/config.h create mode 100644 ddverify/models/con1/include/linux/console.h create mode 100644 ddverify/models/con1/include/linux/cpumask.h create mode 100644 ddverify/models/con1/include/linux/ctype.h create mode 100644 ddverify/models/con1/include/linux/dcache.h create mode 100644 ddverify/models/con1/include/linux/delay.h create mode 100644 ddverify/models/con1/include/linux/devfs_fs_kernel.h create mode 100644 ddverify/models/con1/include/linux/device.h create mode 100644 ddverify/models/con1/include/linux/dma-mapping.h create mode 100644 ddverify/models/con1/include/linux/elevator.h create mode 100644 ddverify/models/con1/include/linux/err.h create mode 100644 ddverify/models/con1/include/linux/errno.h create mode 100644 ddverify/models/con1/include/linux/fcntl.h create mode 100644 ddverify/models/con1/include/linux/fd.h create mode 100644 ddverify/models/con1/include/linux/fdreg.h create mode 100644 ddverify/models/con1/include/linux/file.h create mode 100644 ddverify/models/con1/include/linux/firmware.h create mode 100644 ddverify/models/con1/include/linux/fs.h create mode 100644 ddverify/models/con1/include/linux/genhd.h create mode 100644 ddverify/models/con1/include/linux/gfp.h create mode 100644 ddverify/models/con1/include/linux/hdreg.h create mode 100644 ddverify/models/con1/include/linux/highmem.h create mode 100644 ddverify/models/con1/include/linux/if.h create mode 100644 ddverify/models/con1/include/linux/in.h create mode 100644 ddverify/models/con1/include/linux/init.h create mode 100644 ddverify/models/con1/include/linux/interrupt.h create mode 100644 ddverify/models/con1/include/linux/ioctl.h create mode 100644 ddverify/models/con1/include/linux/ioport.h create mode 100644 ddverify/models/con1/include/linux/jiffies.h create mode 100644 ddverify/models/con1/include/linux/kdb_kern.h create mode 100644 ddverify/models/con1/include/linux/kdev_t.h create mode 100644 ddverify/models/con1/include/linux/kernel.h create mode 100644 ddverify/models/con1/include/linux/kobject.h create mode 100644 ddverify/models/con1/include/linux/kthread.h create mode 100644 ddverify/models/con1/include/linux/list.h create mode 100644 ddverify/models/con1/include/linux/major.h create mode 100644 ddverify/models/con1/include/linux/mc146818rtc.h create mode 100644 ddverify/models/con1/include/linux/mempool.h create mode 100644 ddverify/models/con1/include/linux/miscdevice.h create mode 100644 ddverify/models/con1/include/linux/mm.h create mode 100644 ddverify/models/con1/include/linux/mm_types.h create mode 100644 ddverify/models/con1/include/linux/mman.h create mode 100644 ddverify/models/con1/include/linux/mmzone.h create mode 100644 ddverify/models/con1/include/linux/mod_devicetable.h create mode 100644 ddverify/models/con1/include/linux/module.h create mode 100644 ddverify/models/con1/include/linux/moduleparam.h create mode 100644 ddverify/models/con1/include/linux/mutex.h create mode 100644 ddverify/models/con1/include/linux/net.h create mode 100644 ddverify/models/con1/include/linux/netdevice.h create mode 100644 ddverify/models/con1/include/linux/notifier.h create mode 100644 ddverify/models/con1/include/linux/pagemap.h create mode 100644 ddverify/models/con1/include/linux/parport.h create mode 100644 ddverify/models/con1/include/linux/parport_pc.h create mode 100644 ddverify/models/con1/include/linux/pci.h create mode 100644 ddverify/models/con1/include/linux/pci_ids.h create mode 100644 ddverify/models/con1/include/linux/pci_regs.h create mode 100644 ddverify/models/con1/include/linux/percpu.h create mode 100644 ddverify/models/con1/include/linux/platform_device.h create mode 100644 ddverify/models/con1/include/linux/pm.h create mode 100644 ddverify/models/con1/include/linux/pnp.h create mode 100644 ddverify/models/con1/include/linux/poll.h create mode 100644 ddverify/models/con1/include/linux/posix_types.h create mode 100644 ddverify/models/con1/include/linux/proc_fs.h create mode 100644 ddverify/models/con1/include/linux/ptrace.h create mode 100644 ddverify/models/con1/include/linux/reboot.h create mode 100644 ddverify/models/con1/include/linux/rtc.h create mode 100644 ddverify/models/con1/include/linux/scatterlist.h create mode 100644 ddverify/models/con1/include/linux/sched.h create mode 100644 ddverify/models/con1/include/linux/seq_file.h create mode 100644 ddverify/models/con1/include/linux/serial.h create mode 100644 ddverify/models/con1/include/linux/signal.h create mode 100644 ddverify/models/con1/include/linux/skbuff.h create mode 100644 ddverify/models/con1/include/linux/slab.h create mode 100644 ddverify/models/con1/include/linux/smp_lock.h create mode 100644 ddverify/models/con1/include/linux/socket.h create mode 100644 ddverify/models/con1/include/linux/spinlock.h create mode 100644 ddverify/models/con1/include/linux/spinlock_types.h create mode 100644 ddverify/models/con1/include/linux/stat.h create mode 100644 ddverify/models/con1/include/linux/stddef.h create mode 100644 ddverify/models/con1/include/linux/string.h create mode 100644 ddverify/models/con1/include/linux/stringify.h create mode 100644 ddverify/models/con1/include/linux/suspend.h create mode 100644 ddverify/models/con1/include/linux/swap.h create mode 100644 ddverify/models/con1/include/linux/sysfs.h create mode 100644 ddverify/models/con1/include/linux/sysrq.h create mode 100644 ddverify/models/con1/include/linux/termios.h create mode 100644 ddverify/models/con1/include/linux/time.h create mode 100644 ddverify/models/con1/include/linux/timer.h create mode 100644 ddverify/models/con1/include/linux/tty.h create mode 100644 ddverify/models/con1/include/linux/tty_driver.h create mode 100644 ddverify/models/con1/include/linux/tty_driver.h,v create mode 100644 ddverify/models/con1/include/linux/tty_flip.h create mode 100644 ddverify/models/con1/include/linux/tty_ldisc.h create mode 100644 ddverify/models/con1/include/linux/types.h create mode 100644 ddverify/models/con1/include/linux/uio.h create mode 100644 ddverify/models/con1/include/linux/videodev.h create mode 100644 ddverify/models/con1/include/linux/videodev2.h create mode 100644 ddverify/models/con1/include/linux/vmalloc.h create mode 100644 ddverify/models/con1/include/linux/wait.h create mode 100644 ddverify/models/con1/include/linux/watchdog.h create mode 100644 ddverify/models/con1/include/linux/workqueue.h create mode 100644 ddverify/models/con1/include/linux/writeback.h create mode 100644 ddverify/models/con1/include/media/v4l2-common.h create mode 100644 ddverify/models/con1/include/media/v4l2-dev.h create mode 100644 ddverify/models/con1/include/net/sock.h create mode 100644 ddverify/models/con1/src/ddverify/cdev.c create mode 100644 ddverify/models/con1/src/ddverify/ddverify.c create mode 100644 ddverify/models/con1/src/ddverify/genhd.c create mode 100644 ddverify/models/con1/src/ddverify/interrupt.c create mode 100644 ddverify/models/con1/src/ddverify/ioctl.c create mode 100644 ddverify/models/con1/src/ddverify/pci.c create mode 100644 ddverify/models/con1/src/ddverify/tasklet.c create mode 100644 ddverify/models/con1/src/ddverify/timer.c create mode 100644 ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c create mode 100644 ddverify/models/con1/src/linux/block/elevator.c create mode 100644 ddverify/models/con1/src/linux/block/genhd.c create mode 100644 ddverify/models/con1/src/linux/block/ll_rw_blk.c create mode 100644 ddverify/models/con1/src/linux/drivers/char/misc.c create mode 100644 ddverify/models/con1/src/linux/drivers/char/tty_io.c create mode 100644 ddverify/models/con1/src/linux/fs/char_dev.c create mode 100644 ddverify/models/con1/src/linux/fs/proc/generic.c create mode 100644 ddverify/models/con1/src/linux/kernel/irq/manage.c create mode 100644 ddverify/models/con1/src/linux/kernel/mutex.c create mode 100644 ddverify/models/con1/src/linux/kernel/resource.c create mode 100644 ddverify/models/con1/src/linux/kernel/sched.c create mode 100644 ddverify/models/con1/src/linux/kernel/semaphore.c create mode 100644 ddverify/models/con1/src/linux/kernel/softirq.c create mode 100644 ddverify/models/con1/src/linux/kernel/spinlock.c create mode 100644 ddverify/models/con1/src/linux/kernel/timer.c create mode 100644 ddverify/models/con1/src/linux/kernel/wait.c create mode 100644 ddverify/models/con1/src/linux/kernel/workqueue.c create mode 100644 ddverify/models/con1/src/linux/mm/page_alloc.c create mode 100644 ddverify/models/con1/src/linux/mm/slab.c create mode 100644 ddverify/models/con1/src/linux/mm/vmalloc.c create mode 100644 ddverify/models/con1/src/linux/pci.c create mode 100644 ddverify/models/con2/include/asm-generic/bug.h create mode 100644 ddverify/models/con2/include/asm-generic/errno-base.h create mode 100644 ddverify/models/con2/include/asm-generic/errno.h create mode 100644 ddverify/models/con2/include/asm-generic/fcntl.h create mode 100644 ddverify/models/con2/include/asm-generic/ioctl.h create mode 100644 ddverify/models/con2/include/asm-generic/pci-dma-compat.h create mode 100644 ddverify/models/con2/include/asm-generic/rtc.h create mode 100644 ddverify/models/con2/include/asm-generic/siginfo.h create mode 100644 ddverify/models/con2/include/asm/atomic.h create mode 100644 ddverify/models/con2/include/asm/bitops.h create mode 100644 ddverify/models/con2/include/asm/bug.h create mode 100644 ddverify/models/con2/include/asm/byteorder.h create mode 100644 ddverify/models/con2/include/asm/current.h create mode 100644 ddverify/models/con2/include/asm/delay.h create mode 100644 ddverify/models/con2/include/asm/dma.h create mode 100644 ddverify/models/con2/include/asm/errno.h create mode 100644 ddverify/models/con2/include/asm/fcntl.h create mode 100644 ddverify/models/con2/include/asm/floppy.h create mode 100644 ddverify/models/con2/include/asm/highmem.h create mode 100644 ddverify/models/con2/include/asm/io.h create mode 100644 ddverify/models/con2/include/asm/ioctl.h create mode 100644 ddverify/models/con2/include/asm/ioctls.h create mode 100644 ddverify/models/con2/include/asm/irq.h create mode 100644 ddverify/models/con2/include/asm/kmap_types.h create mode 100644 ddverify/models/con2/include/asm/leds.h create mode 100644 ddverify/models/con2/include/asm/mach-types.h create mode 100644 ddverify/models/con2/include/asm/mc146818rtc.h create mode 100644 ddverify/models/con2/include/asm/msr.h create mode 100644 ddverify/models/con2/include/asm/page.h create mode 100644 ddverify/models/con2/include/asm/param.h create mode 100644 ddverify/models/con2/include/asm/pci.h create mode 100644 ddverify/models/con2/include/asm/poll.h create mode 100644 ddverify/models/con2/include/asm/posix_types.h create mode 100644 ddverify/models/con2/include/asm/processor.h create mode 100644 ddverify/models/con2/include/asm/ptrace.h create mode 100644 ddverify/models/con2/include/asm/rtc.h create mode 100644 ddverify/models/con2/include/asm/scatterlist.h create mode 100644 ddverify/models/con2/include/asm/semaphore.h create mode 100644 ddverify/models/con2/include/asm/siginfo.h create mode 100644 ddverify/models/con2/include/asm/signal.h create mode 100644 ddverify/models/con2/include/asm/stat.h create mode 100644 ddverify/models/con2/include/asm/string.h create mode 100644 ddverify/models/con2/include/asm/system.h create mode 100644 ddverify/models/con2/include/asm/termbits.h create mode 100644 ddverify/models/con2/include/asm/termios.h create mode 100644 ddverify/models/con2/include/asm/types.h create mode 100644 ddverify/models/con2/include/asm/uaccess.h create mode 100644 ddverify/models/con2/include/ddverify/blkdev.h create mode 100644 ddverify/models/con2/include/ddverify/cdev.h create mode 100644 ddverify/models/con2/include/ddverify/ddverify.h create mode 100644 ddverify/models/con2/include/ddverify/fixed_cdev.h create mode 100644 ddverify/models/con2/include/ddverify/genhd.h create mode 100644 ddverify/models/con2/include/ddverify/interrupt.h create mode 100644 ddverify/models/con2/include/ddverify/ioctl.h create mode 100644 ddverify/models/con2/include/ddverify/ioport.h create mode 100644 ddverify/models/con2/include/ddverify/miscdevice.h create mode 100644 ddverify/models/con2/include/ddverify/pci.h create mode 100644 ddverify/models/con2/include/ddverify/pthread.h create mode 100644 ddverify/models/con2/include/ddverify/satabs.h create mode 100644 ddverify/models/con2/include/ddverify/tasklet.h create mode 100644 ddverify/models/con2/include/ddverify/timer.h create mode 100644 ddverify/models/con2/include/ddverify/tty.h create mode 100644 ddverify/models/con2/include/ddverify/workqueue.h create mode 100644 ddverify/models/con2/include/linux/backing-dev.h create mode 100644 ddverify/models/con2/include/linux/bcd.h create mode 100644 ddverify/models/con2/include/linux/bio.h create mode 100644 ddverify/models/con2/include/linux/bitops.h create mode 100644 ddverify/models/con2/include/linux/blkdev.h create mode 100644 ddverify/models/con2/include/linux/blkpg.h create mode 100644 ddverify/models/con2/include/linux/blktrace_api.h create mode 100644 ddverify/models/con2/include/linux/buffer_head.h create mode 100644 ddverify/models/con2/include/linux/byteorder/generic.h create mode 100644 ddverify/models/con2/include/linux/byteorder/little_endian.h create mode 100644 ddverify/models/con2/include/linux/cache.h create mode 100644 ddverify/models/con2/include/linux/capability.h create mode 100644 ddverify/models/con2/include/linux/cdev.h create mode 100644 ddverify/models/con2/include/linux/cdrom.h create mode 100644 ddverify/models/con2/include/linux/compat.h create mode 100644 ddverify/models/con2/include/linux/compiler.h create mode 100644 ddverify/models/con2/include/linux/completion.h create mode 100644 ddverify/models/con2/include/linux/config.h create mode 100644 ddverify/models/con2/include/linux/console.h create mode 100644 ddverify/models/con2/include/linux/cpumask.h create mode 100644 ddverify/models/con2/include/linux/ctype.h create mode 100644 ddverify/models/con2/include/linux/dcache.h create mode 100644 ddverify/models/con2/include/linux/delay.h create mode 100644 ddverify/models/con2/include/linux/devfs_fs_kernel.h create mode 100644 ddverify/models/con2/include/linux/device.h create mode 100644 ddverify/models/con2/include/linux/dma-mapping.h create mode 100644 ddverify/models/con2/include/linux/elevator.h create mode 100644 ddverify/models/con2/include/linux/err.h create mode 100644 ddverify/models/con2/include/linux/errno.h create mode 100644 ddverify/models/con2/include/linux/fcntl.h create mode 100644 ddverify/models/con2/include/linux/fd.h create mode 100644 ddverify/models/con2/include/linux/fdreg.h create mode 100644 ddverify/models/con2/include/linux/file.h create mode 100644 ddverify/models/con2/include/linux/firmware.h create mode 100644 ddverify/models/con2/include/linux/fs.h create mode 100644 ddverify/models/con2/include/linux/genhd.h create mode 100644 ddverify/models/con2/include/linux/gfp.h create mode 100644 ddverify/models/con2/include/linux/hdreg.h create mode 100644 ddverify/models/con2/include/linux/highmem.h create mode 100644 ddverify/models/con2/include/linux/if.h create mode 100644 ddverify/models/con2/include/linux/in.h create mode 100644 ddverify/models/con2/include/linux/init.h create mode 100644 ddverify/models/con2/include/linux/interrupt.h create mode 100644 ddverify/models/con2/include/linux/ioctl.h create mode 100644 ddverify/models/con2/include/linux/ioport.h create mode 100644 ddverify/models/con2/include/linux/jiffies.h create mode 100644 ddverify/models/con2/include/linux/kdb_kern.h create mode 100644 ddverify/models/con2/include/linux/kdev_t.h create mode 100644 ddverify/models/con2/include/linux/kernel.h create mode 100644 ddverify/models/con2/include/linux/kobject.h create mode 100644 ddverify/models/con2/include/linux/kthread.h create mode 100644 ddverify/models/con2/include/linux/list.h create mode 100644 ddverify/models/con2/include/linux/major.h create mode 100644 ddverify/models/con2/include/linux/mc146818rtc.h create mode 100644 ddverify/models/con2/include/linux/mempool.h create mode 100644 ddverify/models/con2/include/linux/miscdevice.h create mode 100644 ddverify/models/con2/include/linux/mm.h create mode 100644 ddverify/models/con2/include/linux/mm_types.h create mode 100644 ddverify/models/con2/include/linux/mman.h create mode 100644 ddverify/models/con2/include/linux/mmzone.h create mode 100644 ddverify/models/con2/include/linux/mod_devicetable.h create mode 100644 ddverify/models/con2/include/linux/module.h create mode 100644 ddverify/models/con2/include/linux/moduleparam.h create mode 100644 ddverify/models/con2/include/linux/mutex.h create mode 100644 ddverify/models/con2/include/linux/net.h create mode 100644 ddverify/models/con2/include/linux/netdevice.h create mode 100644 ddverify/models/con2/include/linux/notifier.h create mode 100644 ddverify/models/con2/include/linux/pagemap.h create mode 100644 ddverify/models/con2/include/linux/parport.h create mode 100644 ddverify/models/con2/include/linux/parport_pc.h create mode 100644 ddverify/models/con2/include/linux/pci.h create mode 100644 ddverify/models/con2/include/linux/pci_ids.h create mode 100644 ddverify/models/con2/include/linux/pci_regs.h create mode 100644 ddverify/models/con2/include/linux/percpu.h create mode 100644 ddverify/models/con2/include/linux/platform_device.h create mode 100644 ddverify/models/con2/include/linux/pm.h create mode 100644 ddverify/models/con2/include/linux/pnp.h create mode 100644 ddverify/models/con2/include/linux/poll.h create mode 100644 ddverify/models/con2/include/linux/posix_types.h create mode 100644 ddverify/models/con2/include/linux/proc_fs.h create mode 100644 ddverify/models/con2/include/linux/ptrace.h create mode 100644 ddverify/models/con2/include/linux/reboot.h create mode 100644 ddverify/models/con2/include/linux/rtc.h create mode 100644 ddverify/models/con2/include/linux/scatterlist.h create mode 100644 ddverify/models/con2/include/linux/sched.h create mode 100644 ddverify/models/con2/include/linux/seq_file.h create mode 100644 ddverify/models/con2/include/linux/serial.h create mode 100644 ddverify/models/con2/include/linux/signal.h create mode 100644 ddverify/models/con2/include/linux/skbuff.h create mode 100644 ddverify/models/con2/include/linux/slab.h create mode 100644 ddverify/models/con2/include/linux/smp_lock.h create mode 100644 ddverify/models/con2/include/linux/socket.h create mode 100644 ddverify/models/con2/include/linux/spinlock.h create mode 100644 ddverify/models/con2/include/linux/spinlock_types.h create mode 100644 ddverify/models/con2/include/linux/stat.h create mode 100644 ddverify/models/con2/include/linux/stddef.h create mode 100644 ddverify/models/con2/include/linux/string.h create mode 100644 ddverify/models/con2/include/linux/stringify.h create mode 100644 ddverify/models/con2/include/linux/suspend.h create mode 100644 ddverify/models/con2/include/linux/swap.h create mode 100644 ddverify/models/con2/include/linux/sysfs.h create mode 100644 ddverify/models/con2/include/linux/sysrq.h create mode 100644 ddverify/models/con2/include/linux/termios.h create mode 100644 ddverify/models/con2/include/linux/time.h create mode 100644 ddverify/models/con2/include/linux/timer.h create mode 100644 ddverify/models/con2/include/linux/tty.h create mode 100644 ddverify/models/con2/include/linux/tty_driver.h create mode 100644 ddverify/models/con2/include/linux/tty_driver.h,v create mode 100644 ddverify/models/con2/include/linux/tty_flip.h create mode 100644 ddverify/models/con2/include/linux/tty_ldisc.h create mode 100644 ddverify/models/con2/include/linux/types.h create mode 100644 ddverify/models/con2/include/linux/uio.h create mode 100644 ddverify/models/con2/include/linux/videodev.h create mode 100644 ddverify/models/con2/include/linux/videodev2.h create mode 100644 ddverify/models/con2/include/linux/vmalloc.h create mode 100644 ddverify/models/con2/include/linux/wait.h create mode 100644 ddverify/models/con2/include/linux/watchdog.h create mode 100644 ddverify/models/con2/include/linux/workqueue.h create mode 100644 ddverify/models/con2/include/linux/writeback.h create mode 100644 ddverify/models/con2/include/media/v4l2-common.h create mode 100644 ddverify/models/con2/include/media/v4l2-dev.h create mode 100644 ddverify/models/con2/include/net/sock.h create mode 100644 ddverify/models/con2/src/ddverify/cdev.c create mode 100644 ddverify/models/con2/src/ddverify/ddverify.c create mode 100644 ddverify/models/con2/src/ddverify/genhd.c create mode 100644 ddverify/models/con2/src/ddverify/interrupt.c create mode 100644 ddverify/models/con2/src/ddverify/ioctl.c create mode 100644 ddverify/models/con2/src/ddverify/pci.c create mode 100644 ddverify/models/con2/src/ddverify/tasklet.c create mode 100644 ddverify/models/con2/src/ddverify/timer.c create mode 100644 ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c create mode 100644 ddverify/models/con2/src/linux/block/elevator.c create mode 100644 ddverify/models/con2/src/linux/block/genhd.c create mode 100644 ddverify/models/con2/src/linux/block/ll_rw_blk.c create mode 100644 ddverify/models/con2/src/linux/drivers/char/misc.c create mode 100644 ddverify/models/con2/src/linux/drivers/char/tty_io.c create mode 100644 ddverify/models/con2/src/linux/fs/char_dev.c create mode 100644 ddverify/models/con2/src/linux/fs/proc/generic.c create mode 100644 ddverify/models/con2/src/linux/kernel/irq/manage.c create mode 100644 ddverify/models/con2/src/linux/kernel/mutex.c create mode 100644 ddverify/models/con2/src/linux/kernel/resource.c create mode 100644 ddverify/models/con2/src/linux/kernel/sched.c create mode 100644 ddverify/models/con2/src/linux/kernel/semaphore.c create mode 100644 ddverify/models/con2/src/linux/kernel/softirq.c create mode 100644 ddverify/models/con2/src/linux/kernel/spinlock.c create mode 100644 ddverify/models/con2/src/linux/kernel/timer.c create mode 100644 ddverify/models/con2/src/linux/kernel/wait.c create mode 100644 ddverify/models/con2/src/linux/kernel/workqueue.c create mode 100644 ddverify/models/con2/src/linux/mm/page_alloc.c create mode 100644 ddverify/models/con2/src/linux/mm/slab.c create mode 100644 ddverify/models/con2/src/linux/mm/vmalloc.c create mode 100644 ddverify/models/con2/src/linux/pci.c create mode 100644 ddverify/models/seq1/include/asm-generic/bug.h create mode 100644 ddverify/models/seq1/include/asm-generic/errno-base.h create mode 100644 ddverify/models/seq1/include/asm-generic/errno.h create mode 100644 ddverify/models/seq1/include/asm-generic/fcntl.h create mode 100644 ddverify/models/seq1/include/asm-generic/ioctl.h create mode 100644 ddverify/models/seq1/include/asm-generic/pci-dma-compat.h create mode 100644 ddverify/models/seq1/include/asm-generic/rtc.h create mode 100644 ddverify/models/seq1/include/asm-generic/siginfo.h create mode 100644 ddverify/models/seq1/include/asm/atomic.h create mode 100644 ddverify/models/seq1/include/asm/bitops.h create mode 100644 ddverify/models/seq1/include/asm/bug.h create mode 100644 ddverify/models/seq1/include/asm/byteorder.h create mode 100644 ddverify/models/seq1/include/asm/current.h create mode 100644 ddverify/models/seq1/include/asm/delay.h create mode 100644 ddverify/models/seq1/include/asm/dma.h create mode 100644 ddverify/models/seq1/include/asm/errno.h create mode 100644 ddverify/models/seq1/include/asm/fcntl.h create mode 100644 ddverify/models/seq1/include/asm/floppy.h create mode 100644 ddverify/models/seq1/include/asm/highmem.h create mode 100644 ddverify/models/seq1/include/asm/io.h create mode 100644 ddverify/models/seq1/include/asm/ioctl.h create mode 100644 ddverify/models/seq1/include/asm/ioctls.h create mode 100644 ddverify/models/seq1/include/asm/irq.h create mode 100644 ddverify/models/seq1/include/asm/kmap_types.h create mode 100644 ddverify/models/seq1/include/asm/leds.h create mode 100644 ddverify/models/seq1/include/asm/mach-types.h create mode 100644 ddverify/models/seq1/include/asm/mc146818rtc.h create mode 100644 ddverify/models/seq1/include/asm/msr.h create mode 100644 ddverify/models/seq1/include/asm/page.h create mode 100644 ddverify/models/seq1/include/asm/param.h create mode 100644 ddverify/models/seq1/include/asm/pci.h create mode 100644 ddverify/models/seq1/include/asm/poll.h create mode 100644 ddverify/models/seq1/include/asm/posix_types.h create mode 100644 ddverify/models/seq1/include/asm/processor.h create mode 100644 ddverify/models/seq1/include/asm/ptrace.h create mode 100644 ddverify/models/seq1/include/asm/rtc.h create mode 100644 ddverify/models/seq1/include/asm/scatterlist.h create mode 100644 ddverify/models/seq1/include/asm/semaphore.h create mode 100644 ddverify/models/seq1/include/asm/siginfo.h create mode 100644 ddverify/models/seq1/include/asm/signal.h create mode 100644 ddverify/models/seq1/include/asm/stat.h create mode 100644 ddverify/models/seq1/include/asm/string.h create mode 100644 ddverify/models/seq1/include/asm/system.h create mode 100644 ddverify/models/seq1/include/asm/termbits.h create mode 100644 ddverify/models/seq1/include/asm/termios.h create mode 100644 ddverify/models/seq1/include/asm/types.h create mode 100644 ddverify/models/seq1/include/asm/uaccess.h create mode 100644 ddverify/models/seq1/include/ddverify/blkdev.h create mode 100644 ddverify/models/seq1/include/ddverify/cdev.h create mode 100644 ddverify/models/seq1/include/ddverify/ddverify.h create mode 100644 ddverify/models/seq1/include/ddverify/fixed_cdev.h create mode 100644 ddverify/models/seq1/include/ddverify/genhd.h create mode 100644 ddverify/models/seq1/include/ddverify/interrupt.h create mode 100644 ddverify/models/seq1/include/ddverify/ioctl.h create mode 100644 ddverify/models/seq1/include/ddverify/ioport.h create mode 100644 ddverify/models/seq1/include/ddverify/miscdevice.h create mode 100644 ddverify/models/seq1/include/ddverify/pci.h create mode 100644 ddverify/models/seq1/include/ddverify/pthread.h create mode 100644 ddverify/models/seq1/include/ddverify/satabs.h create mode 100644 ddverify/models/seq1/include/ddverify/tasklet.h create mode 100644 ddverify/models/seq1/include/ddverify/timer.h create mode 100644 ddverify/models/seq1/include/ddverify/tty.h create mode 100644 ddverify/models/seq1/include/ddverify/workqueue.h create mode 100644 ddverify/models/seq1/include/linux/backing-dev.h create mode 100644 ddverify/models/seq1/include/linux/bcd.h create mode 100644 ddverify/models/seq1/include/linux/bio.h create mode 100644 ddverify/models/seq1/include/linux/bitops.h create mode 100644 ddverify/models/seq1/include/linux/blkdev.h create mode 100644 ddverify/models/seq1/include/linux/blkpg.h create mode 100644 ddverify/models/seq1/include/linux/blktrace_api.h create mode 100644 ddverify/models/seq1/include/linux/buffer_head.h create mode 100644 ddverify/models/seq1/include/linux/byteorder/generic.h create mode 100644 ddverify/models/seq1/include/linux/byteorder/little_endian.h create mode 100644 ddverify/models/seq1/include/linux/cache.h create mode 100644 ddverify/models/seq1/include/linux/capability.h create mode 100644 ddverify/models/seq1/include/linux/cdev.h create mode 100644 ddverify/models/seq1/include/linux/cdrom.h create mode 100644 ddverify/models/seq1/include/linux/compat.h create mode 100644 ddverify/models/seq1/include/linux/compiler.h create mode 100644 ddverify/models/seq1/include/linux/completion.h create mode 100644 ddverify/models/seq1/include/linux/config.h create mode 100644 ddverify/models/seq1/include/linux/console.h create mode 100644 ddverify/models/seq1/include/linux/cpumask.h create mode 100644 ddverify/models/seq1/include/linux/ctype.h create mode 100644 ddverify/models/seq1/include/linux/dcache.h create mode 100644 ddverify/models/seq1/include/linux/delay.h create mode 100644 ddverify/models/seq1/include/linux/devfs_fs_kernel.h create mode 100644 ddverify/models/seq1/include/linux/device.h create mode 100644 ddverify/models/seq1/include/linux/dma-mapping.h create mode 100644 ddverify/models/seq1/include/linux/elevator.h create mode 100644 ddverify/models/seq1/include/linux/err.h create mode 100644 ddverify/models/seq1/include/linux/errno.h create mode 100644 ddverify/models/seq1/include/linux/fcntl.h create mode 100644 ddverify/models/seq1/include/linux/fd.h create mode 100644 ddverify/models/seq1/include/linux/fdreg.h create mode 100644 ddverify/models/seq1/include/linux/file.h create mode 100644 ddverify/models/seq1/include/linux/firmware.h create mode 100644 ddverify/models/seq1/include/linux/fs.h create mode 100644 ddverify/models/seq1/include/linux/genhd.h create mode 100644 ddverify/models/seq1/include/linux/gfp.h create mode 100644 ddverify/models/seq1/include/linux/hdreg.h create mode 100644 ddverify/models/seq1/include/linux/highmem.h create mode 100644 ddverify/models/seq1/include/linux/if.h create mode 100644 ddverify/models/seq1/include/linux/in.h create mode 100644 ddverify/models/seq1/include/linux/init.h create mode 100644 ddverify/models/seq1/include/linux/interrupt.h create mode 100644 ddverify/models/seq1/include/linux/ioctl.h create mode 100644 ddverify/models/seq1/include/linux/ioport.h create mode 100644 ddverify/models/seq1/include/linux/jiffies.h create mode 100644 ddverify/models/seq1/include/linux/kdb_kern.h create mode 100644 ddverify/models/seq1/include/linux/kdev_t.h create mode 100644 ddverify/models/seq1/include/linux/kernel.h create mode 100644 ddverify/models/seq1/include/linux/kobject.h create mode 100644 ddverify/models/seq1/include/linux/kthread.h create mode 100644 ddverify/models/seq1/include/linux/list.h create mode 100644 ddverify/models/seq1/include/linux/major.h create mode 100644 ddverify/models/seq1/include/linux/mc146818rtc.h create mode 100644 ddverify/models/seq1/include/linux/mempool.h create mode 100644 ddverify/models/seq1/include/linux/miscdevice.h create mode 100644 ddverify/models/seq1/include/linux/mm.h create mode 100644 ddverify/models/seq1/include/linux/mm_types.h create mode 100644 ddverify/models/seq1/include/linux/mman.h create mode 100644 ddverify/models/seq1/include/linux/mmzone.h create mode 100644 ddverify/models/seq1/include/linux/mod_devicetable.h create mode 100644 ddverify/models/seq1/include/linux/module.h create mode 100644 ddverify/models/seq1/include/linux/moduleparam.h create mode 100644 ddverify/models/seq1/include/linux/mutex.h create mode 100644 ddverify/models/seq1/include/linux/net.h create mode 100644 ddverify/models/seq1/include/linux/netdevice.h create mode 100644 ddverify/models/seq1/include/linux/notifier.h create mode 100644 ddverify/models/seq1/include/linux/pagemap.h create mode 100644 ddverify/models/seq1/include/linux/parport.h create mode 100644 ddverify/models/seq1/include/linux/parport_pc.h create mode 100644 ddverify/models/seq1/include/linux/pci.h create mode 100644 ddverify/models/seq1/include/linux/pci_ids.h create mode 100644 ddverify/models/seq1/include/linux/pci_regs.h create mode 100644 ddverify/models/seq1/include/linux/percpu.h create mode 100644 ddverify/models/seq1/include/linux/platform_device.h create mode 100644 ddverify/models/seq1/include/linux/pm.h create mode 100644 ddverify/models/seq1/include/linux/pnp.h create mode 100644 ddverify/models/seq1/include/linux/poll.h create mode 100644 ddverify/models/seq1/include/linux/posix_types.h create mode 100644 ddverify/models/seq1/include/linux/proc_fs.h create mode 100644 ddverify/models/seq1/include/linux/ptrace.h create mode 100644 ddverify/models/seq1/include/linux/reboot.h create mode 100644 ddverify/models/seq1/include/linux/rtc.h create mode 100644 ddverify/models/seq1/include/linux/scatterlist.h create mode 100644 ddverify/models/seq1/include/linux/sched.h create mode 100644 ddverify/models/seq1/include/linux/seq_file.h create mode 100644 ddverify/models/seq1/include/linux/serial.h create mode 100644 ddverify/models/seq1/include/linux/signal.h create mode 100644 ddverify/models/seq1/include/linux/skbuff.h create mode 100644 ddverify/models/seq1/include/linux/slab.h create mode 100644 ddverify/models/seq1/include/linux/smp_lock.h create mode 100644 ddverify/models/seq1/include/linux/socket.h create mode 100644 ddverify/models/seq1/include/linux/spinlock.h create mode 100644 ddverify/models/seq1/include/linux/spinlock_types.h create mode 100644 ddverify/models/seq1/include/linux/stat.h create mode 100644 ddverify/models/seq1/include/linux/stddef.h create mode 100644 ddverify/models/seq1/include/linux/string.h create mode 100644 ddverify/models/seq1/include/linux/stringify.h create mode 100644 ddverify/models/seq1/include/linux/suspend.h create mode 100644 ddverify/models/seq1/include/linux/swap.h create mode 100644 ddverify/models/seq1/include/linux/sysfs.h create mode 100644 ddverify/models/seq1/include/linux/sysrq.h create mode 100644 ddverify/models/seq1/include/linux/termios.h create mode 100644 ddverify/models/seq1/include/linux/threads.h create mode 100644 ddverify/models/seq1/include/linux/time.h create mode 100644 ddverify/models/seq1/include/linux/timer.h create mode 100644 ddverify/models/seq1/include/linux/tty.h create mode 100644 ddverify/models/seq1/include/linux/tty_driver.h create mode 100644 ddverify/models/seq1/include/linux/tty_driver.h,v create mode 100644 ddverify/models/seq1/include/linux/tty_flip.h create mode 100644 ddverify/models/seq1/include/linux/tty_ldisc.h create mode 100644 ddverify/models/seq1/include/linux/types.h create mode 100644 ddverify/models/seq1/include/linux/uio.h create mode 100644 ddverify/models/seq1/include/linux/videodev.h create mode 100644 ddverify/models/seq1/include/linux/videodev2.h create mode 100644 ddverify/models/seq1/include/linux/vmalloc.h create mode 100644 ddverify/models/seq1/include/linux/wait.h create mode 100644 ddverify/models/seq1/include/linux/watchdog.h create mode 100644 ddverify/models/seq1/include/linux/workqueue.h create mode 100644 ddverify/models/seq1/include/linux/writeback.h create mode 100644 ddverify/models/seq1/include/media/v4l2-common.h create mode 100644 ddverify/models/seq1/include/media/v4l2-dev.h create mode 100644 ddverify/models/seq1/include/net/sock.h create mode 100644 ddverify/models/seq1/src/ddverify/cdev.c create mode 100644 ddverify/models/seq1/src/ddverify/ddverify.c create mode 100644 ddverify/models/seq1/src/ddverify/genhd.c create mode 100644 ddverify/models/seq1/src/ddverify/interrupt.c create mode 100644 ddverify/models/seq1/src/ddverify/ioctl.c create mode 100644 ddverify/models/seq1/src/ddverify/pci.c create mode 100644 ddverify/models/seq1/src/ddverify/tasklet.c create mode 100644 ddverify/models/seq1/src/ddverify/timer.c create mode 100644 ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c create mode 100644 ddverify/models/seq1/src/linux/block/elevator.c create mode 100644 ddverify/models/seq1/src/linux/block/genhd.c create mode 100644 ddverify/models/seq1/src/linux/block/ll_rw_blk.c create mode 100644 ddverify/models/seq1/src/linux/drivers/char/misc.c create mode 100644 ddverify/models/seq1/src/linux/drivers/char/tty_io.c create mode 100644 ddverify/models/seq1/src/linux/fs/char_dev.c create mode 100644 ddverify/models/seq1/src/linux/fs/proc/generic.c create mode 100644 ddverify/models/seq1/src/linux/fs/read_write.c create mode 100644 ddverify/models/seq1/src/linux/kernel/irq/manage.c create mode 100644 ddverify/models/seq1/src/linux/kernel/mutex.c create mode 100644 ddverify/models/seq1/src/linux/kernel/resource.c create mode 100644 ddverify/models/seq1/src/linux/kernel/sched.c create mode 100644 ddverify/models/seq1/src/linux/kernel/semaphore.c create mode 100644 ddverify/models/seq1/src/linux/kernel/softirq.c create mode 100644 ddverify/models/seq1/src/linux/kernel/spinlock.c create mode 100644 ddverify/models/seq1/src/linux/kernel/timer.c create mode 100644 ddverify/models/seq1/src/linux/kernel/wait.c create mode 100644 ddverify/models/seq1/src/linux/kernel/workqueue.c create mode 100644 ddverify/models/seq1/src/linux/mm/page_alloc.c create mode 100644 ddverify/models/seq1/src/linux/mm/slab.c create mode 100644 ddverify/models/seq1/src/linux/mm/vmalloc.c create mode 100644 ddverify/models/seq1/src/linux/pci.c create mode 100644 ddverify/readme.txt diff --git a/ddverify/awk/convert_satabs_output b/ddverify/awk/convert_satabs_output new file mode 100644 index 000000000..640bc3fee --- /dev/null +++ b/ddverify/awk/convert_satabs_output @@ -0,0 +1,5 @@ +BEGIN {foundclaim = 0;} +/^Claim*/ {foundclaim = 1; claim = NR; n = length($2) - 1; str = substr($2, 1, n); print str} +(NR == claim + 1) && (foundclaim == 1) {print $2 "\n" $4} +(NR == claim + 2) && (foundclaim == 1) {print substr($0, 3)} +(NR == claim + 3) && (foundclaim == 1) {print substr($0, 3) "\n"} diff --git a/ddverify/awk/get_number_of_iteration b/ddverify/awk/get_number_of_iteration new file mode 100644 index 000000000..ee65efa7a --- /dev/null +++ b/ddverify/awk/get_number_of_iteration @@ -0,0 +1,3 @@ +BEGIN {} +/Iterations:/ {print $2} +(foundline == 1) && (NR == linenr + 1) {print $2} diff --git a/ddverify/awk/get_time_result b/ddverify/awk/get_time_result new file mode 100644 index 000000000..0d91fc911 --- /dev/null +++ b/ddverify/awk/get_time_result @@ -0,0 +1,3 @@ +BEGIN {foundline = 0; linenr = 0; ORS = "";} +/^VERIFICATION SUCCESSFUL*/ {foundline = 1; linenr = NR;} +(foundline == 1) && (NR == linenr + 1) {print $2} diff --git a/ddverify/awk/get_too_many_iterations_result b/ddverify/awk/get_too_many_iterations_result new file mode 100644 index 000000000..2dbe25a86 --- /dev/null +++ b/ddverify/awk/get_too_many_iterations_result @@ -0,0 +1,6 @@ +BEGIN {foundline = 0; linenr = 0; ORS = "";} +/^Too many iterations, giving up.*/ {foundline = 1; linenr = NR} +(foundline == 1) && (NR == linenr + 2) {print $2, $4, $6, $9, $11, " "} +(foundline == 1) && (NR == linenr + 3) {print $2, " "} +(foundline == 1) && (NR == linenr + 4) {print $2, "\n"} + diff --git a/ddverify/awk/get_verification_result b/ddverify/awk/get_verification_result new file mode 100644 index 000000000..c933b9d7d --- /dev/null +++ b/ddverify/awk/get_verification_result @@ -0,0 +1,6 @@ +BEGIN {foundline = 0; linenr = 0; ORS = "";} +/VERIFICATION/ {print $2, "\t"; foundline = 1; linenr = NR} +(foundline == 1) && (NR == linenr + 1) {print $2, $4, $6, $9, $11, " "} +(foundline == 1) && (NR == linenr + 2) {print $2, " "} +(foundline == 1) && (NR == linenr + 3) {print $2, "\n"} + diff --git a/ddverify/awk/parse_dd_file b/ddverify/awk/parse_dd_file new file mode 100644 index 000000000..1423e5232 --- /dev/null +++ b/ddverify/awk/parse_dd_file @@ -0,0 +1,3 @@ +/^[ ]*module_init\(*\)*/ {print "MODULE_INIT\n" $1} +/^[ ]*module_exit\(*\)*/ {print "MODULE_EXIT\n" $1} +/^[ ]*#include*/ {print "INCLUDE\n" $2} diff --git a/ddverify/bin/LICENSE b/ddverify/bin/LICENSE new file mode 100644 index 000000000..a05bea818 --- /dev/null +++ b/ddverify/bin/LICENSE @@ -0,0 +1,40 @@ +(C) 2001-2008, Daniel Kroening, ETH Zurich, +Edmund Clarke, Computer Science Department, Carnegie Mellon University + +All rights reserved. Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + + This product includes software developed by Daniel Kroening, + ETH Zurich and Edmund Clarke, Computer Science Department, + Carnegie Mellon University. + + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + 5. We must be notified by email at kroening@cs.cmu.edu after you install + the program for any purpose. + + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITIES AND CONTRIBUTORS `AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/ddverify/bin/ddverify.c b/ddverify/bin/ddverify.c new file mode 100644 index 000000000..483b8e351 --- /dev/null +++ b/ddverify/bin/ddverify.c @@ -0,0 +1,965 @@ +/***************************************************************************** + +Copyright (C) 2001-2008, Daniel Kroening, ETH Zurich, + +All rights reserved. Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + + This product includes software developed by Daniel Kroening, + ETH Zurich and Edmund Clarke, Computer Science Department, + Carnegie Mellon University. + + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + 5. We must be notified by email at kroening@cs.cmu.edu after you install + the program for any purpose. + + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITIES AND CONTRIBUTORS `AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. +******************************************************************************/ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +#include "ddverify.h" + +#ifndef __linux__ +#include + +ssize_t +getline(char **lineptr, size_t *n, FILE *stream) +{ + char *ptr, *tmp; + size_t l; + + if ((ptr=fgetln(stream, &l))==NULL) + return -1; + + if (*lineptr==NULL || *n<(l+1)) + { + if ((tmp=realloc(*lineptr, l+1))==NULL) + return -1; + *lineptr=tmp; + *n=l+1; + } + memcpy(*lineptr, ptr, l); + (*lineptr)[l] = '\0'; + return l; +} +#endif + +void print_msg(char *msg) +{ + fprintf(stdout, msg); + fflush(stdout); +} + +void show_help() +{ + printf("\n"); + printf("********************************************************************\n"); + printf("* *\n"); + printf("* DDVerify 0.1.c *\n"); + printf("* *\n"); + printf("********************************************************************\n"); + printf("\n"); + printf("Usage: Purpose:\n\n"); + printf(" ddverify [-?] [-h] [--help] show help\n"); + printf(" -D macro define preprocessor macro\n"); + printf(" --16, --32, --64 set width of machine word\n"); + printf(" --modelchecker # set the modelchecker to be used\n"); + printf(" --iterations # set maximum number of refinement iterations\n"); + printf(" --unwind # set maximum depth of unwinding\n"); + printf(" --unwindset #:# set maximum depth of unwinding for a loop\n"); + printf(" --ddv-path set ddverify path\n"); + printf(" --module-init set module initalization function\n"); + printf(" --module-exit set module cleanup function\n"); + printf(" --driver-type # set driver type (char, block or net)\n"); + printf(" --model # set the verification model (seq or con)\n"); + printf(" --prepare-only stop after preparation\n"); + printf(" --check-bounds array bounds check\n"); + printf(" --check-pointer pointer check\n"); + printf(" --check-spinlock spinlock check\n"); + printf(" --check-semaphore semaphore check\n"); + printf(" --check-mutex mutex check\n"); + printf(" --check-io I/O communication check\n"); + printf(" --check-wait-queue wait queue check\n"); + printf(" --check-tasklet tasklet check\n"); + printf(" --check-work-queue work queue check\n"); + printf(" --check-timer timer check\n"); + printf(" --check-context context check\n"); + printf(" --no-slicing turn slicing off for CBMC\n"); + printf(" --cbmc use CBMC as verification tool\n"); + printf(" --satabs use SATABS as verification tool (default)\n"); + printf("\n"); + + exit(0); +} + + +void set_number_iterations(char *number) +{ + strcpy(number_iterations, number); +} + +// extends the unwindset string +void set_unwindset(char *set) +{ + if (unwindset==NULL) + { + unwindset=malloc(unwindset_str_size); + if (unwindset==NULL) + exit(-1); + unwindset[0]='\0'; + } + if (strlen(unwindset)+strlen(set)+strlen(UNWINDSET_PARAM)+1>unwindset_str_size) + { + unwindset_str_size+=strlen(set)+strlen(UNWINDSET_PARAM)+STR_LENGTH; + unwindset=realloc(unwindset, unwindset_str_size); + if (unwindset==NULL) + exit(-1); + } + strcat(unwindset, UNWINDSET_PARAM); + strcat(unwindset, set); +} + +void set_unwind(char *set) +{ + if(unwind!=NULL) + free(unwind); // somebody decided to provide two --unwind params + unwind=malloc(strlen(set)+1); + if(unwind==NULL) + exit(-1); + strcpy(unwind, set); +} + +void set_ddv_path(char *path) +{ + int i; + + strcpy(ddv_path, path); + i = strlen(ddv_path) - 1; + + if (ddv_path[i] != '/') { + strcat(ddv_path, "/"); + } +} + +void set_driver_type(char *type) +{ + if (strcmp(type, "char") == 0) { + driver_type = DRIVER_TYPE_CHAR; + return; + } + + if (strcmp(type, "block") == 0) { + driver_type = DRIVER_TYPE_BLOCK; + return; + } + + if (strcmp(type, "net") == 0) { + driver_type = DRIVER_TYPE_NET; + + fprintf(stderr, "Error: Network driver are not supported!\n"); + exit(-1); + } + + fprintf(stderr, "Error: Driver type not recognized. Use \"char\", \"block\" or \"net\".\n"); + exit(-1); +} + +void set_model_type(char *type) +{ + if (strcmp(type, "seq1") == 0) { + model_type = MODEL_TYPE_SEQUENTIAL1; + strcpy(include_path,"models/seq1/include"); + strcpy(src_path,"models/seq1/src/"); + return; + } + + if (strcmp(type, "con1") == 0) { + model_type = MODEL_TYPE_CONCURRENT1; + strcpy(include_path,"models/con1/include"); + strcpy(src_path,"models/con1/src/"); + return; + } + + if (strcmp(type, "con2") == 0) { + model_type = MODEL_TYPE_CONCURRENT2; + strcpy(include_path,"models/con2/include"); + strcpy(src_path,"models/con2/src/"); + return; + } + + fprintf(stderr, "Error: Model type not recognized. Use either \"seq1\", \"con1\", or \"con2\".\n"); + exit(-1); +} + +void write_cc_file() +{ + FILE *fp; + char content[5000]; + int fh; + + strcpy(content, "#include \n"); + + strcat(content, "#include \""); + strcat(content, file[0]); + strcat(content, "\"\n\n"); + + strcat(content, "int main()\n"); + strcat(content, "{\n"); + + if (strcmp(module_init, "") != 0) { + strcat(content, " _ddv_module_init = "); + strcat(content, module_init); + strcat(content, ";\n"); + } + + if (strcmp(module_exit, "") != 0) { + strcat(content, " _ddv_module_exit = "); + strcat(content, module_exit); + strcat(content, ";\n"); + } + + strcat(content, " call_ddv();\n\n"); + strcat(content, " return 0;\n"); + strcat(content, "}\n"); + + if ((fh = open(output_cc_file, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR )) != -1) { + close(fh); + + fp = fopen(output_cc_file, "a"); + fprintf(fp, content); + fclose(fp); + } else { + fprintf(stderr, "Error: Could not create c file!\n"); + exit(-1); + } +} + +void get_preprocessor_string(char *str) +{ + int i; + + strcpy(str, " -D __KERNEL__ -D MODULE "); + + if (driver_type == DRIVER_TYPE_CHAR) { + strcat(str, " -D DRIVER_TYPE_CHAR "); + } else if (driver_type == DRIVER_TYPE_BLOCK) { + strcat(str, " -D DRIVER_TYPE_BLOCK "); + } + + if (driver_type_pci) { + strcat(str, " -D DRIVER_TYPE_PCI "); + } + + if (model_type == MODEL_TYPE_SEQUENTIAL1) { + strcat(str, " -D MODEL_TYPE_SEQUENTIAL1 "); + } else if (model_type == MODEL_TYPE_CONCURRENT1) { + strcat(str, " -D MODEL_TYPE_CONCURRENT1 "); + } + + if (check_spinlock) { + strcat(str, " -D DDV_ASSERT_SPINLOCK "); + } + if (check_semaphore) { + strcat(str, " -D DDV_ASSERT_SEMAPHORE "); + } + if (check_mutex) { + strcat(str, " -D DDV_ASSERT_MUTEX "); + } + if (check_io) { + strcat(str, " -D DDV_ASSERT_IO "); + } + if (check_wait_queue) { + strcat(str, " -D DDV_ASSERT_WAIT_QUEUE "); + } + if (check_tasklet) { + strcat(str, " -D DDV_ASSERT_TASKLET "); + } + if (check_work_queue) { + strcat(str, " -D DDV_ASSERT_WORK_QUEUE "); + } + if (check_timer) { + strcat(str, " -D DDV_ASSERT_TIMER "); + } + if (check_context) { + strcat(str, " -D DDV_ASSERT_CONTEXT "); + } + + for (i = 0; i < nr_macro_registered; i++) { + strcat(str, " -D "); + strcat(str, macro[i]); + } +} + +void write_compile_script() +{ + FILE *fp; + char script[10000]; + string tmp; + int i, fh; + + strcpy(script, "#!/bin/bash\n"); + + strcat(script, "gcc -c -I "); + strcat(script, ddv_path); + strcat(script, include_path); + + get_preprocessor_string(tmp); + strcat(script, tmp); + strcat(script, " \\\n"); + + strcat(script, output_cc_file); + strcat(script, " \\\n"); + + for (i = 1; i < nr_file_registered; i++) { + strcat(script, file[i]); + strcat(script, " \\\n"); + } + + for (i = 0; i < nr_ddv_files; i++) { + strcat(script, ddv_path); + strcat(script, src_path); + strcat(script, ddv_files[i]); + strcat(script, " \\\n"); + } + + + if ((fh = open(output_compile_file, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) != -1) { + close(fh); + + fp = fopen(output_compile_file, "a"); + fprintf(fp, script); + fclose(fp); + } else { + fprintf(stderr, "Error: Could not create compile script!\n"); + exit(-1); + } +} + + +void write_tool_script() +{ + FILE *fp; + char script[10000]; + string tmp; + int i, fh; + + strcpy(script, "#!/bin/bash\n"); + + strcat(script, (tool==SATABS)?"satabs":"cbmc"); + strcat(script, " $* "); + + if (!check_bounds) { + strcat(script, " --no-bounds-check "); + } + if (!check_pointer) { + strcat(script, " --no-pointer-check "); + } + if (!check_div_by_zero) { + strcat(script, " --no-div-by-zero-check "); + } + + switch (word_width) { + case 16: + strcat(script, " --16 "); + break; + case 32: + strcat(script, " --32 "); + break; + case 64: + strcat(script, " --64 "); + break; + default: + fprintf(stderr, "Error: Wrong word width!\n"); + break; + } + + if (tool==SATABS && strcmp(modelchecker, "") != 0) { + strcat(script, " --modelchecker "); + strcat(script, modelchecker); + strcat(script, " "); + } + + if (tool==SATABS) { + strcat(script, " --iterations "); + strcat(script, number_iterations); + strcat(script, " "); + } + + if (tool==CBMC && unwindset!=NULL) { + strcat(script, unwindset); + strcat(script, " "); + } + + if (tool==CBMC && unwind!=NULL) { + strcat(script, " --unwind "); + strcat(script, unwind); + strcat(script, " "); + } + + if (tool==CBMC && cbmc_slicing) + strcat(script, " --slice "); + + strcat(script, " -I "); + strcat(script, ddv_path); + strcat(script, include_path); + + get_preprocessor_string(tmp); + strcat(script, tmp); + strcat(script, " \\\n"); + + strcat(script, output_cc_file); + strcat(script, " \\\n"); + + for (i = 1; i < nr_file_registered; i++) { + strcat(script, file[i]); + strcat(script, " \\\n"); + } + + for (i = 0; i < nr_ddv_files; i++) { + strcat(script, ddv_path); + strcat(script, src_path); + strcat(script, ddv_files[i]); + strcat(script, " \\\n"); + } + + + if ((fh = open(output_tool_file, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) != -1) { + close(fh); + + fp = fopen(output_tool_file, "a"); + fprintf(fp, script); + fclose(fp); + } else { + fprintf(stderr, "Error: Could not create Satabs script!\n"); + exit(-1); + } +} + +void read_output_file() +{ + int ret, line_nr; + size_t t = 0; + char *buffer = NULL; + char **lineptr = &buffer; + + FILE *fp = fopen(".ddv_output_2", "r"); + + if (!fp) { + fprintf(stderr, "\nError: Could not open output file!\n"); + exit(-1); + } + + number_claims = 0; + line_nr = 0; + while((ret = getline(lineptr, &t, fp)) > 0) { + switch (line_nr % 6) { + case 0: + claim[number_claims].number = atoi(buffer); + + break; + case 1: + claim[number_claims].file = buffer; + + break; + case 2: + claim[number_claims].line = atoi(buffer); + + break; + case 3: + claim[number_claims].text = buffer; + + break; + case 4: + claim[number_claims].claim = buffer; + + break; + case 5: + // empty line + number_claims++; + + break; + default: + break; + } + line_nr++; + buffer = NULL; + } + fclose(fp); +} + +void prove_claims_satabs() +{ + int i, ret; + char tmp[1000]; + char cmd[1000]; + FILE *fp; + size_t t = 1000; + char* buffer = (char*) malloc(sizeof(char)*t); + char **lineptr = &buffer; + + for (i = 0; i < number_claims; i++) { + sprintf(tmp, "claim %d ", (i + 1)); + print_msg(tmp); + + if (strcmp(claim[i].claim, "TRUE") == 0) { + printf("SUCCESSFULL 0 \n"); + } else { + sprintf(cmd, "./ddv_satabs --claim %d > .claim_out_%d 2>&1", + claim[i].number, claim[i].number); + ret = system(cmd); + ret = WEXITSTATUS(ret); + if(ret==0 || ret==10) { + sprintf(cmd, "awk -f %sawk/get_verification_result .claim_out_%d", + ddv_path, claim[i].number); + system(cmd); + } + else if(ret==11) + { + print_msg("TOO_MANY_ITERATIONS\t"); + sprintf(cmd, "awk -f %sawk/get_too_many_iterations_result .claim_out_%d", + ddv_path, claim[i].number); + system(cmd); + } else { + print_msg("ERROR\n"); + } + } + + } + free(buffer); +} + +void prove_claims_cbmc() +{ + int i, ret; + char tmp[1000]; + char cmd[1000]; + FILE *fp; + size_t t = 1000; + char* buffer = (char*) malloc(sizeof(char)*t); + char **lineptr = &buffer; + + for (i = 0; i < number_claims; i++) { + sprintf(tmp, "claim %d ", (i + 1)); + print_msg(tmp); + + if (strcmp(claim[i].claim, "TRUE") == 0) { + printf("SUCCESSFULL 0 \n"); + } else { + sprintf(cmd, "./ddv_cbmc --claim %d > .claim_out_%d 2>&1", + claim[i].number, claim[i].number); + ret = system(cmd); + ret = WEXITSTATUS(ret); + if(ret==0 || ret==10) { + sprintf(cmd, "awk -f %sawk/get_verification_result .claim_out_%d", + ddv_path, claim[i].number); + system(cmd); + } + else { + print_msg("ERROR\n"); + } + } + + } + free(buffer); +} + +void run_satabs() +{ + char cmd[1000]; + + print_msg("Run satabs .."); + if (system("./ddv_satabs --show-claims > .ddv_output_1") == 0) { + fprintf(stderr, "\nError: Could not start Satabs!\n"); + exit(-1); + } + print_msg(".\n"); + + print_msg("Parse satabs output .."); + sprintf(cmd, "awk -f %sawk/convert_satabs_output .ddv_output_1 > .ddv_output_2", ddv_path); + system(cmd); + print_msg(".\n"); + + read_output_file(); + + printf("%d Claims\n", number_claims); + + prove_claims_satabs(); +} + +void run_cbmc() +{ + char cmd[1000]; + + print_msg("Run CBMC .."); + if (system("./ddv_cbmc --show-claims > .ddv_output_1") != 0) { + fprintf(stderr, "\nError: Could not start CBMC!\n"); + exit(-1); + } + print_msg(".\n"); + + print_msg("Parse CBMC output .."); + sprintf(cmd, "awk -f %sawk/convert_satabs_output .ddv_output_1 > .ddv_output_2", ddv_path); + system(cmd); + print_msg(".\n"); + + read_output_file(); + + printf("%d Claims\n", number_claims); + + prove_claims_cbmc(); +} + +void parse_args(int argc, char **argv) +{ + int cmd; + + while (1) { + int option_index = 0; + static struct option long_options[] = { + {"help", 0, 0, 0}, + {"16", 0, 0, 0}, + {"32", 0, 0, 0}, + {"64", 0, 0, 0}, + {"modelchecker", 1, 0, 0}, + {"iterations", 1, 0, 0}, + {"ddv-path", 1, 0, 0}, + {"module-init", 1, 0, 0}, + {"module-exit", 1, 0, 0}, + {"driver-type", 1, 0, 0}, + {"model", 1, 0, 0}, + {"prepare-only", 0, 0, 0}, + {"check-bounds", 0, 0, 0}, + {"check-pointer", 0, 0, 0}, + {"check-spinlock", 0, 0, 0}, + {"check-semaphore", 0, 0, 0}, + {"check-mutex", 0, 0, 0}, + {"check-io", 0, 0, 0}, + {"check-wait-queue", 0, 0, 0}, + {"check-tasklet", 0, 0, 0}, + {"check-work-queue", 0, 0, 0}, + {"check-timer", 0, 0, 0}, + {"check-context", 0, 0, 0}, + {"cbmc", 0, 0, 0}, + {"satabs", 0, 0, 0}, + {"unwindset", 1, 0, 0}, + {"unwind", 1, 0, 0}, + {"no-slicing", 0, 0, 0}, + {0, 0, 0, 0} + }; + + cmd = getopt_long(argc, argv, "?hD:1", long_options, &option_index); + if (cmd == -1) { + break; + } + + switch (cmd) { + case 0: + switch (option_index) { + case 0: + show_help(); + break; + case 1: + word_width = 16; + break; + case 2: + word_width = 32; + break; + case 3: + word_width = 64; + break; + case 4: + strcpy(modelchecker, optarg); + break; + case 5: + set_number_iterations(optarg); + break; + case 6: + set_ddv_path(optarg); + break; + case 7: + strcpy(module_init, optarg); + break; + case 8: + strcpy(module_exit, optarg); + break; + case 9: + set_driver_type(optarg); + break; + case 10: + set_model_type(optarg); + break; + case 11: + prepare_only = 1; + break; + case 12: + check_bounds = 1; + break; + case 13: + check_pointer = 1; + break; + case 14: + check_spinlock = 1; + break; + case 15: + check_semaphore = 1; + break; + case 16: + check_mutex = 1; + break; + case 17: + check_io = 1; + break; + case 18: + check_wait_queue = 1; + break; + case 19: + check_tasklet = 1; + break; + case 20: + check_work_queue = 1; + break; + case 21: + check_timer = 1; + break; + case 22: + check_context = 1; + break; + case 23: + tool = CBMC; + break; + case 24: + tool = SATABS; + break; + case 25: + set_unwindset(optarg); + break; + case 26: + set_unwind(optarg); + break; + case 27: + cbmc_slicing = 0; + break; + default: + printf("?? ??\n"); + break; + } + + break; + case 'h': + show_help(); + break; + case '?': + show_help(); + break; + case 'D': + if (nr_macro_registered < NR_MACRO_SUPPORT) { + strcpy(macro[nr_macro_registered], optarg); + nr_macro_registered++; + } else { + fprintf(stderr, "Error: Too many macros in project file!\n"); + exit(-1); + } + break; + default: + printf("?? getopt returned character code 0%o ??\n", cmd); + } + } + + if (optind < argc) { + while (optind < argc) { + if (nr_file_registered < NR_FILE_SUPPORT) { + strcpy(file[nr_file_registered], argv[optind++]); + nr_file_registered++; + } else { + fprintf(stderr, "Error: Too many files in project file!\n"); + exit(-1); + } + } + } +} + +void parse_file() +{ + int ret; + char cmd[1000]; + char tmp[1000]; + FILE *fp; + size_t t = 1000; + char* buffer = (char*)malloc(sizeof(char)*1000); + char **lineptr = &buffer; + + sprintf(cmd, "awk -f %sawk/parse_dd_file %s > .ddv_output_3", ddv_path, file[0]); + system(cmd); + + fp = fopen(".ddv_output_3", "r"); + if (!fp) { + fprintf(stderr, "Error: Could not parse main driver file!\n"); + exit(-1); + } + + while((ret = getline(lineptr, &t, fp)) > 0) { + if (strcmp(*lineptr, "MODULE_INIT\n") == 0) { + getline(lineptr, &t, fp); + + if (strcmp(module_init, "") == 0) { + strcpy(tmp, *lineptr); + strncpy(module_init, &tmp[12], + strlen(tmp) - 12 - ((int)strlen(tmp) - ((int)strchr(tmp, ')') - (int)tmp))); + } + + continue; + } + + if (strcmp(*lineptr, "MODULE_EXIT\n") == 0) { + getline(lineptr, &t, fp); + + if (strcmp(module_exit, "") == 0) { + strcpy(tmp, *lineptr); + strncpy(module_exit, &tmp[12], + strlen(tmp) - 12 - ((int)strlen(tmp) - ((int)strchr(tmp, ')') - (int)tmp))); + } + + continue; + } + + if (strcmp(*lineptr, "INCLUDE\n") == 0) { + getline(lineptr, &t, fp); + + if (driver_type == 0) { + if (strcmp(*lineptr, "\n") == 0) { + driver_type = DRIVER_TYPE_CHAR; + } + + if (strcmp(*lineptr, "\n") == 0) { + driver_type = DRIVER_TYPE_CHAR; + } + + if (strcmp(*lineptr, "\n") == 0) { + driver_type = DRIVER_TYPE_BLOCK; + } + } + + if (strcmp(*lineptr, "\n") == 0) { + driver_type_pci = 1; + } + + continue; + } + + + fclose(fp); + fprintf(stderr, "Error while parsing main driver file!\n"); + exit(-1); + } + free(buffer); + + fclose(fp); +} + +void print_driver_information() +{ + printf("Module initalization function: %s\n", module_init); + printf("Module cleanup function: %s\n", module_exit); + + switch (driver_type) { + case DRIVER_TYPE_CHAR: + printf("Device driver type: char\n"); + break; + + case DRIVER_TYPE_BLOCK: + printf("Device driver type: block\n"); + break; + + case DRIVER_TYPE_NET: + printf("Device driver type: net\n"); + break; + + default: + break; + } + + if (driver_type_pci) { + printf("PCI interface: yes\n"); + } else { + printf("PCI interface: no\n"); + } +} + +int main(int argc, char **argv) +{ + char *tmp; + + tmp = getenv("DDV_PATH"); + if (tmp) { + set_ddv_path(tmp); + } + + parse_args(argc, argv); + + strcpy(output_cc_file, DEFAULT_CC_FILE); + strcpy(output_compile_file, DEFAULT_COMPILE_SCRIPT); + strcpy(output_tool_file, tool==SATABS?DEFAULT_SATABS_SCRIPT:DEFAULT_CBMC_SCRIPT); + + if (strcmp(ddv_path, "") == 0) { + fprintf(stderr, "Error: could not find ddverify path!\n"); + exit(-1); + } + + if (nr_file_registered == 0) { + fprintf(stderr, "Error: no source file given!\n"); + exit(-1); + } + + parse_file(); + + if (driver_type == 0) { + fprintf(stderr, "Error: no driver type set!\n"); + exit(-1); + } + + print_driver_information(); + + write_cc_file(); + write_compile_script(); + write_tool_script(); + + if (!prepare_only) { + tool==SATABS?run_satabs():run_cbmc(); + } + + exit(0); +} diff --git a/ddverify/bin/ddverify.h b/ddverify/bin/ddverify.h new file mode 100644 index 000000000..21ec5303e --- /dev/null +++ b/ddverify/bin/ddverify.h @@ -0,0 +1,155 @@ +/***************************************************************************** + +Copyright (C) 2001-2008, Daniel Kroening, ETH Zurich, + +All rights reserved. Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + + This product includes software developed by Daniel Kroening, + ETH Zurich and Edmund Clarke, Computer Science Department, + Carnegie Mellon University. + + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + 5. We must be notified by email at kroening@cs.cmu.edu after you install + the program for any purpose. + + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITIES AND CONTRIBUTORS `AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. +******************************************************************************/ + + +#ifndef _DDVERIFY_H_ +#define _DDVERIFY_H_ + +#define NR_FILE_SUPPORT 10 +#define NR_MACRO_SUPPORT 20 +#define STR_LENGTH 250 +#define DEFAULT_CC_FILE "__main.c" +#define DEFAULT_SATABS_SCRIPT "ddv_satabs" +#define DEFAULT_CBMC_SCRIPT "ddv_cbmc" +#define DEFAULT_COMPILE_SCRIPT "compile" +#define UNWINDSET_PARAM " --unwindset " + +#define DRIVER_TYPE_CHAR 1 +#define DRIVER_TYPE_BLOCK 2 +#define DRIVER_TYPE_NET 3 + +#define MODEL_TYPE_SEQUENTIAL1 1 +#define MODEL_TYPE_CONCURRENT1 2 +#define MODEL_TYPE_CONCURRENT2 3 + +#define MAX_NUMBER_CLAIMS 5000 + +typedef char string[STR_LENGTH]; + +typedef enum { SATABS, CBMC } tool_choice; + +string src_path = "models/seq1/src/"; +string include_path = "models/seq1/include"; +const char ddv_files[][STR_LENGTH] = {"ddverify/ddverify.c", + "ddverify/cdev.c", + "ddverify/genhd.c", + "ddverify/interrupt.c", + "ddverify/ioctl.c", + "ddverify/pci.c", + "ddverify/tasklet.c", + "ddverify/timer.c", + "linux/pci.c", + "linux/arch/i386/lib/usercopy.c", + "linux/block/genhd.c", + "linux/block/ll_rw_blk.c", + "linux/drivers/char/misc.c", + "linux/drivers/char/tty_io.c", + "linux/fs/char_dev.c", + "linux/kernel/mutex.c", + "linux/kernel/resource.c", + "linux/kernel/sched.c", + "linux/kernel/semaphore.c", + "linux/kernel/softirq.c", + "linux/kernel/spinlock.c", + "linux/kernel/timer.c", + "linux/kernel/wait.c", + "linux/kernel/workqueue.c", + "linux/kernel/irq/manage.c", + "linux/mm/page_alloc.c", + "linux/mm/slab.c", + "linux/mm/vmalloc.c"}; + +const int nr_ddv_files = 28; + +string modelchecker = ""; +string number_iterations = "20"; +char *unwindset = NULL; +unsigned unwindset_str_size = STR_LENGTH; +char *unwind = NULL; + +string output_cc_file = ""; +string output_tool_file = ""; +string output_compile_file = ""; +string file[NR_FILE_SUPPORT]; +string macro[NR_MACRO_SUPPORT]; +string ddv_path = ""; +string module_init = ""; +string module_exit = ""; + +int driver_type = 0; +int driver_type_pci = 0; +int nr_file_registered = 0; +int nr_macro_registered = 0; +int prepare_only = 0; + +int model_type = MODEL_TYPE_SEQUENTIAL1; +int word_width = 32; + +int check_bounds = 0; +int check_pointer = 0; +int check_div_by_zero = 0; +int check_spinlock = 0; +int check_semaphore = 0; +int check_mutex = 0; +int check_io = 0; +int check_wait_queue = 0; +int check_tasklet = 0; +int check_work_queue = 0; +int check_timer = 0; +int check_context = 0; +tool_choice tool = SATABS; +int cbmc_slicing = 1; + +struct claim { + unsigned int number; + char *file; + unsigned int line; + char *text; + char *claim; + float time; +}; + +struct claim claim[MAX_NUMBER_CLAIMS]; +int number_claims; + +#endif diff --git a/ddverify/case_studies/block/cciss/cciss.c b/ddverify/case_studies/block/cciss/cciss.c new file mode 100644 index 000000000..4105c3bf3 --- /dev/null +++ b/ddverify/case_studies/block/cciss/cciss.c @@ -0,0 +1,3533 @@ +/* + * Disk Array driver for HP SA 5xxx and 6xxx Controllers + * Copyright 2000, 2006 Hewlett-Packard Development Company, L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to iss_storagedev@hp.com + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) +#define DRIVER_NAME "HP CISS Driver (v 3.6.10)" +#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,10) + +/* Embedded module documentation macros - see modules.h */ +MODULE_AUTHOR("Hewlett-Packard Company"); +MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.10"); +MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" + " SA6i P600 P800 P400 P400i E200 E200i E500"); +MODULE_LICENSE("GPL"); + +#include "cciss_cmd.h" +#include "cciss.h" +#include + +/* define the PCI info for the cards we can control */ +static const struct pci_device_id cciss_pci_device_id[] = { + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISS, 0x0E11, 0x4070}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4080}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4082}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4083}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x4091}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409A}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409B}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409C}, + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409D}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, 0x103C, 0x3225}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3223}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3234}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3235}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3211}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3212}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3233}, + {0,} +}; + +MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); + +/* board_id = Subsystem Device ID & Vendor ID + * product = Marketing Name for the board + * access = Address of the struct of function pointers + */ +static struct board_type products[] = { + {0x40700E11, "Smart Array 5300", &SA5_access}, + {0x40800E11, "Smart Array 5i", &SA5B_access}, + {0x40820E11, "Smart Array 532", &SA5B_access}, + {0x40830E11, "Smart Array 5312", &SA5B_access}, + {0x409A0E11, "Smart Array 641", &SA5_access}, + {0x409B0E11, "Smart Array 642", &SA5_access}, + {0x409C0E11, "Smart Array 6400", &SA5_access}, + {0x409D0E11, "Smart Array 6400 EM", &SA5_access}, + {0x40910E11, "Smart Array 6i", &SA5_access}, + {0x3225103C, "Smart Array P600", &SA5_access}, + {0x3223103C, "Smart Array P800", &SA5_access}, + {0x3234103C, "Smart Array P400", &SA5_access}, + {0x3235103C, "Smart Array P400i", &SA5_access}, + {0x3211103C, "Smart Array E200i", &SA5_access}, + {0x3212103C, "Smart Array E200", &SA5_access}, + {0x3213103C, "Smart Array E200i", &SA5_access}, + {0x3214103C, "Smart Array E200i", &SA5_access}, + {0x3215103C, "Smart Array E200i", &SA5_access}, + {0x3233103C, "Smart Array E500", &SA5_access}, +}; + +/* How long to wait (in milliseconds) for board to go into simple mode */ +#define MAX_CONFIG_WAIT 30000 +#define MAX_IOCTL_CONFIG_WAIT 1000 + +/*define how many times we will try a command because of bus resets */ +#define MAX_CMD_RETRIES 3 + +#define READ_AHEAD 1024 +#define NR_CMDS 384 /* #commands that can be outstanding */ +#define MAX_CTLR 32 + +/* Originally cciss driver only supports 8 major numbers */ +#define MAX_CTLR_ORIG 8 + +static ctlr_info_t *hba[MAX_CTLR]; + +static void do_cciss_request(request_queue_t *q); +static irqreturn_t do_cciss_intr(int irq, void *dev_id); +static int cciss_open(struct inode *inode, struct file *filep); +static int cciss_release(struct inode *inode, struct file *filep); +static int cciss_ioctl(struct inode *inode, struct file *filep, + unsigned int cmd, unsigned long arg); +static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); + +static int revalidate_allvol(ctlr_info_t *host); +static int cciss_revalidate(struct gendisk *disk); +static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); +static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, + int clear_all); + +static void cciss_read_capacity(int ctlr, int logvol, int withirq, + sector_t *total_size, unsigned int *block_size); +static void cciss_read_capacity_16(int ctlr, int logvol, int withirq, + sector_t *total_size, unsigned int *block_size); +static void cciss_geometry_inquiry(int ctlr, int logvol, + int withirq, sector_t total_size, + unsigned int block_size, InquiryData_struct *inq_buff, + drive_info_struct *drv); +static void cciss_getgeometry(int cntl_num); +static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, + __u32); +static void start_io(ctlr_info_t *h); +static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size, + unsigned int use_unit_num, unsigned int log_unit, + __u8 page_code, unsigned char *scsi3addr, int cmd_type); +static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, + unsigned int use_unit_num, unsigned int log_unit, + __u8 page_code, int cmd_type); + +static void fail_all_cmds(unsigned long ctlr); + +#ifdef CONFIG_PROC_FS +static int cciss_proc_get_info(char *buffer, char **start, off_t offset, + int length, int *eof, void *data); +static void cciss_procinit(int i); +#else +static void cciss_procinit(int i) +{ +} +#endif /* CONFIG_PROC_FS */ + +#ifdef CONFIG_COMPAT +static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); +#endif + +static struct block_device_operations cciss_fops = { + .owner = THIS_MODULE, + .open = cciss_open, + .release = cciss_release, + .ioctl = cciss_ioctl, + .getgeo = cciss_getgeo, +#ifdef CONFIG_COMPAT + .compat_ioctl = cciss_compat_ioctl, +#endif + .revalidate_disk = cciss_revalidate, +}; + +/* + * Enqueuing and dequeuing functions for cmdlists. + */ +static inline void addQ(CommandList_struct **Qptr, CommandList_struct *c) +{ + if (*Qptr == NULL) { + *Qptr = c; + c->next = c->prev = c; + } else { + c->prev = (*Qptr)->prev; + c->next = (*Qptr); + (*Qptr)->prev->next = c; + (*Qptr)->prev = c; + } +} + +static inline CommandList_struct *removeQ(CommandList_struct **Qptr, + CommandList_struct *c) +{ + if (c && c->next != c) { + if (*Qptr == c) + *Qptr = c->next; + c->prev->next = c->next; + c->next->prev = c->prev; + } else { + *Qptr = NULL; + } + return c; +} + +#include "cciss_scsi.c" /* For SCSI tape support */ + +#ifdef CONFIG_PROC_FS + +/* + * Report information about this controller. + */ +#define ENG_GIG 1000000000 +#define ENG_GIG_FACTOR (ENG_GIG/512) +#define RAID_UNKNOWN 6 +static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", + "UNKNOWN" +}; + +static struct proc_dir_entry *proc_cciss; + +static int cciss_proc_get_info(char *buffer, char **start, off_t offset, + int length, int *eof, void *data) +{ + off_t pos = 0; + off_t len = 0; + int size, i, ctlr; + ctlr_info_t *h = (ctlr_info_t *) data; + drive_info_struct *drv; + unsigned long flags; + sector_t vol_sz, vol_sz_frac; + + ctlr = h->ctlr; + + /* prevent displaying bogus info during configuration + * or deconfiguration of a logical volume + */ + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + if (h->busy_configuring) { + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + return -EBUSY; + } + h->busy_configuring = 1; + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + + size = sprintf(buffer, "%s: HP %s Controller\n" + "Board ID: 0x%08lx\n" + "Firmware Version: %c%c%c%c\n" + "IRQ: %d\n" + "Logical drives: %d\n" + "Current Q depth: %d\n" + "Current # commands on controller: %d\n" + "Max Q depth since init: %d\n" + "Max # commands on controller since init: %d\n" + "Max SG entries since init: %d\n\n", + h->devname, + h->product_name, + (unsigned long)h->board_id, + h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], + h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT], + h->num_luns, h->Qdepth, h->commands_outstanding, + h->maxQsinceinit, h->max_outstanding, h->maxSG); + + pos += size; + len += size; + cciss_proc_tape_report(ctlr, buffer, &pos, &len); + for (i = 0; i <= h->highest_lun; i++) { + + drv = &h->drv[i]; + if (drv->heads == 0) + continue; + + vol_sz = drv->nr_blocks; + vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR); + vol_sz_frac *= 100; + sector_div(vol_sz_frac, ENG_GIG_FACTOR); + + if (drv->raid_level > 5) + drv->raid_level = RAID_UNKNOWN; + size = sprintf(buffer + len, "cciss/c%dd%d:" + "\t%4u.%02uGB\tRAID %s\n", + ctlr, i, (int)vol_sz, (int)vol_sz_frac, + raid_label[drv->raid_level]); + pos += size; + len += size; + } + + *eof = 1; + *start = buffer + offset; + len -= offset; + if (len > length) + len = length; + h->busy_configuring = 0; + return len; +} + +static int +cciss_proc_write(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + unsigned char cmd[80]; + int len; +#ifdef CONFIG_CISS_SCSI_TAPE + ctlr_info_t *h = (ctlr_info_t *) data; + int rc; +#endif + + if (count > sizeof(cmd) - 1) + return -EINVAL; + if (copy_from_user(cmd, buffer, count)) + return -EFAULT; + cmd[count] = '\0'; + len = strlen(cmd); // above 3 lines ensure safety + if (len && cmd[len - 1] == '\n') + cmd[--len] = '\0'; +# ifdef CONFIG_CISS_SCSI_TAPE + if (strcmp("engage scsi", cmd) == 0) { + rc = cciss_engage_scsi(h->ctlr); + if (rc != 0) + return -rc; + return count; + } + /* might be nice to have "disengage" too, but it's not + safely possible. (only 1 module use count, lock issues.) */ +# endif + return -EINVAL; +} + +/* + * Get us a file in /proc/cciss that says something about each controller. + * Create /proc/cciss if it doesn't exist yet. + */ +static void __devinit cciss_procinit(int i) +{ + struct proc_dir_entry *pde; + + if (proc_cciss == NULL) { + proc_cciss = proc_mkdir("cciss", proc_root_driver); + if (!proc_cciss) + return; + } + + pde = create_proc_read_entry(hba[i]->devname, + S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH, + proc_cciss, cciss_proc_get_info, hba[i]); + pde->write_proc = cciss_proc_write; +} +#endif /* CONFIG_PROC_FS */ + +/* + * For operations that cannot sleep, a command block is allocated at init, + * and managed by cmd_alloc() and cmd_free() using a simple bitmap to track + * which ones are free or in use. For operations that can wait for kmalloc + * to possible sleep, this routine can be called with get_from_pool set to 0. + * cmd_free() MUST be called with a got_from_pool set to 0 if cmd_alloc was. + */ +static CommandList_struct *cmd_alloc(ctlr_info_t *h, int get_from_pool) +{ + CommandList_struct *c; + int i; + u64bit temp64; + dma_addr_t cmd_dma_handle, err_dma_handle; + + if (!get_from_pool) { + c = (CommandList_struct *) pci_alloc_consistent(h->pdev, + sizeof(CommandList_struct), &cmd_dma_handle); + if (c == NULL) + return NULL; + memset(c, 0, sizeof(CommandList_struct)); + + c->cmdindex = -1; + + c->err_info = (ErrorInfo_struct *) + pci_alloc_consistent(h->pdev, sizeof(ErrorInfo_struct), + &err_dma_handle); + + if (c->err_info == NULL) { + pci_free_consistent(h->pdev, + sizeof(CommandList_struct), c, cmd_dma_handle); + return NULL; + } + memset(c->err_info, 0, sizeof(ErrorInfo_struct)); + } else { /* get it out of the controllers pool */ + + do { + i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); + if (i == NR_CMDS) + return NULL; + } while (test_and_set_bit + (i & (BITS_PER_LONG - 1), + h->cmd_pool_bits + (i / BITS_PER_LONG)) != 0); +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "cciss: using command buffer %d\n", i); +#endif + c = h->cmd_pool + i; + memset(c, 0, sizeof(CommandList_struct)); + cmd_dma_handle = h->cmd_pool_dhandle + + i * sizeof(CommandList_struct); + c->err_info = h->errinfo_pool + i; + memset(c->err_info, 0, sizeof(ErrorInfo_struct)); + err_dma_handle = h->errinfo_pool_dhandle + + i * sizeof(ErrorInfo_struct); + h->nr_allocs++; + + c->cmdindex = i; + } + + c->busaddr = (__u32) cmd_dma_handle; + temp64.val = (__u64) err_dma_handle; + c->ErrDesc.Addr.lower = temp64.val32.lower; + c->ErrDesc.Addr.upper = temp64.val32.upper; + c->ErrDesc.Len = sizeof(ErrorInfo_struct); + + c->ctlr = h->ctlr; + return c; +} + +/* + * Frees a command block that was previously allocated with cmd_alloc(). + */ +static void cmd_free(ctlr_info_t *h, CommandList_struct *c, int got_from_pool) +{ + int i; + u64bit temp64; + + if (!got_from_pool) { + temp64.val32.lower = c->ErrDesc.Addr.lower; + temp64.val32.upper = c->ErrDesc.Addr.upper; + pci_free_consistent(h->pdev, sizeof(ErrorInfo_struct), + c->err_info, (dma_addr_t) temp64.val); + pci_free_consistent(h->pdev, sizeof(CommandList_struct), + c, (dma_addr_t) c->busaddr); + } else { + i = c - h->cmd_pool; + clear_bit(i & (BITS_PER_LONG - 1), + h->cmd_pool_bits + (i / BITS_PER_LONG)); + h->nr_frees++; + } +} + +static inline ctlr_info_t *get_host(struct gendisk *disk) +{ + return disk->queue->queuedata; +} + +static inline drive_info_struct *get_drv(struct gendisk *disk) +{ + return disk->private_data; +} + +/* + * Open. Make sure the device is really there. + */ +static int cciss_open(struct inode *inode, struct file *filep) +{ + ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); +#endif /* CCISS_DEBUG */ + + if (host->busy_initializing || drv->busy_configuring) + return -EBUSY; + /* + * Root is allowed to open raw volume zero even if it's not configured + * so array config can still work. Root is also allowed to open any + * volume that has a LUN ID, so it can issue IOCTL to reread the + * disk information. I don't think I really like this + * but I'm already using way to many device nodes to claim another one + * for "raw controller". + */ + if (drv->nr_blocks == 0) { + if (iminor(inode) != 0) { /* not node 0? */ + /* if not node 0 make sure it is a partition = 0 */ + if (iminor(inode) & 0x0f) { + return -ENXIO; + /* if it is, make sure we have a LUN ID */ + } else if (drv->LunID == 0) { + return -ENXIO; + } + } + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + } + drv->usage_count++; + host->usage_count++; + return 0; +} + +/* + * Close. Sync first. + */ +static int cciss_release(struct inode *inode, struct file *filep) +{ + ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "cciss_release %s\n", + inode->i_bdev->bd_disk->disk_name); +#endif /* CCISS_DEBUG */ + + drv->usage_count--; + host->usage_count--; + return 0; +} + +#ifdef CONFIG_COMPAT + +static int do_ioctl(struct file *f, unsigned cmd, unsigned long arg) +{ + int ret; + lock_kernel(); + ret = cciss_ioctl(f->f_dentry->d_inode, f, cmd, arg); + unlock_kernel(); + return ret; +} + +static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, + unsigned long arg); +static int cciss_ioctl32_big_passthru(struct file *f, unsigned cmd, + unsigned long arg); + +static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) +{ + switch (cmd) { + case CCISS_GETPCIINFO: + case CCISS_GETINTINFO: + case CCISS_SETINTINFO: + case CCISS_GETNODENAME: + case CCISS_SETNODENAME: + case CCISS_GETHEARTBEAT: + case CCISS_GETBUSTYPES: + case CCISS_GETFIRMVER: + case CCISS_GETDRIVVER: + case CCISS_REVALIDVOLS: + case CCISS_DEREGDISK: + case CCISS_REGNEWDISK: + case CCISS_REGNEWD: + case CCISS_RESCANDISK: + case CCISS_GETLUNINFO: + return do_ioctl(f, cmd, arg); + + case CCISS_PASSTHRU32: + return cciss_ioctl32_passthru(f, cmd, arg); + case CCISS_BIG_PASSTHRU32: + return cciss_ioctl32_big_passthru(f, cmd, arg); + + default: + return -ENOIOCTLCMD; + } +} + +static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, + unsigned long arg) +{ + IOCTL32_Command_struct __user *arg32 = + (IOCTL32_Command_struct __user *) arg; + IOCTL_Command_struct arg64; + IOCTL_Command_struct __user *p = compat_alloc_user_space(sizeof(arg64)); + int err; + u32 cp; + + err = 0; + err |= + copy_from_user(&arg64.LUN_info, &arg32->LUN_info, + sizeof(arg64.LUN_info)); + err |= + copy_from_user(&arg64.Request, &arg32->Request, + sizeof(arg64.Request)); + err |= + copy_from_user(&arg64.error_info, &arg32->error_info, + sizeof(arg64.error_info)); + err |= get_user(arg64.buf_size, &arg32->buf_size); + err |= get_user(cp, &arg32->buf); + arg64.buf = compat_ptr(cp); + err |= copy_to_user(p, &arg64, sizeof(arg64)); + + if (err) + return -EFAULT; + + err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long)p); + if (err) + return err; + err |= + copy_in_user(&arg32->error_info, &p->error_info, + sizeof(arg32->error_info)); + if (err) + return -EFAULT; + return err; +} + +static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, + unsigned long arg) +{ + BIG_IOCTL32_Command_struct __user *arg32 = + (BIG_IOCTL32_Command_struct __user *) arg; + BIG_IOCTL_Command_struct arg64; + BIG_IOCTL_Command_struct __user *p = + compat_alloc_user_space(sizeof(arg64)); + int err; + u32 cp; + + err = 0; + err |= + copy_from_user(&arg64.LUN_info, &arg32->LUN_info, + sizeof(arg64.LUN_info)); + err |= + copy_from_user(&arg64.Request, &arg32->Request, + sizeof(arg64.Request)); + err |= + copy_from_user(&arg64.error_info, &arg32->error_info, + sizeof(arg64.error_info)); + err |= get_user(arg64.buf_size, &arg32->buf_size); + err |= get_user(arg64.malloc_size, &arg32->malloc_size); + err |= get_user(cp, &arg32->buf); + arg64.buf = compat_ptr(cp); + err |= copy_to_user(p, &arg64, sizeof(arg64)); + + if (err) + return -EFAULT; + + err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long)p); + if (err) + return err; + err |= + copy_in_user(&arg32->error_info, &p->error_info, + sizeof(arg32->error_info)); + if (err) + return -EFAULT; + return err; +} +#endif + +static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo) +{ + drive_info_struct *drv = get_drv(bdev->bd_disk); + + if (!drv->cylinders) + return -ENXIO; + + geo->heads = drv->heads; + geo->sectors = drv->sectors; + geo->cylinders = drv->cylinders; + return 0; +} + +/* + * ioctl + */ +static int cciss_ioctl(struct inode *inode, struct file *filep, + unsigned int cmd, unsigned long arg) +{ + struct block_device *bdev = inode->i_bdev; + struct gendisk *disk = bdev->bd_disk; + ctlr_info_t *host = get_host(disk); + drive_info_struct *drv = get_drv(disk); + int ctlr = host->ctlr; + void __user *argp = (void __user *)arg; + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "cciss_ioctl: Called with cmd=%x %lx\n", cmd, arg); +#endif /* CCISS_DEBUG */ + + switch (cmd) { + case CCISS_GETPCIINFO: + { + cciss_pci_info_struct pciinfo; + + if (!arg) + return -EINVAL; + pciinfo.domain = pci_domain_nr(host->pdev->bus); + pciinfo.bus = host->pdev->bus->number; + pciinfo.dev_fn = host->pdev->devfn; + pciinfo.board_id = host->board_id; + if (copy_to_user + (argp, &pciinfo, sizeof(cciss_pci_info_struct))) + return -EFAULT; + return 0; + } + case CCISS_GETINTINFO: + { + cciss_coalint_struct intinfo; + if (!arg) + return -EINVAL; + intinfo.delay = + readl(&host->cfgtable->HostWrite.CoalIntDelay); + intinfo.count = + readl(&host->cfgtable->HostWrite.CoalIntCount); + if (copy_to_user + (argp, &intinfo, sizeof(cciss_coalint_struct))) + return -EFAULT; + return 0; + } + case CCISS_SETINTINFO: + { + cciss_coalint_struct intinfo; + unsigned long flags; + int i; + + if (!arg) + return -EINVAL; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (copy_from_user + (&intinfo, argp, sizeof(cciss_coalint_struct))) + return -EFAULT; + if ((intinfo.delay == 0) && (intinfo.count == 0)) + { +// printk("cciss_ioctl: delay and count cannot be 0\n"); + return -EINVAL; + } + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + /* Update the field, and then ring the doorbell */ + writel(intinfo.delay, + &(host->cfgtable->HostWrite.CoalIntDelay)); + writel(intinfo.count, + &(host->cfgtable->HostWrite.CoalIntCount)); + writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); + + for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { + if (!(readl(host->vaddr + SA5_DOORBELL) + & CFGTBL_ChangeReq)) + break; + /* delay and try again */ + udelay(1000); + } + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + if (i >= MAX_IOCTL_CONFIG_WAIT) + return -EAGAIN; + return 0; + } + case CCISS_GETNODENAME: + { + NodeName_type NodeName; + int i; + + if (!arg) + return -EINVAL; + for (i = 0; i < 16; i++) + NodeName[i] = + readb(&host->cfgtable->ServerName[i]); + if (copy_to_user(argp, NodeName, sizeof(NodeName_type))) + return -EFAULT; + return 0; + } + case CCISS_SETNODENAME: + { + NodeName_type NodeName; + unsigned long flags; + int i; + + if (!arg) + return -EINVAL; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (copy_from_user + (NodeName, argp, sizeof(NodeName_type))) + return -EFAULT; + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + + /* Update the field, and then ring the doorbell */ + for (i = 0; i < 16; i++) + writeb(NodeName[i], + &host->cfgtable->ServerName[i]); + + writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); + + for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { + if (!(readl(host->vaddr + SA5_DOORBELL) + & CFGTBL_ChangeReq)) + break; + /* delay and try again */ + udelay(1000); + } + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + if (i >= MAX_IOCTL_CONFIG_WAIT) + return -EAGAIN; + return 0; + } + + case CCISS_GETHEARTBEAT: + { + Heartbeat_type heartbeat; + + if (!arg) + return -EINVAL; + heartbeat = readl(&host->cfgtable->HeartBeat); + if (copy_to_user + (argp, &heartbeat, sizeof(Heartbeat_type))) + return -EFAULT; + return 0; + } + case CCISS_GETBUSTYPES: + { + BusTypes_type BusTypes; + + if (!arg) + return -EINVAL; + BusTypes = readl(&host->cfgtable->BusTypes); + if (copy_to_user + (argp, &BusTypes, sizeof(BusTypes_type))) + return -EFAULT; + return 0; + } + case CCISS_GETFIRMVER: + { + FirmwareVer_type firmware; + + if (!arg) + return -EINVAL; + memcpy(firmware, host->firm_ver, 4); + + if (copy_to_user + (argp, firmware, sizeof(FirmwareVer_type))) + return -EFAULT; + return 0; + } + case CCISS_GETDRIVVER: + { + DriverVer_type DriverVer = DRIVER_VERSION; + + if (!arg) + return -EINVAL; + + if (copy_to_user + (argp, &DriverVer, sizeof(DriverVer_type))) + return -EFAULT; + return 0; + } + + case CCISS_REVALIDVOLS: + if (bdev != bdev->bd_contains || drv != host->drv) + return -ENXIO; + return revalidate_allvol(host); + + case CCISS_GETLUNINFO:{ + LogvolInfo_struct luninfo; + + luninfo.LunID = drv->LunID; + luninfo.num_opens = drv->usage_count; + luninfo.num_parts = 0; + if (copy_to_user(argp, &luninfo, + sizeof(LogvolInfo_struct))) + return -EFAULT; + return 0; + } + case CCISS_DEREGDISK: + return rebuild_lun_table(host, disk); + + case CCISS_REGNEWD: + return rebuild_lun_table(host, NULL); + + case CCISS_PASSTHRU: + { + IOCTL_Command_struct iocommand; + CommandList_struct *c; + char *buff = NULL; + u64bit temp64; + unsigned long flags; + DECLARE_COMPLETION_ONSTACK(wait); + + if (!arg) + return -EINVAL; + + if (!capable(CAP_SYS_RAWIO)) + return -EPERM; + + if (copy_from_user + (&iocommand, argp, sizeof(IOCTL_Command_struct))) + return -EFAULT; + if ((iocommand.buf_size < 1) && + (iocommand.Request.Type.Direction != XFER_NONE)) { + return -EINVAL; + } +#if 0 /* 'buf_size' member is 16-bits, and always smaller than kmalloc limit */ + /* Check kmalloc limits */ + if (iocommand.buf_size > 128000) + return -EINVAL; +#endif + if (iocommand.buf_size > 0) { + buff = kmalloc(iocommand.buf_size, GFP_KERNEL); + if (buff == NULL) + return -EFAULT; + } + if (iocommand.Request.Type.Direction == XFER_WRITE) { + /* Copy the data into the buffer we created */ + if (copy_from_user + (buff, iocommand.buf, iocommand.buf_size)) { + kfree(buff); + return -EFAULT; + } + } else { + memset(buff, 0, iocommand.buf_size); + } + if ((c = cmd_alloc(host, 0)) == NULL) { + kfree(buff); + return -ENOMEM; + } + // Fill in the command type + c->cmd_type = CMD_IOCTL_PEND; + // Fill in Command Header + c->Header.ReplyQueue = 0; // unused in simple mode + if (iocommand.buf_size > 0) // buffer to fill + { + c->Header.SGList = 1; + c->Header.SGTotal = 1; + } else // no buffers to fill + { + c->Header.SGList = 0; + c->Header.SGTotal = 0; + } + c->Header.LUN = iocommand.LUN_info; + c->Header.Tag.lower = c->busaddr; // use the kernel address the cmd block for tag + + // Fill in Request block + c->Request = iocommand.Request; + + // Fill in the scatter gather information + if (iocommand.buf_size > 0) { + temp64.val = pci_map_single(host->pdev, buff, + iocommand.buf_size, + PCI_DMA_BIDIRECTIONAL); + c->SG[0].Addr.lower = temp64.val32.lower; + c->SG[0].Addr.upper = temp64.val32.upper; + c->SG[0].Len = iocommand.buf_size; + c->SG[0].Ext = 0; // we are not chaining + } + c->waiting = &wait; + + /* Put the request on the tail of the request queue */ + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + addQ(&host->reqQ, c); + host->Qdepth++; + start_io(host); + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + + wait_for_completion(&wait); + + /* unlock the buffers from DMA */ + temp64.val32.lower = c->SG[0].Addr.lower; + temp64.val32.upper = c->SG[0].Addr.upper; + pci_unmap_single(host->pdev, (dma_addr_t) temp64.val, + iocommand.buf_size, + PCI_DMA_BIDIRECTIONAL); + + /* Copy the error information out */ + iocommand.error_info = *(c->err_info); + if (copy_to_user + (argp, &iocommand, sizeof(IOCTL_Command_struct))) { + kfree(buff); + cmd_free(host, c, 0); + return -EFAULT; + } + + if (iocommand.Request.Type.Direction == XFER_READ) { + /* Copy the data out of the buffer we created */ + if (copy_to_user + (iocommand.buf, buff, iocommand.buf_size)) { + kfree(buff); + cmd_free(host, c, 0); + return -EFAULT; + } + } + kfree(buff); + cmd_free(host, c, 0); + return 0; + } + case CCISS_BIG_PASSTHRU:{ + BIG_IOCTL_Command_struct *ioc; + CommandList_struct *c; + unsigned char **buff = NULL; + int *buff_size = NULL; + u64bit temp64; + unsigned long flags; + BYTE sg_used = 0; + int status = 0; + int i; + DECLARE_COMPLETION_ONSTACK(wait); + __u32 left; + __u32 sz; + BYTE __user *data_ptr; + + if (!arg) + return -EINVAL; + if (!capable(CAP_SYS_RAWIO)) + return -EPERM; + ioc = (BIG_IOCTL_Command_struct *) + kmalloc(sizeof(*ioc), GFP_KERNEL); + if (!ioc) { + status = -ENOMEM; + goto cleanup1; + } + if (copy_from_user(ioc, argp, sizeof(*ioc))) { + status = -EFAULT; + goto cleanup1; + } + if ((ioc->buf_size < 1) && + (ioc->Request.Type.Direction != XFER_NONE)) { + status = -EINVAL; + goto cleanup1; + } + /* Check kmalloc limits using all SGs */ + if (ioc->malloc_size > MAX_KMALLOC_SIZE) { + status = -EINVAL; + goto cleanup1; + } + if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) { + status = -EINVAL; + goto cleanup1; + } + buff = + kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL); + if (!buff) { + status = -ENOMEM; + goto cleanup1; + } + buff_size = (int *)kmalloc(MAXSGENTRIES * sizeof(int), + GFP_KERNEL); + if (!buff_size) { + status = -ENOMEM; + goto cleanup1; + } + left = ioc->buf_size; + data_ptr = ioc->buf; + while (left) { + sz = (left > + ioc->malloc_size) ? ioc-> + malloc_size : left; + buff_size[sg_used] = sz; + buff[sg_used] = kmalloc(sz, GFP_KERNEL); + if (buff[sg_used] == NULL) { + status = -ENOMEM; + goto cleanup1; + } + if (ioc->Request.Type.Direction == XFER_WRITE) { + if (copy_from_user + (buff[sg_used], data_ptr, sz)) { + status = -ENOMEM; + goto cleanup1; + } + } else { + memset(buff[sg_used], 0, sz); + } + left -= sz; + data_ptr += sz; + sg_used++; + } + if ((c = cmd_alloc(host, 0)) == NULL) { + status = -ENOMEM; + goto cleanup1; + } + c->cmd_type = CMD_IOCTL_PEND; + c->Header.ReplyQueue = 0; + + if (ioc->buf_size > 0) { + c->Header.SGList = sg_used; + c->Header.SGTotal = sg_used; + } else { + c->Header.SGList = 0; + c->Header.SGTotal = 0; + } + c->Header.LUN = ioc->LUN_info; + c->Header.Tag.lower = c->busaddr; + + c->Request = ioc->Request; + if (ioc->buf_size > 0) { + int i; + for (i = 0; i < sg_used; i++) { + temp64.val = + pci_map_single(host->pdev, buff[i], + buff_size[i], + PCI_DMA_BIDIRECTIONAL); + c->SG[i].Addr.lower = + temp64.val32.lower; + c->SG[i].Addr.upper = + temp64.val32.upper; + c->SG[i].Len = buff_size[i]; + c->SG[i].Ext = 0; /* we are not chaining */ + } + } + c->waiting = &wait; + /* Put the request on the tail of the request queue */ + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + addQ(&host->reqQ, c); + host->Qdepth++; + start_io(host); + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + wait_for_completion(&wait); + /* unlock the buffers from DMA */ + for (i = 0; i < sg_used; i++) { + temp64.val32.lower = c->SG[i].Addr.lower; + temp64.val32.upper = c->SG[i].Addr.upper; + pci_unmap_single(host->pdev, + (dma_addr_t) temp64.val, buff_size[i], + PCI_DMA_BIDIRECTIONAL); + } + /* Copy the error information out */ + ioc->error_info = *(c->err_info); + if (copy_to_user(argp, ioc, sizeof(*ioc))) { + cmd_free(host, c, 0); + status = -EFAULT; + goto cleanup1; + } + if (ioc->Request.Type.Direction == XFER_READ) { + /* Copy the data out of the buffer we created */ + BYTE __user *ptr = ioc->buf; + for (i = 0; i < sg_used; i++) { + if (copy_to_user + (ptr, buff[i], buff_size[i])) { + cmd_free(host, c, 0); + status = -EFAULT; + goto cleanup1; + } + ptr += buff_size[i]; + } + } + cmd_free(host, c, 0); + status = 0; + cleanup1: + if (buff) { + for (i = 0; i < sg_used; i++) + kfree(buff[i]); + kfree(buff); + } + kfree(buff_size); + kfree(ioc); + return status; + } + default: + return -ENOTTY; + } +} + +/* + * revalidate_allvol is for online array config utilities. After a + * utility reconfigures the drives in the array, it can use this function + * (through an ioctl) to make the driver zap any previous disk structs for + * that controller and get new ones. + * + * Right now I'm using the getgeometry() function to do this, but this + * function should probably be finer grained and allow you to revalidate one + * particular logical volume (instead of all of them on a particular + * controller). + */ +static int revalidate_allvol(ctlr_info_t *host) +{ + int ctlr = host->ctlr, i; + unsigned long flags; + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + if (host->usage_count > 1) { + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + printk(KERN_WARNING "cciss: Device busy for volume" + " revalidation (usage=%d)\n", host->usage_count); + return -EBUSY; + } + host->usage_count++; + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + + for (i = 0; i < NWD; i++) { + struct gendisk *disk = host->gendisk[i]; + if (disk) { + request_queue_t *q = disk->queue; + + if (disk->flags & GENHD_FL_UP) + del_gendisk(disk); + if (q) + blk_cleanup_queue(q); + } + } + + /* + * Set the partition and block size structures for all volumes + * on this controller to zero. We will reread all of this data + */ + memset(host->drv, 0, sizeof(drive_info_struct) + * CISS_MAX_LUN); + /* + * Tell the array controller not to give us any interrupts while + * we check the new geometry. Then turn interrupts back on when + * we're done. + */ + host->access.set_intr_mask(host, CCISS_INTR_OFF); + cciss_getgeometry(ctlr); + host->access.set_intr_mask(host, CCISS_INTR_ON); + + /* Loop through each real device */ + for (i = 0; i < NWD; i++) { + struct gendisk *disk = host->gendisk[i]; + drive_info_struct *drv = &(host->drv[i]); + /* we must register the controller even if no disks exist */ + /* this is for the online array utilities */ + if (!drv->heads && i) + continue; + blk_queue_hardsect_size(drv->queue, drv->block_size); + set_capacity(disk, drv->nr_blocks); + add_disk(disk); + } + host->usage_count--; + return 0; +} + +static inline void complete_buffers(struct bio *bio, int status) +{ + while (bio) { + struct bio *xbh = bio->bi_next; + int nr_sectors = bio_sectors(bio); + + bio->bi_next = NULL; + bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO); + bio = xbh; + } +} + +static void cciss_check_queues(ctlr_info_t *h) +{ + int start_queue = h->next_to_run; + int i; + + /* check to see if we have maxed out the number of commands that can + * be placed on the queue. If so then exit. We do this check here + * in case the interrupt we serviced was from an ioctl and did not + * free any new commands. + */ + if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) + return; + + /* We have room on the queue for more commands. Now we need to queue + * them up. We will also keep track of the next queue to run so + * that every queue gets a chance to be started first. + */ + for (i = 0; i < h->highest_lun + 1; i++) { + int curr_queue = (start_queue + i) % (h->highest_lun + 1); + /* make sure the disk has been added and the drive is real + * because this can be called from the middle of init_one. + */ + if (!(h->drv[curr_queue].queue) || !(h->drv[curr_queue].heads)) + continue; + blk_start_queue(h->gendisk[curr_queue]->queue); + + /* check to see if we have maxed out the number of commands + * that can be placed on the queue. + */ + if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) { + if (curr_queue == start_queue) { + h->next_to_run = + (start_queue + 1) % (h->highest_lun + 1); + break; + } else { + h->next_to_run = curr_queue; + break; + } + } else { + curr_queue = (curr_queue + 1) % (h->highest_lun + 1); + } + } +} + +static void cciss_softirq_done(struct request *rq) +{ + CommandList_struct *cmd = rq->completion_data; + ctlr_info_t *h = hba[cmd->ctlr]; + unsigned long flags; + u64bit temp64; + int i, ddir; + + if (cmd->Request.Type.Direction == XFER_READ) + ddir = PCI_DMA_FROMDEVICE; + else + ddir = PCI_DMA_TODEVICE; + + /* command did not need to be retried */ + /* unmap the DMA mapping for all the scatter gather elements */ + for (i = 0; i < cmd->Header.SGList; i++) { + temp64.val32.lower = cmd->SG[i].Addr.lower; + temp64.val32.upper = cmd->SG[i].Addr.upper; + pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); + } + + complete_buffers(rq->bio, rq->errors); + + if (blk_fs_request(rq)) { + const int rw = rq_data_dir(rq); + + disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors); + } + +#ifdef CCISS_DEBUG + printk("Done with %p\n", rq); +#endif /* CCISS_DEBUG */ + + add_disk_randomness(rq->rq_disk); + spin_lock_irqsave(&h->lock, flags); + end_that_request_last(rq, rq->errors); + cmd_free(h, cmd, 1); + cciss_check_queues(h); + spin_unlock_irqrestore(&h->lock, flags); +} + +/* This function will check the usage_count of the drive to be updated/added. + * If the usage_count is zero then the drive information will be updated and + * the disk will be re-registered with the kernel. If not then it will be + * left alone for the next reboot. The exception to this is disk 0 which + * will always be left registered with the kernel since it is also the + * controller node. Any changes to disk 0 will show up on the next + * reboot. + */ +static void cciss_update_drive_info(int ctlr, int drv_index) +{ + ctlr_info_t *h = hba[ctlr]; + struct gendisk *disk; + InquiryData_struct *inq_buff = NULL; + unsigned int block_size; + sector_t total_size; + unsigned long flags = 0; + int ret = 0; + + /* if the disk already exists then deregister it before proceeding */ + if (h->drv[drv_index].raid_level != -1) { + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); + h->drv[drv_index].busy_configuring = 1; + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + ret = deregister_disk(h->gendisk[drv_index], + &h->drv[drv_index], 0); + h->drv[drv_index].busy_configuring = 0; + } + + /* If the disk is in use return */ + if (ret) + return; + + /* Get information about the disk and modify the driver structure */ + inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); + if (inq_buff == NULL) + goto mem_msg; + + cciss_read_capacity(ctlr, drv_index, 1, + &total_size, &block_size); + + /* total size = last LBA + 1 */ + /* FFFFFFFF + 1 = 0, cannot have a logical volume of size 0 */ + /* so we assume this volume this must be >2TB in size */ + if (total_size == (__u32) 0) { + cciss_read_capacity_16(ctlr, drv_index, 1, + &total_size, &block_size); + h->cciss_read = CCISS_READ_16; + h->cciss_write = CCISS_WRITE_16; + } else { + h->cciss_read = CCISS_READ_10; + h->cciss_write = CCISS_WRITE_10; + } + cciss_geometry_inquiry(ctlr, drv_index, 1, total_size, block_size, + inq_buff, &h->drv[drv_index]); + + ++h->num_luns; + disk = h->gendisk[drv_index]; + set_capacity(disk, h->drv[drv_index].nr_blocks); + + /* if it's the controller it's already added */ + if (drv_index) { + disk->queue = blk_init_queue(do_cciss_request, &h->lock); + + /* Set up queue information */ + disk->queue->backing_dev_info.ra_pages = READ_AHEAD; + blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask); + + /* This is a hardware imposed limit. */ + blk_queue_max_hw_segments(disk->queue, MAXSGENTRIES); + + /* This is a limit in the driver and could be eliminated. */ + blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES); + + blk_queue_max_sectors(disk->queue, 512); + + blk_queue_softirq_done(disk->queue, cciss_softirq_done); + + disk->queue->queuedata = hba[ctlr]; + + blk_queue_hardsect_size(disk->queue, + hba[ctlr]->drv[drv_index].block_size); + + h->drv[drv_index].queue = disk->queue; + add_disk(disk); + } + + freeret: + kfree(inq_buff); + return; + mem_msg: + printk(KERN_ERR "cciss: out of memory\n"); + goto freeret; +} + +/* This function will find the first index of the controllers drive array + * that has a -1 for the raid_level and will return that index. This is + * where new drives will be added. If the index to be returned is greater + * than the highest_lun index for the controller then highest_lun is set + * to this new index. If there are no available indexes then -1 is returned. + */ +static int cciss_find_free_drive_index(int ctlr) +{ + int i; + + for (i = 0; i < CISS_MAX_LUN; i++) { + if (hba[ctlr]->drv[i].raid_level == -1) { + if (i > hba[ctlr]->highest_lun) + hba[ctlr]->highest_lun = i; + return i; + } + } + return -1; +} + +/* This function will add and remove logical drives from the Logical + * drive array of the controller and maintain persistency of ordering + * so that mount points are preserved until the next reboot. This allows + * for the removal of logical drives in the middle of the drive array + * without a re-ordering of those drives. + * INPUT + * h = The controller to perform the operations on + * del_disk = The disk to remove if specified. If the value given + * is NULL then no disk is removed. + */ +static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) +{ + int ctlr = h->ctlr; + int num_luns; + ReportLunData_struct *ld_buff = NULL; + drive_info_struct *drv = NULL; + int return_code; + int listlength = 0; + int i; + int drv_found; + int drv_index = 0; + __u32 lunid = 0; + unsigned long flags; + + /* Set busy_configuring flag for this operation */ + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); + if (h->num_luns >= CISS_MAX_LUN) { + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return -EINVAL; + } + + if (h->busy_configuring) { + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return -EBUSY; + } + h->busy_configuring = 1; + + /* if del_disk is NULL then we are being called to add a new disk + * and update the logical drive table. If it is not NULL then + * we will check if the disk is in use or not. + */ + if (del_disk != NULL) { + drv = get_drv(del_disk); + drv->busy_configuring = 1; + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return_code = deregister_disk(del_disk, drv, 1); + drv->busy_configuring = 0; + h->busy_configuring = 0; + return return_code; + } else { + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + if (!capable(CAP_SYS_RAWIO)) + return -EPERM; + + ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); + if (ld_buff == NULL) + goto mem_msg; + + return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff, + sizeof(ReportLunData_struct), 0, + 0, 0, TYPE_CMD); + + if (return_code == IO_OK) { + listlength |= + (0xff & (unsigned int)(ld_buff->LUNListLength[0])) + << 24; + listlength |= + (0xff & (unsigned int)(ld_buff->LUNListLength[1])) + << 16; + listlength |= + (0xff & (unsigned int)(ld_buff->LUNListLength[2])) + << 8; + listlength |= + 0xff & (unsigned int)(ld_buff->LUNListLength[3]); + } else { /* reading number of logical volumes failed */ + printk(KERN_WARNING "cciss: report logical volume" + " command failed\n"); + listlength = 0; + goto freeret; + } + + num_luns = listlength / 8; /* 8 bytes per entry */ + if (num_luns > CISS_MAX_LUN) { + num_luns = CISS_MAX_LUN; + printk(KERN_WARNING "cciss: more luns configured" + " on controller than can be handled by" + " this driver.\n"); + } + + /* Compare controller drive array to drivers drive array. + * Check for updates in the drive information and any new drives + * on the controller. + */ + for (i = 0; i < num_luns; i++) { + int j; + + drv_found = 0; + + lunid = (0xff & + (unsigned int)(ld_buff->LUN[i][3])) << 24; + lunid |= (0xff & + (unsigned int)(ld_buff->LUN[i][2])) << 16; + lunid |= (0xff & + (unsigned int)(ld_buff->LUN[i][1])) << 8; + lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); + + /* Find if the LUN is already in the drive array + * of the controller. If so then update its info + * if not is use. If it does not exist then find + * the first free index and add it. + */ + for (j = 0; j <= h->highest_lun; j++) { + if (h->drv[j].LunID == lunid) { + drv_index = j; + drv_found = 1; + } + } + + /* check if the drive was found already in the array */ + if (!drv_found) { + drv_index = cciss_find_free_drive_index(ctlr); + if (drv_index == -1) + goto freeret; + + } + h->drv[drv_index].LunID = lunid; + cciss_update_drive_info(ctlr, drv_index); + } /* end for */ + } /* end else */ + + freeret: + kfree(ld_buff); + h->busy_configuring = 0; + /* We return -1 here to tell the ACU that we have registered/updated + * all of the drives that we can and to keep it from calling us + * additional times. + */ + return -1; + mem_msg: + printk(KERN_ERR "cciss: out of memory\n"); + goto freeret; +} + +/* This function will deregister the disk and it's queue from the + * kernel. It must be called with the controller lock held and the + * drv structures busy_configuring flag set. It's parameters are: + * + * disk = This is the disk to be deregistered + * drv = This is the drive_info_struct associated with the disk to be + * deregistered. It contains information about the disk used + * by the driver. + * clear_all = This flag determines whether or not the disk information + * is going to be completely cleared out and the highest_lun + * reset. Sometimes we want to clear out information about + * the disk in preparation for re-adding it. In this case + * the highest_lun should be left unchanged and the LunID + * should not be cleared. +*/ +static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, + int clear_all) +{ + ctlr_info_t *h = get_host(disk); + + if (!capable(CAP_SYS_RAWIO)) + return -EPERM; + + /* make sure logical volume is NOT is use */ + if (clear_all || (h->gendisk[0] == disk)) { + if (drv->usage_count > 1) + return -EBUSY; + } else if (drv->usage_count > 0) + return -EBUSY; + + /* invalidate the devices and deregister the disk. If it is disk + * zero do not deregister it but just zero out it's values. This + * allows us to delete disk zero but keep the controller registered. + */ + if (h->gendisk[0] != disk) { + if (disk) { + request_queue_t *q = disk->queue; + if (disk->flags & GENHD_FL_UP) + del_gendisk(disk); + if (q) { + blk_cleanup_queue(q); + drv->queue = NULL; + } + } + } + + --h->num_luns; + /* zero out the disk size info */ + drv->nr_blocks = 0; + drv->block_size = 0; + drv->heads = 0; + drv->sectors = 0; + drv->cylinders = 0; + drv->raid_level = -1; /* This can be used as a flag variable to + * indicate that this element of the drive + * array is free. + */ + + if (clear_all) { + /* check to see if it was the last disk */ + if (drv == h->drv + h->highest_lun) { + /* if so, find the new hightest lun */ + int i, newhighest = -1; + for (i = 0; i < h->highest_lun; i++) { + /* if the disk has size > 0, it is available */ + if (h->drv[i].heads) + newhighest = i; + } + h->highest_lun = newhighest; + } + + drv->LunID = 0; + } + return 0; +} + +static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, /* 0: address the controller, + 1: address logical volume log_unit, + 2: periph device address is scsi3addr */ + unsigned int log_unit, __u8 page_code, + unsigned char *scsi3addr, int cmd_type) +{ + ctlr_info_t *h = hba[ctlr]; + u64bit buff_dma_handle; + int status = IO_OK; + + c->cmd_type = CMD_IOCTL_PEND; + c->Header.ReplyQueue = 0; + if (buff != NULL) { + c->Header.SGList = 1; + c->Header.SGTotal = 1; + } else { + c->Header.SGList = 0; + c->Header.SGTotal = 0; + } + c->Header.Tag.lower = c->busaddr; + + c->Request.Type.Type = cmd_type; + if (cmd_type == TYPE_CMD) { + switch (cmd) { + case CISS_INQUIRY: + /* If the logical unit number is 0 then, this is going + to controller so It's a physical command + mode = 0 target = 0. So we have nothing to write. + otherwise, if use_unit_num == 1, + mode = 1(volume set addressing) target = LUNID + otherwise, if use_unit_num == 2, + mode = 0(periph dev addr) target = scsi3addr */ + if (use_unit_num == 1) { + c->Header.LUN.LogDev.VolId = + h->drv[log_unit].LunID; + c->Header.LUN.LogDev.Mode = 1; + } else if (use_unit_num == 2) { + memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, + 8); + c->Header.LUN.LogDev.Mode = 0; + } + /* are we trying to read a vital product page */ + if (page_code != 0) { + c->Request.CDB[1] = 0x01; + c->Request.CDB[2] = page_code; + } + c->Request.CDBLen = 6; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_READ; + c->Request.Timeout = 0; + c->Request.CDB[0] = CISS_INQUIRY; + c->Request.CDB[4] = size & 0xFF; + break; + case CISS_REPORT_LOG: + case CISS_REPORT_PHYS: + /* Talking to controller so It's a physical command + mode = 00 target = 0. Nothing to write. + */ + c->Request.CDBLen = 12; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_READ; + c->Request.Timeout = 0; + c->Request.CDB[0] = cmd; + c->Request.CDB[6] = (size >> 24) & 0xFF; //MSB + c->Request.CDB[7] = (size >> 16) & 0xFF; + c->Request.CDB[8] = (size >> 8) & 0xFF; + c->Request.CDB[9] = size & 0xFF; + break; + + case CCISS_READ_CAPACITY: + c->Header.LUN.LogDev.VolId = h->drv[log_unit].LunID; + c->Header.LUN.LogDev.Mode = 1; + c->Request.CDBLen = 10; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_READ; + c->Request.Timeout = 0; + c->Request.CDB[0] = cmd; + break; + case CCISS_READ_CAPACITY_16: + c->Header.LUN.LogDev.VolId = h->drv[log_unit].LunID; + c->Header.LUN.LogDev.Mode = 1; + c->Request.CDBLen = 16; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_READ; + c->Request.Timeout = 0; + c->Request.CDB[0] = cmd; + c->Request.CDB[1] = 0x10; + c->Request.CDB[10] = (size >> 24) & 0xFF; + c->Request.CDB[11] = (size >> 16) & 0xFF; + c->Request.CDB[12] = (size >> 8) & 0xFF; + c->Request.CDB[13] = size & 0xFF; + c->Request.Timeout = 0; + c->Request.CDB[0] = cmd; + break; + case CCISS_CACHE_FLUSH: + c->Request.CDBLen = 12; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_WRITE; + c->Request.Timeout = 0; + c->Request.CDB[0] = BMIC_WRITE; + c->Request.CDB[6] = BMIC_CACHE_FLUSH; + break; + default: + printk(KERN_WARNING + "cciss%d: Unknown Command 0x%c\n", ctlr, cmd); + return IO_ERROR; + } + } else if (cmd_type == TYPE_MSG) { + switch (cmd) { + case 0: /* ABORT message */ + c->Request.CDBLen = 12; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_WRITE; + c->Request.Timeout = 0; + c->Request.CDB[0] = cmd; /* abort */ + c->Request.CDB[1] = 0; /* abort a command */ + /* buff contains the tag of the command to abort */ + memcpy(&c->Request.CDB[4], buff, 8); + break; + case 1: /* RESET message */ + c->Request.CDBLen = 12; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_WRITE; + c->Request.Timeout = 0; + memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); + c->Request.CDB[0] = cmd; /* reset */ + c->Request.CDB[1] = 0x04; /* reset a LUN */ + break; + case 3: /* No-Op message */ + c->Request.CDBLen = 1; + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = XFER_WRITE; + c->Request.Timeout = 0; + c->Request.CDB[0] = cmd; + break; + default: + printk(KERN_WARNING + "cciss%d: unknown message type %d\n", ctlr, cmd); + return IO_ERROR; + } + } else { + printk(KERN_WARNING + "cciss%d: unknown command type %d\n", ctlr, cmd_type); + return IO_ERROR; + } + /* Fill in the scatter gather information */ + if (size > 0) { + buff_dma_handle.val = (__u64) pci_map_single(h->pdev, + buff, size, + PCI_DMA_BIDIRECTIONAL); + c->SG[0].Addr.lower = buff_dma_handle.val32.lower; + c->SG[0].Addr.upper = buff_dma_handle.val32.upper; + c->SG[0].Len = size; + c->SG[0].Ext = 0; /* we are not chaining */ + } + return status; +} + +static int sendcmd_withirq(__u8 cmd, + int ctlr, + void *buff, + size_t size, + unsigned int use_unit_num, + unsigned int log_unit, __u8 page_code, int cmd_type) +{ + ctlr_info_t *h = hba[ctlr]; + CommandList_struct *c; + u64bit buff_dma_handle; + unsigned long flags; + int return_status; + DECLARE_COMPLETION_ONSTACK(wait); + + if ((c = cmd_alloc(h, 0)) == NULL) + return -ENOMEM; + return_status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, + log_unit, page_code, NULL, cmd_type); + if (return_status != IO_OK) { + cmd_free(h, c, 0); + return return_status; + } + resend_cmd2: + c->waiting = &wait; + + /* Put the request on the tail of the queue and send it */ + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + addQ(&h->reqQ, c); + h->Qdepth++; + start_io(h); + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + + wait_for_completion(&wait); + + if (c->err_info->CommandStatus != 0) { /* an error has occurred */ + switch (c->err_info->CommandStatus) { + case CMD_TARGET_STATUS: + printk(KERN_WARNING "cciss: cmd %p has " + " completed with errors\n", c); + if (c->err_info->ScsiStatus) { + printk(KERN_WARNING "cciss: cmd %p " + "has SCSI Status = %x\n", + c, c->err_info->ScsiStatus); + } + + break; + case CMD_DATA_UNDERRUN: + case CMD_DATA_OVERRUN: + /* expected for inquire and report lun commands */ + break; + case CMD_INVALID: + printk(KERN_WARNING "cciss: Cmd %p is " + "reported invalid\n", c); + return_status = IO_ERROR; + break; + case CMD_PROTOCOL_ERR: + printk(KERN_WARNING "cciss: cmd %p has " + "protocol error \n", c); + return_status = IO_ERROR; + break; + case CMD_HARDWARE_ERR: + printk(KERN_WARNING "cciss: cmd %p had " + " hardware error\n", c); + return_status = IO_ERROR; + break; + case CMD_CONNECTION_LOST: + printk(KERN_WARNING "cciss: cmd %p had " + "connection lost\n", c); + return_status = IO_ERROR; + break; + case CMD_ABORTED: + printk(KERN_WARNING "cciss: cmd %p was " + "aborted\n", c); + return_status = IO_ERROR; + break; + case CMD_ABORT_FAILED: + printk(KERN_WARNING "cciss: cmd %p reports " + "abort failed\n", c); + return_status = IO_ERROR; + break; + case CMD_UNSOLICITED_ABORT: + printk(KERN_WARNING + "cciss%d: unsolicited abort %p\n", ctlr, c); + if (c->retry_count < MAX_CMD_RETRIES) { + printk(KERN_WARNING + "cciss%d: retrying %p\n", ctlr, c); + c->retry_count++; + /* erase the old error information */ + memset(c->err_info, 0, + sizeof(ErrorInfo_struct)); + return_status = IO_OK; + INIT_COMPLETION(wait); + goto resend_cmd2; + } + return_status = IO_ERROR; + break; + default: + printk(KERN_WARNING "cciss: cmd %p returned " + "unknown status %x\n", c, + c->err_info->CommandStatus); + return_status = IO_ERROR; + } + } + /* unlock the buffers from DMA */ + buff_dma_handle.val32.lower = c->SG[0].Addr.lower; + buff_dma_handle.val32.upper = c->SG[0].Addr.upper; + pci_unmap_single(h->pdev, (dma_addr_t) buff_dma_handle.val, + c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); + cmd_free(h, c, 0); + return return_status; +} + +static void cciss_geometry_inquiry(int ctlr, int logvol, + int withirq, sector_t total_size, + unsigned int block_size, + InquiryData_struct *inq_buff, + drive_info_struct *drv) +{ + int return_code; + unsigned long t; + + memset(inq_buff, 0, sizeof(InquiryData_struct)); + if (withirq) + return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, + inq_buff, sizeof(*inq_buff), 1, + logvol, 0xC1, TYPE_CMD); + else + return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff, + sizeof(*inq_buff), 1, logvol, 0xC1, NULL, + TYPE_CMD); + if (return_code == IO_OK) { + if (inq_buff->data_byte[8] == 0xFF) { + printk(KERN_WARNING + "cciss: reading geometry failed, volume " + "does not support reading geometry\n"); + drv->heads = 255; + drv->sectors = 32; // Sectors per track + } else { + drv->heads = inq_buff->data_byte[6]; + drv->sectors = inq_buff->data_byte[7]; + drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8; + drv->cylinders += inq_buff->data_byte[5]; + drv->raid_level = inq_buff->data_byte[8]; + } + drv->block_size = block_size; + drv->nr_blocks = total_size; + t = drv->heads * drv->sectors; + if (t > 1) { + unsigned rem = sector_div(total_size, t); + if (rem) + total_size++; + drv->cylinders = total_size; + } + } else { /* Get geometry failed */ + printk(KERN_WARNING "cciss: reading geometry failed\n"); + } + printk(KERN_INFO " heads=%d, sectors=%d, cylinders=%d\n\n", + drv->heads, drv->sectors, drv->cylinders); +} + +static void +cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size, + unsigned int *block_size) +{ + ReadCapdata_struct *buf; + int return_code; + buf = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL); + if (buf == NULL) { + printk(KERN_WARNING "cciss: out of memory\n"); + return; + } + memset(buf, 0, sizeof(ReadCapdata_struct)); + if (withirq) + return_code = sendcmd_withirq(CCISS_READ_CAPACITY, + ctlr, buf, sizeof(ReadCapdata_struct), + 1, logvol, 0, TYPE_CMD); + else + return_code = sendcmd(CCISS_READ_CAPACITY, + ctlr, buf, sizeof(ReadCapdata_struct), + 1, logvol, 0, NULL, TYPE_CMD); + if (return_code == IO_OK) { + *total_size = be32_to_cpu(*(__u32 *) buf->total_size)+1; + *block_size = be32_to_cpu(*(__u32 *) buf->block_size); + } else { /* read capacity command failed */ + printk(KERN_WARNING "cciss: read capacity failed\n"); + *total_size = 0; + *block_size = BLOCK_SIZE; + } + if (*total_size != (__u32) 0) + printk(KERN_INFO " blocks= %llu block_size= %d\n", + (unsigned long long)*total_size, *block_size); + kfree(buf); + return; +} + +static void +cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size, unsigned int *block_size) +{ + ReadCapdata_struct_16 *buf; + int return_code; + buf = kmalloc(sizeof(ReadCapdata_struct_16), GFP_KERNEL); + if (buf == NULL) { + printk(KERN_WARNING "cciss: out of memory\n"); + return; + } + memset(buf, 0, sizeof(ReadCapdata_struct_16)); + if (withirq) { + return_code = sendcmd_withirq(CCISS_READ_CAPACITY_16, + ctlr, buf, sizeof(ReadCapdata_struct_16), + 1, logvol, 0, TYPE_CMD); + } + else { + return_code = sendcmd(CCISS_READ_CAPACITY_16, + ctlr, buf, sizeof(ReadCapdata_struct_16), + 1, logvol, 0, NULL, TYPE_CMD); + } + if (return_code == IO_OK) { + *total_size = be64_to_cpu(*(__u64 *) buf->total_size)+1; + *block_size = be32_to_cpu(*(__u32 *) buf->block_size); + } else { /* read capacity command failed */ + printk(KERN_WARNING "cciss: read capacity failed\n"); + *total_size = 0; + *block_size = BLOCK_SIZE; + } + printk(KERN_INFO " blocks= %llu block_size= %d\n", + (unsigned long long)*total_size, *block_size); + kfree(buf); + return; +} + +static int cciss_revalidate(struct gendisk *disk) +{ + ctlr_info_t *h = get_host(disk); + drive_info_struct *drv = get_drv(disk); + int logvol; + int FOUND = 0; + unsigned int block_size; + sector_t total_size; + InquiryData_struct *inq_buff = NULL; + + for (logvol = 0; logvol < CISS_MAX_LUN; logvol++) { + if (h->drv[logvol].LunID == drv->LunID) { + FOUND = 1; + break; + } + } + + if (!FOUND) + return 1; + + inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); + if (inq_buff == NULL) { + printk(KERN_WARNING "cciss: out of memory\n"); + return 1; + } + if (h->cciss_read == CCISS_READ_10) { + cciss_read_capacity(h->ctlr, logvol, 1, + &total_size, &block_size); + } else { + cciss_read_capacity_16(h->ctlr, logvol, 1, + &total_size, &block_size); + } + cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, + inq_buff, drv); + + blk_queue_hardsect_size(drv->queue, drv->block_size); + set_capacity(disk, drv->nr_blocks); + + kfree(inq_buff); + return 0; +} + +/* + * Wait polling for a command to complete. + * The memory mapped FIFO is polled for the completion. + * Used only at init time, interrupts from the HBA are disabled. + */ +static unsigned long pollcomplete(int ctlr) +{ + unsigned long done; + int i; + + /* Wait (up to 20 seconds) for a command to complete */ + + for (i = 20 * HZ; i > 0; i--) { + done = hba[ctlr]->access.command_completed(hba[ctlr]); + if (done == FIFO_EMPTY) + schedule_timeout_uninterruptible(1); + else + return done; + } + /* Invalid address to tell caller we ran out of time */ + return 1; +} + +static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete) +{ + /* We get in here if sendcmd() is polling for completions + and gets some command back that it wasn't expecting -- + something other than that which it just sent down. + Ordinarily, that shouldn't happen, but it can happen when + the scsi tape stuff gets into error handling mode, and + starts using sendcmd() to try to abort commands and + reset tape drives. In that case, sendcmd may pick up + completions of commands that were sent to logical drives + through the block i/o system, or cciss ioctls completing, etc. + In that case, we need to save those completions for later + processing by the interrupt handler. + */ + +#ifdef CONFIG_CISS_SCSI_TAPE + struct sendcmd_reject_list *srl = &hba[ctlr]->scsi_rejects; + + /* If it's not the scsi tape stuff doing error handling, (abort */ + /* or reset) then we don't expect anything weird. */ + if (cmd != CCISS_RESET_MSG && cmd != CCISS_ABORT_MSG) { +#endif + printk(KERN_WARNING "cciss cciss%d: SendCmd " + "Invalid command list address returned! (%lx)\n", + ctlr, complete); + /* not much we can do. */ +#ifdef CONFIG_CISS_SCSI_TAPE + return 1; + } + + /* We've sent down an abort or reset, but something else + has completed */ + if (srl->ncompletions >= (NR_CMDS + 2)) { + /* Uh oh. No room to save it for later... */ + printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, " + "reject list overflow, command lost!\n", ctlr); + return 1; + } + /* Save it for later */ + srl->complete[srl->ncompletions] = complete; + srl->ncompletions++; +#endif + return 0; +} + +/* + * Send a command to the controller, and wait for it to complete. + * Only used at init time. + */ +static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, /* 0: address the controller, + 1: address logical volume log_unit, + 2: periph device address is scsi3addr */ + unsigned int log_unit, + __u8 page_code, unsigned char *scsi3addr, int cmd_type) +{ + CommandList_struct *c; + int i; + unsigned long complete; + ctlr_info_t *info_p = hba[ctlr]; + u64bit buff_dma_handle; + int status, done = 0; + + if ((c = cmd_alloc(info_p, 1)) == NULL) { + printk(KERN_WARNING "cciss: unable to get memory"); + return IO_ERROR; + } + status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, + log_unit, page_code, scsi3addr, cmd_type); + if (status != IO_OK) { + cmd_free(info_p, c, 1); + return status; + } + resend_cmd1: + /* + * Disable interrupt + */ +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "cciss: turning intr off\n"); +#endif /* CCISS_DEBUG */ + info_p->access.set_intr_mask(info_p, CCISS_INTR_OFF); + + /* Make sure there is room in the command FIFO */ + /* Actually it should be completely empty at this time */ + /* unless we are in here doing error handling for the scsi */ + /* tape side of the driver. */ + for (i = 200000; i > 0; i--) { + /* if fifo isn't full go */ + if (!(info_p->access.fifo_full(info_p))) { + + break; + } + udelay(10); + printk(KERN_WARNING "cciss cciss%d: SendCmd FIFO full," + " waiting!\n", ctlr); + } + /* + * Send the cmd + */ + info_p->access.submit_command(info_p, c); + done = 0; + do { + complete = pollcomplete(ctlr); + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "cciss: command completed\n"); +#endif /* CCISS_DEBUG */ + + if (complete == 1) { + printk(KERN_WARNING + "cciss cciss%d: SendCmd Timeout out, " + "No command list address returned!\n", ctlr); + status = IO_ERROR; + done = 1; + break; + } + + /* This will need to change for direct lookup completions */ + if ((complete & CISS_ERROR_BIT) + && (complete & ~CISS_ERROR_BIT) == c->busaddr) { + /* if data overrun or underun on Report command + ignore it + */ + if (((c->Request.CDB[0] == CISS_REPORT_LOG) || + (c->Request.CDB[0] == CISS_REPORT_PHYS) || + (c->Request.CDB[0] == CISS_INQUIRY)) && + ((c->err_info->CommandStatus == + CMD_DATA_OVERRUN) || + (c->err_info->CommandStatus == CMD_DATA_UNDERRUN) + )) { + complete = c->busaddr; + } else { + if (c->err_info->CommandStatus == + CMD_UNSOLICITED_ABORT) { + printk(KERN_WARNING "cciss%d: " + "unsolicited abort %p\n", + ctlr, c); + if (c->retry_count < MAX_CMD_RETRIES) { + printk(KERN_WARNING + "cciss%d: retrying %p\n", + ctlr, c); + c->retry_count++; + /* erase the old error */ + /* information */ + memset(c->err_info, 0, + sizeof + (ErrorInfo_struct)); + goto resend_cmd1; + } else { + printk(KERN_WARNING + "cciss%d: retried %p too " + "many times\n", ctlr, c); + status = IO_ERROR; + goto cleanup1; + } + } else if (c->err_info->CommandStatus == + CMD_UNABORTABLE) { + printk(KERN_WARNING + "cciss%d: command could not be aborted.\n", + ctlr); + status = IO_ERROR; + goto cleanup1; + } + printk(KERN_WARNING "ciss ciss%d: sendcmd" + " Error %x \n", ctlr, + c->err_info->CommandStatus); + printk(KERN_WARNING "ciss ciss%d: sendcmd" + " offensive info\n" + " size %x\n num %x value %x\n", + ctlr, + c->err_info->MoreErrInfo.Invalid_Cmd. + offense_size, + c->err_info->MoreErrInfo.Invalid_Cmd. + offense_num, + c->err_info->MoreErrInfo.Invalid_Cmd. + offense_value); + status = IO_ERROR; + goto cleanup1; + } + } + /* This will need changing for direct lookup completions */ + if (complete != c->busaddr) { + if (add_sendcmd_reject(cmd, ctlr, complete) != 0) { + BUG(); /* we are pretty much hosed if we get here. */ + } + continue; + } else + done = 1; + } while (!done); + + cleanup1: + /* unlock the data buffer from DMA */ + buff_dma_handle.val32.lower = c->SG[0].Addr.lower; + buff_dma_handle.val32.upper = c->SG[0].Addr.upper; + pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val, + c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); +#ifdef CONFIG_CISS_SCSI_TAPE + /* if we saved some commands for later, process them now. */ + if (info_p->scsi_rejects.ncompletions > 0) + do_cciss_intr(0, info_p); +#endif + cmd_free(info_p, c, 1); + return status; +} + +/* + * Map (physical) PCI mem into (virtual) kernel space + */ +static void __iomem *remap_pci_mem(ulong base, ulong size) +{ + ulong page_base = ((ulong) base) & PAGE_MASK; + ulong page_offs = ((ulong) base) - page_base; + void __iomem *page_remapped = ioremap(page_base, page_offs + size); + + return page_remapped ? (page_remapped + page_offs) : NULL; +} + +/* + * Takes jobs of the Q and sends them to the hardware, then puts it on + * the Q to wait for completion. + */ +static void start_io(ctlr_info_t *h) +{ + CommandList_struct *c; + + while ((c = h->reqQ) != NULL) { + /* can't do anything if fifo is full */ + if ((h->access.fifo_full(h))) { + printk(KERN_WARNING "cciss: fifo full\n"); + break; + } + + /* Get the first entry from the Request Q */ + removeQ(&(h->reqQ), c); + h->Qdepth--; + + /* Tell the controller execute command */ + h->access.submit_command(h, c); + + /* Put job onto the completed Q */ + addQ(&(h->cmpQ), c); + } +} + +/* Assumes that CCISS_LOCK(h->ctlr) is held. */ +/* Zeros out the error record and then resends the command back */ +/* to the controller */ +static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c) +{ + /* erase the old error information */ + memset(c->err_info, 0, sizeof(ErrorInfo_struct)); + + /* add it to software queue and then send it to the controller */ + addQ(&(h->reqQ), c); + h->Qdepth++; + if (h->Qdepth > h->maxQsinceinit) + h->maxQsinceinit = h->Qdepth; + + start_io(h); +} + +/* checks the status of the job and calls complete buffers to mark all + * buffers for the completed job. Note that this function does not need + * to hold the hba/queue lock. + */ +static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, + int timeout) +{ + int status = 1; + int retry_cmd = 0; + + if (timeout) + status = 0; + + if (cmd->err_info->CommandStatus != 0) { /* an error has occurred */ + switch (cmd->err_info->CommandStatus) { + unsigned char sense_key; + case CMD_TARGET_STATUS: + status = 0; + + if (cmd->err_info->ScsiStatus == 0x02) { + printk(KERN_WARNING "cciss: cmd %p " + "has CHECK CONDITION " + " byte 2 = 0x%x\n", cmd, + cmd->err_info->SenseInfo[2] + ); + /* check the sense key */ + sense_key = 0xf & cmd->err_info->SenseInfo[2]; + /* no status or recovered error */ + if ((sense_key == 0x0) || (sense_key == 0x1)) { + status = 1; + } + } else { + printk(KERN_WARNING "cciss: cmd %p " + "has SCSI Status 0x%x\n", + cmd, cmd->err_info->ScsiStatus); + } + break; + case CMD_DATA_UNDERRUN: + printk(KERN_WARNING "cciss: cmd %p has" + " completed with data underrun " + "reported\n", cmd); + break; + case CMD_DATA_OVERRUN: + printk(KERN_WARNING "cciss: cmd %p has" + " completed with data overrun " + "reported\n", cmd); + break; + case CMD_INVALID: + printk(KERN_WARNING "cciss: cmd %p is " + "reported invalid\n", cmd); + status = 0; + break; + case CMD_PROTOCOL_ERR: + printk(KERN_WARNING "cciss: cmd %p has " + "protocol error \n", cmd); + status = 0; + break; + case CMD_HARDWARE_ERR: + printk(KERN_WARNING "cciss: cmd %p had " + " hardware error\n", cmd); + status = 0; + break; + case CMD_CONNECTION_LOST: + printk(KERN_WARNING "cciss: cmd %p had " + "connection lost\n", cmd); + status = 0; + break; + case CMD_ABORTED: + printk(KERN_WARNING "cciss: cmd %p was " + "aborted\n", cmd); + status = 0; + break; + case CMD_ABORT_FAILED: + printk(KERN_WARNING "cciss: cmd %p reports " + "abort failed\n", cmd); + status = 0; + break; + case CMD_UNSOLICITED_ABORT: + printk(KERN_WARNING "cciss%d: unsolicited " + "abort %p\n", h->ctlr, cmd); + if (cmd->retry_count < MAX_CMD_RETRIES) { + retry_cmd = 1; + printk(KERN_WARNING + "cciss%d: retrying %p\n", h->ctlr, cmd); + cmd->retry_count++; + } else + printk(KERN_WARNING + "cciss%d: %p retried too " + "many times\n", h->ctlr, cmd); + status = 0; + break; + case CMD_TIMEOUT: + printk(KERN_WARNING "cciss: cmd %p timedout\n", cmd); + status = 0; + break; + default: + printk(KERN_WARNING "cciss: cmd %p returned " + "unknown status %x\n", cmd, + cmd->err_info->CommandStatus); + status = 0; + } + } + /* We need to return this command */ + if (retry_cmd) { + resend_cciss_cmd(h, cmd); + return; + } + + cmd->rq->completion_data = cmd; + cmd->rq->errors = status; + blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE); + blk_complete_request(cmd->rq); +} + +/* + * Get a request and submit it to the controller. + */ +static void do_cciss_request(request_queue_t *q) +{ + ctlr_info_t *h = q->queuedata; + CommandList_struct *c; + sector_t start_blk; + int seg; + struct request *creq; + u64bit temp64; + struct scatterlist tmp_sg[MAXSGENTRIES]; + drive_info_struct *drv; + int i, dir; + + /* We call start_io here in case there is a command waiting on the + * queue that has not been sent. + */ + if (blk_queue_plugged(q)) + goto startio; + + queue: + creq = elv_next_request(q); + if (!creq) + goto startio; + + BUG_ON(creq->nr_phys_segments > MAXSGENTRIES); + + if ((c = cmd_alloc(h, 1)) == NULL) + goto full; + + blkdev_dequeue_request(creq); + + spin_unlock_irq(q->queue_lock); + + c->cmd_type = CMD_RWREQ; + c->rq = creq; + + /* fill in the request */ + drv = creq->rq_disk->private_data; + c->Header.ReplyQueue = 0; // unused in simple mode + /* got command from pool, so use the command block index instead */ + /* for direct lookups. */ + /* The first 2 bits are reserved for controller error reporting. */ + c->Header.Tag.lower = (c->cmdindex << 3); + c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */ + c->Header.LUN.LogDev.VolId = drv->LunID; + c->Header.LUN.LogDev.Mode = 1; + c->Request.CDBLen = 10; // 12 byte commands not in FW yet; + c->Request.Type.Type = TYPE_CMD; // It is a command. + c->Request.Type.Attribute = ATTR_SIMPLE; + c->Request.Type.Direction = + (rq_data_dir(creq) == READ) ? h->cciss_read : h->cciss_write; + c->Request.Timeout = 0; // Don't time out + c->Request.CDB[0] = + (rq_data_dir(creq) == READ) ? h->cciss_read : h->cciss_write; + start_blk = creq->sector; +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n", (int)creq->sector, + (int)creq->nr_sectors); +#endif /* CCISS_DEBUG */ + + seg = blk_rq_map_sg(q, creq, tmp_sg); + + /* get the DMA records for the setup */ + if (c->Request.Type.Direction == XFER_READ) + dir = PCI_DMA_FROMDEVICE; + else + dir = PCI_DMA_TODEVICE; + + for (i = 0; i < seg; i++) { + c->SG[i].Len = tmp_sg[i].length; + temp64.val = (__u64) pci_map_page(h->pdev, tmp_sg[i].page, + tmp_sg[i].offset, + tmp_sg[i].length, dir); + c->SG[i].Addr.lower = temp64.val32.lower; + c->SG[i].Addr.upper = temp64.val32.upper; + c->SG[i].Ext = 0; // we are not chaining + } + /* track how many SG entries we are using */ + if (seg > h->maxSG) + h->maxSG = seg; + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "cciss: Submitting %d sectors in %d segments\n", + creq->nr_sectors, seg); +#endif /* CCISS_DEBUG */ + + c->Header.SGList = c->Header.SGTotal = seg; + if(h->cciss_read == CCISS_READ_10) { + c->Request.CDB[1] = 0; + c->Request.CDB[2] = (start_blk >> 24) & 0xff; //MSB + c->Request.CDB[3] = (start_blk >> 16) & 0xff; + c->Request.CDB[4] = (start_blk >> 8) & 0xff; + c->Request.CDB[5] = start_blk & 0xff; + c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB + c->Request.CDB[7] = (creq->nr_sectors >> 8) & 0xff; + c->Request.CDB[8] = creq->nr_sectors & 0xff; + c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; + } else { + c->Request.CDBLen = 16; + c->Request.CDB[1]= 0; + c->Request.CDB[2]= (start_blk >> 56) & 0xff; //MSB + c->Request.CDB[3]= (start_blk >> 48) & 0xff; + c->Request.CDB[4]= (start_blk >> 40) & 0xff; + c->Request.CDB[5]= (start_blk >> 32) & 0xff; + c->Request.CDB[6]= (start_blk >> 24) & 0xff; + c->Request.CDB[7]= (start_blk >> 16) & 0xff; + c->Request.CDB[8]= (start_blk >> 8) & 0xff; + c->Request.CDB[9]= start_blk & 0xff; + c->Request.CDB[10]= (creq->nr_sectors >> 24) & 0xff; + c->Request.CDB[11]= (creq->nr_sectors >> 16) & 0xff; + c->Request.CDB[12]= (creq->nr_sectors >> 8) & 0xff; + c->Request.CDB[13]= creq->nr_sectors & 0xff; + c->Request.CDB[14] = c->Request.CDB[15] = 0; + } + + spin_lock_irq(q->queue_lock); + + addQ(&(h->reqQ), c); + h->Qdepth++; + if (h->Qdepth > h->maxQsinceinit) + h->maxQsinceinit = h->Qdepth; + + goto queue; +full: + blk_stop_queue(q); +startio: + /* We will already have the driver lock here so not need + * to lock it. + */ + start_io(h); +} + +static inline unsigned long get_next_completion(ctlr_info_t *h) +{ +#ifdef CONFIG_CISS_SCSI_TAPE + /* Any rejects from sendcmd() lying around? Process them first */ + if (h->scsi_rejects.ncompletions == 0) + return h->access.command_completed(h); + else { + struct sendcmd_reject_list *srl; + int n; + srl = &h->scsi_rejects; + n = --srl->ncompletions; + /* printk("cciss%d: processing saved reject\n", h->ctlr); */ + printk("p"); + return srl->complete[n]; + } +#else + return h->access.command_completed(h); +#endif +} + +static inline int interrupt_pending(ctlr_info_t *h) +{ +#ifdef CONFIG_CISS_SCSI_TAPE + return (h->access.intr_pending(h) + || (h->scsi_rejects.ncompletions > 0)); +#else + return h->access.intr_pending(h); +#endif +} + +static inline long interrupt_not_for_us(ctlr_info_t *h) +{ +#ifdef CONFIG_CISS_SCSI_TAPE + return (((h->access.intr_pending(h) == 0) || + (h->interrupts_enabled == 0)) + && (h->scsi_rejects.ncompletions == 0)); +#else + return (((h->access.intr_pending(h) == 0) || + (h->interrupts_enabled == 0))); +#endif +} + +static irqreturn_t do_cciss_intr(int irq, void *dev_id) +{ + ctlr_info_t *h = dev_id; + CommandList_struct *c; + unsigned long flags; + __u32 a, a1, a2; + + if (interrupt_not_for_us(h)) + return IRQ_NONE; + /* + * If there are completed commands in the completion queue, + * we had better do something about it. + */ + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); + while (interrupt_pending(h)) { + while ((a = get_next_completion(h)) != FIFO_EMPTY) { + a1 = a; + if ((a & 0x04)) { + a2 = (a >> 3); + if (a2 >= NR_CMDS) { + printk(KERN_WARNING + "cciss: controller cciss%d failed, stopping.\n", + h->ctlr); + fail_all_cmds(h->ctlr); + return IRQ_HANDLED; + } + + c = h->cmd_pool + a2; + a = c->busaddr; + + } else { + a &= ~3; + if ((c = h->cmpQ) == NULL) { + printk(KERN_WARNING + "cciss: Completion of %08x ignored\n", + a1); + continue; + } + while (c->busaddr != a) { + c = c->next; + if (c == h->cmpQ) + break; + } + } + /* + * If we've found the command, take it off the + * completion Q and free it + */ + if (c->busaddr == a) { + removeQ(&h->cmpQ, c); + if (c->cmd_type == CMD_RWREQ) { + complete_command(h, c, 0); + } else if (c->cmd_type == CMD_IOCTL_PEND) { + complete(c->waiting); + } +# ifdef CONFIG_CISS_SCSI_TAPE + else if (c->cmd_type == CMD_SCSI) + complete_scsi_command(c, 0, a1); +# endif + continue; + } + } + } + + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return IRQ_HANDLED; +} + +/* + * We cannot read the structure directly, for portability we must use + * the io functions. + * This is for debug only. + */ +#ifdef CCISS_DEBUG +static void print_cfg_table(CfgTable_struct *tb) +{ + int i; + char temp_name[17]; + + printk("Controller Configuration information\n"); + printk("------------------------------------\n"); + for (i = 0; i < 4; i++) + temp_name[i] = readb(&(tb->Signature[i])); + temp_name[4] = '\0'; + printk(" Signature = %s\n", temp_name); + printk(" Spec Number = %d\n", readl(&(tb->SpecValence))); + printk(" Transport methods supported = 0x%x\n", + readl(&(tb->TransportSupport))); + printk(" Transport methods active = 0x%x\n", + readl(&(tb->TransportActive))); + printk(" Requested transport Method = 0x%x\n", + readl(&(tb->HostWrite.TransportRequest))); + printk(" Coalesce Interrupt Delay = 0x%x\n", + readl(&(tb->HostWrite.CoalIntDelay))); + printk(" Coalesce Interrupt Count = 0x%x\n", + readl(&(tb->HostWrite.CoalIntCount))); + printk(" Max outstanding commands = 0x%d\n", + readl(&(tb->CmdsOutMax))); + printk(" Bus Types = 0x%x\n", readl(&(tb->BusTypes))); + for (i = 0; i < 16; i++) + temp_name[i] = readb(&(tb->ServerName[i])); + temp_name[16] = '\0'; + printk(" Server Name = %s\n", temp_name); + printk(" Heartbeat Counter = 0x%x\n\n\n", readl(&(tb->HeartBeat))); +} +#endif /* CCISS_DEBUG */ + +static int find_PCI_BAR_index(struct pci_dev *pdev, unsigned long pci_bar_addr) +{ + int i, offset, mem_type, bar_type; + if (pci_bar_addr == PCI_BASE_ADDRESS_0) /* looking for BAR zero? */ + return 0; + offset = 0; + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + bar_type = pci_resource_flags(pdev, i) & PCI_BASE_ADDRESS_SPACE; + if (bar_type == PCI_BASE_ADDRESS_SPACE_IO) + offset += 4; + else { + mem_type = pci_resource_flags(pdev, i) & + PCI_BASE_ADDRESS_MEM_TYPE_MASK; + switch (mem_type) { + case PCI_BASE_ADDRESS_MEM_TYPE_32: + case PCI_BASE_ADDRESS_MEM_TYPE_1M: + offset += 4; /* 32 bit */ + break; + case PCI_BASE_ADDRESS_MEM_TYPE_64: + offset += 8; + break; + default: /* reserved in PCI 2.2 */ + printk(KERN_WARNING + "Base address is invalid\n"); + return -1; + break; + } + } + if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0) + return i + 1; + } + return -1; +} + +/* If MSI/MSI-X is supported by the kernel we will try to enable it on + * controllers that are capable. If not, we use IO-APIC mode. + */ + +static void __devinit cciss_interrupt_mode(ctlr_info_t *c, + struct pci_dev *pdev, __u32 board_id) +{ +#ifdef CONFIG_PCI_MSI + int err; + struct msix_entry cciss_msix_entries[4] = { {0, 0}, {0, 1}, + {0, 2}, {0, 3} + }; + + /* Some boards advertise MSI but don't really support it */ + if ((board_id == 0x40700E11) || + (board_id == 0x40800E11) || + (board_id == 0x40820E11) || (board_id == 0x40830E11)) + goto default_int_mode; + + if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { + err = pci_enable_msix(pdev, cciss_msix_entries, 4); + if (!err) { + c->intr[0] = cciss_msix_entries[0].vector; + c->intr[1] = cciss_msix_entries[1].vector; + c->intr[2] = cciss_msix_entries[2].vector; + c->intr[3] = cciss_msix_entries[3].vector; + c->msix_vector = 1; + return; + } + if (err > 0) { + printk(KERN_WARNING "cciss: only %d MSI-X vectors " + "available\n", err); + } else { + printk(KERN_WARNING "cciss: MSI-X init failed %d\n", + err); + } + } + if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { + if (!pci_enable_msi(pdev)) { + c->intr[SIMPLE_MODE_INT] = pdev->irq; + c->msi_vector = 1; + return; + } else { + printk(KERN_WARNING "cciss: MSI init failed\n"); + c->intr[SIMPLE_MODE_INT] = pdev->irq; + return; + } + } + default_int_mode: +#endif /* CONFIG_PCI_MSI */ + /* if we get here we're going to use the default interrupt mode */ + c->intr[SIMPLE_MODE_INT] = pdev->irq; + return; +} + +static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) +{ + ushort subsystem_vendor_id, subsystem_device_id, command; + __u32 board_id, scratchpad = 0; + __u64 cfg_offset; + __u32 cfg_base_addr; + __u64 cfg_base_addr_index; + int i, err; + + /* check to see if controller has been disabled */ + /* BEFORE trying to enable it */ + (void)pci_read_config_word(pdev, PCI_COMMAND, &command); + if (!(command & 0x02)) { + printk(KERN_WARNING + "cciss: controller appears to be disabled\n"); + return -ENODEV; + } + + err = pci_enable_device(pdev); + if (err) { + printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); + return err; + } + + err = pci_request_regions(pdev, "cciss"); + if (err) { + printk(KERN_ERR "cciss: Cannot obtain PCI resources, " + "aborting\n"); + goto err_out_disable_pdev; + } + + subsystem_vendor_id = pdev->subsystem_vendor; + subsystem_device_id = pdev->subsystem_device; + board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | + subsystem_vendor_id); + +#ifdef CCISS_DEBUG + printk("command = %x\n", command); + printk("irq = %x\n", pdev->irq); + printk("board_id = %x\n", board_id); +#endif /* CCISS_DEBUG */ + +/* If the kernel supports MSI/MSI-X we will try to enable that functionality, + * else we use the IO-APIC interrupt assigned to us by system ROM. + */ + cciss_interrupt_mode(c, pdev, board_id); + + /* + * Memory base addr is first addr , the second points to the config + * table + */ + + c->paddr = pci_resource_start(pdev, 0); /* addressing mode bits already removed */ +#ifdef CCISS_DEBUG + printk("address 0 = %x\n", c->paddr); +#endif /* CCISS_DEBUG */ + c->vaddr = remap_pci_mem(c->paddr, 200); + + /* Wait for the board to become ready. (PCI hotplug needs this.) + * We poll for up to 120 secs, once per 100ms. */ + for (i = 0; i < 1200; i++) { + scratchpad = readl(c->vaddr + SA5_SCRATCHPAD_OFFSET); + if (scratchpad == CCISS_FIRMWARE_READY) + break; + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ / 10); /* wait 100ms */ + } + if (scratchpad != CCISS_FIRMWARE_READY) { + printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); + err = -ENODEV; + goto err_out_free_res; + } + + /* get the address index number */ + cfg_base_addr = readl(c->vaddr + SA5_CTCFG_OFFSET); + cfg_base_addr &= (__u32) 0x0000ffff; +#ifdef CCISS_DEBUG + printk("cfg base address = %x\n", cfg_base_addr); +#endif /* CCISS_DEBUG */ + cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); +#ifdef CCISS_DEBUG + printk("cfg base address index = %x\n", cfg_base_addr_index); +#endif /* CCISS_DEBUG */ + if (cfg_base_addr_index == -1) { + printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); + err = -ENODEV; + goto err_out_free_res; + } + + cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); +#ifdef CCISS_DEBUG + printk("cfg offset = %x\n", cfg_offset); +#endif /* CCISS_DEBUG */ + c->cfgtable = remap_pci_mem(pci_resource_start(pdev, + cfg_base_addr_index) + + cfg_offset, sizeof(CfgTable_struct)); + c->board_id = board_id; + +#ifdef CCISS_DEBUG + print_cfg_table(c->cfgtable); +#endif /* CCISS_DEBUG */ + + for (i = 0; i < ARRAY_SIZE(products); i++) { + if (board_id == products[i].board_id) { + c->product_name = products[i].product_name; + c->access = *(products[i].access); + break; + } + } + if (i == ARRAY_SIZE(products)) { + printk(KERN_WARNING "cciss: Sorry, I don't know how" + " to access the Smart Array controller %08lx\n", + (unsigned long)board_id); + err = -ENODEV; + goto err_out_free_res; + } + if ((readb(&c->cfgtable->Signature[0]) != 'C') || + (readb(&c->cfgtable->Signature[1]) != 'I') || + (readb(&c->cfgtable->Signature[2]) != 'S') || + (readb(&c->cfgtable->Signature[3]) != 'S')) { + printk("Does not appear to be a valid CISS config table\n"); + err = -ENODEV; + goto err_out_free_res; + } +#ifdef CONFIG_X86 + { + /* Need to enable prefetch in the SCSI core for 6400 in x86 */ + __u32 prefetch; + prefetch = readl(&(c->cfgtable->SCSI_Prefetch)); + prefetch |= 0x100; + writel(prefetch, &(c->cfgtable->SCSI_Prefetch)); + } +#endif + +#ifdef CCISS_DEBUG + printk("Trying to put board into Simple mode\n"); +#endif /* CCISS_DEBUG */ + c->max_commands = readl(&(c->cfgtable->CmdsOutMax)); + /* Update the field, and then ring the doorbell */ + writel(CFGTBL_Trans_Simple, &(c->cfgtable->HostWrite.TransportRequest)); + writel(CFGTBL_ChangeReq, c->vaddr + SA5_DOORBELL); + + /* under certain very rare conditions, this can take awhile. + * (e.g.: hot replace a failed 144GB drive in a RAID 5 set right + * as we enter this code.) */ + for (i = 0; i < MAX_CONFIG_WAIT; i++) { + if (!(readl(c->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq)) + break; + /* delay and try again */ + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(10); + } + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "I counter got to %d %x\n", i, + readl(c->vaddr + SA5_DOORBELL)); +#endif /* CCISS_DEBUG */ +#ifdef CCISS_DEBUG + print_cfg_table(c->cfgtable); +#endif /* CCISS_DEBUG */ + + if (!(readl(&(c->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) { + printk(KERN_WARNING "cciss: unable to get board into" + " simple mode\n"); + err = -ENODEV; + goto err_out_free_res; + } + return 0; + + err_out_free_res: + pci_release_regions(pdev); + + err_out_disable_pdev: + pci_disable_device(pdev); + return err; +} + +/* + * Gets information about the local volumes attached to the controller. + */ +static void cciss_getgeometry(int cntl_num) +{ + ReportLunData_struct *ld_buff; + InquiryData_struct *inq_buff; + int return_code; + int i; + int listlength = 0; + __u32 lunid = 0; + int block_size; + sector_t total_size; + + ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); + if (ld_buff == NULL) { + printk(KERN_ERR "cciss: out of memory\n"); + return; + } + inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); + if (inq_buff == NULL) { + printk(KERN_ERR "cciss: out of memory\n"); + kfree(ld_buff); + return; + } + /* Get the firmware version */ + return_code = sendcmd(CISS_INQUIRY, cntl_num, inq_buff, + sizeof(InquiryData_struct), 0, 0, 0, NULL, + TYPE_CMD); + if (return_code == IO_OK) { + hba[cntl_num]->firm_ver[0] = inq_buff->data_byte[32]; + hba[cntl_num]->firm_ver[1] = inq_buff->data_byte[33]; + hba[cntl_num]->firm_ver[2] = inq_buff->data_byte[34]; + hba[cntl_num]->firm_ver[3] = inq_buff->data_byte[35]; + } else { /* send command failed */ + + printk(KERN_WARNING "cciss: unable to determine firmware" + " version of controller\n"); + } + /* Get the number of logical volumes */ + return_code = sendcmd(CISS_REPORT_LOG, cntl_num, ld_buff, + sizeof(ReportLunData_struct), 0, 0, 0, NULL, + TYPE_CMD); + + if (return_code == IO_OK) { +#ifdef CCISS_DEBUG + printk("LUN Data\n--------------------------\n"); +#endif /* CCISS_DEBUG */ + + listlength |= + (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24; + listlength |= + (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; + listlength |= + (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; + listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); + } else { /* reading number of logical volumes failed */ + + printk(KERN_WARNING "cciss: report logical volume" + " command failed\n"); + listlength = 0; + } + hba[cntl_num]->num_luns = listlength / 8; // 8 bytes pre entry + if (hba[cntl_num]->num_luns > CISS_MAX_LUN) { + printk(KERN_ERR + "ciss: only %d number of logical volumes supported\n", + CISS_MAX_LUN); + hba[cntl_num]->num_luns = CISS_MAX_LUN; + } +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "Length = %x %x %x %x = %d\n", + ld_buff->LUNListLength[0], ld_buff->LUNListLength[1], + ld_buff->LUNListLength[2], ld_buff->LUNListLength[3], + hba[cntl_num]->num_luns); +#endif /* CCISS_DEBUG */ + + hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns - 1; + for (i = 0; i < CISS_MAX_LUN; i++) { + if (i < hba[cntl_num]->num_luns) { + lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) + << 24; + lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) + << 16; + lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) + << 8; + lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); + + hba[cntl_num]->drv[i].LunID = lunid; + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "LUN[%d]: %x %x %x %x = %x\n", i, + ld_buff->LUN[i][0], ld_buff->LUN[i][1], + ld_buff->LUN[i][2], ld_buff->LUN[i][3], + hba[cntl_num]->drv[i].LunID); +#endif /* CCISS_DEBUG */ + + /* testing to see if 16-byte CDBs are already being used */ + if(hba[cntl_num]->cciss_read == CCISS_READ_16) { + cciss_read_capacity_16(cntl_num, i, 0, + &total_size, &block_size); + goto geo_inq; + } + cciss_read_capacity(cntl_num, i, 0, &total_size, &block_size); + + /* total_size = last LBA + 1 */ + if(total_size == (__u32) 0) { + cciss_read_capacity_16(cntl_num, i, 0, + &total_size, &block_size); + hba[cntl_num]->cciss_read = CCISS_READ_16; + hba[cntl_num]->cciss_write = CCISS_WRITE_16; + } else { + hba[cntl_num]->cciss_read = CCISS_READ_10; + hba[cntl_num]->cciss_write = CCISS_WRITE_10; + } +geo_inq: + cciss_geometry_inquiry(cntl_num, i, 0, total_size, + block_size, inq_buff, + &hba[cntl_num]->drv[i]); + } else { + /* initialize raid_level to indicate a free space */ + hba[cntl_num]->drv[i].raid_level = -1; + } + } + kfree(ld_buff); + kfree(inq_buff); +} + +/* Function to find the first free pointer into our hba[] array */ +/* Returns -1 if no free entries are left. */ +static int alloc_cciss_hba(void) +{ + struct gendisk *disk[NWD]; + int i, n; + for (n = 0; n < NWD; n++) { + disk[n] = alloc_disk(1 << NWD_SHIFT); + if (!disk[n]) + goto out; + } + + for (i = 0; i < MAX_CTLR; i++) { + if (!hba[i]) { + ctlr_info_t *p; + p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); + if (!p) + goto Enomem; + for (n = 0; n < NWD; n++) + p->gendisk[n] = disk[n]; + hba[i] = p; + return i; + } + } + printk(KERN_WARNING "cciss: This driver supports a maximum" + " of %d controllers.\n", MAX_CTLR); + goto out; + Enomem: + printk(KERN_ERR "cciss: out of memory.\n"); + out: + while (n--) + put_disk(disk[n]); + return -1; +} + +static void free_hba(int i) +{ + ctlr_info_t *p = hba[i]; + int n; + + hba[i] = NULL; + for (n = 0; n < NWD; n++) + put_disk(p->gendisk[n]); + kfree(p); +} + +/* + * This is it. Find all the controllers and register them. I really hate + * stealing all these major device numbers. + * returns the number of block devices registered. + */ +static int __devinit cciss_init_one(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + request_queue_t *q; + int i; + int j; + int rc; + int dac; + + i = alloc_cciss_hba(); + if (i < 0) + return -1; + + hba[i]->busy_initializing = 1; + + if (cciss_pci_init(hba[i], pdev) != 0) + goto clean1; + + sprintf(hba[i]->devname, "cciss%d", i); + hba[i]->ctlr = i; + hba[i]->pdev = pdev; + + /* configure PCI DMA stuff */ + if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) + dac = 1; + else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) + dac = 0; + else { + printk(KERN_ERR "cciss: no suitable DMA available\n"); + goto clean1; + } + + /* + * register with the major number, or get a dynamic major number + * by passing 0 as argument. This is done for greater than + * 8 controller support. + */ + if (i < MAX_CTLR_ORIG) + hba[i]->major = COMPAQ_CISS_MAJOR + i; + rc = register_blkdev(hba[i]->major, hba[i]->devname); + if (rc == -EBUSY || rc == -EINVAL) { + printk(KERN_ERR + "cciss: Unable to get major number %d for %s " + "on hba %d\n", hba[i]->major, hba[i]->devname, i); + goto clean1; + } else { + if (i >= MAX_CTLR_ORIG) + hba[i]->major = rc; + } + + /* make sure the board interrupts are off */ + hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_OFF); + if (request_irq(hba[i]->intr[SIMPLE_MODE_INT], do_cciss_intr, + IRQF_DISABLED | IRQF_SHARED, hba[i]->devname, hba[i])) { + printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", + hba[i]->intr[SIMPLE_MODE_INT], hba[i]->devname); + goto clean2; + } + + printk(KERN_INFO "%s: <0x%x> at PCI %s IRQ %d%s using DAC\n", + hba[i]->devname, pdev->device, pci_name(pdev), + hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); + + hba[i]->cmd_pool_bits = + kmalloc(((NR_CMDS + BITS_PER_LONG - + 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); + hba[i]->cmd_pool = (CommandList_struct *) + pci_alloc_consistent(hba[i]->pdev, + NR_CMDS * sizeof(CommandList_struct), + &(hba[i]->cmd_pool_dhandle)); + hba[i]->errinfo_pool = (ErrorInfo_struct *) + pci_alloc_consistent(hba[i]->pdev, + NR_CMDS * sizeof(ErrorInfo_struct), + &(hba[i]->errinfo_pool_dhandle)); + if ((hba[i]->cmd_pool_bits == NULL) + || (hba[i]->cmd_pool == NULL) + || (hba[i]->errinfo_pool == NULL)) { + printk(KERN_ERR "cciss: out of memory"); + goto clean4; + } +#ifdef CONFIG_CISS_SCSI_TAPE + hba[i]->scsi_rejects.complete = + kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) * + (NR_CMDS + 5), GFP_KERNEL); + if (hba[i]->scsi_rejects.complete == NULL) { + printk(KERN_ERR "cciss: out of memory"); + goto clean4; + } +#endif + spin_lock_init(&hba[i]->lock); + + /* Initialize the pdev driver private data. + have it point to hba[i]. */ + pci_set_drvdata(pdev, hba[i]); + /* command and error info recs zeroed out before + they are used */ + memset(hba[i]->cmd_pool_bits, 0, + ((NR_CMDS + BITS_PER_LONG - + 1) / BITS_PER_LONG) * sizeof(unsigned long)); + +#ifdef CCISS_DEBUG + printk(KERN_DEBUG "Scanning for drives on controller cciss%d\n", i); +#endif /* CCISS_DEBUG */ + + cciss_getgeometry(i); + + cciss_scsi_setup(i); + + /* Turn the interrupts on so we can service requests */ + hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON); + + cciss_procinit(i); + hba[i]->busy_initializing = 0; + + for (j = 0; j < NWD; j++) { /* mfm */ + drive_info_struct *drv = &(hba[i]->drv[j]); + struct gendisk *disk = hba[i]->gendisk[j]; + + q = blk_init_queue(do_cciss_request, &hba[i]->lock); + if (!q) { + printk(KERN_ERR + "cciss: unable to allocate queue for disk %d\n", + j); + break; + } + drv->queue = q; + + q->backing_dev_info.ra_pages = READ_AHEAD; + blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); + + /* This is a hardware imposed limit. */ + blk_queue_max_hw_segments(q, MAXSGENTRIES); + + /* This is a limit in the driver and could be eliminated. */ + blk_queue_max_phys_segments(q, MAXSGENTRIES); + + blk_queue_max_sectors(q, 512); + + blk_queue_softirq_done(q, cciss_softirq_done); + + q->queuedata = hba[i]; + sprintf(disk->disk_name, "cciss/c%dd%d", i, j); + disk->major = hba[i]->major; + disk->first_minor = j << NWD_SHIFT; + disk->fops = &cciss_fops; + disk->queue = q; + disk->private_data = drv; + disk->driverfs_dev = &pdev->dev; + /* we must register the controller even if no disks exist */ + /* this is for the online array utilities */ + if (!drv->heads && j) + continue; + blk_queue_hardsect_size(q, drv->block_size); + set_capacity(disk, drv->nr_blocks); + add_disk(disk); + } + + return 1; + + clean4: +#ifdef CONFIG_CISS_SCSI_TAPE + kfree(hba[i]->scsi_rejects.complete); +#endif + kfree(hba[i]->cmd_pool_bits); + if (hba[i]->cmd_pool) + pci_free_consistent(hba[i]->pdev, + NR_CMDS * sizeof(CommandList_struct), + hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); + if (hba[i]->errinfo_pool) + pci_free_consistent(hba[i]->pdev, + NR_CMDS * sizeof(ErrorInfo_struct), + hba[i]->errinfo_pool, + hba[i]->errinfo_pool_dhandle); + free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); + clean2: + unregister_blkdev(hba[i]->major, hba[i]->devname); + clean1: + hba[i]->busy_initializing = 0; + free_hba(i); + return -1; +} + +static void __devexit cciss_remove_one(struct pci_dev *pdev) +{ + ctlr_info_t *tmp_ptr; + int i, j; + char flush_buf[4]; + int return_code; + + if (pci_get_drvdata(pdev) == NULL) { + printk(KERN_ERR "cciss: Unable to remove device \n"); + return; + } + tmp_ptr = pci_get_drvdata(pdev); + i = tmp_ptr->ctlr; + if (hba[i] == NULL) { + printk(KERN_ERR "cciss: device appears to " + "already be removed \n"); + return; + } + /* Turn board interrupts off and send the flush cache command */ + /* sendcmd will turn off interrupt, and send the flush... + * To write all data in the battery backed cache to disks */ + memset(flush_buf, 0, 4); + return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL, + TYPE_CMD); + if (return_code != IO_OK) { + printk(KERN_WARNING "Error Flushing cache on controller %d\n", + i); + } + free_irq(hba[i]->intr[2], hba[i]); + +#ifdef CONFIG_PCI_MSI + if (hba[i]->msix_vector) + pci_disable_msix(hba[i]->pdev); + else if (hba[i]->msi_vector) + pci_disable_msi(hba[i]->pdev); +#endif /* CONFIG_PCI_MSI */ + + iounmap(hba[i]->vaddr); + cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ + unregister_blkdev(hba[i]->major, hba[i]->devname); + remove_proc_entry(hba[i]->devname, proc_cciss); + + /* remove it from the disk list */ + for (j = 0; j < NWD; j++) { + struct gendisk *disk = hba[i]->gendisk[j]; + if (disk) { + request_queue_t *q = disk->queue; + + if (disk->flags & GENHD_FL_UP) + del_gendisk(disk); + if (q) + blk_cleanup_queue(q); + } + } + + pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), + hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); + pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(ErrorInfo_struct), + hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); + kfree(hba[i]->cmd_pool_bits); +#ifdef CONFIG_CISS_SCSI_TAPE + kfree(hba[i]->scsi_rejects.complete); +#endif + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + free_hba(i); +} + +static struct pci_driver cciss_pci_driver = { + .name = "cciss", + .probe = cciss_init_one, + .remove = __devexit_p(cciss_remove_one), + .id_table = cciss_pci_device_id, /* id_table */ +}; + +/* + * This is it. Register the PCI driver information for the cards we control + * the OS will call our registered routines when it finds one of our cards. + */ +static int __init cciss_init(void) +{ + printk(KERN_INFO DRIVER_NAME "\n"); + + /* Register for our PCI devices */ + return pci_register_driver(&cciss_pci_driver); +} + +static void __exit cciss_cleanup(void) +{ + int i; + + pci_unregister_driver(&cciss_pci_driver); + /* double check that all controller entrys have been removed */ + for (i = 0; i < MAX_CTLR; i++) { + if (hba[i] != NULL) { + printk(KERN_WARNING "cciss: had to remove" + " controller %d\n", i); + cciss_remove_one(hba[i]->pdev); + } + } + remove_proc_entry("cciss", proc_root_driver); +} + +static void fail_all_cmds(unsigned long ctlr) +{ + /* If we get here, the board is apparently dead. */ + ctlr_info_t *h = hba[ctlr]; + CommandList_struct *c; + unsigned long flags; + + printk(KERN_WARNING "cciss%d: controller not responding.\n", h->ctlr); + h->alive = 0; /* the controller apparently died... */ + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + + pci_disable_device(h->pdev); /* Make sure it is really dead. */ + + /* move everything off the request queue onto the completed queue */ + while ((c = h->reqQ) != NULL) { + removeQ(&(h->reqQ), c); + h->Qdepth--; + addQ(&(h->cmpQ), c); + } + + /* Now, fail everything on the completed queue with a HW error */ + while ((c = h->cmpQ) != NULL) { + removeQ(&h->cmpQ, c); + c->err_info->CommandStatus = CMD_HARDWARE_ERR; + if (c->cmd_type == CMD_RWREQ) { + complete_command(h, c, 0); + } else if (c->cmd_type == CMD_IOCTL_PEND) + complete(c->waiting); +#ifdef CONFIG_CISS_SCSI_TAPE + else if (c->cmd_type == CMD_SCSI) + complete_scsi_command(c, 0, 0); +#endif + } + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + return; +} + +module_init(cciss_init); +module_exit(cciss_cleanup); diff --git a/ddverify/case_studies/block/cciss/cciss.h b/ddverify/case_studies/block/cciss/cciss.h new file mode 100644 index 000000000..562235c14 --- /dev/null +++ b/ddverify/case_studies/block/cciss/cciss.h @@ -0,0 +1,290 @@ +#ifndef CCISS_H +#define CCISS_H + +#include + +#include "cciss_cmd.h" + + +#define NWD 16 +#define NWD_SHIFT 4 +#define MAX_PART (1 << NWD_SHIFT) + +#define IO_OK 0 +#define IO_ERROR 1 + +struct ctlr_info; +typedef struct ctlr_info ctlr_info_t; + +struct access_method { + void (*submit_command)(ctlr_info_t *h, CommandList_struct *c); + void (*set_intr_mask)(ctlr_info_t *h, unsigned long val); + unsigned long (*fifo_full)(ctlr_info_t *h); + unsigned long (*intr_pending)(ctlr_info_t *h); + unsigned long (*command_completed)(ctlr_info_t *h); +}; +typedef struct _drive_info_struct +{ + __u32 LunID; + int usage_count; + struct request_queue *queue; + sector_t nr_blocks; + int block_size; + int heads; + int sectors; + int cylinders; + int raid_level; /* set to -1 to indicate that + * the drive is not in use/configured + */ + int busy_configuring; /*This is set when the drive is being removed + *to prevent it from being opened or it's queue + *from being started. + */ +} drive_info_struct; + +#ifdef CONFIG_CISS_SCSI_TAPE + +struct sendcmd_reject_list { + int ncompletions; + unsigned long *complete; /* array of NR_CMDS tags */ +}; + +#endif +struct ctlr_info +{ + int ctlr; + char devname[8]; + char *product_name; + char firm_ver[4]; // Firmware version + struct pci_dev *pdev; + __u32 board_id; + void __iomem *vaddr; + unsigned long paddr; + CfgTable_struct __iomem *cfgtable; + int interrupts_enabled; + int major; + int max_commands; + int commands_outstanding; + int max_outstanding; /* Debug */ + int num_luns; + int highest_lun; + int usage_count; /* number of opens all all minor devices */ +# define DOORBELL_INT 0 +# define PERF_MODE_INT 1 +# define SIMPLE_MODE_INT 2 +# define MEMQ_MODE_INT 3 + unsigned int intr[4]; + unsigned int msix_vector; + unsigned int msi_vector; + BYTE cciss_read; + BYTE cciss_write; + BYTE cciss_read_capacity; + + // information about each logical volume + drive_info_struct drv[CISS_MAX_LUN]; + + struct access_method access; + + /* queue and queue Info */ + CommandList_struct *reqQ; + CommandList_struct *cmpQ; + unsigned int Qdepth; + unsigned int maxQsinceinit; + unsigned int maxSG; + spinlock_t lock; + + //* pointers to command and error info pool */ + CommandList_struct *cmd_pool; + dma_addr_t cmd_pool_dhandle; + ErrorInfo_struct *errinfo_pool; + dma_addr_t errinfo_pool_dhandle; + unsigned long *cmd_pool_bits; + int nr_allocs; + int nr_frees; + int busy_configuring; + int busy_initializing; + + /* This element holds the zero based queue number of the last + * queue to be started. It is used for fairness. + */ + int next_to_run; + + // Disk structures we need to pass back + struct gendisk *gendisk[NWD]; +#ifdef CONFIG_CISS_SCSI_TAPE + void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ + /* list of block side commands the scsi error handling sucked up */ + /* and saved for later processing */ + struct sendcmd_reject_list scsi_rejects; +#endif + unsigned char alive; +}; + +/* Defining the diffent access_menthods */ +/* + * Memory mapped FIFO interface (SMART 53xx cards) + */ +#define SA5_DOORBELL 0x20 +#define SA5_REQUEST_PORT_OFFSET 0x40 +#define SA5_REPLY_INTR_MASK_OFFSET 0x34 +#define SA5_REPLY_PORT_OFFSET 0x44 +#define SA5_INTR_STATUS 0x30 +#define SA5_SCRATCHPAD_OFFSET 0xB0 + +#define SA5_CTCFG_OFFSET 0xB4 +#define SA5_CTMEM_OFFSET 0xB8 + +#define SA5_INTR_OFF 0x08 +#define SA5B_INTR_OFF 0x04 +#define SA5_INTR_PENDING 0x08 +#define SA5B_INTR_PENDING 0x04 +#define FIFO_EMPTY 0xffffffff +#define CCISS_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */ + +#define CISS_ERROR_BIT 0x02 + +#define CCISS_INTR_ON 1 +#define CCISS_INTR_OFF 0 +/* + Send the command to the hardware +*/ +static void SA5_submit_command( ctlr_info_t *h, CommandList_struct *c) +{ +#ifdef CCISS_DEBUG + printk("Sending %x - down to controller\n", c->busaddr ); +#endif /* CCISS_DEBUG */ + writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); + h->commands_outstanding++; + if ( h->commands_outstanding > h->max_outstanding) + h->max_outstanding = h->commands_outstanding; +} + +/* + * This card is the opposite of the other cards. + * 0 turns interrupts on... + * 0x08 turns them off... + */ +static void SA5_intr_mask(ctlr_info_t *h, unsigned long val) +{ + if (val) + { /* Turn interrupts on */ + h->interrupts_enabled = 1; + writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET); + } else /* Turn them off */ + { + h->interrupts_enabled = 0; + writel( SA5_INTR_OFF, + h->vaddr + SA5_REPLY_INTR_MASK_OFFSET); + } +} +/* + * This card is the opposite of the other cards. + * 0 turns interrupts on... + * 0x04 turns them off... + */ +static void SA5B_intr_mask(ctlr_info_t *h, unsigned long val) +{ + if (val) + { /* Turn interrupts on */ + h->interrupts_enabled = 1; + writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET); + } else /* Turn them off */ + { + h->interrupts_enabled = 0; + writel( SA5B_INTR_OFF, + h->vaddr + SA5_REPLY_INTR_MASK_OFFSET); + } +} +/* + * Returns true if fifo is full. + * + */ +static unsigned long SA5_fifo_full(ctlr_info_t *h) +{ + if( h->commands_outstanding >= h->max_commands) + return(1); + else + return(0); + +} +/* + * returns value read from hardware. + * returns FIFO_EMPTY if there is nothing to read + */ +static unsigned long SA5_completed(ctlr_info_t *h) +{ + unsigned long register_value + = readl(h->vaddr + SA5_REPLY_PORT_OFFSET); + if(register_value != FIFO_EMPTY) + { + h->commands_outstanding--; +#ifdef CCISS_DEBUG + printk("cciss: Read %lx back from board\n", register_value); +#endif /* CCISS_DEBUG */ + } +#ifdef CCISS_DEBUG + else + { + printk("cciss: FIFO Empty read\n"); + } +#endif + return ( register_value); + +} +/* + * Returns true if an interrupt is pending.. + */ +static unsigned long SA5_intr_pending(ctlr_info_t *h) +{ + unsigned long register_value = + readl(h->vaddr + SA5_INTR_STATUS); +#ifdef CCISS_DEBUG + printk("cciss: intr_pending %lx\n", register_value); +#endif /* CCISS_DEBUG */ + if( register_value & SA5_INTR_PENDING) + return 1; + return 0 ; +} + +/* + * Returns true if an interrupt is pending.. + */ +static unsigned long SA5B_intr_pending(ctlr_info_t *h) +{ + unsigned long register_value = + readl(h->vaddr + SA5_INTR_STATUS); +#ifdef CCISS_DEBUG + printk("cciss: intr_pending %lx\n", register_value); +#endif /* CCISS_DEBUG */ + if( register_value & SA5B_INTR_PENDING) + return 1; + return 0 ; +} + + +static struct access_method SA5_access = { + SA5_submit_command, + SA5_intr_mask, + SA5_fifo_full, + SA5_intr_pending, + SA5_completed, +}; + +static struct access_method SA5B_access = { + SA5_submit_command, + SA5B_intr_mask, + SA5_fifo_full, + SA5B_intr_pending, + SA5_completed, +}; + +struct board_type { + __u32 board_id; + char *product_name; + struct access_method *access; +}; + +#define CCISS_LOCK(i) (&hba[i]->lock) + +#endif /* CCISS_H */ + diff --git a/ddverify/case_studies/block/cciss/cciss_cmd.h b/ddverify/case_studies/block/cciss/cciss_cmd.h new file mode 100644 index 000000000..4af7c4c0c --- /dev/null +++ b/ddverify/case_studies/block/cciss/cciss_cmd.h @@ -0,0 +1,298 @@ +#ifndef CCISS_CMD_H +#define CCISS_CMD_H +//########################################################################### +//DEFINES +//########################################################################### +#define CISS_VERSION "1.00" + +//general boundary defintions +#define SENSEINFOBYTES 32//note that this value may vary between host implementations +#define MAXSGENTRIES 31 +#define MAXREPLYQS 256 + +//Command Status value +#define CMD_SUCCESS 0x0000 +#define CMD_TARGET_STATUS 0x0001 +#define CMD_DATA_UNDERRUN 0x0002 +#define CMD_DATA_OVERRUN 0x0003 +#define CMD_INVALID 0x0004 +#define CMD_PROTOCOL_ERR 0x0005 +#define CMD_HARDWARE_ERR 0x0006 +#define CMD_CONNECTION_LOST 0x0007 +#define CMD_ABORTED 0x0008 +#define CMD_ABORT_FAILED 0x0009 +#define CMD_UNSOLICITED_ABORT 0x000A +#define CMD_TIMEOUT 0x000B +#define CMD_UNABORTABLE 0x000C + +//transfer direction +#define XFER_NONE 0x00 +#define XFER_WRITE 0x01 +#define XFER_READ 0x02 +#define XFER_RSVD 0x03 + +//task attribute +#define ATTR_UNTAGGED 0x00 +#define ATTR_SIMPLE 0x04 +#define ATTR_HEADOFQUEUE 0x05 +#define ATTR_ORDERED 0x06 +#define ATTR_ACA 0x07 + +//cdb type +#define TYPE_CMD 0x00 +#define TYPE_MSG 0x01 + +//config space register offsets +#define CFG_VENDORID 0x00 +#define CFG_DEVICEID 0x02 +#define CFG_I2OBAR 0x10 +#define CFG_MEM1BAR 0x14 + +//i2o space register offsets +#define I2O_IBDB_SET 0x20 +#define I2O_IBDB_CLEAR 0x70 +#define I2O_INT_STATUS 0x30 +#define I2O_INT_MASK 0x34 +#define I2O_IBPOST_Q 0x40 +#define I2O_OBPOST_Q 0x44 + +//Configuration Table +#define CFGTBL_ChangeReq 0x00000001l +#define CFGTBL_AccCmds 0x00000001l + +#define CFGTBL_Trans_Simple 0x00000002l + +#define CFGTBL_BusType_Ultra2 0x00000001l +#define CFGTBL_BusType_Ultra3 0x00000002l +#define CFGTBL_BusType_Fibre1G 0x00000100l +#define CFGTBL_BusType_Fibre2G 0x00000200l +typedef struct _vals32 +{ + __u32 lower; + __u32 upper; +} vals32; + +typedef union _u64bit +{ + vals32 val32; + __u64 val; +} u64bit; + +// Type defs used in the following structs +#define BYTE __u8 +#define WORD __u16 +#define HWORD __u16 +#define DWORD __u32 +#define QWORD vals32 + +//########################################################################### +//STRUCTURES +//########################################################################### +#define CISS_MAX_LUN 16 +#define CISS_MAX_PHYS_LUN 1024 +// SCSI-3 Cmmands + +#pragma pack(1) + +#define CISS_INQUIRY 0x12 +//Date returned +typedef struct _InquiryData_struct +{ + BYTE data_byte[36]; +} InquiryData_struct; + +#define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ +#define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ +// Data returned +typedef struct _ReportLUNdata_struct +{ + BYTE LUNListLength[4]; + DWORD reserved; + BYTE LUN[CISS_MAX_LUN][8]; +} ReportLunData_struct; + +#define CCISS_READ_CAPACITY 0x25 /* Read Capacity */ +typedef struct _ReadCapdata_struct +{ + BYTE total_size[4]; // Total size in blocks + BYTE block_size[4]; // Size of blocks in bytes +} ReadCapdata_struct; + +#define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */ + +/* service action to differentiate a 16 byte read capacity from + other commands that use the 0x9e SCSI op code */ + +#define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10 + +typedef struct _ReadCapdata_struct_16 +{ + BYTE total_size[8]; /* Total size in blocks */ + BYTE block_size[4]; /* Size of blocks in bytes */ + BYTE prot_en:1; /* protection enable bit */ + BYTE rto_en:1; /* reference tag own enable bit */ + BYTE reserved:6; /* reserved bits */ + BYTE reserved2[18]; /* reserved bytes per spec */ +} ReadCapdata_struct_16; + +/* Define the supported read/write commands for cciss based controllers */ + +#define CCISS_READ_10 0x28 /* Read(10) */ +#define CCISS_WRITE_10 0x2a /* Write(10) */ +#define CCISS_READ_16 0x88 /* Read(16) */ +#define CCISS_WRITE_16 0x8a /* Write(16) */ + +/* Define the CDB lengths supported by cciss based controllers */ + +#define CDB_LEN10 10 +#define CDB_LEN16 16 + +// BMIC commands +#define BMIC_READ 0x26 +#define BMIC_WRITE 0x27 +#define BMIC_CACHE_FLUSH 0xc2 +#define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS + +//Command List Structure +typedef union _SCSI3Addr_struct { + struct { + BYTE Dev; + BYTE Bus:6; + BYTE Mode:2; // b00 + } PeripDev; + struct { + BYTE DevLSB; + BYTE DevMSB:6; + BYTE Mode:2; // b01 + } LogDev; + struct { + BYTE Dev:5; + BYTE Bus:3; + BYTE Targ:6; + BYTE Mode:2; // b10 + } LogUnit; +} SCSI3Addr_struct; + +typedef struct _PhysDevAddr_struct { + DWORD TargetId:24; + DWORD Bus:6; + DWORD Mode:2; + SCSI3Addr_struct Target[2]; //2 level target device addr +} PhysDevAddr_struct; + +typedef struct _LogDevAddr_struct { + DWORD VolId:30; + DWORD Mode:2; + BYTE reserved[4]; +} LogDevAddr_struct; + +typedef union _LUNAddr_struct { + BYTE LunAddrBytes[8]; + SCSI3Addr_struct SCSI3Lun[4]; + PhysDevAddr_struct PhysDev; + LogDevAddr_struct LogDev; +} LUNAddr_struct; + +typedef struct _CommandListHeader_struct { + BYTE ReplyQueue; + BYTE SGList; + HWORD SGTotal; + QWORD Tag; + LUNAddr_struct LUN; +} CommandListHeader_struct; +typedef struct _RequestBlock_struct { + BYTE CDBLen; + struct { + BYTE Type:3; + BYTE Attribute:3; + BYTE Direction:2; + } Type; + HWORD Timeout; + BYTE CDB[16]; +} RequestBlock_struct; +typedef struct _ErrDescriptor_struct { + QWORD Addr; + DWORD Len; +} ErrDescriptor_struct; +typedef struct _SGDescriptor_struct { + QWORD Addr; + DWORD Len; + DWORD Ext; +} SGDescriptor_struct; + +typedef union _MoreErrInfo_struct{ + struct { + BYTE Reserved[3]; + BYTE Type; + DWORD ErrorInfo; + }Common_Info; + struct{ + BYTE Reserved[2]; + BYTE offense_size;//size of offending entry + BYTE offense_num; //byte # of offense 0-base + DWORD offense_value; + }Invalid_Cmd; +}MoreErrInfo_struct; +typedef struct _ErrorInfo_struct { + BYTE ScsiStatus; + BYTE SenseLen; + HWORD CommandStatus; + DWORD ResidualCnt; + MoreErrInfo_struct MoreErrInfo; + BYTE SenseInfo[SENSEINFOBYTES]; +} ErrorInfo_struct; + +/* Command types */ +#define CMD_RWREQ 0x00 +#define CMD_IOCTL_PEND 0x01 +#define CMD_SCSI 0x03 +#define CMD_MSG_DONE 0x04 +#define CMD_MSG_TIMEOUT 0x05 + +/* This structure needs to be divisible by 8 for new + * indexing method. + */ +#define PADSIZE (sizeof(long) - 4) +typedef struct _CommandList_struct { + CommandListHeader_struct Header; + RequestBlock_struct Request; + ErrDescriptor_struct ErrDesc; + SGDescriptor_struct SG[MAXSGENTRIES]; + /* information associated with the command */ + __u32 busaddr; /* physical address of this record */ + ErrorInfo_struct * err_info; /* pointer to the allocated mem */ + int ctlr; + int cmd_type; + long cmdindex; + struct _CommandList_struct *prev; + struct _CommandList_struct *next; + struct request * rq; + struct completion *waiting; + int retry_count; + void * scsi_cmd; + char pad[PADSIZE]; +} CommandList_struct; + +//Configuration Table Structure +typedef struct _HostWrite_struct { + DWORD TransportRequest; + DWORD Reserved; + DWORD CoalIntDelay; + DWORD CoalIntCount; +} HostWrite_struct; + +typedef struct _CfgTable_struct { + BYTE Signature[4]; + DWORD SpecValence; + DWORD TransportSupport; + DWORD TransportActive; + HostWrite_struct HostWrite; + DWORD CmdsOutMax; + DWORD BusTypes; + DWORD Reserved; + BYTE ServerName[16]; + DWORD HeartBeat; + DWORD SCSI_Prefetch; +} CfgTable_struct; +#pragma pack() +#endif // CCISS_CMD_H diff --git a/ddverify/case_studies/block/cciss/cciss_scsi.c b/ddverify/case_studies/block/cciss/cciss_scsi.c new file mode 100644 index 000000000..bb15051ff --- /dev/null +++ b/ddverify/case_studies/block/cciss/cciss_scsi.c @@ -0,0 +1,1535 @@ +/* + * Disk Array driver for Compaq SA53xx Controllers, SCSI Tape module + * Copyright 2001 Compaq Computer Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to iss_storagedev@hp.com + * + * Author: Stephen M. Cameron + */ +#ifdef CONFIG_CISS_SCSI_TAPE + +/* Here we have code to present the driver as a scsi driver + as it is simultaneously presented as a block driver. The + reason for doing this is to allow access to SCSI tape drives + through the array controller. Note in particular, neither + physical nor logical disks are presented through the scsi layer. */ + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "cciss_scsi.h" + +#define CCISS_ABORT_MSG 0x00 +#define CCISS_RESET_MSG 0x01 + +/* some prototypes... */ +static int sendcmd( + __u8 cmd, + int ctlr, + void *buff, + size_t size, + unsigned int use_unit_num, /* 0: address the controller, + 1: address logical volume log_unit, + 2: address is in scsi3addr */ + unsigned int log_unit, + __u8 page_code, + unsigned char *scsi3addr, + int cmd_type); + + +static int cciss_scsi_proc_info( + struct Scsi_Host *sh, + char *buffer, /* data buffer */ + char **start, /* where data in buffer starts */ + off_t offset, /* offset from start of imaginary file */ + int length, /* length of data in buffer */ + int func); /* 0 == read, 1 == write */ + +static int cciss_scsi_queue_command (struct scsi_cmnd *cmd, + void (* done)(struct scsi_cmnd *)); +static int cciss_eh_device_reset_handler(struct scsi_cmnd *); +static int cciss_eh_abort_handler(struct scsi_cmnd *); + +static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = { + { .name = "cciss0", .ndevices = 0 }, + { .name = "cciss1", .ndevices = 0 }, + { .name = "cciss2", .ndevices = 0 }, + { .name = "cciss3", .ndevices = 0 }, + { .name = "cciss4", .ndevices = 0 }, + { .name = "cciss5", .ndevices = 0 }, + { .name = "cciss6", .ndevices = 0 }, + { .name = "cciss7", .ndevices = 0 }, +}; + +static struct scsi_host_template cciss_driver_template = { + .module = THIS_MODULE, + .name = "cciss", + .proc_name = "cciss", + .proc_info = cciss_scsi_proc_info, + .queuecommand = cciss_scsi_queue_command, + .can_queue = SCSI_CCISS_CAN_QUEUE, + .this_id = 7, + .sg_tablesize = MAXSGENTRIES, + .cmd_per_lun = 1, + .use_clustering = DISABLE_CLUSTERING, + /* Can't have eh_bus_reset_handler or eh_host_reset_handler for cciss */ + .eh_device_reset_handler= cciss_eh_device_reset_handler, + .eh_abort_handler = cciss_eh_abort_handler, +}; + +#pragma pack(1) +struct cciss_scsi_cmd_stack_elem_t { + CommandList_struct cmd; + ErrorInfo_struct Err; + __u32 busaddr; + __u32 pad; +}; + +#pragma pack() + +#define CMD_STACK_SIZE (SCSI_CCISS_CAN_QUEUE * \ + CCISS_MAX_SCSI_DEVS_PER_HBA + 2) + // plus two for init time usage + +#pragma pack(1) +struct cciss_scsi_cmd_stack_t { + struct cciss_scsi_cmd_stack_elem_t *pool; + struct cciss_scsi_cmd_stack_elem_t *elem[CMD_STACK_SIZE]; + dma_addr_t cmd_pool_handle; + int top; +}; +#pragma pack() + +struct cciss_scsi_adapter_data_t { + struct Scsi_Host *scsi_host; + struct cciss_scsi_cmd_stack_t cmd_stack; + int registered; + spinlock_t lock; // to protect ccissscsi[ctlr]; +}; + +#define CPQ_TAPE_LOCK(ctlr, flags) spin_lock_irqsave( \ + &(((struct cciss_scsi_adapter_data_t *) \ + hba[ctlr]->scsi_ctlr)->lock), flags); +#define CPQ_TAPE_UNLOCK(ctlr, flags) spin_unlock_irqrestore( \ + &(((struct cciss_scsi_adapter_data_t *) \ + hba[ctlr]->scsi_ctlr)->lock), flags); + +static CommandList_struct * +scsi_cmd_alloc(ctlr_info_t *h) +{ + /* assume only one process in here at a time, locking done by caller. */ + /* use CCISS_LOCK(ctlr) */ + /* might be better to rewrite how we allocate scsi commands in a way that */ + /* needs no locking at all. */ + + /* take the top memory chunk off the stack and return it, if any. */ + struct cciss_scsi_cmd_stack_elem_t *c; + struct cciss_scsi_adapter_data_t *sa; + struct cciss_scsi_cmd_stack_t *stk; + u64bit temp64; + + sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr; + stk = &sa->cmd_stack; + + if (stk->top < 0) + return NULL; + c = stk->elem[stk->top]; + /* memset(c, 0, sizeof(*c)); */ + memset(&c->cmd, 0, sizeof(c->cmd)); + memset(&c->Err, 0, sizeof(c->Err)); + /* set physical addr of cmd and addr of scsi parameters */ + c->cmd.busaddr = c->busaddr; + /* (__u32) (stk->cmd_pool_handle + + (sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top)); */ + + temp64.val = (__u64) (c->busaddr + sizeof(CommandList_struct)); + /* (__u64) (stk->cmd_pool_handle + + (sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top) + + sizeof(CommandList_struct)); */ + stk->top--; + c->cmd.ErrDesc.Addr.lower = temp64.val32.lower; + c->cmd.ErrDesc.Addr.upper = temp64.val32.upper; + c->cmd.ErrDesc.Len = sizeof(ErrorInfo_struct); + + c->cmd.ctlr = h->ctlr; + c->cmd.err_info = &c->Err; + + return (CommandList_struct *) c; +} + +static void +scsi_cmd_free(ctlr_info_t *h, CommandList_struct *cmd) +{ + /* assume only one process in here at a time, locking done by caller. */ + /* use CCISS_LOCK(ctlr) */ + /* drop the free memory chunk on top of the stack. */ + + struct cciss_scsi_adapter_data_t *sa; + struct cciss_scsi_cmd_stack_t *stk; + + sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr; + stk = &sa->cmd_stack; + if (stk->top >= CMD_STACK_SIZE) { + printk("cciss: scsi_cmd_free called too many times.\n"); + BUG(); + } + stk->top++; + stk->elem[stk->top] = (struct cciss_scsi_cmd_stack_elem_t *) cmd; +} + +static int +scsi_cmd_stack_setup(int ctlr, struct cciss_scsi_adapter_data_t *sa) +{ + int i; + struct cciss_scsi_cmd_stack_t *stk; + size_t size; + + stk = &sa->cmd_stack; + size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; + + // pci_alloc_consistent guarantees 32-bit DMA address will + // be used + + stk->pool = (struct cciss_scsi_cmd_stack_elem_t *) + pci_alloc_consistent(hba[ctlr]->pdev, size, &stk->cmd_pool_handle); + + if (stk->pool == NULL) { + printk("stk->pool is null\n"); + return -1; + } + + for (i=0; ielem[i] = &stk->pool[i]; + stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle + + (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i)); + } + stk->top = CMD_STACK_SIZE-1; + return 0; +} + +static void +scsi_cmd_stack_free(int ctlr) +{ + struct cciss_scsi_adapter_data_t *sa; + struct cciss_scsi_cmd_stack_t *stk; + size_t size; + + sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; + stk = &sa->cmd_stack; + if (stk->top != CMD_STACK_SIZE-1) { + printk( "cciss: %d scsi commands are still outstanding.\n", + CMD_STACK_SIZE - stk->top); + // BUG(); + printk("WE HAVE A BUG HERE!!! stk=0x%p\n", stk); + } + size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; + + pci_free_consistent(hba[ctlr]->pdev, size, stk->pool, stk->cmd_pool_handle); + stk->pool = NULL; +} + +#if 0 +static int xmargin=8; +static int amargin=60; + +static void +print_bytes (unsigned char *c, int len, int hex, int ascii) +{ + + int i; + unsigned char *x; + + if (hex) + { + x = c; + for (i=0;i0) printk("\n"); + if ((i % xmargin) == 0) printk("0x%04x:", i); + printk(" %02x", *x); + x++; + } + printk("\n"); + } + if (ascii) + { + x = c; + for (i=0;i0) printk("\n"); + if ((i % amargin) == 0) printk("0x%04x:", i); + if (*x > 26 && *x < 128) printk("%c", *x); + else printk("."); + x++; + } + printk("\n"); + } +} + +static void +print_cmd(CommandList_struct *cp) +{ + printk("queue:%d\n", cp->Header.ReplyQueue); + printk("sglist:%d\n", cp->Header.SGList); + printk("sgtot:%d\n", cp->Header.SGTotal); + printk("Tag:0x%08x/0x%08x\n", cp->Header.Tag.upper, + cp->Header.Tag.lower); + printk("LUN:0x%02x%02x%02x%02x%02x%02x%02x%02x\n", + cp->Header.LUN.LunAddrBytes[0], + cp->Header.LUN.LunAddrBytes[1], + cp->Header.LUN.LunAddrBytes[2], + cp->Header.LUN.LunAddrBytes[3], + cp->Header.LUN.LunAddrBytes[4], + cp->Header.LUN.LunAddrBytes[5], + cp->Header.LUN.LunAddrBytes[6], + cp->Header.LUN.LunAddrBytes[7]); + printk("CDBLen:%d\n", cp->Request.CDBLen); + printk("Type:%d\n",cp->Request.Type.Type); + printk("Attr:%d\n",cp->Request.Type.Attribute); + printk(" Dir:%d\n",cp->Request.Type.Direction); + printk("Timeout:%d\n",cp->Request.Timeout); + printk( "CDB: %02x %02x %02x %02x %02x %02x %02x %02x" + " %02x %02x %02x %02x %02x %02x %02x %02x\n", + cp->Request.CDB[0], cp->Request.CDB[1], + cp->Request.CDB[2], cp->Request.CDB[3], + cp->Request.CDB[4], cp->Request.CDB[5], + cp->Request.CDB[6], cp->Request.CDB[7], + cp->Request.CDB[8], cp->Request.CDB[9], + cp->Request.CDB[10], cp->Request.CDB[11], + cp->Request.CDB[12], cp->Request.CDB[13], + cp->Request.CDB[14], cp->Request.CDB[15]), + printk("edesc.Addr: 0x%08x/0%08x, Len = %d\n", + cp->ErrDesc.Addr.upper, cp->ErrDesc.Addr.lower, + cp->ErrDesc.Len); + printk("sgs..........Errorinfo:\n"); + printk("scsistatus:%d\n", cp->err_info->ScsiStatus); + printk("senselen:%d\n", cp->err_info->SenseLen); + printk("cmd status:%d\n", cp->err_info->CommandStatus); + printk("resid cnt:%d\n", cp->err_info->ResidualCnt); + printk("offense size:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size); + printk("offense byte:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num); + printk("offense value:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value); + +} + +#endif + +static int +find_bus_target_lun(int ctlr, int *bus, int *target, int *lun) +{ + /* finds an unused bus, target, lun for a new device */ + /* assumes hba[ctlr]->scsi_ctlr->lock is held */ + int i, found=0; + unsigned char target_taken[CCISS_MAX_SCSI_DEVS_PER_HBA]; + + memset(&target_taken[0], 0, CCISS_MAX_SCSI_DEVS_PER_HBA); + + target_taken[SELF_SCSI_ID] = 1; + for (i=0;iscsi_ctlr->lock is held */ + int n = ccissscsi[ctlr].ndevices; + struct cciss_scsi_dev_t *sd; + + if (n >= CCISS_MAX_SCSI_DEVS_PER_HBA) { + printk("cciss%d: Too many devices, " + "some will be inaccessible.\n", ctlr); + return -1; + } + sd = &ccissscsi[ctlr].dev[n]; + if (find_bus_target_lun(ctlr, &sd->bus, &sd->target, &sd->lun) != 0) + return -1; + memcpy(&sd->scsi3addr[0], scsi3addr, 8); + sd->devtype = devtype; + ccissscsi[ctlr].ndevices++; + + /* initially, (before registering with scsi layer) we don't + know our hostno and we don't want to print anything first + time anyway (the scsi layer's inquiries will show that info) */ + if (hostno != -1) + printk("cciss%d: %s device c%db%dt%dl%d added.\n", + ctlr, scsi_device_type(sd->devtype), hostno, + sd->bus, sd->target, sd->lun); + return 0; +} + +static void +cciss_scsi_remove_entry(int ctlr, int hostno, int entry) +{ + /* assumes hba[ctlr]->scsi_ctlr->lock is held */ + int i; + struct cciss_scsi_dev_t sd; + + if (entry < 0 || entry >= CCISS_MAX_SCSI_DEVS_PER_HBA) return; + sd = ccissscsi[ctlr].dev[entry]; + for (i=entry;iscsi3addr)) { + if (sd[j].devtype == csd->devtype) + found=2; + else + found=1; + break; + } + } + + if (found == 0) { /* device no longer present. */ + changes++; + /* printk("cciss%d: %s device c%db%dt%dl%d removed.\n", + ctlr, scsi_device_type(csd->devtype), hostno, + csd->bus, csd->target, csd->lun); */ + cciss_scsi_remove_entry(ctlr, hostno, i); + /* note, i not incremented */ + } + else if (found == 1) { /* device is different kind */ + changes++; + printk("cciss%d: device c%db%dt%dl%d type changed " + "(device type now %s).\n", + ctlr, hostno, csd->bus, csd->target, csd->lun, + scsi_device_type(csd->devtype)); + csd->devtype = sd[j].devtype; + i++; /* so just move along. */ + } else /* device is same as it ever was, */ + i++; /* so just move along. */ + } + + /* Now, make sure every device listed in sd[] is also + listed in ccissscsi[], adding them if they aren't found */ + + for (i=0;iscsi3addr)) { + if (sd[i].devtype == csd->devtype) + found=2; /* found device */ + else + found=1; /* found a bug. */ + break; + } + } + if (!found) { + changes++; + if (cciss_scsi_add_entry(ctlr, hostno, + &sd[i].scsi3addr[0], sd[i].devtype) != 0) + break; + } else if (found == 1) { + /* should never happen... */ + changes++; + printk("cciss%d: device unexpectedly changed type\n", + ctlr); + /* but if it does happen, we just ignore that device */ + } + } + CPQ_TAPE_UNLOCK(ctlr, flags); + + if (!changes) + printk("cciss%d: No device changes detected.\n", ctlr); + + return 0; +} + +static int +lookup_scsi3addr(int ctlr, int bus, int target, int lun, char *scsi3addr) +{ + int i; + struct cciss_scsi_dev_t *sd; + unsigned long flags; + + CPQ_TAPE_LOCK(ctlr, flags); + for (i=0;ibus == bus && + sd->target == target && + sd->lun == lun) { + memcpy(scsi3addr, &sd->scsi3addr[0], 8); + CPQ_TAPE_UNLOCK(ctlr, flags); + return 0; + } + } + CPQ_TAPE_UNLOCK(ctlr, flags); + return -1; +} + +static void +cciss_scsi_setup(int cntl_num) +{ + struct cciss_scsi_adapter_data_t * shba; + + ccissscsi[cntl_num].ndevices = 0; + shba = (struct cciss_scsi_adapter_data_t *) + kmalloc(sizeof(*shba), GFP_KERNEL); + if (shba == NULL) + return; + shba->scsi_host = NULL; + spin_lock_init(&shba->lock); + shba->registered = 0; + if (scsi_cmd_stack_setup(cntl_num, shba) != 0) { + kfree(shba); + shba = NULL; + } + hba[cntl_num]->scsi_ctlr = (void *) shba; + return; +} + +static void +complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag) +{ + struct scsi_cmnd *cmd; + ctlr_info_t *ctlr; + u64bit addr64; + ErrorInfo_struct *ei; + + ei = cp->err_info; + + /* First, see if it was a message rather than a command */ + if (cp->Request.Type.Type == TYPE_MSG) { + cp->cmd_type = CMD_MSG_DONE; + return; + } + + cmd = (struct scsi_cmnd *) cp->scsi_cmd; + ctlr = hba[cp->ctlr]; + + /* undo the DMA mappings */ + + if (cmd->use_sg) { + pci_unmap_sg(ctlr->pdev, + cmd->request_buffer, cmd->use_sg, + cmd->sc_data_direction); + } + else if (cmd->request_bufflen) { + addr64.val32.lower = cp->SG[0].Addr.lower; + addr64.val32.upper = cp->SG[0].Addr.upper; + pci_unmap_single(ctlr->pdev, (dma_addr_t) addr64.val, + cmd->request_bufflen, + cmd->sc_data_direction); + } + + cmd->result = (DID_OK << 16); /* host byte */ + cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */ + /* cmd->result |= (GOOD < 1); */ /* status byte */ + + cmd->result |= (ei->ScsiStatus); + /* printk("Scsistatus is 0x%02x\n", ei->ScsiStatus); */ + + /* copy the sense data whether we need to or not. */ + + memcpy(cmd->sense_buffer, ei->SenseInfo, + ei->SenseLen > SCSI_SENSE_BUFFERSIZE ? + SCSI_SENSE_BUFFERSIZE : + ei->SenseLen); + cmd->resid = ei->ResidualCnt; + + if(ei->CommandStatus != 0) + { /* an error has occurred */ + switch(ei->CommandStatus) + { + case CMD_TARGET_STATUS: + /* Pass it up to the upper layers... */ + if( ei->ScsiStatus) + { +#if 0 + printk(KERN_WARNING "cciss: cmd %p " + "has SCSI Status = %x\n", + cp, + ei->ScsiStatus); +#endif + cmd->result |= (ei->ScsiStatus < 1); + } + else { /* scsi status is zero??? How??? */ + + /* Ordinarily, this case should never happen, but there is a bug + in some released firmware revisions that allows it to happen + if, for example, a 4100 backplane loses power and the tape + drive is in it. We assume that it's a fatal error of some + kind because we can't show that it wasn't. We will make it + look like selection timeout since that is the most common + reason for this to occur, and it's severe enough. */ + + cmd->result = DID_NO_CONNECT << 16; + } + break; + case CMD_DATA_UNDERRUN: /* let mid layer handle it. */ + break; + case CMD_DATA_OVERRUN: + printk(KERN_WARNING "cciss: cp %p has" + " completed with data overrun " + "reported\n", cp); + break; + case CMD_INVALID: { + /* print_bytes(cp, sizeof(*cp), 1, 0); + print_cmd(cp); */ + /* We get CMD_INVALID if you address a non-existent tape drive instead + of a selection timeout (no response). You will see this if you yank + out a tape drive, then try to access it. This is kind of a shame + because it means that any other CMD_INVALID (e.g. driver bug) will + get interpreted as a missing target. */ + cmd->result = DID_NO_CONNECT << 16; + } + break; + case CMD_PROTOCOL_ERR: + printk(KERN_WARNING "cciss: cp %p has " + "protocol error \n", cp); + break; + case CMD_HARDWARE_ERR: + cmd->result = DID_ERROR << 16; + printk(KERN_WARNING "cciss: cp %p had " + " hardware error\n", cp); + break; + case CMD_CONNECTION_LOST: + cmd->result = DID_ERROR << 16; + printk(KERN_WARNING "cciss: cp %p had " + "connection lost\n", cp); + break; + case CMD_ABORTED: + cmd->result = DID_ABORT << 16; + printk(KERN_WARNING "cciss: cp %p was " + "aborted\n", cp); + break; + case CMD_ABORT_FAILED: + cmd->result = DID_ERROR << 16; + printk(KERN_WARNING "cciss: cp %p reports " + "abort failed\n", cp); + break; + case CMD_UNSOLICITED_ABORT: + cmd->result = DID_ABORT << 16; + printk(KERN_WARNING "cciss: cp %p aborted " + "do to an unsolicited abort\n", cp); + break; + case CMD_TIMEOUT: + cmd->result = DID_TIME_OUT << 16; + printk(KERN_WARNING "cciss: cp %p timedout\n", + cp); + break; + default: + cmd->result = DID_ERROR << 16; + printk(KERN_WARNING "cciss: cp %p returned " + "unknown status %x\n", cp, + ei->CommandStatus); + } + } + // printk("c:%p:c%db%dt%dl%d ", cmd, ctlr->ctlr, cmd->channel, + // cmd->target, cmd->lun); + cmd->scsi_done(cmd); + scsi_cmd_free(ctlr, cp); +} + +static int +cciss_scsi_detect(int ctlr) +{ + struct Scsi_Host *sh; + int error; + + sh = scsi_host_alloc(&cciss_driver_template, sizeof(struct ctlr_info *)); + if (sh == NULL) + goto fail; + sh->io_port = 0; // good enough? FIXME, + sh->n_io_port = 0; // I don't think we use these two... + sh->this_id = SELF_SCSI_ID; + + ((struct cciss_scsi_adapter_data_t *) + hba[ctlr]->scsi_ctlr)->scsi_host = (void *) sh; + sh->hostdata[0] = (unsigned long) hba[ctlr]; + sh->irq = hba[ctlr]->intr[SIMPLE_MODE_INT]; + sh->unique_id = sh->irq; + error = scsi_add_host(sh, &hba[ctlr]->pdev->dev); + if (error) + goto fail_host_put; + scsi_scan_host(sh); + return 1; + + fail_host_put: + scsi_host_put(sh); + fail: + return 0; +} + +static void +cciss_unmap_one(struct pci_dev *pdev, + CommandList_struct *cp, + size_t buflen, + int data_direction) +{ + u64bit addr64; + + addr64.val32.lower = cp->SG[0].Addr.lower; + addr64.val32.upper = cp->SG[0].Addr.upper; + pci_unmap_single(pdev, (dma_addr_t) addr64.val, buflen, data_direction); +} + +static void +cciss_map_one(struct pci_dev *pdev, + CommandList_struct *cp, + unsigned char *buf, + size_t buflen, + int data_direction) +{ + __u64 addr64; + + addr64 = (__u64) pci_map_single(pdev, buf, buflen, data_direction); + cp->SG[0].Addr.lower = + (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF); + cp->SG[0].Addr.upper = + (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF); + cp->SG[0].Len = buflen; + cp->Header.SGList = (__u8) 1; /* no. SGs contig in this cmd */ + cp->Header.SGTotal = (__u16) 1; /* total sgs in this cmd list */ +} + +static int +cciss_scsi_do_simple_cmd(ctlr_info_t *c, + CommandList_struct *cp, + unsigned char *scsi3addr, + unsigned char *cdb, + unsigned char cdblen, + unsigned char *buf, int bufsize, + int direction) +{ + unsigned long flags; + DECLARE_COMPLETION_ONSTACK(wait); + + cp->cmd_type = CMD_IOCTL_PEND; // treat this like an ioctl + cp->scsi_cmd = NULL; + cp->Header.ReplyQueue = 0; // unused in simple mode + memcpy(&cp->Header.LUN, scsi3addr, sizeof(cp->Header.LUN)); + cp->Header.Tag.lower = cp->busaddr; // Use k. address of cmd as tag + // Fill in the request block... + + /* printk("Using scsi3addr 0x%02x%0x2%0x2%0x2%0x2%0x2%0x2%0x2\n", + scsi3addr[0], scsi3addr[1], scsi3addr[2], scsi3addr[3], + scsi3addr[4], scsi3addr[5], scsi3addr[6], scsi3addr[7]); */ + + memset(cp->Request.CDB, 0, sizeof(cp->Request.CDB)); + memcpy(cp->Request.CDB, cdb, cdblen); + cp->Request.Timeout = 0; + cp->Request.CDBLen = cdblen; + cp->Request.Type.Type = TYPE_CMD; + cp->Request.Type.Attribute = ATTR_SIMPLE; + cp->Request.Type.Direction = direction; + + /* Fill in the SG list and do dma mapping */ + cciss_map_one(c->pdev, cp, (unsigned char *) buf, + bufsize, DMA_FROM_DEVICE); + + cp->waiting = &wait; + + /* Put the request on the tail of the request queue */ + spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags); + addQ(&c->reqQ, cp); + c->Qdepth++; + start_io(c); + spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags); + + wait_for_completion(&wait); + + /* undo the dma mapping */ + cciss_unmap_one(c->pdev, cp, bufsize, DMA_FROM_DEVICE); + return(0); +} + +static void +cciss_scsi_interpret_error(CommandList_struct *cp) +{ + ErrorInfo_struct *ei; + + ei = cp->err_info; + switch(ei->CommandStatus) + { + case CMD_TARGET_STATUS: + printk(KERN_WARNING "cciss: cmd %p has " + "completed with errors\n", cp); + printk(KERN_WARNING "cciss: cmd %p " + "has SCSI Status = %x\n", + cp, + ei->ScsiStatus); + if (ei->ScsiStatus == 0) + printk(KERN_WARNING + "cciss:SCSI status is abnormally zero. " + "(probably indicates selection timeout " + "reported incorrectly due to a known " + "firmware bug, circa July, 2001.)\n"); + break; + case CMD_DATA_UNDERRUN: /* let mid layer handle it. */ + printk("UNDERRUN\n"); + break; + case CMD_DATA_OVERRUN: + printk(KERN_WARNING "cciss: cp %p has" + " completed with data overrun " + "reported\n", cp); + break; + case CMD_INVALID: { + /* controller unfortunately reports SCSI passthru's */ + /* to non-existent targets as invalid commands. */ + printk(KERN_WARNING "cciss: cp %p is " + "reported invalid (probably means " + "target device no longer present)\n", + cp); + /* print_bytes((unsigned char *) cp, sizeof(*cp), 1, 0); + print_cmd(cp); */ + } + break; + case CMD_PROTOCOL_ERR: + printk(KERN_WARNING "cciss: cp %p has " + "protocol error \n", cp); + break; + case CMD_HARDWARE_ERR: + /* cmd->result = DID_ERROR << 16; */ + printk(KERN_WARNING "cciss: cp %p had " + " hardware error\n", cp); + break; + case CMD_CONNECTION_LOST: + printk(KERN_WARNING "cciss: cp %p had " + "connection lost\n", cp); + break; + case CMD_ABORTED: + printk(KERN_WARNING "cciss: cp %p was " + "aborted\n", cp); + break; + case CMD_ABORT_FAILED: + printk(KERN_WARNING "cciss: cp %p reports " + "abort failed\n", cp); + break; + case CMD_UNSOLICITED_ABORT: + printk(KERN_WARNING "cciss: cp %p aborted " + "do to an unsolicited abort\n", cp); + break; + case CMD_TIMEOUT: + printk(KERN_WARNING "cciss: cp %p timedout\n", + cp); + break; + default: + printk(KERN_WARNING "cciss: cp %p returned " + "unknown status %x\n", cp, + ei->CommandStatus); + } +} + +static int +cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, + unsigned char *buf, unsigned char bufsize) +{ + int rc; + CommandList_struct *cp; + char cdb[6]; + ErrorInfo_struct *ei; + unsigned long flags; + + spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags); + cp = scsi_cmd_alloc(c); + spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags); + + if (cp == NULL) { /* trouble... */ + printk("cmd_alloc returned NULL!\n"); + return -1; + } + + ei = cp->err_info; + + cdb[0] = CISS_INQUIRY; + cdb[1] = 0; + cdb[2] = 0; + cdb[3] = 0; + cdb[4] = bufsize; + cdb[5] = 0; + rc = cciss_scsi_do_simple_cmd(c, cp, scsi3addr, cdb, + 6, buf, bufsize, XFER_READ); + + if (rc != 0) return rc; /* something went wrong */ + + if (ei->CommandStatus != 0 && + ei->CommandStatus != CMD_DATA_UNDERRUN) { + cciss_scsi_interpret_error(cp); + rc = -1; + } + spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags); + scsi_cmd_free(c, cp); + spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags); + return rc; +} + +static int +cciss_scsi_do_report_phys_luns(ctlr_info_t *c, + ReportLunData_struct *buf, int bufsize) +{ + int rc; + CommandList_struct *cp; + unsigned char cdb[12]; + unsigned char scsi3addr[8]; + ErrorInfo_struct *ei; + unsigned long flags; + + spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags); + cp = scsi_cmd_alloc(c); + spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags); + if (cp == NULL) { /* trouble... */ + printk("cmd_alloc returned NULL!\n"); + return -1; + } + + memset(&scsi3addr[0], 0, 8); /* address the controller */ + cdb[0] = CISS_REPORT_PHYS; + cdb[1] = 0; + cdb[2] = 0; + cdb[3] = 0; + cdb[4] = 0; + cdb[5] = 0; + cdb[6] = (bufsize >> 24) & 0xFF; //MSB + cdb[7] = (bufsize >> 16) & 0xFF; + cdb[8] = (bufsize >> 8) & 0xFF; + cdb[9] = bufsize & 0xFF; + cdb[10] = 0; + cdb[11] = 0; + + rc = cciss_scsi_do_simple_cmd(c, cp, scsi3addr, + cdb, 12, + (unsigned char *) buf, + bufsize, XFER_READ); + + if (rc != 0) return rc; /* something went wrong */ + + ei = cp->err_info; + if (ei->CommandStatus != 0 && + ei->CommandStatus != CMD_DATA_UNDERRUN) { + cciss_scsi_interpret_error(cp); + rc = -1; + } + spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags); + scsi_cmd_free(c, cp); + spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags); + return rc; +} + +static void +cciss_update_non_disk_devices(int cntl_num, int hostno) +{ + /* the idea here is we could get notified from /proc + that some devices have changed, so we do a report + physical luns cmd, and adjust our list of devices + accordingly. (We can't rely on the scsi-mid layer just + doing inquiries, because the "busses" that the scsi + mid-layer probes are totally fabricated by this driver, + so new devices wouldn't show up. + + the scsi3addr's of devices won't change so long as the + adapter is not reset. That means we can rescan and + tell which devices we already know about, vs. new + devices, vs. disappearing devices. + + Also, if you yank out a tape drive, then put in a disk + in it's place, (say, a configured volume from another + array controller for instance) _don't_ poke this driver + (so it thinks it's still a tape, but _do_ poke the scsi + mid layer, so it does an inquiry... the scsi mid layer + will see the physical disk. This would be bad. Need to + think about how to prevent that. One idea would be to + snoop all scsi responses and if an inquiry repsonse comes + back that reports a disk, chuck it an return selection + timeout instead and adjust our table... Not sure i like + that though. + + */ +#define OBDR_TAPE_INQ_SIZE 49 +#define OBDR_TAPE_SIG "$DR-10" + ReportLunData_struct *ld_buff; + unsigned char *inq_buff; + unsigned char scsi3addr[8]; + ctlr_info_t *c; + __u32 num_luns=0; + unsigned char *ch; + /* unsigned char found[CCISS_MAX_SCSI_DEVS_PER_HBA]; */ + struct cciss_scsi_dev_t currentsd[CCISS_MAX_SCSI_DEVS_PER_HBA]; + int ncurrent=0; + int reportlunsize = sizeof(*ld_buff) + CISS_MAX_PHYS_LUN * 8; + int i; + + c = (ctlr_info_t *) hba[cntl_num]; + ld_buff = kzalloc(reportlunsize, GFP_KERNEL); + if (ld_buff == NULL) { + printk(KERN_ERR "cciss: out of memory\n"); + return; + } + inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); + if (inq_buff == NULL) { + printk(KERN_ERR "cciss: out of memory\n"); + kfree(ld_buff); + return; + } + + if (cciss_scsi_do_report_phys_luns(c, ld_buff, reportlunsize) == 0) { + ch = &ld_buff->LUNListLength[0]; + num_luns = ((ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | ch[3]) / 8; + if (num_luns > CISS_MAX_PHYS_LUN) { + printk(KERN_WARNING + "cciss: Maximum physical LUNs (%d) exceeded. " + "%d LUNs ignored.\n", CISS_MAX_PHYS_LUN, + num_luns - CISS_MAX_PHYS_LUN); + num_luns = CISS_MAX_PHYS_LUN; + } + } + else { + printk(KERN_ERR "cciss: Report physical LUNs failed.\n"); + goto out; + } + + + /* adjust our table of devices */ + for(i=0; iLUN[i][3] & 0xC0) continue; + memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE); + memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8); + + if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, inq_buff, + (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) { + /* Inquiry failed (msg printed already) */ + devtype = 0; /* so we will skip this device. */ + } else /* what kind of device is this? */ + devtype = (inq_buff[0] & 0x1f); + + switch (devtype) + { + case 0x05: /* CD-ROM */ { + + /* We don't *really* support actual CD-ROM devices, + * just this "One Button Disaster Recovery" tape drive + * which temporarily pretends to be a CD-ROM drive. + * So we check that the device is really an OBDR tape + * device by checking for "$DR-10" in bytes 43-48 of + * the inquiry data. + */ + char obdr_sig[7]; + + strncpy(obdr_sig, &inq_buff[43], 6); + obdr_sig[6] = '\0'; + if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0) + /* Not OBDR device, ignore it. */ + break; + } + /* fall through . . . */ + case 0x01: /* sequential access, (tape) */ + case 0x08: /* medium changer */ + if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) { + printk(KERN_INFO "cciss%d: %s ignored, " + "too many devices.\n", cntl_num, + scsi_device_type(devtype)); + break; + } + memcpy(¤tsd[ncurrent].scsi3addr[0], + &scsi3addr[0], 8); + currentsd[ncurrent].devtype = devtype; + currentsd[ncurrent].bus = -1; + currentsd[ncurrent].target = -1; + currentsd[ncurrent].lun = -1; + ncurrent++; + break; + default: + break; + } + } + + adjust_cciss_scsi_table(cntl_num, hostno, currentsd, ncurrent); +out: + kfree(inq_buff); + kfree(ld_buff); + return; +} + +static int +is_keyword(char *ptr, int len, char *verb) // Thanks to ncr53c8xx.c +{ + int verb_len = strlen(verb); + if (len >= verb_len && !memcmp(verb,ptr,verb_len)) + return verb_len; + else + return 0; +} + +static int +cciss_scsi_user_command(int ctlr, int hostno, char *buffer, int length) +{ + int arg_len; + + if ((arg_len = is_keyword(buffer, length, "rescan")) != 0) + cciss_update_non_disk_devices(ctlr, hostno); + else + return -EINVAL; + return length; +} + + +static int +cciss_scsi_proc_info(struct Scsi_Host *sh, + char *buffer, /* data buffer */ + char **start, /* where data in buffer starts */ + off_t offset, /* offset from start of imaginary file */ + int length, /* length of data in buffer */ + int func) /* 0 == read, 1 == write */ +{ + + int buflen, datalen; + ctlr_info_t *ci; + int i; + int cntl_num; + + + ci = (ctlr_info_t *) sh->hostdata[0]; + if (ci == NULL) /* This really shouldn't ever happen. */ + return -EINVAL; + + cntl_num = ci->ctlr; /* Get our index into the hba[] array */ + + if (func == 0) { /* User is reading from /proc/scsi/ciss*?/?* */ + buflen = sprintf(buffer, "cciss%d: SCSI host: %d\n", + cntl_num, sh->host_no); + + /* this information is needed by apps to know which cciss + device corresponds to which scsi host number without + having to open a scsi target device node. The device + information is not a duplicate of /proc/scsi/scsi because + the two may be out of sync due to scsi hotplug, rather + this info is for an app to be able to use to know how to + get them back in sync. */ + + for (i=0;ihost_no, sd->bus, sd->target, sd->lun, + sd->devtype, + sd->scsi3addr[0], sd->scsi3addr[1], + sd->scsi3addr[2], sd->scsi3addr[3], + sd->scsi3addr[4], sd->scsi3addr[5], + sd->scsi3addr[6], sd->scsi3addr[7]); + } + datalen = buflen - offset; + if (datalen < 0) { /* they're reading past EOF. */ + datalen = 0; + *start = buffer+buflen; + } else + *start = buffer + offset; + return(datalen); + } else /* User is writing to /proc/scsi/cciss*?/?* ... */ + return cciss_scsi_user_command(cntl_num, sh->host_no, + buffer, length); +} + +/* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci + dma mapping and fills in the scatter gather entries of the + cciss command, cp. */ + +static void +cciss_scatter_gather(struct pci_dev *pdev, + CommandList_struct *cp, + struct scsi_cmnd *cmd) +{ + unsigned int use_sg, nsegs=0, len; + struct scatterlist *scatter = (struct scatterlist *) cmd->request_buffer; + __u64 addr64; + + /* is it just one virtual address? */ + if (!cmd->use_sg) { + if (cmd->request_bufflen) { /* anything to xfer? */ + + addr64 = (__u64) pci_map_single(pdev, + cmd->request_buffer, + cmd->request_bufflen, + cmd->sc_data_direction); + + cp->SG[0].Addr.lower = + (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF); + cp->SG[0].Addr.upper = + (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF); + cp->SG[0].Len = cmd->request_bufflen; + nsegs=1; + } + } /* else, must be a list of virtual addresses.... */ + else if (cmd->use_sg <= MAXSGENTRIES) { /* not too many addrs? */ + + use_sg = pci_map_sg(pdev, cmd->request_buffer, cmd->use_sg, + cmd->sc_data_direction); + + for (nsegs=0; nsegs < use_sg; nsegs++) { + addr64 = (__u64) sg_dma_address(&scatter[nsegs]); + len = sg_dma_len(&scatter[nsegs]); + cp->SG[nsegs].Addr.lower = + (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF); + cp->SG[nsegs].Addr.upper = + (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF); + cp->SG[nsegs].Len = len; + cp->SG[nsegs].Ext = 0; // we are not chaining + } + } else BUG(); + + cp->Header.SGList = (__u8) nsegs; /* no. SGs contig in this cmd */ + cp->Header.SGTotal = (__u16) nsegs; /* total sgs in this cmd list */ + return; +} + + +static int +cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) +{ + ctlr_info_t **c; + int ctlr, rc; + unsigned char scsi3addr[8]; + CommandList_struct *cp; + unsigned long flags; + + // Get the ptr to our adapter structure (hba[i]) out of cmd->host. + // We violate cmd->host privacy here. (Is there another way?) + c = (ctlr_info_t **) &cmd->device->host->hostdata[0]; + ctlr = (*c)->ctlr; + + rc = lookup_scsi3addr(ctlr, cmd->device->channel, cmd->device->id, + cmd->device->lun, scsi3addr); + if (rc != 0) { + /* the scsi nexus does not match any that we presented... */ + /* pretend to mid layer that we got selection timeout */ + cmd->result = DID_NO_CONNECT << 16; + done(cmd); + /* we might want to think about registering controller itself + as a processor device on the bus so sg binds to it. */ + return 0; + } + + /* printk("cciss_queue_command, p=%p, cmd=0x%02x, c%db%dt%dl%d\n", + cmd, cmd->cmnd[0], ctlr, cmd->channel, cmd->target, cmd->lun);*/ + // printk("q:%p:c%db%dt%dl%d ", cmd, ctlr, cmd->channel, + // cmd->target, cmd->lun); + + /* Ok, we have a reasonable scsi nexus, so send the cmd down, and + see what the device thinks of it. */ + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + cp = scsi_cmd_alloc(*c); + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + if (cp == NULL) { /* trouble... */ + printk("scsi_cmd_alloc returned NULL!\n"); + /* FIXME: next 3 lines are -> BAD! <- */ + cmd->result = DID_NO_CONNECT << 16; + done(cmd); + return 0; + } + + // Fill in the command list header + + cmd->scsi_done = done; // save this for use by completion code + + // save cp in case we have to abort it + cmd->host_scribble = (unsigned char *) cp; + + cp->cmd_type = CMD_SCSI; + cp->scsi_cmd = cmd; + cp->Header.ReplyQueue = 0; // unused in simple mode + memcpy(&cp->Header.LUN.LunAddrBytes[0], &scsi3addr[0], 8); + cp->Header.Tag.lower = cp->busaddr; // Use k. address of cmd as tag + + // Fill in the request block... + + cp->Request.Timeout = 0; + memset(cp->Request.CDB, 0, sizeof(cp->Request.CDB)); + BUG_ON(cmd->cmd_len > sizeof(cp->Request.CDB)); + cp->Request.CDBLen = cmd->cmd_len; + memcpy(cp->Request.CDB, cmd->cmnd, cmd->cmd_len); + cp->Request.Type.Type = TYPE_CMD; + cp->Request.Type.Attribute = ATTR_SIMPLE; + switch(cmd->sc_data_direction) + { + case DMA_TO_DEVICE: cp->Request.Type.Direction = XFER_WRITE; break; + case DMA_FROM_DEVICE: cp->Request.Type.Direction = XFER_READ; break; + case DMA_NONE: cp->Request.Type.Direction = XFER_NONE; break; + case DMA_BIDIRECTIONAL: + // This can happen if a buggy application does a scsi passthru + // and sets both inlen and outlen to non-zero. ( see + // ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() ) + + cp->Request.Type.Direction = XFER_RSVD; + // This is technically wrong, and cciss controllers should + // reject it with CMD_INVALID, which is the most correct + // response, but non-fibre backends appear to let it + // slide by, and give the same results as if this field + // were set correctly. Either way is acceptable for + // our purposes here. + + break; + + default: + printk("cciss: unknown data direction: %d\n", + cmd->sc_data_direction); + BUG(); + break; + } + + cciss_scatter_gather((*c)->pdev, cp, cmd); // Fill the SG list + + /* Put the request on the tail of the request queue */ + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + addQ(&(*c)->reqQ, cp); + (*c)->Qdepth++; + start_io(*c); + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + + /* the cmd'll come back via intr handler in complete_scsi_command() */ + return 0; +} + +static void +cciss_unregister_scsi(int ctlr) +{ + struct cciss_scsi_adapter_data_t *sa; + struct cciss_scsi_cmd_stack_t *stk; + unsigned long flags; + + /* we are being forcibly unloaded, and may not refuse. */ + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; + stk = &sa->cmd_stack; + + /* if we weren't ever actually registered, don't unregister */ + if (sa->registered) { + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + scsi_remove_host(sa->scsi_host); + scsi_host_put(sa->scsi_host); + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + } + + /* set scsi_host to NULL so our detect routine will + find us on register */ + sa->scsi_host = NULL; + scsi_cmd_stack_free(ctlr); + kfree(sa); + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); +} + +static int +cciss_register_scsi(int ctlr) +{ + unsigned long flags; + + CPQ_TAPE_LOCK(ctlr, flags); + + /* Since this is really a block driver, the SCSI core may not be + initialized at init time, in which case, calling scsi_register_host + would hang. Instead, we do it later, via /proc filesystem + and rc scripts, when we know SCSI core is good to go. */ + + /* Only register if SCSI devices are detected. */ + if (ccissscsi[ctlr].ndevices != 0) { + ((struct cciss_scsi_adapter_data_t *) + hba[ctlr]->scsi_ctlr)->registered = 1; + CPQ_TAPE_UNLOCK(ctlr, flags); + return cciss_scsi_detect(ctlr); + } + CPQ_TAPE_UNLOCK(ctlr, flags); + printk(KERN_INFO + "cciss%d: No appropriate SCSI device detected, " + "SCSI subsystem not engaged.\n", ctlr); + return 0; +} + +static int +cciss_engage_scsi(int ctlr) +{ + struct cciss_scsi_adapter_data_t *sa; + struct cciss_scsi_cmd_stack_t *stk; + unsigned long flags; + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr; + stk = &sa->cmd_stack; + + if (((struct cciss_scsi_adapter_data_t *) + hba[ctlr]->scsi_ctlr)->registered) { + printk("cciss%d: SCSI subsystem already engaged.\n", ctlr); + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + return ENXIO; + } + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + cciss_update_non_disk_devices(ctlr, -1); + cciss_register_scsi(ctlr); + return 0; +} + +static void +cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len) +{ + unsigned long flags; + int size; + + *pos = *pos -1; *len = *len - 1; // cut off the last trailing newline + + CPQ_TAPE_LOCK(ctlr, flags); + size = sprintf(buffer + *len, + "Sequential access devices: %d\n\n", + ccissscsi[ctlr].ndevices); + CPQ_TAPE_UNLOCK(ctlr, flags); + *pos += size; *len += size; +} + +/* Need at least one of these error handlers to keep ../scsi/hosts.c from + * complaining. Doing a host- or bus-reset can't do anything good here. + * Despite what it might say in scsi_error.c, there may well be commands + * on the controller, as the cciss driver registers twice, once as a block + * device for the logical drives, and once as a scsi device, for any tape + * drives. So we know there are no commands out on the tape drives, but we + * don't know there are no commands on the controller, and it is likely + * that there probably are, as the cciss block device is most commonly used + * as a boot device (embedded controller on HP/Compaq systems.) +*/ + +static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd) +{ + int rc; + CommandList_struct *cmd_in_trouble; + ctlr_info_t **c; + int ctlr; + + /* find the controller to which the command to be aborted was sent */ + c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0]; + if (c == NULL) /* paranoia */ + return FAILED; + ctlr = (*c)->ctlr; + printk(KERN_WARNING "cciss%d: resetting tape drive or medium changer.\n", ctlr); + + /* find the command that's giving us trouble */ + cmd_in_trouble = (CommandList_struct *) scsicmd->host_scribble; + if (cmd_in_trouble == NULL) { /* paranoia */ + return FAILED; + } + /* send a reset to the SCSI LUN which the command was sent to */ + rc = sendcmd(CCISS_RESET_MSG, ctlr, NULL, 0, 2, 0, 0, + (unsigned char *) &cmd_in_trouble->Header.LUN.LunAddrBytes[0], + TYPE_MSG); + /* sendcmd turned off interrputs on the board, turn 'em back on. */ + (*c)->access.set_intr_mask(*c, CCISS_INTR_ON); + if (rc == 0) + return SUCCESS; + printk(KERN_WARNING "cciss%d: resetting device failed.\n", ctlr); + return FAILED; +} + +static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd) +{ + int rc; + CommandList_struct *cmd_to_abort; + ctlr_info_t **c; + int ctlr; + + /* find the controller to which the command to be aborted was sent */ + c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0]; + if (c == NULL) /* paranoia */ + return FAILED; + ctlr = (*c)->ctlr; + printk(KERN_WARNING "cciss%d: aborting tardy SCSI cmd\n", ctlr); + + /* find the command to be aborted */ + cmd_to_abort = (CommandList_struct *) scsicmd->host_scribble; + if (cmd_to_abort == NULL) /* paranoia */ + return FAILED; + rc = sendcmd(CCISS_ABORT_MSG, ctlr, &cmd_to_abort->Header.Tag, + 0, 2, 0, 0, + (unsigned char *) &cmd_to_abort->Header.LUN.LunAddrBytes[0], + TYPE_MSG); + /* sendcmd turned off interrputs on the board, turn 'em back on. */ + (*c)->access.set_intr_mask(*c, CCISS_INTR_ON); + if (rc == 0) + return SUCCESS; + return FAILED; + +} + +#else /* no CONFIG_CISS_SCSI_TAPE */ + +/* If no tape support, then these become defined out of existence */ + +#define cciss_scsi_setup(cntl_num) +#define cciss_unregister_scsi(ctlr) +#define cciss_register_scsi(ctlr) +#define cciss_proc_tape_report(ctlr, buffer, pos, len) + +#endif /* CONFIG_CISS_SCSI_TAPE */ diff --git a/ddverify/case_studies/block/cciss/cciss_scsi.h b/ddverify/case_studies/block/cciss/cciss_scsi.h new file mode 100644 index 000000000..5e7e06c07 --- /dev/null +++ b/ddverify/case_studies/block/cciss/cciss_scsi.h @@ -0,0 +1,79 @@ +/* + * Disk Array driver for Compaq SA53xx Controllers, SCSI Tape module + * Copyright 2001 Compaq Computer Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to iss_storagedev@hp.com + * + */ +#ifdef CONFIG_CISS_SCSI_TAPE +#ifndef _CCISS_SCSI_H_ +#define _CCISS_SCSI_H_ + +#include /* possibly irrelevant, since we don't show disks */ + + // the scsi id of the adapter... +#define SELF_SCSI_ID 15 + // 15 is somewhat arbitrary, since the scsi-2 bus + // that's presented by the driver to the OS is + // fabricated. The "real" scsi-3 bus the + // hardware presents is fabricated too. + // The actual, honest-to-goodness physical + // bus that the devices are attached to is not + // addressible natively, and may in fact turn + // out to be not scsi at all. + +#define SCSI_CCISS_CAN_QUEUE 2 + +/* + +Note, cmd_per_lun could give us some trouble, so I'm setting it very low. +Likewise, SCSI_CCISS_CAN_QUEUE is set very conservatively. + +If the upper scsi layer tries to track how many commands we have +outstanding, it will be operating under the misapprehension that it is +the only one sending us requests. We also have the block interface, +which is where most requests must surely come from, so the upper layer's +notion of how many requests we have outstanding will be wrong most or +all of the time. + +Note, the normal SCSI mid-layer error handling doesn't work well +for this driver because 1) it takes the io_request_lock before +calling error handlers and uses a local variable to store flags, +so the io_request_lock cannot be released and interrupts enabled +inside the error handlers, and, the error handlers cannot poll +for command completion because they might get commands from the +block half of the driver completing, and not know what to do +with them. That's what we get for making a hybrid scsi/block +driver, I suppose. + +*/ + +struct cciss_scsi_dev_t { + int devtype; + int bus, target, lun; /* as presented to the OS */ + unsigned char scsi3addr[8]; /* as presented to the HW */ +}; + +struct cciss_scsi_hba_t { + char *name; + int ndevices; +#define CCISS_MAX_SCSI_DEVS_PER_HBA 16 + struct cciss_scsi_dev_t dev[CCISS_MAX_SCSI_DEVS_PER_HBA]; +}; + +#endif /* _CCISS_SCSI_H_ */ +#endif /* CONFIG_CISS_SCSI_TAPE */ diff --git a/ddverify/case_studies/block/cpqarray/cpqarray.c b/ddverify/case_studies/block/cpqarray/cpqarray.c new file mode 100644 index 000000000..c2960564c --- /dev/null +++ b/ddverify/case_studies/block/cpqarray/cpqarray.c @@ -0,0 +1,1850 @@ +/* + * Disk Array driver for Compaq SMART2 Controllers + * Copyright 1998 Compaq Computer Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to iss_storagedev@hp.com + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define SMART2_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) + +#define DRIVER_NAME "Compaq SMART2 Driver (v 2.6.0)" +#define DRIVER_VERSION SMART2_DRIVER_VERSION(2,6,0) + +/* Embedded module documentation macros - see modules.h */ +/* Original author Chris Frantz - Compaq Computer Corporation */ +MODULE_AUTHOR("Compaq Computer Corporation"); +MODULE_DESCRIPTION("Driver for Compaq Smart2 Array Controllers version 2.6.0"); +MODULE_LICENSE("GPL"); + +#include "cpqarray.h" +#include "ida_cmd.h" +#include "smart1,2.h" +#include "ida_ioctl.h" + +#define READ_AHEAD 128 +#define NR_CMDS 128 /* This could probably go as high as ~400 */ + +#define MAX_CTLR 8 +#define CTLR_SHIFT 8 + +#define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ + +int nr_ctlr; +ctlr_info_t *hba[MAX_CTLR]; + +int eisa[8]; + +#define NR_PRODUCTS ARRAY_SIZE(products) + +/* board_id = Subsystem Device ID & Vendor ID + * product = Marketing Name for the board + * access = Address of the struct of function pointers + */ +struct board_type products[] = { + { 0x0040110E, "IDA", &smart1_access }, + { 0x0140110E, "IDA-2", &smart1_access }, + { 0x1040110E, "IAES", &smart1_access }, + { 0x2040110E, "SMART", &smart1_access }, + { 0x3040110E, "SMART-2/E", &smart2e_access }, + { 0x40300E11, "SMART-2/P", &smart2_access }, + { 0x40310E11, "SMART-2SL", &smart2_access }, + { 0x40320E11, "Smart Array 3200", &smart2_access }, + { 0x40330E11, "Smart Array 3100ES", &smart2_access }, + { 0x40340E11, "Smart Array 221", &smart2_access }, + { 0x40400E11, "Integrated Array", &smart4_access }, + { 0x40480E11, "Compaq Raid LC2", &smart4_access }, + { 0x40500E11, "Smart Array 4200", &smart4_access }, + { 0x40510E11, "Smart Array 4250ES", &smart4_access }, + { 0x40580E11, "Smart Array 431", &smart4_access }, +}; + +/* define the PCI info for the PCI cards this driver can control */ +const struct pci_device_id cpqarray_pci_device_id[] = +{ + { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_COMPAQ_42XX, + 0x0E11, 0x4058, 0, 0, 0}, /* SA431 */ + { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_COMPAQ_42XX, + 0x0E11, 0x4051, 0, 0, 0}, /* SA4250ES */ + { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_COMPAQ_42XX, + 0x0E11, 0x4050, 0, 0, 0}, /* SA4200 */ + { PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C1510, + 0x0E11, 0x4048, 0, 0, 0}, /* LC2 */ + { PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C1510, + 0x0E11, 0x4040, 0, 0, 0}, /* Integrated Array */ + { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_SMART2P, + 0x0E11, 0x4034, 0, 0, 0}, /* SA 221 */ + { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_SMART2P, + 0x0E11, 0x4033, 0, 0, 0}, /* SA 3100ES*/ + { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_SMART2P, + 0x0E11, 0x4032, 0, 0, 0}, /* SA 3200*/ + { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_SMART2P, + 0x0E11, 0x4031, 0, 0, 0}, /* SA 2SL*/ + { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_SMART2P, + 0x0E11, 0x4030, 0, 0, 0}, /* SA 2P */ + { 0 } +}; + +MODULE_DEVICE_TABLE(pci, cpqarray_pci_device_id); + +struct gendisk *ida_gendisk[MAX_CTLR][NWD]; + +/* Debug... */ +#define DBG(s) do { s } while(0) +/* Debug (general info)... */ +#define DBGINFO(s) do { } while(0) +/* Debug Paranoid... */ +#define DBGP(s) do { } while(0) +/* Debug Extra Paranoid... */ +#define DBGPX(s) do { } while(0) + +int cpqarray_pci_init(ctlr_info_t *c, struct pci_dev *pdev); +void __iomem *remap_pci_mem(ulong base, ulong size); +int cpqarray_eisa_detect(void); +int pollcomplete(int ctlr); +void getgeometry(int ctlr); +void start_fwbk(int ctlr); + +cmdlist_t * cmd_alloc(ctlr_info_t *h, int get_from_pool); +void cmd_free(ctlr_info_t *h, cmdlist_t *c, int got_from_pool); + +void free_hba(int i); +int alloc_cpqarray_hba(void); + +int sendcmd( + __u8 cmd, + int ctlr, + void *buff, + size_t size, + unsigned int blk, + unsigned int blkcnt, + unsigned int log_unit ); + +int ida_open(struct inode *inode, struct file *filep); +int ida_release(struct inode *inode, struct file *filep); +int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg); +int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo); +int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); + +void do_ida_request(request_queue_t *q); +void start_io(ctlr_info_t *h); + +inline void addQ(cmdlist_t **Qptr, cmdlist_t *c); +inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c); +inline void complete_buffers(struct bio *bio, int ok); +inline void complete_command(cmdlist_t *cmd, int timeout); + +irqreturn_t do_ida_intr(int irq, void *dev_id); +void ida_timer(unsigned long tdata); +int ida_revalidate(struct gendisk *disk); +int revalidate_allvol(ctlr_info_t *host); +int cpqarray_register_ctlr(int ctlr, struct pci_dev *pdev); + +#ifdef CONFIG_PROC_FS +void ida_procinit(int i); +int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data); +#else +void ida_procinit(int i) {} +#endif + +inline drv_info_t *get_drv(struct gendisk *disk) +{ + return disk->private_data; +} + +inline ctlr_info_t *get_host(struct gendisk *disk) +{ + return disk->queue->queuedata; +} + + +struct block_device_operations ida_fops = { + .owner = THIS_MODULE, + .open = ida_open, + .release = ida_release, + .ioctl = ida_ioctl, + .getgeo = ida_getgeo, + .revalidate_disk= ida_revalidate, +}; + + +#ifdef CONFIG_PROC_FS + +struct proc_dir_entry *proc_array; + +/* + * Get us a file in /proc/array that says something about each controller. + * Create /proc/array if it doesn't exist yet. + */ +void __init ida_procinit(int i) +{ + if (proc_array == NULL) { + proc_array = proc_mkdir("cpqarray", proc_root_driver); + if (!proc_array) return; + } + + create_proc_read_entry(hba[i]->devname, 0, proc_array, + ida_proc_get_info, hba[i]); +} + +/* + * Report information about this controller. + */ +int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data) +{ + off_t pos = 0; + off_t len = 0; + int size, i, ctlr; + ctlr_info_t *h = (ctlr_info_t*)data; + drv_info_t *drv; +#ifdef CPQ_PROC_PRINT_QUEUES + cmdlist_t *c; + unsigned long flags; +#endif + + ctlr = h->ctlr; + size = sprintf(buffer, "%s: Compaq %s Controller\n" + " Board ID: 0x%08lx\n" + " Firmware Revision: %c%c%c%c\n" + " Controller Sig: 0x%08lx\n" + " Memory Address: 0x%08lx\n" + " I/O Port: 0x%04x\n" + " IRQ: %d\n" + " Logical drives: %d\n" + " Physical drives: %d\n\n" + " Current Q depth: %d\n" + " Max Q depth since init: %d\n\n", + h->devname, + h->product_name, + (unsigned long)h->board_id, + h->firm_rev[0], h->firm_rev[1], h->firm_rev[2], h->firm_rev[3], + (unsigned long)h->ctlr_sig, (unsigned long)h->vaddr, + (unsigned int) h->io_mem_addr, (unsigned int)h->intr, + h->log_drives, h->phys_drives, + h->Qdepth, h->maxQsinceinit); + + pos += size; len += size; + + size = sprintf(buffer+len, "Logical Drive Info:\n"); + pos += size; len += size; + + for(i=0; ilog_drives; i++) { + drv = &h->drv[i]; + size = sprintf(buffer+len, "ida/c%dd%d: blksz=%d nr_blks=%d\n", + ctlr, i, drv->blk_size, drv->nr_blks); + pos += size; len += size; + } + +#ifdef CPQ_PROC_PRINT_QUEUES + spin_lock_irqsave(IDA_LOCK(h->ctlr), flags); + size = sprintf(buffer+len, "\nCurrent Queues:\n"); + pos += size; len += size; + + c = h->reqQ; + size = sprintf(buffer+len, "reqQ = %p", c); pos += size; len += size; + if (c) c=c->next; + while(c && c != h->reqQ) { + size = sprintf(buffer+len, "->%p", c); + pos += size; len += size; + c=c->next; + } + + c = h->cmpQ; + size = sprintf(buffer+len, "\ncmpQ = %p", c); pos += size; len += size; + if (c) c=c->next; + while(c && c != h->cmpQ) { + size = sprintf(buffer+len, "->%p", c); + pos += size; len += size; + c=c->next; + } + + size = sprintf(buffer+len, "\n"); pos += size; len += size; + spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); +#endif + size = sprintf(buffer+len, "nr_allocs = %d\nnr_frees = %d\n", + h->nr_allocs, h->nr_frees); + pos += size; len += size; + + *eof = 1; + *start = buffer+offset; + len -= offset; + if (len>length) + len = length; + return len; +} +#endif /* CONFIG_PROC_FS */ + +module_param_array(eisa, int, NULL, 0); + +void release_io_mem(ctlr_info_t *c) +{ + /* if IO mem was not protected do nothing */ + if( c->io_mem_addr == 0) + return; + release_region(c->io_mem_addr, c->io_mem_length); + c->io_mem_addr = 0; + c->io_mem_length = 0; +} + +void __devexit cpqarray_remove_one(int i) +{ + int j; + char buff[4]; + + /* sendcmd will turn off interrupt, and send the flush... + * To write all data in the battery backed cache to disks + * no data returned, but don't want to send NULL to sendcmd */ + if( sendcmd(FLUSH_CACHE, i, buff, 4, 0, 0, 0)) + { + printk(KERN_WARNING "Unable to flush cache on controller %d\n", + i); + } + free_irq(hba[i]->intr, hba[i]); + iounmap(hba[i]->vaddr); + unregister_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname); + del_timer(&hba[i]->timer); + remove_proc_entry(hba[i]->devname, proc_array); + pci_free_consistent(hba[i]->pci_dev, + NR_CMDS * sizeof(cmdlist_t), (hba[i]->cmd_pool), + hba[i]->cmd_pool_dhandle); + kfree(hba[i]->cmd_pool_bits); + for(j = 0; j < NWD; j++) { + if (ida_gendisk[i][j]->flags & GENHD_FL_UP) + del_gendisk(ida_gendisk[i][j]); + put_disk(ida_gendisk[i][j]); + } + blk_cleanup_queue(hba[i]->queue); + release_io_mem(hba[i]); + free_hba(i); +} + +void __devexit cpqarray_remove_one_pci (struct pci_dev *pdev) +{ + int i; + ctlr_info_t *tmp_ptr; + + if (pci_get_drvdata(pdev) == NULL) { + printk( KERN_ERR "cpqarray: Unable to remove device \n"); + return; + } + + tmp_ptr = pci_get_drvdata(pdev); + i = tmp_ptr->ctlr; + if (hba[i] == NULL) { + printk(KERN_ERR "cpqarray: controller %d appears to have" + "already been removed \n", i); + return; + } + pci_set_drvdata(pdev, NULL); + + cpqarray_remove_one(i); +} + +/* removing an instance that was not removed automatically.. + * must be an eisa card. + */ +void __devexit cpqarray_remove_one_eisa (int i) +{ + if (hba[i] == NULL) { + printk(KERN_ERR "cpqarray: controller %d appears to have" + "already been removed \n", i); + return; + } + cpqarray_remove_one(i); +} + +/* pdev is NULL for eisa */ +int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) +{ + request_queue_t *q; + int j; + + /* + * register block devices + * Find disks and fill in structs + * Get an interrupt, set the Q depth and get into /proc + */ + + /* If this successful it should insure that we are the only */ + /* instance of the driver */ + if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) { + goto Enomem4; + } + hba[i]->access.set_intr_mask(hba[i], 0); + if (request_irq(hba[i]->intr, do_ida_intr, + IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i])) + { + printk(KERN_ERR "cpqarray: Unable to get irq %d for %s\n", + hba[i]->intr, hba[i]->devname); + goto Enomem3; + } + + for (j=0; jcmd_pool = (cmdlist_t *)pci_alloc_consistent( + hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t), + &(hba[i]->cmd_pool_dhandle)); + hba[i]->cmd_pool_bits = kmalloc( + ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long), + GFP_KERNEL); + + if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool) + goto Enomem1; + + memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t)); + memset(hba[i]->cmd_pool_bits, 0, ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long)); + printk(KERN_INFO "cpqarray: Finding drives on %s", + hba[i]->devname); + + spin_lock_init(&hba[i]->lock); + q = blk_init_queue(do_ida_request, &hba[i]->lock); + if (!q) + goto Enomem1; + + hba[i]->queue = q; + q->queuedata = hba[i]; + + getgeometry(i); + start_fwbk(i); + + ida_procinit(i); + + if (pdev) + blk_queue_bounce_limit(q, hba[i]->pci_dev->dma_mask); + + /* This is a hardware imposed limit. */ + blk_queue_max_hw_segments(q, SG_MAX); + + /* This is a driver limit and could be eliminated. */ + blk_queue_max_phys_segments(q, SG_MAX); + + init_timer(&hba[i]->timer); + hba[i]->timer.expires = jiffies + IDA_TIMER; + hba[i]->timer.data = (unsigned long)hba[i]; + hba[i]->timer.function = ida_timer; + add_timer(&hba[i]->timer); + + /* Enable IRQ now that spinlock and rate limit timer are set up */ + hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY); + + for(j=0; jdrv[j]; + sprintf(disk->disk_name, "ida/c%dd%d", i, j); + disk->major = COMPAQ_SMART2_MAJOR + i; + disk->first_minor = j<fops = &ida_fops; + if (j && !drv->nr_blks) + continue; + blk_queue_hardsect_size(hba[i]->queue, drv->blk_size); + set_capacity(disk, drv->nr_blks); + disk->queue = hba[i]->queue; + disk->private_data = drv; + add_disk(disk); + } + + /* done ! */ + return(i); + +Enomem1: + nr_ctlr = i; + kfree(hba[i]->cmd_pool_bits); + if (hba[i]->cmd_pool) + pci_free_consistent(hba[i]->pci_dev, NR_CMDS*sizeof(cmdlist_t), + hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); +Enomem2: + while (j--) { + put_disk(ida_gendisk[i][j]); + ida_gendisk[i][j] = NULL; + } + free_irq(hba[i]->intr, hba[i]); +Enomem3: + unregister_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname); +Enomem4: + if (pdev) + pci_set_drvdata(pdev, NULL); + release_io_mem(hba[i]); + free_hba(i); + + printk( KERN_ERR "cpqarray: out of memory"); + + return -1; +} + +int __init cpqarray_init_one( struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + int i; + + printk(KERN_DEBUG "cpqarray: Device 0x%x has been found at" + " bus %d dev %d func %d\n", + pdev->device, pdev->bus->number, PCI_SLOT(pdev->devfn), + PCI_FUNC(pdev->devfn)); + i = alloc_cpqarray_hba(); + if( i < 0 ) + return (-1); + memset(hba[i], 0, sizeof(ctlr_info_t)); + sprintf(hba[i]->devname, "ida%d", i); + hba[i]->ctlr = i; + + pci_set_drvdata(pdev, hba[i]); + + if (cpqarray_pci_init(hba[i], pdev) != 0) { + pci_set_drvdata(pdev, NULL); + release_io_mem(hba[i]); + free_hba(i); + return -1; + } + + return (cpqarray_register_ctlr(i, pdev)); +} + +struct pci_driver cpqarray_pci_driver = { + .name = "cpqarray", + .probe = cpqarray_init_one, + .remove = __devexit_p(cpqarray_remove_one_pci), + .id_table = cpqarray_pci_device_id, +}; + +/* + * This is it. Find all the controllers and register them. + * returns the number of block devices registered. + */ +int __init cpqarray_init(void) +{ + int num_cntlrs_reg = 0; + int i; + int rc = 0; + + /* detect controllers */ + printk(DRIVER_NAME "\n"); + + rc = pci_register_driver(&cpqarray_pci_driver); + if (rc) + return rc; + cpqarray_eisa_detect(); + + for (i=0; i < MAX_CTLR; i++) { + if (hba[i] != NULL) + num_cntlrs_reg++; + } + + return(num_cntlrs_reg); +} + +/* Function to find the first free pointer into our hba[] array */ +/* Returns -1 if no free entries are left. */ +int alloc_cpqarray_hba(void) +{ + int i; + + for(i=0; i< MAX_CTLR; i++) { + if (hba[i] == NULL) { + hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL); + if(hba[i]==NULL) { + printk(KERN_ERR "cpqarray: out of memory.\n"); + return (-1); + } + return (i); + } + } + printk(KERN_WARNING "cpqarray: This driver supports a maximum" + " of 8 controllers.\n"); + return(-1); +} + +void free_hba(int i) +{ + kfree(hba[i]); + hba[i]=NULL; +} + +/* + * Find the IO address of the controller, its IRQ and so forth. Fill + * in some basic stuff into the ctlr_info_t structure. + */ +int cpqarray_pci_init(ctlr_info_t *c, struct pci_dev *pdev) +{ + ushort vendor_id, device_id, command; + unchar cache_line_size, latency_timer; + unchar irq, revision; + unsigned long addr[6]; + __u32 board_id; + + int i; + + c->pci_dev = pdev; + if (pci_enable_device(pdev)) { + printk(KERN_ERR "cpqarray: Unable to Enable PCI device\n"); + return -1; + } + vendor_id = pdev->vendor; + device_id = pdev->device; + irq = pdev->irq; + + for(i=0; i<6; i++) + addr[i] = pci_resource_start(pdev, i); + + if (pci_set_dma_mask(pdev, CPQARRAY_DMA_MASK) != 0) + { + printk(KERN_ERR "cpqarray: Unable to set DMA mask\n"); + return -1; + } + + pci_read_config_word(pdev, PCI_COMMAND, &command); + pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); + pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_line_size); + pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency_timer); + + pci_read_config_dword(pdev, 0x2c, &board_id); + + /* check to see if controller has been disabled */ + if(!(command & 0x02)) { + printk(KERN_WARNING + "cpqarray: controller appears to be disabled\n"); + return(-1); + } + +DBGINFO( + printk("vendor_id = %x\n", vendor_id); + printk("device_id = %x\n", device_id); + printk("command = %x\n", command); + for(i=0; i<6; i++) + printk("addr[%d] = %lx\n", i, addr[i]); + printk("revision = %x\n", revision); + printk("irq = %x\n", irq); + printk("cache_line_size = %x\n", cache_line_size); + printk("latency_timer = %x\n", latency_timer); + printk("board_id = %x\n", board_id); +); + + c->intr = irq; + + for(i=0; i<6; i++) { + if (pci_resource_flags(pdev, i) & PCI_BASE_ADDRESS_SPACE_IO) + { /* IO space */ + c->io_mem_addr = addr[i]; + c->io_mem_length = pci_resource_end(pdev, i) + - pci_resource_start(pdev, i) + 1; + if(!request_region( c->io_mem_addr, c->io_mem_length, + "cpqarray")) + { + printk( KERN_WARNING "cpqarray I/O memory range already in use addr %lx length = %ld\n", c->io_mem_addr, c->io_mem_length); + c->io_mem_addr = 0; + c->io_mem_length = 0; + } + break; + } + } + + c->paddr = 0; + for(i=0; i<6; i++) + if (!(pci_resource_flags(pdev, i) & + PCI_BASE_ADDRESS_SPACE_IO)) { + c->paddr = pci_resource_start (pdev, i); + break; + } + if (!c->paddr) + return -1; + c->vaddr = remap_pci_mem(c->paddr, 128); + if (!c->vaddr) + return -1; + c->board_id = board_id; + + for(i=0; iproduct_name = products[i].product_name; + c->access = *(products[i].access); + break; + } + } + if (i == NR_PRODUCTS) { + printk(KERN_WARNING "cpqarray: Sorry, I don't know how" + " to access the SMART Array controller %08lx\n", + (unsigned long)board_id); + return -1; + } + + return 0; +} + +/* + * Map (physical) PCI mem into (virtual) kernel space + */ +void __iomem *remap_pci_mem(ulong base, ulong size) +{ + ulong page_base = ((ulong) base) & PAGE_MASK; + ulong page_offs = ((ulong) base) - page_base; + void __iomem *page_remapped = ioremap(page_base, page_offs+size); + + return (page_remapped ? (page_remapped + page_offs) : NULL); +} + +#ifndef MODULE +/* + * Config string is a comma separated set of i/o addresses of EISA cards. + */ +int cpqarray_setup(char *str) +{ + int i, ints[9]; + + (void)get_options(str, ARRAY_SIZE(ints), ints); + + for(i=0; iio_mem_addr = eisa[i]; + hba[ctlr]->io_mem_length = 0x7FF; + if(!request_region(hba[ctlr]->io_mem_addr, + hba[ctlr]->io_mem_length, + "cpqarray")) + { + printk(KERN_WARNING "cpqarray: I/O range already in " + "use addr = %lx length = %ld\n", + hba[ctlr]->io_mem_addr, + hba[ctlr]->io_mem_length); + free_hba(ctlr); + continue; + } + + /* + * Read the config register to find our interrupt + */ + intr = inb(eisa[i]+0xCC0) >> 4; + if (intr & 1) intr = 11; + else if (intr & 2) intr = 10; + else if (intr & 4) intr = 14; + else if (intr & 8) intr = 15; + + hba[ctlr]->intr = intr; + sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr); + hba[ctlr]->product_name = products[j].product_name; + hba[ctlr]->access = *(products[j].access); + hba[ctlr]->ctlr = ctlr; + hba[ctlr]->board_id = board_id; + hba[ctlr]->pci_dev = NULL; /* not PCI */ + +DBGINFO( + printk("i = %d, j = %d\n", i, j); + printk("irq = %x\n", intr); + printk("product name = %s\n", products[j].product_name); + printk("board_id = %x\n", board_id); +); + + num_ctlr++; + i++; + + if (cpqarray_register_ctlr(ctlr, NULL) == -1) + printk(KERN_WARNING + "cpqarray: Can't register EISA controller %d\n", + ctlr); + + } + + return num_ctlr; +} + +/* + * Open. Make sure the device is really there. + */ +int ida_open(struct inode *inode, struct file *filep) +{ + drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); + ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + + DBGINFO(printk("ida_open %s\n", inode->i_bdev->bd_disk->disk_name)); + /* + * Root is allowed to open raw volume zero even if it's not configured + * so array config can still work. I don't think I really like this, + * but I'm already using way to many device nodes to claim another one + * for "raw controller". + */ + if (!drv->nr_blks) { + if (!capable(CAP_SYS_RAWIO)) + return -ENXIO; + if (!capable(CAP_SYS_ADMIN) && drv != host->drv) + return -ENXIO; + } + host->usage_count++; + return 0; +} + +/* + * Close. Sync first. + */ +int ida_release(struct inode *inode, struct file *filep) +{ + ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + host->usage_count--; + return 0; +} + +/* + * Enqueuing and dequeuing functions for cmdlists. + */ +inline void addQ(cmdlist_t **Qptr, cmdlist_t *c) +{ + if (*Qptr == NULL) { + *Qptr = c; + c->next = c->prev = c; + } else { + c->prev = (*Qptr)->prev; + c->next = (*Qptr); + (*Qptr)->prev->next = c; + (*Qptr)->prev = c; + } +} + +inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c) +{ + if (c && c->next != c) { + if (*Qptr == c) *Qptr = c->next; + c->prev->next = c->next; + c->next->prev = c->prev; + } else { + *Qptr = NULL; + } + return c; +} + +/* + * Get a request and submit it to the controller. + * This routine needs to grab all the requests it possibly can from the + * req Q and submit them. Interrupts are off (and need to be off) when you + * are in here (either via the dummy do_ida_request functions or by being + * called from the interrupt handler + */ +void do_ida_request(request_queue_t *q) +{ + ctlr_info_t *h = q->queuedata; + cmdlist_t *c; + struct request *creq; + struct scatterlist tmp_sg[SG_MAX]; + int i, dir, seg; + + if (blk_queue_plugged(q)) + goto startio; + +queue_next: + creq = elv_next_request(q); + if (!creq) + goto startio; + + BUG_ON(creq->nr_phys_segments > SG_MAX); + + if ((c = cmd_alloc(h,1)) == NULL) + goto startio; + + blkdev_dequeue_request(creq); + + c->ctlr = h->ctlr; + c->hdr.unit = (drv_info_t *)(creq->rq_disk->private_data) - h->drv; + c->hdr.size = sizeof(rblk_t) >> 2; + c->size += sizeof(rblk_t); + + c->req.hdr.blk = creq->sector; + c->rq = creq; +DBGPX( + printk("sector=%d, nr_sectors=%d\n", creq->sector, creq->nr_sectors); +); + seg = blk_rq_map_sg(q, creq, tmp_sg); + + /* Now do all the DMA Mappings */ + if (rq_data_dir(creq) == READ) + dir = PCI_DMA_FROMDEVICE; + else + dir = PCI_DMA_TODEVICE; + for( i=0; i < seg; i++) + { + c->req.sg[i].size = tmp_sg[i].length; + c->req.sg[i].addr = (__u32) pci_map_page(h->pci_dev, + tmp_sg[i].page, + tmp_sg[i].offset, + tmp_sg[i].length, dir); + } +DBGPX( printk("Submitting %d sectors in %d segments\n", creq->nr_sectors, seg); ); + c->req.hdr.sg_cnt = seg; + c->req.hdr.blk_cnt = creq->nr_sectors; + c->req.hdr.cmd = (rq_data_dir(creq) == READ) ? IDA_READ : IDA_WRITE; + c->type = CMD_RWREQ; + + /* Put the request on the tail of the request queue */ + addQ(&h->reqQ, c); + h->Qdepth++; + if (h->Qdepth > h->maxQsinceinit) + h->maxQsinceinit = h->Qdepth; + + goto queue_next; + +startio: + start_io(h); +} + +/* + * start_io submits everything on a controller's request queue + * and moves it to the completion queue. + * + * Interrupts had better be off if you're in here + */ +void start_io(ctlr_info_t *h) +{ + cmdlist_t *c; + + while((c = h->reqQ) != NULL) { + /* Can't do anything if we're busy */ + if (h->access.fifo_full(h) == 0) + return; + + /* Get the first entry from the request Q */ + removeQ(&h->reqQ, c); + h->Qdepth--; + + /* Tell the controller to do our bidding */ + h->access.submit_command(h, c); + + /* Get onto the completion Q */ + addQ(&h->cmpQ, c); + } +} + +inline void complete_buffers(struct bio *bio, int ok) +{ + struct bio *xbh; + while(bio) { + int nr_sectors = bio_sectors(bio); + + xbh = bio->bi_next; + bio->bi_next = NULL; + + bio_endio(bio, nr_sectors << 9, ok ? 0 : -EIO); + + bio = xbh; + } +} +/* + * Mark all buffers that cmd was responsible for + */ +inline void complete_command(cmdlist_t *cmd, int timeout) +{ + struct request *rq = cmd->rq; + int ok=1; + int i, ddir; + + if (cmd->req.hdr.rcode & RCODE_NONFATAL && + (hba[cmd->ctlr]->misc_tflags & MISC_NONFATAL_WARN) == 0) { + printk(KERN_NOTICE "Non Fatal error on ida/c%dd%d\n", + cmd->ctlr, cmd->hdr.unit); + hba[cmd->ctlr]->misc_tflags |= MISC_NONFATAL_WARN; + } + if (cmd->req.hdr.rcode & RCODE_FATAL) { + printk(KERN_WARNING "Fatal error on ida/c%dd%d\n", + cmd->ctlr, cmd->hdr.unit); + ok = 0; + } + if (cmd->req.hdr.rcode & RCODE_INVREQ) { + printk(KERN_WARNING "Invalid request on ida/c%dd%d = (cmd=%x sect=%d cnt=%d sg=%d ret=%x)\n", + cmd->ctlr, cmd->hdr.unit, cmd->req.hdr.cmd, + cmd->req.hdr.blk, cmd->req.hdr.blk_cnt, + cmd->req.hdr.sg_cnt, cmd->req.hdr.rcode); + ok = 0; + } + if (timeout) ok = 0; + /* unmap the DMA mapping for all the scatter gather elements */ + if (cmd->req.hdr.cmd == IDA_READ) + ddir = PCI_DMA_FROMDEVICE; + else + ddir = PCI_DMA_TODEVICE; + for(i=0; ireq.hdr.sg_cnt; i++) + pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr, + cmd->req.sg[i].size, ddir); + + complete_buffers(rq->bio, ok); + + if (blk_fs_request(rq)) { + const int rw = rq_data_dir(rq); + + //disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors); + } + + add_disk_randomness(rq->rq_disk); + + DBGPX(printk("Done with %p\n", rq);); + end_that_request_last(rq, ok ? 1 : -EIO); +} + +/* + * The controller will interrupt us upon completion of commands. + * Find the command on the completion queue, remove it, tell the OS and + * try to queue up more IO + */ +irqreturn_t do_ida_intr(int irq, void *dev_id) +{ + ctlr_info_t *h = dev_id; + cmdlist_t *c; + unsigned long istat; + unsigned long flags; + __u32 a,a1; + + istat = h->access.intr_pending(h); + /* Is this interrupt for us? */ + if (istat == 0) + return IRQ_NONE; + + /* + * If there are completed commands in the completion queue, + * we had better do something about it. + */ + spin_lock_irqsave(IDA_LOCK(h->ctlr), flags); + if (istat & FIFO_NOT_EMPTY) { + while((a = h->access.command_completed(h))) { + a1 = a; a &= ~3; + if ((c = h->cmpQ) == NULL) + { + printk(KERN_WARNING "cpqarray: Completion of %08lx ignored\n", (unsigned long)a1); + continue; + } + while(c->busaddr != a) { + c = c->next; + if (c == h->cmpQ) + break; + } + /* + * If we've found the command, take it off the + * completion Q and free it + */ + if (c->busaddr == a) { + removeQ(&h->cmpQ, c); + /* Check for invalid command. + * Controller returns command error, + * But rcode = 0. + */ + + if((a1 & 0x03) && (c->req.hdr.rcode == 0)) + { + c->req.hdr.rcode = RCODE_INVREQ; + } + if (c->type == CMD_RWREQ) { + complete_command(c, 0); + cmd_free(h, c, 1); + } else if (c->type == CMD_IOCTL_PEND) { + c->type = CMD_IOCTL_DONE; + } + continue; + } + } + } + + /* + * See if we can queue up some more IO + */ + do_ida_request(h->queue); + spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); + return IRQ_HANDLED; +} + +/* + * This timer was for timing out requests that haven't happened after + * IDA_TIMEOUT. That wasn't such a good idea. This timer is used to + * reset a flags structure so we don't flood the user with + * "Non-Fatal error" messages. + */ +void ida_timer(unsigned long tdata) +{ + ctlr_info_t *h = (ctlr_info_t*)tdata; + + h->timer.expires = jiffies + IDA_TIMER; + add_timer(&h->timer); + h->misc_tflags = 0; +} + +int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo) +{ + drv_info_t *drv = get_drv(bdev->bd_disk); + + if (drv->cylinders) { + geo->heads = drv->heads; + geo->sectors = drv->sectors; + geo->cylinders = drv->cylinders; + } else { + geo->heads = 0xff; + geo->sectors = 0x3f; + geo->cylinders = drv->nr_blks / (0xff*0x3f); + } + + return 0; +} + +/* + * ida_ioctl does some miscellaneous stuff like reporting drive geometry, + * setting readahead and submitting commands from userspace to the controller. + */ +int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg) +{ + drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); + ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + int error; + ida_ioctl_t __user *io = (ida_ioctl_t __user *)arg; + ida_ioctl_t *my_io; + + switch(cmd) { + case IDAGETDRVINFO: + if (copy_to_user(&io->c.drv, drv, sizeof(drv_info_t))) + return -EFAULT; + return 0; + case IDAPASSTHRU: + if (!capable(CAP_SYS_RAWIO)) + return -EPERM; + my_io = kmalloc(sizeof(ida_ioctl_t), GFP_KERNEL); + if (!my_io) + return -ENOMEM; + error = -EFAULT; + if (copy_from_user(my_io, io, sizeof(*my_io))) + goto out_passthru; + error = ida_ctlr_ioctl(host, drv - host->drv, my_io); + if (error) + goto out_passthru; + error = -EFAULT; + if (copy_to_user(io, my_io, sizeof(*my_io))) + goto out_passthru; + error = 0; +out_passthru: + kfree(my_io); + return error; + case IDAGETCTLRSIG: + if (!arg) return -EINVAL; + put_user(host->ctlr_sig, (int __user *)arg); + return 0; + case IDAREVALIDATEVOLS: + if (iminor(inode) != 0) + return -ENXIO; + return revalidate_allvol(host); + case IDADRIVERVERSION: + if (!arg) return -EINVAL; + put_user(DRIVER_VERSION, (unsigned long __user *)arg); + return 0; + case IDAGETPCIINFO: + { + + ida_pci_info_struct pciinfo; + + if (!arg) return -EINVAL; + pciinfo.bus = host->pci_dev->bus->number; + pciinfo.dev_fn = host->pci_dev->devfn; + pciinfo.board_id = host->board_id; + if(copy_to_user((void __user *) arg, &pciinfo, + sizeof( ida_pci_info_struct))) + return -EFAULT; + return(0); + } + + default: + return -EINVAL; + } + +} +/* + * ida_ctlr_ioctl is for passing commands to the controller from userspace. + * The command block (io) has already been copied to kernel space for us, + * however, any elements in the sglist need to be copied to kernel space + * or copied back to userspace. + * + * Only root may perform a controller passthru command, however I'm not doing + * any serious sanity checking on the arguments. Doing an IDA_WRITE_MEDIA and + * putting a 64M buffer in the sglist is probably a *bad* idea. + */ +int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io) +{ + int ctlr = h->ctlr; + cmdlist_t *c; + void *p = NULL; + unsigned long flags; + int error; + + if ((c = cmd_alloc(h, 0)) == NULL) + return -ENOMEM; + c->ctlr = ctlr; + c->hdr.unit = (io->unit & UNITVALID) ? (io->unit & ~UNITVALID) : dsk; + c->hdr.size = sizeof(rblk_t) >> 2; + c->size += sizeof(rblk_t); + + c->req.hdr.cmd = io->cmd; + c->req.hdr.blk = io->blk; + c->req.hdr.blk_cnt = io->blk_cnt; + c->type = CMD_IOCTL_PEND; + + /* Pre submit processing */ + switch(io->cmd) { + case PASSTHRU_A: + p = kmalloc(io->sg[0].size, GFP_KERNEL); + if (!p) + { + error = -ENOMEM; + cmd_free(h, c, 0); + return(error); + } + if (copy_from_user(p, io->sg[0].addr, io->sg[0].size)) { + kfree(p); + cmd_free(h, c, 0); + return -EFAULT; + } + c->req.hdr.blk = pci_map_single(h->pci_dev, &(io->c), + sizeof(ida_ioctl_t), + PCI_DMA_BIDIRECTIONAL); + c->req.sg[0].size = io->sg[0].size; + c->req.sg[0].addr = pci_map_single(h->pci_dev, p, + c->req.sg[0].size, PCI_DMA_BIDIRECTIONAL); + c->req.hdr.sg_cnt = 1; + break; + case IDA_READ: + case READ_FLASH_ROM: + case SENSE_CONTROLLER_PERFORMANCE: + p = kmalloc(io->sg[0].size, GFP_KERNEL); + if (!p) + { + error = -ENOMEM; + cmd_free(h, c, 0); + return(error); + } + + c->req.sg[0].size = io->sg[0].size; + c->req.sg[0].addr = pci_map_single(h->pci_dev, p, + c->req.sg[0].size, PCI_DMA_BIDIRECTIONAL); + c->req.hdr.sg_cnt = 1; + break; + case IDA_WRITE: + case IDA_WRITE_MEDIA: + case DIAG_PASS_THRU: + case COLLECT_BUFFER: + case WRITE_FLASH_ROM: + p = kmalloc(io->sg[0].size, GFP_KERNEL); + if (!p) + { + error = -ENOMEM; + cmd_free(h, c, 0); + return(error); + } + if (copy_from_user(p, io->sg[0].addr, io->sg[0].size)) { + kfree(p); + cmd_free(h, c, 0); + return -EFAULT; + } + c->req.sg[0].size = io->sg[0].size; + c->req.sg[0].addr = pci_map_single(h->pci_dev, p, + c->req.sg[0].size, PCI_DMA_BIDIRECTIONAL); + c->req.hdr.sg_cnt = 1; + break; + default: + c->req.sg[0].size = sizeof(io->c); + c->req.sg[0].addr = pci_map_single(h->pci_dev,&io->c, + c->req.sg[0].size, PCI_DMA_BIDIRECTIONAL); + c->req.hdr.sg_cnt = 1; + } + + /* Put the request on the tail of the request queue */ + spin_lock_irqsave(IDA_LOCK(ctlr), flags); + addQ(&h->reqQ, c); + h->Qdepth++; + start_io(h); + spin_unlock_irqrestore(IDA_LOCK(ctlr), flags); + + /* Wait for completion */ + while(c->type != CMD_IOCTL_DONE) + schedule(); + + /* Unmap the DMA */ + pci_unmap_single(h->pci_dev, c->req.sg[0].addr, c->req.sg[0].size, + PCI_DMA_BIDIRECTIONAL); + /* Post submit processing */ + switch(io->cmd) { + case PASSTHRU_A: + pci_unmap_single(h->pci_dev, c->req.hdr.blk, + sizeof(ida_ioctl_t), + PCI_DMA_BIDIRECTIONAL); + case IDA_READ: + case DIAG_PASS_THRU: + case SENSE_CONTROLLER_PERFORMANCE: + case READ_FLASH_ROM: + if (copy_to_user(io->sg[0].addr, p, io->sg[0].size)) { + kfree(p); + return -EFAULT; + } + /* fall through and free p */ + case IDA_WRITE: + case IDA_WRITE_MEDIA: + case COLLECT_BUFFER: + case WRITE_FLASH_ROM: + kfree(p); + break; + default:; + /* Nothing to do */ + } + + io->rcode = c->req.hdr.rcode; + cmd_free(h, c, 0); + return(0); +} + +/* + * Commands are pre-allocated in a large block. Here we use a simple bitmap + * scheme to suballocte them to the driver. Operations that are not time + * critical (and can wait for kmalloc and possibly sleep) can pass in NULL + * as the first argument to get a new command. + */ +cmdlist_t * cmd_alloc(ctlr_info_t *h, int get_from_pool) +{ + cmdlist_t * c; + int i; + dma_addr_t cmd_dhandle; + + if (!get_from_pool) { + c = (cmdlist_t*)pci_alloc_consistent(h->pci_dev, + sizeof(cmdlist_t), &cmd_dhandle); + if(c==NULL) + return NULL; + } else { + do { + i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); + if (i == NR_CMDS) + return NULL; + } while(test_and_set_bit(i&(BITS_PER_LONG-1), h->cmd_pool_bits+(i/BITS_PER_LONG)) != 0); + c = h->cmd_pool + i; + cmd_dhandle = h->cmd_pool_dhandle + i*sizeof(cmdlist_t); + h->nr_allocs++; + } + + memset(c, 0, sizeof(cmdlist_t)); + c->busaddr = cmd_dhandle; + return c; +} + +void cmd_free(ctlr_info_t *h, cmdlist_t *c, int got_from_pool) +{ + int i; + + if (!got_from_pool) { + pci_free_consistent(h->pci_dev, sizeof(cmdlist_t), c, + c->busaddr); + } else { + i = c - h->cmd_pool; + clear_bit(i&(BITS_PER_LONG-1), h->cmd_pool_bits+(i/BITS_PER_LONG)); + h->nr_frees++; + } +} + +/*********************************************************************** + name: sendcmd + Send a command to an IDA using the memory mapped FIFO interface + and wait for it to complete. + This routine should only be called at init time. +***********************************************************************/ +int sendcmd( + __u8 cmd, + int ctlr, + void *buff, + size_t size, + unsigned int blk, + unsigned int blkcnt, + unsigned int log_unit ) +{ + cmdlist_t *c; + int complete; + unsigned long temp; + unsigned long i; + ctlr_info_t *info_p = hba[ctlr]; + + c = cmd_alloc(info_p, 1); + if(!c) + return IO_ERROR; + c->ctlr = ctlr; + c->hdr.unit = log_unit; + c->hdr.prio = 0; + c->hdr.size = sizeof(rblk_t) >> 2; + c->size += sizeof(rblk_t); + + /* The request information. */ + c->req.hdr.next = 0; + c->req.hdr.rcode = 0; + c->req.bp = 0; + c->req.hdr.sg_cnt = 1; + c->req.hdr.reserved = 0; + + if (size == 0) + c->req.sg[0].size = 512; + else + c->req.sg[0].size = size; + + c->req.hdr.blk = blk; + c->req.hdr.blk_cnt = blkcnt; + c->req.hdr.cmd = (unsigned char) cmd; + c->req.sg[0].addr = (__u32) pci_map_single(info_p->pci_dev, + buff, c->req.sg[0].size, PCI_DMA_BIDIRECTIONAL); + /* + * Disable interrupt + */ + info_p->access.set_intr_mask(info_p, 0); + /* Make sure there is room in the command FIFO */ + /* Actually it should be completely empty at this time. */ + for (i = 200000; i > 0; i--) { + temp = info_p->access.fifo_full(info_p); + if (temp != 0) { + break; + } + udelay(10); +DBG( + printk(KERN_WARNING "cpqarray ida%d: idaSendPciCmd FIFO full," + " waiting!\n", ctlr); +); + } + /* + * Send the cmd + */ + info_p->access.submit_command(info_p, c); + complete = pollcomplete(ctlr); + + pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr, + c->req.sg[0].size, PCI_DMA_BIDIRECTIONAL); + if (complete != 1) { + if (complete != c->busaddr) { + printk( KERN_WARNING + "cpqarray ida%d: idaSendPciCmd " + "Invalid command list address returned! (%08lx)\n", + ctlr, (unsigned long)complete); + cmd_free(info_p, c, 1); + return (IO_ERROR); + } + } else { + printk( KERN_WARNING + "cpqarray ida%d: idaSendPciCmd Timeout out, " + "No command list address returned!\n", + ctlr); + cmd_free(info_p, c, 1); + return (IO_ERROR); + } + + if (c->req.hdr.rcode & 0x00FE) { + if (!(c->req.hdr.rcode & BIG_PROBLEM)) { + printk( KERN_WARNING + "cpqarray ida%d: idaSendPciCmd, error: " + "Controller failed at init time " + "cmd: 0x%x, return code = 0x%x\n", + ctlr, c->req.hdr.cmd, c->req.hdr.rcode); + + cmd_free(info_p, c, 1); + return (IO_ERROR); + } + } + cmd_free(info_p, c, 1); + return (IO_OK); +} + +/* + * revalidate_allvol is for online array config utilities. After a + * utility reconfigures the drives in the array, it can use this function + * (through an ioctl) to make the driver zap any previous disk structs for + * that controller and get new ones. + * + * Right now I'm using the getgeometry() function to do this, but this + * function should probably be finer grained and allow you to revalidate one + * particualar logical volume (instead of all of them on a particular + * controller). + */ +int revalidate_allvol(ctlr_info_t *host) +{ + int ctlr = host->ctlr; + int i; + unsigned long flags; + + spin_lock_irqsave(IDA_LOCK(ctlr), flags); + if (host->usage_count > 1) { + spin_unlock_irqrestore(IDA_LOCK(ctlr), flags); + printk(KERN_WARNING "cpqarray: Device busy for volume" + " revalidation (usage=%d)\n", host->usage_count); + return -EBUSY; + } + host->usage_count++; + spin_unlock_irqrestore(IDA_LOCK(ctlr), flags); + + /* + * Set the partition and block size structures for all volumes + * on this controller to zero. We will reread all of this data + */ + set_capacity(ida_gendisk[ctlr][0], 0); + for (i = 1; i < NWD; i++) { + struct gendisk *disk = ida_gendisk[ctlr][i]; + if (disk->flags & GENHD_FL_UP) + del_gendisk(disk); + } + memset(host->drv, 0, sizeof(drv_info_t)*NWD); + + /* + * Tell the array controller not to give us any interrupts while + * we check the new geometry. Then turn interrupts back on when + * we're done. + */ + host->access.set_intr_mask(host, 0); + getgeometry(ctlr); + host->access.set_intr_mask(host, FIFO_NOT_EMPTY); + + for(i=0; idrv[i]; + if (i && !drv->nr_blks) + continue; + blk_queue_hardsect_size(host->queue, drv->blk_size); + set_capacity(disk, drv->nr_blks); + disk->queue = host->queue; + disk->private_data = drv; + if (i) + add_disk(disk); + } + + host->usage_count--; + return 0; +} + +int ida_revalidate(struct gendisk *disk) +{ + drv_info_t *drv = disk->private_data; + set_capacity(disk, drv->nr_blks); + return 0; +} + +/******************************************************************** + name: pollcomplete + Wait polling for a command to complete. + The memory mapped FIFO is polled for the completion. + Used only at init time, interrupts disabled. + ********************************************************************/ +int pollcomplete(int ctlr) +{ + int done; + int i; + + /* Wait (up to 2 seconds) for a command to complete */ + + for (i = 200000; i > 0; i--) { + done = hba[ctlr]->access.command_completed(hba[ctlr]); + if (done == 0) { + udelay(10); /* a short fixed delay */ + } else + return (done); + } + /* Invalid address to tell caller we ran out of time */ + return 1; +} +/***************************************************************** + start_fwbk + Starts controller firmwares background processing. + Currently only the Integrated Raid controller needs this done. + If the PCI mem address registers are written to after this, + data corruption may occur +*****************************************************************/ +void start_fwbk(int ctlr) +{ + id_ctlr_t *id_ctlr_buf; + int ret_code; + + if( (hba[ctlr]->board_id != 0x40400E11) + && (hba[ctlr]->board_id != 0x40480E11) ) + + /* Not a Integrated Raid, so there is nothing for us to do */ + return; + printk(KERN_DEBUG "cpqarray: Starting firmware's background" + " processing\n"); + /* Command does not return anything, but idasend command needs a + buffer */ + id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); + if(id_ctlr_buf==NULL) + { + printk(KERN_WARNING "cpqarray: Out of memory. " + "Unable to start background processing.\n"); + return; + } + ret_code = sendcmd(RESUME_BACKGROUND_ACTIVITY, ctlr, + id_ctlr_buf, 0, 0, 0, 0); + if(ret_code != IO_OK) + printk(KERN_WARNING "cpqarray: Unable to start" + " background processing\n"); + + kfree(id_ctlr_buf); +} +/***************************************************************** + getgeometry + Get ida logical volume geometry from the controller + This is a large bit of code which once existed in two flavors, + It is used only at init time. +*****************************************************************/ +void getgeometry(int ctlr) +{ + id_log_drv_t *id_ldrive; + id_ctlr_t *id_ctlr_buf; + sense_log_drv_stat_t *id_lstatus_buf; + config_t *sense_config_buf; + unsigned int log_unit, log_index; + int ret_code, size; + drv_info_t *drv; + ctlr_info_t *info_p = hba[ctlr]; + int i; + + info_p->log_drv_map = 0; + + id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); + if(id_ldrive == NULL) + { + printk( KERN_ERR "cpqarray: out of memory.\n"); + return; + } + + id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); + if(id_ctlr_buf == NULL) + { + kfree(id_ldrive); + printk( KERN_ERR "cpqarray: out of memory.\n"); + return; + } + + id_lstatus_buf = (sense_log_drv_stat_t *)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); + if(id_lstatus_buf == NULL) + { + kfree(id_ctlr_buf); + kfree(id_ldrive); + printk( KERN_ERR "cpqarray: out of memory.\n"); + return; + } + + sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL); + if(sense_config_buf == NULL) + { + kfree(id_lstatus_buf); + kfree(id_ctlr_buf); + kfree(id_ldrive); + printk( KERN_ERR "cpqarray: out of memory.\n"); + return; + } + + memset(id_ldrive, 0, sizeof(id_log_drv_t)); + memset(id_ctlr_buf, 0, sizeof(id_ctlr_t)); + memset(id_lstatus_buf, 0, sizeof(sense_log_drv_stat_t)); + memset(sense_config_buf, 0, sizeof(config_t)); + + info_p->phys_drives = 0; + info_p->log_drv_map = 0; + info_p->drv_assign_map = 0; + info_p->drv_spare_map = 0; + info_p->mp_failed_drv_map = 0; /* only initialized here */ + /* Get controllers info for this logical drive */ + ret_code = sendcmd(ID_CTLR, ctlr, id_ctlr_buf, 0, 0, 0, 0); + if (ret_code == IO_ERROR) { + /* + * If can't get controller info, set the logical drive map to 0, + * so the idastubopen will fail on all logical drives + * on the controller. + */ + /* Free all the buffers and return */ + printk(KERN_ERR "cpqarray: error sending ID controller\n"); + kfree(sense_config_buf); + kfree(id_lstatus_buf); + kfree(id_ctlr_buf); + kfree(id_ldrive); + return; + } + + info_p->log_drives = id_ctlr_buf->nr_drvs; + for(i=0;i<4;i++) + info_p->firm_rev[i] = id_ctlr_buf->firm_rev[i]; + info_p->ctlr_sig = id_ctlr_buf->cfg_sig; + + printk(" (%s)\n", info_p->product_name); + /* + * Initialize logical drive map to zero + */ + log_index = 0; + /* + * Get drive geometry for all logical drives + */ + if (id_ctlr_buf->nr_drvs > 16) + printk(KERN_WARNING "cpqarray ida%d: This driver supports " + "16 logical drives per controller.\n. " + " Additional drives will not be " + "detected\n", ctlr); + + for (log_unit = 0; + (log_index < id_ctlr_buf->nr_drvs) + && (log_unit < NWD); + log_unit++) { + size = sizeof(sense_log_drv_stat_t); + + /* + Send "Identify logical drive status" cmd + */ + ret_code = sendcmd(SENSE_LOG_DRV_STAT, + ctlr, id_lstatus_buf, size, 0, 0, log_unit); + if (ret_code == IO_ERROR) { + /* + If can't get logical drive status, set + the logical drive map to 0, so the + idastubopen will fail for all logical drives + on the controller. + */ + info_p->log_drv_map = 0; + printk( KERN_WARNING + "cpqarray ida%d: idaGetGeometry - Controller" + " failed to report status of logical drive %d\n" + "Access to this controller has been disabled\n", + ctlr, log_unit); + /* Free all the buffers and return */ + kfree(sense_config_buf); + kfree(id_lstatus_buf); + kfree(id_ctlr_buf); + kfree(id_ldrive); + return; + } + /* + Make sure the logical drive is configured + */ + if (id_lstatus_buf->status != LOG_NOT_CONF) { + ret_code = sendcmd(ID_LOG_DRV, ctlr, id_ldrive, + sizeof(id_log_drv_t), 0, 0, log_unit); + /* + If error, the bit for this + logical drive won't be set and + idastubopen will return error. + */ + if (ret_code != IO_ERROR) { + drv = &info_p->drv[log_unit]; + drv->blk_size = id_ldrive->blk_size; + drv->nr_blks = id_ldrive->nr_blks; + drv->cylinders = id_ldrive->drv.cyl; + drv->heads = id_ldrive->drv.heads; + drv->sectors = id_ldrive->drv.sect_per_track; + info_p->log_drv_map |= (1 << log_unit); + + printk(KERN_INFO "cpqarray ida/c%dd%d: blksz=%d nr_blks=%d\n", + ctlr, log_unit, drv->blk_size, drv->nr_blks); + ret_code = sendcmd(SENSE_CONFIG, + ctlr, sense_config_buf, + sizeof(config_t), 0, 0, log_unit); + if (ret_code == IO_ERROR) { + info_p->log_drv_map = 0; + /* Free all the buffers and return */ + printk(KERN_ERR "cpqarray: error sending sense config\n"); + kfree(sense_config_buf); + kfree(id_lstatus_buf); + kfree(id_ctlr_buf); + kfree(id_ldrive); + return; + + } + + info_p->phys_drives = + sense_config_buf->ctlr_phys_drv; + info_p->drv_assign_map + |= sense_config_buf->drv_asgn_map; + info_p->drv_assign_map + |= sense_config_buf->spare_asgn_map; + info_p->drv_spare_map + |= sense_config_buf->spare_asgn_map; + } /* end of if no error on id_ldrive */ + log_index = log_index + 1; + } /* end of if logical drive configured */ + } /* end of for log_unit */ + kfree(sense_config_buf); + kfree(id_ldrive); + kfree(id_lstatus_buf); + kfree(id_ctlr_buf); + return; + +} + +void __exit cpqarray_exit(void) +{ + int i; + + pci_unregister_driver(&cpqarray_pci_driver); + + /* Double check that all controller entries have been removed */ + for(i=0; i +#include +#include +#include +#endif + +#include "ida_cmd.h" + +#define IO_OK 0 +#define IO_ERROR 1 +#define NWD 16 +#define NWD_SHIFT 4 + +#define IDA_TIMER (5*HZ) +#define IDA_TIMEOUT (10*HZ) + +#define MISC_NONFATAL_WARN 0x01 + +typedef struct { + unsigned blk_size; + unsigned nr_blks; + unsigned cylinders; + unsigned heads; + unsigned sectors; + int usage_count; +} drv_info_t; + +#ifdef __KERNEL__ + +struct ctlr_info; +typedef struct ctlr_info ctlr_info_t; + +struct access_method { + void (*submit_command)(ctlr_info_t *h, cmdlist_t *c); + void (*set_intr_mask)(ctlr_info_t *h, unsigned long val); + unsigned long (*fifo_full)(ctlr_info_t *h); + unsigned long (*intr_pending)(ctlr_info_t *h); + unsigned long (*command_completed)(ctlr_info_t *h); +}; + +struct board_type { + __u32 board_id; + char *product_name; + struct access_method *access; +}; + +struct ctlr_info { + int ctlr; + char devname[8]; + __u32 log_drv_map; + __u32 drv_assign_map; + __u32 drv_spare_map; + __u32 mp_failed_drv_map; + + char firm_rev[4]; + int ctlr_sig; + + int log_drives; + int phys_drives; + + struct pci_dev *pci_dev; /* NULL if EISA */ + __u32 board_id; + char *product_name; + + void __iomem *vaddr; + unsigned long paddr; + unsigned long io_mem_addr; + unsigned long io_mem_length; + int intr; + int usage_count; + drv_info_t drv[NWD]; + struct proc_dir_entry *proc; + + struct access_method access; + + cmdlist_t *reqQ; + cmdlist_t *cmpQ; + cmdlist_t *cmd_pool; + dma_addr_t cmd_pool_dhandle; + unsigned long *cmd_pool_bits; + struct request_queue *queue; + spinlock_t lock; + + unsigned int Qdepth; + unsigned int maxQsinceinit; + + unsigned int nr_requests; + unsigned int nr_allocs; + unsigned int nr_frees; + struct timer_list timer; + unsigned int misc_tflags; +}; + +#define IDA_LOCK(i) (&hba[i]->lock) + +#endif + +#endif /* CPQARRAY_H */ diff --git a/ddverify/case_studies/block/cpqarray/ida_cmd.h b/ddverify/case_studies/block/cpqarray/ida_cmd.h new file mode 100644 index 000000000..98b5746b3 --- /dev/null +++ b/ddverify/case_studies/block/cpqarray/ida_cmd.h @@ -0,0 +1,349 @@ +/* + * Disk Array driver for Compaq SMART2 Controllers + * Copyright 1998 Compaq Computer Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to iss_storagedev@hp.com + * + */ +#ifndef ARRAYCMD_H +#define ARRAYCMD_H + +#include +#if 0 +#include +#endif + +/* for the Smart Array 42XX cards */ +#define S42XX_REQUEST_PORT_OFFSET 0x40 +#define S42XX_REPLY_INTR_MASK_OFFSET 0x34 +#define S42XX_REPLY_PORT_OFFSET 0x44 +#define S42XX_INTR_STATUS 0x30 + +#define S42XX_INTR_OFF 0x08 +#define S42XX_INTR_PENDING 0x08 + +#define COMMAND_FIFO 0x04 +#define COMMAND_COMPLETE_FIFO 0x08 +#define INTR_MASK 0x0C +#define INTR_STATUS 0x10 +#define INTR_PENDING 0x14 + +#define FIFO_NOT_EMPTY 0x01 +#define FIFO_NOT_FULL 0x02 + +#define BIG_PROBLEM 0x40 +#define LOG_NOT_CONF 2 + +#pragma pack(1) +typedef struct { + __u32 size; + __u32 addr; +} sg_t; + +#define RCODE_NONFATAL 0x02 +#define RCODE_FATAL 0x04 +#define RCODE_INVREQ 0x10 +typedef struct { + __u16 next; + __u8 cmd; + __u8 rcode; + __u32 blk; + __u16 blk_cnt; + __u8 sg_cnt; + __u8 reserved; +} rhdr_t; + +#define SG_MAX 32 +typedef struct { + rhdr_t hdr; + sg_t sg[SG_MAX]; + __u32 bp; +} rblk_t; + +typedef struct { + __u8 unit; + __u8 prio; + __u16 size; +} chdr_t; + +#define CMD_RWREQ 0x00 +#define CMD_IOCTL_PEND 0x01 +#define CMD_IOCTL_DONE 0x02 + +typedef struct cmdlist { + chdr_t hdr; + rblk_t req; + __u32 size; + int retry_cnt; + __u32 busaddr; + int ctlr; + struct cmdlist *prev; + struct cmdlist *next; + struct request *rq; + int type; +} cmdlist_t; + +#define ID_CTLR 0x11 +typedef struct { + __u8 nr_drvs; + __u32 cfg_sig; + __u8 firm_rev[4]; + __u8 rom_rev[4]; + __u8 hw_rev; + __u32 bb_rev; + __u32 drv_present_map; + __u32 ext_drv_map; + __u32 board_id; + __u8 cfg_error; + __u32 non_disk_bits; + __u8 bad_ram_addr; + __u8 cpu_rev; + __u8 pdpi_rev; + __u8 epic_rev; + __u8 wcxc_rev; + __u8 marketing_rev; + __u8 ctlr_flags; + __u8 host_flags; + __u8 expand_dis; + __u8 scsi_chips; + __u32 max_req_blocks; + __u32 ctlr_clock; + __u8 drvs_per_bus; + __u16 big_drv_present_map[8]; + __u16 big_ext_drv_map[8]; + __u16 big_non_disk_map[8]; + __u16 task_flags; + __u8 icl_bus; + __u8 red_modes; + __u8 cur_red_mode; + __u8 red_ctlr_stat; + __u8 red_fail_reason; + __u8 reserved[403]; +} id_ctlr_t; + +typedef struct { + __u16 cyl; + __u8 heads; + __u8 xsig; + __u8 psectors; + __u16 wpre; + __u8 maxecc; + __u8 drv_ctrl; + __u16 pcyls; + __u8 pheads; + __u16 landz; + __u8 sect_per_track; + __u8 cksum; +} drv_param_t; + +#define ID_LOG_DRV 0x10 +typedef struct { + __u16 blk_size; + __u32 nr_blks; + drv_param_t drv; + __u8 fault_tol; + __u8 reserved; + __u8 bios_disable; +} id_log_drv_t; + +#define ID_LOG_DRV_EXT 0x18 +typedef struct { + __u32 log_drv_id; + __u8 log_drv_label[64]; + __u8 reserved[418]; +} id_log_drv_ext_t; + +#define SENSE_LOG_DRV_STAT 0x12 +typedef struct { + __u8 status; + __u32 fail_map; + __u16 read_err[32]; + __u16 write_err[32]; + __u8 drv_err_data[256]; + __u8 drq_timeout[32]; + __u32 blks_to_recover; + __u8 drv_recovering; + __u16 remap_cnt[32]; + __u32 replace_drv_map; + __u32 act_spare_map; + __u8 spare_stat; + __u8 spare_repl_map[32]; + __u32 repl_ok_map; + __u8 media_exch; + __u8 cache_fail; + __u8 expn_fail; + __u8 unit_flags; + __u16 big_fail_map[8]; + __u16 big_remap_map[128]; + __u16 big_repl_map[8]; + __u16 big_act_spare_map[8]; + __u8 big_spar_repl_map[128]; + __u16 big_repl_ok_map[8]; + __u8 big_drv_rebuild; + __u8 reserved[36]; +} sense_log_drv_stat_t; + +#define START_RECOVER 0x13 + +#define ID_PHYS_DRV 0x15 +typedef struct { + __u8 scsi_bus; + __u8 scsi_id; + __u16 blk_size; + __u32 nr_blks; + __u32 rsvd_blks; + __u8 drv_model[40]; + __u8 drv_sn[40]; + __u8 drv_fw[8]; + __u8 scsi_iq_bits; + __u8 compaq_drv_stmp; + __u8 last_fail; + __u8 phys_drv_flags; + __u8 phys_drv_flags1; + __u8 scsi_lun; + __u8 phys_drv_flags2; + __u8 reserved; + __u32 spi_speed_rules; + __u8 phys_connector[2]; + __u8 phys_box_on_bus; + __u8 phys_bay_in_box; +} id_phys_drv_t; + +#define BLINK_DRV_LEDS 0x16 +typedef struct { + __u32 blink_duration; + __u32 reserved; + __u8 blink[256]; + __u8 reserved1[248]; +} blink_drv_leds_t; + +#define SENSE_BLINK_LEDS 0x17 +typedef struct { + __u32 blink_duration; + __u32 btime_elap; + __u8 blink[256]; + __u8 reserved1[248]; +} sense_blink_leds_t; + +#define IDA_READ 0x20 +#define IDA_WRITE 0x30 +#define IDA_WRITE_MEDIA 0x31 +#define RESET_TO_DIAG 0x40 +#define DIAG_PASS_THRU 0x41 + +#define SENSE_CONFIG 0x50 +#define SET_CONFIG 0x51 +typedef struct { + __u32 cfg_sig; + __u16 compat_port; + __u8 data_dist_mode; + __u8 surf_an_ctrl; + __u16 ctlr_phys_drv; + __u16 log_unit_phys_drv; + __u16 fault_tol_mode; + __u8 phys_drv_param[16]; + drv_param_t drv; + __u32 drv_asgn_map; + __u16 dist_factor; + __u32 spare_asgn_map; + __u8 reserved[6]; + __u16 os; + __u8 ctlr_order; + __u8 extra_info; + __u32 data_offs; + __u8 parity_backedout_write_drvs; + __u8 parity_dist_mode; + __u8 parity_shift_fact; + __u8 bios_disable_flag; + __u32 blks_on_vol; + __u32 blks_per_drv; + __u8 scratch[16]; + __u16 big_drv_map[8]; + __u16 big_spare_map[8]; + __u8 ss_source_vol; + __u8 mix_drv_cap_range; + struct { + __u16 big_drv_map[8]; + __u32 blks_per_drv; + __u16 fault_tol_mode; + __u16 dist_factor; + } MDC_range[4]; + __u8 reserved1[248]; +} config_t; + +#define BYPASS_VOL_STATE 0x52 +#define SS_CREATE_VOL 0x53 +#define CHANGE_CONFIG 0x54 +#define SENSE_ORIG_CONF 0x55 +#define REORDER_LOG_DRV 0x56 +typedef struct { + __u8 old_units[32]; +} reorder_log_drv_t; + +#define LABEL_LOG_DRV 0x57 +typedef struct { + __u8 log_drv_label[64]; +} label_log_drv_t; + +#define SS_TO_VOL 0x58 + +#define SET_SURF_DELAY 0x60 +typedef struct { + __u16 delay; + __u8 reserved[510]; +} surf_delay_t; + +#define SET_OVERHEAT_DELAY 0x61 +typedef struct { + __u16 delay; +} overhead_delay_t; + +#define SET_MP_DELAY +typedef struct { + __u16 delay; + __u8 reserved[510]; +} mp_delay_t; + +#define PASSTHRU_A 0x91 +typedef struct { + __u8 target; + __u8 bus; + __u8 lun; + __u32 timeout; + __u32 flags; + __u8 status; + __u8 error; + __u8 cdb_len; + __u8 sense_error; + __u8 sense_key; + __u32 sense_info; + __u8 sense_code; + __u8 sense_qual; + __u32 residual; + __u8 reserved[4]; + __u8 cdb[12]; +} scsi_param_t; + +#define RESUME_BACKGROUND_ACTIVITY 0x99 +#define SENSE_CONTROLLER_PERFORMANCE 0xa8 +#define FLUSH_CACHE 0xc2 +#define COLLECT_BUFFER 0xd2 +#define READ_FLASH_ROM 0xf6 +#define WRITE_FLASH_ROM 0xf7 +#pragma pack() + +#endif /* ARRAYCMD_H */ diff --git a/ddverify/case_studies/block/cpqarray/ida_ioctl.h b/ddverify/case_studies/block/cpqarray/ida_ioctl.h new file mode 100644 index 000000000..888fff9ca --- /dev/null +++ b/ddverify/case_studies/block/cpqarray/ida_ioctl.h @@ -0,0 +1,87 @@ +/* + * Disk Array driver for Compaq SMART2 Controllers + * Copyright 1998 Compaq Computer Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to iss_storagedev@hp.com + * + */ +#ifndef IDA_IOCTL_H +#define IDA_IOCTL_H + +#include "ida_cmd.h" +#include "cpqarray.h" + +#define IDAGETDRVINFO 0x27272828 +#define IDAPASSTHRU 0x28282929 +#define IDAGETCTLRSIG 0x29293030 +#define IDAREVALIDATEVOLS 0x30303131 +#define IDADRIVERVERSION 0x31313232 +#define IDAGETPCIINFO 0x32323333 + +typedef struct _ida_pci_info_struct +{ + unsigned char bus; + unsigned char dev_fn; + __u32 board_id; +} ida_pci_info_struct; +/* + * Normally, the ioctl determines the logical unit for this command by + * the major,minor number of the fd passed to ioctl. If you need to send + * a command to a different/nonexistant unit (such as during config), you + * can override the normal behavior by setting the unit valid bit. (Normally, + * it should be zero) The controller the command is sent to is still + * determined by the major number of the open device. + */ + +#define UNITVALID 0x80 +typedef struct { + __u8 cmd; + __u8 rcode; + __u8 unit; + __u32 blk; + __u16 blk_cnt; + +/* currently, sg_cnt is assumed to be 1: only the 0th element of sg is used */ + struct { + void __user *addr; + size_t size; + } sg[SG_MAX]; + int sg_cnt; + + union ctlr_cmds { + drv_info_t drv; + unsigned char buf[1024]; + + id_ctlr_t id_ctlr; + drv_param_t drv_param; + id_log_drv_t id_log_drv; + id_log_drv_ext_t id_log_drv_ext; + sense_log_drv_stat_t sense_log_drv_stat; + id_phys_drv_t id_phys_drv; + blink_drv_leds_t blink_drv_leds; + sense_blink_leds_t sense_blink_leds; + config_t config; + reorder_log_drv_t reorder_log_drv; + label_log_drv_t label_log_drv; + surf_delay_t surf_delay; + overhead_delay_t overhead_delay; + mp_delay_t mp_delay; + scsi_param_t scsi_param; + } c; +} ida_ioctl_t; + +#endif /* IDA_IOCTL_H */ diff --git a/ddverify/case_studies/block/cpqarray/smart1,2.h b/ddverify/case_studies/block/cpqarray/smart1,2.h new file mode 100644 index 000000000..a0b403a6b --- /dev/null +++ b/ddverify/case_studies/block/cpqarray/smart1,2.h @@ -0,0 +1,278 @@ +/* + * Disk Array driver for Compaq SMART2 Controllers + * Copyright 1998 Compaq Computer Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to iss_storagedev@hp.com + * + * If you want to make changes, improve or add functionality to this + * driver, you'll probably need the Compaq Array Controller Interface + * Specificiation (Document number ECG086/1198) + */ + +/* + * This file contains the controller communication implementation for + * Compaq SMART-1 and SMART-2 controllers. To the best of my knowledge, + * this should support: + * + * PCI: + * SMART-2/P, SMART-2DH, SMART-2SL, SMART-221, SMART-3100ES, SMART-3200 + * Integerated SMART Array Controller, SMART-4200, SMART-4250ES + * + * EISA: + * SMART-2/E, SMART, IAES, IDA-2, IDA + */ + +/* + * Memory mapped FIFO interface (SMART 42xx cards) + */ +static void smart4_submit_command(ctlr_info_t *h, cmdlist_t *c) +{ + writel(c->busaddr, h->vaddr + S42XX_REQUEST_PORT_OFFSET); +} + +/* + * This card is the opposite of the other cards. + * 0 turns interrupts on... + * 0x08 turns them off... + */ +static void smart4_intr_mask(ctlr_info_t *h, unsigned long val) +{ + if (val) + { /* Turn interrupts on */ + writel(0, h->vaddr + S42XX_REPLY_INTR_MASK_OFFSET); + } else /* Turn them off */ + { + writel( S42XX_INTR_OFF, + h->vaddr + S42XX_REPLY_INTR_MASK_OFFSET); + } +} + +/* + * For older cards FIFO Full = 0. + * On this card 0 means there is room, anything else FIFO Full. + * + */ +static unsigned long smart4_fifo_full(ctlr_info_t *h) +{ + + return (!readl(h->vaddr + S42XX_REQUEST_PORT_OFFSET)); +} + +/* This type of controller returns -1 if the fifo is empty, + * Not 0 like the others. + * And we need to let it know we read a value out + */ +static unsigned long smart4_completed(ctlr_info_t *h) +{ + long register_value + = readl(h->vaddr + S42XX_REPLY_PORT_OFFSET); + + /* Fifo is empty */ + if( register_value == 0xffffffff) + return 0; + + /* Need to let it know we got the reply */ + /* We do this by writing a 0 to the port we just read from */ + writel(0, h->vaddr + S42XX_REPLY_PORT_OFFSET); + + return ((unsigned long) register_value); +} + + /* + * This hardware returns interrupt pending at a different place and + * it does not tell us if the fifo is empty, we will have check + * that by getting a 0 back from the comamnd_completed call. + */ +static unsigned long smart4_intr_pending(ctlr_info_t *h) +{ + unsigned long register_value = + readl(h->vaddr + S42XX_INTR_STATUS); + + if( register_value & S42XX_INTR_PENDING) + return FIFO_NOT_EMPTY; + return 0 ; +} + +static struct access_method smart4_access = { + smart4_submit_command, + smart4_intr_mask, + smart4_fifo_full, + smart4_intr_pending, + smart4_completed, +}; + +/* + * Memory mapped FIFO interface (PCI SMART2 and SMART 3xxx cards) + */ +static void smart2_submit_command(ctlr_info_t *h, cmdlist_t *c) +{ + writel(c->busaddr, h->vaddr + COMMAND_FIFO); +} + +static void smart2_intr_mask(ctlr_info_t *h, unsigned long val) +{ + writel(val, h->vaddr + INTR_MASK); +} + +static unsigned long smart2_fifo_full(ctlr_info_t *h) +{ + return readl(h->vaddr + COMMAND_FIFO); +} + +static unsigned long smart2_completed(ctlr_info_t *h) +{ + return readl(h->vaddr + COMMAND_COMPLETE_FIFO); +} + +static unsigned long smart2_intr_pending(ctlr_info_t *h) +{ + return readl(h->vaddr + INTR_PENDING); +} + +static struct access_method smart2_access = { + smart2_submit_command, + smart2_intr_mask, + smart2_fifo_full, + smart2_intr_pending, + smart2_completed, +}; + +/* + * IO access for SMART-2/E cards + */ +static void smart2e_submit_command(ctlr_info_t *h, cmdlist_t *c) +{ + outl(c->busaddr, h->io_mem_addr + COMMAND_FIFO); +} + +static void smart2e_intr_mask(ctlr_info_t *h, unsigned long val) +{ + outl(val, h->io_mem_addr + INTR_MASK); +} + +static unsigned long smart2e_fifo_full(ctlr_info_t *h) +{ + return inl(h->io_mem_addr + COMMAND_FIFO); +} + +static unsigned long smart2e_completed(ctlr_info_t *h) +{ + return inl(h->io_mem_addr + COMMAND_COMPLETE_FIFO); +} + +static unsigned long smart2e_intr_pending(ctlr_info_t *h) +{ + return inl(h->io_mem_addr + INTR_PENDING); +} + +static struct access_method smart2e_access = { + smart2e_submit_command, + smart2e_intr_mask, + smart2e_fifo_full, + smart2e_intr_pending, + smart2e_completed, +}; + +/* + * IO access for older SMART-1 type cards + */ +#define SMART1_SYSTEM_MASK 0xC8E +#define SMART1_SYSTEM_DOORBELL 0xC8F +#define SMART1_LOCAL_MASK 0xC8C +#define SMART1_LOCAL_DOORBELL 0xC8D +#define SMART1_INTR_MASK 0xC89 +#define SMART1_LISTADDR 0xC90 +#define SMART1_LISTLEN 0xC94 +#define SMART1_TAG 0xC97 +#define SMART1_COMPLETE_ADDR 0xC98 +#define SMART1_LISTSTATUS 0xC9E + +#define CHANNEL_BUSY 0x01 +#define CHANNEL_CLEAR 0x02 + +static void smart1_submit_command(ctlr_info_t *h, cmdlist_t *c) +{ + /* + * This __u16 is actually a bunch of control flags on SMART + * and below. We want them all to be zero. + */ + c->hdr.size = 0; + + outb(CHANNEL_CLEAR, h->io_mem_addr + SMART1_SYSTEM_DOORBELL); + + outl(c->busaddr, h->io_mem_addr + SMART1_LISTADDR); + outw(c->size, h->io_mem_addr + SMART1_LISTLEN); + + outb(CHANNEL_BUSY, h->io_mem_addr + SMART1_LOCAL_DOORBELL); +} + +static void smart1_intr_mask(ctlr_info_t *h, unsigned long val) +{ + if (val == 1) { + outb(0xFD, h->io_mem_addr + SMART1_SYSTEM_DOORBELL); + outb(CHANNEL_BUSY, h->io_mem_addr + SMART1_LOCAL_DOORBELL); + outb(0x01, h->io_mem_addr + SMART1_INTR_MASK); + outb(0x01, h->io_mem_addr + SMART1_SYSTEM_MASK); + } else { + outb(0, h->io_mem_addr + 0xC8E); + } +} + +static unsigned long smart1_fifo_full(ctlr_info_t *h) +{ + unsigned char chan; + chan = inb(h->io_mem_addr + SMART1_SYSTEM_DOORBELL) & CHANNEL_CLEAR; + return chan; +} + +static unsigned long smart1_completed(ctlr_info_t *h) +{ + unsigned char status; + unsigned long cmd; + + if (inb(h->io_mem_addr + SMART1_SYSTEM_DOORBELL) & CHANNEL_BUSY) { + outb(CHANNEL_BUSY, h->io_mem_addr + SMART1_SYSTEM_DOORBELL); + + cmd = inl(h->io_mem_addr + SMART1_COMPLETE_ADDR); + status = inb(h->io_mem_addr + SMART1_LISTSTATUS); + + outb(CHANNEL_CLEAR, h->io_mem_addr + SMART1_LOCAL_DOORBELL); + + /* + * this is x86 (actually compaq x86) only, so it's ok + */ + if (cmd) ((cmdlist_t*)bus_to_virt(cmd))->req.hdr.rcode = status; + } else { + cmd = 0; + } + return cmd; +} + +static unsigned long smart1_intr_pending(ctlr_info_t *h) +{ + unsigned char chan; + chan = inb(h->io_mem_addr + SMART1_SYSTEM_DOORBELL) & CHANNEL_BUSY; + return chan; +} + +static struct access_method smart1_access = { + smart1_submit_command, + smart1_intr_mask, + smart1_fifo_full, + smart1_intr_pending, + smart1_completed, +}; diff --git a/ddverify/case_studies/block/floppy/floppy.c b/ddverify/case_studies/block/floppy/floppy.c new file mode 100644 index 000000000..1e3f89a25 --- /dev/null +++ b/ddverify/case_studies/block/floppy/floppy.c @@ -0,0 +1,4586 @@ +/* + * linux/drivers/block/floppy.c + * + * Copyright (C) 1991, 1992 Linus Torvalds + * Copyright (C) 1993, 1994 Alain Knaff + * Copyright (C) 1998 Alan Cox + */ +/* + * 02.12.91 - Changed to static variables to indicate need for reset + * and recalibrate. This makes some things easier (output_byte reset + * checking etc), and means less interrupt jumping in case of errors, + * so the code is hopefully easier to understand. + */ + +/* + * This file is certainly a mess. I've tried my best to get it working, + * but I don't like programming floppies, and I have only one anyway. + * Urgel. I should check for more errors, and do more graceful error + * recovery. Seems there are problems with several drives. I've tried to + * correct them. No promises. + */ + +/* + * As with hd.c, all routines within this file can (and will) be called + * by interrupts, so extreme caution is needed. A hardware interrupt + * handler may not sleep, or a kernel panic will happen. Thus I cannot + * call "floppy-on" directly, but have to set a special timer interrupt + * etc. + */ + +/* + * 28.02.92 - made track-buffering routines, based on the routines written + * by entropy@wintermute.wpi.edu (Lawrence Foard). Linus. + */ + +/* + * Automatic floppy-detection and formatting written by Werner Almesberger + * (almesber@nessie.cs.id.ethz.ch), who also corrected some problems with + * the floppy-change signal detection. + */ + +/* + * 1992/7/22 -- Hennus Bergman: Added better error reporting, fixed + * FDC data overrun bug, added some preliminary stuff for vertical + * recording support. + * + * 1992/9/17: Added DMA allocation & DMA functions. -- hhb. + * + * TODO: Errors are still not counted properly. + */ + +/* 1992/9/20 + * Modifications for ``Sector Shifting'' by Rob Hooft (hooft@chem.ruu.nl) + * modeled after the freeware MS-DOS program fdformat/88 V1.8 by + * Christoph H. Hochst\"atter. + * I have fixed the shift values to the ones I always use. Maybe a new + * ioctl() should be created to be able to modify them. + * There is a bug in the driver that makes it impossible to format a + * floppy as the first thing after bootup. + */ + +/* + * 1993/4/29 -- Linus -- cleaned up the timer handling in the kernel, and + * this helped the floppy driver as well. Much cleaner, and still seems to + * work. + */ + +/* 1994/6/24 --bbroad-- added the floppy table entries and made + * minor modifications to allow 2.88 floppies to be run. + */ + +/* 1994/7/13 -- Paul Vojta -- modified the probing code to allow three or more + * disk types. + */ + +/* + * 1994/8/8 -- Alain Knaff -- Switched to fdpatch driver: Support for bigger + * format bug fixes, but unfortunately some new bugs too... + */ + +/* 1994/9/17 -- Koen Holtman -- added logging of physical floppy write + * errors to allow safe writing by specialized programs. + */ + +/* 1995/4/24 -- Dan Fandrich -- added support for Commodore 1581 3.5" disks + * by defining bit 1 of the "stretch" parameter to mean put sectors on the + * opposite side of the disk, leaving the sector IDs alone (i.e. Commodore's + * drives are "upside-down"). + */ + +/* + * 1995/8/26 -- Andreas Busse -- added Mips support. + */ + +/* + * 1995/10/18 -- Ralf Baechle -- Portability cleanup; move machine dependent + * features to asm/floppy.h. + */ + +/* + * 1998/1/21 -- Richard Gooch -- devfs support + */ + +/* + * 1998/05/07 -- Russell King -- More portability cleanups; moved definition of + * interrupt and dma channel to asm/floppy.h. Cleaned up some formatting & + * use of '0' for NULL. + */ + +/* + * 1998/06/07 -- Alan Cox -- Merged the 2.0.34 fixes for resource allocation + * failures. + */ + +/* + * 1998/09/20 -- David Weinehall -- Added slow-down code for buggy PS/2-drives. + */ + +/* + * 1999/08/13 -- Paul Slootman -- floppy stopped working on Alpha after 24 + * days, 6 hours, 32 minutes and 32 seconds (i.e. MAXINT jiffies; ints were + * being used to store jiffies, which are unsigned longs). + */ + +/* + * 2000/08/28 -- Arnaldo Carvalho de Melo + * - get rid of check_region + * - s/suser/capable/ + */ + +/* + * 2001/08/26 -- Paul Gortmaker - fix insmod oops on machines with no + * floppy controller (lingering task on list after module is gone... boom.) + */ + +/* + * 2002/02/07 -- Anton Altaparmakov - Fix io ports reservation to correct range + * (0x3f2-0x3f5, 0x3f7). This fix is a bit of a hack but the proper fix + * requires many non-obvious changes in arch dependent code. + */ + +/* 2003/07/28 -- Daniele Bellucci . + * Better audit of register_blkdev. + */ + +#define FLOPPY_SANITY_CHECK +#undef FLOPPY_SILENT_DCL_CLEAR + +#define REALLY_SLOW_IO + +#define DEBUGT 2 +#define DCL_DEBUG /* debug disk change line */ + +/* do print messages for unexpected interrupts */ +static int print_unex = 1; +#include +#include +#include +#include +#include +#include +#define FDPATCHES +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include /* CMOS defines */ +#include +#include +#include +#include +#include /* for invalidate_buffers() */ +#include + +/* + * PS/2 floppies have much slower step rates than regular floppies. + * It's been recommended that take about 1/4 of the default speed + * in some more extreme cases. + */ +static int slow_floppy; + +#include +#include +#include +#include +#include + +static int FLOPPY_IRQ = 6; +static int FLOPPY_DMA = 2; +static int can_use_virtual_dma = 2; +/* ======= + * can use virtual DMA: + * 0 = use of virtual DMA disallowed by config + * 1 = use of virtual DMA prescribed by config + * 2 = no virtual DMA preference configured. By default try hard DMA, + * but fall back on virtual DMA when not enough memory available + */ + +static int use_virtual_dma; +/* ======= + * use virtual DMA + * 0 using hard DMA + * 1 using virtual DMA + * This variable is set to virtual when a DMA mem problem arises, and + * reset back in floppy_grab_irq_and_dma. + * It is not safe to reset it in other circumstances, because the floppy + * driver may have several buffers in use at once, and we do currently not + * record each buffers capabilities + */ + +static DEFINE_SPINLOCK(floppy_lock); +static struct completion device_release; + +static unsigned short virtual_dma_port = 0x3f0; +irqreturn_t floppy_interrupt(int irq, void *dev_id); +static int set_dor(int fdc, char mask, char data); + +#define K_64 0x10000 /* 64KB */ + +/* the following is the mask of allowed drives. By default units 2 and + * 3 of both floppy controllers are disabled, because switching on the + * motor of these drives causes system hangs on some PCI computers. drive + * 0 is the low bit (0x1), and drive 7 is the high bit (0x80). Bits are on if + * a drive is allowed. + * + * NOTE: This must come before we include the arch floppy header because + * some ports reference this variable from there. -DaveM + */ + +static int allowed_drive_mask = 0x33; + +#include + +static int irqdma_allocated; + +#define DEVICE_NAME "floppy" + +#include +#include +#include /* for the compatibility eject ioctl */ +#include + +static struct request *current_req; +static struct request_queue *floppy_queue; +static void do_fd_request(request_queue_t * q); + +#ifndef fd_get_dma_residue +#define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA) +#endif + +/* Dma Memory related stuff */ + +#ifndef fd_dma_mem_free +#define fd_dma_mem_free(addr, size) free_pages(addr, get_order(size)) +#endif + +#ifndef fd_dma_mem_alloc +#define fd_dma_mem_alloc(size) __get_dma_pages(GFP_KERNEL,get_order(size)) +#endif + +static inline void fallback_on_nodma_alloc(char **addr, size_t l) +{ +#ifdef FLOPPY_CAN_FALLBACK_ON_NODMA + if (*addr) + return; /* we have the memory */ + if (can_use_virtual_dma != 2) + return; /* no fallback allowed */ + printk + ("DMA memory shortage. Temporarily falling back on virtual DMA\n"); + *addr = (char *)nodma_mem_alloc(l); +#else + return; +#endif +} + +/* End dma memory related stuff */ + +static unsigned long fake_change; +static int initialising = 1; + +#define ITYPE(x) (((x)>>2) & 0x1f) +#define TOMINOR(x) ((x & 3) | ((x & 4) << 5)) +#define UNIT(x) ((x) & 0x03) /* drive on fdc */ +#define FDC(x) (((x) & 0x04) >> 2) /* fdc of drive */ +#define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2)) + /* reverse mapping from unit and fdc to drive */ +#define DP (&drive_params[current_drive]) +#define DRS (&drive_state[current_drive]) +#define DRWE (&write_errors[current_drive]) +#define FDCS (&fdc_state[fdc]) +#define CLEARF(x) (clear_bit(x##_BIT, &DRS->flags)) +#define SETF(x) (set_bit(x##_BIT, &DRS->flags)) +#define TESTF(x) (test_bit(x##_BIT, &DRS->flags)) + +#define UDP (&drive_params[drive]) +#define UDRS (&drive_state[drive]) +#define UDRWE (&write_errors[drive]) +#define UFDCS (&fdc_state[FDC(drive)]) +#define UCLEARF(x) (clear_bit(x##_BIT, &UDRS->flags)) +#define USETF(x) (set_bit(x##_BIT, &UDRS->flags)) +#define UTESTF(x) (test_bit(x##_BIT, &UDRS->flags)) + +#define DPRINT(format, args...) printk(DEVICE_NAME "%d: " format, current_drive , ## args) + +#define PH_HEAD(floppy,head) (((((floppy)->stretch & 2) >>1) ^ head) << 2) +#define STRETCH(floppy) ((floppy)->stretch & FD_STRETCH) + +#define CLEARSTRUCT(x) memset((x), 0, sizeof(*(x))) + +/* read/write */ +#define COMMAND raw_cmd->cmd[0] +#define DR_SELECT raw_cmd->cmd[1] +#define TRACK raw_cmd->cmd[2] +#define HEAD raw_cmd->cmd[3] +#define SECTOR raw_cmd->cmd[4] +#define SIZECODE raw_cmd->cmd[5] +#define SECT_PER_TRACK raw_cmd->cmd[6] +#define GAP raw_cmd->cmd[7] +#define SIZECODE2 raw_cmd->cmd[8] +#define NR_RW 9 + +/* format */ +#define F_SIZECODE raw_cmd->cmd[2] +#define F_SECT_PER_TRACK raw_cmd->cmd[3] +#define F_GAP raw_cmd->cmd[4] +#define F_FILL raw_cmd->cmd[5] +#define NR_F 6 + +/* + * Maximum disk size (in kilobytes). This default is used whenever the + * current disk size is unknown. + * [Now it is rather a minimum] + */ +#define MAX_DISK_SIZE 4 /* 3984 */ + +/* + * globals used by 'result()' + */ +#define MAX_REPLIES 16 +static unsigned char reply_buffer[MAX_REPLIES]; +static int inr; /* size of reply buffer, when called from interrupt */ +#define ST0 (reply_buffer[0]) +#define ST1 (reply_buffer[1]) +#define ST2 (reply_buffer[2]) +#define ST3 (reply_buffer[0]) /* result of GETSTATUS */ +#define R_TRACK (reply_buffer[3]) +#define R_HEAD (reply_buffer[4]) +#define R_SECTOR (reply_buffer[5]) +#define R_SIZECODE (reply_buffer[6]) + +#define SEL_DLY (2*HZ/100) + +/* + * this struct defines the different floppy drive types. + */ +static struct { + struct floppy_drive_params params; + const char *name; /* name printed while booting */ +} default_drive_params[] = { +/* NOTE: the time values in jiffies should be in msec! + CMOS drive type + | Maximum data rate supported by drive type + | | Head load time, msec + | | | Head unload time, msec (not used) + | | | | Step rate interval, usec + | | | | | Time needed for spinup time (jiffies) + | | | | | | Timeout for spinning down (jiffies) + | | | | | | | Spindown offset (where disk stops) + | | | | | | | | Select delay + | | | | | | | | | RPS + | | | | | | | | | | Max number of tracks + | | | | | | | | | | | Interrupt timeout + | | | | | | | | | | | | Max nonintlv. sectors + | | | | | | | | | | | | | -Max Errors- flags */ +{{0, 500, 16, 16, 8000, 1*HZ, 3*HZ, 0, SEL_DLY, 5, 80, 3*HZ, 20, {3,1,2,0,2}, 0, + 0, { 7, 4, 8, 2, 1, 5, 3,10}, 3*HZ/2, 0 }, "unknown" }, + +{{1, 300, 16, 16, 8000, 1*HZ, 3*HZ, 0, SEL_DLY, 5, 40, 3*HZ, 17, {3,1,2,0,2}, 0, + 0, { 1, 0, 0, 0, 0, 0, 0, 0}, 3*HZ/2, 1 }, "360K PC" }, /*5 1/4 360 KB PC*/ + +{{2, 500, 16, 16, 6000, 4*HZ/10, 3*HZ, 14, SEL_DLY, 6, 83, 3*HZ, 17, {3,1,2,0,2}, 0, + 0, { 2, 5, 6,23,10,20,12, 0}, 3*HZ/2, 2 }, "1.2M" }, /*5 1/4 HD AT*/ + +{{3, 250, 16, 16, 3000, 1*HZ, 3*HZ, 0, SEL_DLY, 5, 83, 3*HZ, 20, {3,1,2,0,2}, 0, + 0, { 4,22,21,30, 3, 0, 0, 0}, 3*HZ/2, 4 }, "720k" }, /*3 1/2 DD*/ + +{{4, 500, 16, 16, 4000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5, 83, 3*HZ, 20, {3,1,2,0,2}, 0, + 0, { 7, 4,25,22,31,21,29,11}, 3*HZ/2, 7 }, "1.44M" }, /*3 1/2 HD*/ + +{{5, 1000, 15, 8, 3000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5, 83, 3*HZ, 40, {3,1,2,0,2}, 0, + 0, { 7, 8, 4,25,28,22,31,21}, 3*HZ/2, 8 }, "2.88M AMI BIOS" }, /*3 1/2 ED*/ + +{{6, 1000, 15, 8, 3000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5, 83, 3*HZ, 40, {3,1,2,0,2}, 0, + 0, { 7, 8, 4,25,28,22,31,21}, 3*HZ/2, 8 }, "2.88M" } /*3 1/2 ED*/ +/* | --autodetected formats--- | | | + * read_track | | Name printed when booting + * | Native format + * Frequency of disk change checks */ +}; + +static struct floppy_drive_params drive_params[N_DRIVE]; +static struct floppy_drive_struct drive_state[N_DRIVE]; +static struct floppy_write_errors write_errors[N_DRIVE]; +static struct timer_list motor_off_timer[N_DRIVE]; +static struct gendisk *disks[N_DRIVE]; +static struct block_device *opened_bdev[N_DRIVE]; +static DEFINE_MUTEX(open_lock); +static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; + +/* + * This struct defines the different floppy types. + * + * Bit 0 of 'stretch' tells if the tracks need to be doubled for some + * types (e.g. 360kB diskette in 1.2MB drive, etc.). Bit 1 of 'stretch' + * tells if the disk is in Commodore 1581 format, which means side 0 sectors + * are located on side 1 of the disk but with a side 0 ID, and vice-versa. + * This is the same as the Sharp MZ-80 5.25" CP/M disk format, except that the + * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical + * side 0 is on physical side 0 (but with the misnamed sector IDs). + * 'stretch' should probably be renamed to something more general, like + * 'options'. Other parameters should be self-explanatory (see also + * setfdprm(8)). + */ +/* + Size + | Sectors per track + | | Head + | | | Tracks + | | | | Stretch + | | | | | Gap 1 size + | | | | | | Data rate, | 0x40 for perp + | | | | | | | Spec1 (stepping rate, head unload + | | | | | | | | /fmt gap (gap2) */ +static struct floppy_struct floppy_type[32] = { + { 0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL }, /* 0 no testing */ + { 720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"d360" }, /* 1 360KB PC */ + { 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,"h1200" }, /* 2 1.2MB AT */ + { 720, 9,1,80,0,0x2A,0x02,0xDF,0x50,"D360" }, /* 3 360KB SS 3.5" */ + { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"D720" }, /* 4 720KB 3.5" */ + { 720, 9,2,40,1,0x23,0x01,0xDF,0x50,"h360" }, /* 5 360KB AT */ + { 1440, 9,2,80,0,0x23,0x01,0xDF,0x50,"h720" }, /* 6 720KB AT */ + { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,"H1440" }, /* 7 1.44MB 3.5" */ + { 5760,36,2,80,0,0x1B,0x43,0xAF,0x54,"E2880" }, /* 8 2.88MB 3.5" */ + { 6240,39,2,80,0,0x1B,0x43,0xAF,0x28,"E3120" }, /* 9 3.12MB 3.5" */ + + { 2880,18,2,80,0,0x25,0x00,0xDF,0x02,"h1440" }, /* 10 1.44MB 5.25" */ + { 3360,21,2,80,0,0x1C,0x00,0xCF,0x0C,"H1680" }, /* 11 1.68MB 3.5" */ + { 820,10,2,41,1,0x25,0x01,0xDF,0x2E,"h410" }, /* 12 410KB 5.25" */ + { 1640,10,2,82,0,0x25,0x02,0xDF,0x2E,"H820" }, /* 13 820KB 3.5" */ + { 2952,18,2,82,0,0x25,0x00,0xDF,0x02,"h1476" }, /* 14 1.48MB 5.25" */ + { 3444,21,2,82,0,0x25,0x00,0xDF,0x0C,"H1722" }, /* 15 1.72MB 3.5" */ + { 840,10,2,42,1,0x25,0x01,0xDF,0x2E,"h420" }, /* 16 420KB 5.25" */ + { 1660,10,2,83,0,0x25,0x02,0xDF,0x2E,"H830" }, /* 17 830KB 3.5" */ + { 2988,18,2,83,0,0x25,0x00,0xDF,0x02,"h1494" }, /* 18 1.49MB 5.25" */ + { 3486,21,2,83,0,0x25,0x00,0xDF,0x0C,"H1743" }, /* 19 1.74 MB 3.5" */ + + { 1760,11,2,80,0,0x1C,0x09,0xCF,0x00,"h880" }, /* 20 880KB 5.25" */ + { 2080,13,2,80,0,0x1C,0x01,0xCF,0x00,"D1040" }, /* 21 1.04MB 3.5" */ + { 2240,14,2,80,0,0x1C,0x19,0xCF,0x00,"D1120" }, /* 22 1.12MB 3.5" */ + { 3200,20,2,80,0,0x1C,0x20,0xCF,0x2C,"h1600" }, /* 23 1.6MB 5.25" */ + { 3520,22,2,80,0,0x1C,0x08,0xCF,0x2e,"H1760" }, /* 24 1.76MB 3.5" */ + { 3840,24,2,80,0,0x1C,0x20,0xCF,0x00,"H1920" }, /* 25 1.92MB 3.5" */ + { 6400,40,2,80,0,0x25,0x5B,0xCF,0x00,"E3200" }, /* 26 3.20MB 3.5" */ + { 7040,44,2,80,0,0x25,0x5B,0xCF,0x00,"E3520" }, /* 27 3.52MB 3.5" */ + { 7680,48,2,80,0,0x25,0x63,0xCF,0x00,"E3840" }, /* 28 3.84MB 3.5" */ + + { 3680,23,2,80,0,0x1C,0x10,0xCF,0x00,"H1840" }, /* 29 1.84MB 3.5" */ + { 1600,10,2,80,0,0x25,0x02,0xDF,0x2E,"D800" }, /* 30 800KB 3.5" */ + { 3200,20,2,80,0,0x1C,0x00,0xCF,0x2C,"H1600" }, /* 31 1.6MB 3.5" */ +}; + +#define SECTSIZE (_FD_SECTSIZE(*floppy)) + +/* Auto-detection: Disk type used until the next media change occurs. */ +static struct floppy_struct *current_type[N_DRIVE]; + +/* + * User-provided type information. current_type points to + * the respective entry of this array. + */ +static struct floppy_struct user_params[N_DRIVE]; + +static sector_t floppy_sizes[256]; + +static char floppy_device_name[] = "floppy"; + +/* + * The driver is trying to determine the correct media format + * while probing is set. rw_interrupt() clears it after a + * successful access. + */ +static int probing; + +/* Synchronization of FDC access. */ +#define FD_COMMAND_NONE -1 +#define FD_COMMAND_ERROR 2 +#define FD_COMMAND_OKAY 3 + +static volatile int command_status = FD_COMMAND_NONE; +static unsigned long fdc_busy; +static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); +static DECLARE_WAIT_QUEUE_HEAD(command_done); + +#define NO_SIGNAL (!interruptible || !signal_pending(current)) +#define CALL(x) if ((x) == -EINTR) return -EINTR +#define ECALL(x) if ((ret = (x))) return ret; +#define _WAIT(x,i) CALL(ret=wait_til_done((x),i)) +#define WAIT(x) _WAIT((x),interruptible) +#define IWAIT(x) _WAIT((x),1) + +/* Errors during formatting are counted here. */ +static int format_errors; + +/* Format request descriptor. */ +static struct format_descr format_req; + +/* + * Rate is 0 for 500kb/s, 1 for 300kbps, 2 for 250kbps + * Spec1 is 0xSH, where S is stepping rate (F=1ms, E=2ms, D=3ms etc), + * H is head unload time (1=16ms, 2=32ms, etc) + */ + +/* + * Track buffer + * Because these are written to by the DMA controller, they must + * not contain a 64k byte boundary crossing, or data will be + * corrupted/lost. + */ +static char *floppy_track_buffer; +static int max_buffer_sectors; + +static int *errors; +typedef void (*done_f) (int); +static struct cont_t { + void (*interrupt) (void); /* this is called after the interrupt of the + * main command */ + void (*redo) (void); /* this is called to retry the operation */ + void (*error) (void); /* this is called to tally an error */ + done_f done; /* this is called to say if the operation has + * succeeded/failed */ +} *cont; + +static void floppy_ready(void); +static void floppy_start(void); +static void process_fd_request(void); +static void recalibrate_floppy(void); +static void floppy_shutdown(unsigned long); + +static int floppy_grab_irq_and_dma(void); +static void floppy_release_irq_and_dma(void); + +/* + * The "reset" variable should be tested whenever an interrupt is scheduled, + * after the commands have been sent. This is to ensure that the driver doesn't + * get wedged when the interrupt doesn't come because of a failed command. + * reset doesn't need to be tested before sending commands, because + * output_byte is automatically disabled when reset is set. + */ +#define CHECK_RESET { if (FDCS->reset){ reset_fdc(); return; } } +static void reset_fdc(void); + +/* + * These are global variables, as that's the easiest way to give + * information to interrupts. They are the data used for the current + * request. + */ +#define NO_TRACK -1 +#define NEED_1_RECAL -2 +#define NEED_2_RECAL -3 + +static int usage_count; + +/* buffer related variables */ +static int buffer_track = -1; +static int buffer_drive = -1; +static int buffer_min = -1; +static int buffer_max = -1; + +/* fdc related variables, should end up in a struct */ +static struct floppy_fdc_state fdc_state[N_FDC]; +static int fdc; /* current fdc */ + +static struct floppy_struct *_floppy = floppy_type; +static unsigned char current_drive; +static long current_count_sectors; +static unsigned char fsector_t; /* sector in track */ +static unsigned char in_sector_offset; /* offset within physical sector, + * expressed in units of 512 bytes */ + +#ifndef fd_eject +static inline int fd_eject(int drive) +{ + return -EINVAL; +} +#endif + +/* + * Debugging + * ========= + */ +#ifdef DEBUGT +static long unsigned debugtimer; + +static inline void set_debugt(void) +{ + debugtimer = jiffies; +} + +static inline void debugt(const char *message) +{ + if (DP->flags & DEBUGT) + printk("%s dtime=%lu\n", message, jiffies - debugtimer); +} +#else +static inline void set_debugt(void) { } +static inline void debugt(const char *message) { } +#endif /* DEBUGT */ + +typedef void (*timeout_fn) (unsigned long); +static DEFINE_TIMER(fd_timeout, floppy_shutdown, 0, 0); + +static const char *timeout_message; + +#ifdef FLOPPY_SANITY_CHECK +static void is_alive(const char *message) +{ + /* this routine checks whether the floppy driver is "alive" */ + if (test_bit(0, &fdc_busy) && command_status < 2 + && !timer_pending(&fd_timeout)) { + DPRINT("timeout handler died: %s\n", message); + } +} +#endif + +static void (*do_floppy) (void) = NULL; + +#ifdef FLOPPY_SANITY_CHECK + +#define OLOGSIZE 20 + +static void (*lasthandler) (void); +static unsigned long interruptjiffies; +static unsigned long resultjiffies; +static int resultsize; +static unsigned long lastredo; + +static struct output_log { + unsigned char data; + unsigned char status; + unsigned long jiffies; +} output_log[OLOGSIZE]; + +static int output_log_pos; +#endif + +#define current_reqD -1 +#define MAXTIMEOUT -2 + +static void __reschedule_timeout(int drive, const char *message, int marg) +{ + if (drive == current_reqD) + drive = current_drive; + del_timer(&fd_timeout); + if (drive < 0 || drive > N_DRIVE) { + fd_timeout.expires = jiffies + 20UL * HZ; + drive = 0; + } else + fd_timeout.expires = jiffies + UDP->timeout; + add_timer(&fd_timeout); + if (UDP->flags & FD_DEBUG) { + DPRINT("reschedule timeout "); + printk(message, marg); + printk("\n"); + } + timeout_message = message; +} + +static void reschedule_timeout(int drive, const char *message, int marg) +{ + unsigned long flags; + + spin_lock_irqsave(&floppy_lock, flags); + __reschedule_timeout(drive, message, marg); + spin_unlock_irqrestore(&floppy_lock, flags); +} + +#define INFBOUND(a,b) (a)=max_t(int, a, b) + +#define SUPBOUND(a,b) (a)=min_t(int, a, b) + +/* + * Bottom half floppy driver. + * ========================== + * + * This part of the file contains the code talking directly to the hardware, + * and also the main service loop (seek-configure-spinup-command) + */ + +/* + * disk change. + * This routine is responsible for maintaining the FD_DISK_CHANGE flag, + * and the last_checked date. + * + * last_checked is the date of the last check which showed 'no disk change' + * FD_DISK_CHANGE is set under two conditions: + * 1. The floppy has been changed after some i/o to that floppy already + * took place. + * 2. No floppy disk is in the drive. This is done in order to ensure that + * requests are quickly flushed in case there is no disk in the drive. It + * follows that FD_DISK_CHANGE can only be cleared if there is a disk in + * the drive. + * + * For 1., maxblock is observed. Maxblock is 0 if no i/o has taken place yet. + * For 2., FD_DISK_NEWCHANGE is watched. FD_DISK_NEWCHANGE is cleared on + * each seek. If a disk is present, the disk change line should also be + * cleared on each seek. Thus, if FD_DISK_NEWCHANGE is clear, but the disk + * change line is set, this means either that no disk is in the drive, or + * that it has been removed since the last seek. + * + * This means that we really have a third possibility too: + * The floppy has been changed after the last seek. + */ + +static int disk_change(int drive) +{ + int fdc = FDC(drive); +#ifdef FLOPPY_SANITY_CHECK + if (time_before(jiffies, UDRS->select_date + UDP->select_delay)) + DPRINT("WARNING disk change called early\n"); + if (!(FDCS->dor & (0x10 << UNIT(drive))) || + (FDCS->dor & 3) != UNIT(drive) || fdc != FDC(drive)) { + DPRINT("probing disk change on unselected drive\n"); + DPRINT("drive=%d fdc=%d dor=%x\n", drive, FDC(drive), + (unsigned int)FDCS->dor); + } +#endif + +#ifdef DCL_DEBUG + if (UDP->flags & FD_DEBUG) { + DPRINT("checking disk change line for drive %d\n", drive); + DPRINT("jiffies=%lu\n", jiffies); + DPRINT("disk change line=%x\n", fd_inb(FD_DIR) & 0x80); + DPRINT("flags=%lx\n", UDRS->flags); + } +#endif + if (UDP->flags & FD_BROKEN_DCL) + return UTESTF(FD_DISK_CHANGED); + if ((fd_inb(FD_DIR) ^ UDP->flags) & 0x80) { + USETF(FD_VERIFY); /* verify write protection */ + if (UDRS->maxblock) { + /* mark it changed */ + USETF(FD_DISK_CHANGED); + } + + /* invalidate its geometry */ + if (UDRS->keep_data >= 0) { + if ((UDP->flags & FTD_MSG) && + current_type[drive] != NULL) + DPRINT("Disk type is undefined after " + "disk change\n"); + current_type[drive] = NULL; + floppy_sizes[TOMINOR(drive)] = MAX_DISK_SIZE << 1; + } + + /*USETF(FD_DISK_NEWCHANGE); */ + return 1; + } else { + UDRS->last_checked = jiffies; + UCLEARF(FD_DISK_NEWCHANGE); + } + return 0; +} + +static inline int is_selected(int dor, int unit) +{ + return ((dor & (0x10 << unit)) && (dor & 3) == unit); +} + +static int set_dor(int fdc, char mask, char data) +{ + register unsigned char drive, unit, newdor, olddor; + + if (FDCS->address == -1) + return -1; + + olddor = FDCS->dor; + newdor = (olddor & mask) | data; + if (newdor != olddor) { + unit = olddor & 0x3; + if (is_selected(olddor, unit) && !is_selected(newdor, unit)) { + drive = REVDRIVE(fdc, unit); +#ifdef DCL_DEBUG + if (UDP->flags & FD_DEBUG) { + DPRINT("calling disk change from set_dor\n"); + } +#endif + disk_change(drive); + } + FDCS->dor = newdor; + fd_outb(newdor, FD_DOR); + + unit = newdor & 0x3; + if (!is_selected(olddor, unit) && is_selected(newdor, unit)) { + drive = REVDRIVE(fdc, unit); + UDRS->select_date = jiffies; + } + } + return olddor; +} + +static void twaddle(void) +{ + if (DP->select_delay) + return; + fd_outb(FDCS->dor & ~(0x10 << UNIT(current_drive)), FD_DOR); + fd_outb(FDCS->dor, FD_DOR); + DRS->select_date = jiffies; +} + +/* reset all driver information about the current fdc. This is needed after + * a reset, and after a raw command. */ +static void reset_fdc_info(int mode) +{ + int drive; + + FDCS->spec1 = FDCS->spec2 = -1; + FDCS->need_configure = 1; + FDCS->perp_mode = 1; + FDCS->rawcmd = 0; + for (drive = 0; drive < N_DRIVE; drive++) + if (FDC(drive) == fdc && (mode || UDRS->track != NEED_1_RECAL)) + UDRS->track = NEED_2_RECAL; +} + +/* selects the fdc and drive, and enables the fdc's input/dma. */ +static void set_fdc(int drive) +{ + if (drive >= 0 && drive < N_DRIVE) { + fdc = FDC(drive); + current_drive = drive; + } + if (fdc != 1 && fdc != 0) { + printk("bad fdc value\n"); + return; + } + set_dor(fdc, ~0, 8); +#if N_FDC > 1 + set_dor(1 - fdc, ~8, 0); +#endif + if (FDCS->rawcmd == 2) + reset_fdc_info(1); + if (fd_inb(FD_STATUS) != STATUS_READY) + FDCS->reset = 1; +} + +/* locks the driver */ +static int _lock_fdc(int drive, int interruptible, int line) +{ + if (!usage_count) { + printk(KERN_ERR + "Trying to lock fdc while usage count=0 at line %d\n", + line); + return -1; + } + + if (test_and_set_bit(0, &fdc_busy)) { + DECLARE_WAITQUEUE(wait, current); + add_wait_queue(&fdc_wait, &wait); + + for (;;) { + set_current_state(TASK_INTERRUPTIBLE); + + if (!test_and_set_bit(0, &fdc_busy)) + break; + + schedule(); + + if (!NO_SIGNAL) { + remove_wait_queue(&fdc_wait, &wait); + return -EINTR; + } + } + + set_current_state(TASK_RUNNING); + remove_wait_queue(&fdc_wait, &wait); + + flush_scheduled_work(); + } + command_status = FD_COMMAND_NONE; + + __reschedule_timeout(drive, "lock fdc", 0); + set_fdc(drive); + return 0; +} + +#define lock_fdc(drive,interruptible) _lock_fdc(drive,interruptible, __LINE__) + +#define LOCK_FDC(drive,interruptible) \ +if (lock_fdc(drive,interruptible)) return -EINTR; + +/* unlocks the driver */ +static inline void unlock_fdc(void) +{ + unsigned long flags; + + raw_cmd = NULL; + if (!test_bit(0, &fdc_busy)) + DPRINT("FDC access conflict!\n"); + + if (do_floppy) + DPRINT("device interrupt still active at FDC release: %p!\n", + do_floppy); + command_status = FD_COMMAND_NONE; + spin_lock_irqsave(&floppy_lock, flags); + del_timer(&fd_timeout); + cont = NULL; + clear_bit(0, &fdc_busy); + if (elv_next_request(floppy_queue)) + do_fd_request(floppy_queue); + spin_unlock_irqrestore(&floppy_lock, flags); + wake_up(&fdc_wait); +} + +/* switches the motor off after a given timeout */ +static void motor_off_callback(unsigned long nr) +{ + unsigned char mask = ~(0x10 << UNIT(nr)); + + set_dor(FDC(nr), mask, 0); +} + +/* schedules motor off */ +static void floppy_off(unsigned int drive) +{ + unsigned long volatile delta; + register int fdc = FDC(drive); + + if (!(FDCS->dor & (0x10 << UNIT(drive)))) + return; + + del_timer(motor_off_timer + drive); + + /* make spindle stop in a position which minimizes spinup time + * next time */ + if (UDP->rps) { + delta = jiffies - UDRS->first_read_date + HZ - + UDP->spindown_offset; + delta = ((delta * UDP->rps) % HZ) / UDP->rps; + motor_off_timer[drive].expires = + jiffies + UDP->spindown - delta; + } + add_timer(motor_off_timer + drive); +} + +/* + * cycle through all N_DRIVE floppy drives, for disk change testing. + * stopping at current drive. This is done before any long operation, to + * be sure to have up to date disk change information. + */ +static void scandrives(void) +{ + int i, drive, saved_drive; + + if (DP->select_delay) + return; + + saved_drive = current_drive; + for (i = 0; i < N_DRIVE; i++) { + drive = (saved_drive + i + 1) % N_DRIVE; + if (UDRS->fd_ref == 0 || UDP->select_delay != 0) + continue; /* skip closed drives */ + set_fdc(drive); + if (!(set_dor(fdc, ~3, UNIT(drive) | (0x10 << UNIT(drive))) & + (0x10 << UNIT(drive)))) + /* switch the motor off again, if it was off to + * begin with */ + set_dor(fdc, ~(0x10 << UNIT(drive)), 0); + } + set_fdc(saved_drive); +} + +static void empty(void) +{ +} + +static DECLARE_WORK(floppy_work, NULL, NULL); + +static void schedule_bh(void (*handler) (void)) +{ + PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL); + schedule_work(&floppy_work); +} + +static DEFINE_TIMER(fd_timer, NULL, 0, 0); + +static void cancel_activity(void) +{ + unsigned long flags; + + spin_lock_irqsave(&floppy_lock, flags); + do_floppy = NULL; + PREPARE_WORK(&floppy_work, (void *)empty, NULL); + del_timer(&fd_timer); + spin_unlock_irqrestore(&floppy_lock, flags); +} + +/* this function makes sure that the disk stays in the drive during the + * transfer */ +static void fd_watchdog(void) +{ +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT("calling disk change from watchdog\n"); + } +#endif + + if (disk_change(current_drive)) { + DPRINT("disk removed during i/o\n"); + cancel_activity(); + cont->done(0); + reset_fdc(); + } else { + del_timer(&fd_timer); + fd_timer.function = (timeout_fn) fd_watchdog; + fd_timer.expires = jiffies + HZ / 10; + add_timer(&fd_timer); + } +} + +static void main_command_interrupt(void) +{ + del_timer(&fd_timer); + cont->interrupt(); +} + +/* waits for a delay (spinup or select) to pass */ +static int fd_wait_for_completion(unsigned long delay, timeout_fn function) +{ + if (FDCS->reset) { + reset_fdc(); /* do the reset during sleep to win time + * if we don't need to sleep, it's a good + * occasion anyways */ + return 1; + } + + if (time_before(jiffies, delay)) { + del_timer(&fd_timer); + fd_timer.function = function; + fd_timer.expires = delay; + add_timer(&fd_timer); + return 1; + } + return 0; +} + +static DEFINE_SPINLOCK(floppy_hlt_lock); +static int hlt_disabled; +static void floppy_disable_hlt(void) +{ + unsigned long flags; + + spin_lock_irqsave(&floppy_hlt_lock, flags); + if (!hlt_disabled) { + hlt_disabled = 1; +#ifdef HAVE_DISABLE_HLT + disable_hlt(); +#endif + } + spin_unlock_irqrestore(&floppy_hlt_lock, flags); +} + +static void floppy_enable_hlt(void) +{ + unsigned long flags; + + spin_lock_irqsave(&floppy_hlt_lock, flags); + if (hlt_disabled) { + hlt_disabled = 0; +#ifdef HAVE_DISABLE_HLT + enable_hlt(); +#endif + } + spin_unlock_irqrestore(&floppy_hlt_lock, flags); +} + +static void setup_DMA(void) +{ + unsigned long f; + +#ifdef FLOPPY_SANITY_CHECK + if (raw_cmd->length == 0) { + int i; + + printk("zero dma transfer size:"); + for (i = 0; i < raw_cmd->cmd_count; i++) + printk("%x,", raw_cmd->cmd[i]); + printk("\n"); + cont->done(0); + FDCS->reset = 1; + return; + } + if (((unsigned long)raw_cmd->kernel_data) % 512) { + printk("non aligned address: %p\n", raw_cmd->kernel_data); + cont->done(0); + FDCS->reset = 1; + return; + } +#endif + f = claim_dma_lock(); + fd_disable_dma(); +#ifdef fd_dma_setup + if (fd_dma_setup(raw_cmd->kernel_data, raw_cmd->length, + (raw_cmd->flags & FD_RAW_READ) ? + DMA_MODE_READ : DMA_MODE_WRITE, FDCS->address) < 0) { + release_dma_lock(f); + cont->done(0); + FDCS->reset = 1; + return; + } + release_dma_lock(f); +#else + fd_clear_dma_ff(); + fd_cacheflush(raw_cmd->kernel_data, raw_cmd->length); + fd_set_dma_mode((raw_cmd->flags & FD_RAW_READ) ? + DMA_MODE_READ : DMA_MODE_WRITE); + fd_set_dma_addr(raw_cmd->kernel_data); + fd_set_dma_count(raw_cmd->length); + virtual_dma_port = FDCS->address; + fd_enable_dma(); + release_dma_lock(f); +#endif + floppy_disable_hlt(); +} + +static void show_floppy(void); + +/* waits until the fdc becomes ready */ +static int wait_til_ready(void) +{ + int counter, status; + if (FDCS->reset) + return -1; + for (counter = 0; counter < 10000; counter++) { + status = fd_inb(FD_STATUS); + if (status & STATUS_READY) + return status; + } + if (!initialising) { + DPRINT("Getstatus times out (%x) on fdc %d\n", status, fdc); + show_floppy(); + } + FDCS->reset = 1; + return -1; +} + +/* sends a command byte to the fdc */ +static int output_byte(char byte) +{ + int status; + + if ((status = wait_til_ready()) < 0) + return -1; + if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) { + fd_outb(byte, FD_DATA); +#ifdef FLOPPY_SANITY_CHECK + output_log[output_log_pos].data = byte; + output_log[output_log_pos].status = status; + output_log[output_log_pos].jiffies = jiffies; + output_log_pos = (output_log_pos + 1) % OLOGSIZE; +#endif + return 0; + } + FDCS->reset = 1; + if (!initialising) { + DPRINT("Unable to send byte %x to FDC. Fdc=%x Status=%x\n", + byte, fdc, status); + show_floppy(); + } + return -1; +} + +#define LAST_OUT(x) if (output_byte(x)<0){ reset_fdc();return;} + +/* gets the response from the fdc */ +static int result(void) +{ + int i, status = 0; + + for (i = 0; i < MAX_REPLIES; i++) { + if ((status = wait_til_ready()) < 0) + break; + status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA; + if ((status & ~STATUS_BUSY) == STATUS_READY) { +#ifdef FLOPPY_SANITY_CHECK + resultjiffies = jiffies; + resultsize = i; +#endif + return i; + } + if (status == (STATUS_DIR | STATUS_READY | STATUS_BUSY)) + reply_buffer[i] = fd_inb(FD_DATA); + else + break; + } + if (!initialising) { + DPRINT + ("get result error. Fdc=%d Last status=%x Read bytes=%d\n", + fdc, status, i); + show_floppy(); + } + FDCS->reset = 1; + return -1; +} + +#define MORE_OUTPUT -2 +/* does the fdc need more output? */ +static int need_more_output(void) +{ + int status; + if ((status = wait_til_ready()) < 0) + return -1; + if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) + return MORE_OUTPUT; + return result(); +} + +/* Set perpendicular mode as required, based on data rate, if supported. + * 82077 Now tested. 1Mbps data rate only possible with 82077-1. + */ +static inline void perpendicular_mode(void) +{ + unsigned char perp_mode; + + if (raw_cmd->rate & 0x40) { + switch (raw_cmd->rate & 3) { + case 0: + perp_mode = 2; + break; + case 3: + perp_mode = 3; + break; + default: + DPRINT("Invalid data rate for perpendicular mode!\n"); + cont->done(0); + FDCS->reset = 1; /* convenient way to return to + * redo without to much hassle (deep + * stack et al. */ + return; + } + } else + perp_mode = 0; + + if (FDCS->perp_mode == perp_mode) + return; + if (FDCS->version >= FDC_82077_ORIG) { + output_byte(FD_PERPENDICULAR); + output_byte(perp_mode); + FDCS->perp_mode = perp_mode; + } else if (perp_mode) { + DPRINT("perpendicular mode not supported by this FDC.\n"); + } +} /* perpendicular_mode */ + +static int fifo_depth = 0xa; +static int no_fifo; + +static int fdc_configure(void) +{ + /* Turn on FIFO */ + output_byte(FD_CONFIGURE); + if (need_more_output() != MORE_OUTPUT) + return 0; + output_byte(0); + output_byte(0x10 | (no_fifo & 0x20) | (fifo_depth & 0xf)); + output_byte(0); /* pre-compensation from track + 0 upwards */ + return 1; +} + +#define NOMINAL_DTR 500 + +/* Issue a "SPECIFY" command to set the step rate time, head unload time, + * head load time, and DMA disable flag to values needed by floppy. + * + * The value "dtr" is the data transfer rate in Kbps. It is needed + * to account for the data rate-based scaling done by the 82072 and 82077 + * FDC types. This parameter is ignored for other types of FDCs (i.e. + * 8272a). + * + * Note that changing the data transfer rate has a (probably deleterious) + * effect on the parameters subject to scaling for 82072/82077 FDCs, so + * fdc_specify is called again after each data transfer rate + * change. + * + * srt: 1000 to 16000 in microseconds + * hut: 16 to 240 milliseconds + * hlt: 2 to 254 milliseconds + * + * These values are rounded up to the next highest available delay time. + */ +static void fdc_specify(void) +{ + unsigned char spec1, spec2; + unsigned long srt, hlt, hut; + unsigned long dtr = NOMINAL_DTR; + unsigned long scale_dtr = NOMINAL_DTR; + int hlt_max_code = 0x7f; + int hut_max_code = 0xf; + + if (FDCS->need_configure && FDCS->version >= FDC_82072A) { + fdc_configure(); + FDCS->need_configure = 0; + /*DPRINT("FIFO enabled\n"); */ + } + + switch (raw_cmd->rate & 0x03) { + case 3: + dtr = 1000; + break; + case 1: + dtr = 300; + if (FDCS->version >= FDC_82078) { + /* chose the default rate table, not the one + * where 1 = 2 Mbps */ + output_byte(FD_DRIVESPEC); + if (need_more_output() == MORE_OUTPUT) { + output_byte(UNIT(current_drive)); + output_byte(0xc0); + } + } + break; + case 2: + dtr = 250; + break; + } + + if (FDCS->version >= FDC_82072) { + scale_dtr = dtr; + hlt_max_code = 0x00; /* 0==256msec*dtr0/dtr (not linear!) */ + hut_max_code = 0x0; /* 0==256msec*dtr0/dtr (not linear!) */ + } + + /* Convert step rate from microseconds to milliseconds and 4 bits */ + srt = 16 - (DP->srt * scale_dtr / 1000 + NOMINAL_DTR - 1) / NOMINAL_DTR; + if (slow_floppy) { + srt = srt / 4; + } + SUPBOUND(srt, 0xf); + INFBOUND(srt, 0); + + hlt = (DP->hlt * scale_dtr / 2 + NOMINAL_DTR - 1) / NOMINAL_DTR; + if (hlt < 0x01) + hlt = 0x01; + else if (hlt > 0x7f) + hlt = hlt_max_code; + + hut = (DP->hut * scale_dtr / 16 + NOMINAL_DTR - 1) / NOMINAL_DTR; + if (hut < 0x1) + hut = 0x1; + else if (hut > 0xf) + hut = hut_max_code; + + spec1 = (srt << 4) | hut; + spec2 = (hlt << 1) | (use_virtual_dma & 1); + + /* If these parameters did not change, just return with success */ + if (FDCS->spec1 != spec1 || FDCS->spec2 != spec2) { + /* Go ahead and set spec1 and spec2 */ + output_byte(FD_SPECIFY); + output_byte(FDCS->spec1 = spec1); + output_byte(FDCS->spec2 = spec2); + } +} /* fdc_specify */ + +/* Set the FDC's data transfer rate on behalf of the specified drive. + * NOTE: with 82072/82077 FDCs, changing the data rate requires a reissue + * of the specify command (i.e. using the fdc_specify function). + */ +static int fdc_dtr(void) +{ + /* If data rate not already set to desired value, set it. */ + if ((raw_cmd->rate & 3) == FDCS->dtr) + return 0; + + /* Set dtr */ + fd_outb(raw_cmd->rate & 3, FD_DCR); + + /* TODO: some FDC/drive combinations (C&T 82C711 with TEAC 1.2MB) + * need a stabilization period of several milliseconds to be + * enforced after data rate changes before R/W operations. + * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies) + */ + FDCS->dtr = raw_cmd->rate & 3; + return (fd_wait_for_completion(jiffies + 2UL * HZ / 100, + (timeout_fn) floppy_ready)); +} /* fdc_dtr */ + +static void tell_sector(void) +{ + printk(": track %d, head %d, sector %d, size %d", + R_TRACK, R_HEAD, R_SECTOR, R_SIZECODE); +} /* tell_sector */ + +/* + * OK, this error interpreting routine is called after a + * DMA read/write has succeeded + * or failed, so we check the results, and copy any buffers. + * hhb: Added better error reporting. + * ak: Made this into a separate routine. + */ +static int interpret_errors(void) +{ + char bad; + + if (inr != 7) { + DPRINT("-- FDC reply error"); + FDCS->reset = 1; + return 1; + } + + /* check IC to find cause of interrupt */ + switch (ST0 & ST0_INTR) { + case 0x40: /* error occurred during command execution */ + if (ST1 & ST1_EOC) + return 0; /* occurs with pseudo-DMA */ + bad = 1; + if (ST1 & ST1_WP) { + DPRINT("Drive is write protected\n"); + CLEARF(FD_DISK_WRITABLE); + cont->done(0); + bad = 2; + } else if (ST1 & ST1_ND) { + SETF(FD_NEED_TWADDLE); + } else if (ST1 & ST1_OR) { + if (DP->flags & FTD_MSG) + DPRINT("Over/Underrun - retrying\n"); + bad = 0; + } else if (*errors >= DP->max_errors.reporting) { + DPRINT(""); + if (ST0 & ST0_ECE) { + printk("Recalibrate failed!"); + } else if (ST2 & ST2_CRC) { + printk("data CRC error"); + tell_sector(); + } else if (ST1 & ST1_CRC) { + printk("CRC error"); + tell_sector(); + } else if ((ST1 & (ST1_MAM | ST1_ND)) + || (ST2 & ST2_MAM)) { + if (!probing) { + printk("sector not found"); + tell_sector(); + } else + printk("probe failed..."); + } else if (ST2 & ST2_WC) { /* seek error */ + printk("wrong cylinder"); + } else if (ST2 & ST2_BC) { /* cylinder marked as bad */ + printk("bad cylinder"); + } else { + printk + ("unknown error. ST[0..2] are: 0x%x 0x%x 0x%x", + ST0, ST1, ST2); + tell_sector(); + } + printk("\n"); + + } + if (ST2 & ST2_WC || ST2 & ST2_BC) + /* wrong cylinder => recal */ + DRS->track = NEED_2_RECAL; + return bad; + case 0x80: /* invalid command given */ + DPRINT("Invalid FDC command given!\n"); + cont->done(0); + return 2; + case 0xc0: + DPRINT("Abnormal termination caused by polling\n"); + cont->error(); + return 2; + default: /* (0) Normal command termination */ + return 0; + } +} + +/* + * This routine is called when everything should be correctly set up + * for the transfer (i.e. floppy motor is on, the correct floppy is + * selected, and the head is sitting on the right track). + */ +static void setup_rw_floppy(void) +{ + int i, r, flags, dflags; + unsigned long ready_date; + timeout_fn function; + + flags = raw_cmd->flags; + if (flags & (FD_RAW_READ | FD_RAW_WRITE)) + flags |= FD_RAW_INTR; + + if ((flags & FD_RAW_SPIN) && !(flags & FD_RAW_NO_MOTOR)) { + ready_date = DRS->spinup_date + DP->spinup; + /* If spinup will take a long time, rerun scandrives + * again just before spinup completion. Beware that + * after scandrives, we must again wait for selection. + */ + if (time_after(ready_date, jiffies + DP->select_delay)) { + ready_date -= DP->select_delay; + function = (timeout_fn) floppy_start; + } else + function = (timeout_fn) setup_rw_floppy; + + /* wait until the floppy is spinning fast enough */ + if (fd_wait_for_completion(ready_date, function)) + return; + } + dflags = DRS->flags; + + if ((flags & FD_RAW_READ) || (flags & FD_RAW_WRITE)) + setup_DMA(); + + if (flags & FD_RAW_INTR) + do_floppy = main_command_interrupt; + + r = 0; + for (i = 0; i < raw_cmd->cmd_count; i++) + r |= output_byte(raw_cmd->cmd[i]); + + debugt("rw_command: "); + + if (r) { + cont->error(); + reset_fdc(); + return; + } + + if (!(flags & FD_RAW_INTR)) { + inr = result(); + cont->interrupt(); + } else if (flags & FD_RAW_NEED_DISK) + fd_watchdog(); +} + +static int blind_seek; + +/* + * This is the routine called after every seek (or recalibrate) interrupt + * from the floppy controller. + */ +static void seek_interrupt(void) +{ + debugt("seek interrupt:"); + if (inr != 2 || (ST0 & 0xF8) != 0x20) { + DPRINT("seek failed\n"); + DRS->track = NEED_2_RECAL; + cont->error(); + cont->redo(); + return; + } + if (DRS->track >= 0 && DRS->track != ST1 && !blind_seek) { +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT + ("clearing NEWCHANGE flag because of effective seek\n"); + DPRINT("jiffies=%lu\n", jiffies); + } +#endif + CLEARF(FD_DISK_NEWCHANGE); /* effective seek */ + DRS->select_date = jiffies; + } + DRS->track = ST1; + floppy_ready(); +} + +static void check_wp(void) +{ + if (TESTF(FD_VERIFY)) { + /* check write protection */ + output_byte(FD_GETSTATUS); + output_byte(UNIT(current_drive)); + if (result() != 1) { + FDCS->reset = 1; + return; + } + CLEARF(FD_VERIFY); + CLEARF(FD_NEED_TWADDLE); +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT("checking whether disk is write protected\n"); + DPRINT("wp=%x\n", ST3 & 0x40); + } +#endif + if (!(ST3 & 0x40)) + SETF(FD_DISK_WRITABLE); + else + CLEARF(FD_DISK_WRITABLE); + } +} + +static void seek_floppy(void) +{ + int track; + + blind_seek = 0; + +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT("calling disk change from seek\n"); + } +#endif + + if (!TESTF(FD_DISK_NEWCHANGE) && + disk_change(current_drive) && (raw_cmd->flags & FD_RAW_NEED_DISK)) { + /* the media changed flag should be cleared after the seek. + * If it isn't, this means that there is really no disk in + * the drive. + */ + SETF(FD_DISK_CHANGED); + cont->done(0); + cont->redo(); + return; + } + if (DRS->track <= NEED_1_RECAL) { + recalibrate_floppy(); + return; + } else if (TESTF(FD_DISK_NEWCHANGE) && + (raw_cmd->flags & FD_RAW_NEED_DISK) && + (DRS->track <= NO_TRACK || DRS->track == raw_cmd->track)) { + /* we seek to clear the media-changed condition. Does anybody + * know a more elegant way, which works on all drives? */ + if (raw_cmd->track) + track = raw_cmd->track - 1; + else { + if (DP->flags & FD_SILENT_DCL_CLEAR) { + set_dor(fdc, ~(0x10 << UNIT(current_drive)), 0); + blind_seek = 1; + raw_cmd->flags |= FD_RAW_NEED_SEEK; + } + track = 1; + } + } else { + check_wp(); + if (raw_cmd->track != DRS->track && + (raw_cmd->flags & FD_RAW_NEED_SEEK)) + track = raw_cmd->track; + else { + setup_rw_floppy(); + return; + } + } + + do_floppy = seek_interrupt; + output_byte(FD_SEEK); + output_byte(UNIT(current_drive)); + LAST_OUT(track); + debugt("seek command:"); +} + +static void recal_interrupt(void) +{ + debugt("recal interrupt:"); + if (inr != 2) + FDCS->reset = 1; + else if (ST0 & ST0_ECE) { + switch (DRS->track) { + case NEED_1_RECAL: + debugt("recal interrupt need 1 recal:"); + /* after a second recalibrate, we still haven't + * reached track 0. Probably no drive. Raise an + * error, as failing immediately might upset + * computers possessed by the Devil :-) */ + cont->error(); + cont->redo(); + return; + case NEED_2_RECAL: + debugt("recal interrupt need 2 recal:"); + /* If we already did a recalibrate, + * and we are not at track 0, this + * means we have moved. (The only way + * not to move at recalibration is to + * be already at track 0.) Clear the + * new change flag */ +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT + ("clearing NEWCHANGE flag because of second recalibrate\n"); + } +#endif + + CLEARF(FD_DISK_NEWCHANGE); + DRS->select_date = jiffies; + /* fall through */ + default: + debugt("recal interrupt default:"); + /* Recalibrate moves the head by at + * most 80 steps. If after one + * recalibrate we don't have reached + * track 0, this might mean that we + * started beyond track 80. Try + * again. */ + DRS->track = NEED_1_RECAL; + break; + } + } else + DRS->track = ST1; + floppy_ready(); +} + +static void print_result(char *message, int inr) +{ + int i; + + DPRINT("%s ", message); + if (inr >= 0) + for (i = 0; i < inr; i++) + printk("repl[%d]=%x ", i, reply_buffer[i]); + printk("\n"); +} + +/* interrupt handler. Note that this can be called externally on the Sparc */ +irqreturn_t floppy_interrupt(int irq, void *dev_id) +{ + void (*handler) (void) = do_floppy; + int do_print; + unsigned long f; + + lasthandler = handler; + interruptjiffies = jiffies; + + f = claim_dma_lock(); + fd_disable_dma(); + release_dma_lock(f); + + floppy_enable_hlt(); + do_floppy = NULL; + if (fdc >= N_FDC || FDCS->address == -1) { + /* we don't even know which FDC is the culprit */ + printk("DOR0=%x\n", fdc_state[0].dor); + printk("floppy interrupt on bizarre fdc %d\n", fdc); + printk("handler=%p\n", handler); + is_alive("bizarre fdc"); + return IRQ_NONE; + } + + FDCS->reset = 0; + /* We have to clear the reset flag here, because apparently on boxes + * with level triggered interrupts (PS/2, Sparc, ...), it is needed to + * emit SENSEI's to clear the interrupt line. And FDCS->reset blocks the + * emission of the SENSEI's. + * It is OK to emit floppy commands because we are in an interrupt + * handler here, and thus we have to fear no interference of other + * activity. + */ + + do_print = !handler && print_unex && !initialising; + + inr = result(); + if (do_print) + print_result("unexpected interrupt", inr); + if (inr == 0) { + int max_sensei = 4; + do { + output_byte(FD_SENSEI); + inr = result(); + if (do_print) + print_result("sensei", inr); + max_sensei--; + } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 + && max_sensei); + } + if (!handler) { + FDCS->reset = 1; + return IRQ_NONE; + } + schedule_bh(handler); + is_alive("normal interrupt end"); + + /* FIXME! Was it really for us? */ + return IRQ_HANDLED; +} + +static void recalibrate_floppy(void) +{ + debugt("recalibrate floppy:"); + do_floppy = recal_interrupt; + output_byte(FD_RECALIBRATE); + LAST_OUT(UNIT(current_drive)); +} + +/* + * Must do 4 FD_SENSEIs after reset because of ``drive polling''. + */ +static void reset_interrupt(void) +{ + debugt("reset interrupt:"); + result(); /* get the status ready for set_fdc */ + if (FDCS->reset) { + printk("reset set in interrupt, calling %p\n", cont->error); + cont->error(); /* a reset just after a reset. BAD! */ + } + cont->redo(); +} + +/* + * reset is done by pulling bit 2 of DOR low for a while (old FDCs), + * or by setting the self clearing bit 7 of STATUS (newer FDCs) + */ +static void reset_fdc(void) +{ + unsigned long flags; + + do_floppy = reset_interrupt; + FDCS->reset = 0; + reset_fdc_info(0); + + /* Pseudo-DMA may intercept 'reset finished' interrupt. */ + /* Irrelevant for systems with true DMA (i386). */ + + flags = claim_dma_lock(); + fd_disable_dma(); + release_dma_lock(flags); + + if (FDCS->version >= FDC_82072A) + fd_outb(0x80 | (FDCS->dtr & 3), FD_STATUS); + else { + fd_outb(FDCS->dor & ~0x04, FD_DOR); + udelay(FD_RESET_DELAY); + fd_outb(FDCS->dor, FD_DOR); + } +} + +static void show_floppy(void) +{ + int i; + + printk("\n"); + printk("floppy driver state\n"); + printk("-------------------\n"); + printk("now=%lu last interrupt=%lu diff=%lu last called handler=%p\n", + jiffies, interruptjiffies, jiffies - interruptjiffies, + lasthandler); + +#ifdef FLOPPY_SANITY_CHECK + printk("timeout_message=%s\n", timeout_message); + printk("last output bytes:\n"); + for (i = 0; i < OLOGSIZE; i++) + printk("%2x %2x %lu\n", + output_log[(i + output_log_pos) % OLOGSIZE].data, + output_log[(i + output_log_pos) % OLOGSIZE].status, + output_log[(i + output_log_pos) % OLOGSIZE].jiffies); + printk("last result at %lu\n", resultjiffies); + printk("last redo_fd_request at %lu\n", lastredo); + for (i = 0; i < resultsize; i++) { + printk("%2x ", reply_buffer[i]); + } + printk("\n"); +#endif + + printk("status=%x\n", fd_inb(FD_STATUS)); + printk("fdc_busy=%lu\n", fdc_busy); + if (do_floppy) + printk("do_floppy=%p\n", do_floppy); + if (floppy_work.pending) + printk("floppy_work.func=%p\n", floppy_work.func); + if (timer_pending(&fd_timer)) + printk("fd_timer.function=%p\n", fd_timer.function); + if (timer_pending(&fd_timeout)) { + printk("timer_function=%p\n", fd_timeout.function); + printk("expires=%lu\n", fd_timeout.expires - jiffies); + printk("now=%lu\n", jiffies); + } + printk("cont=%p\n", cont); + printk("current_req=%p\n", current_req); + printk("command_status=%d\n", command_status); + printk("\n"); +} + +static void floppy_shutdown(unsigned long data) +{ + unsigned long flags; + + if (!initialising) + show_floppy(); + cancel_activity(); + + floppy_enable_hlt(); + + flags = claim_dma_lock(); + fd_disable_dma(); + release_dma_lock(flags); + + /* avoid dma going to a random drive after shutdown */ + + if (!initialising) + DPRINT("floppy timeout called\n"); + FDCS->reset = 1; + if (cont) { + cont->done(0); + cont->redo(); /* this will recall reset when needed */ + } else { + printk("no cont in shutdown!\n"); + process_fd_request(); + } + is_alive("floppy shutdown"); +} + +/*typedef void (*timeout_fn)(unsigned long);*/ + +/* start motor, check media-changed condition and write protection */ +static int start_motor(void (*function) (void)) +{ + int mask, data; + + mask = 0xfc; + data = UNIT(current_drive); + if (!(raw_cmd->flags & FD_RAW_NO_MOTOR)) { + if (!(FDCS->dor & (0x10 << UNIT(current_drive)))) { + set_debugt(); + /* no read since this drive is running */ + DRS->first_read_date = 0; + /* note motor start time if motor is not yet running */ + DRS->spinup_date = jiffies; + data |= (0x10 << UNIT(current_drive)); + } + } else if (FDCS->dor & (0x10 << UNIT(current_drive))) + mask &= ~(0x10 << UNIT(current_drive)); + + /* starts motor and selects floppy */ + del_timer(motor_off_timer + current_drive); + set_dor(fdc, mask, data); + + /* wait_for_completion also schedules reset if needed. */ + return (fd_wait_for_completion(DRS->select_date + DP->select_delay, + (timeout_fn) function)); +} + +static void floppy_ready(void) +{ + CHECK_RESET; + if (start_motor(floppy_ready)) + return; + if (fdc_dtr()) + return; + +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT("calling disk change from floppy_ready\n"); + } +#endif + if (!(raw_cmd->flags & FD_RAW_NO_MOTOR) && + disk_change(current_drive) && !DP->select_delay) + twaddle(); /* this clears the dcl on certain drive/controller + * combinations */ + +#ifdef fd_chose_dma_mode + if ((raw_cmd->flags & FD_RAW_READ) || (raw_cmd->flags & FD_RAW_WRITE)) { + unsigned long flags = claim_dma_lock(); + fd_chose_dma_mode(raw_cmd->kernel_data, raw_cmd->length); + release_dma_lock(flags); + } +#endif + + if (raw_cmd->flags & (FD_RAW_NEED_SEEK | FD_RAW_NEED_DISK)) { + perpendicular_mode(); + fdc_specify(); /* must be done here because of hut, hlt ... */ + seek_floppy(); + } else { + if ((raw_cmd->flags & FD_RAW_READ) || + (raw_cmd->flags & FD_RAW_WRITE)) + fdc_specify(); + setup_rw_floppy(); + } +} + +static void floppy_start(void) +{ + reschedule_timeout(current_reqD, "floppy start", 0); + + scandrives(); +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT("setting NEWCHANGE in floppy_start\n"); + } +#endif + SETF(FD_DISK_NEWCHANGE); + floppy_ready(); +} + +/* + * ======================================================================== + * here ends the bottom half. Exported routines are: + * floppy_start, floppy_off, floppy_ready, lock_fdc, unlock_fdc, set_fdc, + * start_motor, reset_fdc, reset_fdc_info, interpret_errors. + * Initialization also uses output_byte, result, set_dor, floppy_interrupt + * and set_dor. + * ======================================================================== + */ +/* + * General purpose continuations. + * ============================== + */ + +static void do_wakeup(void) +{ + reschedule_timeout(MAXTIMEOUT, "do wakeup", 0); + cont = NULL; + command_status += 2; + wake_up(&command_done); +} + +static struct cont_t wakeup_cont = { + .interrupt = empty, + .redo = do_wakeup, + .error = empty, + .done = (done_f) empty +}; + +static struct cont_t intr_cont = { + .interrupt = empty, + .redo = process_fd_request, + .error = empty, + .done = (done_f) empty +}; + +static int wait_til_done(void (*handler) (void), int interruptible) +{ + int ret; + + schedule_bh(handler); + + if (command_status < 2 && NO_SIGNAL) { + DECLARE_WAITQUEUE(wait, current); + + add_wait_queue(&command_done, &wait); + for (;;) { + set_current_state(interruptible ? + TASK_INTERRUPTIBLE : + TASK_UNINTERRUPTIBLE); + + if (command_status >= 2 || !NO_SIGNAL) + break; + + is_alive("wait_til_done"); + + schedule(); + } + + set_current_state(TASK_RUNNING); + remove_wait_queue(&command_done, &wait); + } + + if (command_status < 2) { + cancel_activity(); + cont = &intr_cont; + reset_fdc(); + return -EINTR; + } + + if (FDCS->reset) + command_status = FD_COMMAND_ERROR; + if (command_status == FD_COMMAND_OKAY) + ret = 0; + else + ret = -EIO; + command_status = FD_COMMAND_NONE; + return ret; +} + +static void generic_done(int result) +{ + command_status = result; + cont = &wakeup_cont; +} + +static void generic_success(void) +{ + cont->done(1); +} + +static void generic_failure(void) +{ + cont->done(0); +} + +static void success_and_wakeup(void) +{ + generic_success(); + cont->redo(); +} + +/* + * formatting and rw support. + * ========================== + */ + +static int next_valid_format(void) +{ + int probed_format; + + probed_format = DRS->probed_format; + while (1) { + if (probed_format >= 8 || !DP->autodetect[probed_format]) { + DRS->probed_format = 0; + return 1; + } + if (floppy_type[DP->autodetect[probed_format]].sect) { + DRS->probed_format = probed_format; + return 0; + } + probed_format++; + } +} + +static void bad_flp_intr(void) +{ + int err_count; + + if (probing) { + DRS->probed_format++; + if (!next_valid_format()) + return; + } + err_count = ++(*errors); + INFBOUND(DRWE->badness, err_count); + if (err_count > DP->max_errors.abort) + cont->done(0); + if (err_count > DP->max_errors.reset) + FDCS->reset = 1; + else if (err_count > DP->max_errors.recal) + DRS->track = NEED_2_RECAL; +} + +static void set_floppy(int drive) +{ + int type = ITYPE(UDRS->fd_device); + if (type) + _floppy = floppy_type + type; + else + _floppy = current_type[drive]; +} + +/* + * formatting support. + * =================== + */ +static void format_interrupt(void) +{ + switch (interpret_errors()) { + case 1: + cont->error(); + case 2: + break; + case 0: + cont->done(1); + } + cont->redo(); +} + +#define CODE2SIZE (ssize = ((1 << SIZECODE) + 3) >> 2) +#define FM_MODE(x,y) ((y) & ~(((x)->rate & 0x80) >>1)) +#define CT(x) ((x) | 0xc0) +static void setup_format_params(int track) +{ + struct fparm { + unsigned char track, head, sect, size; + } *here = (struct fparm *)floppy_track_buffer; + int il, n; + int count, head_shift, track_shift; + + raw_cmd = &default_raw_cmd; + raw_cmd->track = track; + + raw_cmd->flags = FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN | + FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK; + raw_cmd->rate = _floppy->rate & 0x43; + raw_cmd->cmd_count = NR_F; + COMMAND = FM_MODE(_floppy, FD_FORMAT); + DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy, format_req.head); + F_SIZECODE = FD_SIZECODE(_floppy); + F_SECT_PER_TRACK = _floppy->sect << 2 >> F_SIZECODE; + F_GAP = _floppy->fmt_gap; + F_FILL = FD_FILL_BYTE; + + raw_cmd->kernel_data = floppy_track_buffer; + raw_cmd->length = 4 * F_SECT_PER_TRACK; + + /* allow for about 30ms for data transport per track */ + head_shift = (F_SECT_PER_TRACK + 5) / 6; + + /* a ``cylinder'' is two tracks plus a little stepping time */ + track_shift = 2 * head_shift + 3; + + /* position of logical sector 1 on this track */ + n = (track_shift * format_req.track + head_shift * format_req.head) + % F_SECT_PER_TRACK; + + /* determine interleave */ + il = 1; + if (_floppy->fmt_gap < 0x22) + il++; + + /* initialize field */ + for (count = 0; count < F_SECT_PER_TRACK; ++count) { + here[count].track = format_req.track; + here[count].head = format_req.head; + here[count].sect = 0; + here[count].size = F_SIZECODE; + } + /* place logical sectors */ + for (count = 1; count <= F_SECT_PER_TRACK; ++count) { + here[n].sect = count; + n = (n + il) % F_SECT_PER_TRACK; + if (here[n].sect) { /* sector busy, find next free sector */ + ++n; + if (n >= F_SECT_PER_TRACK) { + n -= F_SECT_PER_TRACK; + while (here[n].sect) + ++n; + } + } + } + if (_floppy->stretch & FD_ZEROBASED) { + for (count = 0; count < F_SECT_PER_TRACK; count++) + here[count].sect--; + } +} + +static void redo_format(void) +{ + buffer_track = -1; + setup_format_params(format_req.track << STRETCH(_floppy)); + floppy_start(); + debugt("queue format request"); +} + +static struct cont_t format_cont = { + .interrupt = format_interrupt, + .redo = redo_format, + .error = bad_flp_intr, + .done = generic_done +}; + +static int do_format(int drive, struct format_descr *tmp_format_req) +{ + int ret; + + LOCK_FDC(drive, 1); + set_floppy(drive); + if (!_floppy || + _floppy->track > DP->tracks || + tmp_format_req->track >= _floppy->track || + tmp_format_req->head >= _floppy->head || + (_floppy->sect << 2) % (1 << FD_SIZECODE(_floppy)) || + !_floppy->fmt_gap) { + process_fd_request(); + return -EINVAL; + } + format_req = *tmp_format_req; + format_errors = 0; + cont = &format_cont; + errors = &format_errors; + IWAIT(redo_format); + process_fd_request(); + return ret; +} + +/* + * Buffer read/write and support + * ============================= + */ + +static void floppy_end_request(struct request *req, int uptodate) +{ + unsigned int nr_sectors = current_count_sectors; + + /* current_count_sectors can be zero if transfer failed */ + if (!uptodate) + nr_sectors = req->current_nr_sectors; + if (end_that_request_first(req, uptodate, nr_sectors)) + return; + add_disk_randomness(req->rq_disk); + floppy_off((long)req->rq_disk->private_data); + blkdev_dequeue_request(req); + end_that_request_last(req, uptodate); + + /* We're done with the request */ + current_req = NULL; +} + +/* new request_done. Can handle physical sectors which are smaller than a + * logical buffer */ +static void request_done(int uptodate) +{ + struct request_queue *q = floppy_queue; + struct request *req = current_req; + unsigned long flags; + int block; + + probing = 0; + reschedule_timeout(MAXTIMEOUT, "request done %d", uptodate); + + if (!req) { + printk("floppy.c: no request in request_done\n"); + return; + } + + if (uptodate) { + /* maintain values for invalidation on geometry + * change */ + block = current_count_sectors + req->sector; + INFBOUND(DRS->maxblock, block); + if (block > _floppy->sect) + DRS->maxtrack = 1; + + /* unlock chained buffers */ + spin_lock_irqsave(q->queue_lock, flags); + floppy_end_request(req, 1); + spin_unlock_irqrestore(q->queue_lock, flags); + } else { + if (rq_data_dir(req) == WRITE) { + /* record write error information */ + DRWE->write_errors++; + if (DRWE->write_errors == 1) { + DRWE->first_error_sector = req->sector; + DRWE->first_error_generation = DRS->generation; + } + DRWE->last_error_sector = req->sector; + DRWE->last_error_generation = DRS->generation; + } + spin_lock_irqsave(q->queue_lock, flags); + floppy_end_request(req, 0); + spin_unlock_irqrestore(q->queue_lock, flags); + } +} + +/* Interrupt handler evaluating the result of the r/w operation */ +static void rw_interrupt(void) +{ + int nr_sectors, ssize, eoc, heads; + + if (R_HEAD >= 2) { + /* some Toshiba floppy controllers occasionnally seem to + * return bogus interrupts after read/write operations, which + * can be recognized by a bad head number (>= 2) */ + return; + } + + if (!DRS->first_read_date) + DRS->first_read_date = jiffies; + + nr_sectors = 0; + CODE2SIZE; + + if (ST1 & ST1_EOC) + eoc = 1; + else + eoc = 0; + + if (COMMAND & 0x80) + heads = 2; + else + heads = 1; + + nr_sectors = (((R_TRACK - TRACK) * heads + + R_HEAD - HEAD) * SECT_PER_TRACK + + R_SECTOR - SECTOR + eoc) << SIZECODE >> 2; + +#ifdef FLOPPY_SANITY_CHECK + if (nr_sectors / ssize > + (in_sector_offset + current_count_sectors + ssize - 1) / ssize) { + DPRINT("long rw: %x instead of %lx\n", + nr_sectors, current_count_sectors); + printk("rs=%d s=%d\n", R_SECTOR, SECTOR); + printk("rh=%d h=%d\n", R_HEAD, HEAD); + printk("rt=%d t=%d\n", R_TRACK, TRACK); + printk("heads=%d eoc=%d\n", heads, eoc); + printk("spt=%d st=%d ss=%d\n", SECT_PER_TRACK, + fsector_t, ssize); + printk("in_sector_offset=%d\n", in_sector_offset); + } +#endif + + nr_sectors -= in_sector_offset; + INFBOUND(nr_sectors, 0); + SUPBOUND(current_count_sectors, nr_sectors); + + switch (interpret_errors()) { + case 2: + cont->redo(); + return; + case 1: + if (!current_count_sectors) { + cont->error(); + cont->redo(); + return; + } + break; + case 0: + if (!current_count_sectors) { + cont->redo(); + return; + } + current_type[current_drive] = _floppy; + floppy_sizes[TOMINOR(current_drive)] = _floppy->size; + break; + } + + if (probing) { + if (DP->flags & FTD_MSG) + DPRINT("Auto-detected floppy type %s in fd%d\n", + _floppy->name, current_drive); + current_type[current_drive] = _floppy; + floppy_sizes[TOMINOR(current_drive)] = _floppy->size; + probing = 0; + } + + if (CT(COMMAND) != FD_READ || + raw_cmd->kernel_data == current_req->buffer) { + /* transfer directly from buffer */ + cont->done(1); + } else if (CT(COMMAND) == FD_READ) { + buffer_track = raw_cmd->track; + buffer_drive = current_drive; + INFBOUND(buffer_max, nr_sectors + fsector_t); + } + cont->redo(); +} + +/* Compute maximal contiguous buffer size. */ +static int buffer_chain_size(void) +{ + struct bio *bio; + struct bio_vec *bv; + int size, i; + char *base; + + base = bio_data(current_req->bio); + size = 0; + + rq_for_each_bio(bio, current_req) { + bio_for_each_segment(bv, bio, i) { + if (page_address(bv->bv_page) + bv->bv_offset != + base + size) + break; + + size += bv->bv_len; + } + } + + return size >> 9; +} + +/* Compute the maximal transfer size */ +static int transfer_size(int ssize, int max_sector, int max_size) +{ + SUPBOUND(max_sector, fsector_t + max_size); + + /* alignment */ + max_sector -= (max_sector % _floppy->sect) % ssize; + + /* transfer size, beginning not aligned */ + current_count_sectors = max_sector - fsector_t; + + return max_sector; +} + +/* + * Move data from/to the track buffer to/from the buffer cache. + */ +static void copy_buffer(int ssize, int max_sector, int max_sector_2) +{ + int remaining; /* number of transferred 512-byte sectors */ + struct bio_vec *bv; + struct bio *bio; + char *buffer, *dma_buffer; + int size, i; + + max_sector = transfer_size(ssize, + min(max_sector, max_sector_2), + current_req->nr_sectors); + + if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE && + buffer_max > fsector_t + current_req->nr_sectors) + current_count_sectors = min_t(int, buffer_max - fsector_t, + current_req->nr_sectors); + + remaining = current_count_sectors << 9; +#ifdef FLOPPY_SANITY_CHECK + if ((remaining >> 9) > current_req->nr_sectors && + CT(COMMAND) == FD_WRITE) { + DPRINT("in copy buffer\n"); + printk("current_count_sectors=%ld\n", current_count_sectors); + printk("remaining=%d\n", remaining >> 9); + printk("current_req->nr_sectors=%ld\n", + current_req->nr_sectors); + printk("current_req->current_nr_sectors=%u\n", + current_req->current_nr_sectors); + printk("max_sector=%d\n", max_sector); + printk("ssize=%d\n", ssize); + } +#endif + + buffer_max = max(max_sector, buffer_max); + + dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9); + + size = current_req->current_nr_sectors << 9; + + rq_for_each_bio(bio, current_req) { + bio_for_each_segment(bv, bio, i) { + if (!remaining) + break; + + size = bv->bv_len; + SUPBOUND(size, remaining); + + buffer = page_address(bv->bv_page) + bv->bv_offset; +#ifdef FLOPPY_SANITY_CHECK + if (dma_buffer + size > + floppy_track_buffer + (max_buffer_sectors << 10) || + dma_buffer < floppy_track_buffer) { + DPRINT("buffer overrun in copy buffer %d\n", + (int)((floppy_track_buffer - + dma_buffer) >> 9)); + printk("fsector_t=%d buffer_min=%d\n", + fsector_t, buffer_min); + printk("current_count_sectors=%ld\n", + current_count_sectors); + if (CT(COMMAND) == FD_READ) + printk("read\n"); + if (CT(COMMAND) == FD_WRITE) + printk("write\n"); + break; + } + if (((unsigned long)buffer) % 512) + DPRINT("%p buffer not aligned\n", buffer); +#endif + if (CT(COMMAND) == FD_READ) + memcpy(buffer, dma_buffer, size); + else + memcpy(dma_buffer, buffer, size); + + remaining -= size; + dma_buffer += size; + } + } +#ifdef FLOPPY_SANITY_CHECK + if (remaining) { + if (remaining > 0) + max_sector -= remaining >> 9; + DPRINT("weirdness: remaining %d\n", remaining >> 9); + } +#endif +} + +#if 0 +static inline int check_dma_crossing(char *start, + unsigned long length, char *message) +{ + if (CROSS_64KB(start, length)) { + printk("DMA xfer crosses 64KB boundary in %s %p-%p\n", + message, start, start + length); + return 1; + } else + return 0; +} +#endif + +/* work around a bug in pseudo DMA + * (on some FDCs) pseudo DMA does not stop when the CPU stops + * sending data. Hence we need a different way to signal the + * transfer length: We use SECT_PER_TRACK. Unfortunately, this + * does not work with MT, hence we can only transfer one head at + * a time + */ +static void virtualdmabug_workaround(void) +{ + int hard_sectors, end_sector; + + if (CT(COMMAND) == FD_WRITE) { + COMMAND &= ~0x80; /* switch off multiple track mode */ + + hard_sectors = raw_cmd->length >> (7 + SIZECODE); + end_sector = SECTOR + hard_sectors - 1; +#ifdef FLOPPY_SANITY_CHECK + if (end_sector > SECT_PER_TRACK) { + printk("too many sectors %d > %d\n", + end_sector, SECT_PER_TRACK); + return; + } +#endif + SECT_PER_TRACK = end_sector; /* make sure SECT_PER_TRACK points + * to end of transfer */ + } +} + +/* + * Formulate a read/write request. + * this routine decides where to load the data (directly to buffer, or to + * tmp floppy area), how much data to load (the size of the buffer, the whole + * track, or a single sector) + * All floppy_track_buffer handling goes in here. If we ever add track buffer + * allocation on the fly, it should be done here. No other part should need + * modification. + */ + +static int make_raw_rw_request(void) +{ + int aligned_sector_t; + int max_sector, max_size, tracksize, ssize; + + if (max_buffer_sectors == 0) { + printk("VFS: Block I/O scheduled on unopened device\n"); + return 0; + } + + set_fdc((long)current_req->rq_disk->private_data); + + raw_cmd = &default_raw_cmd; + raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_DISK | FD_RAW_NEED_DISK | + FD_RAW_NEED_SEEK; + raw_cmd->cmd_count = NR_RW; + if (rq_data_dir(current_req) == READ) { + raw_cmd->flags |= FD_RAW_READ; + COMMAND = FM_MODE(_floppy, FD_READ); + } else if (rq_data_dir(current_req) == WRITE) { + raw_cmd->flags |= FD_RAW_WRITE; + COMMAND = FM_MODE(_floppy, FD_WRITE); + } else { + DPRINT("make_raw_rw_request: unknown command\n"); + return 0; + } + + max_sector = _floppy->sect * _floppy->head; + + TRACK = (int)current_req->sector / max_sector; + fsector_t = (int)current_req->sector % max_sector; + if (_floppy->track && TRACK >= _floppy->track) { + if (current_req->current_nr_sectors & 1) { + current_count_sectors = 1; + return 1; + } else + return 0; + } + HEAD = fsector_t / _floppy->sect; + + if (((_floppy->stretch & (FD_SWAPSIDES | FD_ZEROBASED)) || + TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect) + max_sector = _floppy->sect; + + /* 2M disks have phantom sectors on the first track */ + if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)) { + max_sector = 2 * _floppy->sect / 3; + if (fsector_t >= max_sector) { + current_count_sectors = + min_t(int, _floppy->sect - fsector_t, + current_req->nr_sectors); + return 1; + } + SIZECODE = 2; + } else + SIZECODE = FD_SIZECODE(_floppy); + raw_cmd->rate = _floppy->rate & 0x43; + if ((_floppy->rate & FD_2M) && (TRACK || HEAD) && raw_cmd->rate == 2) + raw_cmd->rate = 1; + + if (SIZECODE) + SIZECODE2 = 0xff; + else + SIZECODE2 = 0x80; + raw_cmd->track = TRACK << STRETCH(_floppy); + DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy, HEAD); + GAP = _floppy->gap; + CODE2SIZE; + SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; + SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + + ((_floppy->stretch & FD_ZEROBASED) ? 0 : 1); + + /* tracksize describes the size which can be filled up with sectors + * of size ssize. + */ + tracksize = _floppy->sect - _floppy->sect % ssize; + if (tracksize < _floppy->sect) { + SECT_PER_TRACK++; + if (tracksize <= fsector_t % _floppy->sect) + SECTOR--; + + /* if we are beyond tracksize, fill up using smaller sectors */ + while (tracksize <= fsector_t % _floppy->sect) { + while (tracksize + ssize > _floppy->sect) { + SIZECODE--; + ssize >>= 1; + } + SECTOR++; + SECT_PER_TRACK++; + tracksize += ssize; + } + max_sector = HEAD * _floppy->sect + tracksize; + } else if (!TRACK && !HEAD && !(_floppy->rate & FD_2M) && probing) { + max_sector = _floppy->sect; + } else if (!HEAD && CT(COMMAND) == FD_WRITE) { + /* for virtual DMA bug workaround */ + max_sector = _floppy->sect; + } + + in_sector_offset = (fsector_t % _floppy->sect) % ssize; + aligned_sector_t = fsector_t - in_sector_offset; + max_size = current_req->nr_sectors; + if ((raw_cmd->track == buffer_track) && + (current_drive == buffer_drive) && + (fsector_t >= buffer_min) && (fsector_t < buffer_max)) { + /* data already in track buffer */ + if (CT(COMMAND) == FD_READ) { + copy_buffer(1, max_sector, buffer_max); + return 1; + } + } else if (in_sector_offset || current_req->nr_sectors < ssize) { + if (CT(COMMAND) == FD_WRITE) { + if (fsector_t + current_req->nr_sectors > ssize && + fsector_t + current_req->nr_sectors < ssize + ssize) + max_size = ssize + ssize; + else + max_size = ssize; + } + raw_cmd->flags &= ~FD_RAW_WRITE; + raw_cmd->flags |= FD_RAW_READ; + COMMAND = FM_MODE(_floppy, FD_READ); + } else if ((unsigned long)current_req->buffer < MAX_DMA_ADDRESS) { + unsigned long dma_limit; + int direct, indirect; + + indirect = + transfer_size(ssize, max_sector, + max_buffer_sectors * 2) - fsector_t; + + /* + * Do NOT use minimum() here---MAX_DMA_ADDRESS is 64 bits wide + * on a 64 bit machine! + */ + max_size = buffer_chain_size(); + dma_limit = + (MAX_DMA_ADDRESS - + ((unsigned long)current_req->buffer)) >> 9; + if ((unsigned long)max_size > dma_limit) { + max_size = dma_limit; + } + /* 64 kb boundaries */ + if (CROSS_64KB(current_req->buffer, max_size << 9)) + max_size = (K_64 - + ((unsigned long)current_req->buffer) % + K_64) >> 9; + direct = transfer_size(ssize, max_sector, max_size) - fsector_t; + /* + * We try to read tracks, but if we get too many errors, we + * go back to reading just one sector at a time. + * + * This means we should be able to read a sector even if there + * are other bad sectors on this track. + */ + if (!direct || + (indirect * 2 > direct * 3 && + *errors < DP->max_errors.read_track && + /*!TESTF(FD_NEED_TWADDLE) && */ + ((!probing + || (DP->read_track & (1 << DRS->probed_format)))))) { + max_size = current_req->nr_sectors; + } else { + raw_cmd->kernel_data = current_req->buffer; + raw_cmd->length = current_count_sectors << 9; + if (raw_cmd->length == 0) { + DPRINT + ("zero dma transfer attempted from make_raw_request\n"); + DPRINT("indirect=%d direct=%d fsector_t=%d", + indirect, direct, fsector_t); + return 0; + } +/* check_dma_crossing(raw_cmd->kernel_data, + raw_cmd->length, + "end of make_raw_request [1]");*/ + + virtualdmabug_workaround(); + return 2; + } + } + + if (CT(COMMAND) == FD_READ) + max_size = max_sector; /* unbounded */ + + /* claim buffer track if needed */ + if (buffer_track != raw_cmd->track || /* bad track */ + buffer_drive != current_drive || /* bad drive */ + fsector_t > buffer_max || + fsector_t < buffer_min || + ((CT(COMMAND) == FD_READ || + (!in_sector_offset && current_req->nr_sectors >= ssize)) && + max_sector > 2 * max_buffer_sectors + buffer_min && + max_size + fsector_t > 2 * max_buffer_sectors + buffer_min) + /* not enough space */ + ) { + buffer_track = -1; + buffer_drive = current_drive; + buffer_max = buffer_min = aligned_sector_t; + } + raw_cmd->kernel_data = floppy_track_buffer + + ((aligned_sector_t - buffer_min) << 9); + + if (CT(COMMAND) == FD_WRITE) { + /* copy write buffer to track buffer. + * if we get here, we know that the write + * is either aligned or the data already in the buffer + * (buffer will be overwritten) */ +#ifdef FLOPPY_SANITY_CHECK + if (in_sector_offset && buffer_track == -1) + DPRINT("internal error offset !=0 on write\n"); +#endif + buffer_track = raw_cmd->track; + buffer_drive = current_drive; + copy_buffer(ssize, max_sector, + 2 * max_buffer_sectors + buffer_min); + } else + transfer_size(ssize, max_sector, + 2 * max_buffer_sectors + buffer_min - + aligned_sector_t); + + /* round up current_count_sectors to get dma xfer size */ + raw_cmd->length = in_sector_offset + current_count_sectors; + raw_cmd->length = ((raw_cmd->length - 1) | (ssize - 1)) + 1; + raw_cmd->length <<= 9; +#ifdef FLOPPY_SANITY_CHECK + /*check_dma_crossing(raw_cmd->kernel_data, raw_cmd->length, + "end of make_raw_request"); */ + if ((raw_cmd->length < current_count_sectors << 9) || + (raw_cmd->kernel_data != current_req->buffer && + CT(COMMAND) == FD_WRITE && + (aligned_sector_t + (raw_cmd->length >> 9) > buffer_max || + aligned_sector_t < buffer_min)) || + raw_cmd->length % (128 << SIZECODE) || + raw_cmd->length <= 0 || current_count_sectors <= 0) { + DPRINT("fractionary current count b=%lx s=%lx\n", + raw_cmd->length, current_count_sectors); + if (raw_cmd->kernel_data != current_req->buffer) + printk("addr=%d, length=%ld\n", + (int)((raw_cmd->kernel_data - + floppy_track_buffer) >> 9), + current_count_sectors); + printk("st=%d ast=%d mse=%d msi=%d\n", + fsector_t, aligned_sector_t, max_sector, max_size); + printk("ssize=%x SIZECODE=%d\n", ssize, SIZECODE); + printk("command=%x SECTOR=%d HEAD=%d, TRACK=%d\n", + COMMAND, SECTOR, HEAD, TRACK); + printk("buffer drive=%d\n", buffer_drive); + printk("buffer track=%d\n", buffer_track); + printk("buffer_min=%d\n", buffer_min); + printk("buffer_max=%d\n", buffer_max); + return 0; + } + + if (raw_cmd->kernel_data != current_req->buffer) { + if (raw_cmd->kernel_data < floppy_track_buffer || + current_count_sectors < 0 || + raw_cmd->length < 0 || + raw_cmd->kernel_data + raw_cmd->length > + floppy_track_buffer + (max_buffer_sectors << 10)) { + DPRINT("buffer overrun in schedule dma\n"); + printk("fsector_t=%d buffer_min=%d current_count=%ld\n", + fsector_t, buffer_min, raw_cmd->length >> 9); + printk("current_count_sectors=%ld\n", + current_count_sectors); + if (CT(COMMAND) == FD_READ) + printk("read\n"); + if (CT(COMMAND) == FD_WRITE) + printk("write\n"); + return 0; + } + } else if (raw_cmd->length > current_req->nr_sectors << 9 || + current_count_sectors > current_req->nr_sectors) { + DPRINT("buffer overrun in direct transfer\n"); + return 0; + } else if (raw_cmd->length < current_count_sectors << 9) { + DPRINT("more sectors than bytes\n"); + printk("bytes=%ld\n", raw_cmd->length >> 9); + printk("sectors=%ld\n", current_count_sectors); + } + if (raw_cmd->length == 0) { + DPRINT("zero dma transfer attempted from make_raw_request\n"); + return 0; + } +#endif + + virtualdmabug_workaround(); + return 2; +} + +static void redo_fd_request(void) +{ +#define REPEAT {request_done(0); continue; } + int drive; + int tmp; + + lastredo = jiffies; + if (current_drive < N_DRIVE) + floppy_off(current_drive); + + for (;;) { + if (!current_req) { + struct request *req; + + spin_lock_irq(floppy_queue->queue_lock); + req = elv_next_request(floppy_queue); + spin_unlock_irq(floppy_queue->queue_lock); + if (!req) { + do_floppy = NULL; + unlock_fdc(); + return; + } + current_req = req; + } + drive = (long)current_req->rq_disk->private_data; + set_fdc(drive); + reschedule_timeout(current_reqD, "redo fd request", 0); + + set_floppy(drive); + raw_cmd = &default_raw_cmd; + raw_cmd->flags = 0; + if (start_motor(redo_fd_request)) + return; + disk_change(current_drive); + if (test_bit(current_drive, &fake_change) || + TESTF(FD_DISK_CHANGED)) { + DPRINT("disk absent or changed during operation\n"); + REPEAT; + } + if (!_floppy) { /* Autodetection */ + if (!probing) { + DRS->probed_format = 0; + if (next_valid_format()) { + DPRINT("no autodetectable formats\n"); + _floppy = NULL; + REPEAT; + } + } + probing = 1; + _floppy = + floppy_type + DP->autodetect[DRS->probed_format]; + } else + probing = 0; + errors = &(current_req->errors); + tmp = make_raw_rw_request(); + if (tmp < 2) { + request_done(tmp); + continue; + } + + if (TESTF(FD_NEED_TWADDLE)) + twaddle(); + schedule_bh(floppy_start); + debugt("queue fd request"); + return; + } +#undef REPEAT +} + +static struct cont_t rw_cont = { + .interrupt = rw_interrupt, + .redo = redo_fd_request, + .error = bad_flp_intr, + .done = request_done +}; + +static void process_fd_request(void) +{ + cont = &rw_cont; + schedule_bh(redo_fd_request); +} + +static void do_fd_request(request_queue_t * q) +{ + if (max_buffer_sectors == 0) { + printk("VFS: do_fd_request called on non-open device\n"); + return; + } + + if (usage_count == 0) { + printk("warning: usage count=0, current_req=%p exiting\n", + current_req); + printk("sect=%ld type=%x flags=%x\n", (long)current_req->sector, + current_req->cmd_type, current_req->cmd_flags); + return; + } + if (test_bit(0, &fdc_busy)) { + /* fdc busy, this new request will be treated when the + current one is done */ + is_alive("do fd request, old request running"); + return; + } + lock_fdc(MAXTIMEOUT, 0); + process_fd_request(); + is_alive("do fd request"); +} + +static struct cont_t poll_cont = { + .interrupt = success_and_wakeup, + .redo = floppy_ready, + .error = generic_failure, + .done = generic_done +}; + +static int poll_drive(int interruptible, int flag) +{ + int ret; + /* no auto-sense, just clear dcl */ + raw_cmd = &default_raw_cmd; + raw_cmd->flags = flag; + raw_cmd->track = 0; + raw_cmd->cmd_count = 0; + cont = &poll_cont; +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT("setting NEWCHANGE in poll_drive\n"); + } +#endif + SETF(FD_DISK_NEWCHANGE); + WAIT(floppy_ready); + return ret; +} + +/* + * User triggered reset + * ==================== + */ + +static void reset_intr(void) +{ + printk("weird, reset interrupt called\n"); +} + +static struct cont_t reset_cont = { + .interrupt = reset_intr, + .redo = success_and_wakeup, + .error = generic_failure, + .done = generic_done +}; + +static int user_reset_fdc(int drive, int arg, int interruptible) +{ + int ret; + + ret = 0; + LOCK_FDC(drive, interruptible); + if (arg == FD_RESET_ALWAYS) + FDCS->reset = 1; + if (FDCS->reset) { + cont = &reset_cont; + WAIT(reset_fdc); + } + process_fd_request(); + return ret; +} + +/* + * Misc Ioctl's and support + * ======================== + */ +static inline int fd_copyout(void __user *param, const void *address, + unsigned long size) +{ + return copy_to_user(param, address, size) ? -EFAULT : 0; +} + +static inline int fd_copyin(void __user *param, void *address, unsigned long size) +{ + return copy_from_user(address, param, size) ? -EFAULT : 0; +} + +#define _COPYOUT(x) (copy_to_user((void __user *)param, &(x), sizeof(x)) ? -EFAULT : 0) +#define _COPYIN(x) (copy_from_user(&(x), (void __user *)param, sizeof(x)) ? -EFAULT : 0) + +#define COPYOUT(x) ECALL(_COPYOUT(x)) +#define COPYIN(x) ECALL(_COPYIN(x)) + +static inline const char *drive_name(int type, int drive) +{ + struct floppy_struct *floppy; + + if (type) + floppy = floppy_type + type; + else { + if (UDP->native_format) + floppy = floppy_type + UDP->native_format; + else + return "(null)"; + } + if (floppy->name) + return floppy->name; + else + return "(null)"; +} + +/* raw commands */ +static void raw_cmd_done(int flag) +{ + int i; + + if (!flag) { + raw_cmd->flags |= FD_RAW_FAILURE; + raw_cmd->flags |= FD_RAW_HARDFAILURE; + } else { + raw_cmd->reply_count = inr; + if (raw_cmd->reply_count > MAX_REPLIES) + raw_cmd->reply_count = 0; + for (i = 0; i < raw_cmd->reply_count; i++) + raw_cmd->reply[i] = reply_buffer[i]; + + if (raw_cmd->flags & (FD_RAW_READ | FD_RAW_WRITE)) { + unsigned long flags; + flags = claim_dma_lock(); + raw_cmd->length = fd_get_dma_residue(); + release_dma_lock(flags); + } + + if ((raw_cmd->flags & FD_RAW_SOFTFAILURE) && + (!raw_cmd->reply_count || (raw_cmd->reply[0] & 0xc0))) + raw_cmd->flags |= FD_RAW_FAILURE; + + if (disk_change(current_drive)) + raw_cmd->flags |= FD_RAW_DISK_CHANGE; + else + raw_cmd->flags &= ~FD_RAW_DISK_CHANGE; + if (raw_cmd->flags & FD_RAW_NO_MOTOR_AFTER) + motor_off_callback(current_drive); + + if (raw_cmd->next && + (!(raw_cmd->flags & FD_RAW_FAILURE) || + !(raw_cmd->flags & FD_RAW_STOP_IF_FAILURE)) && + ((raw_cmd->flags & FD_RAW_FAILURE) || + !(raw_cmd->flags & FD_RAW_STOP_IF_SUCCESS))) { + raw_cmd = raw_cmd->next; + return; + } + } + generic_done(flag); +} + +static struct cont_t raw_cmd_cont = { + .interrupt = success_and_wakeup, + .redo = floppy_start, + .error = generic_failure, + .done = raw_cmd_done +}; + +static inline int raw_cmd_copyout(int cmd, char __user *param, + struct floppy_raw_cmd *ptr) +{ + int ret; + + while (ptr) { + COPYOUT(*ptr); + param += sizeof(struct floppy_raw_cmd); + if ((ptr->flags & FD_RAW_READ) && ptr->buffer_length) { + if (ptr->length >= 0 + && ptr->length <= ptr->buffer_length) + ECALL(fd_copyout + (ptr->data, ptr->kernel_data, + ptr->buffer_length - ptr->length)); + } + ptr = ptr->next; + } + return 0; +} + +static void raw_cmd_free(struct floppy_raw_cmd **ptr) +{ + struct floppy_raw_cmd *next, *this; + + this = *ptr; + *ptr = NULL; + while (this) { + if (this->buffer_length) { + fd_dma_mem_free((unsigned long)this->kernel_data, + this->buffer_length); + this->buffer_length = 0; + } + next = this->next; + kfree(this); + this = next; + } +} + +static inline int raw_cmd_copyin(int cmd, char __user *param, + struct floppy_raw_cmd **rcmd) +{ + struct floppy_raw_cmd *ptr; + int ret; + int i; + + *rcmd = NULL; + while (1) { + ptr = (struct floppy_raw_cmd *) + kmalloc(sizeof(struct floppy_raw_cmd), GFP_USER); + if (!ptr) + return -ENOMEM; + *rcmd = ptr; + COPYIN(*ptr); + ptr->next = NULL; + ptr->buffer_length = 0; + param += sizeof(struct floppy_raw_cmd); + if (ptr->cmd_count > 33) + /* the command may now also take up the space + * initially intended for the reply & the + * reply count. Needed for long 82078 commands + * such as RESTORE, which takes ... 17 command + * bytes. Murphy's law #137: When you reserve + * 16 bytes for a structure, you'll one day + * discover that you really need 17... + */ + return -EINVAL; + + for (i = 0; i < 16; i++) + ptr->reply[i] = 0; + ptr->resultcode = 0; + ptr->kernel_data = NULL; + + if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { + if (ptr->length <= 0) + return -EINVAL; + ptr->kernel_data = + (char *)fd_dma_mem_alloc(ptr->length); + fallback_on_nodma_alloc(&ptr->kernel_data, ptr->length); + if (!ptr->kernel_data) + return -ENOMEM; + ptr->buffer_length = ptr->length; + } + if (ptr->flags & FD_RAW_WRITE) + ECALL(fd_copyin(ptr->data, ptr->kernel_data, + ptr->length)); + rcmd = &(ptr->next); + if (!(ptr->flags & FD_RAW_MORE)) + return 0; + ptr->rate &= 0x43; + } +} + +static int raw_cmd_ioctl(int cmd, void __user *param) +{ + int drive, ret, ret2; + struct floppy_raw_cmd *my_raw_cmd; + + if (FDCS->rawcmd <= 1) + FDCS->rawcmd = 1; + for (drive = 0; drive < N_DRIVE; drive++) { + if (FDC(drive) != fdc) + continue; + if (drive == current_drive) { + if (UDRS->fd_ref > 1) { + FDCS->rawcmd = 2; + break; + } + } else if (UDRS->fd_ref) { + FDCS->rawcmd = 2; + break; + } + } + + if (FDCS->reset) + return -EIO; + + ret = raw_cmd_copyin(cmd, param, &my_raw_cmd); + if (ret) { + raw_cmd_free(&my_raw_cmd); + return ret; + } + + raw_cmd = my_raw_cmd; + cont = &raw_cmd_cont; + ret = wait_til_done(floppy_start, 1); +#ifdef DCL_DEBUG + if (DP->flags & FD_DEBUG) { + DPRINT("calling disk change from raw_cmd ioctl\n"); + } +#endif + + if (ret != -EINTR && FDCS->reset) + ret = -EIO; + + DRS->track = NO_TRACK; + + ret2 = raw_cmd_copyout(cmd, param, my_raw_cmd); + if (!ret) + ret = ret2; + raw_cmd_free(&my_raw_cmd); + return ret; +} + +static int invalidate_drive(struct block_device *bdev) +{ + /* invalidate the buffer track to force a reread */ + set_bit((long)bdev->bd_disk->private_data, &fake_change); + process_fd_request(); + check_disk_change(bdev); + return 0; +} + +static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, + int drive, int type, struct block_device *bdev) +{ + int cnt; + + /* sanity checking for parameters. */ + if (g->sect <= 0 || + g->head <= 0 || + g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) || + /* check if reserved bits are set */ + (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_ZEROBASED)) != 0) + return -EINVAL; + if (type) { + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + mutex_lock(&open_lock); + LOCK_FDC(drive, 1); + floppy_type[type] = *g; + floppy_type[type].name = "user format"; + for (cnt = type << 2; cnt < (type << 2) + 4; cnt++) + floppy_sizes[cnt] = floppy_sizes[cnt + 0x80] = + floppy_type[type].size + 1; + process_fd_request(); + for (cnt = 0; cnt < N_DRIVE; cnt++) { + struct block_device *bdev = opened_bdev[cnt]; + if (!bdev || ITYPE(drive_state[cnt].fd_device) != type) + continue; + __invalidate_device(bdev); + } + mutex_unlock(&open_lock); + } else { + int oldStretch; + LOCK_FDC(drive, 1); + if (cmd != FDDEFPRM) + /* notice a disk change immediately, else + * we lose our settings immediately*/ + CALL(poll_drive(1, FD_RAW_NEED_DISK)); + oldStretch = g->stretch; + user_params[drive] = *g; + if (buffer_drive == drive) + SUPBOUND(buffer_max, user_params[drive].sect); + current_type[drive] = &user_params[drive]; + floppy_sizes[drive] = user_params[drive].size; + if (cmd == FDDEFPRM) + DRS->keep_data = -1; + else + DRS->keep_data = 1; + /* invalidation. Invalidate only when needed, i.e. + * when there are already sectors in the buffer cache + * whose number will change. This is useful, because + * mtools often changes the geometry of the disk after + * looking at the boot block */ + if (DRS->maxblock > user_params[drive].sect || + DRS->maxtrack || + ((user_params[drive].sect ^ oldStretch) & + (FD_SWAPSIDES | FD_ZEROBASED))) + invalidate_drive(bdev); + else + process_fd_request(); + } + return 0; +} + +/* handle obsolete ioctl's */ +static int ioctl_table[] = { + FDCLRPRM, + FDSETPRM, + FDDEFPRM, + FDGETPRM, + FDMSGON, + FDMSGOFF, + FDFMTBEG, + FDFMTTRK, + FDFMTEND, + FDSETEMSGTRESH, + FDFLUSH, + FDSETMAXERRS, + FDGETMAXERRS, + FDGETDRVTYP, + FDSETDRVPRM, + FDGETDRVPRM, + FDGETDRVSTAT, + FDPOLLDRVSTAT, + FDRESET, + FDGETFDCSTAT, + FDWERRORCLR, + FDWERRORGET, + FDRAWCMD, + FDEJECT, + FDTWADDLE +}; + +static inline int normalize_ioctl(int *cmd, int *size) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(ioctl_table); i++) { + if ((*cmd & 0xffff) == (ioctl_table[i] & 0xffff)) { + *size = _IOC_SIZE(*cmd); + *cmd = ioctl_table[i]; + if (*size > _IOC_SIZE(*cmd)) { + printk("ioctl not yet supported\n"); + return -EFAULT; + } + return 0; + } + } + return -EINVAL; +} + +static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) +{ + if (type) + *g = &floppy_type[type]; + else { + LOCK_FDC(drive, 0); + CALL(poll_drive(0, 0)); + process_fd_request(); + *g = current_type[drive]; + } + if (!*g) + return -ENODEV; + return 0; +} + +static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo) +{ + int drive = (long)bdev->bd_disk->private_data; + int type = ITYPE(drive_state[drive].fd_device); + struct floppy_struct *g; + int ret; + + ret = get_floppy_geometry(drive, type, &g); + if (ret) + return ret; + + geo->heads = g->head; + geo->sectors = g->sect; + geo->cylinders = g->track; + return 0; +} + +static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long param) +{ +#define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data) +#define OUT(c,x) case c: outparam = (const char *) (x); break +#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 + + int drive = (long)inode->i_bdev->bd_disk->private_data; + int i, type = ITYPE(UDRS->fd_device); + int ret; + int size; + union inparam { + struct floppy_struct g; /* geometry */ + struct format_descr f; + struct floppy_max_errors max_errors; + struct floppy_drive_params dp; + } inparam; /* parameters coming from user space */ + const char *outparam; /* parameters passed back to user space */ + + /* convert compatibility eject ioctls into floppy eject ioctl. + * We do this in order to provide a means to eject floppy disks before + * installing the new fdutils package */ + if (cmd == CDROMEJECT || /* CD-ROM eject */ + cmd == 0x6470 /* SunOS floppy eject */ ) { + DPRINT("obsolete eject ioctl\n"); + DPRINT("please use floppycontrol --eject\n"); + cmd = FDEJECT; + } + + /* convert the old style command into a new style command */ + if ((cmd & 0xff00) == 0x0200) { + ECALL(normalize_ioctl(&cmd, &size)); + } else + return -EINVAL; + + /* permission checks */ + if (((cmd & 0x40) && !FD_IOCTL_ALLOWED) || + ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))) + return -EPERM; + + /* copyin */ + CLEARSTRUCT(&inparam); + if (_IOC_DIR(cmd) & _IOC_WRITE) + ECALL(fd_copyin((void __user *)param, &inparam, size)) + + switch (cmd) { + case FDEJECT: + if (UDRS->fd_ref != 1) + /* somebody else has this drive open */ + return -EBUSY; + LOCK_FDC(drive, 1); + + /* do the actual eject. Fails on + * non-Sparc architectures */ + ret = fd_eject(UNIT(drive)); + + USETF(FD_DISK_CHANGED); + USETF(FD_VERIFY); + process_fd_request(); + return ret; + case FDCLRPRM: + LOCK_FDC(drive, 1); + current_type[drive] = NULL; + floppy_sizes[drive] = MAX_DISK_SIZE << 1; + UDRS->keep_data = 0; + return invalidate_drive(inode->i_bdev); + case FDSETPRM: + case FDDEFPRM: + return set_geometry(cmd, &inparam.g, + drive, type, inode->i_bdev); + case FDGETPRM: + ECALL(get_floppy_geometry(drive, type, + (struct floppy_struct **) + &outparam)); + break; + + case FDMSGON: + UDP->flags |= FTD_MSG; + return 0; + case FDMSGOFF: + UDP->flags &= ~FTD_MSG; + return 0; + + case FDFMTBEG: + LOCK_FDC(drive, 1); + CALL(poll_drive(1, FD_RAW_NEED_DISK)); + ret = UDRS->flags; + process_fd_request(); + /* if (ret & FD_VERIFY) + return -ENODEV; + if (!(ret & FD_DISK_WRITABLE)) + return -EROFS;*/ + return 0; + case FDFMTTRK: + if (UDRS->fd_ref != 1) + return -EBUSY; + return do_format(drive, &inparam.f); + case FDFMTEND: + case FDFLUSH: + LOCK_FDC(drive, 1); + return invalidate_drive(inode->i_bdev); + + case FDSETEMSGTRESH: + UDP->max_errors.reporting = + (unsigned short)(param & 0x0f); + return 0; + OUT(FDGETMAXERRS, &UDP->max_errors); + IN(FDSETMAXERRS, &UDP->max_errors, max_errors); + + case FDGETDRVTYP: + outparam = drive_name(type, drive); + SUPBOUND(size, strlen(outparam) + 1); + break; + + IN(FDSETDRVPRM, UDP, dp); + OUT(FDGETDRVPRM, UDP); + + case FDPOLLDRVSTAT: + LOCK_FDC(drive, 1); + CALL(poll_drive(1, FD_RAW_NEED_DISK)); + process_fd_request(); + /* fall through */ + OUT(FDGETDRVSTAT, UDRS); + + case FDRESET: + return user_reset_fdc(drive, (int)param, 1); + + OUT(FDGETFDCSTAT, UFDCS); + + case FDWERRORCLR: + CLEARSTRUCT(UDRWE); + return 0; + OUT(FDWERRORGET, UDRWE); + + case FDRAWCMD: + if (type) + return -EINVAL; + LOCK_FDC(drive, 1); + set_floppy(drive); + CALL(i = raw_cmd_ioctl(cmd, (void __user *)param)); + process_fd_request(); + return i; + + case FDTWADDLE: + LOCK_FDC(drive, 1); + twaddle(); + process_fd_request(); + return 0; + + default: + return -EINVAL; + } + + if (_IOC_DIR(cmd) & _IOC_READ) + return fd_copyout((void __user *)param, outparam, size); + else + return 0; +#undef OUT +#undef IN +} + +static void __init config_types(void) +{ + int first = 1; + int drive; + + /* read drive info out of physical CMOS */ + drive = 0; + if (!UDP->cmos) + UDP->cmos = FLOPPY0_TYPE; + drive = 1; + if (!UDP->cmos && FLOPPY1_TYPE) + UDP->cmos = FLOPPY1_TYPE; + + /* XXX */ + /* additional physical CMOS drive detection should go here */ + + for (drive = 0; drive < N_DRIVE; drive++) { + unsigned int type = UDP->cmos; + struct floppy_drive_params *params; + const char *name = NULL; + static char temparea[32]; + + if (type < ARRAY_SIZE(default_drive_params)) { + params = &default_drive_params[type].params; + if (type) { + name = default_drive_params[type].name; + allowed_drive_mask |= 1 << drive; + } else + allowed_drive_mask &= ~(1 << drive); + } else { + params = &default_drive_params[0].params; + sprintf(temparea, "unknown type %d (usb?)", type); + name = temparea; + } + if (name) { + const char *prepend = ","; + if (first) { + prepend = KERN_INFO "Floppy drive(s):"; + first = 0; + } + printk("%s fd%d is %s", prepend, drive, name); + } + *UDP = *params; + } + if (!first) + printk("\n"); +} + +static int floppy_release(struct inode *inode, struct file *filp) +{ + int drive = (long)inode->i_bdev->bd_disk->private_data; + + mutex_lock(&open_lock); + if (UDRS->fd_ref < 0) + UDRS->fd_ref = 0; + else if (!UDRS->fd_ref--) { + DPRINT("floppy_release with fd_ref == 0"); + UDRS->fd_ref = 0; + } + if (!UDRS->fd_ref) + opened_bdev[drive] = NULL; + mutex_unlock(&open_lock); + + return 0; +} + +/* + * floppy_open check for aliasing (/dev/fd0 can be the same as + * /dev/PS0 etc), and disallows simultaneous access to the same + * drive with different device numbers. + */ +static int floppy_open(struct inode *inode, struct file *filp) +{ + int drive = (long)inode->i_bdev->bd_disk->private_data; + int old_dev; + int try; + int res = -EBUSY; + char *tmp; + + filp->private_data = (void *)0; + mutex_lock(&open_lock); + old_dev = UDRS->fd_device; + if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) + goto out2; + + if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) { + USETF(FD_DISK_CHANGED); + USETF(FD_VERIFY); + } + + if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) + goto out2; + + if (filp->f_flags & O_EXCL) + UDRS->fd_ref = -1; + else + UDRS->fd_ref++; + + opened_bdev[drive] = inode->i_bdev; + + res = -ENXIO; + + if (!floppy_track_buffer) { + /* if opening an ED drive, reserve a big buffer, + * else reserve a small one */ + if ((UDP->cmos == 6) || (UDP->cmos == 5)) + try = 64; /* Only 48 actually useful */ + else + try = 32; /* Only 24 actually useful */ + + tmp = (char *)fd_dma_mem_alloc(1024 * try); + if (!tmp && !floppy_track_buffer) { + try >>= 1; /* buffer only one side */ + INFBOUND(try, 16); + tmp = (char *)fd_dma_mem_alloc(1024 * try); + } + if (!tmp && !floppy_track_buffer) { + fallback_on_nodma_alloc(&tmp, 2048 * try); + } + if (!tmp && !floppy_track_buffer) { + DPRINT("Unable to allocate DMA memory\n"); + goto out; + } + if (floppy_track_buffer) { + if (tmp) + fd_dma_mem_free((unsigned long)tmp, try * 1024); + } else { + buffer_min = buffer_max = -1; + floppy_track_buffer = tmp; + max_buffer_sectors = try; + } + } + + UDRS->fd_device = iminor(inode); + set_capacity(disks[drive], floppy_sizes[iminor(inode)]); + if (old_dev != -1 && old_dev != iminor(inode)) { + if (buffer_drive == drive) + buffer_track = -1; + } + + /* Allow ioctls if we have write-permissions even if read-only open. + * Needed so that programs such as fdrawcmd still can work on write + * protected disks */ + if ((filp->f_mode & FMODE_WRITE) || !file_permission(filp, MAY_WRITE)) + filp->private_data = (void *)8; + + if (UFDCS->rawcmd == 1) + UFDCS->rawcmd = 2; + + if (!(filp->f_flags & O_NDELAY)) { + if (filp->f_mode & 3) { + UDRS->last_checked = 0; + check_disk_change(inode->i_bdev); + if (UTESTF(FD_DISK_CHANGED)) + goto out; + } + res = -EROFS; + if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) + goto out; + } + mutex_unlock(&open_lock); + return 0; +out: + if (UDRS->fd_ref < 0) + UDRS->fd_ref = 0; + else + UDRS->fd_ref--; + if (!UDRS->fd_ref) + opened_bdev[drive] = NULL; +out2: + mutex_unlock(&open_lock); + return res; +} + +/* + * Check if the disk has been changed or if a change has been faked. + */ +static int check_floppy_change(struct gendisk *disk) +{ + int drive = (long)disk->private_data; + + if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY)) + return 1; + + if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { + lock_fdc(drive, 0); + poll_drive(0, 0); + process_fd_request(); + } + + if (UTESTF(FD_DISK_CHANGED) || + UTESTF(FD_VERIFY) || + test_bit(drive, &fake_change) || + (!ITYPE(UDRS->fd_device) && !current_type[drive])) + return 1; + return 0; +} + +/* + * This implements "read block 0" for floppy_revalidate(). + * Needed for format autodetection, checking whether there is + * a disk in the drive, and whether that disk is writable. + */ + +static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done, + int err) +{ + if (bio->bi_size) + return 1; + + complete((struct completion *)bio->bi_private); + return 0; +} + +static int __floppy_read_block_0(struct block_device *bdev) +{ + struct bio bio; + struct bio_vec bio_vec; + struct completion complete; + struct page *page; + size_t size; + + page = alloc_page(GFP_NOIO); + if (!page) { + process_fd_request(); + return -ENOMEM; + } + + size = bdev->bd_block_size; + if (!size) + size = 1024; + + bio_init(&bio); + bio.bi_io_vec = &bio_vec; + bio_vec.bv_page = page; + bio_vec.bv_len = size; + bio_vec.bv_offset = 0; + bio.bi_vcnt = 1; + bio.bi_idx = 0; + bio.bi_size = size; + bio.bi_bdev = bdev; + bio.bi_sector = 0; + init_completion(&complete); + bio.bi_private = &complete; + bio.bi_end_io = floppy_rb0_complete; + + submit_bio(READ, &bio); + generic_unplug_device(bdev_get_queue(bdev)); + process_fd_request(); + wait_for_completion(&complete); + + __free_page(page); + + return 0; +} + +/* revalidate the floppy disk, i.e. trigger format autodetection by reading + * the bootblock (block 0). "Autodetection" is also needed to check whether + * there is a disk in the drive at all... Thus we also do it for fixed + * geometry formats */ +static int floppy_revalidate(struct gendisk *disk) +{ + int drive = (long)disk->private_data; +#define NO_GEOM (!current_type[drive] && !ITYPE(UDRS->fd_device)) + int cf; + int res = 0; + + if (UTESTF(FD_DISK_CHANGED) || + UTESTF(FD_VERIFY) || test_bit(drive, &fake_change) || NO_GEOM) { + if (usage_count == 0) { + printk("VFS: revalidate called on non-open device.\n"); + return -EFAULT; + } + lock_fdc(drive, 0); + cf = UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY); + if (!(cf || test_bit(drive, &fake_change) || NO_GEOM)) { + process_fd_request(); /*already done by another thread */ + return 0; + } + UDRS->maxblock = 0; + UDRS->maxtrack = 0; + if (buffer_drive == drive) + buffer_track = -1; + clear_bit(drive, &fake_change); + UCLEARF(FD_DISK_CHANGED); + if (cf) + UDRS->generation++; + if (NO_GEOM) { + /* auto-sensing */ + res = __floppy_read_block_0(opened_bdev[drive]); + } else { + if (cf) + poll_drive(0, FD_RAW_NEED_DISK); + process_fd_request(); + } + } + set_capacity(disk, floppy_sizes[UDRS->fd_device]); + return res; +} + +static struct block_device_operations floppy_fops = { + .owner = THIS_MODULE, + .open = floppy_open, + .release = floppy_release, + .ioctl = fd_ioctl, + .getgeo = fd_getgeo, + .media_changed = check_floppy_change, + .revalidate_disk = floppy_revalidate, +}; + +/* + * Floppy Driver initialization + * ============================= + */ + +/* Determine the floppy disk controller type */ +/* This routine was written by David C. Niemi */ +static char __init get_fdc_version(void) +{ + int r; + + output_byte(FD_DUMPREGS); /* 82072 and better know DUMPREGS */ + if (FDCS->reset) + return FDC_NONE; + if ((r = result()) <= 0x00) + return FDC_NONE; /* No FDC present ??? */ + if ((r == 1) && (reply_buffer[0] == 0x80)) { + printk(KERN_INFO "FDC %d is an 8272A\n", fdc); + return FDC_8272A; /* 8272a/765 don't know DUMPREGS */ + } + if (r != 10) { + printk + ("FDC %d init: DUMPREGS: unexpected return of %d bytes.\n", + fdc, r); + return FDC_UNKNOWN; + } + + if (!fdc_configure()) { + printk(KERN_INFO "FDC %d is an 82072\n", fdc); + return FDC_82072; /* 82072 doesn't know CONFIGURE */ + } + + output_byte(FD_PERPENDICULAR); + if (need_more_output() == MORE_OUTPUT) { + output_byte(0); + } else { + printk(KERN_INFO "FDC %d is an 82072A\n", fdc); + return FDC_82072A; /* 82072A as found on Sparcs. */ + } + + output_byte(FD_UNLOCK); + r = result(); + if ((r == 1) && (reply_buffer[0] == 0x80)) { + printk(KERN_INFO "FDC %d is a pre-1991 82077\n", fdc); + return FDC_82077_ORIG; /* Pre-1991 82077, doesn't know + * LOCK/UNLOCK */ + } + if ((r != 1) || (reply_buffer[0] != 0x00)) { + printk("FDC %d init: UNLOCK: unexpected return of %d bytes.\n", + fdc, r); + return FDC_UNKNOWN; + } + output_byte(FD_PARTID); + r = result(); + if (r != 1) { + printk("FDC %d init: PARTID: unexpected return of %d bytes.\n", + fdc, r); + return FDC_UNKNOWN; + } + if (reply_buffer[0] == 0x80) { + printk(KERN_INFO "FDC %d is a post-1991 82077\n", fdc); + return FDC_82077; /* Revised 82077AA passes all the tests */ + } + switch (reply_buffer[0] >> 5) { + case 0x0: + /* Either a 82078-1 or a 82078SL running at 5Volt */ + printk(KERN_INFO "FDC %d is an 82078.\n", fdc); + return FDC_82078; + case 0x1: + printk(KERN_INFO "FDC %d is a 44pin 82078\n", fdc); + return FDC_82078; + case 0x2: + printk(KERN_INFO "FDC %d is a S82078B\n", fdc); + return FDC_S82078B; + case 0x3: + printk(KERN_INFO "FDC %d is a National Semiconductor PC87306\n", + fdc); + return FDC_87306; + default: + printk(KERN_INFO + "FDC %d init: 82078 variant with unknown PARTID=%d.\n", + fdc, reply_buffer[0] >> 5); + return FDC_82078_UNKN; + } +} /* get_fdc_version */ + +/* lilo configuration */ + +static void __init floppy_set_flags(int *ints, int param, int param2) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(default_drive_params); i++) { + if (param) + default_drive_params[i].params.flags |= param2; + else + default_drive_params[i].params.flags &= ~param2; + } + DPRINT("%s flag 0x%x\n", param2 ? "Setting" : "Clearing", param); +} + +static void __init daring(int *ints, int param, int param2) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(default_drive_params); i++) { + if (param) { + default_drive_params[i].params.select_delay = 0; + default_drive_params[i].params.flags |= + FD_SILENT_DCL_CLEAR; + } else { + default_drive_params[i].params.select_delay = + 2 * HZ / 100; + default_drive_params[i].params.flags &= + ~FD_SILENT_DCL_CLEAR; + } + } + DPRINT("Assuming %s floppy hardware\n", param ? "standard" : "broken"); +} + +static void __init set_cmos(int *ints, int dummy, int dummy2) +{ + int current_drive = 0; + + if (ints[0] != 2) { + DPRINT("wrong number of parameters for CMOS\n"); + return; + } + current_drive = ints[1]; + if (current_drive < 0 || current_drive >= 8) { + DPRINT("bad drive for set_cmos\n"); + return; + } +#if N_FDC > 1 + if (current_drive >= 4 && !FDC2) + FDC2 = 0x370; +#endif + DP->cmos = ints[2]; + DPRINT("setting CMOS code to %d\n", ints[2]); +} + +static struct param_table { + const char *name; + void (*fn) (int *ints, int param, int param2); + int *var; + int def_param; + int param2; +} config_params[] __initdata = { + {"allowed_drive_mask", NULL, &allowed_drive_mask, 0xff, 0}, /* obsolete */ + {"all_drives", NULL, &allowed_drive_mask, 0xff, 0}, /* obsolete */ + {"asus_pci", NULL, &allowed_drive_mask, 0x33, 0}, + {"irq", NULL, &FLOPPY_IRQ, 6, 0}, + {"dma", NULL, &FLOPPY_DMA, 2, 0}, + {"daring", daring, NULL, 1, 0}, +#if N_FDC > 1 + {"two_fdc", NULL, &FDC2, 0x370, 0}, + {"one_fdc", NULL, &FDC2, 0, 0}, +#endif + {"thinkpad", floppy_set_flags, NULL, 1, FD_INVERTED_DCL}, + {"broken_dcl", floppy_set_flags, NULL, 1, FD_BROKEN_DCL}, + {"messages", floppy_set_flags, NULL, 1, FTD_MSG}, + {"silent_dcl_clear", floppy_set_flags, NULL, 1, FD_SILENT_DCL_CLEAR}, + {"debug", floppy_set_flags, NULL, 1, FD_DEBUG}, + {"nodma", NULL, &can_use_virtual_dma, 1, 0}, + {"omnibook", NULL, &can_use_virtual_dma, 1, 0}, + {"yesdma", NULL, &can_use_virtual_dma, 0, 0}, + {"fifo_depth", NULL, &fifo_depth, 0xa, 0}, + {"nofifo", NULL, &no_fifo, 0x20, 0}, + {"usefifo", NULL, &no_fifo, 0, 0}, + {"cmos", set_cmos, NULL, 0, 0}, + {"slow", NULL, &slow_floppy, 1, 0}, + {"unexpected_interrupts", NULL, &print_unex, 1, 0}, + {"no_unexpected_interrupts", NULL, &print_unex, 0, 0}, + {"L40SX", NULL, &print_unex, 0, 0} + + EXTRA_FLOPPY_PARAMS +}; + +static int __init floppy_setup(char *str) +{ + int i; + int param; + int ints[11]; + + str = get_options(str, ARRAY_SIZE(ints), ints); + if (str) { + for (i = 0; i < ARRAY_SIZE(config_params); i++) { + if (strcmp(str, config_params[i].name) == 0) { + if (ints[0]) + param = ints[1]; + else + param = config_params[i].def_param; + if (config_params[i].fn) + config_params[i]. + fn(ints, param, + config_params[i].param2); + if (config_params[i].var) { + DPRINT("%s=%d\n", str, param); + *config_params[i].var = param; + } + return 1; + } + } + } + if (str) { + DPRINT("unknown floppy option [%s]\n", str); + + DPRINT("allowed options are:"); + for (i = 0; i < ARRAY_SIZE(config_params); i++) + printk(" %s", config_params[i].name); + printk("\n"); + } else + DPRINT("botched floppy option\n"); + DPRINT("Read Documentation/floppy.txt\n"); + return 0; +} + +static int have_no_fdc = -ENODEV; + +static ssize_t floppy_cmos_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct platform_device *p; + int drive; + + p = container_of(dev, struct platform_device,dev); + drive = p->id; + return sprintf(buf, "%X\n", UDP->cmos); +} +DEVICE_ATTR(cmos,S_IRUGO,floppy_cmos_show,NULL); + +static void floppy_device_release(struct device *dev) +{ + complete(&device_release); +} + +static struct platform_device floppy_device[N_DRIVE]; + +static struct kobject *floppy_find(dev_t dev, int *part, void *data) +{ + int drive = (*part & 3) | ((*part & 0x80) >> 5); + if (drive >= N_DRIVE || + !(allowed_drive_mask & (1 << drive)) || + fdc_state[FDC(drive)].version == FDC_NONE) + return NULL; + if (((*part >> 2) & 0x1f) >= ARRAY_SIZE(floppy_type)) + return NULL; + *part = 0; + return get_disk(disks[drive]); +} + +static int __init floppy_init(void) +{ + int i, unit, drive; + int err, dr; + +#if defined(CONFIG_PPC_MERGE) + if (check_legacy_ioport(FDC1)) + return -ENODEV; +#endif + + raw_cmd = NULL; + + for (dr = 0; dr < N_DRIVE; dr++) { + disks[dr] = alloc_disk(1); + if (!disks[dr]) { + err = -ENOMEM; + goto out_put_disk; + } + + disks[dr]->major = FLOPPY_MAJOR; + disks[dr]->first_minor = TOMINOR(dr); + disks[dr]->fops = &floppy_fops; + sprintf(disks[dr]->disk_name, "fd%d", dr); + + init_timer(&motor_off_timer[dr]); + motor_off_timer[dr].data = dr; + motor_off_timer[dr].function = motor_off_callback; + } + + err = register_blkdev(FLOPPY_MAJOR, "fd"); + if (err) + goto out_put_disk; + + floppy_queue = blk_init_queue(do_fd_request, &floppy_lock); + if (!floppy_queue) { + err = -ENOMEM; + goto out_unreg_blkdev; + } + blk_queue_max_sectors(floppy_queue, 64); + + blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, + floppy_find, NULL, NULL); + + for (i = 0; i < 256; i++) + if (ITYPE(i)) + floppy_sizes[i] = floppy_type[ITYPE(i)].size; + else + floppy_sizes[i] = MAX_DISK_SIZE << 1; + + reschedule_timeout(MAXTIMEOUT, "floppy init", MAXTIMEOUT); + config_types(); + + for (i = 0; i < N_FDC; i++) { + fdc = i; + CLEARSTRUCT(FDCS); + FDCS->dtr = -1; + FDCS->dor = 0x4; +#if defined(__sparc__) || defined(__mc68000__) + /*sparcs/sun3x don't have a DOR reset which we can fall back on to */ +#ifdef __mc68000__ + if (MACH_IS_SUN3X) +#endif + FDCS->version = FDC_82072A; +#endif + } + + use_virtual_dma = can_use_virtual_dma & 1; + fdc_state[0].address = FDC1; + if (fdc_state[0].address == -1) { + del_timer(&fd_timeout); + err = -ENODEV; + goto out_unreg_region; + } +#if N_FDC > 1 + fdc_state[1].address = FDC2; +#endif + + fdc = 0; /* reset fdc in case of unexpected interrupt */ + err = floppy_grab_irq_and_dma(); + if (err) { + del_timer(&fd_timeout); + err = -EBUSY; + goto out_unreg_region; + } + + /* initialise drive state */ + for (drive = 0; drive < N_DRIVE; drive++) { + CLEARSTRUCT(UDRS); + CLEARSTRUCT(UDRWE); + USETF(FD_DISK_NEWCHANGE); + USETF(FD_DISK_CHANGED); + USETF(FD_VERIFY); + UDRS->fd_device = -1; + floppy_track_buffer = NULL; + max_buffer_sectors = 0; + } + /* + * Small 10 msec delay to let through any interrupt that + * initialization might have triggered, to not + * confuse detection: + */ + msleep(10); + + for (i = 0; i < N_FDC; i++) { + fdc = i; + FDCS->driver_version = FD_DRIVER_VERSION; + for (unit = 0; unit < 4; unit++) + FDCS->track[unit] = 0; + if (FDCS->address == -1) + continue; + FDCS->rawcmd = 2; + if (user_reset_fdc(-1, FD_RESET_ALWAYS, 0)) { + /* free ioports reserved by floppy_grab_irq_and_dma() */ + release_region(FDCS->address + 2, 4); + release_region(FDCS->address + 7, 1); + FDCS->address = -1; + FDCS->version = FDC_NONE; + continue; + } + /* Try to determine the floppy controller type */ + FDCS->version = get_fdc_version(); + if (FDCS->version == FDC_NONE) { + /* free ioports reserved by floppy_grab_irq_and_dma() */ + release_region(FDCS->address + 2, 4); + release_region(FDCS->address + 7, 1); + FDCS->address = -1; + continue; + } + if (can_use_virtual_dma == 2 && FDCS->version < FDC_82072A) + can_use_virtual_dma = 0; + + have_no_fdc = 0; + /* Not all FDCs seem to be able to handle the version command + * properly, so force a reset for the standard FDC clones, + * to avoid interrupt garbage. + */ + user_reset_fdc(-1, FD_RESET_ALWAYS, 0); + } + fdc = 0; + del_timer(&fd_timeout); + current_drive = 0; + initialising = 0; + if (have_no_fdc) { + DPRINT("no floppy controllers found\n"); + err = have_no_fdc; + goto out_flush_work; + } + + for (drive = 0; drive < N_DRIVE; drive++) { + if (!(allowed_drive_mask & (1 << drive))) + continue; + if (fdc_state[FDC(drive)].version == FDC_NONE) + continue; + + floppy_device[drive].name = floppy_device_name; + floppy_device[drive].id = drive; + floppy_device[drive].dev.release = floppy_device_release; + + err = platform_device_register(&floppy_device[drive]); + if (err) + goto out_flush_work; + + device_create_file(&floppy_device[drive].dev,&dev_attr_cmos); + /* to be cleaned up... */ + disks[drive]->private_data = (void *)(long)drive; + disks[drive]->queue = floppy_queue; + disks[drive]->flags |= GENHD_FL_REMOVABLE; + disks[drive]->driverfs_dev = &floppy_device[drive].dev; + add_disk(disks[drive]); + } + + return 0; + +out_flush_work: + flush_scheduled_work(); + if (usage_count) + floppy_release_irq_and_dma(); +out_unreg_region: + blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); + blk_cleanup_queue(floppy_queue); +out_unreg_blkdev: + unregister_blkdev(FLOPPY_MAJOR, "fd"); +out_put_disk: + while (dr--) { + del_timer(&motor_off_timer[dr]); + put_disk(disks[dr]); + } + return err; +} + +static DEFINE_SPINLOCK(floppy_usage_lock); + +static int floppy_grab_irq_and_dma(void) +{ + unsigned long flags; + + spin_lock_irqsave(&floppy_usage_lock, flags); + if (usage_count++) { + spin_unlock_irqrestore(&floppy_usage_lock, flags); + return 0; + } + spin_unlock_irqrestore(&floppy_usage_lock, flags); + + /* + * We might have scheduled a free_irq(), wait it to + * drain first: + */ + flush_scheduled_work(); + + if (fd_request_irq()) { + DPRINT("Unable to grab IRQ%d for the floppy driver\n", + FLOPPY_IRQ); + spin_lock_irqsave(&floppy_usage_lock, flags); + usage_count--; + spin_unlock_irqrestore(&floppy_usage_lock, flags); + return -1; + } + if (fd_request_dma()) { + DPRINT("Unable to grab DMA%d for the floppy driver\n", + FLOPPY_DMA); + fd_free_irq(); + spin_lock_irqsave(&floppy_usage_lock, flags); + usage_count--; + spin_unlock_irqrestore(&floppy_usage_lock, flags); + return -1; + } + + for (fdc = 0; fdc < N_FDC; fdc++) { + if (FDCS->address != -1) { + if (!request_region(FDCS->address + 2, 4, "floppy")) { + DPRINT("Floppy io-port 0x%04lx in use\n", + FDCS->address + 2); + goto cleanup1; + } + if (!request_region(FDCS->address + 7, 1, "floppy DIR")) { + DPRINT("Floppy io-port 0x%04lx in use\n", + FDCS->address + 7); + goto cleanup2; + } + /* address + 6 is reserved, and may be taken by IDE. + * Unfortunately, Adaptec doesn't know this :-(, */ + } + } + for (fdc = 0; fdc < N_FDC; fdc++) { + if (FDCS->address != -1) { + reset_fdc_info(1); + fd_outb(FDCS->dor, FD_DOR); + } + } + fdc = 0; + set_dor(0, ~0, 8); /* avoid immediate interrupt */ + + for (fdc = 0; fdc < N_FDC; fdc++) + if (FDCS->address != -1) + fd_outb(FDCS->dor, FD_DOR); + /* + * The driver will try and free resources and relies on us + * to know if they were allocated or not. + */ + fdc = 0; + irqdma_allocated = 1; + return 0; +cleanup2: + release_region(FDCS->address + 2, 4); +cleanup1: + fd_free_irq(); + fd_free_dma(); + while (--fdc >= 0) { + release_region(FDCS->address + 2, 4); + release_region(FDCS->address + 7, 1); + } + spin_lock_irqsave(&floppy_usage_lock, flags); + usage_count--; + spin_unlock_irqrestore(&floppy_usage_lock, flags); + return -1; +} + +static void floppy_release_irq_and_dma(void) +{ + int old_fdc; +#ifdef FLOPPY_SANITY_CHECK +#ifndef __sparc__ + int drive; +#endif +#endif + long tmpsize; + unsigned long tmpaddr; + unsigned long flags; + + spin_lock_irqsave(&floppy_usage_lock, flags); + if (--usage_count) { + spin_unlock_irqrestore(&floppy_usage_lock, flags); + return; + } + spin_unlock_irqrestore(&floppy_usage_lock, flags); + if (irqdma_allocated) { + fd_disable_dma(); + fd_free_dma(); + fd_free_irq(); + irqdma_allocated = 0; + } + set_dor(0, ~0, 8); +#if N_FDC > 1 + set_dor(1, ~8, 0); +#endif + floppy_enable_hlt(); + + if (floppy_track_buffer && max_buffer_sectors) { + tmpsize = max_buffer_sectors * 1024; + tmpaddr = (unsigned long)floppy_track_buffer; + floppy_track_buffer = NULL; + max_buffer_sectors = 0; + buffer_min = buffer_max = -1; + fd_dma_mem_free(tmpaddr, tmpsize); + } +#ifdef FLOPPY_SANITY_CHECK +#ifndef __sparc__ + for (drive = 0; drive < N_FDC * 4; drive++) + if (timer_pending(motor_off_timer + drive)) + printk("motor off timer %d still active\n", drive); +#endif + + if (timer_pending(&fd_timeout)) + printk("floppy timer still active:%s\n", timeout_message); + if (timer_pending(&fd_timer)) + printk("auxiliary floppy timer still active\n"); + if (floppy_work.pending) + printk("work still pending\n"); +#endif + old_fdc = fdc; + for (fdc = 0; fdc < N_FDC; fdc++) + if (FDCS->address != -1) { + release_region(FDCS->address + 2, 4); + release_region(FDCS->address + 7, 1); + } + fdc = old_fdc; +} + +#ifdef MODULE + +static char *floppy; + +static void __init parse_floppy_cfg_string(char *cfg) +{ + char *ptr; + + while (*cfg) { + for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++) ; + if (*cfg) { + *cfg = '\0'; + cfg++; + } + if (*ptr) + floppy_setup(ptr); + } +} + +int __init init_module(void) +{ + if (floppy) + parse_floppy_cfg_string(floppy); + return floppy_init(); +} + +void cleanup_module(void) +{ + int drive; + + init_completion(&device_release); + blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); + unregister_blkdev(FLOPPY_MAJOR, "fd"); + + for (drive = 0; drive < N_DRIVE; drive++) { + del_timer_sync(&motor_off_timer[drive]); + + if ((allowed_drive_mask & (1 << drive)) && + fdc_state[FDC(drive)].version != FDC_NONE) { + del_gendisk(disks[drive]); + device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); + platform_device_unregister(&floppy_device[drive]); + } + put_disk(disks[drive]); + } + + del_timer_sync(&fd_timeout); + del_timer_sync(&fd_timer); + blk_cleanup_queue(floppy_queue); + + if (usage_count) + floppy_release_irq_and_dma(); + + /* eject disk, if any */ + fd_eject(0); + + wait_for_completion(&device_release); +} + +module_param(floppy, charp, 0); +module_param(FLOPPY_IRQ, int, 0); +module_param(FLOPPY_DMA, int, 0); +MODULE_AUTHOR("Alain L. Knaff"); +MODULE_SUPPORTED_DEVICE("fd"); +MODULE_LICENSE("GPL"); + +#else + +__setup("floppy=", floppy_setup); +module_init(floppy_init) +module_exit(cleanup_module) +#endif + +MODULE_ALIAS_BLOCKDEV_MAJOR(FLOPPY_MAJOR); diff --git a/ddverify/case_studies/block/nbd/nbd.c b/ddverify/case_studies/block/nbd/nbd.c new file mode 100644 index 000000000..842b47b17 --- /dev/null +++ b/ddverify/case_studies/block/nbd/nbd.c @@ -0,0 +1,703 @@ +/* + * Network block device - make block devices work over TCP + * + * Note that you can not swap over this thing, yet. Seems to work but + * deadlocks sometimes - you can not swap over TCP in general. + * + * Copyright 1997-2000 Pavel Machek + * Parts copyright 2001 Steven Whitehouse + * + * This file is released under GPLv2 or later. + * + * (part of code stolen from loop.c) + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "nbd.h" + +#define LO_MAGIC 0x68797548 + +#ifdef NDEBUG +#define dprintk(flags, fmt...) +#else /* NDEBUG */ +#define dprintk(flags, fmt...) do { \ + if (debugflags & (flags)) printk(KERN_DEBUG fmt); \ +} while (0) +#define DBG_IOCTL 0x0004 +#define DBG_INIT 0x0010 +#define DBG_EXIT 0x0020 +#define DBG_BLKDEV 0x0100 +#define DBG_RX 0x0200 +#define DBG_TX 0x0400 +static unsigned int debugflags; +#endif /* NDEBUG */ + +static unsigned int nbds_max = 16; +static struct nbd_device nbd_dev[MAX_NBD]; + +/* + * Use just one lock (or at most 1 per NIC). Two arguments for this: + * 1. Each NIC is essentially a synchronization point for all servers + * accessed through that NIC so there's no need to have more locks + * than NICs anyway. + * 2. More locks lead to more "Dirty cache line bouncing" which will slow + * down each lock to the point where they're actually slower than just + * a single lock. + * Thanks go to Jens Axboe and Al Viro for their LKML emails explaining this! + */ +static DEFINE_SPINLOCK(nbd_lock); + +#ifndef NDEBUG +static const char *ioctl_cmd_to_ascii(int cmd) +{ + switch (cmd) { + case NBD_SET_SOCK: return "set-sock"; + case NBD_SET_BLKSIZE: return "set-blksize"; + case NBD_SET_SIZE: return "set-size"; + case NBD_DO_IT: return "do-it"; + case NBD_CLEAR_SOCK: return "clear-sock"; + case NBD_CLEAR_QUE: return "clear-que"; + case NBD_PRINT_DEBUG: return "print-debug"; + case NBD_SET_SIZE_BLOCKS: return "set-size-blocks"; + case NBD_DISCONNECT: return "disconnect"; + case BLKROSET: return "set-read-only"; + case BLKFLSBUF: return "flush-buffer-cache"; + } + return "unknown"; +} + +static const char *nbdcmd_to_ascii(int cmd) +{ + switch (cmd) { + case NBD_CMD_READ: return "read"; + case NBD_CMD_WRITE: return "write"; + case NBD_CMD_DISC: return "disconnect"; + } + return "invalid"; +} +#endif /* NDEBUG */ + +static void nbd_end_request(struct request *req) +{ + int uptodate = (req->errors == 0) ? 1 : 0; + request_queue_t *q = req->q; + unsigned long flags; + + dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name, + req, uptodate? "done": "failed"); + + spin_lock_irqsave(q->queue_lock, flags); + if (!end_that_request_first(req, uptodate, req->nr_sectors)) { + end_that_request_last(req, uptodate); + } + spin_unlock_irqrestore(q->queue_lock, flags); +} + +/* + * Send or receive packet. + */ +static int sock_xmit(struct socket *sock, int send, void *buf, int size, + int msg_flags) +{ + int result; + struct msghdr msg; + struct kvec iov; + unsigned long flags; + sigset_t oldset; + + /* Allow interception of SIGKILL only + * Don't allow other signals to interrupt the transmission */ + spin_lock_irqsave(¤t->sighand->siglock, flags); + oldset = current->blocked; + sigfillset(¤t->blocked); + sigdelsetmask(¤t->blocked, sigmask(SIGKILL)); + recalc_sigpending(); + spin_unlock_irqrestore(¤t->sighand->siglock, flags); + + do { + sock->sk->sk_allocation = GFP_NOIO; + iov.iov_base = buf; + iov.iov_len = size; + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_flags = msg_flags | MSG_NOSIGNAL; + + if (send) + result = kernel_sendmsg(sock, &msg, &iov, 1, size); + else + result = kernel_recvmsg(sock, &msg, &iov, 1, size, 0); + + if (signal_pending(current)) { + siginfo_t info; + spin_lock_irqsave(¤t->sighand->siglock, flags); + printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n", + current->pid, current->comm, + dequeue_signal(current, ¤t->blocked, &info)); + spin_unlock_irqrestore(¤t->sighand->siglock, flags); + result = -EINTR; + break; + } + + if (result <= 0) { + if (result == 0) + result = -EPIPE; /* short read */ + break; + } + size -= result; + buf += result; + } while (size > 0); + + spin_lock_irqsave(¤t->sighand->siglock, flags); + current->blocked = oldset; + recalc_sigpending(); + spin_unlock_irqrestore(¤t->sighand->siglock, flags); + + return result; +} + +static inline int sock_send_bvec(struct socket *sock, struct bio_vec *bvec, + int flags) +{ + int result; + void *kaddr = kmap(bvec->bv_page); + result = sock_xmit(sock, 1, kaddr + bvec->bv_offset, bvec->bv_len, + flags); + kunmap(bvec->bv_page); + return result; +} + +static int nbd_send_req(struct nbd_device *lo, struct request *req) +{ + int result, i, flags; + struct nbd_request request; + unsigned long size = req->nr_sectors << 9; + struct socket *sock = lo->sock; + + request.magic = htonl(NBD_REQUEST_MAGIC); + request.type = htonl(nbd_cmd(req)); + request.from = cpu_to_be64((u64) req->sector << 9); + request.len = htonl(size); + memcpy(request.handle, &req, sizeof(req)); + + dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%luB)\n", + lo->disk->disk_name, req, + nbdcmd_to_ascii(nbd_cmd(req)), + (unsigned long long)req->sector << 9, + req->nr_sectors << 9); + result = sock_xmit(sock, 1, &request, sizeof(request), + (nbd_cmd(req) == NBD_CMD_WRITE)? MSG_MORE: 0); + if (result <= 0) { + printk(KERN_ERR "%s: Send control failed (result %d)\n", + lo->disk->disk_name, result); + goto error_out; + } + + if (nbd_cmd(req) == NBD_CMD_WRITE) { + struct bio *bio; + /* + * we are really probing at internals to determine + * whether to set MSG_MORE or not... + */ + rq_for_each_bio(bio, req) { + struct bio_vec *bvec; + bio_for_each_segment(bvec, bio, i) { + flags = 0; + if ((i < (bio->bi_vcnt - 1)) || bio->bi_next) + flags = MSG_MORE; + dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", + lo->disk->disk_name, req, + bvec->bv_len); + result = sock_send_bvec(sock, bvec, flags); + if (result <= 0) { + printk(KERN_ERR "%s: Send data failed (result %d)\n", + lo->disk->disk_name, + result); + goto error_out; + } + } + } + } + return 0; + +error_out: + return 1; +} + +static struct request *nbd_find_request(struct nbd_device *lo, char *handle) +{ + struct request *req; + struct list_head *tmp; + struct request *xreq; + int err; + + memcpy(&xreq, handle, sizeof(xreq)); + + err = wait_event_interruptible(lo->active_wq, lo->active_req != xreq); + if (unlikely(err)) + goto out; + + spin_lock(&lo->queue_lock); + list_for_each(tmp, &lo->queue_head) { + req = list_entry(tmp, struct request, queuelist); + if (req != xreq) + continue; + list_del_init(&req->queuelist); + spin_unlock(&lo->queue_lock); + return req; + } + spin_unlock(&lo->queue_lock); + + err = -ENOENT; + +out: + return ERR_PTR(err); +} + +static inline int sock_recv_bvec(struct socket *sock, struct bio_vec *bvec) +{ + int result; + void *kaddr = kmap(bvec->bv_page); + result = sock_xmit(sock, 0, kaddr + bvec->bv_offset, bvec->bv_len, + MSG_WAITALL); + kunmap(bvec->bv_page); + return result; +} + +/* NULL returned = something went wrong, inform userspace */ +static struct request *nbd_read_stat(struct nbd_device *lo) +{ + int result; + struct nbd_reply reply; + struct request *req; + struct socket *sock = lo->sock; + + reply.magic = 0; + result = sock_xmit(sock, 0, &reply, sizeof(reply), MSG_WAITALL); + if (result <= 0) { + printk(KERN_ERR "%s: Receive control failed (result %d)\n", + lo->disk->disk_name, result); + goto harderror; + } + + if (ntohl(reply.magic) != NBD_REPLY_MAGIC) { + printk(KERN_ERR "%s: Wrong magic (0x%lx)\n", + lo->disk->disk_name, + (unsigned long)ntohl(reply.magic)); + result = -EPROTO; + goto harderror; + } + + req = nbd_find_request(lo, reply.handle); + if (unlikely(IS_ERR(req))) { + result = PTR_ERR(req); + if (result != -ENOENT) + goto harderror; + + printk(KERN_ERR "%s: Unexpected reply (%p)\n", + lo->disk->disk_name, reply.handle); + result = -EBADR; + goto harderror; + } + + if (ntohl(reply.error)) { + printk(KERN_ERR "%s: Other side returned error (%d)\n", + lo->disk->disk_name, ntohl(reply.error)); + req->errors++; + return req; + } + + dprintk(DBG_RX, "%s: request %p: got reply\n", + lo->disk->disk_name, req); + if (nbd_cmd(req) == NBD_CMD_READ) { + int i; + struct bio *bio; + rq_for_each_bio(bio, req) { + struct bio_vec *bvec; + bio_for_each_segment(bvec, bio, i) { + result = sock_recv_bvec(sock, bvec); + if (result <= 0) { + printk(KERN_ERR "%s: Receive data failed (result %d)\n", + lo->disk->disk_name, + result); + req->errors++; + return req; + } + dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", + lo->disk->disk_name, req, bvec->bv_len); + } + } + } + return req; +harderror: + lo->harderror = result; + return NULL; +} + +static void nbd_do_it(struct nbd_device *lo) +{ + struct request *req; + + BUG_ON(lo->magic != LO_MAGIC); + + while ((req = nbd_read_stat(lo)) != NULL) + nbd_end_request(req); + return; +} + +static void nbd_clear_que(struct nbd_device *lo) +{ + struct request *req; + + BUG_ON(lo->magic != LO_MAGIC); + + /* + * Because we have set lo->sock to NULL under the tx_lock, all + * modifications to the list must have completed by now. For + * the same reason, the active_req must be NULL. + * + * As a consequence, we don't need to take the spin lock while + * purging the list here. + */ + BUG_ON(lo->sock); + BUG_ON(lo->active_req); + + while (!list_empty(&lo->queue_head)) { + req = list_entry(lo->queue_head.next, struct request, + queuelist); + list_del_init(&req->queuelist); + req->errors++; + nbd_end_request(req); + } +} + +/* + * We always wait for result of write, for now. It would be nice to make it optional + * in future + * if ((req->cmd == WRITE) && (lo->flags & NBD_WRITE_NOCHK)) + * { printk( "Warning: Ignoring result!\n"); nbd_end_request( req ); } + */ + +void do_nbd_request(request_queue_t * q) +{ + struct request *req; + + while ((req = elv_next_request(q)) != NULL) { + struct nbd_device *lo; + + blkdev_dequeue_request(req); + dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n", + req->rq_disk->disk_name, req, req->cmd_type); + + if (!blk_fs_request(req)) + goto error_out; + + lo = req->rq_disk->private_data; + + BUG_ON(lo->magic != LO_MAGIC); + + nbd_cmd(req) = NBD_CMD_READ; + if (rq_data_dir(req) == WRITE) { + nbd_cmd(req) = NBD_CMD_WRITE; + if (lo->flags & NBD_READ_ONLY) { + printk(KERN_ERR "%s: Write on read-only\n", + lo->disk->disk_name); + goto error_out; + } + } + + req->errors = 0; + spin_unlock_irq(q->queue_lock); + + mutex_lock(&lo->tx_lock); + if (unlikely(!lo->sock)) { + mutex_unlock(&lo->tx_lock); + printk(KERN_ERR "%s: Attempted send on closed socket\n", + lo->disk->disk_name); + req->errors++; + nbd_end_request(req); + spin_lock_irq(q->queue_lock); + continue; + } + + lo->active_req = req; + + if (nbd_send_req(lo, req) != 0) { + printk(KERN_ERR "%s: Request send failed\n", + lo->disk->disk_name); + req->errors++; + nbd_end_request(req); + } else { + spin_lock(&lo->queue_lock); + list_add(&req->queuelist, &lo->queue_head); + spin_unlock(&lo->queue_lock); + } + + lo->active_req = NULL; + mutex_unlock(&lo->tx_lock); + wake_up_all(&lo->active_wq); + + spin_lock_irq(q->queue_lock); + continue; + +error_out: + req->errors++; + spin_unlock(q->queue_lock); + nbd_end_request(req); + spin_lock(q->queue_lock); + } + return; +} + +static int nbd_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; + int error; + struct request sreq ; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + BUG_ON(lo->magic != LO_MAGIC); + + /* Anyone capable of this syscall can do *real bad* things */ + dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", + lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); + + switch (cmd) { + case NBD_DISCONNECT: + printk(KERN_INFO "%s: NBD_DISCONNECT\n", lo->disk->disk_name); + sreq.cmd_type = REQ_TYPE_SPECIAL; + nbd_cmd(&sreq) = NBD_CMD_DISC; + /* + * Set these to sane values in case server implementation + * fails to check the request type first and also to keep + * debugging output cleaner. + */ + sreq.sector = 0; + sreq.nr_sectors = 0; + if (!lo->sock) + return -EINVAL; + nbd_send_req(lo, &sreq); + return 0; + + case NBD_CLEAR_SOCK: + error = 0; + mutex_lock(&lo->tx_lock); + lo->sock = NULL; + mutex_unlock(&lo->tx_lock); + file = lo->file; + lo->file = NULL; + nbd_clear_que(lo); + BUG_ON(!list_empty(&lo->queue_head)); + if (file) + fput(file); + return error; + case NBD_SET_SOCK: + if (lo->file) + return -EBUSY; + error = -EINVAL; + file = fget(arg); + if (file) { + inode = file->f_dentry->d_inode; + if (S_ISSOCK(inode->i_mode)) { + lo->file = file; + lo->sock = SOCKET_I(inode); + error = 0; + } else { + fput(file); + } + } + return error; + case NBD_SET_BLKSIZE: + lo->blksize = arg; + lo->bytesize &= ~(lo->blksize-1); + inode->i_bdev->bd_inode->i_size = lo->bytesize; + set_blocksize(inode->i_bdev, lo->blksize); + set_capacity(lo->disk, lo->bytesize >> 9); + return 0; + case NBD_SET_SIZE: + lo->bytesize = arg & ~(lo->blksize-1); + inode->i_bdev->bd_inode->i_size = lo->bytesize; + set_blocksize(inode->i_bdev, lo->blksize); + set_capacity(lo->disk, lo->bytesize >> 9); + return 0; + case NBD_SET_SIZE_BLOCKS: + lo->bytesize = ((u64) arg) * lo->blksize; + inode->i_bdev->bd_inode->i_size = lo->bytesize; + set_blocksize(inode->i_bdev, lo->blksize); + set_capacity(lo->disk, lo->bytesize >> 9); + return 0; + case NBD_DO_IT: + if (!lo->file) + return -EINVAL; + nbd_do_it(lo); + /* on return tidy up in case we have a signal */ + /* Forcibly shutdown the socket causing all listeners + * to error + * + * FIXME: This code is duplicated from sys_shutdown, but + * there should be a more generic interface rather than + * calling socket ops directly here */ + mutex_lock(&lo->tx_lock); + if (lo->sock) { + printk(KERN_WARNING "%s: shutting down socket\n", + lo->disk->disk_name); + lo->sock->ops->shutdown(lo->sock, + SEND_SHUTDOWN|RCV_SHUTDOWN); + lo->sock = NULL; + } + mutex_unlock(&lo->tx_lock); + file = lo->file; + lo->file = NULL; + nbd_clear_que(lo); + printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name); + if (file) + fput(file); + return lo->harderror; + case NBD_CLEAR_QUE: + /* + * This is for compatibility only. The queue is always cleared + * by NBD_DO_IT or NBD_CLEAR_SOCK. + */ + BUG_ON(!lo->sock && !list_empty(&lo->queue_head)); + return 0; + case NBD_PRINT_DEBUG: + printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n", + inode->i_bdev->bd_disk->disk_name, + lo->queue_head.next, lo->queue_head.prev, + &lo->queue_head); + return 0; + } + return -EINVAL; +} + +static struct block_device_operations nbd_fops = +{ + .owner = THIS_MODULE, + .ioctl = nbd_ioctl, +}; + +/* + * And here should be modules and kernel interface + * (Just smiley confuses emacs :-) + */ + +static int __init nbd_init(void) +{ + int err = -ENOMEM; + int i; + + BUILD_BUG_ON(sizeof(struct nbd_request) != 28); + + if (nbds_max > MAX_NBD) { + printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD, + nbds_max); + return -EINVAL; + } + + for (i = 0; i < nbds_max; i++) { + struct gendisk *disk = alloc_disk(1); + if (!disk) + goto out; + nbd_dev[i].disk = disk; + /* + * The new linux 2.5 block layer implementation requires + * every gendisk to have its very own request_queue struct. + * These structs are big so we dynamically allocate them. + */ + disk->queue = blk_init_queue(do_nbd_request, &nbd_lock); + if (!disk->queue) { + put_disk(disk); + goto out; + } + } + + if (register_blkdev(NBD_MAJOR, "nbd")) { + err = -EIO; + goto out; + } + + printk(KERN_INFO "nbd: registered device at major %d\n", NBD_MAJOR); + dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags); + + for (i = 0; i < nbds_max; i++) { + struct gendisk *disk = nbd_dev[i].disk; + nbd_dev[i].file = NULL; + nbd_dev[i].magic = LO_MAGIC; + nbd_dev[i].flags = 0; + spin_lock_init(&nbd_dev[i].queue_lock); + INIT_LIST_HEAD(&nbd_dev[i].queue_head); + mutex_init(&nbd_dev[i].tx_lock); + init_waitqueue_head(&nbd_dev[i].active_wq); + nbd_dev[i].blksize = 1024; + nbd_dev[i].bytesize = 0x7ffffc00 << 10; /* 2TB */ + disk->major = NBD_MAJOR; + disk->first_minor = i; + disk->fops = &nbd_fops; + disk->private_data = &nbd_dev[i]; + disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; + sprintf(disk->disk_name, "nbd%d", i); + set_capacity(disk, 0x7ffffc00 << 1); /* 2 TB */ + add_disk(disk); + } + + return 0; +out: + while (i--) { + blk_cleanup_queue(nbd_dev[i].disk->queue); + put_disk(nbd_dev[i].disk); + } + return err; +} + +static void __exit nbd_cleanup(void) +{ + int i; + for (i = 0; i < nbds_max; i++) { + struct gendisk *disk = nbd_dev[i].disk; + nbd_dev[i].magic = 0; + if (disk) { + del_gendisk(disk); + blk_cleanup_queue(disk->queue); + put_disk(disk); + } + } + unregister_blkdev(NBD_MAJOR, "nbd"); + printk(KERN_INFO "nbd: unregistered device at major %d\n", NBD_MAJOR); +} + +module_init(nbd_init); +module_exit(nbd_cleanup); + +MODULE_DESCRIPTION("Network Block Device"); +MODULE_LICENSE("GPL"); + +module_param(nbds_max, int, 0444); +MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize."); +#ifndef NDEBUG +module_param(debugflags, int, 0644); +MODULE_PARM_DESC(debugflags, "flags for controlling debug output"); +#endif diff --git a/ddverify/case_studies/block/nbd/nbd.h b/ddverify/case_studies/block/nbd/nbd.h new file mode 100644 index 000000000..d6b6dc09a --- /dev/null +++ b/ddverify/case_studies/block/nbd/nbd.h @@ -0,0 +1,102 @@ +/* + * 1999 Copyright (C) Pavel Machek, pavel@ucw.cz. This code is GPL. + * 1999/11/04 Copyright (C) 1999 VMware, Inc. (Regis "HPReg" Duchesne) + * Made nbd_end_request() use the io_request_lock + * 2001 Copyright (C) Steven Whitehouse + * New nbd_end_request() for compatibility with new linux block + * layer code. + * 2003/06/24 Louis D. Langholtz + * Removed unneeded blksize_bits field from nbd_device struct. + * Cleanup PARANOIA usage & code. + * 2004/02/19 Paul Clements + * Removed PARANOIA, plus various cleanup and comments + */ + +#ifndef LINUX_NBD_H +#define LINUX_NBD_H + +#include + +#define NBD_SET_SOCK _IO( 0xab, 0 ) +#define NBD_SET_BLKSIZE _IO( 0xab, 1 ) +#define NBD_SET_SIZE _IO( 0xab, 2 ) +#define NBD_DO_IT _IO( 0xab, 3 ) +#define NBD_CLEAR_SOCK _IO( 0xab, 4 ) +#define NBD_CLEAR_QUE _IO( 0xab, 5 ) +#define NBD_PRINT_DEBUG _IO( 0xab, 6 ) +#define NBD_SET_SIZE_BLOCKS _IO( 0xab, 7 ) +#define NBD_DISCONNECT _IO( 0xab, 8 ) + +enum { + NBD_CMD_READ = 0, + NBD_CMD_WRITE = 1, + NBD_CMD_DISC = 2 +}; + +#define nbd_cmd(req) ((req)->cmd[0]) +#define MAX_NBD 128 + +/* userspace doesn't need the nbd_device structure */ +#ifdef __KERNEL__ + +#include +#include + +/* values for flags field */ +#define NBD_READ_ONLY 0x0001 +#define NBD_WRITE_NOCHK 0x0002 + +struct request; + +struct nbd_device { + int flags; + int harderror; /* Code of hard error */ + struct socket * sock; + struct file * file; /* If == NULL, device is not ready, yet */ + int magic; + + spinlock_t queue_lock; + struct list_head queue_head;/* Requests are added here... */ + struct request *active_req; + wait_queue_head_t active_wq; + + struct mutex tx_lock; + struct gendisk *disk; + int blksize; + u64 bytesize; +}; + +#endif + +/* These are sent over the network in the request/reply magic fields */ + +#define NBD_REQUEST_MAGIC 0x25609513 +#define NBD_REPLY_MAGIC 0x67446698 +/* Do *not* use magics: 0x12560953 0x96744668. */ + +/* + * This is the packet used for communication between client and + * server. All data are in network byte order. + */ +struct nbd_request { + __be32 magic; + __be32 type; /* == READ || == WRITE */ + char handle[8]; + __be64 from; + __be32 len; +} +#ifdef __GNUC__ + __attribute__ ((packed)) +#endif +; + +/* + * This is the reply packet that nbd-server sends back to the client after + * it has completed an I/O request (or an error occurs). + */ +struct nbd_reply { + __be32 magic; + __be32 error; /* 0 = ok, else error */ + char handle[8]; /* handle you got from request */ +}; +#endif diff --git a/ddverify/case_studies/block/umem/umem.c b/ddverify/case_studies/block/umem/umem.c new file mode 100644 index 000000000..eefe10c74 --- /dev/null +++ b/ddverify/case_studies/block/umem/umem.c @@ -0,0 +1,1244 @@ +/* + * mm.c - Micro Memory(tm) PCI memory board block device driver - v2.3 + * + * (C) 2001 San Mehat + * (C) 2001 Johannes Erdfelt + * (C) 2001 NeilBrown + * + * This driver for the Micro Memory PCI Memory Module with Battery Backup + * is Copyright Micro Memory Inc 2001-2002. All rights reserved. + * + * This driver is released to the public under the terms of the + * GNU GENERAL PUBLIC LICENSE version 2 + * See the file COPYING for details. + * + * This driver provides a standard block device interface for Micro Memory(tm) + * PCI based RAM boards. + * 10/05/01: Phap Nguyen - Rebuilt the driver + * 10/22/01: Phap Nguyen - v2.1 Added disk partitioning + * 29oct2001:NeilBrown - Use make_request_fn instead of request_fn + * - use stand disk partitioning (so fdisk works). + * 08nov2001:NeilBrown - change driver name from "mm" to "umem" + * - incorporate into main kernel + * 08apr2002:NeilBrown - Move some of interrupt handle to tasklet + * - use spin_lock_bh instead of _irq + * - Never block on make_request. queue + * bh's instead. + * - unregister umem from devfs at mod unload + * - Change version to 2.3 + * 07Nov2001:Phap Nguyen - Select pci read command: 06, 12, 15 (Decimal) + * 07Jan2002: P. Nguyen - Used PCI Memory Write & Invalidate for DMA + * 15May2002:NeilBrown - convert to bio for 2.5 + * 17May2002:NeilBrown - remove init_mem initialisation. Instead detect + * - a sequence of writes that cover the card, and + * - set initialised bit then. + */ + +//#define DEBUG /* uncomment if you want debugging info (pr_debug) */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* O_ACCMODE */ +#include /* HDIO_GETGEO */ + +#include "umem.h" + +#include +#include + +#define MM_MAXCARDS 4 +#define MM_RAHEAD 2 /* two sectors */ +#define MM_BLKSIZE 1024 /* 1k blocks */ +#define MM_HARDSECT 512 /* 512-byte hardware sectors */ +#define MM_SHIFT 6 /* max 64 partitions on 4 cards */ + +/* + * Version Information + */ + +#define DRIVER_VERSION "v2.3" +#define DRIVER_AUTHOR "San Mehat, Johannes Erdfelt, NeilBrown" +#define DRIVER_DESC "Micro Memory(tm) PCI memory board block driver" + +int debug; +/* #define HW_TRACE(x) writeb(x,cards[0].csr_remap + MEMCTRLSTATUS_MAGIC) */ +#define HW_TRACE(x) + +#define DEBUG_LED_ON_TRANSFER 0x01 +#define DEBUG_BATTERY_POLLING 0x02 + +module_param(debug, int, 0644); +MODULE_PARM_DESC(debug, "Debug bitmask"); + +int pci_read_cmd = 0x0C; /* Read Multiple */ +module_param(pci_read_cmd, int, 0); +MODULE_PARM_DESC(pci_read_cmd, "PCI read command"); + +int pci_write_cmd = 0x0F; /* Write and Invalidate */ +module_param(pci_write_cmd, int, 0); +MODULE_PARM_DESC(pci_write_cmd, "PCI write command"); + +int pci_cmds; + +int major_nr; + +#include +#include + +struct cardinfo { + int card_number; + struct pci_dev *dev; + + int irq; + + unsigned long csr_base; + unsigned char __iomem *csr_remap; + unsigned long csr_len; +#ifdef CONFIG_MM_MAP_MEMORY + unsigned long mem_base; + unsigned char __iomem *mem_remap; + unsigned long mem_len; +#endif + + unsigned int win_size; /* PCI window size */ + unsigned int mm_size; /* size in kbytes */ + + unsigned int init_size; /* initial segment, in sectors, + * that we know to + * have been written + */ + struct bio *bio, *currentbio, **biotail; + + request_queue_t *queue; + + struct mm_page { + dma_addr_t page_dma; + struct mm_dma_desc *desc; + int cnt, headcnt; + struct bio *bio, **biotail; + } mm_pages[2]; +#define DESC_PER_PAGE ((PAGE_SIZE*2)/sizeof(struct mm_dma_desc)) + + int Active, Ready; + + struct tasklet_struct tasklet; + unsigned int dma_status; + + struct { + int good; + int warned; + unsigned long last_change; + } battery[2]; + + spinlock_t lock; + int check_batteries; + + int flags; +}; + +struct cardinfo cards[MM_MAXCARDS]; +struct block_device_operations mm_fops; +struct timer_list battery_timer; + +int num_cards = 0; + +struct gendisk *mm_gendisk[MM_MAXCARDS]; + +void check_batteries(struct cardinfo *card); + +/* +----------------------------------------------------------------------------------- +-- get_userbit +----------------------------------------------------------------------------------- +*/ +int get_userbit(struct cardinfo *card, int bit) +{ + unsigned char led; + + led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); + return led & bit; +} +/* +----------------------------------------------------------------------------------- +-- set_userbit +----------------------------------------------------------------------------------- +*/ +int set_userbit(struct cardinfo *card, int bit, unsigned char state) +{ + unsigned char led; + + led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); + if (state) + led |= bit; + else + led &= ~bit; + writeb(led, card->csr_remap + MEMCTRLCMD_LEDCTRL); + + return 0; +} +/* +----------------------------------------------------------------------------------- +-- set_led +----------------------------------------------------------------------------------- +*/ +/* + * NOTE: For the power LED, use the LED_POWER_* macros since they differ + */ +void set_led(struct cardinfo *card, int shift, unsigned char state) +{ + unsigned char led; + + led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); + if (state == LED_FLIP) + led ^= (1<csr_remap + MEMCTRLCMD_LEDCTRL); + +} + +#ifdef MM_DIAG +/* +----------------------------------------------------------------------------------- +-- dump_regs +----------------------------------------------------------------------------------- +*/ +void dump_regs(struct cardinfo *card) +{ + unsigned char *p; + int i, i1; + + p = card->csr_remap; + for (i = 0; i < 8; i++) { + printk(KERN_DEBUG "%p ", p); + + for (i1 = 0; i1 < 16; i1++) + printk("%02x ", *p++); + + printk("\n"); + } +} +#endif +/* +----------------------------------------------------------------------------------- +-- dump_dmastat +----------------------------------------------------------------------------------- +*/ +void dump_dmastat(struct cardinfo *card, unsigned int dmastat) +{ + printk(KERN_DEBUG "MM%d*: DMAstat - ", card->card_number); + if (dmastat & DMASCR_ANY_ERR) + printk("ANY_ERR "); + if (dmastat & DMASCR_MBE_ERR) + printk("MBE_ERR "); + if (dmastat & DMASCR_PARITY_ERR_REP) + printk("PARITY_ERR_REP "); + if (dmastat & DMASCR_PARITY_ERR_DET) + printk("PARITY_ERR_DET "); + if (dmastat & DMASCR_SYSTEM_ERR_SIG) + printk("SYSTEM_ERR_SIG "); + if (dmastat & DMASCR_TARGET_ABT) + printk("TARGET_ABT "); + if (dmastat & DMASCR_MASTER_ABT) + printk("MASTER_ABT "); + if (dmastat & DMASCR_CHAIN_COMPLETE) + printk("CHAIN_COMPLETE "); + if (dmastat & DMASCR_DMA_COMPLETE) + printk("DMA_COMPLETE "); + printk("\n"); +} + +/* + * Theory of request handling + * + * Each bio is assigned to one mm_dma_desc - which may not be enough FIXME + * We have two pages of mm_dma_desc, holding about 64 descriptors + * each. These are allocated at init time. + * One page is "Ready" and is either full, or can have request added. + * The other page might be "Active", which DMA is happening on it. + * + * Whenever IO on the active page completes, the Ready page is activated + * and the ex-Active page is clean out and made Ready. + * Otherwise the Ready page is only activated when it becomes full, or + * when mm_unplug_device is called via the unplug_io_fn. + * + * If a request arrives while both pages a full, it is queued, and b_rdev is + * overloaded to record whether it was a read or a write. + * + * The interrupt handler only polls the device to clear the interrupt. + * The processing of the result is done in a tasklet. + */ + +void mm_start_io(struct cardinfo *card) +{ + /* we have the lock, we know there is + * no IO active, and we know that card->Active + * is set + */ + struct mm_dma_desc *desc; + struct mm_page *page; + int offset; + + /* make the last descriptor end the chain */ + page = &card->mm_pages[card->Active]; + pr_debug("start_io: %d %d->%d\n", card->Active, page->headcnt, page->cnt-1); + desc = &page->desc[page->cnt-1]; + + desc->control_bits |= cpu_to_le32(DMASCR_CHAIN_COMP_EN); + desc->control_bits &= ~cpu_to_le32(DMASCR_CHAIN_EN); + desc->sem_control_bits = desc->control_bits; + + + if (debug & DEBUG_LED_ON_TRANSFER) + set_led(card, LED_REMOVE, LED_ON); + + desc = &page->desc[page->headcnt]; + writel(0, card->csr_remap + DMA_PCI_ADDR); + writel(0, card->csr_remap + DMA_PCI_ADDR + 4); + + writel(0, card->csr_remap + DMA_LOCAL_ADDR); + writel(0, card->csr_remap + DMA_LOCAL_ADDR + 4); + + writel(0, card->csr_remap + DMA_TRANSFER_SIZE); + writel(0, card->csr_remap + DMA_TRANSFER_SIZE + 4); + + writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR); + writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR + 4); + + offset = ((char*)desc) - ((char*)page->desc); + writel(cpu_to_le32((page->page_dma+offset)&0xffffffff), + card->csr_remap + DMA_DESCRIPTOR_ADDR); + /* Force the value to u64 before shifting otherwise >> 32 is undefined C + * and on some ports will do nothing ! */ + writel(cpu_to_le32(((u64)page->page_dma)>>32), + card->csr_remap + DMA_DESCRIPTOR_ADDR + 4); + + /* Go, go, go */ + writel(cpu_to_le32(DMASCR_GO | DMASCR_CHAIN_EN | pci_cmds), + card->csr_remap + DMA_STATUS_CTRL); +} + +int add_bio(struct cardinfo *card); + +void activate(struct cardinfo *card) +{ + /* if No page is Active, and Ready is + * not empty, then switch Ready page + * to active and start IO. + * Then add any bh's that are available to Ready + */ + + do { + while (add_bio(card)) + ; + + if (card->Active == -1 && + card->mm_pages[card->Ready].cnt > 0) { + card->Active = card->Ready; + card->Ready = 1-card->Ready; + mm_start_io(card); + } + + } while (card->Active == -1 && add_bio(card)); +} + +inline void reset_page(struct mm_page *page) +{ + page->cnt = 0; + page->headcnt = 0; + page->bio = NULL; + page->biotail = & page->bio; +} + +void mm_unplug_device(request_queue_t *q) +{ + struct cardinfo *card = q->queuedata; + unsigned long flags; + + spin_lock_irqsave(&card->lock, flags); + if (blk_remove_plug(q)) + activate(card); + spin_unlock_irqrestore(&card->lock, flags); +} + +/* + * If there is room on Ready page, take + * one bh off list and add it. + * return 1 if there was room, else 0. + */ +int add_bio(struct cardinfo *card) +{ + struct mm_page *p; + struct mm_dma_desc *desc; + dma_addr_t dma_handle; + int offset; + struct bio *bio; + int rw; + int len; + + bio = card->currentbio; + if (!bio && card->bio) { + card->currentbio = card->bio; + card->bio = card->bio->bi_next; + if (card->bio == NULL) + card->biotail = &card->bio; + card->currentbio->bi_next = NULL; + return 1; + } + if (!bio) + return 0; + + rw = bio_rw(bio); + if (card->mm_pages[card->Ready].cnt >= DESC_PER_PAGE) + return 0; + + len = bio_iovec(bio)->bv_len; + dma_handle = pci_map_page(card->dev, + bio_page(bio), + bio_offset(bio), + len, + (rw==READ) ? + PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); + + p = &card->mm_pages[card->Ready]; + desc = &p->desc[p->cnt]; + p->cnt++; + if ((p->biotail) != &bio->bi_next) { + *(p->biotail) = bio; + p->biotail = &(bio->bi_next); + bio->bi_next = NULL; + } + + desc->data_dma_handle = dma_handle; + + desc->pci_addr = cpu_to_le64((u64)desc->data_dma_handle); + desc->local_addr= cpu_to_le64(bio->bi_sector << 9); + desc->transfer_size = cpu_to_le32(len); + offset = ( ((char*)&desc->sem_control_bits) - ((char*)p->desc)); + desc->sem_addr = cpu_to_le64((u64)(p->page_dma+offset)); + desc->zero1 = desc->zero2 = 0; + offset = ( ((char*)(desc+1)) - ((char*)p->desc)); + desc->next_desc_addr = cpu_to_le64(p->page_dma+offset); + desc->control_bits = cpu_to_le32(DMASCR_GO|DMASCR_ERR_INT_EN| + DMASCR_PARITY_INT_EN| + DMASCR_CHAIN_EN | + DMASCR_SEM_EN | + pci_cmds); + if (rw == WRITE) + desc->control_bits |= cpu_to_le32(DMASCR_TRANSFER_READ); + desc->sem_control_bits = desc->control_bits; + + bio->bi_sector += (len>>9); + bio->bi_size -= len; + bio->bi_idx++; + if (bio->bi_idx >= bio->bi_vcnt) + card->currentbio = NULL; + + return 1; +} + +void process_page(unsigned long data) +{ + /* check if any of the requests in the page are DMA_COMPLETE, + * and deal with them appropriately. + * If we find a descriptor without DMA_COMPLETE in the semaphore, then + * dma must have hit an error on that descriptor, so use dma_status instead + * and assume that all following descriptors must be re-tried. + */ + struct mm_page *page; + struct bio *return_bio=NULL; + struct cardinfo *card = (struct cardinfo *)data; + unsigned int dma_status = card->dma_status; + + spin_lock_bh(&card->lock); + if (card->Active < 0) + goto out_unlock; + page = &card->mm_pages[card->Active]; + + while (page->headcnt < page->cnt) { + struct bio *bio = page->bio; + struct mm_dma_desc *desc = &page->desc[page->headcnt]; + int control = le32_to_cpu(desc->sem_control_bits); + int last=0; + int idx; + + if (!(control & DMASCR_DMA_COMPLETE)) { + control = dma_status; + last=1; + } + page->headcnt++; + idx = bio->bi_phys_segments; + bio->bi_phys_segments++; + if (bio->bi_phys_segments >= bio->bi_vcnt) + page->bio = bio->bi_next; + + pci_unmap_page(card->dev, desc->data_dma_handle, + bio_iovec_idx(bio,idx)->bv_len, + (control& DMASCR_TRANSFER_READ) ? + PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); + if (control & DMASCR_HARD_ERROR) { + /* error */ + clear_bit(BIO_UPTODATE, &bio->bi_flags); + printk(KERN_WARNING "MM%d: I/O error on sector %d/%d\n", + card->card_number, + le32_to_cpu(desc->local_addr)>>9, + le32_to_cpu(desc->transfer_size)); + dump_dmastat(card, control); + } else if (test_bit(BIO_RW, &bio->bi_rw) && + le32_to_cpu(desc->local_addr)>>9 == card->init_size) { + card->init_size += le32_to_cpu(desc->transfer_size)>>9; + if (card->init_size>>1 >= card->mm_size) { + printk(KERN_INFO "MM%d: memory now initialised\n", + card->card_number); + set_userbit(card, MEMORY_INITIALIZED, 1); + } + } + if (bio != page->bio) { + bio->bi_next = return_bio; + return_bio = bio; + } + + if (last) break; + } + + if (debug & DEBUG_LED_ON_TRANSFER) + set_led(card, LED_REMOVE, LED_OFF); + + if (card->check_batteries) { + card->check_batteries = 0; + check_batteries(card); + } + if (page->headcnt >= page->cnt) { + reset_page(page); + card->Active = -1; + activate(card); + } else { + /* haven't finished with this one yet */ + pr_debug("do some more\n"); + mm_start_io(card); + } + out_unlock: + spin_unlock_bh(&card->lock); + + while(return_bio) { + struct bio *bio = return_bio; + + return_bio = bio->bi_next; + bio->bi_next = NULL; + bio_endio(bio, bio->bi_size, 0); + } +} + +/* +----------------------------------------------------------------------------------- +-- mm_make_request +----------------------------------------------------------------------------------- +*/ +int mm_make_request(request_queue_t *q, struct bio *bio) +{ + struct cardinfo *card = q->queuedata; + pr_debug("mm_make_request %llu %u\n", + (unsigned long long)bio->bi_sector, bio->bi_size); + + bio->bi_phys_segments = bio->bi_idx; /* count of completed segments*/ + spin_lock_irq(&card->lock); + *card->biotail = bio; + bio->bi_next = NULL; + card->biotail = &bio->bi_next; + blk_plug_device(q); + spin_unlock_irq(&card->lock); + + return 0; +} + +/* +----------------------------------------------------------------------------------- +-- mm_interrupt +----------------------------------------------------------------------------------- +*/ +irqreturn_t mm_interrupt(int irq, void *__card) +{ + struct cardinfo *card = (struct cardinfo *) __card; + unsigned int dma_status; + unsigned short cfg_status; + +HW_TRACE(0x30); + + dma_status = le32_to_cpu(readl(card->csr_remap + DMA_STATUS_CTRL)); + + if (!(dma_status & (DMASCR_ERROR_MASK | DMASCR_CHAIN_COMPLETE))) { + /* interrupt wasn't for me ... */ + return IRQ_NONE; + } + + /* clear COMPLETION interrupts */ + if (card->flags & UM_FLAG_NO_BYTE_STATUS) + writel(cpu_to_le32(DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE), + card->csr_remap+ DMA_STATUS_CTRL); + else + writeb((DMASCR_DMA_COMPLETE|DMASCR_CHAIN_COMPLETE) >> 16, + card->csr_remap+ DMA_STATUS_CTRL + 2); + + /* log errors and clear interrupt status */ + if (dma_status & DMASCR_ANY_ERR) { + unsigned int data_log1, data_log2; + unsigned int addr_log1, addr_log2; + unsigned char stat, count, syndrome, check; + + stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS); + + data_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG)); + data_log2 = le32_to_cpu(readl(card->csr_remap + ERROR_DATA_LOG + 4)); + addr_log1 = le32_to_cpu(readl(card->csr_remap + ERROR_ADDR_LOG)); + addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4); + + count = readb(card->csr_remap + ERROR_COUNT); + syndrome = readb(card->csr_remap + ERROR_SYNDROME); + check = readb(card->csr_remap + ERROR_CHECK); + + dump_dmastat(card, dma_status); + + if (stat & 0x01) + printk(KERN_ERR "MM%d*: Memory access error detected (err count %d)\n", + card->card_number, count); + if (stat & 0x02) + printk(KERN_ERR "MM%d*: Multi-bit EDC error\n", + card->card_number); + + printk(KERN_ERR "MM%d*: Fault Address 0x%02x%08x, Fault Data 0x%08x%08x\n", + card->card_number, addr_log2, addr_log1, data_log2, data_log1); + printk(KERN_ERR "MM%d*: Fault Check 0x%02x, Fault Syndrome 0x%02x\n", + card->card_number, check, syndrome); + + writeb(0, card->csr_remap + ERROR_COUNT); + } + + if (dma_status & DMASCR_PARITY_ERR_REP) { + printk(KERN_ERR "MM%d*: PARITY ERROR REPORTED\n", card->card_number); + pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); + pci_write_config_word(card->dev, PCI_STATUS, cfg_status); + } + + if (dma_status & DMASCR_PARITY_ERR_DET) { + printk(KERN_ERR "MM%d*: PARITY ERROR DETECTED\n", card->card_number); + pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); + pci_write_config_word(card->dev, PCI_STATUS, cfg_status); + } + + if (dma_status & DMASCR_SYSTEM_ERR_SIG) { + printk(KERN_ERR "MM%d*: SYSTEM ERROR\n", card->card_number); + pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); + pci_write_config_word(card->dev, PCI_STATUS, cfg_status); + } + + if (dma_status & DMASCR_TARGET_ABT) { + printk(KERN_ERR "MM%d*: TARGET ABORT\n", card->card_number); + pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); + pci_write_config_word(card->dev, PCI_STATUS, cfg_status); + } + + if (dma_status & DMASCR_MASTER_ABT) { + printk(KERN_ERR "MM%d*: MASTER ABORT\n", card->card_number); + pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); + pci_write_config_word(card->dev, PCI_STATUS, cfg_status); + } + + /* and process the DMA descriptors */ + card->dma_status = dma_status; + tasklet_schedule(&card->tasklet); + +HW_TRACE(0x36); + + return IRQ_HANDLED; +} +/* +----------------------------------------------------------------------------------- +-- set_fault_to_battery_status +----------------------------------------------------------------------------------- +*/ +/* + * If both batteries are good, no LED + * If either battery has been warned, solid LED + * If both batteries are bad, flash the LED quickly + * If either battery is bad, flash the LED semi quickly + */ +void set_fault_to_battery_status(struct cardinfo *card) +{ + if (card->battery[0].good && card->battery[1].good) + set_led(card, LED_FAULT, LED_OFF); + else if (card->battery[0].warned || card->battery[1].warned) + set_led(card, LED_FAULT, LED_ON); + else if (!card->battery[0].good && !card->battery[1].good) + set_led(card, LED_FAULT, LED_FLASH_7_0); + else + set_led(card, LED_FAULT, LED_FLASH_3_5); +} + +void init_battery_timer(void); + + +/* +----------------------------------------------------------------------------------- +-- check_battery +----------------------------------------------------------------------------------- +*/ +int check_battery(struct cardinfo *card, int battery, int status) +{ + if (status != card->battery[battery].good) { + card->battery[battery].good = !card->battery[battery].good; + card->battery[battery].last_change = jiffies; + + if (card->battery[battery].good) { + printk(KERN_ERR "MM%d: Battery %d now good\n", + card->card_number, battery + 1); + card->battery[battery].warned = 0; + } else + printk(KERN_ERR "MM%d: Battery %d now FAILED\n", + card->card_number, battery + 1); + + return 1; + } else if (!card->battery[battery].good && + !card->battery[battery].warned && + time_after_eq(jiffies, card->battery[battery].last_change + + (HZ * 60 * 60 * 5))) { + printk(KERN_ERR "MM%d: Battery %d still FAILED after 5 hours\n", + card->card_number, battery + 1); + card->battery[battery].warned = 1; + + return 1; + } + + return 0; +} +/* +----------------------------------------------------------------------------------- +-- check_batteries +----------------------------------------------------------------------------------- +*/ +void check_batteries(struct cardinfo *card) +{ + /* NOTE: this must *never* be called while the card + * is doing (bus-to-card) DMA, or you will need the + * reset switch + */ + unsigned char status; + int ret1, ret2; + + status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); + if (debug & DEBUG_BATTERY_POLLING) + printk(KERN_DEBUG "MM%d: checking battery status, 1 = %s, 2 = %s\n", + card->card_number, + (status & BATTERY_1_FAILURE) ? "FAILURE" : "OK", + (status & BATTERY_2_FAILURE) ? "FAILURE" : "OK"); + + ret1 = check_battery(card, 0, !(status & BATTERY_1_FAILURE)); + ret2 = check_battery(card, 1, !(status & BATTERY_2_FAILURE)); + + if (ret1 || ret2) + set_fault_to_battery_status(card); +} + +void check_all_batteries(unsigned long ptr) +{ + int i; + + for (i = 0; i < num_cards; i++) + if (!(cards[i].flags & UM_FLAG_NO_BATT)) { + struct cardinfo *card = &cards[i]; + spin_lock_bh(&card->lock); + if (card->Active >= 0) + card->check_batteries = 1; + else + check_batteries(card); + spin_unlock_bh(&card->lock); + } + + init_battery_timer(); +} +/* +----------------------------------------------------------------------------------- +-- init_battery_timer +----------------------------------------------------------------------------------- +*/ +void init_battery_timer(void) +{ + init_timer(&battery_timer); + battery_timer.function = check_all_batteries; + battery_timer.expires = jiffies + (HZ * 60); + add_timer(&battery_timer); +} +/* +----------------------------------------------------------------------------------- +-- del_battery_timer +----------------------------------------------------------------------------------- +*/ +void del_battery_timer(void) +{ + del_timer(&battery_timer); +} +/* +----------------------------------------------------------------------------------- +-- mm_revalidate +----------------------------------------------------------------------------------- +*/ +/* + * Note no locks taken out here. In a worst case scenario, we could drop + * a chunk of system memory. But that should never happen, since validation + * happens at open or mount time, when locks are held. + * + * That's crap, since doing that while some partitions are opened + * or mounted will give you really nasty results. + */ +int mm_revalidate(struct gendisk *disk) +{ + struct cardinfo *card = disk->private_data; + set_capacity(disk, card->mm_size << 1); + + return 0; +} + +int mm_getgeo(struct block_device *bdev, struct hd_geometry *geo) +{ + struct cardinfo *card = bdev->bd_disk->private_data; + int size = card->mm_size * (1024 / MM_HARDSECT); + + /* + * get geometry: we have to fake one... trim the size to a + * multiple of 2048 (1M): tell we have 32 sectors, 64 heads, + * whatever cylinders. + */ + geo->heads = 64; + geo->sectors = 32; + geo->cylinders = size / (geo->heads * geo->sectors); + return 0; +} + +/* +----------------------------------------------------------------------------------- +-- mm_check_change +----------------------------------------------------------------------------------- + Future support for removable devices +*/ +int mm_check_change(struct gendisk *disk) +{ +/* struct cardinfo *dev = disk->private_data; */ + return 0; +} +/* +----------------------------------------------------------------------------------- +-- mm_fops +----------------------------------------------------------------------------------- +*/ +struct block_device_operations mm_fops = { + .owner = THIS_MODULE, + .getgeo = mm_getgeo, + .revalidate_disk= mm_revalidate, + .media_changed = mm_check_change, +}; +/* +----------------------------------------------------------------------------------- +-- mm_pci_probe +----------------------------------------------------------------------------------- +*/ +int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) +{ + int ret = -ENODEV; + struct cardinfo *card = &cards[num_cards]; + unsigned char mem_present; + unsigned char batt_status; + unsigned int saved_bar, data; + int magic_number; + + if (pci_enable_device(dev) < 0) + return -ENODEV; + + pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF8); + pci_set_master(dev); + + card->dev = dev; + card->card_number = num_cards; + + card->csr_base = pci_resource_start(dev, 0); + card->csr_len = pci_resource_len(dev, 0); +#ifdef CONFIG_MM_MAP_MEMORY + card->mem_base = pci_resource_start(dev, 1); + card->mem_len = pci_resource_len(dev, 1); +#endif + + printk(KERN_INFO "Micro Memory(tm) controller #%d found at %02x:%02x (PCI Mem Module (Battery Backup))\n", + card->card_number, dev->bus->number, dev->devfn); + + if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && + pci_set_dma_mask(dev, DMA_32BIT_MASK)) { + printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards); + return -ENOMEM; + } + if (!request_mem_region(card->csr_base, card->csr_len, "Micro Memory")) { + printk(KERN_ERR "MM%d: Unable to request memory region\n", card->card_number); + ret = -ENOMEM; + + goto failed_req_csr; + } + + card->csr_remap = ioremap_nocache(card->csr_base, card->csr_len); + if (!card->csr_remap) { + printk(KERN_ERR "MM%d: Unable to remap memory region\n", card->card_number); + ret = -ENOMEM; + + goto failed_remap_csr; + } + + printk(KERN_INFO "MM%d: CSR 0x%08lx -> 0x%p (0x%lx)\n", card->card_number, + card->csr_base, card->csr_remap, card->csr_len); + +#ifdef CONFIG_MM_MAP_MEMORY + if (!request_mem_region(card->mem_base, card->mem_len, "Micro Memory")) { + printk(KERN_ERR "MM%d: Unable to request memory region\n", card->card_number); + ret = -ENOMEM; + + goto failed_req_mem; + } + + if (!(card->mem_remap = ioremap(card->mem_base, cards->mem_len))) { + printk(KERN_ERR "MM%d: Unable to remap memory region\n", card->card_number); + ret = -ENOMEM; + + goto failed_remap_mem; + } + + printk(KERN_INFO "MM%d: MEM 0x%8lx -> 0x%8lx (0x%lx)\n", card->card_number, + card->mem_base, card->mem_remap, card->mem_len); +#else + printk(KERN_INFO "MM%d: MEM area not remapped (CONFIG_MM_MAP_MEMORY not set)\n", + card->card_number); +#endif + switch(card->dev->device) { + case 0x5415: + card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG; + magic_number = 0x59; + break; + + case 0x5425: + card->flags |= UM_FLAG_NO_BYTE_STATUS; + magic_number = 0x5C; + break; + + case 0x6155: + card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT; + magic_number = 0x99; + break; + + default: + magic_number = 0x100; + break; + } + + if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) { + printk(KERN_ERR "MM%d: Magic number invalid\n", card->card_number); + ret = -ENOMEM; + goto failed_magic; + } + + card->mm_pages[0].desc = pci_alloc_consistent(card->dev, + PAGE_SIZE*2, + &card->mm_pages[0].page_dma); + card->mm_pages[1].desc = pci_alloc_consistent(card->dev, + PAGE_SIZE*2, + &card->mm_pages[1].page_dma); + if (card->mm_pages[0].desc == NULL || + card->mm_pages[1].desc == NULL) { + printk(KERN_ERR "MM%d: alloc failed\n", card->card_number); + goto failed_alloc; + } + reset_page(&card->mm_pages[0]); + reset_page(&card->mm_pages[1]); + card->Ready = 0; + card->Active = -1; + card->bio = NULL; + card->biotail = &card->bio; + + card->queue = blk_alloc_queue(GFP_KERNEL); + if (!card->queue) + goto failed_alloc; + + blk_queue_make_request(card->queue, mm_make_request); + card->queue->queuedata = card; + card->queue->unplug_fn = mm_unplug_device; + + tasklet_init(&card->tasklet, process_page, (unsigned long)card); + + card->check_batteries = 0; + + mem_present = readb(card->csr_remap + MEMCTRLSTATUS_MEMORY); + switch (mem_present) { + case MEM_128_MB: + card->mm_size = 1024 * 128; + break; + case MEM_256_MB: + card->mm_size = 1024 * 256; + break; + case MEM_512_MB: + card->mm_size = 1024 * 512; + break; + case MEM_1_GB: + card->mm_size = 1024 * 1024; + break; + case MEM_2_GB: + card->mm_size = 1024 * 2048; + break; + default: + card->mm_size = 0; + break; + } + + + set_led(card, LED_REMOVE, LED_OFF); + set_led(card, LED_FAULT, LED_OFF); + + batt_status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); + + card->battery[0].good = !(batt_status & BATTERY_1_FAILURE); + card->battery[1].good = !(batt_status & BATTERY_2_FAILURE); + card->battery[0].last_change = card->battery[1].last_change = jiffies; + + if (card->flags & UM_FLAG_NO_BATT) + printk(KERN_INFO "MM%d: Size %d KB\n", + card->card_number, card->mm_size); + else { + printk(KERN_INFO "MM%d: Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n", + card->card_number, card->mm_size, + (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), + card->battery[0].good ? "OK" : "FAILURE", + (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), + card->battery[1].good ? "OK" : "FAILURE"); + + set_fault_to_battery_status(card); + } + + pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &saved_bar); + data = 0xffffffff; + pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, data); + pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &data); + pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, saved_bar); + data &= 0xfffffff0; + data = ~data; + data += 1; + + card->win_size = data; + + + if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, "pci-umem", card)) { + printk(KERN_ERR "MM%d: Unable to allocate IRQ\n", card->card_number); + ret = -ENODEV; + + goto failed_req_irq; + } + + card->irq = dev->irq; + printk(KERN_INFO "MM%d: Window size %d bytes, IRQ %d\n", card->card_number, + card->win_size, card->irq); + + spin_lock_init(&card->lock); + + pci_set_drvdata(dev, card); + + if (pci_write_cmd != 0x0F) + pci_write_cmd = 0x07; + + if (pci_write_cmd & 0x08) { + unsigned short cfg_command; + pci_read_config_word(dev, PCI_COMMAND, &cfg_command); + cfg_command |= 0x10; + pci_write_config_word(dev, PCI_COMMAND, cfg_command); + } + pci_cmds = (pci_read_cmd << 28) | (pci_write_cmd << 24); + + num_cards++; + + if (!get_userbit(card, MEMORY_INITIALIZED)) { + printk(KERN_INFO "MM%d: memory NOT initialized. Consider over-writing whole device.\n", card->card_number); + card->init_size = 0; + } else { + printk(KERN_INFO "MM%d: memory already initialized\n", card->card_number); + card->init_size = card->mm_size; + } + + + writeb(EDC_STORE_CORRECT, card->csr_remap + MEMCTRLCMD_ERRCTRL); + + return 0; + + failed_req_irq: + failed_alloc: + if (card->mm_pages[0].desc) + pci_free_consistent(card->dev, PAGE_SIZE*2, + card->mm_pages[0].desc, + card->mm_pages[0].page_dma); + if (card->mm_pages[1].desc) + pci_free_consistent(card->dev, PAGE_SIZE*2, + card->mm_pages[1].desc, + card->mm_pages[1].page_dma); + + failed_magic: +#ifdef CONFIG_MM_MAP_MEMORY + iounmap(card->mem_remap); + failed_remap_mem: + release_mem_region(card->mem_base, card->mem_len); + failed_req_mem: +#endif + iounmap(card->csr_remap); + failed_remap_csr: + release_mem_region(card->csr_base, card->csr_len); + failed_req_csr: + + return ret; +} +/* +----------------------------------------------------------------------------------- +-- mm_pci_remove +----------------------------------------------------------------------------------- +*/ +void mm_pci_remove(struct pci_dev *dev) +{ + struct cardinfo *card = pci_get_drvdata(dev); + + tasklet_kill(&card->tasklet); + iounmap(card->csr_remap); + release_mem_region(card->csr_base, card->csr_len); +#ifdef CONFIG_MM_MAP_MEMORY + iounmap(card->mem_remap); + release_mem_region(card->mem_base, card->mem_len); +#endif + free_irq(card->irq, card); + + if (card->mm_pages[0].desc) + pci_free_consistent(card->dev, PAGE_SIZE*2, + card->mm_pages[0].desc, + card->mm_pages[0].page_dma); + if (card->mm_pages[1].desc) + pci_free_consistent(card->dev, PAGE_SIZE*2, + card->mm_pages[1].desc, + card->mm_pages[1].page_dma); + blk_cleanup_queue(card->queue); +} + +const struct pci_device_id mm_pci_ids[] = { { + .vendor = PCI_VENDOR_ID_MICRO_MEMORY, + .device = PCI_DEVICE_ID_MICRO_MEMORY_5415CN, + }, { + .vendor = PCI_VENDOR_ID_MICRO_MEMORY, + .device = PCI_DEVICE_ID_MICRO_MEMORY_5425CN, + }, { + .vendor = PCI_VENDOR_ID_MICRO_MEMORY, + .device = PCI_DEVICE_ID_MICRO_MEMORY_6155, + }, { + .vendor = 0x8086, + .device = 0xB555, + .subvendor= 0x1332, + .subdevice= 0x5460, + .class = 0x050000, + .class_mask= 0, + }, { /* end: all zeroes */ } +}; + +MODULE_DEVICE_TABLE(pci, mm_pci_ids); + +struct pci_driver mm_pci_driver = { + .name = "umem", + .id_table = mm_pci_ids, + .probe = mm_pci_probe, + .remove = mm_pci_remove, +}; +/* +----------------------------------------------------------------------------------- +-- mm_init +----------------------------------------------------------------------------------- +*/ + +int __init mm_init(void) +{ + int retval, i; + int err; + + printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n"); + + retval = pci_register_driver(&mm_pci_driver); + if (retval) + return -ENOMEM; + + err = major_nr = register_blkdev(0, "umem"); + if (err < 0) + return -EIO; + + for (i = 0; i < num_cards; i++) { + mm_gendisk[i] = alloc_disk(1 << MM_SHIFT); + if (!mm_gendisk[i]) + goto out; + } + + for (i = 0; i < num_cards; i++) { + struct gendisk *disk = mm_gendisk[i]; + sprintf(disk->disk_name, "umem%c", 'a'+i); + spin_lock_init(&cards[i].lock); + disk->major = major_nr; + disk->first_minor = i << MM_SHIFT; + disk->fops = &mm_fops; + disk->private_data = &cards[i]; + disk->queue = cards[i].queue; + set_capacity(disk, cards[i].mm_size << 1); + add_disk(disk); + } + + init_battery_timer(); + printk("MM: desc_per_page = %ld\n", DESC_PER_PAGE); +/* printk("mm_init: Done. 10-19-01 9:00\n"); */ + return 0; + +out: + unregister_blkdev(major_nr, "umem"); + while (i--) + put_disk(mm_gendisk[i]); + return -ENOMEM; +} +/* +----------------------------------------------------------------------------------- +-- mm_cleanup +----------------------------------------------------------------------------------- +*/ +void __exit mm_cleanup(void) +{ + int i; + + del_battery_timer(); + + for (i=0; i < num_cards ; i++) { + del_gendisk(mm_gendisk[i]); + put_disk(mm_gendisk[i]); + } + + pci_unregister_driver(&mm_pci_driver); + + unregister_blkdev(major_nr, "umem"); +} + +module_init(mm_init); +module_exit(mm_cleanup); + +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); diff --git a/ddverify/case_studies/block/umem/umem.h b/ddverify/case_studies/block/umem/umem.h new file mode 100644 index 000000000..f36ebfc32 --- /dev/null +++ b/ddverify/case_studies/block/umem/umem.h @@ -0,0 +1,138 @@ + +/* + * This file contains defines for the + * Micro Memory MM5415 + * family PCI Memory Module with Battery Backup. + * + * Copyright Micro Memory INC 2001. All rights reserved. + * Release under the terms of the GNU GENERAL PUBLIC LICENSE version 2. + * See the file COPYING. + */ + +#ifndef _DRIVERS_BLOCK_MM_H +#define _DRIVERS_BLOCK_MM_H + + +#define IRQ_TIMEOUT (1 * HZ) + +/* CSR register definition */ +#define MEMCTRLSTATUS_MAGIC 0x00 +#define MM_MAGIC_VALUE (unsigned char)0x59 + +#define MEMCTRLSTATUS_BATTERY 0x04 +#define BATTERY_1_DISABLED 0x01 +#define BATTERY_1_FAILURE 0x02 +#define BATTERY_2_DISABLED 0x04 +#define BATTERY_2_FAILURE 0x08 + +#define MEMCTRLSTATUS_MEMORY 0x07 +#define MEM_128_MB 0xfe +#define MEM_256_MB 0xfc +#define MEM_512_MB 0xf8 +#define MEM_1_GB 0xf0 +#define MEM_2_GB 0xe0 + +#define MEMCTRLCMD_LEDCTRL 0x08 +#define LED_REMOVE 2 +#define LED_FAULT 4 +#define LED_POWER 6 +#define LED_FLIP 255 +#define LED_OFF 0x00 +#define LED_ON 0x01 +#define LED_FLASH_3_5 0x02 +#define LED_FLASH_7_0 0x03 +#define LED_POWER_ON 0x00 +#define LED_POWER_OFF 0x01 +#define USER_BIT1 0x01 +#define USER_BIT2 0x02 + +#define MEMORY_INITIALIZED USER_BIT1 + +#define MEMCTRLCMD_ERRCTRL 0x0C +#define EDC_NONE_DEFAULT 0x00 +#define EDC_NONE 0x01 +#define EDC_STORE_READ 0x02 +#define EDC_STORE_CORRECT 0x03 + +#define MEMCTRLCMD_ERRCNT 0x0D +#define MEMCTRLCMD_ERRSTATUS 0x0E + +#define ERROR_DATA_LOG 0x20 +#define ERROR_ADDR_LOG 0x28 +#define ERROR_COUNT 0x3D +#define ERROR_SYNDROME 0x3E +#define ERROR_CHECK 0x3F + +#define DMA_PCI_ADDR 0x40 +#define DMA_LOCAL_ADDR 0x48 +#define DMA_TRANSFER_SIZE 0x50 +#define DMA_DESCRIPTOR_ADDR 0x58 +#define DMA_SEMAPHORE_ADDR 0x60 +#define DMA_STATUS_CTRL 0x68 +#define DMASCR_GO 0x00001 +#define DMASCR_TRANSFER_READ 0x00002 +#define DMASCR_CHAIN_EN 0x00004 +#define DMASCR_SEM_EN 0x00010 +#define DMASCR_DMA_COMP_EN 0x00020 +#define DMASCR_CHAIN_COMP_EN 0x00040 +#define DMASCR_ERR_INT_EN 0x00080 +#define DMASCR_PARITY_INT_EN 0x00100 +#define DMASCR_ANY_ERR 0x00800 +#define DMASCR_MBE_ERR 0x01000 +#define DMASCR_PARITY_ERR_REP 0x02000 +#define DMASCR_PARITY_ERR_DET 0x04000 +#define DMASCR_SYSTEM_ERR_SIG 0x08000 +#define DMASCR_TARGET_ABT 0x10000 +#define DMASCR_MASTER_ABT 0x20000 +#define DMASCR_DMA_COMPLETE 0x40000 +#define DMASCR_CHAIN_COMPLETE 0x80000 + +/* +3.SOME PCs HAVE HOST BRIDGES WHICH APPARENTLY DO NOT CORRECTLY HANDLE +READ-LINE (0xE) OR READ-MULTIPLE (0xC) PCI COMMAND CODES DURING DMA +TRANSFERS. IN OTHER SYSTEMS THESE COMMAND CODES WILL CAUSE THE HOST BRIDGE +TO ALLOW LONGER BURSTS DURING DMA READ OPERATIONS. THE UPPER FOUR BITS +(31..28) OF THE DMA CSR HAVE BEEN MADE PROGRAMMABLE, SO THAT EITHER A 0x6, +AN 0xE OR A 0xC CAN BE WRITTEN TO THEM TO SET THE COMMAND CODE USED DURING +DMA READ OPERATIONS. +*/ +#define DMASCR_READ 0x60000000 +#define DMASCR_READLINE 0xE0000000 +#define DMASCR_READMULTI 0xC0000000 + + +#define DMASCR_ERROR_MASK (DMASCR_MASTER_ABT | DMASCR_TARGET_ABT | DMASCR_SYSTEM_ERR_SIG | DMASCR_PARITY_ERR_DET | DMASCR_MBE_ERR | DMASCR_ANY_ERR) +#define DMASCR_HARD_ERROR (DMASCR_MASTER_ABT | DMASCR_TARGET_ABT | DMASCR_SYSTEM_ERR_SIG | DMASCR_PARITY_ERR_DET | DMASCR_MBE_ERR) + +#define WINDOWMAP_WINNUM 0x7B + +#define DMA_READ_FROM_HOST 0 +#define DMA_WRITE_TO_HOST 1 + +struct mm_dma_desc { + __le64 pci_addr; + __le64 local_addr; + __le32 transfer_size; + u32 zero1; + __le64 next_desc_addr; + __le64 sem_addr; + __le32 control_bits; + u32 zero2; + + dma_addr_t data_dma_handle; + + /* Copy of the bits */ + __le64 sem_control_bits; +} __attribute__((aligned(8))); + +#define PCI_VENDOR_ID_MICRO_MEMORY 0x1332 +#define PCI_DEVICE_ID_MICRO_MEMORY_5415CN 0x5415 +#define PCI_DEVICE_ID_MICRO_MEMORY_5425CN 0x5425 +#define PCI_DEVICE_ID_MICRO_MEMORY_6155 0x6155 + +/* bits for card->flags */ +#define UM_FLAG_DMA_IN_REGS 1 +#define UM_FLAG_NO_BYTE_STATUS 2 +#define UM_FLAG_NO_BATTREG 4 +#define UM_FLAG_NO_BATT 8 +#endif diff --git a/ddverify/case_studies/cdrom/aztcd/aztcd.c b/ddverify/case_studies/cdrom/aztcd/aztcd.c new file mode 100644 index 000000000..ce007349b --- /dev/null +++ b/ddverify/case_studies/cdrom/aztcd/aztcd.c @@ -0,0 +1,2494 @@ +#define AZT_VERSION "2.60" + +/* $Id: aztcd.c,v 2.60 1997/11/29 09:51:19 root Exp root $ + linux/drivers/block/aztcd.c - Aztech CD268 CDROM driver + + Copyright (C) 1994-98 Werner Zimmermann(Werner.Zimmermann@fht-esslingen.de) + + based on Mitsumi CDROM driver by Martin Hariss and preworks by + Eberhard Moenkeberg; contains contributions by Joe Nardone and Robby + Schirmer. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + HISTORY + V0.0 Adaption to Aztech CD268-01A Version 1.3 + Version is PRE_ALPHA, unresolved points: + 1. I use busy wait instead of timer wait in STEN_LOW,DTEN_LOW + thus driver causes CPU overhead and is very slow + 2. could not find a way to stop the drive, when it is + in data read mode, therefore I had to set + msf.end.min/sec/frame to 0:0:1 (in azt_poll); so only one + frame can be read in sequence, this is also the reason for + 3. getting 'timeout in state 4' messages, but nevertheless + it works + W.Zimmermann, Oct. 31, 1994 + V0.1 Version is ALPHA, problems #2 and #3 resolved. + W.Zimmermann, Nov. 3, 1994 + V0.2 Modification to some comments, debugging aids for partial test + with Borland C under DOS eliminated. Timer interrupt wait + STEN_LOW_WAIT additionally to busy wait for STEN_LOW implemented; + use it only for the 'slow' commands (ACMD_GET_Q_CHANNEL, ACMD_ + SEEK_TO_LEAD_IN), all other commands are so 'fast', that busy + waiting seems better to me than interrupt rescheduling. + Besides that, when used in the wrong place, STEN_LOW_WAIT causes + kernel panic. + In function aztPlay command ACMD_PLAY_AUDIO added, should make + audio functions work. The Aztech drive needs different commands + to read data tracks and play audio tracks. + W.Zimmermann, Nov. 8, 1994 + V0.3 Recognition of missing drive during boot up improved (speeded up). + W.Zimmermann, Nov. 13, 1994 + V0.35 Rewrote the control mechanism in azt_poll (formerly mcd_poll) + including removal of all 'goto' commands. :-); + J. Nardone, Nov. 14, 1994 + V0.4 Renamed variables and constants to 'azt' instead of 'mcd'; had + to make some "compatibility" defines in azt.h; please note, + that the source file was renamed to azt.c, the include file to + azt.h + Speeded up drive recognition during init (will be a little bit + slower than before if no drive is installed!); suggested by + Robby Schirmer. + read_count declared volatile and set to AZT_BUF_SIZ to make + drive faster (now 300kB/sec, was 60kB/sec before, measured + by 'time dd if=/dev/cdrom of=/dev/null bs=2048 count=4096'; + different AZT_BUF_SIZes were test, above 16 no further im- + provement seems to be possible; suggested by E.Moenkeberg. + W.Zimmermann, Nov. 18, 1994 + V0.42 Included getAztStatus command in GetQChannelInfo() to allow + reading Q-channel info on audio disks, if drive is stopped, + and some other bug fixes in the audio stuff, suggested by + Robby Schirmer. + Added more ioctls (reading data in mode 1 and mode 2). + Completely removed the old azt_poll() routine. + Detection of ORCHID CDS-3110 in aztcd_init implemented. + Additional debugging aids (see the readme file). + W.Zimmermann, Dec. 9, 1994 + V0.50 Autodetection of drives implemented. + W.Zimmermann, Dec. 12, 1994 + V0.52 Prepared for including in the standard kernel, renamed most + variables to contain 'azt', included autoconf.h + W.Zimmermann, Dec. 16, 1994 + V0.6 Version for being included in the standard Linux kernel. + Renamed source and header file to aztcd.c and aztcd.h + W.Zimmermann, Dec. 24, 1994 + V0.7 Changed VERIFY_READ to VERIFY_WRITE in aztcd_ioctl, case + CDROMREADMODE1 and CDROMREADMODE2; bug fix in the ioctl, + which causes kernel crashes when playing audio, changed + include-files (config.h instead of autoconf.h, removed + delay.h) + W.Zimmermann, Jan. 8, 1995 + V0.72 Some more modifications for adaption to the standard kernel. + W.Zimmermann, Jan. 16, 1995 + V0.80 aztcd is now part of the standard kernel since version 1.1.83. + Modified the SET_TIMER and CLEAR_TIMER macros to comply with + the new timer scheme. + W.Zimmermann, Jan. 21, 1995 + V0.90 Included CDROMVOLCTRL, but with my Aztech drive I can only turn + the channels on and off. If it works better with your drive, + please mail me. Also implemented ACMD_CLOSE for CDROMSTART. + W.Zimmermann, Jan. 24, 1995 + V1.00 Implemented close and lock tray commands. Patches supplied by + Frank Racis + Added support for loadable MODULEs, so aztcd can now also be + loaded by insmod and removed by rmmod during run time + Werner Zimmermann, Mar. 24, 95 + V1.10 Implemented soundcard configuration for Orchid CDS-3110 drives + connected to Soundwave32 cards. Release for LST 2.1. + (still experimental) + Werner Zimmermann, May 8, 95 + V1.20 Implemented limited support for DOSEMU0.60's cdrom.c. Now it works, but + sometimes DOSEMU may hang for 30 seconds or so. A fully functional ver- + sion needs an update of Dosemu0.60's cdrom.c, which will come with the + next revision of Dosemu. + Also Soundwave32 support now works. + Werner Zimmermann, May 22, 95 + V1.30 Auto-eject feature. Inspired by Franc Racis (racis@psu.edu) + Werner Zimmermann, July 4, 95 + V1.40 Started multisession support. Implementation copied from mcdx.c + by Heiko Schlittermann. Not tested yet. + Werner Zimmermann, July 15, 95 + V1.50 Implementation of ioctl CDROMRESET, continued multisession, began + XA, but still untested. Heavy modifications to drive status de- + tection. + Werner Zimmermann, July 25, 95 + V1.60 XA support now should work. Speeded up drive recognition in cases, + where no drive is installed. + Werner Zimmermann, August 8, 1995 + V1.70 Multisession support now is completed, but there is still not + enough testing done. If you can test it, please contact me. For + details please read Documentation/cdrom/aztcd + Werner Zimmermann, August 19, 1995 + V1.80 Modification to suit the new kernel boot procedure introduced + with kernel 1.3.33. Will definitely not work with older kernels. + Programming done by Linus himself. + Werner Zimmermann, October 11, 1995 + V1.90 Support for Conrad TXC drives, thank's to Jochen Kunz and Olaf Kaluza. + Werner Zimmermann, October 21, 1995 + V2.00 Changed #include "blk.h" to as the directory + structure was changed. README.aztcd is now /usr/src/docu- + mentation/cdrom/aztcd + Werner Zimmermann, November 10, 95 + V2.10 Started to modify azt_poll to prevent reading beyond end of + tracks. + Werner Zimmermann, December 3, 95 + V2.20 Changed some comments + Werner Zimmermann, April 1, 96 + V2.30 Implemented support for CyCDROM CR520, CR940, Code for CR520 + delivered by H.Berger with preworks by E.Moenkeberg. + Werner Zimmermann, April 29, 96 + V2.40 Reorganized the placement of functions in the source code file + to reflect the layered approach; did not actually change code + Werner Zimmermann, May 1, 96 + V2.50 Heiko Eissfeldt suggested to remove some VERIFY_READs in + aztcd_ioctl; check_aztcd_media_change modified + Werner Zimmermann, May 16, 96 + V2.60 Implemented Auto-Probing; made changes for kernel's 2.1.xx blocksize + Adaption to linux kernel > 2.1.0 + Werner Zimmermann, Nov 29, 97 + + November 1999 -- Make kernel-parameter implementation work with 2.3.x + Removed init_module & cleanup_module in favor of + module_init & module_exit. + Torben Mathiasen +*/ + +#include +#include "aztcd.h" + +#include +#include +#include +#include +#include +#include +#include +#include "cdrom.h" +#include +#include +#include + +#include + +#include +#include + +#include + +/*########################################################################### + Defines + ########################################################################### +*/ + +#define MAJOR_NR AZTECH_CDROM_MAJOR +#define QUEUE (azt_queue) +#define CURRENT elv_next_request(azt_queue) +#define SET_TIMER(func, jifs) delay_timer.expires = jiffies + (jifs); \ + delay_timer.function = (void *) (func); \ + add_timer(&delay_timer); + +#define CLEAR_TIMER del_timer(&delay_timer); + +#define RETURNM(message,value) {printk("aztcd: Warning: %s failed\n",message);\ + return value;} +#define RETURN(message) {printk("aztcd: Warning: %s failed\n",message);\ + return;} + +/* Macros to switch the IDE-interface to the slave device and back to the master*/ +#define SWITCH_IDE_SLAVE outb_p(0xa0,azt_port+6); \ + outb_p(0x10,azt_port+6); \ + outb_p(0x00,azt_port+7); \ + outb_p(0x10,azt_port+6); +#define SWITCH_IDE_MASTER outb_p(0xa0,azt_port+6); + + +#if 0 +#define AZT_TEST +#define AZT_TEST1 /* */ +#define AZT_TEST2 /* do_aztcd_request */ +#define AZT_TEST3 /* AZT_S_state */ +#define AZT_TEST4 /* QUICK_LOOP-counter */ +#define AZT_TEST5 /* port(1) state */ +#define AZT_DEBUG +#define AZT_DEBUG_MULTISESSION +#endif + +struct request_queue *azt_queue; + +int current_valid(void) +{ + return CURRENT && + CURRENT->cmd == READ && + CURRENT->sector != -1; +} + +#define AFL_STATUSorDATA (AFL_STATUS | AFL_DATA) +#define AZT_BUF_SIZ 16 + +#define READ_TIMEOUT 3000 + +#define azt_port aztcd /*needed for the modutils */ + +/*########################################################################## + Type Definitions + ########################################################################## +*/ +enum azt_state_e { AZT_S_IDLE, /* 0 */ + AZT_S_START, /* 1 */ + AZT_S_MODE, /* 2 */ + AZT_S_READ, /* 3 */ + AZT_S_DATA, /* 4 */ + AZT_S_STOP, /* 5 */ + AZT_S_STOPPING /* 6 */ +}; +enum azt_read_modes { AZT_MODE_0, /*read mode for audio disks, not supported by Aztech firmware */ + AZT_MODE_1, /*read mode for normal CD-ROMs */ + AZT_MODE_2 /*read mode for XA CD-ROMs */ +}; + +/*########################################################################## + Global Variables + ########################################################################## +*/ +int aztPresent = 0; + +volatile int azt_transfer_is_active = 0; + +char azt_buf[CD_FRAMESIZE_RAW * AZT_BUF_SIZ]; /*buffer for block size conversion */ +#if AZT_PRIVATE_IOCTLS +char buf[CD_FRAMESIZE_RAW]; /*separate buffer for the ioctls */ +#endif + +volatile int azt_buf_bn[AZT_BUF_SIZ], azt_next_bn; +volatile int azt_buf_in, azt_buf_out = -1; +volatile int azt_error = 0; +int azt_open_count = 0; +volatile enum azt_state_e azt_state = AZT_S_IDLE; +#ifdef AZT_TEST3 +volatile enum azt_state_e azt_state_old = AZT_S_STOP; +volatile int azt_st_old = 0; +#endif +volatile enum azt_read_modes azt_read_mode = AZT_MODE_1; + +int azt_mode = -1; +volatile int azt_read_count = 1; + +int azt_port = AZT_BASE_ADDR; + +module_param(azt_port, int, 0); + +int azt_port_auto[16] = AZT_BASE_AUTO; + +char azt_cont = 0; +char azt_init_end = 0; +char azt_auto_eject = AZT_AUTO_EJECT; + +int AztTimeout, AztTries; +DECLARE_WAIT_QUEUE_HEAD(azt_waitq); +DEFINE_TIMER(delay_timer, NULL, 0, 0); + +struct azt_DiskInfo DiskInfo; +struct azt_Toc Toc[MAX_TRACKS]; +struct azt_Play_msf azt_Play; + +int aztAudioStatus = CDROM_AUDIO_NO_STATUS; +char aztDiskChanged = 1; +char aztTocUpToDate = 0; + +unsigned char aztIndatum; +unsigned long aztTimeOutCount; +int aztCmd = 0; + +DEFINE_SPINLOCK(aztSpin); + +/*########################################################################### + Function Prototypes + ########################################################################### +*/ +/* CDROM Drive Low Level I/O Functions */ +void aztStatTimer(void); + +/* CDROM Drive Command Functions */ +int aztGetDiskInfo(void); +#if AZT_MULTISESSION +int aztGetMultiDiskInfo(void); +#endif +int aztGetToc(int multi); + +/* Kernel Interface Functions */ +int check_aztcd_media_change(struct gendisk *disk); +int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, + unsigned long arg); +int aztcd_open(struct inode *ip, struct file *fp); +int aztcd_release(struct inode *inode, struct file *file); + +struct block_device_operations azt_fops = { + .owner = THIS_MODULE, + .open = aztcd_open, + .release = aztcd_release, + .ioctl = aztcd_ioctl, + .media_changed = check_aztcd_media_change, +}; + +/* Aztcd State Machine: Controls Drive Operating State */ +void azt_poll(void); + +/* Miscellaneous support functions */ +void azt_hsg2msf(long hsg, struct msf *msf); +long azt_msf2hsg(struct msf *mp); +void azt_bin2bcd(unsigned char *p); +int azt_bcd2bin(unsigned char bcd); + +/*########################################################################## + CDROM Drive Low Level I/O Functions + ########################################################################## +*/ +/* Macros for the drive hardware interface handshake, these macros use + busy waiting */ +/* Wait for OP_OK = drive answers with AFL_OP_OK after receiving a command*/ +# define OP_OK op_ok() +void op_ok(void) +{ + aztTimeOutCount = 0; + do { + aztIndatum = inb(DATA_PORT); + aztTimeOutCount++; + if (aztTimeOutCount >= AZT_TIMEOUT) { + printk("aztcd: Error Wait OP_OK\n"); + break; + } + } while (aztIndatum != AFL_OP_OK); +} + +/* Wait for PA_OK = drive answers with AFL_PA_OK after receiving parameters*/ +#if 0 +# define PA_OK pa_ok() +void pa_ok(void) +{ + aztTimeOutCount = 0; + do { + aztIndatum = inb(DATA_PORT); + aztTimeOutCount++; + if (aztTimeOutCount >= AZT_TIMEOUT) { + printk("aztcd: Error Wait PA_OK\n"); + break; + } + } while (aztIndatum != AFL_PA_OK); +} +#endif + +/* Wait for STEN=Low = handshake signal 'AFL_.._OK available or command executed*/ +# define STEN_LOW sten_low() +void sten_low(void) +{ + aztTimeOutCount = 0; + do { + aztIndatum = inb(STATUS_PORT); + aztTimeOutCount++; + if (aztTimeOutCount >= AZT_TIMEOUT) { + if (azt_init_end) + printk + ("aztcd: Error Wait STEN_LOW commands:%x\n", + aztCmd); + break; + } + } while (aztIndatum & AFL_STATUS); +} + +/* Wait for DTEN=Low = handshake signal 'Data available'*/ +# define DTEN_LOW dten_low() +void dten_low(void) +{ + aztTimeOutCount = 0; + do { + aztIndatum = inb(STATUS_PORT); + aztTimeOutCount++; + if (aztTimeOutCount >= AZT_TIMEOUT) { + printk("aztcd: Error Wait DTEN_OK\n"); + break; + } + } while (aztIndatum & AFL_DATA); +} + +/* + * Macro for timer wait on STEN=Low, should only be used for 'slow' commands; + * may cause kernel panic when used in the wrong place +*/ +#define STEN_LOW_WAIT statusAzt() +void statusAzt(void) +{ + AztTimeout = AZT_STATUS_DELAY; + SET_TIMER(aztStatTimer, HZ / 100); + sleep_on(&azt_waitq); + if (AztTimeout <= 0) + printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n", + aztCmd); + return; +} + +void aztStatTimer(void) +{ + if (!(inb(STATUS_PORT) & AFL_STATUS)) { + wake_up(&azt_waitq); + return; + } + AztTimeout--; + if (AztTimeout <= 0) { + wake_up(&azt_waitq); + printk("aztcd: Error aztStatTimer: Timeout\n"); + return; + } + SET_TIMER(aztStatTimer, HZ / 100); +} + +/*########################################################################## + CDROM Drive Command Functions + ########################################################################## +*/ +/* + * Send a single command, return -1 on error, else 0 +*/ +int aztSendCmd(int cmd) +{ + unsigned char data; + int retry; + +#ifdef AZT_DEBUG + printk("aztcd: Executing command %x\n", cmd); +#endif + + if ((azt_port == 0x1f0) || (azt_port == 0x170)) + SWITCH_IDE_SLAVE; /*switch IDE interface to slave configuration */ + + aztCmd = cmd; + outb(POLLED, MODE_PORT); + do { + if (inb(STATUS_PORT) & AFL_STATUS) + break; + inb(DATA_PORT); /* if status left from last command, read and */ + } while (1); /* discard it */ + do { + if (inb(STATUS_PORT) & AFL_DATA) + break; + inb(DATA_PORT); /* if data left from last command, read and */ + } while (1); /* discard it */ + for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) { + outb((unsigned char) cmd, CMD_PORT); + STEN_LOW; + data = inb(DATA_PORT); + if (data == AFL_OP_OK) { + return 0; + } /*OP_OK? */ + if (data == AFL_OP_ERR) { + STEN_LOW; + data = inb(DATA_PORT); + printk + ("### Error 1 aztcd: aztSendCmd %x Error Code %x\n", + cmd, data); + } + } + if (retry >= AZT_RETRY_ATTEMPTS) { + printk("### Error 2 aztcd: aztSendCmd %x \n", cmd); + azt_error = 0xA5; + } + RETURNM("aztSendCmd", -1); +} + +/* + * Send a play or read command to the drive, return -1 on error, else 0 +*/ +int sendAztCmd(int cmd, struct azt_Play_msf *params) +{ + unsigned char data; + int retry; + +#ifdef AZT_DEBUG + printk("aztcd: play start=%02x:%02x:%02x end=%02x:%02x:%02x\n", + params->start.min, params->start.sec, params->start.frame, + params->end.min, params->end.sec, params->end.frame); +#endif + for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) { + aztSendCmd(cmd); + outb(params->start.min, CMD_PORT); + outb(params->start.sec, CMD_PORT); + outb(params->start.frame, CMD_PORT); + outb(params->end.min, CMD_PORT); + outb(params->end.sec, CMD_PORT); + outb(params->end.frame, CMD_PORT); + STEN_LOW; + data = inb(DATA_PORT); + if (data == AFL_PA_OK) { + return 0; + } /*PA_OK ? */ + if (data == AFL_PA_ERR) { + STEN_LOW; + data = inb(DATA_PORT); + printk + ("### Error 1 aztcd: sendAztCmd %x Error Code %x\n", + cmd, data); + } + } + if (retry >= AZT_RETRY_ATTEMPTS) { + printk("### Error 2 aztcd: sendAztCmd %x\n ", cmd); + azt_error = 0xA5; + } + RETURNM("sendAztCmd", -1); +} + +/* + * Send a seek command to the drive, return -1 on error, else 0 +*/ +int aztSeek(struct azt_Play_msf *params) +{ + unsigned char data; + int retry; + +#ifdef AZT_DEBUG + printk("aztcd: aztSeek %02x:%02x:%02x\n", + params->start.min, params->start.sec, params->start.frame); +#endif + for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) { + aztSendCmd(ACMD_SEEK); + outb(params->start.min, CMD_PORT); + outb(params->start.sec, CMD_PORT); + outb(params->start.frame, CMD_PORT); + STEN_LOW; + data = inb(DATA_PORT); + if (data == AFL_PA_OK) { + return 0; + } /*PA_OK ? */ + if (data == AFL_PA_ERR) { + STEN_LOW; + data = inb(DATA_PORT); + printk("### Error 1 aztcd: aztSeek\n"); + } + } + if (retry >= AZT_RETRY_ATTEMPTS) { + printk("### Error 2 aztcd: aztSeek\n "); + azt_error = 0xA5; + } + RETURNM("aztSeek", -1); +} + +/* Send a Set Disk Type command + does not seem to work with Aztech drives, behavior is completely indepen- + dent on which mode is set ??? +*/ +int aztSetDiskType(int type) +{ + unsigned char data; + int retry; + +#ifdef AZT_DEBUG + printk("aztcd: set disk type command: type= %i\n", type); +#endif + for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) { + aztSendCmd(ACMD_SET_DISK_TYPE); + outb(type, CMD_PORT); + STEN_LOW; + data = inb(DATA_PORT); + if (data == AFL_PA_OK) { /*PA_OK ? */ + azt_read_mode = type; + return 0; + } + if (data == AFL_PA_ERR) { + STEN_LOW; + data = inb(DATA_PORT); + printk + ("### Error 1 aztcd: aztSetDiskType %x Error Code %x\n", + type, data); + } + } + if (retry >= AZT_RETRY_ATTEMPTS) { + printk("### Error 2 aztcd: aztSetDiskType %x\n ", type); + azt_error = 0xA5; + } + RETURNM("aztSetDiskType", -1); +} + + +/* used in azt_poll to poll the status, expects another program to issue a + * ACMD_GET_STATUS directly before + */ +int aztStatus(void) +{ + int st; +/* int i; + + i = inb(STATUS_PORT) & AFL_STATUS; is STEN=0? ??? + if (!i) +*/ STEN_LOW; + if (aztTimeOutCount < AZT_TIMEOUT) { + st = inb(DATA_PORT) & 0xFF; + return st; + } else + RETURNM("aztStatus", -1); +} + +/* + * Get the drive status + */ +int getAztStatus(void) +{ + int st; + + if (aztSendCmd(ACMD_GET_STATUS)) + RETURNM("getAztStatus 1", -1); + STEN_LOW; + st = inb(DATA_PORT) & 0xFF; +#ifdef AZT_DEBUG + printk("aztcd: Status = %x\n", st); +#endif + if ((st == 0xFF) || (st & AST_CMD_CHECK)) { + printk + ("aztcd: AST_CMD_CHECK error or no status available\n"); + return -1; + } + + if (((st & AST_MODE_BITS) != AST_BUSY) + && (aztAudioStatus == CDROM_AUDIO_PLAY)) + /* XXX might be an error? look at q-channel? */ + aztAudioStatus = CDROM_AUDIO_COMPLETED; + + if ((st & AST_DSK_CHG) || (st & AST_NOT_READY)) { + aztDiskChanged = 1; + aztTocUpToDate = 0; + aztAudioStatus = CDROM_AUDIO_NO_STATUS; + } + return st; +} + + +/* + * Send a 'Play' command and get the status. Use only from the top half. + */ +int aztPlay(struct azt_Play_msf *arg) +{ + if (sendAztCmd(ACMD_PLAY_AUDIO, arg) < 0) + RETURNM("aztPlay", -1); + return 0; +} + +/* + * Subroutines to automatically close the door (tray) and + * lock it closed when the cd is mounted. Leave the tray + * locking as an option + */ +void aztCloseDoor(void) +{ + aztSendCmd(ACMD_CLOSE); + STEN_LOW; + return; +} + +void aztLockDoor(void) +{ +#if AZT_ALLOW_TRAY_LOCK + aztSendCmd(ACMD_LOCK); + STEN_LOW; +#endif + return; +} + +void aztUnlockDoor(void) +{ +#if AZT_ALLOW_TRAY_LOCK + aztSendCmd(ACMD_UNLOCK); + STEN_LOW; +#endif + return; +} + +/* + * Read a value from the drive. Should return quickly, so a busy wait + * is used to avoid excessive rescheduling. The read command itself must + * be issued with aztSendCmd() directly before + */ +int aztGetValue(unsigned char *result) +{ + int s; + + STEN_LOW; + if (aztTimeOutCount >= AZT_TIMEOUT) { + printk("aztcd: aztGetValue timeout\n"); + return -1; + } + s = inb(DATA_PORT) & 0xFF; + *result = (unsigned char) s; + return 0; +} + +/* + * Read the current Q-channel info. Also used for reading the + * table of contents. + */ +int aztGetQChannelInfo(struct azt_Toc *qp) +{ + unsigned char notUsed; + int st; + +#ifdef AZT_DEBUG + printk("aztcd: starting aztGetQChannelInfo Time:%li\n", jiffies); +#endif + if ((st = getAztStatus()) == -1) + RETURNM("aztGetQChannelInfo 1", -1); + if (aztSendCmd(ACMD_GET_Q_CHANNEL)) + RETURNM("aztGetQChannelInfo 2", -1); + /*STEN_LOW_WAIT; ??? Dosemu0.60's cdrom.c does not like STEN_LOW_WAIT here */ + if (aztGetValue(¬Used)) + RETURNM("aztGetQChannelInfo 3", -1); /*??? Nullbyte einlesen */ + if ((st & AST_MODE_BITS) == AST_INITIAL) { + qp->ctrl_addr = 0; /* when audio stop ACMD_GET_Q_CHANNEL returns */ + qp->track = 0; /* only one byte with Aztech drives */ + qp->pointIndex = 0; + qp->trackTime.min = 0; + qp->trackTime.sec = 0; + qp->trackTime.frame = 0; + qp->diskTime.min = 0; + qp->diskTime.sec = 0; + qp->diskTime.frame = 0; + return 0; + } else { + if (aztGetValue(&qp->ctrl_addr) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->track) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->pointIndex) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->trackTime.min) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->trackTime.sec) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->trackTime.frame) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(¬Used) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->diskTime.min) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->diskTime.sec) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + if (aztGetValue(&qp->diskTime.frame) < 0) + RETURNM("aztGetQChannelInfo 4", -1); + } +#ifdef AZT_DEBUG + printk("aztcd: exiting aztGetQChannelInfo Time:%li\n", jiffies); +#endif + return 0; +} + +/* + * Read the table of contents (TOC) and TOC header if necessary + */ +int aztUpdateToc(void) +{ + int st; + +#ifdef AZT_DEBUG + printk("aztcd: starting aztUpdateToc Time:%li\n", jiffies); +#endif + if (aztTocUpToDate) + return 0; + + if (aztGetDiskInfo() < 0) + return -EIO; + + if (aztGetToc(0) < 0) + return -EIO; + + /*audio disk detection + with my Aztech drive there is no audio status bit, so I use the copy + protection bit of the first track. If this track is copy protected + (copy bit = 0), I assume, it's an audio disk. Strange, but works ??? */ + if (!(Toc[DiskInfo.first].ctrl_addr & 0x40)) + DiskInfo.audio = 1; + else + DiskInfo.audio = 0; + + /* XA detection */ + if (!DiskInfo.audio) { + azt_Play.start.min = 0; /*XA detection only seems to work */ + azt_Play.start.sec = 2; /*when we play a track */ + azt_Play.start.frame = 0; + azt_Play.end.min = 0; + azt_Play.end.sec = 0; + azt_Play.end.frame = 1; + if (sendAztCmd(ACMD_PLAY_READ, &azt_Play)) + return -1; + DTEN_LOW; + for (st = 0; st < CD_FRAMESIZE; st++) + inb(DATA_PORT); + } + DiskInfo.xa = getAztStatus() & AST_MODE; + if (DiskInfo.xa) { + printk + ("aztcd: XA support experimental - mail results to Werner.Zimmermann@fht-esslingen.de\n"); + } + + /*multisession detection + support for multisession CDs is done automatically with Aztech drives, + we don't have to take care about TOC redirection; if we want the isofs + to take care about redirection, we have to set AZT_MULTISESSION to 1 */ + DiskInfo.multi = 0; +#if AZT_MULTISESSION + if (DiskInfo.xa) { + aztGetMultiDiskInfo(); /*here Disk.Info.multi is set */ + } +#endif + if (DiskInfo.multi) { + DiskInfo.lastSession.min = Toc[DiskInfo.next].diskTime.min; + DiskInfo.lastSession.sec = Toc[DiskInfo.next].diskTime.sec; + DiskInfo.lastSession.frame = + Toc[DiskInfo.next].diskTime.frame; + printk("aztcd: Multisession support experimental\n"); + } else { + DiskInfo.lastSession.min = + Toc[DiskInfo.first].diskTime.min; + DiskInfo.lastSession.sec = + Toc[DiskInfo.first].diskTime.sec; + DiskInfo.lastSession.frame = + Toc[DiskInfo.first].diskTime.frame; + } + + aztTocUpToDate = 1; +#ifdef AZT_DEBUG + printk("aztcd: exiting aztUpdateToc Time:%li\n", jiffies); +#endif + return 0; +} + + +/* Read the table of contents header, i.e. no. of tracks and start of first + * track + */ +int aztGetDiskInfo(void) +{ + int limit; + unsigned char test; + struct azt_Toc qInfo; + +#ifdef AZT_DEBUG + printk("aztcd: starting aztGetDiskInfo Time:%li\n", jiffies); +#endif + if (aztSendCmd(ACMD_SEEK_TO_LEADIN)) + RETURNM("aztGetDiskInfo 1", -1); + STEN_LOW_WAIT; + test = 0; + for (limit = 300; limit > 0; limit--) { + if (aztGetQChannelInfo(&qInfo) < 0) + RETURNM("aztGetDiskInfo 2", -1); + if (qInfo.pointIndex == 0xA0) { /*Number of FirstTrack */ + DiskInfo.first = qInfo.diskTime.min; + DiskInfo.first = azt_bcd2bin(DiskInfo.first); + test = test | 0x01; + } + if (qInfo.pointIndex == 0xA1) { /*Number of LastTrack */ + DiskInfo.last = qInfo.diskTime.min; + DiskInfo.last = azt_bcd2bin(DiskInfo.last); + test = test | 0x02; + } + if (qInfo.pointIndex == 0xA2) { /*DiskLength */ + DiskInfo.diskLength.min = qInfo.diskTime.min; + DiskInfo.diskLength.sec = qInfo.diskTime.sec; + DiskInfo.diskLength.frame = qInfo.diskTime.frame; + test = test | 0x04; + } + if ((qInfo.pointIndex == DiskInfo.first) && (test & 0x01)) { /*StartTime of First Track */ + DiskInfo.firstTrack.min = qInfo.diskTime.min; + DiskInfo.firstTrack.sec = qInfo.diskTime.sec; + DiskInfo.firstTrack.frame = qInfo.diskTime.frame; + test = test | 0x08; + } + if (test == 0x0F) + break; + } +#ifdef AZT_DEBUG + printk("aztcd: exiting aztGetDiskInfo Time:%li\n", jiffies); + printk + ("Disk Info: first %d last %d length %02X:%02X.%02X dez first %02X:%02X.%02X dez\n", + DiskInfo.first, DiskInfo.last, DiskInfo.diskLength.min, + DiskInfo.diskLength.sec, DiskInfo.diskLength.frame, + DiskInfo.firstTrack.min, DiskInfo.firstTrack.sec, + DiskInfo.firstTrack.frame); +#endif + if (test != 0x0F) + return -1; + return 0; +} + +#if AZT_MULTISESSION +/* + * Get Multisession Disk Info + */ +int aztGetMultiDiskInfo(void) +{ + int limit, k = 5; + unsigned char test; + struct azt_Toc qInfo; + +#ifdef AZT_DEBUG + printk("aztcd: starting aztGetMultiDiskInfo\n"); +#endif + + do { + azt_Play.start.min = Toc[DiskInfo.last + 1].diskTime.min; + azt_Play.start.sec = Toc[DiskInfo.last + 1].diskTime.sec; + azt_Play.start.frame = + Toc[DiskInfo.last + 1].diskTime.frame; + test = 0; + + for (limit = 30; limit > 0; limit--) { /*Seek for LeadIn of next session */ + if (aztSeek(&azt_Play)) + RETURNM("aztGetMultiDiskInfo 1", -1); + if (aztGetQChannelInfo(&qInfo) < 0) + RETURNM("aztGetMultiDiskInfo 2", -1); + if ((qInfo.track == 0) && (qInfo.pointIndex)) + break; /*LeadIn found */ + if ((azt_Play.start.sec += 10) > 59) { + azt_Play.start.sec = 0; + azt_Play.start.min++; + } + } + if (!limit) + break; /*Check, if a leadin track was found, if not we're + at the end of the disk */ +#ifdef AZT_DEBUG_MULTISESSION + printk("leadin found track %d pointIndex %x limit %d\n", + qInfo.track, qInfo.pointIndex, limit); +#endif + for (limit = 300; limit > 0; limit--) { + if (++azt_Play.start.frame > 74) { + azt_Play.start.frame = 0; + if (azt_Play.start.sec > 59) { + azt_Play.start.sec = 0; + azt_Play.start.min++; + } + } + if (aztSeek(&azt_Play)) + RETURNM("aztGetMultiDiskInfo 3", -1); + if (aztGetQChannelInfo(&qInfo) < 0) + RETURNM("aztGetMultiDiskInfo 4", -1); + if (qInfo.pointIndex == 0xA0) { /*Number of NextTrack */ + DiskInfo.next = qInfo.diskTime.min; + DiskInfo.next = azt_bcd2bin(DiskInfo.next); + test = test | 0x01; + } + if (qInfo.pointIndex == 0xA1) { /*Number of LastTrack */ + DiskInfo.last = qInfo.diskTime.min; + DiskInfo.last = azt_bcd2bin(DiskInfo.last); + test = test | 0x02; + } + if (qInfo.pointIndex == 0xA2) { /*DiskLength */ + DiskInfo.diskLength.min = + qInfo.diskTime.min; + DiskInfo.diskLength.sec = + qInfo.diskTime.sec; + DiskInfo.diskLength.frame = + qInfo.diskTime.frame; + test = test | 0x04; + } + if ((qInfo.pointIndex == DiskInfo.next) && (test & 0x01)) { /*StartTime of Next Track */ + DiskInfo.nextSession.min = + qInfo.diskTime.min; + DiskInfo.nextSession.sec = + qInfo.diskTime.sec; + DiskInfo.nextSession.frame = + qInfo.diskTime.frame; + test = test | 0x08; + } + if (test == 0x0F) + break; + } +#ifdef AZT_DEBUG_MULTISESSION + printk + ("MultiDisk Info: first %d next %d last %d length %02x:%02x.%02x dez first %02x:%02x.%02x dez next %02x:%02x.%02x dez\n", + DiskInfo.first, DiskInfo.next, DiskInfo.last, + DiskInfo.diskLength.min, DiskInfo.diskLength.sec, + DiskInfo.diskLength.frame, DiskInfo.firstTrack.min, + DiskInfo.firstTrack.sec, DiskInfo.firstTrack.frame, + DiskInfo.nextSession.min, DiskInfo.nextSession.sec, + DiskInfo.nextSession.frame); +#endif + if (test != 0x0F) + break; + else + DiskInfo.multi = 1; /*found TOC of more than one session */ + aztGetToc(1); + } while (--k); + +#ifdef AZT_DEBUG + printk("aztcd: exiting aztGetMultiDiskInfo Time:%li\n", jiffies); +#endif + return 0; +} +#endif + +/* + * Read the table of contents (TOC) + */ +int aztGetToc(int multi) +{ + int i, px; + int limit; + struct azt_Toc qInfo; + +#ifdef AZT_DEBUG + printk("aztcd: starting aztGetToc Time:%li\n", jiffies); +#endif + if (!multi) { + for (i = 0; i < MAX_TRACKS; i++) + Toc[i].pointIndex = 0; + i = DiskInfo.last + 3; + } else { + for (i = DiskInfo.next; i < MAX_TRACKS; i++) + Toc[i].pointIndex = 0; + i = DiskInfo.last + 4 - DiskInfo.next; + } + +/*Is there a good reason to stop motor before TOC read? + if (aztSendCmd(ACMD_STOP)) RETURNM("aztGetToc 1",-1); + STEN_LOW_WAIT; +*/ + + if (!multi) { + azt_mode = 0x05; + if (aztSendCmd(ACMD_SEEK_TO_LEADIN)) + RETURNM("aztGetToc 2", -1); + STEN_LOW_WAIT; + } + for (limit = 300; limit > 0; limit--) { + if (multi) { + if (++azt_Play.start.sec > 59) { + azt_Play.start.sec = 0; + azt_Play.start.min++; + } + if (aztSeek(&azt_Play)) + RETURNM("aztGetToc 3", -1); + } + if (aztGetQChannelInfo(&qInfo) < 0) + break; + + px = azt_bcd2bin(qInfo.pointIndex); + + if (px > 0 && px < MAX_TRACKS && qInfo.track == 0) + if (Toc[px].pointIndex == 0) { + Toc[px] = qInfo; + i--; + } + + if (i <= 0) + break; + } + + Toc[DiskInfo.last + 1].diskTime = DiskInfo.diskLength; + Toc[DiskInfo.last].trackTime = DiskInfo.diskLength; + +#ifdef AZT_DEBUG_MULTISESSION + printk("aztcd: exiting aztGetToc\n"); + for (i = 1; i <= DiskInfo.last + 1; i++) + printk + ("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X dez %02X:%02X.%02X dez\n", + i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex, + Toc[i].trackTime.min, Toc[i].trackTime.sec, + Toc[i].trackTime.frame, Toc[i].diskTime.min, + Toc[i].diskTime.sec, Toc[i].diskTime.frame); + for (i = 100; i < 103; i++) + printk + ("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X dez %02X:%02X.%02X dez\n", + i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex, + Toc[i].trackTime.min, Toc[i].trackTime.sec, + Toc[i].trackTime.frame, Toc[i].diskTime.min, + Toc[i].diskTime.sec, Toc[i].diskTime.frame); +#endif + + return limit > 0 ? 0 : -1; +} + + +/*########################################################################## + Kernel Interface Functions + ########################################################################## +*/ + +#ifndef MODULE +int __init aztcd_setup(char *str) +{ + int ints[4]; + + (void) get_options(str, ARRAY_SIZE(ints), ints); + + if (ints[0] > 0) + azt_port = ints[1]; + if (ints[1] > 1) + azt_cont = ints[2]; + return 1; +} + +__setup("aztcd=", aztcd_setup); + +#endif /* !MODULE */ + +/* + * Checking if the media has been changed +*/ +int check_aztcd_media_change(struct gendisk *disk) +{ + if (aztDiskChanged) { /* disk changed */ + aztDiskChanged = 0; + return 1; + } else + return 0; /* no change */ +} + +/* + * Kernel IO-controls +*/ +int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, + unsigned long arg) +{ + int i; + struct azt_Toc qInfo; + struct cdrom_ti ti; + struct cdrom_tochdr tocHdr; + struct cdrom_msf msf; + struct cdrom_tocentry entry; + struct azt_Toc *tocPtr; + struct cdrom_subchnl subchnl; + struct cdrom_volctrl volctrl; + void __user *argp = (void __user *)arg; + +#ifdef AZT_DEBUG + printk("aztcd: starting aztcd_ioctl - Command:%x Time: %li\n", + cmd, jiffies); + printk("aztcd Status %x\n", getAztStatus()); +#endif + if (!ip) + RETURNM("aztcd_ioctl 1", -EINVAL); + if (getAztStatus() < 0) + RETURNM("aztcd_ioctl 2", -EIO); + if ((!aztTocUpToDate) || (aztDiskChanged)) { + if ((i = aztUpdateToc()) < 0) + RETURNM("aztcd_ioctl 3", i); /* error reading TOC */ + } + + switch (cmd) { + case CDROMSTART: /* Spin up the drive. Don't know, what to do, + at least close the tray */ +#if AZT_PRIVATE_IOCTLS + if (aztSendCmd(ACMD_CLOSE)) + RETURNM("aztcd_ioctl 4", -1); + STEN_LOW_WAIT; +#endif + break; + case CDROMSTOP: /* Spin down the drive */ + if (aztSendCmd(ACMD_STOP)) + RETURNM("aztcd_ioctl 5", -1); + STEN_LOW_WAIT; + /* should we do anything if it fails? */ + aztAudioStatus = CDROM_AUDIO_NO_STATUS; + break; + case CDROMPAUSE: /* Pause the drive */ + if (aztAudioStatus != CDROM_AUDIO_PLAY) + return -EINVAL; + + if (aztGetQChannelInfo(&qInfo) < 0) { /* didn't get q channel info */ + aztAudioStatus = CDROM_AUDIO_NO_STATUS; + RETURNM("aztcd_ioctl 7", 0); + } + azt_Play.start = qInfo.diskTime; /* remember restart point */ + + if (aztSendCmd(ACMD_PAUSE)) + RETURNM("aztcd_ioctl 8", -1); + STEN_LOW_WAIT; + aztAudioStatus = CDROM_AUDIO_PAUSED; + break; + case CDROMRESUME: /* Play it again, Sam */ + if (aztAudioStatus != CDROM_AUDIO_PAUSED) + return -EINVAL; + /* restart the drive at the saved position. */ + i = aztPlay(&azt_Play); + if (i < 0) { + aztAudioStatus = CDROM_AUDIO_ERROR; + return -EIO; + } + aztAudioStatus = CDROM_AUDIO_PLAY; + break; + case CDROMMULTISESSION: /*multisession support -- experimental */ + { + struct cdrom_multisession ms; +#ifdef AZT_DEBUG + printk("aztcd ioctl MULTISESSION\n"); +#endif + if (copy_from_user(&ms, argp, + sizeof(struct cdrom_multisession))) + return -EFAULT; + if (ms.addr_format == CDROM_MSF) { + ms.addr.msf.minute = + azt_bcd2bin(DiskInfo.lastSession.min); + ms.addr.msf.second = + azt_bcd2bin(DiskInfo.lastSession.sec); + ms.addr.msf.frame = + azt_bcd2bin(DiskInfo.lastSession. + frame); + } else if (ms.addr_format == CDROM_LBA) + ms.addr.lba = + azt_msf2hsg(&DiskInfo.lastSession); + else + return -EINVAL; + ms.xa_flag = DiskInfo.xa; + if (copy_to_user(argp, &ms, + sizeof(struct cdrom_multisession))) + return -EFAULT; +#ifdef AZT_DEBUG + if (ms.addr_format == CDROM_MSF) + printk + ("aztcd multisession xa:%d, msf:%02x:%02x.%02x [%02x:%02x.%02x])\n", + ms.xa_flag, ms.addr.msf.minute, + ms.addr.msf.second, ms.addr.msf.frame, + DiskInfo.lastSession.min, + DiskInfo.lastSession.sec, + DiskInfo.lastSession.frame); + else + printk + ("aztcd multisession %d, lba:0x%08x [%02x:%02x.%02x])\n", + ms.xa_flag, ms.addr.lba, + DiskInfo.lastSession.min, + DiskInfo.lastSession.sec, + DiskInfo.lastSession.frame); +#endif + return 0; + } + case CDROMPLAYTRKIND: /* Play a track. This currently ignores index. */ + if (copy_from_user(&ti, argp, sizeof ti)) + return -EFAULT; + if (ti.cdti_trk0 < DiskInfo.first + || ti.cdti_trk0 > DiskInfo.last + || ti.cdti_trk1 < ti.cdti_trk0) { + return -EINVAL; + } + if (ti.cdti_trk1 > DiskInfo.last) + ti.cdti_trk1 = DiskInfo.last; + azt_Play.start = Toc[ti.cdti_trk0].diskTime; + azt_Play.end = Toc[ti.cdti_trk1 + 1].diskTime; +#ifdef AZT_DEBUG + printk("aztcd play: %02x:%02x.%02x to %02x:%02x.%02x\n", + azt_Play.start.min, azt_Play.start.sec, + azt_Play.start.frame, azt_Play.end.min, + azt_Play.end.sec, azt_Play.end.frame); +#endif + i = aztPlay(&azt_Play); + if (i < 0) { + aztAudioStatus = CDROM_AUDIO_ERROR; + return -EIO; + } + aztAudioStatus = CDROM_AUDIO_PLAY; + break; + case CDROMPLAYMSF: /* Play starting at the given MSF address. */ +/* if (aztAudioStatus == CDROM_AUDIO_PLAY) + { if (aztSendCmd(ACMD_STOP)) RETURNM("aztcd_ioctl 9",-1); + STEN_LOW; + aztAudioStatus = CDROM_AUDIO_NO_STATUS; + } +*/ + if (copy_from_user(&msf, argp, sizeof msf)) + return -EFAULT; + /* convert to bcd */ + azt_bin2bcd(&msf.cdmsf_min0); + azt_bin2bcd(&msf.cdmsf_sec0); + azt_bin2bcd(&msf.cdmsf_frame0); + azt_bin2bcd(&msf.cdmsf_min1); + azt_bin2bcd(&msf.cdmsf_sec1); + azt_bin2bcd(&msf.cdmsf_frame1); + azt_Play.start.min = msf.cdmsf_min0; + azt_Play.start.sec = msf.cdmsf_sec0; + azt_Play.start.frame = msf.cdmsf_frame0; + azt_Play.end.min = msf.cdmsf_min1; + azt_Play.end.sec = msf.cdmsf_sec1; + azt_Play.end.frame = msf.cdmsf_frame1; +#ifdef AZT_DEBUG + printk("aztcd play: %02x:%02x.%02x to %02x:%02x.%02x\n", + azt_Play.start.min, azt_Play.start.sec, + azt_Play.start.frame, azt_Play.end.min, + azt_Play.end.sec, azt_Play.end.frame); +#endif + i = aztPlay(&azt_Play); + if (i < 0) { + aztAudioStatus = CDROM_AUDIO_ERROR; + return -EIO; + } + aztAudioStatus = CDROM_AUDIO_PLAY; + break; + + case CDROMREADTOCHDR: /* Read the table of contents header */ + tocHdr.cdth_trk0 = DiskInfo.first; + tocHdr.cdth_trk1 = DiskInfo.last; + if (copy_to_user(argp, &tocHdr, sizeof tocHdr)) + return -EFAULT; + break; + case CDROMREADTOCENTRY: /* Read an entry in the table of contents */ + if (copy_from_user(&entry, argp, sizeof entry)) + return -EFAULT; + if ((!aztTocUpToDate) || aztDiskChanged) + aztUpdateToc(); + if (entry.cdte_track == CDROM_LEADOUT) + tocPtr = &Toc[DiskInfo.last + 1]; + else if (entry.cdte_track > DiskInfo.last + || entry.cdte_track < DiskInfo.first) { + return -EINVAL; + } else + tocPtr = &Toc[entry.cdte_track]; + entry.cdte_adr = tocPtr->ctrl_addr; + entry.cdte_ctrl = tocPtr->ctrl_addr >> 4; + if (entry.cdte_format == CDROM_LBA) + entry.cdte_addr.lba = + azt_msf2hsg(&tocPtr->diskTime); + else if (entry.cdte_format == CDROM_MSF) { + entry.cdte_addr.msf.minute = + azt_bcd2bin(tocPtr->diskTime.min); + entry.cdte_addr.msf.second = + azt_bcd2bin(tocPtr->diskTime.sec); + entry.cdte_addr.msf.frame = + azt_bcd2bin(tocPtr->diskTime.frame); + } else { + return -EINVAL; + } + if (copy_to_user(argp, &entry, sizeof entry)) + return -EFAULT; + break; + case CDROMSUBCHNL: /* Get subchannel info */ + if (copy_from_user + (&subchnl, argp, sizeof(struct cdrom_subchnl))) + return -EFAULT; + if (aztGetQChannelInfo(&qInfo) < 0) { +#ifdef AZT_DEBUG + printk + ("aztcd: exiting aztcd_ioctl - Error 3 - Command:%x\n", + cmd); +#endif + return -EIO; + } + subchnl.cdsc_audiostatus = aztAudioStatus; + subchnl.cdsc_adr = qInfo.ctrl_addr; + subchnl.cdsc_ctrl = qInfo.ctrl_addr >> 4; + subchnl.cdsc_trk = azt_bcd2bin(qInfo.track); + subchnl.cdsc_ind = azt_bcd2bin(qInfo.pointIndex); + if (subchnl.cdsc_format == CDROM_LBA) { + subchnl.cdsc_absaddr.lba = + azt_msf2hsg(&qInfo.diskTime); + subchnl.cdsc_reladdr.lba = + azt_msf2hsg(&qInfo.trackTime); + } else { /*default */ + subchnl.cdsc_format = CDROM_MSF; + subchnl.cdsc_absaddr.msf.minute = + azt_bcd2bin(qInfo.diskTime.min); + subchnl.cdsc_absaddr.msf.second = + azt_bcd2bin(qInfo.diskTime.sec); + subchnl.cdsc_absaddr.msf.frame = + azt_bcd2bin(qInfo.diskTime.frame); + subchnl.cdsc_reladdr.msf.minute = + azt_bcd2bin(qInfo.trackTime.min); + subchnl.cdsc_reladdr.msf.second = + azt_bcd2bin(qInfo.trackTime.sec); + subchnl.cdsc_reladdr.msf.frame = + azt_bcd2bin(qInfo.trackTime.frame); + } + if (copy_to_user(argp, &subchnl, sizeof(struct cdrom_subchnl))) + return -EFAULT; + break; + case CDROMVOLCTRL: /* Volume control + * With my Aztech CD268-01A volume control does not work, I can only + turn the channels on (any value !=0) or off (value==0). Maybe it + works better with your drive */ + if (copy_from_user(&volctrl, argp, sizeof(volctrl))) + return -EFAULT; + azt_Play.start.min = 0x21; + azt_Play.start.sec = 0x84; + azt_Play.start.frame = volctrl.channel0; + azt_Play.end.min = volctrl.channel1; + azt_Play.end.sec = volctrl.channel2; + azt_Play.end.frame = volctrl.channel3; + sendAztCmd(ACMD_SET_VOLUME, &azt_Play); + STEN_LOW_WAIT; + break; + case CDROMEJECT: + aztUnlockDoor(); /* Assume user knows what they're doing */ + /* all drives can at least stop! */ + if (aztAudioStatus == CDROM_AUDIO_PLAY) { + if (aztSendCmd(ACMD_STOP)) + RETURNM("azt_ioctl 10", -1); + STEN_LOW_WAIT; + } + if (aztSendCmd(ACMD_EJECT)) + RETURNM("azt_ioctl 11", -1); + STEN_LOW_WAIT; + aztAudioStatus = CDROM_AUDIO_NO_STATUS; + break; + case CDROMEJECT_SW: + azt_auto_eject = (char) arg; + break; + case CDROMRESET: + outb(ACMD_SOFT_RESET, CMD_PORT); /*send reset */ + STEN_LOW; + if (inb(DATA_PORT) != AFL_OP_OK) { /*OP_OK? */ + printk + ("aztcd: AZTECH CD-ROM drive does not respond\n"); + } + break; +/*Take care, the following code is not compatible with other CD-ROM drivers, + use it at your own risk with cdplay.c. Set AZT_PRIVATE_IOCTLS to 0 in aztcd.h, + if you do not want to use it! +*/ +#if AZT_PRIVATE_IOCTLS + case CDROMREADCOOKED: /*read data in mode 1 (2048 Bytes) */ + case CDROMREADRAW: /*read data in mode 2 (2336 Bytes) */ + { + if (copy_from_user(&msf, argp, sizeof msf)) + return -EFAULT; + /* convert to bcd */ + azt_bin2bcd(&msf.cdmsf_min0); + azt_bin2bcd(&msf.cdmsf_sec0); + azt_bin2bcd(&msf.cdmsf_frame0); + msf.cdmsf_min1 = 0; + msf.cdmsf_sec1 = 0; + msf.cdmsf_frame1 = 1; /*read only one frame */ + azt_Play.start.min = msf.cdmsf_min0; + azt_Play.start.sec = msf.cdmsf_sec0; + azt_Play.start.frame = msf.cdmsf_frame0; + azt_Play.end.min = msf.cdmsf_min1; + azt_Play.end.sec = msf.cdmsf_sec1; + azt_Play.end.frame = msf.cdmsf_frame1; + if (cmd == CDROMREADRAW) { + if (DiskInfo.xa) { + return -1; /*XA Disks can't be read raw */ + } else { + if (sendAztCmd(ACMD_PLAY_READ_RAW, &azt_Play)) + return -1; + DTEN_LOW; + insb(DATA_PORT, buf, CD_FRAMESIZE_RAW); + if (copy_to_user(argp, &buf, CD_FRAMESIZE_RAW)) + return -EFAULT; + } + } else + /*CDROMREADCOOKED*/ { + if (sendAztCmd(ACMD_PLAY_READ, &azt_Play)) + return -1; + DTEN_LOW; + insb(DATA_PORT, buf, CD_FRAMESIZE); + if (copy_to_user(argp, &buf, CD_FRAMESIZE)) + return -EFAULT; + } + } + break; + case CDROMSEEK: /*seek msf address */ + if (copy_from_user(&msf, argp, sizeof msf)) + return -EFAULT; + /* convert to bcd */ + azt_bin2bcd(&msf.cdmsf_min0); + azt_bin2bcd(&msf.cdmsf_sec0); + azt_bin2bcd(&msf.cdmsf_frame0); + azt_Play.start.min = msf.cdmsf_min0; + azt_Play.start.sec = msf.cdmsf_sec0; + azt_Play.start.frame = msf.cdmsf_frame0; + if (aztSeek(&azt_Play)) + return -1; + break; +#endif /*end of incompatible code */ + case CDROMREADMODE1: /*set read data in mode 1 */ + return aztSetDiskType(AZT_MODE_1); + case CDROMREADMODE2: /*set read data in mode 2 */ + return aztSetDiskType(AZT_MODE_2); + default: + return -EINVAL; + } +#ifdef AZT_DEBUG + printk("aztcd: exiting aztcd_ioctl Command:%x Time:%li\n", cmd, + jiffies); +#endif + return 0; +} + +/* + * Take care of the different block sizes between cdrom and Linux. + * When Linux gets variable block sizes this will probably go away. + */ +void azt_transfer(void) +{ +#ifdef AZT_TEST + printk("aztcd: executing azt_transfer Time:%li\n", jiffies); +#endif + if (!current_valid()) + return; + + while (CURRENT->nr_sectors) { + int bn = CURRENT->sector / 4; + int i; + for (i = 0; i < AZT_BUF_SIZ && azt_buf_bn[i] != bn; ++i); + if (i < AZT_BUF_SIZ) { + int offs = (i * 4 + (CURRENT->sector & 3)) * 512; + int nr_sectors = 4 - (CURRENT->sector & 3); + if (azt_buf_out != i) { + azt_buf_out = i; + if (azt_buf_bn[i] != bn) { + azt_buf_out = -1; + continue; + } + } + if (nr_sectors > CURRENT->nr_sectors) + nr_sectors = CURRENT->nr_sectors; + memcpy(CURRENT->buffer, azt_buf + offs, + nr_sectors * 512); + CURRENT->nr_sectors -= nr_sectors; + CURRENT->sector += nr_sectors; + CURRENT->buffer += nr_sectors * 512; + } else { + azt_buf_out = -1; + break; + } + } +} + +void do_aztcd_request(request_queue_t * q) +{ +#ifdef AZT_TEST + printk(" do_aztcd_request(%ld+%ld) Time:%li\n", CURRENT->sector, + CURRENT->nr_sectors, jiffies); +#endif + if (DiskInfo.audio) { + printk("aztcd: Error, tried to mount an Audio CD\n"); + end_request(CURRENT, 0); + return; + } + azt_transfer_is_active = 1; + while (current_valid()) { + azt_transfer(); + if (CURRENT->nr_sectors == 0) { + end_request(CURRENT, 1); + } else { + azt_buf_out = -1; /* Want to read a block not in buffer */ + if (azt_state == AZT_S_IDLE) { + if ((!aztTocUpToDate) || aztDiskChanged) { + if (aztUpdateToc() < 0) { + while (current_valid()) + end_request(CURRENT, 0); + break; + } + } + azt_state = AZT_S_START; + AztTries = 5; + SET_TIMER(azt_poll, HZ / 100); + } + break; + } + } + azt_transfer_is_active = 0; +#ifdef AZT_TEST2 + printk + ("azt_next_bn:%x azt_buf_in:%x azt_buf_out:%x azt_buf_bn:%x\n", + azt_next_bn, azt_buf_in, azt_buf_out, azt_buf_bn[azt_buf_in]); + printk(" do_aztcd_request ends Time:%li\n", jiffies); +#endif +} + + +void azt_invalidate_buffers(void) +{ + int i; + +#ifdef AZT_DEBUG + printk("aztcd: executing azt_invalidate_buffers\n"); +#endif + for (i = 0; i < AZT_BUF_SIZ; ++i) + azt_buf_bn[i] = -1; + azt_buf_out = -1; +} + +/* + * Open the device special file. Check that a disk is in. + */ +int aztcd_open(struct inode *ip, struct file *fp) +{ + int st; + +#ifdef AZT_DEBUG + printk("aztcd: starting aztcd_open\n"); +#endif + + if (aztPresent == 0) + return -ENXIO; /* no hardware */ + + if (!azt_open_count && azt_state == AZT_S_IDLE) { + azt_invalidate_buffers(); + + st = getAztStatus(); /* check drive status */ + if (st == -1) + goto err_out; /* drive doesn't respond */ + + if (st & AST_DOOR_OPEN) { /* close door, then get the status again. */ + printk("aztcd: Door Open?\n"); + aztCloseDoor(); + st = getAztStatus(); + } + + if ((st & AST_NOT_READY) || (st & AST_DSK_CHG)) { /*no disk in drive or changed */ + printk + ("aztcd: Disk Changed or No Disk in Drive?\n"); + aztTocUpToDate = 0; + } + if (aztUpdateToc()) + goto err_out; + + } + ++azt_open_count; + aztLockDoor(); + +#ifdef AZT_DEBUG + printk("aztcd: exiting aztcd_open\n"); +#endif + return 0; + + err_out: + return -EIO; +} + + +/* + * On close, we flush all azt blocks from the buffer cache. + */ +int aztcd_release(struct inode *inode, struct file *file) +{ +#ifdef AZT_DEBUG + printk("aztcd: executing aztcd_release\n"); + printk("inode: %p, device: %s file: %p\n", inode, + inode->i_bdev->bd_disk->disk_name, file); +#endif + if (!--azt_open_count) { + azt_invalidate_buffers(); + aztUnlockDoor(); + if (azt_auto_eject) + aztSendCmd(ACMD_EJECT); + CLEAR_TIMER; + } + return 0; +} + +struct gendisk *azt_disk; + +/* + * Test for presence of drive and initialize it. Called at boot time. + */ + +int __init aztcd_init(void) +{ + long int count, max_count; + unsigned char result[50]; + int st; + void* status = NULL; + int i = 0; + int ret = 0; + + if (azt_port == 0) { + printk(KERN_INFO "aztcd: no Aztech CD-ROM Initialization"); + return -EIO; + } + + printk(KERN_INFO "aztcd: AZTECH, ORCHID, OKANO, WEARNES, TXC, CyDROM " + "CD-ROM Driver\n"); + printk(KERN_INFO "aztcd: (C) 1994-98 W.Zimmermann\n"); + if (azt_port == -1) { + printk + ("aztcd: DriverVersion=%s For IDE/ATAPI-drives use ide-cd.c\n", + AZT_VERSION); + } else + printk + ("aztcd: DriverVersion=%s BaseAddress=0x%x For IDE/ATAPI-drives use ide-cd.c\n", + AZT_VERSION, azt_port); + printk(KERN_INFO "aztcd: If you have problems, read /usr/src/linux/" + "Documentation/cdrom/aztcd\n"); + + +#ifdef AZT_SW32 /*CDROM connected to Soundwave32 card */ + if ((0xFF00 & inw(AZT_SW32_ID_REG)) != 0x4500) { + printk + ("aztcd: no Soundwave32 card detected at base:%x init:%x config:%x id:%x\n", + AZT_SW32_BASE_ADDR, AZT_SW32_INIT, + AZT_SW32_CONFIG_REG, AZT_SW32_ID_REG); + return -EIO; + } else { + printk(KERN_INFO + "aztcd: Soundwave32 card detected at %x Version %x\n", + AZT_SW32_BASE_ADDR, inw(AZT_SW32_ID_REG)); + outw(AZT_SW32_INIT, AZT_SW32_CONFIG_REG); + for (count = 0; count < 10000; count++); /*delay a bit */ + } +#endif + + /* check for presence of drive */ + + if (azt_port == -1) { /* autoprobing for proprietary interface */ + for (i = 0; (azt_port_auto[i] != 0) && (i < 16); i++) { + azt_port = azt_port_auto[i]; + printk(KERN_INFO "aztcd: Autoprobing BaseAddress=0x%x" + "\n", azt_port); + /*proprietary interfaces need 4 bytes */ + if (!request_region(azt_port, 4, "aztcd")) { + continue; + } + outb(POLLED, MODE_PORT); + inb(CMD_PORT); + inb(CMD_PORT); + outb(ACMD_GET_VERSION, CMD_PORT); /*Try to get version info */ + + aztTimeOutCount = 0; + do { + aztIndatum = inb(STATUS_PORT); + aztTimeOutCount++; + if (aztTimeOutCount >= AZT_FAST_TIMEOUT) + break; + } while (aztIndatum & AFL_STATUS); + if (inb(DATA_PORT) == AFL_OP_OK) { /* OK drive found */ + break; + } + else { /* Drive not found on this port - try next one */ + release_region(azt_port, 4); + } + } + if ((azt_port_auto[i] == 0) || (i == 16)) { + printk(KERN_INFO "aztcd: no AZTECH CD-ROM drive found\n"); + return -EIO; + } + } else { /* no autoprobing */ + if ((azt_port == 0x1f0) || (azt_port == 0x170)) + status = request_region(azt_port, 8, "aztcd"); /*IDE-interfaces need 8 bytes */ + else + status = request_region(azt_port, 4, "aztcd"); /*proprietary interfaces need 4 bytes */ + if (!status) { + printk(KERN_WARNING "aztcd: conflict, I/O port (%X) " + "already used\n", azt_port); + return -EIO; + } + + if ((azt_port == 0x1f0) || (azt_port == 0x170)) + SWITCH_IDE_SLAVE; /*switch IDE interface to slave configuration */ + + outb(POLLED, MODE_PORT); + inb(CMD_PORT); + inb(CMD_PORT); + outb(ACMD_GET_VERSION, CMD_PORT); /*Try to get version info */ + + aztTimeOutCount = 0; + do { + aztIndatum = inb(STATUS_PORT); + aztTimeOutCount++; + if (aztTimeOutCount >= AZT_FAST_TIMEOUT) + break; + } while (aztIndatum & AFL_STATUS); + + if (inb(DATA_PORT) != AFL_OP_OK) { /*OP_OK? If not, reset and try again */ +#ifndef MODULE + if (azt_cont != 0x79) { + printk(KERN_WARNING "aztcd: no AZTECH CD-ROM " + "drive found-Try boot parameter aztcd=" + ",0x79\n"); + ret = -EIO; + goto err_out; + } +#else + if (0) { + } +#endif + else { + printk(KERN_INFO "aztcd: drive reset - " + "please wait\n"); + for (count = 0; count < 50; count++) { + inb(STATUS_PORT); /*removing all data from earlier tries */ + inb(DATA_PORT); + } + outb(POLLED, MODE_PORT); + inb(CMD_PORT); + inb(CMD_PORT); + getAztStatus(); /*trap errors */ + outb(ACMD_SOFT_RESET, CMD_PORT); /*send reset */ + STEN_LOW; + if (inb(DATA_PORT) != AFL_OP_OK) { /*OP_OK? */ + printk(KERN_WARNING "aztcd: no AZTECH " + "CD-ROM drive found\n"); + ret = -EIO; + goto err_out; + } + + for (count = 0; count < AZT_TIMEOUT; + count++) + barrier(); /* Stop gcc 2.96 being smart */ + /* use udelay(), damnit -- AV */ + + if ((st = getAztStatus()) == -1) { + printk(KERN_WARNING "aztcd: Drive Status" + " Error Status=%x\n", st); + ret = -EIO; + goto err_out; + } +#ifdef AZT_DEBUG + printk(KERN_DEBUG "aztcd: Status = %x\n", st); +#endif + outb(POLLED, MODE_PORT); + inb(CMD_PORT); + inb(CMD_PORT); + outb(ACMD_GET_VERSION, CMD_PORT); /*GetVersion */ + STEN_LOW; + OP_OK; + } + } + } + + azt_init_end = 1; + STEN_LOW; + result[0] = inb(DATA_PORT); /*reading in a null byte??? */ + for (count = 1; count < 50; count++) { /*Reading version string */ + aztTimeOutCount = 0; /*here we must implement STEN_LOW differently */ + do { + aztIndatum = inb(STATUS_PORT); /*because we want to exit by timeout */ + aztTimeOutCount++; + if (aztTimeOutCount >= AZT_FAST_TIMEOUT) + break; + } while (aztIndatum & AFL_STATUS); + if (aztTimeOutCount >= AZT_FAST_TIMEOUT) + break; /*all chars read? */ + result[count] = inb(DATA_PORT); + } + if (count > 30) + max_count = 30; /*print max.30 chars of the version string */ + else + max_count = count; + printk(KERN_INFO "aztcd: FirmwareVersion="); + for (count = 1; count < max_count; count++) + printk("%c", result[count]); + printk("<<>> "); + + if ((result[1] == 'A') && (result[2] == 'Z') && (result[3] == 'T')) { + printk("AZTECH drive detected\n"); + /*AZTECH*/} + else if ((result[2] == 'C') && (result[3] == 'D') + && (result[4] == 'D')) { + printk("ORCHID or WEARNES drive detected\n"); /*ORCHID or WEARNES */ + } else if ((result[1] == 0x03) && (result[2] == '5')) { + printk("TXC or CyCDROM drive detected\n"); /*Conrad TXC, CyCDROM */ + } else { /*OTHERS or none */ + printk("\nunknown drive or firmware version detected\n"); + printk + ("aztcd may not run stable, if you want to try anyhow,\n"); + printk("boot with: aztcd=,0x79\n"); + if ((azt_cont != 0x79)) { + printk("aztcd: FirmwareVersion="); + for (count = 1; count < 5; count++) + printk("%c", result[count]); + printk("<<>> "); + printk("Aborted\n"); + ret = -EIO; + goto err_out; + } + } + azt_disk = alloc_disk(1); + if (!azt_disk) + goto err_out; + + if (register_blkdev(MAJOR_NR, "aztcd")) { + ret = -EIO; + goto err_out2; + } + + azt_queue = blk_init_queue(do_aztcd_request, &aztSpin); + if (!azt_queue) { + ret = -ENOMEM; + goto err_out3; + } + + blk_queue_hardsect_size(azt_queue, 2048); + azt_disk->major = MAJOR_NR; + azt_disk->first_minor = 0; + azt_disk->fops = &azt_fops; + sprintf(azt_disk->disk_name, "aztcd"); + sprintf(azt_disk->devfs_name, "aztcd"); + azt_disk->queue = azt_queue; + add_disk(azt_disk); + azt_invalidate_buffers(); + aztPresent = 1; + aztCloseDoor(); + return 0; +err_out3: + unregister_blkdev(MAJOR_NR, "aztcd"); +err_out2: + put_disk(azt_disk); +err_out: + if ((azt_port == 0x1f0) || (azt_port == 0x170)) { + SWITCH_IDE_MASTER; + release_region(azt_port, 8); /*IDE-interface */ + } else + release_region(azt_port, 4); /*proprietary interface */ + return ret; + +} + +void __exit aztcd_exit(void) +{ + del_gendisk(azt_disk); + put_disk(azt_disk); + if ((unregister_blkdev(MAJOR_NR, "aztcd") == -EINVAL)) { + printk("What's that: can't unregister aztcd\n"); + return; + } + blk_cleanup_queue(azt_queue); + if ((azt_port == 0x1f0) || (azt_port == 0x170)) { + SWITCH_IDE_MASTER; + release_region(azt_port, 8); /*IDE-interface */ + } else + release_region(azt_port, 4); /*proprietary interface */ + printk(KERN_INFO "aztcd module released.\n"); +} + +module_init(aztcd_init); +module_exit(aztcd_exit); + +/*########################################################################## + Aztcd State Machine: Controls Drive Operating State + ########################################################################## +*/ +void azt_poll(void) +{ + int st = 0; + int loop_ctl = 1; + int skip = 0; + + if (azt_error) { + if (aztSendCmd(ACMD_GET_ERROR)) + RETURN("azt_poll 1"); + STEN_LOW; + azt_error = inb(DATA_PORT) & 0xFF; + printk("aztcd: I/O error 0x%02x\n", azt_error); + azt_invalidate_buffers(); +#ifdef WARN_IF_READ_FAILURE + if (AztTries == 5) + printk + ("aztcd: Read of Block %d Failed - Maybe Audio Disk?\n", + azt_next_bn); +#endif + if (!AztTries--) { + printk + ("aztcd: Read of Block %d Failed, Maybe Audio Disk? Giving up\n", + azt_next_bn); + if (azt_transfer_is_active) { + AztTries = 0; + loop_ctl = 0; + } + if (current_valid()) + end_request(CURRENT, 0); + AztTries = 5; + } + azt_error = 0; + azt_state = AZT_S_STOP; + } + + while (loop_ctl) { + loop_ctl = 0; /* each case must flip this back to 1 if we want + to come back up here */ + switch (azt_state) { + + case AZT_S_IDLE: +#ifdef AZT_TEST3 + if (azt_state != azt_state_old) { + azt_state_old = azt_state; + printk("AZT_S_IDLE\n"); + } +#endif + return; + + case AZT_S_START: +#ifdef AZT_TEST3 + if (azt_state != azt_state_old) { + azt_state_old = azt_state; + printk("AZT_S_START\n"); + } +#endif + if (aztSendCmd(ACMD_GET_STATUS)) + RETURN("azt_poll 2"); /*result will be checked by aztStatus() */ + azt_state = + azt_mode == 1 ? AZT_S_READ : AZT_S_MODE; + AztTimeout = 3000; + break; + + case AZT_S_MODE: +#ifdef AZT_TEST3 + if (azt_state != azt_state_old) { + azt_state_old = azt_state; + printk("AZT_S_MODE\n"); + } +#endif + if (!skip) { + if ((st = aztStatus()) != -1) { + if ((st & AST_DSK_CHG) + || (st & AST_NOT_READY)) { + aztDiskChanged = 1; + aztTocUpToDate = 0; + azt_invalidate_buffers(); + end_request(CURRENT, 0); + printk + ("aztcd: Disk Changed or Not Ready 1 - Unmount Disk!\n"); + } + } else + break; + } + skip = 0; + + if ((st & AST_DOOR_OPEN) || (st & AST_NOT_READY)) { + aztDiskChanged = 1; + aztTocUpToDate = 0; + printk + ("aztcd: Disk Changed or Not Ready 2 - Unmount Disk!\n"); + end_request(CURRENT, 0); + printk((st & AST_DOOR_OPEN) ? + "aztcd: door open\n" : + "aztcd: disk removed\n"); + if (azt_transfer_is_active) { + azt_state = AZT_S_START; + loop_ctl = 1; /* goto immediately */ + break; + } + azt_state = AZT_S_IDLE; + while (current_valid()) + end_request(CURRENT, 0); + return; + } + +/* if (aztSendCmd(ACMD_SET_MODE)) RETURN("azt_poll 3"); + outb(0x01, DATA_PORT); + PA_OK; + STEN_LOW; +*/ + if (aztSendCmd(ACMD_GET_STATUS)) + RETURN("azt_poll 4"); + STEN_LOW; + azt_mode = 1; + azt_state = AZT_S_READ; + AztTimeout = 3000; + + break; + + + case AZT_S_READ: +#ifdef AZT_TEST3 + if (azt_state != azt_state_old) { + azt_state_old = azt_state; + printk("AZT_S_READ\n"); + } +#endif + if (!skip) { + if ((st = aztStatus()) != -1) { + if ((st & AST_DSK_CHG) + || (st & AST_NOT_READY)) { + aztDiskChanged = 1; + aztTocUpToDate = 0; + azt_invalidate_buffers(); + printk + ("aztcd: Disk Changed or Not Ready 3 - Unmount Disk!\n"); + end_request(CURRENT, 0); + } + } else + break; + } + + skip = 0; + if ((st & AST_DOOR_OPEN) || (st & AST_NOT_READY)) { + aztDiskChanged = 1; + aztTocUpToDate = 0; + printk((st & AST_DOOR_OPEN) ? + "aztcd: door open\n" : + "aztcd: disk removed\n"); + if (azt_transfer_is_active) { + azt_state = AZT_S_START; + loop_ctl = 1; + break; + } + azt_state = AZT_S_IDLE; + while (current_valid()) + end_request(CURRENT, 0); + return; + } + + if (current_valid()) { + struct azt_Play_msf msf; + int i; + azt_next_bn = CURRENT->sector / 4; + azt_hsg2msf(azt_next_bn, &msf.start); + i = 0; + /* find out in which track we are */ + while (azt_msf2hsg(&msf.start) > + azt_msf2hsg(&Toc[++i].trackTime)) { + }; + if (azt_msf2hsg(&msf.start) < + azt_msf2hsg(&Toc[i].trackTime) - + AZT_BUF_SIZ) { + azt_read_count = AZT_BUF_SIZ; /*fast, because we read ahead */ + /*azt_read_count=CURRENT->nr_sectors; slow, no read ahead */ + } else /* don't read beyond end of track */ +#if AZT_MULTISESSION + { + azt_read_count = + (azt_msf2hsg(&Toc[i].trackTime) + / 4) * 4 - + azt_msf2hsg(&msf.start); + if (azt_read_count < 0) + azt_read_count = 0; + if (azt_read_count > AZT_BUF_SIZ) + azt_read_count = + AZT_BUF_SIZ; + printk + ("aztcd: warning - trying to read beyond end of track\n"); +/* printk("%i %i %li %li\n",i,azt_read_count,azt_msf2hsg(&msf.start),azt_msf2hsg(&Toc[i].trackTime)); +*/ } +#else + { + azt_read_count = AZT_BUF_SIZ; + } +#endif + msf.end.min = 0; + msf.end.sec = 0; + msf.end.frame = azt_read_count; /*Mitsumi here reads 0xffffff sectors */ +#ifdef AZT_TEST3 + printk + ("---reading msf-address %x:%x:%x %x:%x:%x\n", + msf.start.min, msf.start.sec, + msf.start.frame, msf.end.min, + msf.end.sec, msf.end.frame); + printk + ("azt_next_bn:%x azt_buf_in:%x azt_buf_out:%x azt_buf_bn:%x\n", + azt_next_bn, azt_buf_in, azt_buf_out, + azt_buf_bn[azt_buf_in]); +#endif + if (azt_read_mode == AZT_MODE_2) { + sendAztCmd(ACMD_PLAY_READ_RAW, &msf); /*XA disks in raw mode */ + } else { + sendAztCmd(ACMD_PLAY_READ, &msf); /*others in cooked mode */ + } + azt_state = AZT_S_DATA; + AztTimeout = READ_TIMEOUT; + } else { + azt_state = AZT_S_STOP; + loop_ctl = 1; + break; + } + + break; + + + case AZT_S_DATA: +#ifdef AZT_TEST3 + if (azt_state != azt_state_old) { + azt_state_old = azt_state; + printk("AZT_S_DATA\n"); + } +#endif + + st = inb(STATUS_PORT) & AFL_STATUSorDATA; + + switch (st) { + + case AFL_DATA: +#ifdef AZT_TEST3 + if (st != azt_st_old) { + azt_st_old = st; + printk("---AFL_DATA st:%x\n", st); + } +#endif + if (!AztTries--) { + printk + ("aztcd: Read of Block %d Failed, Maybe Audio Disk ? Giving up\n", + azt_next_bn); + if (azt_transfer_is_active) { + AztTries = 0; + break; + } + if (current_valid()) + end_request(CURRENT, 0); + AztTries = 5; + } + azt_state = AZT_S_START; + AztTimeout = READ_TIMEOUT; + loop_ctl = 1; + break; + + case AFL_STATUSorDATA: +#ifdef AZT_TEST3 + if (st != azt_st_old) { + azt_st_old = st; + printk + ("---AFL_STATUSorDATA st:%x\n", + st); + } +#endif + break; + + default: +#ifdef AZT_TEST3 + if (st != azt_st_old) { + azt_st_old = st; + printk("---default: st:%x\n", st); + } +#endif + AztTries = 5; + if (!current_valid() && azt_buf_in == azt_buf_out) { + azt_state = AZT_S_STOP; + loop_ctl = 1; + break; + } + if (azt_read_count <= 0) + printk + ("aztcd: warning - try to read 0 frames\n"); + while (azt_read_count) { /*??? fast read ahead loop */ + azt_buf_bn[azt_buf_in] = -1; + DTEN_LOW; /*??? unsolved problem, very + seldom we get timeouts + here, don't now the real + reason. With my drive this + sometimes also happens with + Aztech's original driver under + DOS. Is it a hardware bug? + I tried to recover from such + situations here. Zimmermann */ + if (aztTimeOutCount >= AZT_TIMEOUT) { + printk + ("read_count:%d CURRENT->nr_sectors:%ld azt_buf_in:%d\n", + azt_read_count, + CURRENT->nr_sectors, + azt_buf_in); + printk + ("azt_transfer_is_active:%x\n", + azt_transfer_is_active); + azt_read_count = 0; + azt_state = AZT_S_STOP; + loop_ctl = 1; + end_request(CURRENT, 1); /*should we have here (1) or (0)? */ + } else { + if (azt_read_mode == + AZT_MODE_2) { + insb(DATA_PORT, + azt_buf + + CD_FRAMESIZE_RAW + * azt_buf_in, + CD_FRAMESIZE_RAW); + } else { + insb(DATA_PORT, + azt_buf + + CD_FRAMESIZE * + azt_buf_in, + CD_FRAMESIZE); + } + azt_read_count--; +#ifdef AZT_TEST3 + printk + ("AZT_S_DATA; ---I've read data- read_count: %d\n", + azt_read_count); + printk + ("azt_next_bn:%d azt_buf_in:%d azt_buf_out:%d azt_buf_bn:%d\n", + azt_next_bn, + azt_buf_in, + azt_buf_out, + azt_buf_bn + [azt_buf_in]); +#endif + azt_buf_bn[azt_buf_in] = + azt_next_bn++; + if (azt_buf_out == -1) + azt_buf_out = + azt_buf_in; + azt_buf_in = + azt_buf_in + 1 == + AZT_BUF_SIZ ? 0 : + azt_buf_in + 1; + } + } + if (!azt_transfer_is_active) { + while (current_valid()) { + azt_transfer(); + if (CURRENT->nr_sectors == + 0) + end_request(CURRENT, 1); + else + break; + } + } + + if (current_valid() + && (CURRENT->sector / 4 < azt_next_bn + || CURRENT->sector / 4 > + azt_next_bn + AZT_BUF_SIZ)) { + azt_state = AZT_S_STOP; + loop_ctl = 1; + break; + } + AztTimeout = READ_TIMEOUT; + if (azt_read_count == 0) { + azt_state = AZT_S_STOP; + loop_ctl = 1; + break; + } + break; + } + break; + + + case AZT_S_STOP: +#ifdef AZT_TEST3 + if (azt_state != azt_state_old) { + azt_state_old = azt_state; + printk("AZT_S_STOP\n"); + } +#endif + if (azt_read_count != 0) + printk("aztcd: discard data=%x frames\n", + azt_read_count); + while (azt_read_count != 0) { + int i; + if (!(inb(STATUS_PORT) & AFL_DATA)) { + if (azt_read_mode == AZT_MODE_2) + for (i = 0; + i < CD_FRAMESIZE_RAW; + i++) + inb(DATA_PORT); + else + for (i = 0; + i < CD_FRAMESIZE; i++) + inb(DATA_PORT); + } + azt_read_count--; + } + if (aztSendCmd(ACMD_GET_STATUS)) + RETURN("azt_poll 5"); + azt_state = AZT_S_STOPPING; + AztTimeout = 1000; + break; + + case AZT_S_STOPPING: +#ifdef AZT_TEST3 + if (azt_state != azt_state_old) { + azt_state_old = azt_state; + printk("AZT_S_STOPPING\n"); + } +#endif + + if ((st = aztStatus()) == -1 && AztTimeout) + break; + + if ((st != -1) + && ((st & AST_DSK_CHG) + || (st & AST_NOT_READY))) { + aztDiskChanged = 1; + aztTocUpToDate = 0; + azt_invalidate_buffers(); + printk + ("aztcd: Disk Changed or Not Ready 4 - Unmount Disk!\n"); + end_request(CURRENT, 0); + } + +#ifdef AZT_TEST3 + printk("CURRENT_VALID %d azt_mode %d\n", + current_valid(), azt_mode); +#endif + + if (current_valid()) { + if (st != -1) { + if (azt_mode == 1) { + azt_state = AZT_S_READ; + loop_ctl = 1; + skip = 1; + break; + } else { + azt_state = AZT_S_MODE; + loop_ctl = 1; + skip = 1; + break; + } + } else { + azt_state = AZT_S_START; + AztTimeout = 1; + } + } else { + azt_state = AZT_S_IDLE; + return; + } + break; + + default: + printk("aztcd: invalid state %d\n", azt_state); + return; + } /* case */ + } /* while */ + + + if (!AztTimeout--) { + printk("aztcd: timeout in state %d\n", azt_state); + azt_state = AZT_S_STOP; + if (aztSendCmd(ACMD_STOP)) + RETURN("azt_poll 6"); + STEN_LOW_WAIT; + }; + + SET_TIMER(azt_poll, HZ / 100); +} + + +/*########################################################################### + * Miscellaneous support functions + ########################################################################### +*/ +void azt_hsg2msf(long hsg, struct msf *msf) +{ + hsg += 150; + msf->min = hsg / 4500; + hsg %= 4500; + msf->sec = hsg / 75; + msf->frame = hsg % 75; +#ifdef AZT_DEBUG + if (msf->min >= 70) + printk("aztcd: Error hsg2msf address Minutes\n"); + if (msf->sec >= 60) + printk("aztcd: Error hsg2msf address Seconds\n"); + if (msf->frame >= 75) + printk("aztcd: Error hsg2msf address Frames\n"); +#endif + azt_bin2bcd(&msf->min); /* convert to BCD */ + azt_bin2bcd(&msf->sec); + azt_bin2bcd(&msf->frame); +} + +long azt_msf2hsg(struct msf *mp) +{ + return azt_bcd2bin(mp->frame) + azt_bcd2bin(mp->sec) * 75 + + azt_bcd2bin(mp->min) * 4500 - CD_MSF_OFFSET; +} + +void azt_bin2bcd(unsigned char *p) +{ + int u, t; + + u = *p % 10; + t = *p / 10; + *p = u | (t << 4); +} + +int azt_bcd2bin(unsigned char bcd) +{ + return (bcd >> 4) * 10 + (bcd & 0xF); +} + +MODULE_LICENSE("GPL"); +MODULE_ALIAS_BLOCKDEV_MAJOR(AZTECH_CDROM_MAJOR); diff --git a/ddverify/case_studies/cdrom/aztcd/aztcd.h b/ddverify/case_studies/cdrom/aztcd/aztcd.h new file mode 100644 index 000000000..057501e31 --- /dev/null +++ b/ddverify/case_studies/cdrom/aztcd/aztcd.h @@ -0,0 +1,162 @@ +/* $Id: aztcd.h,v 2.60 1997/11/29 09:51:22 root Exp root $ + * + * Definitions for a AztechCD268 CD-ROM interface + * Copyright (C) 1994-98 Werner Zimmermann + * + * based on Mitsumi CDROM driver by Martin Harriss + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * History: W.Zimmermann adaption to Aztech CD268-01A Version 1.3 + * October 1994 Email: Werner.Zimmermann@fht-esslingen.de + */ + +/* *** change this to set the I/O port address of your CD-ROM drive, + set to '-1', if you want autoprobing */ +#define AZT_BASE_ADDR -1 + +/* list of autoprobing addresses (not more than 15), last value must be 0x000 + Note: Autoprobing is only enabled, if AZT_BASE_ADDR is set to '-1' ! */ +#define AZT_BASE_AUTO { 0x320, 0x300, 0x310, 0x330, 0x000 } + +/* Uncomment this, if your CDROM is connected to a Soundwave32-soundcard + and configure AZT_BASE_ADDR and AZT_SW32_BASE_ADDR */ +/*#define AZT_SW32 1 +*/ + +#ifdef AZT_SW32 +#define AZT_SW32_BASE_ADDR 0x220 /*I/O port base address of your soundcard*/ +#endif + +/* Set this to 1, if you want your tray to be locked, set to 0 to prevent tray + from locking */ +#define AZT_ALLOW_TRAY_LOCK 1 + +/*Set this to 1 to allow auto-eject when unmounting a disk, set to 0, if you + don't want the auto-eject feature*/ +#define AZT_AUTO_EJECT 0 + +/*Set this to 1, if you want to use incompatible ioctls for reading in raw and + cooked mode */ +#define AZT_PRIVATE_IOCTLS 1 + +/*Set this to 1, if you want multisession support by the ISO fs. Even if you set + this value to '0' you can use multisession CDs. In that case the drive's firm- + ware will do the appropriate redirection automatically. The CD will then look + like a single session CD (but nevertheless all data may be read). Please read + chapter '5.1 Multisession support' in README.aztcd for details. Normally it's + uncritical to leave this setting untouched */ +#define AZT_MULTISESSION 1 + +/*Uncomment this, if you are using a linux kernel version prior to 2.1.0 */ +/*#define AZT_KERNEL_PRIOR_2_1 */ + +/*---------------------------------------------------------------------------*/ +/*-----nothing to be configured for normal applications below this line------*/ + + +/* Increase this if you get lots of timeouts; if you get kernel panic, replace + STEN_LOW_WAIT by STEN_LOW in the source code */ +#define AZT_STATUS_DELAY 400 /*for timer wait, STEN_LOW_WAIT*/ +#define AZT_TIMEOUT 8000000 /*for busy wait STEN_LOW, DTEN_LOW*/ +#define AZT_FAST_TIMEOUT 10000 /*for reading the version string*/ + +/* number of times to retry a command before giving up */ +#define AZT_RETRY_ATTEMPTS 3 + +/* port access macros */ +#define CMD_PORT azt_port +#define DATA_PORT azt_port +#define STATUS_PORT azt_port+1 +#define MODE_PORT azt_port+2 +#ifdef AZT_SW32 + #define AZT_SW32_INIT (unsigned int) (0xFF00 & (AZT_BASE_ADDR*16)) + #define AZT_SW32_CONFIG_REG AZT_SW32_BASE_ADDR+0x16 /*Soundwave32 Config. Register*/ + #define AZT_SW32_ID_REG AZT_SW32_BASE_ADDR+0x04 /*Soundwave32 ID Version Register*/ +#endif + +/* status bits */ +#define AST_CMD_CHECK 0x80 /* 1 = command error */ +#define AST_DOOR_OPEN 0x40 /* 1 = door is open */ +#define AST_NOT_READY 0x20 /* 1 = no disk in the drive */ +#define AST_DSK_CHG 0x02 /* 1 = disk removed or changed */ +#define AST_MODE 0x01 /* 0=MODE1, 1=MODE2 */ +#define AST_MODE_BITS 0x1C /* Mode Bits */ +#define AST_INITIAL 0x0C /* initial, only valid ... */ +#define AST_BUSY 0x04 /* now playing, only valid + in combination with mode + bits */ +/* flag bits */ +#define AFL_DATA 0x02 /* data available if low */ +#define AFL_STATUS 0x04 /* status available if low */ +#define AFL_OP_OK 0x01 /* OP_OK command correct*/ +#define AFL_PA_OK 0x02 /* PA_OK parameter correct*/ +#define AFL_OP_ERR 0x05 /* error in command*/ +#define AFL_PA_ERR 0x06 /* error in parameters*/ +#define POLLED 0x04 /* polled mode */ + +/* commands */ +#define ACMD_SOFT_RESET 0x10 /* reset drive */ +#define ACMD_PLAY_READ 0x20 /* read data track in cooked mode */ +#define ACMD_PLAY_READ_RAW 0x21 /* reading in raw mode*/ +#define ACMD_SEEK 0x30 /* seek msf address*/ +#define ACMD_SEEK_TO_LEADIN 0x31 /* seek to leadin track*/ +#define ACMD_GET_ERROR 0x40 /* get error code */ +#define ACMD_GET_STATUS 0x41 /* get status */ +#define ACMD_GET_Q_CHANNEL 0x50 /* read info from q channel */ +#define ACMD_EJECT 0x60 /* eject/open tray */ +#define ACMD_CLOSE 0x61 /* close tray */ +#define ACMD_LOCK 0x71 /* lock tray closed */ +#define ACMD_UNLOCK 0x72 /* unlock tray */ +#define ACMD_PAUSE 0x80 /* pause */ +#define ACMD_STOP 0x81 /* stop play */ +#define ACMD_PLAY_AUDIO 0x90 /* play audio track */ +#define ACMD_SET_VOLUME 0x93 /* set audio level */ +#define ACMD_GET_VERSION 0xA0 /* get firmware version */ +#define ACMD_SET_DISK_TYPE 0xA1 /* set disk data mode */ + +#define MAX_TRACKS 104 + +struct msf { + unsigned char min; + unsigned char sec; + unsigned char frame; +}; + +struct azt_Play_msf { + struct msf start; + struct msf end; +}; + +struct azt_DiskInfo { + unsigned char first; + unsigned char next; + unsigned char last; + struct msf diskLength; + struct msf firstTrack; + unsigned char multi; + struct msf nextSession; + struct msf lastSession; + unsigned char xa; + unsigned char audio; +}; + +struct azt_Toc { + unsigned char ctrl_addr; + unsigned char track; + unsigned char pointIndex; + struct msf trackTime; + struct msf diskTime; +}; diff --git a/ddverify/case_studies/cdrom/aztcd/cdrom.h b/ddverify/case_studies/cdrom/aztcd/cdrom.h new file mode 100644 index 000000000..b68fdf1f3 --- /dev/null +++ b/ddverify/case_studies/cdrom/aztcd/cdrom.h @@ -0,0 +1,1192 @@ +/* + * -- + * General header file for linux CD-ROM drivers + * Copyright (C) 1992 David Giller, rafetmad@oxy.edu + * 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de + * 1996 David van Leeuwen, david@tm.tno.nl + * 1997, 1998 Erik Andersen, andersee@debian.org + * 1998-2002 Jens Axboe, axboe@suse.de + */ + +#ifndef _LINUX_CDROM_H +#define _LINUX_CDROM_H + +#include + +/******************************************************* + * As of Linux 2.1.x, all Linux CD-ROM application programs will use this + * (and only this) include file. It is my hope to provide Linux with + * a uniform interface between software accessing CD-ROMs and the various + * device drivers that actually talk to the drives. There may still be + * 23 different kinds of strange CD-ROM drives, but at least there will + * now be one, and only one, Linux CD-ROM interface. + * + * Additionally, as of Linux 2.1.x, all Linux application programs + * should use the O_NONBLOCK option when opening a CD-ROM device + * for subsequent ioctl commands. This allows for neat system errors + * like "No medium found" or "Wrong medium type" upon attempting to + * mount or play an empty slot, mount an audio disc, or play a data disc. + * Generally, changing an application program to support O_NONBLOCK + * is as easy as the following: + * - drive = open("/dev/cdrom", O_RDONLY); + * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); + * It is worth the small change. + * + * Patches for many common CD programs (provided by David A. van Leeuwen) + * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/ + * + *******************************************************/ + +/* When a driver supports a certain function, but the cdrom drive we are + * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will + * borrow the "Operation not supported" error from the network folks to + * accomplish this. Maybe someday we will get a more targeted error code, + * but this will do for now... */ +#define EDRIVE_CANT_DO_THIS EOPNOTSUPP + +/******************************************************* + * The CD-ROM IOCTL commands -- these should be supported by + * all the various cdrom drivers. For the CD-ROM ioctls, we + * will commandeer byte 0x53, or 'S'. + *******************************************************/ +#define CDROMPAUSE 0x5301 /* Pause Audio Operation */ +#define CDROMRESUME 0x5302 /* Resume paused Audio Operation */ +#define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ +#define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index + (struct cdrom_ti) */ +#define CDROMREADTOCHDR 0x5305 /* Read TOC header + (struct cdrom_tochdr) */ +#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry + (struct cdrom_tocentry) */ +#define CDROMSTOP 0x5307 /* Stop the cdrom drive */ +#define CDROMSTART 0x5308 /* Start the cdrom drive */ +#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ +#define CDROMVOLCTRL 0x530a /* Control output volume + (struct cdrom_volctrl) */ +#define CDROMSUBCHNL 0x530b /* Read subchannel data + (struct cdrom_subchnl) */ +#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) + (struct cdrom_read) */ +#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) + (struct cdrom_read) */ +#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ +#define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ +#define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session + address of multi session disks + (struct cdrom_multisession) */ +#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" + if available (struct cdrom_mcn) */ +#define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated, + but here anyway for compatibility */ +#define CDROMRESET 0x5312 /* hard-reset the drive */ +#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting + (struct cdrom_volctrl) */ +#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) + (struct cdrom_read) */ +/* + * These ioctls are used only used in aztcd.c and optcd.c + */ +#define CDROMREADCOOKED 0x5315 /* read data in cooked mode */ +#define CDROMSEEK 0x5316 /* seek msf address */ + +/* + * This ioctl is only used by the scsi-cd driver. + It is for playing audio in logical block addressing mode. + */ +#define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ + +/* + * These ioctls are only used in optcd.c + */ +#define CDROMREADALL 0x5318 /* read all 2646 bytes */ + +/* + * These ioctls are (now) only in ide-cd.c for controlling + * drive spindown time. They should be implemented in the + * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, + * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... + * -Erik + */ +#define CDROMGETSPINDOWN 0x531d +#define CDROMSETSPINDOWN 0x531e + +/* + * These ioctls are implemented through the uniform CD-ROM driver + * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM + * drivers are eventually ported to the uniform CD-ROM driver interface. + */ +#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ +#define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */ +#define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */ +#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ +#define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */ +#define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */ +#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ +#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ +#define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */ +#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */ +#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */ +#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ + +/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386. + * Future CDROM ioctls should be kept below 0x537F + */ + +/* This ioctl is only used by sbpcd at the moment */ +#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ + /* conflict with SCSI_IOCTL_GET_IDLUN */ + +/* DVD-ROM Specific ioctls */ +#define DVD_READ_STRUCT 0x5390 /* Read structure */ +#define DVD_WRITE_STRUCT 0x5391 /* Write structure */ +#define DVD_AUTH 0x5392 /* Authentication */ + +#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */ +#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */ +#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */ + +/******************************************************* + * CDROM IOCTL structures + *******************************************************/ + +/* Address in MSF format */ +struct cdrom_msf0 +{ + __u8 minute; + __u8 second; + __u8 frame; +}; + +/* Address in either MSF or logical format */ +union cdrom_addr +{ + struct cdrom_msf0 msf; + int lba; +}; + +/* This struct is used by the CDROMPLAYMSF ioctl */ +struct cdrom_msf +{ + __u8 cdmsf_min0; /* start minute */ + __u8 cdmsf_sec0; /* start second */ + __u8 cdmsf_frame0; /* start frame */ + __u8 cdmsf_min1; /* end minute */ + __u8 cdmsf_sec1; /* end second */ + __u8 cdmsf_frame1; /* end frame */ +}; + +/* This struct is used by the CDROMPLAYTRKIND ioctl */ +struct cdrom_ti +{ + __u8 cdti_trk0; /* start track */ + __u8 cdti_ind0; /* start index */ + __u8 cdti_trk1; /* end track */ + __u8 cdti_ind1; /* end index */ +}; + +/* This struct is used by the CDROMREADTOCHDR ioctl */ +struct cdrom_tochdr +{ + __u8 cdth_trk0; /* start track */ + __u8 cdth_trk1; /* end track */ +}; + +/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */ +struct cdrom_volctrl +{ + __u8 channel0; + __u8 channel1; + __u8 channel2; + __u8 channel3; +}; + +/* This struct is used by the CDROMSUBCHNL ioctl */ +struct cdrom_subchnl +{ + __u8 cdsc_format; + __u8 cdsc_audiostatus; + __u8 cdsc_adr: 4; + __u8 cdsc_ctrl: 4; + __u8 cdsc_trk; + __u8 cdsc_ind; + union cdrom_addr cdsc_absaddr; + union cdrom_addr cdsc_reladdr; +}; + + +/* This struct is used by the CDROMREADTOCENTRY ioctl */ +struct cdrom_tocentry +{ + __u8 cdte_track; + __u8 cdte_adr :4; + __u8 cdte_ctrl :4; + __u8 cdte_format; + union cdrom_addr cdte_addr; + __u8 cdte_datamode; +}; + +/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */ +struct cdrom_read +{ + int cdread_lba; + char *cdread_bufaddr; + int cdread_buflen; +}; + +/* This struct is used by the CDROMREADAUDIO ioctl */ +struct cdrom_read_audio +{ + union cdrom_addr addr; /* frame address */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ + int nframes; /* number of 2352-byte-frames to read at once */ + __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */ +}; + +/* This struct is used with the CDROMMULTISESSION ioctl */ +struct cdrom_multisession +{ + union cdrom_addr addr; /* frame address: start-of-last-session + (not the new "frame 16"!). Only valid + if the "xa_flag" is true. */ + __u8 xa_flag; /* 1: "is XA disk" */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ +}; + +/* This struct is used with the CDROM_GET_MCN ioctl. + * Very few audio discs actually have Universal Product Code information, + * which should just be the Medium Catalog Number on the box. Also note + * that the way the codeis written on CD is _not_ uniform across all discs! + */ +struct cdrom_mcn +{ + __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */ +}; + +/* This is used by the CDROMPLAYBLK ioctl */ +struct cdrom_blk +{ + unsigned from; + unsigned short len; +}; + +#define CDROM_PACKET_SIZE 12 + +#define CGC_DATA_UNKNOWN 0 +#define CGC_DATA_WRITE 1 +#define CGC_DATA_READ 2 +#define CGC_DATA_NONE 3 + +/* for CDROM_PACKET_COMMAND ioctl */ +struct cdrom_generic_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char __user *buffer; + unsigned int buflen; + int stat; + struct request_sense __user *sense; + unsigned char data_direction; + int quiet; + int timeout; + void __user *reserved[1]; /* unused, actually */ +}; + +/* + * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, + * 2340, or 2352 bytes long. + +* Sector types of the standard CD-ROM data formats: + * + * format sector type user data size (bytes) + * ----------------------------------------------------------------------------- + * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW) + * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE) + * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0) + * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE) + * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes) + * + * + * The layout of the standard CD-ROM data formats: + * ----------------------------------------------------------------------------- + * - audio (red): | audio_sample_bytes | + * | 2352 | + * + * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC | + * | 12 - 4 - 2048 - 4 - 8 - 276 | + * + * - data (yellow, mode2): | sync - head - data | + * | 12 - 4 - 2336 | + * + * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC | + * | 12 - 4 - 8 - 2048 - 4 - 276 | + * + * - XA data (green, mode2 form2): | sync - head - sub - data - Spare | + * | 12 - 4 - 8 - 2324 - 4 | + * + */ + +/* Some generally useful CD-ROM information -- mostly based on the above */ +#define CD_MINS 74 /* max. minutes per CD, not really a limit */ +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ +#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ +#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ +#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ +#define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */ +#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ +#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */ +#define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */ +#define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */ +#define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */ +#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ +#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ +/* most drives don't deliver everything: */ +#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ +#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ + +#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */ +#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */ +#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */ + +/* CD-ROM address types (cdrom_tocentry.cdte_format) */ +#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ +#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ + +/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ +#define CDROM_DATA_TRACK 0x04 + +/* The leadout track is always 0xAA, regardless of # of tracks on disc */ +#define CDROM_LEADOUT 0xAA + +/* audio states (from SCSI-2, but seen with other drives, too) */ +#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ +#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ +#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ +#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ +#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ +#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ + +/* capability flags used with the uniform CD-ROM driver */ +#define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */ +#define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */ +#define CDC_LOCK 0x4 /* disable manual eject */ +#define CDC_SELECT_SPEED 0x8 /* programmable speed */ +#define CDC_SELECT_DISC 0x10 /* select disc from juke-box */ +#define CDC_MULTI_SESSION 0x20 /* read sessions>1 */ +#define CDC_MCN 0x40 /* Medium Catalog Number */ +#define CDC_MEDIA_CHANGED 0x80 /* media changed */ +#define CDC_PLAY_AUDIO 0x100 /* audio functions */ +#define CDC_RESET 0x200 /* hard reset device */ +#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */ +#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ +#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ +#define CDC_CD_R 0x2000 /* drive is a CD-R */ +#define CDC_CD_RW 0x4000 /* drive is a CD-RW */ +#define CDC_DVD 0x8000 /* drive is a DVD */ +#define CDC_DVD_R 0x10000 /* drive can write DVD-R */ +#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */ +#define CDC_MO_DRIVE 0x40000 /* drive is an MO device */ +#define CDC_MRW 0x80000 /* drive can read MRW */ +#define CDC_MRW_W 0x100000 /* drive can write MRW */ +#define CDC_RAM 0x200000 /* ok to open for WRITE */ + +/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ +#define CDS_NO_INFO 0 /* if not implemented */ +#define CDS_NO_DISC 1 +#define CDS_TRAY_OPEN 2 +#define CDS_DRIVE_NOT_READY 3 +#define CDS_DISC_OK 4 + +/* return values for the CDROM_DISC_STATUS ioctl */ +/* can also return CDS_NO_[INFO|DISC], from above */ +#define CDS_AUDIO 100 +#define CDS_DATA_1 101 +#define CDS_DATA_2 102 +#define CDS_XA_2_1 103 +#define CDS_XA_2_2 104 +#define CDS_MIXED 105 + +/* User-configurable behavior options for the uniform CD-ROM driver */ +#define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */ +#define CDO_AUTO_EJECT 0x2 /* open tray on last release() */ +#define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */ +#define CDO_LOCK 0x8 /* lock tray on open files */ +#define CDO_CHECK_TYPE 0x10 /* check type on open for data */ + +/* Special codes used when specifying changer slots. */ +#define CDSL_NONE ((int) (~0U>>1)-1) +#define CDSL_CURRENT ((int) (~0U>>1)) + +/* For partition based multisession access. IDE can handle 64 partitions + * per drive - SCSI CD-ROM's use minors to differentiate between the + * various drives, so we can't do multisessions the same way there. + * Use the -o session=x option to mount on them. + */ +#define CD_PART_MAX 64 +#define CD_PART_MASK (CD_PART_MAX - 1) + +/********************************************************************* + * Generic Packet commands, MMC commands, and such + *********************************************************************/ + + /* The generic packet command opcodes for CD/DVD Logical Units, + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +#define GPCMD_BLANK 0xa1 +#define GPCMD_CLOSE_TRACK 0x5b +#define GPCMD_FLUSH_CACHE 0x35 +#define GPCMD_FORMAT_UNIT 0x04 +#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a +#define GPCMD_GET_PERFORMANCE 0xac +#define GPCMD_INQUIRY 0x12 +#define GPCMD_LOAD_UNLOAD 0xa6 +#define GPCMD_MECHANISM_STATUS 0xbd +#define GPCMD_MODE_SELECT_10 0x55 +#define GPCMD_MODE_SENSE_10 0x5a +#define GPCMD_PAUSE_RESUME 0x4b +#define GPCMD_PLAY_AUDIO_10 0x45 +#define GPCMD_PLAY_AUDIO_MSF 0x47 +#define GPCMD_PLAY_AUDIO_TI 0x48 +#define GPCMD_PLAY_CD 0xbc +#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e +#define GPCMD_READ_10 0x28 +#define GPCMD_READ_12 0xa8 +#define GPCMD_READ_BUFFER_CAPACITY 0x5c +#define GPCMD_READ_CDVD_CAPACITY 0x25 +#define GPCMD_READ_CD 0xbe +#define GPCMD_READ_CD_MSF 0xb9 +#define GPCMD_READ_DISC_INFO 0x51 +#define GPCMD_READ_DVD_STRUCTURE 0xad +#define GPCMD_READ_FORMAT_CAPACITIES 0x23 +#define GPCMD_READ_HEADER 0x44 +#define GPCMD_READ_TRACK_RZONE_INFO 0x52 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_REPAIR_RZONE_TRACK 0x58 +#define GPCMD_REPORT_KEY 0xa4 +#define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_RESERVE_RZONE_TRACK 0x53 +#define GPCMD_SEND_CUE_SHEET 0x5d +#define GPCMD_SCAN 0xba +#define GPCMD_SEEK 0x2b +#define GPCMD_SEND_DVD_STRUCTURE 0xbf +#define GPCMD_SEND_EVENT 0xa2 +#define GPCMD_SEND_KEY 0xa3 +#define GPCMD_SEND_OPC 0x54 +#define GPCMD_SET_READ_AHEAD 0xa7 +#define GPCMD_SET_STREAMING 0xb6 +#define GPCMD_START_STOP_UNIT 0x1b +#define GPCMD_STOP_PLAY_SCAN 0x4e +#define GPCMD_TEST_UNIT_READY 0x00 +#define GPCMD_VERIFY_10 0x2f +#define GPCMD_WRITE_10 0x2a +#define GPCMD_WRITE_AND_VERIFY_10 0x2e +/* This is listed as optional in ATAPI 2.6, but is (curiously) + * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji + * Table 377 as an MMC command for SCSi devices though... Most ATAPI + * drives support it. */ +#define GPCMD_SET_SPEED 0xbb +/* This seems to be a SCSI specific CD-ROM opcode + * to play data at track/index */ +#define GPCMD_PLAYAUDIO_TI 0x48 +/* + * From MS Media Status Notification Support Specification. For + * older drives only. + */ +#define GPCMD_GET_MEDIA_STATUS 0xda + +/* Mode page codes for mode sense/set */ +#define GPMODE_VENDOR_PAGE 0x00 +#define GPMODE_R_W_ERROR_PAGE 0x01 +#define GPMODE_WRITE_PARMS_PAGE 0x05 +#define GPMODE_WCACHING_PAGE 0x08 +#define GPMODE_AUDIO_CTL_PAGE 0x0e +#define GPMODE_POWER_PAGE 0x1a +#define GPMODE_FAULT_FAIL_PAGE 0x1c +#define GPMODE_TO_PROTECT_PAGE 0x1d +#define GPMODE_CAPABILITIES_PAGE 0x2a +#define GPMODE_ALL_PAGES 0x3f +/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor + * of MODE_SENSE_POWER_PAGE */ +#define GPMODE_CDROM_PAGE 0x0d + + + +/* DVD struct types */ +#define DVD_STRUCT_PHYSICAL 0x00 +#define DVD_STRUCT_COPYRIGHT 0x01 +#define DVD_STRUCT_DISCKEY 0x02 +#define DVD_STRUCT_BCA 0x03 +#define DVD_STRUCT_MANUFACT 0x04 + +struct dvd_layer { + __u8 book_version : 4; + __u8 book_type : 4; + __u8 min_rate : 4; + __u8 disc_size : 4; + __u8 layer_type : 4; + __u8 track_path : 1; + __u8 nlayers : 2; + __u8 track_density : 4; + __u8 linear_density : 4; + __u8 bca : 1; + __u32 start_sector; + __u32 end_sector; + __u32 end_sector_l0; +}; + +#define DVD_LAYERS 4 + +struct dvd_physical { + __u8 type; + __u8 layer_num; + struct dvd_layer layer[DVD_LAYERS]; +}; + +struct dvd_copyright { + __u8 type; + + __u8 layer_num; + __u8 cpst; + __u8 rmi; +}; + +struct dvd_disckey { + __u8 type; + + unsigned agid : 2; + __u8 value[2048]; +}; + +struct dvd_bca { + __u8 type; + + int len; + __u8 value[188]; +}; + +struct dvd_manufact { + __u8 type; + + __u8 layer_num; + int len; + __u8 value[2048]; +}; + +typedef union { + __u8 type; + + struct dvd_physical physical; + struct dvd_copyright copyright; + struct dvd_disckey disckey; + struct dvd_bca bca; + struct dvd_manufact manufact; +} dvd_struct; + +/* + * DVD authentication ioctl + */ + +/* Authentication states */ +#define DVD_LU_SEND_AGID 0 +#define DVD_HOST_SEND_CHALLENGE 1 +#define DVD_LU_SEND_KEY1 2 +#define DVD_LU_SEND_CHALLENGE 3 +#define DVD_HOST_SEND_KEY2 4 + +/* Termination states */ +#define DVD_AUTH_ESTABLISHED 5 +#define DVD_AUTH_FAILURE 6 + +/* Other functions */ +#define DVD_LU_SEND_TITLE_KEY 7 +#define DVD_LU_SEND_ASF 8 +#define DVD_INVALIDATE_AGID 9 +#define DVD_LU_SEND_RPC_STATE 10 +#define DVD_HOST_SEND_RPC_STATE 11 + +/* State data */ +typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ +typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ + +struct dvd_lu_send_agid { + __u8 type; + unsigned agid : 2; +}; + +struct dvd_host_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +struct dvd_send_key { + __u8 type; + unsigned agid : 2; + + dvd_key key; +}; + +struct dvd_lu_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +#define DVD_CPM_NO_COPYRIGHT 0 +#define DVD_CPM_COPYRIGHTED 1 + +#define DVD_CP_SEC_NONE 0 +#define DVD_CP_SEC_EXIST 1 + +#define DVD_CGMS_UNRESTRICTED 0 +#define DVD_CGMS_SINGLE 2 +#define DVD_CGMS_RESTRICTED 3 + +struct dvd_lu_send_title_key { + __u8 type; + unsigned agid : 2; + + dvd_key title_key; + int lba; + unsigned cpm : 1; + unsigned cp_sec : 1; + unsigned cgms : 2; +}; + +struct dvd_lu_send_asf { + __u8 type; + unsigned agid : 2; + + unsigned asf : 1; +}; + +struct dvd_host_send_rpcstate { + __u8 type; + __u8 pdrc; +}; + +struct dvd_lu_send_rpcstate { + __u8 type : 2; + __u8 vra : 3; + __u8 ucca : 3; + __u8 region_mask; + __u8 rpc_scheme; +}; + +typedef union { + __u8 type; + + struct dvd_lu_send_agid lsa; + struct dvd_host_send_challenge hsc; + struct dvd_send_key lsk; + struct dvd_lu_send_challenge lsc; + struct dvd_send_key hsk; + struct dvd_lu_send_title_key lstk; + struct dvd_lu_send_asf lsasf; + struct dvd_host_send_rpcstate hrpcs; + struct dvd_lu_send_rpcstate lrpcs; +} dvd_authinfo; + +struct request_sense { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 valid : 1; + __u8 error_code : 7; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 error_code : 7; + __u8 valid : 1; +#endif + __u8 segment_number; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 ili : 1; + __u8 reserved2 : 1; + __u8 sense_key : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 sense_key : 4; + __u8 reserved2 : 1; + __u8 ili : 1; + __u8 reserved1 : 2; +#endif + __u8 information[4]; + __u8 add_sense_len; + __u8 command_info[4]; + __u8 asc; + __u8 ascq; + __u8 fruc; + __u8 sks[3]; + __u8 asb[46]; +}; + +/* + * feature profile + */ +#define CDF_RWRT 0x0020 /* "Random Writable" */ +#define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ +#define CDF_MRW 0x0028 + +/* + * media status bits + */ +#define CDM_MRW_NOTMRW 0 +#define CDM_MRW_BGFORMAT_INACTIVE 1 +#define CDM_MRW_BGFORMAT_ACTIVE 2 +#define CDM_MRW_BGFORMAT_COMPLETE 3 + +/* + * mrw address spaces + */ +#define MRW_LBA_DMA 0 +#define MRW_LBA_GAA 1 + +/* + * mrw mode pages (first is deprecated) -- probed at init time and + * cdi->mrw_mode_page is set + */ +#define MRW_MODE_PC_PRE1 0x2c +#define MRW_MODE_PC 0x03 + +struct mrw_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 write : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 write : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; + __u8 reserved4; + __u8 reserved5; +}; + +/* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */ +struct rwrt_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; + __u32 last_lba; + __u32 block_size; + __u16 blocking; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 page_present : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_present : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; +}; + +typedef struct { + __u16 disc_information_length; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 3; + __u8 erasable : 1; + __u8 border_status : 2; + __u8 disc_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 disc_status : 2; + __u8 border_status : 2; + __u8 erasable : 1; + __u8 reserved1 : 3; +#else +#error "Please fix " +#endif + __u8 n_first_track; + __u8 n_sessions_lsb; + __u8 first_track_lsb; + __u8 last_track_lsb; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 did_v : 1; + __u8 dbc_v : 1; + __u8 uru : 1; + __u8 reserved2 : 2; + __u8 dbit : 1; + __u8 mrw_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 mrw_status : 2; + __u8 dbit : 1; + __u8 reserved2 : 2; + __u8 uru : 1; + __u8 dbc_v : 1; + __u8 did_v : 1; +#endif + __u8 disc_type; + __u8 n_sessions_msb; + __u8 first_track_msb; + __u8 last_track_msb; + __u32 disc_id; + __u32 lead_in; + __u32 lead_out; + __u8 disc_bar_code[8]; + __u8 reserved3; + __u8 n_opc; +} disc_information; + +typedef struct { + __u16 track_information_length; + __u8 track_lsb; + __u8 session_lsb; + __u8 reserved1; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 2; + __u8 damage : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 rt : 1; + __u8 blank : 1; + __u8 packet : 1; + __u8 fp : 1; + __u8 data_mode : 4; + __u8 reserved3 : 6; + __u8 lra_v : 1; + __u8 nwa_v : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 track_mode : 4; + __u8 copy : 1; + __u8 damage : 1; + __u8 reserved2 : 2; + __u8 data_mode : 4; + __u8 fp : 1; + __u8 packet : 1; + __u8 blank : 1; + __u8 rt : 1; + __u8 nwa_v : 1; + __u8 lra_v : 1; + __u8 reserved3 : 6; +#endif + __u32 track_start; + __u32 next_writable; + __u32 free_blocks; + __u32 fixed_packet_size; + __u32 track_size; + __u32 last_rec_address; +} track_information; + +struct feature_header { + __u32 data_len; + __u8 reserved1; + __u8 reserved2; + __u16 curr_profile; +}; + +struct mode_page_header { + __u16 mode_data_length; + __u8 medium_type; + __u8 reserved1; + __u8 reserved2; + __u8 reserved3; + __u16 desc_length; +}; + +#ifdef __KERNEL__ +#include /* not really needed, later.. */ +#include + +struct packet_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char *buffer; + unsigned int buflen; + int stat; + struct request_sense *sense; + unsigned char data_direction; + int quiet; + int timeout; + void *reserved[1]; +}; + +/* + * _OLD will use PIO transfer on atapi devices, _BPC_* will use DMA + */ +#define CDDA_OLD 0 /* old style */ +#define CDDA_BPC_SINGLE 1 /* single frame block pc */ +#define CDDA_BPC_FULL 2 /* multi frame block pc */ + +/* Uniform cdrom data structures for cdrom.c */ +struct cdrom_device_info { + struct cdrom_device_ops *ops; /* link to device_ops */ + struct cdrom_device_info *next; /* next device_info for this major */ + struct gendisk *disk; /* matching block layer disk */ + void *handle; /* driver-dependent data */ +/* specifications */ + int mask; /* mask of capability: disables them */ + int speed; /* maximum speed for reading data */ + int capacity; /* number of discs in jukebox */ +/* device-related storage */ + int options : 30; /* options flags */ + unsigned mc_flags : 2; /* media change buffer flags */ + int use_count; /* number of times device opened */ + char name[20]; /* name of the device type */ +/* per-device flags */ + __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ + __u8 reserved : 6; /* not used yet */ + int cdda_method; /* see flags */ + __u8 last_sense; + __u8 media_written; /* dirty flag, DVD+RW bookkeeping */ + unsigned short mmc3_profile; /* current MMC3 profile */ + int for_data; + int (*exit)(struct cdrom_device_info *); + int mrw_mode_page; +}; + +struct cdrom_device_ops { +/* routines */ + int (*open) (struct cdrom_device_info *, int); + void (*release) (struct cdrom_device_info *); + int (*drive_status) (struct cdrom_device_info *, int); + int (*media_changed) (struct cdrom_device_info *, int); + int (*tray_move) (struct cdrom_device_info *, int); + int (*lock_door) (struct cdrom_device_info *, int); + int (*select_speed) (struct cdrom_device_info *, int); + int (*select_disc) (struct cdrom_device_info *, int); + int (*get_last_session) (struct cdrom_device_info *, + struct cdrom_multisession *); + int (*get_mcn) (struct cdrom_device_info *, + struct cdrom_mcn *); + /* hard reset device */ + int (*reset) (struct cdrom_device_info *); + /* play stuff */ + int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *); + /* dev-specific */ + int (*dev_ioctl) (struct cdrom_device_info *, + unsigned int, unsigned long); +/* driver specifications */ + const int capability; /* capability flags */ + int n_minors; /* number of active minor devices */ + /* handle uniform packets for scsi type devices (scsi,atapi) */ + int (*generic_packet) (struct cdrom_device_info *, + struct packet_command *); +}; + +/* the general block_device operations structure: */ +extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, + struct file *fp); +extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp); +extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi, + struct inode *ip, unsigned int cmd, unsigned long arg); +extern int cdrom_media_changed(struct cdrom_device_info *); + +extern int register_cdrom(struct cdrom_device_info *cdi); +extern int unregister_cdrom(struct cdrom_device_info *cdi); + +typedef struct { + int data; + int audio; + int cdi; + int xa; + long error; +} tracktype; + +extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written); +extern int cdrom_number_of_slots(struct cdrom_device_info *cdi); +extern int cdrom_mode_select(struct cdrom_device_info *cdi, + struct packet_command *cgc); +extern int cdrom_mode_sense(struct cdrom_device_info *cdi, + struct packet_command *cgc, + int page_code, int page_control); +extern void init_cdrom_command(struct packet_command *cgc, + void *buffer, int len, int type); + +/* The SCSI spec says there could be 256 slots. */ +#define CDROM_MAX_SLOTS 256 + +struct cdrom_mechstat_header { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 fault : 1; + __u8 changer_state : 2; + __u8 curslot : 5; + __u8 mech_state : 3; + __u8 door_open : 1; + __u8 reserved1 : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curslot : 5; + __u8 changer_state : 2; + __u8 fault : 1; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 mech_state : 3; +#endif + __u8 curlba[3]; + __u8 nslots; + __u16 slot_tablelen; +}; + +struct cdrom_slot { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 disc_present : 1; + __u8 reserved1 : 6; + __u8 change : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 change : 1; + __u8 reserved1 : 6; + __u8 disc_present : 1; +#endif + __u8 reserved2[3]; +}; + +struct cdrom_changer_info { + struct cdrom_mechstat_header hdr; + struct cdrom_slot slots[CDROM_MAX_SLOTS]; +}; + +typedef enum { + mechtype_caddy = 0, + mechtype_tray = 1, + mechtype_popup = 2, + mechtype_individual_changer = 4, + mechtype_cartridge_changer = 5 +} mechtype_t; + +typedef struct { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 ps : 1; + __u8 reserved1 : 1; + __u8 page_code : 6; + __u8 page_length; + __u8 reserved2 : 1; + __u8 bufe : 1; + __u8 ls_v : 1; + __u8 test_write : 1; + __u8 write_type : 4; + __u8 multi_session : 2; /* or border, DVD */ + __u8 fp : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 reserved3 : 4; + __u8 data_block_type : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_code : 6; + __u8 reserved1 : 1; + __u8 ps : 1; + __u8 page_length; + __u8 write_type : 4; + __u8 test_write : 1; + __u8 ls_v : 1; + __u8 bufe : 1; + __u8 reserved2 : 1; + __u8 track_mode : 4; + __u8 copy : 1; + __u8 fp : 1; + __u8 multi_session : 2; /* or border, DVD */ + __u8 data_block_type : 4; + __u8 reserved3 : 4; +#endif + __u8 link_size; + __u8 reserved4; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved5 : 2; + __u8 app_code : 6; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 app_code : 6; + __u8 reserved5 : 2; +#endif + __u8 session_format; + __u8 reserved6; + __u32 packet_size; + __u16 audio_pause; + __u8 mcn[16]; + __u8 isrc[16]; + __u8 subhdr0; + __u8 subhdr1; + __u8 subhdr2; + __u8 subhdr3; +} __attribute__((packed)) write_param_page; + +struct modesel_head +{ + __u8 reserved1; + __u8 medium; + __u8 reserved2; + __u8 block_desc_length; + __u8 density; + __u8 number_of_blocks_hi; + __u8 number_of_blocks_med; + __u8 number_of_blocks_lo; + __u8 reserved3; + __u8 block_length_hi; + __u8 block_length_med; + __u8 block_length_lo; +}; + +typedef struct { + __u16 report_key_length; + __u8 reserved1; + __u8 reserved2; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 type_code : 2; + __u8 vra : 3; + __u8 ucca : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ucca : 3; + __u8 vra : 3; + __u8 type_code : 2; +#endif + __u8 region_mask; + __u8 rpc_scheme; + __u8 reserved3; +} rpc_state_t; + +struct event_header { + __u16 data_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 nea : 1; + __u8 reserved1 : 4; + __u8 notification_class : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 notification_class : 3; + __u8 reserved1 : 4; + __u8 nea : 1; +#endif + __u8 supp_event_class; +}; + +struct media_event_desc { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 4; + __u8 media_event_code : 4; + __u8 reserved2 : 6; + __u8 media_present : 1; + __u8 door_open : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 media_event_code : 4; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 media_present : 1; + __u8 reserved2 : 6; +#endif + __u8 start_slot; + __u8 end_slot; +}; + +extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); + +#endif /* End of kernel only stuff */ + +#endif /* _LINUX_CDROM_H */ diff --git a/ddverify/case_studies/cdrom/cdu31a/cdu31a.c b/ddverify/case_studies/cdrom/cdu31a/cdu31a.c new file mode 100644 index 000000000..a23711b28 --- /dev/null +++ b/ddverify/case_studies/cdrom/cdu31a/cdu31a.c @@ -0,0 +1,3248 @@ +/* +* Sony CDU-31A CDROM interface device driver. +* +* Corey Minyard (minyard@wf-rch.cirr.com) +* +* Colossians 3:17 +* +* See Documentation/cdrom/cdu31a for additional details about this driver. +* +* The Sony interface device driver handles Sony interface CDROM +* drives and provides a complete block-level interface as well as an +* ioctl() interface compatible with the Sun (as specified in +* include/linux/cdrom.h). With this interface, CDROMs can be +* accessed and standard audio CDs can be played back normally. +* +* WARNING - All autoprobes have been removed from the driver. +* You MUST configure the CDU31A via a LILO config +* at boot time or in lilo.conf. I have the +* following in my lilo.conf: +* +* append="cdu31a=0x1f88,0,PAS" +* +* The first number is the I/O base address of the +* card. The second is the interrupt (0 means none). + * The third should be "PAS" if on a Pro-Audio + * spectrum, or nothing if on something else. + * + * This interface is (unfortunately) a polled interface. This is + * because most Sony interfaces are set up with DMA and interrupts + * disables. Some (like mine) do not even have the capability to + * handle interrupts or DMA. For this reason you will see a lot of + * the following: + * + * retry_count = jiffies+ SONY_JIFFIES_TIMEOUT; + * while (time_before(jiffies, retry_count) && (! + * For finding abug in the return of the track numbers. + * TOC processing redone for proper multisession support. + * + * + * It probably a little late to be adding a history, but I guess I + * will start. + * + * 10/24/95 - Added support for disabling the eject button when the + * drive is open. Note that there is a small problem + * still here, if the eject button is pushed while the + * drive light is flashing, the drive will return a bad + * status and be reset. It recovers, though. + * + * 03/07/97 - Fixed a problem with timers. + * + * + * 18 Spetember 1997 -- Ported to Uniform CD-ROM driver by + * Heiko Eissfeldt with additional + * changes by Erik Andersen + * + * 24 January 1998 -- Removed the scd_disc_status() function, which was now + * just dead code left over from the port. + * Erik Andersen + * + * 16 July 1998 -- Drive donated to Erik Andersen by John Kodis + * . Work begun on fixing driver to + * work under 2.1.X. Added temporary extra printks + * which seem to slow it down enough to work. + * + * 9 November 1999 -- Make kernel-parameter implementation work with 2.3.x + * Removed init_module & cleanup_module in favor of + * module_init & module_exit. + * Torben Mathiasen + * + * 22 October 2004 -- Make the driver work in 2.6.X + * Added workaround to fix hard lockups on eject + * Fixed door locking problem after mounting empty drive + * Set double-speed drives to double speed by default + * Removed all readahead things - not needed anymore + * Ondrej Zary +*/ + +#define DEBUG 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "cdu31a.h" + +#define MAJOR_NR CDU31A_CDROM_MAJOR +#include + +#define CDU31A_MAX_CONSECUTIVE_ATTENTIONS 10 + +#define PFX "CDU31A: " + +/* +** Edit the following data to change interrupts, DMA channels, etc. +** Default is polled and no DMA. DMA is not recommended for double-speed +** drives. +*/ +static struct { + unsigned short base; /* I/O Base Address */ + short int_num; /* Interrupt Number (-1 means scan for it, + 0 means don't use) */ +} cdu31a_addresses[] __initdata = { + {0} +}; + +static int handle_sony_cd_attention(void); +static int read_subcode(void); +static void sony_get_toc(void); +static int scd_spinup(void); +/*static int scd_open(struct inode *inode, struct file *filp);*/ +static int scd_open(struct cdrom_device_info *, int); +static void do_sony_cd_cmd(unsigned char cmd, + unsigned char *params, + unsigned int num_params, + unsigned char *result_buffer, + unsigned int *result_size); +static void size_to_buf(unsigned int size, unsigned char *buf); + +/* Parameters for the read-ahead. */ +static unsigned int sony_next_block; /* Next 512 byte block offset */ +static unsigned int sony_blocks_left = 0; /* Number of 512 byte blocks left + in the current read command. */ + + +/* The base I/O address of the Sony Interface. This is a variable (not a + #define) so it can be easily changed via some future ioctl() */ +static unsigned int cdu31a_port = 0; +module_param(cdu31a_port, uint, 0); + +/* + * The following are I/O addresses of the various registers for the drive. The + * comment for the base address also applies here. + */ +static volatile unsigned short sony_cd_cmd_reg; +static volatile unsigned short sony_cd_param_reg; +static volatile unsigned short sony_cd_write_reg; +static volatile unsigned short sony_cd_control_reg; +static volatile unsigned short sony_cd_status_reg; +static volatile unsigned short sony_cd_result_reg; +static volatile unsigned short sony_cd_read_reg; +static volatile unsigned short sony_cd_fifost_reg; + +static struct request_queue *cdu31a_queue; +static DEFINE_SPINLOCK(cdu31a_lock); /* queue lock */ + +static int sony_spun_up = 0; /* Has the drive been spun up? */ + +static int sony_speed = 0; /* Last wanted speed */ + +static int sony_xa_mode = 0; /* Is an XA disk in the drive + and the drive a CDU31A? */ + +static int sony_raw_data_mode = 1; /* 1 if data tracks, 0 if audio. + For raw data reads. */ + +static unsigned int sony_usage = 0; /* How many processes have the + drive open. */ + +static int sony_pas_init = 0; /* Initialize the Pro-Audio + Spectrum card? */ + +static struct s_sony_session_toc single_toc; /* Holds the + table of + contents. */ + +static struct s_all_sessions_toc sony_toc; /* entries gathered from all + sessions */ + +static int sony_toc_read = 0; /* Has the TOC been read for + the drive? */ + +static struct s_sony_subcode last_sony_subcode; /* Points to the last + subcode address read */ + +static DECLARE_MUTEX(sony_sem); /* Semaphore for drive hardware access */ + +static int is_double_speed = 0; /* does the drive support double speed ? */ + +static int is_auto_eject = 1; /* Door has been locked? 1=No/0=Yes */ + +/* + * The audio status uses the values from read subchannel data as specified + * in include/linux/cdrom.h. + */ +static volatile int sony_audio_status = CDROM_AUDIO_NO_STATUS; + +/* + * The following are a hack for pausing and resuming audio play. The drive + * does not work as I would expect it, if you stop it then start it again, + * the drive seeks back to the beginning and starts over. This holds the + * position during a pause so a resume can restart it. It uses the + * audio status variable above to tell if it is paused. + */ +static unsigned volatile char cur_pos_msf[3] = { 0, 0, 0 }; +static unsigned volatile char final_pos_msf[3] = { 0, 0, 0 }; + +/* What IRQ is the drive using? 0 if none. */ +static int cdu31a_irq = 0; +module_param(cdu31a_irq, int, 0); + +/* The interrupt handler will wake this queue up when it gets an + interrupts. */ +static DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait); +static int irq_flag = 0; + +static int curr_control_reg = 0; /* Current value of the control register */ + +/* A disk changed variable. When a disk change is detected, it will + all be set to TRUE. As the upper layers ask for disk_changed status + it will be cleared. */ +static char disk_changed; + +/* This was readahead_buffer once... Now it's used only for audio reads */ +static char audio_buffer[CD_FRAMESIZE_RAW]; + +/* Used to time a short period to abort an operation after the + drive has been idle for a while. This keeps the light on + the drive from flashing for very long. */ +static struct timer_list cdu31a_abort_timer; + +/* Marks if the timeout has started an abort read. This is used + on entry to the drive to tell the code to read out the status + from the abort read. */ +static int abort_read_started = 0; + +/* + * Uniform cdrom interface function + * report back, if disc has changed from time of last request. + */ +static int scd_media_changed(struct cdrom_device_info *cdi, int disc_nr) +{ + int retval; + + retval = disk_changed; + disk_changed = 0; + + return retval; +} + +/* + * Uniform cdrom interface function + * report back, if drive is ready + */ +static int scd_drive_status(struct cdrom_device_info *cdi, int slot_nr) +{ + if (CDSL_CURRENT != slot_nr) + /* we have no changer support */ + return -EINVAL; + if (sony_spun_up) + return CDS_DISC_OK; + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + if (scd_spinup() == 0) + sony_spun_up = 1; + up(&sony_sem); + return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY; +} + +static inline void enable_interrupts(void) +{ + curr_control_reg |= (SONY_ATTN_INT_EN_BIT + | SONY_RES_RDY_INT_EN_BIT + | SONY_DATA_RDY_INT_EN_BIT); + outb(curr_control_reg, sony_cd_control_reg); +} + +static inline void disable_interrupts(void) +{ + curr_control_reg &= ~(SONY_ATTN_INT_EN_BIT + | SONY_RES_RDY_INT_EN_BIT + | SONY_DATA_RDY_INT_EN_BIT); + outb(curr_control_reg, sony_cd_control_reg); +} + +/* + * Wait a little while (used for polling the drive). If in initialization, + * setting a timeout doesn't work, so just loop for a while. + */ +static inline void sony_sleep(void) +{ + if (cdu31a_irq <= 0) { + yield(); + } else { /* Interrupt driven */ + DEFINE_WAIT(w); + int first = 1; + + while (1) { + prepare_to_wait(&cdu31a_irq_wait, &w, + TASK_INTERRUPTIBLE); + if (first) { + enable_interrupts(); + first = 0; + } + + if (irq_flag != 0) + break; + if (!signal_pending(current)) { + schedule(); + continue; + } else + disable_interrupts(); + break; + } + finish_wait(&cdu31a_irq_wait, &w); + irq_flag = 0; + } +} + + +/* + * The following are convenience routine to read various status and set + * various conditions in the drive. + */ +static inline int is_attention(void) +{ + return (inb(sony_cd_status_reg) & SONY_ATTN_BIT) != 0; +} + +static inline int is_busy(void) +{ + return (inb(sony_cd_status_reg) & SONY_BUSY_BIT) != 0; +} + +static inline int is_data_ready(void) +{ + return (inb(sony_cd_status_reg) & SONY_DATA_RDY_BIT) != 0; +} + +static inline int is_data_requested(void) +{ + return (inb(sony_cd_status_reg) & SONY_DATA_REQUEST_BIT) != 0; +} + +static inline int is_result_ready(void) +{ + return (inb(sony_cd_status_reg) & SONY_RES_RDY_BIT) != 0; +} + +static inline int is_param_write_rdy(void) +{ + return (inb(sony_cd_fifost_reg) & SONY_PARAM_WRITE_RDY_BIT) != 0; +} + +static inline int is_result_reg_not_empty(void) +{ + return (inb(sony_cd_fifost_reg) & SONY_RES_REG_NOT_EMP_BIT) != 0; +} + +static inline void reset_drive(void) +{ + curr_control_reg = 0; + sony_toc_read = 0; + outb(SONY_DRIVE_RESET_BIT, sony_cd_control_reg); +} + +/* + * Uniform cdrom interface function + * reset drive and return when it is ready + */ +static int scd_reset(struct cdrom_device_info *cdi) +{ + unsigned long retry_count; + + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + reset_drive(); + + retry_count = jiffies + SONY_RESET_TIMEOUT; + while (time_before(jiffies, retry_count) && (!is_attention())) { + sony_sleep(); + } + + up(&sony_sem); + return 0; +} + +static inline void clear_attention(void) +{ + outb(curr_control_reg | SONY_ATTN_CLR_BIT, sony_cd_control_reg); +} + +static inline void clear_result_ready(void) +{ + outb(curr_control_reg | SONY_RES_RDY_CLR_BIT, sony_cd_control_reg); +} + +static inline void clear_data_ready(void) +{ + outb(curr_control_reg | SONY_DATA_RDY_CLR_BIT, + sony_cd_control_reg); +} + +static inline void clear_param_reg(void) +{ + outb(curr_control_reg | SONY_PARAM_CLR_BIT, sony_cd_control_reg); +} + +static inline unsigned char read_status_register(void) +{ + return inb(sony_cd_status_reg); +} + +static inline unsigned char read_result_register(void) +{ + return inb(sony_cd_result_reg); +} + +static inline unsigned char read_data_register(void) +{ + return inb(sony_cd_read_reg); +} + +static inline void write_param(unsigned char param) +{ + outb(param, sony_cd_param_reg); +} + +static inline void write_cmd(unsigned char cmd) +{ + outb(curr_control_reg | SONY_RES_RDY_INT_EN_BIT, + sony_cd_control_reg); + outb(cmd, sony_cd_cmd_reg); +} + +static irqreturn_t cdu31a_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + unsigned char val; + + if (abort_read_started) { + /* We might be waiting for an abort to finish. Don't + disable interrupts yet, though, because we handle + this one here. */ + /* Clear out the result registers. */ + while (is_result_reg_not_empty()) { + val = read_result_register(); + } + clear_data_ready(); + clear_result_ready(); + + /* Clear out the data */ + while (is_data_requested()) { + val = read_data_register(); + } + abort_read_started = 0; + + /* If something was waiting, wake it up now. */ + if (waitqueue_active(&cdu31a_irq_wait)) { + disable_interrupts(); + irq_flag = 1; + wake_up_interruptible(&cdu31a_irq_wait); + } + } else if (waitqueue_active(&cdu31a_irq_wait)) { + disable_interrupts(); + irq_flag = 1; + wake_up_interruptible(&cdu31a_irq_wait); + } else { + disable_interrupts(); + printk(KERN_NOTICE PFX + "Got an interrupt but nothing was waiting\n"); + } + return IRQ_HANDLED; +} + +/* + * give more verbose error messages + */ +static unsigned char *translate_error(unsigned char err_code) +{ + static unsigned char errbuf[80]; + + switch (err_code) { + case 0x10: return "illegal command "; + case 0x11: return "illegal parameter "; + + case 0x20: return "not loaded "; + case 0x21: return "no disc "; + case 0x22: return "not spinning "; + case 0x23: return "spinning "; + case 0x25: return "spindle servo "; + case 0x26: return "focus servo "; + case 0x29: return "eject mechanism "; + case 0x2a: return "audio playing "; + case 0x2c: return "emergency eject "; + + case 0x30: return "focus "; + case 0x31: return "frame sync "; + case 0x32: return "subcode address "; + case 0x33: return "block sync "; + case 0x34: return "header address "; + + case 0x40: return "illegal track read "; + case 0x41: return "mode 0 read "; + case 0x42: return "illegal mode read "; + case 0x43: return "illegal block size read "; + case 0x44: return "mode read "; + case 0x45: return "form read "; + case 0x46: return "leadout read "; + case 0x47: return "buffer overrun "; + + case 0x53: return "unrecoverable CIRC "; + case 0x57: return "unrecoverable LECC "; + + case 0x60: return "no TOC "; + case 0x61: return "invalid subcode data "; + case 0x63: return "focus on TOC read "; + case 0x64: return "frame sync on TOC read "; + case 0x65: return "TOC data "; + + case 0x70: return "hardware failure "; + case 0x91: return "leadin "; + case 0x92: return "leadout "; + case 0x93: return "data track "; + } + sprintf(errbuf, "unknown 0x%02x ", err_code); + return errbuf; +} + +/* + * Set the drive parameters so the drive will auto-spin-up when a + * disk is inserted. + */ +static void set_drive_params(int want_doublespeed) +{ + unsigned char res_reg[12]; + unsigned int res_size; + unsigned char params[3]; + + + params[0] = SONY_SD_AUTO_SPIN_DOWN_TIME; + params[1] = 0x00; /* Never spin down the drive. */ + do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, + params, 2, res_reg, &res_size); + if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_NOTICE PFX + "Unable to set spin-down time: 0x%2.2x\n", res_reg[1]); + } + + params[0] = SONY_SD_MECH_CONTROL; + params[1] = SONY_AUTO_SPIN_UP_BIT; /* Set auto spin up */ + + if (is_auto_eject) + params[1] |= SONY_AUTO_EJECT_BIT; + + if (is_double_speed && want_doublespeed) { + params[1] |= SONY_DOUBLE_SPEED_BIT; /* Set the drive to double speed if + possible */ + } + do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, + params, 2, res_reg, &res_size); + if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_NOTICE PFX "Unable to set mechanical " + "parameters: 0x%2.2x\n", res_reg[1]); + } +} + +/* + * Uniform cdrom interface function + * select reading speed for data access + */ +static int scd_select_speed(struct cdrom_device_info *cdi, int speed) +{ + if (speed == 0) + sony_speed = 1; + else + sony_speed = speed - 1; + + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + set_drive_params(sony_speed); + up(&sony_sem); + return 0; +} + +/* + * Uniform cdrom interface function + * lock or unlock eject button + */ +static int scd_lock_door(struct cdrom_device_info *cdi, int lock) +{ + if (lock == 0) { + is_auto_eject = 1; + } else { + is_auto_eject = 0; + } + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + set_drive_params(sony_speed); + up(&sony_sem); + return 0; +} + +/* + * This code will reset the drive and attempt to restore sane parameters. + */ +static void restart_on_error(void) +{ + unsigned char res_reg[12]; + unsigned int res_size; + unsigned long retry_count; + + + printk(KERN_NOTICE PFX "Resetting drive on error\n"); + reset_drive(); + retry_count = jiffies + SONY_RESET_TIMEOUT; + while (time_before(jiffies, retry_count) && (!is_attention())) { + sony_sleep(); + } + set_drive_params(sony_speed); + do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); + if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_NOTICE PFX "Unable to spin up drive: 0x%2.2x\n", + res_reg[1]); + } + + msleep(2000); + + sony_get_toc(); +} + +/* + * This routine writes data to the parameter register. Since this should + * happen fairly fast, it is polled with no OS waits between. + */ +static int write_params(unsigned char *params, int num_params) +{ + unsigned int retry_count; + + + retry_count = SONY_READY_RETRIES; + while ((retry_count > 0) && (!is_param_write_rdy())) { + retry_count--; + } + if (!is_param_write_rdy()) { + return -EIO; + } + + while (num_params > 0) { + write_param(*params); + params++; + num_params--; + } + + return 0; +} + + +/* + * The following reads data from the command result register. It is a + * fairly complex routine, all status info flows back through this + * interface. The algorithm is stolen directly from the flowcharts in + * the drive manual. + */ +static void +get_result(unsigned char *result_buffer, unsigned int *result_size) +{ + unsigned char a, b; + int i; + unsigned long retry_count; + + + while (handle_sony_cd_attention()); + /* Wait for the result data to be ready */ + retry_count = jiffies + SONY_JIFFIES_TIMEOUT; + while (time_before(jiffies, retry_count) + && (is_busy() || (!(is_result_ready())))) { + sony_sleep(); + + while (handle_sony_cd_attention()); + } + if (is_busy() || (!(is_result_ready()))) { + pr_debug(PFX "timeout out %d\n", __LINE__); + result_buffer[0] = 0x20; + result_buffer[1] = SONY_TIMEOUT_OP_ERR; + *result_size = 2; + return; + } + + /* + * Get the first two bytes. This determines what else needs + * to be done. + */ + clear_result_ready(); + a = read_result_register(); + *result_buffer = a; + result_buffer++; + + /* Check for block error status result. */ + if ((a & 0xf0) == 0x50) { + *result_size = 1; + return; + } + + b = read_result_register(); + *result_buffer = b; + result_buffer++; + *result_size = 2; + + /* + * 0x20 means an error occurred. Byte 2 will have the error code. + * Otherwise, the command succeeded, byte 2 will have the count of + * how many more status bytes are coming. + * + * The result register can be read 10 bytes at a time, a wait for + * result ready to be asserted must be done between every 10 bytes. + */ + if ((a & 0xf0) != 0x20) { + if (b > 8) { + for (i = 0; i < 8; i++) { + *result_buffer = read_result_register(); + result_buffer++; + (*result_size)++; + } + b = b - 8; + + while (b > 10) { + retry_count = SONY_READY_RETRIES; + while ((retry_count > 0) + && (!is_result_ready())) { + retry_count--; + } + if (!is_result_ready()) { + pr_debug(PFX "timeout out %d\n", + __LINE__); + result_buffer[0] = 0x20; + result_buffer[1] = + SONY_TIMEOUT_OP_ERR; + *result_size = 2; + return; + } + + clear_result_ready(); + + for (i = 0; i < 10; i++) { + *result_buffer = + read_result_register(); + result_buffer++; + (*result_size)++; + } + b = b - 10; + } + + if (b > 0) { + retry_count = SONY_READY_RETRIES; + while ((retry_count > 0) + && (!is_result_ready())) { + retry_count--; + } + if (!is_result_ready()) { + pr_debug(PFX "timeout out %d\n", + __LINE__); + result_buffer[0] = 0x20; + result_buffer[1] = + SONY_TIMEOUT_OP_ERR; + *result_size = 2; + return; + } + } + } + + while (b > 0) { + *result_buffer = read_result_register(); + result_buffer++; + (*result_size)++; + b--; + } + } +} + +/* + * Do a command that does not involve data transfer. This routine must + * be re-entrant from the same task to support being called from the + * data operation code when an error occurs. + */ +static void +do_sony_cd_cmd(unsigned char cmd, + unsigned char *params, + unsigned int num_params, + unsigned char *result_buffer, unsigned int *result_size) +{ + unsigned long retry_count; + int num_retries = 0; + +retry_cd_operation: + + while (handle_sony_cd_attention()); + + retry_count = jiffies + SONY_JIFFIES_TIMEOUT; + while (time_before(jiffies, retry_count) && (is_busy())) { + sony_sleep(); + + while (handle_sony_cd_attention()); + } + if (is_busy()) { + pr_debug(PFX "timeout out %d\n", __LINE__); + result_buffer[0] = 0x20; + result_buffer[1] = SONY_TIMEOUT_OP_ERR; + *result_size = 2; + } else { + clear_result_ready(); + clear_param_reg(); + + write_params(params, num_params); + write_cmd(cmd); + + get_result(result_buffer, result_size); + } + + if (((result_buffer[0] & 0xf0) == 0x20) + && (num_retries < MAX_CDU31A_RETRIES)) { + num_retries++; + msleep(100); + goto retry_cd_operation; + } +} + + +/* + * Handle an attention from the drive. This will return 1 if it found one + * or 0 if not (if one is found, the caller might want to call again). + * + * This routine counts the number of consecutive times it is called + * (since this is always called from a while loop until it returns + * a 0), and returns a 0 if it happens too many times. This will help + * prevent a lockup. + */ +static int handle_sony_cd_attention(void) +{ + unsigned char atten_code; + static int num_consecutive_attentions = 0; + volatile int val; + + +#if 0 + pr_debug(PFX "Entering %s\n", __FUNCTION__); +#endif + if (is_attention()) { + if (num_consecutive_attentions > + CDU31A_MAX_CONSECUTIVE_ATTENTIONS) { + printk(KERN_NOTICE PFX "Too many consecutive " + "attentions: %d\n", num_consecutive_attentions); + num_consecutive_attentions = 0; + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, + __LINE__); + return 0; + } + + clear_attention(); + atten_code = read_result_register(); + + switch (atten_code) { + /* Someone changed the CD. Mark it as changed */ + case SONY_MECH_LOADED_ATTN: + disk_changed = 1; + sony_toc_read = 0; + sony_audio_status = CDROM_AUDIO_NO_STATUS; + sony_blocks_left = 0; + break; + + case SONY_SPIN_DOWN_COMPLETE_ATTN: + /* Mark the disk as spun down. */ + sony_spun_up = 0; + break; + + case SONY_AUDIO_PLAY_DONE_ATTN: + sony_audio_status = CDROM_AUDIO_COMPLETED; + read_subcode(); + break; + + case SONY_EJECT_PUSHED_ATTN: + if (is_auto_eject) { + sony_audio_status = CDROM_AUDIO_INVALID; + } + break; + + case SONY_LEAD_IN_ERR_ATTN: + case SONY_LEAD_OUT_ERR_ATTN: + case SONY_DATA_TRACK_ERR_ATTN: + case SONY_AUDIO_PLAYBACK_ERR_ATTN: + sony_audio_status = CDROM_AUDIO_ERROR; + break; + } + + num_consecutive_attentions++; + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); + return 1; + } else if (abort_read_started) { + while (is_result_reg_not_empty()) { + val = read_result_register(); + } + clear_data_ready(); + clear_result_ready(); + /* Clear out the data */ + while (is_data_requested()) { + val = read_data_register(); + } + abort_read_started = 0; + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); + return 1; + } + + num_consecutive_attentions = 0; +#if 0 + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); +#endif + return 0; +} + + +/* Convert from an integer 0-99 to BCD */ +static inline unsigned int int_to_bcd(unsigned int val) +{ + int retval; + + + retval = (val / 10) << 4; + retval = retval | val % 10; + return retval; +} + + +/* Convert from BCD to an integer from 0-99 */ +static unsigned int bcd_to_int(unsigned int bcd) +{ + return (((bcd >> 4) & 0x0f) * 10) + (bcd & 0x0f); +} + + +/* + * Convert a logical sector value (like the OS would want to use for + * a block device) to an MSF format. + */ +static void log_to_msf(unsigned int log, unsigned char *msf) +{ + log = log + LOG_START_OFFSET; + msf[0] = int_to_bcd(log / 4500); + log = log % 4500; + msf[1] = int_to_bcd(log / 75); + msf[2] = int_to_bcd(log % 75); +} + + +/* + * Convert an MSF format to a logical sector. + */ +static unsigned int msf_to_log(unsigned char *msf) +{ + unsigned int log; + + + log = msf[2]; + log += msf[1] * 75; + log += msf[0] * 4500; + log = log - LOG_START_OFFSET; + + return log; +} + + +/* + * Take in integer size value and put it into a buffer like + * the drive would want to see a number-of-sector value. + */ +static void size_to_buf(unsigned int size, unsigned char *buf) +{ + buf[0] = size / 65536; + size = size % 65536; + buf[1] = size / 256; + buf[2] = size % 256; +} + +/* Starts a read operation. Returns 0 on success and 1 on failure. + The read operation used here allows multiple sequential sectors + to be read and status returned for each sector. The driver will + read the output one at a time as the requests come and abort the + operation if the requested sector is not the next one from the + drive. */ +static int +start_request(unsigned int sector, unsigned int nsect) +{ + unsigned char params[6]; + unsigned long retry_count; + + + pr_debug(PFX "Entering %s\n", __FUNCTION__); + log_to_msf(sector, params); + size_to_buf(nsect, ¶ms[3]); + + /* + * Clear any outstanding attentions and wait for the drive to + * complete any pending operations. + */ + while (handle_sony_cd_attention()); + + retry_count = jiffies + SONY_JIFFIES_TIMEOUT; + while (time_before(jiffies, retry_count) && (is_busy())) { + sony_sleep(); + + while (handle_sony_cd_attention()); + } + + if (is_busy()) { + printk(KERN_NOTICE PFX "Timeout while waiting " + "to issue command\n"); + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); + return 1; + } else { + /* Issue the command */ + clear_result_ready(); + clear_param_reg(); + + write_params(params, 6); + write_cmd(SONY_READ_BLKERR_STAT_CMD); + + sony_blocks_left = nsect * 4; + sony_next_block = sector * 4; + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); + return 0; + } + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); +} + +/* Abort a pending read operation. Clear all the drive status variables. */ +static void abort_read(void) +{ + unsigned char result_reg[2]; + int result_size; + volatile int val; + + + do_sony_cd_cmd(SONY_ABORT_CMD, NULL, 0, result_reg, &result_size); + if ((result_reg[0] & 0xf0) == 0x20) { + printk(KERN_ERR PFX "Aborting read, %s error\n", + translate_error(result_reg[1])); + } + + while (is_result_reg_not_empty()) { + val = read_result_register(); + } + clear_data_ready(); + clear_result_ready(); + /* Clear out the data */ + while (is_data_requested()) { + val = read_data_register(); + } + + sony_blocks_left = 0; +} + +/* Called when the timer times out. This will abort the + pending read operation. */ +static void handle_abort_timeout(unsigned long data) +{ + pr_debug(PFX "Entering %s\n", __FUNCTION__); + /* If it is in use, ignore it. */ + if (down_trylock(&sony_sem) == 0) { + /* We can't use abort_read(), because it will sleep + or schedule in the timer interrupt. Just start + the operation, finish it on the next access to + the drive. */ + clear_result_ready(); + clear_param_reg(); + write_cmd(SONY_ABORT_CMD); + + sony_blocks_left = 0; + abort_read_started = 1; + up(&sony_sem); + } + pr_debug(PFX "Leaving %s\n", __FUNCTION__); +} + +/* Actually get one sector of data from the drive. */ +static void +input_data_sector(char *buffer) +{ + pr_debug(PFX "Entering %s\n", __FUNCTION__); + + /* If an XA disk on a CDU31A, skip the first 12 bytes of data from + the disk. The real data is after that. We can use audio_buffer. */ + if (sony_xa_mode) + insb(sony_cd_read_reg, audio_buffer, CD_XA_HEAD); + + clear_data_ready(); + + insb(sony_cd_read_reg, buffer, 2048); + + /* If an XA disk, we have to clear out the rest of the unused + error correction data. We can use audio_buffer for that. */ + if (sony_xa_mode) + insb(sony_cd_read_reg, audio_buffer, CD_XA_TAIL); + + pr_debug(PFX "Leaving %s\n", __FUNCTION__); +} + +/* read data from the drive. Note the nsect must be <= 4. */ +static void +read_data_block(char *buffer, + unsigned int block, + unsigned int nblocks, + unsigned char res_reg[], int *res_size) +{ + unsigned long retry_count; + + pr_debug(PFX "Entering %s\n", __FUNCTION__); + + res_reg[0] = 0; + res_reg[1] = 0; + *res_size = 0; + + /* Wait for the drive to tell us we have something */ + retry_count = jiffies + SONY_JIFFIES_TIMEOUT; + while (time_before(jiffies, retry_count) && !(is_data_ready())) { + while (handle_sony_cd_attention()); + + sony_sleep(); + } + if (!(is_data_ready())) { + if (is_result_ready()) { + get_result(res_reg, res_size); + if ((res_reg[0] & 0xf0) != 0x20) { + printk(KERN_NOTICE PFX "Got result that should" + " have been error: %d\n", res_reg[0]); + res_reg[0] = 0x20; + res_reg[1] = SONY_BAD_DATA_ERR; + *res_size = 2; + } + abort_read(); + } else { + pr_debug(PFX "timeout out %d\n", __LINE__); + res_reg[0] = 0x20; + res_reg[1] = SONY_TIMEOUT_OP_ERR; + *res_size = 2; + abort_read(); + } + } else { + input_data_sector(buffer); + sony_blocks_left -= nblocks; + sony_next_block += nblocks; + + /* Wait for the status from the drive. */ + retry_count = jiffies + SONY_JIFFIES_TIMEOUT; + while (time_before(jiffies, retry_count) + && !(is_result_ready())) { + while (handle_sony_cd_attention()); + + sony_sleep(); + } + + if (!is_result_ready()) { + pr_debug(PFX "timeout out %d\n", __LINE__); + res_reg[0] = 0x20; + res_reg[1] = SONY_TIMEOUT_OP_ERR; + *res_size = 2; + abort_read(); + } else { + get_result(res_reg, res_size); + + /* If we got a buffer status, handle that. */ + if ((res_reg[0] & 0xf0) == 0x50) { + + if ((res_reg[0] == + SONY_NO_CIRC_ERR_BLK_STAT) + || (res_reg[0] == + SONY_NO_LECC_ERR_BLK_STAT) + || (res_reg[0] == + SONY_RECOV_LECC_ERR_BLK_STAT)) { + /* nothing here */ + } else { + printk(KERN_ERR PFX "Data block " + "error: 0x%x\n", res_reg[0]); + res_reg[0] = 0x20; + res_reg[1] = SONY_BAD_DATA_ERR; + *res_size = 2; + } + + /* Final transfer is done for read command, get final result. */ + if (sony_blocks_left == 0) { + get_result(res_reg, res_size); + } + } else if ((res_reg[0] & 0xf0) != 0x20) { + /* The drive gave me bad status, I don't know what to do. + Reset the driver and return an error. */ + printk(KERN_ERR PFX "Invalid block " + "status: 0x%x\n", res_reg[0]); + restart_on_error(); + res_reg[0] = 0x20; + res_reg[1] = SONY_BAD_DATA_ERR; + *res_size = 2; + } + } + } + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); +} + + +/* + * The OS calls this to perform a read or write operation to the drive. + * Write obviously fail. Reads to a read ahead of sony_buffer_size + * bytes to help speed operations. This especially helps since the OS + * uses 1024 byte blocks and the drive uses 2048 byte blocks. Since most + * data access on a CD is done sequentially, this saves a lot of operations. + */ +static void do_cdu31a_request(request_queue_t * q) +{ + struct request *req; + int block, nblock, num_retries; + unsigned char res_reg[12]; + unsigned int res_size; + + pr_debug(PFX "Entering %s\n", __FUNCTION__); + + spin_unlock_irq(q->queue_lock); + if (down_interruptible(&sony_sem)) { + spin_lock_irq(q->queue_lock); + return; + } + + /* Get drive status before doing anything. */ + while (handle_sony_cd_attention()); + + /* Make sure we have a valid TOC. */ + sony_get_toc(); + + + /* Make sure the timer is cancelled. */ + del_timer(&cdu31a_abort_timer); + + while (1) { + /* + * The beginning here is stolen from the hard disk driver. I hope + * it's right. + */ + req = elv_next_request(q); + if (!req) + goto end_do_cdu31a_request; + + if (!sony_spun_up) + scd_spinup(); + + block = req->sector; + nblock = req->nr_sectors; + pr_debug(PFX "request at block %d, length %d blocks\n", + block, nblock); + if (!sony_toc_read) { + printk(KERN_NOTICE PFX "TOC not read\n"); + end_request(req, 0); + continue; + } + + /* WTF??? */ +// if (!(req->flags & REQ_CMD)) +// continue; + if (rq_data_dir(req) == WRITE) { + end_request(req, 0); + continue; + } + + /* + * If the block address is invalid or the request goes beyond the end of + * the media, return an error. + */ + if (((block + nblock) / 4) >= sony_toc.lead_out_start_lba) { + printk(KERN_NOTICE PFX "Request past end of media\n"); + end_request(req, 0); + continue; + } + + if (nblock > 4) + nblock = 4; + num_retries = 0; + + try_read_again: + while (handle_sony_cd_attention()); + + if (!sony_toc_read) { + printk(KERN_NOTICE PFX "TOC not read\n"); + end_request(req, 0); + continue; + } + + /* If no data is left to be read from the drive, start the + next request. */ + if (sony_blocks_left == 0) { + if (start_request(block / 4, nblock / 4)) { + end_request(req, 0); + continue; + } + } + /* If the requested block is not the next one waiting in + the driver, abort the current operation and start a + new one. */ + else if (block != sony_next_block) { + pr_debug(PFX "Read for block %d, expected %d\n", + block, sony_next_block); + abort_read(); + if (!sony_toc_read) { + printk(KERN_NOTICE PFX "TOC not read\n"); + end_request(req, 0); + continue; + } + if (start_request(block / 4, nblock / 4)) { + printk(KERN_NOTICE PFX "start request failed\n"); + end_request(req, 0); + continue; + } + } + + read_data_block(req->buffer, block, nblock, res_reg, &res_size); + + if (res_reg[0] != 0x20) { + if (!end_that_request_first(req, 1, nblock)) { + spin_lock_irq(q->queue_lock); + blkdev_dequeue_request(req); + end_that_request_last(req, 1); + spin_unlock_irq(q->queue_lock); + } + continue; + } + + if (num_retries > MAX_CDU31A_RETRIES) { + end_request(req, 0); + continue; + } + + num_retries++; + if (res_reg[1] == SONY_NOT_SPIN_ERR) { + do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, + &res_size); + } else { + printk(KERN_NOTICE PFX "%s error for block %d, nblock %d\n", + translate_error(res_reg[1]), block, nblock); + } + goto try_read_again; + } + end_do_cdu31a_request: +#if 0 + /* After finished, cancel any pending operations. */ + abort_read(); +#else + /* Start a timer to time out after a while to disable + the read. */ + cdu31a_abort_timer.expires = jiffies + 2 * HZ; /* Wait 2 seconds */ + add_timer(&cdu31a_abort_timer); +#endif + + up(&sony_sem); + spin_lock_irq(q->queue_lock); + pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); +} + + +/* + * Read the table of contents from the drive and set up TOC if + * successful. + */ +static void sony_get_toc(void) +{ + unsigned char res_reg[2]; + unsigned int res_size; + unsigned char parms[1]; + int session; + int num_spin_ups; + int totaltracks = 0; + int mint = 99; + int maxt = 0; + + pr_debug(PFX "Entering %s\n", __FUNCTION__); + + num_spin_ups = 0; + if (!sony_toc_read) { + respinup_on_gettoc: + /* Ignore the result, since it might error if spinning already. */ + do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, + &res_size); + + do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg, + &res_size); + + /* The drive sometimes returns error 0. I don't know why, but ignore + it. It seems to mean the drive has already done the operation. */ + if ((res_size < 2) + || ((res_reg[0] != 0) && (res_reg[1] != 0))) { + /* If the drive is already playing, it's ok. */ + if ((res_reg[1] == SONY_AUDIO_PLAYING_ERR) + || (res_reg[1] == 0)) { + goto gettoc_drive_spinning; + } + + /* If the drive says it is not spun up (even though we just did it!) + then retry the operation at least a few times. */ + if ((res_reg[1] == SONY_NOT_SPIN_ERR) + && (num_spin_ups < MAX_CDU31A_RETRIES)) { + num_spin_ups++; + goto respinup_on_gettoc; + } + + printk("cdu31a: Error reading TOC: %x %s\n", + res_reg[0], translate_error(res_reg[1])); + return; + } + + gettoc_drive_spinning: + + /* The idea here is we keep asking for sessions until the command + fails. Then we know what the last valid session on the disk is. + No need to check session 0, since session 0 is the same as session + 1; the command returns different information if you give it 0. + */ +#if DEBUG + memset(&sony_toc, 0x0e, sizeof(sony_toc)); + memset(&single_toc, 0x0f, sizeof(single_toc)); +#endif + session = 1; + while (1) { +/* This seems to slow things down enough to make it work. This + * appears to be a problem in do_sony_cd_cmd. This printk seems + * to address the symptoms... -Erik */ + pr_debug(PFX "Trying session %d\n", session); + parms[0] = session; + do_sony_cd_cmd(SONY_READ_TOC_SPEC_CMD, + parms, 1, res_reg, &res_size); + + pr_debug(PFX "%2.2x %2.2x\n", res_reg[0], res_reg[1]); + + if ((res_size < 2) + || ((res_reg[0] & 0xf0) == 0x20)) { + /* An error reading the TOC, this must be past the last session. */ + if (session == 1) + printk + ("Yikes! Couldn't read any sessions!"); + break; + } + pr_debug(PFX "Reading session %d\n", session); + + parms[0] = session; + do_sony_cd_cmd(SONY_REQ_TOC_DATA_SPEC_CMD, + parms, + 1, + (unsigned char *) &single_toc, + &res_size); + if ((res_size < 2) + || ((single_toc.exec_status[0] & 0xf0) == + 0x20)) { + printk(KERN_ERR PFX "Error reading " + "session %d: %x %s\n", + session, single_toc.exec_status[0], + translate_error(single_toc. + exec_status[1])); + /* An error reading the TOC. Return without sony_toc_read + set. */ + return; + } + pr_debug(PFX "add0 %01x, con0 %01x, poi0 %02x, " + "1st trk %d, dsktyp %x, dum0 %x\n", + single_toc.address0, single_toc.control0, + single_toc.point0, + bcd_to_int(single_toc.first_track_num), + single_toc.disk_type, single_toc.dummy0); + pr_debug(PFX "add1 %01x, con1 %01x, poi1 %02x, " + "lst trk %d, dummy1 %x, dum2 %x\n", + single_toc.address1, single_toc.control1, + single_toc.point1, + bcd_to_int(single_toc.last_track_num), + single_toc.dummy1, single_toc.dummy2); + pr_debug(PFX "add2 %01x, con2 %01x, poi2 %02x " + "leadout start min %d, sec %d, frame %d\n", + single_toc.address2, single_toc.control2, + single_toc.point2, + bcd_to_int(single_toc.lead_out_start_msf[0]), + bcd_to_int(single_toc.lead_out_start_msf[1]), + bcd_to_int(single_toc.lead_out_start_msf[2])); + if (res_size > 18 && single_toc.pointb0 > 0xaf) + pr_debug(PFX "addb0 %01x, conb0 %01x, poib0 %02x, nextsession min %d, sec %d, frame %d\n" + "#mode5_ptrs %02d, max_start_outer_leadout_msf min %d, sec %d, frame %d\n", + single_toc.addressb0, + single_toc.controlb0, + single_toc.pointb0, + bcd_to_int(single_toc. + next_poss_prog_area_msf + [0]), + bcd_to_int(single_toc. + next_poss_prog_area_msf + [1]), + bcd_to_int(single_toc. + next_poss_prog_area_msf + [2]), + single_toc.num_mode_5_pointers, + bcd_to_int(single_toc. + max_start_outer_leadout_msf + [0]), + bcd_to_int(single_toc. + max_start_outer_leadout_msf + [1]), + bcd_to_int(single_toc. + max_start_outer_leadout_msf + [2])); + if (res_size > 27 && single_toc.pointb1 > 0xaf) + pr_debug(PFX "addb1 %01x, conb1 %01x, poib1 %02x, %x %x %x %x #skipint_ptrs %d, #skiptrkassign %d %x\n", + single_toc.addressb1, + single_toc.controlb1, + single_toc.pointb1, + single_toc.dummyb0_1[0], + single_toc.dummyb0_1[1], + single_toc.dummyb0_1[2], + single_toc.dummyb0_1[3], + single_toc.num_skip_interval_pointers, + single_toc.num_skip_track_assignments, + single_toc.dummyb0_2); + if (res_size > 36 && single_toc.pointb2 > 0xaf) + pr_debug(PFX "addb2 %01x, conb2 %01x, poib2 %02x, %02x %02x %02x %02x %02x %02x %02x\n", + single_toc.addressb2, + single_toc.controlb2, + single_toc.pointb2, + single_toc.tracksb2[0], + single_toc.tracksb2[1], + single_toc.tracksb2[2], + single_toc.tracksb2[3], + single_toc.tracksb2[4], + single_toc.tracksb2[5], + single_toc.tracksb2[6]); + if (res_size > 45 && single_toc.pointb3 > 0xaf) + pr_debug(PFX "addb3 %01x, conb3 %01x, poib3 %02x, %02x %02x %02x %02x %02x %02x %02x\n", + single_toc.addressb3, + single_toc.controlb3, + single_toc.pointb3, + single_toc.tracksb3[0], + single_toc.tracksb3[1], + single_toc.tracksb3[2], + single_toc.tracksb3[3], + single_toc.tracksb3[4], + single_toc.tracksb3[5], + single_toc.tracksb3[6]); + if (res_size > 54 && single_toc.pointb4 > 0xaf) + pr_debug(PFX "addb4 %01x, conb4 %01x, poib4 %02x, %02x %02x %02x %02x %02x %02x %02x\n", + single_toc.addressb4, + single_toc.controlb4, + single_toc.pointb4, + single_toc.tracksb4[0], + single_toc.tracksb4[1], + single_toc.tracksb4[2], + single_toc.tracksb4[3], + single_toc.tracksb4[4], + single_toc.tracksb4[5], + single_toc.tracksb4[6]); + if (res_size > 63 && single_toc.pointc0 > 0xaf) + pr_debug(PFX "addc0 %01x, conc0 %01x, poic0 %02x, %02x %02x %02x %02x %02x %02x %02x\n", + single_toc.addressc0, + single_toc.controlc0, + single_toc.pointc0, + single_toc.dummyc0[0], + single_toc.dummyc0[1], + single_toc.dummyc0[2], + single_toc.dummyc0[3], + single_toc.dummyc0[4], + single_toc.dummyc0[5], + single_toc.dummyc0[6]); +#undef DEBUG +#define DEBUG 0 + + sony_toc.lead_out_start_msf[0] = + bcd_to_int(single_toc.lead_out_start_msf[0]); + sony_toc.lead_out_start_msf[1] = + bcd_to_int(single_toc.lead_out_start_msf[1]); + sony_toc.lead_out_start_msf[2] = + bcd_to_int(single_toc.lead_out_start_msf[2]); + sony_toc.lead_out_start_lba = + single_toc.lead_out_start_lba = + msf_to_log(sony_toc.lead_out_start_msf); + + /* For points that do not exist, move the data over them + to the right location. */ + if (single_toc.pointb0 != 0xb0) { + memmove(((char *) &single_toc) + 27, + ((char *) &single_toc) + 18, + res_size - 18); + res_size += 9; + } else if (res_size > 18) { + sony_toc.lead_out_start_msf[0] = + bcd_to_int(single_toc. + max_start_outer_leadout_msf + [0]); + sony_toc.lead_out_start_msf[1] = + bcd_to_int(single_toc. + max_start_outer_leadout_msf + [1]); + sony_toc.lead_out_start_msf[2] = + bcd_to_int(single_toc. + max_start_outer_leadout_msf + [2]); + sony_toc.lead_out_start_lba = + msf_to_log(sony_toc. + lead_out_start_msf); + } + if (single_toc.pointb1 != 0xb1) { + memmove(((char *) &single_toc) + 36, + ((char *) &single_toc) + 27, + res_size - 27); + res_size += 9; + } + if (single_toc.pointb2 != 0xb2) { + memmove(((char *) &single_toc) + 45, + ((char *) &single_toc) + 36, + res_size - 36); + res_size += 9; + } + if (single_toc.pointb3 != 0xb3) { + memmove(((char *) &single_toc) + 54, + ((char *) &single_toc) + 45, + res_size - 45); + res_size += 9; + } + if (single_toc.pointb4 != 0xb4) { + memmove(((char *) &single_toc) + 63, + ((char *) &single_toc) + 54, + res_size - 54); + res_size += 9; + } + if (single_toc.pointc0 != 0xc0) { + memmove(((char *) &single_toc) + 72, + ((char *) &single_toc) + 63, + res_size - 63); + res_size += 9; + } +#if DEBUG + printk(PRINT_INFO PFX "start track lba %u, " + "leadout start lba %u\n", + single_toc.start_track_lba, + single_toc.lead_out_start_lba); + { + int i; + for (i = 0; + i < + 1 + + bcd_to_int(single_toc.last_track_num) + - + bcd_to_int(single_toc. + first_track_num); i++) { + printk(KERN_INFO PFX "trk %02d: add 0x%01x, con 0x%01x, track %02d, start min %02d, sec %02d, frame %02d\n", + i, + single_toc.tracks[i].address, + single_toc.tracks[i].control, + bcd_to_int(single_toc. + tracks[i].track), + bcd_to_int(single_toc. + tracks[i]. + track_start_msf + [0]), + bcd_to_int(single_toc. + tracks[i]. + track_start_msf + [1]), + bcd_to_int(single_toc. + tracks[i]. + track_start_msf + [2])); + if (mint > + bcd_to_int(single_toc. + tracks[i].track)) + mint = + bcd_to_int(single_toc. + tracks[i]. + track); + if (maxt < + bcd_to_int(single_toc. + tracks[i].track)) + maxt = + bcd_to_int(single_toc. + tracks[i]. + track); + } + printk(KERN_INFO PFX "min track number %d, " + "max track number %d\n", + mint, maxt); + } +#endif + + /* prepare a special table of contents for a CD-I disc. They don't have one. */ + if (single_toc.disk_type == 0x10 && + single_toc.first_track_num == 2 && + single_toc.last_track_num == 2 /* CD-I */ ) { + sony_toc.tracks[totaltracks].address = 1; + sony_toc.tracks[totaltracks].control = 4; /* force data tracks */ + sony_toc.tracks[totaltracks].track = 1; + sony_toc.tracks[totaltracks]. + track_start_msf[0] = 0; + sony_toc.tracks[totaltracks]. + track_start_msf[1] = 2; + sony_toc.tracks[totaltracks]. + track_start_msf[2] = 0; + mint = maxt = 1; + totaltracks++; + } else + /* gather track entries from this session */ + { + int i; + for (i = 0; + i < + 1 + + bcd_to_int(single_toc.last_track_num) + - + bcd_to_int(single_toc. + first_track_num); + i++, totaltracks++) { + sony_toc.tracks[totaltracks]. + address = + single_toc.tracks[i].address; + sony_toc.tracks[totaltracks]. + control = + single_toc.tracks[i].control; + sony_toc.tracks[totaltracks]. + track = + bcd_to_int(single_toc. + tracks[i].track); + sony_toc.tracks[totaltracks]. + track_start_msf[0] = + bcd_to_int(single_toc. + tracks[i]. + track_start_msf[0]); + sony_toc.tracks[totaltracks]. + track_start_msf[1] = + bcd_to_int(single_toc. + tracks[i]. + track_start_msf[1]); + sony_toc.tracks[totaltracks]. + track_start_msf[2] = + bcd_to_int(single_toc. + tracks[i]. + track_start_msf[2]); + if (i == 0) + single_toc. + start_track_lba = + msf_to_log(sony_toc. + tracks + [totaltracks]. + track_start_msf); + if (mint > + sony_toc.tracks[totaltracks]. + track) + mint = + sony_toc. + tracks[totaltracks]. + track; + if (maxt < + sony_toc.tracks[totaltracks]. + track) + maxt = + sony_toc. + tracks[totaltracks]. + track; + } + } + sony_toc.first_track_num = mint; + sony_toc.last_track_num = maxt; + /* Disk type of last session wins. For example: + CD-Extra has disk type 0 for the first session, so + a dumb HiFi CD player thinks it is a plain audio CD. + We are interested in the disk type of the last session, + which is 0x20 (XA) for CD-Extra, so we can access the + data track ... */ + sony_toc.disk_type = single_toc.disk_type; + sony_toc.sessions = session; + + /* don't believe everything :-) */ + if (session == 1) + single_toc.start_track_lba = 0; + sony_toc.start_track_lba = + single_toc.start_track_lba; + + if (session > 1 && single_toc.pointb0 == 0xb0 && + sony_toc.lead_out_start_lba == + single_toc.lead_out_start_lba) { + break; + } + + /* Let's not get carried away... */ + if (session > 40) { + printk(KERN_NOTICE PFX "too many sessions: " + "%d\n", session); + break; + } + session++; + } + sony_toc.track_entries = totaltracks; + /* add one entry for the LAST track with track number CDROM_LEADOUT */ + sony_toc.tracks[totaltracks].address = single_toc.address2; + sony_toc.tracks[totaltracks].control = single_toc.control2; + sony_toc.tracks[totaltracks].track = CDROM_LEADOUT; + sony_toc.tracks[totaltracks].track_start_msf[0] = + sony_toc.lead_out_start_msf[0]; + sony_toc.tracks[totaltracks].track_start_msf[1] = + sony_toc.lead_out_start_msf[1]; + sony_toc.tracks[totaltracks].track_start_msf[2] = + sony_toc.lead_out_start_msf[2]; + + sony_toc_read = 1; + + pr_debug(PFX "Disk session %d, start track: %d, " + "stop track: %d\n", + session, single_toc.start_track_lba, + single_toc.lead_out_start_lba); + } + pr_debug(PFX "Leaving %s\n", __FUNCTION__); +} + + +/* + * Uniform cdrom interface function + * return multisession offset and sector information + */ +static int scd_get_last_session(struct cdrom_device_info *cdi, + struct cdrom_multisession *ms_info) +{ + if (ms_info == NULL) + return 1; + + if (!sony_toc_read) { + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + sony_get_toc(); + up(&sony_sem); + } + + ms_info->addr_format = CDROM_LBA; + ms_info->addr.lba = sony_toc.start_track_lba; + ms_info->xa_flag = sony_toc.disk_type == SONY_XA_DISK_TYPE || + sony_toc.disk_type == 0x10 /* CDI */ ; + + return 0; +} + +/* + * Search for a specific track in the table of contents. + */ +static int find_track(int track) +{ + int i; + + for (i = 0; i <= sony_toc.track_entries; i++) { + if (sony_toc.tracks[i].track == track) { + return i; + } + } + + return -1; +} + + +/* + * Read the subcode and put it in last_sony_subcode for future use. + */ +static int read_subcode(void) +{ + unsigned int res_size; + + + do_sony_cd_cmd(SONY_REQ_SUBCODE_ADDRESS_CMD, + NULL, + 0, (unsigned char *) &last_sony_subcode, &res_size); + if ((res_size < 2) + || ((last_sony_subcode.exec_status[0] & 0xf0) == 0x20)) { + printk(KERN_ERR PFX "Sony CDROM error %s (read_subcode)\n", + translate_error(last_sony_subcode.exec_status[1])); + return -EIO; + } + + last_sony_subcode.track_num = + bcd_to_int(last_sony_subcode.track_num); + last_sony_subcode.index_num = + bcd_to_int(last_sony_subcode.index_num); + last_sony_subcode.abs_msf[0] = + bcd_to_int(last_sony_subcode.abs_msf[0]); + last_sony_subcode.abs_msf[1] = + bcd_to_int(last_sony_subcode.abs_msf[1]); + last_sony_subcode.abs_msf[2] = + bcd_to_int(last_sony_subcode.abs_msf[2]); + + last_sony_subcode.rel_msf[0] = + bcd_to_int(last_sony_subcode.rel_msf[0]); + last_sony_subcode.rel_msf[1] = + bcd_to_int(last_sony_subcode.rel_msf[1]); + last_sony_subcode.rel_msf[2] = + bcd_to_int(last_sony_subcode.rel_msf[2]); + return 0; +} + +/* + * Uniform cdrom interface function + * return the media catalog number found on some older audio cds + */ +static int +scd_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) +{ + unsigned char resbuffer[2 + 14]; + unsigned char *mcnp = mcn->medium_catalog_number; + unsigned char *resp = resbuffer + 3; + unsigned int res_size; + + memset(mcn->medium_catalog_number, 0, 14); + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + do_sony_cd_cmd(SONY_REQ_UPC_EAN_CMD, + NULL, 0, resbuffer, &res_size); + up(&sony_sem); + if ((res_size < 2) || ((resbuffer[0] & 0xf0) == 0x20)); + else { + /* packed bcd to single ASCII digits */ + *mcnp++ = (*resp >> 4) + '0'; + *mcnp++ = (*resp++ & 0x0f) + '0'; + *mcnp++ = (*resp >> 4) + '0'; + *mcnp++ = (*resp++ & 0x0f) + '0'; + *mcnp++ = (*resp >> 4) + '0'; + *mcnp++ = (*resp++ & 0x0f) + '0'; + *mcnp++ = (*resp >> 4) + '0'; + *mcnp++ = (*resp++ & 0x0f) + '0'; + *mcnp++ = (*resp >> 4) + '0'; + *mcnp++ = (*resp++ & 0x0f) + '0'; + *mcnp++ = (*resp >> 4) + '0'; + *mcnp++ = (*resp++ & 0x0f) + '0'; + *mcnp++ = (*resp >> 4) + '0'; + } + *mcnp = '\0'; + return 0; +} + + +/* + * Get the subchannel info like the CDROMSUBCHNL command wants to see it. If + * the drive is playing, the subchannel needs to be read (since it would be + * changing). If the drive is paused or completed, the subcode information has + * already been stored, just use that. The ioctl call wants things in decimal + * (not BCD), so all the conversions are done. + */ +static int sony_get_subchnl_info(struct cdrom_subchnl *schi) +{ + /* Get attention stuff */ + while (handle_sony_cd_attention()); + + sony_get_toc(); + if (!sony_toc_read) { + return -EIO; + } + + switch (sony_audio_status) { + case CDROM_AUDIO_NO_STATUS: + case CDROM_AUDIO_PLAY: + if (read_subcode() < 0) { + return -EIO; + } + break; + + case CDROM_AUDIO_PAUSED: + case CDROM_AUDIO_COMPLETED: + break; + +#if 0 + case CDROM_AUDIO_NO_STATUS: + schi->cdsc_audiostatus = sony_audio_status; + return 0; + break; +#endif + case CDROM_AUDIO_INVALID: + case CDROM_AUDIO_ERROR: + default: + return -EIO; + } + + schi->cdsc_audiostatus = sony_audio_status; + schi->cdsc_adr = last_sony_subcode.address; + schi->cdsc_ctrl = last_sony_subcode.control; + schi->cdsc_trk = last_sony_subcode.track_num; + schi->cdsc_ind = last_sony_subcode.index_num; + if (schi->cdsc_format == CDROM_MSF) { + schi->cdsc_absaddr.msf.minute = + last_sony_subcode.abs_msf[0]; + schi->cdsc_absaddr.msf.second = + last_sony_subcode.abs_msf[1]; + schi->cdsc_absaddr.msf.frame = + last_sony_subcode.abs_msf[2]; + + schi->cdsc_reladdr.msf.minute = + last_sony_subcode.rel_msf[0]; + schi->cdsc_reladdr.msf.second = + last_sony_subcode.rel_msf[1]; + schi->cdsc_reladdr.msf.frame = + last_sony_subcode.rel_msf[2]; + } else if (schi->cdsc_format == CDROM_LBA) { + schi->cdsc_absaddr.lba = + msf_to_log(last_sony_subcode.abs_msf); + schi->cdsc_reladdr.lba = + msf_to_log(last_sony_subcode.rel_msf); + } + + return 0; +} + +/* Get audio data from the drive. This is fairly complex because I + am looking for status and data at the same time, but if I get status + then I just look for data. I need to get the status immediately so + the switch from audio to data tracks will happen quickly. */ +static void +read_audio_data(char *buffer, unsigned char res_reg[], int *res_size) +{ + unsigned long retry_count; + int result_read; + + + res_reg[0] = 0; + res_reg[1] = 0; + *res_size = 0; + result_read = 0; + + /* Wait for the drive to tell us we have something */ + retry_count = jiffies + SONY_JIFFIES_TIMEOUT; + continue_read_audio_wait: + while (time_before(jiffies, retry_count) && !(is_data_ready()) + && !(is_result_ready() || result_read)) { + while (handle_sony_cd_attention()); + + sony_sleep(); + } + if (!(is_data_ready())) { + if (is_result_ready() && !result_read) { + get_result(res_reg, res_size); + + /* Read block status and continue waiting for data. */ + if ((res_reg[0] & 0xf0) == 0x50) { + result_read = 1; + goto continue_read_audio_wait; + } + /* Invalid data from the drive. Shut down the operation. */ + else if ((res_reg[0] & 0xf0) != 0x20) { + printk(KERN_WARNING PFX "Got result that " + "should have been error: %d\n", + res_reg[0]); + res_reg[0] = 0x20; + res_reg[1] = SONY_BAD_DATA_ERR; + *res_size = 2; + } + abort_read(); + } else { + pr_debug(PFX "timeout out %d\n", __LINE__); + res_reg[0] = 0x20; + res_reg[1] = SONY_TIMEOUT_OP_ERR; + *res_size = 2; + abort_read(); + } + } else { + clear_data_ready(); + + /* If data block, then get 2340 bytes offset by 12. */ + if (sony_raw_data_mode) { + insb(sony_cd_read_reg, buffer + CD_XA_HEAD, + CD_FRAMESIZE_RAW1); + } else { + /* Audio gets the whole 2352 bytes. */ + insb(sony_cd_read_reg, buffer, CD_FRAMESIZE_RAW); + } + + /* If I haven't already gotten the result, get it now. */ + if (!result_read) { + /* Wait for the drive to tell us we have something */ + retry_count = jiffies + SONY_JIFFIES_TIMEOUT; + while (time_before(jiffies, retry_count) + && !(is_result_ready())) { + while (handle_sony_cd_attention()); + + sony_sleep(); + } + + if (!is_result_ready()) { + pr_debug(PFX "timeout out %d\n", __LINE__); + res_reg[0] = 0x20; + res_reg[1] = SONY_TIMEOUT_OP_ERR; + *res_size = 2; + abort_read(); + return; + } else { + get_result(res_reg, res_size); + } + } + + if ((res_reg[0] & 0xf0) == 0x50) { + if ((res_reg[0] == SONY_NO_CIRC_ERR_BLK_STAT) + || (res_reg[0] == SONY_NO_LECC_ERR_BLK_STAT) + || (res_reg[0] == SONY_RECOV_LECC_ERR_BLK_STAT) + || (res_reg[0] == SONY_NO_ERR_DETECTION_STAT)) { + /* Ok, nothing to do. */ + } else { + printk(KERN_ERR PFX "Data block error: 0x%x\n", + res_reg[0]); + res_reg[0] = 0x20; + res_reg[1] = SONY_BAD_DATA_ERR; + *res_size = 2; + } + } else if ((res_reg[0] & 0xf0) != 0x20) { + /* The drive gave me bad status, I don't know what to do. + Reset the driver and return an error. */ + printk(KERN_NOTICE PFX "Invalid block status: 0x%x\n", + res_reg[0]); + restart_on_error(); + res_reg[0] = 0x20; + res_reg[1] = SONY_BAD_DATA_ERR; + *res_size = 2; + } + } +} + +/* Perform a raw data read. This will automatically detect the + track type and read the proper data (audio or data). */ +static int read_audio(struct cdrom_read_audio *ra) +{ + int retval; + unsigned char params[2]; + unsigned char res_reg[12]; + unsigned int res_size; + unsigned int cframe; + + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + if (!sony_spun_up) + scd_spinup(); + + /* Set the drive to do raw operations. */ + params[0] = SONY_SD_DECODE_PARAM; + params[1] = 0x06 | sony_raw_data_mode; + do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, + params, 2, res_reg, &res_size); + if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_ERR PFX "Unable to set decode params: 0x%2.2x\n", + res_reg[1]); + retval = -EIO; + goto out_up; + } + + /* From here down, we have to goto exit_read_audio instead of returning + because the drive parameters have to be set back to data before + return. */ + + retval = 0; + if (start_request(ra->addr.lba, ra->nframes)) { + retval = -EIO; + goto exit_read_audio; + } + + /* For every requested frame. */ + cframe = 0; + while (cframe < ra->nframes) { + read_audio_data(audio_buffer, res_reg, &res_size); + if ((res_reg[0] & 0xf0) == 0x20) { + if (res_reg[1] == SONY_BAD_DATA_ERR) { + printk(KERN_ERR PFX "Data error on audio " + "sector %d\n", + ra->addr.lba + cframe); + } else if (res_reg[1] == SONY_ILL_TRACK_R_ERR) { + /* Illegal track type, change track types and start over. */ + sony_raw_data_mode = + (sony_raw_data_mode) ? 0 : 1; + + /* Set the drive mode. */ + params[0] = SONY_SD_DECODE_PARAM; + params[1] = 0x06 | sony_raw_data_mode; + do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, + params, + 2, res_reg, &res_size); + if ((res_size < 2) + || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_ERR PFX "Unable to set " + "decode params: 0x%2.2x\n", + res_reg[1]); + retval = -EIO; + goto exit_read_audio; + } + + /* Restart the request on the current frame. */ + if (start_request + (ra->addr.lba + cframe, + ra->nframes - cframe)) { + retval = -EIO; + goto exit_read_audio; + } + + /* Don't go back to the top because don't want to get into + and infinite loop. A lot of code gets duplicated, but + that's no big deal, I don't guess. */ + read_audio_data(audio_buffer, res_reg, + &res_size); + if ((res_reg[0] & 0xf0) == 0x20) { + if (res_reg[1] == + SONY_BAD_DATA_ERR) { + printk(KERN_ERR PFX "Data error" + " on audio sector %d\n", + ra->addr.lba + + cframe); + } else { + printk(KERN_ERR PFX "Error reading audio data on sector %d: %s\n", + ra->addr.lba + cframe, + translate_error + (res_reg[1])); + retval = -EIO; + goto exit_read_audio; + } + } else if (copy_to_user(ra->buf + + (CD_FRAMESIZE_RAW + * cframe), + audio_buffer, + CD_FRAMESIZE_RAW)) { + retval = -EFAULT; + goto exit_read_audio; + } + } else { + printk(KERN_ERR PFX "Error reading audio " + "data on sector %d: %s\n", + ra->addr.lba + cframe, + translate_error(res_reg[1])); + retval = -EIO; + goto exit_read_audio; + } + } else if (copy_to_user(ra->buf + (CD_FRAMESIZE_RAW * cframe), + (char *)audio_buffer, + CD_FRAMESIZE_RAW)) { + retval = -EFAULT; + goto exit_read_audio; + } + + cframe++; + } + + get_result(res_reg, &res_size); + if ((res_reg[0] & 0xf0) == 0x20) { + printk(KERN_ERR PFX "Error return from audio read: %s\n", + translate_error(res_reg[1])); + retval = -EIO; + goto exit_read_audio; + } + + exit_read_audio: + + /* Set the drive mode back to the proper one for the disk. */ + params[0] = SONY_SD_DECODE_PARAM; + if (!sony_xa_mode) { + params[1] = 0x0f; + } else { + params[1] = 0x07; + } + do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, + params, 2, res_reg, &res_size); + if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_ERR PFX "Unable to reset decode params: 0x%2.2x\n", + res_reg[1]); + retval = -EIO; + } + + out_up: + up(&sony_sem); + + return retval; +} + +static int +do_sony_cd_cmd_chk(const char *name, + unsigned char cmd, + unsigned char *params, + unsigned int num_params, + unsigned char *result_buffer, unsigned int *result_size) +{ + do_sony_cd_cmd(cmd, params, num_params, result_buffer, + result_size); + if ((*result_size < 2) || ((result_buffer[0] & 0xf0) == 0x20)) { + printk(KERN_ERR PFX "Error %s (CDROM%s)\n", + translate_error(result_buffer[1]), name); + return -EIO; + } + return 0; +} + +/* + * Uniform cdrom interface function + * open the tray + */ +static int scd_tray_move(struct cdrom_device_info *cdi, int position) +{ + int retval; + + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + if (position == 1 /* open tray */ ) { + unsigned char res_reg[12]; + unsigned int res_size; + + do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, + &res_size); + do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, + &res_size); + + sony_audio_status = CDROM_AUDIO_INVALID; + retval = do_sony_cd_cmd_chk("EJECT", SONY_EJECT_CMD, NULL, 0, + res_reg, &res_size); + } else { + if (0 == scd_spinup()) + sony_spun_up = 1; + retval = 0; + } + up(&sony_sem); + return retval; +} + +/* + * The big ugly ioctl handler. + */ +static int scd_audio_ioctl(struct cdrom_device_info *cdi, + unsigned int cmd, void *arg) +{ + unsigned char res_reg[12]; + unsigned int res_size; + unsigned char params[7]; + int i, retval; + + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + switch (cmd) { + case CDROMSTART: /* Spin up the drive */ + retval = do_sony_cd_cmd_chk("START", SONY_SPIN_UP_CMD, NULL, + 0, res_reg, &res_size); + break; + + case CDROMSTOP: /* Spin down the drive */ + do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, + &res_size); + + /* + * Spin the drive down, ignoring the error if the disk was + * already not spinning. + */ + sony_audio_status = CDROM_AUDIO_NO_STATUS; + retval = do_sony_cd_cmd_chk("STOP", SONY_SPIN_DOWN_CMD, NULL, + 0, res_reg, &res_size); + break; + + case CDROMPAUSE: /* Pause the drive */ + if (do_sony_cd_cmd_chk + ("PAUSE", SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, + &res_size)) { + retval = -EIO; + break; + } + /* Get the current position and save it for resuming */ + if (read_subcode() < 0) { + retval = -EIO; + break; + } + cur_pos_msf[0] = last_sony_subcode.abs_msf[0]; + cur_pos_msf[1] = last_sony_subcode.abs_msf[1]; + cur_pos_msf[2] = last_sony_subcode.abs_msf[2]; + sony_audio_status = CDROM_AUDIO_PAUSED; + retval = 0; + break; + + case CDROMRESUME: /* Start the drive after being paused */ + if (sony_audio_status != CDROM_AUDIO_PAUSED) { + retval = -EINVAL; + break; + } + + do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, + &res_size); + + /* Start the drive at the saved position. */ + params[1] = int_to_bcd(cur_pos_msf[0]); + params[2] = int_to_bcd(cur_pos_msf[1]); + params[3] = int_to_bcd(cur_pos_msf[2]); + params[4] = int_to_bcd(final_pos_msf[0]); + params[5] = int_to_bcd(final_pos_msf[1]); + params[6] = int_to_bcd(final_pos_msf[2]); + params[0] = 0x03; + if (do_sony_cd_cmd_chk + ("RESUME", SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg, + &res_size) < 0) { + retval = -EIO; + break; + } + sony_audio_status = CDROM_AUDIO_PLAY; + retval = 0; + break; + + case CDROMPLAYMSF: /* Play starting at the given MSF address. */ + do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, + &res_size); + + /* The parameters are given in int, must be converted */ + for (i = 1; i < 7; i++) { + params[i] = + int_to_bcd(((unsigned char *) arg)[i - 1]); + } + params[0] = 0x03; + if (do_sony_cd_cmd_chk + ("PLAYMSF", SONY_AUDIO_PLAYBACK_CMD, params, 7, + res_reg, &res_size) < 0) { + retval = -EIO; + break; + } + + /* Save the final position for pauses and resumes */ + final_pos_msf[0] = bcd_to_int(params[4]); + final_pos_msf[1] = bcd_to_int(params[5]); + final_pos_msf[2] = bcd_to_int(params[6]); + sony_audio_status = CDROM_AUDIO_PLAY; + retval = 0; + break; + + case CDROMREADTOCHDR: /* Read the table of contents header */ + { + struct cdrom_tochdr *hdr; + + sony_get_toc(); + if (!sony_toc_read) { + retval = -EIO; + break; + } + + hdr = (struct cdrom_tochdr *) arg; + hdr->cdth_trk0 = sony_toc.first_track_num; + hdr->cdth_trk1 = sony_toc.last_track_num; + } + retval = 0; + break; + + case CDROMREADTOCENTRY: /* Read a given table of contents entry */ + { + struct cdrom_tocentry *entry; + int track_idx; + unsigned char *msf_val = NULL; + + sony_get_toc(); + if (!sony_toc_read) { + retval = -EIO; + break; + } + + entry = (struct cdrom_tocentry *) arg; + + track_idx = find_track(entry->cdte_track); + if (track_idx < 0) { + retval = -EINVAL; + break; + } + + entry->cdte_adr = + sony_toc.tracks[track_idx].address; + entry->cdte_ctrl = + sony_toc.tracks[track_idx].control; + msf_val = + sony_toc.tracks[track_idx].track_start_msf; + + /* Logical buffer address or MSF format requested? */ + if (entry->cdte_format == CDROM_LBA) { + entry->cdte_addr.lba = msf_to_log(msf_val); + } else if (entry->cdte_format == CDROM_MSF) { + entry->cdte_addr.msf.minute = *msf_val; + entry->cdte_addr.msf.second = + *(msf_val + 1); + entry->cdte_addr.msf.frame = + *(msf_val + 2); + } + } + retval = 0; + break; + + case CDROMPLAYTRKIND: /* Play a track. This currently ignores index. */ + { + struct cdrom_ti *ti = (struct cdrom_ti *) arg; + int track_idx; + + sony_get_toc(); + if (!sony_toc_read) { + retval = -EIO; + break; + } + + if ((ti->cdti_trk0 < sony_toc.first_track_num) + || (ti->cdti_trk0 > sony_toc.last_track_num) + || (ti->cdti_trk1 < ti->cdti_trk0)) { + retval = -EINVAL; + break; + } + + track_idx = find_track(ti->cdti_trk0); + if (track_idx < 0) { + retval = -EINVAL; + break; + } + params[1] = + int_to_bcd(sony_toc.tracks[track_idx]. + track_start_msf[0]); + params[2] = + int_to_bcd(sony_toc.tracks[track_idx]. + track_start_msf[1]); + params[3] = + int_to_bcd(sony_toc.tracks[track_idx]. + track_start_msf[2]); + + /* + * If we want to stop after the last track, use the lead-out + * MSF to do that. + */ + if (ti->cdti_trk1 >= sony_toc.last_track_num) { + track_idx = find_track(CDROM_LEADOUT); + } else { + track_idx = find_track(ti->cdti_trk1 + 1); + } + if (track_idx < 0) { + retval = -EINVAL; + break; + } + params[4] = + int_to_bcd(sony_toc.tracks[track_idx]. + track_start_msf[0]); + params[5] = + int_to_bcd(sony_toc.tracks[track_idx]. + track_start_msf[1]); + params[6] = + int_to_bcd(sony_toc.tracks[track_idx]. + track_start_msf[2]); + params[0] = 0x03; + + do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, + &res_size); + + do_sony_cd_cmd(SONY_AUDIO_PLAYBACK_CMD, params, 7, + res_reg, &res_size); + + if ((res_size < 2) + || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_ERR PFX + "Params: %x %x %x %x %x %x %x\n", + params[0], params[1], params[2], + params[3], params[4], params[5], + params[6]); + printk(KERN_ERR PFX + "Error %s (CDROMPLAYTRKIND)\n", + translate_error(res_reg[1])); + retval = -EIO; + break; + } + + /* Save the final position for pauses and resumes */ + final_pos_msf[0] = bcd_to_int(params[4]); + final_pos_msf[1] = bcd_to_int(params[5]); + final_pos_msf[2] = bcd_to_int(params[6]); + sony_audio_status = CDROM_AUDIO_PLAY; + retval = 0; + break; + } + + case CDROMVOLCTRL: /* Volume control. What volume does this change, anyway? */ + { + struct cdrom_volctrl *volctrl = + (struct cdrom_volctrl *) arg; + + params[0] = SONY_SD_AUDIO_VOLUME; + params[1] = volctrl->channel0; + params[2] = volctrl->channel1; + retval = do_sony_cd_cmd_chk("VOLCTRL", + SONY_SET_DRIVE_PARAM_CMD, + params, 3, res_reg, + &res_size); + break; + } + case CDROMSUBCHNL: /* Get subchannel info */ + retval = sony_get_subchnl_info((struct cdrom_subchnl *) arg); + break; + + default: + retval = -EINVAL; + break; + } + up(&sony_sem); + return retval; +} + +static int scd_dev_ioctl(struct cdrom_device_info *cdi, + unsigned int cmd, unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int retval; + + if (down_interruptible(&sony_sem)) + return -ERESTARTSYS; + switch (cmd) { + case CDROMREADAUDIO: /* Read 2352 byte audio tracks and 2340 byte + raw data tracks. */ + { + struct cdrom_read_audio ra; + + + sony_get_toc(); + if (!sony_toc_read) { + retval = -EIO; + break; + } + + if (copy_from_user(&ra, argp, sizeof(ra))) { + retval = -EFAULT; + break; + } + + if (ra.nframes == 0) { + retval = 0; + break; + } + + if (!access_ok(VERIFY_WRITE, ra.buf, + CD_FRAMESIZE_RAW * ra.nframes)) + return -EFAULT; + + if (ra.addr_format == CDROM_LBA) { + if ((ra.addr.lba >= + sony_toc.lead_out_start_lba) + || (ra.addr.lba + ra.nframes >= + sony_toc.lead_out_start_lba)) { + retval = -EINVAL; + break; + } + } else if (ra.addr_format == CDROM_MSF) { + if ((ra.addr.msf.minute >= 75) + || (ra.addr.msf.second >= 60) + || (ra.addr.msf.frame >= 75)) { + retval = -EINVAL; + break; + } + + ra.addr.lba = ((ra.addr.msf.minute * 4500) + + (ra.addr.msf.second * 75) + + ra.addr.msf.frame); + if ((ra.addr.lba >= + sony_toc.lead_out_start_lba) + || (ra.addr.lba + ra.nframes >= + sony_toc.lead_out_start_lba)) { + retval = -EINVAL; + break; + } + + /* I know, this can go negative on an unsigned. However, + the first thing done to the data is to add this value, + so this should compensate and allow direct msf access. */ + ra.addr.lba -= LOG_START_OFFSET; + } else { + retval = -EINVAL; + break; + } + + retval = read_audio(&ra); + break; + } + retval = 0; + break; + + default: + retval = -EINVAL; + } + up(&sony_sem); + return retval; +} + +static int scd_spinup(void) +{ + unsigned char res_reg[12]; + unsigned int res_size; + int num_spin_ups; + + num_spin_ups = 0; + + respinup_on_open: + do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); + + /* The drive sometimes returns error 0. I don't know why, but ignore + it. It seems to mean the drive has already done the operation. */ + if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0))) { + printk(KERN_ERR PFX "%s error (scd_open, spin up)\n", + translate_error(res_reg[1])); + return 1; + } + + do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg, &res_size); + + /* The drive sometimes returns error 0. I don't know why, but ignore + it. It seems to mean the drive has already done the operation. */ + if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0))) { + /* If the drive is already playing, it's ok. */ + if ((res_reg[1] == SONY_AUDIO_PLAYING_ERR) + || (res_reg[1] == 0)) { + return 0; + } + + /* If the drive says it is not spun up (even though we just did it!) + then retry the operation at least a few times. */ + if ((res_reg[1] == SONY_NOT_SPIN_ERR) + && (num_spin_ups < MAX_CDU31A_RETRIES)) { + num_spin_ups++; + goto respinup_on_open; + } + + printk(KERN_ERR PFX "Error %s (scd_open, read toc)\n", + translate_error(res_reg[1])); + do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, + &res_size); + return 1; + } + return 0; +} + +/* + * Open the drive for operations. Spin the drive up and read the table of + * contents if these have not already been done. + */ +static int scd_open(struct cdrom_device_info *cdi, int purpose) +{ + unsigned char res_reg[12]; + unsigned int res_size; + unsigned char params[2]; + + if (purpose == 1) { + /* Open for IOCTLs only - no media check */ + sony_usage++; + return 0; + } + + if (sony_usage == 0) { + if (scd_spinup() != 0) + return -EIO; + sony_get_toc(); + if (!sony_toc_read) { + do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, + res_reg, &res_size); + return -EIO; + } + + /* For XA on the CDU31A only, we have to do special reads. + The CDU33A handles XA automagically. */ + /* if ( (sony_toc.disk_type == SONY_XA_DISK_TYPE) */ + if ((sony_toc.disk_type != 0x00) + && (!is_double_speed)) { + params[0] = SONY_SD_DECODE_PARAM; + params[1] = 0x07; + do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, + params, 2, res_reg, &res_size); + if ((res_size < 2) + || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_WARNING PFX "Unable to set " + "XA params: 0x%2.2x\n", res_reg[1]); + } + sony_xa_mode = 1; + } + /* A non-XA disk. Set the parms back if necessary. */ + else if (sony_xa_mode) { + params[0] = SONY_SD_DECODE_PARAM; + params[1] = 0x0f; + do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, + params, 2, res_reg, &res_size); + if ((res_size < 2) + || ((res_reg[0] & 0xf0) == 0x20)) { + printk(KERN_WARNING PFX "Unable to reset " + "XA params: 0x%2.2x\n", res_reg[1]); + } + sony_xa_mode = 0; + } + + sony_spun_up = 1; + } + + sony_usage++; + + return 0; +} + + +/* + * Close the drive. Spin it down if no task is using it. The spin + * down will fail if playing audio, so audio play is OK. + */ +static void scd_release(struct cdrom_device_info *cdi) +{ + if (sony_usage == 1) { + unsigned char res_reg[12]; + unsigned int res_size; + + do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, + &res_size); + + sony_spun_up = 0; + } + sony_usage--; +} + +static struct cdrom_device_ops scd_dops = { + .open = scd_open, + .release = scd_release, + .drive_status = scd_drive_status, + .media_changed = scd_media_changed, + .tray_move = scd_tray_move, + .lock_door = scd_lock_door, + .select_speed = scd_select_speed, + .get_last_session = scd_get_last_session, + .get_mcn = scd_get_mcn, + .reset = scd_reset, + .audio_ioctl = scd_audio_ioctl, + .dev_ioctl = scd_dev_ioctl, + .capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK | + CDC_SELECT_SPEED | CDC_MULTI_SESSION | + CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | + CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS, + .n_minors = 1, +}; + +static struct cdrom_device_info scd_info = { + .ops = &scd_dops, + .speed = 2, + .capacity = 1, + .name = "cdu31a" +}; + +static int scd_block_open(struct inode *inode, struct file *file) +{ + return cdrom_open(&scd_info, inode, file); +} + +static int scd_block_release(struct inode *inode, struct file *file) +{ + return cdrom_release(&scd_info, file); +} + +static int scd_block_ioctl(struct inode *inode, struct file *file, + unsigned cmd, unsigned long arg) +{ + int retval; + + /* The eject and close commands should be handled by Uniform CD-ROM + * driver - but I always got hard lockup instead of eject + * until I put this here. + */ + switch (cmd) { + case CDROMEJECT: + scd_lock_door(&scd_info, 0); + retval = scd_tray_move(&scd_info, 1); + break; + case CDROMCLOSETRAY: + retval = scd_tray_move(&scd_info, 0); + break; + default: + retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg); + } + return retval; +} + +static int scd_block_media_changed(struct gendisk *disk) +{ + return cdrom_media_changed(&scd_info); +} + +static struct block_device_operations scd_bdops = +{ + .owner = THIS_MODULE, + .open = scd_block_open, + .release = scd_block_release, + .ioctl = scd_block_ioctl, + .media_changed = scd_block_media_changed, +}; + +static struct gendisk *scd_gendisk; + +/* The different types of disc loading mechanisms supported */ +static char *load_mech[] __initdata = + { "caddy", "tray", "pop-up", "unknown" }; + +static int __init +get_drive_configuration(unsigned short base_io, + unsigned char res_reg[], unsigned int *res_size) +{ + unsigned long retry_count; + + + if (!request_region(base_io, 4, "cdu31a")) + return 0; + + /* Set the base address */ + cdu31a_port = base_io; + + /* Set up all the register locations */ + sony_cd_cmd_reg = cdu31a_port + SONY_CMD_REG_OFFSET; + sony_cd_param_reg = cdu31a_port + SONY_PARAM_REG_OFFSET; + sony_cd_write_reg = cdu31a_port + SONY_WRITE_REG_OFFSET; + sony_cd_control_reg = cdu31a_port + SONY_CONTROL_REG_OFFSET; + sony_cd_status_reg = cdu31a_port + SONY_STATUS_REG_OFFSET; + sony_cd_result_reg = cdu31a_port + SONY_RESULT_REG_OFFSET; + sony_cd_read_reg = cdu31a_port + SONY_READ_REG_OFFSET; + sony_cd_fifost_reg = cdu31a_port + SONY_FIFOST_REG_OFFSET; + + /* + * Check to see if anything exists at the status register location. + * I don't know if this is a good way to check, but it seems to work + * ok for me. + */ + if (read_status_register() != 0xff) { + /* + * Reset the drive and wait for attention from it (to say it's reset). + * If you don't wait, the next operation will probably fail. + */ + reset_drive(); + retry_count = jiffies + SONY_RESET_TIMEOUT; + while (time_before(jiffies, retry_count) + && (!is_attention())) { + sony_sleep(); + } + +#if 0 + /* If attention is never seen probably not a CDU31a present */ + if (!is_attention()) { + res_reg[0] = 0x20; + goto out_err; + } +#endif + + /* + * Get the drive configuration. + */ + do_sony_cd_cmd(SONY_REQ_DRIVE_CONFIG_CMD, + NULL, + 0, (unsigned char *) res_reg, res_size); + if (*res_size <= 2 || (res_reg[0] & 0xf0) != 0) + goto out_err; + return 1; + } + + /* Return an error */ + res_reg[0] = 0x20; +out_err: + release_region(cdu31a_port, 4); + cdu31a_port = 0; + return 0; +} + +#ifndef MODULE +/* + * Set up base I/O and interrupts, called from main.c. + */ + +static int __init cdu31a_setup(char *strings) +{ + int ints[4]; + + (void) get_options(strings, ARRAY_SIZE(ints), ints); + + if (ints[0] > 0) { + cdu31a_port = ints[1]; + } + if (ints[0] > 1) { + cdu31a_irq = ints[2]; + } + if ((strings != NULL) && (*strings != '\0')) { + if (strcmp(strings, "PAS") == 0) { + sony_pas_init = 1; + } else { + printk(KERN_NOTICE PFX "Unknown interface type: %s\n", + strings); + } + } + + return 1; +} + +__setup("cdu31a=", cdu31a_setup); + +#endif + +/* + * Initialize the driver. + */ +int __init cdu31a_init(void) +{ + struct s_sony_drive_config drive_config; + struct gendisk *disk; + int deficiency = 0; + unsigned int res_size; + char msg[255]; + char buf[40]; + int i; + int tmp_irq; + + /* + * According to Alex Freed (freed@europa.orion.adobe.com), this is + * required for the Fusion CD-16 package. If the sound driver is + * loaded, it should work fine, but just in case... + * + * The following turn on the CD-ROM interface for a Fusion CD-16. + */ + if (sony_pas_init) { + outb(0xbc, 0x9a01); + outb(0xe2, 0x9a01); + } + + /* Setting the base I/O address to 0xffff will disable it. */ + if (cdu31a_port == 0xffff) + goto errout3; + + if (cdu31a_port != 0) { + /* Need IRQ 0 because we can't sleep here. */ + tmp_irq = cdu31a_irq; + cdu31a_irq = 0; + if (!get_drive_configuration(cdu31a_port, + drive_config.exec_status, + &res_size)) + goto errout3; + cdu31a_irq = tmp_irq; + } else { + cdu31a_irq = 0; + for (i = 0; cdu31a_addresses[i].base; i++) { + if (get_drive_configuration(cdu31a_addresses[i].base, + drive_config.exec_status, + &res_size)) { + cdu31a_irq = cdu31a_addresses[i].int_num; + break; + } + } + if (!cdu31a_port) + goto errout3; + } + + if (register_blkdev(MAJOR_NR, "cdu31a")) + goto errout2; + + disk = alloc_disk(1); + if (!disk) + goto errout1; + disk->major = MAJOR_NR; + disk->first_minor = 0; + sprintf(disk->disk_name, "cdu31a"); + disk->fops = &scd_bdops; + disk->flags = GENHD_FL_CD; + + if (SONY_HWC_DOUBLE_SPEED(drive_config)) + is_double_speed = 1; + + tmp_irq = cdu31a_irq; /* Need IRQ 0 because we can't sleep here. */ + cdu31a_irq = 0; + + sony_speed = is_double_speed; /* Set 2X drives to 2X by default */ + set_drive_params(sony_speed); + + cdu31a_irq = tmp_irq; + + if (cdu31a_irq > 0) { + if (request_irq + (cdu31a_irq, cdu31a_interrupt, SA_INTERRUPT, + "cdu31a", NULL)) { + printk(KERN_WARNING PFX "Unable to grab IRQ%d for " + "the CDU31A driver\n", cdu31a_irq); + cdu31a_irq = 0; + } + } + + sprintf(msg, "Sony I/F CDROM : %8.8s %16.16s %8.8s\n", + drive_config.vendor_id, + drive_config.product_id, + drive_config.product_rev_level); + sprintf(buf, " Capabilities: %s", + load_mech[SONY_HWC_GET_LOAD_MECH(drive_config)]); + strcat(msg, buf); + if (SONY_HWC_AUDIO_PLAYBACK(drive_config)) + strcat(msg, ", audio"); + else + deficiency |= CDC_PLAY_AUDIO; + if (SONY_HWC_EJECT(drive_config)) + strcat(msg, ", eject"); + else + deficiency |= CDC_OPEN_TRAY; + if (SONY_HWC_LED_SUPPORT(drive_config)) + strcat(msg, ", LED"); + if (SONY_HWC_ELECTRIC_VOLUME(drive_config)) + strcat(msg, ", elec. Vol"); + if (SONY_HWC_ELECTRIC_VOLUME_CTL(drive_config)) + strcat(msg, ", sep. Vol"); + if (is_double_speed) + strcat(msg, ", double speed"); + else + deficiency |= CDC_SELECT_SPEED; + if (cdu31a_irq > 0) { + sprintf(buf, ", irq %d", cdu31a_irq); + strcat(msg, buf); + } + strcat(msg, "\n"); + printk(KERN_INFO PFX "%s",msg); + + cdu31a_queue = blk_init_queue(do_cdu31a_request, &cdu31a_lock); + if (!cdu31a_queue) + goto errout0; + blk_queue_hardsect_size(cdu31a_queue, 2048); + + init_timer(&cdu31a_abort_timer); + cdu31a_abort_timer.function = handle_abort_timeout; + + scd_info.mask = deficiency; + scd_gendisk = disk; + if (register_cdrom(&scd_info)) + goto err; + disk->queue = cdu31a_queue; + add_disk(disk); + + disk_changed = 1; + return 0; + +err: + blk_cleanup_queue(cdu31a_queue); +errout0: + if (cdu31a_irq) + free_irq(cdu31a_irq, NULL); + printk(KERN_ERR PFX "Unable to register with Uniform cdrom driver\n"); + put_disk(disk); +errout1: + if (unregister_blkdev(MAJOR_NR, "cdu31a")) { + printk(KERN_WARNING PFX "Can't unregister block device\n"); + } +errout2: + release_region(cdu31a_port, 4); +errout3: + return -EIO; +} + + +static void __exit cdu31a_exit(void) +{ + del_gendisk(scd_gendisk); + put_disk(scd_gendisk); + if (unregister_cdrom(&scd_info)) { + printk(KERN_WARNING PFX "Can't unregister from Uniform " + "cdrom driver\n"); + return; + } + if ((unregister_blkdev(MAJOR_NR, "cdu31a") == -EINVAL)) { + printk(KERN_WARNING PFX "Can't unregister\n"); + return; + } + + blk_cleanup_queue(cdu31a_queue); + + if (cdu31a_irq > 0) + free_irq(cdu31a_irq, NULL); + + release_region(cdu31a_port, 4); + printk(KERN_INFO PFX "module released.\n"); +} + +#ifdef MODULE +module_init(cdu31a_init); +#endif +module_exit(cdu31a_exit); + +MODULE_LICENSE("GPL"); +MODULE_ALIAS_BLOCKDEV_MAJOR(CDU31A_CDROM_MAJOR); diff --git a/ddverify/case_studies/cdrom/cdu31a/cdu31a.h b/ddverify/case_studies/cdrom/cdu31a/cdu31a.h new file mode 100644 index 000000000..61d4768c4 --- /dev/null +++ b/ddverify/case_studies/cdrom/cdu31a/cdu31a.h @@ -0,0 +1,411 @@ +/* + * Definitions for a Sony interface CDROM drive. + * + * Corey Minyard (minyard@wf-rch.cirr.com) + * + * Copyright (C) 1993 Corey Minyard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* + * General defines. + */ +#define SONY_XA_DISK_TYPE 0x20 + +/* + * Offsets (from the base address) and bits for the various write registers + * of the drive. + */ +#define SONY_CMD_REG_OFFSET 0 +#define SONY_PARAM_REG_OFFSET 1 +#define SONY_WRITE_REG_OFFSET 2 +#define SONY_CONTROL_REG_OFFSET 3 +# define SONY_ATTN_CLR_BIT 0x01 +# define SONY_RES_RDY_CLR_BIT 0x02 +# define SONY_DATA_RDY_CLR_BIT 0x04 +# define SONY_ATTN_INT_EN_BIT 0x08 +# define SONY_RES_RDY_INT_EN_BIT 0x10 +# define SONY_DATA_RDY_INT_EN_BIT 0x20 +# define SONY_PARAM_CLR_BIT 0x40 +# define SONY_DRIVE_RESET_BIT 0x80 + +/* + * Offsets (from the base address) and bits for the various read registers + * of the drive. + */ +#define SONY_STATUS_REG_OFFSET 0 +# define SONY_ATTN_BIT 0x01 +# define SONY_RES_RDY_BIT 0x02 +# define SONY_DATA_RDY_BIT 0x04 +# define SONY_ATTN_INT_ST_BIT 0x08 +# define SONY_RES_RDY_INT_ST_BIT 0x10 +# define SONY_DATA_RDY_INT_ST_BIT 0x20 +# define SONY_DATA_REQUEST_BIT 0x40 +# define SONY_BUSY_BIT 0x80 +#define SONY_RESULT_REG_OFFSET 1 +#define SONY_READ_REG_OFFSET 2 +#define SONY_FIFOST_REG_OFFSET 3 +# define SONY_PARAM_WRITE_RDY_BIT 0x01 +# define SONY_PARAM_REG_EMPTY_BIT 0x02 +# define SONY_RES_REG_NOT_EMP_BIT 0x04 +# define SONY_RES_REG_FULL_BIT 0x08 + +#define LOG_START_OFFSET 150 /* Offset of first logical sector */ + +#define SONY_DETECT_TIMEOUT (8*HZ/10) /* Maximum amount of time + that drive detection code + will wait for response + from drive (in 1/100th's + of seconds). */ + +#define SONY_JIFFIES_TIMEOUT (10*HZ) /* Maximum number of times the + drive will wait/try for an + operation */ +#define SONY_RESET_TIMEOUT HZ /* Maximum number of times the + drive will wait/try a reset + operation */ +#define SONY_READY_RETRIES 20000 /* How many times to retry a + spin waiting for a register + to come ready */ + +#define MAX_CDU31A_RETRIES 3 /* How many times to retry an + operation */ + +/* Commands to request or set drive control parameters and disc information */ +#define SONY_REQ_DRIVE_CONFIG_CMD 0x00 /* Returns s_sony_drive_config */ +#define SONY_REQ_DRIVE_MODE_CMD 0x01 +#define SONY_REQ_DRIVE_PARAM_CMD 0x02 +#define SONY_REQ_MECH_STATUS_CMD 0x03 +#define SONY_REQ_AUDIO_STATUS_CMD 0x04 +#define SONY_SET_DRIVE_PARAM_CMD 0x10 +#define SONY_REQ_TOC_DATA_CMD 0x20 /* Returns s_sony_toc */ +#define SONY_REQ_SUBCODE_ADDRESS_CMD 0x21 /* Returns s_sony_subcode */ +#define SONY_REQ_UPC_EAN_CMD 0x22 +#define SONY_REQ_ISRC_CMD 0x23 +#define SONY_REQ_TOC_DATA_SPEC_CMD 0x24 /* Returns s_sony_session_toc */ + +/* Commands to request information from the drive */ +#define SONY_READ_TOC_CMD 0x30 /* let the drive firmware grab the TOC */ +#define SONY_SEEK_CMD 0x31 +#define SONY_READ_CMD 0x32 +#define SONY_READ_BLKERR_STAT_CMD 0x34 +#define SONY_ABORT_CMD 0x35 +#define SONY_READ_TOC_SPEC_CMD 0x36 + +/* Commands to control audio */ +#define SONY_AUDIO_PLAYBACK_CMD 0x40 +#define SONY_AUDIO_STOP_CMD 0x41 +#define SONY_AUDIO_SCAN_CMD 0x42 + +/* Miscellaneous control commands */ +#define SONY_EJECT_CMD 0x50 +#define SONY_SPIN_UP_CMD 0x51 +#define SONY_SPIN_DOWN_CMD 0x52 + +/* Diagnostic commands */ +#define SONY_WRITE_BUFFER_CMD 0x60 +#define SONY_READ_BUFFER_CMD 0x61 +#define SONY_DIAGNOSTICS_CMD 0x62 + + +/* + * The following are command parameters for the set drive parameter command + */ +#define SONY_SD_DECODE_PARAM 0x00 +#define SONY_SD_INTERFACE_PARAM 0x01 +#define SONY_SD_BUFFERING_PARAM 0x02 +#define SONY_SD_AUDIO_PARAM 0x03 +#define SONY_SD_AUDIO_VOLUME 0x04 +#define SONY_SD_MECH_CONTROL 0x05 +#define SONY_SD_AUTO_SPIN_DOWN_TIME 0x06 + +/* + * The following are parameter bits for the mechanical control command + */ +#define SONY_AUTO_SPIN_UP_BIT 0x01 +#define SONY_AUTO_EJECT_BIT 0x02 +#define SONY_DOUBLE_SPEED_BIT 0x04 + +/* + * The following extract information from the drive configuration about + * the drive itself. + */ +#define SONY_HWC_GET_LOAD_MECH(c) (c.hw_config[0] & 0x03) +#define SONY_HWC_EJECT(c) (c.hw_config[0] & 0x04) +#define SONY_HWC_LED_SUPPORT(c) (c.hw_config[0] & 0x08) +#define SONY_HWC_DOUBLE_SPEED(c) (c.hw_config[0] & 0x10) +#define SONY_HWC_GET_BUF_MEM_SIZE(c) ((c.hw_config[0] & 0xc0) >> 6) +#define SONY_HWC_AUDIO_PLAYBACK(c) (c.hw_config[1] & 0x01) +#define SONY_HWC_ELECTRIC_VOLUME(c) (c.hw_config[1] & 0x02) +#define SONY_HWC_ELECTRIC_VOLUME_CTL(c) (c.hw_config[1] & 0x04) + +#define SONY_HWC_CADDY_LOAD_MECH 0x00 +#define SONY_HWC_TRAY_LOAD_MECH 0x01 +#define SONY_HWC_POPUP_LOAD_MECH 0x02 +#define SONY_HWC_UNKWN_LOAD_MECH 0x03 + +#define SONY_HWC_8KB_BUFFER 0x00 +#define SONY_HWC_32KB_BUFFER 0x01 +#define SONY_HWC_64KB_BUFFER 0x02 +#define SONY_HWC_UNKWN_BUFFER 0x03 + +/* + * This is the complete status returned from the drive configuration request + * command. + */ +struct s_sony_drive_config +{ + unsigned char exec_status[2]; + char vendor_id[8]; + char product_id[16]; + char product_rev_level[8]; + unsigned char hw_config[2]; +}; + +/* The following is returned from the request subcode address command */ +struct s_sony_subcode +{ + unsigned char exec_status[2]; + unsigned char address :4; + unsigned char control :4; + unsigned char track_num; + unsigned char index_num; + unsigned char rel_msf[3]; + unsigned char reserved1; + unsigned char abs_msf[3]; +}; + +#define MAX_TRACKS 100 /* The maximum tracks a disk may have. */ +/* + * The following is returned from the request TOC (Table Of Contents) command. + * (last_track_num-first_track_num+1) values are valid in tracks. + */ +struct s_sony_toc +{ + unsigned char exec_status[2]; + unsigned char address0 :4; + unsigned char control0 :4; + unsigned char point0; + unsigned char first_track_num; + unsigned char disk_type; + unsigned char dummy0; + unsigned char address1 :4; + unsigned char control1 :4; + unsigned char point1; + unsigned char last_track_num; + unsigned char dummy1; + unsigned char dummy2; + unsigned char address2 :4; + unsigned char control2 :4; + unsigned char point2; + unsigned char lead_out_start_msf[3]; + struct + { + unsigned char address :4; + unsigned char control :4; + unsigned char track; + unsigned char track_start_msf[3]; + } tracks[MAX_TRACKS]; + + unsigned int lead_out_start_lba; +}; + +struct s_sony_session_toc +{ + unsigned char exec_status[2]; + unsigned char session_number; + unsigned char address0 :4; + unsigned char control0 :4; + unsigned char point0; + unsigned char first_track_num; + unsigned char disk_type; + unsigned char dummy0; + unsigned char address1 :4; + unsigned char control1 :4; + unsigned char point1; + unsigned char last_track_num; + unsigned char dummy1; + unsigned char dummy2; + unsigned char address2 :4; + unsigned char control2 :4; + unsigned char point2; + unsigned char lead_out_start_msf[3]; + unsigned char addressb0 :4; + unsigned char controlb0 :4; + unsigned char pointb0; + unsigned char next_poss_prog_area_msf[3]; + unsigned char num_mode_5_pointers; + unsigned char max_start_outer_leadout_msf[3]; + unsigned char addressb1 :4; + unsigned char controlb1 :4; + unsigned char pointb1; + unsigned char dummyb0_1[4]; + unsigned char num_skip_interval_pointers; + unsigned char num_skip_track_assignments; + unsigned char dummyb0_2; + unsigned char addressb2 :4; + unsigned char controlb2 :4; + unsigned char pointb2; + unsigned char tracksb2[7]; + unsigned char addressb3 :4; + unsigned char controlb3 :4; + unsigned char pointb3; + unsigned char tracksb3[7]; + unsigned char addressb4 :4; + unsigned char controlb4 :4; + unsigned char pointb4; + unsigned char tracksb4[7]; + unsigned char addressc0 :4; + unsigned char controlc0 :4; + unsigned char pointc0; + unsigned char dummyc0[7]; + struct + { + unsigned char address :4; + unsigned char control :4; + unsigned char track; + unsigned char track_start_msf[3]; + } tracks[MAX_TRACKS]; + + unsigned int start_track_lba; + unsigned int lead_out_start_lba; + unsigned int mint; + unsigned int maxt; +}; + +struct s_all_sessions_toc +{ + unsigned char sessions; + unsigned int track_entries; + unsigned char first_track_num; + unsigned char last_track_num; + unsigned char disk_type; + unsigned char lead_out_start_msf[3]; + struct + { + unsigned char address :4; + unsigned char control :4; + unsigned char track; + unsigned char track_start_msf[3]; + } tracks[MAX_TRACKS]; + + unsigned int start_track_lba; + unsigned int lead_out_start_lba; +}; + + +/* + * The following are errors returned from the drive. + */ + +/* Command error group */ +#define SONY_ILL_CMD_ERR 0x10 +#define SONY_ILL_PARAM_ERR 0x11 + +/* Mechanism group */ +#define SONY_NOT_LOAD_ERR 0x20 +#define SONY_NO_DISK_ERR 0x21 +#define SONY_NOT_SPIN_ERR 0x22 +#define SONY_SPIN_ERR 0x23 +#define SONY_SPINDLE_SERVO_ERR 0x25 +#define SONY_FOCUS_SERVO_ERR 0x26 +#define SONY_EJECT_MECH_ERR 0x29 +#define SONY_AUDIO_PLAYING_ERR 0x2a +#define SONY_EMERGENCY_EJECT_ERR 0x2c + +/* Seek error group */ +#define SONY_FOCUS_ERR 0x30 +#define SONY_FRAME_SYNC_ERR 0x31 +#define SONY_SUBCODE_ADDR_ERR 0x32 +#define SONY_BLOCK_SYNC_ERR 0x33 +#define SONY_HEADER_ADDR_ERR 0x34 + +/* Read error group */ +#define SONY_ILL_TRACK_R_ERR 0x40 +#define SONY_MODE_0_R_ERR 0x41 +#define SONY_ILL_MODE_R_ERR 0x42 +#define SONY_ILL_BLOCK_SIZE_R_ERR 0x43 +#define SONY_MODE_R_ERR 0x44 +#define SONY_FORM_R_ERR 0x45 +#define SONY_LEAD_OUT_R_ERR 0x46 +#define SONY_BUFFER_OVERRUN_R_ERR 0x47 + +/* Data error group */ +#define SONY_UNREC_CIRC_ERR 0x53 +#define SONY_UNREC_LECC_ERR 0x57 + +/* Subcode error group */ +#define SONY_NO_TOC_ERR 0x60 +#define SONY_SUBCODE_DATA_NVAL_ERR 0x61 +#define SONY_FOCUS_ON_TOC_READ_ERR 0x63 +#define SONY_FRAME_SYNC_ON_TOC_READ_ERR 0x64 +#define SONY_TOC_DATA_ERR 0x65 + +/* Hardware failure group */ +#define SONY_HW_FAILURE_ERR 0x70 +#define SONY_LEAD_IN_A_ERR 0x91 +#define SONY_LEAD_OUT_A_ERR 0x92 +#define SONY_DATA_TRACK_A_ERR 0x93 + +/* + * The following are returned from the Read With Block Error Status command. + * They are not errors but information (Errors from the 0x5x group above may + * also be returned + */ +#define SONY_NO_CIRC_ERR_BLK_STAT 0x50 +#define SONY_NO_LECC_ERR_BLK_STAT 0x54 +#define SONY_RECOV_LECC_ERR_BLK_STAT 0x55 +#define SONY_NO_ERR_DETECTION_STAT 0x59 + +/* + * The following is not an error returned by the drive, but by the code + * that talks to the drive. It is returned because of a timeout. + */ +#define SONY_TIMEOUT_OP_ERR 0x01 +#define SONY_SIGNAL_OP_ERR 0x02 +#define SONY_BAD_DATA_ERR 0x03 + + +/* + * The following are attention code for asynchronous events from the drive. + */ + +/* Standard attention group */ +#define SONY_EMER_EJECT_ATTN 0x2c +#define SONY_HW_FAILURE_ATTN 0x70 +#define SONY_MECH_LOADED_ATTN 0x80 +#define SONY_EJECT_PUSHED_ATTN 0x81 + +/* Audio attention group */ +#define SONY_AUDIO_PLAY_DONE_ATTN 0x90 +#define SONY_LEAD_IN_ERR_ATTN 0x91 +#define SONY_LEAD_OUT_ERR_ATTN 0x92 +#define SONY_DATA_TRACK_ERR_ATTN 0x93 +#define SONY_AUDIO_PLAYBACK_ERR_ATTN 0x94 + +/* Auto spin up group */ +#define SONY_SPIN_UP_COMPLETE_ATTN 0x24 +#define SONY_SPINDLE_SERVO_ERR_ATTN 0x25 +#define SONY_FOCUS_SERVO_ERR_ATTN 0x26 +#define SONY_TOC_READ_DONE_ATTN 0x62 +#define SONY_FOCUS_ON_TOC_READ_ERR_ATTN 0x63 +#define SONY_SYNC_ON_TOC_READ_ERR_ATTN 0x65 + +/* Auto eject group */ +#define SONY_SPIN_DOWN_COMPLETE_ATTN 0x27 +#define SONY_EJECT_COMPLETE_ATTN 0x28 +#define SONY_EJECT_MECH_ERR_ATTN 0x29 diff --git a/ddverify/case_studies/cdrom/cm206/cm206.c b/ddverify/case_studies/cdrom/cm206/cm206.c new file mode 100644 index 000000000..e6d8e9ede --- /dev/null +++ b/ddverify/case_studies/cdrom/cm206/cm206.c @@ -0,0 +1,1595 @@ +/* cm206.c. A linux-driver for the cm206 cdrom player with cm260 adapter card. + Copyright (c) 1995--1997 David A. van Leeuwen. + $Id: cm206.c,v 1.5 1997/12/26 11:02:51 david Exp $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +History: + Started 25 jan 1994. Waiting for documentation... + 22 feb 1995: 0.1a first reasonably safe polling driver. + Two major bugs, one in read_sector and one in + do_cm206_request, happened to cancel! + 25 feb 1995: 0.2a first reasonable interrupt driven version of above. + uart writes are still done in polling mode. + 25 feb 1995: 0.21a writes also in interrupt mode, still some + small bugs to be found... Larger buffer. + 2 mrt 1995: 0.22 Bug found (cd-> nowhere, interrupt was called in + initialization), read_ahead of 16. Timeouts implemented. + unclear if they do something... + 7 mrt 1995: 0.23 Start of background read-ahead. + 18 mrt 1995: 0.24 Working background read-ahead. (still problems) + 26 mrt 1995: 0.25 Multi-session ioctl added (kernel v1.2). + Statistics implemented, though separate stats206.h. + Accessible through ioctl 0x1000 (just a number). + Hard to choose between v1.2 development and 1.1.75. + Bottom-half doesn't work with 1.2... + 0.25a: fixed... typo. Still problems... + 1 apr 1995: 0.26 Module support added. Most bugs found. Use kernel 1.2.n. + 5 apr 1995: 0.27 Auto-probe for the adapter card base address. + Auto-probe for the adaptor card irq line. + 7 apr 1995: 0.28 Added lilo setup support for base address and irq. + Use major number 32 (not in this source), officially + assigned to this driver. + 9 apr 1995: 0.29 Added very limited audio support. Toc_header, stop, pause, + resume, eject. Play_track ignores track info, because we can't + read a table-of-contents entry. Toc_entry is implemented + as a `placebo' function: always returns start of disc. + 3 may 1995: 0.30 Audio support completed. The get_toc_entry function + is implemented as a binary search. + 15 may 1995: 0.31 More work on audio stuff. Workman is not easy to + satisfy; changed binary search into linear search. + Auto-probe for base address somewhat relaxed. + 1 jun 1995: 0.32 Removed probe_irq_on/off for module version. + 10 jun 1995: 0.33 Workman still behaves funny, but you should be + able to eject and substitute another disc. + + An adaptation of 0.33 is included in linux-1.3.7 by Eberhard Moenkeberg + + 18 jul 1995: 0.34 Patch by Heiko Eissfeldt included, mainly considering + verify_area's in the ioctls. Some bugs introduced by + EM considering the base port and irq fixed. + + 18 dec 1995: 0.35 Add some code for error checking... no luck... + + We jump to reach our goal: version 1.0 in the next stable linux kernel. + + 19 mar 1996: 0.95 Different implementation of CDROM_GET_UPC, on + request of Thomas Quinot. + 25 mar 1996: 0.96 Interpretation of opening with O_WRONLY or O_RDWR: + open only for ioctl operation, e.g., for operation of + tray etc. + 4 apr 1996: 0.97 First implementation of layer between VFS and cdrom + driver, a generic interface. Much of the functionality + of cm206_open() and cm206_ioctl() is transferred to a + new file cdrom.c and its header ucdrom.h. + + Upgrade to Linux kernel 1.3.78. + + 11 apr 1996 0.98 Upgrade to Linux kernel 1.3.85 + More code moved to cdrom.c + + 0.99 Some more small changes to decrease number + of oopses at module load; + + 27 jul 1996 0.100 Many hours of debugging, kernel change from 1.2.13 + to 2.0.7 seems to have introduced some weird behavior + in (interruptible_)sleep_on(&cd->data): the process + seems to be woken without any explicit wake_up in my own + code. Patch to try 100x in case such untriggered wake_up's + occur. + + 28 jul 1996 0.101 Rewriting of the code that receives the command echo, + using a fifo to store echoed bytes. + + Branch from 0.99: + + 0.99.1.0 Update to kernel release 2.0.10 dev_t -> kdev_t + (emoenke) various typos found by others. extra + module-load oops protection. + + 0.99.1.1 Initialization constant cdrom_dops.speed + changed from float (2.0) to int (2); Cli()-sti() pair + around cm260_reset() in module initialization code. + + 0.99.1.2 Changes literally as proposed by Scott Snyder + for the 2.1 kernel line, which + have to do mainly with the poor minor support i had. The + major new concept is to change a cdrom driver's + operations struct from the capabilities struct. This + reflects the fact that there is one major for a driver, + whilst there can be many minors whith completely + different capabilities. + + 0.99.1.3 More changes for operations/info separation. + + 0.99.1.4 Added speed selection (someone had to do this + first). + + 23 jan 1997 0.99.1.5 MODULE_PARMS call added. + + 23 jan 1997 0.100.1.2--0.100.1.5 following similar lines as + 0.99.1.1--0.99.1.5. I get too many complaints about the + drive making read errors. What't wrong with the 2.0+ + kernel line? Why get i (and othe cm206 owners) weird + results? Why were things good in the good old 1.1--1.2 + era? Why don't i throw away the drive? + + 2 feb 1997 0.102 Added `volatile' to values in cm206_struct. Seems to + reduce many of the problems. Rewrote polling routines + to use fixed delays between polls. + 0.103 Changed printk behavior. + 0.104 Added a 0.100 -> 0.100.1.1 change + +11 feb 1997 0.105 Allow auto_probe during module load, disable + with module option "auto_probe=0". Moved some debugging + statements to lower priority. Implemented select_speed() + function. + +13 feb 1997 1.0 Final version for 2.0 kernel line. + + All following changes will be for the 2.1 kernel line. + +15 feb 1997 1.1 Keep up with kernel 2.1.26, merge in changes from + cdrom.c 0.100.1.1--1.0. Add some more MODULE_PARMS. + +14 sep 1997 1.2 Upgrade to Linux 2.1.55. Added blksize_size[], patch + sent by James Bottomley . + +21 dec 1997 1.4 Upgrade to Linux 2.1.72. + +24 jan 1998 Removed the cm206_disc_status() function, as it was now dead + code. The Uniform CDROM driver now provides this functionality. + +9 Nov. 1999 Make kernel-parameter implementation work with 2.3.x + Removed init_module & cleanup_module in favor of + module_init & module_exit. + Torben Mathiasen + * + * Parts of the code are based upon lmscd.c written by Kai Petzke, + * sbpcd.c written by Eberhard Moenkeberg, and mcd.c by Martin + * Harriss, but any off-the-shelf dynamic programming algorithm won't + * be able to find them. + * + * The cm206 drive interface and the cm260 adapter card seem to be + * sufficiently different from their cm205/cm250 counterparts + * in order to write a complete new driver. + * + * I call all routines connected to the Linux kernel something + * with `cm206' in it, as this stuff is too series-dependent. + * + * Currently, my limited knowledge is based on: + * - The Linux Kernel Hacker's guide, v. 0.5, by Michael K. Johnson + * - Linux Kernel Programmierung, by Michael Beck and others + * - Philips/LMS cm206 and cm226 product specification + * - Philips/LMS cm260 product specification + * + * David van Leeuwen, david@tm.tno.nl. */ +#define REVISION "$Revision: 1.5 $" + +#include + +#include /* These include what we really need */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* #include */ + +#include + +#define MAJOR_NR CM206_CDROM_MAJOR + +#include + +#undef DEBUG +#define STATISTICS /* record times and frequencies of events */ +#define AUTO_PROBE_MODULE +#define USE_INSW + +#include "cm206.h" + +/* This variable defines whether or not to probe for adapter base port + address and interrupt request. It can be overridden by the boot + parameter `auto'. +*/ +static int auto_probe = 1; /* Yes, why not? */ + +static int cm206_base = CM206_BASE; +static int cm206_irq = CM206_IRQ; +#ifdef MODULE +static int cm206[2] = { 0, 0 }; /* for compatible `insmod' parameter passing */ +module_param_array(cm206, int, NULL, 0); /* base,irq or irq,base */ +#endif + +module_param(cm206_base, int, 0); /* base */ +module_param(cm206_irq, int, 0); /* irq */ +module_param(auto_probe, bool, 0); /* auto probe base and irq */ +MODULE_LICENSE("GPL"); + +#define POLLOOP 100 /* milliseconds */ +#define READ_AHEAD 1 /* defines private buffer, waste! */ +#define BACK_AHEAD 1 /* defines adapter-read ahead */ +#define DATA_TIMEOUT (3*HZ) /* measured in jiffies (10 ms) */ +#define UART_TIMEOUT (5*HZ/100) +#define DSB_TIMEOUT (7*HZ) /* time for the slowest command to finish */ +#define UR_SIZE 4 /* uart receive buffer fifo size */ + +#define LINUX_BLOCK_SIZE 512 /* WHERE is this defined? */ +#define RAW_SECTOR_SIZE 2352 /* ok, is also defined in cdrom.h */ +#define ISO_SECTOR_SIZE 2048 +#define BLOCKS_ISO (ISO_SECTOR_SIZE/LINUX_BLOCK_SIZE) /* 4 */ +#define CD_SYNC_HEAD 16 /* CD_SYNC + CD_HEAD */ + +#ifdef STATISTICS /* keep track of errors in counters */ +#define stats(i) { ++cd->stats[st_ ## i]; \ + cd->last_stat[st_ ## i] = cd->stat_counter++; \ + } +#else +#define stats(i) (void) 0; +#endif + +#define Debug(a) {printk (KERN_DEBUG); printk a;} +#ifdef DEBUG +#define debug(a) Debug(a) +#else +#define debug(a) (void) 0; +#endif + +typedef unsigned char uch; /* 8-bits */ +typedef unsigned short ush; /* 16-bits */ + +struct toc_struct { /* private copy of Table of Contents */ + uch track, fsm[3], q0; +}; + +struct cm206_struct { + volatile ush intr_ds; /* data status read on last interrupt */ + volatile ush intr_ls; /* uart line status read on last interrupt */ + volatile uch ur[UR_SIZE]; /* uart receive buffer fifo */ + volatile uch ur_w, ur_r; /* write/read buffer index */ + volatile uch dsb, cc; /* drive status byte and condition (error) code */ + int command; /* command to be written to the uart */ + int openfiles; + ush sector[READ_AHEAD * RAW_SECTOR_SIZE / 2]; /* buffered cd-sector */ + int sector_first, sector_last; /* range of these sectors */ + wait_queue_head_t uart; /* wait queues for interrupt */ + wait_queue_head_t data; + struct timer_list timer; /* time-out */ + char timed_out; + signed char max_sectors; /* number of sectors that fit in adapter mem */ + char wait_back; /* we're waiting for a background-read */ + char background; /* is a read going on in the background? */ + int adapter_first; /* if so, that's the starting sector */ + int adapter_last; + char fifo_overflowed; + uch disc_status[7]; /* result of get_disc_status command */ +#ifdef STATISTICS + int stats[NR_STATS]; + int last_stat[NR_STATS]; /* `time' at which stat was stat */ + int stat_counter; +#endif + struct toc_struct toc[101]; /* The whole table of contents + lead-out */ + uch q[10]; /* Last read q-channel info */ + uch audio_status[5]; /* last read position on pause */ + uch media_changed; /* record if media changed */ +}; + +#define DISC_STATUS cd->disc_status[0] +#define FIRST_TRACK cd->disc_status[1] +#define LAST_TRACK cd->disc_status[2] +#define PAUSED cd->audio_status[0] /* misuse this memory byte! */ +#define PLAY_TO cd->toc[0] /* toc[0] records end-time in play */ + +static struct cm206_struct *cd; /* the main memory structure */ +static struct request_queue *cm206_queue; +static DEFINE_SPINLOCK(cm206_lock); + +/* First, we define some polling functions. These are actually + only being used in the initialization. */ + +static void send_command_polled(int command) +{ + int loop = POLLOOP; + while (!(inw(r_line_status) & ls_transmitter_buffer_empty) + && loop > 0) { + mdelay(1); /* one millisec delay */ + --loop; + } + outw(command, r_uart_transmit); +} + +static uch receive_echo_polled(void) +{ + int loop = POLLOOP; + while (!(inw(r_line_status) & ls_receive_buffer_full) && loop > 0) { + mdelay(1); + --loop; + } + return ((uch) inw(r_uart_receive)); +} + +static uch send_receive_polled(int command) +{ + send_command_polled(command); + return receive_echo_polled(); +} + +static inline void clear_ur(void) +{ + if (cd->ur_r != cd->ur_w) { + debug(("Deleting bytes from fifo:")); + for (; cd->ur_r != cd->ur_w; + cd->ur_r++, cd->ur_r %= UR_SIZE) + debug((" 0x%x", cd->ur[cd->ur_r])); + debug(("\n")); + } +} + +static struct tasklet_struct cm206_tasklet; + +/* The interrupt handler. When the cm260 generates an interrupt, very + much care has to be taken in reading out the registers in the right + order; in case of a receive_buffer_full interrupt, first the + uart_receive must be read, and then the line status again to + de-assert the interrupt line. It took me a couple of hours to find + this out:-( + + The function reset_cm206 appears to cause an interrupt, because + pulling up the INIT line clears both the uart-write-buffer /and/ + the uart-write-buffer-empty mask. We call this a `lost interrupt,' + as there seems so reason for this to happen. +*/ + +static irqreturn_t cm206_interrupt(int sig, void *dev_id) +{ + volatile ush fool; + cd->intr_ds = inw(r_data_status); /* resets data_ready, data_error, + crc_error, sync_error, toc_ready + interrupts */ + cd->intr_ls = inw(r_line_status); /* resets overrun bit */ + debug(("Intr, 0x%x 0x%x, %d\n", cd->intr_ds, cd->intr_ls, + cd->background)); + if (cd->intr_ls & ls_attention) + stats(attention); + /* receive buffer full? */ + if (cd->intr_ls & ls_receive_buffer_full) { + cd->ur[cd->ur_w] = inb(r_uart_receive); /* get order right! */ + cd->intr_ls = inw(r_line_status); /* resets rbf interrupt */ + debug(("receiving #%d: 0x%x\n", cd->ur_w, + cd->ur[cd->ur_w])); + cd->ur_w++; + cd->ur_w %= UR_SIZE; + if (cd->ur_w == cd->ur_r) + debug(("cd->ur overflow!\n")); + if (waitqueue_active(&cd->uart) && cd->background < 2) { + del_timer(&cd->timer); + wake_up_interruptible(&cd->uart); + } + } + /* data ready in fifo? */ + else if (cd->intr_ds & ds_data_ready) { + if (cd->background) + ++cd->adapter_last; + if (waitqueue_active(&cd->data) + && (cd->wait_back || !cd->background)) { + del_timer(&cd->timer); + wake_up_interruptible(&cd->data); + } + stats(data_ready); + } + /* ready to issue a write command? */ + else if (cd->command && cd->intr_ls & ls_transmitter_buffer_empty) { + outw(dc_normal | (inw(r_data_status) & 0x7f), + r_data_control); + outw(cd->command, r_uart_transmit); + cd->command = 0; + if (!cd->background) + wake_up_interruptible(&cd->uart); + } + /* now treat errors (at least, identify them for debugging) */ + else if (cd->intr_ds & ds_fifo_overflow) { + debug(("Fifo overflow at sectors 0x%x\n", + cd->sector_first)); + fool = inw(r_fifo_output_buffer); /* de-assert the interrupt */ + cd->fifo_overflowed = 1; /* signal one word less should be read */ + stats(fifo_overflow); + } else if (cd->intr_ds & ds_data_error) { + debug(("Data error at sector 0x%x\n", cd->sector_first)); + stats(data_error); + } else if (cd->intr_ds & ds_crc_error) { + debug(("CRC error at sector 0x%x\n", cd->sector_first)); + stats(crc_error); + } else if (cd->intr_ds & ds_sync_error) { + debug(("Sync at sector 0x%x\n", cd->sector_first)); + stats(sync_error); + } else if (cd->intr_ds & ds_toc_ready) { + /* do something appropriate */ + } + /* couldn't see why this interrupt, maybe due to init */ + else { + outw(dc_normal | READ_AHEAD, r_data_control); + stats(lost_intr); + } + if (cd->background + && (cd->adapter_last - cd->adapter_first == cd->max_sectors + || cd->fifo_overflowed)) + tasklet_schedule(&cm206_tasklet); /* issue a stop read command */ + stats(interrupt); + return IRQ_HANDLED; +} + +/* we have put the address of the wait queue in who */ +static void cm206_timeout(unsigned long who) +{ + cd->timed_out = 1; + debug(("Timing out\n")); + wake_up_interruptible((wait_queue_head_t *) who); +} + +/* This function returns 1 if a timeout occurred, 0 if an interrupt + happened */ +static int sleep_or_timeout(wait_queue_head_t * wait, int timeout) +{ + cd->timed_out = 0; + init_timer(&cd->timer); + cd->timer.data = (unsigned long) wait; + cd->timer.expires = jiffies + timeout; + add_timer(&cd->timer); + debug(("going to sleep\n")); + interruptible_sleep_on(wait); + del_timer(&cd->timer); + if (cd->timed_out) { + cd->timed_out = 0; + return 1; + } else + return 0; +} + +static void send_command(int command) +{ + debug(("Sending 0x%x\n", command)); + if (!(inw(r_line_status) & ls_transmitter_buffer_empty)) { + cd->command = command; + cli(); /* don't interrupt before sleep */ + outw(dc_mask_sync_error | dc_no_stop_on_error | + (inw(r_data_status) & 0x7f), r_data_control); + /* interrupt routine sends command */ + if (sleep_or_timeout(&cd->uart, UART_TIMEOUT)) { + debug(("Time out on write-buffer\n")); + stats(write_timeout); + outw(command, r_uart_transmit); + } + debug(("Write commmand delayed\n")); + } else + outw(command, r_uart_transmit); +} + +static uch receive_byte(int timeout) +{ + uch ret; + cli(); + debug(("cli\n")); + ret = cd->ur[cd->ur_r]; + if (cd->ur_r != cd->ur_w) { + sti(); + debug(("returning #%d: 0x%x\n", cd->ur_r, + cd->ur[cd->ur_r])); + cd->ur_r++; + cd->ur_r %= UR_SIZE; + return ret; + } else if (sleep_or_timeout(&cd->uart, timeout)) { /* does sti() */ + debug(("Time out on receive-buffer\n")); +#ifdef STATISTICS + if (timeout == UART_TIMEOUT) + stats(receive_timeout) /* no `;'! */ + else + stats(dsb_timeout); +#endif + return 0xda; + } + ret = cd->ur[cd->ur_r]; + debug(("slept; returning #%d: 0x%x\n", cd->ur_r, + cd->ur[cd->ur_r])); + cd->ur_r++; + cd->ur_r %= UR_SIZE; + return ret; +} + +static inline uch receive_echo(void) +{ + return receive_byte(UART_TIMEOUT); +} + +static inline uch send_receive(int command) +{ + send_command(command); + return receive_echo(); +} + +static inline uch wait_dsb(void) +{ + return receive_byte(DSB_TIMEOUT); +} + +static int type_0_command(int command, int expect_dsb) +{ + int e; + clear_ur(); + if (command != (e = send_receive(command))) { + debug(("command 0x%x echoed as 0x%x\n", command, e)); + stats(echo); + return -1; + } + if (expect_dsb) { + cd->dsb = wait_dsb(); /* wait for command to finish */ + } + return 0; +} + +static int type_1_command(int command, int bytes, uch * status) +{ /* returns info */ + int i; + if (type_0_command(command, 0)) + return -1; + for (i = 0; i < bytes; i++) + status[i] = send_receive(c_gimme); + return 0; +} + +/* This function resets the adapter card. We'd better not do this too + * often, because it tends to generate `lost interrupts.' */ +static void reset_cm260(void) +{ + outw(dc_normal | dc_initialize | READ_AHEAD, r_data_control); + udelay(10); /* 3.3 mu sec minimum */ + outw(dc_normal | READ_AHEAD, r_data_control); +} + +/* fsm: frame-sec-min from linear address; one of many */ +static void fsm(int lba, uch * fsm) +{ + fsm[0] = lba % 75; + lba /= 75; + lba += 2; + fsm[1] = lba % 60; + fsm[2] = lba / 60; +} + +static inline int fsm2lba(uch * fsm) +{ + return fsm[0] + 75 * (fsm[1] - 2 + 60 * fsm[2]); +} + +static inline int f_s_m2lba(uch f, uch s, uch m) +{ + return f + 75 * (s - 2 + 60 * m); +} + +static int start_read(int start) +{ + uch read_sector[4] = { c_read_data, }; + int i, e; + + fsm(start, &read_sector[1]); + clear_ur(); + for (i = 0; i < 4; i++) + if (read_sector[i] != (e = send_receive(read_sector[i]))) { + debug(("read_sector: %x echoes %x\n", + read_sector[i], e)); + stats(echo); + if (e == 0xff) { /* this seems to happen often */ + e = receive_echo(); + debug(("Second try %x\n", e)); + if (e != read_sector[i]) + return -1; + } + } + return 0; +} + +static int stop_read(void) +{ + int e; + type_0_command(c_stop, 0); + if ((e = receive_echo()) != 0xff) { + debug(("c_stop didn't send 0xff, but 0x%x\n", e)); + stats(stop_0xff); + return -1; + } + return 0; +} + +/* This function starts to read sectors in adapter memory, the + interrupt routine should stop the read. In fact, the bottom_half + routine takes care of this. Set a flag `background' in the cd + struct to indicate the process. */ + +static int read_background(int start, int reading) +{ + if (cd->background) + return -1; /* can't do twice */ + outw(dc_normal | BACK_AHEAD, r_data_control); + if (!reading && start_read(start)) + return -2; + cd->adapter_first = cd->adapter_last = start; + cd->background = 1; /* flag a read is going on */ + return 0; +} + +#ifdef USE_INSW +#define transport_data insw +#else +/* this routine implements insw(,,). There was a time i had the + impression that there would be any difference in error-behaviour. */ +void transport_data(int port, ush * dest, int count) +{ + int i; + ush *d; + for (i = 0, d = dest; i < count; i++, d++) + *d = inw(port); +} +#endif + + +#define MAX_TRIES 100 +static int read_sector(int start) +{ + int tries = 0; + if (cd->background) { + cd->background = 0; + cd->adapter_last = -1; /* invalidate adapter memory */ + stop_read(); + } + cd->fifo_overflowed = 0; + reset_cm260(); /* empty fifo etc. */ + if (start_read(start)) + return -1; + do { + if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) { + debug(("Read timed out sector 0x%x\n", start)); + stats(read_timeout); + stop_read(); + return -3; + } + tries++; + } while (cd->intr_ds & ds_fifo_empty && tries < MAX_TRIES); + if (tries > 1) + debug(("Took me some tries\n")) + else + if (tries == MAX_TRIES) + debug(("MAX_TRIES tries for read sector\n")); + transport_data(r_fifo_output_buffer, cd->sector, + READ_AHEAD * RAW_SECTOR_SIZE / 2); + if (read_background(start + READ_AHEAD, 1)) + stats(read_background); + cd->sector_first = start; + cd->sector_last = start + READ_AHEAD; + stats(read_restarted); + return 0; +} + +/* The function of bottom-half is to send a stop command to the drive + This isn't easy because the routine is not `owned' by any process; + we can't go to sleep! The variable cd->background gives the status: + 0 no read pending + 1 a read is pending + 2 c_stop waits for write_buffer_empty + 3 c_stop waits for receive_buffer_full: echo + 4 c_stop waits for receive_buffer_full: 0xff +*/ + +static void cm206_tasklet_func(unsigned long ignore) +{ + debug(("bh: %d\n", cd->background)); + switch (cd->background) { + case 1: + stats(bh); + if (!(cd->intr_ls & ls_transmitter_buffer_empty)) { + cd->command = c_stop; + outw(dc_mask_sync_error | dc_no_stop_on_error | + (inw(r_data_status) & 0x7f), r_data_control); + cd->background = 2; + break; /* we'd better not time-out here! */ + } else + outw(c_stop, r_uart_transmit); + /* fall into case 2: */ + case 2: + /* the write has been satisfied by interrupt routine */ + cd->background = 3; + break; + case 3: + if (cd->ur_r != cd->ur_w) { + if (cd->ur[cd->ur_r] != c_stop) { + debug(("cm206_bh: c_stop echoed 0x%x\n", + cd->ur[cd->ur_r])); + stats(echo); + } + cd->ur_r++; + cd->ur_r %= UR_SIZE; + } + cd->background++; + break; + case 4: + if (cd->ur_r != cd->ur_w) { + if (cd->ur[cd->ur_r] != 0xff) { + debug(("cm206_bh: c_stop reacted with 0x%x\n", cd->ur[cd->ur_r])); + stats(stop_0xff); + } + cd->ur_r++; + cd->ur_r %= UR_SIZE; + } + cd->background = 0; + } +} + +static DECLARE_TASKLET(cm206_tasklet, cm206_tasklet_func, 0); + +/* This command clears the dsb_possible_media_change flag, so we must + * retain it. + */ +static void get_drive_status(void) +{ + uch status[2]; + type_1_command(c_drive_status, 2, status); /* this might be done faster */ + cd->dsb = status[0]; + cd->cc = status[1]; + cd->media_changed |= + !!(cd->dsb & (dsb_possible_media_change | + dsb_drive_not_ready | dsb_tray_not_closed)); +} + +static void get_disc_status(void) +{ + if (type_1_command(c_disc_status, 7, cd->disc_status)) { + debug(("get_disc_status: error\n")); + } +} + +/* The new open. The real opening strategy is defined in cdrom.c. */ + +static int cm206_open(struct cdrom_device_info *cdi, int purpose) +{ + if (!cd->openfiles) { /* reset only first time */ + cd->background = 0; + reset_cm260(); + cd->adapter_last = -1; /* invalidate adapter memory */ + cd->sector_last = -1; + } + ++cd->openfiles; + stats(open); + return 0; +} + +static void cm206_release(struct cdrom_device_info *cdi) +{ + if (cd->openfiles == 1) { + if (cd->background) { + cd->background = 0; + stop_read(); + } + cd->sector_last = -1; /* Make our internal buffer invalid */ + FIRST_TRACK = 0; /* No valid disc status */ + } + --cd->openfiles; +} + +/* Empty buffer empties $sectors$ sectors of the adapter card buffer, + * and then reads a sector in kernel memory. */ +static void empty_buffer(int sectors) +{ + while (sectors >= 0) { + transport_data(r_fifo_output_buffer, + cd->sector + cd->fifo_overflowed, + RAW_SECTOR_SIZE / 2 - cd->fifo_overflowed); + --sectors; + ++cd->adapter_first; /* update the current adapter sector */ + cd->fifo_overflowed = 0; /* reset overflow bit */ + stats(sector_transferred); + } + cd->sector_first = cd->adapter_first - 1; + cd->sector_last = cd->adapter_first; /* update the buffer sector */ +} + +/* try_adapter. This function determines if the requested sector is + in adapter memory, or will appear there soon. Returns 0 upon + success */ +static int try_adapter(int sector) +{ + if (cd->adapter_first <= sector && sector < cd->adapter_last) { + /* sector is in adapter memory */ + empty_buffer(sector - cd->adapter_first); + return 0; + } else if (cd->background == 1 && cd->adapter_first <= sector + && sector < cd->adapter_first + cd->max_sectors) { + /* a read is going on, we can wait for it */ + cd->wait_back = 1; + while (sector >= cd->adapter_last) { + if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) { + debug(("Timed out during background wait: %d %d %d %d\n", sector, cd->adapter_last, cd->adapter_first, cd->background)); + stats(back_read_timeout); + cd->wait_back = 0; + return -1; + } + } + cd->wait_back = 0; + empty_buffer(sector - cd->adapter_first); + return 0; + } else + return -2; +} + +/* This is not a very smart implementation. We could optimize for + consecutive block numbers. I'm not convinced this would really + bring down the processor load. */ +static void do_cm206_request(request_queue_t * q) +{ + long int i, cd_sec_no; + int quarter, error; + uch *source, *dest; + struct request *req; + + while (1) { /* repeat until all requests have been satisfied */ + req = elv_next_request(q); + if (!req) + return; + + if (req->cmd != READ) { + debug(("Non-read command %d on cdrom\n", req->cmd)); + end_request(req, 0); + continue; + } + spin_unlock_irq(q->queue_lock); + error = 0; + for (i = 0; i < req->nr_sectors; i++) { + int e1, e2; + cd_sec_no = (req->sector + i) / BLOCKS_ISO; /* 4 times 512 bytes */ + quarter = (req->sector + i) % BLOCKS_ISO; + dest = req->buffer + i * LINUX_BLOCK_SIZE; + /* is already in buffer memory? */ + if (cd->sector_first <= cd_sec_no + && cd_sec_no < cd->sector_last) { + source = + ((uch *) cd->sector) + 16 + + quarter * LINUX_BLOCK_SIZE + + (cd_sec_no - + cd->sector_first) * RAW_SECTOR_SIZE; + memcpy(dest, source, LINUX_BLOCK_SIZE); + } else if (!(e1 = try_adapter(cd_sec_no)) || + !(e2 = read_sector(cd_sec_no))) { + source = + ((uch *) cd->sector) + 16 + + quarter * LINUX_BLOCK_SIZE; + memcpy(dest, source, LINUX_BLOCK_SIZE); + } else { + error = 1; + debug(("cm206_request: %d %d\n", e1, e2)); + } + } + spin_lock_irq(q->queue_lock); + end_request(req, !error); + } +} + +/* Audio support. I've tried very hard, but the cm206 drive doesn't + seem to have a get_toc (table-of-contents) function, while i'm + pretty sure it must read the toc upon disc insertion. Therefore + this function has been implemented through a binary search + strategy. All track starts that happen to be found are stored in + cd->toc[], for future use. + + I've spent a whole day on a bug that only shows under Workman--- + I don't get it. Tried everything, nothing works. If workman asks + for track# 0xaa, it'll get the wrong time back. Any other program + receives the correct value. I'm stymied. +*/ + +/* seek seeks to address lba. It does wait to arrive there. */ +static void seek(int lba) +{ + int i; + uch seek_command[4] = { c_seek, }; + + fsm(lba, &seek_command[1]); + for (i = 0; i < 4; i++) + type_0_command(seek_command[i], 0); + cd->dsb = wait_dsb(); +} + +static uch bcdbin(unsigned char bcd) +{ /* stolen from mcd.c! */ + return (bcd >> 4) * 10 + (bcd & 0xf); +} + +static inline uch normalize_track(uch track) +{ + if (track < 1) + return 1; + if (track > LAST_TRACK) + return LAST_TRACK + 1; + return track; +} + +/* This function does a binary search for track start. It records all + * tracks seen in the process. Input $track$ must be between 1 and + * #-of-tracks+1. Note that the start of the disc must be in toc[1].fsm. + */ +static int get_toc_lba(uch track) +{ + int max = 74 * 60 * 75 - 150, min = fsm2lba(cd->toc[1].fsm); + int i, lba, l, old_lba = 0; + uch *q = cd->q; + uch ct; /* current track */ + int binary = 0; + const int skip = 3 * 60 * 75; /* 3 minutes */ + + for (i = track; i > 0; i--) + if (cd->toc[i].track) { + min = fsm2lba(cd->toc[i].fsm); + break; + } + lba = min + skip; + do { + seek(lba); + type_1_command(c_read_current_q, 10, q); + ct = normalize_track(q[1]); + if (!cd->toc[ct].track) { + l = q[9] - bcdbin(q[5]) + 75 * (q[8] - + bcdbin(q[4]) - 2 + + 60 * (q[7] - + bcdbin(q + [3]))); + cd->toc[ct].track = q[1]; /* lead out still 0xaa */ + fsm(l, cd->toc[ct].fsm); + cd->toc[ct].q0 = q[0]; /* contains adr and ctrl info */ + if (ct == track) + return l; + } + old_lba = lba; + if (binary) { + if (ct < track) + min = lba; + else + max = lba; + lba = (min + max) / 2; + } else { + if (ct < track) + lba += skip; + else { + binary = 1; + max = lba; + min = lba - skip; + lba = (min + max) / 2; + } + } + } while (lba != old_lba); + return lba; +} + +static void update_toc_entry(uch track) +{ + track = normalize_track(track); + if (!cd->toc[track].track) + get_toc_lba(track); +} + +/* return 0 upon success */ +static int read_toc_header(struct cdrom_tochdr *hp) +{ + if (!FIRST_TRACK) + get_disc_status(); + if (hp) { + int i; + hp->cdth_trk0 = FIRST_TRACK; + hp->cdth_trk1 = LAST_TRACK; + /* fill in first track position */ + for (i = 0; i < 3; i++) + cd->toc[1].fsm[i] = cd->disc_status[3 + i]; + update_toc_entry(LAST_TRACK + 1); /* find most entries */ + return 0; + } + return -1; +} + +static void play_from_to_msf(struct cdrom_msf *msfp) +{ + uch play_command[] = { c_play, + msfp->cdmsf_frame0, msfp->cdmsf_sec0, msfp->cdmsf_min0, + msfp->cdmsf_frame1, msfp->cdmsf_sec1, msfp->cdmsf_min1, 2, + 2 + }; + int i; + for (i = 0; i < 9; i++) + type_0_command(play_command[i], 0); + for (i = 0; i < 3; i++) + PLAY_TO.fsm[i] = play_command[i + 4]; + PLAY_TO.track = 0; /* say no track end */ + cd->dsb = wait_dsb(); +} + +static void play_from_to_track(int from, int to) +{ + uch play_command[8] = { c_play, }; + int i; + + if (from == 0) { /* continue paused play */ + for (i = 0; i < 3; i++) { + play_command[i + 1] = cd->audio_status[i + 2]; + play_command[i + 4] = PLAY_TO.fsm[i]; + } + } else { + update_toc_entry(from); + update_toc_entry(to + 1); + for (i = 0; i < 3; i++) { + play_command[i + 1] = cd->toc[from].fsm[i]; + PLAY_TO.fsm[i] = play_command[i + 4] = + cd->toc[to + 1].fsm[i]; + } + PLAY_TO.track = to; + } + for (i = 0; i < 7; i++) + type_0_command(play_command[i], 0); + for (i = 0; i < 2; i++) + type_0_command(0x2, 0); /* volume */ + cd->dsb = wait_dsb(); +} + +static int get_current_q(struct cdrom_subchnl *qp) +{ + int i; + uch *q = cd->q; + if (type_1_command(c_read_current_q, 10, q)) + return 0; +/* q[0] = bcdbin(q[0]); Don't think so! */ + for (i = 2; i < 6; i++) + q[i] = bcdbin(q[i]); + qp->cdsc_adr = q[0] & 0xf; + qp->cdsc_ctrl = q[0] >> 4; /* from mcd.c */ + qp->cdsc_trk = q[1]; + qp->cdsc_ind = q[2]; + if (qp->cdsc_format == CDROM_MSF) { + qp->cdsc_reladdr.msf.minute = q[3]; + qp->cdsc_reladdr.msf.second = q[4]; + qp->cdsc_reladdr.msf.frame = q[5]; + qp->cdsc_absaddr.msf.minute = q[7]; + qp->cdsc_absaddr.msf.second = q[8]; + qp->cdsc_absaddr.msf.frame = q[9]; + } else { + qp->cdsc_reladdr.lba = f_s_m2lba(q[5], q[4], q[3]); + qp->cdsc_absaddr.lba = f_s_m2lba(q[9], q[8], q[7]); + } + get_drive_status(); + if (cd->dsb & dsb_play_in_progress) + qp->cdsc_audiostatus = CDROM_AUDIO_PLAY; + else if (PAUSED) + qp->cdsc_audiostatus = CDROM_AUDIO_PAUSED; + else + qp->cdsc_audiostatus = CDROM_AUDIO_NO_STATUS; + return 0; +} + +static void invalidate_toc(void) +{ + memset(cd->toc, 0, sizeof(cd->toc)); + memset(cd->disc_status, 0, sizeof(cd->disc_status)); +} + +/* cdrom.c guarantees that cdte_format == CDROM_MSF */ +static void get_toc_entry(struct cdrom_tocentry *ep) +{ + uch track = normalize_track(ep->cdte_track); + update_toc_entry(track); + ep->cdte_addr.msf.frame = cd->toc[track].fsm[0]; + ep->cdte_addr.msf.second = cd->toc[track].fsm[1]; + ep->cdte_addr.msf.minute = cd->toc[track].fsm[2]; + ep->cdte_adr = cd->toc[track].q0 & 0xf; + ep->cdte_ctrl = cd->toc[track].q0 >> 4; + ep->cdte_datamode = 0; +} + +/* Audio ioctl. Ioctl commands connected to audio are in such an + * idiosyncratic i/o format, that we leave these untouched. Return 0 + * upon success. Memory checking has been done by cdrom_ioctl(), the + * calling function, as well as LBA/MSF sanitization. +*/ +static int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, + void *arg) +{ + switch (cmd) { + case CDROMREADTOCHDR: + return read_toc_header((struct cdrom_tochdr *) arg); + case CDROMREADTOCENTRY: + get_toc_entry((struct cdrom_tocentry *) arg); + return 0; + case CDROMPLAYMSF: + play_from_to_msf((struct cdrom_msf *) arg); + return 0; + case CDROMPLAYTRKIND: /* admittedly, not particularly beautiful */ + play_from_to_track(((struct cdrom_ti *) arg)->cdti_trk0, + ((struct cdrom_ti *) arg)->cdti_trk1); + return 0; + case CDROMSTOP: + PAUSED = 0; + if (cd->dsb & dsb_play_in_progress) + return type_0_command(c_stop, 1); + else + return 0; + case CDROMPAUSE: + get_drive_status(); + if (cd->dsb & dsb_play_in_progress) { + type_0_command(c_stop, 1); + type_1_command(c_audio_status, 5, + cd->audio_status); + PAUSED = 1; /* say we're paused */ + } + return 0; + case CDROMRESUME: + if (PAUSED) + play_from_to_track(0, 0); + PAUSED = 0; + return 0; + case CDROMSTART: + case CDROMVOLCTRL: + return 0; + case CDROMSUBCHNL: + return get_current_q((struct cdrom_subchnl *) arg); + default: + return -EINVAL; + } +} + +static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) +{ + if (cd != NULL) { + int r; + get_drive_status(); /* ensure cd->media_changed OK */ + r = cd->media_changed; + cd->media_changed = 0; /* clear bit */ + return r; + } else + return -EIO; +} + +/* The new generic cdrom support. Routines should be concise, most of + the logic should be in cdrom.c */ + + +/* controls tray movement */ +static int cm206_tray_move(struct cdrom_device_info *cdi, int position) +{ + if (position) { /* 1: eject */ + type_0_command(c_open_tray, 1); + invalidate_toc(); + } else + type_0_command(c_close_tray, 1); /* 0: close */ + return 0; +} + +/* gives current state of the drive */ +static int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr) +{ + get_drive_status(); + if (cd->dsb & dsb_tray_not_closed) + return CDS_TRAY_OPEN; + if (!(cd->dsb & dsb_disc_present)) + return CDS_NO_DISC; + if (cd->dsb & dsb_drive_not_ready) + return CDS_DRIVE_NOT_READY; + return CDS_DISC_OK; +} + +/* locks or unlocks door lock==1: lock; return 0 upon success */ +static int cm206_lock_door(struct cdrom_device_info *cdi, int lock) +{ + uch command = (lock) ? c_lock_tray : c_unlock_tray; + type_0_command(command, 1); /* wait and get dsb */ + /* the logic calculates the success, 0 means successful */ + return lock ^ ((cd->dsb & dsb_tray_locked) != 0); +} + +/* Although a session start should be in LBA format, we return it in + MSF format because it is slightly easier, and the new generic ioctl + will take care of the necessary conversion. */ +static int cm206_get_last_session(struct cdrom_device_info *cdi, + struct cdrom_multisession *mssp) +{ + if (!FIRST_TRACK) + get_disc_status(); + if (mssp != NULL) { + if (DISC_STATUS & cds_multi_session) { /* multi-session */ + mssp->addr.msf.frame = cd->disc_status[3]; + mssp->addr.msf.second = cd->disc_status[4]; + mssp->addr.msf.minute = cd->disc_status[5]; + mssp->addr_format = CDROM_MSF; + mssp->xa_flag = 1; + } else { + mssp->xa_flag = 0; + } + return 1; + } + return 0; +} + +static int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) +{ + uch upc[10]; + char *ret = mcn->medium_catalog_number; + int i; + + if (type_1_command(c_read_upc, 10, upc)) + return -EIO; + for (i = 0; i < 13; i++) { + int w = i / 2 + 1, r = i % 2; + if (r) + ret[i] = 0x30 | (upc[w] & 0x0f); + else + ret[i] = 0x30 | ((upc[w] >> 4) & 0x0f); + } + ret[13] = '\0'; + return 0; +} + +static int cm206_reset(struct cdrom_device_info *cdi) +{ + stop_read(); + reset_cm260(); + outw(dc_normal | dc_break | READ_AHEAD, r_data_control); + mdelay(1); /* 750 musec minimum */ + outw(dc_normal | READ_AHEAD, r_data_control); + cd->sector_last = -1; /* flag no data buffered */ + cd->adapter_last = -1; + invalidate_toc(); + return 0; +} + +static int cm206_select_speed(struct cdrom_device_info *cdi, int speed) +{ + int r; + switch (speed) { + case 0: + r = type_0_command(c_auto_mode, 1); + break; + case 1: + r = type_0_command(c_force_1x, 1); + break; + case 2: + r = type_0_command(c_force_2x, 1); + break; + default: + return -1; + } + if (r < 0) + return r; + else + return 1; +} + +static struct cdrom_device_ops cm206_dops = { + .open = cm206_open, + .release = cm206_release, + .drive_status = cm206_drive_status, + .media_changed = cm206_media_changed, + .tray_move = cm206_tray_move, + .lock_door = cm206_lock_door, + .select_speed = cm206_select_speed, + .get_last_session = cm206_get_last_session, + .get_mcn = cm206_get_upc, + .reset = cm206_reset, + .audio_ioctl = cm206_audio_ioctl, + .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | + CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | + CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED | + CDC_DRIVE_STATUS, + .n_minors = 1, +}; + + +static struct cdrom_device_info cm206_info = { + .ops = &cm206_dops, + .speed = 2, + .capacity = 1, + .name = "cm206", +}; + +static int cm206_block_open(struct inode *inode, struct file *file) +{ + return cdrom_open(&cm206_info, inode, file); +} + +static int cm206_block_release(struct inode *inode, struct file *file) +{ + return cdrom_release(&cm206_info, file); +} + +static int cm206_block_ioctl(struct inode *inode, struct file *file, + unsigned cmd, unsigned long arg) +{ + switch (cmd) { +#ifdef STATISTICS + case CM206CTL_GET_STAT: + if (arg >= NR_STATS) + return -EINVAL; + return cd->stats[arg]; + case CM206CTL_GET_LAST_STAT: + if (arg >= NR_STATS) + return -EINVAL; + return cd->last_stat[arg]; +#endif + default: + break; + } + + return cdrom_ioctl(file, &cm206_info, inode, cmd, arg); +} + +static int cm206_block_media_changed(struct gendisk *disk) +{ + return cdrom_media_changed(&cm206_info); +} + +static struct block_device_operations cm206_bdops = +{ + .owner = THIS_MODULE, + .open = cm206_block_open, + .release = cm206_block_release, + .ioctl = cm206_block_ioctl, + .media_changed = cm206_block_media_changed, +}; + +static struct gendisk *cm206_gendisk; + +/* This function probes for the adapter card. It returns the base + address if it has found the adapter card. One can specify a base + port to probe specifically, or 0 which means span all possible + bases. + + Linus says it is too dangerous to use writes for probing, so we + stick with pure reads for a while. Hope that 8 possible ranges, + request_region, 15 bits of one port and 6 of another make things + likely enough to accept the region on the first hit... + */ +static int __init probe_base_port(int base) +{ + int b = 0x300, e = 0x370; /* this is the range of start addresses */ + volatile int fool, i; + + if (base) + b = e = base; + for (base = b; base <= e; base += 0x10) { + if (!request_region(base, 0x10,"cm206")) + continue; + for (i = 0; i < 3; i++) + fool = inw(base + 2); /* empty possibly uart_receive_buffer */ + if ((inw(base + 6) & 0xffef) != 0x0001 || /* line_status */ + (inw(base) & 0xad00) != 0) { /* data status */ + release_region(base,0x10); + continue; + } + return (base); + } + return 0; +} + +#if !defined(MODULE) || defined(AUTO_PROBE_MODULE) +/* Probe for irq# nr. If nr==0, probe for all possible irq's. */ +static int __init probe_irq(int nr) +{ + int irqs, irq; + outw(dc_normal | READ_AHEAD, r_data_control); /* disable irq-generation */ + sti(); + irqs = probe_irq_on(); + reset_cm260(); /* causes interrupt */ + udelay(100); /* wait for it */ + irq = probe_irq_off(irqs); + outw(dc_normal | READ_AHEAD, r_data_control); /* services interrupt */ + if (nr && irq != nr && irq > 0) + return 0; /* wrong interrupt happened */ + else + return irq; +} +#endif + +int __init cm206_init(void) +{ + uch e = 0; + long int size = sizeof(struct cm206_struct); + struct gendisk *disk; + + printk(KERN_INFO "cm206 cdrom driver " REVISION); + cm206_base = probe_base_port(auto_probe ? 0 : cm206_base); + if (!cm206_base) { + printk(" can't find adapter!\n"); + return -EIO; + } + printk(" adapter at 0x%x", cm206_base); + cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL); + if (!cd) + goto out_base; + /* Now we have found the adaptor card, try to reset it. As we have + * found out earlier, this process generates an interrupt as well, + * so we might just exploit that fact for irq probing! */ +#if !defined(MODULE) || defined(AUTO_PROBE_MODULE) + cm206_irq = probe_irq(auto_probe ? 0 : cm206_irq); + if (cm206_irq <= 0) { + printk("can't find IRQ!\n"); + goto out_probe; + } else + printk(" IRQ %d found\n", cm206_irq); +#else + cli(); + reset_cm260(); + /* Now, the problem here is that reset_cm260 can generate an + interrupt. It seems that this can cause a kernel oops some time + later. So we wait a while and `service' this interrupt. */ + mdelay(1); + outw(dc_normal | READ_AHEAD, r_data_control); + sti(); + printk(" using IRQ %d\n", cm206_irq); +#endif + if (send_receive_polled(c_drive_configuration) != + c_drive_configuration) { + printk(KERN_INFO " drive not there\n"); + goto out_probe; + } + e = send_receive_polled(c_gimme); + printk(KERN_INFO "Firmware revision %d", e & dcf_revision_code); + if (e & dcf_transfer_rate) + printk(" double"); + else + printk(" single"); + printk(" speed drive"); + if (e & dcf_motorized_tray) + printk(", motorized tray"); + if (request_irq(cm206_irq, cm206_interrupt, 0, "cm206", NULL)) { + printk("\nUnable to reserve IRQ---aborted\n"); + goto out_probe; + } + printk(".\n"); + + if (register_blkdev(MAJOR_NR, "cm206")) + goto out_blkdev; + + disk = alloc_disk(1); + if (!disk) + goto out_disk; + disk->major = MAJOR_NR; + disk->first_minor = 0; + sprintf(disk->disk_name, "cm206cd"); + disk->fops = &cm206_bdops; + disk->flags = GENHD_FL_CD; + cm206_gendisk = disk; + if (register_cdrom(&cm206_info) != 0) { + printk(KERN_INFO "Cannot register for cdrom %d!\n", MAJOR_NR); + goto out_cdrom; + } + cm206_queue = blk_init_queue(do_cm206_request, &cm206_lock); + if (!cm206_queue) + goto out_queue; + + blk_queue_hardsect_size(cm206_queue, 2048); + disk->queue = cm206_queue; + add_disk(disk); + + memset(cd, 0, sizeof(*cd)); /* give'm some reasonable value */ + cd->sector_last = -1; /* flag no data buffered */ + cd->adapter_last = -1; + init_timer(&cd->timer); + cd->timer.function = cm206_timeout; + cd->max_sectors = (inw(r_data_status) & ds_ram_size) ? 24 : 97; + printk(KERN_INFO "%d kB adapter memory available, " + " %ld bytes kernel memory used.\n", cd->max_sectors * 2, + size); + return 0; + +out_queue: + unregister_cdrom(&cm206_info); +out_cdrom: + put_disk(disk); +out_disk: + unregister_blkdev(MAJOR_NR, "cm206"); +out_blkdev: + free_irq(cm206_irq, NULL); +out_probe: + kfree(cd); +out_base: + release_region(cm206_base, 16); + return -EIO; +} + +#ifdef MODULE + + +static void __init parse_options(void) +{ + int i; + for (i = 0; i < 2; i++) { + if (0x300 <= cm206[i] && i <= 0x370 + && cm206[i] % 0x10 == 0) { + cm206_base = cm206[i]; + auto_probe = 0; + } else if (3 <= cm206[i] && cm206[i] <= 15) { + cm206_irq = cm206[i]; + auto_probe = 0; + } + } +} + +static int __init __cm206_init(void) +{ + parse_options(); +#if !defined(AUTO_PROBE_MODULE) + auto_probe = 0; +#endif + return cm206_init(); +} + +static void __exit cm206_exit(void) +{ + del_gendisk(cm206_gendisk); + put_disk(cm206_gendisk); + if (unregister_cdrom(&cm206_info)) { + printk("Can't unregister cdrom cm206\n"); + return; + } + if (unregister_blkdev(MAJOR_NR, "cm206")) { + printk("Can't unregister major cm206\n"); + return; + } + blk_cleanup_queue(cm206_queue); + free_irq(cm206_irq, NULL); + kfree(cd); + release_region(cm206_base, 16); + printk(KERN_INFO "cm206 removed\n"); +} + +module_init(__cm206_init); +module_exit(cm206_exit); + +#else /* !MODULE */ + +/* This setup function accepts either `auto' or numbers in the range + * 3--11 (for irq) or 0x300--0x370 (for base port) or both. */ + +static int __init cm206_setup(char *s) +{ + int i, p[4]; + + (void) get_options(s, ARRAY_SIZE(p), p); + + if (!strcmp(s, "auto")) + auto_probe = 1; + for (i = 1; i <= p[0]; i++) { + if (0x300 <= p[i] && i <= 0x370 && p[i] % 0x10 == 0) { + cm206_base = p[i]; + auto_probe = 0; + } else if (3 <= p[i] && p[i] <= 15) { + cm206_irq = p[i]; + auto_probe = 0; + } + } + return 1; +} + +__setup("cm206=", cm206_setup); + +#endif /* !MODULE */ +MODULE_ALIAS_BLOCKDEV_MAJOR(CM206_CDROM_MAJOR); + diff --git a/ddverify/case_studies/cdrom/cm206/cm206.h b/ddverify/case_studies/cdrom/cm206/cm206.h new file mode 100644 index 000000000..0ae51c1a0 --- /dev/null +++ b/ddverify/case_studies/cdrom/cm206/cm206.h @@ -0,0 +1,171 @@ +/* cm206.h Header file for cm206.c. + Copyright (c) 1995 David van Leeuwen +*/ + +#ifndef LINUX_CM206_H +#define LINUX_CM206_H + +#include + +/* First, the cm260 stuff */ +/* The ports and irq used. Although CM206_BASE and CM206_IRQ are defined + below, the values are not used unless autoprobing is turned off and + no LILO boot options or module command line options are given. Change + these values to your own as last resort if autoprobing and options + don't work. */ + +#define CM206_BASE 0x340 +#define CM206_IRQ 11 + +#define r_data_status (cm206_base) +#define r_uart_receive (cm206_base+0x2) +#define r_fifo_output_buffer (cm206_base+0x4) +#define r_line_status (cm206_base+0x6) +#define r_data_control (cm206_base+0x8) +#define r_uart_transmit (cm206_base+0xa) +#define r_test_clock (cm206_base+0xc) +#define r_test_control (cm206_base+0xe) + +/* the data_status flags */ +#define ds_ram_size 0x4000 +#define ds_toc_ready 0x2000 +#define ds_fifo_empty 0x1000 +#define ds_sync_error 0x800 +#define ds_crc_error 0x400 +#define ds_data_error 0x200 +#define ds_fifo_overflow 0x100 +#define ds_data_ready 0x80 + +/* the line_status flags */ +#define ls_attention 0x10 +#define ls_parity_error 0x8 +#define ls_overrun 0x4 +#define ls_receive_buffer_full 0x2 +#define ls_transmitter_buffer_empty 0x1 + +/* the data control register flags */ +#define dc_read_q_channel 0x4000 +#define dc_mask_sync_error 0x2000 +#define dc_toc_enable 0x1000 +#define dc_no_stop_on_error 0x800 +#define dc_break 0x400 +#define dc_initialize 0x200 +#define dc_mask_transmit_ready 0x100 +#define dc_flag_enable 0x80 + +/* Define the default data control register flags here */ +#define dc_normal (dc_mask_sync_error | dc_no_stop_on_error | \ + dc_mask_transmit_ready) + +/* now some constants related to the cm206 */ +/* another drive status byte, echoed by the cm206 on most commands */ + +#define dsb_error_condition 0x1 +#define dsb_play_in_progress 0x4 +#define dsb_possible_media_change 0x8 +#define dsb_disc_present 0x10 +#define dsb_drive_not_ready 0x20 +#define dsb_tray_locked 0x40 +#define dsb_tray_not_closed 0x80 + +#define dsb_not_useful (dsb_drive_not_ready | dsb_tray_not_closed) + +/* the cm206 command set */ + +#define c_close_tray 0 +#define c_lock_tray 0x01 +#define c_unlock_tray 0x04 +#define c_open_tray 0x05 +#define c_seek 0x10 +#define c_read_data 0x20 +#define c_force_1x 0x21 +#define c_force_2x 0x22 +#define c_auto_mode 0x23 +#define c_play 0x30 +#define c_set_audio_mode 0x31 +#define c_read_current_q 0x41 +#define c_stream_q 0x42 +#define c_drive_status 0x50 +#define c_disc_status 0x51 +#define c_audio_status 0x52 +#define c_drive_configuration 0x53 +#define c_read_upc 0x60 +#define c_stop 0x70 +#define c_calc_checksum 0xe5 + +#define c_gimme 0xf8 + +/* finally, the (error) condition that the drive can be in * + * OK, this is not always an error, but let's prefix it with e_ */ + +#define e_none 0 +#define e_illegal_command 0x01 +#define e_sync 0x02 +#define e_seek 0x03 +#define e_parity 0x04 +#define e_focus 0x05 +#define e_header_sync 0x06 +#define e_code_incompatibility 0x07 +#define e_reset_done 0x08 +#define e_bad_parameter 0x09 +#define e_radial 0x0a +#define e_sub_code 0x0b +#define e_no_data_track 0x0c +#define e_scan 0x0d +#define e_tray_open 0x0f +#define e_no_disc 0x10 +#define e_tray stalled 0x11 + +/* drive configuration masks */ + +#define dcf_revision_code 0x7 +#define dcf_transfer_rate 0x60 +#define dcf_motorized_tray 0x80 + +/* disc status byte */ + +#define cds_multi_session 0x2 +#define cds_all_audio 0x8 +#define cds_xa_mode 0xf0 + +/* finally some ioctls for the driver */ + +#define CM206CTL_GET_STAT _IO( 0x20, 0 ) +#define CM206CTL_GET_LAST_STAT _IO( 0x20, 1 ) + +#ifdef STATISTICS + +/* This is an ugly way to guarantee that the names of the statistics + * are the same in the code and in the diagnostics program. */ + +#ifdef __KERNEL__ +#define x(a) st_ ## a +#define y enum +#else +#define x(a) #a +#define y char * stats_name[] = +#endif + +y {x(interrupt), x(data_ready), x(fifo_overflow), x(data_error), + x(crc_error), x(sync_error), x(lost_intr), x(echo), + x(write_timeout), x(receive_timeout), x(read_timeout), + x(dsb_timeout), x(stop_0xff), x(back_read_timeout), + x(sector_transferred), x(read_restarted), x(read_background), + x(bh), x(open), x(ioctl_multisession), x(attention) +#ifdef __KERNEL__ + , x(last_entry) +#endif + }; + +#ifdef __KERNEL__ +#define NR_STATS st_last_entry +#else +#define NR_STATS (sizeof(stats_name)/sizeof(char*)) +#endif + +#undef y +#undef x + +#endif /* STATISTICS */ + +#endif /* LINUX_CM206_H */ diff --git a/ddverify/case_studies/char/applicom/applicom.c b/ddverify/case_studies/char/applicom/applicom.c new file mode 100644 index 000000000..8ccca29ab --- /dev/null +++ b/ddverify/case_studies/char/applicom/applicom.c @@ -0,0 +1,850 @@ +/* Derived from Applicom driver ac.c for SCO Unix */ +/* Ported by David Woodhouse, Axiom (Cambridge) Ltd. */ +/* dwmw2@infradead.org 30/8/98 */ +/* $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $ */ +/* This module is for Linux 2.1 and 2.2 series kernels. */ +/*****************************************************************************/ +/* J PAGET 18/02/94 passage V2.4.2 ioctl avec code 2 reset to les interrupt */ +/* ceci pour reseter correctement apres une sortie sauvage */ +/* J PAGET 02/05/94 passage V2.4.3 dans le traitement de d'interruption, */ +/* LoopCount n'etait pas initialise a 0. */ +/* F LAFORSE 04/07/95 version V2.6.0 lecture bidon apres acces a une carte */ +/* pour liberer le bus */ +/* J.PAGET 19/11/95 version V2.6.1 Nombre, addresse,irq n'est plus configure */ +/* et passe en argument a acinit, mais est scrute sur le bus pour s'adapter */ +/* au nombre de cartes presentes sur le bus. IOCL code 6 affichait V2.4.3 */ +/* F.LAFORSE 28/11/95 creation de fichiers acXX.o avec les differentes */ +/* adresses de base des cartes, IOCTL 6 plus complet */ +/* J.PAGET le 19/08/96 copie de la version V2.6 en V2.8.0 sans modification */ +/* de code autre que le texte V2.6.1 en V2.8.0 */ +/*****************************************************************************/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "applicom.h" + + +/* NOTE: We use for loops with {write,read}b() instead of + memcpy_{from,to}io throughout this driver. This is because + the board doesn't correctly handle word accesses - only + bytes. +*/ + + +#undef DEBUG + +#define MAX_BOARD 8 /* maximum of pc board possible */ +#define MAX_ISA_BOARD 4 +#define LEN_RAM_IO 0x800 +#define AC_MINOR 157 + +#ifndef PCI_VENDOR_ID_APPLICOM +#define PCI_VENDOR_ID_APPLICOM 0x1389 +#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001 +#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002 +#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 +#endif +#define MAX_PCI_DEVICE_NUM 3 + +char *applicom_pci_devnames[] = { + "PCI board", + "PCI2000IBS / PCI2000CAN", + "PCI2000PFB" +}; + +struct pci_device_id applicom_pci_tbl[] = { + { PCI_VENDOR_ID_APPLICOM, PCI_DEVICE_ID_APPLICOM_PCIGENERIC, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_VENDOR_ID_APPLICOM, PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_VENDOR_ID_APPLICOM, PCI_DEVICE_ID_APPLICOM_PCI2000PFB, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { 0 } +}; +MODULE_DEVICE_TABLE(pci, applicom_pci_tbl); + +MODULE_AUTHOR("David Woodhouse & Applicom International"); +MODULE_DESCRIPTION("Driver for Applicom Profibus card"); +MODULE_LICENSE("GPL"); + +MODULE_SUPPORTED_DEVICE("ac"); + + +struct applicom_board { + unsigned long PhysIO; + void __iomem *RamIO; + wait_queue_head_t FlagSleepSend; + long irq; + spinlock_t mutex; +} apbs[MAX_BOARD]; + +unsigned int irq = 0; /* interrupt number IRQ */ +unsigned long mem = 0; /* physical segment of board */ + +module_param(irq, uint, 0); +MODULE_PARM_DESC(irq, "IRQ of the Applicom board"); +module_param(mem, ulong, 0); +MODULE_PARM_DESC(mem, "Shared Memory Address of Applicom board"); + +unsigned int numboards; /* number of installed boards */ +volatile unsigned char Dummy; +DECLARE_WAIT_QUEUE_HEAD(FlagSleepRec); +unsigned int WriteErrorCount; /* number of write error */ +unsigned int ReadErrorCount; /* number of read error */ +unsigned int DeviceErrorCount; /* number of device error */ + +ssize_t ac_read (struct file *, char __user *, size_t, loff_t *); +ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *); +int ac_ioctl(struct inode *, struct file *, unsigned int, + unsigned long); +irqreturn_t ac_interrupt(int, void *); + +const struct file_operations ac_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = ac_read, + .write = ac_write, + .ioctl = ac_ioctl, +}; + +struct miscdevice ac_miscdev = { + AC_MINOR, + "ac", + &ac_fops +}; + +int dummy; /* dev_id for request_irq() */ + +int ac_register_board(unsigned long physloc, void __iomem *loc, + unsigned char boardno) +{ + volatile unsigned char byte_reset_it; + + if((readb(loc + CONF_END_TEST) != 0x00) || + (readb(loc + CONF_END_TEST + 1) != 0x55) || + (readb(loc + CONF_END_TEST + 2) != 0xAA) || + (readb(loc + CONF_END_TEST + 3) != 0xFF)) + return 0; + + if (!boardno) + boardno = readb(loc + NUMCARD_OWNER_TO_PC); + + if (!boardno || boardno > MAX_BOARD) { + printk(KERN_WARNING "Board #%d (at 0x%lx) is out of range (1 <= x <= %d).\n", + boardno, physloc, MAX_BOARD); + return 0; + } + + if (apbs[boardno - 1].RamIO) { + printk(KERN_WARNING "Board #%d (at 0x%lx) conflicts with previous board #%d (at 0x%lx)\n", + boardno, physloc, boardno, apbs[boardno-1].PhysIO); + return 0; + } + + boardno--; + + apbs[boardno].PhysIO = physloc; + apbs[boardno].RamIO = loc; + init_waitqueue_head(&apbs[boardno].FlagSleepSend); + spin_lock_init(&apbs[boardno].mutex); + byte_reset_it = readb(loc + RAM_IT_TO_PC); + + numboards++; + return boardno + 1; +} + +void __exit applicom_exit(void) +{ + unsigned int i; + + misc_deregister(&ac_miscdev); + + for (i = 0; i < MAX_BOARD; i++) { + + if (!apbs[i].RamIO) + continue; + + if (apbs[i].irq) + free_irq(apbs[i].irq, &dummy); + + iounmap(apbs[i].RamIO); + } +} + +int __init applicom_init(void) +{ + int i, numisa = 0; + struct pci_dev *dev = NULL; + void __iomem *RamIO; + int boardno, ret; + + printk(KERN_INFO "Applicom driver: $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $\n"); + + /* No mem and irq given - check for a PCI card */ + numboards = 0; + + while ( (dev = pci_get_class(PCI_CLASS_OTHERS << 16, dev))) { + if (dev->vendor != PCI_VENDOR_ID_APPLICOM) + continue; + + + if (dev->device > MAX_PCI_DEVICE_NUM || dev->device == 0) + continue; + + if (pci_enable_device(dev)) + return -EIO; + + RamIO = ioremap(dev->resource[0].start, LEN_RAM_IO); + + if (!RamIO) { + printk(KERN_INFO "ac.o: Failed to ioremap PCI memory " + "space at 0x%llx\n", + (unsigned long long)dev->resource[0].start); + pci_disable_device(dev); + return -EIO; + } + + printk(KERN_INFO "Applicom %s found at mem 0x%llx, irq %d\n", + applicom_pci_devnames[dev->device-1], + (unsigned long long)dev->resource[0].start, + dev->irq); + + boardno = ac_register_board(dev->resource[0].start, RamIO,0); + + if (!boardno) { + printk(KERN_INFO "ac.o: PCI Applicom device doesn't have correct signature.\n"); + iounmap(RamIO); + pci_disable_device(dev); + continue; + } + + if (request_irq(dev->irq, &ac_interrupt, IRQF_SHARED, "Applicom PCI", &dummy)) { + printk(KERN_INFO "Could not allocate IRQ %d for PCI Applicom device.\n", dev->irq); + iounmap(RamIO); + pci_disable_device(dev); + apbs[boardno - 1].RamIO = NULL; + continue; + } + + /* Enable interrupts. */ + + writeb(0x40, apbs[boardno - 1].RamIO + RAM_IT_FROM_PC); + + apbs[boardno - 1].irq = dev->irq; + } + + /* Finished with PCI cards. If none registered, + * and there was no mem/irq specified, exit */ + if (!mem || !irq) { + if (numboards) { + goto fin; + } else { + printk(KERN_INFO "ac.o: No PCI boards found.\n"); + printk(KERN_INFO "ac.o: For an ISA board you must supply memory and irq parameters.\n"); + return -ENXIO; + } + } + + /* Now try the specified ISA cards */ + + for (i = 0; i < MAX_ISA_BOARD; i++) { + RamIO = ioremap(mem + (LEN_RAM_IO * i), LEN_RAM_IO); + + if (!RamIO) { + printk(KERN_INFO "ac.o: Failed to ioremap the ISA card's memory space (slot #%d)\n", i + 1); + continue; + } + + if (!(boardno = ac_register_board((unsigned long)mem+ (LEN_RAM_IO*i), + RamIO,i+1))) { + iounmap(RamIO); + continue; + } + + printk(KERN_NOTICE "Applicom ISA card found at mem 0x%lx, irq %d\n", mem + (LEN_RAM_IO*i), irq); + + if (!numisa) { + if (request_irq(irq, &ac_interrupt, IRQF_SHARED, "Applicom ISA", &dummy)) { + printk(KERN_WARNING "Could not allocate IRQ %d for ISA Applicom device.\n", irq); + iounmap(RamIO); + apbs[boardno - 1].RamIO = NULL; + } + else + apbs[boardno - 1].irq = irq; + } + else + apbs[boardno - 1].irq = 0; + + numisa++; + } + + if (!numisa) + printk(KERN_WARNING "ac.o: No valid ISA Applicom boards found " + "at mem 0x%lx\n", mem); + + fin: + init_waitqueue_head(&FlagSleepRec); + + WriteErrorCount = 0; + ReadErrorCount = 0; + DeviceErrorCount = 0; + + if (numboards) { + ret = misc_register(&ac_miscdev); + if (ret) { + printk(KERN_WARNING "ac.o: Unable to register misc device\n"); + goto out; + } + for (i = 0; i < MAX_BOARD; i++) { + int serial; + char boardname[(SERIAL_NUMBER - TYPE_CARD) + 1]; + + if (!apbs[i].RamIO) + continue; + + for (serial = 0; serial < SERIAL_NUMBER - TYPE_CARD; serial++) + boardname[serial] = readb(apbs[i].RamIO + TYPE_CARD + serial); + + boardname[serial] = 0; + + + printk(KERN_INFO "Applicom board %d: %s, PROM V%d.%d", + i+1, boardname, + (int)(readb(apbs[i].RamIO + VERS) >> 4), + (int)(readb(apbs[i].RamIO + VERS) & 0xF)); + + serial = (readb(apbs[i].RamIO + SERIAL_NUMBER) << 16) + + (readb(apbs[i].RamIO + SERIAL_NUMBER + 1) << 8) + + (readb(apbs[i].RamIO + SERIAL_NUMBER + 2) ); + + if (serial != 0) + printk(" S/N %d\n", serial); + else + printk("\n"); + } + return 0; + } + + else + return -ENXIO; + +out: + for (i = 0; i < MAX_BOARD; i++) { + if (!apbs[i].RamIO) + continue; + if (apbs[i].irq) + free_irq(apbs[i].irq, &dummy); + iounmap(apbs[i].RamIO); + } + pci_disable_device(dev); + return ret; +} + +module_init(applicom_init); +module_exit(applicom_exit); + + +ssize_t ac_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) +{ + unsigned int NumCard; /* Board number 1 -> 8 */ + unsigned int IndexCard; /* Index board number 0 -> 7 */ + unsigned char TicCard; /* Board TIC to send */ + unsigned long flags; /* Current priority */ + struct st_ram_io st_loc; + struct mailbox tmpmailbox; +#ifdef DEBUG + int c; +#endif + DECLARE_WAITQUEUE(wait, current); + + if (count != sizeof(struct st_ram_io) + sizeof(struct mailbox)) { + static int warncount = 5; + if (warncount) { + printk(KERN_INFO "Hmmm. write() of Applicom card, length %zd != expected %zd\n", + count, sizeof(struct st_ram_io) + sizeof(struct mailbox)); + warncount--; + } + return -EINVAL; + } + + if(copy_from_user(&st_loc, buf, sizeof(struct st_ram_io))) + return -EFAULT; + + if(copy_from_user(&tmpmailbox, &buf[sizeof(struct st_ram_io)], + sizeof(struct mailbox))) + return -EFAULT; + + NumCard = st_loc.num_card; /* board number to send */ + TicCard = st_loc.tic_des_from_pc; /* tic number to send */ + IndexCard = NumCard - 1; + + if((NumCard < 1) || (NumCard > MAX_BOARD) || !apbs[IndexCard].RamIO) + return -EINVAL; + +#ifdef DEBUG + printk("Write to applicom card #%d. struct st_ram_io follows:", + IndexCard+1); + + for (c = 0; c < sizeof(struct st_ram_io);) { + + printk("\n%5.5X: %2.2X", c, ((unsigned char *) &st_loc)[c]); + + for (c++; c % 8 && c < sizeof(struct st_ram_io); c++) { + printk(" %2.2X", ((unsigned char *) &st_loc)[c]); + } + } + + printk("\nstruct mailbox follows:"); + + for (c = 0; c < sizeof(struct mailbox);) { + printk("\n%5.5X: %2.2X", c, ((unsigned char *) &tmpmailbox)[c]); + + for (c++; c % 8 && c < sizeof(struct mailbox); c++) { + printk(" %2.2X", ((unsigned char *) &tmpmailbox)[c]); + } + } + + printk("\n"); +#endif + + spin_lock_irqsave(&apbs[IndexCard].mutex, flags); + + /* Test octet ready correct */ + if(readb(apbs[IndexCard].RamIO + DATA_FROM_PC_READY) > 2) { + Dummy = readb(apbs[IndexCard].RamIO + VERS); + spin_unlock_irqrestore(&apbs[IndexCard].mutex, flags); + printk(KERN_WARNING "APPLICOM driver write error board %d, DataFromPcReady = %d\n", + IndexCard,(int)readb(apbs[IndexCard].RamIO + DATA_FROM_PC_READY)); + DeviceErrorCount++; + return -EIO; + } + + /* Place ourselves on the wait queue */ + set_current_state(TASK_INTERRUPTIBLE); + add_wait_queue(&apbs[IndexCard].FlagSleepSend, &wait); + + /* Check whether the card is ready for us */ + while (readb(apbs[IndexCard].RamIO + DATA_FROM_PC_READY) != 0) { + Dummy = readb(apbs[IndexCard].RamIO + VERS); + /* It's busy. Sleep. */ + + spin_unlock_irqrestore(&apbs[IndexCard].mutex, flags); + schedule(); + if (signal_pending(current)) { + remove_wait_queue(&apbs[IndexCard].FlagSleepSend, + &wait); + return -EINTR; + } + spin_lock_irqsave(&apbs[IndexCard].mutex, flags); + set_current_state(TASK_INTERRUPTIBLE); + } + + /* We may not have actually slept */ + set_current_state(TASK_RUNNING); + remove_wait_queue(&apbs[IndexCard].FlagSleepSend, &wait); + + writeb(1, apbs[IndexCard].RamIO + DATA_FROM_PC_READY); + + /* Which is best - lock down the pages with rawio and then + copy directly, or use bounce buffers? For now we do the latter + because it works with 2.2 still */ + { + unsigned char *from = (unsigned char *) &tmpmailbox; + void __iomem *to = apbs[IndexCard].RamIO + RAM_FROM_PC; + int c; + + for (c = 0; c < sizeof(struct mailbox); c++) + writeb(*(from++), to++); + } + + writeb(0x20, apbs[IndexCard].RamIO + TIC_OWNER_FROM_PC); + writeb(0xff, apbs[IndexCard].RamIO + NUMCARD_OWNER_FROM_PC); + writeb(TicCard, apbs[IndexCard].RamIO + TIC_DES_FROM_PC); + writeb(NumCard, apbs[IndexCard].RamIO + NUMCARD_DES_FROM_PC); + writeb(2, apbs[IndexCard].RamIO + DATA_FROM_PC_READY); + writeb(1, apbs[IndexCard].RamIO + RAM_IT_FROM_PC); + Dummy = readb(apbs[IndexCard].RamIO + VERS); + spin_unlock_irqrestore(&apbs[IndexCard].mutex, flags); + return 0; +} + +int do_ac_read(int IndexCard, char __user *buf, + struct st_ram_io *st_loc, struct mailbox *mailbox) +{ + void __iomem *from = apbs[IndexCard].RamIO + RAM_TO_PC; + unsigned char *to = (unsigned char *)&mailbox; +#ifdef DEBUG + int c; +#endif + + st_loc->tic_owner_to_pc = readb(apbs[IndexCard].RamIO + TIC_OWNER_TO_PC); + st_loc->numcard_owner_to_pc = readb(apbs[IndexCard].RamIO + NUMCARD_OWNER_TO_PC); + + + { + int c; + + for (c = 0; c < sizeof(struct mailbox); c++) + *(to++) = readb(from++); + } + writeb(1, apbs[IndexCard].RamIO + ACK_FROM_PC_READY); + writeb(1, apbs[IndexCard].RamIO + TYP_ACK_FROM_PC); + writeb(IndexCard+1, apbs[IndexCard].RamIO + NUMCARD_ACK_FROM_PC); + writeb(readb(apbs[IndexCard].RamIO + TIC_OWNER_TO_PC), + apbs[IndexCard].RamIO + TIC_ACK_FROM_PC); + writeb(2, apbs[IndexCard].RamIO + ACK_FROM_PC_READY); + writeb(0, apbs[IndexCard].RamIO + DATA_TO_PC_READY); + writeb(2, apbs[IndexCard].RamIO + RAM_IT_FROM_PC); + Dummy = readb(apbs[IndexCard].RamIO + VERS); + +#ifdef DEBUG + printk("Read from applicom card #%d. struct st_ram_io follows:", NumCard); + + for (c = 0; c < sizeof(struct st_ram_io);) { + printk("\n%5.5X: %2.2X", c, ((unsigned char *)st_loc)[c]); + + for (c++; c % 8 && c < sizeof(struct st_ram_io); c++) { + printk(" %2.2X", ((unsigned char *)st_loc)[c]); + } + } + + printk("\nstruct mailbox follows:"); + + for (c = 0; c < sizeof(struct mailbox);) { + printk("\n%5.5X: %2.2X", c, ((unsigned char *)mailbox)[c]); + + for (c++; c % 8 && c < sizeof(struct mailbox); c++) { + printk(" %2.2X", ((unsigned char *)mailbox)[c]); + } + } + printk("\n"); +#endif + return (sizeof(struct st_ram_io) + sizeof(struct mailbox)); +} + +ssize_t ac_read (struct file *filp, char __user *buf, size_t count, loff_t *ptr) +{ + unsigned long flags; + unsigned int i; + unsigned char tmp; + int ret = 0; + DECLARE_WAITQUEUE(wait, current); +#ifdef DEBUG + int loopcount=0; +#endif + /* No need to ratelimit this. Only root can trigger it anyway */ + if (count != sizeof(struct st_ram_io) + sizeof(struct mailbox)) { + printk( KERN_WARNING "Hmmm. read() of Applicom card, length %zd != expected %zd\n", + count,sizeof(struct st_ram_io) + sizeof(struct mailbox)); + return -EINVAL; + } + + while(1) { + /* Stick ourself on the wait queue */ + set_current_state(TASK_INTERRUPTIBLE); + add_wait_queue(&FlagSleepRec, &wait); + + /* Scan each board, looking for one which has a packet for us */ + for (i=0; i < MAX_BOARD; i++) { + if (!apbs[i].RamIO) + continue; + spin_lock_irqsave(&apbs[i].mutex, flags); + + tmp = readb(apbs[i].RamIO + DATA_TO_PC_READY); + + if (tmp == 2) { + struct st_ram_io st_loc; + struct mailbox mailbox; + + /* Got a packet for us */ + ret = do_ac_read(i, buf, &st_loc, &mailbox); + spin_unlock_irqrestore(&apbs[i].mutex, flags); + set_current_state(TASK_RUNNING); + remove_wait_queue(&FlagSleepRec, &wait); + + if (copy_to_user(buf, &st_loc, sizeof(st_loc))) + return -EFAULT; + if (copy_to_user(buf + sizeof(st_loc), &mailbox, sizeof(mailbox))) + return -EFAULT; + return tmp; + } + + if (tmp > 2) { + /* Got an error */ + Dummy = readb(apbs[i].RamIO + VERS); + + spin_unlock_irqrestore(&apbs[i].mutex, flags); + set_current_state(TASK_RUNNING); + remove_wait_queue(&FlagSleepRec, &wait); + + printk(KERN_WARNING "APPLICOM driver read error board %d, DataToPcReady = %d\n", + i,(int)readb(apbs[i].RamIO + DATA_TO_PC_READY)); + DeviceErrorCount++; + return -EIO; + } + + /* Nothing for us. Try the next board */ + Dummy = readb(apbs[i].RamIO + VERS); + spin_unlock_irqrestore(&apbs[i].mutex, flags); + + } /* per board */ + + /* OK - No boards had data for us. Sleep now */ + + schedule(); + remove_wait_queue(&FlagSleepRec, &wait); + + if (signal_pending(current)) + return -EINTR; + +#ifdef DEBUG + if (loopcount++ > 2) { + printk(KERN_DEBUG "Looping in ac_read. loopcount %d\n", loopcount); + } +#endif + } +} + +irqreturn_t ac_interrupt(int vec, void *dev_instance) +{ + unsigned int i; + unsigned int FlagInt; + unsigned int LoopCount; + int handled = 0; + + // printk("Applicom interrupt on IRQ %d occurred\n", vec); + + LoopCount = 0; + + do { + FlagInt = 0; + for (i = 0; i < MAX_BOARD; i++) { + + /* Skip if this board doesn't exist */ + if (!apbs[i].RamIO) + continue; + + spin_lock(&apbs[i].mutex); + + /* Skip if this board doesn't want attention */ + if(readb(apbs[i].RamIO + RAM_IT_TO_PC) == 0) { + spin_unlock(&apbs[i].mutex); + continue; + } + + handled = 1; + FlagInt = 1; + writeb(0, apbs[i].RamIO + RAM_IT_TO_PC); + + if (readb(apbs[i].RamIO + DATA_TO_PC_READY) > 2) { + printk(KERN_WARNING "APPLICOM driver interrupt err board %d, DataToPcReady = %d\n", + i+1,(int)readb(apbs[i].RamIO + DATA_TO_PC_READY)); + DeviceErrorCount++; + } + + if((readb(apbs[i].RamIO + DATA_FROM_PC_READY) > 2) && + (readb(apbs[i].RamIO + DATA_FROM_PC_READY) != 6)) { + + printk(KERN_WARNING "APPLICOM driver interrupt err board %d, DataFromPcReady = %d\n", + i+1,(int)readb(apbs[i].RamIO + DATA_FROM_PC_READY)); + DeviceErrorCount++; + } + + if (readb(apbs[i].RamIO + DATA_TO_PC_READY) == 2) { /* mailbox sent by the card ? */ + if (waitqueue_active(&FlagSleepRec)) { + wake_up_interruptible(&FlagSleepRec); + } + } + + if (readb(apbs[i].RamIO + DATA_FROM_PC_READY) == 0) { /* ram i/o free for write by pc ? */ + if (waitqueue_active(&apbs[i].FlagSleepSend)) { /* process sleep during read ? */ + wake_up_interruptible(&apbs[i].FlagSleepSend); + } + } + Dummy = readb(apbs[i].RamIO + VERS); + + if(readb(apbs[i].RamIO + RAM_IT_TO_PC)) { + /* There's another int waiting on this card */ + spin_unlock(&apbs[i].mutex); + i--; + } else { + spin_unlock(&apbs[i].mutex); + } + } + if (FlagInt) + LoopCount = 0; + else + LoopCount++; + } while(LoopCount < 2); + return IRQ_RETVAL(handled); +} + + + +int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) + +{ /* @ ADG ou ATO selon le cas */ + int i; + unsigned char IndexCard; + void __iomem *pmem; + int ret = 0; + volatile unsigned char byte_reset_it; + struct st_ram_io *adgl; + void __user *argp = (void __user *)arg; + + /* In general, the device is only openable by root anyway, so we're not + particularly concerned that bogus ioctls can flood the console. */ + + adgl = kmalloc(sizeof(struct st_ram_io), GFP_KERNEL); + if (!adgl) + return -ENOMEM; + + if (copy_from_user(adgl, argp, sizeof(struct st_ram_io))) { + kfree(adgl); + return -EFAULT; + } + + IndexCard = adgl->num_card-1; + + if(cmd != 0 && cmd != 6 && + ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { + static int warncount = 10; + if (warncount) { + printk( KERN_WARNING "APPLICOM driver IOCTL, bad board number %d\n",(int)IndexCard+1); + warncount--; + } + kfree(adgl); + return -EINVAL; + } + + switch (cmd) { + + case 0: + pmem = apbs[IndexCard].RamIO; + for (i = 0; i < sizeof(struct st_ram_io); i++) + ((unsigned char *)adgl)[i]=readb(pmem++); + if (copy_to_user(argp, adgl, sizeof(struct st_ram_io))) + ret = -EFAULT; + break; + case 1: + pmem = apbs[IndexCard].RamIO + CONF_END_TEST; + for (i = 0; i < 4; i++) + adgl->conf_end_test[i] = readb(pmem++); + for (i = 0; i < 2; i++) + adgl->error_code[i] = readb(pmem++); + for (i = 0; i < 4; i++) + adgl->parameter_error[i] = readb(pmem++); + pmem = apbs[IndexCard].RamIO + VERS; + adgl->vers = readb(pmem); + pmem = apbs[IndexCard].RamIO + TYPE_CARD; + for (i = 0; i < 20; i++) + adgl->reserv1[i] = readb(pmem++); + *(int *)&adgl->reserv1[20] = + (readb(apbs[IndexCard].RamIO + SERIAL_NUMBER) << 16) + + (readb(apbs[IndexCard].RamIO + SERIAL_NUMBER + 1) << 8) + + (readb(apbs[IndexCard].RamIO + SERIAL_NUMBER + 2) ); + + if (copy_to_user(argp, adgl, sizeof(struct st_ram_io))) + ret = -EFAULT; + break; + case 2: + pmem = apbs[IndexCard].RamIO + CONF_END_TEST; + for (i = 0; i < 10; i++) + writeb(0xff, pmem++); + writeb(adgl->data_from_pc_ready, + apbs[IndexCard].RamIO + DATA_FROM_PC_READY); + + writeb(1, apbs[IndexCard].RamIO + RAM_IT_FROM_PC); + + for (i = 0; i < MAX_BOARD; i++) { + if (apbs[i].RamIO) { + byte_reset_it = readb(apbs[i].RamIO + RAM_IT_TO_PC); + } + } + break; + case 3: + pmem = apbs[IndexCard].RamIO + TIC_DES_FROM_PC; + writeb(adgl->tic_des_from_pc, pmem); + break; + case 4: + pmem = apbs[IndexCard].RamIO + TIC_OWNER_TO_PC; + adgl->tic_owner_to_pc = readb(pmem++); + adgl->numcard_owner_to_pc = readb(pmem); + if (copy_to_user(argp, adgl,sizeof(struct st_ram_io))) + ret = -EFAULT; + break; + case 5: + writeb(adgl->num_card, apbs[IndexCard].RamIO + NUMCARD_OWNER_TO_PC); + writeb(adgl->num_card, apbs[IndexCard].RamIO + NUMCARD_DES_FROM_PC); + writeb(adgl->num_card, apbs[IndexCard].RamIO + NUMCARD_ACK_FROM_PC); + writeb(4, apbs[IndexCard].RamIO + DATA_FROM_PC_READY); + writeb(1, apbs[IndexCard].RamIO + RAM_IT_FROM_PC); + break; + case 6: + printk(KERN_INFO "APPLICOM driver release .... V2.8.0 ($Revision: 1.30 $)\n"); + printk(KERN_INFO "Number of installed boards . %d\n", (int) numboards); + printk(KERN_INFO "Segment of board ........... %X\n", (int) mem); + printk(KERN_INFO "Interrupt IRQ number ....... %d\n", (int) irq); + for (i = 0; i < MAX_BOARD; i++) { + int serial; + char boardname[(SERIAL_NUMBER - TYPE_CARD) + 1]; + + if (!apbs[i].RamIO) + continue; + + for (serial = 0; serial < SERIAL_NUMBER - TYPE_CARD; serial++) + boardname[serial] = readb(apbs[i].RamIO + TYPE_CARD + serial); + boardname[serial] = 0; + + printk(KERN_INFO "Prom version board %d ....... V%d.%d %s", + i+1, + (int)(readb(apbs[IndexCard].RamIO + VERS) >> 4), + (int)(readb(apbs[IndexCard].RamIO + VERS) & 0xF), + boardname); + + + serial = (readb(apbs[i].RamIO + SERIAL_NUMBER) << 16) + + (readb(apbs[i].RamIO + SERIAL_NUMBER + 1) << 8) + + (readb(apbs[i].RamIO + SERIAL_NUMBER + 2) ); + + if (serial != 0) + printk(" S/N %d\n", serial); + else + printk("\n"); + } + if (DeviceErrorCount != 0) + printk(KERN_INFO "DeviceErrorCount ........... %d\n", DeviceErrorCount); + if (ReadErrorCount != 0) + printk(KERN_INFO "ReadErrorCount ............. %d\n", ReadErrorCount); + if (WriteErrorCount != 0) + printk(KERN_INFO "WriteErrorCount ............ %d\n", WriteErrorCount); + if (waitqueue_active(&FlagSleepRec)) + printk(KERN_INFO "Process in read pending\n"); + for (i = 0; i < MAX_BOARD; i++) { + if (apbs[i].RamIO && waitqueue_active(&apbs[i].FlagSleepSend)) + printk(KERN_INFO "Process in write pending board %d\n",i+1); + } + break; + default: + printk(KERN_INFO "APPLICOM driver ioctl, unknown function code %d\n",cmd) ; + ret = -EINVAL; + break; + } + Dummy = readb(apbs[IndexCard].RamIO + VERS); + kfree(adgl); + return 0; +} + diff --git a/ddverify/case_studies/char/applicom/applicom.h b/ddverify/case_studies/char/applicom/applicom.h new file mode 100644 index 000000000..35530b3d9 --- /dev/null +++ b/ddverify/case_studies/char/applicom/applicom.h @@ -0,0 +1,85 @@ +/* $Id: applicom.h,v 1.2 1999/08/28 15:09:49 dwmw2 Exp $ */ + + +#ifndef __LINUX_APPLICOM_H__ +#define __LINUX_APPLICOM_H__ + + +#define DATA_TO_PC_READY 0x00 +#define TIC_OWNER_TO_PC 0x01 +#define NUMCARD_OWNER_TO_PC 0x02 +#define TIC_DES_TO_PC 0x03 +#define NUMCARD_DES_TO_PC 0x04 +#define DATA_FROM_PC_READY 0x05 +#define TIC_OWNER_FROM_PC 0x06 +#define NUMCARD_OWNER_FROM_PC 0x07 +#define TIC_DES_FROM_PC 0x08 +#define NUMCARD_DES_FROM_PC 0x09 +#define ACK_FROM_PC_READY 0x0E +#define TIC_ACK_FROM_PC 0x0F +#define NUMCARD_ACK_FROM_PC 0x010 +#define TYP_ACK_FROM_PC 0x011 +#define CONF_END_TEST 0x012 +#define ERROR_CODE 0x016 +#define PARAMETER_ERROR 0x018 +#define VERS 0x01E +#define RAM_TO_PC 0x040 +#define RAM_FROM_PC 0x0170 +#define TYPE_CARD 0x03C0 +#define SERIAL_NUMBER 0x03DA +#define RAM_IT_FROM_PC 0x03FE +#define RAM_IT_TO_PC 0x03FF + +struct mailbox{ + u16 stjb_codef; /* offset 00 */ + s16 stjb_status; /* offset 02 */ + u16 stjb_ticuser_root; /* offset 04 */ + u8 stjb_piduser[4]; /* offset 06 */ + u16 stjb_mode; /* offset 0A */ + u16 stjb_time; /* offset 0C */ + u16 stjb_stop; /* offset 0E */ + u16 stjb_nfonc; /* offset 10 */ + u16 stjb_ncard; /* offset 12 */ + u16 stjb_nchan; /* offset 14 */ + u16 stjb_nes; /* offset 16 */ + u16 stjb_nb; /* offset 18 */ + u16 stjb_typvar; /* offset 1A */ + u32 stjb_adr; /* offset 1C */ + u16 stjb_ticuser_dispcyc; /* offset 20 */ + u16 stjb_ticuser_protocol; /* offset 22 */ + u8 stjb_filler[12]; /* offset 24 */ + u8 stjb_data[256]; /* offset 30 */ + }; + +struct st_ram_io +{ + unsigned char data_to_pc_ready; + unsigned char tic_owner_to_pc; + unsigned char numcard_owner_to_pc; + unsigned char tic_des_to_pc; + unsigned char numcard_des_to_pc; + unsigned char data_from_pc_ready; + unsigned char tic_owner_from_pc; + unsigned char numcard_owner_from_pc; + unsigned char tic_des_from_pc; + unsigned char numcard_des_from_pc; + unsigned char ack_to_pc_ready; + unsigned char tic_ack_to_pc; + unsigned char numcard_ack_to_pc; + unsigned char typ_ack_to_pc; + unsigned char ack_from_pc_ready; + unsigned char tic_ack_from_pc; + unsigned char numcard_ack_from_pc; + unsigned char typ_ack_from_pc; + unsigned char conf_end_test[4]; + unsigned char error_code[2]; + unsigned char parameter_error[4]; + unsigned char time_base; + unsigned char nul_inc; + unsigned char vers; + unsigned char num_card; + unsigned char reserv1[32]; +}; + + +#endif /* __LINUX_APPLICOM_H__ */ diff --git a/ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.c b/ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.c new file mode 100644 index 000000000..6ba96de4e --- /dev/null +++ b/ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.c @@ -0,0 +1,251 @@ +/* + * AMD CS5535/CS5536 GPIO driver. + * Allows a user space process to play with the GPIO pins. + * + * Copyright (c) 2005 Ben Gardner + * + * This program is free software; you can redistribute it and/or modify + * it under the smems of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define NAME "cs5535_gpio" + +MODULE_AUTHOR("Ben Gardner "); +MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO Pin Driver"); +MODULE_LICENSE("GPL"); + +int major; +module_param(major, int, 0); +MODULE_PARM_DESC(major, "Major device number"); + +ulong mask; +module_param(mask, ulong, 0); +MODULE_PARM_DESC(mask, "GPIO channel mask"); + +#define MSR_LBAR_GPIO 0x5140000C + +u32 gpio_base; + +struct pci_device_id divil_pci[] = { + { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, + { } /* NULL entry */ +}; + +struct cdev cs5535_gpio_cdev; + +/* reserve 32 entries even though some aren't usable */ +#define CS5535_GPIO_COUNT 32 + +/* IO block size */ +#define CS5535_GPIO_SIZE 256 + +struct gpio_regmap { + u32 rd_offset; + u32 wr_offset; + char on; + char off; +}; +struct gpio_regmap rm[] = +{ + { 0x30, 0x00, '1', '0' }, /* GPIOx_READ_BACK / GPIOx_OUT_VAL */ + { 0x20, 0x20, 'I', 'i' }, /* GPIOx_IN_EN */ + { 0x04, 0x04, 'O', 'o' }, /* GPIOx_OUT_EN */ + { 0x08, 0x08, 't', 'T' }, /* GPIOx_OUT_OD_EN */ + { 0x18, 0x18, 'P', 'p' }, /* GPIOx_OUT_PU_EN */ + { 0x1c, 0x1c, 'D', 'd' }, /* GPIOx_OUT_PD_EN */ +}; + + +/** + * Gets the register offset for the GPIO bank. + * Low (0-15) starts at 0x00, high (16-31) starts at 0x80 + */ +inline u32 cs5535_lowhigh_base(int reg) +{ + return (reg & 0x10) << 3; +} + +ssize_t cs5535_gpio_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos) +{ + u32 m = iminor(file->f_dentry->d_inode); + int i, j; + u32 base = gpio_base + cs5535_lowhigh_base(m); + u32 m0, m1; + char c; + + /** + * Creates the mask for atomic bit programming. + * The high 16 bits and the low 16 bits are used to set the mask. + * For example, GPIO 15 maps to 31,15: 0,1 => On; 1,0=> Off + */ + m1 = 1 << (m & 0x0F); + m0 = m1 << 16; + + for (i = 0; i < len; ++i) { + if (get_user(c, data+i)) + return -EFAULT; + + for (j = 0; j < ARRAY_SIZE(rm); j++) { + if (c == rm[j].on) { + outl(m1, base + rm[j].wr_offset); + break; + } else if (c == rm[j].off) { + outl(m0, base + rm[j].wr_offset); + break; + } + } + } + *ppos = 0; + return len; +} + +ssize_t cs5535_gpio_read(struct file *file, char __user *buf, + size_t len, loff_t *ppos) +{ + u32 m = iminor(file->f_dentry->d_inode); + u32 base = gpio_base + cs5535_lowhigh_base(m); + int rd_bit = 1 << (m & 0x0f); + int i; + char ch; + ssize_t count = 0; + + if (*ppos >= ARRAY_SIZE(rm)) + return 0; + + for (i = *ppos; (i < (*ppos + len)) && (i < ARRAY_SIZE(rm)); i++) { + ch = (inl(base + rm[i].rd_offset) & rd_bit) ? + rm[i].on : rm[i].off; + + if (put_user(ch, buf+count)) + return -EFAULT; + + count++; + } + + /* add a line-feed if there is room */ + if ((i == ARRAY_SIZE(rm)) && (count < len)) { + put_user('\n', buf + count); + count++; + } + + *ppos += count; + return count; +} + +int cs5535_gpio_open(struct inode *inode, struct file *file) +{ + u32 m = iminor(inode); + + /* the mask says which pins are usable by this driver */ + if ((mask & (1 << m)) == 0) + return -EINVAL; + + return nonseekable_open(inode, file); +} + +const struct file_operations cs5535_gpio_fops = { + .owner = THIS_MODULE, + .write = cs5535_gpio_write, + .read = cs5535_gpio_read, + .open = cs5535_gpio_open +}; + +int __init cs5535_gpio_init(void) +{ + dev_t dev_id; + u32 low, hi; + int retval; + + if (pci_dev_present(divil_pci) == 0) { + printk(KERN_WARNING NAME ": DIVIL not found\n"); + return -ENODEV; + } + + /* Grab the GPIO I/O range */ + rdmsr(MSR_LBAR_GPIO, low, hi); + + /* Check the mask and whether GPIO is enabled (sanity check) */ + if (hi != 0x0000f001) { + printk(KERN_WARNING NAME ": GPIO not enabled\n"); + return -ENODEV; + } + + /* Mask off the IO base address */ + gpio_base = low & 0x0000ff00; + + /** + * Some GPIO pins + * 31-29,23 : reserved (always mask out) + * 28 : Power Button + * 26 : PME# + * 22-16 : LPC + * 14,15 : SMBus + * 9,8 : UART1 + * 7 : PCI INTB + * 3,4 : UART2/DDC + * 2 : IDE_IRQ0 + * 0 : PCI INTA + * + * If a mask was not specified, be conservative and only allow: + * 1,2,5,6,10-13,24,25,27 + */ + if (mask != 0) + mask &= 0x1f7fffff; + else + mask = 0x0b003c66; + + if (request_region(gpio_base, CS5535_GPIO_SIZE, NAME) == 0) { + printk(KERN_ERR NAME ": can't allocate I/O for GPIO\n"); + return -ENODEV; + } + + if (major) { + dev_id = MKDEV(major, 0); + retval = register_chrdev_region(dev_id, CS5535_GPIO_COUNT, + NAME); + } else { + retval = alloc_chrdev_region(&dev_id, 0, CS5535_GPIO_COUNT, + NAME); + major = MAJOR(dev_id); + } + + if (retval) { + release_region(gpio_base, CS5535_GPIO_SIZE); + return -1; + } + + printk(KERN_DEBUG NAME ": base=%#x mask=%#lx major=%d\n", + gpio_base, mask, major); + + cdev_init(&cs5535_gpio_cdev, &cs5535_gpio_fops); + cdev_add(&cs5535_gpio_cdev, dev_id, CS5535_GPIO_COUNT); + + return 0; +} + +void __exit cs5535_gpio_cleanup(void) +{ + dev_t dev_id = MKDEV(major, 0); + + cdev_del(&cs5535_gpio_cdev); + unregister_chrdev_region(dev_id, CS5535_GPIO_COUNT); + release_region(gpio_base, CS5535_GPIO_SIZE); +} + +module_init(cs5535_gpio_init); +module_exit(cs5535_gpio_cleanup); diff --git a/ddverify/case_studies/char/ds1286/ds1286.c b/ddverify/case_studies/char/ds1286/ds1286.c new file mode 100644 index 000000000..898c0b09c --- /dev/null +++ b/ddverify/case_studies/char/ds1286/ds1286.c @@ -0,0 +1,579 @@ +/* + * DS1286 Real Time Clock interface for Linux + * + * Copyright (C) 1998, 1999, 2000 Ralf Baechle + * + * Based on code written by Paul Gortmaker. + * + * This driver allows use of the real time clock (built into nearly all + * computers) from user space. It exports the /dev/rtc interface supporting + * various ioctl() and also the /proc/rtc pseudo-file for status + * information. + * + * The ioctls can be used to set the interrupt behaviour and generation rate + * from the RTC via IRQ 8. Then the /dev/rtc interface can be used to make + * use of these timer interrupts, be they interval or alarm based. + * + * The /dev/rtc interface will block on reads until an interrupt has been + * received. If a RTC interrupt has already happened, it will output an + * unsigned long and then block. The output value contains the interrupt + * status in the low byte and the number of interrupts since the last read + * in the remaining high bytes. The /dev/rtc interface can also be used with + * the select(2) call. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#include "ds1286.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define DS1286_VERSION "1.0" + +/* + * We sponge a minor off of the misc major. No need slurping + * up another valuable major dev number for this. If you add + * an ioctl, make sure you don't conflict with SPARC's RTC + * ioctls. + */ + +DECLARE_WAIT_QUEUE_HEAD(ds1286_wait); + +ssize_t ds1286_read(struct file *file, char *buf, + size_t count, loff_t *ppos); + +int ds1286_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg); + +unsigned int ds1286_poll(struct file *file, poll_table *wait); + +void ds1286_get_alm_time (struct rtc_time *alm_tm); +void ds1286_get_time(struct rtc_time *rtc_tm); +int ds1286_set_time(struct rtc_time *rtc_tm); + +inline unsigned char ds1286_is_updating(void); + +DEFINE_SPINLOCK(ds1286_lock); + +int ds1286_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data); + +/* + * Bits in rtc_status. (7 bits of room for future expansion) + */ + +#define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ +#define RTC_TIMER_ON 0x02 /* missed irq timer active */ + +unsigned char ds1286_status; /* bitmapped status byte. */ + +unsigned char days_in_mo[] = { + 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 +}; + +/* + * Now all the various file operations that we export. + */ + +ssize_t ds1286_read(struct file *file, char *buf, + size_t count, loff_t *ppos) +{ + return -EIO; +} + +int ds1286_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + struct rtc_time wtime; + + switch (cmd) { + case RTC_AIE_OFF: /* Mask alarm int. enab. bit */ + { + unsigned long flags; + unsigned char val; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + spin_lock_irqsave(&ds1286_lock, flags); + val = rtc_read(RTC_CMD); + val |= RTC_TDM; + rtc_write(val, RTC_CMD); + spin_unlock_irqrestore(&ds1286_lock, flags); + + return 0; + } + case RTC_AIE_ON: /* Allow alarm interrupts. */ + { + unsigned long flags; + unsigned char val; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + spin_lock_irqsave(&ds1286_lock, flags); + val = rtc_read(RTC_CMD); + val &= ~RTC_TDM; + rtc_write(val, RTC_CMD); + spin_unlock_irqrestore(&ds1286_lock, flags); + + return 0; + } + case RTC_WIE_OFF: /* Mask watchdog int. enab. bit */ + { + unsigned long flags; + unsigned char val; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + spin_lock_irqsave(&ds1286_lock, flags); + val = rtc_read(RTC_CMD); + val |= RTC_WAM; + rtc_write(val, RTC_CMD); + spin_unlock_irqrestore(&ds1286_lock, flags); + + return 0; + } + case RTC_WIE_ON: /* Allow watchdog interrupts. */ + { + unsigned long flags; + unsigned char val; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + spin_lock_irqsave(&ds1286_lock, flags); + val = rtc_read(RTC_CMD); + val &= ~RTC_WAM; + rtc_write(val, RTC_CMD); + spin_unlock_irqrestore(&ds1286_lock, flags); + + return 0; + } + case RTC_ALM_READ: /* Read the present alarm time */ + { + /* + * This returns a struct rtc_time. Reading >= 0xc0 + * means "don't care" or "match all". Only the tm_hour, + * tm_min, and tm_sec values are filled in. + */ + + memset(&wtime, 0, sizeof(wtime)); + ds1286_get_alm_time(&wtime); + break; + } + case RTC_ALM_SET: /* Store a time into the alarm */ + { + /* + * This expects a struct rtc_time. Writing 0xff means + * "don't care" or "match all". Only the tm_hour, + * tm_min and tm_sec are used. + */ + unsigned char hrs, min, sec; + struct rtc_time alm_tm; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + if (copy_from_user(&alm_tm, (struct rtc_time*)arg, + sizeof(struct rtc_time))) + return -EFAULT; + + hrs = alm_tm.tm_hour; + min = alm_tm.tm_min; + + if (hrs >= 24) + hrs = 0xff; + + if (min >= 60) + min = 0xff; + + BIN_TO_BCD(sec); + BIN_TO_BCD(min); + BIN_TO_BCD(hrs); + + spin_lock(&ds1286_lock); + rtc_write(hrs, RTC_HOURS_ALARM); + rtc_write(min, RTC_MINUTES_ALARM); + spin_unlock(&ds1286_lock); + + return 0; + } + case RTC_RD_TIME: /* Read the time/date from RTC */ + { + memset(&wtime, 0, sizeof(wtime)); + ds1286_get_time(&wtime); + break; + } + case RTC_SET_TIME: /* Set the RTC */ + { + struct rtc_time rtc_tm; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, + sizeof(struct rtc_time))) + return -EFAULT; + + return ds1286_set_time(&rtc_tm); + } + default: + return -EINVAL; + } + return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0; +} + +/* + * We enforce only one user at a time here with the open/close. + * Also clear the previous interrupt data on an open, and clean + * up things on a close. + */ + +int ds1286_open(struct inode *inode, struct file *file) +{ + spin_lock_irq(&ds1286_lock); + + if (ds1286_status & RTC_IS_OPEN) + goto out_busy; + + ds1286_status |= RTC_IS_OPEN; + + spin_unlock_irq(&ds1286_lock); + return 0; + +out_busy: + spin_lock_irq(&ds1286_lock); + return -EBUSY; +} + +int ds1286_release(struct inode *inode, struct file *file) +{ + ds1286_status &= ~RTC_IS_OPEN; + + return 0; +} + +unsigned int ds1286_poll(struct file *file, poll_table *wait) +{ + poll_wait(file, &ds1286_wait, wait); + + return 0; +} + +/* + * The various file operations we support. + */ + +const struct file_operations ds1286_fops = { + .llseek = no_llseek, + .read = ds1286_read, + .poll = ds1286_poll, + .ioctl = ds1286_ioctl, + .open = ds1286_open, + .release = ds1286_release, +}; + +struct miscdevice ds1286_dev= +{ + .minor = RTC_MINOR, + .name = "rtc", + .fops = &ds1286_fops, +}; + +int __init ds1286_init(void) +{ + int err; + + printk(KERN_INFO "DS1286 Real Time Clock Driver v%s\n", DS1286_VERSION); + + err = misc_register(&ds1286_dev); + if (err) + goto out; + + if (!create_proc_read_entry("driver/rtc", 0, 0, ds1286_read_proc, NULL)) { + err = -ENOMEM; + + goto out_deregister; + } + + return 0; + +out_deregister: + misc_deregister(&ds1286_dev); + +out: + return err; +} + +void __exit ds1286_exit(void) +{ + remove_proc_entry("driver/rtc", NULL); + misc_deregister(&ds1286_dev); +} + +char *days[] = { + "***", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; + +/* + * Info exported via "/proc/rtc". + */ +int ds1286_proc_output(char *buf) +{ + char *p, *s; + struct rtc_time tm; + unsigned char hundredth, month, cmd, amode; + + p = buf; + + ds1286_get_time(&tm); + hundredth = rtc_read(RTC_HUNDREDTH_SECOND); + BCD_TO_BIN(hundredth); + + p += sprintf(p, + "rtc_time\t: %02d:%02d:%02d.%02d\n" + "rtc_date\t: %04d-%02d-%02d\n", + tm.tm_hour, tm.tm_min, tm.tm_sec, hundredth, + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); + + /* + * We implicitly assume 24hr mode here. Alarm values >= 0xc0 will + * match any value for that particular field. Values that are + * greater than a valid time, but less than 0xc0 shouldn't appear. + */ + ds1286_get_alm_time(&tm); + p += sprintf(p, "alarm\t\t: %s ", days[tm.tm_wday]); + if (tm.tm_hour <= 24) + p += sprintf(p, "%02d:", tm.tm_hour); + else + p += sprintf(p, "**:"); + + if (tm.tm_min <= 59) + p += sprintf(p, "%02d\n", tm.tm_min); + else + p += sprintf(p, "**\n"); + + month = rtc_read(RTC_MONTH); + p += sprintf(p, + "oscillator\t: %s\n" + "square_wave\t: %s\n", + (month & RTC_EOSC) ? "disabled" : "enabled", + (month & RTC_ESQW) ? "disabled" : "enabled"); + + amode = ((rtc_read(RTC_MINUTES_ALARM) & 0x80) >> 5) | + ((rtc_read(RTC_HOURS_ALARM) & 0x80) >> 6) | + ((rtc_read(RTC_DAY_ALARM) & 0x80) >> 7); + if (amode == 7) s = "each minute"; + else if (amode == 3) s = "minutes match"; + else if (amode == 1) s = "hours and minutes match"; + else if (amode == 0) s = "days, hours and minutes match"; + else s = "invalid"; + p += sprintf(p, "alarm_mode\t: %s\n", s); + + cmd = rtc_read(RTC_CMD); + p += sprintf(p, + "alarm_enable\t: %s\n" + "wdog_alarm\t: %s\n" + "alarm_mask\t: %s\n" + "wdog_alarm_mask\t: %s\n" + "interrupt_mode\t: %s\n" + "INTB_mode\t: %s_active\n" + "interrupt_pins\t: %s\n", + (cmd & RTC_TDF) ? "yes" : "no", + (cmd & RTC_WAF) ? "yes" : "no", + (cmd & RTC_TDM) ? "disabled" : "enabled", + (cmd & RTC_WAM) ? "disabled" : "enabled", + (cmd & RTC_PU_LVL) ? "pulse" : "level", + (cmd & RTC_IBH_LO) ? "low" : "high", + (cmd & RTC_IPSW) ? "unswapped" : "swapped"); + + return p - buf; +} + +int ds1286_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = ds1286_proc_output (page); + if (len <= off+count) *eof = 1; + *start = page + off; + len -= off; + if (len>count) + len = count; + if (len<0) + len = 0; + + return len; +} + +/* + * Returns true if a clock update is in progress + */ +inline unsigned char ds1286_is_updating(void) +{ + return rtc_read(RTC_CMD) & RTC_TE; +} + + +void ds1286_get_time(struct rtc_time *rtc_tm) +{ + unsigned char save_control; + unsigned long flags; + unsigned long uip_watchdog = jiffies; + + /* + * read RTC once any update in progress is done. The update + * can take just over 2ms. We wait 10 to 20ms. There is no need to + * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP. + * If you need to know *exactly* when a second has started, enable + * periodic update complete interrupts, (via ioctl) and then + * immediately read /dev/rtc which will block until you get the IRQ. + * Once the read clears, read the RTC time (again via ioctl). Easy. + */ + + if (ds1286_is_updating() != 0) + while (jiffies - uip_watchdog < 2*HZ/100) + barrier(); + + /* + * Only the values that we read from the RTC are set. We leave + * tm_wday, tm_yday and tm_isdst untouched. Even though the + * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated + * by the RTC when initially set to a non-zero value. + */ + spin_lock_irqsave(&ds1286_lock, flags); + save_control = rtc_read(RTC_CMD); + rtc_write((save_control|RTC_TE), RTC_CMD); + + rtc_tm->tm_sec = rtc_read(RTC_SECONDS); + rtc_tm->tm_min = rtc_read(RTC_MINUTES); + rtc_tm->tm_hour = rtc_read(RTC_HOURS) & 0x3f; + rtc_tm->tm_mday = rtc_read(RTC_DATE); + rtc_tm->tm_mon = rtc_read(RTC_MONTH) & 0x1f; + rtc_tm->tm_year = rtc_read(RTC_YEAR); + + rtc_write(save_control, RTC_CMD); + spin_unlock_irqrestore(&ds1286_lock, flags); + + BCD_TO_BIN(rtc_tm->tm_sec); + BCD_TO_BIN(rtc_tm->tm_min); + BCD_TO_BIN(rtc_tm->tm_hour); + BCD_TO_BIN(rtc_tm->tm_mday); + BCD_TO_BIN(rtc_tm->tm_mon); + BCD_TO_BIN(rtc_tm->tm_year); + + /* + * Account for differences between how the RTC uses the values + * and how they are defined in a struct rtc_time; + */ + if (rtc_tm->tm_year < 45) + rtc_tm->tm_year += 30; + if ((rtc_tm->tm_year += 40) < 70) + rtc_tm->tm_year += 100; + + rtc_tm->tm_mon--; +} + +int ds1286_set_time(struct rtc_time *rtc_tm) +{ + unsigned char mon, day, hrs, min, sec, leap_yr; + unsigned char save_control; + unsigned int yrs; + unsigned long flags; + + + yrs = rtc_tm->tm_year + 1900; + mon = rtc_tm->tm_mon + 1; /* tm_mon starts at zero */ + day = rtc_tm->tm_mday; + hrs = rtc_tm->tm_hour; + min = rtc_tm->tm_min; + sec = rtc_tm->tm_sec; + + if (yrs < 1970) + return -EINVAL; + + leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400)); + + if ((mon > 12) || (day == 0)) + return -EINVAL; + + if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr))) + return -EINVAL; + + if ((hrs >= 24) || (min >= 60) || (sec >= 60)) + return -EINVAL; + + if ((yrs -= 1940) > 255) /* They are unsigned */ + return -EINVAL; + + if (yrs >= 100) + yrs -= 100; + + BIN_TO_BCD(sec); + BIN_TO_BCD(min); + BIN_TO_BCD(hrs); + BIN_TO_BCD(day); + BIN_TO_BCD(mon); + BIN_TO_BCD(yrs); + + spin_lock_irqsave(&ds1286_lock, flags); + save_control = rtc_read(RTC_CMD); + rtc_write((save_control|RTC_TE), RTC_CMD); + + rtc_write(yrs, RTC_YEAR); + rtc_write(mon, RTC_MONTH); + rtc_write(day, RTC_DATE); + rtc_write(hrs, RTC_HOURS); + rtc_write(min, RTC_MINUTES); + rtc_write(sec, RTC_SECONDS); + rtc_write(0, RTC_HUNDREDTH_SECOND); + + rtc_write(save_control, RTC_CMD); + spin_unlock_irqrestore(&ds1286_lock, flags); + + return 0; +} + +void ds1286_get_alm_time(struct rtc_time *alm_tm) +{ + unsigned char cmd; + unsigned long flags; + + /* + * Only the values that we read from the RTC are set. That + * means only tm_wday, tm_hour, tm_min. + */ + spin_lock_irqsave(&ds1286_lock, flags); + alm_tm->tm_min = rtc_read(RTC_MINUTES_ALARM) & 0x7f; + alm_tm->tm_hour = rtc_read(RTC_HOURS_ALARM) & 0x1f; + alm_tm->tm_wday = rtc_read(RTC_DAY_ALARM) & 0x07; + cmd = rtc_read(RTC_CMD); + spin_unlock_irqrestore(&ds1286_lock, flags); + + BCD_TO_BIN(alm_tm->tm_min); + BCD_TO_BIN(alm_tm->tm_hour); + alm_tm->tm_sec = 0; +} + +module_init(ds1286_init); +module_exit(ds1286_exit); + +MODULE_AUTHOR("Ralf Baechle"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(RTC_MINOR); diff --git a/ddverify/case_studies/char/ds1286/ds1286.h b/ddverify/case_studies/char/ds1286/ds1286.h new file mode 100644 index 000000000..c1a4119ec --- /dev/null +++ b/ddverify/case_studies/char/ds1286/ds1286.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 1998, 1999, 2003 Ralf Baechle + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ +#ifndef __LINUX_DS1286_H +#define __LINUX_DS1286_H + +//#include "asm_ds1286.h" + +/********************************************************************** + * register summary + **********************************************************************/ +#define RTC_HUNDREDTH_SECOND 0 +#define RTC_SECONDS 1 +#define RTC_MINUTES 2 +#define RTC_MINUTES_ALARM 3 +#define RTC_HOURS 4 +#define RTC_HOURS_ALARM 5 +#define RTC_DAY 6 +#define RTC_DAY_ALARM 7 +#define RTC_DATE 8 +#define RTC_MONTH 9 +#define RTC_YEAR 10 +#define RTC_CMD 11 +#define RTC_WHSEC 12 +#define RTC_WSEC 13 +#define RTC_UNUSED 14 + +/* RTC_*_alarm is always true if 2 MSBs are set */ +# define RTC_ALARM_DONT_CARE 0xC0 + + +/* + * Bits in the month register + */ +#define RTC_EOSC 0x80 +#define RTC_ESQW 0x40 + +/* + * Bits in the Command register + */ +#define RTC_TDF 0x01 +#define RTC_WAF 0x02 +#define RTC_TDM 0x04 +#define RTC_WAM 0x08 +#define RTC_PU_LVL 0x10 +#define RTC_IBH_LO 0x20 +#define RTC_IPSW 0x40 +#define RTC_TE 0x80 + +#endif /* __LINUX_DS1286_H */ diff --git a/ddverify/case_studies/char/dtlk/dtlk.c b/ddverify/case_studies/char/dtlk/dtlk.c new file mode 100644 index 000000000..36ba38e99 --- /dev/null +++ b/ddverify/case_studies/char/dtlk/dtlk.c @@ -0,0 +1,654 @@ +/* -*- linux-c -*- + * dtlk.c - DoubleTalk PC driver for Linux + * + * Original author: Chris Pallotta + * Current maintainer: Jim Van Zandt + * + * 2000-03-18 Jim Van Zandt: Fix polling. + * Eliminate dtlk_timer_active flag and separate dtlk_stop_timer + * function. Don't restart timer in dtlk_timer_tick. Restart timer + * in dtlk_poll after every poll. dtlk_poll returns mask (duh). + * Eliminate unused function dtlk_write_byte. Misc. code cleanups. + */ + +/* This driver is for the DoubleTalk PC, a speech synthesizer + manufactured by RC Systems (http://www.rcsys.com/). It was written + based on documentation in their User's Manual file and Developer's + Tools disk. + + The DoubleTalk PC contains four voice synthesizers: text-to-speech + (TTS), linear predictive coding (LPC), PCM/ADPCM, and CVSD. It + also has a tone generator. Output data for LPC are written to the + LPC port, and output data for the other modes are written to the + TTS port. + + Two kinds of data can be read from the DoubleTalk: status + information (in response to the "\001?" interrogation command) is + read from the TTS port, and index markers (which mark the progress + of the speech) are read from the LPC port. Not all models of the + DoubleTalk PC implement index markers. Both the TTS and LPC ports + can also display status flags. + + The DoubleTalk PC generates no interrupts. + + These characteristics are mapped into the Unix stream I/O model as + follows: + + "write" sends bytes to the TTS port. It is the responsibility of + the user program to switch modes among TTS, PCM/ADPCM, and CVSD. + This driver was written for use with the text-to-speech + synthesizer. If LPC output is needed some day, other minor device + numbers can be used to select among output modes. + + "read" gets index markers from the LPC port. If the device does + not implement index markers, the read will fail with error EINVAL. + + Status information is available using the DTLK_INTERROGATE ioctl. + + */ + +#include + +#define KERNEL +#include +#include +#include +#include /* for -EBUSY */ +#include /* for request_region */ +#include /* for loops_per_jiffy */ +#include /* for inb_p, outb_p, inb, outb, etc. */ +#include /* for get_user, etc. */ +#include /* for wait_queue */ +#include /* for __init, module_{init,exit} */ +#include /* for POLLIN, etc. */ +#include "dtlk.h" /* local header file for DoubleTalk values */ +#include + +#ifdef TRACING +#define TRACE_TEXT(str) printk(str); +#define TRACE_RET printk(")") +#else /* !TRACING */ +#define TRACE_TEXT(str) ((void) 0) +#define TRACE_RET ((void) 0) +#endif /* TRACING */ + + +int dtlk_major; +int dtlk_port_lpc; +int dtlk_port_tts; +int dtlk_busy; +int dtlk_has_indexing; +unsigned int dtlk_portlist[] = +{0x25e, 0x29e, 0x2de, 0x31e, 0x35e, 0x39e, 0}; +wait_queue_head_t dtlk_process_list; +struct timer_list dtlk_timer; + +/* prototypes for file_operations struct */ +ssize_t dtlk_read(struct file *, char __user *, + size_t nbytes, loff_t * ppos); +ssize_t dtlk_write(struct file *, const char __user *, + size_t nbytes, loff_t * ppos); +unsigned int dtlk_poll(struct file *, poll_table *); +int dtlk_open(struct inode *, struct file *); +int dtlk_release(struct inode *, struct file *); +int dtlk_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg); + +const struct file_operations dtlk_fops = +{ + .owner = THIS_MODULE, + .read = dtlk_read, + .write = dtlk_write, + .poll = dtlk_poll, + .ioctl = dtlk_ioctl, + .open = dtlk_open, + .release = dtlk_release, +}; + +/* local prototypes */ +int dtlk_dev_probe(void); +struct dtlk_settings *dtlk_interrogate(void); +int dtlk_readable(void); +char dtlk_read_lpc(void); +char dtlk_read_tts(void); +int dtlk_writeable(void); +char dtlk_write_bytes(const char *buf, int n); +char dtlk_write_tts(char); +/* + static void dtlk_handle_error(char, char, unsigned int); + */ +void dtlk_timer_tick(unsigned long data); + +ssize_t dtlk_read(struct file *file, char __user *buf, + size_t count, loff_t * ppos) +{ + unsigned int minor = iminor(file->f_dentry->d_inode); + char ch; + int i = 0, retries; + + TRACE_TEXT("(dtlk_read"); + /* printk("DoubleTalk PC - dtlk_read()\n"); */ + + if (minor != DTLK_MINOR || !dtlk_has_indexing) + return -EINVAL; + + for (retries = 0; retries < loops_per_jiffy; retries++) { + while (i < count && dtlk_readable()) { + ch = dtlk_read_lpc(); + /* printk("dtlk_read() reads 0x%02x\n", ch); */ + if (put_user(ch, buf++)) + return -EFAULT; + i++; + } + if (i) + return i; + if (file->f_flags & O_NONBLOCK) + break; + msleep_interruptible(100); + } + if (retries == loops_per_jiffy) + printk(KERN_ERR "dtlk_read times out\n"); + TRACE_RET; + return -EAGAIN; +} + +ssize_t dtlk_write(struct file *file, const char __user *buf, + size_t count, loff_t * ppos) +{ + int i = 0, retries = 0, ch; + + TRACE_TEXT("(dtlk_write"); +#ifdef TRACING + printk(" \""); + { + int i, ch; + for (i = 0; i < count; i++) { + if (get_user(ch, buf + i)) + return -EFAULT; + if (' ' <= ch && ch <= '~') + printk("%c", ch); + else + printk("\\%03o", ch); + } + printk("\""); + } +#endif + + if (iminor(file->f_dentry->d_inode) != DTLK_MINOR) + return -EINVAL; + + while (1) { + while (i < count && !get_user(ch, buf) && + (ch == DTLK_CLEAR || dtlk_writeable())) { + dtlk_write_tts(ch); + buf++; + i++; + if (i % 5 == 0) + /* We yield our time until scheduled + again. This reduces the transfer + rate to 500 bytes/sec, but that's + still enough to keep up with the + speech synthesizer. */ + msleep_interruptible(1); + else { + /* the RDY bit goes zero 2-3 usec + after writing, and goes 1 again + 180-190 usec later. Here, we wait + up to 250 usec for the RDY bit to + go nonzero. */ + for (retries = 0; + retries < loops_per_jiffy / (4000/HZ); + retries++) + if (inb_p(dtlk_port_tts) & + TTS_WRITABLE) + break; + } + retries = 0; + } + if (i == count) + return i; + if (file->f_flags & O_NONBLOCK) + break; + + msleep_interruptible(1); + + if (++retries > 10 * HZ) { /* wait no more than 10 sec + from last write */ + printk("dtlk: write timeout. " + "inb_p(dtlk_port_tts) = 0x%02x\n", + inb_p(dtlk_port_tts)); + TRACE_RET; + return -EBUSY; + } + } + TRACE_RET; + return -EAGAIN; +} + +unsigned int dtlk_poll(struct file *file, poll_table * wait) +{ + int mask = 0; + unsigned long expires; + + TRACE_TEXT(" dtlk_poll"); + /* + static long int j; + printk("."); + printk("<%ld>", jiffies-j); + j=jiffies; + */ + poll_wait(file, &dtlk_process_list, wait); + + if (dtlk_has_indexing && dtlk_readable()) { + del_timer(&dtlk_timer); + mask = POLLIN | POLLRDNORM; + } + if (dtlk_writeable()) { + del_timer(&dtlk_timer); + mask |= POLLOUT | POLLWRNORM; + } + /* there are no exception conditions */ + + /* There won't be any interrupts, so we set a timer instead. */ + expires = jiffies + 3*HZ / 100; + mod_timer(&dtlk_timer, expires); + + return mask; +} + +void dtlk_timer_tick(unsigned long data) +{ + TRACE_TEXT(" dtlk_timer_tick"); + wake_up_interruptible(&dtlk_process_list); +} + +int dtlk_ioctl(struct inode *inode, + struct file *file, + unsigned int cmd, + unsigned long arg) +{ + char __user *argp = (char __user *)arg; + struct dtlk_settings *sp; + char portval; + TRACE_TEXT(" dtlk_ioctl"); + + switch (cmd) { + + case DTLK_INTERROGATE: + sp = dtlk_interrogate(); + if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) + return -EINVAL; + return 0; + + case DTLK_STATUS: + portval = inb_p(dtlk_port_tts); + return put_user(portval, argp); + + default: + return -EINVAL; + } +} + +int dtlk_open(struct inode *inode, struct file *file) +{ + TRACE_TEXT("(dtlk_open"); + + nonseekable_open(inode, file); + switch (iminor(inode)) { + case DTLK_MINOR: + if (dtlk_busy) + return -EBUSY; + return nonseekable_open(inode, file); + + default: + return -ENXIO; + } +} + +int dtlk_release(struct inode *inode, struct file *file) +{ + TRACE_TEXT("(dtlk_release"); + + switch (iminor(inode)) { + case DTLK_MINOR: + break; + + default: + break; + } + TRACE_RET; + + del_timer(&dtlk_timer); + + return 0; +} + +int __init dtlk_init(void) +{ + dtlk_port_lpc = 0; + dtlk_port_tts = 0; + dtlk_busy = 0; + dtlk_major = register_chrdev(0, "dtlk", &dtlk_fops); + if (dtlk_major == 0) { + printk(KERN_ERR "DoubleTalk PC - cannot register device\n"); + return 0; + } + if (dtlk_dev_probe() == 0) + printk(", MAJOR %d\n", dtlk_major); + + init_timer(&dtlk_timer); + dtlk_timer.function = dtlk_timer_tick; + init_waitqueue_head(&dtlk_process_list); + + return 0; +} + +void __exit dtlk_cleanup (void) +{ + dtlk_write_bytes("goodbye", 8); + msleep_interruptible(500); /* nap 0.50 sec but + could be awakened + earlier by + signals... */ + + dtlk_write_tts(DTLK_CLEAR); + unregister_chrdev(dtlk_major, "dtlk"); + release_region(dtlk_port_lpc, DTLK_IO_EXTENT); +} + +module_init(dtlk_init); +module_exit(dtlk_cleanup); + +/* ------------------------------------------------------------------------ */ + +int dtlk_readable(void) +{ +#ifdef TRACING + printk(" dtlk_readable=%u@%u", inb_p(dtlk_port_lpc) != 0x7f, jiffies); +#endif + return inb_p(dtlk_port_lpc) != 0x7f; +} + +int dtlk_writeable(void) +{ + /* TRACE_TEXT(" dtlk_writeable"); */ +#ifdef TRACINGMORE + printk(" dtlk_writeable=%u", (inb_p(dtlk_port_tts) & TTS_WRITABLE)!=0); +#endif + return inb_p(dtlk_port_tts) & TTS_WRITABLE; +} + +int __init dtlk_dev_probe(void) +{ + unsigned int testval = 0; + int i = 0; + struct dtlk_settings *sp; + + if (dtlk_port_lpc | dtlk_port_tts) + return -EBUSY; + + for (i = 0; dtlk_portlist[i]; i++) { +#if 0 + printk("DoubleTalk PC - Port %03x = %04x\n", + dtlk_portlist[i], (testval = inw_p(dtlk_portlist[i]))); +#endif + + if (!request_region(dtlk_portlist[i], DTLK_IO_EXTENT, + "dtlk")) + continue; + testval = inw_p(dtlk_portlist[i]); + if ((testval &= 0xfbff) == 0x107f) { + dtlk_port_lpc = dtlk_portlist[i]; + dtlk_port_tts = dtlk_port_lpc + 1; + + sp = dtlk_interrogate(); + printk("DoubleTalk PC at %03x-%03x, " + "ROM version %s, serial number %u", + dtlk_portlist[i], dtlk_portlist[i] + + DTLK_IO_EXTENT - 1, + sp->rom_version, sp->serial_number); + + /* put LPC port into known state, so + dtlk_readable() gives valid result */ + outb_p(0xff, dtlk_port_lpc); + + /* INIT string and index marker */ + dtlk_write_bytes("\036\1@\0\0012I\r", 8); + /* posting an index takes 18 msec. Here, we + wait up to 100 msec to see whether it + appears. */ + msleep_interruptible(100); + dtlk_has_indexing = dtlk_readable(); +#ifdef TRACING + printk(", indexing %d\n", dtlk_has_indexing); +#endif +#ifdef INSCOPE + { +/* This macro records ten samples read from the LPC port, for later display */ +#define LOOK \ +for (i = 0; i < 10; i++) \ + { \ + buffer[b++] = inb_p(dtlk_port_lpc); \ + __delay(loops_per_jiffy/(1000000/HZ)); \ + } + char buffer[1000]; + int b = 0, i, j; + + LOOK + outb_p(0xff, dtlk_port_lpc); + buffer[b++] = 0; + LOOK + dtlk_write_bytes("\0012I\r", 4); + buffer[b++] = 0; + __delay(50 * loops_per_jiffy / (1000/HZ)); + outb_p(0xff, dtlk_port_lpc); + buffer[b++] = 0; + LOOK + + printk("\n"); + for (j = 0; j < b; j++) + printk(" %02x", buffer[j]); + printk("\n"); + } +#endif /* INSCOPE */ + +#ifdef OUTSCOPE + { +/* This macro records ten samples read from the TTS port, for later display */ +#define LOOK \ +for (i = 0; i < 10; i++) \ + { \ + buffer[b++] = inb_p(dtlk_port_tts); \ + __delay(loops_per_jiffy/(1000000/HZ)); /* 1 us */ \ + } + char buffer[1000]; + int b = 0, i, j; + + mdelay(10); /* 10 ms */ + LOOK + outb_p(0x03, dtlk_port_tts); + buffer[b++] = 0; + LOOK + LOOK + + printk("\n"); + for (j = 0; j < b; j++) + printk(" %02x", buffer[j]); + printk("\n"); + } +#endif /* OUTSCOPE */ + + dtlk_write_bytes("Double Talk found", 18); + + return 0; + } + release_region(dtlk_portlist[i], DTLK_IO_EXTENT); + } + + printk(KERN_INFO "DoubleTalk PC - not found\n"); + return -ENODEV; +} + +/* + static void dtlk_handle_error(char op, char rc, unsigned int minor) + { + printk(KERN_INFO"\nDoubleTalk PC - MINOR: %d, OPCODE: %d, ERROR: %d\n", + minor, op, rc); + return; + } + */ + +/* interrogate the DoubleTalk PC and return its settings */ +struct dtlk_settings *dtlk_interrogate(void) +{ + unsigned char *t; + static char buf[sizeof(struct dtlk_settings) + 1]; + int total, i; + static struct dtlk_settings status; + TRACE_TEXT("(dtlk_interrogate"); + dtlk_write_bytes("\030\001?", 3); + for (total = 0, i = 0; i < 50; i++) { + buf[total] = dtlk_read_tts(); + if (total > 2 && buf[total] == 0x7f) + break; + if (total < sizeof(struct dtlk_settings)) + total++; + } + /* + if (i==50) printk("interrogate() read overrun\n"); + for (i=0; i 0); + if (retries == 0) + printk(KERN_ERR "dtlk_read_lpc() timeout\n"); + + TRACE_RET; + return ch; +} + +/* write n bytes to tts port */ +char dtlk_write_bytes(const char *buf, int n) +{ + char val = 0; + /* printk("dtlk_write_bytes(\"%-*s\", %d)\n", n, buf, n); */ + TRACE_TEXT("(dtlk_write_bytes"); + while (n-- > 0) + val = dtlk_write_tts(*buf++); + TRACE_RET; + return val; +} + +char dtlk_write_tts(char ch) +{ + int retries = 0; +#ifdef TRACINGMORE + printk(" dtlk_write_tts("); + if (' ' <= ch && ch <= '~') + printk("'%c'", ch); + else + printk("0x%02x", ch); +#endif + if (ch != DTLK_CLEAR) /* no flow control for CLEAR command */ + while ((inb_p(dtlk_port_tts) & TTS_WRITABLE) == 0 && + retries++ < DTLK_MAX_RETRIES) /* DT ready? */ + ; + if (retries == DTLK_MAX_RETRIES) + printk(KERN_ERR "dtlk_write_tts() timeout\n"); + + outb_p(ch, dtlk_port_tts); /* output to TTS port */ + /* the RDY bit goes zero 2-3 usec after writing, and goes + 1 again 180-190 usec later. Here, we wait up to 10 + usec for the RDY bit to go zero. */ + for (retries = 0; retries < loops_per_jiffy / (100000/HZ); retries++) + if ((inb_p(dtlk_port_tts) & TTS_WRITABLE) == 0) + break; + +#ifdef TRACINGMORE + printk(")\n"); +#endif + return 0; +} + +MODULE_LICENSE("GPL"); diff --git a/ddverify/case_studies/char/dtlk/dtlk.h b/ddverify/case_studies/char/dtlk/dtlk.h new file mode 100644 index 000000000..2896d9011 --- /dev/null +++ b/ddverify/case_studies/char/dtlk/dtlk.h @@ -0,0 +1,104 @@ +#if 0 + +#define TRACE_TXT(text) \ + { \ + if(dtlk_trace) \ + { \ + console_print(text); \ + console_print("\n"); \ + } \ + } + +#define TRACE_CHR(chr) \ + { \ + if(dtlk_trace) \ + console_print(chr); \ + } \ + +#endif + +#define DTLK_MINOR 0 +#define DTLK_IO_EXTENT 0x02 + + /* ioctl's use magic number of 0xa3 */ +#define DTLK_INTERROGATE 0xa390 /* get settings from the DoubleTalk */ +#define DTLK_STATUS 0xa391 /* get status from the DoubleTalk */ + + +#define DTLK_CLEAR 0x18 /* stops speech */ + +#define DTLK_MAX_RETRIES (loops_per_jiffy/(10000/HZ)) + + /* TTS Port Status Flags */ +#define TTS_READABLE 0x80 /* mask for bit which is nonzero if a + byte can be read from the TTS port */ +#define TTS_SPEAKING 0x40 /* mask for SYNC bit, which is nonzero + while DoubleTalk is producing + output with TTS, PCM or CVSD + synthesizers or tone generators + (that is, all but LPC) */ +#define TTS_SPEAKING2 0x20 /* mask for SYNC2 bit, + which falls to zero up to 0.4 sec + before speech stops */ +#define TTS_WRITABLE 0x10 /* mask for RDY bit, which when set to + 1, indicates the TTS port is ready + to accept a byte of data. The RDY + bit goes zero 2-3 usec after + writing, and goes 1 again 180-190 + usec later. */ +#define TTS_ALMOST_FULL 0x08 /* mask for AF bit: When set to 1, + indicates that less than 300 free + bytes are available in the TTS + input buffer. AF is always 0 in the + PCM, TGN and CVSD modes. */ +#define TTS_ALMOST_EMPTY 0x04 /* mask for AE bit: When set to 1, + indicates that less than 300 bytes + of data remain in DoubleTalk's + input (TTS or PCM) buffer. AE is + always 1 in the TGN and CVSD + modes. */ + + /* LPC speak commands */ +#define LPC_5220_NORMAL 0x60 /* 5220 format decoding table, normal rate */ +#define LPC_5220_FAST 0x64 /* 5220 format decoding table, fast rate */ +#define LPC_D6_NORMAL 0x20 /* D6 format decoding table, normal rate */ +#define LPC_D6_FAST 0x24 /* D6 format decoding table, fast rate */ + + /* LPC Port Status Flags (valid only after one of the LPC + speak commands) */ +#define LPC_SPEAKING 0x80 /* mask for TS bit: When set to 1, + indicates the LPC synthesizer is + producing speech.*/ +#define LPC_BUFFER_LOW 0x40 /* mask for BL bit: When set to 1, + indicates that the hardware LPC + data buffer has less than 30 bytes + remaining. (Total internal buffer + size = 4096 bytes.) */ +#define LPC_BUFFER_EMPTY 0x20 /* mask for BE bit: When set to 1, + indicates that the LPC data buffer + ran out of data (error condition if + TS is also 1). */ + + /* data returned by Interrogate command */ +struct dtlk_settings +{ + unsigned short serial_number; /* 0-7Fh:0-7Fh */ + unsigned char rom_version[24]; /* null terminated string */ + unsigned char mode; /* 0=Character; 1=Phoneme; 2=Text */ + unsigned char punc_level; /* nB; 0-7 */ + unsigned char formant_freq; /* nF; 0-9 */ + unsigned char pitch; /* nP; 0-99 */ + unsigned char speed; /* nS; 0-9 */ + unsigned char volume; /* nV; 0-9 */ + unsigned char tone; /* nX; 0-2 */ + unsigned char expression; /* nE; 0-9 */ + unsigned char ext_dict_loaded; /* 1=exception dictionary loaded */ + unsigned char ext_dict_status; /* 1=exception dictionary enabled */ + unsigned char free_ram; /* # pages (truncated) remaining for + text buffer */ + unsigned char articulation; /* nA; 0-9 */ + unsigned char reverb; /* nR; 0-9 */ + unsigned char eob; /* 7Fh value indicating end of + parameter block */ + unsigned char has_indexing; /* nonzero if indexing is implemented */ +}; diff --git a/ddverify/case_studies/char/efirtc/efi.h b/ddverify/case_studies/char/efirtc/efi.h new file mode 100644 index 000000000..e99ef2836 --- /dev/null +++ b/ddverify/case_studies/char/efirtc/efi.h @@ -0,0 +1,397 @@ +#ifndef _LINUX_EFI_H +#define _LINUX_EFI_H + +/* + * Extensible Firmware Interface + * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999 + * + * Copyright (C) 1999 VA Linux Systems + * Copyright (C) 1999 Walt Drummond + * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co. + * David Mosberger-Tang + * Stephane Eranian + */ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define EFI_SUCCESS 0 +#define EFI_LOAD_ERROR ( 1 | (1UL << (BITS_PER_LONG-1))) +#define EFI_INVALID_PARAMETER ( 2 | (1UL << (BITS_PER_LONG-1))) +#define EFI_UNSUPPORTED ( 3 | (1UL << (BITS_PER_LONG-1))) +#define EFI_BAD_BUFFER_SIZE ( 4 | (1UL << (BITS_PER_LONG-1))) +#define EFI_BUFFER_TOO_SMALL ( 5 | (1UL << (BITS_PER_LONG-1))) +#define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1))) + +typedef unsigned long efi_status_t; +typedef u8 efi_bool_t; +typedef u16 efi_char16_t; /* UNICODE character */ + + +typedef struct { + u8 b[16]; +} efi_guid_t; + +#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ +((efi_guid_t) \ +{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ + (b) & 0xff, ((b) >> 8) & 0xff, \ + (c) & 0xff, ((c) >> 8) & 0xff, \ + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) + +/* + * Generic EFI table header + */ +typedef struct { + u64 signature; + u32 revision; + u32 headersize; + u32 crc32; + u32 reserved; +} efi_table_hdr_t; + +/* + * Memory map descriptor: + */ + +/* Memory types: */ +#define EFI_RESERVED_TYPE 0 +#define EFI_LOADER_CODE 1 +#define EFI_LOADER_DATA 2 +#define EFI_BOOT_SERVICES_CODE 3 +#define EFI_BOOT_SERVICES_DATA 4 +#define EFI_RUNTIME_SERVICES_CODE 5 +#define EFI_RUNTIME_SERVICES_DATA 6 +#define EFI_CONVENTIONAL_MEMORY 7 +#define EFI_UNUSABLE_MEMORY 8 +#define EFI_ACPI_RECLAIM_MEMORY 9 +#define EFI_ACPI_MEMORY_NVS 10 +#define EFI_MEMORY_MAPPED_IO 11 +#define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12 +#define EFI_PAL_CODE 13 +#define EFI_MAX_MEMORY_TYPE 14 + +/* Attribute values: */ +#define EFI_MEMORY_UC ((u64)0x0000000000000001) /* uncached */ +#define EFI_MEMORY_WC ((u64)0x0000000000000002) /* write-coalescing */ +#define EFI_MEMORY_WT ((u64)0x0000000000000004) /* write-through */ +#define EFI_MEMORY_WB ((u64)0x0000000000000008) /* write-back */ +#define EFI_MEMORY_WP ((u64)0x0000000000001000) /* write-protect */ +#define EFI_MEMORY_RP ((u64)0x0000000000002000) /* read-protect */ +#define EFI_MEMORY_XP ((u64)0x0000000000004000) /* execute-protect */ +#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000) /* range requires runtime mapping */ +#define EFI_MEMORY_DESCRIPTOR_VERSION 1 + +#define EFI_PAGE_SHIFT 12 + +typedef struct { + u32 type; + u32 pad; + u64 phys_addr; + u64 virt_addr; + u64 num_pages; + u64 attribute; +} efi_memory_desc_t; + +typedef int (*efi_freemem_callback_t) (unsigned long start, unsigned long end, void *arg); + +/* + * Types and defines for Time Services + */ +#define EFI_TIME_ADJUST_DAYLIGHT 0x1 +#define EFI_TIME_IN_DAYLIGHT 0x2 +#define EFI_UNSPECIFIED_TIMEZONE 0x07ff + +typedef struct { + u16 year; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; + u8 pad1; + u32 nanosecond; + s16 timezone; + u8 daylight; + u8 pad2; +} efi_time_t; + +typedef struct { + u32 resolution; + u32 accuracy; + u8 sets_to_zero; +} efi_time_cap_t; + +/* + * Types and defines for EFI ResetSystem + */ +#define EFI_RESET_COLD 0 +#define EFI_RESET_WARM 1 +#define EFI_RESET_SHUTDOWN 2 + +/* + * EFI Runtime Services table + */ +#define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL) +#define EFI_RUNTIME_SERVICES_REVISION 0x00010000 + +typedef struct { + efi_table_hdr_t hdr; + unsigned long get_time; + unsigned long set_time; + unsigned long get_wakeup_time; + unsigned long set_wakeup_time; + unsigned long set_virtual_address_map; + unsigned long convert_pointer; + unsigned long get_variable; + unsigned long get_next_variable; + unsigned long set_variable; + unsigned long get_next_high_mono_count; + unsigned long reset_system; +} efi_runtime_services_t; + +typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc); +typedef efi_status_t efi_set_time_t (efi_time_t *tm); +typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending, + efi_time_t *tm); +typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm); +typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr, + unsigned long *data_size, void *data); +typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name, + efi_guid_t *vendor); +typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor, + unsigned long attr, unsigned long data_size, + void *data); +typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count); +typedef void efi_reset_system_t (int reset_type, efi_status_t status, + unsigned long data_size, efi_char16_t *data); +typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size, + unsigned long descriptor_size, + u32 descriptor_version, + efi_memory_desc_t *virtual_map); + +/* + * EFI Configuration Table and GUID definitions + */ +#define NULL_GUID \ + EFI_GUID( 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ) + +#define MPS_TABLE_GUID \ + EFI_GUID( 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define ACPI_TABLE_GUID \ + EFI_GUID( 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define ACPI_20_TABLE_GUID \ + EFI_GUID( 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 ) + +#define SMBIOS_TABLE_GUID \ + EFI_GUID( 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define SAL_SYSTEM_TABLE_GUID \ + EFI_GUID( 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) + +#define HCDP_TABLE_GUID \ + EFI_GUID( 0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 ) + +#define UGA_IO_PROTOCOL_GUID \ + EFI_GUID( 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 ) + +#define EFI_GLOBAL_VARIABLE_GUID \ + EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c ) + +typedef struct { + efi_guid_t guid; + unsigned long table; +} efi_config_table_t; + +#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) +#define EFI_SYSTEM_TABLE_REVISION ((1 << 16) | 00) + +typedef struct { + efi_table_hdr_t hdr; + unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */ + u32 fw_revision; + unsigned long con_in_handle; + unsigned long con_in; + unsigned long con_out_handle; + unsigned long con_out; + unsigned long stderr_handle; + unsigned long stderr; + efi_runtime_services_t *runtime; + unsigned long boottime; + unsigned long nr_tables; + unsigned long tables; +} efi_system_table_t; + +struct efi_memory_map { + void *phys_map; + void *map; + void *map_end; + int nr_map; + unsigned long desc_version; + unsigned long desc_size; +}; + +#define EFI_INVALID_TABLE_ADDR (~0UL) + +/* + * All runtime access to EFI goes through this structure: + */ +extern struct efi { + efi_system_table_t *systab; /* EFI system table */ + unsigned long mps; /* MPS table */ + unsigned long acpi; /* ACPI table (IA64 ext 0.71) */ + unsigned long acpi20; /* ACPI table (ACPI 2.0) */ + unsigned long smbios; /* SM BIOS table */ + unsigned long sal_systab; /* SAL system table */ + unsigned long boot_info; /* boot info table */ + unsigned long hcdp; /* HCDP table */ + unsigned long uga; /* UGA table */ + efi_get_time_t *get_time; + efi_set_time_t *set_time; + efi_get_wakeup_time_t *get_wakeup_time; + efi_set_wakeup_time_t *set_wakeup_time; + efi_get_variable_t *get_variable; + efi_get_next_variable_t *get_next_variable; + efi_set_variable_t *set_variable; + efi_get_next_high_mono_count_t *get_next_high_mono_count; + efi_reset_system_t *reset_system; + efi_set_virtual_address_map_t *set_virtual_address_map; +} efi; + +static inline int +efi_guidcmp (efi_guid_t left, efi_guid_t right) +{ + return memcmp(&left, &right, sizeof (efi_guid_t)); +} + +static inline char * +efi_guid_unparse(efi_guid_t *guid, char *out) +{ + sprintf(out, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid->b[3], guid->b[2], guid->b[1], guid->b[0], + guid->b[5], guid->b[4], guid->b[7], guid->b[6], + guid->b[8], guid->b[9], guid->b[10], guid->b[11], + guid->b[12], guid->b[13], guid->b[14], guid->b[15]); + return out; +} + +extern void efi_init (void); +extern void *efi_get_pal_addr (void); +extern void efi_map_pal_code (void); +extern void efi_map_memmap(void); +extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg); +extern void efi_gettimeofday (struct timespec *ts); +extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */ +extern u64 efi_get_iobase (void); +extern u32 efi_mem_type (unsigned long phys_addr); +extern u64 efi_mem_attributes (unsigned long phys_addr); +extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size); +extern int efi_mem_attribute_range (unsigned long phys_addr, unsigned long size, + u64 attr); +extern int __init efi_uart_console_only (void); +extern void efi_initialize_iomem_resources(struct resource *code_resource, + struct resource *data_resource); +extern unsigned long __init efi_get_time(void); +extern int __init efi_set_rtc_mmss(unsigned long nowtime); +extern struct efi_memory_map memmap; + +/** + * efi_range_is_wc - check the WC bit on an address range + * @start: starting kvirt address + * @len: length of range + * + * Consult the EFI memory map and make sure it's ok to set this range WC. + * Returns true or false. + */ +static inline int efi_range_is_wc(unsigned long start, unsigned long len) +{ + unsigned long i; + + for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) { + unsigned long paddr = __pa(start + i); + if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC)) + return 0; + } + /* The range checked out */ + return 1; +} + +#ifdef CONFIG_EFI_PCDP +extern int __init efi_setup_pcdp_console(char *); +#endif + +/* + * We play games with efi_enabled so that the compiler will, if possible, remove + * EFI-related code altogether. + */ +#ifdef CONFIG_EFI +# ifdef CONFIG_X86 + extern int efi_enabled; +# else +# define efi_enabled 1 +# endif +#else +# define efi_enabled 0 +#endif + +/* + * Variable Attributes + */ +#define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004 + +/* + * EFI Device Path information + */ +#define EFI_DEV_HW 0x01 +#define EFI_DEV_PCI 1 +#define EFI_DEV_PCCARD 2 +#define EFI_DEV_MEM_MAPPED 3 +#define EFI_DEV_VENDOR 4 +#define EFI_DEV_CONTROLLER 5 +#define EFI_DEV_ACPI 0x02 +#define EFI_DEV_BASIC_ACPI 1 +#define EFI_DEV_EXPANDED_ACPI 2 +#define EFI_DEV_MSG 0x03 +#define EFI_DEV_MSG_ATAPI 1 +#define EFI_DEV_MSG_SCSI 2 +#define EFI_DEV_MSG_FC 3 +#define EFI_DEV_MSG_1394 4 +#define EFI_DEV_MSG_USB 5 +#define EFI_DEV_MSG_USB_CLASS 15 +#define EFI_DEV_MSG_I20 6 +#define EFI_DEV_MSG_MAC 11 +#define EFI_DEV_MSG_IPV4 12 +#define EFI_DEV_MSG_IPV6 13 +#define EFI_DEV_MSG_INFINIBAND 9 +#define EFI_DEV_MSG_UART 14 +#define EFI_DEV_MSG_VENDOR 10 +#define EFI_DEV_MEDIA 0x04 +#define EFI_DEV_MEDIA_HARD_DRIVE 1 +#define EFI_DEV_MEDIA_CDROM 2 +#define EFI_DEV_MEDIA_VENDOR 3 +#define EFI_DEV_MEDIA_FILE 4 +#define EFI_DEV_MEDIA_PROTOCOL 5 +#define EFI_DEV_BIOS_BOOT 0x05 +#define EFI_DEV_END_PATH 0x7F +#define EFI_DEV_END_PATH2 0xFF +#define EFI_DEV_END_INSTANCE 0x01 +#define EFI_DEV_END_ENTIRE 0xFF + +struct efi_generic_dev_path { + u8 type; + u8 sub_type; + u16 length; +} __attribute ((packed)); + +#endif /* _LINUX_EFI_H */ diff --git a/ddverify/case_studies/char/efirtc/efirtc.c b/ddverify/case_studies/char/efirtc/efirtc.c new file mode 100644 index 000000000..1e6bfa98f --- /dev/null +++ b/ddverify/case_studies/char/efirtc/efirtc.c @@ -0,0 +1,418 @@ +/* + * EFI Time Services Driver for Linux + * + * Copyright (C) 1999 Hewlett-Packard Co + * Copyright (C) 1999 Stephane Eranian + * + * Based on skeleton from the drivers/char/rtc.c driver by P. Gortmaker + * + * This code provides an architected & portable interface to the real time + * clock by using EFI instead of direct bit fiddling. The functionalities are + * quite different from the rtc.c driver. The only way to talk to the device + * is by using ioctl(). There is a /proc interface which provides the raw + * information. + * + * Please note that we have kept the API as close as possible to the + * legacy RTC. The standard /sbin/hwclock program should work normally + * when used to get/set the time. + * + * NOTES: + * - Locking is required for safe execution of EFI calls with regards + * to interrrupts and SMP. + * + * TODO (December 1999): + * - provide the API to set/get the WakeUp Alarm (different from the + * rtc.c alarm). + * - SMP testing + * - Add module support + */ + + +#include +#include +#include +#include +#include +#include +#include +#include "efi.h" + +#include +#include + +#define EFI_RTC_VERSION "0.4" + +#define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT) +/* + * EFI Epoch is 1/1/1998 + */ +#define EFI_RTC_EPOCH 1998 + +DEFINE_SPINLOCK(efi_rtc_lock); + +int efi_rtc_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg); + +#define is_leap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) + +const unsigned short int __mon_yday[2][13] = +{ + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } +}; + +/* + * returns day of the year [0-365] + */ +inline int +compute_yday(efi_time_t *eft) +{ + /* efi_time_t.month is in the [1-12] so, we need -1 */ + return __mon_yday[is_leap(eft->year)][eft->month-1]+ eft->day -1; +} +/* + * returns day of the week [0-6] 0=Sunday + * + * Don't try to provide a year that's before 1998, please ! + */ +int +compute_wday(efi_time_t *eft) +{ + int y; + int ndays = 0; + + if ( eft->year < 1998 ) { + printk(KERN_ERR "efirtc: EFI year < 1998, invalid date\n"); + return -1; + } + + for(y=EFI_RTC_EPOCH; y < eft->year; y++ ) { + ndays += 365 + (is_leap(y) ? 1 : 0); + } + ndays += compute_yday(eft); + + /* + * 4=1/1/1998 was a Thursday + */ + return (ndays + 4) % 7; +} + +void +convert_to_efi_time(struct rtc_time *wtime, efi_time_t *eft) +{ + + eft->year = wtime->tm_year + 1900; + eft->month = wtime->tm_mon + 1; + eft->day = wtime->tm_mday; + eft->hour = wtime->tm_hour; + eft->minute = wtime->tm_min; + eft->second = wtime->tm_sec; + eft->nanosecond = 0; + eft->daylight = wtime->tm_isdst ? EFI_ISDST: 0; + eft->timezone = EFI_UNSPECIFIED_TIMEZONE; +} + +void +convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) +{ + memset(wtime, 0, sizeof(*wtime)); + wtime->tm_sec = eft->second; + wtime->tm_min = eft->minute; + wtime->tm_hour = eft->hour; + wtime->tm_mday = eft->day; + wtime->tm_mon = eft->month - 1; + wtime->tm_year = eft->year - 1900; + + /* day of the week [0-6], Sunday=0 */ + wtime->tm_wday = compute_wday(eft); + + /* day in the year [1-365]*/ + wtime->tm_yday = compute_yday(eft); + + + switch (eft->daylight & EFI_ISDST) { + case EFI_ISDST: + wtime->tm_isdst = 1; + break; + case EFI_TIME_ADJUST_DAYLIGHT: + wtime->tm_isdst = 0; + break; + default: + wtime->tm_isdst = -1; + } +} + +int +efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + + efi_status_t status; + unsigned long flags; + efi_time_t eft; + efi_time_cap_t cap; + struct rtc_time wtime; + struct rtc_wkalrm __user *ewp; + unsigned char enabled, pending; + + + switch (cmd) { + case RTC_UIE_ON: + case RTC_UIE_OFF: + case RTC_PIE_ON: + case RTC_PIE_OFF: + case RTC_AIE_ON: + case RTC_AIE_OFF: + case RTC_ALM_SET: + case RTC_ALM_READ: + case RTC_IRQP_READ: + case RTC_IRQP_SET: + case RTC_EPOCH_READ: + case RTC_EPOCH_SET: + return -EINVAL; + + case RTC_RD_TIME: + spin_lock_irqsave(&efi_rtc_lock, flags); + + status = efi.get_time(&eft, &cap); + + spin_unlock_irqrestore(&efi_rtc_lock,flags); + + if (status != EFI_SUCCESS) { + /* should never happen */ + printk(KERN_ERR "efitime: can't read time\n"); + return -EINVAL; + } + + convert_from_efi_time(&eft, &wtime); + + return copy_to_user((void __user *)arg, &wtime, + sizeof (struct rtc_time)) ? - EFAULT : 0; + + case RTC_SET_TIME: + + if (!capable(CAP_SYS_TIME)) return -EACCES; + + if (copy_from_user(&wtime, (struct rtc_time __user *)arg, + sizeof(struct rtc_time)) ) + return -EFAULT; + + convert_to_efi_time(&wtime, &eft); + + spin_lock_irqsave(&efi_rtc_lock, flags); + + status = efi.set_time(&eft); + + spin_unlock_irqrestore(&efi_rtc_lock,flags); + + return status == EFI_SUCCESS ? 0 : -EINVAL; + + case RTC_WKALM_SET: + + if (!capable(CAP_SYS_TIME)) return -EACCES; + + ewp = (struct rtc_wkalrm __user *)arg; + + if ( get_user(enabled, &ewp->enabled) + || copy_from_user(&wtime, &ewp->time, sizeof(struct rtc_time)) ) + return -EFAULT; + + convert_to_efi_time(&wtime, &eft); + + spin_lock_irqsave(&efi_rtc_lock, flags); + /* + * XXX Fixme: + * As of EFI 0.92 with the firmware I have on my + * machine this call does not seem to work quite + * right + */ + status = efi.set_wakeup_time((efi_bool_t)enabled, &eft); + + spin_unlock_irqrestore(&efi_rtc_lock,flags); + + return status == EFI_SUCCESS ? 0 : -EINVAL; + + case RTC_WKALM_RD: + + spin_lock_irqsave(&efi_rtc_lock, flags); + + status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft); + + spin_unlock_irqrestore(&efi_rtc_lock,flags); + + if (status != EFI_SUCCESS) return -EINVAL; + + ewp = (struct rtc_wkalrm __user *)arg; + + if ( put_user(enabled, &ewp->enabled) + || put_user(pending, &ewp->pending)) return -EFAULT; + + convert_from_efi_time(&eft, &wtime); + + return copy_to_user(&ewp->time, &wtime, + sizeof(struct rtc_time)) ? -EFAULT : 0; + } + return -EINVAL; +} + +/* + * We enforce only one user at a time here with the open/close. + * Also clear the previous interrupt data on an open, and clean + * up things on a close. + */ + +int +efi_rtc_open(struct inode *inode, struct file *file) +{ + /* + * nothing special to do here + * We do accept multiple open files at the same time as we + * synchronize on the per call operation. + */ + + return 0; +} + +int +efi_rtc_close(struct inode *inode, struct file *file) +{ + return 0; +} + +/* + * The various file operations we support. + */ + +const struct file_operations efi_rtc_fops = { + .owner = THIS_MODULE, + .ioctl = efi_rtc_ioctl, + .open = efi_rtc_open, + .release = efi_rtc_close, +}; + +struct miscdevice efi_rtc_dev= +{ + EFI_RTC_MINOR, + "efirtc", + &efi_rtc_fops +}; + +/* + * We export RAW EFI information to /proc/driver/efirtc + */ +int +efi_rtc_get_status(char *buf) +{ + efi_time_t eft, alm; + efi_time_cap_t cap; + char *p = buf; + efi_bool_t enabled, pending; + unsigned long flags; + + memset(&eft, 0, sizeof(eft)); + memset(&alm, 0, sizeof(alm)); + memset(&cap, 0, sizeof(cap)); + + spin_lock_irqsave(&efi_rtc_lock, flags); + + efi.get_time(&eft, &cap); + efi.get_wakeup_time(&enabled, &pending, &alm); + + spin_unlock_irqrestore(&efi_rtc_lock,flags); + + p += sprintf(p, + "Time : %u:%u:%u.%09u\n" + "Date : %u-%u-%u\n" + "Daylight : %u\n", + eft.hour, eft.minute, eft.second, eft.nanosecond, + eft.year, eft.month, eft.day, + eft.daylight); + + if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) + p += sprintf(p, "Timezone : unspecified\n"); + else + /* XXX fixme: convert to string? */ + p += sprintf(p, "Timezone : %u\n", eft.timezone); + + + p += sprintf(p, + "Alarm Time : %u:%u:%u.%09u\n" + "Alarm Date : %u-%u-%u\n" + "Alarm Daylight : %u\n" + "Enabled : %s\n" + "Pending : %s\n", + alm.hour, alm.minute, alm.second, alm.nanosecond, + alm.year, alm.month, alm.day, + alm.daylight, + enabled == 1 ? "yes" : "no", + pending == 1 ? "yes" : "no"); + + if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) + p += sprintf(p, "Timezone : unspecified\n"); + else + /* XXX fixme: convert to string? */ + p += sprintf(p, "Timezone : %u\n", alm.timezone); + + /* + * now prints the capabilities + */ + p += sprintf(p, + "Resolution : %u\n" + "Accuracy : %u\n" + "SetstoZero : %u\n", + cap.resolution, cap.accuracy, cap.sets_to_zero); + + return p - buf; +} + +int +efi_rtc_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = efi_rtc_get_status(page); + if (len <= off+count) *eof = 1; + *start = page + off; + len -= off; + if (len>count) len = count; + if (len<0) len = 0; + return len; +} + +int __init +efi_rtc_init(void) +{ + int ret; + struct proc_dir_entry *dir; + + printk(KERN_INFO "EFI Time Services Driver v%s\n", EFI_RTC_VERSION); + + ret = misc_register(&efi_rtc_dev); + if (ret) { + printk(KERN_ERR "efirtc: can't misc_register on minor=%d\n", + EFI_RTC_MINOR); + return ret; + } + + dir = create_proc_read_entry ("driver/efirtc", 0, NULL, + efi_rtc_read_proc, NULL); + if (dir == NULL) { + printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n"); + misc_deregister(&efi_rtc_dev); + return -1; + } + return 0; +} + +void __exit +efi_rtc_exit(void) +{ + /* not yet used */ +} + +module_init(efi_rtc_init); +module_exit(efi_rtc_exit); + +MODULE_LICENSE("GPL"); diff --git a/ddverify/case_studies/char/generic_nvram/generic_nvram.c b/ddverify/case_studies/char/generic_nvram/generic_nvram.c new file mode 100644 index 000000000..1af6976dd --- /dev/null +++ b/ddverify/case_studies/char/generic_nvram/generic_nvram.c @@ -0,0 +1,150 @@ +/* + * Generic /dev/nvram driver for architectures providing some + * "generic" hooks, that is : + * + * nvram_read_byte, nvram_write_byte, nvram_sync + * + * Note that an additional hook is supported for PowerMac only + * for getting the nvram "partition" informations + * + */ + +#define NVRAM_VERSION "1.1" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#ifdef CONFIG_PPC_PMAC +#include +#endif + +#define NVRAM_SIZE 8192 + +#define IOC_NVRAM_SYNC _IO('p', 0x43) + +loff_t nvram_llseek(struct file *file, loff_t offset, int origin) +{ + lock_kernel(); + switch (origin) { + case 1: + offset += file->f_pos; + break; + case 2: + offset += NVRAM_SIZE; + break; + } + if (offset < 0) { + unlock_kernel(); + return -EINVAL; + } + file->f_pos = offset; + unlock_kernel(); + return file->f_pos; +} + +ssize_t read_nvram(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + unsigned int i; + char __user *p = buf; + + if (!access_ok(VERIFY_WRITE, buf, count)) + return -EFAULT; + if (*ppos >= NVRAM_SIZE) + return 0; + for (i = *ppos; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count) + if (__put_user(nvram_read_byte(i), p)) + return -EFAULT; + *ppos = i; + return p - buf; +} + +ssize_t write_nvram(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + unsigned int i; + const char __user *p = buf; + char c; + + if (!access_ok(VERIFY_READ, buf, count)) + return -EFAULT; + if (*ppos >= NVRAM_SIZE) + return 0; + for (i = *ppos; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count) { + if (__get_user(c, p)) + return -EFAULT; + nvram_write_byte(c, i); + } + *ppos = i; + return p - buf; +} + +int nvram_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + switch(cmd) { +#ifdef CONFIG_PPC_PMAC + case OBSOLETE_PMAC_NVRAM_GET_OFFSET: + printk(KERN_WARNING "nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n"); + case IOC_NVRAM_GET_OFFSET: { + int part, offset; + + if (!machine_is(powermac)) + return -EINVAL; + if (copy_from_user(&part, (void __user*)arg, sizeof(part)) != 0) + return -EFAULT; + if (part < pmac_nvram_OF || part > pmac_nvram_NR) + return -EINVAL; + offset = pmac_get_partition(part); + if (copy_to_user((void __user*)arg, &offset, sizeof(offset)) != 0) + return -EFAULT; + break; + } +#endif /* CONFIG_PPC_PMAC */ + case IOC_NVRAM_SYNC: + nvram_sync(); + break; + default: + return -EINVAL; + } + + return 0; +} + +struct file_operations nvram_fops = { + .owner = THIS_MODULE, + .llseek = nvram_llseek, + .read = read_nvram, + .write = write_nvram, + .ioctl = nvram_ioctl, +}; + +struct miscdevice nvram_dev = { + NVRAM_MINOR, + "nvram", + &nvram_fops +}; + +int __init nvram_init(void) +{ + printk(KERN_INFO "Macintosh non-volatile memory driver v%s\n", + NVRAM_VERSION); + return misc_register(&nvram_dev); +} + +void __exit nvram_cleanup(void) +{ + misc_deregister( &nvram_dev ); +} + +module_init(nvram_init); +module_exit(nvram_cleanup); +MODULE_LICENSE("GPL"); diff --git a/ddverify/case_studies/char/genrtc/genrtc.c b/ddverify/case_studies/char/genrtc/genrtc.c new file mode 100644 index 000000000..98cdbf1ab --- /dev/null +++ b/ddverify/case_studies/char/genrtc/genrtc.c @@ -0,0 +1,536 @@ +/* + * Real Time Clock interface for + * - q40 and other m68k machines, + * - HP PARISC machines + * - PowerPC machines + * emulate some RTC irq capabilities in software + * + * Copyright (C) 1999 Richard Zidlicky + * + * based on Paul Gortmaker's rtc.c device and + * Sam Creasey Generic rtc driver + * + * This driver allows use of the real time clock (built into + * nearly all computers) from user space. It exports the /dev/rtc + * interface supporting various ioctl() and also the /proc/dev/rtc + * pseudo-file for status information. + * + * The ioctls can be used to set the interrupt behaviour where + * supported. + * + * The /dev/rtc interface will block on reads until an interrupt + * has been received. If a RTC interrupt has already happened, + * it will output an unsigned long and then block. The output value + * contains the interrupt status in the low byte and the number of + * interrupts since the last read in the remaining high bytes. The + * /dev/rtc interface can also be used with the select(2) call. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + + * 1.01 fix for 2.3.X rz@linux-m68k.org + * 1.02 merged with code from genrtc.c rz@linux-m68k.org + * 1.03 make it more portable zippel@linux-m68k.org + * 1.04 removed useless timer code rz@linux-m68k.org + * 1.05 portable RTC_UIE emulation rz@linux-m68k.org + * 1.06 set_rtc_time can return an error trini@kernel.crashing.org + * 1.07 ported to HP PARISC (hppa) Helge Deller + */ + +#define RTC_VERSION "1.07" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +/* + * We sponge a minor off of the misc major. No need slurping + * up another valuable major dev number for this. If you add + * an ioctl, make sure you don't conflict with SPARC's RTC + * ioctls. + */ + +DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); + +/* + * Bits in gen_rtc_status. + */ + +#define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ + +unsigned char gen_rtc_status; /* bitmapped status byte. */ +unsigned long gen_rtc_irq_data; /* our output to the world */ + +/* months start at 0 now */ +unsigned char days_in_mo[] = +{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +int irq_active; + +#ifdef CONFIG_GEN_RTC_X +struct work_struct genrtc_task; +struct timer_list timer_task; + +unsigned int oldsecs; +int lostint; +unsigned long tt_exp; + +void gen_rtc_timer(unsigned long data); + +volatile int stask_active; /* schedule_work */ +volatile int ttask_active; /* timer_task */ +int stop_rtc_timers; /* don't requeue tasks */ +DEFINE_SPINLOCK(gen_rtc_lock); + +void gen_rtc_interrupt(unsigned long arg); + +/* + * Routine to poll RTC seconds field for change as often as possible, + * after first RTC_UIE use timer to reduce polling + */ +void genrtc_troutine(void *data) +{ + unsigned int tmp = get_rtc_ss(); + + if (stop_rtc_timers) { + stask_active = 0; + return; + } + + if (oldsecs != tmp){ + oldsecs = tmp; + + timer_task.function = gen_rtc_timer; + timer_task.expires = jiffies + HZ - (HZ/10); + tt_exp=timer_task.expires; + ttask_active=1; + stask_active=0; + add_timer(&timer_task); + + gen_rtc_interrupt(0); + } else if (schedule_work(&genrtc_task) == 0) + stask_active = 0; +} + +void gen_rtc_timer(unsigned long data) +{ + lostint = get_rtc_ss() - oldsecs ; + if (lostint<0) + lostint = 60 - lostint; + if (time_after(jiffies, tt_exp)) + printk(KERN_INFO "genrtc: timer task delayed by %ld jiffies\n", + jiffies-tt_exp); + ttask_active=0; + stask_active=1; + if ((schedule_work(&genrtc_task) == 0)) + stask_active = 0; +} + +/* + * call gen_rtc_interrupt function to signal an RTC_UIE, + * arg is unused. + * Could be invoked either from a real interrupt handler or + * from some routine that periodically (eg 100HZ) monitors + * whether RTC_SECS changed + */ +void gen_rtc_interrupt(unsigned long arg) +{ + /* We store the status in the low byte and the number of + * interrupts received since the last read in the remainder + * of rtc_irq_data. */ + + gen_rtc_irq_data += 0x100; + gen_rtc_irq_data &= ~0xff; + gen_rtc_irq_data |= RTC_UIE; + + if (lostint){ + printk("genrtc: system delaying clock ticks?\n"); + /* increment count so that userspace knows something is wrong */ + gen_rtc_irq_data += ((lostint-1)<<8); + lostint = 0; + } + + wake_up_interruptible(&gen_rtc_wait); +} + +/* + * Now all the various file operations that we export. + */ +ssize_t gen_rtc_read(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + DECLARE_WAITQUEUE(wait, current); + unsigned long data; + ssize_t retval; + + if (count != sizeof (unsigned int) && count != sizeof (unsigned long)) + return -EINVAL; + + if (file->f_flags & O_NONBLOCK && !gen_rtc_irq_data) + return -EAGAIN; + + add_wait_queue(&gen_rtc_wait, &wait); + retval = -ERESTARTSYS; + + while (1) { + set_current_state(TASK_INTERRUPTIBLE); + data = xchg(&gen_rtc_irq_data, 0); + if (data) + break; + if (signal_pending(current)) + goto out; + schedule(); + } + + /* first test allows optimizer to nuke this case for 32-bit machines */ + if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { + unsigned int uidata = data; + retval = put_user(uidata, (unsigned int __user *)buf); + if (retval == 0) + retval = sizeof(unsigned int); + } + else { + retval = put_user(data, (unsigned long __user *)buf); + if (retval == 0) + retval = sizeof(unsigned long); + } + out: + current->state = TASK_RUNNING; + remove_wait_queue(&gen_rtc_wait, &wait); + + return retval; +} + +unsigned int gen_rtc_poll(struct file *file, + struct poll_table_struct *wait) +{ + poll_wait(file, &gen_rtc_wait, wait); + if (gen_rtc_irq_data != 0) + return POLLIN | POLLRDNORM; + return 0; +} + +#endif + +/* + * Used to disable/enable interrupts, only RTC_UIE supported + * We also clear out any old irq data after an ioctl() that + * meddles with the interrupt enable/disable bits. + */ + +inline void gen_clear_rtc_irq_bit(unsigned char bit) +{ +#ifdef CONFIG_GEN_RTC_X + stop_rtc_timers = 1; + if (ttask_active){ + del_timer_sync(&timer_task); + ttask_active = 0; + } + while (stask_active) + schedule(); + + spin_lock(&gen_rtc_lock); + irq_active = 0; + spin_unlock(&gen_rtc_lock); +#endif +} + +inline int gen_set_rtc_irq_bit(unsigned char bit) +{ +#ifdef CONFIG_GEN_RTC_X + spin_lock(&gen_rtc_lock); + if ( !irq_active ) { + irq_active = 1; + stop_rtc_timers = 0; + lostint = 0; + INIT_WORK(&genrtc_task, genrtc_troutine, NULL); + oldsecs = get_rtc_ss(); + init_timer(&timer_task); + + stask_active = 1; + if (schedule_work(&genrtc_task) == 0){ + stask_active = 0; + } + } + spin_unlock(&gen_rtc_lock); + gen_rtc_irq_data = 0; + return 0; +#else + return -EINVAL; +#endif +} + +int gen_rtc_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + struct rtc_time wtime; + struct rtc_pll_info pll; + void __user *argp = (void __user *)arg; + + switch (cmd) { + + case RTC_PLL_GET: + if (get_rtc_pll(&pll)) + return -EINVAL; + else + return copy_to_user(argp, &pll, sizeof pll) ? -EFAULT : 0; + + case RTC_PLL_SET: + if (!capable(CAP_SYS_TIME)) + return -EACCES; + if (copy_from_user(&pll, argp, sizeof(pll))) + return -EFAULT; + return set_rtc_pll(&pll); + + case RTC_UIE_OFF: /* disable ints from RTC updates. */ + gen_clear_rtc_irq_bit(RTC_UIE); + return 0; + + case RTC_UIE_ON: /* enable ints for RTC updates. */ + return gen_set_rtc_irq_bit(RTC_UIE); + + case RTC_RD_TIME: /* Read the time/date from RTC */ + /* this doesn't get week-day, who cares */ + memset(&wtime, 0, sizeof(wtime)); + get_rtc_time(&wtime); + + return copy_to_user(argp, &wtime, sizeof(wtime)) ? -EFAULT : 0; + + case RTC_SET_TIME: /* Set the RTC */ + { + int year; + unsigned char leap_yr; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + if (copy_from_user(&wtime, argp, sizeof(wtime))) + return -EFAULT; + + year = wtime.tm_year + 1900; + leap_yr = ((!(year % 4) && (year % 100)) || + !(year % 400)); + + if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) || (wtime.tm_mday < 1)) + return -EINVAL; + + if (wtime.tm_mday < 0 || wtime.tm_mday > + (days_in_mo[wtime.tm_mon] + ((wtime.tm_mon == 1) && leap_yr))) + return -EINVAL; + + if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 || + wtime.tm_min < 0 || wtime.tm_min >= 60 || + wtime.tm_sec < 0 || wtime.tm_sec >= 60) + return -EINVAL; + + return set_rtc_time(&wtime); + } + } + + return -EINVAL; +} + +/* + * We enforce only one user at a time here with the open/close. + * Also clear the previous interrupt data on an open, and clean + * up things on a close. + */ + +int gen_rtc_open(struct inode *inode, struct file *file) +{ + if (gen_rtc_status & RTC_IS_OPEN) + return -EBUSY; + + gen_rtc_status |= RTC_IS_OPEN; + gen_rtc_irq_data = 0; + irq_active = 0; + + return 0; +} + +int gen_rtc_release(struct inode *inode, struct file *file) +{ + /* + * Turn off all interrupts once the device is no longer + * in use and clear the data. + */ + + gen_clear_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE); + + gen_rtc_status &= ~RTC_IS_OPEN; + return 0; +} + + +#ifdef CONFIG_PROC_FS + +/* + * Info exported via "/proc/rtc". + */ + +atic int gen_rtc_proc_output(char *buf) +{ + char *p; + struct rtc_time tm; + unsigned int flags; + struct rtc_pll_info pll; + + p = buf; + + flags = get_rtc_time(&tm); + + p += sprintf(p, + "rtc_time\t: %02d:%02d:%02d\n" + "rtc_date\t: %04d-%02d-%02d\n" + "rtc_epoch\t: %04u\n", + tm.tm_hour, tm.tm_min, tm.tm_sec, + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 1900); + + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + + p += sprintf(p, "alarm\t\t: "); + if (tm.tm_hour <= 24) + p += sprintf(p, "%02d:", tm.tm_hour); + else + p += sprintf(p, "**:"); + + if (tm.tm_min <= 59) + p += sprintf(p, "%02d:", tm.tm_min); + else + p += sprintf(p, "**:"); + + if (tm.tm_sec <= 59) + p += sprintf(p, "%02d\n", tm.tm_sec); + else + p += sprintf(p, "**\n"); + + p += sprintf(p, + "DST_enable\t: %s\n" + "BCD\t\t: %s\n" + "24hr\t\t: %s\n" + "square_wave\t: %s\n" + "alarm_IRQ\t: %s\n" + "update_IRQ\t: %s\n" + "periodic_IRQ\t: %s\n" + "periodic_freq\t: %ld\n" + "batt_status\t: %s\n", + (flags & RTC_DST_EN) ? "yes" : "no", + (flags & RTC_DM_BINARY) ? "no" : "yes", + (flags & RTC_24H) ? "yes" : "no", + (flags & RTC_SQWE) ? "yes" : "no", + (flags & RTC_AIE) ? "yes" : "no", + irq_active ? "yes" : "no", + (flags & RTC_PIE) ? "yes" : "no", + 0L /* freq */, + (flags & RTC_BATT_BAD) ? "bad" : "okay"); + if (!get_rtc_pll(&pll)) + p += sprintf(p, + "PLL adjustment\t: %d\n" + "PLL max +ve adjustment\t: %d\n" + "PLL max -ve adjustment\t: %d\n" + "PLL +ve adjustment factor\t: %d\n" + "PLL -ve adjustment factor\t: %d\n" + "PLL frequency\t: %ld\n", + pll.pll_value, + pll.pll_max, + pll.pll_min, + pll.pll_posmult, + pll.pll_negmult, + pll.pll_clock); + return p - buf; +} + +int gen_rtc_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = gen_rtc_proc_output (page); + if (len <= off+count) *eof = 1; + *start = page + off; + len -= off; + if (len>count) len = count; + if (len<0) len = 0; + return len; +} + +int __init gen_rtc_proc_init(void) +{ + struct proc_dir_entry *r; + + r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL); + if (!r) + return -ENOMEM; + return 0; +} +#else +inline int gen_rtc_proc_init(void) { return 0; } +#endif /* CONFIG_PROC_FS */ + + +/* + * The various file operations we support. + */ + +const struct file_operations gen_rtc_fops = { + .owner = THIS_MODULE, +#ifdef CONFIG_GEN_RTC_X + .read = gen_rtc_read, + .poll = gen_rtc_poll, +#endif + .ioctl = gen_rtc_ioctl, + .open = gen_rtc_open, + .release = gen_rtc_release, +}; + +struct miscdevice rtc_gen_dev = +{ + .minor = RTC_MINOR, + .name = "rtc", + .fops = &gen_rtc_fops, +}; + +int __init rtc_generic_init(void) +{ + int retval; + + printk(KERN_INFO "Generic RTC Driver v%s\n", RTC_VERSION); + + retval = misc_register(&rtc_gen_dev); + if (retval < 0) + return retval; + + retval = gen_rtc_proc_init(); + if (retval) { + misc_deregister(&rtc_gen_dev); + return retval; + } + + return 0; +} + +void __exit rtc_generic_exit(void) +{ + remove_proc_entry ("driver/rtc", NULL); + misc_deregister(&rtc_gen_dev); +} + + +module_init(rtc_generic_init); +module_exit(rtc_generic_exit); + +MODULE_AUTHOR("Richard Zidlicky"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(RTC_MINOR); diff --git a/ddverify/case_studies/char/nwbutton/nwbutton.c b/ddverify/case_studies/char/nwbutton/nwbutton.c new file mode 100644 index 000000000..1e7aa75dc --- /dev/null +++ b/ddverify/case_studies/char/nwbutton/nwbutton.c @@ -0,0 +1,247 @@ +/* + * NetWinder Button Driver- + * Copyright (C) Alex Holden 1998, 1999. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define IRQ_NETWINDER_BUTTON 10 +#define __NWBUTTON_C /* Tell the header file who we are */ +#include "nwbutton.h" + +int button_press_count; /* The count of button presses */ +struct timer_list button_timer; /* Times for the end of a sequence */ +DECLARE_WAIT_QUEUE_HEAD(button_wait_queue); /* Used for blocking read */ +char button_output_buffer[32]; /* Stores data to write out of device */ +int bcount; /* The number of bytes in the buffer */ +int bdelay = BUTTON_DELAY; /* The delay, in jiffies */ +struct button_callback button_callback_list[32]; /* The callback list */ +int callback_count; /* The number of callbacks registered */ +int reboot_count = NUM_PRESSES_REBOOT; /* Number of presses to reboot */ + +/* + * This function is called by other drivers to register a callback function + * to be called when a particular number of button presses occurs. + * The callback list is a static array of 32 entries (I somehow doubt many + * people are ever going to want to register more than 32 different actions + * to be performed by the kernel on different numbers of button presses ;). + * However, if an attempt to register a 33rd entry (perhaps a stuck loop + * somewhere registering the same entry over and over?) it will fail to + * do so and return -ENOMEM. If an attempt is made to register a null pointer, + * it will fail to do so and return -EINVAL. + * Because callbacks can be unregistered at random the list can become + * fragmented, so we need to search through the list until we find the first + * free entry. + * + * FIXME: Has anyone spotted any locking functions int his code recently ?? + */ + +int button_add_callback (void (*callback) (void), int count) +{ + int lp = 0; + if (callback_count == 32) { + return -ENOMEM; + } + if (!callback) { + return -EINVAL; + } + callback_count++; + for (; (button_callback_list [lp].callback); lp++); + button_callback_list [lp].callback = callback; + button_callback_list [lp].count = count; + return 0; +} + +/* + * This function is called by other drivers to deregister a callback function. + * If you attempt to unregister a callback which does not exist, it will fail + * with -EINVAL. If there is more than one entry with the same address, + * because it searches the list from end to beginning, it will unregister the + * last one to be registered first (FILO- First In Last Out). + * Note that this is not neccessarily true if the entries are not submitted + * at the same time, because another driver could have unregistered a callback + * between the submissions creating a gap earlier in the list, which would + * be filled first at submission time. + */ + +int button_del_callback (void (*callback) (void)) +{ + int lp = 31; + if (!callback) { + return -EINVAL; + } + while (lp >= 0) { + if ((button_callback_list [lp].callback) == callback) { + button_callback_list [lp].callback = NULL; + button_callback_list [lp].count = 0; + callback_count--; + return 0; + }; + lp--; + }; + return -EINVAL; +} + +/* + * This function is called by button_sequence_finished to search through the + * list of callback functions, and call any of them whose count argument + * matches the current count of button presses. It starts at the beginning + * of the list and works up to the end. It will refuse to follow a null + * pointer (which should never happen anyway). + */ + +void button_consume_callbacks (int bpcount) +{ + int lp = 0; + for (; lp <= 31; lp++) { + if ((button_callback_list [lp].count) == bpcount) { + if (button_callback_list [lp].callback) { + button_callback_list[lp].callback(); + } + } + } +} + +/* + * This function is called when the button_timer times out. + * ie. When you don't press the button for bdelay jiffies, this is taken to + * mean you have ended the sequence of key presses, and this function is + * called to wind things up (write the press_count out to /dev/button, call + * any matching registered function callbacks, initiate reboot, etc.). + */ + +void button_sequence_finished (unsigned long parameters) +{ +#ifdef CONFIG_NWBUTTON_REBOOT /* Reboot using button is enabled */ + if (button_press_count == reboot_count) + kill_cad_pid(SIGINT, 1); /* Ask init to reboot us */ +#endif /* CONFIG_NWBUTTON_REBOOT */ + button_consume_callbacks (button_press_count); + bcount = sprintf (button_output_buffer, "%d\n", button_press_count); + button_press_count = 0; /* Reset the button press counter */ + wake_up_interruptible (&button_wait_queue); +} + +/* + * This handler is called when the orange button is pressed (GPIO 10 of the + * SuperIO chip, which maps to logical IRQ 26). If the press_count is 0, + * this is the first press, so it starts a timer and increments the counter. + * If it is higher than 0, it deletes the old timer, starts a new one, and + * increments the counter. + */ + +irqreturn_t button_handler (int irq, void *dev_id) +{ + if (button_press_count) { + del_timer (&button_timer); + } + button_press_count++; + init_timer (&button_timer); + button_timer.function = button_sequence_finished; + button_timer.expires = (jiffies + bdelay); + add_timer (&button_timer); + + return IRQ_HANDLED; +} + +/* + * This function is called when a user space program attempts to read + * /dev/nwbutton. It puts the device to sleep on the wait queue until + * button_sequence_finished writes some data to the buffer and flushes + * the queue, at which point it writes the data out to the device and + * returns the number of characters it has written. This function is + * reentrant, so that many processes can be attempting to read from the + * device at any one time. + */ + +int button_read (struct file *filp, char __user *buffer, + size_t count, loff_t *ppos) +{ + interruptible_sleep_on (&button_wait_queue); + return (copy_to_user (buffer, &button_output_buffer, bcount)) + ? -EFAULT : bcount; +} + +/* + * This structure is the file operations structure, which specifies what + * callbacks functions the kernel should call when a user mode process + * attempts to perform these operations on the device. + */ + +const struct file_operations button_fops = { + .owner = THIS_MODULE, + .read = button_read, +}; + +/* + * This structure is the misc device structure, which specifies the minor + * device number (158 in this case), the name of the device (for /proc/misc), + * and the address of the above file operations structure. + */ + +struct miscdevice button_misc_device = { + BUTTON_MINOR, + "nwbutton", + &button_fops, +}; + +/* + * This function is called to initialise the driver, either from misc.c at + * bootup if the driver is compiled into the kernel, or from init_module + * below at module insert time. It attempts to register the device node + * and the IRQ and fails with a warning message if either fails, though + * neither ever should because the device number and IRQ are unique to + * this driver. + */ + +int __init nwbutton_init(void) +{ + if (!machine_is_netwinder()) + return -ENODEV; + + printk (KERN_INFO "NetWinder Button Driver Version %s (C) Alex Holden " + " 1998.\n", VERSION); + + if (misc_register (&button_misc_device)) { + printk (KERN_WARNING "nwbutton: Couldn't register device 10, " + "%d.\n", BUTTON_MINOR); + return -EBUSY; + } + + if (request_irq (IRQ_NETWINDER_BUTTON, button_handler, IRQF_DISABLED, + "nwbutton", NULL)) { + printk (KERN_WARNING "nwbutton: IRQ %d is not free.\n", + IRQ_NETWINDER_BUTTON); + misc_deregister (&button_misc_device); + return -EIO; + } + return 0; +} + +void __exit nwbutton_exit (void) +{ + free_irq (IRQ_NETWINDER_BUTTON, NULL); + misc_deregister (&button_misc_device); +} + + +MODULE_AUTHOR("Alex Holden"); +MODULE_LICENSE("GPL"); + +module_init(nwbutton_init); +module_exit(nwbutton_exit); diff --git a/ddverify/case_studies/char/nwbutton/nwbutton.h b/ddverify/case_studies/char/nwbutton/nwbutton.h new file mode 100644 index 000000000..69e4510ce --- /dev/null +++ b/ddverify/case_studies/char/nwbutton/nwbutton.h @@ -0,0 +1,40 @@ +#ifndef __NWBUTTON_H +#define __NWBUTTON_H + +/* + * NetWinder Button Driver- + * Copyright (C) Alex Holden 1998, 1999. + */ + +#ifdef __NWBUTTON_C /* Actually compiling the driver itself */ + +/* Various defines: */ + +#define NUM_PRESSES_REBOOT 2 /* How many presses to activate shutdown */ +#define BUTTON_DELAY 30 /* How many jiffies for sequence to end */ +#define VERSION "0.3" /* Driver version number */ +#define BUTTON_MINOR 158 /* Major 10, Minor 158, /dev/nwbutton */ + +/* Structure definitions: */ + +struct button_callback { + void (*callback) (void); + int count; +}; + +/* Function prototypes: */ + +void button_sequence_finished (unsigned long parameters); +irqreturn_t button_handler (int irq, void *dev_id); +int button_init (void); +int button_add_callback (void (*callback) (void), int count); +int button_del_callback (void (*callback) (void)); +void button_consume_callbacks (int bpcount); + +#else /* Not compiling the driver itself */ + +extern int button_add_callback (void (*callback) (void), int count); +extern int button_del_callback (void (*callback) (void)); + +#endif /* __NWBUTTON_C */ +#endif /* __NWBUTTON_H */ diff --git a/ddverify/case_studies/char/toshiba/toshiba.c b/ddverify/case_studies/char/toshiba/toshiba.c new file mode 100644 index 000000000..618b733c4 --- /dev/null +++ b/ddverify/case_studies/char/toshiba/toshiba.c @@ -0,0 +1,527 @@ +/* toshiba.c -- Linux driver for accessing the SMM on Toshiba laptops + * + * Copyright (c) 1996-2001 Jonathan A. Buzzard (jonathan@buzzard.org.uk) + * + * Valuable assistance and patches from: + * Tom May + * Rob Napier + * + * Fn status port numbers for machine ID's courtesy of + * 0xfc02: Scott Eisert + * 0xfc04: Steve VanDevender + * 0xfc08: Garth Berry + * 0xfc0a: Egbert Eich + * 0xfc10: Andrew Lofthouse + * 0xfc11: Spencer Olson + * 0xfc13: Claudius Frankewitz + * 0xfc15: Tom May + * 0xfc17: Dave Konrad + * 0xfc1a: George Betzos + * 0xfc1b: Munemasa Wada + * 0xfc1d: Arthur Liu + * 0xfc5a: Jacques L'helgoualc'h + * 0xfcd1: Mr. Dave Konrad + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * This code is covered by the GNU GPL and you are free to make any + * changes you wish to it under the terms of the license. However the + * code has the potential to render your computer and/or someone else's + * unusable. Please proceed with care when modifying the code. + * + * Note: Unfortunately the laptop hardware can close the System Configuration + * Interface on it's own accord. It is therefore necessary for *all* + * programs using this driver to be aware that *any* SCI call can fail at + * *any* time. It is up to any program to be aware of this eventuality + * and take appropriate steps. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * The information used to write this driver has been obtained by reverse + * engineering the software supplied by Toshiba for their portable computers in + * strict accordance with the European Council Directive 92/250/EEC on the legal + * protection of computer programs, and it's implementation into English Law by + * the Copyright (Computer Programs) Regulations 1992 (S.I. 1992 No.3233). + * + */ + +#define TOSH_VERSION "1.11 26/9/2001" +#define TOSH_DEBUG 0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "toshiba.h" + +#define TOSH_MINOR_DEV 181 + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Jonathan Buzzard "); +MODULE_DESCRIPTION("Toshiba laptop SMM driver"); +MODULE_SUPPORTED_DEVICE("toshiba"); + +int tosh_fn; +module_param_named(fn, tosh_fn, int, 0); +MODULE_PARM_DESC(fn, "User specified Fn key detection port"); + +int tosh_id; +int tosh_bios; +int tosh_date; +int tosh_sci; +int tosh_fan; + +int tosh_ioctl(struct inode *, struct file *, unsigned int, + unsigned long); + + +const struct file_operations tosh_fops = { + .owner = THIS_MODULE, + .ioctl = tosh_ioctl, +}; + +struct miscdevice tosh_device = { + TOSH_MINOR_DEV, + "toshiba", + &tosh_fops +}; + +/* + * Read the Fn key status + */ +#ifdef CONFIG_PROC_FS +int tosh_fn_status(void) +{ + unsigned char scan; + unsigned long flags; + + if (tosh_fn!=0) { + scan = inb(tosh_fn); + } else { + local_irq_save(flags); + outb(0x8e, 0xe4); + scan = inb(0xe5); + local_irq_restore(flags); + } + + return (int) scan; +} +#endif + + +/* + * For the Portage 610CT and the Tecra 700CS/700CDT emulate the HCI fan function + */ +int tosh_emulate_fan(SMMRegisters *regs) +{ + unsigned long eax,ecx,flags; + unsigned char al; + + eax = regs->eax & 0xff00; + ecx = regs->ecx & 0xffff; + + /* Portage 610CT */ + + if (tosh_id==0xfccb) { + if (eax==0xfe00) { + /* fan status */ + local_irq_save(flags); + outb(0xbe, 0xe4); + al = inb(0xe5); + local_irq_restore(flags); + regs->eax = 0x00; + regs->ecx = (unsigned int) (al & 0x01); + } + if ((eax==0xff00) && (ecx==0x0000)) { + /* fan off */ + local_irq_save(flags); + outb(0xbe, 0xe4); + al = inb(0xe5); + outb(0xbe, 0xe4); + outb (al | 0x01, 0xe5); + local_irq_restore(flags); + regs->eax = 0x00; + regs->ecx = 0x00; + } + if ((eax==0xff00) && (ecx==0x0001)) { + /* fan on */ + local_irq_save(flags); + outb(0xbe, 0xe4); + al = inb(0xe5); + outb(0xbe, 0xe4); + outb(al & 0xfe, 0xe5); + local_irq_restore(flags); + regs->eax = 0x00; + regs->ecx = 0x01; + } + } + + /* Tecra 700CS/CDT */ + + if (tosh_id==0xfccc) { + if (eax==0xfe00) { + /* fan status */ + local_irq_save(flags); + outb(0xe0, 0xe4); + al = inb(0xe5); + local_irq_restore(flags); + regs->eax = 0x00; + regs->ecx = al & 0x01; + } + if ((eax==0xff00) && (ecx==0x0000)) { + /* fan off */ + local_irq_save(flags); + outb(0xe0, 0xe4); + al = inb(0xe5); + outw(0xe0 | ((al & 0xfe) << 8), 0xe4); + local_irq_restore(flags); + regs->eax = 0x00; + regs->ecx = 0x00; + } + if ((eax==0xff00) && (ecx==0x0001)) { + /* fan on */ + local_irq_save(flags); + outb(0xe0, 0xe4); + al = inb(0xe5); + outw(0xe0 | ((al | 0x01) << 8), 0xe4); + local_irq_restore(flags); + regs->eax = 0x00; + regs->ecx = 0x01; + } + } + + return 0; +} + + +/* + * Put the laptop into System Management Mode + */ +int tosh_smm(SMMRegisters *regs) +{ + int eax; + + asm ("# load the values into the registers\n\t" \ + "pushl %%eax\n\t" \ + "movl 0(%%eax),%%edx\n\t" \ + "push %%edx\n\t" \ + "movl 4(%%eax),%%ebx\n\t" \ + "movl 8(%%eax),%%ecx\n\t" \ + "movl 12(%%eax),%%edx\n\t" \ + "movl 16(%%eax),%%esi\n\t" \ + "movl 20(%%eax),%%edi\n\t" \ + "popl %%eax\n\t" \ + "# call the System Management mode\n\t" \ + "inb $0xb2,%%al\n\t" + "# fill out the memory with the values in the registers\n\t" \ + "xchgl %%eax,(%%esp)\n\t" + "movl %%ebx,4(%%eax)\n\t" \ + "movl %%ecx,8(%%eax)\n\t" \ + "movl %%edx,12(%%eax)\n\t" \ + "movl %%esi,16(%%eax)\n\t" \ + "movl %%edi,20(%%eax)\n\t" \ + "popl %%edx\n\t" \ + "movl %%edx,0(%%eax)\n\t" \ + "# setup the return value to the carry flag\n\t" \ + "lahf\n\t" \ + "shrl $8,%%eax\n\t" \ + "andl $1,%%eax\n" \ + : "=a" (eax) + : "a" (regs) + : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); + + return eax; +} + + +int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, + unsigned long arg) +{ + SMMRegisters regs; + SMMRegisters __user *argp = (SMMRegisters __user *)arg; + unsigned short ax,bx; + int err; + + if (!argp) + return -EINVAL; + + if (copy_from_user(®s, argp, sizeof(SMMRegisters))) + return -EFAULT; + + switch (cmd) { + case TOSH_SMM: + ax = regs.eax & 0xff00; + bx = regs.ebx & 0xffff; + /* block HCI calls to read/write memory & PCI devices */ + if (((ax==0xff00) || (ax==0xfe00)) && (bx>0x0069)) + return -EINVAL; + + /* do we need to emulate the fan ? */ + if (tosh_fan==1) { + if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { + err = tosh_emulate_fan(®s); + break; + } + } + err = tosh_smm(®s); + break; + default: + return -EINVAL; + } + + if (copy_to_user(argp, ®s, sizeof(SMMRegisters))) + return -EFAULT; + + return (err==0) ? 0:-EINVAL; +} + + +/* + * Print the information for /proc/toshiba + */ +#ifdef CONFIG_PROC_FS +int tosh_get_info(char *buffer, char **start, off_t fpos, int length) +{ + char *temp; + int key; + + temp = buffer; + key = tosh_fn_status(); + + /* Arguments + 0) Linux driver version (this will change if format changes) + 1) Machine ID + 2) SCI version + 3) BIOS version (major, minor) + 4) BIOS date (in SCI date format) + 5) Fn Key status + */ + + temp += sprintf(temp, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n", + tosh_id, + (tosh_sci & 0xff00)>>8, + tosh_sci & 0xff, + (tosh_bios & 0xff00)>>8, + tosh_bios & 0xff, + tosh_date, + key); + + return temp-buffer; +} +#endif + + +/* + * Determine which port to use for the Fn key status + */ +void tosh_set_fn_port(void) +{ + switch (tosh_id) { + case 0xfc02: case 0xfc04: case 0xfc09: case 0xfc0a: case 0xfc10: + case 0xfc11: case 0xfc13: case 0xfc15: case 0xfc1a: case 0xfc1b: + case 0xfc5a: + tosh_fn = 0x62; + break; + case 0xfc08: case 0xfc17: case 0xfc1d: case 0xfcd1: case 0xfce0: + case 0xfce2: + tosh_fn = 0x68; + break; + default: + tosh_fn = 0x00; + break; + } + + return; +} + + +/* + * Get the machine identification number of the current model + */ +int tosh_get_machine_id(void __iomem *bios) +{ + int id; + SMMRegisters regs; + unsigned short bx,cx; + unsigned long address; + + id = (0x100*(int) readb(bios+0xfffe))+((int) readb(bios+0xfffa)); + + /* do we have a SCTTable machine identication number on our hands */ + + if (id==0xfc2f) { + + /* start by getting a pointer into the BIOS */ + + regs.eax = 0xc000; + regs.ebx = 0x0000; + regs.ecx = 0x0000; + tosh_smm(®s); + bx = (unsigned short) (regs.ebx & 0xffff); + + /* At this point in the Toshiba routines under MS Windows + the bx register holds 0xe6f5. However my code is producing + a different value! For the time being I will just fudge the + value. This has been verified on a Satellite Pro 430CDT, + Tecra 750CDT, Tecra 780DVD and Satellite 310CDT. */ +#if TOSH_DEBUG + printk("toshiba: debugging ID ebx=0x%04x\n", regs.ebx); +#endif + bx = 0xe6f5; + + /* now twiddle with our pointer a bit */ + + address = bx; + cx = readw(bios + address); + address = 9+bx+cx; + cx = readw(bios + address); + address = 0xa+cx; + cx = readw(bios + address); + + /* now construct our machine identification number */ + + id = ((cx & 0xff)<<8)+((cx & 0xff00)>>8); + } + + return id; +} + + +/* + * Probe for the presence of a Toshiba laptop + * + * returns and non-zero if unable to detect the presence of a Toshiba + * laptop, otherwise zero and determines the Machine ID, BIOS version and + * date, and SCI version. + */ +int tosh_probe(void) +{ + int i,major,minor,day,year,month,flag; + unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 }; + SMMRegisters regs; + void __iomem *bios = ioremap(0xf0000, 0x10000); + + if (!bios) + return -ENOMEM; + + /* extra sanity check for the string "TOSHIBA" in the BIOS because + some machines that are not Toshiba's pass the next test */ + + for (i=0;i<7;i++) { + if (readb(bios+0xe010+i)!=signature[i]) { + printk("toshiba: not a supported Toshiba laptop\n"); + iounmap(bios); + return -ENODEV; + } + } + + /* call the Toshiba SCI support check routine */ + + regs.eax = 0xf0f0; + regs.ebx = 0x0000; + regs.ecx = 0x0000; + flag = tosh_smm(®s); + + /* if this is not a Toshiba laptop carry flag is set and ah=0x86 */ + + if ((flag==1) || ((regs.eax & 0xff00)==0x8600)) { + printk("toshiba: not a supported Toshiba laptop\n"); + iounmap(bios); + return -ENODEV; + } + + /* if we get this far then we are running on a Toshiba (probably)! */ + + tosh_sci = regs.edx & 0xffff; + + /* next get the machine ID of the current laptop */ + + tosh_id = tosh_get_machine_id(bios); + + /* get the BIOS version */ + + major = readb(bios+0xe009)-'0'; + minor = ((readb(bios+0xe00b)-'0')*10)+(readb(bios+0xe00c)-'0'); + tosh_bios = (major*0x100)+minor; + + /* get the BIOS date */ + + day = ((readb(bios+0xfff5)-'0')*10)+(readb(bios+0xfff6)-'0'); + month = ((readb(bios+0xfff8)-'0')*10)+(readb(bios+0xfff9)-'0'); + year = ((readb(bios+0xfffb)-'0')*10)+(readb(bios+0xfffc)-'0'); + tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6) + | ((day & 0x1f)<<1); + + + /* in theory we should check the ports we are going to use for the + fn key detection (and the fan on the Portage 610/Tecra700), and + then request them to stop other drivers using them. However as + the keyboard driver grabs 0x60-0x6f and the pic driver grabs + 0xa0-0xbf we can't. We just have to live dangerously and use the + ports anyway, oh boy! */ + + /* do we need to emulate the fan? */ + + if ((tosh_id==0xfccb) || (tosh_id==0xfccc)) + tosh_fan = 1; + + iounmap(bios); + + return 0; +} + +int __init toshiba_init(void) +{ + int retval; + /* are we running on a Toshiba laptop */ + + if (tosh_probe()) + return -ENODEV; + + printk(KERN_INFO "Toshiba System Managment Mode driver v" TOSH_VERSION "\n"); + + /* set the port to use for Fn status if not specified as a parameter */ + if (tosh_fn==0x00) + tosh_set_fn_port(); + + /* register the device file */ + retval = misc_register(&tosh_device); + if (retval < 0) + return retval; + +#ifdef CONFIG_PROC_FS + /* register the proc entry */ + if (create_proc_info_entry("toshiba", 0, NULL, tosh_get_info) == NULL) { + misc_deregister(&tosh_device); + return -ENOMEM; + } +#endif + + return 0; +} + +void __exit toshiba_exit(void) +{ + remove_proc_entry("toshiba", NULL); + misc_deregister(&tosh_device); +} + +module_init(toshiba_init); +module_exit(toshiba_exit); diff --git a/ddverify/case_studies/char/toshiba/toshiba.h b/ddverify/case_studies/char/toshiba/toshiba.h new file mode 100644 index 000000000..916e5e3a6 --- /dev/null +++ b/ddverify/case_studies/char/toshiba/toshiba.h @@ -0,0 +1,36 @@ +/* toshiba.h -- Linux driver for accessing the SMM on Toshiba laptops + * + * Copyright (c) 1996-2000 Jonathan A. Buzzard (jonathan@buzzard.org.uk) + * + * Thanks to Juergen Heinzl for the pointers + * on making sure the structure is aligned and packed. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#ifndef _LINUX_TOSHIBA_H +#define _LINUX_TOSHIBA_H + +#define TOSH_PROC "/proc/toshiba" +#define TOSH_DEVICE "/dev/toshiba" +#define TOSH_SMM _IOWR('t', 0x90, int) /* broken: meant 24 bytes */ + +typedef struct { + unsigned int eax; + unsigned int ebx __attribute__ ((packed)); + unsigned int ecx __attribute__ ((packed)); + unsigned int edx __attribute__ ((packed)); + unsigned int esi __attribute__ ((packed)); + unsigned int edi __attribute__ ((packed)); +} SMMRegisters; + +#endif diff --git a/ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.c b/ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.c new file mode 100644 index 000000000..e0627d797 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.c @@ -0,0 +1,571 @@ +/* + * i8xx_tco: TCO timer driver for i8xx chipsets + * + * (c) Copyright 2000 kernel concepts , All Rights Reserved. + * http://www.kernelconcepts.de + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither kernel concepts nor Nils Faerber admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. + * + * (c) Copyright 2000 kernel concepts + * developed for + * Jentro AG, Haar/Munich (Germany) + * + * TCO timer driver for i8xx chipsets + * based on softdog.c by Alan Cox + * + * The TCO timer is implemented in the following I/O controller hubs: + * (See the intel documentation on http://developer.intel.com.) + * 82801AA (ICH) : document number 290655-003, 290677-014, + * 82801AB (ICHO) : document number 290655-003, 290677-014, + * 82801BA (ICH2) : document number 290687-002, 298242-027, + * 82801BAM (ICH2-M) : document number 290687-002, 298242-027, + * 82801CA (ICH3-S) : document number 290733-003, 290739-013, + * 82801CAM (ICH3-M) : document number 290716-001, 290718-007, + * 82801DB (ICH4) : document number 290744-001, 290745-020, + * 82801DBM (ICH4-M) : document number 252337-001, 252663-005, + * 82801E (C-ICH) : document number 273599-001, 273645-002, + * 82801EB (ICH5) : document number 252516-001, 252517-003, + * 82801ER (ICH5R) : document number 252516-001, 252517-003, + * + * 20000710 Nils Faerber + * Initial Version 0.01 + * 20000728 Nils Faerber + * 0.02 Fix for SMI_EN->TCO_EN bit, some cleanups + * 20011214 Matt Domsch + * 0.03 Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT + * Didn't add timeout option as i810_margin already exists. + * 20020224 Joel Becker, Wim Van Sebroeck + * 0.04 Support for 82801CA(M) chipset, timer margin needs to be > 3, + * add support for WDIOC_SETTIMEOUT and WDIOC_GETTIMEOUT. + * 20020412 Rob Radez , Wim Van Sebroeck + * 0.05 Fix possible timer_alive race, add expect close support, + * clean up ioctls (WDIOC_GETSTATUS, WDIOC_GETBOOTSTATUS and + * WDIOC_SETOPTIONS), made i810tco_getdevice __init, + * removed boot_status, removed tco_timer_read, + * added support for 82801DB and 82801E chipset, + * added support for 82801EB and 8280ER chipset, + * general cleanup. + * 20030921 Wim Van Sebroeck + * 0.06 change i810_margin to heartbeat, use module_param, + * added notify system support, renamed module to i8xx_tco. + * 20050128 Wim Van Sebroeck + * 0.07 Added support for the ICH4-M, ICH6, ICH6R, ICH6-M, ICH6W and ICH6RW + * chipsets. Also added support for the "undocumented" ICH7 chipset. + * 20050807 Wim Van Sebroeck + * 0.08 Make sure that the watchdog is only "armed" when started. + * (Kernel Bug 4251) + * 20060416 Wim Van Sebroeck + * 0.09 Remove support for the ICH6, ICH6R, ICH6-M, ICH6W and ICH6RW and + * ICH7 chipsets. (See Kernel Bug 6031 - other code will support these + * chipsets) + */ + +/* + * Includes, defines, variables, module parameters, ... + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "i8xx_tco.h" + +/* Module and version information */ +#define TCO_VERSION "0.09" +#define TCO_MODULE_NAME "i8xx TCO timer" +#define TCO_DRIVER_NAME TCO_MODULE_NAME ", v" TCO_VERSION +#define PFX TCO_MODULE_NAME ": " + +/* internal variables */ +static unsigned int ACPIBASE; +static spinlock_t tco_lock; /* Guards the hardware */ +static unsigned long timer_alive; +static char tco_expect_close; +static struct pci_dev *i8xx_tco_pci; + +/* module parameters */ +#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (2 0 = The TCO timer is enabled to count */ + val = inb (TCO1_CNT + 1); + val &= 0xf7; + outb (val, TCO1_CNT + 1); + val = inb (TCO1_CNT + 1); + + spin_unlock(&tco_lock); + + if (val & 0x08) + return -1; + return 0; +} + +static int tco_timer_stop (void) +{ + unsigned char val, val1; + + spin_lock(&tco_lock); + /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */ + val = inb (TCO1_CNT + 1); + val |= 0x08; + outb (val, TCO1_CNT + 1); + val = inb (TCO1_CNT + 1); + + /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ + pci_read_config_byte (i8xx_tco_pci, 0xd4, &val1); + val1 |= 0x02; + pci_write_config_byte (i8xx_tco_pci, 0xd4, val1); + + spin_unlock(&tco_lock); + + if ((val & 0x08) == 0) + return -1; + return 0; +} + +static int tco_timer_keepalive (void) +{ + spin_lock(&tco_lock); + /* Reload the timer by writing to the TCO Timer Reload register */ + outb (0x01, TCO1_RLD); + spin_unlock(&tco_lock); + return 0; +} + +static int tco_timer_set_heartbeat (int t) +{ + unsigned char val; + unsigned char tmrval; + + tmrval = seconds_to_ticks(t); + /* from the specs: */ + /* "Values of 0h-3h are ignored and should not be attempted" */ + if (tmrval > 0x3f || tmrval < 0x04) + return -EINVAL; + + /* Write new heartbeat to watchdog */ + spin_lock(&tco_lock); + val = inb (TCO1_TMR); + val &= 0xc0; + val |= tmrval; + outb (val, TCO1_TMR); + val = inb (TCO1_TMR); + spin_unlock(&tco_lock); + + if ((val & 0x3f) != tmrval) + return -EINVAL; + + heartbeat = t; + return 0; +} + +static int tco_timer_get_timeleft (int *time_left) +{ + unsigned char val; + + spin_lock(&tco_lock); + + /* read the TCO Timer */ + val = inb (TCO1_RLD); + val &= 0x3f; + + spin_unlock(&tco_lock); + + *time_left = (int)((val * 6) / 10); + + return 0; +} + +/* + * /dev/watchdog handling + */ + +static int i8xx_tco_open (struct inode *inode, struct file *file) +{ + /* /dev/watchdog can only be opened once */ + if (test_and_set_bit(0, &timer_alive)) + return -EBUSY; + + /* + * Reload and activate timer + */ + tco_timer_keepalive (); + tco_timer_start (); + return nonseekable_open(inode, file); +} + +static int i8xx_tco_release (struct inode *inode, struct file *file) +{ + /* + * Shut off the timer. + */ + if (tco_expect_close == 42) { + tco_timer_stop (); + } else { + printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); + tco_timer_keepalive (); + } + clear_bit(0, &timer_alive); + tco_expect_close = 0; + return 0; +} + +static ssize_t i8xx_tco_write (struct file *file, const char __user *data, + size_t len, loff_t * ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if (len) { + if (!nowayout) { + size_t i; + + /* note: just in case someone wrote the magic character + * five months ago... */ + tco_expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for (i = 0; i != len; i++) { + char c; + if(get_user(c, data+i)) + return -EFAULT; + if (c == 'V') + tco_expect_close = 42; + } + } + + /* someone wrote to us, we should reload the timer */ + tco_timer_keepalive (); + } + return len; +} + +static int i8xx_tco_ioctl (struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int new_options, retval = -EINVAL; + int new_heartbeat; + int time_left; + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | + WDIOF_KEEPALIVEPING | + WDIOF_MAGICCLOSE, + .firmware_version = 0, + .identity = TCO_MODULE_NAME, + }; + + switch (cmd) { + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, + sizeof (ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + return put_user (0, p); + + case WDIOC_KEEPALIVE: + tco_timer_keepalive (); + return 0; + + case WDIOC_SETOPTIONS: + { + if (get_user (new_options, p)) + return -EFAULT; + + if (new_options & WDIOS_DISABLECARD) { + tco_timer_stop (); + retval = 0; + } + + if (new_options & WDIOS_ENABLECARD) { + tco_timer_keepalive (); + tco_timer_start (); + retval = 0; + } + + return retval; + } + + case WDIOC_SETTIMEOUT: + { + if (get_user(new_heartbeat, p)) + return -EFAULT; + + if (tco_timer_set_heartbeat(new_heartbeat)) + return -EINVAL; + + tco_timer_keepalive (); + /* Fall */ + } + + case WDIOC_GETTIMEOUT: + return put_user(heartbeat, p); + + case WDIOC_GETTIMELEFT: + { + if (tco_timer_get_timeleft(&time_left)) + return -EINVAL; + + return put_user(time_left, p); + } + + default: + return -ENOTTY; + } +} + +/* + * Notify system + */ + +static int i8xx_tco_notify_sys (struct notifier_block *this, unsigned long code, void *unused) +{ + if (code==SYS_DOWN || code==SYS_HALT) { + /* Turn the WDT off */ + tco_timer_stop (); + } + + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + +static const struct file_operations i8xx_tco_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = i8xx_tco_write, + .ioctl = i8xx_tco_ioctl, + .open = i8xx_tco_open, + .release = i8xx_tco_release, +}; + +static struct miscdevice i8xx_tco_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &i8xx_tco_fops, +}; + +static struct notifier_block i8xx_tco_notifier = { + .notifier_call = i8xx_tco_notify_sys, +}; + +/* + * Data for PCI driver interface + * + * This data only exists for exporting the supported + * PCI ids via MODULE_DEVICE_TABLE. We do not actually + * register a pci_driver, because someone else might one day + * want to register another driver on the same PCI id. + */ +static struct pci_device_id i8xx_tco_pci_tbl[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_10) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_0) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1) }, + { }, /* End of list */ +}; +MODULE_DEVICE_TABLE (pci, i8xx_tco_pci_tbl); + +/* + * Init & exit routines + */ + +static unsigned char __init i8xx_tco_getdevice (void) +{ + struct pci_dev *dev = NULL; + u8 val1, val2; + u16 badr; + /* + * Find the PCI device + */ + + for_each_pci_dev(dev) + if (pci_match_id(i8xx_tco_pci_tbl, dev)) { + i8xx_tco_pci = dev; + break; + } + + if (i8xx_tco_pci) { + /* + * Find the ACPI base I/O address which is the base + * for the TCO registers (TCOBASE=ACPIBASE + 0x60) + * ACPIBASE is bits [15:7] from 0x40-0x43 + */ + pci_read_config_byte (i8xx_tco_pci, 0x40, &val1); + pci_read_config_byte (i8xx_tco_pci, 0x41, &val2); + badr = ((val2 << 1) | (val1 >> 7)) << 7; + ACPIBASE = badr; + /* Something's wrong here, ACPIBASE has to be set */ + if (badr == 0x0001 || badr == 0x0000) { + printk (KERN_ERR PFX "failed to get TCOBASE address\n"); + pci_dev_put(i8xx_tco_pci); + return 0; + } + + /* Check chipset's NO_REBOOT bit */ + pci_read_config_byte (i8xx_tco_pci, 0xd4, &val1); + if (val1 & 0x02) { + val1 &= 0xfd; + pci_write_config_byte (i8xx_tco_pci, 0xd4, val1); + pci_read_config_byte (i8xx_tco_pci, 0xd4, &val1); + if (val1 & 0x02) { + printk (KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); + pci_dev_put(i8xx_tco_pci); + return 0; /* Cannot reset NO_REBOOT bit */ + } + } + /* Disable reboots untill the watchdog starts */ + val1 |= 0x02; + pci_write_config_byte (i8xx_tco_pci, 0xd4, val1); + + /* Set the TCO_EN bit in SMI_EN register */ + if (!request_region (SMI_EN + 1, 1, "i8xx TCO")) { + printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", + SMI_EN + 1); + pci_dev_put(i8xx_tco_pci); + return 0; + } + val1 = inb (SMI_EN + 1); + val1 &= 0xdf; + outb (val1, SMI_EN + 1); + release_region (SMI_EN + 1, 1); + return 1; + } + return 0; +} + +static int __init watchdog_init (void) +{ + int ret; + + spin_lock_init(&tco_lock); + + /* Check whether or not the hardware watchdog is there */ + if (!i8xx_tco_getdevice () || i8xx_tco_pci == NULL) + return -ENODEV; + + if (!request_region (TCOBASE, 0x10, "i8xx TCO")) { + printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", + TCOBASE); + ret = -EIO; + goto out; + } + + /* Clear out the (probably old) status */ + outb (0, TCO1_STS); + outb (3, TCO2_STS); + + /* Check that the heartbeat value is within it's range ; if not reset to the default */ + if (tco_timer_set_heartbeat (heartbeat)) { + heartbeat = WATCHDOG_HEARTBEAT; + tco_timer_set_heartbeat (heartbeat); + printk(KERN_INFO PFX "heartbeat value must be 2, All Rights Reserved. + * http://www.kernelconcepts.de + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither kernel concepts nor Nils Faerber admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. + * + * (c) Copyright 2000 kernel concepts + * developed for + * Jentro AG, Haar/Munich (Germany) + * + * TCO timer driver for i8xx chipsets + * based on softdog.c by Alan Cox + * + * For history and the complete list of supported I/O Controller Hub's + * see i8xx_tco.c + */ + + +/* + * Some address definitions for the TCO + */ + +#define TCOBASE ACPIBASE + 0x60 /* TCO base address */ +#define TCO1_RLD TCOBASE + 0x00 /* TCO Timer Reload and Current Value */ +#define TCO1_TMR TCOBASE + 0x01 /* TCO Timer Initial Value */ +#define TCO1_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */ +#define TCO1_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */ +#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */ +#define TCO2_STS TCOBASE + 0x06 /* TCO2 Status Register */ +#define TCO1_CNT TCOBASE + 0x08 /* TCO1 Control Register */ +#define TCO2_CNT TCOBASE + 0x0a /* TCO2 Control Register */ + +#define SMI_EN ACPIBASE + 0x30 /* SMI Control and Enable Register */ diff --git a/ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.c b/ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.c new file mode 100644 index 000000000..c1ed209a1 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.c @@ -0,0 +1,346 @@ +/* + * IB700 Single Board Computer WDT driver + * + * (c) Copyright 2001 Charles Howes + * + * Based on advantechwdt.c which is based on acquirewdt.c which + * is based on wdt.c. + * + * (c) Copyright 2000-2001 Marek Michalkiewicz + * + * Based on acquirewdt.c which is based on wdt.c. + * Original copyright messages: + * + * (c) Copyright 1996 Alan Cox , All Rights Reserved. + * http://www.redhat.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. + * + * (c) Copyright 1995 Alan Cox + * + * 14-Dec-2001 Matt Domsch + * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT + * Added timeout module option to override default + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static unsigned long ibwdt_is_open; +static spinlock_t ibwdt_lock; +static char expect_close; + +#define PFX "ib700wdt: " + +/* + * + * Watchdog Timer Configuration + * + * The function of the watchdog timer is to reset the system + * automatically and is defined at I/O port 0443H. To enable the + * watchdog timer and allow the system to reset, write I/O port 0443H. + * To disable the timer, write I/O port 0441H for the system to stop the + * watchdog function. The timer has a tolerance of 20% for its + * intervals. + * + * The following describes how the timer should be programmed. + * + * Enabling Watchdog: + * MOV AX,000FH (Choose the values from 0 to F) + * MOV DX,0443H + * OUT DX,AX + * + * Disabling Watchdog: + * MOV AX,000FH (Any value is fine.) + * MOV DX,0441H + * OUT DX,AX + * + * Watchdog timer control table: + * Level Value Time/sec | Level Value Time/sec + * 1 F 0 | 9 7 16 + * 2 E 2 | 10 6 18 + * 3 D 4 | 11 5 20 + * 4 C 6 | 12 4 22 + * 5 B 8 | 13 3 24 + * 6 A 10 | 14 2 26 + * 7 9 12 | 15 1 28 + * 8 8 14 | 16 0 30 + * + */ + +static int wd_times[] = { + 30, /* 0x0 */ + 28, /* 0x1 */ + 26, /* 0x2 */ + 24, /* 0x3 */ + 22, /* 0x4 */ + 20, /* 0x5 */ + 18, /* 0x6 */ + 16, /* 0x7 */ + 14, /* 0x8 */ + 12, /* 0x9 */ + 10, /* 0xA */ + 8, /* 0xB */ + 6, /* 0xC */ + 4, /* 0xD */ + 2, /* 0xE */ + 0, /* 0xF */ +}; + +#define WDT_STOP 0x441 +#define WDT_START 0x443 + +/* Default timeout */ +#define WD_TIMO 0 /* 30 seconds +/- 20%, from table */ + +static int wd_margin = WD_TIMO; + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + + +/* + * Kernel methods. + */ + +static void +ibwdt_ping(void) +{ + /* Write a watchdog value */ + outb_p(wd_margin, WDT_START); +} + +static ssize_t +ibwdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) +{ + if (count) { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + expect_close = 0; + + for (i = 0; i != count; i++) { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + ibwdt_ping(); + } + return count; +} + +static int +ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + int i, new_margin; + void __user *argp = (void __user *)arg; + int __user *p = argp; + + static struct watchdog_info ident = { + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "IB700 WDT", + }; + + switch (cmd) { + case WDIOC_GETSUPPORT: + if (copy_to_user(argp, &ident, sizeof(ident))) + return -EFAULT; + break; + + case WDIOC_GETSTATUS: + return put_user(0, p); + + case WDIOC_KEEPALIVE: + ibwdt_ping(); + break; + + case WDIOC_SETTIMEOUT: + if (get_user(new_margin, p)) + return -EFAULT; + if ((new_margin < 0) || (new_margin > 30)) + return -EINVAL; + for (i = 0x0F; i > -1; i--) + if (wd_times[i] > new_margin) + break; + wd_margin = i; + ibwdt_ping(); + /* Fall */ + + case WDIOC_GETTIMEOUT: + return put_user(wd_times[wd_margin], p); + break; + + default: + return -ENOTTY; + } + return 0; +} + +static int +ibwdt_open(struct inode *inode, struct file *file) +{ + spin_lock(&ibwdt_lock); + if (test_and_set_bit(0, &ibwdt_is_open)) { + spin_unlock(&ibwdt_lock); + return -EBUSY; + } + if (nowayout) + __module_get(THIS_MODULE); + + /* Activate */ + ibwdt_ping(); + spin_unlock(&ibwdt_lock); + return nonseekable_open(inode, file); +} + +static int +ibwdt_close(struct inode *inode, struct file *file) +{ + spin_lock(&ibwdt_lock); + if (expect_close == 42) + outb_p(0, WDT_STOP); + else + printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); + + clear_bit(0, &ibwdt_is_open); + expect_close = 0; + spin_unlock(&ibwdt_lock); + return 0; +} + +/* + * Notifier for system down + */ + +static int +ibwdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if (code == SYS_DOWN || code == SYS_HALT) { + /* Turn the WDT off */ + outb_p(0, WDT_STOP); + } + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + +static const struct file_operations ibwdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = ibwdt_write, + .ioctl = ibwdt_ioctl, + .open = ibwdt_open, + .release = ibwdt_close, +}; + +static struct miscdevice ibwdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &ibwdt_fops, +}; + +/* + * The WDT needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ + +static struct notifier_block ibwdt_notifier = { + .notifier_call = ibwdt_notify_sys, +}; + +static int __init ibwdt_init(void) +{ + int res; + + printk(KERN_INFO PFX "WDT driver for IB700 single board computer initialising.\n"); + + spin_lock_init(&ibwdt_lock); + res = misc_register(&ibwdt_miscdev); + if (res) { + printk (KERN_ERR PFX "failed to register misc device\n"); + goto out_nomisc; + } + +#if WDT_START != WDT_STOP + if (!request_region(WDT_STOP, 1, "IB700 WDT")) { + printk (KERN_ERR PFX "STOP method I/O %X is not available.\n", WDT_STOP); + res = -EIO; + goto out_nostopreg; + } +#endif + + if (!request_region(WDT_START, 1, "IB700 WDT")) { + printk (KERN_ERR PFX "START method I/O %X is not available.\n", WDT_START); + res = -EIO; + goto out_nostartreg; + } + res = register_reboot_notifier(&ibwdt_notifier); + if (res) { + printk (KERN_ERR PFX "Failed to register reboot notifier.\n"); + goto out_noreboot; + } + return 0; + +out_noreboot: + release_region(WDT_START, 1); +out_nostartreg: +#if WDT_START != WDT_STOP + release_region(WDT_STOP, 1); +#endif +out_nostopreg: + misc_deregister(&ibwdt_miscdev); +out_nomisc: + return res; +} + +static void __exit +ibwdt_exit(void) +{ + misc_deregister(&ibwdt_miscdev); + unregister_reboot_notifier(&ibwdt_notifier); +#if WDT_START != WDT_STOP + release_region(WDT_STOP,1); +#endif + release_region(WDT_START,1); +} + +module_init(ibwdt_init); +module_exit(ibwdt_exit); + +MODULE_AUTHOR("Charles Howes "); +MODULE_DESCRIPTION("IB700 SBC watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); + +/* end of ib700wdt.c */ diff --git a/ddverify/case_studies/char/watchdog/machzwd/machzwd.c b/ddverify/case_studies/char/watchdog/machzwd/machzwd.c new file mode 100644 index 000000000..276577d08 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/machzwd/machzwd.c @@ -0,0 +1,494 @@ +/* + * MachZ ZF-Logic Watchdog Timer driver for Linux + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * The author does NOT admit liability nor provide warranty for + * any of this software. This material is provided "AS-IS" in + * the hope that it may be useful for others. + * + * Author: Fernando Fuganti + * + * Based on sbc60xxwdt.c by Jakob Oestergaard + * + * + * We have two timers (wd#1, wd#2) driven by a 32 KHz clock with the + * following periods: + * wd#1 - 2 seconds; + * wd#2 - 7.2 ms; + * After the expiration of wd#1, it can generate a NMI, SCI, SMI, or + * a system RESET and it starts wd#2 that unconditionaly will RESET + * the system when the counter reaches zero. + * + * 14-Dec-2001 Matt Domsch + * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* ports */ +#define ZF_IOBASE 0x218 +#define INDEX 0x218 +#define DATA_B 0x219 +#define DATA_W 0x21A +#define DATA_D 0x21A + +/* indexes */ /* size */ +#define ZFL_VERSION 0x02 /* 16 */ +#define CONTROL 0x10 /* 16 */ +#define STATUS 0x12 /* 8 */ +#define COUNTER_1 0x0C /* 16 */ +#define COUNTER_2 0x0E /* 8 */ +#define PULSE_LEN 0x0F /* 8 */ + +/* controls */ +#define ENABLE_WD1 0x0001 +#define ENABLE_WD2 0x0002 +#define RESET_WD1 0x0010 +#define RESET_WD2 0x0020 +#define GEN_SCI 0x0100 +#define GEN_NMI 0x0200 +#define GEN_SMI 0x0400 +#define GEN_RESET 0x0800 + + +/* utilities */ + +#define WD1 0 +#define WD2 1 + +#define zf_writew(port, data) { outb(port, INDEX); outw(data, DATA_W); } +#define zf_writeb(port, data) { outb(port, INDEX); outb(data, DATA_B); } +#define zf_get_ZFL_version() zf_readw(ZFL_VERSION) + + +static unsigned short zf_readw(unsigned char port) +{ + outb(port, INDEX); + return inw(DATA_W); +} + + +MODULE_AUTHOR("Fernando Fuganti "); +MODULE_DESCRIPTION("MachZ ZF-Logic Watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +#define PFX "machzwd" + +static struct watchdog_info zf_info = { + .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "ZF-Logic watchdog", +}; + + +/* + * action refers to action taken when watchdog resets + * 0 = GEN_RESET + * 1 = GEN_SMI + * 2 = GEN_NMI + * 3 = GEN_SCI + * defaults to GEN_RESET (0) + */ +static int action = 0; +module_param(action, int, 0); +MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI"); + +static int zf_action = GEN_RESET; +static unsigned long zf_is_open; +static char zf_expect_close; +static spinlock_t zf_lock; +static spinlock_t zf_port_lock; +static struct timer_list zf_timer; +static unsigned long next_heartbeat = 0; + + +/* timeout for user land heart beat (10 seconds) */ +#define ZF_USER_TIMEO (HZ*10) + +/* timeout for hardware watchdog (~500ms) */ +#define ZF_HW_TIMEO (HZ/2) + +/* number of ticks on WD#1 (driven by a 32KHz clock, 2s) */ +#define ZF_CTIMEOUT 0xffff + +#ifndef ZF_DEBUG +# define dprintk(format, args...) +#else +# define dprintk(format, args...) printk(KERN_DEBUG PFX ":%s:%d: " format, __FUNCTION__, __LINE__ , ## args) +#endif + + +static inline void zf_set_status(unsigned char new) +{ + zf_writeb(STATUS, new); +} + + +/* CONTROL register functions */ + +static inline unsigned short zf_get_control(void) +{ + return zf_readw(CONTROL); +} + +static inline void zf_set_control(unsigned short new) +{ + zf_writew(CONTROL, new); +} + + +/* WD#? counter functions */ +/* + * Just set counter value + */ + +static inline void zf_set_timer(unsigned short new, unsigned char n) +{ + switch(n){ + case WD1: + zf_writew(COUNTER_1, new); + case WD2: + zf_writeb(COUNTER_2, new > 0xff ? 0xff : new); + default: + return; + } +} + +/* + * stop hardware timer + */ +static void zf_timer_off(void) +{ + unsigned int ctrl_reg = 0; + unsigned long flags; + + /* stop internal ping */ + del_timer_sync(&zf_timer); + + spin_lock_irqsave(&zf_port_lock, flags); + /* stop watchdog timer */ + ctrl_reg = zf_get_control(); + ctrl_reg |= (ENABLE_WD1|ENABLE_WD2); /* disable wd1 and wd2 */ + ctrl_reg &= ~(ENABLE_WD1|ENABLE_WD2); + zf_set_control(ctrl_reg); + spin_unlock_irqrestore(&zf_port_lock, flags); + + printk(KERN_INFO PFX ": Watchdog timer is now disabled\n"); +} + + +/* + * start hardware timer + */ +static void zf_timer_on(void) +{ + unsigned int ctrl_reg = 0; + unsigned long flags; + + spin_lock_irqsave(&zf_port_lock, flags); + + zf_writeb(PULSE_LEN, 0xff); + + zf_set_timer(ZF_CTIMEOUT, WD1); + + /* user land ping */ + next_heartbeat = jiffies + ZF_USER_TIMEO; + + /* start the timer for internal ping */ + zf_timer.expires = jiffies + ZF_HW_TIMEO; + + add_timer(&zf_timer); + + /* start watchdog timer */ + ctrl_reg = zf_get_control(); + ctrl_reg |= (ENABLE_WD1|zf_action); + zf_set_control(ctrl_reg); + spin_unlock_irqrestore(&zf_port_lock, flags); + + printk(KERN_INFO PFX ": Watchdog timer is now enabled\n"); +} + + +static void zf_ping(unsigned long data) +{ + unsigned int ctrl_reg = 0; + unsigned long flags; + + zf_writeb(COUNTER_2, 0xff); + + if(time_before(jiffies, next_heartbeat)){ + + dprintk("time_before: %ld\n", next_heartbeat - jiffies); + + /* + * reset event is activated by transition from 0 to 1 on + * RESET_WD1 bit and we assume that it is already zero... + */ + + spin_lock_irqsave(&zf_port_lock, flags); + ctrl_reg = zf_get_control(); + ctrl_reg |= RESET_WD1; + zf_set_control(ctrl_reg); + + /* ...and nothing changes until here */ + ctrl_reg &= ~(RESET_WD1); + zf_set_control(ctrl_reg); + spin_unlock_irqrestore(&zf_port_lock, flags); + + zf_timer.expires = jiffies + ZF_HW_TIMEO; + add_timer(&zf_timer); + }else{ + printk(KERN_CRIT PFX ": I will reset your machine\n"); + } +} + +static ssize_t zf_write(struct file *file, const char __user *buf, size_t count, + loff_t *ppos) +{ + /* See if we got the magic character */ + if(count){ + + /* + * no need to check for close confirmation + * no way to disable watchdog ;) + */ + if (!nowayout) { + size_t ofs; + + /* + * note: just in case someone wrote the magic character + * five months ago... + */ + zf_expect_close = 0; + + /* now scan */ + for (ofs = 0; ofs != count; ofs++){ + char c; + if (get_user(c, buf + ofs)) + return -EFAULT; + if (c == 'V'){ + zf_expect_close = 42; + dprintk("zf_expect_close = 42\n"); + } + } + } + + /* + * Well, anyhow someone wrote to us, + * we should return that favour + */ + next_heartbeat = jiffies + ZF_USER_TIMEO; + dprintk("user ping at %ld\n", jiffies); + + } + + return count; +} + +static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + switch(cmd){ + case WDIOC_GETSUPPORT: + if (copy_to_user(argp, &zf_info, sizeof(zf_info))) + return -EFAULT; + break; + + case WDIOC_GETSTATUS: + return put_user(0, p); + + case WDIOC_KEEPALIVE: + zf_ping(0); + break; + + default: + return -ENOTTY; + } + + return 0; +} + +static int zf_open(struct inode *inode, struct file *file) +{ + spin_lock(&zf_lock); + if(test_and_set_bit(0, &zf_is_open)) { + spin_unlock(&zf_lock); + return -EBUSY; + } + + if (nowayout) + __module_get(THIS_MODULE); + + spin_unlock(&zf_lock); + + zf_timer_on(); + + return nonseekable_open(inode, file); +} + +static int zf_close(struct inode *inode, struct file *file) +{ + if(zf_expect_close == 42){ + zf_timer_off(); + } else { + del_timer(&zf_timer); + printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n"); + } + + spin_lock(&zf_lock); + clear_bit(0, &zf_is_open); + spin_unlock(&zf_lock); + + zf_expect_close = 0; + + return 0; +} + +/* + * Notifier for system down + */ + +static int zf_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if(code == SYS_DOWN || code == SYS_HALT){ + zf_timer_off(); + } + + return NOTIFY_DONE; +} + + + + +static const struct file_operations zf_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = zf_write, + .ioctl = zf_ioctl, + .open = zf_open, + .release = zf_close, +}; + +static struct miscdevice zf_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &zf_fops, +}; + + +/* + * The device needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ +static struct notifier_block zf_notifier = { + .notifier_call = zf_notify_sys, +}; + +static void __init zf_show_action(int act) +{ + char *str[] = { "RESET", "SMI", "NMI", "SCI" }; + + printk(KERN_INFO PFX ": Watchdog using action = %s\n", str[act]); +} + +static int __init zf_init(void) +{ + int ret; + + printk(KERN_INFO PFX ": MachZ ZF-Logic Watchdog driver initializing.\n"); + + ret = zf_get_ZFL_version(); + if ((!ret) || (ret == 0xffff)) { + printk(KERN_WARNING PFX ": no ZF-Logic found\n"); + return -ENODEV; + } + + if((action <= 3) && (action >= 0)){ + zf_action = zf_action>>action; + } else + action = 0; + + zf_show_action(action); + + spin_lock_init(&zf_lock); + spin_lock_init(&zf_port_lock); + + ret = misc_register(&zf_miscdev); + if (ret){ + printk(KERN_ERR "can't misc_register on minor=%d\n", + WATCHDOG_MINOR); + goto out; + } + + if(!request_region(ZF_IOBASE, 3, "MachZ ZFL WDT")){ + printk(KERN_ERR "cannot reserve I/O ports at %d\n", + ZF_IOBASE); + ret = -EBUSY; + goto no_region; + } + + ret = register_reboot_notifier(&zf_notifier); + if(ret){ + printk(KERN_ERR "can't register reboot notifier (err=%d)\n", + ret); + goto no_reboot; + } + + zf_set_status(0); + zf_set_control(0); + + /* this is the timer that will do the hard work */ + init_timer(&zf_timer); + zf_timer.function = zf_ping; + zf_timer.data = 0; + + return 0; + +no_reboot: + release_region(ZF_IOBASE, 3); +no_region: + misc_deregister(&zf_miscdev); +out: + return ret; +} + + +static void __exit zf_exit(void) +{ + zf_timer_off(); + + misc_deregister(&zf_miscdev); + unregister_reboot_notifier(&zf_notifier); + release_region(ZF_IOBASE, 3); +} + +module_init(zf_init); +module_exit(zf_exit); diff --git a/ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.c b/ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.c new file mode 100644 index 000000000..c2dac0aa1 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.c @@ -0,0 +1,302 @@ +/* + * MixCom Watchdog: A Simple Hardware Watchdog Device + * Based on Softdog driver by Alan Cox and PC Watchdog driver by Ken Hollis + * + * Author: Gergely Madarasz + * + * Copyright (c) 1999 ITConsult-Pro Co. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Version 0.1 (99/04/15): + * - first version + * + * Version 0.2 (99/06/16): + * - added kernel timer watchdog ping after close + * since the hardware does not support watchdog shutdown + * + * Version 0.3 (99/06/21): + * - added WDIOC_GETSTATUS and WDIOC_GETSUPPORT ioctl calls + * + * Version 0.3.1 (99/06/22): + * - allow module removal while internal timer is active, + * print warning about probable reset + * + * Version 0.4 (99/11/15): + * - support for one more type board + * + * Version 0.5 (2001/12/14) Matt Domsch + * - added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT + * + */ + +#define VERSION "0.5" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 }; + +#define MIXCOM_WATCHDOG_OFFSET 0xc10 +#define MIXCOM_ID 0x11 +#define FLASHCOM_WATCHDOG_OFFSET 0x4 +#define FLASHCOM_ID 0x18 + +static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */ + +static int watchdog_port; +static int mixcomwd_timer_alive; +static DEFINE_TIMER(mixcomwd_timer, NULL, 0, 0); +static char expect_close; + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +static void mixcomwd_ping(void) +{ + outb_p(55,watchdog_port); + return; +} + +static void mixcomwd_timerfun(unsigned long d) +{ + mixcomwd_ping(); + + mod_timer(&mixcomwd_timer,jiffies+ 5*HZ); +} + +/* + * Allow only one person to hold it open + */ + +static int mixcomwd_open(struct inode *inode, struct file *file) +{ + if(test_and_set_bit(0,&mixcomwd_opened)) { + return -EBUSY; + } + mixcomwd_ping(); + + if (nowayout) { + /* + * fops_get() code via open() has already done + * a try_module_get() so it is safe to do the + * __module_get(). + */ + __module_get(THIS_MODULE); + } else { + if(mixcomwd_timer_alive) { + del_timer(&mixcomwd_timer); + mixcomwd_timer_alive=0; + } + } + return nonseekable_open(inode, file); +} + +static int mixcomwd_release(struct inode *inode, struct file *file) +{ + if (expect_close == 42) { + if(mixcomwd_timer_alive) { + printk(KERN_ERR "mixcomwd: release called while internal timer alive"); + return -EBUSY; + } + init_timer(&mixcomwd_timer); + mixcomwd_timer.expires=jiffies + 5 * HZ; + mixcomwd_timer.function=mixcomwd_timerfun; + mixcomwd_timer.data=0; + mixcomwd_timer_alive=1; + add_timer(&mixcomwd_timer); + } else { + printk(KERN_CRIT "mixcomwd: WDT device closed unexpectedly. WDT will not stop!\n"); + } + + clear_bit(0,&mixcomwd_opened); + expect_close=0; + return 0; +} + + +static ssize_t mixcomwd_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) +{ + if(len) + { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + expect_close = 0; + + for (i = 0; i != len; i++) { + char c; + if (get_user(c, data + i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + mixcomwd_ping(); + } + return len; +} + +static int mixcomwd_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + int status; + static struct watchdog_info ident = { + .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "MixCOM watchdog", + }; + + switch(cmd) + { + case WDIOC_GETSTATUS: + status=mixcomwd_opened; + if (!nowayout) { + status|=mixcomwd_timer_alive; + } + if (copy_to_user(p, &status, sizeof(int))) { + return -EFAULT; + } + break; + case WDIOC_GETSUPPORT: + if (copy_to_user(argp, &ident, sizeof(ident))) { + return -EFAULT; + } + break; + case WDIOC_KEEPALIVE: + mixcomwd_ping(); + break; + default: + return -ENOTTY; + } + return 0; +} + +static const struct file_operations mixcomwd_fops= +{ + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = mixcomwd_write, + .ioctl = mixcomwd_ioctl, + .open = mixcomwd_open, + .release = mixcomwd_release, +}; + +static struct miscdevice mixcomwd_miscdev= +{ + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &mixcomwd_fops, +}; + +static int __init mixcomwd_checkcard(int port) +{ + int id; + + port += MIXCOM_WATCHDOG_OFFSET; + if (!request_region(port, 1, "MixCOM watchdog")) { + return 0; + } + + id=inb_p(port) & 0x3f; + if(id!=MIXCOM_ID) { + release_region(port, 1); + return 0; + } + return port; +} + +static int __init flashcom_checkcard(int port) +{ + int id; + + port += FLASHCOM_WATCHDOG_OFFSET; + if (!request_region(port, 1, "MixCOM watchdog")) { + return 0; + } + + id=inb_p(port); + if(id!=FLASHCOM_ID) { + release_region(port, 1); + return 0; + } + return port; + } + +static int __init mixcomwd_init(void) +{ + int i; + int ret; + int found=0; + + for (i = 0; !found && mixcomwd_ioports[i] != 0; i++) { + watchdog_port = mixcomwd_checkcard(mixcomwd_ioports[i]); + if (watchdog_port) { + found = 1; + } + } + + /* The FlashCOM card can be set up at 0x300 -> 0x378, in 0x8 jumps */ + for (i = 0x300; !found && i < 0x380; i+=0x8) { + watchdog_port = flashcom_checkcard(i); + if (watchdog_port) { + found = 1; + } + } + + if (!found) { + printk("mixcomwd: No card detected, or port not available.\n"); + return -ENODEV; + } + + ret = misc_register(&mixcomwd_miscdev); + if (ret) + { + release_region(watchdog_port, 1); + return ret; + } + + printk(KERN_INFO "MixCOM watchdog driver v%s, watchdog port at 0x%3x\n",VERSION,watchdog_port); + + return 0; +} + +static void __exit mixcomwd_exit(void) +{ + if (!nowayout) { + if(mixcomwd_timer_alive) { + printk(KERN_WARNING "mixcomwd: I quit now, hardware will" + " probably reboot!\n"); + del_timer(&mixcomwd_timer); + mixcomwd_timer_alive=0; + } + } + release_region(watchdog_port,1); + misc_deregister(&mixcomwd_miscdev); +} + +module_init(mixcomwd_init); +module_exit(mixcomwd_exit); + +MODULE_AUTHOR("Gergely Madarasz "); +MODULE_DESCRIPTION("MixCom Watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/ddverify/case_studies/char/watchdog/pcwd/pcwd.c b/ddverify/case_studies/char/watchdog/pcwd/pcwd.c new file mode 100644 index 000000000..edb942520 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/pcwd/pcwd.c @@ -0,0 +1,1001 @@ +/* + * PC Watchdog Driver + * by Ken Hollis (khollis@bitgate.com) + * + * Permission granted from Simon Machell (73244.1270@compuserve.com) + * Written for the Linux Kernel, and GPLed by Ken Hollis + * + * 960107 Added request_region routines, modulized the whole thing. + * 960108 Fixed end-of-file pointer (Thanks to Dan Hollis), added + * WD_TIMEOUT define. + * 960216 Added eof marker on the file, and changed verbose messages. + * 960716 Made functional and cosmetic changes to the source for + * inclusion in Linux 2.0.x kernels, thanks to Alan Cox. + * 960717 Removed read/seek routines, replaced with ioctl. Also, added + * check_region command due to Alan's suggestion. + * 960821 Made changes to compile in newer 2.0.x kernels. Added + * "cold reboot sense" entry. + * 960825 Made a few changes to code, deleted some defines and made + * typedefs to replace them. Made heartbeat reset only available + * via ioctl, and removed the write routine. + * 960828 Added new items for PC Watchdog Rev.C card. + * 960829 Changed around all of the IOCTLs, added new features, + * added watchdog disable/re-enable routines. Added firmware + * version reporting. Added read routine for temperature. + * Removed some extra defines, added an autodetect Revision + * routine. + * 961006 Revised some documentation, fixed some cosmetic bugs. Made + * drivers to panic the system if it's overheating at bootup. + * 961118 Changed some verbiage on some of the output, tidied up + * code bits, and added compatibility to 2.1.x. + * 970912 Enabled board on open and disable on close. + * 971107 Took account of recent VFS changes (broke read). + * 971210 Disable board on initialisation in case board already ticking. + * 971222 Changed open/close for temperature handling + * Michael Meskes . + * 980112 Used minor numbers from include/linux/miscdevice.h + * 990403 Clear reset status after reading control status register in + * pcwd_showprevstate(). [Marc Boucher ] + * 990605 Made changes to code to support Firmware 1.22a, added + * fairly useless proc entry. + * 990610 removed said useless proc code for the merge + * 000403 Removed last traces of proc code. + * 011214 Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT + * Added timeout module option to override default + */ + +/* + * A bells and whistles driver is available from http://www.pcwd.de/ + * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ + */ + +#include /* For module specific items */ +#include /* For new moduleparam's */ +#include /* For standard types (like size_t) */ +#include /* For the -ENODEV/... values */ +#include /* For printk/panic/... */ +#include /* For mdelay function */ +#include /* For timer related operations */ +#include /* For jiffies stuff */ +#include /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ +#include /* For the watchdog specific items */ +#include /* For notifier support */ +#include /* For reboot_notifier stuff */ +#include /* For __init/__exit/... */ +#include /* For file operations */ +#include /* For io-port access */ +#include /* For spin_lock/spin_unlock/... */ + +#include /* For copy_to_user/put_user/... */ +#include /* For inb/outb/... */ + +/* Module and version information */ +#define WATCHDOG_VERSION "1.17" +#define WATCHDOG_DATE "12 Feb 2006" +#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" +#define WATCHDOG_NAME "pcwd" +#define PFX WATCHDOG_NAME ": " +#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n" +#define WD_VER WATCHDOG_VERSION " (" WATCHDOG_DATE ")" + +/* + * It should be noted that PCWD_REVISION_B was removed because A and B + * are essentially the same types of card, with the exception that B + * has temperature reporting. Since I didn't receive a Rev.B card, + * the Rev.B card is not supported. (It's a good thing too, as they + * are no longer in production.) + */ +#define PCWD_REVISION_A 1 +#define PCWD_REVISION_C 2 + +/* + * These are the defines that describe the control status bits for the + * PCI-PC Watchdog card. +*/ +/* Port 1 : Control Status #1 for the PC Watchdog card, revision A. */ +#define WD_WDRST 0x01 /* Previously reset state */ +#define WD_T110 0x02 /* Temperature overheat sense */ +#define WD_HRTBT 0x04 /* Heartbeat sense */ +#define WD_RLY2 0x08 /* External relay triggered */ +#define WD_SRLY2 0x80 /* Software external relay triggered */ +/* Port 1 : Control Status #1 for the PC Watchdog card, revision C. */ +#define WD_REVC_WTRP 0x01 /* Watchdog Trip status */ +#define WD_REVC_HRBT 0x02 /* Watchdog Heartbeat */ +#define WD_REVC_TTRP 0x04 /* Temperature Trip status */ +#define WD_REVC_RL2A 0x08 /* Relay 2 activated by on-board processor */ +#define WD_REVC_RL1A 0x10 /* Relay 1 active */ +#define WD_REVC_R2DS 0x40 /* Relay 2 disable */ +#define WD_REVC_RLY2 0x80 /* Relay 2 activated? */ +/* Port 2 : Control Status #2 */ +#define WD_WDIS 0x10 /* Watchdog Disabled */ +#define WD_ENTP 0x20 /* Watchdog Enable Temperature Trip */ +#define WD_SSEL 0x40 /* Watchdog Switch Select (1:SW1 <-> 0:SW2) */ +#define WD_WCMD 0x80 /* Watchdog Command Mode */ + +/* max. time we give an ISA watchdog card to process a command */ +/* 500ms for each 4 bit response (according to spec.) */ +#define ISA_COMMAND_TIMEOUT 1000 + +/* Watchdog's internal commands */ +#define CMD_ISA_IDLE 0x00 +#define CMD_ISA_VERSION_INTEGER 0x01 +#define CMD_ISA_VERSION_TENTH 0x02 +#define CMD_ISA_VERSION_HUNDRETH 0x03 +#define CMD_ISA_VERSION_MINOR 0x04 +#define CMD_ISA_SWITCH_SETTINGS 0x05 +#define CMD_ISA_RESET_PC 0x06 +#define CMD_ISA_ARM_0 0x07 +#define CMD_ISA_ARM_30 0x08 +#define CMD_ISA_ARM_60 0x09 +#define CMD_ISA_DELAY_TIME_2SECS 0x0A +#define CMD_ISA_DELAY_TIME_4SECS 0x0B +#define CMD_ISA_DELAY_TIME_8SECS 0x0C +#define CMD_ISA_RESET_RELAYS 0x0D + +/* + * We are using an kernel timer to do the pinging of the watchdog + * every ~500ms. We try to set the internal heartbeat of the + * watchdog to 2 ms. + */ + +#define WDT_INTERVAL (HZ/2+1) + +/* We can only use 1 card due to the /dev/watchdog restriction */ +static int cards_found; + +/* internal variables */ +static atomic_t open_allowed = ATOMIC_INIT(1); +static char expect_close; +static int temp_panic; +static struct { /* this is private data for each ISA-PC watchdog card */ + char fw_ver_str[6]; /* The cards firmware version */ + int revision; /* The card's revision */ + int supports_temp; /* Wether or not the card has a temperature device */ + int command_mode; /* Wether or not the card is in command mode */ + int boot_status; /* The card's boot status */ + int io_addr; /* The cards I/O address */ + spinlock_t io_lock; /* the lock for io operations */ + struct timer_list timer; /* The timer that pings the watchdog */ + unsigned long next_heartbeat; /* the next_heartbeat for the timer */ +} pcwd_private; + +/* module parameters */ +#define QUIET 0 /* Default */ +#define VERBOSE 1 /* Verbose */ +#define DEBUG 2 /* print fancy stuff too */ +static int debug = QUIET; +module_param(debug, int, 0); +MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); + +#define WATCHDOG_HEARTBEAT 60 /* 60 sec default heartbeat */ +static int heartbeat = WATCHDOG_HEARTBEAT; +module_param(heartbeat, int, 0); +MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<=heartbeat<=7200, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +/* + * Internal functions + */ + +static int send_isa_command(int cmd) +{ + int i; + int control_status; + int port0, last_port0; /* Double read for stabilising */ + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "sending following data cmd=0x%02x\n", + cmd); + + /* The WCMD bit must be 1 and the command is only 4 bits in size */ + control_status = (cmd & 0x0F) | WD_WCMD; + outb_p(control_status, pcwd_private.io_addr + 2); + udelay(ISA_COMMAND_TIMEOUT); + + port0 = inb_p(pcwd_private.io_addr); + for (i = 0; i < 25; ++i) { + last_port0 = port0; + port0 = inb_p(pcwd_private.io_addr); + + if (port0 == last_port0) + break; /* Data is stable */ + + udelay (250); + } + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n", + cmd, port0, last_port0); + + return port0; +} + +static int set_command_mode(void) +{ + int i, found=0, count=0; + + /* Set the card into command mode */ + spin_lock(&pcwd_private.io_lock); + while ((!found) && (count < 3)) { + i = send_isa_command(CMD_ISA_IDLE); + + if (i == 0x00) + found = 1; + else if (i == 0xF3) { + /* Card does not like what we've done to it */ + outb_p(0x00, pcwd_private.io_addr + 2); + udelay(1200); /* Spec says wait 1ms */ + outb_p(0x00, pcwd_private.io_addr + 2); + udelay(ISA_COMMAND_TIMEOUT); + } + count++; + } + spin_unlock(&pcwd_private.io_lock); + pcwd_private.command_mode = found; + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "command_mode=%d\n", + pcwd_private.command_mode); + + return(found); +} + +static void unset_command_mode(void) +{ + /* Set the card into normal mode */ + spin_lock(&pcwd_private.io_lock); + outb_p(0x00, pcwd_private.io_addr + 2); + udelay(ISA_COMMAND_TIMEOUT); + spin_unlock(&pcwd_private.io_lock); + + pcwd_private.command_mode = 0; + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "command_mode=%d\n", + pcwd_private.command_mode); +} + +static inline void pcwd_check_temperature_support(void) +{ + if (inb(pcwd_private.io_addr) != 0xF0) + pcwd_private.supports_temp = 1; +} + +static inline void pcwd_get_firmware(void) +{ + int one, ten, hund, minor; + + strcpy(pcwd_private.fw_ver_str, "ERROR"); + + if (set_command_mode()) { + one = send_isa_command(CMD_ISA_VERSION_INTEGER); + ten = send_isa_command(CMD_ISA_VERSION_TENTH); + hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH); + minor = send_isa_command(CMD_ISA_VERSION_MINOR); + sprintf(pcwd_private.fw_ver_str, "%c.%c%c%c", one, ten, hund, minor); + } + unset_command_mode(); + + return; +} + +static inline int pcwd_get_option_switches(void) +{ + int option_switches=0; + + if (set_command_mode()) { + /* Get switch settings */ + option_switches = send_isa_command(CMD_ISA_SWITCH_SETTINGS); + } + + unset_command_mode(); + return(option_switches); +} + +static void pcwd_show_card_info(void) +{ + int option_switches; + + /* Get some extra info from the hardware (in command/debug/diag mode) */ + if (pcwd_private.revision == PCWD_REVISION_A) + printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr); + else if (pcwd_private.revision == PCWD_REVISION_C) { + pcwd_get_firmware(); + printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n", + pcwd_private.io_addr, pcwd_private.fw_ver_str); + option_switches = pcwd_get_option_switches(); + printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", + option_switches, + ((option_switches & 0x10) ? "ON" : "OFF"), + ((option_switches & 0x08) ? "ON" : "OFF")); + + /* Reprogram internal heartbeat to 2 seconds */ + if (set_command_mode()) { + send_isa_command(CMD_ISA_DELAY_TIME_2SECS); + unset_command_mode(); + } + } + + if (pcwd_private.supports_temp) + printk(KERN_INFO PFX "Temperature Option Detected\n"); + + if (pcwd_private.boot_status & WDIOF_CARDRESET) + printk(KERN_INFO PFX "Previous reboot was caused by the card\n"); + + if (pcwd_private.boot_status & WDIOF_OVERHEAT) { + printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n"); + printk(KERN_EMERG PFX "CPU Overheat\n"); + } + + if (pcwd_private.boot_status == 0) + printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); +} + +void pcwd_timer_ping(unsigned long data) +{ + int wdrst_stat; + + /* If we got a heartbeat pulse within the WDT_INTERVAL + * we agree to ping the WDT */ + if(time_before(jiffies, pcwd_private.next_heartbeat)) { + /* Ping the watchdog */ + spin_lock(&pcwd_private.io_lock); + if (pcwd_private.revision == PCWD_REVISION_A) { + /* Rev A cards are reset by setting the WD_WDRST bit in register 1 */ + wdrst_stat = inb_p(pcwd_private.io_addr); + wdrst_stat &= 0x0F; + wdrst_stat |= WD_WDRST; + + outb_p(wdrst_stat, pcwd_private.io_addr + 1); + } else { + /* Re-trigger watchdog by writing to port 0 */ + outb_p(0x00, pcwd_private.io_addr); + } + + /* Re-set the timer interval */ + mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL); + + spin_unlock(&pcwd_private.io_lock); + } else { + printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); + } +} + +static int pcwd_start(void) +{ + int stat_reg; + + pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ); + + /* Start the timer */ + mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL); + + /* Enable the port */ + if (pcwd_private.revision == PCWD_REVISION_C) { + spin_lock(&pcwd_private.io_lock); + outb_p(0x00, pcwd_private.io_addr + 3); + udelay(ISA_COMMAND_TIMEOUT); + stat_reg = inb_p(pcwd_private.io_addr + 2); + spin_unlock(&pcwd_private.io_lock); + if (stat_reg & WD_WDIS) { + printk(KERN_INFO PFX "Could not start watchdog\n"); + return -EIO; + } + } + + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "Watchdog started\n"); + + return 0; +} + +static int pcwd_stop(void) +{ + int stat_reg; + + /* Stop the timer */ + del_timer(&pcwd_private.timer); + + /* Disable the board */ + if (pcwd_private.revision == PCWD_REVISION_C) { + spin_lock(&pcwd_private.io_lock); + outb_p(0xA5, pcwd_private.io_addr + 3); + udelay(ISA_COMMAND_TIMEOUT); + outb_p(0xA5, pcwd_private.io_addr + 3); + udelay(ISA_COMMAND_TIMEOUT); + stat_reg = inb_p(pcwd_private.io_addr + 2); + spin_unlock(&pcwd_private.io_lock); + if ((stat_reg & WD_WDIS) == 0) { + printk(KERN_INFO PFX "Could not stop watchdog\n"); + return -EIO; + } + } + + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "Watchdog stopped\n"); + + return 0; +} + +static int pcwd_keepalive(void) +{ + /* user land ping */ + pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ); + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); + + return 0; +} + +static int pcwd_set_heartbeat(int t) +{ + if ((t < 2) || (t > 7200)) /* arbitrary upper limit */ + return -EINVAL; + + heartbeat = t; + + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "New heartbeat: %d\n", + heartbeat); + + return 0; +} + +static int pcwd_get_status(int *status) +{ + int control_status; + + *status=0; + spin_lock(&pcwd_private.io_lock); + if (pcwd_private.revision == PCWD_REVISION_A) + /* Rev A cards return status information from + * the base register, which is used for the + * temperature in other cards. */ + control_status = inb(pcwd_private.io_addr); + else { + /* Rev C cards return card status in the base + * address + 1 register. And use different bits + * to indicate a card initiated reset, and an + * over-temperature condition. And the reboot + * status can be reset. */ + control_status = inb(pcwd_private.io_addr + 1); + } + spin_unlock(&pcwd_private.io_lock); + + if (pcwd_private.revision == PCWD_REVISION_A) { + if (control_status & WD_WDRST) + *status |= WDIOF_CARDRESET; + + if (control_status & WD_T110) { + *status |= WDIOF_OVERHEAT; + if (temp_panic) { + printk (KERN_INFO PFX "Temperature overheat trip!\n"); + kernel_power_off(); + /* or should we just do a: panic(PFX "Temperature overheat trip!\n"); */ + } + } + } else { + if (control_status & WD_REVC_WTRP) + *status |= WDIOF_CARDRESET; + + if (control_status & WD_REVC_TTRP) { + *status |= WDIOF_OVERHEAT; + if (temp_panic) { + printk (KERN_INFO PFX "Temperature overheat trip!\n"); + kernel_power_off(); + /* or should we just do a: panic(PFX "Temperature overheat trip!\n"); */ + } + } + } + + return 0; +} + +static int pcwd_clear_status(void) +{ + int control_status; + + if (pcwd_private.revision == PCWD_REVISION_C) { + spin_lock(&pcwd_private.io_lock); + + if (debug >= VERBOSE) + printk(KERN_INFO PFX "clearing watchdog trip status\n"); + + control_status = inb_p(pcwd_private.io_addr + 1); + + if (debug >= DEBUG) { + printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status); + printk(KERN_DEBUG PFX "sending: 0x%02x\n", + (control_status & WD_REVC_R2DS)); + } + + /* clear reset status & Keep Relay 2 disable state as it is */ + outb_p((control_status & WD_REVC_R2DS), pcwd_private.io_addr + 1); + + spin_unlock(&pcwd_private.io_lock); + } + return 0; +} + +static int pcwd_get_temperature(int *temperature) +{ + /* check that port 0 gives temperature info and no command results */ + if (pcwd_private.command_mode) + return -1; + + *temperature = 0; + if (!pcwd_private.supports_temp) + return -ENODEV; + + /* + * Convert celsius to fahrenheit, since this was + * the decided 'standard' for this return value. + */ + spin_lock(&pcwd_private.io_lock); + *temperature = ((inb(pcwd_private.io_addr)) * 9 / 5) + 32; + spin_unlock(&pcwd_private.io_lock); + + if (debug >= DEBUG) { + printk(KERN_DEBUG PFX "temperature is: %d F\n", + *temperature); + } + + return 0; +} + +/* + * /dev/watchdog handling + */ + +static int pcwd_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int rv; + int status; + int temperature; + int new_heartbeat; + int __user *argp = (int __user *)arg; + static struct watchdog_info ident = { + .options = WDIOF_OVERHEAT | + WDIOF_CARDRESET | + WDIOF_KEEPALIVEPING | + WDIOF_SETTIMEOUT | + WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "PCWD", + }; + + switch(cmd) { + default: + return -ENOTTY; + + case WDIOC_GETSUPPORT: + if(copy_to_user(argp, &ident, sizeof(ident))) + return -EFAULT; + return 0; + + case WDIOC_GETSTATUS: + pcwd_get_status(&status); + return put_user(status, argp); + + case WDIOC_GETBOOTSTATUS: + return put_user(pcwd_private.boot_status, argp); + + case WDIOC_GETTEMP: + if (pcwd_get_temperature(&temperature)) + return -EFAULT; + + return put_user(temperature, argp); + + case WDIOC_SETOPTIONS: + if (pcwd_private.revision == PCWD_REVISION_C) + { + if(copy_from_user(&rv, argp, sizeof(int))) + return -EFAULT; + + if (rv & WDIOS_DISABLECARD) + { + return pcwd_stop(); + } + + if (rv & WDIOS_ENABLECARD) + { + return pcwd_start(); + } + + if (rv & WDIOS_TEMPPANIC) + { + temp_panic = 1; + } + } + return -EINVAL; + + case WDIOC_KEEPALIVE: + pcwd_keepalive(); + return 0; + + case WDIOC_SETTIMEOUT: + if (get_user(new_heartbeat, argp)) + return -EFAULT; + + if (pcwd_set_heartbeat(new_heartbeat)) + return -EINVAL; + + pcwd_keepalive(); + /* Fall */ + + case WDIOC_GETTIMEOUT: + return put_user(heartbeat, argp); + } + + return 0; +} + +static ssize_t pcwd_write(struct file *file, const char __user *buf, size_t len, + loff_t *ppos) +{ + if (len) { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + expect_close = 0; + + for (i = 0; i != len; i++) { + char c; + + if (get_user(c, buf + i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + pcwd_keepalive(); + } + return len; +} + +static int pcwd_open(struct inode *inode, struct file *file) +{ + if (!atomic_dec_and_test(&open_allowed) ) { + if (debug >= VERBOSE) + printk(KERN_ERR PFX "Attempt to open already opened device.\n"); + atomic_inc( &open_allowed ); + return -EBUSY; + } + + if (nowayout) + __module_get(THIS_MODULE); + + /* Activate */ + pcwd_start(); + pcwd_keepalive(); + return nonseekable_open(inode, file); +} + +static int pcwd_close(struct inode *inode, struct file *file) +{ + if (expect_close == 42) { + pcwd_stop(); + } else { + printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); + pcwd_keepalive(); + } + expect_close = 0; + atomic_inc( &open_allowed ); + return 0; +} + +/* + * /dev/temperature handling + */ + +static ssize_t pcwd_temp_read(struct file *file, char __user *buf, size_t count, + loff_t *ppos) +{ + int temperature; + + if (pcwd_get_temperature(&temperature)) + return -EFAULT; + + if (copy_to_user(buf, &temperature, 1)) + return -EFAULT; + + return 1; +} + +static int pcwd_temp_open(struct inode *inode, struct file *file) +{ + if (!pcwd_private.supports_temp) + return -ENODEV; + + return nonseekable_open(inode, file); +} + +static int pcwd_temp_close(struct inode *inode, struct file *file) +{ + return 0; +} + +/* + * Notify system + */ + +static int pcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) +{ + if (code==SYS_DOWN || code==SYS_HALT) { + /* Turn the WDT off */ + pcwd_stop(); + } + + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + +static const struct file_operations pcwd_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = pcwd_write, + .ioctl = pcwd_ioctl, + .open = pcwd_open, + .release = pcwd_close, +}; + +static struct miscdevice pcwd_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &pcwd_fops, +}; + +static const struct file_operations pcwd_temp_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = pcwd_temp_read, + .open = pcwd_temp_open, + .release = pcwd_temp_close, +}; + +static struct miscdevice temp_miscdev = { + .minor = TEMP_MINOR, + .name = "temperature", + .fops = &pcwd_temp_fops, +}; + +static struct notifier_block pcwd_notifier = { + .notifier_call = pcwd_notify_sys, +}; + +/* + * Init & exit routines + */ + +static inline int get_revision(void) +{ + int r = PCWD_REVISION_C; + + spin_lock(&pcwd_private.io_lock); + /* REV A cards use only 2 io ports; test + * presumes a floating bus reads as 0xff. */ + if ((inb(pcwd_private.io_addr + 2) == 0xFF) || + (inb(pcwd_private.io_addr + 3) == 0xFF)) + r=PCWD_REVISION_A; + spin_unlock(&pcwd_private.io_lock); + + return r; +} + +static int __devinit pcwatchdog_init(int base_addr) +{ + int ret; + + cards_found++; + if (cards_found == 1) + printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n", WD_VER); + + if (cards_found > 1) { + printk(KERN_ERR PFX "This driver only supports 1 device\n"); + return -ENODEV; + } + + if (base_addr == 0x0000) { + printk(KERN_ERR PFX "No I/O-Address for card detected\n"); + return -ENODEV; + } + pcwd_private.io_addr = base_addr; + + /* Check card's revision */ + pcwd_private.revision = get_revision(); + + if (!request_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + pcwd_private.io_addr); + pcwd_private.io_addr = 0x0000; + return -EIO; + } + + /* Initial variables */ + pcwd_private.supports_temp = 0; + temp_panic = 0; + pcwd_private.boot_status = 0x0000; + + /* get the boot_status */ + pcwd_get_status(&pcwd_private.boot_status); + + /* clear the "card caused reboot" flag */ + pcwd_clear_status(); + + init_timer(&pcwd_private.timer); + pcwd_private.timer.function = pcwd_timer_ping; + pcwd_private.timer.data = 0; + + /* Disable the board */ + pcwd_stop(); + + /* Check whether or not the card supports the temperature device */ + pcwd_check_temperature_support(); + + /* Show info about the card itself */ + pcwd_show_card_info(); + + /* Check that the heartbeat value is within it's range ; if not reset to the default */ + if (pcwd_set_heartbeat(heartbeat)) { + pcwd_set_heartbeat(WATCHDOG_HEARTBEAT); + printk(KERN_INFO PFX "heartbeat value must be 2<=heartbeat<=7200, using %d\n", + WATCHDOG_HEARTBEAT); + } + + ret = register_reboot_notifier(&pcwd_notifier); + if (ret) { + printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", + ret); + release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); + pcwd_private.io_addr = 0x0000; + return ret; + } + + if (pcwd_private.supports_temp) { + ret = misc_register(&temp_miscdev); + if (ret) { + printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + TEMP_MINOR, ret); + unregister_reboot_notifier(&pcwd_notifier); + release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); + pcwd_private.io_addr = 0x0000; + return ret; + } + } + + ret = misc_register(&pcwd_miscdev); + if (ret) { + printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + WATCHDOG_MINOR, ret); + if (pcwd_private.supports_temp) + misc_deregister(&temp_miscdev); + unregister_reboot_notifier(&pcwd_notifier); + release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); + pcwd_private.io_addr = 0x0000; + return ret; + } + + printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", + heartbeat, nowayout); + + return 0; +} + +static void __devexit pcwatchdog_exit(void) +{ + /* Disable the board */ + if (!nowayout) + pcwd_stop(); + + /* Deregister */ + misc_deregister(&pcwd_miscdev); + if (pcwd_private.supports_temp) + misc_deregister(&temp_miscdev); + unregister_reboot_notifier(&pcwd_notifier); + release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); + pcwd_private.io_addr = 0x0000; + cards_found--; +} + +/* + * The ISA cards have a heartbeat bit in one of the registers, which + * register is card dependent. The heartbeat bit is monitored, and if + * found, is considered proof that a Berkshire card has been found. + * The initial rate is once per second at board start up, then twice + * per second for normal operation. + */ +static int __init pcwd_checkcard(int base_addr) +{ + int port0, last_port0; /* Reg 0, in case it's REV A */ + int port1, last_port1; /* Register 1 for REV C cards */ + int i; + int retval; + + if (!request_region (base_addr, 4, "PCWD")) { + printk (KERN_INFO PFX "Port 0x%04x unavailable\n", base_addr); + return 0; + } + + retval = 0; + + port0 = inb_p(base_addr); /* For REV A boards */ + port1 = inb_p(base_addr + 1); /* For REV C boards */ + if (port0 != 0xff || port1 != 0xff) { + /* Not an 'ff' from a floating bus, so must be a card! */ + for (i = 0; i < 4; ++i) { + + msleep(500); + + last_port0 = port0; + last_port1 = port1; + + port0 = inb_p(base_addr); + port1 = inb_p(base_addr + 1); + + /* Has either hearbeat bit changed? */ + if ((port0 ^ last_port0) & WD_HRTBT || + (port1 ^ last_port1) & WD_REVC_HRBT) { + retval = 1; + break; + } + } + } + release_region (base_addr, 4); + + return retval; +} + +/* + * These are the auto-probe addresses available. + * + * Revision A only uses ports 0x270 and 0x370. Revision C introduced 0x350. + * Revision A has an address range of 2 addresses, while Revision C has 4. + */ +static int pcwd_ioports[] = { 0x270, 0x350, 0x370, 0x000 }; + +static int __init pcwd_init_module(void) +{ + int i, found = 0; + + spin_lock_init(&pcwd_private.io_lock); + + for (i = 0; pcwd_ioports[i] != 0; i++) { + if (pcwd_checkcard(pcwd_ioports[i])) { + if (!(pcwatchdog_init(pcwd_ioports[i]))) + found++; + } + } + + if (!found) { + printk (KERN_INFO PFX "No card detected, or port not available\n"); + return -ENODEV; + } + + return 0; +} + +static void __exit pcwd_cleanup_module(void) +{ + if (pcwd_private.io_addr) + pcwatchdog_exit(); + + printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); +} + +module_init(pcwd_init_module); +module_exit(pcwd_cleanup_module); + +MODULE_AUTHOR("Ken Hollis "); +MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); +MODULE_ALIAS_MISCDEV(TEMP_MINOR); diff --git a/ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.c b/ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.c new file mode 100644 index 000000000..e80665e2f --- /dev/null +++ b/ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.c @@ -0,0 +1,810 @@ +/* + * Berkshire PCI-PC Watchdog Card Driver + * + * (c) Copyright 2003-2005 Wim Van Sebroeck . + * + * Based on source code of the following authors: + * Ken Hollis , + * Lindsay Harris , + * Alan Cox , + * Matt Domsch , + * Rob Radez + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor + * provide warranty for any of this software. This material is + * provided "AS-IS" and at no charge. + */ + +/* + * A bells and whistles driver is available from: + * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ + * + * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ + */ + +/* + * Includes, defines, variables, module parameters, ... + */ + +#include /* For module specific items */ +#include /* For new moduleparam's */ +#include /* For standard types (like size_t) */ +#include /* For the -ENODEV/... values */ +#include /* For printk/panic/... */ +#include /* For mdelay function */ +#include /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ +#include /* For the watchdog specific items */ +#include /* For notifier support */ +#include /* For reboot_notifier stuff */ +#include /* For __init/__exit/... */ +#include /* For file operations */ +#include /* For pci functions */ +#include /* For io-port access */ +#include /* For spin_lock/spin_unlock/... */ + +#include /* For copy_to_user/put_user/... */ +#include /* For inb/outb/... */ + +/* Module and version information */ +#define WATCHDOG_VERSION "1.02" +#define WATCHDOG_DATE "03 Sep 2005" +#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" +#define WATCHDOG_NAME "pcwd_pci" +#define PFX WATCHDOG_NAME ": " +#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n" + +/* Stuff for the PCI ID's */ +#ifndef PCI_VENDOR_ID_QUICKLOGIC +#define PCI_VENDOR_ID_QUICKLOGIC 0x11e3 +#endif + +#ifndef PCI_DEVICE_ID_WATCHDOG_PCIPCWD +#define PCI_DEVICE_ID_WATCHDOG_PCIPCWD 0x5030 +#endif + +/* + * These are the defines that describe the control status bits for the + * PCI-PC Watchdog card. + */ +/* Port 1 : Control Status #1 */ +#define WD_PCI_WTRP 0x01 /* Watchdog Trip status */ +#define WD_PCI_HRBT 0x02 /* Watchdog Heartbeat */ +#define WD_PCI_TTRP 0x04 /* Temperature Trip status */ +#define WD_PCI_RL2A 0x08 /* Relay 2 Active */ +#define WD_PCI_RL1A 0x10 /* Relay 1 Active */ +#define WD_PCI_R2DS 0x40 /* Relay 2 Disable Temperature-trip/reset */ +#define WD_PCI_RLY2 0x80 /* Activate Relay 2 on the board */ +/* Port 2 : Control Status #2 */ +#define WD_PCI_WDIS 0x10 /* Watchdog Disable */ +#define WD_PCI_ENTP 0x20 /* Enable Temperature Trip Reset */ +#define WD_PCI_WRSP 0x40 /* Watchdog wrote response */ +#define WD_PCI_PCMD 0x80 /* PC has sent command */ + +/* according to documentation max. time to process a command for the pci + * watchdog card is 100 ms, so we give it 150 ms to do it's job */ +#define PCI_COMMAND_TIMEOUT 150 + +/* Watchdog's internal commands */ +#define CMD_GET_STATUS 0x04 +#define CMD_GET_FIRMWARE_VERSION 0x08 +#define CMD_READ_WATCHDOG_TIMEOUT 0x18 +#define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 +#define CMD_GET_CLEAR_RESET_COUNT 0x84 + +/* We can only use 1 card due to the /dev/watchdog restriction */ +static int cards_found; + +/* internal variables */ +static int temp_panic; +static unsigned long is_active; +static char expect_release; +static struct { /* this is private data for each PCI-PC watchdog card */ + int supports_temp; /* Wether or not the card has a temperature device */ + int boot_status; /* The card's boot status */ + unsigned long io_addr; /* The cards I/O address */ + spinlock_t io_lock; /* the lock for io operations */ + struct pci_dev *pdev; /* the PCI-device */ +} pcipcwd_private; + +/* module parameters */ +#define QUIET 0 /* Default */ +#define VERBOSE 1 /* Verbose */ +#define DEBUG 2 /* print fancy stuff too */ +static int debug = QUIET; +module_param(debug, int, 0); +MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); + +#define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ +static int heartbeat = WATCHDOG_HEARTBEAT; +module_param(heartbeat, int, 0); +MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0= DEBUG) + printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n", + cmd, *msb, *lsb); + + spin_lock(&pcipcwd_private.io_lock); + /* If a command requires data it should be written first. + * Data for commands with 8 bits of data should be written to port 4. + * Commands with 16 bits of data, should be written as LSB to port 4 + * and MSB to port 5. + * After the required data has been written then write the command to + * port 6. */ + outb_p(*lsb, pcipcwd_private.io_addr + 4); + outb_p(*msb, pcipcwd_private.io_addr + 5); + outb_p(cmd, pcipcwd_private.io_addr + 6); + + /* wait till the pci card processed the command, signaled by + * the WRSP bit in port 2 and give it a max. timeout of + * PCI_COMMAND_TIMEOUT to process */ + got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; + for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response); count++) { + mdelay(1); + got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; + } + + if (debug >= DEBUG) { + if (got_response) { + printk(KERN_DEBUG PFX "time to process command was: %d ms\n", + count); + } else { + printk(KERN_DEBUG PFX "card did not respond on command!\n"); + } + } + + if (got_response) { + /* read back response */ + *lsb = inb_p(pcipcwd_private.io_addr + 4); + *msb = inb_p(pcipcwd_private.io_addr + 5); + + /* clear WRSP bit */ + inb_p(pcipcwd_private.io_addr + 6); + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n", + cmd, *msb, *lsb); + } + + spin_unlock(&pcipcwd_private.io_lock); + + return got_response; +} + +static inline void pcipcwd_check_temperature_support(void) +{ + if (inb_p(pcipcwd_private.io_addr) != 0xF0) + pcipcwd_private.supports_temp = 1; +} + +static int pcipcwd_get_option_switches(void) +{ + int option_switches; + + option_switches = inb_p(pcipcwd_private.io_addr + 3); + return option_switches; +} + +static void pcipcwd_show_card_info(void) +{ + int got_fw_rev, fw_rev_major, fw_rev_minor; + char fw_ver_str[20]; /* The cards firmware version */ + int option_switches; + + got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor); + if (got_fw_rev) { + sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor); + } else { + sprintf(fw_ver_str, ""); + } + + /* Get switch settings */ + option_switches = pcipcwd_get_option_switches(); + + printk(KERN_INFO PFX "Found card at port 0x%04x (Firmware: %s) %s temp option\n", + (int) pcipcwd_private.io_addr, fw_ver_str, + (pcipcwd_private.supports_temp ? "with" : "without")); + + printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", + option_switches, + ((option_switches & 0x10) ? "ON" : "OFF"), + ((option_switches & 0x08) ? "ON" : "OFF")); + + if (pcipcwd_private.boot_status & WDIOF_CARDRESET) + printk(KERN_INFO PFX "Previous reset was caused by the Watchdog card\n"); + + if (pcipcwd_private.boot_status & WDIOF_OVERHEAT) + printk(KERN_INFO PFX "Card sensed a CPU Overheat\n"); + + if (pcipcwd_private.boot_status == 0) + printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); +} + +static int pcipcwd_start(void) +{ + int stat_reg; + + spin_lock(&pcipcwd_private.io_lock); + outb_p(0x00, pcipcwd_private.io_addr + 3); + udelay(1000); + + stat_reg = inb_p(pcipcwd_private.io_addr + 2); + spin_unlock(&pcipcwd_private.io_lock); + + if (stat_reg & WD_PCI_WDIS) { + printk(KERN_ERR PFX "Card timer not enabled\n"); + return -1; + } + + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "Watchdog started\n"); + + return 0; +} + +static int pcipcwd_stop(void) +{ + int stat_reg; + + spin_lock(&pcipcwd_private.io_lock); + outb_p(0xA5, pcipcwd_private.io_addr + 3); + udelay(1000); + + outb_p(0xA5, pcipcwd_private.io_addr + 3); + udelay(1000); + + stat_reg = inb_p(pcipcwd_private.io_addr + 2); + spin_unlock(&pcipcwd_private.io_lock); + + if (!(stat_reg & WD_PCI_WDIS)) { + printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n"); + return -1; + } + + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "Watchdog stopped\n"); + + return 0; +} + +static int pcipcwd_keepalive(void) +{ + /* Re-trigger watchdog by writing to port 0 */ + outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */ + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); + + return 0; +} + +static int pcipcwd_set_heartbeat(int t) +{ + int t_msb = t / 256; + int t_lsb = t % 256; + + if ((t < 0x0001) || (t > 0xFFFF)) + return -EINVAL; + + /* Write new heartbeat to watchdog */ + send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb); + + heartbeat = t; + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "New heartbeat: %d\n", + heartbeat); + + return 0; +} + +static int pcipcwd_get_status(int *status) +{ + int control_status; + + *status=0; + control_status = inb_p(pcipcwd_private.io_addr + 1); + if (control_status & WD_PCI_WTRP) + *status |= WDIOF_CARDRESET; + if (control_status & WD_PCI_TTRP) { + *status |= WDIOF_OVERHEAT; + if (temp_panic) + panic(PFX "Temperature overheat trip!\n"); + } + + if (debug >= DEBUG) + printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n", + control_status); + + return 0; +} + +static int pcipcwd_clear_status(void) +{ + int control_status; + int msb; + int reset_counter; + + if (debug >= VERBOSE) + printk(KERN_INFO PFX "clearing watchdog trip status & LED\n"); + + control_status = inb_p(pcipcwd_private.io_addr + 1); + + if (debug >= DEBUG) { + printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status); + printk(KERN_DEBUG PFX "sending: 0x%02x\n", + (control_status & WD_PCI_R2DS) | WD_PCI_WTRP); + } + + /* clear trip status & LED and keep mode of relay 2 */ + outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); + + /* clear reset counter */ + msb=0; + reset_counter=0xff; + send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter); + + if (debug >= DEBUG) { + printk(KERN_DEBUG PFX "reset count was: 0x%02x\n", + reset_counter); + } + + return 0; +} + +static int pcipcwd_get_temperature(int *temperature) +{ + *temperature = 0; + if (!pcipcwd_private.supports_temp) + return -ENODEV; + + *temperature = inb_p(pcipcwd_private.io_addr); + + /* + * Convert celsius to fahrenheit, since this was + * the decided 'standard' for this return value. + */ + *temperature = (*temperature * 9 / 5) + 32; + + if (debug >= DEBUG) { + printk(KERN_DEBUG PFX "temperature is: %d F\n", + *temperature); + } + + return 0; +} + +static int pcipcwd_get_timeleft(int *time_left) +{ + int msb; + int lsb; + + /* Read the time that's left before rebooting */ + /* Note: if the board is not yet armed then we will read 0xFFFF */ + send_command(CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb); + + *time_left = (msb << 8) + lsb; + + if (debug >= VERBOSE) + printk(KERN_DEBUG PFX "Time left before next reboot: %d\n", + *time_left); + + return 0; +} + +/* + * /dev/watchdog handling + */ + +static ssize_t pcipcwd_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if (len) { + if (!nowayout) { + size_t i; + + /* note: just in case someone wrote the magic character + * five months ago... */ + expect_release = 0; + + /* scan to see whether or not we got the magic character */ + for (i = 0; i != len; i++) { + char c; + if(get_user(c, data+i)) + return -EFAULT; + if (c == 'V') + expect_release = 42; + } + } + + /* someone wrote to us, we should reload the timer */ + pcipcwd_keepalive(); + } + return len; +} + +static int pcipcwd_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident = { + .options = WDIOF_OVERHEAT | + WDIOF_CARDRESET | + WDIOF_KEEPALIVEPING | + WDIOF_SETTIMEOUT | + WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = WATCHDOG_DRIVER_NAME, + }; + + switch (cmd) { + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, + sizeof (ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + { + int status; + + pcipcwd_get_status(&status); + + return put_user(status, p); + } + + case WDIOC_GETBOOTSTATUS: + return put_user(pcipcwd_private.boot_status, p); + + case WDIOC_GETTEMP: + { + int temperature; + + if (pcipcwd_get_temperature(&temperature)) + return -EFAULT; + + return put_user(temperature, p); + } + + case WDIOC_KEEPALIVE: + pcipcwd_keepalive(); + return 0; + + case WDIOC_SETOPTIONS: + { + int new_options, retval = -EINVAL; + + if (get_user (new_options, p)) + return -EFAULT; + + if (new_options & WDIOS_DISABLECARD) { + if (pcipcwd_stop()) + return -EIO; + retval = 0; + } + + if (new_options & WDIOS_ENABLECARD) { + if (pcipcwd_start()) + return -EIO; + retval = 0; + } + + if (new_options & WDIOS_TEMPPANIC) { + temp_panic = 1; + retval = 0; + } + + return retval; + } + + case WDIOC_SETTIMEOUT: + { + int new_heartbeat; + + if (get_user(new_heartbeat, p)) + return -EFAULT; + + if (pcipcwd_set_heartbeat(new_heartbeat)) + return -EINVAL; + + pcipcwd_keepalive(); + /* Fall */ + } + + case WDIOC_GETTIMEOUT: + return put_user(heartbeat, p); + + case WDIOC_GETTIMELEFT: + { + int time_left; + + if (pcipcwd_get_timeleft(&time_left)) + return -EFAULT; + + return put_user(time_left, p); + } + + default: + return -ENOTTY; + } +} + +static int pcipcwd_open(struct inode *inode, struct file *file) +{ + /* /dev/watchdog can only be opened once */ + if (test_and_set_bit(0, &is_active)) { + if (debug >= VERBOSE) + printk(KERN_ERR PFX "Attempt to open already opened device.\n"); + return -EBUSY; + } + + /* Activate */ + pcipcwd_start(); + pcipcwd_keepalive(); + return nonseekable_open(inode, file); +} + +static int pcipcwd_release(struct inode *inode, struct file *file) +{ + /* + * Shut off the timer. + */ + if (expect_release == 42) { + pcipcwd_stop(); + } else { + printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); + pcipcwd_keepalive(); + } + expect_release = 0; + clear_bit(0, &is_active); + return 0; +} + +/* + * /dev/temperature handling + */ + +static ssize_t pcipcwd_temp_read(struct file *file, char __user *data, + size_t len, loff_t *ppos) +{ + int temperature; + + if (pcipcwd_get_temperature(&temperature)) + return -EFAULT; + + if (copy_to_user (data, &temperature, 1)) + return -EFAULT; + + return 1; +} + +static int pcipcwd_temp_open(struct inode *inode, struct file *file) +{ + if (!pcipcwd_private.supports_temp) + return -ENODEV; + + return nonseekable_open(inode, file); +} + +static int pcipcwd_temp_release(struct inode *inode, struct file *file) +{ + return 0; +} + +/* + * Notify system + */ + +static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) +{ + if (code==SYS_DOWN || code==SYS_HALT) { + /* Turn the WDT off */ + pcipcwd_stop(); + } + + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + +static const struct file_operations pcipcwd_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = pcipcwd_write, + .ioctl = pcipcwd_ioctl, + .open = pcipcwd_open, + .release = pcipcwd_release, +}; + +static struct miscdevice pcipcwd_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &pcipcwd_fops, +}; + +static const struct file_operations pcipcwd_temp_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = pcipcwd_temp_read, + .open = pcipcwd_temp_open, + .release = pcipcwd_temp_release, +}; + +static struct miscdevice pcipcwd_temp_miscdev = { + .minor = TEMP_MINOR, + .name = "temperature", + .fops = &pcipcwd_temp_fops, +}; + +static struct notifier_block pcipcwd_notifier = { + .notifier_call = pcipcwd_notify_sys, +}; + +/* + * Init & exit routines + */ + +int __devinit pcipcwd_card_init(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + int ret = -EIO; + + cards_found++; + if (cards_found == 1) + printk(KERN_INFO PFX DRIVER_VERSION); + + if (cards_found > 1) { + printk(KERN_ERR PFX "This driver only supports 1 device\n"); + return -ENODEV; + } + + if (pci_enable_device(pdev)) { + printk(KERN_ERR PFX "Not possible to enable PCI Device\n"); + return -ENODEV; + } + + if (pci_resource_start(pdev, 0) == 0x0000) { + printk(KERN_ERR PFX "No I/O-Address for card detected\n"); + ret = -ENODEV; + goto err_out_disable_device; + } + + pcipcwd_private.pdev = pdev; + pcipcwd_private.io_addr = pci_resource_start(pdev, 0); + + if (pci_request_regions(pdev, WATCHDOG_NAME)) { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + (int) pcipcwd_private.io_addr); + ret = -EIO; + goto err_out_disable_device; + } + + /* get the boot_status */ + pcipcwd_get_status(&pcipcwd_private.boot_status); + + /* clear the "card caused reboot" flag */ + pcipcwd_clear_status(); + + /* disable card */ + pcipcwd_stop(); + + /* Check whether or not the card supports the temperature device */ + pcipcwd_check_temperature_support(); + + /* Show info about the card itself */ + pcipcwd_show_card_info(); + + /* Check that the heartbeat value is within it's range ; if not reset to the default */ + if (pcipcwd_set_heartbeat(heartbeat)) { + pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); + printk(KERN_INFO PFX "heartbeat value must be 0"); +MODULE_DESCRIPTION("Berkshire PCI-PC Watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); +MODULE_ALIAS_MISCDEV(TEMP_MINOR); diff --git a/ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c b/ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c new file mode 100644 index 000000000..c7b2045bc --- /dev/null +++ b/ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c @@ -0,0 +1,408 @@ +/* + * 60xx Single Board Computer Watchdog Timer driver for Linux 2.2.x + * + * Based on acquirewdt.c by Alan Cox. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * The author does NOT admit liability nor provide warranty for + * any of this software. This material is provided "AS-IS" in + * the hope that it may be useful for others. + * + * (c) Copyright 2000 Jakob Oestergaard + * + * 12/4 - 2000 [Initial revision] + * 25/4 - 2000 Added /dev/watchdog support + * 09/5 - 2001 [smj@oro.net] fixed fop_write to "return 1" on success + * 12/4 - 2002 [rob@osinvestor.com] eliminate fop_read + * fix possible wdt_is_open race + * add CONFIG_WATCHDOG_NOWAYOUT support + * remove lock_kernel/unlock_kernel pairs + * added KERN_* to printk's + * got rid of extraneous comments + * changed watchdog_info to correctly reflect what the driver offers + * added WDIOC_GETSTATUS, WDIOC_GETBOOTSTATUS, WDIOC_SETTIMEOUT, + * WDIOC_GETTIMEOUT, and WDIOC_SETOPTIONS ioctls + * 09/8 - 2003 [wim@iguana.be] cleanup of trailing spaces + * use module_param + * made timeout (the emulated heartbeat) a module_param + * made the keepalive ping an internal subroutine + * made wdt_stop and wdt_start module params + * added extra printk's for startup problems + * added MODULE_AUTHOR and MODULE_DESCRIPTION info + * + * + * This WDT driver is different from the other Linux WDT + * drivers in the following ways: + * *) The driver will ping the watchdog by itself, because this + * particular WDT has a very short timeout (one second) and it + * would be insane to count on any userspace daemon always + * getting scheduled within that time frame. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define OUR_NAME "sbc60xxwdt" +#define PFX OUR_NAME ": " + +/* + * You must set these - The driver cannot probe for the settings + */ + +static int wdt_stop = 0x45; +module_param(wdt_stop, int, 0); +MODULE_PARM_DESC(wdt_stop, "SBC60xx WDT 'stop' io port (default 0x45)"); + +static int wdt_start = 0x443; +module_param(wdt_start, int, 0); +MODULE_PARM_DESC(wdt_start, "SBC60xx WDT 'start' io port (default 0x443)"); + +/* + * The 60xx board can use watchdog timeout values from one second + * to several minutes. The default is one second, so if we reset + * the watchdog every ~250ms we should be safe. + */ + +#define WDT_INTERVAL (HZ/4+1) + +/* + * We must not require too good response from the userspace daemon. + * Here we require the userspace daemon to send us a heartbeat + * char to /dev/watchdog every 30 seconds. + * If the daemon pulses us every 25 seconds, we can still afford + * a 5 second scheduling delay on the (high priority) daemon. That + * should be sufficient for a box under any load. + */ + +#define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */ +static int timeout = WATCHDOG_TIMEOUT; /* in seconds, will be multiplied by HZ to get seconds to wait for a ping */ +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +static void wdt_timer_ping(unsigned long); +static struct timer_list timer; +static unsigned long next_heartbeat; +static unsigned long wdt_is_open; +static char wdt_expect_close; + +/* + * Whack the dog + */ + +static void wdt_timer_ping(unsigned long data) +{ + /* If we got a heartbeat pulse within the WDT_US_INTERVAL + * we agree to ping the WDT + */ + if(time_before(jiffies, next_heartbeat)) + { + /* Ping the WDT by reading from wdt_start */ + inb_p(wdt_start); + /* Re-set the timer interval */ + timer.expires = jiffies + WDT_INTERVAL; + add_timer(&timer); + } else { + printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); + } +} + +/* + * Utility routines + */ + +static void wdt_startup(void) +{ + next_heartbeat = jiffies + (timeout * HZ); + + /* Start the timer */ + timer.expires = jiffies + WDT_INTERVAL; + add_timer(&timer); + printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); +} + +static void wdt_turnoff(void) +{ + /* Stop the timer */ + del_timer(&timer); + inb_p(wdt_stop); + printk(KERN_INFO PFX "Watchdog timer is now disabled...\n"); +} + +static void wdt_keepalive(void) +{ + /* user land ping */ + next_heartbeat = jiffies + (timeout * HZ); +} + +/* + * /dev/watchdog handling + */ + +static ssize_t fop_write(struct file * file, const char __user * buf, size_t count, loff_t * ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if(count) + { + if (!nowayout) + { + size_t ofs; + + /* note: just in case someone wrote the magic character + * five months ago... */ + wdt_expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for(ofs = 0; ofs != count; ofs++) + { + char c; + if(get_user(c, buf+ofs)) + return -EFAULT; + if(c == 'V') + wdt_expect_close = 42; + } + } + + /* Well, anyhow someone wrote to us, we should return that favour */ + wdt_keepalive(); + } + return count; +} + +static int fop_open(struct inode * inode, struct file * file) +{ + nonseekable_open(inode, file); + + /* Just in case we're already talking to someone... */ + if(test_and_set_bit(0, &wdt_is_open)) + return -EBUSY; + + if (nowayout) + __module_get(THIS_MODULE); + + /* Good, fire up the show */ + wdt_startup(); + return 0; +} + +static int fop_close(struct inode * inode, struct file * file) +{ + if(wdt_expect_close == 42) + wdt_turnoff(); + else { + del_timer(&timer); + printk(KERN_CRIT PFX "device file closed unexpectedly. Will not stop the WDT!\n"); + } + clear_bit(0, &wdt_is_open); + wdt_expect_close = 0; + return 0; +} + +static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident= + { + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "SBC60xx", + }; + + switch(cmd) + { + default: + return -ENOTTY; + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0; + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + case WDIOC_KEEPALIVE: + wdt_keepalive(); + return 0; + case WDIOC_SETOPTIONS: + { + int new_options, retval = -EINVAL; + + if(get_user(new_options, p)) + return -EFAULT; + + if(new_options & WDIOS_DISABLECARD) { + wdt_turnoff(); + retval = 0; + } + + if(new_options & WDIOS_ENABLECARD) { + wdt_startup(); + retval = 0; + } + + return retval; + } + case WDIOC_SETTIMEOUT: + { + int new_timeout; + + if(get_user(new_timeout, p)) + return -EFAULT; + + if(new_timeout < 1 || new_timeout > 3600) /* arbitrary upper limit */ + return -EINVAL; + + timeout = new_timeout; + wdt_keepalive(); + /* Fall through */ + } + case WDIOC_GETTIMEOUT: + return put_user(timeout, p); + } +} + +static const struct file_operations wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = fop_write, + .open = fop_open, + .release = fop_close, + .ioctl = fop_ioctl, +}; + +static struct miscdevice wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt_fops, +}; + +/* + * Notifier for system down + */ + +static int wdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if(code==SYS_DOWN || code==SYS_HALT) + wdt_turnoff(); + return NOTIFY_DONE; +} + +/* + * The WDT needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ + +static struct notifier_block wdt_notifier= +{ + .notifier_call = wdt_notify_sys, +}; + +static void __exit sbc60xxwdt_unload(void) +{ + wdt_turnoff(); + + /* Deregister */ + misc_deregister(&wdt_miscdev); + + unregister_reboot_notifier(&wdt_notifier); + if ((wdt_stop != 0x45) && (wdt_stop != wdt_start)) + release_region(wdt_stop,1); + release_region(wdt_start,1); +} + +static int __init sbc60xxwdt_init(void) +{ + int rc = -EBUSY; + + if(timeout < 1 || timeout > 3600) /* arbitrary upper limit */ + { + timeout = WATCHDOG_TIMEOUT; + printk(KERN_INFO PFX "timeout value must be 1<=x<=3600, using %d\n", + timeout); + } + + if (!request_region(wdt_start, 1, "SBC 60XX WDT")) + { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + wdt_start); + rc = -EIO; + goto err_out; + } + + /* We cannot reserve 0x45 - the kernel already has! */ + if ((wdt_stop != 0x45) && (wdt_stop != wdt_start)) + { + if (!request_region(wdt_stop, 1, "SBC 60XX WDT")) + { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + wdt_stop); + rc = -EIO; + goto err_out_region1; + } + } + + init_timer(&timer); + timer.function = wdt_timer_ping; + timer.data = 0; + + rc = misc_register(&wdt_miscdev); + if (rc) + { + printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + wdt_miscdev.minor, rc); + goto err_out_region2; + } + + rc = register_reboot_notifier(&wdt_notifier); + if (rc) + { + printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", + rc); + goto err_out_miscdev; + } + + printk(KERN_INFO PFX "WDT driver for 60XX single board computer initialised. timeout=%d sec (nowayout=%d)\n", + timeout, nowayout); + + return 0; + +err_out_miscdev: + misc_deregister(&wdt_miscdev); +err_out_region2: + if ((wdt_stop != 0x45) && (wdt_stop != wdt_start)) + release_region(wdt_stop,1); +err_out_region1: + release_region(wdt_start,1); +err_out: + return rc; +} + +module_init(sbc60xxwdt_init); +module_exit(sbc60xxwdt_unload); + +MODULE_AUTHOR("Jakob Oestergaard "); +MODULE_DESCRIPTION("60xx Single Board Computer Watchdog Timer driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.c b/ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.c new file mode 100644 index 000000000..8e870424a --- /dev/null +++ b/ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.c @@ -0,0 +1,466 @@ +/* + * National Semiconductor PC87307/PC97307 (ala SC1200) WDT driver + * (c) Copyright 2002 Zwane Mwaikambo , + * All Rights Reserved. + * Based on wdt.c and wdt977.c by Alan Cox and Woody Suwalski respectively. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * The author(s) of this software shall not be held liable for damages + * of any nature resulting due to the use of this software. This + * software is provided AS-IS with no warranties. + * + * Changelog: + * 20020220 Zwane Mwaikambo Code based on datasheet, no hardware. + * 20020221 Zwane Mwaikambo Cleanups as suggested by Jeff Garzik and Alan Cox. + * 20020222 Zwane Mwaikambo Added probing. + * 20020225 Zwane Mwaikambo Added ISAPNP support. + * 20020412 Rob Radez Broke out start/stop functions + * Return proper status instead of temperature warning + * Add WDIOC_GETBOOTSTATUS and WDIOC_SETOPTIONS ioctls + * Fix CONFIG_WATCHDOG_NOWAYOUT + * 20020530 Joel Becker Add Matt Domsch's nowayout module option + * 20030116 Adam Belay Updated to the latest pnp code + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define SC1200_MODULE_VER "build 20020303" +#define SC1200_MODULE_NAME "sc1200wdt" +#define PFX SC1200_MODULE_NAME ": " + +#define MAX_TIMEOUT 255 /* 255 minutes */ +#define PMIR (io) /* Power Management Index Register */ +#define PMDR (io+1) /* Power Management Data Register */ + +/* Data Register indexes */ +#define FER1 0x00 /* Function enable register 1 */ +#define FER2 0x01 /* Function enable register 2 */ +#define PMC1 0x02 /* Power Management Ctrl 1 */ +#define PMC2 0x03 /* Power Management Ctrl 2 */ +#define PMC3 0x04 /* Power Management Ctrl 3 */ +#define WDTO 0x05 /* Watchdog timeout register */ +#define WDCF 0x06 /* Watchdog config register */ +#define WDST 0x07 /* Watchdog status register */ + +/* WDCF bitfields - which devices assert WDO */ +#define KBC_IRQ 0x01 /* Keyboard Controller */ +#define MSE_IRQ 0x02 /* Mouse */ +#define UART1_IRQ 0x03 /* Serial0 */ +#define UART2_IRQ 0x04 /* Serial1 */ +/* 5 -7 are reserved */ + +static char banner[] __initdata = KERN_INFO PFX SC1200_MODULE_VER; +static int timeout = 1; +static int io = 0; +static int io_len = 2; /* for non plug and play */ +static struct semaphore open_sem; +static char expect_close; +static spinlock_t sc1200wdt_lock; /* io port access serialisation */ + +#if defined CONFIG_PNP +static int isapnp = 1; +static struct pnp_dev *wdt_dev; + +module_param(isapnp, int, 0); +MODULE_PARM_DESC(isapnp, "When set to 0 driver ISA PnP support will be disabled"); +#endif + +module_param(io, int, 0); +MODULE_PARM_DESC(io, "io port"); +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "range is 0-255 minutes, default is 1"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + + + +/* Read from Data Register */ +static inline void sc1200wdt_read_data(unsigned char index, unsigned char *data) +{ + spin_lock(&sc1200wdt_lock); + outb_p(index, PMIR); + *data = inb(PMDR); + spin_unlock(&sc1200wdt_lock); +} + + +/* Write to Data Register */ +static inline void sc1200wdt_write_data(unsigned char index, unsigned char data) +{ + spin_lock(&sc1200wdt_lock); + outb_p(index, PMIR); + outb(data, PMDR); + spin_unlock(&sc1200wdt_lock); +} + + +static void sc1200wdt_start(void) +{ + unsigned char reg; + + sc1200wdt_read_data(WDCF, ®); + /* assert WDO when any of the following interrupts are triggered too */ + reg |= (KBC_IRQ | MSE_IRQ | UART1_IRQ | UART2_IRQ); + sc1200wdt_write_data(WDCF, reg); + /* set the timeout and get the ball rolling */ + sc1200wdt_write_data(WDTO, timeout); +} + + +static void sc1200wdt_stop(void) +{ + sc1200wdt_write_data(WDTO, 0); +} + + +/* This returns the status of the WDO signal, inactive high. */ +static inline int sc1200wdt_status(void) +{ + unsigned char ret; + + sc1200wdt_read_data(WDST, &ret); + /* If the bit is inactive, the watchdog is enabled, so return + * KEEPALIVEPING which is a bit of a kludge because there's nothing + * else for enabled/disabled status + */ + return (ret & 0x01) ? 0 : WDIOF_KEEPALIVEPING; /* bits 1 - 7 are undefined */ +} + + +static int sc1200wdt_open(struct inode *inode, struct file *file) +{ + nonseekable_open(inode, file); + + /* allow one at a time */ + if (down_trylock(&open_sem)) + return -EBUSY; + + if (timeout > MAX_TIMEOUT) + timeout = MAX_TIMEOUT; + + sc1200wdt_start(); + printk(KERN_INFO PFX "Watchdog enabled, timeout = %d min(s)", timeout); + + return 0; +} + + +static int sc1200wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ + int new_timeout; + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident = { + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, + .firmware_version = 0, + .identity = "PC87307/PC97307", + }; + + switch (cmd) { + default: + return -ENOTTY; + + case WDIOC_GETSUPPORT: + if (copy_to_user(argp, &ident, sizeof ident)) + return -EFAULT; + return 0; + + case WDIOC_GETSTATUS: + return put_user(sc1200wdt_status(), p); + + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + + case WDIOC_KEEPALIVE: + sc1200wdt_write_data(WDTO, timeout); + return 0; + + case WDIOC_SETTIMEOUT: + if (get_user(new_timeout, p)) + return -EFAULT; + + /* the API states this is given in secs */ + new_timeout /= 60; + if (new_timeout < 0 || new_timeout > MAX_TIMEOUT) + return -EINVAL; + + timeout = new_timeout; + sc1200wdt_write_data(WDTO, timeout); + /* fall through and return the new timeout */ + + case WDIOC_GETTIMEOUT: + return put_user(timeout * 60, p); + + case WDIOC_SETOPTIONS: + { + int options, retval = -EINVAL; + + if (get_user(options, p)) + return -EFAULT; + + if (options & WDIOS_DISABLECARD) { + sc1200wdt_stop(); + retval = 0; + } + + if (options & WDIOS_ENABLECARD) { + sc1200wdt_start(); + retval = 0; + } + + return retval; + } + } +} + + +static int sc1200wdt_release(struct inode *inode, struct file *file) +{ + if (expect_close == 42) { + sc1200wdt_stop(); + printk(KERN_INFO PFX "Watchdog disabled\n"); + } else { + sc1200wdt_write_data(WDTO, timeout); + printk(KERN_CRIT PFX "Unexpected close!, timeout = %d min(s)\n", timeout); + } + up(&open_sem); + expect_close = 0; + + return 0; +} + + +static ssize_t sc1200wdt_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) +{ + if (len) { + if (!nowayout) { + size_t i; + + expect_close = 0; + + for (i = 0; i != len; i++) { + char c; + + if (get_user(c, data+i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + + sc1200wdt_write_data(WDTO, timeout); + return len; + } + + return 0; +} + + +static int sc1200wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused) +{ + if (code == SYS_DOWN || code == SYS_HALT) + sc1200wdt_stop(); + + return NOTIFY_DONE; +} + + +static struct notifier_block sc1200wdt_notifier = +{ + .notifier_call = sc1200wdt_notify_sys, +}; + +static const struct file_operations sc1200wdt_fops = +{ + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = sc1200wdt_write, + .ioctl = sc1200wdt_ioctl, + .open = sc1200wdt_open, + .release = sc1200wdt_release, +}; + +static struct miscdevice sc1200wdt_miscdev = +{ + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &sc1200wdt_fops, +}; + + +static int __init sc1200wdt_probe(void) +{ + /* The probe works by reading the PMC3 register's default value of 0x0e + * there is one caveat, if the device disables the parallel port or any + * of the UARTs we won't be able to detect it. + * Nb. This could be done with accuracy by reading the SID registers, but + * we don't have access to those io regions. + */ + + unsigned char reg; + + sc1200wdt_read_data(PMC3, ®); + reg &= 0x0f; /* we don't want the UART busy bits */ + return (reg == 0x0e) ? 0 : -ENODEV; +} + + +#if defined CONFIG_PNP + +static struct pnp_device_id scl200wdt_pnp_devices[] = { + /* National Semiconductor PC87307/PC97307 watchdog component */ + {.id = "NSC0800", .driver_data = 0}, + {.id = ""}, +}; + +static int scl200wdt_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) +{ + /* this driver only supports one card at a time */ + if (wdt_dev || !isapnp) + return -EBUSY; + + wdt_dev = dev; + io = pnp_port_start(wdt_dev, 0); + io_len = pnp_port_len(wdt_dev, 0); + + if (!request_region(io, io_len, SC1200_MODULE_NAME)) { + printk(KERN_ERR PFX "Unable to register IO port %#x\n", io); + return -EBUSY; + } + + printk(KERN_INFO "scl200wdt: PnP device found at io port %#x/%d\n", io, io_len); + return 0; +} + +static void scl200wdt_pnp_remove(struct pnp_dev * dev) +{ + if (wdt_dev){ + release_region(io, io_len); + wdt_dev = NULL; + } +} + +static struct pnp_driver scl200wdt_pnp_driver = { + .name = "scl200wdt", + .id_table = scl200wdt_pnp_devices, + .probe = scl200wdt_pnp_probe, + .remove = scl200wdt_pnp_remove, +}; + +#endif /* CONFIG_PNP */ + + +static int __init sc1200wdt_init(void) +{ + int ret; + + printk("%s\n", banner); + + spin_lock_init(&sc1200wdt_lock); + sema_init(&open_sem, 1); + +#if defined CONFIG_PNP + if (isapnp) { + ret = pnp_register_driver(&scl200wdt_pnp_driver); + if (ret) + goto out_clean; + } +#endif + + if (io == -1) { + printk(KERN_ERR PFX "io parameter must be specified\n"); + ret = -EINVAL; + goto out_pnp; + } + +#if defined CONFIG_PNP + /* now that the user has specified an IO port and we haven't detected + * any devices, disable pnp support */ + isapnp = 0; + pnp_unregister_driver(&scl200wdt_pnp_driver); +#endif + + if (!request_region(io, io_len, SC1200_MODULE_NAME)) { + printk(KERN_ERR PFX "Unable to register IO port %#x\n", io); + ret = -EBUSY; + goto out_pnp; + } + + ret = sc1200wdt_probe(); + if (ret) + goto out_io; + + ret = register_reboot_notifier(&sc1200wdt_notifier); + if (ret) { + printk(KERN_ERR PFX "Unable to register reboot notifier err = %d\n", ret); + goto out_io; + } + + ret = misc_register(&sc1200wdt_miscdev); + if (ret) { + printk(KERN_ERR PFX "Unable to register miscdev on minor %d\n", WATCHDOG_MINOR); + goto out_rbt; + } + + /* ret = 0 */ + +out_clean: + return ret; + +out_rbt: + unregister_reboot_notifier(&sc1200wdt_notifier); + +out_io: + release_region(io, io_len); + +out_pnp: +#if defined CONFIG_PNP + if (isapnp) + pnp_unregister_driver(&scl200wdt_pnp_driver); +#endif + goto out_clean; +} + + +static void __exit sc1200wdt_exit(void) +{ + misc_deregister(&sc1200wdt_miscdev); + unregister_reboot_notifier(&sc1200wdt_notifier); + +#if defined CONFIG_PNP + if(isapnp) + pnp_unregister_driver(&scl200wdt_pnp_driver); + else +#endif + release_region(io, io_len); +} + +module_init(sc1200wdt_init); +module_exit(sc1200wdt_exit); + +MODULE_AUTHOR("Zwane Mwaikambo "); +MODULE_DESCRIPTION("Driver for National Semiconductor PC87307/PC97307 watchdog component"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.c b/ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.c new file mode 100644 index 000000000..caec37ba7 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.c @@ -0,0 +1,443 @@ +/* + * AMD Elan SC520 processor Watchdog Timer driver + * + * Based on acquirewdt.c by Alan Cox, + * and sbc60xxwdt.c by Jakob Oestergaard + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * The authors do NOT admit liability nor provide warranty for + * any of this software. This material is provided "AS-IS" in + * the hope that it may be useful for others. + * + * (c) Copyright 2001 Scott Jennings + * 9/27 - 2001 [Initial release] + * + * Additional fixes Alan Cox + * - Fixed formatting + * - Removed debug printks + * - Fixed SMP built kernel deadlock + * - Switched to private locks not lock_kernel + * - Used ioremap/writew/readw + * - Added NOWAYOUT support + * 4/12 - 2002 Changes by Rob Radez + * - Change comments + * - Eliminate fop_llseek + * - Change CONFIG_WATCHDOG_NOWAYOUT semantics + * - Add KERN_* tags to printks + * - fix possible wdt_is_open race + * - Report proper capabilities in watchdog_info + * - Add WDIOC_{GETSTATUS, GETBOOTSTATUS, SETTIMEOUT, + * GETTIMEOUT, SETOPTIONS} ioctls + * 09/8 - 2003 Changes by Wim Van Sebroeck + * - cleanup of trailing spaces + * - added extra printk's for startup problems + * - use module_param + * - made timeout (the emulated heartbeat) a module_param + * - made the keepalive ping an internal subroutine + * 3/27 - 2004 Changes by Sean Young + * - set MMCR_BASE to 0xfffef000 + * - CBAR does not need to be read + * - removed debugging printks + * + * This WDT driver is different from most other Linux WDT + * drivers in that the driver will ping the watchdog by itself, + * because this particular WDT has a very short timeout (1.6 + * seconds) and it would be insane to count on any userspace + * daemon always getting scheduled within that time frame. + * + * This driver uses memory mapped IO, and spinlock. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define OUR_NAME "sc520_wdt" +#define PFX OUR_NAME ": " + +/* + * The AMD Elan SC520 timeout value is 492us times a power of 2 (0-7) + * + * 0: 492us 2: 1.01s 4: 4.03s 6: 16.22s + * 1: 503ms 3: 2.01s 5: 8.05s 7: 32.21s + * + * We will program the SC520 watchdog for a timeout of 2.01s. + * If we reset the watchdog every ~250ms we should be safe. + */ + +#define WDT_INTERVAL (HZ/4+1) + +/* + * We must not require too good response from the userspace daemon. + * Here we require the userspace daemon to send us a heartbeat + * char to /dev/watchdog every 30 seconds. + */ + +#define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */ +static int timeout = WATCHDOG_TIMEOUT; /* in seconds, will be multiplied by HZ to get seconds to wait for a ping */ +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +/* + * AMD Elan SC520 - Watchdog Timer Registers + */ +#define MMCR_BASE 0xfffef000 /* The default base address */ +#define OFFS_WDTMRCTL 0xCB0 /* Watchdog Timer Control Register */ + +/* WDT Control Register bit definitions */ +#define WDT_EXP_SEL_01 0x0001 /* [01] Time-out = 496 us (with 33 Mhz clk). */ +#define WDT_EXP_SEL_02 0x0002 /* [02] Time-out = 508 ms (with 33 Mhz clk). */ +#define WDT_EXP_SEL_03 0x0004 /* [03] Time-out = 1.02 s (with 33 Mhz clk). */ +#define WDT_EXP_SEL_04 0x0008 /* [04] Time-out = 2.03 s (with 33 Mhz clk). */ +#define WDT_EXP_SEL_05 0x0010 /* [05] Time-out = 4.07 s (with 33 Mhz clk). */ +#define WDT_EXP_SEL_06 0x0020 /* [06] Time-out = 8.13 s (with 33 Mhz clk). */ +#define WDT_EXP_SEL_07 0x0040 /* [07] Time-out = 16.27s (with 33 Mhz clk). */ +#define WDT_EXP_SEL_08 0x0080 /* [08] Time-out = 32.54s (with 33 Mhz clk). */ +#define WDT_IRQ_FLG 0x1000 /* [12] Interrupt Request Flag */ +#define WDT_WRST_ENB 0x4000 /* [14] Watchdog Timer Reset Enable */ +#define WDT_ENB 0x8000 /* [15] Watchdog Timer Enable */ + +static __u16 __iomem *wdtmrctl; + +static void wdt_timer_ping(unsigned long); +static struct timer_list timer; +static unsigned long next_heartbeat; +static unsigned long wdt_is_open; +static char wdt_expect_close; +static spinlock_t wdt_spinlock; + +/* + * Whack the dog + */ + +static void wdt_timer_ping(unsigned long data) +{ + /* If we got a heartbeat pulse within the WDT_US_INTERVAL + * we agree to ping the WDT + */ + if(time_before(jiffies, next_heartbeat)) + { + /* Ping the WDT */ + spin_lock(&wdt_spinlock); + writew(0xAAAA, wdtmrctl); + writew(0x5555, wdtmrctl); + spin_unlock(&wdt_spinlock); + + /* Re-set the timer interval */ + timer.expires = jiffies + WDT_INTERVAL; + add_timer(&timer); + } else { + printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); + } +} + +/* + * Utility routines + */ + +static void wdt_config(int writeval) +{ + __u16 dummy; + unsigned long flags; + + /* buy some time (ping) */ + spin_lock_irqsave(&wdt_spinlock, flags); + dummy=readw(wdtmrctl); /* ensure write synchronization */ + writew(0xAAAA, wdtmrctl); + writew(0x5555, wdtmrctl); + /* unlock WDT = make WDT configuration register writable one time */ + writew(0x3333, wdtmrctl); + writew(0xCCCC, wdtmrctl); + /* write WDT configuration register */ + writew(writeval, wdtmrctl); + spin_unlock_irqrestore(&wdt_spinlock, flags); +} + +static int wdt_startup(void) +{ + next_heartbeat = jiffies + (timeout * HZ); + + /* Start the timer */ + timer.expires = jiffies + WDT_INTERVAL; + add_timer(&timer); + + /* Start the watchdog */ + wdt_config(WDT_ENB | WDT_WRST_ENB | WDT_EXP_SEL_04); + + printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); + return 0; +} + +static int wdt_turnoff(void) +{ + /* Stop the timer */ + del_timer(&timer); + + /* Stop the watchdog */ + wdt_config(0); + + printk(KERN_INFO PFX "Watchdog timer is now disabled...\n"); + return 0; +} + +static int wdt_keepalive(void) +{ + /* user land ping */ + next_heartbeat = jiffies + (timeout * HZ); + return 0; +} + +static int wdt_set_heartbeat(int t) +{ + if ((t < 1) || (t > 3600)) /* arbitrary upper limit */ + return -EINVAL; + + timeout = t; + return 0; +} + +/* + * /dev/watchdog handling + */ + +static ssize_t fop_write(struct file * file, const char __user * buf, size_t count, loff_t * ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if(count) { + if (!nowayout) { + size_t ofs; + + /* note: just in case someone wrote the magic character + * five months ago... */ + wdt_expect_close = 0; + + /* now scan */ + for(ofs = 0; ofs != count; ofs++) { + char c; + if (get_user(c, buf + ofs)) + return -EFAULT; + if(c == 'V') + wdt_expect_close = 42; + } + } + + /* Well, anyhow someone wrote to us, we should return that favour */ + wdt_keepalive(); + } + return count; +} + +static int fop_open(struct inode * inode, struct file * file) +{ + nonseekable_open(inode, file); + + /* Just in case we're already talking to someone... */ + if(test_and_set_bit(0, &wdt_is_open)) + return -EBUSY; + if (nowayout) + __module_get(THIS_MODULE); + + /* Good, fire up the show */ + wdt_startup(); + return 0; +} + +static int fop_close(struct inode * inode, struct file * file) +{ + if(wdt_expect_close == 42) { + wdt_turnoff(); + } else { + printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); + wdt_keepalive(); + } + clear_bit(0, &wdt_is_open); + wdt_expect_close = 0; + return 0; +} + +static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident = { + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "SC520", + }; + + switch(cmd) + { + default: + return -ENOTTY; + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0; + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + case WDIOC_KEEPALIVE: + wdt_keepalive(); + return 0; + case WDIOC_SETOPTIONS: + { + int new_options, retval = -EINVAL; + + if(get_user(new_options, p)) + return -EFAULT; + + if(new_options & WDIOS_DISABLECARD) { + wdt_turnoff(); + retval = 0; + } + + if(new_options & WDIOS_ENABLECARD) { + wdt_startup(); + retval = 0; + } + + return retval; + } + case WDIOC_SETTIMEOUT: + { + int new_timeout; + + if(get_user(new_timeout, p)) + return -EFAULT; + + if(wdt_set_heartbeat(new_timeout)) + return -EINVAL; + + wdt_keepalive(); + /* Fall through */ + } + case WDIOC_GETTIMEOUT: + return put_user(timeout, p); + } +} + +static const struct file_operations wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = fop_write, + .open = fop_open, + .release = fop_close, + .ioctl = fop_ioctl, +}; + +static struct miscdevice wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt_fops, +}; + +/* + * Notifier for system down + */ + +static int wdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if(code==SYS_DOWN || code==SYS_HALT) + wdt_turnoff(); + return NOTIFY_DONE; +} + +/* + * The WDT needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ + +static struct notifier_block wdt_notifier = { + .notifier_call = wdt_notify_sys, +}; + +static void __exit sc520_wdt_unload(void) +{ + if (!nowayout) + wdt_turnoff(); + + /* Deregister */ + misc_deregister(&wdt_miscdev); + unregister_reboot_notifier(&wdt_notifier); + iounmap(wdtmrctl); +} + +static int __init sc520_wdt_init(void) +{ + int rc = -EBUSY; + + spin_lock_init(&wdt_spinlock); + + init_timer(&timer); + timer.function = wdt_timer_ping; + timer.data = 0; + + /* Check that the timeout value is within it's range ; if not reset to the default */ + if (wdt_set_heartbeat(timeout)) { + wdt_set_heartbeat(WATCHDOG_TIMEOUT); + printk(KERN_INFO PFX "timeout value must be 1<=timeout<=3600, using %d\n", + WATCHDOG_TIMEOUT); + } + + wdtmrctl = ioremap((unsigned long)(MMCR_BASE + OFFS_WDTMRCTL), 2); + if (!wdtmrctl) { + printk(KERN_ERR PFX "Unable to remap memory\n"); + rc = -ENOMEM; + goto err_out_region2; + } + + rc = register_reboot_notifier(&wdt_notifier); + if (rc) { + printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", + rc); + goto err_out_ioremap; + } + + rc = misc_register(&wdt_miscdev); + if (rc) { + printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + WATCHDOG_MINOR, rc); + goto err_out_notifier; + } + + printk(KERN_INFO PFX "WDT driver for SC520 initialised. timeout=%d sec (nowayout=%d)\n", + timeout,nowayout); + + return 0; + +err_out_notifier: + unregister_reboot_notifier(&wdt_notifier); +err_out_ioremap: + iounmap(wdtmrctl); +err_out_region2: + return rc; +} + +module_init(sc520_wdt_init); +module_exit(sc520_wdt_unload); + +MODULE_AUTHOR("Scott and Bill Jennings"); +MODULE_DESCRIPTION("Driver for watchdog timer in AMD \"Elan\" SC520 uProcessor"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c b/ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c new file mode 100644 index 000000000..9f56913b4 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c @@ -0,0 +1,627 @@ +/* + * SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x + * + * Based on acquirewdt.c by Alan Cox + * and some other existing drivers + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * The authors do NOT admit liability nor provide warranty for + * any of this software. This material is provided "AS-IS" in + * the hope that it may be useful for others. + * + * (C) Copyright 2003-2006 Sven Anders + * + * History: + * 2003 - Created version 1.0 for Linux 2.4.x. + * 2006 - Ported to Linux 2.6, added nowayout and MAGICCLOSE + * features. Released version 1.1 + * + * Theory of operation: + * + * A Watchdog Timer (WDT) is a hardware circuit that can + * reset the computer system in case of a software fault. + * You probably knew that already. + * + * Usually a userspace daemon will notify the kernel WDT driver + * via the /dev/watchdog special device file that userspace is + * still alive, at regular intervals. When such a notification + * occurs, the driver will usually tell the hardware watchdog + * that everything is in order, and that the watchdog should wait + * for yet another little while to reset the system. + * If userspace fails (RAM error, kernel bug, whatever), the + * notifications cease to occur, and the hardware watchdog will + * reset the system (causing a reboot) after the timeout occurs. + * + * Create device with: + * mknod /dev/watchdog c 10 130 + * + * For an example userspace keep-alive daemon, see: + * Documentation/watchdog/watchdog.txt + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* enable support for minutes as units? */ +/* (does not always work correctly, so disabled by default!) */ +#define SMSC_SUPPORT_MINUTES +#undef SMSC_SUPPORT_MINUTES + +#define MAX_TIMEOUT 255 + +#define UNIT_SECOND 0 +#define UNIT_MINUTE 1 + +#define MODNAME "smsc37b787_wdt: " +#define VERSION "1.1" + +#define IOPORT 0x3F0 +#define IOPORT_SIZE 2 +#define IODEV_NO 8 + +static int unit = UNIT_SECOND; /* timer's unit */ +static int timeout = 60; /* timeout value: default is 60 "units" */ +static unsigned long timer_enabled = 0; /* is the timer enabled? */ + +static char expect_close; /* is the close expected? */ + +static spinlock_t io_lock; /* to guard the watchdog from io races */ + +static int nowayout = WATCHDOG_NOWAYOUT; + +/* -- Low level function ----------------------------------------*/ + +/* unlock the IO chip */ + +static inline void open_io_config(void) +{ + outb(0x55, IOPORT); + mdelay(1); + outb(0x55, IOPORT); +} + +/* lock the IO chip */ +static inline void close_io_config(void) +{ + outb(0xAA, IOPORT); +} + +/* select the IO device */ +static inline void select_io_device(unsigned char devno) +{ + outb(0x07, IOPORT); + outb(devno, IOPORT+1); +} + +/* write to the control register */ +static inline void write_io_cr(unsigned char reg, unsigned char data) +{ + outb(reg, IOPORT); + outb(data, IOPORT+1); +} + +/* read from the control register */ +static inline char read_io_cr(unsigned char reg) +{ + outb(reg, IOPORT); + return inb(IOPORT+1); +} + +/* -- Medium level functions ------------------------------------*/ + +static inline void gpio_bit12(unsigned char reg) +{ + // -- General Purpose I/O Bit 1.2 -- + // Bit 0, In/Out: 0 = Output, 1 = Input + // Bit 1, Polarity: 0 = No Invert, 1 = Invert + // Bit 2, Group Enable Intr.: 0 = Disable, 1 = Enable + // Bit 3/4, Function select: 00 = GPI/O, 01 = WDT, 10 = P17, + // 11 = Either Edge Triggered Intr. 2 + // Bit 5/6 (Reserved) + // Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain + write_io_cr(0xE2, reg); +} + +static inline void gpio_bit13(unsigned char reg) +{ + // -- General Purpose I/O Bit 1.3 -- + // Bit 0, In/Out: 0 = Output, 1 = Input + // Bit 1, Polarity: 0 = No Invert, 1 = Invert + // Bit 2, Group Enable Intr.: 0 = Disable, 1 = Enable + // Bit 3, Function select: 0 = GPI/O, 1 = LED + // Bit 4-6 (Reserved) + // Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain + write_io_cr(0xE3, reg); +} + +static inline void wdt_timer_units(unsigned char new_units) +{ + // -- Watchdog timer units -- + // Bit 0-6 (Reserved) + // Bit 7, WDT Time-out Value Units Select + // (0 = Minutes, 1 = Seconds) + write_io_cr(0xF1, new_units); +} + +static inline void wdt_timeout_value(unsigned char new_timeout) +{ + // -- Watchdog Timer Time-out Value -- + // Bit 0-7 Binary coded units (0=Disabled, 1..255) + write_io_cr(0xF2, new_timeout); +} + +static inline void wdt_timer_conf(unsigned char conf) +{ + // -- Watchdog timer configuration -- + // Bit 0 Joystick enable: 0* = No Reset, 1 = Reset WDT upon Gameport I/O + // Bit 1 Keyboard enable: 0* = No Reset, 1 = Reset WDT upon KBD Intr. + // Bit 2 Mouse enable: 0* = No Reset, 1 = Reset WDT upon Mouse Intr. + // Bit 3 Reset the timer + // (Wrong in SMsC documentation? Given as: PowerLED Timout Enabled) + // Bit 4-7 WDT Interrupt Mapping: (0000* = Disabled, + // 0001=IRQ1, 0010=(Invalid), 0011=IRQ3 to 1111=IRQ15) + write_io_cr(0xF3, conf); +} + +static inline void wdt_timer_ctrl(unsigned char reg) +{ + // -- Watchdog timer control -- + // Bit 0 Status Bit: 0 = Timer counting, 1 = Timeout occured + // Bit 1 Power LED Toggle: 0 = Disable Toggle, 1 = Toggle at 1 Hz + // Bit 2 Force Timeout: 1 = Forces WD timeout event (self-cleaning) + // Bit 3 P20 Force Timeout enabled: + // 0 = P20 activity does not generate the WD timeout event + // 1 = P20 Allows rising edge of P20, from the keyboard + // controller, to force the WD timeout event. + // Bit 4 (Reserved) + // -- Soft power management -- + // Bit 5 Stop Counter: 1 = Stop software power down counter + // set via register 0xB8, (self-cleaning) + // (Upon read: 0 = Counter running, 1 = Counter stopped) + // Bit 6 Restart Counter: 1 = Restart software power down counter + // set via register 0xB8, (self-cleaning) + // Bit 7 SPOFF: 1 = Force software power down (self-cleaning) + + write_io_cr(0xF4, reg); +} + +/* -- Higher level functions ------------------------------------*/ + +/* initialize watchdog */ + +static void wb_smsc_wdt_initialize(void) +{ + unsigned char old; + + spin_lock(&io_lock); + open_io_config(); + select_io_device(IODEV_NO); + + // enable the watchdog + gpio_bit13(0x08); // Select pin 80 = LED not GPIO + gpio_bit12(0x0A); // Set pin 79 = WDT not GPIO/Output/Polarity=Invert + + // disable the timeout + wdt_timeout_value(0); + + // reset control register + wdt_timer_ctrl(0x00); + + // reset configuration register + wdt_timer_conf(0x00); + + // read old (timer units) register + old = read_io_cr(0xF1) & 0x7F; + if (unit == UNIT_SECOND) old |= 0x80; // set to seconds + + // set the watchdog timer units + wdt_timer_units(old); + + close_io_config(); + spin_unlock(&io_lock); +} + +/* shutdown the watchdog */ + +static void wb_smsc_wdt_shutdown(void) +{ + spin_lock(&io_lock); + open_io_config(); + select_io_device(IODEV_NO); + + // disable the watchdog + gpio_bit13(0x09); + gpio_bit12(0x09); + + // reset watchdog config register + wdt_timer_conf(0x00); + + // reset watchdog control register + wdt_timer_ctrl(0x00); + + // disable timeout + wdt_timeout_value(0x00); + + close_io_config(); + spin_unlock(&io_lock); +} + +/* set timeout => enable watchdog */ + +static void wb_smsc_wdt_set_timeout(unsigned char new_timeout) +{ + spin_lock(&io_lock); + open_io_config(); + select_io_device(IODEV_NO); + + // set Power LED to blink, if we enable the timeout + wdt_timer_ctrl((new_timeout == 0) ? 0x00 : 0x02); + + // set timeout value + wdt_timeout_value(new_timeout); + + close_io_config(); + spin_unlock(&io_lock); +} + +/* get timeout */ + +static unsigned char wb_smsc_wdt_get_timeout(void) +{ + unsigned char set_timeout; + + spin_lock(&io_lock); + open_io_config(); + select_io_device(IODEV_NO); + set_timeout = read_io_cr(0xF2); + close_io_config(); + spin_unlock(&io_lock); + + return set_timeout; +} + +/* disable watchdog */ + +static void wb_smsc_wdt_disable(void) +{ + // set the timeout to 0 to disable the watchdog + wb_smsc_wdt_set_timeout(0); +} + +/* enable watchdog by setting the current timeout */ + +static void wb_smsc_wdt_enable(void) +{ + // set the current timeout... + wb_smsc_wdt_set_timeout(timeout); +} + +/* reset the timer */ + +static void wb_smsc_wdt_reset_timer(void) +{ + spin_lock(&io_lock); + open_io_config(); + select_io_device(IODEV_NO); + + // reset the timer + wdt_timeout_value(timeout); + wdt_timer_conf(0x08); + + close_io_config(); + spin_unlock(&io_lock); +} + +/* return, if the watchdog is enabled (timeout is set...) */ + +static int wb_smsc_wdt_status(void) +{ + return (wb_smsc_wdt_get_timeout() == 0) ? 0 : WDIOF_KEEPALIVEPING; +} + + +/* -- File operations -------------------------------------------*/ + +/* open => enable watchdog and set initial timeout */ + +static int wb_smsc_wdt_open(struct inode *inode, struct file *file) +{ + /* /dev/watchdog can only be opened once */ + + if (test_and_set_bit(0, &timer_enabled)) + return -EBUSY; + + if (nowayout) + __module_get(THIS_MODULE); + + /* Reload and activate timer */ + wb_smsc_wdt_enable(); + + printk(KERN_INFO MODNAME "Watchdog enabled. Timeout set to %d %s.\n", timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)"); + + return nonseekable_open(inode, file); +} + +/* close => shut off the timer */ + +static int wb_smsc_wdt_release(struct inode *inode, struct file *file) +{ + /* Shut off the timer. */ + + if (expect_close == 42) { + wb_smsc_wdt_disable(); + printk(KERN_INFO MODNAME "Watchdog disabled, sleeping again...\n"); + } else { + printk(KERN_CRIT MODNAME "Unexpected close, not stopping watchdog!\n"); + wb_smsc_wdt_reset_timer(); + } + + clear_bit(0, &timer_enabled); + expect_close = 0; + return 0; +} + +/* write => update the timer to keep the machine alive */ + +static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data, + size_t len, loff_t *ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if (len) { + if (!nowayout) { + size_t i; + + /* reset expect flag */ + expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for (i = 0; i != len; i++) { + char c; + if (get_user(c, data+i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + + /* someone wrote to us, we should reload the timer */ + wb_smsc_wdt_reset_timer(); + } + return len; +} + +/* ioctl => control interface */ + +static int wb_smsc_wdt_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int new_timeout; + + union { + struct watchdog_info __user *ident; + int __user *i; + } uarg; + + static struct watchdog_info ident = { + .options = WDIOF_KEEPALIVEPING | + WDIOF_SETTIMEOUT | + WDIOF_MAGICCLOSE, + .firmware_version = 0, + .identity = "SMsC 37B787 Watchdog" + }; + + uarg.i = (int __user *)arg; + + switch (cmd) { + default: + return -ENOTTY; + + case WDIOC_GETSUPPORT: + return copy_to_user(uarg.ident, &ident, + sizeof(ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + return put_user(wb_smsc_wdt_status(), uarg.i); + + case WDIOC_GETBOOTSTATUS: + return put_user(0, uarg.i); + + case WDIOC_KEEPALIVE: + wb_smsc_wdt_reset_timer(); + return 0; + + case WDIOC_SETTIMEOUT: + if (get_user(new_timeout, uarg.i)) + return -EFAULT; + + // the API states this is given in secs + if (unit == UNIT_MINUTE) + new_timeout /= 60; + + if (new_timeout < 0 || new_timeout > MAX_TIMEOUT) + return -EINVAL; + + timeout = new_timeout; + wb_smsc_wdt_set_timeout(timeout); + + // fall through and return the new timeout... + + case WDIOC_GETTIMEOUT: + + new_timeout = timeout; + + if (unit == UNIT_MINUTE) + new_timeout *= 60; + + return put_user(new_timeout, uarg.i); + + case WDIOC_SETOPTIONS: + { + int options, retval = -EINVAL; + + if (get_user(options, uarg.i)) + return -EFAULT; + + if (options & WDIOS_DISABLECARD) { + wb_smsc_wdt_disable(); + retval = 0; + } + + if (options & WDIOS_ENABLECARD) { + wb_smsc_wdt_enable(); + retval = 0; + } + + return retval; + } + } +} + +/* -- Notifier funtions -----------------------------------------*/ + +static int wb_smsc_wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused) +{ + if (code == SYS_DOWN || code == SYS_HALT) + { + // set timeout to 0, to avoid possible race-condition + timeout = 0; + wb_smsc_wdt_disable(); + } + return NOTIFY_DONE; +} + +/* -- Module's structures ---------------------------------------*/ + +static struct file_operations wb_smsc_wdt_fops = +{ + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = wb_smsc_wdt_write, + .ioctl = wb_smsc_wdt_ioctl, + .open = wb_smsc_wdt_open, + .release = wb_smsc_wdt_release, +}; + +static struct notifier_block wb_smsc_wdt_notifier = +{ + .notifier_call = wb_smsc_wdt_notify_sys, +}; + +static struct miscdevice wb_smsc_wdt_miscdev = +{ + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wb_smsc_wdt_fops, +}; + +/* -- Module init functions -------------------------------------*/ + +/* module's "constructor" */ + +static int __init wb_smsc_wdt_init(void) +{ + int ret; + + spin_lock_init(&io_lock); + + printk("SMsC 37B787 watchdog component driver " VERSION " initialising...\n"); + + if (!request_region(IOPORT, IOPORT_SIZE, "SMsC 37B787 watchdog")) { + printk(KERN_ERR MODNAME "Unable to register IO port %#x\n", IOPORT); + ret = -EBUSY; + goto out_pnp; + } + + // set new maximum, if it's too big + if (timeout > MAX_TIMEOUT) + timeout = MAX_TIMEOUT; + + // init the watchdog timer + wb_smsc_wdt_initialize(); + + ret = register_reboot_notifier(&wb_smsc_wdt_notifier); + if (ret) { + printk(KERN_ERR MODNAME "Unable to register reboot notifier err = %d\n", ret); + goto out_io; + } + + ret = misc_register(&wb_smsc_wdt_miscdev); + if (ret) { + printk(KERN_ERR MODNAME "Unable to register miscdev on minor %d\n", WATCHDOG_MINOR); + goto out_rbt; + } + + // output info + printk(KERN_INFO MODNAME "Timeout set to %d %s.\n", timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)"); + printk(KERN_INFO MODNAME "Watchdog initialized and sleeping (nowayout=%d)...\n", nowayout); + + // ret = 0 + +out_clean: + return ret; + +out_rbt: + unregister_reboot_notifier(&wb_smsc_wdt_notifier); + +out_io: + release_region(IOPORT, IOPORT_SIZE); + +out_pnp: + goto out_clean; +} + +/* module's "destructor" */ + +static void __exit wb_smsc_wdt_exit(void) +{ + /* Stop the timer before we leave */ + if (!nowayout) + { + wb_smsc_wdt_shutdown(); + printk(KERN_INFO MODNAME "Watchdog disabled.\n"); + } + + misc_deregister(&wb_smsc_wdt_miscdev); + unregister_reboot_notifier(&wb_smsc_wdt_notifier); + release_region(IOPORT, IOPORT_SIZE); + + printk("SMsC 37B787 watchdog component driver removed.\n"); +} + +module_init(wb_smsc_wdt_init); +module_exit(wb_smsc_wdt_exit); + +MODULE_AUTHOR("Sven Anders "); +MODULE_DESCRIPTION("Driver for SMsC 37B787 watchdog component (Version " VERSION ")"); +MODULE_LICENSE("GPL"); + +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); + +#ifdef SMSC_SUPPORT_MINUTES +module_param(unit, int, 0); +MODULE_PARM_DESC(unit, "set unit to use, 0=seconds or 1=minutes, default is 0"); +#endif + +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "range is 1-255 units, default is 60"); + +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); diff --git a/ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c b/ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c new file mode 100644 index 000000000..b0e5f84d6 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c @@ -0,0 +1,421 @@ +/* + * W83877F Computer Watchdog Timer driver + * + * Based on acquirewdt.c by Alan Cox, + * and sbc60xxwdt.c by Jakob Oestergaard + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * The authors do NOT admit liability nor provide warranty for + * any of this software. This material is provided "AS-IS" in + * the hope that it may be useful for others. + * + * (c) Copyright 2001 Scott Jennings + * + * 4/19 - 2001 [Initial revision] + * 9/27 - 2001 Added spinlocking + * 4/12 - 2002 [rob@osinvestor.com] Eliminate extra comments + * Eliminate fop_read + * Eliminate extra spin_unlock + * Added KERN_* tags to printks + * add CONFIG_WATCHDOG_NOWAYOUT support + * fix possible wdt_is_open race + * changed watchdog_info to correctly reflect what the driver offers + * added WDIOC_GETSTATUS, WDIOC_GETBOOTSTATUS, WDIOC_SETTIMEOUT, + * WDIOC_GETTIMEOUT, and WDIOC_SETOPTIONS ioctls + * 09/8 - 2003 [wim@iguana.be] cleanup of trailing spaces + * added extra printk's for startup problems + * use module_param + * made timeout (the emulated heartbeat) a module_param + * made the keepalive ping an internal subroutine + * + * This WDT driver is different from most other Linux WDT + * drivers in that the driver will ping the watchdog by itself, + * because this particular WDT has a very short timeout (1.6 + * seconds) and it would be insane to count on any userspace + * daemon always getting scheduled within that time frame. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define OUR_NAME "w83877f_wdt" +#define PFX OUR_NAME ": " + +#define ENABLE_W83877F_PORT 0x3F0 +#define ENABLE_W83877F 0x87 +#define DISABLE_W83877F 0xAA +#define WDT_PING 0x443 +#define WDT_REGISTER 0x14 +#define WDT_ENABLE 0x9C +#define WDT_DISABLE 0x8C + +/* + * The W83877F seems to be fixed at 1.6s timeout (at least on the + * EMACS PC-104 board I'm using). If we reset the watchdog every + * ~250ms we should be safe. */ + +#define WDT_INTERVAL (HZ/4+1) + +/* + * We must not require too good response from the userspace daemon. + * Here we require the userspace daemon to send us a heartbeat + * char to /dev/watchdog every 30 seconds. + */ + +#define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */ +static int timeout = WATCHDOG_TIMEOUT; /* in seconds, will be multiplied by HZ to get seconds to wait for a ping */ +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); + + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +static void wdt_timer_ping(unsigned long); +static struct timer_list timer; +static unsigned long next_heartbeat; +static unsigned long wdt_is_open; +static char wdt_expect_close; +static spinlock_t wdt_spinlock; + +/* + * Whack the dog + */ + +static void wdt_timer_ping(unsigned long data) +{ + /* If we got a heartbeat pulse within the WDT_US_INTERVAL + * we agree to ping the WDT + */ + if(time_before(jiffies, next_heartbeat)) + { + /* Ping the WDT */ + spin_lock(&wdt_spinlock); + + /* Ping the WDT by reading from WDT_PING */ + inb_p(WDT_PING); + + /* Re-set the timer interval */ + timer.expires = jiffies + WDT_INTERVAL; + add_timer(&timer); + + spin_unlock(&wdt_spinlock); + + } else { + printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); + } +} + +/* + * Utility routines + */ + +static void wdt_change(int writeval) +{ + unsigned long flags; + spin_lock_irqsave(&wdt_spinlock, flags); + + /* buy some time */ + inb_p(WDT_PING); + + /* make W83877F available */ + outb_p(ENABLE_W83877F, ENABLE_W83877F_PORT); + outb_p(ENABLE_W83877F, ENABLE_W83877F_PORT); + + /* enable watchdog */ + outb_p(WDT_REGISTER, ENABLE_W83877F_PORT); + outb_p(writeval, ENABLE_W83877F_PORT+1); + + /* lock the W8387FF away */ + outb_p(DISABLE_W83877F, ENABLE_W83877F_PORT); + + spin_unlock_irqrestore(&wdt_spinlock, flags); +} + +static void wdt_startup(void) +{ + next_heartbeat = jiffies + (timeout * HZ); + + /* Start the timer */ + timer.expires = jiffies + WDT_INTERVAL; + add_timer(&timer); + + wdt_change(WDT_ENABLE); + + printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); +} + +static void wdt_turnoff(void) +{ + /* Stop the timer */ + del_timer(&timer); + + wdt_change(WDT_DISABLE); + + printk(KERN_INFO PFX "Watchdog timer is now disabled...\n"); +} + +static void wdt_keepalive(void) +{ + /* user land ping */ + next_heartbeat = jiffies + (timeout * HZ); +} + +/* + * /dev/watchdog handling + */ + +static ssize_t fop_write(struct file * file, const char __user * buf, size_t count, loff_t * ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if(count) + { + if (!nowayout) + { + size_t ofs; + + /* note: just in case someone wrote the magic character + * five months ago... */ + wdt_expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for(ofs = 0; ofs != count; ofs++) + { + char c; + if (get_user(c, buf + ofs)) + return -EFAULT; + if (c == 'V') + wdt_expect_close = 42; + } + } + + /* someone wrote to us, we should restart timer */ + wdt_keepalive(); + } + return count; +} + +static int fop_open(struct inode * inode, struct file * file) +{ + /* Just in case we're already talking to someone... */ + if(test_and_set_bit(0, &wdt_is_open)) + return -EBUSY; + + /* Good, fire up the show */ + wdt_startup(); + return nonseekable_open(inode, file); +} + +static int fop_close(struct inode * inode, struct file * file) +{ + if(wdt_expect_close == 42) + wdt_turnoff(); + else { + del_timer(&timer); + printk(KERN_CRIT PFX "device file closed unexpectedly. Will not stop the WDT!\n"); + } + clear_bit(0, &wdt_is_open); + wdt_expect_close = 0; + return 0; +} + +static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident= + { + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "W83877F", + }; + + switch(cmd) + { + default: + return -ENOTTY; + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0; + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + case WDIOC_KEEPALIVE: + wdt_keepalive(); + return 0; + case WDIOC_SETOPTIONS: + { + int new_options, retval = -EINVAL; + + if(get_user(new_options, p)) + return -EFAULT; + + if(new_options & WDIOS_DISABLECARD) { + wdt_turnoff(); + retval = 0; + } + + if(new_options & WDIOS_ENABLECARD) { + wdt_startup(); + retval = 0; + } + + return retval; + } + case WDIOC_SETTIMEOUT: + { + int new_timeout; + + if(get_user(new_timeout, p)) + return -EFAULT; + + if(new_timeout < 1 || new_timeout > 3600) /* arbitrary upper limit */ + return -EINVAL; + + timeout = new_timeout; + wdt_keepalive(); + /* Fall through */ + } + case WDIOC_GETTIMEOUT: + return put_user(timeout, p); + } +} + +static const struct file_operations wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = fop_write, + .open = fop_open, + .release = fop_close, + .ioctl = fop_ioctl, +}; + +static struct miscdevice wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt_fops, +}; + +/* + * Notifier for system down + */ + +static int wdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if(code==SYS_DOWN || code==SYS_HALT) + wdt_turnoff(); + return NOTIFY_DONE; +} + +/* + * The WDT needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ + +static struct notifier_block wdt_notifier= +{ + .notifier_call = wdt_notify_sys, +}; + +static void __exit w83877f_wdt_unload(void) +{ + wdt_turnoff(); + + /* Deregister */ + misc_deregister(&wdt_miscdev); + + unregister_reboot_notifier(&wdt_notifier); + release_region(WDT_PING,1); + release_region(ENABLE_W83877F_PORT,2); +} + +static int __init w83877f_wdt_init(void) +{ + int rc = -EBUSY; + + spin_lock_init(&wdt_spinlock); + + if(timeout < 1 || timeout > 3600) /* arbitrary upper limit */ + { + timeout = WATCHDOG_TIMEOUT; + printk(KERN_INFO PFX "timeout value must be 1<=x<=3600, using %d\n", + timeout); + } + + if (!request_region(ENABLE_W83877F_PORT, 2, "W83877F WDT")) + { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + ENABLE_W83877F_PORT); + rc = -EIO; + goto err_out; + } + + if (!request_region(WDT_PING, 1, "W8387FF WDT")) + { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + WDT_PING); + rc = -EIO; + goto err_out_region1; + } + + init_timer(&timer); + timer.function = wdt_timer_ping; + timer.data = 0; + + rc = misc_register(&wdt_miscdev); + if (rc) + { + printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + wdt_miscdev.minor, rc); + goto err_out_region2; + } + + rc = register_reboot_notifier(&wdt_notifier); + if (rc) + { + printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", + rc); + goto err_out_miscdev; + } + + printk(KERN_INFO PFX "WDT driver for W83877F initialised. timeout=%d sec (nowayout=%d)\n", + timeout, nowayout); + + return 0; + +err_out_miscdev: + misc_deregister(&wdt_miscdev); +err_out_region2: + release_region(WDT_PING,1); +err_out_region1: + release_region(ENABLE_W83877F_PORT,2); +err_out: + return rc; +} + +module_init(w83877f_wdt_init); +module_exit(w83877f_wdt_unload); + +MODULE_AUTHOR("Scott and Bill Jennings"); +MODULE_DESCRIPTION("Driver for watchdog timer in w83877f chip"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c b/ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c new file mode 100644 index 000000000..2c8d5d8bd --- /dev/null +++ b/ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c @@ -0,0 +1,542 @@ +/* + * W83977F Watchdog Timer Driver for Winbond W83977F I/O Chip + * + * (c) Copyright 2005 Jose Goncalves + * + * Based on w83877f_wdt.c by Scott Jennings, + * and wdt977.c by Woody Suwalski + * + * ----------------------- + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define WATCHDOG_VERSION "1.00" +#define WATCHDOG_NAME "W83977F WDT" +#define PFX WATCHDOG_NAME ": " +#define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n" + +#define IO_INDEX_PORT 0x3F0 +#define IO_DATA_PORT (IO_INDEX_PORT+1) + +#define UNLOCK_DATA 0x87 +#define LOCK_DATA 0xAA +#define DEVICE_REGISTER 0x07 + +#define DEFAULT_TIMEOUT 45 /* default timeout in seconds */ + +static int timeout = DEFAULT_TIMEOUT; +static int timeoutW; /* timeout in watchdog counter units */ +static unsigned long timer_alive; +static int testmode; +static char expect_close; +static spinlock_t spinlock; + +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); +module_param(testmode, int, 0); +MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +/* + * Start the watchdog + */ + +static int wdt_start(void) +{ + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* + * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4. + * F2 has the timeout in watchdog counter units. + * F3 is set to enable watchdog LED blink at timeout. + * F4 is used to just clear the TIMEOUT'ed state (bit 0). + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(timeoutW,IO_DATA_PORT); + outb_p(0xF3,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF4,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + + /* Set device Aux2 active */ + outb_p(0x30,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + + /* + * Select device Aux1 (dev=7) to set GP16 as the watchdog output + * (in reg E6) and GP13 as the watchdog LED output (in reg E3). + * Map GP16 at pin 119. + * In test mode watch the bit 0 on F4 to indicate "triggered" or + * check watchdog LED on SBC. + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x07,IO_DATA_PORT); + if (!testmode) + { + unsigned pin_map; + + outb_p(0xE6,IO_INDEX_PORT); + outb_p(0x0A,IO_DATA_PORT); + outb_p(0x2C,IO_INDEX_PORT); + pin_map = inb_p(IO_DATA_PORT); + pin_map |= 0x10; + pin_map &= ~(0x20); + outb_p(0x2C,IO_INDEX_PORT); + outb_p(pin_map,IO_DATA_PORT); + } + outb_p(0xE3,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + + /* Set device Aux1 active */ + outb_p(0x30,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + printk(KERN_INFO PFX "activated.\n"); + + return 0; +} + +/* + * Stop the watchdog + */ + +static int wdt_stop(void) +{ + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* + * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4. + * F2 is reset to its default value (watchdog timer disabled). + * F3 is reset to its default state. + * F4 clears the TIMEOUT'ed state (bit 0) - back to default. + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(0xFF,IO_DATA_PORT); + outb_p(0xF3,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + outb_p(0xF4,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + + /* + * Select device Aux1 (dev=7) to set GP16 (in reg E6) and + * Gp13 (in reg E3) as inputs. + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x07,IO_DATA_PORT); + if (!testmode) + { + outb_p(0xE6,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + } + outb_p(0xE3,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + printk(KERN_INFO PFX "shutdown.\n"); + + return 0; +} + +/* + * Send a keepalive ping to the watchdog + * This is done by simply re-writing the timeout to reg. 0xF2 + */ + +static int wdt_keepalive(void) +{ + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* Select device Aux2 (device=8) to kick watchdog reg F2 */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(timeoutW,IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + return 0; +} + +/* + * Set the watchdog timeout value + */ + +static int wdt_set_timeout(int t) +{ + int tmrval; + + /* + * Convert seconds to watchdog counter time units, rounding up. + * On PCM-5335 watchdog units are 30 seconds/step with 15 sec startup + * value. This information is supplied in the PCM-5335 manual and was + * checked by me on a real board. This is a bit strange because W83977f + * datasheet says counter unit is in minutes! + */ + if (t < 15) + return -EINVAL; + + tmrval = ((t + 15) + 29) / 30; + + if (tmrval > 255) + return -EINVAL; + + /* + * timeout is the timeout in seconds, + * timeoutW is the timeout in watchdog counter units. + */ + timeoutW = tmrval; + timeout = (timeoutW * 30) - 15; + return 0; +} + +/* + * Get the watchdog status + */ + +static int wdt_get_status(int *status) +{ + int new_status; + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* Select device Aux2 (device=8) to read watchdog reg F4 */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF4,IO_INDEX_PORT); + new_status = inb_p(IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + *status = 0; + if (new_status & 1) + *status |= WDIOF_CARDRESET; + + return 0; +} + + +/* + * /dev/watchdog handling + */ + +static int wdt_open(struct inode *inode, struct file *file) +{ + /* If the watchdog is alive we don't need to start it again */ + if( test_and_set_bit(0, &timer_alive) ) + return -EBUSY; + + if (nowayout) + __module_get(THIS_MODULE); + + wdt_start(); + return nonseekable_open(inode, file); +} + +static int wdt_release(struct inode *inode, struct file *file) +{ + /* + * Shut off the timer. + * Lock it in if it's a module and we set nowayout + */ + if (expect_close == 42) + { + wdt_stop(); + clear_bit(0, &timer_alive); + } else { + wdt_keepalive(); + printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); + } + expect_close = 0; + return 0; +} + +/* + * wdt_write: + * @file: file handle to the watchdog + * @buf: buffer to write (unused as data does not matter here + * @count: count of bytes + * @ppos: pointer to the position to write. No seeks allowed + * + * A write to a watchdog device is defined as a keepalive signal. Any + * write of data will do, as we we don't define content meaning. + */ + +static ssize_t wdt_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if(count) + { + if (!nowayout) + { + size_t ofs; + + /* note: just in case someone wrote the magic character long ago */ + expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for(ofs = 0; ofs != count; ofs++) + { + char c; + if (get_user(c, buf + ofs)) + return -EFAULT; + if (c == 'V') { + expect_close = 42; + } + } + } + + /* someone wrote to us, we should restart timer */ + wdt_keepalive(); + } + return count; +} + +/* + * wdt_ioctl: + * @inode: inode of the device + * @file: file handle to the device + * @cmd: watchdog command + * @arg: argument pointer + * + * The watchdog API defines a common set of functions for all watchdogs + * according to their available features. + */ + +static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, + .firmware_version = 1, + .identity = WATCHDOG_NAME, +}; + +static int wdt_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int status; + int new_options, retval = -EINVAL; + int new_timeout; + union { + struct watchdog_info __user *ident; + int __user *i; + } uarg; + + uarg.i = (int __user *)arg; + + switch(cmd) + { + default: + return -ENOTTY; + + case WDIOC_GETSUPPORT: + return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + wdt_get_status(&status); + return put_user(status, uarg.i); + + case WDIOC_GETBOOTSTATUS: + return put_user(0, uarg.i); + + case WDIOC_KEEPALIVE: + wdt_keepalive(); + return 0; + + case WDIOC_SETOPTIONS: + if (get_user (new_options, uarg.i)) + return -EFAULT; + + if (new_options & WDIOS_DISABLECARD) { + wdt_stop(); + retval = 0; + } + + if (new_options & WDIOS_ENABLECARD) { + wdt_start(); + retval = 0; + } + + return retval; + + case WDIOC_SETTIMEOUT: + if (get_user(new_timeout, uarg.i)) + return -EFAULT; + + if (wdt_set_timeout(new_timeout)) + return -EINVAL; + + wdt_keepalive(); + /* Fall */ + + case WDIOC_GETTIMEOUT: + return put_user(timeout, uarg.i); + + } +} + +static int wdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if (code==SYS_DOWN || code==SYS_HALT) + wdt_stop(); + return NOTIFY_DONE; +} + +static const struct file_operations wdt_fops= +{ + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = wdt_write, + .ioctl = wdt_ioctl, + .open = wdt_open, + .release = wdt_release, +}; + +static struct miscdevice wdt_miscdev= +{ + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt_fops, +}; + +static struct notifier_block wdt_notifier = { + .notifier_call = wdt_notify_sys, +}; + +static int __init w83977f_wdt_init(void) +{ + int rc; + + printk(KERN_INFO PFX DRIVER_VERSION); + + spin_lock_init(&spinlock); + + /* + * Check that the timeout value is within it's range ; + * if not reset to the default + */ + if (wdt_set_timeout(timeout)) { + wdt_set_timeout(DEFAULT_TIMEOUT); + printk(KERN_INFO PFX "timeout value must be 15<=timeout<=7635, using %d\n", + DEFAULT_TIMEOUT); + } + + if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) + { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + IO_INDEX_PORT); + rc = -EIO; + goto err_out; + } + + rc = misc_register(&wdt_miscdev); + if (rc) + { + printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + wdt_miscdev.minor, rc); + goto err_out_region; + } + + rc = register_reboot_notifier(&wdt_notifier); + if (rc) + { + printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", + rc); + goto err_out_miscdev; + } + + printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", + timeout, nowayout, testmode); + + return 0; + +err_out_miscdev: + misc_deregister(&wdt_miscdev); +err_out_region: + release_region(IO_INDEX_PORT,2); +err_out: + return rc; +} + +static void __exit w83977f_wdt_exit(void) +{ + wdt_stop(); + misc_deregister(&wdt_miscdev); + unregister_reboot_notifier(&wdt_notifier); + release_region(IO_INDEX_PORT,2); +} + +module_init(w83977f_wdt_init); +module_exit(w83977f_wdt_exit); + +MODULE_AUTHOR("Jose Goncalves "); +MODULE_DESCRIPTION("Driver for watchdog timer in W83977F I/O chip"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/ddverify/case_studies/char/watchdog/wdt/wd501p.h b/ddverify/case_studies/char/watchdog/wdt/wd501p.h new file mode 100644 index 000000000..a4504f403 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/wdt/wd501p.h @@ -0,0 +1,51 @@ +/* + * Industrial Computer Source WDT500/501 driver + * + * (c) Copyright 1995 CymruNET Ltd + * Innovation Centre + * Singleton Park + * Swansea + * Wales + * UK + * SA2 8PP + * + * http://www.cymru.net + * + * This driver is provided under the GNU General Public License, incorporated + * herein by reference. The driver is provided without warranty or + * support. + * + * Release 0.04. + * + */ + + +#define WDT_COUNT0 (io+0) +#define WDT_COUNT1 (io+1) +#define WDT_COUNT2 (io+2) +#define WDT_CR (io+3) +#define WDT_SR (io+4) /* Start buzzer on PCI write */ +#define WDT_RT (io+5) /* Stop buzzer on PCI write */ +#define WDT_BUZZER (io+6) /* PCI only: rd=disable, wr=enable */ +#define WDT_DC (io+7) + +/* The following are only on the PCI card, they're outside of I/O space on + * the ISA card: */ +#define WDT_CLOCK (io+12) /* COUNT2: rd=16.67MHz, wr=2.0833MHz */ +/* inverted opto isolated reset output: */ +#define WDT_OPTONOTRST (io+13) /* wr=enable, rd=disable */ +/* opto isolated reset output: */ +#define WDT_OPTORST (io+14) /* wr=enable, rd=disable */ +/* programmable outputs: */ +#define WDT_PROGOUT (io+15) /* wr=enable, rd=disable */ + + /* FAN 501 500 */ +#define WDC_SR_WCCR 1 /* Active low */ /* X X X */ +#define WDC_SR_TGOOD 2 /* X X - */ +#define WDC_SR_ISOI0 4 /* X X X */ +#define WDC_SR_ISII1 8 /* X X X */ +#define WDC_SR_FANGOOD 16 /* X - - */ +#define WDC_SR_PSUOVER 32 /* Active low */ /* X X - */ +#define WDC_SR_PSUUNDR 64 /* Active low */ /* X X - */ +#define WDC_SR_IRQ 128 /* Active low */ /* X X X */ + diff --git a/ddverify/case_studies/char/watchdog/wdt/wdt.c b/ddverify/case_studies/char/watchdog/wdt/wdt.c new file mode 100644 index 000000000..517fbd864 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/wdt/wdt.c @@ -0,0 +1,640 @@ +/* + * Industrial Computer Source WDT500/501 driver + * + * (c) Copyright 1996-1997 Alan Cox , All Rights Reserved. + * http://www.redhat.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. + * + * (c) Copyright 1995 Alan Cox + * + * Release 0.10. + * + * Fixes + * Dave Gregorich : Modularisation and minor bugs + * Alan Cox : Added the watchdog ioctl() stuff + * Alan Cox : Fixed the reboot problem (as noted by + * Matt Crocker). + * Alan Cox : Added wdt= boot option + * Alan Cox : Cleaned up copy/user stuff + * Tim Hockin : Added insmod parameters, comment cleanup + * Parameterized timeout + * Tigran Aivazian : Restructured wdt_init() to handle failures + * Joel Becker : Added WDIOC_GET/SETTIMEOUT + * Matt Domsch : Added nowayout module option + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "wd501p.h" + +static unsigned long wdt_is_open; +static char expect_close; + +/* + * Module parameters + */ + +#define WD_TIMO 60 /* Default heartbeat = 60 seconds */ + +static int heartbeat = WD_TIMO; +static int wd_heartbeat; +module_param(heartbeat, int, 0); +MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0>8, WDT_COUNT0+ctr); +} + +/** + * wdt_start: + * + * Start the watchdog driver. + */ + +static int wdt_start(void) +{ + inb_p(WDT_DC); /* Disable watchdog */ + wdt_ctr_mode(0,3); /* Program CTR0 for Mode 3: Square Wave Generator */ + wdt_ctr_mode(1,2); /* Program CTR1 for Mode 2: Rate Generator */ + wdt_ctr_mode(2,0); /* Program CTR2 for Mode 0: Pulse on Terminal Count */ + wdt_ctr_load(0, 8948); /* Count at 100Hz */ + wdt_ctr_load(1,wd_heartbeat); /* Heartbeat */ + wdt_ctr_load(2,65535); /* Length of reset pulse */ + outb_p(0, WDT_DC); /* Enable watchdog */ + return 0; +} + +/** + * wdt_stop: + * + * Stop the watchdog driver. + */ + +static int wdt_stop (void) +{ + /* Turn the card off */ + inb_p(WDT_DC); /* Disable watchdog */ + wdt_ctr_load(2,0); /* 0 length reset pulses now */ + return 0; +} + +/** + * wdt_ping: + * + * Reload counter one with the watchdog heartbeat. We don't bother reloading + * the cascade counter. + */ + +static int wdt_ping(void) +{ + /* Write a watchdog value */ + inb_p(WDT_DC); /* Disable watchdog */ + wdt_ctr_mode(1,2); /* Re-Program CTR1 for Mode 2: Rate Generator */ + wdt_ctr_load(1,wd_heartbeat); /* Heartbeat */ + outb_p(0, WDT_DC); /* Enable watchdog */ + return 0; +} + +/** + * wdt_set_heartbeat: + * @t: the new heartbeat value that needs to be set. + * + * Set a new heartbeat value for the watchdog device. If the heartbeat value is + * incorrect we keep the old value and return -EINVAL. If successfull we + * return 0. + */ +static int wdt_set_heartbeat(int t) +{ + if ((t < 1) || (t > 65535)) + return -EINVAL; + + heartbeat = t; + wd_heartbeat = t * 100; + return 0; +} + +/** + * wdt_get_status: + * @status: the new status. + * + * Extract the status information from a WDT watchdog device. There are + * several board variants so we have to know which bits are valid. Some + * bits default to one and some to zero in order to be maximally painful. + * + * we then map the bits onto the status ioctl flags. + */ + +static int wdt_get_status(int *status) +{ + unsigned char new_status=inb_p(WDT_SR); + + *status=0; + if (new_status & WDC_SR_ISOI0) + *status |= WDIOF_EXTERN1; + if (new_status & WDC_SR_ISII1) + *status |= WDIOF_EXTERN2; +#ifdef CONFIG_WDT_501 + if (!(new_status & WDC_SR_TGOOD)) + *status |= WDIOF_OVERHEAT; + if (!(new_status & WDC_SR_PSUOVER)) + *status |= WDIOF_POWEROVER; + if (!(new_status & WDC_SR_PSUUNDR)) + *status |= WDIOF_POWERUNDER; + if (tachometer) { + if (!(new_status & WDC_SR_FANGOOD)) + *status |= WDIOF_FANFAULT; + } +#endif /* CONFIG_WDT_501 */ + return 0; +} + +#ifdef CONFIG_WDT_501 +/** + * wdt_get_temperature: + * + * Reports the temperature in degrees Fahrenheit. The API is in + * farenheit. It was designed by an imperial measurement luddite. + */ + +static int wdt_get_temperature(int *temperature) +{ + unsigned short c=inb_p(WDT_RT); + + *temperature = (c * 11 / 15) + 7; + return 0; +} +#endif /* CONFIG_WDT_501 */ + +/** + * wdt_interrupt: + * @irq: Interrupt number + * @dev_id: Unused as we don't allow multiple devices. + * + * Handle an interrupt from the board. These are raised when the status + * map changes in what the board considers an interesting way. That means + * a failure condition occurring. + */ + +static irqreturn_t wdt_interrupt(int irq, void *dev_id) +{ + /* + * Read the status register see what is up and + * then printk it. + */ + unsigned char status=inb_p(WDT_SR); + + printk(KERN_CRIT "WDT status %d\n", status); + +#ifdef CONFIG_WDT_501 + if (!(status & WDC_SR_TGOOD)) + printk(KERN_CRIT "Overheat alarm.(%d)\n",inb_p(WDT_RT)); + if (!(status & WDC_SR_PSUOVER)) + printk(KERN_CRIT "PSU over voltage.\n"); + if (!(status & WDC_SR_PSUUNDR)) + printk(KERN_CRIT "PSU under voltage.\n"); + if (tachometer) { + if (!(status & WDC_SR_FANGOOD)) + printk(KERN_CRIT "Possible fan fault.\n"); + } +#endif /* CONFIG_WDT_501 */ + if (!(status & WDC_SR_WCCR)) +#ifdef SOFTWARE_REBOOT +#ifdef ONLY_TESTING + printk(KERN_CRIT "Would Reboot.\n"); +#else + printk(KERN_CRIT "Initiating system reboot.\n"); + emergency_restart(); +#endif +#else + printk(KERN_CRIT "Reset in 5ms.\n"); +#endif + return IRQ_HANDLED; +} + + +/** + * wdt_write: + * @file: file handle to the watchdog + * @buf: buffer to write (unused as data does not matter here + * @count: count of bytes + * @ppos: pointer to the position to write. No seeks allowed + * + * A write to a watchdog device is defined as a keepalive signal. Any + * write of data will do, as we we don't define content meaning. + */ + +static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) +{ + if(count) { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + expect_close = 0; + + for (i = 0; i != count; i++) { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + wdt_ping(); + } + return count; +} + +/** + * wdt_ioctl: + * @inode: inode of the device + * @file: file handle to the device + * @cmd: watchdog command + * @arg: argument pointer + * + * The watchdog API defines a common set of functions for all watchdogs + * according to their available features. We only actually usefully support + * querying capabilities and current status. + */ + +static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + void __user *argp = (void __user *)arg; + int __user *p = argp; + int new_heartbeat; + int status; + + static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT| + WDIOF_MAGICCLOSE| + WDIOF_KEEPALIVEPING, + .firmware_version = 1, + .identity = "WDT500/501", + }; + + /* Add options according to the card we have */ + ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2); +#ifdef CONFIG_WDT_501 + ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER); + if (tachometer) + ident.options |= WDIOF_FANFAULT; +#endif /* CONFIG_WDT_501 */ + + switch(cmd) + { + default: + return -ENOTTY; + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0; + + case WDIOC_GETSTATUS: + wdt_get_status(&status); + return put_user(status, p); + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + case WDIOC_KEEPALIVE: + wdt_ping(); + return 0; + case WDIOC_SETTIMEOUT: + if (get_user(new_heartbeat, p)) + return -EFAULT; + + if (wdt_set_heartbeat(new_heartbeat)) + return -EINVAL; + + wdt_ping(); + /* Fall */ + case WDIOC_GETTIMEOUT: + return put_user(heartbeat, p); + } +} + +/** + * wdt_open: + * @inode: inode of device + * @file: file handle to device + * + * The watchdog device has been opened. The watchdog device is single + * open and on opening we load the counters. Counter zero is a 100Hz + * cascade, into counter 1 which downcounts to reboot. When the counter + * triggers counter 2 downcounts the length of the reset pulse which + * set set to be as long as possible. + */ + +static int wdt_open(struct inode *inode, struct file *file) +{ + if(test_and_set_bit(0, &wdt_is_open)) + return -EBUSY; + /* + * Activate + */ + wdt_start(); + return nonseekable_open(inode, file); +} + +/** + * wdt_release: + * @inode: inode to board + * @file: file handle to board + * + * The watchdog has a configurable API. There is a religious dispute + * between people who want their watchdog to be able to shut down and + * those who want to be sure if the watchdog manager dies the machine + * reboots. In the former case we disable the counters, in the latter + * case you have to open it again very soon. + */ + +static int wdt_release(struct inode *inode, struct file *file) +{ + if (expect_close == 42) { + wdt_stop(); + clear_bit(0, &wdt_is_open); + } else { + printk(KERN_CRIT "wdt: WDT device closed unexpectedly. WDT will not stop!\n"); + wdt_ping(); + } + expect_close = 0; + return 0; +} + +#ifdef CONFIG_WDT_501 +/** + * wdt_temp_read: + * @file: file handle to the watchdog board + * @buf: buffer to write 1 byte into + * @count: length of buffer + * @ptr: offset (no seek allowed) + * + * Temp_read reports the temperature in degrees Fahrenheit. The API is in + * farenheit. It was designed by an imperial measurement luddite. + */ + +static ssize_t wdt_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) +{ + int temperature; + + if (wdt_get_temperature(&temperature)) + return -EFAULT; + + if (copy_to_user (buf, &temperature, 1)) + return -EFAULT; + + return 1; +} + +/** + * wdt_temp_open: + * @inode: inode of device + * @file: file handle to device + * + * The temperature device has been opened. + */ + +static int wdt_temp_open(struct inode *inode, struct file *file) +{ + return nonseekable_open(inode, file); +} + +/** + * wdt_temp_release: + * @inode: inode to board + * @file: file handle to board + * + * The temperature device has been closed. + */ + +static int wdt_temp_release(struct inode *inode, struct file *file) +{ + return 0; +} +#endif /* CONFIG_WDT_501 */ + +/** + * notify_sys: + * @this: our notifier block + * @code: the event being reported + * @unused: unused + * + * Our notifier is called on system shutdowns. We want to turn the card + * off at reboot otherwise the machine will reboot again during memory + * test or worse yet during the following fsck. This would suck, in fact + * trust me - if it happens it does suck. + */ + +static int wdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if(code==SYS_DOWN || code==SYS_HALT) { + /* Turn the card off */ + wdt_stop(); + } + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + + +static const struct file_operations wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = wdt_write, + .ioctl = wdt_ioctl, + .open = wdt_open, + .release = wdt_release, +}; + +static struct miscdevice wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt_fops, +}; + +#ifdef CONFIG_WDT_501 +static const struct file_operations wdt_temp_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = wdt_temp_read, + .open = wdt_temp_open, + .release = wdt_temp_release, +}; + +static struct miscdevice temp_miscdev = { + .minor = TEMP_MINOR, + .name = "temperature", + .fops = &wdt_temp_fops, +}; +#endif /* CONFIG_WDT_501 */ + +/* + * The WDT card needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ + +static struct notifier_block wdt_notifier = { + .notifier_call = wdt_notify_sys, +}; + +/** + * cleanup_module: + * + * Unload the watchdog. You cannot do this with any file handles open. + * If your watchdog is set to continue ticking on close and you unload + * it, well it keeps ticking. We won't get the interrupt but the board + * will not touch PC memory so all is fine. You just have to load a new + * module in 60 seconds or reboot. + */ + +static void __exit wdt_exit(void) +{ + misc_deregister(&wdt_miscdev); +#ifdef CONFIG_WDT_501 + misc_deregister(&temp_miscdev); +#endif /* CONFIG_WDT_501 */ + unregister_reboot_notifier(&wdt_notifier); + free_irq(irq, NULL); + release_region(io,8); +} + +/** + * wdt_init: + * + * Set up the WDT watchdog board. All we have to do is grab the + * resources we require and bitch if anyone beat us to them. + * The open() function will actually kick the board off. + */ + +static int __init wdt_init(void) +{ + int ret; + + /* Check that the heartbeat value is within it's range ; if not reset to the default */ + if (wdt_set_heartbeat(heartbeat)) { + wdt_set_heartbeat(WD_TIMO); + printk(KERN_INFO "wdt: heartbeat value must be 0) + * + * ----------------------- + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * ----------------------- + * 14-Dec-2001 Matt Domsch + * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT + * 19-Dec-2001 Woody Suwalski: Netwinder fixes, ioctl interface + * 06-Jan-2002 Woody Suwalski: For compatibility, convert all timeouts + * from minutes to seconds. + * 07-Jul-2003 Daniele Bellucci: Audit return code of misc_register in + * nwwatchdog_init. + * 25-Oct-2005 Woody Suwalski: Convert addresses to #defs, add spinlocks + * remove limitiation to be used on Netwinders only + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define WATCHDOG_VERSION "0.04" +#define WATCHDOG_NAME "Wdt977" +#define PFX WATCHDOG_NAME ": " +#define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n" + +#define IO_INDEX_PORT 0x370 /* on some systems it can be 0x3F0 */ +#define IO_DATA_PORT (IO_INDEX_PORT+1) + +#define UNLOCK_DATA 0x87 +#define LOCK_DATA 0xAA +#define DEVICE_REGISTER 0x07 + + +#define DEFAULT_TIMEOUT 60 /* default timeout in seconds */ + +static int timeout = DEFAULT_TIMEOUT; +static int timeoutM; /* timeout in minutes */ +static unsigned long timer_alive; +static int testmode; +static char expect_close; +static spinlock_t spinlock; + +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (60..15300), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); +module_param(testmode, int, 0); +MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0"); + +static int nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +/* + * Start the watchdog + */ + +static int wdt977_start(void) +{ + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* unlock the SuperIO chip */ + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + + /* select device Aux2 (device=8) and set watchdog regs F2, F3 and F4 + * F2 has the timeout in minutes + * F3 could be set to the POWER LED blink (with GP17 set to PowerLed) + * at timeout, and to reset timer on kbd/mouse activity (not impl.) + * F4 is used to just clear the TIMEOUT'ed state (bit 0) + */ + outb_p(DEVICE_REGISTER, IO_INDEX_PORT); + outb_p(0x08, IO_DATA_PORT); + outb_p(0xF2, IO_INDEX_PORT); + outb_p(timeoutM, IO_DATA_PORT); + outb_p(0xF3, IO_INDEX_PORT); + outb_p(0x00, IO_DATA_PORT); /* another setting is 0E for kbd/mouse/LED */ + outb_p(0xF4, IO_INDEX_PORT); + outb_p(0x00, IO_DATA_PORT); + + /* at last select device Aux1 (dev=7) and set GP16 as a watchdog output */ + /* in test mode watch the bit 1 on F4 to indicate "triggered" */ + if (!testmode) + { + outb_p(DEVICE_REGISTER, IO_INDEX_PORT); + outb_p(0x07, IO_DATA_PORT); + outb_p(0xE6, IO_INDEX_PORT); + outb_p(0x08, IO_DATA_PORT); + } + + /* lock the SuperIO chip */ + outb_p(LOCK_DATA, IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + printk(KERN_INFO PFX "activated.\n"); + + return 0; +} + +/* + * Stop the watchdog + */ + +static int wdt977_stop(void) +{ + unsigned long flags; + spin_lock_irqsave(&spinlock, flags); + + /* unlock the SuperIO chip */ + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + + /* select device Aux2 (device=8) and set watchdog regs F2,F3 and F4 + * F3 is reset to its default state + * F4 can clear the TIMEOUT'ed state (bit 0) - back to default + * We can not use GP17 as a PowerLed, as we use its usage as a RedLed + */ + outb_p(DEVICE_REGISTER, IO_INDEX_PORT); + outb_p(0x08, IO_DATA_PORT); + outb_p(0xF2, IO_INDEX_PORT); + outb_p(0xFF, IO_DATA_PORT); + outb_p(0xF3, IO_INDEX_PORT); + outb_p(0x00, IO_DATA_PORT); + outb_p(0xF4, IO_INDEX_PORT); + outb_p(0x00, IO_DATA_PORT); + outb_p(0xF2, IO_INDEX_PORT); + outb_p(0x00, IO_DATA_PORT); + + /* at last select device Aux1 (dev=7) and set GP16 as a watchdog output */ + outb_p(DEVICE_REGISTER, IO_INDEX_PORT); + outb_p(0x07, IO_DATA_PORT); + outb_p(0xE6, IO_INDEX_PORT); + outb_p(0x08, IO_DATA_PORT); + + /* lock the SuperIO chip */ + outb_p(LOCK_DATA, IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + printk(KERN_INFO PFX "shutdown.\n"); + + return 0; +} + +/* + * Send a keepalive ping to the watchdog + * This is done by simply re-writing the timeout to reg. 0xF2 + */ + +static int wdt977_keepalive(void) +{ + unsigned long flags; + spin_lock_irqsave(&spinlock, flags); + + /* unlock the SuperIO chip */ + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + + /* select device Aux2 (device=8) and kicks watchdog reg F2 */ + /* F2 has the timeout in minutes */ + outb_p(DEVICE_REGISTER, IO_INDEX_PORT); + outb_p(0x08, IO_DATA_PORT); + outb_p(0xF2, IO_INDEX_PORT); + outb_p(timeoutM, IO_DATA_PORT); + + /* lock the SuperIO chip */ + outb_p(LOCK_DATA, IO_INDEX_PORT); + spin_unlock_irqrestore(&spinlock, flags); + + return 0; +} + +/* + * Set the watchdog timeout value + */ + +static int wdt977_set_timeout(int t) +{ + int tmrval; + + /* convert seconds to minutes, rounding up */ + tmrval = (t + 59) / 60; + + if (machine_is_netwinder()) { + /* we have a hw bug somewhere, so each 977 minute is actually only 30sec + * this limits the max timeout to half of device max of 255 minutes... + */ + tmrval += tmrval; + } + + if ((tmrval < 1) || (tmrval > 255)) + return -EINVAL; + + /* timeout is the timeout in seconds, timeoutM is the timeout in minutes) */ + timeout = t; + timeoutM = tmrval; + return 0; +} + +/* + * Get the watchdog status + */ + +static int wdt977_get_status(int *status) +{ + int new_status; + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* unlock the SuperIO chip */ + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + outb_p(UNLOCK_DATA, IO_INDEX_PORT); + + /* select device Aux2 (device=8) and read watchdog reg F4 */ + outb_p(DEVICE_REGISTER, IO_INDEX_PORT); + outb_p(0x08, IO_DATA_PORT); + outb_p(0xF4, IO_INDEX_PORT); + new_status = inb_p(IO_DATA_PORT); + + /* lock the SuperIO chip */ + outb_p(LOCK_DATA, IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + *status=0; + if (new_status & 1) + *status |= WDIOF_CARDRESET; + + return 0; +} + + +/* + * /dev/watchdog handling + */ + +static int wdt977_open(struct inode *inode, struct file *file) +{ + /* If the watchdog is alive we don't need to start it again */ + if( test_and_set_bit(0,&timer_alive) ) + return -EBUSY; + + if (nowayout) + __module_get(THIS_MODULE); + + wdt977_start(); + return nonseekable_open(inode, file); +} + +static int wdt977_release(struct inode *inode, struct file *file) +{ + /* + * Shut off the timer. + * Lock it in if it's a module and we set nowayout + */ + if (expect_close == 42) + { + wdt977_stop(); + clear_bit(0,&timer_alive); + } else { + wdt977_keepalive(); + printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); + } + expect_close = 0; + return 0; +} + + +/* + * wdt977_write: + * @file: file handle to the watchdog + * @buf: buffer to write (unused as data does not matter here + * @count: count of bytes + * @ppos: pointer to the position to write. No seeks allowed + * + * A write to a watchdog device is defined as a keepalive signal. Any + * write of data will do, as we we don't define content meaning. + */ + +static ssize_t wdt977_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + if (count) + { + if (!nowayout) + { + size_t i; + + /* In case it was set long ago */ + expect_close = 0; + + for (i = 0; i != count; i++) + { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + + /* someone wrote to us, we should restart timer */ + wdt977_keepalive(); + } + return count; +} + +/* + * wdt977_ioctl: + * @inode: inode of the device + * @file: file handle to the device + * @cmd: watchdog command + * @arg: argument pointer + * + * The watchdog API defines a common set of functions for all watchdogs + * according to their available features. + */ + +static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | + WDIOF_MAGICCLOSE | + WDIOF_KEEPALIVEPING, + .firmware_version = 1, + .identity = WATCHDOG_NAME, +}; + +static int wdt977_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int status; + int new_options, retval = -EINVAL; + int new_timeout; + union { + struct watchdog_info __user *ident; + int __user *i; + } uarg; + + uarg.i = (int __user *)arg; + + switch(cmd) + { + default: + return -ENOTTY; + + case WDIOC_GETSUPPORT: + return copy_to_user(uarg.ident, &ident, + sizeof(ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + wdt977_get_status(&status); + return put_user(status, uarg.i); + + case WDIOC_GETBOOTSTATUS: + return put_user(0, uarg.i); + + case WDIOC_KEEPALIVE: + wdt977_keepalive(); + return 0; + + case WDIOC_SETOPTIONS: + if (get_user (new_options, uarg.i)) + return -EFAULT; + + if (new_options & WDIOS_DISABLECARD) { + wdt977_stop(); + retval = 0; + } + + if (new_options & WDIOS_ENABLECARD) { + wdt977_start(); + retval = 0; + } + + return retval; + + case WDIOC_SETTIMEOUT: + if (get_user(new_timeout, uarg.i)) + return -EFAULT; + + if (wdt977_set_timeout(new_timeout)) + return -EINVAL; + + wdt977_keepalive(); + /* Fall */ + + case WDIOC_GETTIMEOUT: + return put_user(timeout, uarg.i); + + } +} + +static int wdt977_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if(code==SYS_DOWN || code==SYS_HALT) + wdt977_stop(); + return NOTIFY_DONE; +} + +static const struct file_operations wdt977_fops= +{ + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = wdt977_write, + .ioctl = wdt977_ioctl, + .open = wdt977_open, + .release = wdt977_release, +}; + +static struct miscdevice wdt977_miscdev= +{ + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt977_fops, +}; + +static struct notifier_block wdt977_notifier = { + .notifier_call = wdt977_notify_sys, +}; + +static int __init wd977_init(void) +{ + int rc; + + //if (!machine_is_netwinder()) + // return -ENODEV; + + printk(KERN_INFO PFX DRIVER_VERSION); + + spin_lock_init(&spinlock); + + /* Check that the timeout value is within it's range ; if not reset to the default */ + if (wdt977_set_timeout(timeout)) + { + wdt977_set_timeout(DEFAULT_TIMEOUT); + printk(KERN_INFO PFX "timeout value must be 60"); +MODULE_DESCRIPTION("W83977AF Watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/ddverify/case_studies/char/watchdog/wdt_pci/wd501p.h b/ddverify/case_studies/char/watchdog/wdt_pci/wd501p.h new file mode 100644 index 000000000..a4504f403 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/wdt_pci/wd501p.h @@ -0,0 +1,51 @@ +/* + * Industrial Computer Source WDT500/501 driver + * + * (c) Copyright 1995 CymruNET Ltd + * Innovation Centre + * Singleton Park + * Swansea + * Wales + * UK + * SA2 8PP + * + * http://www.cymru.net + * + * This driver is provided under the GNU General Public License, incorporated + * herein by reference. The driver is provided without warranty or + * support. + * + * Release 0.04. + * + */ + + +#define WDT_COUNT0 (io+0) +#define WDT_COUNT1 (io+1) +#define WDT_COUNT2 (io+2) +#define WDT_CR (io+3) +#define WDT_SR (io+4) /* Start buzzer on PCI write */ +#define WDT_RT (io+5) /* Stop buzzer on PCI write */ +#define WDT_BUZZER (io+6) /* PCI only: rd=disable, wr=enable */ +#define WDT_DC (io+7) + +/* The following are only on the PCI card, they're outside of I/O space on + * the ISA card: */ +#define WDT_CLOCK (io+12) /* COUNT2: rd=16.67MHz, wr=2.0833MHz */ +/* inverted opto isolated reset output: */ +#define WDT_OPTONOTRST (io+13) /* wr=enable, rd=disable */ +/* opto isolated reset output: */ +#define WDT_OPTORST (io+14) /* wr=enable, rd=disable */ +/* programmable outputs: */ +#define WDT_PROGOUT (io+15) /* wr=enable, rd=disable */ + + /* FAN 501 500 */ +#define WDC_SR_WCCR 1 /* Active low */ /* X X X */ +#define WDC_SR_TGOOD 2 /* X X - */ +#define WDC_SR_ISOI0 4 /* X X X */ +#define WDC_SR_ISII1 8 /* X X X */ +#define WDC_SR_FANGOOD 16 /* X - - */ +#define WDC_SR_PSUOVER 32 /* Active low */ /* X X - */ +#define WDC_SR_PSUUNDR 64 /* Active low */ /* X X - */ +#define WDC_SR_IRQ 128 /* Active low */ /* X X X */ + diff --git a/ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.c b/ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.c new file mode 100644 index 000000000..ce1261c5c --- /dev/null +++ b/ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.c @@ -0,0 +1,756 @@ +/* + * Industrial Computer Source PCI-WDT500/501 driver + * + * (c) Copyright 1996-1997 Alan Cox , All Rights Reserved. + * http://www.redhat.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. + * + * (c) Copyright 1995 Alan Cox + * + * Release 0.10. + * + * Fixes + * Dave Gregorich : Modularisation and minor bugs + * Alan Cox : Added the watchdog ioctl() stuff + * Alan Cox : Fixed the reboot problem (as noted by + * Matt Crocker). + * Alan Cox : Added wdt= boot option + * Alan Cox : Cleaned up copy/user stuff + * Tim Hockin : Added insmod parameters, comment cleanup + * Parameterized timeout + * JP Nollmann : Added support for PCI wdt501p + * Alan Cox : Split ISA and PCI cards into two drivers + * Jeff Garzik : PCI cleanups + * Tigran Aivazian : Restructured wdtpci_init_one() to handle failures + * Joel Becker : Added WDIOC_GET/SETTIMEOUT + * Zwane Mwaikambo : Magic char closing, locking changes, cleanups + * Matt Domsch : nowayout module option + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define WDT_IS_PCI +#include "wd501p.h" + +#define PFX "wdt_pci: " + +/* + * Until Access I/O gets their application for a PCI vendor ID approved, + * I don't think that it's appropriate to move these constants into the + * regular pci_ids.h file. -- JPN 2000/01/18 + */ + +#ifndef PCI_VENDOR_ID_ACCESSIO +#define PCI_VENDOR_ID_ACCESSIO 0x494f +#endif +#ifndef PCI_DEVICE_ID_WDG_CSM +#define PCI_DEVICE_ID_WDG_CSM 0x22c0 +#endif + +/* We can only use 1 card due to the /dev/watchdog restriction */ +static int dev_count; + +static struct semaphore open_sem; +static spinlock_t wdtpci_lock; +static char expect_close; + +static int io; +static int irq; + +/* Default timeout */ +#define WD_TIMO 60 /* Default heartbeat = 60 seconds */ + +static int heartbeat = WD_TIMO; +static int wd_heartbeat; +module_param(heartbeat, int, 0); +MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0>8, WDT_COUNT0+ctr); +} + +/** + * wdtpci_start: + * + * Start the watchdog driver. + */ + +static int wdtpci_start(void) +{ + unsigned long flags; + + spin_lock_irqsave(&wdtpci_lock, flags); + + /* + * "pet" the watchdog, as Access says. + * This resets the clock outputs. + */ + inb_p(WDT_DC); /* Disable watchdog */ + wdtpci_ctr_mode(2,0); /* Program CTR2 for Mode 0: Pulse on Terminal Count */ + outb_p(0, WDT_DC); /* Enable watchdog */ + + inb_p(WDT_DC); /* Disable watchdog */ + outb_p(0, WDT_CLOCK); /* 2.0833MHz clock */ + inb_p(WDT_BUZZER); /* disable */ + inb_p(WDT_OPTONOTRST); /* disable */ + inb_p(WDT_OPTORST); /* disable */ + inb_p(WDT_PROGOUT); /* disable */ + wdtpci_ctr_mode(0,3); /* Program CTR0 for Mode 3: Square Wave Generator */ + wdtpci_ctr_mode(1,2); /* Program CTR1 for Mode 2: Rate Generator */ + wdtpci_ctr_mode(2,1); /* Program CTR2 for Mode 1: Retriggerable One-Shot */ + wdtpci_ctr_load(0,20833); /* count at 100Hz */ + wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */ + /* DO NOT LOAD CTR2 on PCI card! -- JPN */ + outb_p(0, WDT_DC); /* Enable watchdog */ + + spin_unlock_irqrestore(&wdtpci_lock, flags); + return 0; +} + +/** + * wdtpci_stop: + * + * Stop the watchdog driver. + */ + +static int wdtpci_stop (void) +{ + unsigned long flags; + + /* Turn the card off */ + spin_lock_irqsave(&wdtpci_lock, flags); + inb_p(WDT_DC); /* Disable watchdog */ + wdtpci_ctr_load(2,0); /* 0 length reset pulses now */ + spin_unlock_irqrestore(&wdtpci_lock, flags); + return 0; +} + +/** + * wdtpci_ping: + * + * Reload counter one with the watchdog heartbeat. We don't bother reloading + * the cascade counter. + */ + +static int wdtpci_ping(void) +{ + unsigned long flags; + + /* Write a watchdog value */ + spin_lock_irqsave(&wdtpci_lock, flags); + inb_p(WDT_DC); /* Disable watchdog */ + wdtpci_ctr_mode(1,2); /* Re-Program CTR1 for Mode 2: Rate Generator */ + wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */ + outb_p(0, WDT_DC); /* Enable watchdog */ + spin_unlock_irqrestore(&wdtpci_lock, flags); + return 0; +} + +/** + * wdtpci_set_heartbeat: + * @t: the new heartbeat value that needs to be set. + * + * Set a new heartbeat value for the watchdog device. If the heartbeat value is + * incorrect we keep the old value and return -EINVAL. If successfull we + * return 0. + */ +static int wdtpci_set_heartbeat(int t) +{ + /* Arbitrary, can't find the card's limits */ + if ((t < 1) || (t > 65535)) + return -EINVAL; + + heartbeat = t; + wd_heartbeat = t * 100; + return 0; +} + +/** + * wdtpci_get_status: + * @status: the new status. + * + * Extract the status information from a WDT watchdog device. There are + * several board variants so we have to know which bits are valid. Some + * bits default to one and some to zero in order to be maximally painful. + * + * we then map the bits onto the status ioctl flags. + */ + +static int wdtpci_get_status(int *status) +{ + unsigned char new_status=inb_p(WDT_SR); + + *status=0; + if (new_status & WDC_SR_ISOI0) + *status |= WDIOF_EXTERN1; + if (new_status & WDC_SR_ISII1) + *status |= WDIOF_EXTERN2; +#ifdef CONFIG_WDT_501_PCI + if (!(new_status & WDC_SR_TGOOD)) + *status |= WDIOF_OVERHEAT; + if (!(new_status & WDC_SR_PSUOVER)) + *status |= WDIOF_POWEROVER; + if (!(new_status & WDC_SR_PSUUNDR)) + *status |= WDIOF_POWERUNDER; + if (tachometer) { + if (!(new_status & WDC_SR_FANGOOD)) + *status |= WDIOF_FANFAULT; + } +#endif /* CONFIG_WDT_501_PCI */ + return 0; +} + +#ifdef CONFIG_WDT_501_PCI +/** + * wdtpci_get_temperature: + * + * Reports the temperature in degrees Fahrenheit. The API is in + * farenheit. It was designed by an imperial measurement luddite. + */ + +static int wdtpci_get_temperature(int *temperature) +{ + unsigned short c=inb_p(WDT_RT); + + *temperature = (c * 11 / 15) + 7; + return 0; +} +#endif /* CONFIG_WDT_501_PCI */ + +/** + * wdtpci_interrupt: + * @irq: Interrupt number + * @dev_id: Unused as we don't allow multiple devices. + * + * Handle an interrupt from the board. These are raised when the status + * map changes in what the board considers an interesting way. That means + * a failure condition occurring. + */ + +static irqreturn_t wdtpci_interrupt(int irq, void *dev_id) +{ + /* + * Read the status register see what is up and + * then printk it. + */ + unsigned char status=inb_p(WDT_SR); + + printk(KERN_CRIT PFX "status %d\n", status); + +#ifdef CONFIG_WDT_501_PCI + if (!(status & WDC_SR_TGOOD)) + printk(KERN_CRIT PFX "Overheat alarm.(%d)\n",inb_p(WDT_RT)); + if (!(status & WDC_SR_PSUOVER)) + printk(KERN_CRIT PFX "PSU over voltage.\n"); + if (!(status & WDC_SR_PSUUNDR)) + printk(KERN_CRIT PFX "PSU under voltage.\n"); + if (tachometer) { + if (!(status & WDC_SR_FANGOOD)) + printk(KERN_CRIT PFX "Possible fan fault.\n"); + } +#endif /* CONFIG_WDT_501_PCI */ + if (!(status&WDC_SR_WCCR)) +#ifdef SOFTWARE_REBOOT +#ifdef ONLY_TESTING + printk(KERN_CRIT PFX "Would Reboot.\n"); +#else + printk(KERN_CRIT PFX "Initiating system reboot.\n"); + emergency_restart(NULL); +#endif +#else + printk(KERN_CRIT PFX "Reset in 5ms.\n"); +#endif + return IRQ_HANDLED; +} + + +/** + * wdtpci_write: + * @file: file handle to the watchdog + * @buf: buffer to write (unused as data does not matter here + * @count: count of bytes + * @ppos: pointer to the position to write. No seeks allowed + * + * A write to a watchdog device is defined as a keepalive signal. Any + * write of data will do, as we we don't define content meaning. + */ + +static ssize_t wdtpci_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) +{ + if (count) { + if (!nowayout) { + size_t i; + + expect_close = 0; + + for (i = 0; i != count; i++) { + char c; + if(get_user(c, buf+i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + wdtpci_ping(); + } + + return count; +} + +/** + * wdtpci_ioctl: + * @inode: inode of the device + * @file: file handle to the device + * @cmd: watchdog command + * @arg: argument pointer + * + * The watchdog API defines a common set of functions for all watchdogs + * according to their available features. We only actually usefully support + * querying capabilities and current status. + */ + +static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + int new_heartbeat; + int status; + void __user *argp = (void __user *)arg; + int __user *p = argp; + + static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT| + WDIOF_MAGICCLOSE| + WDIOF_KEEPALIVEPING, + .firmware_version = 1, + .identity = "PCI-WDT500/501", + }; + + /* Add options according to the card we have */ + ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2); +#ifdef CONFIG_WDT_501_PCI + ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER); + if (tachometer) + ident.options |= WDIOF_FANFAULT; +#endif /* CONFIG_WDT_501_PCI */ + + switch(cmd) + { + default: + return -ENOTTY; + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0; + + case WDIOC_GETSTATUS: + wdtpci_get_status(&status); + return put_user(status, p); + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + case WDIOC_KEEPALIVE: + wdtpci_ping(); + return 0; + case WDIOC_SETTIMEOUT: + if (get_user(new_heartbeat, p)) + return -EFAULT; + + if (wdtpci_set_heartbeat(new_heartbeat)) + return -EINVAL; + + wdtpci_ping(); + /* Fall */ + case WDIOC_GETTIMEOUT: + return put_user(heartbeat, p); + } +} + +/** + * wdtpci_open: + * @inode: inode of device + * @file: file handle to device + * + * The watchdog device has been opened. The watchdog device is single + * open and on opening we load the counters. Counter zero is a 100Hz + * cascade, into counter 1 which downcounts to reboot. When the counter + * triggers counter 2 downcounts the length of the reset pulse which + * set set to be as long as possible. + */ + +static int wdtpci_open(struct inode *inode, struct file *file) +{ + if (down_trylock(&open_sem)) + return -EBUSY; + + if (nowayout) { + __module_get(THIS_MODULE); + } + /* + * Activate + */ + wdtpci_start(); + return nonseekable_open(inode, file); +} + +/** + * wdtpci_release: + * @inode: inode to board + * @file: file handle to board + * + * The watchdog has a configurable API. There is a religious dispute + * between people who want their watchdog to be able to shut down and + * those who want to be sure if the watchdog manager dies the machine + * reboots. In the former case we disable the counters, in the latter + * case you have to open it again very soon. + */ + +static int wdtpci_release(struct inode *inode, struct file *file) +{ + if (expect_close == 42) { + wdtpci_stop(); + } else { + printk(KERN_CRIT PFX "Unexpected close, not stopping timer!"); + wdtpci_ping(); + } + expect_close = 0; + up(&open_sem); + return 0; +} + +#ifdef CONFIG_WDT_501_PCI +/** + * wdtpci_temp_read: + * @file: file handle to the watchdog board + * @buf: buffer to write 1 byte into + * @count: length of buffer + * @ptr: offset (no seek allowed) + * + * Read reports the temperature in degrees Fahrenheit. The API is in + * fahrenheit. It was designed by an imperial measurement luddite. + */ + +static ssize_t wdtpci_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) +{ + int temperature; + + if (wdtpci_get_temperature(&temperature)) + return -EFAULT; + + if (copy_to_user (buf, &temperature, 1)) + return -EFAULT; + + return 1; +} + +/** + * wdtpci_temp_open: + * @inode: inode of device + * @file: file handle to device + * + * The temperature device has been opened. + */ + +static int wdtpci_temp_open(struct inode *inode, struct file *file) +{ + return nonseekable_open(inode, file); +} + +/** + * wdtpci_temp_release: + * @inode: inode to board + * @file: file handle to board + * + * The temperature device has been closed. + */ + +static int wdtpci_temp_release(struct inode *inode, struct file *file) +{ + return 0; +} +#endif /* CONFIG_WDT_501_PCI */ + +/** + * notify_sys: + * @this: our notifier block + * @code: the event being reported + * @unused: unused + * + * Our notifier is called on system shutdowns. We want to turn the card + * off at reboot otherwise the machine will reboot again during memory + * test or worse yet during the following fsck. This would suck, in fact + * trust me - if it happens it does suck. + */ + +static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if (code==SYS_DOWN || code==SYS_HALT) { + /* Turn the card off */ + wdtpci_stop(); + } + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + + +static const struct file_operations wdtpci_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = wdtpci_write, + .ioctl = wdtpci_ioctl, + .open = wdtpci_open, + .release = wdtpci_release, +}; + +static struct miscdevice wdtpci_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdtpci_fops, +}; + +#ifdef CONFIG_WDT_501_PCI +static const struct file_operations wdtpci_temp_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = wdtpci_temp_read, + .open = wdtpci_temp_open, + .release = wdtpci_temp_release, +}; + +static struct miscdevice temp_miscdev = { + .minor = TEMP_MINOR, + .name = "temperature", + .fops = &wdtpci_temp_fops, +}; +#endif /* CONFIG_WDT_501_PCI */ + +/* + * The WDT card needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ + +static struct notifier_block wdtpci_notifier = { + .notifier_call = wdtpci_notify_sys, +}; + + +static int __devinit wdtpci_init_one (struct pci_dev *dev, + const struct pci_device_id *ent) +{ + int ret = -EIO; + + dev_count++; + if (dev_count > 1) { + printk (KERN_ERR PFX "this driver only supports 1 device\n"); + return -ENODEV; + } + + if (pci_enable_device (dev)) { + printk (KERN_ERR PFX "Not possible to enable PCI Device\n"); + return -ENODEV; + } + + if (pci_resource_start (dev, 2) == 0x0000) { + printk (KERN_ERR PFX "No I/O-Address for card detected\n"); + ret = -ENODEV; + goto out_pci; + } + + sema_init(&open_sem, 1); + spin_lock_init(&wdtpci_lock); + + irq = dev->irq; + io = pci_resource_start (dev, 2); + + if (request_region (io, 16, "wdt_pci") == NULL) { + printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", io); + goto out_pci; + } + + if (request_irq (irq, wdtpci_interrupt, IRQF_DISABLED | IRQF_SHARED, + "wdt_pci", &wdtpci_miscdev)) { + printk (KERN_ERR PFX "IRQ %d is not free\n", irq); + goto out_reg; + } + + printk ("PCI-WDT500/501 (PCI-WDG-CSM) driver 0.10 at 0x%04x (Interrupt %d)\n", + io, irq); + + /* Check that the heartbeat value is within it's range ; if not reset to the default */ + if (wdtpci_set_heartbeat(heartbeat)) { + wdtpci_set_heartbeat(WD_TIMO); + printk(KERN_INFO PFX "heartbeat value must be 0 +#include + +#define BUG_ON(condition) __CPROVER_assume(condition) + +#endif diff --git a/ddverify/models/con1/include/asm-generic/errno-base.h b/ddverify/models/con1/include/asm-generic/errno-base.h new file mode 100644 index 000000000..651159785 --- /dev/null +++ b/ddverify/models/con1/include/asm-generic/errno-base.h @@ -0,0 +1,39 @@ +#ifndef _ASM_GENERIC_ERRNO_BASE_H +#define _ASM_GENERIC_ERRNO_BASE_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#endif diff --git a/ddverify/models/con1/include/asm-generic/errno.h b/ddverify/models/con1/include/asm-generic/errno.h new file mode 100644 index 000000000..e8852c092 --- /dev/null +++ b/ddverify/models/con1/include/asm-generic/errno.h @@ -0,0 +1,109 @@ +#ifndef _ASM_GENERIC_ERRNO_H +#define _ASM_GENERIC_ERRNO_H + +#include + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* for robust mutexes */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ + +#endif diff --git a/ddverify/models/con1/include/asm-generic/fcntl.h b/ddverify/models/con1/include/asm-generic/fcntl.h new file mode 100644 index 000000000..897b3f5a5 --- /dev/null +++ b/ddverify/models/con1/include/asm-generic/fcntl.h @@ -0,0 +1,110 @@ +#ifndef _ASM_GENERIC_FCNTL_H +#define _ASM_GENERIC_FCNTL_H + +#include +#include + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 00000003 +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 +#ifndef O_CREAT +#define O_CREAT 00000100 /* not fcntl */ +#endif +#ifndef O_EXCL +#define O_EXCL 00000200 /* not fcntl */ +#endif +#ifndef O_NOCTTY +#define O_NOCTTY 00000400 /* not fcntl */ +#endif +#ifndef O_TRUNC +#define O_TRUNC 00001000 /* not fcntl */ +#endif +#ifndef O_APPEND +#define O_APPEND 00002000 +#endif +#ifndef O_NONBLOCK +#define O_NONBLOCK 00004000 +#endif +#ifndef O_SYNC +#define O_SYNC 00010000 +#endif +#ifndef FASYNC +#define FASYNC 00020000 /* fcntl, for BSD compatibility */ +#endif +#ifndef O_DIRECT +#define O_DIRECT 00040000 /* direct disk access hint */ +#endif +#ifndef O_LARGEFILE +#define O_LARGEFILE 00100000 +#endif +#ifndef O_DIRECTORY +#define O_DIRECTORY 00200000 /* must be a directory */ +#endif +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 00400000 /* don't follow links */ +#endif +#ifndef O_NOATIME +#define O_NOATIME 01000000 +#endif +#ifndef O_NDELAY +#define O_NDELAY O_NONBLOCK +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get close_on_exec */ +#define F_SETFD 2 /* set/clear close_on_exec */ +#define F_GETFL 3 /* get file->f_flags */ +#define F_SETFL 4 /* set file->f_flags */ +#ifndef F_GETLK +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#endif +#ifndef F_SETOWN +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ +#endif +#ifndef F_SETSIG +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ +#endif + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#ifndef F_RDLCK +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 +#endif + +/* for old implementation of bsd flock () */ +#ifndef F_EXLCK +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ +#endif + +/* for leases */ +#ifndef F_INPROGRESS +#define F_INPROGRESS 16 +#endif + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#define LOCK_MAND 32 /* This is a mandatory flock ... */ +#define LOCK_READ 64 /* which allows concurrent read operations */ +#define LOCK_WRITE 128 /* which allows concurrent write operations */ +#define LOCK_RW 192 /* which allows concurrent read & write ops */ + +#define F_LINUX_SPECIFIC_BASE 1024 + +#endif /* _ASM_GENERIC_FCNTL_H */ diff --git a/ddverify/models/con1/include/asm-generic/ioctl.h b/ddverify/models/con1/include/asm-generic/ioctl.h new file mode 100644 index 000000000..cd027298b --- /dev/null +++ b/ddverify/models/con1/include/asm-generic/ioctl.h @@ -0,0 +1,80 @@ +#ifndef _ASM_GENERIC_IOCTL_H +#define _ASM_GENERIC_IOCTL_H + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The generic ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __invalid_size_argument_for_IOC; +#define _IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ + sizeof(t) : __invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#endif /* _ASM_GENERIC_IOCTL_H */ diff --git a/ddverify/models/con1/include/asm-generic/pci-dma-compat.h b/ddverify/models/con1/include/asm-generic/pci-dma-compat.h new file mode 100644 index 000000000..4bb451317 --- /dev/null +++ b/ddverify/models/con1/include/asm-generic/pci-dma-compat.h @@ -0,0 +1,20 @@ +/* include this file if the platform implements the dma_ DMA Mapping API + * and wants to provide the pci_ DMA Mapping API in terms of it */ + +#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H +#define _ASM_GENERIC_PCI_DMA_COMPAT_H + +void * pci_alloc_consistent(struct pci_dev *hwdev, size_t size, + dma_addr_t *dma_handle); + +void pci_free_consistent(struct pci_dev *hwdev, size_t size, + void *vaddr, dma_addr_t dma_handle); + +dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction); +void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction); + +dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page, + unsigned long offset, size_t size, int direction); +void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, + size_t size, int direction); +#endif diff --git a/ddverify/models/con1/include/asm-generic/rtc.h b/ddverify/models/con1/include/asm-generic/rtc.h new file mode 100644 index 000000000..a8a13c916 --- /dev/null +++ b/ddverify/models/con1/include/asm-generic/rtc.h @@ -0,0 +1,18 @@ +#ifndef __ASM_GENERIC_RTC_H__ +#define __ASM_GENERIC_RTC_H__ + +#include +#include + +#define RTC_PIE 0x40 /* periodic interrupt enable */ +#define RTC_AIE 0x20 /* alarm interrupt enable */ +#define RTC_UIE 0x10 /* update-finished interrupt enable */ + +/* some dummy definitions */ +#define RTC_BATT_BAD 0x100 /* battery bad */ +#define RTC_SQWE 0x08 /* enable square-wave output */ +#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +#endif diff --git a/ddverify/models/con1/include/asm-generic/siginfo.h b/ddverify/models/con1/include/asm-generic/siginfo.h new file mode 100644 index 000000000..383411b5c --- /dev/null +++ b/ddverify/models/con1/include/asm-generic/siginfo.h @@ -0,0 +1,118 @@ +#ifndef _ASM_GENERIC_SIGINFO_H +#define _ASM_GENERIC_SIGINFO_H + +#include +#include + +/* + * This is the size (including padding) of the part of the + * struct siginfo that is before the union. + */ +#ifndef __ARCH_SI_PREAMBLE_SIZE +#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) +#endif + +#define SI_MAX_SIZE 128 +#ifndef SI_PAD_SIZE +#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) +#endif + +#ifndef __ARCH_SI_UID_T +#define __ARCH_SI_UID_T uid_t +#endif + +/* + * The default "si_band" type is "long", as specified by POSIX. + * However, some architectures want to override this to "int" + * for historical compatibility reasons, so we allow that. + */ +#ifndef __ARCH_SI_BAND_T +#define __ARCH_SI_BAND_T long +#endif + + +#define __SI_MASK 0xffff0000u +#define __SI_KILL (0 << 16) +#define __SI_TIMER (1 << 16) +#define __SI_POLL (2 << 16) +#define __SI_FAULT (3 << 16) +#define __SI_CHLD (4 << 16) +#define __SI_RT (5 << 16) +#define __SI_MESGQ (6 << 16) + + +/* + * SIGILL si_codes + */ +#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ +#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ +#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ +#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ +#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ +#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ +#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ +#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ +#define NSIGILL 8 + +/* + * SIGFPE si_codes + */ +#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ +#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ +#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ +#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ +#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ +#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ +#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ +#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ +#define NSIGFPE 8 + +/* + * SIGSEGV si_codes + */ +#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ +#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ +#define NSIGSEGV 2 + +/* + * SIGBUS si_codes + */ +#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ +#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ +#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ +#define NSIGBUS 3 + +/* + * SIGTRAP si_codes + */ +#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ +#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ +#define NSIGTRAP 2 + +/* + * SIGCHLD si_codes + */ +#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ +#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ +#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ +#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ +#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ +#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ +#define NSIGCHLD 6 + +/* + * SIGPOLL si_codes + */ +#define POLL_IN (__SI_POLL|1) /* data input available */ +#define POLL_OUT (__SI_POLL|2) /* output buffers available */ +#define POLL_MSG (__SI_POLL|3) /* input message available */ +#define POLL_ERR (__SI_POLL|4) /* i/o error */ +#define POLL_PRI (__SI_POLL|5) /* high priority input available */ +#define POLL_HUP (__SI_POLL|6) /* device disconnected */ +#define NSIGPOLL 6 + +typedef struct siginfo { + int something; +} siginfo_t; + +#endif diff --git a/ddverify/models/con1/include/asm/atomic.h b/ddverify/models/con1/include/asm/atomic.h new file mode 100644 index 000000000..226e1b397 --- /dev/null +++ b/ddverify/models/con1/include/asm/atomic.h @@ -0,0 +1,169 @@ +#ifndef __ARCH_I386_ATOMIC__ +#define __ARCH_I386_ATOMIC__ + +#include + +typedef int atomic_t; + +#define ATOMIC_INIT(i) { (i) } + +/** + * atomic_read - read atomic variable + * @v: pointer of type atomic_t + * + * Atomically reads the value of @v. + */ +#define atomic_read(v) (*v) + +/** + * atomic_set - set atomic variable + * @v: pointer of type atomic_t + * @i: required value + * + * Atomically sets the value of @v to @i. + */ +#define atomic_set(v,i) (*v) = i + +/** + * atomic_add - add integer to atomic variable + * @i: integer value to add + * @v: pointer of type atomic_t + * + * Atomically adds @i to @v. + */ +static __inline__ void atomic_add(int i, atomic_t *v) +{ + (*v) = (*v) + i; +} + +/** + * atomic_sub - subtract the atomic variable + * @i: integer value to subtract + * @v: pointer of type atomic_t + * + * Atomically subtracts @i from @v. + */ +static __inline__ void atomic_sub(int i, atomic_t *v) +{ + (*v) = (*v) - i; +} + +/** + * atomic_inc - increment atomic variable + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1. + */ +static __inline__ void atomic_inc(atomic_t *v) +{ + (*v)++; +} + +/** + * atomic_dec - decrement atomic variable + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1. + */ +static __inline__ void atomic_dec(atomic_t *v) +{ + (*v)--; +} + +/** + * atomic_dec_and_test - decrement and test + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1 and + * returns true if the result is 0, or false for all other + * cases. + */ +static __inline__ int atomic_dec_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)--; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_inc_and_test - increment and test + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1 + * and returns true if the result is zero, or false for all + * other cases. + */ +static __inline__ int atomic_inc_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)++; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_negative - add and test if negative + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns true + * if the result is negative, or false when + * result is greater than or equal to zero. + */ +static __inline__ int atomic_add_negative(int i, atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v) = (*v) + i; + if ((*v) < 0) { + ret = 1; + } else { + ret = 0; + } + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_return - add and return + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns @i + @v + */ +static __inline__ int atomic_add_return(int i, atomic_t *v) +{ + return (*v) + i; +} + +static __inline__ int atomic_sub_return(int i, atomic_t *v) +{ + return (*v) - i; +} + +#define atomic_inc_return(v) (atomic_add_return(1,v)) +#define atomic_dec_return(v) (atomic_sub_return(1,v)) + +#endif diff --git a/ddverify/models/con1/include/asm/bitops.h b/ddverify/models/con1/include/asm/bitops.h new file mode 100644 index 000000000..6b4e2116a --- /dev/null +++ b/ddverify/models/con1/include/asm/bitops.h @@ -0,0 +1,13 @@ +#ifndef _I386_BITOPS_H +#define _I386_BITOPS_H + +void set_bit(int nr, unsigned long * addr); + +int test_and_set_bit(int nr, unsigned long * addr); +int test_and_clear_bit(int nr, unsigned long * addr); +int test_and_change_bit(int nr, unsigned long* addr); +int test_bit(int nr, const void * addr); +void clear_bit(int nr, volatile unsigned long * addr); +int find_first_zero_bit(const unsigned long *addr, unsigned size); + +#endif /* _I386_BITOPS_H */ diff --git a/ddverify/models/con1/include/asm/bug.h b/ddverify/models/con1/include/asm/bug.h new file mode 100644 index 000000000..9536f4539 --- /dev/null +++ b/ddverify/models/con1/include/asm/bug.h @@ -0,0 +1,7 @@ +#ifndef _I386_BUG_H +#define _I386_BUG_H + +#include +#include +#endif + diff --git a/ddverify/models/con1/include/asm/byteorder.h b/ddverify/models/con1/include/asm/byteorder.h new file mode 100644 index 000000000..20edb1dfa --- /dev/null +++ b/ddverify/models/con1/include/asm/byteorder.h @@ -0,0 +1,9 @@ +#ifndef _I386_BYTEORDER_H +#define _I386_BYTEORDER_H + +#include +#include + +#include + +#endif /* _I386_BYTEORDER_H */ diff --git a/ddverify/models/con1/include/asm/current.h b/ddverify/models/con1/include/asm/current.h new file mode 100644 index 000000000..f124ae985 --- /dev/null +++ b/ddverify/models/con1/include/asm/current.h @@ -0,0 +1,14 @@ +#ifndef _I386_CURRENT_H +#define _I386_CURRENT_H + +//#include +#include + +struct task_struct; + +struct task_struct *get_current(void); + +#define current get_current() + +#endif /* !(_I386_CURRENT_H) */ + diff --git a/ddverify/models/con1/include/asm/delay.h b/ddverify/models/con1/include/asm/delay.h new file mode 100644 index 000000000..153e9bc14 --- /dev/null +++ b/ddverify/models/con1/include/asm/delay.h @@ -0,0 +1,6 @@ +#ifndef _I386_DELAY_H +#define _I386_DELAY_H + +void udelay(int); + +#endif /* defined(_I386_DELAY_H) */ diff --git a/ddverify/models/con1/include/asm/dma.h b/ddverify/models/con1/include/asm/dma.h new file mode 100644 index 000000000..1e1f3855e --- /dev/null +++ b/ddverify/models/con1/include/asm/dma.h @@ -0,0 +1,72 @@ +#ifndef _ASM_DMA_H +#define _ASM_DMA_H + +#include /* And spinlocks */ +#include /* need byte IO */ +#include + +#define MAX_DMA_CHANNELS 8 + +/* The maximum address that we can perform a DMA transfer to on this platform */ +#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000) + +/* 8237 DMA controllers */ +#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ +#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ + +/* DMA controller registers */ +#define DMA1_CMD_REG 0x08 /* command register (w) */ +#define DMA1_STAT_REG 0x08 /* status register (r) */ +#define DMA1_REQ_REG 0x09 /* request register (w) */ +#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ +#define DMA1_MODE_REG 0x0B /* mode register (w) */ +#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ +#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ +#define DMA1_RESET_REG 0x0D /* Master Clear (w) */ +#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ +#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ + +#define DMA2_CMD_REG 0xD0 /* command register (w) */ +#define DMA2_STAT_REG 0xD0 /* status register (r) */ +#define DMA2_REQ_REG 0xD2 /* request register (w) */ +#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ +#define DMA2_MODE_REG 0xD6 /* mode register (w) */ +#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ +#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ +#define DMA2_RESET_REG 0xDA /* Master Clear (w) */ +#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ +#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ + +#define DMA_ADDR_0 0x00 /* DMA address registers */ +#define DMA_ADDR_1 0x02 +#define DMA_ADDR_2 0x04 +#define DMA_ADDR_3 0x06 +#define DMA_ADDR_4 0xC0 +#define DMA_ADDR_5 0xC4 +#define DMA_ADDR_6 0xC8 +#define DMA_ADDR_7 0xCC + +#define DMA_CNT_0 0x01 /* DMA count registers */ +#define DMA_CNT_1 0x03 +#define DMA_CNT_2 0x05 +#define DMA_CNT_3 0x07 +#define DMA_CNT_4 0xC2 +#define DMA_CNT_5 0xC6 +#define DMA_CNT_6 0xCA +#define DMA_CNT_7 0xCE + +#define DMA_PAGE_0 0x87 /* DMA page registers */ +#define DMA_PAGE_1 0x83 +#define DMA_PAGE_2 0x81 +#define DMA_PAGE_3 0x82 +#define DMA_PAGE_5 0x8B +#define DMA_PAGE_6 0x89 +#define DMA_PAGE_7 0x8A + +#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ +#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ +#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ + +#define DMA_AUTOINIT 0x10 + +#endif /* _ASM_DMA_H */ diff --git a/ddverify/models/con1/include/asm/errno.h b/ddverify/models/con1/include/asm/errno.h new file mode 100644 index 000000000..969b34374 --- /dev/null +++ b/ddverify/models/con1/include/asm/errno.h @@ -0,0 +1,6 @@ +#ifndef _I386_ERRNO_H +#define _I386_ERRNO_H + +#include + +#endif diff --git a/ddverify/models/con1/include/asm/fcntl.h b/ddverify/models/con1/include/asm/fcntl.h new file mode 100644 index 000000000..46ab12db5 --- /dev/null +++ b/ddverify/models/con1/include/asm/fcntl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/con1/include/asm/floppy.h b/ddverify/models/con1/include/asm/floppy.h new file mode 100644 index 000000000..fdbf1c705 --- /dev/null +++ b/ddverify/models/con1/include/asm/floppy.h @@ -0,0 +1,45 @@ +#ifndef __ASM_I386_FLOPPY_H +#define __ASM_I386_FLOPPY_H + +#include + +static int FDC1 = 0x3f0; +static int FDC2 = -1; + + +/* + * Floppy types are stored in the rtc's CMOS RAM and so rtc_lock + * is needed to prevent corrupted CMOS RAM in case "insmod floppy" + * coincides with another rtc CMOS user. Paul G. + */ +/*#define FLOPPY0_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = (CMOS_READ(0x10) >> 4) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) + +#define FLOPPY1_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = CMOS_READ(0x10) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) +*/ +#define FLOPPY0_TYPE (CMOS_READ(0x10) >> 4) & 15 +#define FLOPPY1_TYPE CMOS_READ(0x10) & 15 + +#define N_FDC 2 +#define N_DRIVE 8 + +#define FLOPPY_MOTOR_MASK 0xf0 + +#define AUTO_DMA + +#define EXTRA_FLOPPY_PARAMS + +#endif /* __ASM_I386_FLOPPY_H */ diff --git a/ddverify/models/con1/include/asm/highmem.h b/ddverify/models/con1/include/asm/highmem.h new file mode 100644 index 000000000..c9c362c4f --- /dev/null +++ b/ddverify/models/con1/include/asm/highmem.h @@ -0,0 +1,17 @@ +#ifndef _ASM_HIGHMEM_H +#define _ASM_HIGHMEM_H + +#include +//#include +#include +//#include + + +void *kmap(struct page *page); +void kunmap(struct page *page); +void *kmap_atomic(struct page *page, enum km_type type); +void kunmap_atomic(void *kvaddr, enum km_type type); +void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); +struct page *kmap_atomic_to_page(void *ptr); + +#endif /* _ASM_HIGHMEM_H */ diff --git a/ddverify/models/con1/include/asm/io.h b/ddverify/models/con1/include/asm/io.h new file mode 100644 index 000000000..703139060 --- /dev/null +++ b/ddverify/models/con1/include/asm/io.h @@ -0,0 +1,69 @@ +#ifndef _ASM_IO_H +#define _ASM_IO_H + +void * phys_to_virt(unsigned long); + +#define bus_to_virt phys_to_virt + +void *ioremap(unsigned long offset, unsigned long size); +void *ioremap_nocache(unsigned long offset, unsigned long size); +void iounmap(void *addr); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb(unsigned int); +void outb(unsigned char byte, unsigned int); +unsigned short inw(unsigned int); +void outw(unsigned short word, unsigned int); +unsigned inl(unsigned int); +void outl(unsigned doubleword, unsigned int); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb_p(unsigned int); +void outb_p(unsigned char byte, unsigned int); +unsigned short inw_p(unsigned int); +void outw_p(unsigned short word, unsigned int); +unsigned inl_p(unsigned int); +void outl_p(unsigned doubleword, unsigned int); + + + +unsigned insb(unsigned int, void *addr, unsigned long count); +void outsb(unsigned int, void *addr, unsigned long count); + +unsigned insw(unsigned int, void *addr, unsigned long count); +void outsw(unsigned int, void *addr, unsigned long count); + +unsigned insl(unsigned int, void *addr, unsigned long count); +void outsl(unsigned int, void *addr, unsigned long count); + + + +unsigned int ioread8(void *addr); +unsigned int ioread16(void *addr); +unsigned int ioread32(void *addr); + +void iowrite8(u8 value, void *addr); +void iowrite16(u16 value, void *addr); +void iowrite32(u32 value, void *addr); + +void ioread8_rep(void *addr, void *buf, unsigned long count); +void ioread16_rep(void *addr, void *buf, unsigned long count); +void ioread32_rep(void *addr, void *buf, unsigned long count); + +void iowrite8_rep(void *addr, const void *buf, unsigned long count); +void iowrite16_rep(void *addr, const void *buf, unsigned long count); +void iowrite32_rep(void *addr, const void *buf, unsigned long count); + +// DDV: no bodies required for these functions: +unsigned char readb(const void *); +unsigned short readw(const void *); +unsigned int readl(const void *); + +// DDV: no bodies required for these functions: +void writeb(unsigned char, void *); +void writew(unsigned short, void *); +void writel(unsigned int, void *); + +#endif diff --git a/ddverify/models/con1/include/asm/ioctl.h b/ddverify/models/con1/include/asm/ioctl.h new file mode 100644 index 000000000..b279fe06d --- /dev/null +++ b/ddverify/models/con1/include/asm/ioctl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/con1/include/asm/ioctls.h b/ddverify/models/con1/include/asm/ioctls.h new file mode 100644 index 000000000..4157abdb1 --- /dev/null +++ b/ddverify/models/con1/include/asm/ioctls.h @@ -0,0 +1,91 @@ +#ifndef __ARCH_CRIS_IOCTLS_H__ +#define __ARCH_CRIS_IOCTLS_H__ + +/* verbatim copy of asm-i386/ioctls.h */ + +#include + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TCGETS2 _IOR('T',0x2A, struct termios2) +#define TCSETS2 _IOW('T',0x2B, struct termios2) +#define TCSETSW2 _IOW('T',0x2C, struct termios2) +#define TCSETSF2 _IOW('T',0x2D, struct termios2) +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ +#define FIOQSIZE 0x5460 + +#define TIOCSERSETRS485 0x5461 /* enable rs-485 */ +#define TIOCSERWRRS485 0x5462 /* write rs-485 */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif diff --git a/ddverify/models/con1/include/asm/irq.h b/ddverify/models/con1/include/asm/irq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/asm/kmap_types.h b/ddverify/models/con1/include/asm/kmap_types.h new file mode 100644 index 000000000..fd2cdabbd --- /dev/null +++ b/ddverify/models/con1/include/asm/kmap_types.h @@ -0,0 +1,23 @@ +#ifndef _ASM_KMAP_TYPES_H +#define _ASM_KMAP_TYPES_H + +enum km_type { + KM_BOUNCE_READ, + KM_SKB_SUNRPC_DATA, + KM_SKB_DATA_SOFTIRQ, + KM_USER0, + KM_USER1, + KM_BIO_SRC_IRQ, + KM_BIO_DST_IRQ, + KM_PTE0, + KM_PTE1, + KM_IRQ0, + KM_IRQ1, + KM_SOFTIRQ0, + KM_SOFTIRQ1, + KM_KDB, + KM_DUMP, + KM_TYPE_NR +}; + +#endif diff --git a/ddverify/models/con1/include/asm/leds.h b/ddverify/models/con1/include/asm/leds.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/asm/mach-types.h b/ddverify/models/con1/include/asm/mach-types.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/asm/mc146818rtc.h b/ddverify/models/con1/include/asm/mc146818rtc.h new file mode 100644 index 000000000..0c97cfb90 --- /dev/null +++ b/ddverify/models/con1/include/asm/mc146818rtc.h @@ -0,0 +1,34 @@ +/* + * Machine dependent access functions for RTC registers. + */ +#ifndef _ASM_MC146818RTC_H +#define _ASM_MC146818RTC_H + +#include +#include +#include + +#ifndef RTC_PORT +#define RTC_PORT(x) (0x70 + (x)) +#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ +#endif + +#define lock_cmos_prefix(reg) do {} while (0) +#define lock_cmos_suffix(reg) do {} while (0) +#define lock_cmos(reg) +#define unlock_cmos() +#define do_i_have_lock_cmos() 0 +#define current_lock_cmos_reg() 0 + +/* + * The yet supported machines all access the RTC index register via + * an ISA port access but the way to access the date register differs ... + */ +#define CMOS_READ(addr) rtc_cmos_read(addr) +#define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr) +unsigned char rtc_cmos_read(unsigned char addr); +void rtc_cmos_write(unsigned char val, unsigned char addr); + +#define RTC_IRQ 8 + +#endif /* _ASM_MC146818RTC_H */ diff --git a/ddverify/models/con1/include/asm/msr.h b/ddverify/models/con1/include/asm/msr.h new file mode 100644 index 000000000..adf72e79e --- /dev/null +++ b/ddverify/models/con1/include/asm/msr.h @@ -0,0 +1,10 @@ +#ifndef __ASM_MSR_H +#define __ASM_MSR_H + +#define rdmsr(msr, val1, val2) \ + do { \ + val1 = nondet_u32(); \ + val2 = nondet_u32(); \ + } while(0); + +#endif diff --git a/ddverify/models/con1/include/asm/page.h b/ddverify/models/con1/include/asm/page.h new file mode 100644 index 000000000..b2bc603c9 --- /dev/null +++ b/ddverify/models/con1/include/asm/page.h @@ -0,0 +1,24 @@ +#ifndef _I386_PAGE_H +#define _I386_PAGE_H + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +//#include + + +// DDV: taken from arch/i386/defconfig +#define CONFIG_PAGE_OFFSET 0xC0000000 +// DDV: taken from arch/i386/defconfig +#define CONFIG_PHYSICAL_START 0x100000 + +#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET) +#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START) + +#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) +#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) +#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) + +#endif /* _I386_PAGE_H */ diff --git a/ddverify/models/con1/include/asm/param.h b/ddverify/models/con1/include/asm/param.h new file mode 100644 index 000000000..6148b8ddf --- /dev/null +++ b/ddverify/models/con1/include/asm/param.h @@ -0,0 +1,8 @@ +#ifndef _ASMi386_PARAM_H +#define _ASMi386_PARAM_H + +#ifndef HZ +#define HZ 100 +#endif + +#endif diff --git a/ddverify/models/con1/include/asm/pci.h b/ddverify/models/con1/include/asm/pci.h new file mode 100644 index 000000000..c41fd10d2 --- /dev/null +++ b/ddverify/models/con1/include/asm/pci.h @@ -0,0 +1,17 @@ +#ifndef __i386_PCI_H +#define __i386_PCI_H + +#include /* for struct page */ + +#include +#include +#include +#include +#include + + + +#include + + +#endif /* __i386_PCI_H */ diff --git a/ddverify/models/con1/include/asm/poll.h b/ddverify/models/con1/include/asm/poll.h new file mode 100644 index 000000000..905fb4d78 --- /dev/null +++ b/ddverify/models/con1/include/asm/poll.h @@ -0,0 +1,20 @@ +#ifndef __i386_POLL_H +#define __i386_POLL_H + +/* These are specified by iBCS2 */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +/* The rest seem to be more-or-less nonstandard. Check them! */ +#define POLLRDNORM 0x0040 +#define POLLRDBAND 0x0080 +#define POLLWRNORM 0x0100 +#define POLLWRBAND 0x0200 +#define POLLMSG 0x0400 +#define POLLREMOVE 0x1000 + +#endif diff --git a/ddverify/models/con1/include/asm/posix_types.h b/ddverify/models/con1/include/asm/posix_types.h new file mode 100644 index 000000000..798ec0819 --- /dev/null +++ b/ddverify/models/con1/include/asm/posix_types.h @@ -0,0 +1,32 @@ +#ifndef __ARCH_I386_POSIX_TYPES_H +#define __ARCH_I386_POSIX_TYPES_H + +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; + +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; +typedef unsigned short __kernel_old_dev_t; + + +#endif diff --git a/ddverify/models/con1/include/asm/processor.h b/ddverify/models/con1/include/asm/processor.h new file mode 100644 index 000000000..b6dedb7ad --- /dev/null +++ b/ddverify/models/con1/include/asm/processor.h @@ -0,0 +1,6 @@ +#ifndef __ASM_I386_PROCESSOR_H +#define __ASM_I386_PROCESSOR_H + +#include + +#endif /* __ASM_I386_PROCESSOR_H */ diff --git a/ddverify/models/con1/include/asm/ptrace.h b/ddverify/models/con1/include/asm/ptrace.h new file mode 100644 index 000000000..69130f62a --- /dev/null +++ b/ddverify/models/con1/include/asm/ptrace.h @@ -0,0 +1,8 @@ +#ifndef _I386_PTRACE_H +#define _I386_PTRACE_H + +struct pt_regs { + int something; +}; + +#endif diff --git a/ddverify/models/con1/include/asm/rtc.h b/ddverify/models/con1/include/asm/rtc.h new file mode 100644 index 000000000..3d2d9102e --- /dev/null +++ b/ddverify/models/con1/include/asm/rtc.h @@ -0,0 +1,7 @@ +#ifndef __ASM_RTC_H__ +#define __ASM_RTC_H__ + +#include + +#endif + diff --git a/ddverify/models/con1/include/asm/scatterlist.h b/ddverify/models/con1/include/asm/scatterlist.h new file mode 100644 index 000000000..55d6c953a --- /dev/null +++ b/ddverify/models/con1/include/asm/scatterlist.h @@ -0,0 +1,21 @@ +#ifndef _I386_SCATTERLIST_H +#define _I386_SCATTERLIST_H + +struct scatterlist { + struct page *page; + unsigned int offset; + dma_addr_t dma_address; + unsigned int length; +}; + +/* These macros should be used after a pci_map_sg call has been done + * to get bus addresses of each of the SG entries and their lengths. + * You should only work with the number of sg entries pci_map_sg + * returns. + */ +#define sg_dma_address(sg) ((sg)->dma_address) +#define sg_dma_len(sg) ((sg)->length) + +#define ISA_DMA_THRESHOLD (0x00ffffff) + +#endif /* !(_I386_SCATTERLIST_H) */ diff --git a/ddverify/models/con1/include/asm/semaphore.h b/ddverify/models/con1/include/asm/semaphore.h new file mode 100644 index 000000000..5d574f8a9 --- /dev/null +++ b/ddverify/models/con1/include/asm/semaphore.h @@ -0,0 +1,37 @@ +#ifndef _I386_SEMAPHORE_H +#define _I386_SEMAPHORE_H + +struct semaphore { + int init; + int locked; +}; + + +#define __SEMAPHORE_INITIALIZER(name, n) \ +{ \ + .init = 1, \ + .locked = n \ +} + +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) + +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,0) +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,1) + +// DDV: Body is defined in linux/kernel/semaphore.c +void sema_init(struct semaphore *sem, int val); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX_LOCKED(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void down(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_interruptible(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_trylock(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void up(struct semaphore * sem); + +#endif diff --git a/ddverify/models/con1/include/asm/siginfo.h b/ddverify/models/con1/include/asm/siginfo.h new file mode 100644 index 000000000..fe18f98fc --- /dev/null +++ b/ddverify/models/con1/include/asm/siginfo.h @@ -0,0 +1,6 @@ +#ifndef _I386_SIGINFO_H +#define _I386_SIGINFO_H + +#include + +#endif diff --git a/ddverify/models/con1/include/asm/signal.h b/ddverify/models/con1/include/asm/signal.h new file mode 100644 index 000000000..d85fd7a75 --- /dev/null +++ b/ddverify/models/con1/include/asm/signal.h @@ -0,0 +1,86 @@ +#ifndef _ASMi386_SIGNAL_H +#define _ASMi386_SIGNAL_H + +#define _NSIG 64 +#define _NSIG_BPW 32 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef unsigned long old_sigset_t; /* at least 32 bits */ + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG + + +/* + * SA_FLAGS values: + * + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_NODEFER prevents the current signal from being masked in the handler. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#define SA_NOCLDSTOP 0x00000001u +#define SA_NOCLDWAIT 0x00000002u +#define SA_SIGINFO 0x00000004u +#define SA_ONSTACK 0x08000000u +#define SA_RESTART 0x10000000u +#define SA_NODEFER 0x40000000u +#define SA_RESETHAND 0x80000000u + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND +#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */ + +#define SA_RESTORER 0x04000000 + + +#endif diff --git a/ddverify/models/con1/include/asm/stat.h b/ddverify/models/con1/include/asm/stat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/asm/string.h b/ddverify/models/con1/include/asm/string.h new file mode 100644 index 000000000..6b1131c19 --- /dev/null +++ b/ddverify/models/con1/include/asm/string.h @@ -0,0 +1,6 @@ +#ifndef _I386_STRING_H_ +#define _I386_STRING_H_ + +void *memset(void *s, int c, size_t n); + +#endif diff --git a/ddverify/models/con1/include/asm/system.h b/ddverify/models/con1/include/asm/system.h new file mode 100644 index 000000000..1d6f962e6 --- /dev/null +++ b/ddverify/models/con1/include/asm/system.h @@ -0,0 +1,9 @@ +#ifndef __ASM_SYSTEM_H +#define __ASM_SYSTEM_H + +void rmb(void); +void read_barrier_depends(void); +void wmb(void); +void mb(void); + +#endif diff --git a/ddverify/models/con1/include/asm/termbits.h b/ddverify/models/con1/include/asm/termbits.h new file mode 100644 index 000000000..3606b9897 --- /dev/null +++ b/ddverify/models/con1/include/asm/termbits.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_I386_TERMBITS_H__ +#define __ARCH_I386_TERMBITS_H__ + +#include + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +#endif diff --git a/ddverify/models/con1/include/asm/termios.h b/ddverify/models/con1/include/asm/termios.h new file mode 100644 index 000000000..8f71467a2 --- /dev/null +++ b/ddverify/models/con1/include/asm/termios.h @@ -0,0 +1,54 @@ +#ifndef _I386_TERMIOS_H +#define _I386_TERMIOS_H + +#include +#include + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 /* X.25 async */ +#define N_6PACK 7 +#define N_MASC 8 /* Reserved for Mobitex module */ +#define N_R3964 9 /* Reserved for Simatic R3964 module */ +#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */ +#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */ +#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */ +#define N_HDLC 13 /* synchronous HDLC */ +#define N_SYNC_PPP 14 /* synchronous PPP */ +#define N_HCI 15 /* Bluetooth HCI UART */ + +#endif /* _I386_TERMIOS_H */ diff --git a/ddverify/models/con1/include/asm/types.h b/ddverify/models/con1/include/asm/types.h new file mode 100644 index 000000000..39b35bb5e --- /dev/null +++ b/ddverify/models/con1/include/asm/types.h @@ -0,0 +1,35 @@ +#ifndef _I386_TYPES_H +#define _I386_TYPES_H + +typedef unsigned short umode_t; + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +typedef __signed__ long long __s64; +typedef unsigned long long __u64; + +#define BITS_PER_LONG 32 + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +typedef u32 dma_addr_t; +typedef u64 dma64_addr_t; + +#endif diff --git a/ddverify/models/con1/include/asm/uaccess.h b/ddverify/models/con1/include/asm/uaccess.h new file mode 100644 index 000000000..a764a014c --- /dev/null +++ b/ddverify/models/con1/include/asm/uaccess.h @@ -0,0 +1,55 @@ +#ifndef __i386_UACCESS_H +#define __i386_UACCESS_H + +/* + * User space memory access functions + */ +#include +#include +#include +#include + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +/** + * access_ok: - Checks if a user space pointer is valid + * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that + * %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe + * to write to a block, it is always safe to read from it. + * @addr: User space pointer to start of block to check + * @size: Size of block to check + * + * Context: User context only. This function may sleep. + * + * Checks if a pointer to a block of memory in user space is valid. + * + * Returns true (nonzero) if the memory block may be valid, false (zero) + * if it is definitely invalid. + * + * Note that, depending on architecture, this function probably just + * checks that the pointer is in the user space range - after calling + * this function, memory access functions may still return -EFAULT. + */ +// #define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0)) +int access_ok(int type, const void *addr, unsigned long size); + + +// DDV-TODO: get_user and put_user are defined as macros!!! if bug030 is fixed, this should be done here. + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __get_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int get_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __put_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int put_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n); +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_from_user(void *to, void __user *from, unsigned long n); + +#endif /* __i386_UACCESS_H */ diff --git a/ddverify/models/con1/include/ddverify/blkdev.h b/ddverify/models/con1/include/ddverify/blkdev.h new file mode 100644 index 000000000..aa65ce957 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/blkdev.h @@ -0,0 +1,10 @@ +#ifndef _DDV_BLKDEV_H_ +#define _DDV_BLKDEV_H_ + +#define MAX_REQUEST_QUEUE_SUPPORT 10 + +request_queue_t fixed_request_queue[MAX_REQUEST_QUEUE_SUPPORT]; + +int number_request_queue_used = 0; + +#endif diff --git a/ddverify/models/con1/include/ddverify/cdev.h b/ddverify/models/con1/include/ddverify/cdev.h new file mode 100644 index 000000000..b4fa43cbe --- /dev/null +++ b/ddverify/models/con1/include/ddverify/cdev.h @@ -0,0 +1,26 @@ +#ifndef _DDV_CDEV_H +#define _DDV_CDEV_H + +#include +#include + +#define MAX_CDEV_SUPPORT 10 + +#include + +short number_cdev_registered = 0; + +struct ddv_cdev { + struct cdev *cdevp; + + struct file filp; + struct inode inode; + + int open; +}; + +struct ddv_cdev cdev_registered[MAX_CDEV_SUPPORT]; + +void call_cdev_functions(); + +#endif diff --git a/ddverify/models/con1/include/ddverify/ddverify.h b/ddverify/models/con1/include/ddverify/ddverify.h new file mode 100644 index 000000000..f6d8a06fe --- /dev/null +++ b/ddverify/models/con1/include/ddverify/ddverify.h @@ -0,0 +1,47 @@ +#ifndef _DDVERIFY_H +#define _DDVERIFY_H + +enum __bool { false, true }; + +#ifndef NULL +#define NULL ((void *)0) +#endif + + +int current_execution_context; + +#define CONTEXT_PROCESS 1 +#define CONTEXT_INTERRUPT 2 + +#define switch_context(x) current_execution_context = x + +#ifdef DDV_ASSERT_CONTEXT + +static inline assert_context_process() +{ + __CPROVER_assert(current_execution_context == CONTEXT_PROCESS, "Process context"); +} + +static inline assert_context_interrupt() +{ + __CPROVER_assert(current_execution_context == CONTEXT_INTERRUPT, "Interrupt context"); +} + +#else + +static inline assert_context_process() +{ +} + +static inline assert_context_interrupt() +{ +} + +#endif /* DDV_ASSERT_CONTEXT */ + +int (* _ddv_module_init)(void); +void (* _ddv_module_exit)(void); + +int call_ddv(); + +#endif diff --git a/ddverify/models/con1/include/ddverify/fixed_cdev.h b/ddverify/models/con1/include/ddverify/fixed_cdev.h new file mode 100644 index 000000000..347972b25 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/fixed_cdev.h @@ -0,0 +1,15 @@ +#ifndef _DDV_FIXED_CDEV_H_ +#define _DDV_FIXED_CDEV_H_ + +#include +#include +#include + +// Used in function misc_register and cdev_alloc. Instead allocating a cdev structure, +// a cdev structure from this array is used. This make the verification process much +// simpler. + +struct cdev fixed_cdev[MAX_CDEV_SUPPORT]; +int fixed_cdev_used = 0; + +#endif diff --git a/ddverify/models/con1/include/ddverify/genhd.h b/ddverify/models/con1/include/ddverify/genhd.h new file mode 100644 index 000000000..3d0161e60 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/genhd.h @@ -0,0 +1,29 @@ +#ifndef _DDV_GENHD_H +#define _DDV_GENHD_H + +#include +#include +#include + +#include + +#define MAX_GENHD_SUPPORT 10 + +short number_genhd_registered = 0; +short number_fixed_genhd_used = 0; + +struct ddv_genhd { + struct gendisk *gd; + + struct inode inode; + struct file file; + struct request current_request; + int requests_open; +}; + +struct gendisk fixed_gendisk[MAX_GENHD_SUPPORT]; +struct ddv_genhd genhd_registered[MAX_GENHD_SUPPORT]; + +void call_genhd_functions(); + +#endif diff --git a/ddverify/models/con1/include/ddverify/interrupt.h b/ddverify/models/con1/include/ddverify/interrupt.h new file mode 100644 index 000000000..bca87a686 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/interrupt.h @@ -0,0 +1,19 @@ +#ifndef _DDV_INTERRUPT_H +#define _DDV_INTERRUPT_H + +#include +#include + +#define MAX_IRQ_SUPPORT 16 + +struct registered_irq { + irq_handler_t handler; + void *dev_id; +}; + +struct registered_irq registered_irq[MAX_IRQ_SUPPORT]; + +void call_interrupt_handler(); + +#endif + diff --git a/ddverify/models/con1/include/ddverify/ioctl.h b/ddverify/models/con1/include/ddverify/ioctl.h new file mode 100644 index 000000000..76312e082 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/ioctl.h @@ -0,0 +1,15 @@ +#ifndef _DDV_IOCTL_H +#define _DDV_IOCTL_H + +/*#define MAX_IOCTL_SUPPORT 20 + +short number_ioctl_registered = 0; + +typedef unsigned int ddv_ioctl; + +ddv_ioctl ioctl_registered[MAX_IOCTL_SUPPORT]; + +void add_ioctl(unsigned int); +unsigned int get_ioctl_cmd(); +*/ +#endif diff --git a/ddverify/models/con1/include/ddverify/ioport.h b/ddverify/models/con1/include/ddverify/ioport.h new file mode 100644 index 000000000..d96407ad7 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/ioport.h @@ -0,0 +1,27 @@ +#ifndef _DDV_IOPORT_H +#define _DDV_IOPORT_H + +#include + +//#define NUMBER_IO_PORTS 65536 + +//ushort ddv_ioport[NUMBER_IO_PORTS - 1]; + +int ddv_ioport_request_start; +int ddv_ioport_request_len; + +#ifdef DDV_ASSERT_IO + +// __CPROVER_assert(ddv_ioport[port], "Used I/O Port was requested") + +#define ddv_correct_port_use(port) \ +__CPROVER_assert(port >= ddv_ioport_request_start && port < ddv_ioport_request_start + ddv_ioport_request_len, "I/O port is requested") + +#else + +#define ddv_correct_port_use(port) \ + do { } while(0) + +#endif /* DDV_ASSERT_IO */ + +#endif diff --git a/ddverify/models/con1/include/ddverify/miscdevice.h b/ddverify/models/con1/include/ddverify/miscdevice.h new file mode 100644 index 000000000..43b174d28 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/miscdevice.h @@ -0,0 +1,7 @@ +#ifndef _DDV_MISCDEVICE_H +#define _DDV_MISCDEVICE_H + +#include + +#endif + diff --git a/ddverify/models/con1/include/ddverify/pci.h b/ddverify/models/con1/include/ddverify/pci.h new file mode 100644 index 000000000..d2ece19a8 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/pci.h @@ -0,0 +1,22 @@ +#ifndef _DDV_PCI_H_ +#define _DDV_PCI_H_ + +#include + +struct ddv_pci_driver { + struct pci_driver *pci_driver; + struct pci_dev pci_dev; + + unsigned int no_pci_device_id; + int dev_initialized; +}; + +struct ddv_pci_driver registered_pci_driver; + +int pci_probe_device(); +void pci_remove_device(); + +void call_pci_functions(); + + +#endif diff --git a/ddverify/models/con1/include/ddverify/pthread.h b/ddverify/models/con1/include/ddverify/pthread.h new file mode 100644 index 000000000..64c351ee6 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/pthread.h @@ -0,0 +1,253 @@ +#ifndef __POSIX_PTHREAD_H +#define __POSIX_PTHREAD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NULL +#define NULL ((void *)0) +#endif + +/* Types */ +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +struct __pthread_mutex_t_struct +{ + _Bool locked; +}; + +struct __pthread_mutexattr_t_struct +{ + int dummy; +}; + +struct __pthread_spinlock_t_struct +{ + int dummy; +}; + +struct __pthread_barrier_t_struct +{ + int dummy; +}; + +struct __pthread_barrierattr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; +typedef struct __pthread_mutex_t_struct pthread_mutex_t; +typedef struct __pthread_mutexattr_t_struct pthread_mutexattr_t; +typedef struct __pthread_spinlock_t_struct pthread_spinlock_t; +typedef struct __pthread_barrier_t_struct pthread_barrier_t; +typedef struct __pthread_barrierattr_t_struct pthread_barrierattr_t; + +/* Initializers */ + +#define PTHREAD_MUTEX_INITIALIZER {0} + +/* Attributes */ + +enum +{ + PTHREAD_CREATE_JOINABLE, +#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE + PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED +}; + +enum +{ + PTHREAD_INHERIT_SCHED, +#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED + PTHREAD_EXPLICIT_SCHED +#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED +}; + +enum +{ + PTHREAD_SCOPE_SYSTEM, +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM + PTHREAD_SCOPE_PROCESS +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +}; + +enum +{ + PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_ADAPTIVE_NP, + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +}; + +enum +{ + PTHREAD_PROCESS_PRIVATE, +#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE + PTHREAD_PROCESS_SHARED +#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED +}; + +enum +{ + PTHREAD_RWLOCK_PREFER_READER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, + PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP +}; + +#define PTHREAD_ONCE_INIT 0 + +/* -1 is distinct from 0 and all errno constants */ +#define PTHREAD_BARRIER_SERIAL_THREAD -1 + +enum +{ + PTHREAD_CANCEL_ENABLE, +#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE + PTHREAD_CANCEL_DISABLE +#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +}; +enum +{ + PTHREAD_CANCEL_DEFERRED, +#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED + PTHREAD_CANCEL_ASYNCHRONOUS +#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS +}; +#define PTHREAD_CANCELED ((void *) -1) + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create( + pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg); + +extern pthread_t pthread_self(void); +extern int pthread_equal(pthread_t __thread1, pthread_t __thread2); +extern void pthread_exit(void *__retval); +extern int pthread_join(pthread_t __th, void **__thread_return); +extern int pthread_detach(pthread_t __th); +extern int pthread_attr_init(pthread_attr_t *__attr); +extern int pthread_attr_destroy(pthread_attr_t *__attr); +extern int pthread_attr_setdetachstate(pthread_attr_t *__attr, int __detachstate); +extern int pthread_attr_getdetachstate(__const pthread_attr_t *__attr, int *__detachstate); +extern int pthread_attr_setschedparam(pthread_attr_t *__attr, __const struct sched_param *__param); +extern int pthread_attr_getschedparam(__const pthread_attr_t *__attr, struct sched_param *__param); +extern int pthread_attr_setschedpolicy(pthread_attr_t *__attr, int __policy); +extern int pthread_attr_getschedpolicy(__const pthread_attr_t *__attr, int *__policy); +extern int pthread_attr_setinheritsched(pthread_attr_t *__attr, int __inherit); +extern int pthread_attr_getinheritsched(__const pthread_attr_t *__attr, int *__inherit); +extern int pthread_attr_setscope(pthread_attr_t *__attr, int __scope); +extern int pthread_attr_getscope(__const pthread_attr_t *__attr, int *__scope); +extern int pthread_attr_setguardsize(pthread_attr_t *__attr, size_t __guardsize); +extern int pthread_attr_getguardsize(__const pthread_attr_t *__attr, size_t *__guardsize); +extern int pthread_attr_setstackaddr(pthread_attr_t *__attr, void *__stackaddr); +extern int pthread_attr_getstackaddr(__const pthread_attr_t *__attr, void **__stackaddr); +extern int pthread_attr_setstack(pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize); +extern int pthread_attr_getstack(__const pthread_attr_t *__attr, + void **__stackaddr, + size_t *__stacksize); +extern int pthread_attr_setstacksize(pthread_attr_t *__attr, size_t __stacksize); +extern int pthread_attr_getstacksize(__const pthread_attr_t *, size_t *__stacksize); + +extern int pthread_getattr_np(pthread_t __th, pthread_attr_t *__attr); + +extern int pthread_setschedparam(pthread_t __target_thread, int __policy, + __const struct sched_param *__param); + +extern int pthread_getschedparam(pthread_t __target_thread, + int *__policy, + struct sched_param *__param); + +extern int pthread_getconcurrency(void); +extern int pthread_setconcurrency(int __level); +extern int pthread_yield(void); + +extern inline int pthread_mutex_init( + pthread_mutex_t *__mutex, + __const pthread_mutexattr_t *__mutex_attr) +{ + pthread_mutex_t i=PTHREAD_MUTEX_INITIALIZER; + *__mutex=i; +} + +extern inline int pthread_mutex_destroy(pthread_mutex_t *__mutex) +{ +} + +extern int pthread_mutex_trylock(pthread_mutex_t *__mutex); + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + +extern inline int pthread_mutex_lock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + __CPROVER_assume(!__mutex->locked); + __mutex->locked=1; + __CPROVER_atomic_end(); + return 0; // we never fail +} + +extern inline int pthread_mutex_unlock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_assert(__mutex->locked, "pthread_mutex_unlock without lock"); + __mutex->locked=0; + return 0; // we never fail +} + +extern int pthread_spin_init(pthread_spinlock_t *__lock, int __pshared); +extern int pthread_spin_destroy(pthread_spinlock_t *__lock); +extern int pthread_spin_lock(pthread_spinlock_t *__lock); +extern int pthread_spin_trylock(pthread_spinlock_t *__lock); +extern int pthread_spin_unlock(pthread_spinlock_t *__lock); +extern int pthread_barrier_init(pthread_barrier_t *__barrier, + __const pthread_barrierattr_t *__attr, unsigned int __count); + +extern int pthread_barrier_destroy(pthread_barrier_t *__barrier); +extern int pthread_barrierattr_init(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_destroy(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_getpshared(__const pthread_barrierattr_t *__attr, + int *__pshared); + +extern int pthread_barrierattr_setpshared(pthread_barrierattr_t *__attr, int __pshared); +extern int pthread_barrier_wait(pthread_barrier_t *__barrier); + +extern int pthread_setcancelstate(int __state, int *__oldstate); +extern int pthread_setcanceltype(int __type, int *__oldtype); +extern int pthread_cancel(pthread_t __cancelthread); +extern void pthread_testcancel(void); + +extern int pthread_atfork(void (*__prepare)(void), + void (*__parent)(void), + void (*__child)(void)); + +extern void pthread_kill_other_threads_np(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ddverify/models/con1/include/ddverify/satabs.h b/ddverify/models/con1/include/ddverify/satabs.h new file mode 100644 index 000000000..bb40b9867 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/satabs.h @@ -0,0 +1,69 @@ +#ifndef _SATABS_H +#define _SATABS_H + +#include +#include + +// memory management + +void *malloc(size_t size); + + +// nondeterministic functions + +short nondet_short(); +unsigned short nondet_ushort(); +int nondet_int(); +unsigned int nondet_uint(); +long nondet_long(); +unsigned long nondet_ulong(); +char nondet_char(); +unsigned char nondet_uchar(); +unsigned nondet_unsigned(); +loff_t nondet_loff_t(); +size_t nondet_size_t(); +sector_t nondet_sector_t(); +u32 nondet_u32(); +char * nondet_pchar(); +enum __bool nondet_bool(); + + +// handling asm code + +void noop(); +#define asm(code, ...) noop() + + +// __CPROVER functions + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + + +// pthread +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create(pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg) +{ + __CPROVER_HIDE: + *__threadp = nondet_pthread_t(); + CPROVER_ASYNC_1: __start_routine(__arg); + return 0; +} +#endif diff --git a/ddverify/models/con1/include/ddverify/tasklet.h b/ddverify/models/con1/include/ddverify/tasklet.h new file mode 100644 index 000000000..52e9e64f6 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/tasklet.h @@ -0,0 +1,20 @@ +#ifndef _DDV_TASKLET_H_ +#define _DDV_TASKLET_H_ + +#include + +#define MAX_TASKLET_SUPPORT 10 + +short number_tasklet_registered = 0; + +struct ddv_tasklet { + struct tasklet_struct *tasklet; + unsigned short is_running; +}; + +struct ddv_tasklet tasklet_registered[MAX_TASKLET_SUPPORT]; + +void call_tasklet_functions(); + +#endif + diff --git a/ddverify/models/con1/include/ddverify/timer.h b/ddverify/models/con1/include/ddverify/timer.h new file mode 100644 index 000000000..929cd7fca --- /dev/null +++ b/ddverify/models/con1/include/ddverify/timer.h @@ -0,0 +1,17 @@ +#ifndef _DDV_TIMER_H_ +#define _DDV_TIMER_H_ + +#include + +#define MAX_TIMER_SUPPORT 5 + +short number_timer_registered = 0; + +struct ddv_timer { + struct timer_list *timer; +}; + +struct ddv_timer timer_registered[MAX_TIMER_SUPPORT]; + +void call_timer_functions(); +#endif diff --git a/ddverify/models/con1/include/ddverify/tty.h b/ddverify/models/con1/include/ddverify/tty.h new file mode 100644 index 000000000..de3b5226f --- /dev/null +++ b/ddverify/models/con1/include/ddverify/tty.h @@ -0,0 +1,16 @@ +#ifndef _DDV_TTY_H_ +#define _DDV_TTY_H_ + +#include +#include + +struct ddv_tty_driver { + struct tty_driver driver; + unsigned short allocated; + unsigned short registered; +}; + +struct ddv_tty_driver global_tty_driver; + +#endif + diff --git a/ddverify/models/con1/include/ddverify/workqueue.h b/ddverify/models/con1/include/ddverify/workqueue.h new file mode 100644 index 000000000..2db429169 --- /dev/null +++ b/ddverify/models/con1/include/ddverify/workqueue.h @@ -0,0 +1,12 @@ +#ifndef _DDV_WORKQUEUE_H_ +#define _DDV_WORKQUEUE_H_ + +#include + +#define MAX_WORKQUEUE_ELEMENTS_SUPPORT 10 + +struct work_struct *shared_workqueue[MAX_WORKQUEUE_ELEMENTS_SUPPORT]; + +void call_shared_workqueue_functions(); + +#endif diff --git a/ddverify/models/con1/include/linux/backing-dev.h b/ddverify/models/con1/include/linux/backing-dev.h new file mode 100644 index 000000000..1804ab33f --- /dev/null +++ b/ddverify/models/con1/include/linux/backing-dev.h @@ -0,0 +1,37 @@ +/* + * include/linux/backing-dev.h + * + * low-level device information and state which is propagated up through + * to high-level code. + */ + +#ifndef _LINUX_BACKING_DEV_H +#define _LINUX_BACKING_DEV_H + +struct backing_dev_info { + unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ + unsigned long state; /* Always use atomic bitops on this */ + unsigned int capabilities; /* Device capabilities */ +}; + + +/* + * Flags in backing_dev_info::capability + * - The first two flags control whether dirty pages will contribute to the + * VM's accounting and whether writepages() should be called for dirty pages + * (something that would not, for example, be appropriate for ramfs) + * - These flags let !MMU mmap() govern direct device mapping vs immediate + * copying more easily for MAP_PRIVATE, especially for ROM filesystems + */ +#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ +#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ +#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ +#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ +#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ +#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ +#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ +#define BDI_CAP_VMFLAGS \ + (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) + + +#endif /* _LINUX_BACKING_DEV_H */ diff --git a/ddverify/models/con1/include/linux/bcd.h b/ddverify/models/con1/include/linux/bcd.h new file mode 100644 index 000000000..c54530812 --- /dev/null +++ b/ddverify/models/con1/include/linux/bcd.h @@ -0,0 +1,20 @@ +/* Permission is hereby granted to copy, modify and redistribute this code + * in terms of the GNU Library General Public License, Version 2 or later, + * at your option. + */ + +/* macros to translate to/from binary and binary-coded decimal (frequently + * found in RTC chips). + */ + +#ifndef _BCD_H +#define _BCD_H + +#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) +#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) + +/* backwards compat */ +#define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) +#define BIN_TO_BCD(val) ((val)=BIN2BCD(val)) + +#endif /* _BCD_H */ diff --git a/ddverify/models/con1/include/linux/bio.h b/ddverify/models/con1/include/linux/bio.h new file mode 100644 index 000000000..159afe963 --- /dev/null +++ b/ddverify/models/con1/include/linux/bio.h @@ -0,0 +1,110 @@ +#ifndef __LINUX_BIO_H +#define __LINUX_BIO_H + +#include + +struct bio_vec { + struct page *bv_page; + unsigned int bv_len; + unsigned int bv_offset; +}; + +struct bio_set; +struct bio; +typedef int (bio_end_io_t) (struct bio *, unsigned int, int); +typedef void (bio_destructor_t) (struct bio *); + +struct bio { + sector_t bi_sector; + + struct bio *bi_next; /* request queue link */ + struct block_device *bi_bdev; + unsigned long bi_flags; /* status, command, etc */ + unsigned long bi_rw; + + unsigned short bi_vcnt; + unsigned short bi_idx; + + /* Number of segments in this BIO after + * physical address coalescing is performed. + */ + unsigned short bi_phys_segments; + + unsigned int bi_size; + struct bio_vec *bi_io_vec; + + bio_end_io_t *bi_end_io; + + void *bi_private; +}; + +/* + * bio flags + */ +#define BIO_UPTODATE 0 /* ok after I/O completion */ +#define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ +#define BIO_EOF 2 /* out-out-bounds error */ +#define BIO_SEG_VALID 3 /* nr_hw_seg valid */ +#define BIO_CLONED 4 /* doesn't own data */ +#define BIO_BOUNCED 5 /* bio is a bounce bio */ +#define BIO_USER_MAPPED 6 /* contains user pages */ +#define BIO_EOPNOTSUPP 7 /* not supported */ +#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) + +/* + * top 4 bits of bio flags indicate the pool this bio came from + */ +#define BIO_POOL_BITS (4) +#define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) +#define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) +#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) + +/* + * bio bi_rw flags + * + * bit 0 -- read (not set) or write (set) + * bit 1 -- rw-ahead when set + * bit 2 -- barrier + * bit 3 -- fail fast, don't want low level driver retries + * bit 4 -- synchronous I/O hint: the block layer will unplug immediately + */ +#define BIO_RW 0 +#define BIO_RW_AHEAD 1 +#define BIO_RW_BARRIER 2 +#define BIO_RW_FAILFAST 3 +#define BIO_RW_SYNC 4 + + +#define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)])) +#define bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_idx) +#define bio_page(bio) bio_iovec((bio))->bv_page +#define bio_offset(bio) bio_iovec((bio))->bv_offset +#define bio_sectors(bio) ((bio)->bi_size >> 9) +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +#define bio_data(bio) (page_address(bio_page((bio))) + bio_offset((bio))) +#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER)) +#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC)) +#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) +#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) +#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) + +/* + * drivers should not use the __ version unless they _really_ want to + * run through the entire bio and not just pending pieces + */ +#define __bio_for_each_segment(bvl, bio, i, start_idx) \ + for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ + i < (bio)->bi_vcnt; \ + bvl++, i++) + +#define bio_for_each_segment(bvl, bio, i) \ + __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx) + +void * __bio_kmap_atomic(struct bio *, int, enum km_type); +void __bio_kunmap_atomic(char *buffer, enum km_type); + +void bio_endio(struct bio *, unsigned int, int); +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +int bio_cur_sectors(struct bio *); + +#endif /* __LINUX_BIO_H */ diff --git a/ddverify/models/con1/include/linux/bitops.h b/ddverify/models/con1/include/linux/bitops.h new file mode 100644 index 000000000..3e24f9c39 --- /dev/null +++ b/ddverify/models/con1/include/linux/bitops.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_BITOPS_H +#define _LINUX_BITOPS_H + +#include + +#endif diff --git a/ddverify/models/con1/include/linux/blkdev.h b/ddverify/models/con1/include/linux/blkdev.h new file mode 100644 index 000000000..d31cd7561 --- /dev/null +++ b/ddverify/models/con1/include/linux/blkdev.h @@ -0,0 +1,239 @@ +#ifndef _LINUX_BLKDEV_H +#define _LINUX_BLKDEV_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include + +#include + +struct request_queue; +typedef struct request_queue request_queue_t; + +typedef void (request_fn_proc) (request_queue_t *q); +typedef int (make_request_fn) (request_queue_t *q, struct bio *bio); +typedef void (unplug_fn) (request_queue_t *); + +/* + * request command types + */ +enum rq_cmd_type_bits { + REQ_TYPE_FS = 1, /* fs request */ + REQ_TYPE_BLOCK_PC, /* scsi command */ + REQ_TYPE_SENSE, /* sense request */ + REQ_TYPE_PM_SUSPEND, /* suspend request */ + REQ_TYPE_PM_RESUME, /* resume request */ + REQ_TYPE_PM_SHUTDOWN, /* shutdown request */ + REQ_TYPE_FLUSH, /* flush request */ + REQ_TYPE_SPECIAL, /* driver defined type */ + REQ_TYPE_LINUX_BLOCK, /* generic block layer message */ + /* + * for ATA/ATAPI devices. this really doesn't belong here, ide should + * use REQ_TYPE_SPECIAL and use rq->cmd[0] with the range of driver + * private REQ_LB opcodes to differentiate what type of request this is + */ + REQ_TYPE_ATA_CMD, + REQ_TYPE_ATA_TASK, + REQ_TYPE_ATA_TASKFILE, + REQ_TYPE_ATA_PC, +}; + + +struct request_queue { + request_fn_proc *request_fn; + make_request_fn *make_request_fn; + unplug_fn *unplug_fn; + + struct backing_dev_info backing_dev_info; + void *queuedata; + + /* + * various queue flags, see QUEUE_* below + */ + unsigned long queue_flags; + + spinlock_t *queue_lock; + + unsigned short hardsect_size; + + int __ddv_genhd_no; + int __ddv_queue_alive; +}; + +#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ +#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ +#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */ +#define QUEUE_FLAG_READFULL 3 /* write queue has been filled */ +#define QUEUE_FLAG_WRITEFULL 4 /* read queue has been filled */ +#define QUEUE_FLAG_DEAD 5 /* queue being torn down */ +#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ +#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ +#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ + + + +#define BLK_MAX_CDB 16 + + +struct request { + struct list_head queuelist; + struct list_head donelist; + + request_queue_t *q; + + + unsigned long flags; /* see REQ_ bits below */ + + unsigned int cmd_flags; + enum rq_cmd_type_bits cmd_type; + + struct bio *bio; + + void *completion_data; + + struct gendisk *rq_disk; + sector_t sector; + unsigned long nr_sectors; /* no. of sectors left to submit */ + unsigned int current_nr_sectors; + char *buffer; + + int errors; + + unsigned short nr_phys_segments; + + unsigned char cmd[BLK_MAX_CDB]; +}; + + + +/* + * first three bits match BIO_RW* bits, important + */ +enum rq_flag_bits { + __REQ_RW, /* not set, read. set, write */ + __REQ_FAILFAST, /* no low level driver retries */ + __REQ_SORTED, /* elevator knows about this request */ + __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ + __REQ_HARDBARRIER, /* may not be passed by drive either */ + __REQ_FUA, /* forced unit access */ + __REQ_CMD, /* is a regular fs rw request */ + __REQ_NOMERGE, /* don't touch this for merging */ + __REQ_STARTED, /* drive already may have started this one */ + __REQ_DONTPREP, /* don't call prep for this one */ + __REQ_QUEUED, /* uses queueing */ + __REQ_ELVPRIV, /* elevator private data attached */ + /* + * for ATA/ATAPI devices + */ + __REQ_PC, /* packet command (special) */ + __REQ_BLOCK_PC, /* queued down pc from block layer */ + __REQ_SENSE, /* sense retrival */ + + __REQ_FAILED, /* set if the request failed */ + __REQ_QUIET, /* don't worry about errors */ + __REQ_SPECIAL, /* driver suplied command */ + __REQ_DRIVE_CMD, + __REQ_DRIVE_TASK, + __REQ_DRIVE_TASKFILE, + __REQ_PREEMPT, /* set for "ide_preempt" requests */ + __REQ_PM_SUSPEND, /* suspend request */ + __REQ_PM_RESUME, /* resume request */ + __REQ_PM_SHUTDOWN, /* shutdown request */ + __REQ_ORDERED_COLOR, /* is before or after barrier */ + __REQ_NR_BITS, /* stops here */ +}; + +#define REQ_RW (1 << __REQ_RW) +#define REQ_FAILFAST (1 << __REQ_FAILFAST) +#define REQ_SORTED (1 << __REQ_SORTED) +#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) +#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) +#define REQ_FUA (1 << __REQ_FUA) +#define REQ_CMD (1 << __REQ_CMD) +#define REQ_NOMERGE (1 << __REQ_NOMERGE) +#define REQ_STARTED (1 << __REQ_STARTED) +#define REQ_DONTPREP (1 << __REQ_DONTPREP) +#define REQ_QUEUED (1 << __REQ_QUEUED) +#define REQ_ELVPRIV (1 << __REQ_ELVPRIV) +#define REQ_PC (1 << __REQ_PC) +#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC) +#define REQ_SENSE (1 << __REQ_SENSE) +#define REQ_FAILED (1 << __REQ_FAILED) +#define REQ_QUIET (1 << __REQ_QUIET) +#define REQ_SPECIAL (1 << __REQ_SPECIAL) +#define REQ_DRIVE_CMD (1 << __REQ_DRIVE_CMD) +#define REQ_DRIVE_TASK (1 << __REQ_DRIVE_TASK) +#define REQ_DRIVE_TASKFILE (1 << __REQ_DRIVE_TASKFILE) +#define REQ_PREEMPT (1 << __REQ_PREEMPT) +#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) +#define REQ_PM_RESUME (1 << __REQ_PM_RESUME) +#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) +#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) + + +#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) +#define rq_data_dir(rq) ((rq)->cmd_flags & 1) + +#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) + +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_alloc_queue(gfp_t); +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_make_request(request_queue_t *, make_request_fn *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_hardsect_size(request_queue_t *, unsigned short); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_cleanup_queue(request_queue_t *); +// DDV: TODO +void blk_put_queue(request_queue_t *); + + +// DDV: TODO +void blk_plug_device(request_queue_t *); +// DDV: TODO +int blk_remove_plug(request_queue_t *); + +// DDV: TODO +void blkdev_dequeue_request(struct request *req); + +// DDV: TODO +int end_that_request_first(struct request *, int, int); +// DDV: TODO +int end_that_request_chunk(struct request *, int, int); +// DDV: TODO +void end_that_request_last(struct request *, int); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void end_request(struct request *req, int uptodate); +// DDV: TODO +void blk_complete_request(struct request *); + +// DDV: TODO +void blk_queue_bounce_limit(request_queue_t *, u64); + +// DDV: TODO +void blk_queue_max_phys_segments(request_queue_t *, unsigned short); +// DDV: TODO +void blk_queue_max_hw_segments(request_queue_t *, unsigned short); + +// DDV: TODO +int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); + +#define rq_for_each_bio(_bio, rq) \ + if ((rq->bio)) \ + for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next) + +#endif diff --git a/ddverify/models/con1/include/linux/blkpg.h b/ddverify/models/con1/include/linux/blkpg.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/blktrace_api.h b/ddverify/models/con1/include/linux/blktrace_api.h new file mode 100644 index 000000000..4a4b02e12 --- /dev/null +++ b/ddverify/models/con1/include/linux/blktrace_api.h @@ -0,0 +1,141 @@ +#ifndef BLKTRACE_H +#define BLKTRACE_H + +#include +//#include + +/* + * Trace categories + */ +enum blktrace_cat { + BLK_TC_READ = 1 << 0, /* reads */ + BLK_TC_WRITE = 1 << 1, /* writes */ + BLK_TC_BARRIER = 1 << 2, /* barrier */ + BLK_TC_SYNC = 1 << 3, /* sync IO */ + BLK_TC_QUEUE = 1 << 4, /* queueing/merging */ + BLK_TC_REQUEUE = 1 << 5, /* requeueing */ + BLK_TC_ISSUE = 1 << 6, /* issue */ + BLK_TC_COMPLETE = 1 << 7, /* completions */ + BLK_TC_FS = 1 << 8, /* fs requests */ + BLK_TC_PC = 1 << 9, /* pc requests */ + BLK_TC_NOTIFY = 1 << 10, /* special message */ + BLK_TC_AHEAD = 1 << 11, /* readahead */ + BLK_TC_META = 1 << 12, /* metadata */ + + BLK_TC_END = 1 << 15, /* only 16-bits, reminder */ +}; + +#define BLK_TC_SHIFT (16) +#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT) + +/* + * Basic trace actions + */ +enum blktrace_act { + __BLK_TA_QUEUE = 1, /* queued */ + __BLK_TA_BACKMERGE, /* back merged to existing rq */ + __BLK_TA_FRONTMERGE, /* front merge to existing rq */ + __BLK_TA_GETRQ, /* allocated new request */ + __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */ + __BLK_TA_REQUEUE, /* request requeued */ + __BLK_TA_ISSUE, /* sent to driver */ + __BLK_TA_COMPLETE, /* completed by driver */ + __BLK_TA_PLUG, /* queue was plugged */ + __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */ + __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */ + __BLK_TA_INSERT, /* insert request */ + __BLK_TA_SPLIT, /* bio was split */ + __BLK_TA_BOUNCE, /* bio was bounced */ + __BLK_TA_REMAP, /* bio was remapped */ +}; + +/* + * Trace actions in full. Additionally, read or write is masked + */ +#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE)) +#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE)) +#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE)) +#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SPLIT (__BLK_TA_SPLIT) +#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) +#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) + +#define BLK_IO_TRACE_MAGIC 0x65617400 +#define BLK_IO_TRACE_VERSION 0x07 + +/* + * The trace itself + */ +struct blk_io_trace { + u32 magic; /* MAGIC << 8 | version */ + u32 sequence; /* event number */ + u64 time; /* in microseconds */ + u64 sector; /* disk offset */ + u32 bytes; /* transfer length */ + u32 action; /* what happened */ + u32 pid; /* who did it */ + u32 device; /* device number */ + u32 cpu; /* on what cpu did it happen */ + u16 error; /* completion error */ + u16 pdu_len; /* length of data after this trace */ +}; + +/* + * The remap event + */ +struct blk_io_trace_remap { + __be32 device; + u32 __pad; + __be64 sector; +}; + +enum { + Blktrace_setup = 1, + Blktrace_running, + Blktrace_stopped, +}; + +struct blk_trace { + int trace_state; + struct rchan *rchan; + unsigned long *sequence; + u16 act_mask; + u64 start_lba; + u64 end_lba; + u32 pid; + u32 dev; + struct dentry *dir; + struct dentry *dropped_file; + atomic_t dropped; +}; + +/* + * User setup structure passed with BLKTRACESTART + */ +struct blk_user_trace_setup { + char name[BDEVNAME_SIZE]; /* output */ + u16 act_mask; /* input */ + u32 buf_size; /* input */ + u32 buf_nr; /* input */ + u64 start_lba; + u64 end_lba; + u32 pid; +}; + +#define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) +#define blk_trace_shutdown(q) do { } while (0) +#define blk_add_trace_rq(q, rq, what) do { } while (0) +#define blk_add_trace_bio(q, rq, what) do { } while (0) +#define blk_add_trace_generic(q, rq, rw, what) do { } while (0) +#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0) +#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0) + +#endif diff --git a/ddverify/models/con1/include/linux/buffer_head.h b/ddverify/models/con1/include/linux/buffer_head.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/byteorder/generic.h b/ddverify/models/con1/include/linux/byteorder/generic.h new file mode 100644 index 000000000..4dd8f5fb9 --- /dev/null +++ b/ddverify/models/con1/include/linux/byteorder/generic.h @@ -0,0 +1,46 @@ +#ifndef _LINUX_BYTEORDER_GENERIC_H +#define _LINUX_BYTEORDER_GENERIC_H + +#define cpu_to_le64 __cpu_to_le64 +#define le64_to_cpu __le64_to_cpu +#define cpu_to_le32 __cpu_to_le32 +#define le32_to_cpu __le32_to_cpu +#define cpu_to_le16 __cpu_to_le16 +#define le16_to_cpu __le16_to_cpu +#define cpu_to_be64 __cpu_to_be64 +#define be64_to_cpu __be64_to_cpu +#define cpu_to_be32 __cpu_to_be32 +#define be32_to_cpu __be32_to_cpu +#define cpu_to_be16 __cpu_to_be16 +#define be16_to_cpu __be16_to_cpu +#define cpu_to_le64p __cpu_to_le64p +#define le64_to_cpup __le64_to_cpup +#define cpu_to_le32p __cpu_to_le32p +#define le32_to_cpup __le32_to_cpup +#define cpu_to_le16p __cpu_to_le16p +#define le16_to_cpup __le16_to_cpup +#define cpu_to_be64p __cpu_to_be64p +#define be64_to_cpup __be64_to_cpup +#define cpu_to_be32p __cpu_to_be32p +#define be32_to_cpup __be32_to_cpup +#define cpu_to_be16p __cpu_to_be16p +#define be16_to_cpup __be16_to_cpup +#define cpu_to_le64s __cpu_to_le64s +#define le64_to_cpus __le64_to_cpus +#define cpu_to_le32s __cpu_to_le32s +#define le32_to_cpus __le32_to_cpus +#define cpu_to_le16s __cpu_to_le16s +#define le16_to_cpus __le16_to_cpus +#define cpu_to_be64s __cpu_to_be64s +#define be64_to_cpus __be64_to_cpus +#define cpu_to_be32s __cpu_to_be32s +#define be32_to_cpus __be32_to_cpus +#define cpu_to_be16s __cpu_to_be16s +#define be16_to_cpus __be16_to_cpus + +#define htonl(x) x +#define ntohl(x) x +#define htons(x) x +#define ntohs(x) x + +#endif /* _LINUX_BYTEORDER_GENERIC_H */ diff --git a/ddverify/models/con1/include/linux/byteorder/little_endian.h b/ddverify/models/con1/include/linux/byteorder/little_endian.h new file mode 100644 index 000000000..9925e2e4e --- /dev/null +++ b/ddverify/models/con1/include/linux/byteorder/little_endian.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H +#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H + +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN 1234 +#endif +#ifndef __LITTLE_ENDIAN_BITFIELD +#define __LITTLE_ENDIAN_BITFIELD +#endif + +#include +//#include + + +#define __cpu_to_le64(x) x +#define __le64_to_cpu(x) x +#define __cpu_to_le32(x) x +#define __le32_to_cpu(x) x +#define __cpu_to_le16(x) x +#define __le16_to_cpu(x) x +#define __cpu_to_be64(x) x +#define __be64_to_cpu(x) x +#define __cpu_to_be32(x) x +#define __be32_to_cpu(x) x +#define __cpu_to_be16(x) x +#define __be16_to_cpu(x) x + +#include + +#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ diff --git a/ddverify/models/con1/include/linux/cache.h b/ddverify/models/con1/include/linux/cache.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/capability.h b/ddverify/models/con1/include/linux/capability.h new file mode 100644 index 000000000..2d039b6e8 --- /dev/null +++ b/ddverify/models/con1/include/linux/capability.h @@ -0,0 +1,244 @@ +/* + * This is + * + * Andrew G. Morgan + * Alexander Kjeldaas + * with help from Aleph1, Roland Buresund and Andrew Main. + * + * See here for the libcap library ("POSIX draft" compliance): + * + * ftp://linux.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.2/ + */ + +#ifndef _LINUX_CAPABILITY_H +#define _LINUX_CAPABILITY_H + +#include +#include + +/** + ** POSIX-draft defined capabilities. + **/ + +/* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this + overrides the restriction of changing file ownership and group + ownership. */ + +#define CAP_CHOWN 0 + +/* Override all DAC access, including ACL execute access if + [_POSIX_ACL] is defined. Excluding DAC access covered by + CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_OVERRIDE 1 + +/* Overrides all DAC restrictions regarding read and search on files + and directories, including ACL restrictions if [_POSIX_ACL] is + defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_READ_SEARCH 2 + +/* Overrides all restrictions about allowed operations on files, where + file owner ID must be equal to the user ID, except where CAP_FSETID + is applicable. It doesn't override MAC and DAC restrictions. */ + +#define CAP_FOWNER 3 + +/* Overrides the following restrictions that the effective user ID + shall match the file owner ID when setting the S_ISUID and S_ISGID + bits on that file; that the effective group ID (or one of the + supplementary group IDs) shall match the file owner ID when setting + the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are + cleared on successful return from chown(2) (not implemented). */ + +#define CAP_FSETID 4 + +/* Used to decide between falling back on the old suser() or fsuser(). */ + +#define CAP_FS_MASK 0x1f + +/* Overrides the restriction that the real or effective user ID of a + process sending a signal must match the real or effective user ID + of the process receiving the signal. */ + +#define CAP_KILL 5 + +/* Allows setgid(2) manipulation */ +/* Allows setgroups(2) */ +/* Allows forged gids on socket credentials passing. */ + +#define CAP_SETGID 6 + +/* Allows set*uid(2) manipulation (including fsuid). */ +/* Allows forged pids on socket credentials passing. */ + +#define CAP_SETUID 7 + + +/** + ** Linux-specific capabilities + **/ + +/* Transfer any capability in your permitted set to any pid, + remove any capability in your permitted set from any pid */ + +#define CAP_SETPCAP 8 + +/* Allow modification of S_IMMUTABLE and S_APPEND file attributes */ + +#define CAP_LINUX_IMMUTABLE 9 + +/* Allows binding to TCP/UDP sockets below 1024 */ +/* Allows binding to ATM VCIs below 32 */ + +#define CAP_NET_BIND_SERVICE 10 + +/* Allow broadcasting, listen to multicast */ + +#define CAP_NET_BROADCAST 11 + +/* Allow interface configuration */ +/* Allow administration of IP firewall, masquerading and accounting */ +/* Allow setting debug option on sockets */ +/* Allow modification of routing tables */ +/* Allow setting arbitrary process / process group ownership on + sockets */ +/* Allow binding to any address for transparent proxying */ +/* Allow setting TOS (type of service) */ +/* Allow setting promiscuous mode */ +/* Allow clearing driver statistics */ +/* Allow multicasting */ +/* Allow read/write of device-specific registers */ +/* Allow activation of ATM control sockets */ + +#define CAP_NET_ADMIN 12 + +/* Allow use of RAW sockets */ +/* Allow use of PACKET sockets */ + +#define CAP_NET_RAW 13 + +/* Allow locking of shared memory segments */ +/* Allow mlock and mlockall (which doesn't really have anything to do + with IPC) */ + +#define CAP_IPC_LOCK 14 + +/* Override IPC ownership checks */ + +#define CAP_IPC_OWNER 15 + +/* Insert and remove kernel modules - modify kernel without limit */ +/* Modify cap_bset */ +#define CAP_SYS_MODULE 16 + +/* Allow ioperm/iopl access */ +/* Allow sending USB messages to any device via /proc/bus/usb */ + +#define CAP_SYS_RAWIO 17 + +/* Allow use of chroot() */ + +#define CAP_SYS_CHROOT 18 + +/* Allow ptrace() of any process */ + +#define CAP_SYS_PTRACE 19 + +/* Allow configuration of process accounting */ + +#define CAP_SYS_PACCT 20 + +/* Allow configuration of the secure attention key */ +/* Allow administration of the random device */ +/* Allow examination and configuration of disk quotas */ +/* Allow configuring the kernel's syslog (printk behaviour) */ +/* Allow setting the domainname */ +/* Allow setting the hostname */ +/* Allow calling bdflush() */ +/* Allow mount() and umount(), setting up new smb connection */ +/* Allow some autofs root ioctls */ +/* Allow nfsservctl */ +/* Allow VM86_REQUEST_IRQ */ +/* Allow to read/write pci config on alpha */ +/* Allow irix_prctl on mips (setstacksize) */ +/* Allow flushing all cache on m68k (sys_cacheflush) */ +/* Allow removing semaphores */ +/* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores + and shared memory */ +/* Allow locking/unlocking of shared memory segment */ +/* Allow turning swap on/off */ +/* Allow forged pids on socket credentials passing */ +/* Allow setting readahead and flushing buffers on block devices */ +/* Allow setting geometry in floppy driver */ +/* Allow turning DMA on/off in xd driver */ +/* Allow administration of md devices (mostly the above, but some + extra ioctls) */ +/* Allow tuning the ide driver */ +/* Allow access to the nvram device */ +/* Allow administration of apm_bios, serial and bttv (TV) device */ +/* Allow manufacturer commands in isdn CAPI support driver */ +/* Allow reading non-standardized portions of pci configuration space */ +/* Allow DDI debug ioctl on sbpcd driver */ +/* Allow setting up serial ports */ +/* Allow sending raw qic-117 commands */ +/* Allow enabling/disabling tagged queuing on SCSI controllers and sending + arbitrary SCSI commands */ +/* Allow setting encryption key on loopback filesystem */ +/* Allow setting zone reclaim policy */ + +#define CAP_SYS_ADMIN 21 + +/* Allow use of reboot() */ + +#define CAP_SYS_BOOT 22 + +/* Allow raising priority and setting priority on other (different + UID) processes */ +/* Allow use of FIFO and round-robin (realtime) scheduling on own + processes and setting the scheduling algorithm used by another + process. */ +/* Allow setting cpu affinity on other processes */ + +#define CAP_SYS_NICE 23 + +/* Override resource limits. Set resource limits. */ +/* Override quota limits. */ +/* Override reserved space on ext2 filesystem */ +/* Modify data journaling mode on ext3 filesystem (uses journaling + resources) */ +/* NOTE: ext2 honors fsuid when checking for resource overrides, so + you can override using fsuid too */ +/* Override size restrictions on IPC message queues */ +/* Allow more than 64hz interrupts from the real-time clock */ +/* Override max number of consoles on console allocation */ +/* Override max number of keymaps */ + +#define CAP_SYS_RESOURCE 24 + +/* Allow manipulation of system clock */ +/* Allow irix_stime on mips */ +/* Allow setting the real-time clock */ + +#define CAP_SYS_TIME 25 + +/* Allow configuration of tty devices */ +/* Allow vhangup() of tty */ + +#define CAP_SYS_TTY_CONFIG 26 + +/* Allow the privileged aspects of mknod() */ + +#define CAP_MKNOD 27 + +/* Allow taking of leases on files */ + +#define CAP_LEASE 28 + +#define CAP_AUDIT_WRITE 29 + +#define CAP_AUDIT_CONTROL 30 + +int capable(int cap); + +#endif /* !_LINUX_CAPABILITY_H */ diff --git a/ddverify/models/con1/include/linux/cdev.h b/ddverify/models/con1/include/linux/cdev.h new file mode 100644 index 000000000..92608a6ff --- /dev/null +++ b/ddverify/models/con1/include/linux/cdev.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_CDEV_H +#define _LINUX_CDEV_H + +struct cdev { + struct module *owner; + struct file_operations *ops; + dev_t dev; + unsigned int count; +}; + +void cdev_init(struct cdev *, struct file_operations *); + +struct cdev *cdev_alloc(void); + +void cdev_put(struct cdev *p); + +int cdev_add(struct cdev *, dev_t, unsigned); + +void cdev_del(struct cdev *); + +void cd_forget(struct inode *); + +#endif diff --git a/ddverify/models/con1/include/linux/cdrom.h b/ddverify/models/con1/include/linux/cdrom.h new file mode 100644 index 000000000..b68fdf1f3 --- /dev/null +++ b/ddverify/models/con1/include/linux/cdrom.h @@ -0,0 +1,1192 @@ +/* + * -- + * General header file for linux CD-ROM drivers + * Copyright (C) 1992 David Giller, rafetmad@oxy.edu + * 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de + * 1996 David van Leeuwen, david@tm.tno.nl + * 1997, 1998 Erik Andersen, andersee@debian.org + * 1998-2002 Jens Axboe, axboe@suse.de + */ + +#ifndef _LINUX_CDROM_H +#define _LINUX_CDROM_H + +#include + +/******************************************************* + * As of Linux 2.1.x, all Linux CD-ROM application programs will use this + * (and only this) include file. It is my hope to provide Linux with + * a uniform interface between software accessing CD-ROMs and the various + * device drivers that actually talk to the drives. There may still be + * 23 different kinds of strange CD-ROM drives, but at least there will + * now be one, and only one, Linux CD-ROM interface. + * + * Additionally, as of Linux 2.1.x, all Linux application programs + * should use the O_NONBLOCK option when opening a CD-ROM device + * for subsequent ioctl commands. This allows for neat system errors + * like "No medium found" or "Wrong medium type" upon attempting to + * mount or play an empty slot, mount an audio disc, or play a data disc. + * Generally, changing an application program to support O_NONBLOCK + * is as easy as the following: + * - drive = open("/dev/cdrom", O_RDONLY); + * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); + * It is worth the small change. + * + * Patches for many common CD programs (provided by David A. van Leeuwen) + * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/ + * + *******************************************************/ + +/* When a driver supports a certain function, but the cdrom drive we are + * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will + * borrow the "Operation not supported" error from the network folks to + * accomplish this. Maybe someday we will get a more targeted error code, + * but this will do for now... */ +#define EDRIVE_CANT_DO_THIS EOPNOTSUPP + +/******************************************************* + * The CD-ROM IOCTL commands -- these should be supported by + * all the various cdrom drivers. For the CD-ROM ioctls, we + * will commandeer byte 0x53, or 'S'. + *******************************************************/ +#define CDROMPAUSE 0x5301 /* Pause Audio Operation */ +#define CDROMRESUME 0x5302 /* Resume paused Audio Operation */ +#define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ +#define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index + (struct cdrom_ti) */ +#define CDROMREADTOCHDR 0x5305 /* Read TOC header + (struct cdrom_tochdr) */ +#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry + (struct cdrom_tocentry) */ +#define CDROMSTOP 0x5307 /* Stop the cdrom drive */ +#define CDROMSTART 0x5308 /* Start the cdrom drive */ +#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ +#define CDROMVOLCTRL 0x530a /* Control output volume + (struct cdrom_volctrl) */ +#define CDROMSUBCHNL 0x530b /* Read subchannel data + (struct cdrom_subchnl) */ +#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) + (struct cdrom_read) */ +#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) + (struct cdrom_read) */ +#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ +#define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ +#define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session + address of multi session disks + (struct cdrom_multisession) */ +#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" + if available (struct cdrom_mcn) */ +#define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated, + but here anyway for compatibility */ +#define CDROMRESET 0x5312 /* hard-reset the drive */ +#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting + (struct cdrom_volctrl) */ +#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) + (struct cdrom_read) */ +/* + * These ioctls are used only used in aztcd.c and optcd.c + */ +#define CDROMREADCOOKED 0x5315 /* read data in cooked mode */ +#define CDROMSEEK 0x5316 /* seek msf address */ + +/* + * This ioctl is only used by the scsi-cd driver. + It is for playing audio in logical block addressing mode. + */ +#define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ + +/* + * These ioctls are only used in optcd.c + */ +#define CDROMREADALL 0x5318 /* read all 2646 bytes */ + +/* + * These ioctls are (now) only in ide-cd.c for controlling + * drive spindown time. They should be implemented in the + * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, + * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... + * -Erik + */ +#define CDROMGETSPINDOWN 0x531d +#define CDROMSETSPINDOWN 0x531e + +/* + * These ioctls are implemented through the uniform CD-ROM driver + * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM + * drivers are eventually ported to the uniform CD-ROM driver interface. + */ +#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ +#define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */ +#define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */ +#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ +#define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */ +#define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */ +#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ +#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ +#define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */ +#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */ +#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */ +#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ + +/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386. + * Future CDROM ioctls should be kept below 0x537F + */ + +/* This ioctl is only used by sbpcd at the moment */ +#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ + /* conflict with SCSI_IOCTL_GET_IDLUN */ + +/* DVD-ROM Specific ioctls */ +#define DVD_READ_STRUCT 0x5390 /* Read structure */ +#define DVD_WRITE_STRUCT 0x5391 /* Write structure */ +#define DVD_AUTH 0x5392 /* Authentication */ + +#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */ +#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */ +#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */ + +/******************************************************* + * CDROM IOCTL structures + *******************************************************/ + +/* Address in MSF format */ +struct cdrom_msf0 +{ + __u8 minute; + __u8 second; + __u8 frame; +}; + +/* Address in either MSF or logical format */ +union cdrom_addr +{ + struct cdrom_msf0 msf; + int lba; +}; + +/* This struct is used by the CDROMPLAYMSF ioctl */ +struct cdrom_msf +{ + __u8 cdmsf_min0; /* start minute */ + __u8 cdmsf_sec0; /* start second */ + __u8 cdmsf_frame0; /* start frame */ + __u8 cdmsf_min1; /* end minute */ + __u8 cdmsf_sec1; /* end second */ + __u8 cdmsf_frame1; /* end frame */ +}; + +/* This struct is used by the CDROMPLAYTRKIND ioctl */ +struct cdrom_ti +{ + __u8 cdti_trk0; /* start track */ + __u8 cdti_ind0; /* start index */ + __u8 cdti_trk1; /* end track */ + __u8 cdti_ind1; /* end index */ +}; + +/* This struct is used by the CDROMREADTOCHDR ioctl */ +struct cdrom_tochdr +{ + __u8 cdth_trk0; /* start track */ + __u8 cdth_trk1; /* end track */ +}; + +/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */ +struct cdrom_volctrl +{ + __u8 channel0; + __u8 channel1; + __u8 channel2; + __u8 channel3; +}; + +/* This struct is used by the CDROMSUBCHNL ioctl */ +struct cdrom_subchnl +{ + __u8 cdsc_format; + __u8 cdsc_audiostatus; + __u8 cdsc_adr: 4; + __u8 cdsc_ctrl: 4; + __u8 cdsc_trk; + __u8 cdsc_ind; + union cdrom_addr cdsc_absaddr; + union cdrom_addr cdsc_reladdr; +}; + + +/* This struct is used by the CDROMREADTOCENTRY ioctl */ +struct cdrom_tocentry +{ + __u8 cdte_track; + __u8 cdte_adr :4; + __u8 cdte_ctrl :4; + __u8 cdte_format; + union cdrom_addr cdte_addr; + __u8 cdte_datamode; +}; + +/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */ +struct cdrom_read +{ + int cdread_lba; + char *cdread_bufaddr; + int cdread_buflen; +}; + +/* This struct is used by the CDROMREADAUDIO ioctl */ +struct cdrom_read_audio +{ + union cdrom_addr addr; /* frame address */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ + int nframes; /* number of 2352-byte-frames to read at once */ + __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */ +}; + +/* This struct is used with the CDROMMULTISESSION ioctl */ +struct cdrom_multisession +{ + union cdrom_addr addr; /* frame address: start-of-last-session + (not the new "frame 16"!). Only valid + if the "xa_flag" is true. */ + __u8 xa_flag; /* 1: "is XA disk" */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ +}; + +/* This struct is used with the CDROM_GET_MCN ioctl. + * Very few audio discs actually have Universal Product Code information, + * which should just be the Medium Catalog Number on the box. Also note + * that the way the codeis written on CD is _not_ uniform across all discs! + */ +struct cdrom_mcn +{ + __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */ +}; + +/* This is used by the CDROMPLAYBLK ioctl */ +struct cdrom_blk +{ + unsigned from; + unsigned short len; +}; + +#define CDROM_PACKET_SIZE 12 + +#define CGC_DATA_UNKNOWN 0 +#define CGC_DATA_WRITE 1 +#define CGC_DATA_READ 2 +#define CGC_DATA_NONE 3 + +/* for CDROM_PACKET_COMMAND ioctl */ +struct cdrom_generic_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char __user *buffer; + unsigned int buflen; + int stat; + struct request_sense __user *sense; + unsigned char data_direction; + int quiet; + int timeout; + void __user *reserved[1]; /* unused, actually */ +}; + +/* + * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, + * 2340, or 2352 bytes long. + +* Sector types of the standard CD-ROM data formats: + * + * format sector type user data size (bytes) + * ----------------------------------------------------------------------------- + * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW) + * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE) + * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0) + * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE) + * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes) + * + * + * The layout of the standard CD-ROM data formats: + * ----------------------------------------------------------------------------- + * - audio (red): | audio_sample_bytes | + * | 2352 | + * + * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC | + * | 12 - 4 - 2048 - 4 - 8 - 276 | + * + * - data (yellow, mode2): | sync - head - data | + * | 12 - 4 - 2336 | + * + * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC | + * | 12 - 4 - 8 - 2048 - 4 - 276 | + * + * - XA data (green, mode2 form2): | sync - head - sub - data - Spare | + * | 12 - 4 - 8 - 2324 - 4 | + * + */ + +/* Some generally useful CD-ROM information -- mostly based on the above */ +#define CD_MINS 74 /* max. minutes per CD, not really a limit */ +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ +#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ +#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ +#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ +#define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */ +#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ +#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */ +#define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */ +#define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */ +#define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */ +#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ +#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ +/* most drives don't deliver everything: */ +#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ +#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ + +#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */ +#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */ +#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */ + +/* CD-ROM address types (cdrom_tocentry.cdte_format) */ +#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ +#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ + +/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ +#define CDROM_DATA_TRACK 0x04 + +/* The leadout track is always 0xAA, regardless of # of tracks on disc */ +#define CDROM_LEADOUT 0xAA + +/* audio states (from SCSI-2, but seen with other drives, too) */ +#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ +#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ +#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ +#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ +#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ +#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ + +/* capability flags used with the uniform CD-ROM driver */ +#define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */ +#define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */ +#define CDC_LOCK 0x4 /* disable manual eject */ +#define CDC_SELECT_SPEED 0x8 /* programmable speed */ +#define CDC_SELECT_DISC 0x10 /* select disc from juke-box */ +#define CDC_MULTI_SESSION 0x20 /* read sessions>1 */ +#define CDC_MCN 0x40 /* Medium Catalog Number */ +#define CDC_MEDIA_CHANGED 0x80 /* media changed */ +#define CDC_PLAY_AUDIO 0x100 /* audio functions */ +#define CDC_RESET 0x200 /* hard reset device */ +#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */ +#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ +#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ +#define CDC_CD_R 0x2000 /* drive is a CD-R */ +#define CDC_CD_RW 0x4000 /* drive is a CD-RW */ +#define CDC_DVD 0x8000 /* drive is a DVD */ +#define CDC_DVD_R 0x10000 /* drive can write DVD-R */ +#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */ +#define CDC_MO_DRIVE 0x40000 /* drive is an MO device */ +#define CDC_MRW 0x80000 /* drive can read MRW */ +#define CDC_MRW_W 0x100000 /* drive can write MRW */ +#define CDC_RAM 0x200000 /* ok to open for WRITE */ + +/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ +#define CDS_NO_INFO 0 /* if not implemented */ +#define CDS_NO_DISC 1 +#define CDS_TRAY_OPEN 2 +#define CDS_DRIVE_NOT_READY 3 +#define CDS_DISC_OK 4 + +/* return values for the CDROM_DISC_STATUS ioctl */ +/* can also return CDS_NO_[INFO|DISC], from above */ +#define CDS_AUDIO 100 +#define CDS_DATA_1 101 +#define CDS_DATA_2 102 +#define CDS_XA_2_1 103 +#define CDS_XA_2_2 104 +#define CDS_MIXED 105 + +/* User-configurable behavior options for the uniform CD-ROM driver */ +#define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */ +#define CDO_AUTO_EJECT 0x2 /* open tray on last release() */ +#define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */ +#define CDO_LOCK 0x8 /* lock tray on open files */ +#define CDO_CHECK_TYPE 0x10 /* check type on open for data */ + +/* Special codes used when specifying changer slots. */ +#define CDSL_NONE ((int) (~0U>>1)-1) +#define CDSL_CURRENT ((int) (~0U>>1)) + +/* For partition based multisession access. IDE can handle 64 partitions + * per drive - SCSI CD-ROM's use minors to differentiate between the + * various drives, so we can't do multisessions the same way there. + * Use the -o session=x option to mount on them. + */ +#define CD_PART_MAX 64 +#define CD_PART_MASK (CD_PART_MAX - 1) + +/********************************************************************* + * Generic Packet commands, MMC commands, and such + *********************************************************************/ + + /* The generic packet command opcodes for CD/DVD Logical Units, + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +#define GPCMD_BLANK 0xa1 +#define GPCMD_CLOSE_TRACK 0x5b +#define GPCMD_FLUSH_CACHE 0x35 +#define GPCMD_FORMAT_UNIT 0x04 +#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a +#define GPCMD_GET_PERFORMANCE 0xac +#define GPCMD_INQUIRY 0x12 +#define GPCMD_LOAD_UNLOAD 0xa6 +#define GPCMD_MECHANISM_STATUS 0xbd +#define GPCMD_MODE_SELECT_10 0x55 +#define GPCMD_MODE_SENSE_10 0x5a +#define GPCMD_PAUSE_RESUME 0x4b +#define GPCMD_PLAY_AUDIO_10 0x45 +#define GPCMD_PLAY_AUDIO_MSF 0x47 +#define GPCMD_PLAY_AUDIO_TI 0x48 +#define GPCMD_PLAY_CD 0xbc +#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e +#define GPCMD_READ_10 0x28 +#define GPCMD_READ_12 0xa8 +#define GPCMD_READ_BUFFER_CAPACITY 0x5c +#define GPCMD_READ_CDVD_CAPACITY 0x25 +#define GPCMD_READ_CD 0xbe +#define GPCMD_READ_CD_MSF 0xb9 +#define GPCMD_READ_DISC_INFO 0x51 +#define GPCMD_READ_DVD_STRUCTURE 0xad +#define GPCMD_READ_FORMAT_CAPACITIES 0x23 +#define GPCMD_READ_HEADER 0x44 +#define GPCMD_READ_TRACK_RZONE_INFO 0x52 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_REPAIR_RZONE_TRACK 0x58 +#define GPCMD_REPORT_KEY 0xa4 +#define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_RESERVE_RZONE_TRACK 0x53 +#define GPCMD_SEND_CUE_SHEET 0x5d +#define GPCMD_SCAN 0xba +#define GPCMD_SEEK 0x2b +#define GPCMD_SEND_DVD_STRUCTURE 0xbf +#define GPCMD_SEND_EVENT 0xa2 +#define GPCMD_SEND_KEY 0xa3 +#define GPCMD_SEND_OPC 0x54 +#define GPCMD_SET_READ_AHEAD 0xa7 +#define GPCMD_SET_STREAMING 0xb6 +#define GPCMD_START_STOP_UNIT 0x1b +#define GPCMD_STOP_PLAY_SCAN 0x4e +#define GPCMD_TEST_UNIT_READY 0x00 +#define GPCMD_VERIFY_10 0x2f +#define GPCMD_WRITE_10 0x2a +#define GPCMD_WRITE_AND_VERIFY_10 0x2e +/* This is listed as optional in ATAPI 2.6, but is (curiously) + * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji + * Table 377 as an MMC command for SCSi devices though... Most ATAPI + * drives support it. */ +#define GPCMD_SET_SPEED 0xbb +/* This seems to be a SCSI specific CD-ROM opcode + * to play data at track/index */ +#define GPCMD_PLAYAUDIO_TI 0x48 +/* + * From MS Media Status Notification Support Specification. For + * older drives only. + */ +#define GPCMD_GET_MEDIA_STATUS 0xda + +/* Mode page codes for mode sense/set */ +#define GPMODE_VENDOR_PAGE 0x00 +#define GPMODE_R_W_ERROR_PAGE 0x01 +#define GPMODE_WRITE_PARMS_PAGE 0x05 +#define GPMODE_WCACHING_PAGE 0x08 +#define GPMODE_AUDIO_CTL_PAGE 0x0e +#define GPMODE_POWER_PAGE 0x1a +#define GPMODE_FAULT_FAIL_PAGE 0x1c +#define GPMODE_TO_PROTECT_PAGE 0x1d +#define GPMODE_CAPABILITIES_PAGE 0x2a +#define GPMODE_ALL_PAGES 0x3f +/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor + * of MODE_SENSE_POWER_PAGE */ +#define GPMODE_CDROM_PAGE 0x0d + + + +/* DVD struct types */ +#define DVD_STRUCT_PHYSICAL 0x00 +#define DVD_STRUCT_COPYRIGHT 0x01 +#define DVD_STRUCT_DISCKEY 0x02 +#define DVD_STRUCT_BCA 0x03 +#define DVD_STRUCT_MANUFACT 0x04 + +struct dvd_layer { + __u8 book_version : 4; + __u8 book_type : 4; + __u8 min_rate : 4; + __u8 disc_size : 4; + __u8 layer_type : 4; + __u8 track_path : 1; + __u8 nlayers : 2; + __u8 track_density : 4; + __u8 linear_density : 4; + __u8 bca : 1; + __u32 start_sector; + __u32 end_sector; + __u32 end_sector_l0; +}; + +#define DVD_LAYERS 4 + +struct dvd_physical { + __u8 type; + __u8 layer_num; + struct dvd_layer layer[DVD_LAYERS]; +}; + +struct dvd_copyright { + __u8 type; + + __u8 layer_num; + __u8 cpst; + __u8 rmi; +}; + +struct dvd_disckey { + __u8 type; + + unsigned agid : 2; + __u8 value[2048]; +}; + +struct dvd_bca { + __u8 type; + + int len; + __u8 value[188]; +}; + +struct dvd_manufact { + __u8 type; + + __u8 layer_num; + int len; + __u8 value[2048]; +}; + +typedef union { + __u8 type; + + struct dvd_physical physical; + struct dvd_copyright copyright; + struct dvd_disckey disckey; + struct dvd_bca bca; + struct dvd_manufact manufact; +} dvd_struct; + +/* + * DVD authentication ioctl + */ + +/* Authentication states */ +#define DVD_LU_SEND_AGID 0 +#define DVD_HOST_SEND_CHALLENGE 1 +#define DVD_LU_SEND_KEY1 2 +#define DVD_LU_SEND_CHALLENGE 3 +#define DVD_HOST_SEND_KEY2 4 + +/* Termination states */ +#define DVD_AUTH_ESTABLISHED 5 +#define DVD_AUTH_FAILURE 6 + +/* Other functions */ +#define DVD_LU_SEND_TITLE_KEY 7 +#define DVD_LU_SEND_ASF 8 +#define DVD_INVALIDATE_AGID 9 +#define DVD_LU_SEND_RPC_STATE 10 +#define DVD_HOST_SEND_RPC_STATE 11 + +/* State data */ +typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ +typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ + +struct dvd_lu_send_agid { + __u8 type; + unsigned agid : 2; +}; + +struct dvd_host_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +struct dvd_send_key { + __u8 type; + unsigned agid : 2; + + dvd_key key; +}; + +struct dvd_lu_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +#define DVD_CPM_NO_COPYRIGHT 0 +#define DVD_CPM_COPYRIGHTED 1 + +#define DVD_CP_SEC_NONE 0 +#define DVD_CP_SEC_EXIST 1 + +#define DVD_CGMS_UNRESTRICTED 0 +#define DVD_CGMS_SINGLE 2 +#define DVD_CGMS_RESTRICTED 3 + +struct dvd_lu_send_title_key { + __u8 type; + unsigned agid : 2; + + dvd_key title_key; + int lba; + unsigned cpm : 1; + unsigned cp_sec : 1; + unsigned cgms : 2; +}; + +struct dvd_lu_send_asf { + __u8 type; + unsigned agid : 2; + + unsigned asf : 1; +}; + +struct dvd_host_send_rpcstate { + __u8 type; + __u8 pdrc; +}; + +struct dvd_lu_send_rpcstate { + __u8 type : 2; + __u8 vra : 3; + __u8 ucca : 3; + __u8 region_mask; + __u8 rpc_scheme; +}; + +typedef union { + __u8 type; + + struct dvd_lu_send_agid lsa; + struct dvd_host_send_challenge hsc; + struct dvd_send_key lsk; + struct dvd_lu_send_challenge lsc; + struct dvd_send_key hsk; + struct dvd_lu_send_title_key lstk; + struct dvd_lu_send_asf lsasf; + struct dvd_host_send_rpcstate hrpcs; + struct dvd_lu_send_rpcstate lrpcs; +} dvd_authinfo; + +struct request_sense { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 valid : 1; + __u8 error_code : 7; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 error_code : 7; + __u8 valid : 1; +#endif + __u8 segment_number; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 ili : 1; + __u8 reserved2 : 1; + __u8 sense_key : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 sense_key : 4; + __u8 reserved2 : 1; + __u8 ili : 1; + __u8 reserved1 : 2; +#endif + __u8 information[4]; + __u8 add_sense_len; + __u8 command_info[4]; + __u8 asc; + __u8 ascq; + __u8 fruc; + __u8 sks[3]; + __u8 asb[46]; +}; + +/* + * feature profile + */ +#define CDF_RWRT 0x0020 /* "Random Writable" */ +#define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ +#define CDF_MRW 0x0028 + +/* + * media status bits + */ +#define CDM_MRW_NOTMRW 0 +#define CDM_MRW_BGFORMAT_INACTIVE 1 +#define CDM_MRW_BGFORMAT_ACTIVE 2 +#define CDM_MRW_BGFORMAT_COMPLETE 3 + +/* + * mrw address spaces + */ +#define MRW_LBA_DMA 0 +#define MRW_LBA_GAA 1 + +/* + * mrw mode pages (first is deprecated) -- probed at init time and + * cdi->mrw_mode_page is set + */ +#define MRW_MODE_PC_PRE1 0x2c +#define MRW_MODE_PC 0x03 + +struct mrw_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 write : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 write : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; + __u8 reserved4; + __u8 reserved5; +}; + +/* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */ +struct rwrt_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; + __u32 last_lba; + __u32 block_size; + __u16 blocking; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 page_present : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_present : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; +}; + +typedef struct { + __u16 disc_information_length; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 3; + __u8 erasable : 1; + __u8 border_status : 2; + __u8 disc_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 disc_status : 2; + __u8 border_status : 2; + __u8 erasable : 1; + __u8 reserved1 : 3; +#else +#error "Please fix " +#endif + __u8 n_first_track; + __u8 n_sessions_lsb; + __u8 first_track_lsb; + __u8 last_track_lsb; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 did_v : 1; + __u8 dbc_v : 1; + __u8 uru : 1; + __u8 reserved2 : 2; + __u8 dbit : 1; + __u8 mrw_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 mrw_status : 2; + __u8 dbit : 1; + __u8 reserved2 : 2; + __u8 uru : 1; + __u8 dbc_v : 1; + __u8 did_v : 1; +#endif + __u8 disc_type; + __u8 n_sessions_msb; + __u8 first_track_msb; + __u8 last_track_msb; + __u32 disc_id; + __u32 lead_in; + __u32 lead_out; + __u8 disc_bar_code[8]; + __u8 reserved3; + __u8 n_opc; +} disc_information; + +typedef struct { + __u16 track_information_length; + __u8 track_lsb; + __u8 session_lsb; + __u8 reserved1; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 2; + __u8 damage : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 rt : 1; + __u8 blank : 1; + __u8 packet : 1; + __u8 fp : 1; + __u8 data_mode : 4; + __u8 reserved3 : 6; + __u8 lra_v : 1; + __u8 nwa_v : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 track_mode : 4; + __u8 copy : 1; + __u8 damage : 1; + __u8 reserved2 : 2; + __u8 data_mode : 4; + __u8 fp : 1; + __u8 packet : 1; + __u8 blank : 1; + __u8 rt : 1; + __u8 nwa_v : 1; + __u8 lra_v : 1; + __u8 reserved3 : 6; +#endif + __u32 track_start; + __u32 next_writable; + __u32 free_blocks; + __u32 fixed_packet_size; + __u32 track_size; + __u32 last_rec_address; +} track_information; + +struct feature_header { + __u32 data_len; + __u8 reserved1; + __u8 reserved2; + __u16 curr_profile; +}; + +struct mode_page_header { + __u16 mode_data_length; + __u8 medium_type; + __u8 reserved1; + __u8 reserved2; + __u8 reserved3; + __u16 desc_length; +}; + +#ifdef __KERNEL__ +#include /* not really needed, later.. */ +#include + +struct packet_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char *buffer; + unsigned int buflen; + int stat; + struct request_sense *sense; + unsigned char data_direction; + int quiet; + int timeout; + void *reserved[1]; +}; + +/* + * _OLD will use PIO transfer on atapi devices, _BPC_* will use DMA + */ +#define CDDA_OLD 0 /* old style */ +#define CDDA_BPC_SINGLE 1 /* single frame block pc */ +#define CDDA_BPC_FULL 2 /* multi frame block pc */ + +/* Uniform cdrom data structures for cdrom.c */ +struct cdrom_device_info { + struct cdrom_device_ops *ops; /* link to device_ops */ + struct cdrom_device_info *next; /* next device_info for this major */ + struct gendisk *disk; /* matching block layer disk */ + void *handle; /* driver-dependent data */ +/* specifications */ + int mask; /* mask of capability: disables them */ + int speed; /* maximum speed for reading data */ + int capacity; /* number of discs in jukebox */ +/* device-related storage */ + int options : 30; /* options flags */ + unsigned mc_flags : 2; /* media change buffer flags */ + int use_count; /* number of times device opened */ + char name[20]; /* name of the device type */ +/* per-device flags */ + __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ + __u8 reserved : 6; /* not used yet */ + int cdda_method; /* see flags */ + __u8 last_sense; + __u8 media_written; /* dirty flag, DVD+RW bookkeeping */ + unsigned short mmc3_profile; /* current MMC3 profile */ + int for_data; + int (*exit)(struct cdrom_device_info *); + int mrw_mode_page; +}; + +struct cdrom_device_ops { +/* routines */ + int (*open) (struct cdrom_device_info *, int); + void (*release) (struct cdrom_device_info *); + int (*drive_status) (struct cdrom_device_info *, int); + int (*media_changed) (struct cdrom_device_info *, int); + int (*tray_move) (struct cdrom_device_info *, int); + int (*lock_door) (struct cdrom_device_info *, int); + int (*select_speed) (struct cdrom_device_info *, int); + int (*select_disc) (struct cdrom_device_info *, int); + int (*get_last_session) (struct cdrom_device_info *, + struct cdrom_multisession *); + int (*get_mcn) (struct cdrom_device_info *, + struct cdrom_mcn *); + /* hard reset device */ + int (*reset) (struct cdrom_device_info *); + /* play stuff */ + int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *); + /* dev-specific */ + int (*dev_ioctl) (struct cdrom_device_info *, + unsigned int, unsigned long); +/* driver specifications */ + const int capability; /* capability flags */ + int n_minors; /* number of active minor devices */ + /* handle uniform packets for scsi type devices (scsi,atapi) */ + int (*generic_packet) (struct cdrom_device_info *, + struct packet_command *); +}; + +/* the general block_device operations structure: */ +extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, + struct file *fp); +extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp); +extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi, + struct inode *ip, unsigned int cmd, unsigned long arg); +extern int cdrom_media_changed(struct cdrom_device_info *); + +extern int register_cdrom(struct cdrom_device_info *cdi); +extern int unregister_cdrom(struct cdrom_device_info *cdi); + +typedef struct { + int data; + int audio; + int cdi; + int xa; + long error; +} tracktype; + +extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written); +extern int cdrom_number_of_slots(struct cdrom_device_info *cdi); +extern int cdrom_mode_select(struct cdrom_device_info *cdi, + struct packet_command *cgc); +extern int cdrom_mode_sense(struct cdrom_device_info *cdi, + struct packet_command *cgc, + int page_code, int page_control); +extern void init_cdrom_command(struct packet_command *cgc, + void *buffer, int len, int type); + +/* The SCSI spec says there could be 256 slots. */ +#define CDROM_MAX_SLOTS 256 + +struct cdrom_mechstat_header { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 fault : 1; + __u8 changer_state : 2; + __u8 curslot : 5; + __u8 mech_state : 3; + __u8 door_open : 1; + __u8 reserved1 : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curslot : 5; + __u8 changer_state : 2; + __u8 fault : 1; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 mech_state : 3; +#endif + __u8 curlba[3]; + __u8 nslots; + __u16 slot_tablelen; +}; + +struct cdrom_slot { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 disc_present : 1; + __u8 reserved1 : 6; + __u8 change : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 change : 1; + __u8 reserved1 : 6; + __u8 disc_present : 1; +#endif + __u8 reserved2[3]; +}; + +struct cdrom_changer_info { + struct cdrom_mechstat_header hdr; + struct cdrom_slot slots[CDROM_MAX_SLOTS]; +}; + +typedef enum { + mechtype_caddy = 0, + mechtype_tray = 1, + mechtype_popup = 2, + mechtype_individual_changer = 4, + mechtype_cartridge_changer = 5 +} mechtype_t; + +typedef struct { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 ps : 1; + __u8 reserved1 : 1; + __u8 page_code : 6; + __u8 page_length; + __u8 reserved2 : 1; + __u8 bufe : 1; + __u8 ls_v : 1; + __u8 test_write : 1; + __u8 write_type : 4; + __u8 multi_session : 2; /* or border, DVD */ + __u8 fp : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 reserved3 : 4; + __u8 data_block_type : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_code : 6; + __u8 reserved1 : 1; + __u8 ps : 1; + __u8 page_length; + __u8 write_type : 4; + __u8 test_write : 1; + __u8 ls_v : 1; + __u8 bufe : 1; + __u8 reserved2 : 1; + __u8 track_mode : 4; + __u8 copy : 1; + __u8 fp : 1; + __u8 multi_session : 2; /* or border, DVD */ + __u8 data_block_type : 4; + __u8 reserved3 : 4; +#endif + __u8 link_size; + __u8 reserved4; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved5 : 2; + __u8 app_code : 6; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 app_code : 6; + __u8 reserved5 : 2; +#endif + __u8 session_format; + __u8 reserved6; + __u32 packet_size; + __u16 audio_pause; + __u8 mcn[16]; + __u8 isrc[16]; + __u8 subhdr0; + __u8 subhdr1; + __u8 subhdr2; + __u8 subhdr3; +} __attribute__((packed)) write_param_page; + +struct modesel_head +{ + __u8 reserved1; + __u8 medium; + __u8 reserved2; + __u8 block_desc_length; + __u8 density; + __u8 number_of_blocks_hi; + __u8 number_of_blocks_med; + __u8 number_of_blocks_lo; + __u8 reserved3; + __u8 block_length_hi; + __u8 block_length_med; + __u8 block_length_lo; +}; + +typedef struct { + __u16 report_key_length; + __u8 reserved1; + __u8 reserved2; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 type_code : 2; + __u8 vra : 3; + __u8 ucca : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ucca : 3; + __u8 vra : 3; + __u8 type_code : 2; +#endif + __u8 region_mask; + __u8 rpc_scheme; + __u8 reserved3; +} rpc_state_t; + +struct event_header { + __u16 data_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 nea : 1; + __u8 reserved1 : 4; + __u8 notification_class : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 notification_class : 3; + __u8 reserved1 : 4; + __u8 nea : 1; +#endif + __u8 supp_event_class; +}; + +struct media_event_desc { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 4; + __u8 media_event_code : 4; + __u8 reserved2 : 6; + __u8 media_present : 1; + __u8 door_open : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 media_event_code : 4; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 media_present : 1; + __u8 reserved2 : 6; +#endif + __u8 start_slot; + __u8 end_slot; +}; + +extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); + +#endif /* End of kernel only stuff */ + +#endif /* _LINUX_CDROM_H */ diff --git a/ddverify/models/con1/include/linux/compat.h b/ddverify/models/con1/include/linux/compat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/compiler.h b/ddverify/models/con1/include/linux/compiler.h new file mode 100644 index 000000000..3b8f75ea3 --- /dev/null +++ b/ddverify/models/con1/include/linux/compiler.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_COMPILER_H +#define __LINUX_COMPILER_H + +# define __user +# define __kernel +# define __safe +# define __force +# define __nocast +# define __iomem + +#ifndef __must_check +#define __must_check +#endif + +#define likely(x) x +#define unlikely(x) x + +void barrier(void); + +#endif diff --git a/ddverify/models/con1/include/linux/completion.h b/ddverify/models/con1/include/linux/completion.h new file mode 100644 index 000000000..011ec59af --- /dev/null +++ b/ddverify/models/con1/include/linux/completion.h @@ -0,0 +1,18 @@ +#ifndef __LINUX_COMPLETION_H +#define __LINUX_COMPLETION_H + +/* + * (C) Copyright 2001 Linus Torvalds + * + * Atomic wait-for-completion handler data structures. + * See kernel/sched.c for details. + */ + +#include + +struct completion { + unsigned int done; + wait_queue_head_t wait; +}; + +#endif diff --git a/ddverify/models/con1/include/linux/config.h b/ddverify/models/con1/include/linux/config.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/console.h b/ddverify/models/con1/include/linux/console.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/cpumask.h b/ddverify/models/con1/include/linux/cpumask.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/ctype.h b/ddverify/models/con1/include/linux/ctype.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/dcache.h b/ddverify/models/con1/include/linux/dcache.h new file mode 100644 index 000000000..2813f54c1 --- /dev/null +++ b/ddverify/models/con1/include/linux/dcache.h @@ -0,0 +1,9 @@ +#ifndef __LINUX_DCACHE_H +#define __LINUX_DCACHE_H + +struct dentry { + struct inode *d_inode; /* Where the name belongs to - NULL is + * negative */ +}; + +#endif /* __LINUX_DCACHE_H */ diff --git a/ddverify/models/con1/include/linux/delay.h b/ddverify/models/con1/include/linux/delay.h new file mode 100644 index 000000000..c3bb525bb --- /dev/null +++ b/ddverify/models/con1/include/linux/delay.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_DELAY_H +#define _LINUX_DELAY_H + +extern unsigned long loops_per_jiffy; + +#include + + +#ifndef mdelay +#define mdelay(n) do {} while(0) +#endif + +#ifndef ndelay +#define ndelay(x) do {} while(0) +#endif + +// DDV: This function does not need a body! +void msleep(unsigned int msecs); +// DDV: This function does not need a body! +unsigned long msleep_interruptible(unsigned int msecs); + +#endif /* defined(_LINUX_DELAY_H) */ diff --git a/ddverify/models/con1/include/linux/devfs_fs_kernel.h b/ddverify/models/con1/include/linux/devfs_fs_kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/device.h b/ddverify/models/con1/include/linux/device.h new file mode 100644 index 000000000..920ff5519 --- /dev/null +++ b/ddverify/models/con1/include/linux/device.h @@ -0,0 +1,112 @@ +/* + * device.h - generic, centralized driver model + * + * Copyright (c) 2001-2003 Patrick Mochel + * + * This file is released under the GPLv2 + * + * See Documentation/driver-model/ for more information. + */ + +#ifndef _DEVICE_H_ +#define _DEVICE_H_ + +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include + +struct device { + void *driver_data; /* data private to the driver */ + void (*release)(struct device * dev); +}; + +struct device_driver { + const char * name; +}; + + +struct class { + int someting; +}; + +struct class_device { + int something; +}; + +struct class_interface { + int something; +}; + +struct class_device_attribute { + struct attribute attr; + ssize_t (*show)(struct class_device *, char * buf); + ssize_t (*store)(struct class_device *, const char * buf, size_t count); +}; + +#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \ +struct class_device_attribute class_device_attr_##_name = \ + __ATTR(_name,_mode,_show,_store) + +extern struct class *class_create(struct module *owner, const char *name); +extern void class_destroy(struct class *cls); + +extern struct class_device *class_device_create(struct class *cls, + struct class_device *parent, + dev_t devt, + struct device *device, + const char *fmt, ...); +extern void class_device_destroy(struct class *cls, dev_t devt); + + +struct device_attribute { + struct attribute attr; + ssize_t (*show)(struct device *dev, struct device_attribute *attr, + char *buf); + ssize_t (*store)(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +}; + +#define DEVICE_ATTR(_name,_mode,_show,_store) \ +struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) + + +static inline void * dev_get_drvdata (struct device *dev) +{ + return dev->driver_data; +} + +static inline void dev_set_drvdata (struct device *dev, void *data) +{ + dev->driver_data = data; +} + +extern const char *dev_driver_string(struct device *dev); + + +#define dev_printk(level, dev, format, arg...) \ + printk("dev_printk") + +#ifdef DEBUG +#define dev_dbg(dev, format, arg...) \ + dev_printk(KERN_DEBUG , dev , format , ## arg) +#else +#define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) +#endif + +#define dev_err(dev, format, arg...) \ + dev_printk(KERN_ERR , dev , format , ## arg) +#define dev_info(dev, format, arg...) \ + dev_printk(KERN_INFO , dev , format , ## arg) +#define dev_warn(dev, format, arg...) \ + dev_printk(KERN_WARNING , dev , format , ## arg) +#define dev_notice(dev, format, arg...) \ + dev_printk(KERN_NOTICE , dev , format , ## arg) + +#endif /* _DEVICE_H_ */ diff --git a/ddverify/models/con1/include/linux/dma-mapping.h b/ddverify/models/con1/include/linux/dma-mapping.h new file mode 100644 index 000000000..9ea999ba9 --- /dev/null +++ b/ddverify/models/con1/include/linux/dma-mapping.h @@ -0,0 +1,19 @@ +#ifndef _ASM_LINUX_DMA_MAPPING_H +#define _ASM_LINUX_DMA_MAPPING_H + +#include +#include + + +#define DMA_64BIT_MASK (unsigned long long int)0xffffffffffffffff +#define DMA_48BIT_MASK (unsigned long long int)0x0000ffffffffffff +#define DMA_40BIT_MASK (unsigned long long int)0x000000ffffffffff +#define DMA_39BIT_MASK (unsigned long long int)0x0000007fffffffff +#define DMA_32BIT_MASK (unsigned long long int)0x00000000ffffffff +#define DMA_31BIT_MASK (unsigned long long int)0x000000007fffffff +#define DMA_30BIT_MASK (unsigned long long int)0x000000003fffffff +#define DMA_29BIT_MASK (unsigned long long int)0x000000001fffffff +#define DMA_28BIT_MASK (unsigned long long int)0x000000000fffffff +#define DMA_24BIT_MASK (unsigned long long int)0x0000000000ffffff + +#endif diff --git a/ddverify/models/con1/include/linux/elevator.h b/ddverify/models/con1/include/linux/elevator.h new file mode 100644 index 000000000..f0e7f6f17 --- /dev/null +++ b/ddverify/models/con1/include/linux/elevator.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_ELEVATOR_H +#define _LINUX_ELEVATOR_H + +struct request *elv_next_request(struct request_queue *q); + +#endif diff --git a/ddverify/models/con1/include/linux/err.h b/ddverify/models/con1/include/linux/err.h new file mode 100644 index 000000000..18c9cf814 --- /dev/null +++ b/ddverify/models/con1/include/linux/err.h @@ -0,0 +1,27 @@ +#ifndef _LINUX_ERR_H +#define _LINUX_ERR_H + +#include + +#include + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) (x) >= (unsigned long)-MAX_ERRNO + +static inline void *ERR_PTR(long error) +{ + return (void *) error; +} + +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline long IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + +#endif /* _LINUX_ERR_H */ diff --git a/ddverify/models/con1/include/linux/errno.h b/ddverify/models/con1/include/linux/errno.h new file mode 100644 index 000000000..91762481a --- /dev/null +++ b/ddverify/models/con1/include/linux/errno.h @@ -0,0 +1,25 @@ +#ifndef _LINUX_ERRNO_H +#define _LINUX_ERRNO_H + +#include + +/* Should never be seen by user programs */ +#define ERESTARTSYS 512 +#define ERESTARTNOINTR 513 +#define ERESTARTNOHAND 514 /* restart if no handler.. */ +#define ENOIOCTLCMD 515 /* No ioctl command */ +#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ + +/* Defined for the NFSv3 protocol */ +#define EBADHANDLE 521 /* Illegal NFS file handle */ +#define ENOTSYNC 522 /* Update synchronization mismatch */ +#define EBADCOOKIE 523 /* Cookie is stale */ +#define ENOTSUPP 524 /* Operation is not supported */ +#define ETOOSMALL 525 /* Buffer or request is too small */ +#define ESERVERFAULT 526 /* An untranslatable error occurred */ +#define EBADTYPE 527 /* Type not supported by server */ +#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ +#define EIOCBQUEUED 529 /* iocb queued, will get completion event */ +#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */ + +#endif diff --git a/ddverify/models/con1/include/linux/fcntl.h b/ddverify/models/con1/include/linux/fcntl.h new file mode 100644 index 000000000..9de3512e8 --- /dev/null +++ b/ddverify/models/con1/include/linux/fcntl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_FCNTL_H +#define _LINUX_FCNTL_H + +#include + +#endif diff --git a/ddverify/models/con1/include/linux/fd.h b/ddverify/models/con1/include/linux/fd.h new file mode 100644 index 000000000..5b5a51a4e --- /dev/null +++ b/ddverify/models/con1/include/linux/fd.h @@ -0,0 +1,373 @@ +#ifndef _LINUX_FD_H +#define _LINUX_FD_H + +#include +#include +/* New file layout: Now the ioctl definitions immediately follow the + * definitions of the structures that they use */ + +/* + * Geometry + */ +struct floppy_struct { + unsigned int size, /* nr of sectors total */ + sect, /* sectors per track */ + head, /* nr of heads */ + track, /* nr of tracks */ + stretch; /* !=0 means double track steps */ +#define FD_STRETCH 1 +#define FD_SWAPSIDES 2 +#define FD_ZEROBASED 4 + + unsigned char gap, /* gap1 size */ + + rate, /* data rate. |= 0x40 for perpendicular */ +#define FD_2M 0x4 +#define FD_SIZECODEMASK 0x38 +#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) +#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ + 512 : 128 << FD_SIZECODE(floppy) ) +#define FD_PERP 0x40 + + spec1, /* stepping rate, head unload time */ + fmt_gap; /* gap2 size */ + const char * name; /* used only for predefined formats */ +}; + + +/* commands needing write access have 0x40 set */ +/* commands needing super user access have 0x80 set */ + +#define FDCLRPRM _IO(2, 0x41) +/* clear user-defined parameters */ + +#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) +#define FDSETMEDIAPRM FDSETPRM +/* set user-defined parameters for current media */ + +#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) +#define FDGETPRM _IOR(2, 0x04, struct floppy_struct) +#define FDDEFMEDIAPRM FDDEFPRM +#define FDGETMEDIAPRM FDGETPRM +/* set/get disk parameters */ + + +#define FDMSGON _IO(2,0x45) +#define FDMSGOFF _IO(2,0x46) +/* issue/don't issue kernel messages on media type change */ + + +/* + * Formatting (obsolete) + */ +#define FD_FILL_BYTE 0xF6 /* format fill byte. */ + +struct format_descr { + unsigned int device,head,track; +}; + +#define FDFMTBEG _IO(2,0x47) +/* begin formatting a disk */ +#define FDFMTTRK _IOW(2,0x48, struct format_descr) +/* format the specified track */ +#define FDFMTEND _IO(2,0x49) +/* end formatting a disk */ + + +/* + * Error thresholds + */ +struct floppy_max_errors { + unsigned int + abort, /* number of errors to be reached before aborting */ + read_track, /* maximal number of errors permitted to read an + * entire track at once */ + reset, /* maximal number of errors before a reset is tried */ + recal, /* maximal number of errors before a recalibrate is + * tried */ + + /* + * Threshold for reporting FDC errors to the console. + * Setting this to zero may flood your screen when using + * ultra cheap floppies ;-) + */ + reporting; + +}; + +#define FDSETEMSGTRESH _IO(2,0x4a) +/* set fdc error reporting threshold */ + +#define FDFLUSH _IO(2,0x4b) +/* flush buffers for media; either for verifying media, or for + * handling a media change without closing the file descriptor */ + +#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors) +#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors) +/* set/get abortion and read_track threshold. See also floppy_drive_params + * structure */ + + +typedef char floppy_drive_name[16]; +#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name) +/* get drive type: 5 1/4 or 3 1/2 */ + + +/* + * Drive parameters (user modifiable) + */ +struct floppy_drive_params { + signed char cmos; /* CMOS type */ + + /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms + * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). + */ + unsigned long max_dtr; /* Step rate, usec */ + unsigned long hlt; /* Head load/settle time, msec */ + unsigned long hut; /* Head unload time (remnant of + * 8" drives) */ + unsigned long srt; /* Step rate, usec */ + + unsigned long spinup; /* time needed for spinup (expressed + * in jiffies) */ + unsigned long spindown; /* timeout needed for spindown */ + unsigned char spindown_offset; /* decides in which position the disk + * will stop */ + unsigned char select_delay; /* delay to wait after select */ + unsigned char rps; /* rotations per second */ + unsigned char tracks; /* maximum number of tracks */ + unsigned long timeout; /* timeout for interrupt requests */ + + unsigned char interleave_sect; /* if there are more sectors, use + * interleave */ + + struct floppy_max_errors max_errors; + + char flags; /* various flags, including ftd_msg */ +/* + * Announce successful media type detection and media information loss after + * disk changes. + * Also used to enable/disable printing of overrun warnings. + */ + +#define FTD_MSG 0x10 +#define FD_BROKEN_DCL 0x20 +#define FD_DEBUG 0x02 +#define FD_SILENT_DCL_CLEAR 0x4 +#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware + considerations */ + + char read_track; /* use readtrack during probing? */ + +/* + * Auto-detection. Each drive type has eight formats which are + * used in succession to try to read the disk. If the FDC cannot lock onto + * the disk, the next format is tried. This uses the variable 'probing'. + */ + short autodetect[8]; /* autodetected formats */ + + int checkfreq; /* how often should the drive be checked for disk + * changes */ + int native_format; /* native format of this drive */ +}; + +enum { + FD_NEED_TWADDLE_BIT, /* more magic */ + FD_VERIFY_BIT, /* inquire for write protection */ + FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet + * to clear media change status */ + FD_UNUSED_BIT, + FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ + FD_DISK_WRITABLE_BIT /* disk is writable */ +}; + +#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params) +#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params) +/* set/get drive parameters */ + + +/* + * Current drive state (not directly modifiable by user, readonly) + */ +struct floppy_drive_struct { + unsigned long flags; +/* values for these flags */ +#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT) +#define FD_VERIFY (1 << FD_VERIFY_BIT) +#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT) +#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT) +#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT) + + unsigned long spinup_date; + unsigned long select_date; + unsigned long first_read_date; + short probed_format; + short track; /* current track */ + short maxblock; /* id of highest block read */ + short maxtrack; /* id of highest half track read */ + int generation; /* how many diskchanges? */ + +/* + * (User-provided) media information is _not_ discarded after a media change + * if the corresponding keep_data flag is non-zero. Positive values are + * decremented after each probe. + */ + int keep_data; + + /* Prevent "aliased" accesses. */ + int fd_ref; + int fd_device; + unsigned long last_checked; /* when was the drive last checked for a disk + * change? */ + + char *dmabuf; + int bufblocks; +}; + +#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct) +#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct) +/* get drive state: GET returns the cached state, POLL polls for new state */ + + +/* + * reset FDC + */ +enum reset_mode { + FD_RESET_IF_NEEDED, /* reset only if the reset flags is set */ + FD_RESET_IF_RAWCMD, /* obsolete */ + FD_RESET_ALWAYS /* reset always */ +}; +#define FDRESET _IO(2, 0x54) + + +/* + * FDC state + */ +struct floppy_fdc_state { + int spec1; /* spec1 value last used */ + int spec2; /* spec2 value last used */ + int dtr; + unsigned char version; /* FDC version code */ + unsigned char dor; + unsigned long address; /* io address */ + unsigned int rawcmd:2; + unsigned int reset:1; + unsigned int need_configure:1; + unsigned int perp_mode:2; + unsigned int has_fifo:1; + unsigned int driver_version; /* version code for floppy driver */ +#define FD_DRIVER_VERSION 0x100 +/* user programs using the floppy API should use floppy_fdc_state to + * get the version number of the floppy driver that they are running + * on. If this version number is bigger than the one compiled into the + * user program (the FD_DRIVER_VERSION define), it should be prepared + * to bigger structures + */ + + unsigned char track[4]; + /* Position of the heads of the 4 units attached to this FDC, + * as stored on the FDC. In the future, the position as stored + * on the FDC might not agree with the actual physical + * position of these drive heads. By allowing such + * disagreement, it will be possible to reset the FDC without + * incurring the expensive cost of repositioning all heads. + * Right now, these positions are hard wired to 0. */ + +}; + +#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state) + + +/* + * Asynchronous Write error tracking + */ +struct floppy_write_errors { + /* Write error logging. + * + * These fields can be cleared with the FDWERRORCLR ioctl. + * Only writes that were attempted but failed due to a physical media + * error are logged. write(2) calls that fail and return an error code + * to the user process are not counted. + */ + + unsigned int write_errors; /* number of physical write errors + * encountered */ + + /* position of first and last write errors */ + unsigned long first_error_sector; + int first_error_generation; + unsigned long last_error_sector; + int last_error_generation; + + unsigned int badness; /* highest retry count for a read or write + * operation */ +}; + +#define FDWERRORCLR _IO(2, 0x56) +/* clear write error and badness information */ +#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors) +/* get write error and badness information */ + + +/* + * Raw commands + */ +/* new interface flag: now we can do them in batches */ +#define FDHAVEBATCHEDRAWCMD + +struct floppy_raw_cmd { + unsigned int flags; +#define FD_RAW_READ 1 +#define FD_RAW_WRITE 2 +#define FD_RAW_NO_MOTOR 4 +#define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */ +#define FD_RAW_INTR 8 /* wait for an interrupt */ +#define FD_RAW_SPIN 0x10 /* spin up the disk for this command */ +#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command + * completion */ +#define FD_RAW_NEED_DISK 0x40 /* this command needs a disk to be present */ +#define FD_RAW_NEED_SEEK 0x80 /* this command uses an implied seek (soft) */ + +/* more "in" flags */ +#define FD_RAW_MORE 0x100 /* more records follow */ +#define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */ +#define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */ +#define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure + * detection too */ + +/* more "out" flags */ +#define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */ +#define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */ + + void __user *data; + char *kernel_data; /* location of data buffer in the kernel */ + struct floppy_raw_cmd *next; /* used for chaining of raw cmd's + * within the kernel */ + long length; /* in: length of dma transfer. out: remaining bytes */ + long phys_length; /* physical length, if different from dma length */ + int buffer_length; /* length of allocated buffer */ + + unsigned char rate; + unsigned char cmd_count; + unsigned char cmd[16]; + unsigned char reply_count; + unsigned char reply[16]; + int track; + int resultcode; + + int reserved1; + int reserved2; +}; + +#define FDRAWCMD _IO(2, 0x58) +/* send a raw command to the fdc. Structure size not included, because of + * batches */ + +#define FDTWADDLE _IO(2, 0x59) +/* flicker motor-on bit before reading a sector. Experimental */ + + +#define FDEJECT _IO(2, 0x5a) +/* eject the disk */ + +#endif diff --git a/ddverify/models/con1/include/linux/fdreg.h b/ddverify/models/con1/include/linux/fdreg.h new file mode 100644 index 000000000..c2eeb63b7 --- /dev/null +++ b/ddverify/models/con1/include/linux/fdreg.h @@ -0,0 +1,137 @@ +#ifndef _LINUX_FDREG_H +#define _LINUX_FDREG_H +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ + +#ifdef FDPATCHES +#define FD_IOPORT fdc_state[fdc].address +#else +/* It would be a lot saner just to force fdc_state[fdc].address to always + be set ! FIXME */ +#define FD_IOPORT 0x3f0 +#endif + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS (4 + FD_IOPORT ) +#define FD_DATA (5 + FD_IOPORT ) + +/* Digital Output Register */ +#define FD_DOR (2 + FD_IOPORT ) + +/* Digital Input Register (read) */ +#define FD_DIR (7 + FD_IOPORT ) + +/* Diskette Control Register (write)*/ +#define FD_DCR (7 + FD_IOPORT ) + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment check error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Address Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_DS 0x08 /* drive is double-sided */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_RY 0x20 /* drive is ready */ +#define ST3_WP 0x40 /* Write Protect */ +#define ST3_FT 0x80 /* Drive Fault */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ +#define FD_FORMAT 0x4D /* format one track */ +#define FD_VERSION 0x10 /* get version code */ +#define FD_CONFIGURE 0x13 /* configure FIFO operation */ +#define FD_PERPENDICULAR 0x12 /* perpendicular r/w mode */ +#define FD_GETSTATUS 0x04 /* read ST3 */ +#define FD_DUMPREGS 0x0E /* dump the contents of the fdc regs */ +#define FD_READID 0xEA /* prints the header of a sector */ +#define FD_UNLOCK 0x14 /* Fifo config unlock */ +#define FD_LOCK 0x94 /* Fifo config lock */ +#define FD_RSEEK_OUT 0x8f /* seek out (i.e. to lower tracks) */ +#define FD_RSEEK_IN 0xcf /* seek in (i.e. to higher tracks) */ + +/* the following commands are new in the 82078. They are not used in the + * floppy driver, except the first three. These commands may be useful for apps + * which use the FDRAWCMD interface. For doc, get the 82078 spec sheets at + * http://www-techdoc.intel.com/docs/periph/fd_contr/datasheets/ */ + +#define FD_PARTID 0x18 /* part id ("extended" version cmd) */ +#define FD_SAVE 0x2e /* save fdc regs for later restore */ +#define FD_DRIVESPEC 0x8e /* drive specification: Access to the + * 2 Mbps data transfer rate for tape + * drives */ + +#define FD_RESTORE 0x4e /* later restore */ +#define FD_POWERDOWN 0x27 /* configure FDC's powersave features */ +#define FD_FORMAT_N_WRITE 0xef /* format and write in one go. */ +#define FD_OPTION 0x33 /* ISO format (which is a clean way to + * pack more sectors on a track) */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +/* FDC version return types */ +#define FDC_NONE 0x00 +#define FDC_UNKNOWN 0x10 /* DO NOT USE THIS TYPE EXCEPT IF IDENTIFICATION + FAILS EARLY */ +#define FDC_8272A 0x20 /* Intel 8272a, NEC 765 */ +#define FDC_765ED 0x30 /* Non-Intel 1MB-compatible FDC, can't detect */ +#define FDC_82072 0x40 /* Intel 82072; 8272a + FIFO + DUMPREGS */ +#define FDC_82072A 0x45 /* 82072A (on Sparcs) */ +#define FDC_82077_ORIG 0x51 /* Original version of 82077AA, sans LOCK */ +#define FDC_82077 0x52 /* 82077AA-1 */ +#define FDC_82078_UNKN 0x5f /* Unknown 82078 variant */ +#define FDC_82078 0x60 /* 44pin 82078 or 64pin 82078SL */ +#define FDC_82078_1 0x61 /* 82078-1 (2Mbps fdc) */ +#define FDC_S82078B 0x62 /* S82078B (first seen on Adaptec AVA-2825 VLB + * SCSI/EIDE/Floppy controller) */ +#define FDC_87306 0x63 /* National Semiconductor PC 87306 */ + +/* + * Beware: the fdc type list is roughly sorted by increasing features. + * Presence of features is tested by comparing the FDC version id with the + * "oldest" version that has the needed feature. + * If during FDC detection, an obscure test fails late in the sequence, don't + * assign FDC_UNKNOWN. Else the FDC will be treated as a dumb 8272a, or worse. + * This is especially true if the tests are unneeded. + */ + +#define FD_RESET_DELAY 20 +#endif diff --git a/ddverify/models/con1/include/linux/file.h b/ddverify/models/con1/include/linux/file.h new file mode 100644 index 000000000..df49c59d6 --- /dev/null +++ b/ddverify/models/con1/include/linux/file.h @@ -0,0 +1,14 @@ +#ifndef __LINUX_FILE_H +#define __LINUX_FILE_H + +#include +#include +#include +#include +//#include +#include + +extern void fput(struct file *); +extern struct file * fget(unsigned int fd); + +#endif /* __LINUX_FILE_H */ diff --git a/ddverify/models/con1/include/linux/firmware.h b/ddverify/models/con1/include/linux/firmware.h new file mode 100644 index 000000000..33d8f2087 --- /dev/null +++ b/ddverify/models/con1/include/linux/firmware.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_FIRMWARE_H +#define _LINUX_FIRMWARE_H +#include +#include +#define FIRMWARE_NAME_MAX 30 +#define FW_ACTION_NOHOTPLUG 0 +#define FW_ACTION_HOTPLUG 1 + +struct firmware { + size_t size; + u8 *data; +}; +struct device; +int request_firmware(const struct firmware **fw, const char *name, + struct device *device); +int request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, void *context, + void (*cont)(const struct firmware *fw, void *context)); + +void release_firmware(const struct firmware *fw); +#endif diff --git a/ddverify/models/con1/include/linux/fs.h b/ddverify/models/con1/include/linux/fs.h new file mode 100644 index 000000000..7314a5b99 --- /dev/null +++ b/ddverify/models/con1/include/linux/fs.h @@ -0,0 +1,238 @@ +#ifndef _LINUX_FS_H +#define _LINUX_FS_H + +/* + * This file has definitions for some important file table + * structures etc. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#undef NR_OPEN +#define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */ +#define INR_OPEN 1024 /* Initial setting for nfile rlimits */ + +#define BLOCK_SIZE_BITS 10 +#define BLOCK_SIZE (1<bi_rw & 1) + + +int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); +int register_chrdev_region(dev_t, unsigned, const char *); +void unregister_chrdev_region(dev_t, unsigned); + +int register_chrdev(unsigned int, const char *, struct file_operations *); +int unregister_chrdev(unsigned int, const char *); + +int chrdev_open(struct inode *, struct file *); +void chrdev_show(struct seq_file *,off_t); + +#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ + +int register_blkdev(unsigned int, const char *); +int unregister_blkdev(unsigned int, const char *); + + +void kill_fasync(struct fasync_struct **, int, int); + +static inline unsigned iminor(struct inode *inode) +{ + return MINOR(inode->i_rdev); +} + +static inline unsigned imajor(struct inode *inode) +{ + return MAJOR(inode->i_rdev); +} + +loff_t no_llseek(struct file *file, loff_t offset, int origin); + + +int check_disk_change(struct block_device *); + +/* + * return READ, READA, or WRITE + */ +#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK)) + +int nonseekable_open(struct inode * inode, struct file * filp); + +loff_t i_size_read(struct inode *inode); + +int set_blocksize(struct block_device *, int); +#endif diff --git a/ddverify/models/con1/include/linux/genhd.h b/ddverify/models/con1/include/linux/genhd.h new file mode 100644 index 000000000..46dd433cb --- /dev/null +++ b/ddverify/models/con1/include/linux/genhd.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_GENHD_H +#define _LINUX_GENHD_H + +#include +#include +#include +//#include +#include +#include + +#define GENHD_FL_REMOVABLE 1 +#define GENHD_FL_DRIVERFS 2 +#define GENHD_FL_CD 8 +#define GENHD_FL_UP 16 +#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 + +struct gendisk { + int major; /* major number of driver */ + int first_minor; + int minors; /* maximum number of minors, =1 for + * disks that can't be partitioned. */ + char disk_name[32]; /* name of major driver */ + struct block_device_operations *fops; + struct request_queue *queue; + void *private_data; + + int flags; + struct device *driverfs_dev; + char devfs_name[64]; /* devfs crap */ +}; + +// DDV: defined in file linux/block/genhd.c +void add_disk(struct gendisk *disk); +// DDV: defined in file linux/block/genhd.c +void del_gendisk(struct gendisk *gp); +// DDV: defined in file linux/block/genhd.c +struct gendisk *alloc_disk(int minors); +// DDV: TODO +void put_disk(struct gendisk *disk); +// DDV: TODO +extern struct kobject *get_disk(struct gendisk *disk); + +// DDV: TODO +void set_capacity(struct gendisk *disk, sector_t size); + +// DDV: TODO +void add_disk_randomness(struct gendisk *disk); +#endif diff --git a/ddverify/models/con1/include/linux/gfp.h b/ddverify/models/con1/include/linux/gfp.h new file mode 100644 index 000000000..d01d2dd5e --- /dev/null +++ b/ddverify/models/con1/include/linux/gfp.h @@ -0,0 +1,74 @@ +#ifndef __LINUX_GFP_H +#define __LINUX_GFP_H + +#include +#include +//#include +#include + +/* + * Action modifiers - doesn't change the zoning + * + * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt + * _might_ fail. This depends upon the particular VM implementation. + * + * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller + * cannot handle allocation failures. + * + * __GFP_NORETRY: The VM implementation must not retry indefinitely. + */ +#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */ +#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */ +#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */ +#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ +#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ +#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ +#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */ +#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */ +#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */ +#define __GFP_NO_GROW ((__force gfp_t)0x2000u)/* Slab internal usage */ +#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ +#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ +#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ +#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ + +#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ +#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) + +/* if you forget to add the bitmask here kernel will crash, period */ +#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ + __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ + __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ + __GFP_NOMEMALLOC|__GFP_HARDWALL) + +/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ +#define GFP_ATOMIC (__GFP_HIGH) +#define GFP_NOIO (__GFP_WAIT) +#define GFP_NOFS (__GFP_WAIT | __GFP_IO) +#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) +#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL) +#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \ + __GFP_HIGHMEM) + + +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_page(gfp_t gfp_mask); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long get_zeroed_page(gfp_t gfp_mask); + +// DDV: No body required +void free_pages(unsigned long addr, unsigned int order); +// DDV: No body required +void free_page(unsigned long addr); + +// DDV: Body defined in linux/mm/page_alloc.c +static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, + unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_page(gfp_t gfp_mask); + +#endif diff --git a/ddverify/models/con1/include/linux/hdreg.h b/ddverify/models/con1/include/linux/hdreg.h new file mode 100644 index 000000000..a57304a20 --- /dev/null +++ b/ddverify/models/con1/include/linux/hdreg.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_HDREG_H +#define _LINUX_HDREG_H + +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + unsigned short cylinders; + unsigned long start; +}; + +#define HDIO_GETGEO 0x0301 /* get device geometry */ + +#endif /* _LINUX_HDREG_H */ diff --git a/ddverify/models/con1/include/linux/highmem.h b/ddverify/models/con1/include/linux/highmem.h new file mode 100644 index 000000000..9ec708efa --- /dev/null +++ b/ddverify/models/con1/include/linux/highmem.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_HIGHMEM_H +#define _LINUX_HIGHMEM_H + +#include +#include + +#include + +#endif /* _LINUX_HIGHMEM_H */ diff --git a/ddverify/models/con1/include/linux/if.h b/ddverify/models/con1/include/linux/if.h new file mode 100644 index 000000000..544dc09d7 --- /dev/null +++ b/ddverify/models/con1/include/linux/if.h @@ -0,0 +1,8 @@ +#ifndef _LINUX_IF_H +#define _LINUX_IF_H + +#include /* for "__kernel_caddr_t" et al */ +#include /* for "struct sockaddr" et al */ +#include /* for "__user" et al */ + +#endif /* _LINUX_IF_H */ diff --git a/ddverify/models/con1/include/linux/in.h b/ddverify/models/con1/include/linux/in.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/init.h b/ddverify/models/con1/include/linux/init.h new file mode 100644 index 000000000..ee78bf673 --- /dev/null +++ b/ddverify/models/con1/include/linux/init.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_INIT_H +#define _LINUX_INIT_H + +#include +#include + +#define module_init(_function) int (* _ddv_tmp_init)(void) = _function +#define module_exit(_function) void (* _ddv_tmp_exit)(void) = _function + +#define __init +#define __initdata +#define __exitdata +#define __exit + +#define __devinit +#define __devinitdata +#define __devexit +#define __devexitdata +#define __devexit_p(x) x + +#define __setup(str, func) int (* _ddv_setup_function)(char *) = func + +#endif diff --git a/ddverify/models/con1/include/linux/interrupt.h b/ddverify/models/con1/include/linux/interrupt.h new file mode 100644 index 000000000..68c9dc998 --- /dev/null +++ b/ddverify/models/con1/include/linux/interrupt.h @@ -0,0 +1,96 @@ +/* interrupt.h */ +#ifndef _LINUX_INTERRUPT_H +#define _LINUX_INTERRUPT_H + +#include +#include +#include +#include + +/* + * These flags used only by the kernel as part of the + * irq handling routines. + * + * IRQF_DISABLED - keep irqs disabled when calling the action handler + * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator + * IRQF_SHARED - allow sharing the irq among several devices + * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur + * IRQF_TIMER - Flag to mark this interrupt as timer interrupt + */ +#define IRQF_DISABLED 0x00000020 +#define IRQF_SAMPLE_RANDOM 0x00000040 +#define IRQF_SHARED 0x00000080 +#define IRQF_PROBE_SHARED 0x00000100 +#define IRQF_TIMER 0x00000200 +#define IRQF_PERCPU 0x00000400 + + +typedef int irqreturn_t; + +#define IRQ_NONE (0) +#define IRQ_HANDLED (1) +#define IRQ_RETVAL(x) ((x) != 0) + +struct tasklet_struct +{ + atomic_t count; + void (*func)(unsigned long); + unsigned long data; + + int init; +}; + +#define DECLARE_TASKLET(name, func, data) \ + struct tasklet_struct name = { 0, func, data, 1 } + +#define DECLARE_TASKLET_DISABLED(name, func, data) \ + struct tasklet_struct name = { 1, func, data, 1 } + +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_schedule(struct tasklet_struct *t); + +static inline void tasklet_disable(struct tasklet_struct *t) +{ + t->count++; +} + +static inline void tasklet_enable(struct tasklet_struct *t) +{ + t->count++; +} + +// DDV: TODO +void tasklet_kill(struct tasklet_struct *t); +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data); + +#ifdef OLD_INTERRUPT_HANDLER +typedef irqreturn_t (*irq_handler_t)(int, void *); +#else +typedef irqreturn_t (*irq_handler_t)(int, void *, struct pt_regs *); +#endif + +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +int request_irq(unsigned int, irq_handler_t handler, + unsigned long, const char *, void *); +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +void free_irq(unsigned int, void *); + +// DDV: TODO +unsigned long probe_irq_on(void); +// DDV: TODO +int probe_irq_off(unsigned long); +// DDV: TODO +unsigned int probe_irq_mask(unsigned long); + +// DDV: TODO +void cli(void); +// DDV: TODO +void sti(void); +// DDV: TODO +void save_flags(unsigned long x); +// DDV: TODO +void restore_flags(unsigned long x); + +#endif diff --git a/ddverify/models/con1/include/linux/ioctl.h b/ddverify/models/con1/include/linux/ioctl.h new file mode 100644 index 000000000..6f08f2f94 --- /dev/null +++ b/ddverify/models/con1/include/linux/ioctl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_IOCTL_H +#define _LINUX_IOCTL_H + +#include + +#endif diff --git a/ddverify/models/con1/include/linux/ioport.h b/ddverify/models/con1/include/linux/ioport.h new file mode 100644 index 000000000..7df1143c6 --- /dev/null +++ b/ddverify/models/con1/include/linux/ioport.h @@ -0,0 +1,102 @@ +/* + * ioport.h Definitions of routines for detecting, reserving and + * allocating system resources. + * + * Authors: Linus Torvalds + */ + +#ifndef _LINUX_IOPORT_H +#define _LINUX_IOPORT_H + +#include + + +/* + * Resources are tree-like, allowing + * nesting etc.. + */ +struct resource { + const char *name; + unsigned long start, end; + unsigned long flags; +// struct resource *parent, *sibling, *child; +}; + + +/* + * IO resources have these defined flags. + */ +#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ + +#define IORESOURCE_IO 0x00000100 /* Resource type */ +#define IORESOURCE_MEM 0x00000200 +#define IORESOURCE_IRQ 0x00000400 +#define IORESOURCE_DMA 0x00000800 + +#define IORESOURCE_PREFETCH 0x00001000 /* No side effects */ +#define IORESOURCE_READONLY 0x00002000 +#define IORESOURCE_CACHEABLE 0x00004000 +#define IORESOURCE_RANGELENGTH 0x00008000 +#define IORESOURCE_SHADOWABLE 0x00010000 +#define IORESOURCE_BUS_HAS_VGA 0x00080000 + +#define IORESOURCE_DISABLED 0x10000000 +#define IORESOURCE_UNSET 0x20000000 +#define IORESOURCE_AUTO 0x40000000 +#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ + +/* ISA PnP IRQ specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_IRQ_HIGHEDGE (1<<0) +#define IORESOURCE_IRQ_LOWEDGE (1<<1) +#define IORESOURCE_IRQ_HIGHLEVEL (1<<2) +#define IORESOURCE_IRQ_LOWLEVEL (1<<3) +#define IORESOURCE_IRQ_SHAREABLE (1<<4) + +/* ISA PnP DMA specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_DMA_TYPE_MASK (3<<0) +#define IORESOURCE_DMA_8BIT (0<<0) +#define IORESOURCE_DMA_8AND16BIT (1<<0) +#define IORESOURCE_DMA_16BIT (2<<0) + +#define IORESOURCE_DMA_MASTER (1<<2) +#define IORESOURCE_DMA_BYTE (1<<3) +#define IORESOURCE_DMA_WORD (1<<4) + +#define IORESOURCE_DMA_SPEED_MASK (3<<6) +#define IORESOURCE_DMA_COMPATIBLE (0<<6) +#define IORESOURCE_DMA_TYPEA (1<<6) +#define IORESOURCE_DMA_TYPEB (2<<6) +#define IORESOURCE_DMA_TYPEF (3<<6) + +/* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */ +#define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */ +#define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */ +#define IORESOURCE_MEM_TYPE_MASK (3<<3) +#define IORESOURCE_MEM_8BIT (0<<3) +#define IORESOURCE_MEM_16BIT (1<<3) +#define IORESOURCE_MEM_8AND16BIT (2<<3) +#define IORESOURCE_MEM_32BIT (3<<3) +#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ +#define IORESOURCE_MEM_EXPANSIONROM (1<<6) + +/* PCI ROM control bits (IORESOURCE_BITS) */ +#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ +#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */ +#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */ + + +// DDV: Body defined in linux/kernel/resource.c +struct resource *request_region(unsigned long, unsigned long, const char *); +// DDV: Body defined in linux/kernel/resource.c +void release_region(unsigned long, unsigned long); + + +// DDV: TODO +struct resource *request_mem_region(unsigned long start, unsigned long len, const char *name); +// DDV: TODO +void release_mem_region(unsigned long start, unsigned long len); + + + +#endif /* _LINUX_IOPORT_H */ diff --git a/ddverify/models/con1/include/linux/jiffies.h b/ddverify/models/con1/include/linux/jiffies.h new file mode 100644 index 000000000..2d4a183ca --- /dev/null +++ b/ddverify/models/con1/include/linux/jiffies.h @@ -0,0 +1,84 @@ +#ifndef _LINUX_JIFFIES_H +#define _LINUX_JIFFIES_H + +#include +#include + +unsigned long jiffies; + +/* + * These inlines deal with timer wrapping correctly. You are + * strongly encouraged to use them + * 1. Because people otherwise forget + * 2. Because if the timer wrap changes in future you won't have to + * alter your driver code. + * + * time_after(a,b) returns true if the time a is after time b. + * + * Do this with "<0" and ">=0" to only test the sign of the result. A + * good compiler would generate better code (and a really good compiler + * wouldn't care). Gcc is currently neither. + */ +#define time_after(a,b) ((long)(b) - (long)(a) < 0) +#define time_before(a,b) time_after(b,a) +#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_before_eq(a,b) time_after_eq(b,a) + + +#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) + +/* + * Convert jiffies to milliseconds and back. + * + * Avoid unnecessary multiplications/divisions in the + * two most common HZ cases: + */ +static inline unsigned int jiffies_to_msecs(const unsigned long j) +{ +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (MSEC_PER_SEC / HZ) * j; +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); +#else + return (j * MSEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned int jiffies_to_usecs(const unsigned long j) +{ +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (USEC_PER_SEC / HZ) * j; +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); +#else + return (j * USEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned long msecs_to_jiffies(const unsigned int m) +{ + if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return m * (HZ / MSEC_PER_SEC); +#else + return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; +#endif +} + +static inline unsigned long usecs_to_jiffies(const unsigned int u) +{ + if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ); +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return u * (HZ / USEC_PER_SEC); +#else + return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC; +#endif +} + +#endif diff --git a/ddverify/models/con1/include/linux/kdb_kern.h b/ddverify/models/con1/include/linux/kdb_kern.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/kdev_t.h b/ddverify/models/con1/include/linux/kdev_t.h new file mode 100644 index 000000000..647632b51 --- /dev/null +++ b/ddverify/models/con1/include/linux/kdev_t.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_KDEV_T_H +#define _LINUX_KDEV_T_H + +#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK)) +#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi)) + +#endif diff --git a/ddverify/models/con1/include/linux/kernel.h b/ddverify/models/con1/include/linux/kernel.h new file mode 100644 index 000000000..a228a8a21 --- /dev/null +++ b/ddverify/models/con1/include/linux/kernel.h @@ -0,0 +1,115 @@ +#ifndef _LINUX_KERNEL_H +#define _LINUX_KERNEL_H + +/* + * 'kernel.h' contains some often-used function prototypes etc + */ + +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + +#define KERN_EMERG "<0>" /* system is unusable */ +#define KERN_ALERT "<1>" /* action must be taken immediately */ +#define KERN_CRIT "<2>" /* critical conditions */ +#define KERN_ERR "<3>" /* error conditions */ +#define KERN_WARNING "<4>" /* warning conditions */ +#define KERN_NOTICE "<5>" /* normal but significant condition */ +#define KERN_INFO "<6>" /* informational */ +#define KERN_DEBUG "<7>" /* debug-level messages */ + +unsigned long simple_strtoul(const char *,char **,unsigned int); +long simple_strtol(const char *,char **,unsigned int); +unsigned long long simple_strtoull(const char *,char **,unsigned int); +long long simple_strtoll(const char *,char **,unsigned int); + +int printk(const char * fmt, ...); +int sprintf(char * buf, const char * fmt, ...); +int snprintf(char * buf, size_t size, const char * fmt, ...); + +extern int cond_resched(void); + +extern int get_option(char **str, int *pint); +extern char *get_options(const char *str, int nints, int *ints); + +/* Values used for system_state */ +extern enum system_states { + SYSTEM_BOOTING, + SYSTEM_RUNNING, + SYSTEM_HALT, + SYSTEM_POWER_OFF, + SYSTEM_RESTART, + SYSTEM_SUSPEND_DISK, +} system_state; + +#define TAINT_PROPRIETARY_MODULE (1<<0) +#define TAINT_FORCED_MODULE (1<<1) +#define TAINT_UNSAFE_SMP (1<<2) +#define TAINT_FORCED_RMMOD (1<<3) +#define TAINT_MACHINE_CHECK (1<<4) +#define TAINT_BAD_PAGE (1<<5) + +extern void dump_stack(void); + +/* + * min()/max() macros that also do + * strict type-checking.. See the + * "unnecessary" pointer comparison. + */ +#define min(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + +#define max(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +/* + * ..and if you can't take the strict + * types, you can specify one yourself. + * + * Or not use min/max at all, of course. + */ +#define min_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) +#define max_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) + +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + +#define pr_debug(fmt,arg...) \ + do { } while (0) + +#define BUILD_BUG_ON(condition) \ + do { } while (0) + +#define BUILD_BUG_ON_ZERO(condition) \ + do { } while (0) + + +/* Trap pasters of __FUNCTION__ at compile-time */ +#define __FUNCTION__ (__func__) + +#endif diff --git a/ddverify/models/con1/include/linux/kobject.h b/ddverify/models/con1/include/linux/kobject.h new file mode 100644 index 000000000..4c1ba3fd0 --- /dev/null +++ b/ddverify/models/con1/include/linux/kobject.h @@ -0,0 +1,34 @@ +/* + * kobject.h - generic kernel object infrastructure. + * + * Copyright (c) 2002-2003 Patrick Mochel + * Copyright (c) 2002-2003 Open Source Development Labs + * + * This file is released under the GPLv2. + * + * + * Please read Documentation/kobject.txt before using the kobject + * interface, ESPECIALLY the parts about reference counts and object + * destructors. + */ + +#ifndef _KOBJECT_H_ +#define _KOBJECT_H_ + + +#include +#include +#include +#include +#include +//#include +//#include +#include +#include +#include + +struct kobject { + int something; +}; + +#endif /* _KOBJECT_H_ */ diff --git a/ddverify/models/con1/include/linux/kthread.h b/ddverify/models/con1/include/linux/kthread.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/list.h b/ddverify/models/con1/include/linux/list.h new file mode 100644 index 000000000..0132dfc43 --- /dev/null +++ b/ddverify/models/con1/include/linux/list.h @@ -0,0 +1,108 @@ +#ifndef _LINUX_LIST_H +#define _LINUX_LIST_H + +//#include +//#include +//#include +#include + +struct list_head { + struct list_head *next, *prev; +}; + +#define LIST_HEAD_INIT(name) { &(name), &(name) } + + +#define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + +static inline void INIT_LIST_HEAD(struct list_head *list) +{ + list->next = list; + list->prev = list; +} + +/** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop cursor. + * @head: the head for your list. + */ +#define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ +static inline void list_del_init(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); +} + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +#endif + + diff --git a/ddverify/models/con1/include/linux/major.h b/ddverify/models/con1/include/linux/major.h new file mode 100644 index 000000000..0a74c5292 --- /dev/null +++ b/ddverify/models/con1/include/linux/major.h @@ -0,0 +1,169 @@ +#ifndef _LINUX_MAJOR_H +#define _LINUX_MAJOR_H + +/* + * This file has definitions for major device numbers. + * For the device number assignments, see Documentation/devices.txt. + */ + +#define UNNAMED_MAJOR 0 +#define MEM_MAJOR 1 +#define RAMDISK_MAJOR 1 +#define FLOPPY_MAJOR 2 +#define PTY_MASTER_MAJOR 2 +#define IDE0_MAJOR 3 +#define HD_MAJOR IDE0_MAJOR +#define PTY_SLAVE_MAJOR 3 +#define TTY_MAJOR 4 +#define TTYAUX_MAJOR 5 +#define LP_MAJOR 6 +#define VCS_MAJOR 7 +#define LOOP_MAJOR 7 +#define SCSI_DISK0_MAJOR 8 +#define SCSI_TAPE_MAJOR 9 +#define MD_MAJOR 9 +#define MISC_MAJOR 10 +#define SCSI_CDROM_MAJOR 11 +#define MUX_MAJOR 11 /* PA-RISC only */ +#define XT_DISK_MAJOR 13 +#define INPUT_MAJOR 13 +#define SOUND_MAJOR 14 +#define CDU31A_CDROM_MAJOR 15 +#define JOYSTICK_MAJOR 15 +#define GOLDSTAR_CDROM_MAJOR 16 +#define OPTICS_CDROM_MAJOR 17 +#define SANYO_CDROM_MAJOR 18 +#define CYCLADES_MAJOR 19 +#define CYCLADESAUX_MAJOR 20 +#define MITSUMI_X_CDROM_MAJOR 20 +#define MFM_ACORN_MAJOR 21 /* ARM Linux /dev/mfm */ +#define SCSI_GENERIC_MAJOR 21 +#define IDE1_MAJOR 22 +#define DIGICU_MAJOR 22 +#define DIGI_MAJOR 23 +#define MITSUMI_CDROM_MAJOR 23 +#define CDU535_CDROM_MAJOR 24 +#define STL_SERIALMAJOR 24 +#define MATSUSHITA_CDROM_MAJOR 25 +#define STL_CALLOUTMAJOR 25 +#define MATSUSHITA_CDROM2_MAJOR 26 +#define QIC117_TAPE_MAJOR 27 +#define MATSUSHITA_CDROM3_MAJOR 27 +#define MATSUSHITA_CDROM4_MAJOR 28 +#define STL_SIOMEMMAJOR 28 +#define ACSI_MAJOR 28 +#define AZTECH_CDROM_MAJOR 29 +#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */ +#define CM206_CDROM_MAJOR 32 +#define IDE2_MAJOR 33 +#define IDE3_MAJOR 34 +#define Z8530_MAJOR 34 +#define XPRAM_MAJOR 35 /* Expanded storage on S/390: "slow ram"*/ +#define NETLINK_MAJOR 36 +#define PS2ESDI_MAJOR 36 +#define IDETAPE_MAJOR 37 +#define Z2RAM_MAJOR 37 +#define APBLOCK_MAJOR 38 /* AP1000 Block device */ +#define DDV_MAJOR 39 /* AP1000 DDV block device */ +#define NBD_MAJOR 43 /* Network block device */ +#define RISCOM8_NORMAL_MAJOR 48 +#define DAC960_MAJOR 48 /* 48..55 */ +#define RISCOM8_CALLOUT_MAJOR 49 +#define MKISS_MAJOR 55 +#define DSP56K_MAJOR 55 /* DSP56001 processor device */ + +#define IDE4_MAJOR 56 +#define IDE5_MAJOR 57 + +#define SCSI_DISK1_MAJOR 65 +#define SCSI_DISK2_MAJOR 66 +#define SCSI_DISK3_MAJOR 67 +#define SCSI_DISK4_MAJOR 68 +#define SCSI_DISK5_MAJOR 69 +#define SCSI_DISK6_MAJOR 70 +#define SCSI_DISK7_MAJOR 71 + +#define COMPAQ_SMART2_MAJOR 72 +#define COMPAQ_SMART2_MAJOR1 73 +#define COMPAQ_SMART2_MAJOR2 74 +#define COMPAQ_SMART2_MAJOR3 75 +#define COMPAQ_SMART2_MAJOR4 76 +#define COMPAQ_SMART2_MAJOR5 77 +#define COMPAQ_SMART2_MAJOR6 78 +#define COMPAQ_SMART2_MAJOR7 79 + +#define SPECIALIX_NORMAL_MAJOR 75 +#define SPECIALIX_CALLOUT_MAJOR 76 + +#define AURORA_MAJOR 79 + +#define I2O_MAJOR 80 /* 80->87 */ + +#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */ +#define SCSI_CHANGER_MAJOR 86 + +#define IDE6_MAJOR 88 +#define IDE7_MAJOR 89 +#define IDE8_MAJOR 90 +#define IDE9_MAJOR 91 + +#define DASD_MAJOR 94 + +#define MDISK_MAJOR 95 + +#define UBD_MAJOR 98 + +#define PP_MAJOR 99 +#define JSFD_MAJOR 99 + +#define PHONE_MAJOR 100 + +#define COMPAQ_CISS_MAJOR 104 +#define COMPAQ_CISS_MAJOR1 105 +#define COMPAQ_CISS_MAJOR2 106 +#define COMPAQ_CISS_MAJOR3 107 +#define COMPAQ_CISS_MAJOR4 108 +#define COMPAQ_CISS_MAJOR5 109 +#define COMPAQ_CISS_MAJOR6 110 +#define COMPAQ_CISS_MAJOR7 111 + +#define VIODASD_MAJOR 112 +#define VIOCD_MAJOR 113 + +#define ATARAID_MAJOR 114 + +#define SCSI_DISK8_MAJOR 128 +#define SCSI_DISK9_MAJOR 129 +#define SCSI_DISK10_MAJOR 130 +#define SCSI_DISK11_MAJOR 131 +#define SCSI_DISK12_MAJOR 132 +#define SCSI_DISK13_MAJOR 133 +#define SCSI_DISK14_MAJOR 134 +#define SCSI_DISK15_MAJOR 135 + +#define UNIX98_PTY_MASTER_MAJOR 128 +#define UNIX98_PTY_MAJOR_COUNT 8 +#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT) + +#define RTF_MAJOR 150 +#define RAW_MAJOR 162 + +#define USB_ACM_MAJOR 166 +#define USB_ACM_AUX_MAJOR 167 +#define USB_CHAR_MAJOR 180 + +#define VXVM_MAJOR 199 /* VERITAS volume i/o driver */ +#define VXSPEC_MAJOR 200 /* VERITAS volume config driver */ +#define VXDMP_MAJOR 201 /* VERITAS volume multipath driver */ + +#define MSR_MAJOR 202 +#define CPUID_MAJOR 203 + +#define OSST_MAJOR 206 /* OnStream-SCx0 SCSI tape */ + +#define IBM_TTY3270_MAJOR 227 +#define IBM_FS3270_MAJOR 228 + +#define VIOTAPE_MAJOR 230 + +#endif diff --git a/ddverify/models/con1/include/linux/mc146818rtc.h b/ddverify/models/con1/include/linux/mc146818rtc.h new file mode 100644 index 000000000..38ed29876 --- /dev/null +++ b/ddverify/models/con1/include/linux/mc146818rtc.h @@ -0,0 +1,87 @@ +#ifndef _MC146818RTC_H +#define _MC146818RTC_H + +#include +#include /* get the user-level API */ +#include /* register access macros */ + +#include /* spinlock_t */ +extern spinlock_t rtc_lock; /* serialize CMOS RAM access */ + +/********************************************************************** + * register summary + **********************************************************************/ +#define RTC_SECONDS 0 +#define RTC_SECONDS_ALARM 1 +#define RTC_MINUTES 2 +#define RTC_MINUTES_ALARM 3 +#define RTC_HOURS 4 +#define RTC_HOURS_ALARM 5 +/* RTC_*_alarm is always true if 2 MSBs are set */ +# define RTC_ALARM_DONT_CARE 0xC0 + +#define RTC_DAY_OF_WEEK 6 +#define RTC_DAY_OF_MONTH 7 +#define RTC_MONTH 8 +#define RTC_YEAR 9 + +/* control registers - Moto names + */ +#define RTC_REG_A 10 +#define RTC_REG_B 11 +#define RTC_REG_C 12 +#define RTC_REG_D 13 + +/********************************************************************** + * register details + **********************************************************************/ +#define RTC_FREQ_SELECT RTC_REG_A + +/* update-in-progress - set to "1" 244 microsecs before RTC goes off the bus, + * reset after update (may take 1.984ms @ 32768Hz RefClock) is complete, + * totalling to a max high interval of 2.228 ms. + */ +# define RTC_UIP 0x80 +# define RTC_DIV_CTL 0x70 + /* divider control: refclock values 4.194 / 1.049 MHz / 32.768 kHz */ +# define RTC_REF_CLCK_4MHZ 0x00 +# define RTC_REF_CLCK_1MHZ 0x10 +# define RTC_REF_CLCK_32KHZ 0x20 + /* 2 values for divider stage reset, others for "testing purposes only" */ +# define RTC_DIV_RESET1 0x60 +# define RTC_DIV_RESET2 0x70 + /* Periodic intr. / Square wave rate select. 0=none, 1=32.8kHz,... 15=2Hz */ +# define RTC_RATE_SELECT 0x0F + +/**********************************************************************/ +#define RTC_CONTROL RTC_REG_B +# define RTC_SET 0x80 /* disable updates for clock setting */ +# define RTC_PIE 0x40 /* periodic interrupt enable */ +# define RTC_AIE 0x20 /* alarm interrupt enable */ +# define RTC_UIE 0x10 /* update-finished interrupt enable */ +# define RTC_SQWE 0x08 /* enable square-wave output */ +# define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +# define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +# define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +/**********************************************************************/ +#define RTC_INTR_FLAGS RTC_REG_C +/* caution - cleared by read */ +# define RTC_IRQF 0x80 /* any of the following 3 is active */ +# define RTC_PF 0x40 +# define RTC_AF 0x20 +# define RTC_UF 0x10 + +/**********************************************************************/ +#define RTC_VALID RTC_REG_D +# define RTC_VRT 0x80 /* valid RAM and time */ +/**********************************************************************/ + +#ifndef ARCH_RTC_LOCATION /* Override by ? */ + +#define RTC_IO_EXTENT 0x8 +#define RTC_IOMAPPED 1 /* Default to I/O mapping. */ + +#endif /* ARCH_RTC_LOCATION */ + +#endif /* _MC146818RTC_H */ diff --git a/ddverify/models/con1/include/linux/mempool.h b/ddverify/models/con1/include/linux/mempool.h new file mode 100644 index 000000000..dd86176f1 --- /dev/null +++ b/ddverify/models/con1/include/linux/mempool.h @@ -0,0 +1,11 @@ +/* + * memory buffer pool support + */ +#ifndef _LINUX_MEMPOOL_H +#define _LINUX_MEMPOOL_H + +#include + + + +#endif /* _LINUX_MEMPOOL_H */ diff --git a/ddverify/models/con1/include/linux/miscdevice.h b/ddverify/models/con1/include/linux/miscdevice.h new file mode 100644 index 000000000..1b6241373 --- /dev/null +++ b/ddverify/models/con1/include/linux/miscdevice.h @@ -0,0 +1,43 @@ +#ifndef _LINUX_MISCDEVICE_H +#define _LINUX_MISCDEVICE_H +#include +#include + +#define PSMOUSE_MINOR 1 +#define MS_BUSMOUSE_MINOR 2 +#define ATIXL_BUSMOUSE_MINOR 3 +/*#define AMIGAMOUSE_MINOR 4 FIXME OBSOLETE */ +#define ATARIMOUSE_MINOR 5 +#define SUN_MOUSE_MINOR 6 +#define APOLLO_MOUSE_MINOR 7 +#define PC110PAD_MINOR 9 +/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */ +#define WATCHDOG_MINOR 130 /* Watchdog timer */ +#define TEMP_MINOR 131 /* Temperature Sensor */ +#define RTC_MINOR 135 +#define EFI_RTC_MINOR 136 /* EFI Time services */ +#define SUN_OPENPROM_MINOR 139 +#define DMAPI_MINOR 140 /* DMAPI */ +#define NVRAM_MINOR 144 +#define SGI_MMTIMER 153 +#define STORE_QUEUE_MINOR 155 +#define I2O_MINOR 166 +#define MICROCODE_MINOR 184 +#define MWAVE_MINOR 219 /* ACP/Mwave Modem */ +#define MPT_MINOR 220 +#define MISC_DYNAMIC_MINOR 255 + +#define TUN_MINOR 200 +#define HPET_MINOR 228 + + +struct miscdevice { + int minor; + const char *name; + struct file_operations *fops; +}; + +extern int misc_register(struct miscdevice * misc); +extern int misc_deregister(struct miscdevice * misc); + +#endif diff --git a/ddverify/models/con1/include/linux/mm.h b/ddverify/models/con1/include/linux/mm.h new file mode 100644 index 000000000..4bbf229f1 --- /dev/null +++ b/ddverify/models/con1/include/linux/mm.h @@ -0,0 +1,17 @@ +#ifndef _LINUX_MM_H +#define _LINUX_MM_H + +#include +#include +#include + +#include +#include +#include +#include + +#include + +void *page_address(struct page *page); + +#endif /* _LINUX_MM_H */ diff --git a/ddverify/models/con1/include/linux/mm_types.h b/ddverify/models/con1/include/linux/mm_types.h new file mode 100644 index 000000000..0645b00a5 --- /dev/null +++ b/ddverify/models/con1/include/linux/mm_types.h @@ -0,0 +1,14 @@ +#ifndef _LINUX_MM_TYPES_H +#define _LINUX_MM_TYPES_H + +#include +//#include +#include +#include + +struct page { + int something; +}; + +#endif /* _LINUX_MM_TYPES_H */ + diff --git a/ddverify/models/con1/include/linux/mman.h b/ddverify/models/con1/include/linux/mman.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/mmzone.h b/ddverify/models/con1/include/linux/mmzone.h new file mode 100644 index 000000000..709447587 --- /dev/null +++ b/ddverify/models/con1/include/linux/mmzone.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_MMZONE_H +#define _LINUX_MMZONE_H + +#include +#include +//#include +#include +//#include +#include +//#include +#include +//#include +#include + +#endif /* _LINUX_MMZONE_H */ + diff --git a/ddverify/models/con1/include/linux/mod_devicetable.h b/ddverify/models/con1/include/linux/mod_devicetable.h new file mode 100644 index 000000000..0c41094d7 --- /dev/null +++ b/ddverify/models/con1/include/linux/mod_devicetable.h @@ -0,0 +1,18 @@ +#ifndef LINUX_MOD_DEVICETABLE_H +#define LINUX_MOD_DEVICETABLE_H + +#include + +typedef unsigned long kernel_ulong_t; + +#define PCI_ANY_ID (~0) + +struct pci_device_id { + __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/ + __u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ + __u32 class, class_mask; /* (class,subclass,prog-if) triplet */ + kernel_ulong_t driver_data; /* Data private to the driver */ +}; + +#endif /* LINUX_MOD_DEVICETABLE_H */ + diff --git a/ddverify/models/con1/include/linux/module.h b/ddverify/models/con1/include/linux/module.h new file mode 100644 index 000000000..e911d572d --- /dev/null +++ b/ddverify/models/con1/include/linux/module.h @@ -0,0 +1,32 @@ +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H + +#include +#include +#include +#include +#include +#include + +#define MODULE_AUTHOR(_author) char _ddv_module_author[] = _author +#define MODULE_LICENSE(_license) char _ddv_module_license[] = _license +#define MODULE_DESCRIPTION(_description) char _ddv_module_description[] = _description +#define MODULE_SUPPORTED_DEVICE(_device) char _ddv_module_supported_device[] = _device +#define MODULE_PARM_DESC(_param, _description) char _ddv_module_param_##_param [] = _description +#define MODULE_ALIAS(_whatever) void +#define MODULE_ALIAS_CHARDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_BLOCKDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_MISCDEV(_dev) void +#define MODULE_DEVICE_TABLE(type,name) void + +#define THIS_MODULE ((struct module *) 0) + +struct module { + int something; +}; + +#define __MODULE_STRING(x) #x + +void __module_get(struct module *module); + +#endif diff --git a/ddverify/models/con1/include/linux/moduleparam.h b/ddverify/models/con1/include/linux/moduleparam.h new file mode 100644 index 000000000..8df1e77e0 --- /dev/null +++ b/ddverify/models/con1/include/linux/moduleparam.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_MODULE_PARAMS_H +#define _LINUX_MODULE_PARAMS_H + +#include +#include +#include + +#define module_param(var, type, arg) void +#define module_param_named(name, var, type, arg) void +#define module_param_array(name, type, nump, perm) void + +#endif diff --git a/ddverify/models/con1/include/linux/mutex.h b/ddverify/models/con1/include/linux/mutex.h new file mode 100644 index 000000000..7298d3300 --- /dev/null +++ b/ddverify/models/con1/include/linux/mutex.h @@ -0,0 +1,38 @@ +/* + * Mutexes: blocking mutual exclusion locks + * + * started by Ingo Molnar: + * + * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar + * + * This file contains the main data structure and API definitions. + */ +#ifndef __LINUX_MUTEX_H +#define __LINUX_MUTEX_H + +#include +#include +//#include +//#include + +#include + +struct mutex { + int locked; + int init; +}; + +#define __MUTEX_INITIALIZER(lockname) \ + { .locked = 0, .init = 1 } + +#define DEFINE_MUTEX(mutexname) \ + struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) + +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_init(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_lock(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_unlock(struct mutex *lock); + +#endif diff --git a/ddverify/models/con1/include/linux/net.h b/ddverify/models/con1/include/linux/net.h new file mode 100644 index 000000000..1339d2421 --- /dev/null +++ b/ddverify/models/con1/include/linux/net.h @@ -0,0 +1,19 @@ +#ifndef _LINUX_NET_H +#define _LINUX_NET_H + +struct socket { + const struct proto_ops *ops; + struct sock *sk; +}; + +struct proto_ops { + int (*shutdown) (struct socket *sock, int flags); +}; + +extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, size_t len); +extern int kernel_recvmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, + size_t len, int flags); + +#endif /* _LINUX_NET_H */ diff --git a/ddverify/models/con1/include/linux/netdevice.h b/ddverify/models/con1/include/linux/netdevice.h new file mode 100644 index 000000000..f90cdbfa3 --- /dev/null +++ b/ddverify/models/con1/include/linux/netdevice.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_NETDEVICE_H +#define _LINUX_NETDEVICE_H + +#include + +#endif /* _LINUX_DEV_H */ diff --git a/ddverify/models/con1/include/linux/notifier.h b/ddverify/models/con1/include/linux/notifier.h new file mode 100644 index 000000000..1029f233e --- /dev/null +++ b/ddverify/models/con1/include/linux/notifier.h @@ -0,0 +1,61 @@ +/* + * Routines to manage notifier chains for passing status changes to any + * interested routines. We need this instead of hard coded call lists so + * that modules can poke their nose into the innards. The network devices + * needed them so here they are for the rest of you. + * + * Alan Cox + */ + +#ifndef _LINUX_NOTIFIER_H +#define _LINUX_NOTIFIER_H +#include + + +struct notifier_block +{ + int (*notifier_call)(struct notifier_block *self, unsigned long, void *); + struct notifier_block *next; + int priority; +}; + +#define NOTIFY_DONE 0x0000 /* Don't care */ +#define NOTIFY_OK 0x0001 /* Suits me */ +#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ +#define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */ +/* + * Clean way to return from the notifier and stop further calls. + */ +#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) + +/* netdevice notifier chain */ +#define NETDEV_UP 0x0001 /* For now you can't veto a device up/down */ +#define NETDEV_DOWN 0x0002 +#define NETDEV_REBOOT 0x0003 /* Tell a protocol stack a network interface + detected a hardware crash and restarted + - we can use this eg to kick tcp sessions + once done */ +#define NETDEV_CHANGE 0x0004 /* Notify device state change */ +#define NETDEV_REGISTER 0x0005 +#define NETDEV_UNREGISTER 0x0006 +#define NETDEV_CHANGEMTU 0x0007 +#define NETDEV_CHANGEADDR 0x0008 +#define NETDEV_GOING_DOWN 0x0009 +#define NETDEV_CHANGENAME 0x000A +#define NETDEV_FEAT_CHANGE 0x000B + +#define SYS_DOWN 0x0001 /* Notify of system down */ +#define SYS_RESTART SYS_DOWN +#define SYS_HALT 0x0002 /* Notify of system halt */ +#define SYS_POWER_OFF 0x0003 /* Notify of system power off */ + +#define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */ + +#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ +#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ +#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ +#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ +#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ +#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ + +#endif /* _LINUX_NOTIFIER_H */ diff --git a/ddverify/models/con1/include/linux/pagemap.h b/ddverify/models/con1/include/linux/pagemap.h new file mode 100644 index 000000000..0525a9fc0 --- /dev/null +++ b/ddverify/models/con1/include/linux/pagemap.h @@ -0,0 +1,15 @@ +#ifndef _LINUX_PAGEMAP_H +#define _LINUX_PAGEMAP_H + +/* + * Copyright 1995 Linus Torvalds + */ +#include +#include +#include +#include +#include +#include +#include + +#endif /* _LINUX_PAGEMAP_H */ diff --git a/ddverify/models/con1/include/linux/parport.h b/ddverify/models/con1/include/linux/parport.h new file mode 100644 index 000000000..4e29e513d --- /dev/null +++ b/ddverify/models/con1/include/linux/parport.h @@ -0,0 +1,559 @@ +/* $Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea $ */ + +/* + * Any part of this program may be used in documents licensed under + * the GNU Free Documentation License, Version 1.1 or any later version + * published by the Free Software Foundation. + */ + +#ifndef _PARPORT_H_ +#define _PARPORT_H_ + +/* Start off with user-visible constants */ + +/* Maximum of 16 ports per machine */ +#define PARPORT_MAX 16 + +/* Magic numbers */ +#define PARPORT_IRQ_NONE -1 +#define PARPORT_DMA_NONE -1 +#define PARPORT_IRQ_AUTO -2 +#define PARPORT_DMA_AUTO -2 +#define PARPORT_DMA_NOFIFO -3 +#define PARPORT_DISABLE -2 +#define PARPORT_IRQ_PROBEONLY -3 +#define PARPORT_IOHI_AUTO -1 + +#define PARPORT_CONTROL_STROBE 0x1 +#define PARPORT_CONTROL_AUTOFD 0x2 +#define PARPORT_CONTROL_INIT 0x4 +#define PARPORT_CONTROL_SELECT 0x8 + +#define PARPORT_STATUS_ERROR 0x8 +#define PARPORT_STATUS_SELECT 0x10 +#define PARPORT_STATUS_PAPEROUT 0x20 +#define PARPORT_STATUS_ACK 0x40 +#define PARPORT_STATUS_BUSY 0x80 + +/* Type classes for Plug-and-Play probe. */ +typedef enum { + PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */ + PARPORT_CLASS_PRINTER, + PARPORT_CLASS_MODEM, + PARPORT_CLASS_NET, + PARPORT_CLASS_HDC, /* Hard disk controller */ + PARPORT_CLASS_PCMCIA, + PARPORT_CLASS_MEDIA, /* Multimedia device */ + PARPORT_CLASS_FDC, /* Floppy disk controller */ + PARPORT_CLASS_PORTS, + PARPORT_CLASS_SCANNER, + PARPORT_CLASS_DIGCAM, + PARPORT_CLASS_OTHER, /* Anything else */ + PARPORT_CLASS_UNSPEC, /* No CLS field in ID */ + PARPORT_CLASS_SCSIADAPTER +} parport_device_class; + +/* The "modes" entry in parport is a bit field representing the + capabilities of the hardware. */ +#define PARPORT_MODE_PCSPP (1<<0) /* IBM PC registers available. */ +#define PARPORT_MODE_TRISTATE (1<<1) /* Can tristate. */ +#define PARPORT_MODE_EPP (1<<2) /* Hardware EPP. */ +#define PARPORT_MODE_ECP (1<<3) /* Hardware ECP. */ +#define PARPORT_MODE_COMPAT (1<<4) /* Hardware 'printer protocol'. */ +#define PARPORT_MODE_DMA (1<<5) /* Hardware can DMA. */ +#define PARPORT_MODE_SAFEININT (1<<6) /* SPP registers accessible in IRQ. */ + +/* IEEE1284 modes: + Nibble mode, byte mode, ECP, ECPRLE and EPP are their own + 'extensibility request' values. Others are special. + 'Real' ECP modes must have the IEEE1284_MODE_ECP bit set. */ +#define IEEE1284_MODE_NIBBLE 0 +#define IEEE1284_MODE_BYTE (1<<0) +#define IEEE1284_MODE_COMPAT (1<<8) +#define IEEE1284_MODE_BECP (1<<9) /* Bounded ECP mode */ +#define IEEE1284_MODE_ECP (1<<4) +#define IEEE1284_MODE_ECPRLE (IEEE1284_MODE_ECP | (1<<5)) +#define IEEE1284_MODE_ECPSWE (1<<10) /* Software-emulated */ +#define IEEE1284_MODE_EPP (1<<6) +#define IEEE1284_MODE_EPPSL (1<<11) /* EPP 1.7 */ +#define IEEE1284_MODE_EPPSWE (1<<12) /* Software-emulated */ +#define IEEE1284_DEVICEID (1<<2) /* This is a flag */ +#define IEEE1284_EXT_LINK (1<<14) /* This flag causes the + * extensibility link to + * be requested, using + * bits 0-6. */ + +/* For the benefit of parport_read/write, you can use these with + * parport_negotiate to use address operations. They have no effect + * other than to make parport_read/write use address transfers. */ +#define IEEE1284_ADDR (1<<13) /* This is a flag */ +#define IEEE1284_DATA 0 /* So is this */ + +/* Flags for block transfer operations. */ +#define PARPORT_EPP_FAST (1<<0) /* Unreliable counts. */ +#define PARPORT_W91284PIC (1<<1) /* have a Warp9 w91284pic in the device */ + +#include +#include +#include +#include +#include +#include +#include + +/* Define this later. */ +struct parport; +struct pardevice; + +struct pc_parport_state { + unsigned int ctr; + unsigned int ecr; +}; + +struct ax_parport_state { + unsigned int ctr; + unsigned int ecr; + unsigned int dcsr; +}; + +/* used by both parport_amiga and parport_mfc3 */ +struct amiga_parport_state { + unsigned char data; /* ciaa.prb */ + unsigned char datadir; /* ciaa.ddrb */ + unsigned char status; /* ciab.pra & 7 */ + unsigned char statusdir;/* ciab.ddrb & 7 */ +}; + +struct ax88796_parport_state { + unsigned char cpr; +}; + +struct ip32_parport_state { + unsigned int dcr; + unsigned int ecr; +}; + +struct parport_state { + union { + struct pc_parport_state pc; + /* ARC has no state. */ + struct ax_parport_state ax; + struct amiga_parport_state amiga; + struct ax88796_parport_state ax88796; + /* Atari has not state. */ + struct ip32_parport_state ip32; + void *misc; + } u; +}; + +struct parport_operations { + /* IBM PC-style virtual registers. */ + void (*write_data)(struct parport *, unsigned char); + unsigned char (*read_data)(struct parport *); + + void (*write_control)(struct parport *, unsigned char); + unsigned char (*read_control)(struct parport *); + unsigned char (*frob_control)(struct parport *, unsigned char mask, + unsigned char val); + + unsigned char (*read_status)(struct parport *); + + /* IRQs. */ + void (*enable_irq)(struct parport *); + void (*disable_irq)(struct parport *); + + /* Data direction. */ + void (*data_forward) (struct parport *); + void (*data_reverse) (struct parport *); + + /* For core parport code. */ + void (*init_state)(struct pardevice *, struct parport_state *); + void (*save_state)(struct parport *, struct parport_state *); + void (*restore_state)(struct parport *, struct parport_state *); + + /* Block read/write */ + size_t (*epp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*epp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_addr) (struct parport *port, void *buf, size_t len, + int flags); + + size_t (*ecp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*ecp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*ecp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + + size_t (*compat_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*nibble_read_data) (struct parport *port, void *buf, + size_t len, int flags); + size_t (*byte_read_data) (struct parport *port, void *buf, + size_t len, int flags); + struct module *owner; +}; + +struct parport_device_info { + parport_device_class class; + const char *class_name; + const char *mfr; + const char *model; + const char *cmdset; + const char *description; +}; + +/* Each device can have two callback functions: + * 1) a preemption function, called by the resource manager to request + * that the driver relinquish control of the port. The driver should + * return zero if it agrees to release the port, and nonzero if it + * refuses. Do not call parport_release() - the kernel will do this + * implicitly. + * + * 2) a wake-up function, called by the resource manager to tell drivers + * that the port is available to be claimed. If a driver wants to use + * the port, it should call parport_claim() here. + */ + +/* A parallel port device */ +struct pardevice { + const char *name; + struct parport *port; + int daisy; + int (*preempt)(void *); + void (*wakeup)(void *); + void *private; + void (*irq_func)(int, void *); + unsigned int flags; + struct pardevice *next; + struct pardevice *prev; + struct parport_state *state; /* saved status over preemption */ + wait_queue_head_t wait_q; + unsigned long int time; + unsigned long int timeslice; + volatile long int timeout; + unsigned long waiting; /* long req'd for set_bit --RR */ + struct pardevice *waitprev; + struct pardevice *waitnext; + void * sysctl_table; +}; + +/* IEEE1284 information */ + +/* IEEE1284 phases. These are exposed to userland through ppdev IOCTL + * PP[GS]ETPHASE, so do not change existing values. */ +enum ieee1284_phase { + IEEE1284_PH_FWD_DATA, + IEEE1284_PH_FWD_IDLE, + IEEE1284_PH_TERMINATE, + IEEE1284_PH_NEGOTIATION, + IEEE1284_PH_HBUSY_DNA, + IEEE1284_PH_REV_IDLE, + IEEE1284_PH_HBUSY_DAVAIL, + IEEE1284_PH_REV_DATA, + IEEE1284_PH_ECP_SETUP, + IEEE1284_PH_ECP_FWD_TO_REV, + IEEE1284_PH_ECP_REV_TO_FWD, + IEEE1284_PH_ECP_DIR_UNKNOWN, +}; +struct ieee1284_info { + int mode; + volatile enum ieee1284_phase phase; + struct semaphore irq; +}; + +/* A parallel port */ +struct parport { + unsigned long base; /* base address */ + unsigned long base_hi; /* base address (hi - ECR) */ + unsigned int size; /* IO extent */ + const char *name; + unsigned int modes; + int irq; /* interrupt (or -1 for none) */ + int dma; + int muxport; /* which muxport (if any) this is */ + int portnum; /* which physical parallel port (not mux) */ + + struct parport *physport; + /* If this is a non-default mux + parport, i.e. we're a clone of a real + physical port, this is a pointer to that + port. The locking is only done in the + real port. For a clone port, the + following structure members are + meaningless: devices, cad, muxsel, + waithead, waittail, flags, pdir, + ieee1284, *_lock. + + It this is a default mux parport, or + there is no mux involved, this points to + ourself. */ + + struct pardevice *devices; + struct pardevice *cad; /* port owner */ + int daisy; /* currently selected daisy addr */ + int muxsel; /* currently selected mux port */ + + struct pardevice *waithead; + struct pardevice *waittail; + + struct list_head list; + unsigned int flags; + + void *sysctl_table; + struct parport_device_info probe_info[5]; /* 0-3 + non-IEEE1284.3 */ + struct ieee1284_info ieee1284; + + struct parport_operations *ops; + void *private_data; /* for lowlevel driver */ + + int number; /* port index - the `n' in `parportn' */ + spinlock_t pardevice_lock; + spinlock_t waitlist_lock; + rwlock_t cad_lock; + + int spintime; + atomic_t ref_count; + + struct list_head full_list; + struct parport *slaves[3]; +}; + +#define DEFAULT_SPIN_TIME 500 /* us */ + +struct parport_driver { + const char *name; + void (*attach) (struct parport *); + void (*detach) (struct parport *); + struct list_head list; +}; + +/* parport_register_port registers a new parallel port at the given + address (if one does not already exist) and returns a pointer to it. + This entails claiming the I/O region, IRQ and DMA. NULL is returned + if initialisation fails. */ +struct parport *parport_register_port(unsigned long base, int irq, int dma, + struct parport_operations *ops); + +/* Once a registered port is ready for high-level drivers to use, the + low-level driver that registered it should announce it. This will + call the high-level drivers' attach() functions (after things like + determining the IEEE 1284.3 topology of the port and collecting + DeviceIDs). */ +void parport_announce_port (struct parport *port); + +/* Unregister a port. */ +extern void parport_remove_port(struct parport *port); + +/* Register a new high-level driver. */ +extern int parport_register_driver (struct parport_driver *); + +/* Unregister a high-level driver. */ +extern void parport_unregister_driver (struct parport_driver *); + +/* If parport_register_driver doesn't fit your needs, perhaps + * parport_find_xxx does. */ +extern struct parport *parport_find_number (int); +extern struct parport *parport_find_base (unsigned long); + +/* Reference counting for ports. */ +extern struct parport *parport_get_port (struct parport *); +extern void parport_put_port (struct parport *); + +/* parport_register_device declares that a device is connected to a + port, and tells the kernel all it needs to know. + - pf is the preemption function (may be NULL for no callback) + - kf is the wake-up function (may be NULL for no callback) + - irq_func is the interrupt handler (may be NULL for no interrupts) + - handle is a user pointer that gets handed to callback functions. */ +struct pardevice *parport_register_device(struct parport *port, + const char *name, + int (*pf)(void *), void (*kf)(void *), + void (*irq_func)(int, void *), + int flags, void *handle); + +/* parport_unregister unlinks a device from the chain. */ +extern void parport_unregister_device(struct pardevice *dev); + +/* parport_claim tries to gain ownership of the port for a particular + driver. This may fail (return non-zero) if another driver is busy. + If this driver has registered an interrupt handler, it will be + enabled. */ +extern int parport_claim(struct pardevice *dev); + +/* parport_claim_or_block is the same, but sleeps if the port cannot + be claimed. Return value is 1 if it slept, 0 normally and -errno + on error. */ +extern int parport_claim_or_block(struct pardevice *dev); + +/* parport_release reverses a previous parport_claim. This can never + fail, though the effects are undefined (except that they are bad) + if you didn't previously own the port. Once you have released the + port you should make sure that neither your code nor the hardware + on the port tries to initiate any communication without first + re-claiming the port. If you mess with the port state (enabling + ECP for example) you should clean up before releasing the port. */ + +extern void parport_release(struct pardevice *dev); + +/** + * parport_yield - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim(), and the return value is the same as for + * parport_claim(). If it fails, the port is left unclaimed and it is + * the driver's responsibility to reclaim the port. + * + * The parport_yield() and parport_yield_blocking() functions are for + * marking points in the driver at which other drivers may claim the + * port and use their devices. Yielding the port is similar to + * releasing it and reclaiming it, but is more efficient because no + * action is taken if there are no other devices needing the port. In + * fact, nothing is done even if there are other devices waiting but + * the current device is still within its "timeslice". The default + * timeslice is half a second, but it can be adjusted via the /proc + * interface. + **/ +static __inline__ int parport_yield(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim(dev); +} + +/** + * parport_yield_blocking - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim_or_block(), and the return value is the same as for + * parport_claim_or_block(). + **/ +static __inline__ int parport_yield_blocking(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim_or_block(dev); +} + +/* Flags used to identify what a device does. */ +#define PARPORT_DEV_TRAN 0 /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_LURK (1<<0) /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_EXCL (1<<1) /* Need exclusive access. */ + +#define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */ + +/* IEEE1284 functions */ +extern void parport_ieee1284_interrupt (int, void *); +extern int parport_negotiate (struct parport *, int mode); +extern ssize_t parport_write (struct parport *, const void *buf, size_t len); +extern ssize_t parport_read (struct parport *, void *buf, size_t len); + +#define PARPORT_INACTIVITY_O_NONBLOCK 1 +extern long parport_set_timeout (struct pardevice *, long inactivity); + +extern int parport_wait_event (struct parport *, long timeout); +extern int parport_wait_peripheral (struct parport *port, + unsigned char mask, + unsigned char val); +extern int parport_poll_peripheral (struct parport *port, + unsigned char mask, + unsigned char val, + int usec); + +/* For architectural drivers */ +extern size_t parport_ieee1284_write_compat (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_read_nibble (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_read_byte (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_epp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_addr (struct parport *, + void *, size_t, int); + +/* IEEE1284.3 functions */ +extern int parport_daisy_init (struct parport *port); +extern void parport_daisy_fini (struct parport *port); +extern struct pardevice *parport_open (int devnum, const char *name, + int (*pf) (void *), + void (*kf) (void *), + void (*irqf) (int, void *), + int flags, void *handle); +extern void parport_close (struct pardevice *dev); +extern ssize_t parport_device_id (int devnum, char *buffer, size_t len); +extern int parport_device_num (int parport, int mux, int daisy); +extern void parport_daisy_deselect_all (struct parport *port); +extern int parport_daisy_select (struct parport *port, int daisy, int mode); + +/* Lowlevel drivers _can_ call this support function to handle irqs. */ +/* +static __inline__ void parport_generic_irq(int irq, struct parport *port) +{ + parport_ieee1284_interrupt (irq, port); + read_lock(&port->cad_lock); + if (port->cad && port->cad->irq_func) + port->cad->irq_func(irq, port->cad->private); + read_unlock(&port->cad_lock); +} +*/ + +/* Prototypes from parport_procfs */ +extern int parport_proc_register(struct parport *pp); +extern int parport_proc_unregister(struct parport *pp); +extern int parport_device_proc_register(struct pardevice *device); +extern int parport_device_proc_unregister(struct pardevice *device); + +/* If PC hardware is the only type supported, we can optimise a bit. */ +#if !defined(CONFIG_PARPORT_NOT_PC) + +#include +#define parport_write_data(p,x) parport_pc_write_data(p,x) +#define parport_read_data(p) parport_pc_read_data(p) +#define parport_write_control(p,x) parport_pc_write_control(p,x) +#define parport_read_control(p) parport_pc_read_control(p) +#define parport_frob_control(p,m,v) parport_pc_frob_control(p,m,v) +#define parport_read_status(p) parport_pc_read_status(p) +#define parport_enable_irq(p) parport_pc_enable_irq(p) +#define parport_disable_irq(p) parport_pc_disable_irq(p) +#define parport_data_forward(p) parport_pc_data_forward(p) +#define parport_data_reverse(p) parport_pc_data_reverse(p) + +#else /* !CONFIG_PARPORT_NOT_PC */ + +/* Generic operations vector through the dispatch table. */ +#define parport_write_data(p,x) (p)->ops->write_data(p,x) +#define parport_read_data(p) (p)->ops->read_data(p) +#define parport_write_control(p,x) (p)->ops->write_control(p,x) +#define parport_read_control(p) (p)->ops->read_control(p) +#define parport_frob_control(p,m,v) (p)->ops->frob_control(p,m,v) +#define parport_read_status(p) (p)->ops->read_status(p) +#define parport_enable_irq(p) (p)->ops->enable_irq(p) +#define parport_disable_irq(p) (p)->ops->disable_irq(p) +#define parport_data_forward(p) (p)->ops->data_forward(p) +#define parport_data_reverse(p) (p)->ops->data_reverse(p) + +#endif /* !CONFIG_PARPORT_NOT_PC */ + +#endif /* _PARPORT_H_ */ diff --git a/ddverify/models/con1/include/linux/parport_pc.h b/ddverify/models/con1/include/linux/parport_pc.h new file mode 100644 index 000000000..1c6df907d --- /dev/null +++ b/ddverify/models/con1/include/linux/parport_pc.h @@ -0,0 +1,42 @@ +#ifndef __LINUX_PARPORT_PC_H +#define __LINUX_PARPORT_PC_H + +#include + +/* --- register definitions ------------------------------- */ + +#define ECONTROL(p) ((p)->base_hi + 0x2) +#define CONFIGB(p) ((p)->base_hi + 0x1) +#define CONFIGA(p) ((p)->base_hi + 0x0) +#define FIFO(p) ((p)->base_hi + 0x0) +#define EPPDATA(p) ((p)->base + 0x4) +#define EPPADDR(p) ((p)->base + 0x3) +#define CONTROL(p) ((p)->base + 0x2) +#define STATUS(p) ((p)->base + 0x1) +#define DATA(p) ((p)->base + 0x0) + +struct parport_pc_private { + int something; +}; + +struct parport_pc_via_data +{ + int something; +}; + +void parport_pc_write_data(struct parport *p, unsigned char d); +unsigned char parport_pc_read_data(struct parport *p); +void parport_pc_data_reverse (struct parport *p); +void parport_pc_data_forward (struct parport *p); +void parport_pc_write_control (struct parport *p, unsigned char d); +unsigned char parport_pc_read_control(struct parport *p); +unsigned char parport_pc_frob_control (struct parport *p, + unsigned char mask, + unsigned char val); +unsigned char parport_pc_read_status(struct parport *p); +void parport_pc_disable_irq(struct parport *p); +void parport_pc_enable_irq(struct parport *p); +void parport_pc_release_resources(struct parport *p); +int parport_pc_claim_resources(struct parport *p); + +#endif diff --git a/ddverify/models/con1/include/linux/pci.h b/ddverify/models/con1/include/linux/pci.h new file mode 100644 index 000000000..e2076f1a4 --- /dev/null +++ b/ddverify/models/con1/include/linux/pci.h @@ -0,0 +1,176 @@ +#ifndef LINUX_PCI_H +#define LINUX_PCI_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Include the pci register defines */ +#include + +/* Include the ID list */ +#include + +/* + * The PCI interface treats multi-function devices as independent + * devices. The slot/function address of each device is encoded + * in a single byte as follows: + * + * 7:3 = slot + * 2:0 = function + */ +#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) +#define PCI_FUNC(devfn) ((devfn) & 0x07) + +/* This defines the direction arg to the DMA mapping routines. */ +#define PCI_DMA_BIDIRECTIONAL 0 +#define PCI_DMA_TODEVICE 1 +#define PCI_DMA_FROMDEVICE 2 +#define PCI_DMA_NONE 3 + +#define DEVICE_COUNT_COMPATIBLE 4 +#define DEVICE_COUNT_RESOURCE 12 + +typedef int __bitwise pci_power_t; + + +struct pci_dev { + struct pci_bus *bus; /* bus this device is on */ + + unsigned int devfn; /* encoded device & function index */ + unsigned short vendor; + unsigned short device; + + + u64 dma_mask; + + struct device dev; + + unsigned int irq; + struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ +}; + + +#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) + +struct pci_bus { + unsigned char number; /* bus number */ +}; + + +struct pci_driver { + char *name; + const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */ + int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ + void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ + int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ + int (*resume) (struct pci_dev *dev); /* Device woken up */ + int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ + void (*shutdown) (struct pci_dev *dev); +}; + +#define PCI_DEVICE(vend,dev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID + + +// DDV: Does not need a body! Return an arbitrary integer. +int pci_dev_present(const struct pci_device_id *ids); + +// DDV: Body for this function is defined in linux/pci.c +struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); + + +/* Similar to the helpers above, these manipulate per-pci_dev + * driver-specific data. They are really just a wrapper around + * the generic device structure functions of these calls. + */ +static inline void *pci_get_drvdata (struct pci_dev *pdev) +{ + return dev_get_drvdata(&pdev->dev); +} + +static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) +{ + dev_set_drvdata(&pdev->dev, data); +} + +int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); +int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); +int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); +int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); +int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); +int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); + +static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) +{ + return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) +{ + return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) +{ + return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) +{ + return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) +{ + return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) +{ + return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); +} + +int pci_set_dma_mask(struct pci_dev *dev, u64 mask); +void pci_set_master(struct pci_dev *dev); + + +// DDV: Body for this function is defined in linux/pci.c +int pci_register_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +void pci_unregister_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +int pci_enable_device(struct pci_dev *dev); +// DDV: No body for this function +void pci_disable_device(struct pci_dev *dev); + + +#define HAVE_PCI_REQ_REGIONS 2 +// DDV: Body for this function is defined in linux/pci.c +int pci_request_regions(struct pci_dev *, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_regions(struct pci_dev *); +// DDV: Body for this function is defined in linux/pci.c +int pci_request_region(struct pci_dev *, int, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_region(struct pci_dev *, int); + + +#include + +/* these helpers provide future and backwards compatibility + * for accessing popular PCI BAR info */ +#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) +#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) +#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) +#define pci_resource_len(dev,bar) \ + ((pci_resource_start((dev),(bar)) == 0 && \ + pci_resource_end((dev),(bar)) == \ + pci_resource_start((dev),(bar))) ? 0 : \ + \ + (pci_resource_end((dev),(bar)) - \ + pci_resource_start((dev),(bar)) + 1)) + +#endif /* LINUX_PCI_H */ diff --git a/ddverify/models/con1/include/linux/pci_ids.h b/ddverify/models/con1/include/linux/pci_ids.h new file mode 100644 index 000000000..a3a09cceb --- /dev/null +++ b/ddverify/models/con1/include/linux/pci_ids.h @@ -0,0 +1,2260 @@ +/* + * PCI Class, Vendor and Device IDs + * + * Please keep sorted. + */ + +/* Device classes and subclasses */ + +#define PCI_CLASS_NOT_DEFINED 0x0000 +#define PCI_CLASS_NOT_DEFINED_VGA 0x0001 + +#define PCI_BASE_CLASS_STORAGE 0x01 +#define PCI_CLASS_STORAGE_SCSI 0x0100 +#define PCI_CLASS_STORAGE_IDE 0x0101 +#define PCI_CLASS_STORAGE_FLOPPY 0x0102 +#define PCI_CLASS_STORAGE_IPI 0x0103 +#define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SAS 0x0107 +#define PCI_CLASS_STORAGE_OTHER 0x0180 + +#define PCI_BASE_CLASS_NETWORK 0x02 +#define PCI_CLASS_NETWORK_ETHERNET 0x0200 +#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 +#define PCI_CLASS_NETWORK_FDDI 0x0202 +#define PCI_CLASS_NETWORK_ATM 0x0203 +#define PCI_CLASS_NETWORK_OTHER 0x0280 + +#define PCI_BASE_CLASS_DISPLAY 0x03 +#define PCI_CLASS_DISPLAY_VGA 0x0300 +#define PCI_CLASS_DISPLAY_XGA 0x0301 +#define PCI_CLASS_DISPLAY_3D 0x0302 +#define PCI_CLASS_DISPLAY_OTHER 0x0380 + +#define PCI_BASE_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400 +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 +#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402 +#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480 + +#define PCI_BASE_CLASS_MEMORY 0x05 +#define PCI_CLASS_MEMORY_RAM 0x0500 +#define PCI_CLASS_MEMORY_FLASH 0x0501 +#define PCI_CLASS_MEMORY_OTHER 0x0580 + +#define PCI_BASE_CLASS_BRIDGE 0x06 +#define PCI_CLASS_BRIDGE_HOST 0x0600 +#define PCI_CLASS_BRIDGE_ISA 0x0601 +#define PCI_CLASS_BRIDGE_EISA 0x0602 +#define PCI_CLASS_BRIDGE_MC 0x0603 +#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_BRIDGE_PCMCIA 0x0605 +#define PCI_CLASS_BRIDGE_NUBUS 0x0606 +#define PCI_CLASS_BRIDGE_CARDBUS 0x0607 +#define PCI_CLASS_BRIDGE_RACEWAY 0x0608 +#define PCI_CLASS_BRIDGE_OTHER 0x0680 + +#define PCI_BASE_CLASS_COMMUNICATION 0x07 +#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700 +#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701 +#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702 +#define PCI_CLASS_COMMUNICATION_MODEM 0x0703 +#define PCI_CLASS_COMMUNICATION_OTHER 0x0780 + +#define PCI_BASE_CLASS_SYSTEM 0x08 +#define PCI_CLASS_SYSTEM_PIC 0x0800 +#define PCI_CLASS_SYSTEM_PIC_IOAPIC 0x080010 +#define PCI_CLASS_SYSTEM_PIC_IOXAPIC 0x080020 +#define PCI_CLASS_SYSTEM_DMA 0x0801 +#define PCI_CLASS_SYSTEM_TIMER 0x0802 +#define PCI_CLASS_SYSTEM_RTC 0x0803 +#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804 +#define PCI_CLASS_SYSTEM_OTHER 0x0880 + +#define PCI_BASE_CLASS_INPUT 0x09 +#define PCI_CLASS_INPUT_KEYBOARD 0x0900 +#define PCI_CLASS_INPUT_PEN 0x0901 +#define PCI_CLASS_INPUT_MOUSE 0x0902 +#define PCI_CLASS_INPUT_SCANNER 0x0903 +#define PCI_CLASS_INPUT_GAMEPORT 0x0904 +#define PCI_CLASS_INPUT_OTHER 0x0980 + +#define PCI_BASE_CLASS_DOCKING 0x0a +#define PCI_CLASS_DOCKING_GENERIC 0x0a00 +#define PCI_CLASS_DOCKING_OTHER 0x0a80 + +#define PCI_BASE_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_PROCESSOR_386 0x0b00 +#define PCI_CLASS_PROCESSOR_486 0x0b01 +#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02 +#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10 +#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20 +#define PCI_CLASS_PROCESSOR_MIPS 0x0b30 +#define PCI_CLASS_PROCESSOR_CO 0x0b40 + +#define PCI_BASE_CLASS_SERIAL 0x0c +#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00 +#define PCI_CLASS_SERIAL_ACCESS 0x0c01 +#define PCI_CLASS_SERIAL_SSA 0x0c02 +#define PCI_CLASS_SERIAL_USB 0x0c03 +#define PCI_CLASS_SERIAL_USB_UHCI 0x0c0300 +#define PCI_CLASS_SERIAL_USB_OHCI 0x0c0310 +#define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320 +#define PCI_CLASS_SERIAL_FIBER 0x0c04 +#define PCI_CLASS_SERIAL_SMBUS 0x0c05 + +#define PCI_BASE_CLASS_INTELLIGENT 0x0e +#define PCI_CLASS_INTELLIGENT_I2O 0x0e00 + +#define PCI_BASE_CLASS_SATELLITE 0x0f +#define PCI_CLASS_SATELLITE_TV 0x0f00 +#define PCI_CLASS_SATELLITE_AUDIO 0x0f01 +#define PCI_CLASS_SATELLITE_VOICE 0x0f03 +#define PCI_CLASS_SATELLITE_DATA 0x0f04 + +#define PCI_BASE_CLASS_CRYPT 0x10 +#define PCI_CLASS_CRYPT_NETWORK 0x1000 +#define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001 +#define PCI_CLASS_CRYPT_OTHER 0x1080 + +#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11 +#define PCI_CLASS_SP_DPIO 0x1100 +#define PCI_CLASS_SP_OTHER 0x1180 + +#define PCI_CLASS_OTHERS 0xff + +/* Vendors and devices. Sort key: vendor first, device next. */ + +#define PCI_VENDOR_ID_DYNALINK 0x0675 +#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702 + +#define PCI_VENDOR_ID_BERKOM 0x0871 +#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1 +#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2 +#define PCI_DEVICE_ID_BERKOM_A4T 0xffa4 +#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xffa8 + +#define PCI_VENDOR_ID_COMPAQ 0x0e11 +#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508 +#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc +#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10 +#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32 +#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34 +#define PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE 0xae33 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35 +#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40 +#define PCI_DEVICE_ID_COMPAQ_NETEL100PI 0xae43 +#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011 +#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060 +#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178 +#define PCI_DEVICE_ID_COMPAQ_CISSC 0x46 +#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150 + +#define PCI_VENDOR_ID_NCR 0x1000 +#define PCI_VENDOR_ID_LSI_LOGIC 0x1000 +#define PCI_DEVICE_ID_NCR_53C810 0x0001 +#define PCI_DEVICE_ID_NCR_53C820 0x0002 +#define PCI_DEVICE_ID_NCR_53C825 0x0003 +#define PCI_DEVICE_ID_NCR_53C815 0x0004 +#define PCI_DEVICE_ID_LSI_53C810AP 0x0005 +#define PCI_DEVICE_ID_NCR_53C860 0x0006 +#define PCI_DEVICE_ID_LSI_53C1510 0x000a +#define PCI_DEVICE_ID_NCR_53C896 0x000b +#define PCI_DEVICE_ID_NCR_53C895 0x000c +#define PCI_DEVICE_ID_NCR_53C885 0x000d +#define PCI_DEVICE_ID_NCR_53C875 0x000f +#define PCI_DEVICE_ID_NCR_53C1510 0x0010 +#define PCI_DEVICE_ID_LSI_53C895A 0x0012 +#define PCI_DEVICE_ID_LSI_53C875A 0x0013 +#define PCI_DEVICE_ID_LSI_53C1010_33 0x0020 +#define PCI_DEVICE_ID_LSI_53C1010_66 0x0021 +#define PCI_DEVICE_ID_LSI_53C1030 0x0030 +#define PCI_DEVICE_ID_LSI_1030_53C1035 0x0032 +#define PCI_DEVICE_ID_LSI_53C1035 0x0040 +#define PCI_DEVICE_ID_NCR_53C875J 0x008f +#define PCI_DEVICE_ID_LSI_FC909 0x0621 +#define PCI_DEVICE_ID_LSI_FC929 0x0622 +#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623 +#define PCI_DEVICE_ID_LSI_FC919 0x0624 +#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625 +#define PCI_DEVICE_ID_LSI_FC929X 0x0626 +#define PCI_DEVICE_ID_LSI_FC939X 0x0642 +#define PCI_DEVICE_ID_LSI_FC949X 0x0640 +#define PCI_DEVICE_ID_LSI_FC949ES 0x0646 +#define PCI_DEVICE_ID_LSI_FC919X 0x0628 +#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701 +#define PCI_DEVICE_ID_LSI_61C102 0x0901 +#define PCI_DEVICE_ID_LSI_63C815 0x1000 +#define PCI_DEVICE_ID_LSI_SAS1064 0x0050 +#define PCI_DEVICE_ID_LSI_SAS1064R 0x0411 +#define PCI_DEVICE_ID_LSI_SAS1066 0x005E +#define PCI_DEVICE_ID_LSI_SAS1068 0x0054 +#define PCI_DEVICE_ID_LSI_SAS1064A 0x005C +#define PCI_DEVICE_ID_LSI_SAS1064E 0x0056 +#define PCI_DEVICE_ID_LSI_SAS1066E 0x005A +#define PCI_DEVICE_ID_LSI_SAS1068E 0x0058 +#define PCI_DEVICE_ID_LSI_SAS1078 0x0060 + +#define PCI_VENDOR_ID_ATI 0x1002 +/* Mach64 */ +#define PCI_DEVICE_ID_ATI_68800 0x4158 +#define PCI_DEVICE_ID_ATI_215CT222 0x4354 +#define PCI_DEVICE_ID_ATI_210888CX 0x4358 +#define PCI_DEVICE_ID_ATI_215ET222 0x4554 +/* Mach64 / Rage */ +#define PCI_DEVICE_ID_ATI_215GB 0x4742 +#define PCI_DEVICE_ID_ATI_215GD 0x4744 +#define PCI_DEVICE_ID_ATI_215GI 0x4749 +#define PCI_DEVICE_ID_ATI_215GP 0x4750 +#define PCI_DEVICE_ID_ATI_215GQ 0x4751 +#define PCI_DEVICE_ID_ATI_215XL 0x4752 +#define PCI_DEVICE_ID_ATI_215GT 0x4754 +#define PCI_DEVICE_ID_ATI_215GTB 0x4755 +#define PCI_DEVICE_ID_ATI_215_IV 0x4756 +#define PCI_DEVICE_ID_ATI_215_IW 0x4757 +#define PCI_DEVICE_ID_ATI_215_IZ 0x475A +#define PCI_DEVICE_ID_ATI_210888GX 0x4758 +#define PCI_DEVICE_ID_ATI_215_LB 0x4c42 +#define PCI_DEVICE_ID_ATI_215_LD 0x4c44 +#define PCI_DEVICE_ID_ATI_215_LG 0x4c47 +#define PCI_DEVICE_ID_ATI_215_LI 0x4c49 +#define PCI_DEVICE_ID_ATI_215_LM 0x4c4D +#define PCI_DEVICE_ID_ATI_215_LN 0x4c4E +#define PCI_DEVICE_ID_ATI_215_LR 0x4c52 +#define PCI_DEVICE_ID_ATI_215_LS 0x4c53 +#define PCI_DEVICE_ID_ATI_264_LT 0x4c54 +/* Mach64 VT */ +#define PCI_DEVICE_ID_ATI_264VT 0x5654 +#define PCI_DEVICE_ID_ATI_264VU 0x5655 +#define PCI_DEVICE_ID_ATI_264VV 0x5656 +/* Rage128 GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245 +#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246 +#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x5247 +/* Rage128 VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b +#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c +#define PCI_DEVICE_ID_ATI_RAGE128_SE 0x5345 +#define PCI_DEVICE_ID_ATI_RAGE128_SF 0x5346 +#define PCI_DEVICE_ID_ATI_RAGE128_SG 0x5347 +#define PCI_DEVICE_ID_ATI_RAGE128_SH 0x5348 +#define PCI_DEVICE_ID_ATI_RAGE128_SK 0x534b +#define PCI_DEVICE_ID_ATI_RAGE128_SL 0x534c +#define PCI_DEVICE_ID_ATI_RAGE128_SM 0x534d +#define PCI_DEVICE_ID_ATI_RAGE128_SN 0x534e +/* Rage128 Ultra */ +#define PCI_DEVICE_ID_ATI_RAGE128_TF 0x5446 +#define PCI_DEVICE_ID_ATI_RAGE128_TL 0x544c +#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452 +#define PCI_DEVICE_ID_ATI_RAGE128_TS 0x5453 +#define PCI_DEVICE_ID_ATI_RAGE128_TT 0x5454 +#define PCI_DEVICE_ID_ATI_RAGE128_TU 0x5455 +/* Rage128 M3 */ +#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45 +#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46 +/* Rage128 M4 */ +#define PCI_DEVICE_ID_ATI_RAGE128_MF 0x4d46 +#define PCI_DEVICE_ID_ATI_RAGE128_ML 0x4d4c +/* Rage128 Pro GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_PA 0x5041 +#define PCI_DEVICE_ID_ATI_RAGE128_PB 0x5042 +#define PCI_DEVICE_ID_ATI_RAGE128_PC 0x5043 +#define PCI_DEVICE_ID_ATI_RAGE128_PD 0x5044 +#define PCI_DEVICE_ID_ATI_RAGE128_PE 0x5045 +#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046 +/* Rage128 Pro VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047 +#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048 +#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049 +#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A +#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B +#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C +#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D +#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E +#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F +#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050 +#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051 +#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052 +#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053 +#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054 +#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055 +#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056 +#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057 +#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058 +/* Rage128 M4 */ +/* Radeon R100 */ +#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144 +#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145 +#define PCI_DEVICE_ID_ATI_RADEON_QF 0x5146 +#define PCI_DEVICE_ID_ATI_RADEON_QG 0x5147 +/* Radeon RV100 (VE) */ +#define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 +#define PCI_DEVICE_ID_ATI_RADEON_QZ 0x515a +/* Radeon R200 (8500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QL 0x514c +#define PCI_DEVICE_ID_ATI_RADEON_QN 0x514e +#define PCI_DEVICE_ID_ATI_RADEON_QO 0x514f +#define PCI_DEVICE_ID_ATI_RADEON_Ql 0x516c +#define PCI_DEVICE_ID_ATI_RADEON_BB 0x4242 +/* Radeon R200 (9100) */ +#define PCI_DEVICE_ID_ATI_RADEON_QM 0x514d +/* Radeon RV200 (7500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157 +#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158 +/* Radeon NV-100 */ +/* Radeon RV250 (9000) */ +#define PCI_DEVICE_ID_ATI_RADEON_Id 0x4964 +#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965 +#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966 +#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967 +/* Radeon RV280 (9200) */ +#define PCI_DEVICE_ID_ATI_RADEON_Ya 0x5961 +#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964 +/* Radeon R300 (9500) */ +/* Radeon R300 (9700) */ +#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44 +#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45 +#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46 +#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47 +/* Radeon R350 (9800) */ +/* Radeon RV350 (9600) */ +/* Radeon M6 */ +#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59 +#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a +/* Radeon M7 */ +#define PCI_DEVICE_ID_ATI_RADEON_LW 0x4c57 +#define PCI_DEVICE_ID_ATI_RADEON_LX 0x4c58 +/* Radeon M9 */ +#define PCI_DEVICE_ID_ATI_RADEON_Ld 0x4c64 +#define PCI_DEVICE_ID_ATI_RADEON_Le 0x4c65 +#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66 +#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67 +/* Radeon */ +/* RadeonIGP */ +#define PCI_DEVICE_ID_ATI_RS100 0xcab0 +#define PCI_DEVICE_ID_ATI_RS200 0xcab2 +#define PCI_DEVICE_ID_ATI_RS200_B 0xcbb2 +#define PCI_DEVICE_ID_ATI_RS250 0xcab3 +#define PCI_DEVICE_ID_ATI_RS300_100 0x5830 +#define PCI_DEVICE_ID_ATI_RS300_133 0x5831 +#define PCI_DEVICE_ID_ATI_RS300_166 0x5832 +#define PCI_DEVICE_ID_ATI_RS300_200 0x5833 +#define PCI_DEVICE_ID_ATI_RS350_100 0x7830 +#define PCI_DEVICE_ID_ATI_RS350_133 0x7831 +#define PCI_DEVICE_ID_ATI_RS350_166 0x7832 +#define PCI_DEVICE_ID_ATI_RS350_200 0x7833 +#define PCI_DEVICE_ID_ATI_RS400_100 0x5a30 +#define PCI_DEVICE_ID_ATI_RS400_133 0x5a31 +#define PCI_DEVICE_ID_ATI_RS400_166 0x5a32 +#define PCI_DEVICE_ID_ATI_RS400_200 0x5a33 +#define PCI_DEVICE_ID_ATI_RS480 0x5950 +/* ATI IXP Chipset */ +#define PCI_DEVICE_ID_ATI_IXP200_IDE 0x4349 +#define PCI_DEVICE_ID_ATI_IXP300_IDE 0x4369 +#define PCI_DEVICE_ID_ATI_IXP300_SATA 0x436e +#define PCI_DEVICE_ID_ATI_IXP400_IDE 0x4376 +#define PCI_DEVICE_ID_ATI_IXP400_SATA 0x4379 + +#define PCI_VENDOR_ID_VLSI 0x1004 +#define PCI_DEVICE_ID_VLSI_82C592 0x0005 +#define PCI_DEVICE_ID_VLSI_82C593 0x0006 +#define PCI_DEVICE_ID_VLSI_82C594 0x0007 +#define PCI_DEVICE_ID_VLSI_82C597 0x0009 +#define PCI_DEVICE_ID_VLSI_82C541 0x000c +#define PCI_DEVICE_ID_VLSI_82C543 0x000d +#define PCI_DEVICE_ID_VLSI_82C532 0x0101 +#define PCI_DEVICE_ID_VLSI_82C534 0x0102 +#define PCI_DEVICE_ID_VLSI_82C535 0x0104 +#define PCI_DEVICE_ID_VLSI_82C147 0x0105 +#define PCI_DEVICE_ID_VLSI_VAS96011 0x0702 + +#define PCI_VENDOR_ID_ADL 0x1005 +#define PCI_DEVICE_ID_ADL_2301 0x2301 + +#define PCI_VENDOR_ID_NS 0x100b +#define PCI_DEVICE_ID_NS_87415 0x0002 +#define PCI_DEVICE_ID_NS_87560_LIO 0x000e +#define PCI_DEVICE_ID_NS_87560_USB 0x0012 +#define PCI_DEVICE_ID_NS_83815 0x0020 +#define PCI_DEVICE_ID_NS_83820 0x0022 +#define PCI_DEVICE_ID_NS_CS5535_ISA 0x002b +#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d +#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e +#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f +#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 +#define PCI_DEVICE_ID_NS_SATURN 0x0035 +#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 +#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 +#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502 +#define PCI_DEVICE_ID_NS_SCx200_AUDIO 0x0503 +#define PCI_DEVICE_ID_NS_SCx200_VIDEO 0x0504 +#define PCI_DEVICE_ID_NS_SCx200_XBUS 0x0505 +#define PCI_DEVICE_ID_NS_SC1100_BRIDGE 0x0510 +#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511 +#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 +#define PCI_DEVICE_ID_NS_87410 0xd001 + +#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 +#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b + +#define PCI_VENDOR_ID_TSENG 0x100c +#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 +#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205 +#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206 +#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207 +#define PCI_DEVICE_ID_TSENG_ET6000 0x3208 + +#define PCI_VENDOR_ID_WEITEK 0x100e +#define PCI_DEVICE_ID_WEITEK_P9000 0x9001 +#define PCI_DEVICE_ID_WEITEK_P9100 0x9100 + +#define PCI_VENDOR_ID_DEC 0x1011 +#define PCI_DEVICE_ID_DEC_BRD 0x0001 +#define PCI_DEVICE_ID_DEC_TULIP 0x0002 +#define PCI_DEVICE_ID_DEC_TGA 0x0004 +#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009 +#define PCI_DEVICE_ID_DEC_TGA2 0x000D +#define PCI_DEVICE_ID_DEC_FDDI 0x000F +#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014 +#define PCI_DEVICE_ID_DEC_21142 0x0019 +#define PCI_DEVICE_ID_DEC_21052 0x0021 +#define PCI_DEVICE_ID_DEC_21150 0x0022 +#define PCI_DEVICE_ID_DEC_21152 0x0024 +#define PCI_DEVICE_ID_DEC_21153 0x0025 +#define PCI_DEVICE_ID_DEC_21154 0x0026 +#define PCI_DEVICE_ID_DEC_21285 0x1065 +#define PCI_DEVICE_ID_COMPAQ_42XX 0x0046 + +#define PCI_VENDOR_ID_CIRRUS 0x1013 +#define PCI_DEVICE_ID_CIRRUS_7548 0x0038 +#define PCI_DEVICE_ID_CIRRUS_5430 0x00a0 +#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00a4 +#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00a8 +#define PCI_DEVICE_ID_CIRRUS_5436 0x00ac +#define PCI_DEVICE_ID_CIRRUS_5446 0x00b8 +#define PCI_DEVICE_ID_CIRRUS_5480 0x00bc +#define PCI_DEVICE_ID_CIRRUS_5462 0x00d0 +#define PCI_DEVICE_ID_CIRRUS_5464 0x00d4 +#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6 +#define PCI_DEVICE_ID_CIRRUS_6729 0x1100 +#define PCI_DEVICE_ID_CIRRUS_6832 0x1110 +#define PCI_DEVICE_ID_CIRRUS_7543 0x1202 +#define PCI_DEVICE_ID_CIRRUS_4610 0x6001 +#define PCI_DEVICE_ID_CIRRUS_4612 0x6003 +#define PCI_DEVICE_ID_CIRRUS_4615 0x6004 + +#define PCI_VENDOR_ID_IBM 0x1014 +#define PCI_DEVICE_ID_IBM_TR 0x0018 +#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e +#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc +#define PCI_DEVICE_ID_IBM_SNIPE 0x0180 +#define PCI_DEVICE_ID_IBM_CITRINE 0x028C +#define PCI_DEVICE_ID_IBM_GEMSTONE 0xB166 +#define PCI_DEVICE_ID_IBM_OBSIDIAN 0x02BD +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1 0x0031 +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2 0x0219 +#define PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX 0x021A +#define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251 +#define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252 + +#define PCI_VENDOR_ID_COMPEX2 0x101a /* pci.ids says "AT&T GIS (NCR)" */ +#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005 + +#define PCI_VENDOR_ID_WD 0x101c +#define PCI_DEVICE_ID_WD_90C 0xc24a + +#define PCI_VENDOR_ID_AMI 0x101e +#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960 +#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010 +#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060 + +#define PCI_VENDOR_ID_AMD 0x1022 +#define PCI_DEVICE_ID_AMD_K8_NB 0x1100 +#define PCI_DEVICE_ID_AMD_LANCE 0x2000 +#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001 +#define PCI_DEVICE_ID_AMD_SCSI 0x2020 +#define PCI_DEVICE_ID_AMD_SERENADE 0x36c0 +#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006 +#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007 +#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C +#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E +#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401 +#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409 +#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B +#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410 +#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411 +#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413 +#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440 +#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441 +#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443 +#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443 +#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445 +#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468 +#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469 +#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a +#define PCI_DEVICE_ID_AMD_8111_SMBUS 0x746b +#define PCI_DEVICE_ID_AMD_8111_AUDIO 0x746d +#define PCI_DEVICE_ID_AMD_8151_0 0x7454 +#define PCI_DEVICE_ID_AMD_8131_APIC 0x7450 +#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090 +#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091 +#define PCI_DEVICE_ID_AMD_CS5536_AUDIO 0x2093 +#define PCI_DEVICE_ID_AMD_CS5536_OHC 0x2094 +#define PCI_DEVICE_ID_AMD_CS5536_EHC 0x2095 +#define PCI_DEVICE_ID_AMD_CS5536_UDC 0x2096 +#define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097 +#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A + +#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 +#define PCI_DEVICE_ID_AMD_LX_AES 0x2082 + +#define PCI_VENDOR_ID_TRIDENT 0x1023 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001 +#define PCI_DEVICE_ID_TRIDENT_9320 0x9320 +#define PCI_DEVICE_ID_TRIDENT_9388 0x9388 +#define PCI_DEVICE_ID_TRIDENT_9397 0x9397 +#define PCI_DEVICE_ID_TRIDENT_939A 0x939A +#define PCI_DEVICE_ID_TRIDENT_9520 0x9520 +#define PCI_DEVICE_ID_TRIDENT_9525 0x9525 +#define PCI_DEVICE_ID_TRIDENT_9420 0x9420 +#define PCI_DEVICE_ID_TRIDENT_9440 0x9440 +#define PCI_DEVICE_ID_TRIDENT_9660 0x9660 +#define PCI_DEVICE_ID_TRIDENT_9750 0x9750 +#define PCI_DEVICE_ID_TRIDENT_9850 0x9850 +#define PCI_DEVICE_ID_TRIDENT_9880 0x9880 +#define PCI_DEVICE_ID_TRIDENT_8400 0x8400 +#define PCI_DEVICE_ID_TRIDENT_8420 0x8420 +#define PCI_DEVICE_ID_TRIDENT_8500 0x8500 + +#define PCI_VENDOR_ID_AI 0x1025 +#define PCI_DEVICE_ID_AI_M1435 0x1435 + +#define PCI_VENDOR_ID_DELL 0x1028 +#define PCI_DEVICE_ID_DELL_RACIII 0x0008 +#define PCI_DEVICE_ID_DELL_RAC4 0x0012 +#define PCI_DEVICE_ID_DELL_PERC5 0x0015 + +#define PCI_VENDOR_ID_MATROX 0x102B +#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518 +#define PCI_DEVICE_ID_MATROX_MIL 0x0519 +#define PCI_DEVICE_ID_MATROX_MYS 0x051A +#define PCI_DEVICE_ID_MATROX_MIL_2 0x051b +#define PCI_DEVICE_ID_MATROX_MYS_AGP 0x051e +#define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f +#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10 +#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000 +#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001 +#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 +#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 +#define PCI_DEVICE_ID_MATROX_G400 0x0525 +#define PCI_DEVICE_ID_MATROX_G550 0x2527 +#define PCI_DEVICE_ID_MATROX_VIA 0x4536 + +#define PCI_VENDOR_ID_CT 0x102c +#define PCI_DEVICE_ID_CT_69000 0x00c0 +#define PCI_DEVICE_ID_CT_65545 0x00d8 +#define PCI_DEVICE_ID_CT_65548 0x00dc +#define PCI_DEVICE_ID_CT_65550 0x00e0 +#define PCI_DEVICE_ID_CT_65554 0x00e4 +#define PCI_DEVICE_ID_CT_65555 0x00e5 + +#define PCI_VENDOR_ID_MIRO 0x1031 +#define PCI_DEVICE_ID_MIRO_36050 0x5601 +#define PCI_DEVICE_ID_MIRO_DC10PLUS 0x7efe +#define PCI_DEVICE_ID_MIRO_DC30PLUS 0xd801 + +#define PCI_VENDOR_ID_NEC 0x1033 +#define PCI_DEVICE_ID_NEC_CBUS_1 0x0001 /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_LOCAL 0x0002 /* Local Bridge */ +#define PCI_DEVICE_ID_NEC_ATM 0x0003 /* ATM LAN Controller */ +#define PCI_DEVICE_ID_NEC_R4000 0x0004 /* R4000 Bridge */ +#define PCI_DEVICE_ID_NEC_486 0x0005 /* 486 Like Peripheral Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_1 0x0006 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_UXBUS 0x0007 /* UX-Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_2 0x0008 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_GRAPH 0x0009 /* PCI-CoreGraph Bridge */ +#define PCI_DEVICE_ID_NEC_VL 0x0016 /* PCI-VL Bridge */ +#define PCI_DEVICE_ID_NEC_STARALPHA2 0x002c /* STAR ALPHA2 */ +#define PCI_DEVICE_ID_NEC_CBUS_2 0x002d /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_USB 0x0035 /* PCI-USB Host */ +#define PCI_DEVICE_ID_NEC_CBUS_3 0x003b +#define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e +#define PCI_DEVICE_ID_NEC_PCX2 0x0046 /* PowerVR */ +#define PCI_DEVICE_ID_NEC_NILE4 0x005a +#define PCI_DEVICE_ID_NEC_VRC5476 0x009b +#define PCI_DEVICE_ID_NEC_VRC4173 0x00a5 +#define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6 +#define PCI_DEVICE_ID_NEC_PC9821CS01 0x800c /* PC-9821-CS01 */ +#define PCI_DEVICE_ID_NEC_PC9821NRB06 0x800d /* PC-9821NR-B06 */ + +#define PCI_VENDOR_ID_FD 0x1036 +#define PCI_DEVICE_ID_FD_36C70 0x0000 + +#define PCI_VENDOR_ID_SI 0x1039 +#define PCI_DEVICE_ID_SI_5591_AGP 0x0001 +#define PCI_DEVICE_ID_SI_6202 0x0002 +#define PCI_DEVICE_ID_SI_503 0x0008 +#define PCI_DEVICE_ID_SI_ACPI 0x0009 +#define PCI_DEVICE_ID_SI_SMBUS 0x0016 +#define PCI_DEVICE_ID_SI_LPC 0x0018 +#define PCI_DEVICE_ID_SI_5597_VGA 0x0200 +#define PCI_DEVICE_ID_SI_6205 0x0205 +#define PCI_DEVICE_ID_SI_501 0x0406 +#define PCI_DEVICE_ID_SI_496 0x0496 +#define PCI_DEVICE_ID_SI_300 0x0300 +#define PCI_DEVICE_ID_SI_315H 0x0310 +#define PCI_DEVICE_ID_SI_315 0x0315 +#define PCI_DEVICE_ID_SI_315PRO 0x0325 +#define PCI_DEVICE_ID_SI_530 0x0530 +#define PCI_DEVICE_ID_SI_540 0x0540 +#define PCI_DEVICE_ID_SI_550 0x0550 +#define PCI_DEVICE_ID_SI_540_VGA 0x5300 +#define PCI_DEVICE_ID_SI_550_VGA 0x5315 +#define PCI_DEVICE_ID_SI_620 0x0620 +#define PCI_DEVICE_ID_SI_630 0x0630 +#define PCI_DEVICE_ID_SI_633 0x0633 +#define PCI_DEVICE_ID_SI_635 0x0635 +#define PCI_DEVICE_ID_SI_640 0x0640 +#define PCI_DEVICE_ID_SI_645 0x0645 +#define PCI_DEVICE_ID_SI_646 0x0646 +#define PCI_DEVICE_ID_SI_648 0x0648 +#define PCI_DEVICE_ID_SI_650 0x0650 +#define PCI_DEVICE_ID_SI_651 0x0651 +#define PCI_DEVICE_ID_SI_655 0x0655 +#define PCI_DEVICE_ID_SI_661 0x0661 +#define PCI_DEVICE_ID_SI_730 0x0730 +#define PCI_DEVICE_ID_SI_733 0x0733 +#define PCI_DEVICE_ID_SI_630_VGA 0x6300 +#define PCI_DEVICE_ID_SI_735 0x0735 +#define PCI_DEVICE_ID_SI_740 0x0740 +#define PCI_DEVICE_ID_SI_741 0x0741 +#define PCI_DEVICE_ID_SI_745 0x0745 +#define PCI_DEVICE_ID_SI_746 0x0746 +#define PCI_DEVICE_ID_SI_755 0x0755 +#define PCI_DEVICE_ID_SI_760 0x0760 +#define PCI_DEVICE_ID_SI_900 0x0900 +#define PCI_DEVICE_ID_SI_961 0x0961 +#define PCI_DEVICE_ID_SI_962 0x0962 +#define PCI_DEVICE_ID_SI_963 0x0963 +#define PCI_DEVICE_ID_SI_965 0x0965 +#define PCI_DEVICE_ID_SI_5511 0x5511 +#define PCI_DEVICE_ID_SI_5513 0x5513 +#define PCI_DEVICE_ID_SI_5518 0x5518 +#define PCI_DEVICE_ID_SI_5571 0x5571 +#define PCI_DEVICE_ID_SI_5581 0x5581 +#define PCI_DEVICE_ID_SI_5582 0x5582 +#define PCI_DEVICE_ID_SI_5591 0x5591 +#define PCI_DEVICE_ID_SI_5596 0x5596 +#define PCI_DEVICE_ID_SI_5597 0x5597 +#define PCI_DEVICE_ID_SI_5598 0x5598 +#define PCI_DEVICE_ID_SI_5600 0x5600 +#define PCI_DEVICE_ID_SI_7012 0x7012 +#define PCI_DEVICE_ID_SI_7013 0x7013 +#define PCI_DEVICE_ID_SI_7016 0x7016 +#define PCI_DEVICE_ID_SI_7018 0x7018 + +#define PCI_VENDOR_ID_HP 0x103c +#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX6 0x1006 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX4 0x1008 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX2 0x100a +#define PCI_DEVICE_ID_HP_TACHYON 0x1028 +#define PCI_DEVICE_ID_HP_TACHLITE 0x1029 +#define PCI_DEVICE_ID_HP_J2585A 0x1030 +#define PCI_DEVICE_ID_HP_J2585B 0x1031 +#define PCI_DEVICE_ID_HP_J2973A 0x1040 +#define PCI_DEVICE_ID_HP_J2970A 0x1042 +#define PCI_DEVICE_ID_HP_DIVA 0x1048 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA1 0x1049 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA2 0x104A +#define PCI_DEVICE_ID_HP_DIVA_MAESTRO 0x104B +#define PCI_DEVICE_ID_HP_REO_IOC 0x10f1 +#define PCI_DEVICE_ID_HP_VISUALIZE_FXE 0x108b +#define PCI_DEVICE_ID_HP_DIVA_HALFDOME 0x1223 +#define PCI_DEVICE_ID_HP_DIVA_KEYSTONE 0x1226 +#define PCI_DEVICE_ID_HP_DIVA_POWERBAR 0x1227 +#define PCI_DEVICE_ID_HP_ZX1_IOC 0x122a +#define PCI_DEVICE_ID_HP_PCIX_LBA 0x122e +#define PCI_DEVICE_ID_HP_SX1000_IOC 0x127c +#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282 +#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 +#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 +#define PCI_DEVICE_ID_HP_DIVA_HURRICANE 0x132a +#define PCI_DEVICE_ID_HP_CISSA 0x3220 +#define PCI_DEVICE_ID_HP_CISSC 0x3230 +#define PCI_DEVICE_ID_HP_CISSD 0x3238 +#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 + +#define PCI_VENDOR_ID_PCTECH 0x1042 +#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000 +#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001 +#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020 + +#define PCI_VENDOR_ID_ASUSTEK 0x1043 +#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675 + +#define PCI_VENDOR_ID_DPT 0x1044 +#define PCI_DEVICE_ID_DPT 0xa400 + +#define PCI_VENDOR_ID_OPTI 0x1045 +#define PCI_DEVICE_ID_OPTI_82C558 0xc558 +#define PCI_DEVICE_ID_OPTI_82C621 0xc621 +#define PCI_DEVICE_ID_OPTI_82C700 0xc700 +#define PCI_DEVICE_ID_OPTI_82C825 0xd568 + +#define PCI_VENDOR_ID_ELSA 0x1048 +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000 +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000 + + +#define PCI_VENDOR_ID_BUSLOGIC 0x104B +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140 +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040 +#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130 + +#define PCI_VENDOR_ID_TI 0x104c +#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 +#define PCI_DEVICE_ID_TI_4450 0x8011 +#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 +#define PCI_DEVICE_ID_TI_X515 0x8036 +#define PCI_DEVICE_ID_TI_1130 0xac12 +#define PCI_DEVICE_ID_TI_1031 0xac13 +#define PCI_DEVICE_ID_TI_1131 0xac15 +#define PCI_DEVICE_ID_TI_1250 0xac16 +#define PCI_DEVICE_ID_TI_1220 0xac17 +#define PCI_DEVICE_ID_TI_1221 0xac19 +#define PCI_DEVICE_ID_TI_1210 0xac1a +#define PCI_DEVICE_ID_TI_1450 0xac1b +#define PCI_DEVICE_ID_TI_1225 0xac1c +#define PCI_DEVICE_ID_TI_1251A 0xac1d +#define PCI_DEVICE_ID_TI_1211 0xac1e +#define PCI_DEVICE_ID_TI_1251B 0xac1f +#define PCI_DEVICE_ID_TI_4410 0xac41 +#define PCI_DEVICE_ID_TI_4451 0xac42 +#define PCI_DEVICE_ID_TI_4510 0xac44 +#define PCI_DEVICE_ID_TI_4520 0xac46 +#define PCI_DEVICE_ID_TI_7510 0xac47 +#define PCI_DEVICE_ID_TI_7610 0xac48 +#define PCI_DEVICE_ID_TI_7410 0xac49 +#define PCI_DEVICE_ID_TI_1410 0xac50 +#define PCI_DEVICE_ID_TI_1420 0xac51 +#define PCI_DEVICE_ID_TI_1451A 0xac52 +#define PCI_DEVICE_ID_TI_1620 0xac54 +#define PCI_DEVICE_ID_TI_1520 0xac55 +#define PCI_DEVICE_ID_TI_1510 0xac56 +#define PCI_DEVICE_ID_TI_X620 0xac8d +#define PCI_DEVICE_ID_TI_X420 0xac8e + +#define PCI_VENDOR_ID_SONY 0x104d + + +/* Winbond have two vendor IDs! See 0x10ad as well */ +#define PCI_VENDOR_ID_WINBOND2 0x1050 +#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a +#define PCI_DEVICE_ID_WINBOND2_6692 0x6692 + +#define PCI_VENDOR_ID_ANIGMA 0x1051 +#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100 + +#define PCI_VENDOR_ID_EFAR 0x1055 +#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130 +#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463 + +#define PCI_VENDOR_ID_MOTOROLA 0x1057 +#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001 +#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 +#define PCI_DEVICE_ID_MOTOROLA_MPC107 0x0004 +#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801 +#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802 +#define PCI_DEVICE_ID_MOTOROLA_HAWK 0x4803 +#define PCI_DEVICE_ID_MOTOROLA_HARRIER 0x480b +#define PCI_DEVICE_ID_MOTOROLA_MPC5200 0x5803 + +#define PCI_VENDOR_ID_PROMISE 0x105a +#define PCI_DEVICE_ID_PROMISE_20265 0x0d30 +#define PCI_DEVICE_ID_PROMISE_20267 0x4d30 +#define PCI_DEVICE_ID_PROMISE_20246 0x4d33 +#define PCI_DEVICE_ID_PROMISE_20262 0x4d38 +#define PCI_DEVICE_ID_PROMISE_20263 0x0D38 +#define PCI_DEVICE_ID_PROMISE_20268 0x4d68 +#define PCI_DEVICE_ID_PROMISE_20269 0x4d69 +#define PCI_DEVICE_ID_PROMISE_20270 0x6268 +#define PCI_DEVICE_ID_PROMISE_20271 0x6269 +#define PCI_DEVICE_ID_PROMISE_20275 0x1275 +#define PCI_DEVICE_ID_PROMISE_20276 0x5275 +#define PCI_DEVICE_ID_PROMISE_20277 0x7275 + + +#define PCI_VENDOR_ID_UMC 0x1060 +#define PCI_DEVICE_ID_UMC_UM8673F 0x0101 +#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a +#define PCI_DEVICE_ID_UMC_UM8886A 0x886a + + +#define PCI_VENDOR_ID_MYLEX 0x1069 +#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001 +#define PCI_DEVICE_ID_MYLEX_DAC960_PD 0x0002 +#define PCI_DEVICE_ID_MYLEX_DAC960_PG 0x0010 +#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020 +#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050 +#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56 +#define PCI_DEVICE_ID_MYLEX_DAC960_GEM 0xB166 + + +#define PCI_VENDOR_ID_APPLE 0x106b +#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001 +#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e +#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d +#define PCI_DEVICE_ID_APPLE_UNI_N_PCI15 0x002e +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032 +#define PCI_DEVICE_ID_APPLE_UNI_N_ATA 0x0033 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034 +#define PCI_DEVICE_ID_APPLE_IPID_ATA100 0x003b +#define PCI_DEVICE_ID_APPLE_K2_ATA100 0x0043 +#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b +#define PCI_DEVICE_ID_APPLE_K2_GMAC 0x004c +#define PCI_DEVICE_ID_APPLE_SH_ATA 0x0050 +#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051 +#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058 +#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059 +#define PCI_DEVICE_ID_APPLE_IPID2_AGP 0x0066 +#define PCI_DEVICE_ID_APPLE_IPID2_ATA 0x0069 +#define PCI_DEVICE_ID_APPLE_IPID2_FW 0x006a +#define PCI_DEVICE_ID_APPLE_IPID2_GMAC 0x006b +#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645 + +#define PCI_VENDOR_ID_YAMAHA 0x1073 +#define PCI_DEVICE_ID_YAMAHA_724 0x0004 +#define PCI_DEVICE_ID_YAMAHA_724F 0x000d +#define PCI_DEVICE_ID_YAMAHA_740 0x000a +#define PCI_DEVICE_ID_YAMAHA_740C 0x000c +#define PCI_DEVICE_ID_YAMAHA_744 0x0010 +#define PCI_DEVICE_ID_YAMAHA_754 0x0012 + + +#define PCI_VENDOR_ID_QLOGIC 0x1077 +#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020 +#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100 +#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200 +#define PCI_DEVICE_ID_QLOGIC_ISP2300 0x2300 +#define PCI_DEVICE_ID_QLOGIC_ISP2312 0x2312 +#define PCI_DEVICE_ID_QLOGIC_ISP2322 0x2322 +#define PCI_DEVICE_ID_QLOGIC_ISP6312 0x6312 +#define PCI_DEVICE_ID_QLOGIC_ISP6322 0x6322 +#define PCI_DEVICE_ID_QLOGIC_ISP2422 0x2422 +#define PCI_DEVICE_ID_QLOGIC_ISP2432 0x2432 +#define PCI_DEVICE_ID_QLOGIC_ISP2512 0x2512 +#define PCI_DEVICE_ID_QLOGIC_ISP2522 0x2522 + +#define PCI_VENDOR_ID_CYRIX 0x1078 +#define PCI_DEVICE_ID_CYRIX_5510 0x0000 +#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001 +#define PCI_DEVICE_ID_CYRIX_5520 0x0002 +#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100 +#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102 +#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103 +#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104 + + + +#define PCI_VENDOR_ID_CONTAQ 0x1080 +#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693 + + +#define PCI_VENDOR_ID_OLICOM 0x108d +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012 +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013 +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014 + +#define PCI_VENDOR_ID_SUN 0x108e +#define PCI_DEVICE_ID_SUN_EBUS 0x1000 +#define PCI_DEVICE_ID_SUN_HAPPYMEAL 0x1001 +#define PCI_DEVICE_ID_SUN_RIO_EBUS 0x1100 +#define PCI_DEVICE_ID_SUN_RIO_GEM 0x1101 +#define PCI_DEVICE_ID_SUN_RIO_1394 0x1102 +#define PCI_DEVICE_ID_SUN_RIO_USB 0x1103 +#define PCI_DEVICE_ID_SUN_GEM 0x2bad +#define PCI_DEVICE_ID_SUN_SIMBA 0x5000 +#define PCI_DEVICE_ID_SUN_PBM 0x8000 +#define PCI_DEVICE_ID_SUN_SCHIZO 0x8001 +#define PCI_DEVICE_ID_SUN_SABRE 0xa000 +#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001 +#define PCI_DEVICE_ID_SUN_TOMATILLO 0xa801 +#define PCI_DEVICE_ID_SUN_CASSINI 0xabba + +#define PCI_VENDOR_ID_CMD 0x1095 +#define PCI_DEVICE_ID_CMD_643 0x0643 +#define PCI_DEVICE_ID_CMD_646 0x0646 +#define PCI_DEVICE_ID_CMD_648 0x0648 +#define PCI_DEVICE_ID_CMD_649 0x0649 + +#define PCI_DEVICE_ID_SII_680 0x0680 +#define PCI_DEVICE_ID_SII_3112 0x3112 +#define PCI_DEVICE_ID_SII_1210SA 0x0240 + + +#define PCI_VENDOR_ID_BROOKTREE 0x109e +#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 +#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 + + +#define PCI_VENDOR_ID_SGI 0x10a9 +#define PCI_DEVICE_ID_SGI_IOC3 0x0003 +#define PCI_DEVICE_ID_SGI_IOC4 0x100a +#define PCI_VENDOR_ID_SGI_LITHIUM 0x1002 + + +#define PCI_VENDOR_ID_WINBOND 0x10ad +#define PCI_DEVICE_ID_WINBOND_82C105 0x0105 +#define PCI_DEVICE_ID_WINBOND_83C553 0x0565 + + +#define PCI_VENDOR_ID_PLX 0x10b5 +#define PCI_DEVICE_ID_PLX_R685 0x1030 +#define PCI_DEVICE_ID_PLX_ROMULUS 0x106a +#define PCI_DEVICE_ID_PLX_SPCOM800 0x1076 +#define PCI_DEVICE_ID_PLX_1077 0x1077 +#define PCI_DEVICE_ID_PLX_SPCOM200 0x1103 +#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151 +#define PCI_DEVICE_ID_PLX_R753 0x1152 +#define PCI_DEVICE_ID_PLX_OLITEC 0x1187 +#define PCI_DEVICE_ID_PLX_9050 0x9050 +#define PCI_DEVICE_ID_PLX_9080 0x9080 +#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001 + +#define PCI_VENDOR_ID_MADGE 0x10b6 +#define PCI_DEVICE_ID_MADGE_MK2 0x0002 + +#define PCI_VENDOR_ID_3COM 0x10b7 +#define PCI_DEVICE_ID_3COM_3C985 0x0001 +#define PCI_DEVICE_ID_3COM_3C940 0x1700 +#define PCI_DEVICE_ID_3COM_3C339 0x3390 +#define PCI_DEVICE_ID_3COM_3C359 0x3590 +#define PCI_DEVICE_ID_3COM_3C940B 0x80eb +#define PCI_DEVICE_ID_3COM_3CR990 0x9900 +#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902 +#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903 +#define PCI_DEVICE_ID_3COM_3CR990B 0x9904 +#define PCI_DEVICE_ID_3COM_3CR990_FX 0x9905 +#define PCI_DEVICE_ID_3COM_3CR990SVR95 0x9908 +#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909 +#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a + + +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1533 0x1533 +#define PCI_DEVICE_ID_AL_M1535 0x1535 +#define PCI_DEVICE_ID_AL_M1541 0x1541 +#define PCI_DEVICE_ID_AL_M1563 0x1563 +#define PCI_DEVICE_ID_AL_M1621 0x1621 +#define PCI_DEVICE_ID_AL_M1631 0x1631 +#define PCI_DEVICE_ID_AL_M1632 0x1632 +#define PCI_DEVICE_ID_AL_M1641 0x1641 +#define PCI_DEVICE_ID_AL_M1644 0x1644 +#define PCI_DEVICE_ID_AL_M1647 0x1647 +#define PCI_DEVICE_ID_AL_M1651 0x1651 +#define PCI_DEVICE_ID_AL_M1671 0x1671 +#define PCI_DEVICE_ID_AL_M1681 0x1681 +#define PCI_DEVICE_ID_AL_M1683 0x1683 +#define PCI_DEVICE_ID_AL_M1689 0x1689 +#define PCI_DEVICE_ID_AL_M5219 0x5219 +#define PCI_DEVICE_ID_AL_M5228 0x5228 +#define PCI_DEVICE_ID_AL_M5229 0x5229 +#define PCI_DEVICE_ID_AL_M5451 0x5451 +#define PCI_DEVICE_ID_AL_M7101 0x7101 + + + +#define PCI_VENDOR_ID_NEOMAGIC 0x10c8 +#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 +#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 +#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 + + +#define PCI_VENDOR_ID_TCONRAD 0x10da +#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508 + + +#define PCI_VENDOR_ID_NVIDIA 0x10de +#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020 +#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028 +#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029 +#define PCI_DEVICE_ID_NVIDIA_TNT_UNKNOWN 0x002a +#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C +#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS 0x0034 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE 0x0035 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA 0x0036 +#define PCI_DEVICE_ID_NVIDIA_NVENET_10 0x0037 +#define PCI_DEVICE_ID_NVIDIA_NVENET_11 0x0038 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2 0x003e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_ULTRA 0x0040 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800 0x0041 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_LE 0x0042 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x0045 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_4000 0x004E +#define PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS 0x0052 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE 0x0053 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA 0x0054 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2 0x0055 +#define PCI_DEVICE_ID_NVIDIA_NVENET_8 0x0056 +#define PCI_DEVICE_ID_NVIDIA_NVENET_9 0x0057 +#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065 +#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066 +#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069 +#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085 +#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086 +#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089 +#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a +#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GT 0x0090 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GTX 0x0091 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800 0x0098 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800_GTX 0x0099 +#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 +#define PCI_DEVICE_ID_GEFORCE_6800A 0x00c1 +#define PCI_DEVICE_ID_GEFORCE_6800A_LE 0x00c2 +#define PCI_DEVICE_ID_GEFORCE_GO_6800 0x00c8 +#define PCI_DEVICE_ID_GEFORCE_GO_6800_ULTRA 0x00c9 +#define PCI_DEVICE_ID_QUADRO_FX_GO1400 0x00cc +#define PCI_DEVICE_ID_QUADRO_FX_1400 0x00ce +#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 +#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9 +#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da +#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA 0x00e3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 +#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_ALT1 0x00f0 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT1 0x00f1 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT2 0x00f2 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6200_ALT1 0x00f3 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x00f9 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101 +#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO 0x0112 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600_GT 0x0140 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600 0x0141 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6610_XL 0x0145 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_540 0x014E +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200 0x014F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200_TURBOCACHE 0x0161 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200 0x0164 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250 0x0166 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200_1 0x0167 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250_1 0x0168 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460 0x0170 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440 0x0171 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420 0x0172 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_SE 0x0173 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO 0x0174 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO 0x0175 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32 0x0176 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_460_GO 0x0177 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL 0x0178 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64 0x0179 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_200 0x017A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL 0x017B +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL 0x017C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_410_GO_M16 0x017D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_8X 0x0181 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440SE_8X 0x0182 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420_8X 0x0183 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_4000 0x0185 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_448_GO 0x0186 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_488_GO 0x0187 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_580_XGL 0x0188 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_MAC 0x0189 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_280_NVS 0x018A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_380_XGL 0x018B +#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0 +#define PCI_DEVICE_ID_NVIDIA_NFORCE 0x01a4 +#define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc +#define PCI_DEVICE_ID_NVIDIA_MCP1_MODEM 0x01c1 +#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2 0x0202 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC 0x0203 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B 0x0211 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_LE 0x0212 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_GT 0x0215 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600 0x0250 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400 0x0251 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200 0x0253 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE 0x0265 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE 0x036E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA 0x037E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2 0x037F +#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268 +#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO 0x0286 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_980_XGL 0x0288 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_780_XGL 0x0289 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700_GOGL 0x028C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_ULTRA 0x0301 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800 0x0302 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_2000 0x0308 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1000 0x0309 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_ULTRA 0x0311 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600 0x0312 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600SE 0x0314 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5600 0x031A +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5650 0x031B +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO700 0x031C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200 0x0320 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_ULTRA 0x0321 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_1 0x0322 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200SE 0x0323 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5200 0x0324 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250 0x0325 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5500 0x0326 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5100 0x0327 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250_32 0x0328 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200 0x0329 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_NVS_280_PCI 0x032A +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_500 0x032B +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5300 0x032C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5100 0x032D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900_ULTRA 0x0330 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900 0x0331 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900XT 0x0332 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5950_ULTRA 0x0333 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900ZT 0x0334 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_3000 0x0338 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_700 0x033F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700_ULTRA 0x0341 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700 0x0342 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700LE 0x0343 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700VE 0x0344 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_1 0x0347 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_2 0x0348 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO1000 0x034C +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E +#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372 +#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 + +#define PCI_VENDOR_ID_IMS 0x10e0 +#define PCI_DEVICE_ID_IMS_TT128 0x9128 +#define PCI_DEVICE_ID_IMS_TT3D 0x9135 + + + + +#define PCI_VENDOR_ID_INTERG 0x10ea +#define PCI_DEVICE_ID_INTERG_1682 0x1682 +#define PCI_DEVICE_ID_INTERG_2000 0x2000 +#define PCI_DEVICE_ID_INTERG_2010 0x2010 +#define PCI_DEVICE_ID_INTERG_5000 0x5000 +#define PCI_DEVICE_ID_INTERG_5050 0x5050 + +#define PCI_VENDOR_ID_REALTEK 0x10ec +#define PCI_DEVICE_ID_REALTEK_8139 0x8139 + +#define PCI_VENDOR_ID_XILINX 0x10ee +#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0 +#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1 +#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2 +#define PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST 0x3fc3 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 + + +#define PCI_VENDOR_ID_INIT 0x1101 + +#define PCI_VENDOR_ID_CREATIVE 0x1102 /* duplicate: ECTIVA */ +#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002 + +#define PCI_VENDOR_ID_ECTIVA 0x1102 /* duplicate: CREATIVE */ +#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938 + +#define PCI_VENDOR_ID_TTI 0x1103 +#define PCI_DEVICE_ID_TTI_HPT343 0x0003 +#define PCI_DEVICE_ID_TTI_HPT366 0x0004 +#define PCI_DEVICE_ID_TTI_HPT372 0x0005 +#define PCI_DEVICE_ID_TTI_HPT302 0x0006 +#define PCI_DEVICE_ID_TTI_HPT371 0x0007 +#define PCI_DEVICE_ID_TTI_HPT374 0x0008 +#define PCI_DEVICE_ID_TTI_HPT372N 0x0009 /* apparently a 372N variant? */ + +#define PCI_VENDOR_ID_VIA 0x1106 +#define PCI_DEVICE_ID_VIA_8763_0 0x0198 +#define PCI_DEVICE_ID_VIA_8380_0 0x0204 +#define PCI_DEVICE_ID_VIA_3238_0 0x0238 +#define PCI_DEVICE_ID_VIA_PT880 0x0258 +#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 +#define PCI_DEVICE_ID_VIA_3269_0 0x0269 +#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 +#define PCI_DEVICE_ID_VIA_8363_0 0x0305 +#define PCI_DEVICE_ID_VIA_P4M800CE 0x0314 +#define PCI_DEVICE_ID_VIA_8371_0 0x0391 +#define PCI_DEVICE_ID_VIA_8501_0 0x0501 +#define PCI_DEVICE_ID_VIA_82C561 0x0561 +#define PCI_DEVICE_ID_VIA_82C586_1 0x0571 +#define PCI_DEVICE_ID_VIA_82C576 0x0576 +#define PCI_DEVICE_ID_VIA_82C586_0 0x0586 +#define PCI_DEVICE_ID_VIA_82C596 0x0596 +#define PCI_DEVICE_ID_VIA_82C597_0 0x0597 +#define PCI_DEVICE_ID_VIA_82C598_0 0x0598 +#define PCI_DEVICE_ID_VIA_8601_0 0x0601 +#define PCI_DEVICE_ID_VIA_8605_0 0x0605 +#define PCI_DEVICE_ID_VIA_82C686 0x0686 +#define PCI_DEVICE_ID_VIA_82C691_0 0x0691 +#define PCI_DEVICE_ID_VIA_82C576_1 0x1571 +#define PCI_DEVICE_ID_VIA_82C586_2 0x3038 +#define PCI_DEVICE_ID_VIA_82C586_3 0x3040 +#define PCI_DEVICE_ID_VIA_82C596_3 0x3050 +#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051 +#define PCI_DEVICE_ID_VIA_82C686_4 0x3057 +#define PCI_DEVICE_ID_VIA_82C686_5 0x3058 +#define PCI_DEVICE_ID_VIA_8233_5 0x3059 +#define PCI_DEVICE_ID_VIA_8233_0 0x3074 +#define PCI_DEVICE_ID_VIA_8633_0 0x3091 +#define PCI_DEVICE_ID_VIA_8367_0 0x3099 +#define PCI_DEVICE_ID_VIA_8653_0 0x3101 +#define PCI_DEVICE_ID_VIA_8622 0x3102 +#define PCI_DEVICE_ID_VIA_8233C_0 0x3109 +#define PCI_DEVICE_ID_VIA_8361 0x3112 +#define PCI_DEVICE_ID_VIA_XM266 0x3116 +#define PCI_DEVICE_ID_VIA_612X 0x3119 +#define PCI_DEVICE_ID_VIA_862X_0 0x3123 +#define PCI_DEVICE_ID_VIA_8753_0 0x3128 +#define PCI_DEVICE_ID_VIA_8233A 0x3147 +#define PCI_DEVICE_ID_VIA_8703_51_0 0x3148 +#define PCI_DEVICE_ID_VIA_8237_SATA 0x3149 +#define PCI_DEVICE_ID_VIA_XN266 0x3156 +#define PCI_DEVICE_ID_VIA_6410 0x3164 +#define PCI_DEVICE_ID_VIA_8754C_0 0x3168 +#define PCI_DEVICE_ID_VIA_8235 0x3177 +#define PCI_DEVICE_ID_VIA_8385_0 0x3188 +#define PCI_DEVICE_ID_VIA_8377_0 0x3189 +#define PCI_DEVICE_ID_VIA_8378_0 0x3205 +#define PCI_DEVICE_ID_VIA_8783_0 0x3208 +#define PCI_DEVICE_ID_VIA_8237 0x3227 +#define PCI_DEVICE_ID_VIA_8251 0x3287 +#define PCI_DEVICE_ID_VIA_3296_0 0x0296 +#define PCI_DEVICE_ID_VIA_8231 0x8231 +#define PCI_DEVICE_ID_VIA_8231_4 0x8235 +#define PCI_DEVICE_ID_VIA_8365_1 0x8305 +#define PCI_DEVICE_ID_VIA_8371_1 0x8391 +#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 +#define PCI_DEVICE_ID_VIA_838X_1 0xB188 +#define PCI_DEVICE_ID_VIA_83_87XX_1 0xB198 + +#define PCI_VENDOR_ID_SIEMENS 0x110A +#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102 + + +#define PCI_VENDOR_ID_VORTEX 0x1119 +#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000 +#define PCI_DEVICE_ID_VORTEX_GDT6000B 0x0001 +#define PCI_DEVICE_ID_VORTEX_GDT6x10 0x0002 +#define PCI_DEVICE_ID_VORTEX_GDT6x20 0x0003 +#define PCI_DEVICE_ID_VORTEX_GDT6530 0x0004 +#define PCI_DEVICE_ID_VORTEX_GDT6550 0x0005 +#define PCI_DEVICE_ID_VORTEX_GDT6x17 0x0006 +#define PCI_DEVICE_ID_VORTEX_GDT6x27 0x0007 +#define PCI_DEVICE_ID_VORTEX_GDT6537 0x0008 +#define PCI_DEVICE_ID_VORTEX_GDT6557 0x0009 +#define PCI_DEVICE_ID_VORTEX_GDT6x15 0x000a +#define PCI_DEVICE_ID_VORTEX_GDT6x25 0x000b +#define PCI_DEVICE_ID_VORTEX_GDT6535 0x000c +#define PCI_DEVICE_ID_VORTEX_GDT6555 0x000d +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x0100 +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x0101 +#define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x0102 +#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103 +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104 +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105 + +#define PCI_VENDOR_ID_EF 0x111a +#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000 +#define PCI_DEVICE_ID_EF_ATM_ASIC 0x0002 +#define PCI_VENDOR_ID_EF_ATM_LANAI2 0x0003 +#define PCI_VENDOR_ID_EF_ATM_LANAIHB 0x0005 + +#define PCI_VENDOR_ID_IDT 0x111d +#define PCI_DEVICE_ID_IDT_IDT77201 0x0001 + +#define PCI_VENDOR_ID_FORE 0x1127 +#define PCI_DEVICE_ID_FORE_PCA200E 0x0300 + + +#define PCI_VENDOR_ID_PHILIPS 0x1131 +#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146 +#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730 + +#define PCI_VENDOR_ID_EICON 0x1133 +#define PCI_DEVICE_ID_EICON_DIVA20 0xe002 +#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004 +#define PCI_DEVICE_ID_EICON_DIVA201 0xe005 +#define PCI_DEVICE_ID_EICON_DIVA202 0xe00b +#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010 +#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012 +#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013 +#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014 + +#define PCI_VENDOR_ID_ZIATECH 0x1138 +#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550 + + + +#define PCI_VENDOR_ID_SYSKONNECT 0x1148 +#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200 +#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300 +#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320 +#define PCI_DEVICE_ID_SYSKONNECT_9DXX 0x4400 +#define PCI_DEVICE_ID_SYSKONNECT_9MXX 0x4500 + + +#define PCI_VENDOR_ID_DIGI 0x114f +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070 +#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071 +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072 +#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073 +#define PCI_DEVICE_ID_NEO_2DB9 0x00C8 +#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 +#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA +#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB + + +#define PCI_VENDOR_ID_XIRCOM 0x115d +#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 +#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103 + + +#define PCI_VENDOR_ID_SERVERWORKS 0x1166 +#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008 +#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009 +#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017 +#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 +#define PCI_DEVICE_ID_SERVERWORKS_HT1000IDE 0x0214 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6LPC 0x0227 + +#define PCI_VENDOR_ID_SBE 0x1176 +#define PCI_DEVICE_ID_SBE_WANXL100 0x0301 +#define PCI_DEVICE_ID_SBE_WANXL200 0x0302 +#define PCI_DEVICE_ID_SBE_WANXL400 0x0104 + +#define PCI_VENDOR_ID_TOSHIBA 0x1179 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a +#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f +#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617 + +#define PCI_VENDOR_ID_TOSHIBA_2 0x102f +#define PCI_DEVICE_ID_TOSHIBA_TC35815CF 0x0030 +#define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC 0x0108 +#define PCI_DEVICE_ID_TOSHIBA_SPIDER_NET 0x01b3 + +#define PCI_VENDOR_ID_RICOH 0x1180 +#define PCI_DEVICE_ID_RICOH_RL5C465 0x0465 +#define PCI_DEVICE_ID_RICOH_RL5C466 0x0466 +#define PCI_DEVICE_ID_RICOH_RL5C475 0x0475 +#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476 +#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478 + +#define PCI_VENDOR_ID_DLINK 0x1186 +#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00 + +#define PCI_VENDOR_ID_ARTOP 0x1191 +#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005 +#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006 +#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007 +#define PCI_DEVICE_ID_ARTOP_ATP865 0x0008 +#define PCI_DEVICE_ID_ARTOP_ATP865R 0x0009 +#define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002 +#define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010 +#define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020 +#define PCI_DEVICE_ID_ARTOP_AEC7612S 0x8030 +#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040 +#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050 +#define PCI_DEVICE_ID_ARTOP_8060 0x8060 + +#define PCI_VENDOR_ID_ZEITNET 0x1193 +#define PCI_DEVICE_ID_ZEITNET_1221 0x0001 +#define PCI_DEVICE_ID_ZEITNET_1225 0x0002 + + +#define PCI_VENDOR_ID_FUJITSU_ME 0x119e +#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001 +#define PCI_DEVICE_ID_FUJITSU_FS50 0x0003 + +#define PCI_SUBVENDOR_ID_KEYSPAN 0x11a9 +#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334 + +#define PCI_VENDOR_ID_MARVELL 0x11ab +#define PCI_DEVICE_ID_MARVELL_GT64111 0x4146 +#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 +#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 +#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480 +#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652 +#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653 + + +#define PCI_VENDOR_ID_V3 0x11b0 +#define PCI_DEVICE_ID_V3_V960 0x0001 +#define PCI_DEVICE_ID_V3_V351 0x0002 + + +#define PCI_VENDOR_ID_ATT 0x11c1 +#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480 + + +#define PCI_VENDOR_ID_SPECIALIX 0x11cb +#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000 +#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000 +#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004 + + +#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4 +#define PCI_DEVICE_ID_AD1889JS 0x1889 + + +#define PCI_DEVICE_ID_SEGA_BBA 0x1234 + +#define PCI_VENDOR_ID_ZORAN 0x11de +#define PCI_DEVICE_ID_ZORAN_36057 0x6057 +#define PCI_DEVICE_ID_ZORAN_36120 0x6120 + + +#define PCI_VENDOR_ID_COMPEX 0x11f6 +#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112 + +#define PCI_VENDOR_ID_RP 0x11fe +#define PCI_DEVICE_ID_RP32INTF 0x0001 +#define PCI_DEVICE_ID_RP8INTF 0x0002 +#define PCI_DEVICE_ID_RP16INTF 0x0003 +#define PCI_DEVICE_ID_RP4QUAD 0x0004 +#define PCI_DEVICE_ID_RP8OCTA 0x0005 +#define PCI_DEVICE_ID_RP8J 0x0006 +#define PCI_DEVICE_ID_RP4J 0x0007 +#define PCI_DEVICE_ID_RP8SNI 0x0008 +#define PCI_DEVICE_ID_RP16SNI 0x0009 +#define PCI_DEVICE_ID_RPP4 0x000A +#define PCI_DEVICE_ID_RPP8 0x000B +#define PCI_DEVICE_ID_RP4M 0x000D +#define PCI_DEVICE_ID_RP2_232 0x000E +#define PCI_DEVICE_ID_RP2_422 0x000F +#define PCI_DEVICE_ID_URP32INTF 0x0801 +#define PCI_DEVICE_ID_URP8INTF 0x0802 +#define PCI_DEVICE_ID_URP16INTF 0x0803 +#define PCI_DEVICE_ID_URP8OCTA 0x0805 +#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C +#define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D +#define PCI_DEVICE_ID_CRP16INTF 0x0903 + +#define PCI_VENDOR_ID_CYCLADES 0x120e +#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100 +#define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101 +#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102 +#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103 +#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104 +#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105 +#define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200 +#define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201 +#define PCI_DEVICE_ID_PC300_RX_2 0x0300 +#define PCI_DEVICE_ID_PC300_RX_1 0x0301 +#define PCI_DEVICE_ID_PC300_TE_2 0x0310 +#define PCI_DEVICE_ID_PC300_TE_1 0x0311 +#define PCI_DEVICE_ID_PC300_TE_M_2 0x0320 +#define PCI_DEVICE_ID_PC300_TE_M_1 0x0321 + +#define PCI_VENDOR_ID_ESSENTIAL 0x120f +#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001 + +#define PCI_VENDOR_ID_O2 0x1217 +#define PCI_DEVICE_ID_O2_6729 0x6729 +#define PCI_DEVICE_ID_O2_6730 0x673a +#define PCI_DEVICE_ID_O2_6832 0x6832 +#define PCI_DEVICE_ID_O2_6836 0x6836 + +#define PCI_VENDOR_ID_3DFX 0x121a +#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001 +#define PCI_DEVICE_ID_3DFX_VOODOO2 0x0002 +#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003 +#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005 +#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009 + + + +#define PCI_VENDOR_ID_AVM 0x1244 +#define PCI_DEVICE_ID_AVM_B1 0x0700 +#define PCI_DEVICE_ID_AVM_C4 0x0800 +#define PCI_DEVICE_ID_AVM_A1 0x0a00 +#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00 +#define PCI_DEVICE_ID_AVM_C2 0x1100 +#define PCI_DEVICE_ID_AVM_T1 0x1200 + + +#define PCI_VENDOR_ID_STALLION 0x124d + +/* Allied Telesyn */ +#define PCI_VENDOR_ID_AT 0x1259 +#define PCI_SUBDEVICE_ID_AT_2700FX 0x2701 +#define PCI_SUBDEVICE_ID_AT_2701FX 0x2703 + +#define PCI_VENDOR_ID_ESS 0x125d +#define PCI_DEVICE_ID_ESS_ESS1968 0x1968 +#define PCI_DEVICE_ID_ESS_ESS1978 0x1978 +#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988 +#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989 +#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990 +#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992 +#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998 +#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999 +#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a +#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b + +#define PCI_VENDOR_ID_SATSAGEM 0x1267 +#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 + + +#define PCI_VENDOR_ID_ENSONIQ 0x1274 +#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 +#define PCI_DEVICE_ID_ENSONIQ_ES1370 0x5000 +#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371 + +#define PCI_VENDOR_ID_TRANSMETA 0x1279 +#define PCI_DEVICE_ID_EFFICEON 0x0060 + +#define PCI_VENDOR_ID_ROCKWELL 0x127A + +#define PCI_VENDOR_ID_ITE 0x1283 +#define PCI_DEVICE_ID_ITE_IT8172G 0x8172 +#define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801 +#define PCI_DEVICE_ID_ITE_8211 0x8211 +#define PCI_DEVICE_ID_ITE_8212 0x8212 +#define PCI_DEVICE_ID_ITE_8872 0x8872 +#define PCI_DEVICE_ID_ITE_IT8330G_0 0xe886 + +/* formerly Platform Tech */ +#define PCI_DEVICE_ID_ESS_ESS0100 0x0100 + +#define PCI_VENDOR_ID_ALTEON 0x12ae + + +#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232 0x0003 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485 0x0004 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4 0x0005 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485 0x0006 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2 0x0007 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485 0x0008 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6 0x0009 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_20MHZ 0x000C +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_PTM 0x000D +#define PCI_SUBDEVICE_ID_CONNECT_TECH_NT960PCI 0x0100 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_2 0x0201 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_4 0x0202 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_232 0x0300 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_232 0x0301 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_232 0x0302 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1 0x0310 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2 0x0311 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4 0x0312 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2 0x0320 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4 0x0321 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8 0x0322 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_485 0x0330 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_485 0x0331 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_485 0x0332 + + +#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2 +#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018 + +#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16 0x0011 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC 0x0041 +#define PCI_SUBVENDOR_ID_CHASE_PCIRAS 0x124D +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS4 0xF001 +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS8 0xF010 + +#define PCI_VENDOR_ID_AUREAL 0x12eb +#define PCI_DEVICE_ID_AUREAL_VORTEX_1 0x0001 +#define PCI_DEVICE_ID_AUREAL_VORTEX_2 0x0002 +#define PCI_DEVICE_ID_AUREAL_ADVANTAGE 0x0003 + +#define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8 +#define PCI_DEVICE_ID_LML_33R10 0x8a02 + + +#define PCI_VENDOR_ID_SIIG 0x131f +#define PCI_SUBVENDOR_ID_SIIG 0x131f +#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000 +#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001 +#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_550 0x1010 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_650 0x1011 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_850 0x1012 +#define PCI_DEVICE_ID_SIIG_1P_10x 0x1020 +#define PCI_DEVICE_ID_SIIG_2P_10x 0x1021 +#define PCI_DEVICE_ID_SIIG_2S_10x_550 0x1030 +#define PCI_DEVICE_ID_SIIG_2S_10x_650 0x1031 +#define PCI_DEVICE_ID_SIIG_2S_10x_850 0x1032 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_550 0x1034 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_650 0x1035 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_850 0x1036 +#define PCI_DEVICE_ID_SIIG_4S_10x_550 0x1050 +#define PCI_DEVICE_ID_SIIG_4S_10x_650 0x1051 +#define PCI_DEVICE_ID_SIIG_4S_10x_850 0x1052 +#define PCI_DEVICE_ID_SIIG_1S_20x_550 0x2000 +#define PCI_DEVICE_ID_SIIG_1S_20x_650 0x2001 +#define PCI_DEVICE_ID_SIIG_1S_20x_850 0x2002 +#define PCI_DEVICE_ID_SIIG_1P_20x 0x2020 +#define PCI_DEVICE_ID_SIIG_2P_20x 0x2021 +#define PCI_DEVICE_ID_SIIG_2S_20x_550 0x2030 +#define PCI_DEVICE_ID_SIIG_2S_20x_650 0x2031 +#define PCI_DEVICE_ID_SIIG_2S_20x_850 0x2032 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_550 0x2040 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_650 0x2041 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_850 0x2042 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_550 0x2010 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_650 0x2011 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_850 0x2012 +#define PCI_DEVICE_ID_SIIG_4S_20x_550 0x2050 +#define PCI_DEVICE_ID_SIIG_4S_20x_650 0x2051 +#define PCI_DEVICE_ID_SIIG_4S_20x_850 0x2052 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062 +#define PCI_DEVICE_ID_SIIG_8S_20x_550 0x2080 +#define PCI_DEVICE_ID_SIIG_8S_20x_650 0x2081 +#define PCI_DEVICE_ID_SIIG_8S_20x_850 0x2082 +#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050 + +#define PCI_VENDOR_ID_RADISYS 0x1331 + +#define PCI_VENDOR_ID_DOMEX 0x134a +#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001 + +#define PCI_VENDOR_ID_QUATECH 0x135C +#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010 +#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020 +#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050 +#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060 + +#define PCI_VENDOR_ID_SEALEVEL 0x135e +#define PCI_DEVICE_ID_SEALEVEL_U530 0x7101 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM2 0x7201 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM422 0x7402 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM232 0x7202 +#define PCI_DEVICE_ID_SEALEVEL_COMM4 0x7401 +#define PCI_DEVICE_ID_SEALEVEL_COMM8 0x7801 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM8 0x7804 + +#define PCI_VENDOR_ID_HYPERCOPE 0x1365 +#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050 +#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104 +#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106 +#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107 +#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108 + +#define PCI_VENDOR_ID_KAWASAKI 0x136b +#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01 + +#define PCI_VENDOR_ID_CNET 0x1371 +#define PCI_DEVICE_ID_CNET_GIGACARD 0x434e + +#define PCI_VENDOR_ID_LMC 0x1376 +#define PCI_DEVICE_ID_LMC_HSSI 0x0003 +#define PCI_DEVICE_ID_LMC_DS3 0x0004 +#define PCI_DEVICE_ID_LMC_SSI 0x0005 +#define PCI_DEVICE_ID_LMC_T1 0x0006 + + +#define PCI_VENDOR_ID_NETGEAR 0x1385 +#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a + +#define PCI_VENDOR_ID_APPLICOM 0x1389 +#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001 +#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002 +#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 + +#define PCI_VENDOR_ID_MOXA 0x1393 +#define PCI_DEVICE_ID_MOXA_RC7000 0x0001 +#define PCI_DEVICE_ID_MOXA_CP102 0x1020 +#define PCI_DEVICE_ID_MOXA_CP102UL 0x1021 +#define PCI_DEVICE_ID_MOXA_CP102U 0x1022 +#define PCI_DEVICE_ID_MOXA_C104 0x1040 +#define PCI_DEVICE_ID_MOXA_CP104U 0x1041 +#define PCI_DEVICE_ID_MOXA_CP104JU 0x1042 +#define PCI_DEVICE_ID_MOXA_CT114 0x1140 +#define PCI_DEVICE_ID_MOXA_CP114 0x1141 +#define PCI_DEVICE_ID_MOXA_CP118U 0x1180 +#define PCI_DEVICE_ID_MOXA_CP132 0x1320 +#define PCI_DEVICE_ID_MOXA_CP132U 0x1321 +#define PCI_DEVICE_ID_MOXA_CP134U 0x1340 +#define PCI_DEVICE_ID_MOXA_C168 0x1680 +#define PCI_DEVICE_ID_MOXA_CP168U 0x1681 + +#define PCI_VENDOR_ID_CCD 0x1397 +#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0 +#define PCI_DEVICE_ID_CCD_B000 0xb000 +#define PCI_DEVICE_ID_CCD_B006 0xb006 +#define PCI_DEVICE_ID_CCD_B007 0xb007 +#define PCI_DEVICE_ID_CCD_B008 0xb008 +#define PCI_DEVICE_ID_CCD_B009 0xb009 +#define PCI_DEVICE_ID_CCD_B00A 0xb00a +#define PCI_DEVICE_ID_CCD_B00B 0xb00b +#define PCI_DEVICE_ID_CCD_B00C 0xb00c +#define PCI_DEVICE_ID_CCD_B100 0xb100 +#define PCI_DEVICE_ID_CCD_B700 0xb700 +#define PCI_DEVICE_ID_CCD_B701 0xb701 + +#define PCI_VENDOR_ID_EXAR 0x13a8 +#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152 +#define PCI_DEVICE_ID_EXAR_XR17C154 0x0154 +#define PCI_DEVICE_ID_EXAR_XR17C158 0x0158 + +#define PCI_VENDOR_ID_MICROGATE 0x13c0 +#define PCI_DEVICE_ID_MICROGATE_USC 0x0010 +#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030 + +#define PCI_VENDOR_ID_3WARE 0x13C1 +#define PCI_DEVICE_ID_3WARE_1000 0x1000 +#define PCI_DEVICE_ID_3WARE_7000 0x1001 +#define PCI_DEVICE_ID_3WARE_9000 0x1002 + +#define PCI_VENDOR_ID_IOMEGA 0x13ca +#define PCI_DEVICE_ID_IOMEGA_BUZ 0x4231 + +#define PCI_VENDOR_ID_ABOCOM 0x13D1 +#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1 + +#define PCI_VENDOR_ID_CMEDIA 0x13f6 +#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100 +#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101 +#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111 +#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112 + +#define PCI_VENDOR_ID_LAVA 0x1407 +#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */ +#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_A 0x0180 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_B 0x0181 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200 /* 2x 16650 */ +#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500 /* 1x 16550 */ +#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600 /* 1x 16650 */ +#define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000 +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002 /* The Lava Dual Parallel is */ +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003 /* two PCI devices on a card */ +#define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800 + +#define PCI_VENDOR_ID_TIMEDIA 0x1409 +#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168 + +#define PCI_VENDOR_ID_ICE 0x1412 +#define PCI_DEVICE_ID_ICE_1712 0x1712 +#define PCI_DEVICE_ID_VT1724 0x1724 + +#define PCI_VENDOR_ID_OXSEMI 0x1415 +#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403 +#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501 +#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511 +#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513 +#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521 + +#define PCI_VENDOR_ID_SAMSUNG 0x144d + + +#define PCI_VENDOR_ID_TITAN 0x14D2 +#define PCI_DEVICE_ID_TITAN_010L 0x8001 +#define PCI_DEVICE_ID_TITAN_100L 0x8010 +#define PCI_DEVICE_ID_TITAN_110L 0x8011 +#define PCI_DEVICE_ID_TITAN_200L 0x8020 +#define PCI_DEVICE_ID_TITAN_210L 0x8021 +#define PCI_DEVICE_ID_TITAN_400L 0x8040 +#define PCI_DEVICE_ID_TITAN_800L 0x8080 +#define PCI_DEVICE_ID_TITAN_100 0xA001 +#define PCI_DEVICE_ID_TITAN_200 0xA005 +#define PCI_DEVICE_ID_TITAN_400 0xA003 +#define PCI_DEVICE_ID_TITAN_800B 0xA004 + +#define PCI_VENDOR_ID_PANACOM 0x14d4 +#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400 +#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402 + + +#define PCI_VENDOR_ID_AFAVLAB 0x14db +#define PCI_DEVICE_ID_AFAVLAB_P028 0x2180 +#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 +#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150 + +#define PCI_VENDOR_ID_BROADCOM 0x14e4 +#define PCI_DEVICE_ID_TIGON3_5752 0x1600 +#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 +#define PCI_DEVICE_ID_TIGON3_5700 0x1644 +#define PCI_DEVICE_ID_TIGON3_5701 0x1645 +#define PCI_DEVICE_ID_TIGON3_5702 0x1646 +#define PCI_DEVICE_ID_TIGON3_5703 0x1647 +#define PCI_DEVICE_ID_TIGON3_5704 0x1648 +#define PCI_DEVICE_ID_TIGON3_5704S_2 0x1649 +#define PCI_DEVICE_ID_NX2_5706 0x164a +#define PCI_DEVICE_ID_NX2_5708 0x164c +#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d +#define PCI_DEVICE_ID_TIGON3_5705 0x1653 +#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 +#define PCI_DEVICE_ID_TIGON3_5720 0x1658 +#define PCI_DEVICE_ID_TIGON3_5721 0x1659 +#define PCI_DEVICE_ID_TIGON3_5705M 0x165d +#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e +#define PCI_DEVICE_ID_TIGON3_5714 0x1668 +#define PCI_DEVICE_ID_TIGON3_5714S 0x1669 +#define PCI_DEVICE_ID_TIGON3_5780 0x166a +#define PCI_DEVICE_ID_TIGON3_5780S 0x166b +#define PCI_DEVICE_ID_TIGON3_5705F 0x166e +#define PCI_DEVICE_ID_TIGON3_5750 0x1676 +#define PCI_DEVICE_ID_TIGON3_5751 0x1677 +#define PCI_DEVICE_ID_TIGON3_5715 0x1678 +#define PCI_DEVICE_ID_TIGON3_5715S 0x1679 +#define PCI_DEVICE_ID_TIGON3_5750M 0x167c +#define PCI_DEVICE_ID_TIGON3_5751M 0x167d +#define PCI_DEVICE_ID_TIGON3_5751F 0x167e +#define PCI_DEVICE_ID_TIGON3_5782 0x1696 +#define PCI_DEVICE_ID_TIGON3_5788 0x169c +#define PCI_DEVICE_ID_TIGON3_5789 0x169d +#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6 +#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7 +#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8 +#define PCI_DEVICE_ID_NX2_5706S 0x16aa +#define PCI_DEVICE_ID_NX2_5708S 0x16ac +#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6 +#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7 +#define PCI_DEVICE_ID_TIGON3_5781 0x16dd +#define PCI_DEVICE_ID_TIGON3_5753 0x16f7 +#define PCI_DEVICE_ID_TIGON3_5753M 0x16fd +#define PCI_DEVICE_ID_TIGON3_5753F 0x16fe +#define PCI_DEVICE_ID_TIGON3_5901 0x170d +#define PCI_DEVICE_ID_BCM4401B1 0x170c +#define PCI_DEVICE_ID_TIGON3_5901_2 0x170e +#define PCI_DEVICE_ID_BCM4401 0x4401 +#define PCI_DEVICE_ID_BCM4401B0 0x4402 + +#define PCI_VENDOR_ID_TOPIC 0x151f +#define PCI_DEVICE_ID_TOPIC_TP560 0x0000 + +#define PCI_VENDOR_ID_ENE 0x1524 +#define PCI_DEVICE_ID_ENE_1211 0x1211 +#define PCI_DEVICE_ID_ENE_1225 0x1225 +#define PCI_DEVICE_ID_ENE_1410 0x1410 +#define PCI_DEVICE_ID_ENE_710 0x1411 +#define PCI_DEVICE_ID_ENE_712 0x1412 +#define PCI_DEVICE_ID_ENE_1420 0x1420 +#define PCI_DEVICE_ID_ENE_720 0x1421 +#define PCI_DEVICE_ID_ENE_722 0x1422 + +#define PCI_VENDOR_ID_CHELSIO 0x1425 + + +#define PCI_VENDOR_ID_SYBA 0x1592 +#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782 +#define PCI_DEVICE_ID_SYBA_1P_ECP 0x0783 + +#define PCI_VENDOR_ID_MORETON 0x15aa +#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000 + +#define PCI_VENDOR_ID_ZOLTRIX 0x15b0 +#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0 + +#define PCI_VENDOR_ID_MELLANOX 0x15b3 +#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 +#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278 +#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282 +#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c +#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 + +#define PCI_VENDOR_ID_PDC 0x15e9 + + +#define PCI_VENDOR_ID_FARSITE 0x1619 +#define PCI_DEVICE_ID_FARSITE_T2P 0x0400 +#define PCI_DEVICE_ID_FARSITE_T4P 0x0440 +#define PCI_DEVICE_ID_FARSITE_T1U 0x0610 +#define PCI_DEVICE_ID_FARSITE_T2U 0x0620 +#define PCI_DEVICE_ID_FARSITE_T4U 0x0640 +#define PCI_DEVICE_ID_FARSITE_TE1 0x1610 +#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612 + +#define PCI_VENDOR_ID_SIBYTE 0x166d +#define PCI_DEVICE_ID_BCM1250_HT 0x0002 + +#define PCI_VENDOR_ID_NETCELL 0x169c +#define PCI_DEVICE_ID_REVOLUTION 0x0044 + +#define PCI_VENDOR_ID_LINKSYS 0x1737 +#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064 + +#define PCI_VENDOR_ID_ALTIMA 0x173b +#define PCI_DEVICE_ID_ALTIMA_AC1000 0x03e8 +#define PCI_DEVICE_ID_ALTIMA_AC1001 0x03e9 +#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea +#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb + +#define PCI_VENDOR_ID_S2IO 0x17d5 +#define PCI_DEVICE_ID_S2IO_WIN 0x5731 +#define PCI_DEVICE_ID_S2IO_UNI 0x5831 +#define PCI_DEVICE_ID_HERC_WIN 0x5732 +#define PCI_DEVICE_ID_HERC_UNI 0x5832 + + +#define PCI_VENDOR_ID_SITECOM 0x182d +#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069 + +#define PCI_VENDOR_ID_TOPSPIN 0x1867 + +#define PCI_VENDOR_ID_TDI 0x192E +#define PCI_DEVICE_ID_TDI_EHCI 0x0101 + + +#define PCI_VENDOR_ID_TEKRAM 0x1de1 +#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 + +#define PCI_VENDOR_ID_HINT 0x3388 +#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013 + +#define PCI_VENDOR_ID_3DLABS 0x3d3d +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007 +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009 + + +#define PCI_VENDOR_ID_AKS 0x416c +#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100 + + + +#define PCI_VENDOR_ID_S3 0x5333 +#define PCI_DEVICE_ID_S3_TRIO 0x8811 +#define PCI_DEVICE_ID_S3_868 0x8880 +#define PCI_DEVICE_ID_S3_968 0x88f0 +#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 +#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04 +#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00 + +#define PCI_VENDOR_ID_DUNORD 0x5544 +#define PCI_DEVICE_ID_DUNORD_I3000 0x0001 + + +#define PCI_VENDOR_ID_DCI 0x6666 +#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001 +#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002 +#define PCI_DEVICE_ID_DCI_PCCOM2 0x0004 + +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_EESSC 0x0008 +#define PCI_DEVICE_ID_INTEL_PXHD_0 0x0320 +#define PCI_DEVICE_ID_INTEL_PXHD_1 0x0321 +#define PCI_DEVICE_ID_INTEL_PXH_0 0x0329 +#define PCI_DEVICE_ID_INTEL_PXH_1 0x032A +#define PCI_DEVICE_ID_INTEL_PXHV 0x032C +#define PCI_DEVICE_ID_INTEL_82375 0x0482 +#define PCI_DEVICE_ID_INTEL_82424 0x0483 +#define PCI_DEVICE_ID_INTEL_82378 0x0484 +#define PCI_DEVICE_ID_INTEL_I960 0x0960 +#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 +#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130 +#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 +#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 +#define PCI_DEVICE_ID_INTEL_7505_0 0x2550 +#define PCI_DEVICE_ID_INTEL_7205_0 0x255d +#define PCI_DEVICE_ID_INTEL_82437 0x122d +#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e +#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230 +#define PCI_DEVICE_ID_INTEL_82371MX 0x1234 +#define PCI_DEVICE_ID_INTEL_82441 0x1237 +#define PCI_DEVICE_ID_INTEL_82380FB 0x124b +#define PCI_DEVICE_ID_INTEL_82439 0x1250 +#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960 +#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 +#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 +#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 +#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 +#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 +#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415 +#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416 +#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418 +#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420 +#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421 +#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423 +#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425 +#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426 +#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428 +#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440 +#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443 +#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445 +#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448 +#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a +#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b +#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c +#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e +#define PCI_DEVICE_ID_INTEL_82801E_0 0x2450 +#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b +#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480 +#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483 +#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485 +#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486 +#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a +#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b +#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c +#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0 +#define PCI_DEVICE_ID_INTEL_82801DB_1 0x24c1 +#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3 +#define PCI_DEVICE_ID_INTEL_82801DB_5 0x24c5 +#define PCI_DEVICE_ID_INTEL_82801DB_6 0x24c6 +#define PCI_DEVICE_ID_INTEL_82801DB_9 0x24c9 +#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca +#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb +#define PCI_DEVICE_ID_INTEL_82801DB_12 0x24cc +#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0 +#define PCI_DEVICE_ID_INTEL_82801EB_1 0x24d1 +#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3 +#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5 +#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6 +#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db +#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd +#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1 +#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2 +#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4 +#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6 +#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab +#define PCI_DEVICE_ID_INTEL_82820_HB 0x2500 +#define PCI_DEVICE_ID_INTEL_82820_UP_HB 0x2501 +#define PCI_DEVICE_ID_INTEL_82850_HB 0x2530 +#define PCI_DEVICE_ID_INTEL_82860_HB 0x2531 +#define PCI_DEVICE_ID_INTEL_82845G_HB 0x2560 +#define PCI_DEVICE_ID_INTEL_82845G_IG 0x2562 +#define PCI_DEVICE_ID_INTEL_82865_HB 0x2570 +#define PCI_DEVICE_ID_INTEL_82865_IG 0x2572 +#define PCI_DEVICE_ID_INTEL_82875_HB 0x2578 +#define PCI_DEVICE_ID_INTEL_82915G_HB 0x2580 +#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 +#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 +#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 +#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 +#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 +#define PCI_DEVICE_ID_INTEL_82945GM_HB 0x27A0 +#define PCI_DEVICE_ID_INTEL_82945GM_IG 0x27A2 +#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 +#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 +#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 +#define PCI_DEVICE_ID_INTEL_ICH6_16 0x266a +#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d +#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e +#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f +#define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670 +#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698 +#define PCI_DEVICE_ID_INTEL_ESB2_17 0x269b +#define PCI_DEVICE_ID_INTEL_ESB2_18 0x269e +#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8 +#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9 +#define PCI_DEVICE_ID_INTEL_ICH7_30 0x27b0 +#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd +#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da +#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd +#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de +#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df +#define PCI_DEVICE_ID_INTEL_ICH8_0 0x2810 +#define PCI_DEVICE_ID_INTEL_ICH8_1 0x2811 +#define PCI_DEVICE_ID_INTEL_ICH8_2 0x2812 +#define PCI_DEVICE_ID_INTEL_ICH8_3 0x2814 +#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815 +#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e +#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850 +#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 +#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 +#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 +#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580 +#define PCI_DEVICE_ID_INTEL_82855GM_IG 0x3582 +#define PCI_DEVICE_ID_INTEL_E7520_MCH 0x3590 +#define PCI_DEVICE_ID_INTEL_E7320_MCH 0x3592 +#define PCI_DEVICE_ID_INTEL_MCH_PA 0x3595 +#define PCI_DEVICE_ID_INTEL_MCH_PA1 0x3596 +#define PCI_DEVICE_ID_INTEL_MCH_PB 0x3597 +#define PCI_DEVICE_ID_INTEL_MCH_PB1 0x3598 +#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599 +#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a +#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e +#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000 +#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010 +#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 +#define PCI_DEVICE_ID_INTEL_82437VX 0x7030 +#define PCI_DEVICE_ID_INTEL_82439TX 0x7100 +#define PCI_DEVICE_ID_INTEL_82371AB_0 0x7110 +#define PCI_DEVICE_ID_INTEL_82371AB 0x7111 +#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112 +#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113 +#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120 +#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121 +#define PCI_DEVICE_ID_INTEL_82810_MC3 0x7122 +#define PCI_DEVICE_ID_INTEL_82810_IG3 0x7123 +#define PCI_DEVICE_ID_INTEL_82810E_MC 0x7124 +#define PCI_DEVICE_ID_INTEL_82810E_IG 0x7125 +#define PCI_DEVICE_ID_INTEL_82443LX_0 0x7180 +#define PCI_DEVICE_ID_INTEL_82443LX_1 0x7181 +#define PCI_DEVICE_ID_INTEL_82443BX_0 0x7190 +#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191 +#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192 +#define PCI_DEVICE_ID_INTEL_440MX 0x7195 +#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196 +#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198 +#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199 +#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b +#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0 +#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 +#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 +#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 +#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 +#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca +#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb +#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea +#define PCI_DEVICE_ID_INTEL_IXP4XX 0x8500 +#define PCI_DEVICE_ID_INTEL_IXP2800 0x9004 +#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 + +#define PCI_VENDOR_ID_SCALEMP 0x8686 +#define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010 + +#define PCI_VENDOR_ID_COMPUTONE 0x8e0e +#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291 +#define PCI_DEVICE_ID_COMPUTONE_PG 0x0302 +#define PCI_SUBVENDOR_ID_COMPUTONE 0x8e0e +#define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG8 0x0002 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003 + +#define PCI_VENDOR_ID_KTI 0x8e2e + +#define PCI_VENDOR_ID_ADAPTEC 0x9004 +#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078 +#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178 +#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860 +#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078 +#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578 +#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038 +#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075 +#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078 +#define PCI_DEVICE_ID_ADAPTEC_7861 0x6178 +#define PCI_DEVICE_ID_ADAPTEC_7870 0x7078 +#define PCI_DEVICE_ID_ADAPTEC_7871 0x7178 +#define PCI_DEVICE_ID_ADAPTEC_7872 0x7278 +#define PCI_DEVICE_ID_ADAPTEC_7873 0x7378 +#define PCI_DEVICE_ID_ADAPTEC_7874 0x7478 +#define PCI_DEVICE_ID_ADAPTEC_7895 0x7895 +#define PCI_DEVICE_ID_ADAPTEC_7880 0x8078 +#define PCI_DEVICE_ID_ADAPTEC_7881 0x8178 +#define PCI_DEVICE_ID_ADAPTEC_7882 0x8278 +#define PCI_DEVICE_ID_ADAPTEC_7883 0x8378 +#define PCI_DEVICE_ID_ADAPTEC_7884 0x8478 +#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578 +#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678 +#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778 +#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878 + +#define PCI_VENDOR_ID_ADAPTEC2 0x9005 +#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010 +#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011 +#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013 +#define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f +#define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050 +#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051 +#define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f +#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080 +#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081 +#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083 +#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f +#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0 +#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1 +#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3 +#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf +#define PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN 0x0500 +#define PCI_DEVICE_ID_ADAPTEC2_SCAMP 0x0503 + + +#define PCI_VENDOR_ID_HOLTEK 0x9412 +#define PCI_DEVICE_ID_HOLTEK_6565 0x6565 + +#define PCI_VENDOR_ID_NETMOS 0x9710 +#define PCI_DEVICE_ID_NETMOS_9705 0x9705 +#define PCI_DEVICE_ID_NETMOS_9715 0x9715 +#define PCI_DEVICE_ID_NETMOS_9735 0x9735 +#define PCI_DEVICE_ID_NETMOS_9745 0x9745 +#define PCI_DEVICE_ID_NETMOS_9755 0x9755 +#define PCI_DEVICE_ID_NETMOS_9805 0x9805 +#define PCI_DEVICE_ID_NETMOS_9815 0x9815 +#define PCI_DEVICE_ID_NETMOS_9835 0x9835 +#define PCI_DEVICE_ID_NETMOS_9845 0x9845 +#define PCI_DEVICE_ID_NETMOS_9855 0x9855 + +#define PCI_SUBVENDOR_ID_EXSYS 0xd84d +#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014 +#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055 + +#define PCI_VENDOR_ID_TIGERJET 0xe159 +#define PCI_DEVICE_ID_TIGERJET_300 0x0001 +#define PCI_DEVICE_ID_TIGERJET_100 0x0002 + +#define PCI_VENDOR_ID_TTTECH 0x0357 +#define PCI_DEVICE_ID_TTTECH_MC322 0x000A + +#define PCI_VENDOR_ID_XILINX_RME 0xea60 +#define PCI_DEVICE_ID_RME_DIGI32 0x9896 +#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897 +#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898 + diff --git a/ddverify/models/con1/include/linux/pci_regs.h b/ddverify/models/con1/include/linux/pci_regs.h new file mode 100644 index 000000000..d27a78b71 --- /dev/null +++ b/ddverify/models/con1/include/linux/pci_regs.h @@ -0,0 +1,449 @@ +/* + * pci_regs.h + * + * PCI standard defines + * Copyright 1994, Drew Eckhardt + * Copyright 1997--1999 Martin Mares + * + * For more information, please consult the following manuals (look at + * http://www.pcisig.com/ for how to get them): + * + * PCI BIOS Specification + * PCI Local Bus Specification + * PCI to PCI Bridge Specification + * PCI System Design Guide + */ + +#ifndef LINUX_PCI_REGS_H +#define LINUX_PCI_REGS_H + +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes are standardized as follows: + */ +#define PCI_VENDOR_ID 0x00 /* 16 bits */ +#define PCI_DEVICE_ID 0x02 /* 16 bits */ +#define PCI_COMMAND 0x04 /* 16 bits */ +#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ +#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ + +#define PCI_STATUS 0x06 /* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ +#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ +#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVSEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +/* + * Base addresses specify locations in memory or I/O space. + * Decoded size can be determined by writing a value of + * 0xffffffff to the register, and reading it back. Only + * 1 bits are decoded. + */ +#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ +#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ +#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ +#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ +#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ +#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ +#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ +#define PCI_BASE_ADDRESS_SPACE_IO 0x01 +#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ +#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) +#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) +/* bit 1 is reserved if address_space = 1 */ + +/* Header type 0 (normal devices) */ +#define PCI_CARDBUS_CIS 0x28 +#define PCI_SUBSYSTEM_VENDOR_ID 0x2c +#define PCI_SUBSYSTEM_ID 0x2e +#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ +#define PCI_ROM_ADDRESS_ENABLE 0x01 +#define PCI_ROM_ADDRESS_MASK (~0x7ffUL) + +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ + +/* 0x35-0x3b are reserved */ +#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ +#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ +#define PCI_MIN_GNT 0x3e /* 8 bits */ +#define PCI_MAX_LAT 0x3f /* 8 bits */ + +/* Header type 1 (PCI-to-PCI bridges) */ +#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ +#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ +#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ +#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ +#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ +#define PCI_IO_LIMIT 0x1d +#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */ +#define PCI_IO_RANGE_TYPE_16 0x00 +#define PCI_IO_RANGE_TYPE_32 0x01 +#define PCI_IO_RANGE_MASK (~0x0fUL) +#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */ +#define PCI_MEMORY_BASE 0x20 /* Memory range behind */ +#define PCI_MEMORY_LIMIT 0x22 +#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL +#define PCI_MEMORY_RANGE_MASK (~0x0fUL) +#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ +#define PCI_PREF_MEMORY_LIMIT 0x26 +#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL +#define PCI_PREF_RANGE_TYPE_32 0x00 +#define PCI_PREF_RANGE_TYPE_64 0x01 +#define PCI_PREF_RANGE_MASK (~0x0fUL) +#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ +#define PCI_PREF_LIMIT_UPPER32 0x2c +#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ +#define PCI_IO_LIMIT_UPPER16 0x32 +/* 0x34 same as for htype 0 */ +/* 0x35-0x3b is reserved */ +#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_BRIDGE_CONTROL 0x3e +#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ +#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ +#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ +#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ +#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ +#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ +#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ + +/* Header type 2 (CardBus bridges) */ +#define PCI_CB_CAPABILITY_LIST 0x14 +/* 0x15 reserved */ +#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ +#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ +#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ +#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ +#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ +#define PCI_CB_MEMORY_BASE_0 0x1c +#define PCI_CB_MEMORY_LIMIT_0 0x20 +#define PCI_CB_MEMORY_BASE_1 0x24 +#define PCI_CB_MEMORY_LIMIT_1 0x28 +#define PCI_CB_IO_BASE_0 0x2c +#define PCI_CB_IO_BASE_0_HI 0x2e +#define PCI_CB_IO_LIMIT_0 0x30 +#define PCI_CB_IO_LIMIT_0_HI 0x32 +#define PCI_CB_IO_BASE_1 0x34 +#define PCI_CB_IO_BASE_1_HI 0x36 +#define PCI_CB_IO_LIMIT_1 0x38 +#define PCI_CB_IO_LIMIT_1_HI 0x3a +#define PCI_CB_IO_RANGE_MASK (~0x03UL) +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_CB_BRIDGE_CONTROL 0x3e +#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ +#define PCI_CB_BRIDGE_CTL_SERR 0x02 +#define PCI_CB_BRIDGE_CTL_ISA 0x04 +#define PCI_CB_BRIDGE_CTL_VGA 0x08 +#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 +#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ +#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 +#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 +#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 +#define PCI_CB_SUBSYSTEM_ID 0x42 +#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ +/* 0x48-0x7f reserved */ + +/* Capability lists */ + +#define PCI_CAP_LIST_ID 0 /* Capability ID */ +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ +#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ +#define PCI_CAP_ID_HT_IRQCONF 0x08 /* HyperTransport IRQ Configuration */ +#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ +#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + +/* Power Management Registers */ + +#define PCI_PM_PMC 2 /* PM Capabilities Register */ +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ +#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ +#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */ +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ +#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */ +#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */ +#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */ +#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ +#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ +#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ +#define PCI_PM_CTRL 4 /* PM control and status register */ +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_NO_SOFT_RESET 0x0004 /* No reset for D3hot->D0 */ +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ +#define PCI_PM_DATA_REGISTER 7 /* (??) */ +#define PCI_PM_SIZEOF 8 + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ +#define PCI_AGP_SIZEOF 12 + +/* Vital Product Data */ + +#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */ +#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */ +#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */ +#define PCI_VPD_DATA 4 /* 32-bits of data returned here */ + +/* Slot Identification */ + +#define PCI_SID_ESR 2 /* Expansion Slot Register */ +#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ +#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ +#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ + +/* Message Signalled Interrupts registers */ + +#define PCI_MSI_FLAGS 2 /* Various flags */ +#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ +#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ +#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ +#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ +#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */ +#define PCI_MSI_RFU 3 /* Rest of capability flags */ +#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ +#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ +#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ +#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ +#define PCI_MSI_MASK_BIT 16 /* Mask bits register */ + +/* CompactPCI Hotswap Register */ + +#define PCI_CHSWP_CSR 2 /* Control and Status Register */ +#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */ +#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */ +#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */ +#define PCI_CHSWP_LOO 0x08 /* LED On / Off */ +#define PCI_CHSWP_PI 0x30 /* Programming Interface */ +#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */ +#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */ + +/* PCI-X registers */ + +#define PCI_X_CMD 2 /* Modes & Features */ +#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */ +#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */ +#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */ +#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */ +#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */ +#define PCI_X_STATUS 4 /* PCI-X capabilities */ +#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */ +#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */ +#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */ +#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */ +#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */ +#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */ +#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */ +#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */ +#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */ +#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */ +#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */ +#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */ +#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */ + +/* PCI Express capability registers */ + +#define PCI_EXP_FLAGS 2 /* Capabilities register */ +#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */ +#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */ +#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */ +#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */ +#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */ +#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ +#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ +#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ +#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ +#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ +#define PCI_EXP_DEVCAP 4 /* Device capabilities */ +#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */ +#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */ +#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */ +#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */ +#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */ +#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ +#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ +#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ +#define PCI_EXP_DEVCTL 8 /* Device Control */ +#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ +#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ +#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */ +#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ +#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ +#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ +#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */ +#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ +#define PCI_EXP_DEVSTA 10 /* Device Status */ +#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ +#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ +#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */ +#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ +#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ +#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ +#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ +#define PCI_EXP_LNKCTL 16 /* Link Control */ +#define PCI_EXP_LNKSTA 18 /* Link Status */ +#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ +#define PCI_EXP_SLTCTL 24 /* Slot Control */ +#define PCI_EXP_SLTSTA 26 /* Slot Status */ +#define PCI_EXP_RTCTL 28 /* Root Control */ +#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */ +#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */ +#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */ +#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */ +#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ +#define PCI_EXP_RTCAP 30 /* Root Capabilities */ +#define PCI_EXP_RTSTA 32 /* Root Status */ + +/* Extended Capabilities (PCI-X 2.0 and Express) */ +#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) +#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf) +#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) + +#define PCI_EXT_CAP_ID_ERR 1 +#define PCI_EXT_CAP_ID_VC 2 +#define PCI_EXT_CAP_ID_DSN 3 +#define PCI_EXT_CAP_ID_PWR 4 + +/* Advanced Error Reporting */ +#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ +#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */ +#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */ +#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */ +#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */ +#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */ +#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */ +#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */ +#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */ +#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */ +#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */ +#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */ +#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */ + /* Same bits as above */ +#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */ +#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */ +#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */ +#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */ +#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */ +#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */ +#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */ +#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */ +#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */ +#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */ +#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ +#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ +#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */ +#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */ +#define PCI_ERR_ROOT_STATUS 48 +#define PCI_ERR_ROOT_COR_SRC 52 +#define PCI_ERR_ROOT_SRC 54 + +/* Virtual Channel */ +#define PCI_VC_PORT_REG1 4 +#define PCI_VC_PORT_REG2 8 +#define PCI_VC_PORT_CTRL 12 +#define PCI_VC_PORT_STATUS 14 +#define PCI_VC_RES_CAP 16 +#define PCI_VC_RES_CTRL 20 +#define PCI_VC_RES_STATUS 26 + +/* Power Budgeting */ +#define PCI_PWR_DSR 4 /* Data Select Register */ +#define PCI_PWR_DATA 8 /* Data Register */ +#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */ +#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */ +#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */ +#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */ +#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */ +#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */ +#define PCI_PWR_CAP 12 /* Capability */ +#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ + +#endif /* LINUX_PCI_REGS_H */ diff --git a/ddverify/models/con1/include/linux/percpu.h b/ddverify/models/con1/include/linux/percpu.h new file mode 100644 index 000000000..8e9945bd8 --- /dev/null +++ b/ddverify/models/con1/include/linux/percpu.h @@ -0,0 +1,10 @@ +#ifndef __LINUX_PERCPU_H +#define __LINUX_PERCPU_H + +#include +#include +//#include +#include +//#include + +#endif /* __LINUX_PERCPU_H */ diff --git a/ddverify/models/con1/include/linux/platform_device.h b/ddverify/models/con1/include/linux/platform_device.h new file mode 100644 index 000000000..97a8fed3f --- /dev/null +++ b/ddverify/models/con1/include/linux/platform_device.h @@ -0,0 +1,25 @@ +#ifndef _PLATFORM_DEVICE_H_ +#define _PLATFORM_DEVICE_H_ + +#include + +struct platform_device { + const char * name; + u32 id; + struct device dev; + u32 num_resources; + struct resource * resource; +}; + +struct platform_driver { + int (*probe)(struct platform_device *); + int (*remove)(struct platform_device *); + void (*shutdown)(struct platform_device *); + int (*suspend)(struct platform_device *, pm_message_t state); + int (*suspend_late)(struct platform_device *, pm_message_t state); + int (*resume_early)(struct platform_device *); + int (*resume)(struct platform_device *); + struct device_driver driver; +}; + +#endif /* _PLATFORM_DEVICE_H_ */ diff --git a/ddverify/models/con1/include/linux/pm.h b/ddverify/models/con1/include/linux/pm.h new file mode 100644 index 000000000..430226d01 --- /dev/null +++ b/ddverify/models/con1/include/linux/pm.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_PM_H +#define _LINUX_PM_H + +#include +#include +#include + +typedef struct pm_message { + int event; +} pm_message_t; + +#endif /* _LINUX_PM_H */ diff --git a/ddverify/models/con1/include/linux/pnp.h b/ddverify/models/con1/include/linux/pnp.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/poll.h b/ddverify/models/con1/include/linux/poll.h new file mode 100644 index 000000000..326affc5f --- /dev/null +++ b/ddverify/models/con1/include/linux/poll.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_POLL_H +#define _LINUX_POLL_H + +#include +#include +#include +#include +#include + +typedef struct poll_table_struct { + int something; +} poll_table; + +void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p); + +#endif /* _LINUX_POLL_H */ diff --git a/ddverify/models/con1/include/linux/posix_types.h b/ddverify/models/con1/include/linux/posix_types.h new file mode 100644 index 000000000..f60a473e2 --- /dev/null +++ b/ddverify/models/con1/include/linux/posix_types.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_POSIX_TYPES_H +#define _LINUX_POSIX_TYPES_H + +typedef int __kernel_key_t; +typedef int __kernel_mqd_t; + +#include + +#endif /* _LINUX_POSIX_TYPES_H */ diff --git a/ddverify/models/con1/include/linux/proc_fs.h b/ddverify/models/con1/include/linux/proc_fs.h new file mode 100644 index 000000000..48ffb5cf2 --- /dev/null +++ b/ddverify/models/con1/include/linux/proc_fs.h @@ -0,0 +1,29 @@ +#ifndef _LINUX_PROC_FS_H +#define _LINUX_PROC_FS_H + +#include +#include + +struct proc_dir_entry { + int something; +}; + +struct proc_dir_entry *proc_root_driver; + +typedef int (read_proc_t)(char *page, char **start, off_t off, + int count, int *eof, void *data); + +struct proc_dir_entry *create_proc_read_entry(const char *name, + mode_t mode, + struct proc_dir_entry *base, + read_proc_t *read_proc, + void * data); + +struct proc_dir_entry *create_proc_entry(const char *name, + mode_t mode, + struct proc_dir_entry *parent); + +void remove_proc_entry(const char *name, struct proc_dir_entry *parent); +struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); + +#endif diff --git a/ddverify/models/con1/include/linux/ptrace.h b/ddverify/models/con1/include/linux/ptrace.h new file mode 100644 index 000000000..e47ffb1ac --- /dev/null +++ b/ddverify/models/con1/include/linux/ptrace.h @@ -0,0 +1,80 @@ +#ifndef _LINUX_PTRACE_H +#define _LINUX_PTRACE_H +/* ptrace.h */ +/* structs and defines to help the user use the ptrace system call. */ + +/* has the defines to get at the registers. */ + +#define PTRACE_TRACEME 0 +#define PTRACE_PEEKTEXT 1 +#define PTRACE_PEEKDATA 2 +#define PTRACE_PEEKUSR 3 +#define PTRACE_POKETEXT 4 +#define PTRACE_POKEDATA 5 +#define PTRACE_POKEUSR 6 +#define PTRACE_CONT 7 +#define PTRACE_KILL 8 +#define PTRACE_SINGLESTEP 9 + +#define PTRACE_ATTACH 16 +#define PTRACE_DETACH 17 + +#define PTRACE_SYSCALL 24 + +/* 0x4200-0x4300 are reserved for architecture-independent additions. */ +#define PTRACE_SETOPTIONS 0x4200 +#define PTRACE_GETEVENTMSG 0x4201 +#define PTRACE_GETSIGINFO 0x4202 +#define PTRACE_SETSIGINFO 0x4203 + +/* options set using PTRACE_SETOPTIONS */ +#define PTRACE_O_TRACESYSGOOD 0x00000001 +#define PTRACE_O_TRACEFORK 0x00000002 +#define PTRACE_O_TRACEVFORK 0x00000004 +#define PTRACE_O_TRACECLONE 0x00000008 +#define PTRACE_O_TRACEEXEC 0x00000010 +#define PTRACE_O_TRACEVFORKDONE 0x00000020 +#define PTRACE_O_TRACEEXIT 0x00000040 + +#define PTRACE_O_MASK 0x0000007f + +/* Wait extended result codes for the above trace options. */ +#define PTRACE_EVENT_FORK 1 +#define PTRACE_EVENT_VFORK 2 +#define PTRACE_EVENT_CLONE 3 +#define PTRACE_EVENT_EXEC 4 +#define PTRACE_EVENT_VFORK_DONE 5 +#define PTRACE_EVENT_EXIT 6 + +/* + * Ptrace flags + * + * The owner ship rules for task->ptrace which holds the ptrace + * flags is simple. When a task is running it owns it's task->ptrace + * flags. When the a task is stopped the ptracer owns task->ptrace. + */ + +#define PT_PTRACED 0x00000001 +#define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ +#define PT_TRACESYSGOOD 0x00000004 +#define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */ +#define PT_TRACE_FORK 0x00000010 +#define PT_TRACE_VFORK 0x00000020 +#define PT_TRACE_CLONE 0x00000040 +#define PT_TRACE_EXEC 0x00000080 +#define PT_TRACE_VFORK_DONE 0x00000100 +#define PT_TRACE_EXIT 0x00000200 +#define PT_ATTACHED 0x00000400 /* parent != real_parent */ + +#define PT_TRACE_MASK 0x000003f4 + +/* single stepping state bits (used on ARM and PA-RISC) */ +#define PT_SINGLESTEP_BIT 31 +#define PT_SINGLESTEP (1< /* For unlikely. */ +#include /* For struct task_struct. */ + +#endif diff --git a/ddverify/models/con1/include/linux/reboot.h b/ddverify/models/con1/include/linux/reboot.h new file mode 100644 index 000000000..b1d2d7da1 --- /dev/null +++ b/ddverify/models/con1/include/linux/reboot.h @@ -0,0 +1,75 @@ +#ifndef _LINUX_REBOOT_H +#define _LINUX_REBOOT_H + +/* + * Magic values required to use _reboot() system call. + */ + +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_MAGIC2A 85072278 +#define LINUX_REBOOT_MAGIC2B 369367448 +#define LINUX_REBOOT_MAGIC2C 537993216 + + +/* + * Commands accepted by the _reboot() system call. + * + * RESTART Restart system using default command and mode. + * HALT Stop OS and give system control to ROM monitor, if any. + * CAD_ON Ctrl-Alt-Del sequence causes RESTART command. + * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task. + * POWER_OFF Stop OS and remove all power from system, if possible. + * RESTART2 Restart system using given command string. + * SW_SUSPEND Suspend system using software suspend if compiled in. + * KEXEC Restart system using a previously loaded Linux kernel + */ + +#define LINUX_REBOOT_CMD_RESTART 0x01234567 +#define LINUX_REBOOT_CMD_HALT 0xCDEF0123 +#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF +#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000 +#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 +#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2 +#define LINUX_REBOOT_CMD_KEXEC 0x45584543 + + +#include + +extern int register_reboot_notifier(struct notifier_block *); +extern int unregister_reboot_notifier(struct notifier_block *); + + +/* + * Architecture-specific implementations of sys_reboot commands. + */ + +extern void machine_restart(char *cmd); +extern void machine_halt(void); +extern void machine_power_off(void); + +extern void machine_shutdown(void); +struct pt_regs; +extern void machine_crash_shutdown(struct pt_regs *); + +/* + * Architecture independent implemenations of sys_reboot commands. + */ + +extern void kernel_shutdown_prepare(enum system_states state); + +extern void kernel_restart(char *cmd); +extern void kernel_halt(void); +extern void kernel_power_off(void); + +void ctrl_alt_del(void); + +/* + * Emergency restart, callable from an interrupt handler. + */ + +extern void emergency_restart(void); +//#include + +#endif /* _LINUX_REBOOT_H */ diff --git a/ddverify/models/con1/include/linux/rtc.h b/ddverify/models/con1/include/linux/rtc.h new file mode 100644 index 000000000..58ff91583 --- /dev/null +++ b/ddverify/models/con1/include/linux/rtc.h @@ -0,0 +1,219 @@ +/* + * Generic RTC interface. + * This version contains the part of the user interface to the Real Time Clock + * service. It is used with both the legacy mc146818 and also EFI + * Struct rtc_time and first 12 ioctl by Paul Gortmaker, 1996 - separated out + * from to this file for 2.4 kernels. + * + * Copyright (C) 1999 Hewlett-Packard Co. + * Copyright (C) 1999 Stephane Eranian + */ +#ifndef _LINUX_RTC_H_ +#define _LINUX_RTC_H_ + +/* + * The struct used to pass data via the following ioctl. Similar to the + * struct tm in , but it needs to be here so that the kernel + * source is self contained, allowing cross-compiles, etc. etc. + */ +struct rtc_time { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +/* + * This data structure is inspired by the EFI (v0.92) wakeup + * alarm API. + */ +struct rtc_wkalrm { + unsigned char enabled; + unsigned char pending; + struct rtc_time time; +}; + +/* + * Data structure to control PLL correction some better RTC feature + * pll_value is used to get or set current value of correction, + * the rest of the struct is used to query HW capabilities. + * This is modeled after the RTC used in Q40/Q60 computers but + * should be sufficiently flexible for other devices + * + * +ve pll_value means clock will run faster by + * pll_value*pll_posmult/pll_clock + * -ve pll_value means clock will run slower by + * pll_value*pll_negmult/pll_clock + */ + +struct rtc_pll_info { + /* int pll_ctrl; + int pll_value; + int pll_max; + int pll_min; + int pll_posmult; + int pll_negmult; + long pll_clock; +*/ + int something; +}; + +/* + * ioctl calls that are permitted to the /dev/rtc interface, if + * any of the RTC drivers are enabled. + */ + +#define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */ +#define RTC_AIE_OFF _IO('p', 0x02) /* ... off */ +#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */ +#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */ +#define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */ +#define RTC_PIE_OFF _IO('p', 0x06) /* ... off */ +#define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */ +#define RTC_WIE_OFF _IO('p', 0x10) /* ... off */ + +#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */ +#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */ +#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */ +#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */ +#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */ +#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */ +#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */ +#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */ + +#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/ +#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/ + +#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */ +#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */ + +/* interrupt flags */ +#define RTC_IRQF 0x80 /* any of the following is active */ +#define RTC_PF 0x40 +#define RTC_AF 0x20 +#define RTC_UF 0x10 + + +#include + +extern int rtc_month_days(unsigned int month, unsigned int year); +extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); +extern int rtc_valid_tm(struct rtc_time *tm); +extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); +extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); + +#include +#include +#include +#include +#include + +extern struct class *rtc_class; + +struct rtc_class_ops { + /* int (*open)(struct device *); + void (*release)(struct device *); + int (*ioctl)(struct device *, unsigned int, unsigned long); + int (*read_time)(struct device *, struct rtc_time *); + int (*set_time)(struct device *, struct rtc_time *); + int (*read_alarm)(struct device *, struct rtc_wkalrm *); + int (*set_alarm)(struct device *, struct rtc_wkalrm *); + int (*proc)(struct device *, struct seq_file *); + int (*set_mmss)(struct device *, unsigned long secs); + int (*irq_set_state)(struct device *, int enabled); + int (*irq_set_freq)(struct device *, int freq); + int (*read_callback)(struct device *, int data); + */ + int something; +}; + +#define RTC_DEVICE_NAME_SIZE 20 +struct rtc_task; + +struct rtc_device +{ + /* struct class_device class_dev; + struct module *owner; + + int id; + char name[RTC_DEVICE_NAME_SIZE]; + + const struct rtc_class_ops *ops; + struct mutex ops_lock; + + struct class_device *rtc_dev; + struct cdev char_dev; + struct mutex char_lock; + + unsigned long irq_data; + spinlock_t irq_lock; + wait_queue_head_t irq_queue; + struct fasync_struct *async_queue; + + struct rtc_task *irq_task; + spinlock_t irq_task_lock; + int irq_freq; + int max_user_freq; +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL + struct work_struct uie_task; + struct timer_list uie_timer; + unsigned int oldsecs; + unsigned int irq_active:1; + unsigned int stop_uie_polling:1; + unsigned int uie_task_active:1; + unsigned int uie_timer_active:1; +#endif + */ + int something; +}; +#define to_rtc_device(d) container_of(d, struct rtc_device, class_dev) + +extern struct rtc_device *rtc_device_register(const char *name, + struct device *dev, + const struct rtc_class_ops *ops, + struct module *owner); +extern void rtc_device_unregister(struct rtc_device *rdev); +extern int rtc_interface_register(struct class_interface *intf); + +extern int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_mmss(struct class_device *class_dev, unsigned long secs); +extern int rtc_read_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern int rtc_set_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern void rtc_update_irq(struct class_device *class_dev, + unsigned long num, unsigned long events); + +extern struct class_device *rtc_class_open(char *name); +extern void rtc_class_close(struct class_device *class_dev); + +extern int rtc_irq_register(struct class_device *class_dev, + struct rtc_task *task); +extern void rtc_irq_unregister(struct class_device *class_dev, + struct rtc_task *task); +extern int rtc_irq_set_state(struct class_device *class_dev, + struct rtc_task *task, int enabled); +extern int rtc_irq_set_freq(struct class_device *class_dev, + struct rtc_task *task, int freq); + +typedef struct rtc_task { + void (*func)(void *private_data); + void *private_data; +} rtc_task_t; + +int rtc_register(rtc_task_t *task); +int rtc_unregister(rtc_task_t *task); +int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); +void rtc_get_rtc_time(struct rtc_time *rtc_tm); +irqreturn_t rtc_interrupt(int irq, void *dev_id); + + +unsigned char rtc_read(unsigned char); +void rtc_write(unsigned char, unsigned char); +#endif /* _LINUX_RTC_H_ */ diff --git a/ddverify/models/con1/include/linux/scatterlist.h b/ddverify/models/con1/include/linux/scatterlist.h new file mode 100644 index 000000000..32da1e633 --- /dev/null +++ b/ddverify/models/con1/include/linux/scatterlist.h @@ -0,0 +1,24 @@ +#ifndef _LINUX_SCATTERLIST_H +#define _LINUX_SCATTERLIST_H + +#include +#include +#include + +/*static inline void sg_set_buf(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + sg->page = virt_to_page(buf); + sg->offset = offset_in_page(buf); + sg->length = buflen; +} + +static inline void sg_init_one(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + memset(sg, 0, sizeof(*sg)); + sg_set_buf(sg, buf, buflen); +} +*/ + +#endif /* _LINUX_SCATTERLIST_H */ diff --git a/ddverify/models/con1/include/linux/sched.h b/ddverify/models/con1/include/linux/sched.h new file mode 100644 index 000000000..c15cd8719 --- /dev/null +++ b/ddverify/models/con1/include/linux/sched.h @@ -0,0 +1,62 @@ +#ifndef _LINUX_SCHED_H +#define _LINUX_SCHED_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_STOPPED 4 +#define TASK_TRACED 8 + +#define TASK_COMM_LEN 16 + +struct sighand_struct { + spinlock_t siglock; +}; + +struct task_struct { + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + pid_t pid; + char comm[TASK_COMM_LEN]; + + sigset_t blocked, real_blocked; + + struct sighand_struct *sighand; +}; + +#include + +int signal_pending(struct task_struct *p); + +// DDV: Body is defined in linux/kernel/sched.c +void schedule(void); +// DDV: Body is defined in linux/kernel/sched.c +long schedule_timeout(long timeout); +// DDV: TODO +int need_resched(void); + +// DDV: TODO +extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); + +// DDV: TODO +void yield(void); + +// DDV: No body for this function +void set_current_state(int); + +// DDV: TODO +extern int kill_proc(pid_t, int, int); +// DDV: TODO +extern void recalc_sigpending(void); +#endif diff --git a/ddverify/models/con1/include/linux/seq_file.h b/ddverify/models/con1/include/linux/seq_file.h new file mode 100644 index 000000000..bb64052b9 --- /dev/null +++ b/ddverify/models/con1/include/linux/seq_file.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_SEQ_FILE_H +#define _LINUX_SEQ_FILE_H + +#include +#include +#include + +struct seq_operations; +struct file; +struct vfsmount; +struct dentry; +struct inode; + +struct seq_file { + int something; +}; + +struct seq_operations { + void * (*start) (struct seq_file *m, loff_t *pos); + void (*stop) (struct seq_file *m, void *v); + void * (*next) (struct seq_file *m, void *v, loff_t *pos); + int (*show) (struct seq_file *m, void *v); +}; + +int seq_open(struct file *, struct seq_operations *); +ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); +loff_t seq_lseek(struct file *, loff_t, int); +int seq_release(struct inode *, struct file *); +int seq_escape(struct seq_file *, const char *, const char *); +int seq_putc(struct seq_file *m, char c); +int seq_puts(struct seq_file *m, const char *s); + +int seq_printf(struct seq_file *, const char *, ...); + +#endif diff --git a/ddverify/models/con1/include/linux/serial.h b/ddverify/models/con1/include/linux/serial.h new file mode 100644 index 000000000..b532862fc --- /dev/null +++ b/ddverify/models/con1/include/linux/serial.h @@ -0,0 +1,131 @@ +/* + * include/linux/serial.h + * + * Copyright (C) 1992 by Theodore Ts'o. + * + * Redistribution of this file is permitted under the terms of the GNU + * Public License (GPL) + */ + +#ifndef _LINUX_SERIAL_H +#define _LINUX_SERIAL_H + +#include +#include + +#define SERIAL_XMIT_SIZE PAGE_SIZE + +struct serial_struct { + int type; + int line; + unsigned int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + unsigned short close_delay; + char io_type; + char reserved_char[1]; + int hub6; + unsigned short closing_wait; /* time to wait before closing */ + unsigned short closing_wait2; /* no longer used... */ + unsigned char *iomem_base; + unsigned short iomem_reg_shift; + unsigned int port_high; + unsigned long iomap_base; /* cookie passed into ioremap */ +}; + + +/* + * For the close wait times, 0 means wait forever for serial port to + * flush its output. 65535 means don't wait at all. + */ +#define ASYNC_CLOSING_WAIT_INF 0 +#define ASYNC_CLOSING_WAIT_NONE 65535 + + +/* + * These are the supported serial types. + */ +#define PORT_UNKNOWN 0 +#define PORT_8250 1 +#define PORT_16450 2 +#define PORT_16550 3 +#define PORT_16550A 4 +#define PORT_CIRRUS 5 /* usurped by cyclades.c */ +#define PORT_16650 6 +#define PORT_16650V2 7 +#define PORT_16750 8 +#define PORT_STARTECH 9 /* usurped by cyclades.c */ +#define PORT_16C950 10 /* Oxford Semiconductor */ +#define PORT_16654 11 +#define PORT_16850 12 +#define PORT_RSA 13 /* RSA-DV II/S card */ +#define PORT_MAX 13 + +#define SERIAL_IO_PORT 0 +#define SERIAL_IO_HUB6 1 +#define SERIAL_IO_MEM 2 + + + + +#define UART_CLEAR_FIFO 0x01 +#define UART_USE_FIFO 0x02 +#define UART_STARTECH 0x04 +#define UART_NATSEMI 0x08 + + +/* + * Definitions for async_struct (and serial_struct) flags field + */ +#define ASYNC_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes + on the callout port */ +#define ASYNC_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */ +#define ASYNC_SAK 0x0004 /* Secure Attention Key (Orange book) */ +#define ASYNC_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ + +#define ASYNC_SPD_MASK 0x1030 +#define ASYNC_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ + +#define ASYNC_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ +#define ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */ + +#define ASYNC_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ +#define ASYNC_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ +#define ASYNC_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ +#define ASYNC_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ +#define ASYNC_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ + +#define ASYNC_HARDPPS_CD 0x0800 /* Call hardpps when CD goes high */ + +#define ASYNC_SPD_SHI 0x1000 /* Use 230400 instead of 38400 bps */ +#define ASYNC_SPD_WARP 0x1010 /* Use 460800 instead of 38400 bps */ + +#define ASYNC_LOW_LATENCY 0x2000 /* Request low latency behaviour */ + +#define ASYNC_BUGGY_UART 0x4000 /* This is a buggy UART, skip some safety + * checks. Note: can be dangerous! */ + +#define ASYNC_AUTOPROBE 0x8000 /* Port was autoprobed by PCI or PNP code */ + +#define ASYNC_FLAGS 0x7FFF /* Possible legal async flags */ +#define ASYNC_USR_MASK 0x3430 /* Legal flags that non-privileged + * users can set or reset */ + +/* Internal flags used only by kernel/chr_drv/serial.c */ +#define ASYNC_INITIALIZED 0x80000000 /* Serial port was initialized */ +#define ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ +#define ASYNC_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ +#define ASYNC_CLOSING 0x08000000 /* Serial port is closing */ +#define ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */ +#define ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */ +#define ASYNC_SHARE_IRQ 0x01000000 /* for multifunction cards + --- no longer used */ +#define ASYNC_CONS_FLOW 0x00800000 /* flow control for console */ + +#define ASYNC_BOOT_ONLYMCA 0x00400000 /* Probe only if MCA bus */ +#define ASYNC_INTERNAL_FLAGS 0xFFC00000 /* Internal flags */ + +#endif /* _LINUX_SERIAL_H */ diff --git a/ddverify/models/con1/include/linux/signal.h b/ddverify/models/con1/include/linux/signal.h new file mode 100644 index 000000000..2b8814641 --- /dev/null +++ b/ddverify/models/con1/include/linux/signal.h @@ -0,0 +1,54 @@ +#ifndef _LINUX_SIGNAL_H +#define _LINUX_SIGNAL_H + +#include +#include + +#include +#include + +#include + +/* + * These values of sa_flags are used only by the kernel as part of the + * irq handling routines. + * + * SA_INTERRUPT is also used by the irq handling routines. + * SA_SHIRQ is for shared interrupt support on PCI and EISA. + */ +#define SA_PROBE SA_ONESHOT +#define SA_SAMPLE_RANDOM SA_RESTART +#define SA_SHIRQ 0x04000000 + +static inline void sigfillset(sigset_t *set) +{ + switch (_NSIG_WORDS) { + default: + memset(set, -1, sizeof(sigset_t)); + break; + case 2: set->sig[1] = -1; + case 1: set->sig[0] = -1; + break; + } +} + +/* Some extensions for manipulating the low 32 signals in particular. */ + +static inline void sigaddsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] |= mask; +} + +static inline void sigdelsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] &= ~mask; +} + +static inline int sigtestsetmask(sigset_t *set, unsigned long mask) +{ + return (set->sig[0] & mask) != 0; +} + +#define sigmask(sig) (1UL << ((sig) - 1)) + +#endif /* _LINUX_SIGNAL_H */ diff --git a/ddverify/models/con1/include/linux/skbuff.h b/ddverify/models/con1/include/linux/skbuff.h new file mode 100644 index 000000000..abc4822d9 --- /dev/null +++ b/ddverify/models/con1/include/linux/skbuff.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_SKBUFF_H +#define _LINUX_SKBUFF_H + +#include + +#endif /* _LINUX_SKBUFF_H */ diff --git a/ddverify/models/con1/include/linux/slab.h b/ddverify/models/con1/include/linux/slab.h new file mode 100644 index 000000000..edfc1e1ca --- /dev/null +++ b/ddverify/models/con1/include/linux/slab.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_SLAB_H +#define _LINUX_SLAB_H + +#include +#include + +// DDV: TODO +void kfree(const void *); +// DDV: Body is defined in linux/mm/slab.c +void *kmalloc(size_t size, gfp_t flags); +// DDV: Body is defined in linux/mm/slab.c +void *kzalloc(size_t size, gfp_t flags); +// DDV: TODO +unsigned int ksize(const void *); + +#endif diff --git a/ddverify/models/con1/include/linux/smp_lock.h b/ddverify/models/con1/include/linux/smp_lock.h new file mode 100644 index 000000000..fbd5463bc --- /dev/null +++ b/ddverify/models/con1/include/linux/smp_lock.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_SMPLOCK_H +#define __LINUX_SMPLOCK_H + +#include +#include + +spinlock_t kernel_lock; + +#define lock_kernel() spin_lock(&kernel_lock) +#define unlock_kernel() spin_unlock(&kernel_lock) + +#endif /* __LINUX_SMPLOCK_H */ diff --git a/ddverify/models/con1/include/linux/socket.h b/ddverify/models/con1/include/linux/socket.h new file mode 100644 index 000000000..365beed9c --- /dev/null +++ b/ddverify/models/con1/include/linux/socket.h @@ -0,0 +1,109 @@ +#ifndef _LINUX_SOCKET_H +#define _LINUX_SOCKET_H + +#include /* iovec support */ + +/* Supported address families. */ +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* AppleTalk DDP */ +#define AF_NETROM 6 /* Amateur Radio NET/ROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_ATMPVC 8 /* ATM PVCs */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_INET6 10 /* IP version 6 */ +#define AF_ROSE 11 /* Amateur Radio X.25 PLP */ +#define AF_DECnet 12 /* Reserved for DECnet project */ +#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ +#define AF_KEY 15 /* PF_KEY key management API */ +#define AF_NETLINK 16 +#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ +#define AF_PACKET 17 /* Packet family */ +#define AF_ASH 18 /* Ash */ +#define AF_ECONET 19 /* Acorn Econet */ +#define AF_ATMSVC 20 /* ATM SVCs */ +#define AF_SNA 22 /* Linux SNA Project (nutters!) */ +#define AF_IRDA 23 /* IRDA sockets */ +#define AF_PPPOX 24 /* PPPoX sockets */ +#define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_LLC 26 /* Linux LLC */ +#define AF_TIPC 30 /* TIPC sockets */ +#define AF_BLUETOOTH 31 /* Bluetooth sockets */ +#define AF_MAX 32 /* For now.. */ + +/* Protocol families, same as address families. */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL AF_LOCAL +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_ATMPVC AF_ATMPVC +#define PF_X25 AF_X25 +#define PF_INET6 AF_INET6 +#define PF_ROSE AF_ROSE +#define PF_DECnet AF_DECnet +#define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY +#define PF_KEY AF_KEY +#define PF_NETLINK AF_NETLINK +#define PF_ROUTE AF_ROUTE +#define PF_PACKET AF_PACKET +#define PF_ASH AF_ASH +#define PF_ECONET AF_ECONET +#define PF_ATMSVC AF_ATMSVC +#define PF_SNA AF_SNA +#define PF_IRDA AF_IRDA +#define PF_PPPOX AF_PPPOX +#define PF_WANPIPE AF_WANPIPE +#define PF_LLC AF_LLC +#define PF_TIPC AF_TIPC +#define PF_BLUETOOTH AF_BLUETOOTH +#define PF_MAX AF_MAX + +/* Maximum queue length specifiable by listen. */ +#define SOMAXCONN 128 + +/* Flags we can use with send/ and recv. + Added those for 1003.1g not all are supported yet + */ + +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 /* Confirm path validity */ +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ +#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ +#define MSG_MORE 0x8000 /* Sender will send more */ + +#define MSG_EOF MSG_FIN + +struct msghdr { + void * msg_name; /* Socket name */ + int msg_namelen; /* Length of name */ +// struct iovec * msg_iov; /* Data blocks */ + __kernel_size_t msg_iovlen; /* Number of blocks */ + void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + __kernel_size_t msg_controllen; /* Length of cmsg list */ + unsigned msg_flags; +}; + +#endif /* _LINUX_SOCKET_H */ diff --git a/ddverify/models/con1/include/linux/spinlock.h b/ddverify/models/con1/include/linux/spinlock.h new file mode 100644 index 000000000..71531ae4f --- /dev/null +++ b/ddverify/models/con1/include/linux/spinlock.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_SPINLOCK_H +#define __LINUX_SPINLOCK_H + +#include +#include + +// DDV: Bodies for all spinlock-functions are defined in linux/kernel/spinlock.c + +void spin_lock_init(spinlock_t *); +void spin_lock(spinlock_t *); +void spin_lock_irqsave(spinlock_t *, unsigned long); +void spin_lock_irq(spinlock_t *); +void spin_lock_bh(spinlock_t *); + +void spin_unlock(spinlock_t *); +void spin_unlock_irqrestore(spinlock_t *, unsigned long); +void spin_unlock_irq(spinlock_t *); +void spin_unlock_bh(spinlock_t *); + +#endif /* __LINUX_SPINLOCK_H */ diff --git a/ddverify/models/con1/include/linux/spinlock_types.h b/ddverify/models/con1/include/linux/spinlock_types.h new file mode 100644 index 000000000..86dd36d84 --- /dev/null +++ b/ddverify/models/con1/include/linux/spinlock_types.h @@ -0,0 +1,21 @@ +#ifndef __LINUX_SPINLOCK_TYPES_H +#define __LINUX_SPINLOCK_TYPES_H + +typedef struct { + int init; + int locked; +} spinlock_t; + +typedef struct { + int something; +} rwlock_t; + +# define __SPIN_LOCK_UNLOCKED \ + { .init = 1, \ + .locked = 0 } + +#define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED + +#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED + +#endif /* __LINUX_SPINLOCK_TYPES_H */ diff --git a/ddverify/models/con1/include/linux/stat.h b/ddverify/models/con1/include/linux/stat.h new file mode 100644 index 000000000..262124881 --- /dev/null +++ b/ddverify/models/con1/include/linux/stat.h @@ -0,0 +1,66 @@ +#ifndef _LINUX_STAT_H +#define _LINUX_STAT_H + +#include + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) + +#include +#include + +struct kstat { + unsigned long ino; + dev_t dev; +// umode_t mode; + unsigned int nlink; +// uid_t uid; +// gid_t gid; + dev_t rdev; + loff_t size; +// struct timespec atime; +// struct timespec mtime; +// struct timespec ctime; + unsigned long blksize; + unsigned long blocks; +}; + +#endif diff --git a/ddverify/models/con1/include/linux/stddef.h b/ddverify/models/con1/include/linux/stddef.h new file mode 100644 index 000000000..b3a2cadf9 --- /dev/null +++ b/ddverify/models/con1/include/linux/stddef.h @@ -0,0 +1,20 @@ +#ifndef _LINUX_STDDEF_H +#define _LINUX_STDDEF_H + +#include + +#undef NULL +#if defined(__cplusplus) +#define NULL 0 +#else +#define NULL ((void *)0) +#endif + +#undef offsetof +#ifdef __compiler_offsetof +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#endif diff --git a/ddverify/models/con1/include/linux/string.h b/ddverify/models/con1/include/linux/string.h new file mode 100644 index 000000000..9734c2052 --- /dev/null +++ b/ddverify/models/con1/include/linux/string.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_STRING_H_ +#define _LINUX_STRING_H_ + +#include +#include +#include + +extern char * strcpy(char *,const char *); +extern char * strncpy(char *,const char *, __kernel_size_t); +size_t strlcpy(char *, const char *, size_t); +extern char * strcat(char *, const char *); +extern char * strncat(char *, const char *, __kernel_size_t); +extern size_t strlcat(char *, const char *, __kernel_size_t); +extern int strcmp(const char *,const char *); +extern int strncmp(const char *,const char *,__kernel_size_t); +extern int strnicmp(const char *, const char *, __kernel_size_t); +extern char * strchr(const char *,int); +extern char * strnchr(const char *, size_t, int); +extern char * strrchr(const char *,int); +extern char * strstrip(char *); +extern char * strstr(const char *,const char *); +extern __kernel_size_t strlen(const char *); +extern __kernel_size_t strnlen(const char *,__kernel_size_t); +extern char * strpbrk(const char *,const char *); +extern char * strsep(char **,const char *); +extern __kernel_size_t strspn(const char *,const char *); +extern __kernel_size_t strcspn(const char *,const char *); + +extern void * memset(void *,int,__kernel_size_t); +extern void * memcpy(void *,const void *,__kernel_size_t); +extern void * memmove(void *,const void *,__kernel_size_t); +extern void * memscan(void *,int,__kernel_size_t); +extern int memcmp(const void *,const void *,__kernel_size_t); +extern void * memchr(const void *,int,__kernel_size_t); +#endif /* _LINUX_STRING_H_ */ diff --git a/ddverify/models/con1/include/linux/stringify.h b/ddverify/models/con1/include/linux/stringify.h new file mode 100644 index 000000000..0b4388356 --- /dev/null +++ b/ddverify/models/con1/include/linux/stringify.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H + +/* Indirect stringification. Doing two levels allows the parameter to be a + * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) + * converts to "bar". + */ + +#define __stringify_1(x) #x +#define __stringify(x) __stringify_1(x) + +#endif /* !__LINUX_STRINGIFY_H */ diff --git a/ddverify/models/con1/include/linux/suspend.h b/ddverify/models/con1/include/linux/suspend.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/swap.h b/ddverify/models/con1/include/linux/swap.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/sysfs.h b/ddverify/models/con1/include/linux/sysfs.h new file mode 100644 index 000000000..4e1dd65ae --- /dev/null +++ b/ddverify/models/con1/include/linux/sysfs.h @@ -0,0 +1,43 @@ +#ifndef _SYSFS_H_ +#define _SYSFS_H_ + +#include +#include + +struct kobject; +struct module; + +struct attribute { + const char * name; + struct module * owner; + mode_t mode; +}; + +struct attribute_group { + const char * name; + struct attribute ** attrs; +}; + + + +/** + * Use these macros to make defining attributes easier. See include/linux/device.h + * for examples.. + */ + +#define __ATTR(_name,_mode,_show,_store) { \ + .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \ + .show = _show, \ + .store = _store, \ +} + +#define __ATTR_RO(_name) { \ + .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \ + .show = _name##_show, \ +} + +#define __ATTR_NULL { .attr = { .name = NULL } } + +#define attr_name(_attr) (_attr).attr.name + +#endif /* _SYSFS_H_ */ diff --git a/ddverify/models/con1/include/linux/sysrq.h b/ddverify/models/con1/include/linux/sysrq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/linux/termios.h b/ddverify/models/con1/include/linux/termios.h new file mode 100644 index 000000000..758803c4c --- /dev/null +++ b/ddverify/models/con1/include/linux/termios.h @@ -0,0 +1,7 @@ +#ifndef _LINUX_TERMIOS_H +#define _LINUX_TERMIOS_H + +#include +#include + +#endif diff --git a/ddverify/models/con1/include/linux/time.h b/ddverify/models/con1/include/linux/time.h new file mode 100644 index 000000000..907f53e8e --- /dev/null +++ b/ddverify/models/con1/include/linux/time.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_TIME_H +#define _LINUX_TIME_H + +#include + +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; + + +/* Parameters used to convert the timespec values: */ +#define MSEC_PER_SEC 1000L +#define USEC_PER_MSEC 1000L +#define NSEC_PER_USEC 1000L +#define NSEC_PER_MSEC 1000000L +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L +#define FSEC_PER_SEC 1000000000000000L + + +void do_gettimeofday(struct timeval *tv); + +#endif + diff --git a/ddverify/models/con1/include/linux/timer.h b/ddverify/models/con1/include/linux/timer.h new file mode 100644 index 000000000..a531db358 --- /dev/null +++ b/ddverify/models/con1/include/linux/timer.h @@ -0,0 +1,34 @@ +#ifndef _LINUX_TIMER_H +#define _LINUX_TIMER_H + +struct timer_list { + unsigned long expires; + void (*function)(unsigned long); + unsigned long data; + + short __ddv_active; + short __ddv_init; +}; + +#define TIMER_INITIALIZER(_function, _expires, _data) { \ + .function = (_function), \ + .expires = (_expires), \ + .data = (_data), \ + .__ddv_init = 1, \ + } + + +#define DEFINE_TIMER(_name, _function, _expires, _data) \ + struct timer_list _name = \ + TIMER_INITIALIZER(_function, _expires, _data) + +// DDV: Bodies for the following functions are defined in linux/kernel/timer.c +void init_timer(struct timer_list * timer); +void add_timer_on(struct timer_list *timer, int cpu); +void add_timer(struct timer_list *timer); +int del_timer(struct timer_list * timer); +int mod_timer(struct timer_list *timer, unsigned long expires); + +#define del_timer_sync(t) del_timer(t) + +#endif diff --git a/ddverify/models/con1/include/linux/tty.h b/ddverify/models/con1/include/linux/tty.h new file mode 100644 index 000000000..5bde39f3c --- /dev/null +++ b/ddverify/models/con1/include/linux/tty.h @@ -0,0 +1,180 @@ +#ifndef _LINUX_TTY_H +#define _LINUX_TTY_H + +#include +#include +#include +#include +#include +#include +#include + +#include + + +/* + * The pty uses char_buf and flag_buf as a contiguous buffer + */ +#define PTY_BUF_SIZE 4*TTY_FLIPBUF_SIZE + +/* + * When a break, frame error, or parity error happens, these codes are + * stuffed into the flags buffer. + */ +#define TTY_NORMAL 0 +#define TTY_BREAK 1 +#define TTY_FRAME 2 +#define TTY_PARITY 3 +#define TTY_OVERRUN 4 + + +#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR]) +#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT]) +#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE]) +#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL]) +#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF]) +#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME]) +#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN]) +#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC]) +#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART]) +#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP]) +#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP]) +#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL]) +#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT]) +#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD]) +#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE]) +#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) +#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) + +#define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f)) +#define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f)) +#define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f)) +#define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f)) + +#define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK) +#define I_BRKINT(tty) _I_FLAG((tty),BRKINT) +#define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR) +#define I_PARMRK(tty) _I_FLAG((tty),PARMRK) +#define I_INPCK(tty) _I_FLAG((tty),INPCK) +#define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP) +#define I_INLCR(tty) _I_FLAG((tty),INLCR) +#define I_IGNCR(tty) _I_FLAG((tty),IGNCR) +#define I_ICRNL(tty) _I_FLAG((tty),ICRNL) +#define I_IUCLC(tty) _I_FLAG((tty),IUCLC) +#define I_IXON(tty) _I_FLAG((tty),IXON) +#define I_IXANY(tty) _I_FLAG((tty),IXANY) +#define I_IXOFF(tty) _I_FLAG((tty),IXOFF) +#define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL) +#define I_IUTF8(tty) _I_FLAG((tty),IUTF8) + +#define O_OPOST(tty) _O_FLAG((tty),OPOST) +#define O_OLCUC(tty) _O_FLAG((tty),OLCUC) +#define O_ONLCR(tty) _O_FLAG((tty),ONLCR) +#define O_OCRNL(tty) _O_FLAG((tty),OCRNL) +#define O_ONOCR(tty) _O_FLAG((tty),ONOCR) +#define O_ONLRET(tty) _O_FLAG((tty),ONLRET) +#define O_OFILL(tty) _O_FLAG((tty),OFILL) +#define O_OFDEL(tty) _O_FLAG((tty),OFDEL) +#define O_NLDLY(tty) _O_FLAG((tty),NLDLY) +#define O_CRDLY(tty) _O_FLAG((tty),CRDLY) +#define O_TABDLY(tty) _O_FLAG((tty),TABDLY) +#define O_BSDLY(tty) _O_FLAG((tty),BSDLY) +#define O_VTDLY(tty) _O_FLAG((tty),VTDLY) +#define O_FFDLY(tty) _O_FLAG((tty),FFDLY) + +#define C_BAUD(tty) _C_FLAG((tty),CBAUD) +#define C_CSIZE(tty) _C_FLAG((tty),CSIZE) +#define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB) +#define C_CREAD(tty) _C_FLAG((tty),CREAD) +#define C_PARENB(tty) _C_FLAG((tty),PARENB) +#define C_PARODD(tty) _C_FLAG((tty),PARODD) +#define C_HUPCL(tty) _C_FLAG((tty),HUPCL) +#define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL) +#define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD) +#define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS) + +#define L_ISIG(tty) _L_FLAG((tty),ISIG) +#define L_ICANON(tty) _L_FLAG((tty),ICANON) +#define L_XCASE(tty) _L_FLAG((tty),XCASE) +#define L_ECHO(tty) _L_FLAG((tty),ECHO) +#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) +#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) +#define L_ECHONL(tty) _L_FLAG((tty),ECHONL) +#define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH) +#define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP) +#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) +#define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT) +#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) +#define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO) +#define L_PENDIN(tty) _L_FLAG((tty),PENDIN) +#define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN) + + +struct tty_struct { + int magic; + struct tty_driver *driver; + int index; + struct termios *termios, *termios_locked; + char name[64]; + + unsigned long flags; + int count; + unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; + unsigned int receive_room; /* Bytes free for queue */ + + wait_queue_head_t write_wait; + wait_queue_head_t read_wait; + void *disc_data; + void *driver_data; + + unsigned char closing:1; +}; + + +/* tty magic number */ +#define TTY_MAGIC 0x5401 + +/* + * These bits are used in the flags field of the tty structure. + * + * So that interrupts won't be able to mess up the queues, + * copy_to_cooked must be atomic with respect to itself, as must + * tty->write. Thus, you must use the inline functions set_bit() and + * clear_bit() to make things atomic. + */ +#define TTY_THROTTLED 0 /* Call unthrottle() at threshold min */ +#define TTY_IO_ERROR 1 /* Canse an I/O error (may be no ldisc too) */ +#define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */ +#define TTY_EXCLUSIVE 3 /* Exclusive open mode */ +#define TTY_DEBUG 4 /* Debugging */ +#define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */ +#define TTY_PUSH 6 /* n_tty private */ +#define TTY_CLOSING 7 /* ->close() in progress */ +#define TTY_LDISC 9 /* Line discipline attached */ +#define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */ +#define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */ +#define TTY_PTY_LOCK 16 /* pty private */ +#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ +#define TTY_HUPPED 18 /* Post driver->hangup() */ + +extern struct termios tty_std_termios; + + +extern int tty_check_change(struct tty_struct * tty); +extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); +extern int tty_unregister_ldisc(int disc); +extern int tty_register_driver(struct tty_driver *driver); +extern int tty_unregister_driver(struct tty_driver *driver); + +extern void tty_wait_until_sent(struct tty_struct * tty, long timeout); + + +extern void tty_hangup(struct tty_struct * tty); +extern int tty_hung_up_p(struct file * filp); +extern void do_SAK(struct tty_struct *tty); +extern void tty_flip_buffer_push(struct tty_struct *tty); +extern int tty_get_baud_rate(struct tty_struct *tty); + +extern void tty_wakeup(struct tty_struct *tty); +extern void tty_ldisc_flush(struct tty_struct *tty); +#endif diff --git a/ddverify/models/con1/include/linux/tty_driver.h b/ddverify/models/con1/include/linux/tty_driver.h new file mode 100644 index 000000000..805c70977 --- /dev/null +++ b/ddverify/models/con1/include/linux/tty_driver.h @@ -0,0 +1,166 @@ +#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +// DDV: TODO +void put_tty_driver(struct tty_driver *driver); +// DDV: is defined in driver/char/tty_io.c +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ diff --git a/ddverify/models/con1/include/linux/tty_driver.h,v b/ddverify/models/con1/include/linux/tty_driver.h,v new file mode 100644 index 000000000..f5748324d --- /dev/null +++ b/ddverify/models/con1/include/linux/tty_driver.h,v @@ -0,0 +1,187 @@ +head 1.1; +access; +symbols; +locks; strict; +comment @ * @; + + +1.1 +date 2007.02.11.11.29.05; author thomaswi; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@Initial revision +@ +text +@#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: Body of this function is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +void put_tty_driver(struct tty_driver *driver); +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ +@ diff --git a/ddverify/models/con1/include/linux/tty_flip.h b/ddverify/models/con1/include/linux/tty_flip.h new file mode 100644 index 000000000..b0864fa14 --- /dev/null +++ b/ddverify/models/con1/include/linux/tty_flip.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_TTY_FLIP_H +#define _LINUX_TTY_FLIP_H + +int tty_buffer_request_room(struct tty_struct *tty, size_t size); +int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size); +int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); +int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); +int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); +void tty_schedule_flip(struct tty_struct *tty); + +inline int tty_insert_flip_char(struct tty_struct *tty, unsigned char ch, char flag); + +#endif /* _LINUX_TTY_FLIP_H */ diff --git a/ddverify/models/con1/include/linux/tty_ldisc.h b/ddverify/models/con1/include/linux/tty_ldisc.h new file mode 100644 index 000000000..35466133a --- /dev/null +++ b/ddverify/models/con1/include/linux/tty_ldisc.h @@ -0,0 +1,51 @@ +#ifndef _LINUX_TTY_LDISC_H +#define _LINUX_TTY_LDISC_H + + +#include +#include + +struct tty_ldisc { + int magic; + char *name; + int num; + int flags; + + /* + * The following routines are called from above. + */ + int (*open)(struct tty_struct *); + void (*close)(struct tty_struct *); + void (*flush_buffer)(struct tty_struct *tty); + ssize_t (*chars_in_buffer)(struct tty_struct *tty); + ssize_t (*read)(struct tty_struct * tty, struct file * file, + unsigned char __user * buf, size_t nr); + ssize_t (*write)(struct tty_struct * tty, struct file * file, + const unsigned char * buf, size_t nr); + int (*ioctl)(struct tty_struct * tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + unsigned int (*poll)(struct tty_struct *, struct file *, + struct poll_table_struct *); + int (*hangup)(struct tty_struct *tty); + + /* + * The following routines are called from below. + */ + void (*receive_buf)(struct tty_struct *, const unsigned char *cp, + char *fp, int count); + void (*write_wakeup)(struct tty_struct *); + + struct module *owner; + + int refcount; +}; + +#define TTY_LDISC_MAGIC 0x5403 + +#define LDISC_FLAG_DEFINED 0x00000001 + +#define MODULE_ALIAS_LDISC(ldisc) \ + MODULE_ALIAS("tty-ldisc-" __stringify(ldisc)) + +#endif /* _LINUX_TTY_LDISC_H */ diff --git a/ddverify/models/con1/include/linux/types.h b/ddverify/models/con1/include/linux/types.h new file mode 100644 index 000000000..b437e9baa --- /dev/null +++ b/ddverify/models/con1/include/linux/types.h @@ -0,0 +1,105 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#include +#include + +#define __bitwise + +typedef __u32 __kernel_dev_t; + +typedef __kernel_dev_t dev_t; +typedef __kernel_ino_t ino_t; +typedef __kernel_mode_t mode_t; +typedef __kernel_nlink_t nlink_t; +typedef __kernel_off_t off_t; +typedef __kernel_pid_t pid_t; +typedef __kernel_daddr_t daddr_t; +typedef __kernel_key_t key_t; +typedef __kernel_suseconds_t suseconds_t; +typedef __kernel_timer_t timer_t; +typedef __kernel_clockid_t clockid_t; +typedef __kernel_mqd_t mqd_t; + +typedef __kernel_uid32_t uid_t; +typedef __kernel_gid32_t gid_t; +typedef __kernel_uid16_t uid16_t; +typedef __kernel_gid16_t gid16_t; + + +typedef long long loff_t; + +/* + * The following typedefs are also protected by individual ifdefs for + * historical reasons: + */ +#ifndef _SIZE_T +#define _SIZE_T +typedef __kernel_size_t size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __kernel_ssize_t ssize_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef __kernel_ptrdiff_t ptrdiff_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef __kernel_time_t time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef __kernel_clock_t clock_t; +#endif + +#ifndef _CADDR_T +#define _CADDR_T +typedef __kernel_caddr_t caddr_t; +#endif + + +/* bsd */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +/* sysv */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + + +typedef __u8 uint8_t; +typedef __u16 uint16_t; +typedef __u32 uint32_t; + +typedef __u64 uint64_t; +typedef __u64 u_int64_t; +//typedef __s64 int64_t; + +typedef unsigned gfp_t; + +#ifndef HAVE_SECTOR_T +typedef unsigned long sector_t; +#endif + +#ifndef HAVE_BLKCNT_T +typedef unsigned long blkcnt_t; +#endif + +typedef __u16 __bitwise __le16; +typedef __u16 __bitwise __be16; +typedef __u32 __bitwise __le32; +typedef __u32 __bitwise __be32; +typedef __u64 __bitwise __le64; +typedef __u64 __bitwise __be64; + +#endif diff --git a/ddverify/models/con1/include/linux/uio.h b/ddverify/models/con1/include/linux/uio.h new file mode 100644 index 000000000..c59931d23 --- /dev/null +++ b/ddverify/models/con1/include/linux/uio.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_UIO_H +#define __LINUX_UIO_H + +#include +#include + +struct kvec { + void *iov_base; /* and that should *never* hold a userland pointer */ + size_t iov_len; +}; + +#endif diff --git a/ddverify/models/con1/include/linux/videodev.h b/ddverify/models/con1/include/linux/videodev.h new file mode 100644 index 000000000..2628e86ac --- /dev/null +++ b/ddverify/models/con1/include/linux/videodev.h @@ -0,0 +1,346 @@ +#ifndef __LINUX_VIDEODEV_H +#define __LINUX_VIDEODEV_H + +#include +#include +#include + +extern struct video_device* video_devdata(struct file*); + +static inline void *video_get_drvdata(struct video_device *dev) +{ + return dev->priv; +} + +static inline void video_set_drvdata(struct video_device *dev, void *data) +{ + dev->priv = data; +} + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +struct video_capability +{ + char name[32]; + int type; + int channels; /* Num channels */ + int audios; /* Num audio devices */ + int maxwidth; /* Supported width */ + int maxheight; /* And height */ + int minwidth; /* Supported width */ + int minheight; /* And height */ +}; + + +struct video_channel +{ + int channel; + char name[32]; + int tuners; + __u32 flags; +#define VIDEO_VC_TUNER 1 /* Channel has a tuner */ +#define VIDEO_VC_AUDIO 2 /* Channel has audio */ + __u16 type; +#define VIDEO_TYPE_TV 1 +#define VIDEO_TYPE_CAMERA 2 + __u16 norm; /* Norm set by channel */ +}; + + +struct video_tuner +{ + int tuner; + char name[32]; + unsigned long rangelow, rangehigh; /* Tuner range */ + __u32 flags; +#define VIDEO_TUNER_PAL 1 +#define VIDEO_TUNER_NTSC 2 +#define VIDEO_TUNER_SECAM 4 +#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */ +#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */ +#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */ +#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */ +#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */ + __u16 mode; /* PAL/NTSC/SECAM/OTHER */ +#define VIDEO_MODE_PAL 0 +#define VIDEO_MODE_NTSC 1 +#define VIDEO_MODE_SECAM 2 +#define VIDEO_MODE_AUTO 3 + __u16 signal; /* Signal strength 16bit scale */ +}; + + +struct video_picture +{ + __u16 brightness; + __u16 hue; + __u16 colour; + __u16 contrast; + __u16 whiteness; /* Black and white only */ + __u16 depth; /* Capture depth */ + __u16 palette; /* Palette in use */ +#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ +#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ +#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ +#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */ +#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */ +#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */ +#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */ +#define VIDEO_PALETTE_YUYV 8 +#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */ +#define VIDEO_PALETTE_YUV420 10 +#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */ +#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */ +#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */ +#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */ +#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */ +#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ +#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ +#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ +}; + +struct video_audio +{ + int audio; /* Audio channel */ + __u16 volume; /* If settable */ + __u16 bass, treble; + __u32 flags; +#define VIDEO_AUDIO_MUTE 1 +#define VIDEO_AUDIO_MUTABLE 2 +#define VIDEO_AUDIO_VOLUME 4 +#define VIDEO_AUDIO_BASS 8 +#define VIDEO_AUDIO_TREBLE 16 +#define VIDEO_AUDIO_BALANCE 32 + char name[16]; +#define VIDEO_SOUND_MONO 1 +#define VIDEO_SOUND_STEREO 2 +#define VIDEO_SOUND_LANG1 4 +#define VIDEO_SOUND_LANG2 8 + __u16 mode; + __u16 balance; /* Stereo balance */ + __u16 step; /* Step actual volume uses */ +}; + +struct video_clip +{ + __s32 x,y; + __s32 width, height; + struct video_clip *next; /* For user use/driver use only */ +}; + +struct video_window +{ + __u32 x,y; /* Position of window */ + __u32 width,height; /* Its size */ + __u32 chromakey; + __u32 flags; + struct video_clip __user *clips; /* Set only */ + int clipcount; +#define VIDEO_WINDOW_INTERLACE 1 +#define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */ +#define VIDEO_CLIP_BITMAP -1 +/* bitmap is 1024x625, a '1' bit represents a clipped pixel */ +#define VIDEO_CLIPMAP_SIZE (128 * 625) +}; + +struct video_capture +{ + __u32 x,y; /* Offsets into image */ + __u32 width, height; /* Area to capture */ + __u16 decimation; /* Decimation divider */ + __u16 flags; /* Flags for capture */ +#define VIDEO_CAPTURE_ODD 0 /* Temporal */ +#define VIDEO_CAPTURE_EVEN 1 +}; + +struct video_buffer +{ + void *base; + int height,width; + int depth; + int bytesperline; +}; + +struct video_mmap +{ + unsigned int frame; /* Frame (0 - n) for double buffer */ + int height,width; + unsigned int format; /* should be VIDEO_PALETTE_* */ +}; + +struct video_key +{ + __u8 key[8]; + __u32 flags; +}; + +struct video_mbuf +{ + int size; /* Total memory to map */ + int frames; /* Frames */ + int offsets[VIDEO_MAX_FRAME]; +}; + +#define VIDEO_NO_UNIT (-1) + +struct video_unit +{ + int video; /* Video minor */ + int vbi; /* VBI minor */ + int radio; /* Radio minor */ + int audio; /* Audio minor */ + int teletext; /* Teletext minor */ +}; + +struct vbi_format { + __u32 sampling_rate; /* in Hz */ + __u32 samples_per_line; + __u32 sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */ + __s32 start[2]; /* starting line for each frame */ + __u32 count[2]; /* count of lines for each frame */ + __u32 flags; +#define VBI_UNSYNC 1 /* can distingues between top/bottom field */ +#define VBI_INTERLACED 2 /* lines are interlaced */ +}; + +/* video_info is biased towards hardware mpeg encode/decode */ +/* but it could apply generically to any hardware compressor/decompressor */ +struct video_info +{ + __u32 frame_count; /* frames output since decode/encode began */ + __u32 h_size; /* current unscaled horizontal size */ + __u32 v_size; /* current unscaled veritcal size */ + __u32 smpte_timecode; /* current SMPTE timecode (for current GOP) */ + __u32 picture_type; /* current picture type */ + __u32 temporal_reference; /* current temporal reference */ + __u8 user_data[256]; /* user data last found in compressed stream */ + /* user_data[0] contains user data flags, user_data[1] has count */ +}; + +/* generic structure for setting playback modes */ +struct video_play_mode +{ + int mode; + int p1; + int p2; +}; + +/* for loading microcode / fpga programming */ +struct video_code +{ + char loadwhat[16]; /* name or tag of file being passed */ + int datasize; + __u8 *data; +}; + + +#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */ +#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */ +#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */ +#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */ +#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */ +#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */ +#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */ +#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */ +#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */ +#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */ +#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */ +#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */ +#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) */ +#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */ +#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */ +#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */ +#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */ +#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */ +#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */ +#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */ +#define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */ +#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */ +#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */ +#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */ +#define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */ +#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */ +#define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */ +#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */ +#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */ + + +#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */ + +/* VIDIOCSWRITEMODE */ +#define VID_WRITE_MPEG_AUD 0 +#define VID_WRITE_MPEG_VID 1 +#define VID_WRITE_OSD 2 +#define VID_WRITE_TTX 3 +#define VID_WRITE_CC 4 +#define VID_WRITE_MJPEG 5 + +/* VIDIOCSPLAYMODE */ +#define VID_PLAY_VID_OUT_MODE 0 + /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */ +#define VID_PLAY_GENLOCK 1 + /* p1: 0 = OFF, 1 = ON */ + /* p2: GENLOCK FINE DELAY value */ +#define VID_PLAY_NORMAL 2 +#define VID_PLAY_PAUSE 3 +#define VID_PLAY_SINGLE_FRAME 4 +#define VID_PLAY_FAST_FORWARD 5 +#define VID_PLAY_SLOW_MOTION 6 +#define VID_PLAY_IMMEDIATE_NORMAL 7 +#define VID_PLAY_SWITCH_CHANNELS 8 +#define VID_PLAY_FREEZE_FRAME 9 +#define VID_PLAY_STILL_MODE 10 +#define VID_PLAY_MASTER_MODE 11 + /* p1: see below */ +#define VID_PLAY_MASTER_NONE 1 +#define VID_PLAY_MASTER_VIDEO 2 +#define VID_PLAY_MASTER_AUDIO 3 +#define VID_PLAY_ACTIVE_SCANLINES 12 + /* p1 = first active; p2 = last active */ +#define VID_PLAY_RESET 13 +#define VID_PLAY_END_MARK 14 + + + +#define VID_HARDWARE_BT848 1 +#define VID_HARDWARE_QCAM_BW 2 +#define VID_HARDWARE_PMS 3 +#define VID_HARDWARE_QCAM_C 4 +#define VID_HARDWARE_PSEUDO 5 +#define VID_HARDWARE_SAA5249 6 +#define VID_HARDWARE_AZTECH 7 +#define VID_HARDWARE_SF16MI 8 +#define VID_HARDWARE_RTRACK 9 +#define VID_HARDWARE_ZOLTRIX 10 +#define VID_HARDWARE_SAA7146 11 +#define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */ +#define VID_HARDWARE_RTRACK2 13 +#define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */ +#define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */ +#define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */ +#define VID_HARDWARE_BROADWAY 17 /* Broadway project */ +#define VID_HARDWARE_GEMTEK 18 +#define VID_HARDWARE_TYPHOON 19 +#define VID_HARDWARE_VINO 20 /* SGI Indy Vino */ +#define VID_HARDWARE_CADET 21 /* Cadet radio */ +#define VID_HARDWARE_TRUST 22 /* Trust FM Radio */ +#define VID_HARDWARE_TERRATEC 23 /* TerraTec ActiveRadio */ +#define VID_HARDWARE_CPIA 24 +#define VID_HARDWARE_ZR36120 25 /* Zoran ZR36120/ZR36125 */ +#define VID_HARDWARE_ZR36067 26 /* Zoran ZR36067/36060 */ +#define VID_HARDWARE_OV511 27 +#define VID_HARDWARE_ZR356700 28 /* Zoran 36700 series */ +#define VID_HARDWARE_W9966 29 +#define VID_HARDWARE_SE401 30 /* SE401 USB webcams */ +#define VID_HARDWARE_PWC 31 /* Philips webcams */ +#define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */ +#define VID_HARDWARE_CPIA2 33 +#define VID_HARDWARE_VICAM 34 +#define VID_HARDWARE_SF16FMR2 35 +#define VID_HARDWARE_W9968CF 36 +#define VID_HARDWARE_SAA7114H 37 +#define VID_HARDWARE_SN9C102 38 +#define VID_HARDWARE_ARV 39 + +#endif /* __LINUX_VIDEODEV_H */ diff --git a/ddverify/models/con1/include/linux/videodev2.h b/ddverify/models/con1/include/linux/videodev2.h new file mode 100644 index 000000000..df5c46543 --- /dev/null +++ b/ddverify/models/con1/include/linux/videodev2.h @@ -0,0 +1,1351 @@ +/* + * Video for Linux Two + * + * Header file for v4l or V4L2 drivers and applications + * with public API. + * All kernel-specific stuff were moved to media/v4l2-dev.h, so + * no #if __KERNEL tests are allowed here + * + * See http://linuxtv.org for more info + * + * Author: Bill Dirks + * Justin Schoeman + * et al. + */ +#ifndef __LINUX_VIDEODEV2_H +#define __LINUX_VIDEODEV2_H +#ifdef __KERNEL__ +#include /* need struct timeval */ +#include /* need __user */ +#else +#define __user +#endif +#include + +/* + * Common stuff for both V4L1 and V4L2 + * Moved from videodev.h + */ +#define VIDEO_MAX_FRAME 32 + +#define VID_TYPE_CAPTURE 1 /* Can capture */ +#define VID_TYPE_TUNER 2 /* Can tune */ +#define VID_TYPE_TELETEXT 4 /* Does teletext */ +#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */ +#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */ +#define VID_TYPE_CLIPPING 32 /* Can clip */ +#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */ +#define VID_TYPE_SCALES 128 /* Scalable */ +#define VID_TYPE_MONOCHROME 256 /* Monochrome only */ +#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */ +#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */ +#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ +#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ +#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ + +/* + * M I S C E L L A N E O U S + */ + +/* Four-character-code (FOURCC) */ +#define v4l2_fourcc(a,b,c,d)\ + (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) + +/* + * E N U M S + */ +enum v4l2_field { + V4L2_FIELD_ANY = 0, /* driver can choose from none, + top, bottom, interlaced + depending on whatever it thinks + is approximate ... */ + V4L2_FIELD_NONE = 1, /* this device has no fields ... */ + V4L2_FIELD_TOP = 2, /* top field only */ + V4L2_FIELD_BOTTOM = 3, /* bottom field only */ + V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ + V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one + buffer, top-bottom order */ + V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ + V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into + separate buffers */ +}; +#define V4L2_FIELD_HAS_TOP(field) \ + ((field) == V4L2_FIELD_TOP ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTTOM(field) \ + ((field) == V4L2_FIELD_BOTTOM ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTH(field) \ + ((field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) + +enum v4l2_buf_type { + V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, + V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, + V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, + V4L2_BUF_TYPE_VBI_CAPTURE = 4, + V4L2_BUF_TYPE_VBI_OUTPUT = 5, +#if 1 + /* Experimental Sliced VBI */ + V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, + V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, +#endif + V4L2_BUF_TYPE_PRIVATE = 0x80, +}; + +enum v4l2_ctrl_type { + V4L2_CTRL_TYPE_INTEGER = 1, + V4L2_CTRL_TYPE_BOOLEAN = 2, + V4L2_CTRL_TYPE_MENU = 3, + V4L2_CTRL_TYPE_BUTTON = 4, + V4L2_CTRL_TYPE_INTEGER64 = 5, + V4L2_CTRL_TYPE_CTRL_CLASS = 6, +}; + +enum v4l2_tuner_type { + V4L2_TUNER_RADIO = 1, + V4L2_TUNER_ANALOG_TV = 2, + V4L2_TUNER_DIGITAL_TV = 3, +}; + +enum v4l2_memory { + V4L2_MEMORY_MMAP = 1, + V4L2_MEMORY_USERPTR = 2, + V4L2_MEMORY_OVERLAY = 3, +}; + +/* see also http://vektor.theorem.ca/graphics/ycbcr/ */ +enum v4l2_colorspace { + /* ITU-R 601 -- broadcast NTSC/PAL */ + V4L2_COLORSPACE_SMPTE170M = 1, + + /* 1125-Line (US) HDTV */ + V4L2_COLORSPACE_SMPTE240M = 2, + + /* HD and modern captures. */ + V4L2_COLORSPACE_REC709 = 3, + + /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */ + V4L2_COLORSPACE_BT878 = 4, + + /* These should be useful. Assume 601 extents. */ + V4L2_COLORSPACE_470_SYSTEM_M = 5, + V4L2_COLORSPACE_470_SYSTEM_BG = 6, + + /* I know there will be cameras that send this. So, this is + * unspecified chromaticities and full 0-255 on each of the + * Y'CbCr components + */ + V4L2_COLORSPACE_JPEG = 7, + + /* For RGB colourspaces, this is probably a good start. */ + V4L2_COLORSPACE_SRGB = 8, +}; + +enum v4l2_priority { + V4L2_PRIORITY_UNSET = 0, /* not initialized */ + V4L2_PRIORITY_BACKGROUND = 1, + V4L2_PRIORITY_INTERACTIVE = 2, + V4L2_PRIORITY_RECORD = 3, + V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE, +}; + +struct v4l2_rect { + __s32 left; + __s32 top; + __s32 width; + __s32 height; +}; + +struct v4l2_fract { + __u32 numerator; + __u32 denominator; +}; + +/* + * D R I V E R C A P A B I L I T I E S + */ +struct v4l2_capability +{ + __u8 driver[16]; /* i.e. "bttv" */ + __u8 card[32]; /* i.e. "Hauppauge WinTV" */ + __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ + __u32 version; /* should use KERNEL_VERSION() */ + __u32 capabilities; /* Device capabilities */ + __u32 reserved[4]; +}; + +/* Values for 'capabilities' field */ +#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ +#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ +#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ +#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ +#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ +#if 1 +#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ +#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ +#endif +#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ + +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ +#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ + +#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ +#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ +#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ + +/* + * V I D E O I M A G E F O R M A T + */ +struct v4l2_pix_format +{ + __u32 width; + __u32 height; + __u32 pixelformat; + enum v4l2_field field; + __u32 bytesperline; /* for padding, zero if unused */ + __u32 sizeimage; + enum v4l2_colorspace colorspace; + __u32 priv; /* private data, depends on pixelformat */ +}; + +/* Pixel format FOURCC depth Description */ +#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */ +#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */ +#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */ +#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */ +#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */ +#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */ +#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */ +#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ +#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ +#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ +#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ +#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ +#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */ +#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */ +#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */ + +/* two planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */ + +/* The following formats are not defined in the V4L2 specification */ +#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */ +#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ +#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ +#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */ + +/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ +#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ + +/* compressed formats */ +#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ +#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */ +#define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */ +#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG-1/2/4 */ + +/* Vendor-specific formats */ +#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */ +#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */ + +/* + * F O R M A T E N U M E R A T I O N + */ +struct v4l2_fmtdesc +{ + __u32 index; /* Format number */ + enum v4l2_buf_type type; /* buffer type */ + __u32 flags; + __u8 description[32]; /* Description string */ + __u32 pixelformat; /* Format fourcc */ + __u32 reserved[4]; +}; + +#define V4L2_FMT_FLAG_COMPRESSED 0x0001 + +#if 1 + /* Experimental Frame Size and frame rate enumeration */ +/* + * F R A M E S I Z E E N U M E R A T I O N + */ +enum v4l2_frmsizetypes +{ + V4L2_FRMSIZE_TYPE_DISCRETE = 1, + V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, + V4L2_FRMSIZE_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmsize_discrete +{ + __u32 width; /* Frame width [pixel] */ + __u32 height; /* Frame height [pixel] */ +}; + +struct v4l2_frmsize_stepwise +{ + __u32 min_width; /* Minimum frame width [pixel] */ + __u32 max_width; /* Maximum frame width [pixel] */ + __u32 step_width; /* Frame width step size [pixel] */ + __u32 min_height; /* Minimum frame height [pixel] */ + __u32 max_height; /* Maximum frame height [pixel] */ + __u32 step_height; /* Frame height step size [pixel] */ +}; + +struct v4l2_frmsizeenum +{ + __u32 index; /* Frame size number */ + __u32 pixel_format; /* Pixel format */ + __u32 type; /* Frame size type the device supports. */ + + union { /* Frame size */ + struct v4l2_frmsize_discrete discrete; + struct v4l2_frmsize_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; + +/* + * F R A M E R A T E E N U M E R A T I O N + */ +enum v4l2_frmivaltypes +{ + V4L2_FRMIVAL_TYPE_DISCRETE = 1, + V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, + V4L2_FRMIVAL_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmival_stepwise +{ + struct v4l2_fract min; /* Minimum frame interval [s] */ + struct v4l2_fract max; /* Maximum frame interval [s] */ + struct v4l2_fract step; /* Frame interval step size [s] */ +}; + +struct v4l2_frmivalenum +{ + __u32 index; /* Frame format index */ + __u32 pixel_format; /* Pixel format */ + __u32 width; /* Frame width */ + __u32 height; /* Frame height */ + __u32 type; /* Frame interval type the device supports. */ + + union { /* Frame interval */ + struct v4l2_fract discrete; + struct v4l2_frmival_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; +#endif + +/* + * T I M E C O D E + */ +struct v4l2_timecode +{ + __u32 type; + __u32 flags; + __u8 frames; + __u8 seconds; + __u8 minutes; + __u8 hours; + __u8 userbits[4]; +}; + +/* Type */ +#define V4L2_TC_TYPE_24FPS 1 +#define V4L2_TC_TYPE_25FPS 2 +#define V4L2_TC_TYPE_30FPS 3 +#define V4L2_TC_TYPE_50FPS 4 +#define V4L2_TC_TYPE_60FPS 5 + +/* Flags */ +#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */ +#define V4L2_TC_FLAG_COLORFRAME 0x0002 +#define V4L2_TC_USERBITS_field 0x000C +#define V4L2_TC_USERBITS_USERDEFINED 0x0000 +#define V4L2_TC_USERBITS_8BITCHARS 0x0008 +/* The above is based on SMPTE timecodes */ + +#ifdef __KERNEL__ +/* + * 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 + * + * ### WARNING: This experimental MPEG compression API is obsolete. + * ### It is replaced by the MPEG controls API. + * ### This old API will disappear in the near future! + * + */ +enum v4l2_bitrate_mode { + V4L2_BITRATE_NONE = 0, /* not specified */ + V4L2_BITRATE_CBR, /* constant bitrate */ + V4L2_BITRATE_VBR, /* variable bitrate */ +}; +struct v4l2_bitrate { + /* rates are specified in kbit/sec */ + enum v4l2_bitrate_mode mode; + __u32 min; + __u32 target; /* use this one for CBR */ + __u32 max; +}; + +enum v4l2_mpeg_streamtype { + V4L2_MPEG_SS_1, /* MPEG-1 system stream */ + V4L2_MPEG_PS_2, /* MPEG-2 program stream */ + V4L2_MPEG_TS_2, /* MPEG-2 transport stream */ + V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */ +}; +enum v4l2_mpeg_audiotype { + V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */ + V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */ + V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */ + V4L2_MPEG_AC3, /* AC3 */ + V4L2_MPEG_LPCM, /* LPCM */ +}; +enum v4l2_mpeg_videotype { + V4L2_MPEG_VI_1, /* MPEG-1 */ + V4L2_MPEG_VI_2, /* MPEG-2 */ +}; +enum v4l2_mpeg_aspectratio { + V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */ + V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */ + V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */ + V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */ +}; + +struct v4l2_mpeg_compression { + /* general */ + enum v4l2_mpeg_streamtype st_type; + struct v4l2_bitrate st_bitrate; + + /* transport streams */ + __u16 ts_pid_pmt; + __u16 ts_pid_audio; + __u16 ts_pid_video; + __u16 ts_pid_pcr; + + /* program stream */ + __u16 ps_size; + __u16 reserved_1; /* align */ + + /* audio */ + enum v4l2_mpeg_audiotype au_type; + struct v4l2_bitrate au_bitrate; + __u32 au_sample_rate; + __u8 au_pesid; + __u8 reserved_2[3]; /* align */ + + /* video */ + enum v4l2_mpeg_videotype vi_type; + enum v4l2_mpeg_aspectratio vi_aspect_ratio; + struct v4l2_bitrate vi_bitrate; + __u32 vi_frame_rate; + __u16 vi_frames_per_gop; + __u16 vi_bframes_count; + __u8 vi_pesid; + __u8 reserved_3[3]; /* align */ + + /* misc flags */ + __u32 closed_gops:1; + __u32 pulldown:1; + __u32 reserved_4:30; /* align */ + + /* I don't expect the above being perfect yet ;) */ + __u32 reserved_5[8]; +}; +#endif + +struct v4l2_jpegcompression +{ + int quality; + + int APPn; /* Number of APP segment to be written, + * must be 0..15 */ + int APP_len; /* Length of data in JPEG APPn segment */ + char APP_data[60]; /* Data in the JPEG APPn segment. */ + + int COM_len; /* Length of data in JPEG COM segment */ + char COM_data[60]; /* Data in JPEG COM segment */ + + __u32 jpeg_markers; /* Which markers should go into the JPEG + * output. Unless you exactly know what + * you do, leave them untouched. + * Inluding less markers will make the + * resulting code smaller, but there will + * be fewer aplications which can read it. + * The presence of the APP and COM marker + * is influenced by APP_len and COM_len + * ONLY, not by this property! */ + +#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ +#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ +#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ +#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ +#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will + * allways use APP0 */ +}; + +/* + * M E M O R Y - M A P P I N G B U F F E R S + */ +struct v4l2_requestbuffers +{ + __u32 count; + enum v4l2_buf_type type; + enum v4l2_memory memory; + __u32 reserved[2]; +}; + +struct v4l2_buffer +{ + __u32 index; + enum v4l2_buf_type type; + __u32 bytesused; + __u32 flags; + enum v4l2_field field; + struct timeval timestamp; + struct v4l2_timecode timecode; + __u32 sequence; + + /* memory location */ + enum v4l2_memory memory; + union { + __u32 offset; + unsigned long userptr; + } m; + __u32 length; + __u32 input; + __u32 reserved; +}; + +/* Flags for 'flags' field */ +#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */ +#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */ +#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */ +#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */ +#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */ +#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */ +#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ +#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */ + +/* + * O V E R L A Y P R E V I E W + */ +struct v4l2_framebuffer +{ + __u32 capability; + __u32 flags; +/* FIXME: in theory we should pass something like PCI device + memory + * region + offset instead of some physical address */ + void* base; + struct v4l2_pix_format fmt; +}; +/* Flags for the 'capability' field. Read only */ +#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 +#define V4L2_FBUF_CAP_CHROMAKEY 0x0002 +#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 +#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 +/* Flags for the 'flags' field. */ +#define V4L2_FBUF_FLAG_PRIMARY 0x0001 +#define V4L2_FBUF_FLAG_OVERLAY 0x0002 +#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 + +struct v4l2_clip +{ + struct v4l2_rect c; + struct v4l2_clip __user *next; +}; + +struct v4l2_window +{ + struct v4l2_rect w; + enum v4l2_field field; + __u32 chromakey; + struct v4l2_clip __user *clips; + __u32 clipcount; + void __user *bitmap; +}; + +/* + * C A P T U R E P A R A M E T E R S + */ +struct v4l2_captureparm +{ + __u32 capability; /* Supported modes */ + __u32 capturemode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in .1us units */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 readbuffers; /* # of buffers for read */ + __u32 reserved[4]; +}; + +/* Flags for 'capability' and 'capturemode' fields */ +#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ +#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ + +struct v4l2_outputparm +{ + __u32 capability; /* Supported modes */ + __u32 outputmode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in seconds */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 writebuffers; /* # of buffers for write */ + __u32 reserved[4]; +}; + +/* + * I N P U T I M A G E C R O P P I N G + */ +struct v4l2_cropcap { + enum v4l2_buf_type type; + struct v4l2_rect bounds; + struct v4l2_rect defrect; + struct v4l2_fract pixelaspect; +}; + +struct v4l2_crop { + enum v4l2_buf_type type; + struct v4l2_rect c; +}; + +/* + * A N A L O G V I D E O S T A N D A R D + */ + +typedef __u64 v4l2_std_id; + +/* one bit for each */ +#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001) +#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002) +#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004) +#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008) +#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010) +#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020) +#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040) +#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080) + +#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100) +#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200) +#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400) +#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800) + +#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) +#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) +#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) +#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) + +#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000) +#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000) +#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000) +#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000) +#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) +#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) +#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) +#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000) + +/* ATSC/HDTV */ +#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) +#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) + +/* some merged standards */ +#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) +#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) +#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) +#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) + +/* some common needed stuff */ +#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ + V4L2_STD_PAL_B1 |\ + V4L2_STD_PAL_G) +#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\ + V4L2_STD_PAL_D1 |\ + V4L2_STD_PAL_K) +#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ + V4L2_STD_PAL_DK |\ + V4L2_STD_PAL_H |\ + V4L2_STD_PAL_I) +#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\ + V4L2_STD_NTSC_M_JP |\ + V4L2_STD_NTSC_M_KR) +#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ + V4L2_STD_SECAM_K |\ + V4L2_STD_SECAM_K1) +#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\ + V4L2_STD_SECAM_G |\ + V4L2_STD_SECAM_H |\ + V4L2_STD_SECAM_DK |\ + V4L2_STD_SECAM_L |\ + V4L2_STD_SECAM_LC) + +#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ + V4L2_STD_PAL_60 |\ + V4L2_STD_NTSC |\ + V4L2_STD_NTSC_443) +#define V4L2_STD_625_50 (V4L2_STD_PAL |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc |\ + V4L2_STD_SECAM) +#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\ + V4L2_STD_ATSC_16_VSB) + +#define V4L2_STD_UNKNOWN 0 +#define V4L2_STD_ALL (V4L2_STD_525_60 |\ + V4L2_STD_625_50) + +struct v4l2_standard +{ + __u32 index; + v4l2_std_id id; + __u8 name[24]; + struct v4l2_fract frameperiod; /* Frames, not fields */ + __u32 framelines; + __u32 reserved[4]; +}; + +/* + * V I D E O I N P U T S + */ +struct v4l2_input +{ + __u32 index; /* Which input */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of input */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 tuner; /* Associated tuner */ + v4l2_std_id std; + __u32 status; + __u32 reserved[4]; +}; + +/* Values for the 'type' field */ +#define V4L2_INPUT_TYPE_TUNER 1 +#define V4L2_INPUT_TYPE_CAMERA 2 + +/* field 'status' - general */ +#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */ +#define V4L2_IN_ST_NO_SIGNAL 0x00000002 +#define V4L2_IN_ST_NO_COLOR 0x00000004 + +/* field 'status' - analog */ +#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ +#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ + +/* field 'status' - digital */ +#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */ +#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */ +#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */ + +/* field 'status' - VCR and set-top box */ +#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */ +#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ +#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ + +/* + * V I D E O O U T P U T S + */ +struct v4l2_output +{ + __u32 index; /* Which output */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of output */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 modulator; /* Associated modulator */ + v4l2_std_id std; + __u32 reserved[4]; +}; +/* Values for the 'type' field */ +#define V4L2_OUTPUT_TYPE_MODULATOR 1 +#define V4L2_OUTPUT_TYPE_ANALOG 2 +#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 + +/* + * C O N T R O L S + */ +struct v4l2_control +{ + __u32 id; + __s32 value; +}; + +struct v4l2_ext_control +{ + __u32 id; + __u32 reserved2[2]; + union { + __s32 value; + __s64 value64; + void *reserved; + }; +} __attribute__ ((packed)); + +struct v4l2_ext_controls +{ + __u32 ctrl_class; + __u32 count; + __u32 error_idx; + __u32 reserved[2]; + struct v4l2_ext_control *controls; +}; + +/* Values for ctrl_class field */ +#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ +#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ + +#define V4L2_CTRL_ID_MASK (0x0fffffff) +#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) +#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) + +/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ +struct v4l2_queryctrl +{ + __u32 id; + enum v4l2_ctrl_type type; + __u8 name[32]; /* Whatever */ + __s32 minimum; /* Note signedness */ + __s32 maximum; + __s32 step; + __s32 default_value; + __u32 flags; + __u32 reserved[2]; +}; + +/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ +struct v4l2_querymenu +{ + __u32 id; + __u32 index; + __u8 name[32]; /* Whatever */ + __u32 reserved; +}; + +/* Control flags */ +#define V4L2_CTRL_FLAG_DISABLED 0x0001 +#define V4L2_CTRL_FLAG_GRABBED 0x0002 +#define V4L2_CTRL_FLAG_READ_ONLY 0x0004 +#define V4L2_CTRL_FLAG_UPDATE 0x0008 +#define V4L2_CTRL_FLAG_INACTIVE 0x0010 +#define V4L2_CTRL_FLAG_SLIDER 0x0020 + +/* Query flag, to be ORed with the control ID */ +#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 + +/* User-class control IDs defined by V4L2 */ +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) +#define V4L2_CID_USER_BASE V4L2_CID_BASE +/* IDs reserved for driver specific controls */ +#define V4L2_CID_PRIVATE_BASE 0x08000000 + +#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) +#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) +#define V4L2_CID_SATURATION (V4L2_CID_BASE+2) +#define V4L2_CID_HUE (V4L2_CID_BASE+3) +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) +#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7) +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) +#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) +#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) +#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */ +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) +#define V4L2_CID_GAIN (V4L2_CID_BASE+19) +#define V4L2_CID_HFLIP (V4L2_CID_BASE+20) +#define V4L2_CID_VFLIP (V4L2_CID_BASE+21) +#define V4L2_CID_HCENTER (V4L2_CID_BASE+22) +#define V4L2_CID_VCENTER (V4L2_CID_BASE+23) +#define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */ + +/* MPEG-class control IDs defined by V4L2 */ +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) + +/* MPEG streams */ +#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) +enum v4l2_mpeg_stream_type { + V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */ +}; +#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) +#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) +#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) +#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) +#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) +enum v4l2_mpeg_stream_vbi_fmt { + V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ + V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */ +}; + +/* MPEG audio */ +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) +enum v4l2_mpeg_audio_sampling_freq { + V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) +enum v4l2_mpeg_audio_encoding { + V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, + V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, + V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) +enum v4l2_mpeg_audio_l1_bitrate { + V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, + V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2, + V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3, + V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4, + V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5, + V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6, + V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7, + V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8, + V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9, + V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10, + V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11, + V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, + V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) +enum v4l2_mpeg_audio_l2_bitrate { + V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, + V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2, + V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3, + V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4, + V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5, + V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6, + V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7, + V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8, + V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9, + V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10, + V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11, + V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, + V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) +enum v4l2_mpeg_audio_l3_bitrate { + V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, + V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2, + V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3, + V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4, + V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5, + V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6, + V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7, + V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8, + V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9, + V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10, + V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11, + V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, + V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) +enum v4l2_mpeg_audio_mode { + V4L2_MPEG_AUDIO_MODE_STEREO = 0, + V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, + V4L2_MPEG_AUDIO_MODE_DUAL = 2, + V4L2_MPEG_AUDIO_MODE_MONO = 3, +}; +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) +enum v4l2_mpeg_audio_mode_extension { + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3, +}; +#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) +enum v4l2_mpeg_audio_emphasis { + V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, + V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, + V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) +enum v4l2_mpeg_audio_crc { + V4L2_MPEG_AUDIO_CRC_NONE = 0, + V4L2_MPEG_AUDIO_CRC_CRC16 = 1, +}; + +/* MPEG video */ +#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) +enum v4l2_mpeg_video_encoding { + V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, + V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, +}; +#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) +enum v4l2_mpeg_video_aspect { + V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, + V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, + V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, + V4L2_MPEG_VIDEO_ASPECT_221x100 = 3, +}; +#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) +#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) +enum v4l2_mpeg_video_bitrate_mode { + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, +}; +#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) + +/* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) +enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2) +enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3) +enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4) +enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5) +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6) +enum v4l2_mpeg_cx2341x_video_median_filter_type { + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) + +/* + * T U N I N G + */ +struct v4l2_tuner +{ + __u32 index; + __u8 name[32]; + enum v4l2_tuner_type type; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 rxsubchans; + __u32 audmode; + __s32 signal; + __s32 afc; + __u32 reserved[4]; +}; + +struct v4l2_modulator +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 txsubchans; + __u32 reserved[4]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_TUNER_CAP_LOW 0x0001 +#define V4L2_TUNER_CAP_NORM 0x0002 +#define V4L2_TUNER_CAP_STEREO 0x0010 +#define V4L2_TUNER_CAP_LANG2 0x0020 +#define V4L2_TUNER_CAP_SAP 0x0020 +#define V4L2_TUNER_CAP_LANG1 0x0040 + +/* Flags for the 'rxsubchans' field */ +#define V4L2_TUNER_SUB_MONO 0x0001 +#define V4L2_TUNER_SUB_STEREO 0x0002 +#define V4L2_TUNER_SUB_LANG2 0x0004 +#define V4L2_TUNER_SUB_SAP 0x0004 +#define V4L2_TUNER_SUB_LANG1 0x0008 + +/* Values for the 'audmode' field */ +#define V4L2_TUNER_MODE_MONO 0x0000 +#define V4L2_TUNER_MODE_STEREO 0x0001 +#define V4L2_TUNER_MODE_LANG2 0x0002 +#define V4L2_TUNER_MODE_SAP 0x0002 +#define V4L2_TUNER_MODE_LANG1 0x0003 +#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 + +struct v4l2_frequency +{ + __u32 tuner; + enum v4l2_tuner_type type; + __u32 frequency; + __u32 reserved[8]; +}; + +/* + * A U D I O + */ +struct v4l2_audio +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_AUDCAP_STEREO 0x00001 +#define V4L2_AUDCAP_AVL 0x00002 + +/* Flags for the 'mode' field */ +#define V4L2_AUDMODE_AVL 0x00001 + +struct v4l2_audioout +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* + * D A T A S E R V I C E S ( V B I ) + * + * Data services API by Michael Schimek + */ + +/* Raw VBI */ +struct v4l2_vbi_format +{ + __u32 sampling_rate; /* in 1 Hz */ + __u32 offset; + __u32 samples_per_line; + __u32 sample_format; /* V4L2_PIX_FMT_* */ + __s32 start[2]; + __u32 count[2]; + __u32 flags; /* V4L2_VBI_* */ + __u32 reserved[2]; /* must be zero */ +}; + +/* VBI flags */ +#define V4L2_VBI_UNSYNC (1<< 0) +#define V4L2_VBI_INTERLACED (1<< 1) + +#if 1 +/* Sliced VBI + * + * This implements is a proposal V4L2 API to allow SLICED VBI + * required for some hardware encoders. It should change without + * notice in the definitive implementation. + */ + +struct v4l2_sliced_vbi_format +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + __u32 io_size; + __u32 reserved[2]; /* must be zero */ +}; + +/* Teletext World System Teletext + (WST), defined on ITU-R BT.653-2 */ +#define V4L2_SLICED_TELETEXT_B (0x0001) +/* Video Program System, defined on ETS 300 231*/ +#define V4L2_SLICED_VPS (0x0400) +/* Closed Caption, defined on EIA-608 */ +#define V4L2_SLICED_CAPTION_525 (0x1000) +/* Wide Screen System, defined on ITU-R BT1119.1 */ +#define V4L2_SLICED_WSS_625 (0x4000) + +#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) +#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) + + +struct v4l2_sliced_vbi_cap +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + enum v4l2_buf_type type; + __u32 reserved[3]; /* must be 0 */ +}; + +struct v4l2_sliced_vbi_data +{ + __u32 id; + __u32 field; /* 0: first field, 1: second field */ + __u32 line; /* 1-23 */ + __u32 reserved; /* must be 0 */ + __u8 data[48]; +}; +#endif + +/* + * A G G R E G A T E S T R U C T U R E S + */ + +/* Stream data format + */ +struct v4l2_format +{ + enum v4l2_buf_type type; + union + { + struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE + struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY + struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE +#if 1 + struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE +#endif + __u8 raw_data[200]; // user-defined + } fmt; +}; + + +/* Stream type-dependent parameters + */ +struct v4l2_streamparm +{ + enum v4l2_buf_type type; + union + { + struct v4l2_captureparm capture; + struct v4l2_outputparm output; + __u8 raw_data[200]; /* user-defined */ + } parm; +}; + +/* + * 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 + * + */ +#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) +#define VIDIOC_RESERVED _IO ('V', 1) +#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) +#define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) +#define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) +#ifdef __KERNEL__ +#define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) +#define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) +#endif +#define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) +#define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) +#define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) +#define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer) +#define VIDIOC_OVERLAY _IOW ('V', 14, int) +#define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer) +#define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer) +#define VIDIOC_STREAMON _IOW ('V', 18, int) +#define VIDIOC_STREAMOFF _IOW ('V', 19, int) +#define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm) +#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm) +#define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id) +#define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id) +#define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard) +#define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input) +#define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control) +#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control) +#define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner) +#define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner) +#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio) +#define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio) +#define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl) +#define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu) +#define VIDIOC_G_INPUT _IOR ('V', 38, int) +#define VIDIOC_S_INPUT _IOWR ('V', 39, int) +#define VIDIOC_G_OUTPUT _IOR ('V', 46, int) +#define VIDIOC_S_OUTPUT _IOWR ('V', 47, int) +#define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output) +#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout) +#define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout) +#define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator) +#define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator) +#define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency) +#define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency) +#define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap) +#define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop) +#define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop) +#define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression) +#define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression) +#define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id) +#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format) +#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio) +#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) +#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) +#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) +#if 1 +#define VIDIOC_G_SLICED_VBI_CAP _IOWR ('V', 69, struct v4l2_sliced_vbi_cap) +#endif +#define VIDIOC_LOG_STATUS _IO ('V', 70) +#define VIDIOC_G_EXT_CTRLS _IOWR ('V', 71, struct v4l2_ext_controls) +#define VIDIOC_S_EXT_CTRLS _IOWR ('V', 72, struct v4l2_ext_controls) +#define VIDIOC_TRY_EXT_CTRLS _IOWR ('V', 73, struct v4l2_ext_controls) +#if 1 +#define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) +#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) +#endif + +#ifdef __OLD_VIDIOC_ +/* for compatibility, will go away some day */ +#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) +#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) +#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control) +#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) +#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) +#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) +#endif + +#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ + +#endif /* __LINUX_VIDEODEV2_H */ + +/* + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/ddverify/models/con1/include/linux/vmalloc.h b/ddverify/models/con1/include/linux/vmalloc.h new file mode 100644 index 000000000..747bc9653 --- /dev/null +++ b/ddverify/models/con1/include/linux/vmalloc.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_VMALLOC_H +#define _LINUX_VMALLOC_H + +#include + +void *vmalloc(unsigned long size); +void vfree(void *addr); + +#endif /* _LINUX_VMALLOC_H */ diff --git a/ddverify/models/con1/include/linux/wait.h b/ddverify/models/con1/include/linux/wait.h new file mode 100644 index 000000000..91dc48dbf --- /dev/null +++ b/ddverify/models/con1/include/linux/wait.h @@ -0,0 +1,91 @@ +#ifndef _LINUX_WAIT_H +#define _LINUX_WAIT_H + +#include +#include +#include +#include +#include +#include + +struct __wait_queue { + int something; +}; +typedef struct __wait_queue wait_queue_t; + +struct __wait_queue_head { + int number_process_waiting; + int wakeup; + + int init; +}; +typedef struct __wait_queue_head wait_queue_head_t; + + +#define DECLARE_WAITQUEUE(name, tsk) wait_queue_t name +#define DECLARE_WAIT_QUEUE_HEAD(name) wait_queue_head_t name = { \ + .number_process_waiting = 0, \ + .wakeup = 0, \ + .init = 1} + + +#ifdef DDV_ASSERT_WAIT_QUEUE +#define assert_wait_queue(wq) __CPROVER_assert((wq)->init, "Wait queue is initialized!") +#else +#define assert_wait_queue(wq) do {} while(0) +#endif + +#define wait_event(wq, condition) \ +do { \ + if (condition) \ + break; \ + do { \ + wq.number_process_waiting++; \ + do { \ + } while(!wq.wakeup); \ + if (condition) \ + break; \ + do { \ + } while(wq.wakeup); \ + } while (1); \ +} while (0) + + +#define wait_event_interruptible(wq, condition) \ +({ \ + int __ret = 0; \ + __ret; \ +}) + + +#define DEFINE_WAIT(name) wait_queue_t name + +// DDV: Body is defined in linux/kernel/wait.c +void init_waitqueue_head(wait_queue_head_t *q); +// DDV: TODO +void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state); +// DDV: TODO +void finish_wait(wait_queue_head_t *q, wait_queue_t *wait); + +// DDV: Body is defined in linux/kernel/wait.c +void wake_up(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_all(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_interruptible(wait_queue_head_t *q); + +// DDV: TODO +void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); + +// DDV: TODO +int waitqueue_active(wait_queue_head_t *q); + +// DDV: Body is defined in linux/kernel/wait.c +void sleep_on(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void interruptible_sleep_on(wait_queue_head_t *q); +#endif diff --git a/ddverify/models/con1/include/linux/watchdog.h b/ddverify/models/con1/include/linux/watchdog.h new file mode 100644 index 000000000..afc7f8318 --- /dev/null +++ b/ddverify/models/con1/include/linux/watchdog.h @@ -0,0 +1,52 @@ +#ifndef _LINUX_WATCHDOG_H +#define _LINUX_WATCHDOG_H + +#include +#include + +#define WATCHDOG_IOCTL_BASE 'W' + +struct watchdog_info { + __u32 options; /* Options the card/driver supports */ + __u32 firmware_version; /* Firmware version of the card */ + __u8 identity[32]; /* Identity of the board */ +}; + +#define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info) +#define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int) +#define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int) +#define WDIOC_GETTEMP _IOR(WATCHDOG_IOCTL_BASE, 3, int) +#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int) +#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int) +#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) +#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) +#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int) +#define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int) +#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int) + +#define WDIOF_UNKNOWN -1 /* Unknown flag error */ +#define WDIOS_UNKNOWN -1 /* Unknown status error */ + +#define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */ +#define WDIOF_FANFAULT 0x0002 /* Fan failed */ +#define WDIOF_EXTERN1 0x0004 /* External relay 1 */ +#define WDIOF_EXTERN2 0x0008 /* External relay 2 */ +#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ +#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ +#define WDIOF_POWEROVER 0x0040 /* Power over voltage */ +#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ +#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ +#define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ +#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ + +#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ +#define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */ +#define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */ + +#ifdef CONFIG_WATCHDOG_NOWAYOUT +#define WATCHDOG_NOWAYOUT 1 +#else +#define WATCHDOG_NOWAYOUT 0 +#endif + +#endif /* ifndef _LINUX_WATCHDOG_H */ diff --git a/ddverify/models/con1/include/linux/workqueue.h b/ddverify/models/con1/include/linux/workqueue.h new file mode 100644 index 000000000..968ed7e62 --- /dev/null +++ b/ddverify/models/con1/include/linux/workqueue.h @@ -0,0 +1,50 @@ +/* + * workqueue.h --- work queue handling for Linux. + */ + +#ifndef _LINUX_WORKQUEUE_H +#define _LINUX_WORKQUEUE_H + +#include +//#include +#include + +struct work_struct { + unsigned long pending; + void (*func)(void *); + void *data; + + int init; +}; + +#define DECLARE_WORK(n, f, d) \ + struct work_struct n = { \ + .func = (f), \ + .data = (d), \ + .init = 1, \ + } + +/* + * initialize a work-struct's func and data pointers: + */ +#define PREPARE_WORK(_work, _func, _data) \ + do { \ + (_work)->func = _func; \ + (_work)->data = _data; \ + (_work)->init = 1; \ + } while (0) + +/* + * initialize all of a work-struct: + */ +#define INIT_WORK(_work, _func, _data) \ + do { \ + PREPARE_WORK((_work), (_func), (_data)); \ + } while (0) + +// DDV: Body for this function is defined in linux/kernel/workqueue.c +int schedule_work(struct work_struct *work); +// DDV: TODO +void flush_scheduled_work(void); + +#endif diff --git a/ddverify/models/con1/include/linux/writeback.h b/ddverify/models/con1/include/linux/writeback.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con1/include/media/v4l2-common.h b/ddverify/models/con1/include/media/v4l2-common.h new file mode 100644 index 000000000..1863cce24 --- /dev/null +++ b/ddverify/models/con1/include/media/v4l2-common.h @@ -0,0 +1,6 @@ +#ifndef V4L2_COMMON_H_ +#define V4L2_COMMON_H_ + +#include + +#endif /* V4L2_COMMON_H_ */ diff --git a/ddverify/models/con1/include/media/v4l2-dev.h b/ddverify/models/con1/include/media/v4l2-dev.h new file mode 100644 index 000000000..94b52e78e --- /dev/null +++ b/ddverify/models/con1/include/media/v4l2-dev.h @@ -0,0 +1,255 @@ +#ifndef _V4L2_DEV_H +#define _V4L2_DEV_H + +#include +#include +#include +#include +#include +#include + + +#define VIDEO_MAJOR 81 +/* Minor device allocation */ +#define MINOR_VFL_TYPE_GRABBER_MIN 0 +#define MINOR_VFL_TYPE_GRABBER_MAX 63 +#define MINOR_VFL_TYPE_RADIO_MIN 64 +#define MINOR_VFL_TYPE_RADIO_MAX 127 +#define MINOR_VFL_TYPE_VTX_MIN 192 +#define MINOR_VFL_TYPE_VTX_MAX 223 +#define MINOR_VFL_TYPE_VBI_MIN 224 +#define MINOR_VFL_TYPE_VBI_MAX 255 + +#define VFL_TYPE_GRABBER 0 +#define VFL_TYPE_VBI 1 +#define VFL_TYPE_RADIO 2 +#define VFL_TYPE_VTX 3 + + + +struct video_device +{ + /* device ops */ + const struct file_operations *fops; + + /* device info */ + struct device *dev; + char name[32]; + int type; /* v4l1 */ + int type2; /* v4l2 */ + int hardware; + int minor; + + int debug; /* Activates debug level*/ + + /* Video standard vars */ + int tvnormsize; /* Size of tvnorm array */ + v4l2_std_id current_norm; /* Current tvnorm */ + struct v4l2_tvnorm *tvnorms; + + /* callbacks */ + void (*release)(struct video_device *vfd); + + /* ioctl callbacks */ + + /* VIDIOC_QUERYCAP handler */ + int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap); + + /* Priority handling */ + int (*vidioc_g_priority) (struct file *file, void *fh, + enum v4l2_priority *p); + int (*vidioc_s_priority) (struct file *file, void *fh, + enum v4l2_priority p); + + /* VIDIOC_ENUM_FMT handlers */ + int (*vidioc_enum_fmt_cap) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_overlay) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_capture) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_video_output)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + + /* VIDIOC_G_FMT handlers */ + int (*vidioc_g_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_S_FMT handlers */ + int (*vidioc_s_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + + int (*vidioc_s_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_TRY_FMT handlers */ + int (*vidioc_try_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* Buffer handlers */ + int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); + int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + + + int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); + + int (*vidioc_g_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + int (*vidioc_s_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + + /* Stream on/off */ + int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i); + int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i); + + /* Standard handling + G_STD and ENUMSTD are handled by videodev.c + */ + int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id a); + int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a); + + /* Input handling */ + int (*vidioc_enum_input)(struct file *file, void *fh, + struct v4l2_input *inp); + int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i); + + /* Output handling */ + int (*vidioc_enumoutput) (struct file *file, void *fh, + struct v4l2_output *a); + int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i); + + /* Control handling */ + int (*vidioc_queryctrl) (struct file *file, void *fh, + struct v4l2_queryctrl *a); + int (*vidioc_g_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_s_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_g_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_s_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_try_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_querymenu) (struct file *file, void *fh, + struct v4l2_querymenu *a); + + /* Audio ioctls */ + int (*vidioc_enumaudio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_g_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_s_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + + /* Audio out ioctls */ + int (*vidioc_enumaudout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_s_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + int (*vidioc_s_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + /* Crop ioctls */ + int (*vidioc_cropcap) (struct file *file, void *fh, + struct v4l2_cropcap *a); + int (*vidioc_g_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + int (*vidioc_s_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + /* Compression ioctls */ + int (*vidioc_g_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_s_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_g_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + int (*vidioc_s_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + + /* Stream type-dependent parameter ioctls */ + int (*vidioc_g_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + int (*vidioc_s_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + + /* Tuner ioctls */ + int (*vidioc_g_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_s_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_g_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + int (*vidioc_s_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + + /* Sliced VBI cap */ + int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh, + struct v4l2_sliced_vbi_cap *a); + + /* Log status ioctl */ + int (*vidioc_log_status) (struct file *file, void *fh); + + + struct module *owner; + + void *priv; + +}; + + + +extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, + unsigned long arg); + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +#endif /* _V4L2_DEV_H */ diff --git a/ddverify/models/con1/include/net/sock.h b/ddverify/models/con1/include/net/sock.h new file mode 100644 index 000000000..2eefd9c6c --- /dev/null +++ b/ddverify/models/con1/include/net/sock.h @@ -0,0 +1,29 @@ +#ifndef _SOCK_H +#define _SOCK_H + +#include +#include +#include +#include +//#include +#include +#include /* struct sk_buff */ +//#include + + +#define SHUTDOWN_MASK 3 +#define RCV_SHUTDOWN 1 +#define SEND_SHUTDOWN 2 + +#define SOCK_SNDBUF_LOCK 1 +#define SOCK_RCVBUF_LOCK 2 +#define SOCK_BINDADDR_LOCK 4 +#define SOCK_BINDPORT_LOCK 8 + +struct sock { + gfp_t sk_allocation; +}; + +struct socket *SOCKET_I(struct inode *inode); + +#endif /* _SOCK_H */ diff --git a/ddverify/models/con1/src/ddverify/cdev.c b/ddverify/models/con1/src/ddverify/cdev.c new file mode 100644 index 000000000..c608b16d5 --- /dev/null +++ b/ddverify/models/con1/src/ddverify/cdev.c @@ -0,0 +1,156 @@ +#include +#include +#include + +void call_cdev_functions() +{ + int cdev_no, function_no, result; + + loff_t loff_t_value; + int int_value; + unsigned int uint_value; + unsigned long ulong_value; + char char_value; + size_t size_t_value; + + if (number_cdev_registered == 0) { + return; + } + + cdev_no = nondet_ushort(); + __CPROVER_assume (0 <= cdev_no && cdev_no < number_cdev_registered); + + switch (nondet_ushort()) { + case 0: + if (cdev_registered[cdev_no].cdevp->ops->llseek) { + loff_t_value = nondet_loff_t(); + int_value = nondet_int(); + + (* cdev_registered[cdev_no].cdevp->ops->llseek)(&cdev_registered[cdev_no].filp, + loff_t_value, + int_value); + } + break; + case 1: + if (cdev_registered[cdev_no].cdevp->ops->read) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->read)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 2: + // aio_read - NOT SUPPORTED! + break; + case 3: + if (cdev_registered[cdev_no].cdevp->ops->write) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->write)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 4: + // aio_write - NOT SUPPORTED! + break; + case 5: + // readdir - NOT SUPPORTED! + break; + case 6: + // poll - NOT SUPPORTED! + break; + case 7: + if (cdev_registered[cdev_no].cdevp->ops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + + (* cdev_registered[cdev_no].cdevp->ops->ioctl)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp, + uint_value, + ulong_value); + } + + break; + case 8: + // unlocked_ioctl - NOT SUPPORTED! + break; + case 9: + // compat_ioctl - NOT SUPPORTED! + break; + case 10: + // mmap - NOT SUPPORTED! + break; + case 11: + if ((cdev_registered[cdev_no].cdevp->ops->open) && + (!cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->open)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 1; + } + } + break; + case 12: + // flush - NOT SUPPORTED! + break; + case 13: + if ((cdev_registered[cdev_no].cdevp->ops->release) && + (cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->release)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 0; + } + } + break; + case 14: + // fsync - NOT SUPPORTED! + break; + case 15: + // aio_fsync - NOT SUPPORTED! + break; + case 16: + // fasync - NOT SUPPORTED! + break; + case 17: + // lock - NOT SUPPORTED! + break; + case 18: + // readv - NOT SUPPORTED! + break; + case 19: + // writev - NOT SUPPORTED! + break; + case 20: + // sendfile - NOT SUPPORTED! + break; + case 21: + // sendpage - NOT SUPPORTED! + break; + case 22: + // get_unmapped_area - NOT SUPPORTED! + break; + case 23: + // check_flags - NOT SUPPORTED! + break; + case 24: + // dir_notify - NOT SUPPORTED! + break; + case 25: + // flock - NOT SUPPORTED! + break; + case 26: + // open_exec - NOT SUPPORTED! + break; + default: + break; + } +} diff --git a/ddverify/models/con1/src/ddverify/ddverify.c b/ddverify/models/con1/src/ddverify/ddverify.c new file mode 100644 index 000000000..2e086bebb --- /dev/null +++ b/ddverify/models/con1/src/ddverify/ddverify.c @@ -0,0 +1,116 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void init_kernel() +{ + int i; + + spin_lock_init(&kernel_lock); + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + shared_workqueue[i] = NULL; + } + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + tasklet_registered[i].tasklet = NULL; + tasklet_registered[i].is_running = 0; + } +} + +static void * ddv_2(void *arg) +{ + unsigned short random; + + do { + random = nondet_ushort(); + + switch (random) { + case 1: + switch_context(CONTEXT_INTERRUPT); + call_timer_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 2: + switch_context(CONTEXT_INTERRUPT); + call_interrupt_handler(); + switch_context(CONTEXT_PROCESS); + break; + + case 3: + switch_context(CONTEXT_PROCESS); + call_shared_workqueue_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 4: + switch_context(CONTEXT_INTERRUPT); + call_tasklet_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 5: + switch_context(CONTEXT_PROCESS); + call_pci_functions(); + switch_context(CONTEXT_PROCESS); + break; + + default: + break; + } + } while(random); +} + +void ddv() +{ + unsigned short random; + + pthread_t thread; + + pthread_create(&thread, NULL, ddv_2, NULL); + + do { + switch_context(CONTEXT_PROCESS); +#ifdef DRIVER_TYPE_CHAR + call_cdev_functions(); +#endif + +#ifdef DRIVER_TYPE_BLOCK + call_genhd_functions(); +#endif + } while (nondet_int()); +} + +int call_ddv() +{ + int err; + + switch_context(CONTEXT_PROCESS); + + init_kernel(); + + err = (* _ddv_module_init)(); + + if (err) { + return -1; + } + + + ddv(); + + switch_context(CONTEXT_PROCESS); + (* _ddv_module_exit)(); + + return 0; +} diff --git a/ddverify/models/con1/src/ddverify/genhd.c b/ddverify/models/con1/src/ddverify/genhd.c new file mode 100644 index 000000000..8938bbdd3 --- /dev/null +++ b/ddverify/models/con1/src/ddverify/genhd.c @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include + +create_request(int genhd_no) +{ + struct request rq; + + rq.cmd_type = REQ_TYPE_FS; + rq.rq_disk = genhd_registered[genhd_no].gd; + rq.sector = nondet_sector_t(); + rq.current_nr_sectors = nondet_uint(); + rq.buffer = nondet_pchar(); + + genhd_registered[genhd_no].current_request = rq; + genhd_registered[genhd_no].requests_open = 1; +} + +void call_rq_function(int genhd_no) +{ + if ((genhd_registered[genhd_no].gd->queue->request_fn != NULL) && + (genhd_registered[genhd_no].gd->queue->__ddv_queue_alive)) + { + spin_lock(genhd_registered[genhd_no].gd->queue->queue_lock); + + create_request(genhd_no); + genhd_registered[genhd_no].gd->queue->__ddv_genhd_no = genhd_no; + + (* genhd_registered[genhd_no].gd->queue->request_fn)(genhd_registered[genhd_no].gd->queue); + // do_cm206_request(genhd_registered[genhd_no].gd->queue); + + spin_unlock(genhd_registered[genhd_no].gd->queue->queue_lock); + + return; + } + + if (genhd_registered[genhd_no].gd->queue->make_request_fn) { + return; + } +} + +void call_genhd_functions() +{ + unsigned short genhd_no, function_no; + unsigned int uint_value; + unsigned long ulong_value; + int result; + + if (number_genhd_registered == 0) { + return; + } + + genhd_no = nondet_ushort(); + __CPROVER_assume (genhd_no < number_genhd_registered); + + + function_no = nondet_ushort(); + + switch (function_no) { + case 0: + call_rq_function(genhd_no); + break; + + case 1: + if (genhd_registered[genhd_no].gd->fops->open) { + genhd_registered[genhd_no].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[genhd_no].inode.i_bdev->bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->open)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 2: + if (genhd_registered[genhd_no].gd->fops->release) { + (* genhd_registered[genhd_no].gd->fops->release)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 3: + if (genhd_registered[genhd_no].gd->fops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + (* genhd_registered[genhd_no].gd->fops->ioctl)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file, + uint_value, + ulong_value); + } + break; + + case 4: + if (genhd_registered[genhd_no].gd->fops->media_changed) { + (* genhd_registered[genhd_no].gd->fops->media_changed)(genhd_registered[genhd_no].gd); + } + break; + + case 5: + if (genhd_registered[genhd_no].gd->fops->revalidate_disk) { + (* genhd_registered[genhd_no].gd->fops->revalidate_disk)(genhd_registered[genhd_no].gd); + } + break; + + case 6: + if (genhd_registered[genhd_no].gd->fops->getgeo) { + struct hd_geometry hdg; + struct block_device blk_dev; + + blk_dev.bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->getgeo)(&blk_dev, &hdg); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/con1/src/ddverify/interrupt.c b/ddverify/models/con1/src/ddverify/interrupt.c new file mode 100644 index 000000000..4a5ed1daf --- /dev/null +++ b/ddverify/models/con1/src/ddverify/interrupt.c @@ -0,0 +1,22 @@ +#include +#include + +#ifdef OLD_INTERRUPT_HANDLER +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id) +#else +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id, regs) +#endif + +void call_interrupt_handler() +{ + unsigned short i; + struct pt_regs regs; + + i = nondet_int(); + __CPROVER_assume(i < MAX_IRQ_SUPPORT); + + if (registered_irq[i].handler) { + __call_interrupt_handler((* registered_irq[i].handler), + (int)i, registered_irq[i].dev_id, ®s); + } +} diff --git a/ddverify/models/con1/src/ddverify/ioctl.c b/ddverify/models/con1/src/ddverify/ioctl.c new file mode 100644 index 000000000..2f95c45aa --- /dev/null +++ b/ddverify/models/con1/src/ddverify/ioctl.c @@ -0,0 +1,19 @@ +#include +#include + +/*void add_ioctl(unsigned int ioctl) +{ + if (number_ioctl_registered < MAX_IOCTL_SUPPORT) { + ioctl_registered[number_ioctl_registered] = ioctl; + number_ioctl_registered++; + } +} + +unsigned int get_ioctl_cmd() +{ + short cmd = nondet_short(); + __CPROVER_assume (cmd >= 0 && cmd < number_ioctl_registered); + + return ioctl_registered[cmd]; +} +*/ diff --git a/ddverify/models/con1/src/ddverify/pci.c b/ddverify/models/con1/src/ddverify/pci.c new file mode 100644 index 000000000..7f9df6bbb --- /dev/null +++ b/ddverify/models/con1/src/ddverify/pci.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include + +void create_pci_dev() +{ +} + +int pci_probe_device() +{ + int err; + unsigned int dev_id; + + registered_pci_driver.no_pci_device_id = 1; + + dev_id = nondet_uint(); + __CPROVER_assume(dev_id < registered_pci_driver.no_pci_device_id); + + err = (*registered_pci_driver.pci_driver->probe)(®istered_pci_driver.pci_dev, + ®istered_pci_driver.pci_driver->id_table[dev_id]); + + if (!err) { + registered_pci_driver.dev_initialized = 1; + } + + return err; +} + +void pci_remove_device() +{ + (*registered_pci_driver.pci_driver->remove)(®istered_pci_driver.pci_dev); + + registered_pci_driver.dev_initialized = 0; +} + +void call_pci_functions() +{ + switch (nondet_uint()) { + case 0: + if (!registered_pci_driver.dev_initialized) { + pci_probe_device(); + } + break; + + case 1: + if (registered_pci_driver.dev_initialized) { + pci_remove_device(); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/con1/src/ddverify/tasklet.c b/ddverify/models/con1/src/ddverify/tasklet.c new file mode 100644 index 000000000..776673eb8 --- /dev/null +++ b/ddverify/models/con1/src/ddverify/tasklet.c @@ -0,0 +1,15 @@ +#include + +void call_tasklet_functions() +{ + unsigned int i; + __CPROVER_assume(i < MAX_TASKLET_SUPPORT); + + if ((tasklet_registered[i].tasklet != NULL) && + (tasklet_registered[i].tasklet->count == 0)) { + tasklet_registered[i].is_running = 1; + (* tasklet_registered[i].tasklet->func)(tasklet_registered[i].tasklet->data); + tasklet_registered[i].is_running = 0; + tasklet_registered[i].tasklet = NULL; + } +} diff --git a/ddverify/models/con1/src/ddverify/timer.c b/ddverify/models/con1/src/ddverify/timer.c new file mode 100644 index 000000000..45c22052a --- /dev/null +++ b/ddverify/models/con1/src/ddverify/timer.c @@ -0,0 +1,13 @@ +#include +#include + +void call_timer_functions() +{ + unsigned short i = nondet_ushort(); + + __CPROVER_assume(i < number_timer_registered); + + if (timer_registered[i].timer->__ddv_active) { + (* timer_registered[i].timer->function)(timer_registered[i].timer->data); + } +} diff --git a/ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c b/ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c new file mode 100644 index 000000000..06fc72517 --- /dev/null +++ b/ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c @@ -0,0 +1,51 @@ +#include +#include +#include + +int __get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int __put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} + +unsigned long copy_from_user(void *to, void __user *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} diff --git a/ddverify/models/con1/src/linux/block/elevator.c b/ddverify/models/con1/src/linux/block/elevator.c new file mode 100644 index 000000000..8511b9dd9 --- /dev/null +++ b/ddverify/models/con1/src/linux/block/elevator.c @@ -0,0 +1,13 @@ +#include +#include + +struct request *elv_next_request(request_queue_t *q) +{ + int genhd_no = q->__ddv_genhd_no; + + if (genhd_registered[genhd_no].requests_open > 0) { + return genhd_registered[genhd_no].current_request; + } else { + return NULL; + } +} diff --git a/ddverify/models/con1/src/linux/block/genhd.c b/ddverify/models/con1/src/linux/block/genhd.c new file mode 100644 index 000000000..2cbcc717d --- /dev/null +++ b/ddverify/models/con1/src/linux/block/genhd.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +int register_blkdev(unsigned int major, const char *name) +{ + int result = nondet_int(); + + /*if ((major > 0) && (result > 0)) { + return major; + }*/ + + return result; +} + +int unregister_blkdev(unsigned int major, const char *name) +{ + return 0; +} + +struct gendisk *alloc_disk(int minors) +{ + struct gendisk * gd; + + if (number_fixed_genhd_used < MAX_GENHD_SUPPORT) { + gd = &fixed_gendisk[number_fixed_genhd_used]; + gd->minors = minors; + + number_fixed_genhd_used++; + + return gd; + } else { + return NULL; + } +} + +void add_disk(struct gendisk *disk) +{ + if (number_genhd_registered < MAX_GENHD_SUPPORT) { + genhd_registered[number_genhd_registered].gd = disk; + genhd_registered[number_genhd_registered].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[number_genhd_registered].inode.i_bdev->bd_disk = disk; + + number_genhd_registered++; + } +} + +void del_gendisk(struct gendisk *gp) +{ + int i; + + for (i = 0; i < number_genhd_registered; i++) { + if (genhd_registered[i].gd == gp) { + genhd_registered[i].gd = NULL; + } + } +} diff --git a/ddverify/models/con1/src/linux/block/ll_rw_blk.c b/ddverify/models/con1/src/linux/block/ll_rw_blk.c new file mode 100644 index 000000000..eb27f72a2 --- /dev/null +++ b/ddverify/models/con1/src/linux/block/ll_rw_blk.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include + +request_queue_t *get_fixed_request_queue() +{ + if (number_request_queue_used < MAX_REQUEST_QUEUE_SUPPORT) { + return &fixed_request_queue[number_request_queue_used++]; + } else { + return NULL; + } +} + +request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->queue_lock = lock; + queue->request_fn = rfn; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +request_queue_t *blk_alloc_queue(gfp_t gfp_mask) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->request_fn = NULL; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn) +{ + q->make_request_fn = mfn; +} + +void end_request(struct request *req, int uptodate) +{ + int genhd_no = req->rq_disk->queue->__ddv_genhd_no; + + genhd_registered[genhd_no].requests_open = 0; +} + + +void blk_queue_hardsect_size(request_queue_t *q, unsigned short size) +{ + q->hardsect_size = size; +} + +void blk_cleanup_queue(request_queue_t *q) +{ + q->__ddv_queue_alive = 0; +} diff --git a/ddverify/models/con1/src/linux/drivers/char/misc.c b/ddverify/models/con1/src/linux/drivers/char/misc.c new file mode 100644 index 000000000..1bcc5a5ac --- /dev/null +++ b/ddverify/models/con1/src/linux/drivers/char/misc.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +//#include +//#include +#include + +#include + +int misc_register(struct miscdevice * misc) +{ + int i; + dev_t dev; + + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + i = fixed_cdev_used; + fixed_cdev_used++; + + fixed_cdev[i].owner = THIS_MODULE; + fixed_cdev[i].ops = misc->fops; + + dev = MKDEV(MISC_MAJOR, misc->minor); + + return cdev_add(&fixed_cdev[i], dev, 0); + } else { + return -1; + } +} diff --git a/ddverify/models/con1/src/linux/drivers/char/tty_io.c b/ddverify/models/con1/src/linux/drivers/char/tty_io.c new file mode 100644 index 000000000..30fe841cc --- /dev/null +++ b/ddverify/models/con1/src/linux/drivers/char/tty_io.c @@ -0,0 +1,40 @@ +#include +#include + +struct tty_driver *alloc_tty_driver(int lines) +{ + if (!global_tty_driver.allocated) { + global_tty_driver.driver.magic = TTY_DRIVER_MAGIC; + global_tty_driver.driver.num = lines; + } else { + return NULL; + } +} + +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op) +{ + driver->open = op->open; + driver->close = op->close; + driver->write = op->write; + driver->put_char = op->put_char; + driver->flush_chars = op->flush_chars; + driver->write_room = op->write_room; + driver->chars_in_buffer = op->chars_in_buffer; + driver->ioctl = op->ioctl; + driver->set_termios = op->set_termios; + driver->throttle = op->throttle; + driver->unthrottle = op->unthrottle; + driver->stop = op->stop; + driver->start = op->start; + driver->hangup = op->hangup; + driver->break_ctl = op->break_ctl; + driver->flush_buffer = op->flush_buffer; + driver->set_ldisc = op->set_ldisc; + driver->wait_until_sent = op->wait_until_sent; + driver->send_xchar = op->send_xchar; + driver->read_proc = op->read_proc; + driver->write_proc = op->write_proc; + driver->tiocmget = op->tiocmget; + driver->tiocmset = op->tiocmset; +} diff --git a/ddverify/models/con1/src/linux/fs/char_dev.c b/ddverify/models/con1/src/linux/fs/char_dev.c new file mode 100644 index 000000000..8a0a278bf --- /dev/null +++ b/ddverify/models/con1/src/linux/fs/char_dev.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +#include +#include + +int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) +{ + int major; + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + major = nondet_uint(); + *dev = MKDEV(major, baseminor); + } + + return return_value; +} + +int register_chrdev_region(dev_t from, unsigned count, const char *name) +{ + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + return return_value; +} + +//void unregister_chrdev_region(dev_t, unsigned) {} + + +int register_chrdev(unsigned int major, const char *name, + struct file_operations *fops) +{ + struct cdev *cdev; + int err; + + major = register_chrdev_region(0, 256, name); + + cdev = cdev_alloc(); + cdev->owner = fops->owner; + cdev->ops = fops; + + err = cdev_add(cdev, MKDEV(major, 0), 256); + + if (err) { + kfree(cdev); + return err; + } + + return major; +} + + +int unregister_chrdev(unsigned int major, const char *name) +{ + return 0; +} + +struct cdev *cdev_alloc(void) +{ + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + return &fixed_cdev[fixed_cdev_used++]; + } +} + +void cdev_init(struct cdev *cdev, struct file_operations *fops) +{ + cdev->ops = fops; +} + +int cdev_add(struct cdev *p, dev_t dev, unsigned count) +{ + p->dev = dev; + p->count = count; + + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + if (number_cdev_registered < MAX_CDEV_SUPPORT) { + + cdev_registered[number_cdev_registered].cdevp = p; + cdev_registered[number_cdev_registered].inode.i_rdev = dev; + cdev_registered[number_cdev_registered].inode.i_cdev = p; + cdev_registered[number_cdev_registered].open = 0; + + number_cdev_registered++; + } else { + return -1; + } + } + + return return_value; +} + +void cdev_del(struct cdev *p) +{ + int i; + + for (i = 0; i < number_cdev_registered; i++) { + if (cdev_registered[i].cdevp == p) { + cdev_registered[i].cdevp = 0; + + return; + } + } +} diff --git a/ddverify/models/con1/src/linux/fs/proc/generic.c b/ddverify/models/con1/src/linux/fs/proc/generic.c new file mode 100644 index 000000000..d2d29e78b --- /dev/null +++ b/ddverify/models/con1/src/linux/fs/proc/generic.c @@ -0,0 +1,7 @@ +#include + +// struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, +// struct proc_dir_entry *parent) + + +// void remove_proc_entry(const char *name, struct proc_dir_entry *parent) diff --git a/ddverify/models/con1/src/linux/kernel/irq/manage.c b/ddverify/models/con1/src/linux/kernel/irq/manage.c new file mode 100644 index 000000000..54df106a0 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/irq/manage.c @@ -0,0 +1,21 @@ +#include +#include + +int request_irq(unsigned int irq, irq_handler_t handler, + unsigned long irqflags, const char * devname, void *dev_id) +{ + if (nondet_int()) { + registered_irq[irq].handler = handler; + registered_irq[irq].dev_id = dev_id; + + return 0; + } else { + return -1; + } +} + +void free_irq(unsigned int irq, void *dev_id) +{ + registered_irq[irq].handler = NULL; + registered_irq[irq].dev_id = NULL; +} diff --git a/ddverify/models/con1/src/linux/kernel/mutex.c b/ddverify/models/con1/src/linux/kernel/mutex.c new file mode 100644 index 000000000..9254af9d1 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/mutex.c @@ -0,0 +1,37 @@ +#include +#include + +void mutex_init(struct mutex *lock) +{ + __CPROVER_HIDE: +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(!lock->locked, "Locked mutex must not be reinitialized"); +#endif + lock->locked = 0; + lock->init = 1; +} + +void mutex_lock(struct mutex *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(lock->init, "Mutex is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked mutex"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void mutex_unlock(struct mutex *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(lock->locked, "Unlock a not locked mutex"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} diff --git a/ddverify/models/con1/src/linux/kernel/resource.c b/ddverify/models/con1/src/linux/kernel/resource.c new file mode 100644 index 000000000..c187db976 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/resource.c @@ -0,0 +1,115 @@ +#include +#include +#include +#include + +struct resource *request_region(unsigned long start, unsigned long len, const char *name) +{ + unsigned int i; + struct resource *resource = (struct resource*)malloc(sizeof(struct resource)); + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 1; + // } + ddv_ioport_request_start = start; + ddv_ioport_request_len = len; + + return resource; +} + +void release_region(unsigned long start, unsigned long len) +{ + unsigned int i = 0; + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 0; + // } + + ddv_ioport_request_start = 0; + ddv_ioport_request_len = 0; +} + +unsigned char inb(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +void outb(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned short inw(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +void outw(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned inl(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +void outl(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + + +unsigned char inb_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +void outb_p(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned short inw_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +void outw_p(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned inl_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +void outl_p(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} diff --git a/ddverify/models/con1/src/linux/kernel/sched.c b/ddverify/models/con1/src/linux/kernel/sched.c new file mode 100644 index 000000000..9a23084b2 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/sched.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include +#include + +void schedule() +{ + assert_context_process(); +} + +long schedule_timeout(long timeout) +{ + assert_context_process(); + + return nondet_long(); +} diff --git a/ddverify/models/con1/src/linux/kernel/semaphore.c b/ddverify/models/con1/src/linux/kernel/semaphore.c new file mode 100644 index 000000000..7ea94e8fc --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/semaphore.c @@ -0,0 +1,86 @@ +#include +#include +#include + +// DDV: The count value is ignored because ddverify only supports binary semaphores! +void sema_init(struct semaphore *sem, int val) +{ + sem->init = 1; + sem->locked = 0; +} + +void init_MUTEX(struct semaphore * sem) +{ + sem->init = 1; + sem->locked = 0; +} + +void init_MUTEX_LOCKED(struct semaphore * sem) +{ + sem->init = 1; + sem->locked = 1; +} + +void down(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); + __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); +#endif + sem->locked = 1; + __CPROVER_atomic_end(); +} + +int down_interruptible(struct semaphore * sem) +{ + if (nondet_int()) { + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); + __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); +#endif + sem->locked = 1; + __CPROVER_atomic_end(); + + return 0; + } else { + return -1; + } +} + +int down_trylock(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); + +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); +#endif + + if (sem->locked == 0) { + sem->locked = 1; + return 0; + } else { + return 1; + } + + __CPROVER_atomic_end(); + + return 0; +} + +void up(struct semaphore * sem) +{ + __CPROVER_HIDE: + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->locked, "Unlock a not locked semaphore"); +#endif + sem->locked = 0; +} diff --git a/ddverify/models/con1/src/linux/kernel/softirq.c b/ddverify/models/con1/src/linux/kernel/softirq.c new file mode 100644 index 000000000..4a6c5e988 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/softirq.c @@ -0,0 +1,38 @@ +#include +#include + +void tasklet_schedule(struct tasklet_struct *t) +{ + int i; + int next_free = -1; + +#ifdef DDV_ASSERT_TASKLET + __CPROVER_assert(t->init, "Tasklet is initialized!"); +#endif + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + if (tasklet_registered[i].tasklet == NULL) { + next_free = i; + } + if ((tasklet_registered[i].tasklet == t) && + (tasklet_registered[i].is_running == 0)) { + return; + } + } + + if (next_free == -1) { +// __CPROVER_assert(0, "Number of supported tasklets is sufficient"); + } + + tasklet_registered[next_free].tasklet = t; + tasklet_registered[next_free].is_running = 0; +} + +void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data) +{ + t->count = 0; + t->init = 0; + t->func = func; + t->data = data; +} diff --git a/ddverify/models/con1/src/linux/kernel/spinlock.c b/ddverify/models/con1/src/linux/kernel/spinlock.c new file mode 100644 index 000000000..34b709927 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/spinlock.c @@ -0,0 +1,100 @@ +#include +#include + +void spin_lock_init(spinlock_t * lock) +{ + lock->init = 1; + lock->locked = 0; +} + +void spin_lock(spinlock_t * lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_lock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_lock_bh(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_unlock(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; +} + + +void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} + +void spin_unlock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} + +void spin_unlock_bh(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} diff --git a/ddverify/models/con1/src/linux/kernel/timer.c b/ddverify/models/con1/src/linux/kernel/timer.c new file mode 100644 index 000000000..2018c2931 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/timer.c @@ -0,0 +1,47 @@ +#include +#include + +void init_timer(struct timer_list * timer) +{ + if (number_timer_registered < MAX_TIMER_SUPPORT) { + timer->__ddv_active = 0; + timer->__ddv_init = 1; + timer_registered[number_timer_registered].timer = timer; + + number_timer_registered++; + } +} + + +void add_timer(struct timer_list *timer) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->__ddv_active = 1; +} + + +void add_timer_on(struct timer_list *timer, int cpu) +{ + // We do not care about the cpu number! + add_timer(timer); +} + + +int del_timer(struct timer_list * timer) +{ + timer->__ddv_active = 0; +} + + +int mod_timer(struct timer_list *timer, unsigned long expires) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->expires = expires; + timer->__ddv_active = 1; +} diff --git a/ddverify/models/con1/src/linux/kernel/wait.c b/ddverify/models/con1/src/linux/kernel/wait.c new file mode 100644 index 000000000..04822ab0b --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/wait.c @@ -0,0 +1,46 @@ +#include + +void init_waitqueue_head(wait_queue_head_t *q) +{ + q->init = 1; +} + +void wake_up(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void wake_up_all(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void wake_up_interruptible(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void interruptible_sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} diff --git a/ddverify/models/con1/src/linux/kernel/workqueue.c b/ddverify/models/con1/src/linux/kernel/workqueue.c new file mode 100644 index 000000000..26d035768 --- /dev/null +++ b/ddverify/models/con1/src/linux/kernel/workqueue.c @@ -0,0 +1,39 @@ +#include +#include +#include + +int schedule_work(struct work_struct *work) +{ + int i; + +#ifdef DDV_ASSERT_WORK_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(work->init, "Work queue is initalized"); +#endif + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + if (shared_workqueue[i] == work) { + return 0; + } + + if (shared_workqueue[i] == NULL) { + shared_workqueue[i] = work; + + return 1; + } + } + + + return -1; +} + +void call_shared_workqueue_functions() +{ + unsigned short i = nondet_ushort(); + __CPROVER_assume(i < MAX_WORKQUEUE_ELEMENTS_SUPPORT); + + if (shared_workqueue[i] != NULL) { + (*shared_workqueue[i]->func)(shared_workqueue[i]->data); + shared_workqueue[i] = NULL; + } +} diff --git a/ddverify/models/con1/src/linux/mm/page_alloc.c b/ddverify/models/con1/src/linux/mm/page_alloc.c new file mode 100644 index 000000000..40d236be0 --- /dev/null +++ b/ddverify/models/con1/src/linux/mm/page_alloc.c @@ -0,0 +1,52 @@ +#include +#include +#include + +unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +unsigned long __get_free_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +unsigned long get_zeroed_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, + unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +struct page * alloc_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} diff --git a/ddverify/models/con1/src/linux/mm/slab.c b/ddverify/models/con1/src/linux/mm/slab.c new file mode 100644 index 000000000..7b21afa25 --- /dev/null +++ b/ddverify/models/con1/src/linux/mm/slab.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +void * kmalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} + +void * kzalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} diff --git a/ddverify/models/con1/src/linux/mm/vmalloc.c b/ddverify/models/con1/src/linux/mm/vmalloc.c new file mode 100644 index 000000000..0edd579f7 --- /dev/null +++ b/ddverify/models/con1/src/linux/mm/vmalloc.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +void * vmalloc(unsigned long size) +{ + return malloc(size); +} diff --git a/ddverify/models/con1/src/linux/pci.c b/ddverify/models/con1/src/linux/pci.c new file mode 100644 index 000000000..26d58cee1 --- /dev/null +++ b/ddverify/models/con1/src/linux/pci.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include +#include + +int pci_enable_device(struct pci_dev *dev) +{ + int i; + + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + dev->resource[i].flags = IORESOURCE_IO; + dev->resource[i].start = nondet_uint(); + dev->resource[i].end = dev->resource[i].start + nondet_ushort(); + } +} + +struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) +{ + if (from == NULL) { + from = (struct pci_dev*)malloc(sizeof(struct pci_dev)); + } + + if (nondet_int()) { + from->vendor = nondet_ushort(); + from->device = nondet_ushort(); + from->irq = nondet_uint(); + __CPROVER_assume(from->irq < MAX_IRQ_SUPPORT); + + return from; + } else { + return NULL; + } +} + +int pci_register_driver(struct pci_driver *driver) +{ + if (nondet_int()) { + registered_pci_driver.pci_driver = driver; + registered_pci_driver.no_pci_device_id = sizeof(driver->id_table) / sizeof(struct pci_device_id); + registered_pci_driver.dev_initialized = 0; + + return 0; + } else { + return -1; + } +} + +void pci_unregister_driver(struct pci_driver *driver) +{ + registered_pci_driver.pci_driver = NULL; + registered_pci_driver.no_pci_device_id = 0; +} + +void pci_release_region(struct pci_dev *pdev, int bar) +{ + if (pci_resource_len(pdev, bar) == 0) + return; + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) + release_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) + release_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); +} + +int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) +{ + if (pci_resource_len(pdev, bar) == 0) + return 0; + + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) { + if (!request_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { + if (!request_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + + return 0; +} + + +void pci_release_regions(struct pci_dev *pdev) +{ + int i; + + for (i = 0; i < 6; i++) + pci_release_region(pdev, i); +} + + +int pci_request_regions(struct pci_dev *pdev, const char *res_name) +{ + int i; + + for (i = 0; i < 6; i++) + if(pci_request_region(pdev, i, res_name)) + goto err_out; + return 0; + + err_out: + while(--i >= 0) + pci_release_region(pdev, i); + + return -EBUSY; +} diff --git a/ddverify/models/con2/include/asm-generic/bug.h b/ddverify/models/con2/include/asm-generic/bug.h new file mode 100644 index 000000000..18a3c237d --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/bug.h @@ -0,0 +1,9 @@ +#ifndef _ASM_GENERIC_BUG_H +#define _ASM_GENERIC_BUG_H + +#include +#include + +#define BUG_ON(condition) __CPROVER_assume(condition) + +#endif diff --git a/ddverify/models/con2/include/asm-generic/errno-base.h b/ddverify/models/con2/include/asm-generic/errno-base.h new file mode 100644 index 000000000..651159785 --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/errno-base.h @@ -0,0 +1,39 @@ +#ifndef _ASM_GENERIC_ERRNO_BASE_H +#define _ASM_GENERIC_ERRNO_BASE_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#endif diff --git a/ddverify/models/con2/include/asm-generic/errno.h b/ddverify/models/con2/include/asm-generic/errno.h new file mode 100644 index 000000000..e8852c092 --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/errno.h @@ -0,0 +1,109 @@ +#ifndef _ASM_GENERIC_ERRNO_H +#define _ASM_GENERIC_ERRNO_H + +#include + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* for robust mutexes */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ + +#endif diff --git a/ddverify/models/con2/include/asm-generic/fcntl.h b/ddverify/models/con2/include/asm-generic/fcntl.h new file mode 100644 index 000000000..897b3f5a5 --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/fcntl.h @@ -0,0 +1,110 @@ +#ifndef _ASM_GENERIC_FCNTL_H +#define _ASM_GENERIC_FCNTL_H + +#include +#include + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 00000003 +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 +#ifndef O_CREAT +#define O_CREAT 00000100 /* not fcntl */ +#endif +#ifndef O_EXCL +#define O_EXCL 00000200 /* not fcntl */ +#endif +#ifndef O_NOCTTY +#define O_NOCTTY 00000400 /* not fcntl */ +#endif +#ifndef O_TRUNC +#define O_TRUNC 00001000 /* not fcntl */ +#endif +#ifndef O_APPEND +#define O_APPEND 00002000 +#endif +#ifndef O_NONBLOCK +#define O_NONBLOCK 00004000 +#endif +#ifndef O_SYNC +#define O_SYNC 00010000 +#endif +#ifndef FASYNC +#define FASYNC 00020000 /* fcntl, for BSD compatibility */ +#endif +#ifndef O_DIRECT +#define O_DIRECT 00040000 /* direct disk access hint */ +#endif +#ifndef O_LARGEFILE +#define O_LARGEFILE 00100000 +#endif +#ifndef O_DIRECTORY +#define O_DIRECTORY 00200000 /* must be a directory */ +#endif +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 00400000 /* don't follow links */ +#endif +#ifndef O_NOATIME +#define O_NOATIME 01000000 +#endif +#ifndef O_NDELAY +#define O_NDELAY O_NONBLOCK +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get close_on_exec */ +#define F_SETFD 2 /* set/clear close_on_exec */ +#define F_GETFL 3 /* get file->f_flags */ +#define F_SETFL 4 /* set file->f_flags */ +#ifndef F_GETLK +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#endif +#ifndef F_SETOWN +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ +#endif +#ifndef F_SETSIG +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ +#endif + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#ifndef F_RDLCK +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 +#endif + +/* for old implementation of bsd flock () */ +#ifndef F_EXLCK +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ +#endif + +/* for leases */ +#ifndef F_INPROGRESS +#define F_INPROGRESS 16 +#endif + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#define LOCK_MAND 32 /* This is a mandatory flock ... */ +#define LOCK_READ 64 /* which allows concurrent read operations */ +#define LOCK_WRITE 128 /* which allows concurrent write operations */ +#define LOCK_RW 192 /* which allows concurrent read & write ops */ + +#define F_LINUX_SPECIFIC_BASE 1024 + +#endif /* _ASM_GENERIC_FCNTL_H */ diff --git a/ddverify/models/con2/include/asm-generic/ioctl.h b/ddverify/models/con2/include/asm-generic/ioctl.h new file mode 100644 index 000000000..cd027298b --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/ioctl.h @@ -0,0 +1,80 @@ +#ifndef _ASM_GENERIC_IOCTL_H +#define _ASM_GENERIC_IOCTL_H + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The generic ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __invalid_size_argument_for_IOC; +#define _IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ + sizeof(t) : __invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#endif /* _ASM_GENERIC_IOCTL_H */ diff --git a/ddverify/models/con2/include/asm-generic/pci-dma-compat.h b/ddverify/models/con2/include/asm-generic/pci-dma-compat.h new file mode 100644 index 000000000..4bb451317 --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/pci-dma-compat.h @@ -0,0 +1,20 @@ +/* include this file if the platform implements the dma_ DMA Mapping API + * and wants to provide the pci_ DMA Mapping API in terms of it */ + +#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H +#define _ASM_GENERIC_PCI_DMA_COMPAT_H + +void * pci_alloc_consistent(struct pci_dev *hwdev, size_t size, + dma_addr_t *dma_handle); + +void pci_free_consistent(struct pci_dev *hwdev, size_t size, + void *vaddr, dma_addr_t dma_handle); + +dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction); +void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction); + +dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page, + unsigned long offset, size_t size, int direction); +void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, + size_t size, int direction); +#endif diff --git a/ddverify/models/con2/include/asm-generic/rtc.h b/ddverify/models/con2/include/asm-generic/rtc.h new file mode 100644 index 000000000..a8a13c916 --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/rtc.h @@ -0,0 +1,18 @@ +#ifndef __ASM_GENERIC_RTC_H__ +#define __ASM_GENERIC_RTC_H__ + +#include +#include + +#define RTC_PIE 0x40 /* periodic interrupt enable */ +#define RTC_AIE 0x20 /* alarm interrupt enable */ +#define RTC_UIE 0x10 /* update-finished interrupt enable */ + +/* some dummy definitions */ +#define RTC_BATT_BAD 0x100 /* battery bad */ +#define RTC_SQWE 0x08 /* enable square-wave output */ +#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +#endif diff --git a/ddverify/models/con2/include/asm-generic/siginfo.h b/ddverify/models/con2/include/asm-generic/siginfo.h new file mode 100644 index 000000000..383411b5c --- /dev/null +++ b/ddverify/models/con2/include/asm-generic/siginfo.h @@ -0,0 +1,118 @@ +#ifndef _ASM_GENERIC_SIGINFO_H +#define _ASM_GENERIC_SIGINFO_H + +#include +#include + +/* + * This is the size (including padding) of the part of the + * struct siginfo that is before the union. + */ +#ifndef __ARCH_SI_PREAMBLE_SIZE +#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) +#endif + +#define SI_MAX_SIZE 128 +#ifndef SI_PAD_SIZE +#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) +#endif + +#ifndef __ARCH_SI_UID_T +#define __ARCH_SI_UID_T uid_t +#endif + +/* + * The default "si_band" type is "long", as specified by POSIX. + * However, some architectures want to override this to "int" + * for historical compatibility reasons, so we allow that. + */ +#ifndef __ARCH_SI_BAND_T +#define __ARCH_SI_BAND_T long +#endif + + +#define __SI_MASK 0xffff0000u +#define __SI_KILL (0 << 16) +#define __SI_TIMER (1 << 16) +#define __SI_POLL (2 << 16) +#define __SI_FAULT (3 << 16) +#define __SI_CHLD (4 << 16) +#define __SI_RT (5 << 16) +#define __SI_MESGQ (6 << 16) + + +/* + * SIGILL si_codes + */ +#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ +#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ +#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ +#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ +#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ +#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ +#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ +#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ +#define NSIGILL 8 + +/* + * SIGFPE si_codes + */ +#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ +#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ +#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ +#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ +#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ +#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ +#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ +#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ +#define NSIGFPE 8 + +/* + * SIGSEGV si_codes + */ +#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ +#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ +#define NSIGSEGV 2 + +/* + * SIGBUS si_codes + */ +#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ +#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ +#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ +#define NSIGBUS 3 + +/* + * SIGTRAP si_codes + */ +#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ +#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ +#define NSIGTRAP 2 + +/* + * SIGCHLD si_codes + */ +#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ +#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ +#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ +#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ +#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ +#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ +#define NSIGCHLD 6 + +/* + * SIGPOLL si_codes + */ +#define POLL_IN (__SI_POLL|1) /* data input available */ +#define POLL_OUT (__SI_POLL|2) /* output buffers available */ +#define POLL_MSG (__SI_POLL|3) /* input message available */ +#define POLL_ERR (__SI_POLL|4) /* i/o error */ +#define POLL_PRI (__SI_POLL|5) /* high priority input available */ +#define POLL_HUP (__SI_POLL|6) /* device disconnected */ +#define NSIGPOLL 6 + +typedef struct siginfo { + int something; +} siginfo_t; + +#endif diff --git a/ddverify/models/con2/include/asm/atomic.h b/ddverify/models/con2/include/asm/atomic.h new file mode 100644 index 000000000..226e1b397 --- /dev/null +++ b/ddverify/models/con2/include/asm/atomic.h @@ -0,0 +1,169 @@ +#ifndef __ARCH_I386_ATOMIC__ +#define __ARCH_I386_ATOMIC__ + +#include + +typedef int atomic_t; + +#define ATOMIC_INIT(i) { (i) } + +/** + * atomic_read - read atomic variable + * @v: pointer of type atomic_t + * + * Atomically reads the value of @v. + */ +#define atomic_read(v) (*v) + +/** + * atomic_set - set atomic variable + * @v: pointer of type atomic_t + * @i: required value + * + * Atomically sets the value of @v to @i. + */ +#define atomic_set(v,i) (*v) = i + +/** + * atomic_add - add integer to atomic variable + * @i: integer value to add + * @v: pointer of type atomic_t + * + * Atomically adds @i to @v. + */ +static __inline__ void atomic_add(int i, atomic_t *v) +{ + (*v) = (*v) + i; +} + +/** + * atomic_sub - subtract the atomic variable + * @i: integer value to subtract + * @v: pointer of type atomic_t + * + * Atomically subtracts @i from @v. + */ +static __inline__ void atomic_sub(int i, atomic_t *v) +{ + (*v) = (*v) - i; +} + +/** + * atomic_inc - increment atomic variable + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1. + */ +static __inline__ void atomic_inc(atomic_t *v) +{ + (*v)++; +} + +/** + * atomic_dec - decrement atomic variable + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1. + */ +static __inline__ void atomic_dec(atomic_t *v) +{ + (*v)--; +} + +/** + * atomic_dec_and_test - decrement and test + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1 and + * returns true if the result is 0, or false for all other + * cases. + */ +static __inline__ int atomic_dec_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)--; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_inc_and_test - increment and test + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1 + * and returns true if the result is zero, or false for all + * other cases. + */ +static __inline__ int atomic_inc_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)++; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_negative - add and test if negative + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns true + * if the result is negative, or false when + * result is greater than or equal to zero. + */ +static __inline__ int atomic_add_negative(int i, atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v) = (*v) + i; + if ((*v) < 0) { + ret = 1; + } else { + ret = 0; + } + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_return - add and return + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns @i + @v + */ +static __inline__ int atomic_add_return(int i, atomic_t *v) +{ + return (*v) + i; +} + +static __inline__ int atomic_sub_return(int i, atomic_t *v) +{ + return (*v) - i; +} + +#define atomic_inc_return(v) (atomic_add_return(1,v)) +#define atomic_dec_return(v) (atomic_sub_return(1,v)) + +#endif diff --git a/ddverify/models/con2/include/asm/bitops.h b/ddverify/models/con2/include/asm/bitops.h new file mode 100644 index 000000000..6b4e2116a --- /dev/null +++ b/ddverify/models/con2/include/asm/bitops.h @@ -0,0 +1,13 @@ +#ifndef _I386_BITOPS_H +#define _I386_BITOPS_H + +void set_bit(int nr, unsigned long * addr); + +int test_and_set_bit(int nr, unsigned long * addr); +int test_and_clear_bit(int nr, unsigned long * addr); +int test_and_change_bit(int nr, unsigned long* addr); +int test_bit(int nr, const void * addr); +void clear_bit(int nr, volatile unsigned long * addr); +int find_first_zero_bit(const unsigned long *addr, unsigned size); + +#endif /* _I386_BITOPS_H */ diff --git a/ddverify/models/con2/include/asm/bug.h b/ddverify/models/con2/include/asm/bug.h new file mode 100644 index 000000000..9536f4539 --- /dev/null +++ b/ddverify/models/con2/include/asm/bug.h @@ -0,0 +1,7 @@ +#ifndef _I386_BUG_H +#define _I386_BUG_H + +#include +#include +#endif + diff --git a/ddverify/models/con2/include/asm/byteorder.h b/ddverify/models/con2/include/asm/byteorder.h new file mode 100644 index 000000000..20edb1dfa --- /dev/null +++ b/ddverify/models/con2/include/asm/byteorder.h @@ -0,0 +1,9 @@ +#ifndef _I386_BYTEORDER_H +#define _I386_BYTEORDER_H + +#include +#include + +#include + +#endif /* _I386_BYTEORDER_H */ diff --git a/ddverify/models/con2/include/asm/current.h b/ddverify/models/con2/include/asm/current.h new file mode 100644 index 000000000..f124ae985 --- /dev/null +++ b/ddverify/models/con2/include/asm/current.h @@ -0,0 +1,14 @@ +#ifndef _I386_CURRENT_H +#define _I386_CURRENT_H + +//#include +#include + +struct task_struct; + +struct task_struct *get_current(void); + +#define current get_current() + +#endif /* !(_I386_CURRENT_H) */ + diff --git a/ddverify/models/con2/include/asm/delay.h b/ddverify/models/con2/include/asm/delay.h new file mode 100644 index 000000000..153e9bc14 --- /dev/null +++ b/ddverify/models/con2/include/asm/delay.h @@ -0,0 +1,6 @@ +#ifndef _I386_DELAY_H +#define _I386_DELAY_H + +void udelay(int); + +#endif /* defined(_I386_DELAY_H) */ diff --git a/ddverify/models/con2/include/asm/dma.h b/ddverify/models/con2/include/asm/dma.h new file mode 100644 index 000000000..1e1f3855e --- /dev/null +++ b/ddverify/models/con2/include/asm/dma.h @@ -0,0 +1,72 @@ +#ifndef _ASM_DMA_H +#define _ASM_DMA_H + +#include /* And spinlocks */ +#include /* need byte IO */ +#include + +#define MAX_DMA_CHANNELS 8 + +/* The maximum address that we can perform a DMA transfer to on this platform */ +#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000) + +/* 8237 DMA controllers */ +#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ +#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ + +/* DMA controller registers */ +#define DMA1_CMD_REG 0x08 /* command register (w) */ +#define DMA1_STAT_REG 0x08 /* status register (r) */ +#define DMA1_REQ_REG 0x09 /* request register (w) */ +#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ +#define DMA1_MODE_REG 0x0B /* mode register (w) */ +#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ +#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ +#define DMA1_RESET_REG 0x0D /* Master Clear (w) */ +#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ +#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ + +#define DMA2_CMD_REG 0xD0 /* command register (w) */ +#define DMA2_STAT_REG 0xD0 /* status register (r) */ +#define DMA2_REQ_REG 0xD2 /* request register (w) */ +#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ +#define DMA2_MODE_REG 0xD6 /* mode register (w) */ +#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ +#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ +#define DMA2_RESET_REG 0xDA /* Master Clear (w) */ +#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ +#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ + +#define DMA_ADDR_0 0x00 /* DMA address registers */ +#define DMA_ADDR_1 0x02 +#define DMA_ADDR_2 0x04 +#define DMA_ADDR_3 0x06 +#define DMA_ADDR_4 0xC0 +#define DMA_ADDR_5 0xC4 +#define DMA_ADDR_6 0xC8 +#define DMA_ADDR_7 0xCC + +#define DMA_CNT_0 0x01 /* DMA count registers */ +#define DMA_CNT_1 0x03 +#define DMA_CNT_2 0x05 +#define DMA_CNT_3 0x07 +#define DMA_CNT_4 0xC2 +#define DMA_CNT_5 0xC6 +#define DMA_CNT_6 0xCA +#define DMA_CNT_7 0xCE + +#define DMA_PAGE_0 0x87 /* DMA page registers */ +#define DMA_PAGE_1 0x83 +#define DMA_PAGE_2 0x81 +#define DMA_PAGE_3 0x82 +#define DMA_PAGE_5 0x8B +#define DMA_PAGE_6 0x89 +#define DMA_PAGE_7 0x8A + +#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ +#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ +#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ + +#define DMA_AUTOINIT 0x10 + +#endif /* _ASM_DMA_H */ diff --git a/ddverify/models/con2/include/asm/errno.h b/ddverify/models/con2/include/asm/errno.h new file mode 100644 index 000000000..969b34374 --- /dev/null +++ b/ddverify/models/con2/include/asm/errno.h @@ -0,0 +1,6 @@ +#ifndef _I386_ERRNO_H +#define _I386_ERRNO_H + +#include + +#endif diff --git a/ddverify/models/con2/include/asm/fcntl.h b/ddverify/models/con2/include/asm/fcntl.h new file mode 100644 index 000000000..46ab12db5 --- /dev/null +++ b/ddverify/models/con2/include/asm/fcntl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/con2/include/asm/floppy.h b/ddverify/models/con2/include/asm/floppy.h new file mode 100644 index 000000000..fdbf1c705 --- /dev/null +++ b/ddverify/models/con2/include/asm/floppy.h @@ -0,0 +1,45 @@ +#ifndef __ASM_I386_FLOPPY_H +#define __ASM_I386_FLOPPY_H + +#include + +static int FDC1 = 0x3f0; +static int FDC2 = -1; + + +/* + * Floppy types are stored in the rtc's CMOS RAM and so rtc_lock + * is needed to prevent corrupted CMOS RAM in case "insmod floppy" + * coincides with another rtc CMOS user. Paul G. + */ +/*#define FLOPPY0_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = (CMOS_READ(0x10) >> 4) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) + +#define FLOPPY1_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = CMOS_READ(0x10) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) +*/ +#define FLOPPY0_TYPE (CMOS_READ(0x10) >> 4) & 15 +#define FLOPPY1_TYPE CMOS_READ(0x10) & 15 + +#define N_FDC 2 +#define N_DRIVE 8 + +#define FLOPPY_MOTOR_MASK 0xf0 + +#define AUTO_DMA + +#define EXTRA_FLOPPY_PARAMS + +#endif /* __ASM_I386_FLOPPY_H */ diff --git a/ddverify/models/con2/include/asm/highmem.h b/ddverify/models/con2/include/asm/highmem.h new file mode 100644 index 000000000..c9c362c4f --- /dev/null +++ b/ddverify/models/con2/include/asm/highmem.h @@ -0,0 +1,17 @@ +#ifndef _ASM_HIGHMEM_H +#define _ASM_HIGHMEM_H + +#include +//#include +#include +//#include + + +void *kmap(struct page *page); +void kunmap(struct page *page); +void *kmap_atomic(struct page *page, enum km_type type); +void kunmap_atomic(void *kvaddr, enum km_type type); +void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); +struct page *kmap_atomic_to_page(void *ptr); + +#endif /* _ASM_HIGHMEM_H */ diff --git a/ddverify/models/con2/include/asm/io.h b/ddverify/models/con2/include/asm/io.h new file mode 100644 index 000000000..703139060 --- /dev/null +++ b/ddverify/models/con2/include/asm/io.h @@ -0,0 +1,69 @@ +#ifndef _ASM_IO_H +#define _ASM_IO_H + +void * phys_to_virt(unsigned long); + +#define bus_to_virt phys_to_virt + +void *ioremap(unsigned long offset, unsigned long size); +void *ioremap_nocache(unsigned long offset, unsigned long size); +void iounmap(void *addr); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb(unsigned int); +void outb(unsigned char byte, unsigned int); +unsigned short inw(unsigned int); +void outw(unsigned short word, unsigned int); +unsigned inl(unsigned int); +void outl(unsigned doubleword, unsigned int); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb_p(unsigned int); +void outb_p(unsigned char byte, unsigned int); +unsigned short inw_p(unsigned int); +void outw_p(unsigned short word, unsigned int); +unsigned inl_p(unsigned int); +void outl_p(unsigned doubleword, unsigned int); + + + +unsigned insb(unsigned int, void *addr, unsigned long count); +void outsb(unsigned int, void *addr, unsigned long count); + +unsigned insw(unsigned int, void *addr, unsigned long count); +void outsw(unsigned int, void *addr, unsigned long count); + +unsigned insl(unsigned int, void *addr, unsigned long count); +void outsl(unsigned int, void *addr, unsigned long count); + + + +unsigned int ioread8(void *addr); +unsigned int ioread16(void *addr); +unsigned int ioread32(void *addr); + +void iowrite8(u8 value, void *addr); +void iowrite16(u16 value, void *addr); +void iowrite32(u32 value, void *addr); + +void ioread8_rep(void *addr, void *buf, unsigned long count); +void ioread16_rep(void *addr, void *buf, unsigned long count); +void ioread32_rep(void *addr, void *buf, unsigned long count); + +void iowrite8_rep(void *addr, const void *buf, unsigned long count); +void iowrite16_rep(void *addr, const void *buf, unsigned long count); +void iowrite32_rep(void *addr, const void *buf, unsigned long count); + +// DDV: no bodies required for these functions: +unsigned char readb(const void *); +unsigned short readw(const void *); +unsigned int readl(const void *); + +// DDV: no bodies required for these functions: +void writeb(unsigned char, void *); +void writew(unsigned short, void *); +void writel(unsigned int, void *); + +#endif diff --git a/ddverify/models/con2/include/asm/ioctl.h b/ddverify/models/con2/include/asm/ioctl.h new file mode 100644 index 000000000..b279fe06d --- /dev/null +++ b/ddverify/models/con2/include/asm/ioctl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/con2/include/asm/ioctls.h b/ddverify/models/con2/include/asm/ioctls.h new file mode 100644 index 000000000..4157abdb1 --- /dev/null +++ b/ddverify/models/con2/include/asm/ioctls.h @@ -0,0 +1,91 @@ +#ifndef __ARCH_CRIS_IOCTLS_H__ +#define __ARCH_CRIS_IOCTLS_H__ + +/* verbatim copy of asm-i386/ioctls.h */ + +#include + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TCGETS2 _IOR('T',0x2A, struct termios2) +#define TCSETS2 _IOW('T',0x2B, struct termios2) +#define TCSETSW2 _IOW('T',0x2C, struct termios2) +#define TCSETSF2 _IOW('T',0x2D, struct termios2) +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ +#define FIOQSIZE 0x5460 + +#define TIOCSERSETRS485 0x5461 /* enable rs-485 */ +#define TIOCSERWRRS485 0x5462 /* write rs-485 */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif diff --git a/ddverify/models/con2/include/asm/irq.h b/ddverify/models/con2/include/asm/irq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/asm/kmap_types.h b/ddverify/models/con2/include/asm/kmap_types.h new file mode 100644 index 000000000..fd2cdabbd --- /dev/null +++ b/ddverify/models/con2/include/asm/kmap_types.h @@ -0,0 +1,23 @@ +#ifndef _ASM_KMAP_TYPES_H +#define _ASM_KMAP_TYPES_H + +enum km_type { + KM_BOUNCE_READ, + KM_SKB_SUNRPC_DATA, + KM_SKB_DATA_SOFTIRQ, + KM_USER0, + KM_USER1, + KM_BIO_SRC_IRQ, + KM_BIO_DST_IRQ, + KM_PTE0, + KM_PTE1, + KM_IRQ0, + KM_IRQ1, + KM_SOFTIRQ0, + KM_SOFTIRQ1, + KM_KDB, + KM_DUMP, + KM_TYPE_NR +}; + +#endif diff --git a/ddverify/models/con2/include/asm/leds.h b/ddverify/models/con2/include/asm/leds.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/asm/mach-types.h b/ddverify/models/con2/include/asm/mach-types.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/asm/mc146818rtc.h b/ddverify/models/con2/include/asm/mc146818rtc.h new file mode 100644 index 000000000..0c97cfb90 --- /dev/null +++ b/ddverify/models/con2/include/asm/mc146818rtc.h @@ -0,0 +1,34 @@ +/* + * Machine dependent access functions for RTC registers. + */ +#ifndef _ASM_MC146818RTC_H +#define _ASM_MC146818RTC_H + +#include +#include +#include + +#ifndef RTC_PORT +#define RTC_PORT(x) (0x70 + (x)) +#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ +#endif + +#define lock_cmos_prefix(reg) do {} while (0) +#define lock_cmos_suffix(reg) do {} while (0) +#define lock_cmos(reg) +#define unlock_cmos() +#define do_i_have_lock_cmos() 0 +#define current_lock_cmos_reg() 0 + +/* + * The yet supported machines all access the RTC index register via + * an ISA port access but the way to access the date register differs ... + */ +#define CMOS_READ(addr) rtc_cmos_read(addr) +#define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr) +unsigned char rtc_cmos_read(unsigned char addr); +void rtc_cmos_write(unsigned char val, unsigned char addr); + +#define RTC_IRQ 8 + +#endif /* _ASM_MC146818RTC_H */ diff --git a/ddverify/models/con2/include/asm/msr.h b/ddverify/models/con2/include/asm/msr.h new file mode 100644 index 000000000..adf72e79e --- /dev/null +++ b/ddverify/models/con2/include/asm/msr.h @@ -0,0 +1,10 @@ +#ifndef __ASM_MSR_H +#define __ASM_MSR_H + +#define rdmsr(msr, val1, val2) \ + do { \ + val1 = nondet_u32(); \ + val2 = nondet_u32(); \ + } while(0); + +#endif diff --git a/ddverify/models/con2/include/asm/page.h b/ddverify/models/con2/include/asm/page.h new file mode 100644 index 000000000..b2bc603c9 --- /dev/null +++ b/ddverify/models/con2/include/asm/page.h @@ -0,0 +1,24 @@ +#ifndef _I386_PAGE_H +#define _I386_PAGE_H + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +//#include + + +// DDV: taken from arch/i386/defconfig +#define CONFIG_PAGE_OFFSET 0xC0000000 +// DDV: taken from arch/i386/defconfig +#define CONFIG_PHYSICAL_START 0x100000 + +#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET) +#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START) + +#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) +#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) +#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) + +#endif /* _I386_PAGE_H */ diff --git a/ddverify/models/con2/include/asm/param.h b/ddverify/models/con2/include/asm/param.h new file mode 100644 index 000000000..6148b8ddf --- /dev/null +++ b/ddverify/models/con2/include/asm/param.h @@ -0,0 +1,8 @@ +#ifndef _ASMi386_PARAM_H +#define _ASMi386_PARAM_H + +#ifndef HZ +#define HZ 100 +#endif + +#endif diff --git a/ddverify/models/con2/include/asm/pci.h b/ddverify/models/con2/include/asm/pci.h new file mode 100644 index 000000000..c41fd10d2 --- /dev/null +++ b/ddverify/models/con2/include/asm/pci.h @@ -0,0 +1,17 @@ +#ifndef __i386_PCI_H +#define __i386_PCI_H + +#include /* for struct page */ + +#include +#include +#include +#include +#include + + + +#include + + +#endif /* __i386_PCI_H */ diff --git a/ddverify/models/con2/include/asm/poll.h b/ddverify/models/con2/include/asm/poll.h new file mode 100644 index 000000000..905fb4d78 --- /dev/null +++ b/ddverify/models/con2/include/asm/poll.h @@ -0,0 +1,20 @@ +#ifndef __i386_POLL_H +#define __i386_POLL_H + +/* These are specified by iBCS2 */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +/* The rest seem to be more-or-less nonstandard. Check them! */ +#define POLLRDNORM 0x0040 +#define POLLRDBAND 0x0080 +#define POLLWRNORM 0x0100 +#define POLLWRBAND 0x0200 +#define POLLMSG 0x0400 +#define POLLREMOVE 0x1000 + +#endif diff --git a/ddverify/models/con2/include/asm/posix_types.h b/ddverify/models/con2/include/asm/posix_types.h new file mode 100644 index 000000000..798ec0819 --- /dev/null +++ b/ddverify/models/con2/include/asm/posix_types.h @@ -0,0 +1,32 @@ +#ifndef __ARCH_I386_POSIX_TYPES_H +#define __ARCH_I386_POSIX_TYPES_H + +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; + +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; +typedef unsigned short __kernel_old_dev_t; + + +#endif diff --git a/ddverify/models/con2/include/asm/processor.h b/ddverify/models/con2/include/asm/processor.h new file mode 100644 index 000000000..b6dedb7ad --- /dev/null +++ b/ddverify/models/con2/include/asm/processor.h @@ -0,0 +1,6 @@ +#ifndef __ASM_I386_PROCESSOR_H +#define __ASM_I386_PROCESSOR_H + +#include + +#endif /* __ASM_I386_PROCESSOR_H */ diff --git a/ddverify/models/con2/include/asm/ptrace.h b/ddverify/models/con2/include/asm/ptrace.h new file mode 100644 index 000000000..69130f62a --- /dev/null +++ b/ddverify/models/con2/include/asm/ptrace.h @@ -0,0 +1,8 @@ +#ifndef _I386_PTRACE_H +#define _I386_PTRACE_H + +struct pt_regs { + int something; +}; + +#endif diff --git a/ddverify/models/con2/include/asm/rtc.h b/ddverify/models/con2/include/asm/rtc.h new file mode 100644 index 000000000..3d2d9102e --- /dev/null +++ b/ddverify/models/con2/include/asm/rtc.h @@ -0,0 +1,7 @@ +#ifndef __ASM_RTC_H__ +#define __ASM_RTC_H__ + +#include + +#endif + diff --git a/ddverify/models/con2/include/asm/scatterlist.h b/ddverify/models/con2/include/asm/scatterlist.h new file mode 100644 index 000000000..55d6c953a --- /dev/null +++ b/ddverify/models/con2/include/asm/scatterlist.h @@ -0,0 +1,21 @@ +#ifndef _I386_SCATTERLIST_H +#define _I386_SCATTERLIST_H + +struct scatterlist { + struct page *page; + unsigned int offset; + dma_addr_t dma_address; + unsigned int length; +}; + +/* These macros should be used after a pci_map_sg call has been done + * to get bus addresses of each of the SG entries and their lengths. + * You should only work with the number of sg entries pci_map_sg + * returns. + */ +#define sg_dma_address(sg) ((sg)->dma_address) +#define sg_dma_len(sg) ((sg)->length) + +#define ISA_DMA_THRESHOLD (0x00ffffff) + +#endif /* !(_I386_SCATTERLIST_H) */ diff --git a/ddverify/models/con2/include/asm/semaphore.h b/ddverify/models/con2/include/asm/semaphore.h new file mode 100644 index 000000000..5d574f8a9 --- /dev/null +++ b/ddverify/models/con2/include/asm/semaphore.h @@ -0,0 +1,37 @@ +#ifndef _I386_SEMAPHORE_H +#define _I386_SEMAPHORE_H + +struct semaphore { + int init; + int locked; +}; + + +#define __SEMAPHORE_INITIALIZER(name, n) \ +{ \ + .init = 1, \ + .locked = n \ +} + +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) + +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,0) +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,1) + +// DDV: Body is defined in linux/kernel/semaphore.c +void sema_init(struct semaphore *sem, int val); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX_LOCKED(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void down(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_interruptible(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_trylock(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void up(struct semaphore * sem); + +#endif diff --git a/ddverify/models/con2/include/asm/siginfo.h b/ddverify/models/con2/include/asm/siginfo.h new file mode 100644 index 000000000..fe18f98fc --- /dev/null +++ b/ddverify/models/con2/include/asm/siginfo.h @@ -0,0 +1,6 @@ +#ifndef _I386_SIGINFO_H +#define _I386_SIGINFO_H + +#include + +#endif diff --git a/ddverify/models/con2/include/asm/signal.h b/ddverify/models/con2/include/asm/signal.h new file mode 100644 index 000000000..d85fd7a75 --- /dev/null +++ b/ddverify/models/con2/include/asm/signal.h @@ -0,0 +1,86 @@ +#ifndef _ASMi386_SIGNAL_H +#define _ASMi386_SIGNAL_H + +#define _NSIG 64 +#define _NSIG_BPW 32 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef unsigned long old_sigset_t; /* at least 32 bits */ + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG + + +/* + * SA_FLAGS values: + * + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_NODEFER prevents the current signal from being masked in the handler. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#define SA_NOCLDSTOP 0x00000001u +#define SA_NOCLDWAIT 0x00000002u +#define SA_SIGINFO 0x00000004u +#define SA_ONSTACK 0x08000000u +#define SA_RESTART 0x10000000u +#define SA_NODEFER 0x40000000u +#define SA_RESETHAND 0x80000000u + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND +#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */ + +#define SA_RESTORER 0x04000000 + + +#endif diff --git a/ddverify/models/con2/include/asm/stat.h b/ddverify/models/con2/include/asm/stat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/asm/string.h b/ddverify/models/con2/include/asm/string.h new file mode 100644 index 000000000..6b1131c19 --- /dev/null +++ b/ddverify/models/con2/include/asm/string.h @@ -0,0 +1,6 @@ +#ifndef _I386_STRING_H_ +#define _I386_STRING_H_ + +void *memset(void *s, int c, size_t n); + +#endif diff --git a/ddverify/models/con2/include/asm/system.h b/ddverify/models/con2/include/asm/system.h new file mode 100644 index 000000000..1d6f962e6 --- /dev/null +++ b/ddverify/models/con2/include/asm/system.h @@ -0,0 +1,9 @@ +#ifndef __ASM_SYSTEM_H +#define __ASM_SYSTEM_H + +void rmb(void); +void read_barrier_depends(void); +void wmb(void); +void mb(void); + +#endif diff --git a/ddverify/models/con2/include/asm/termbits.h b/ddverify/models/con2/include/asm/termbits.h new file mode 100644 index 000000000..3606b9897 --- /dev/null +++ b/ddverify/models/con2/include/asm/termbits.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_I386_TERMBITS_H__ +#define __ARCH_I386_TERMBITS_H__ + +#include + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +#endif diff --git a/ddverify/models/con2/include/asm/termios.h b/ddverify/models/con2/include/asm/termios.h new file mode 100644 index 000000000..8f71467a2 --- /dev/null +++ b/ddverify/models/con2/include/asm/termios.h @@ -0,0 +1,54 @@ +#ifndef _I386_TERMIOS_H +#define _I386_TERMIOS_H + +#include +#include + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 /* X.25 async */ +#define N_6PACK 7 +#define N_MASC 8 /* Reserved for Mobitex module */ +#define N_R3964 9 /* Reserved for Simatic R3964 module */ +#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */ +#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */ +#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */ +#define N_HDLC 13 /* synchronous HDLC */ +#define N_SYNC_PPP 14 /* synchronous PPP */ +#define N_HCI 15 /* Bluetooth HCI UART */ + +#endif /* _I386_TERMIOS_H */ diff --git a/ddverify/models/con2/include/asm/types.h b/ddverify/models/con2/include/asm/types.h new file mode 100644 index 000000000..39b35bb5e --- /dev/null +++ b/ddverify/models/con2/include/asm/types.h @@ -0,0 +1,35 @@ +#ifndef _I386_TYPES_H +#define _I386_TYPES_H + +typedef unsigned short umode_t; + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +typedef __signed__ long long __s64; +typedef unsigned long long __u64; + +#define BITS_PER_LONG 32 + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +typedef u32 dma_addr_t; +typedef u64 dma64_addr_t; + +#endif diff --git a/ddverify/models/con2/include/asm/uaccess.h b/ddverify/models/con2/include/asm/uaccess.h new file mode 100644 index 000000000..a764a014c --- /dev/null +++ b/ddverify/models/con2/include/asm/uaccess.h @@ -0,0 +1,55 @@ +#ifndef __i386_UACCESS_H +#define __i386_UACCESS_H + +/* + * User space memory access functions + */ +#include +#include +#include +#include + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +/** + * access_ok: - Checks if a user space pointer is valid + * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that + * %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe + * to write to a block, it is always safe to read from it. + * @addr: User space pointer to start of block to check + * @size: Size of block to check + * + * Context: User context only. This function may sleep. + * + * Checks if a pointer to a block of memory in user space is valid. + * + * Returns true (nonzero) if the memory block may be valid, false (zero) + * if it is definitely invalid. + * + * Note that, depending on architecture, this function probably just + * checks that the pointer is in the user space range - after calling + * this function, memory access functions may still return -EFAULT. + */ +// #define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0)) +int access_ok(int type, const void *addr, unsigned long size); + + +// DDV-TODO: get_user and put_user are defined as macros!!! if bug030 is fixed, this should be done here. + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __get_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int get_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __put_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int put_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n); +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_from_user(void *to, void __user *from, unsigned long n); + +#endif /* __i386_UACCESS_H */ diff --git a/ddverify/models/con2/include/ddverify/blkdev.h b/ddverify/models/con2/include/ddverify/blkdev.h new file mode 100644 index 000000000..aa65ce957 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/blkdev.h @@ -0,0 +1,10 @@ +#ifndef _DDV_BLKDEV_H_ +#define _DDV_BLKDEV_H_ + +#define MAX_REQUEST_QUEUE_SUPPORT 10 + +request_queue_t fixed_request_queue[MAX_REQUEST_QUEUE_SUPPORT]; + +int number_request_queue_used = 0; + +#endif diff --git a/ddverify/models/con2/include/ddverify/cdev.h b/ddverify/models/con2/include/ddverify/cdev.h new file mode 100644 index 000000000..b4fa43cbe --- /dev/null +++ b/ddverify/models/con2/include/ddverify/cdev.h @@ -0,0 +1,26 @@ +#ifndef _DDV_CDEV_H +#define _DDV_CDEV_H + +#include +#include + +#define MAX_CDEV_SUPPORT 10 + +#include + +short number_cdev_registered = 0; + +struct ddv_cdev { + struct cdev *cdevp; + + struct file filp; + struct inode inode; + + int open; +}; + +struct ddv_cdev cdev_registered[MAX_CDEV_SUPPORT]; + +void call_cdev_functions(); + +#endif diff --git a/ddverify/models/con2/include/ddverify/ddverify.h b/ddverify/models/con2/include/ddverify/ddverify.h new file mode 100644 index 000000000..f6d8a06fe --- /dev/null +++ b/ddverify/models/con2/include/ddverify/ddverify.h @@ -0,0 +1,47 @@ +#ifndef _DDVERIFY_H +#define _DDVERIFY_H + +enum __bool { false, true }; + +#ifndef NULL +#define NULL ((void *)0) +#endif + + +int current_execution_context; + +#define CONTEXT_PROCESS 1 +#define CONTEXT_INTERRUPT 2 + +#define switch_context(x) current_execution_context = x + +#ifdef DDV_ASSERT_CONTEXT + +static inline assert_context_process() +{ + __CPROVER_assert(current_execution_context == CONTEXT_PROCESS, "Process context"); +} + +static inline assert_context_interrupt() +{ + __CPROVER_assert(current_execution_context == CONTEXT_INTERRUPT, "Interrupt context"); +} + +#else + +static inline assert_context_process() +{ +} + +static inline assert_context_interrupt() +{ +} + +#endif /* DDV_ASSERT_CONTEXT */ + +int (* _ddv_module_init)(void); +void (* _ddv_module_exit)(void); + +int call_ddv(); + +#endif diff --git a/ddverify/models/con2/include/ddverify/fixed_cdev.h b/ddverify/models/con2/include/ddverify/fixed_cdev.h new file mode 100644 index 000000000..347972b25 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/fixed_cdev.h @@ -0,0 +1,15 @@ +#ifndef _DDV_FIXED_CDEV_H_ +#define _DDV_FIXED_CDEV_H_ + +#include +#include +#include + +// Used in function misc_register and cdev_alloc. Instead allocating a cdev structure, +// a cdev structure from this array is used. This make the verification process much +// simpler. + +struct cdev fixed_cdev[MAX_CDEV_SUPPORT]; +int fixed_cdev_used = 0; + +#endif diff --git a/ddverify/models/con2/include/ddverify/genhd.h b/ddverify/models/con2/include/ddverify/genhd.h new file mode 100644 index 000000000..3d0161e60 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/genhd.h @@ -0,0 +1,29 @@ +#ifndef _DDV_GENHD_H +#define _DDV_GENHD_H + +#include +#include +#include + +#include + +#define MAX_GENHD_SUPPORT 10 + +short number_genhd_registered = 0; +short number_fixed_genhd_used = 0; + +struct ddv_genhd { + struct gendisk *gd; + + struct inode inode; + struct file file; + struct request current_request; + int requests_open; +}; + +struct gendisk fixed_gendisk[MAX_GENHD_SUPPORT]; +struct ddv_genhd genhd_registered[MAX_GENHD_SUPPORT]; + +void call_genhd_functions(); + +#endif diff --git a/ddverify/models/con2/include/ddverify/interrupt.h b/ddverify/models/con2/include/ddverify/interrupt.h new file mode 100644 index 000000000..bca87a686 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/interrupt.h @@ -0,0 +1,19 @@ +#ifndef _DDV_INTERRUPT_H +#define _DDV_INTERRUPT_H + +#include +#include + +#define MAX_IRQ_SUPPORT 16 + +struct registered_irq { + irq_handler_t handler; + void *dev_id; +}; + +struct registered_irq registered_irq[MAX_IRQ_SUPPORT]; + +void call_interrupt_handler(); + +#endif + diff --git a/ddverify/models/con2/include/ddverify/ioctl.h b/ddverify/models/con2/include/ddverify/ioctl.h new file mode 100644 index 000000000..76312e082 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/ioctl.h @@ -0,0 +1,15 @@ +#ifndef _DDV_IOCTL_H +#define _DDV_IOCTL_H + +/*#define MAX_IOCTL_SUPPORT 20 + +short number_ioctl_registered = 0; + +typedef unsigned int ddv_ioctl; + +ddv_ioctl ioctl_registered[MAX_IOCTL_SUPPORT]; + +void add_ioctl(unsigned int); +unsigned int get_ioctl_cmd(); +*/ +#endif diff --git a/ddverify/models/con2/include/ddverify/ioport.h b/ddverify/models/con2/include/ddverify/ioport.h new file mode 100644 index 000000000..d96407ad7 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/ioport.h @@ -0,0 +1,27 @@ +#ifndef _DDV_IOPORT_H +#define _DDV_IOPORT_H + +#include + +//#define NUMBER_IO_PORTS 65536 + +//ushort ddv_ioport[NUMBER_IO_PORTS - 1]; + +int ddv_ioport_request_start; +int ddv_ioport_request_len; + +#ifdef DDV_ASSERT_IO + +// __CPROVER_assert(ddv_ioport[port], "Used I/O Port was requested") + +#define ddv_correct_port_use(port) \ +__CPROVER_assert(port >= ddv_ioport_request_start && port < ddv_ioport_request_start + ddv_ioport_request_len, "I/O port is requested") + +#else + +#define ddv_correct_port_use(port) \ + do { } while(0) + +#endif /* DDV_ASSERT_IO */ + +#endif diff --git a/ddverify/models/con2/include/ddverify/miscdevice.h b/ddverify/models/con2/include/ddverify/miscdevice.h new file mode 100644 index 000000000..43b174d28 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/miscdevice.h @@ -0,0 +1,7 @@ +#ifndef _DDV_MISCDEVICE_H +#define _DDV_MISCDEVICE_H + +#include + +#endif + diff --git a/ddverify/models/con2/include/ddverify/pci.h b/ddverify/models/con2/include/ddverify/pci.h new file mode 100644 index 000000000..d2ece19a8 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/pci.h @@ -0,0 +1,22 @@ +#ifndef _DDV_PCI_H_ +#define _DDV_PCI_H_ + +#include + +struct ddv_pci_driver { + struct pci_driver *pci_driver; + struct pci_dev pci_dev; + + unsigned int no_pci_device_id; + int dev_initialized; +}; + +struct ddv_pci_driver registered_pci_driver; + +int pci_probe_device(); +void pci_remove_device(); + +void call_pci_functions(); + + +#endif diff --git a/ddverify/models/con2/include/ddverify/pthread.h b/ddverify/models/con2/include/ddverify/pthread.h new file mode 100644 index 000000000..64c351ee6 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/pthread.h @@ -0,0 +1,253 @@ +#ifndef __POSIX_PTHREAD_H +#define __POSIX_PTHREAD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NULL +#define NULL ((void *)0) +#endif + +/* Types */ +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +struct __pthread_mutex_t_struct +{ + _Bool locked; +}; + +struct __pthread_mutexattr_t_struct +{ + int dummy; +}; + +struct __pthread_spinlock_t_struct +{ + int dummy; +}; + +struct __pthread_barrier_t_struct +{ + int dummy; +}; + +struct __pthread_barrierattr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; +typedef struct __pthread_mutex_t_struct pthread_mutex_t; +typedef struct __pthread_mutexattr_t_struct pthread_mutexattr_t; +typedef struct __pthread_spinlock_t_struct pthread_spinlock_t; +typedef struct __pthread_barrier_t_struct pthread_barrier_t; +typedef struct __pthread_barrierattr_t_struct pthread_barrierattr_t; + +/* Initializers */ + +#define PTHREAD_MUTEX_INITIALIZER {0} + +/* Attributes */ + +enum +{ + PTHREAD_CREATE_JOINABLE, +#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE + PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED +}; + +enum +{ + PTHREAD_INHERIT_SCHED, +#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED + PTHREAD_EXPLICIT_SCHED +#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED +}; + +enum +{ + PTHREAD_SCOPE_SYSTEM, +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM + PTHREAD_SCOPE_PROCESS +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +}; + +enum +{ + PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_ADAPTIVE_NP, + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +}; + +enum +{ + PTHREAD_PROCESS_PRIVATE, +#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE + PTHREAD_PROCESS_SHARED +#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED +}; + +enum +{ + PTHREAD_RWLOCK_PREFER_READER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, + PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP +}; + +#define PTHREAD_ONCE_INIT 0 + +/* -1 is distinct from 0 and all errno constants */ +#define PTHREAD_BARRIER_SERIAL_THREAD -1 + +enum +{ + PTHREAD_CANCEL_ENABLE, +#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE + PTHREAD_CANCEL_DISABLE +#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +}; +enum +{ + PTHREAD_CANCEL_DEFERRED, +#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED + PTHREAD_CANCEL_ASYNCHRONOUS +#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS +}; +#define PTHREAD_CANCELED ((void *) -1) + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create( + pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg); + +extern pthread_t pthread_self(void); +extern int pthread_equal(pthread_t __thread1, pthread_t __thread2); +extern void pthread_exit(void *__retval); +extern int pthread_join(pthread_t __th, void **__thread_return); +extern int pthread_detach(pthread_t __th); +extern int pthread_attr_init(pthread_attr_t *__attr); +extern int pthread_attr_destroy(pthread_attr_t *__attr); +extern int pthread_attr_setdetachstate(pthread_attr_t *__attr, int __detachstate); +extern int pthread_attr_getdetachstate(__const pthread_attr_t *__attr, int *__detachstate); +extern int pthread_attr_setschedparam(pthread_attr_t *__attr, __const struct sched_param *__param); +extern int pthread_attr_getschedparam(__const pthread_attr_t *__attr, struct sched_param *__param); +extern int pthread_attr_setschedpolicy(pthread_attr_t *__attr, int __policy); +extern int pthread_attr_getschedpolicy(__const pthread_attr_t *__attr, int *__policy); +extern int pthread_attr_setinheritsched(pthread_attr_t *__attr, int __inherit); +extern int pthread_attr_getinheritsched(__const pthread_attr_t *__attr, int *__inherit); +extern int pthread_attr_setscope(pthread_attr_t *__attr, int __scope); +extern int pthread_attr_getscope(__const pthread_attr_t *__attr, int *__scope); +extern int pthread_attr_setguardsize(pthread_attr_t *__attr, size_t __guardsize); +extern int pthread_attr_getguardsize(__const pthread_attr_t *__attr, size_t *__guardsize); +extern int pthread_attr_setstackaddr(pthread_attr_t *__attr, void *__stackaddr); +extern int pthread_attr_getstackaddr(__const pthread_attr_t *__attr, void **__stackaddr); +extern int pthread_attr_setstack(pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize); +extern int pthread_attr_getstack(__const pthread_attr_t *__attr, + void **__stackaddr, + size_t *__stacksize); +extern int pthread_attr_setstacksize(pthread_attr_t *__attr, size_t __stacksize); +extern int pthread_attr_getstacksize(__const pthread_attr_t *, size_t *__stacksize); + +extern int pthread_getattr_np(pthread_t __th, pthread_attr_t *__attr); + +extern int pthread_setschedparam(pthread_t __target_thread, int __policy, + __const struct sched_param *__param); + +extern int pthread_getschedparam(pthread_t __target_thread, + int *__policy, + struct sched_param *__param); + +extern int pthread_getconcurrency(void); +extern int pthread_setconcurrency(int __level); +extern int pthread_yield(void); + +extern inline int pthread_mutex_init( + pthread_mutex_t *__mutex, + __const pthread_mutexattr_t *__mutex_attr) +{ + pthread_mutex_t i=PTHREAD_MUTEX_INITIALIZER; + *__mutex=i; +} + +extern inline int pthread_mutex_destroy(pthread_mutex_t *__mutex) +{ +} + +extern int pthread_mutex_trylock(pthread_mutex_t *__mutex); + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + +extern inline int pthread_mutex_lock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + __CPROVER_assume(!__mutex->locked); + __mutex->locked=1; + __CPROVER_atomic_end(); + return 0; // we never fail +} + +extern inline int pthread_mutex_unlock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_assert(__mutex->locked, "pthread_mutex_unlock without lock"); + __mutex->locked=0; + return 0; // we never fail +} + +extern int pthread_spin_init(pthread_spinlock_t *__lock, int __pshared); +extern int pthread_spin_destroy(pthread_spinlock_t *__lock); +extern int pthread_spin_lock(pthread_spinlock_t *__lock); +extern int pthread_spin_trylock(pthread_spinlock_t *__lock); +extern int pthread_spin_unlock(pthread_spinlock_t *__lock); +extern int pthread_barrier_init(pthread_barrier_t *__barrier, + __const pthread_barrierattr_t *__attr, unsigned int __count); + +extern int pthread_barrier_destroy(pthread_barrier_t *__barrier); +extern int pthread_barrierattr_init(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_destroy(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_getpshared(__const pthread_barrierattr_t *__attr, + int *__pshared); + +extern int pthread_barrierattr_setpshared(pthread_barrierattr_t *__attr, int __pshared); +extern int pthread_barrier_wait(pthread_barrier_t *__barrier); + +extern int pthread_setcancelstate(int __state, int *__oldstate); +extern int pthread_setcanceltype(int __type, int *__oldtype); +extern int pthread_cancel(pthread_t __cancelthread); +extern void pthread_testcancel(void); + +extern int pthread_atfork(void (*__prepare)(void), + void (*__parent)(void), + void (*__child)(void)); + +extern void pthread_kill_other_threads_np(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ddverify/models/con2/include/ddverify/satabs.h b/ddverify/models/con2/include/ddverify/satabs.h new file mode 100644 index 000000000..bb40b9867 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/satabs.h @@ -0,0 +1,69 @@ +#ifndef _SATABS_H +#define _SATABS_H + +#include +#include + +// memory management + +void *malloc(size_t size); + + +// nondeterministic functions + +short nondet_short(); +unsigned short nondet_ushort(); +int nondet_int(); +unsigned int nondet_uint(); +long nondet_long(); +unsigned long nondet_ulong(); +char nondet_char(); +unsigned char nondet_uchar(); +unsigned nondet_unsigned(); +loff_t nondet_loff_t(); +size_t nondet_size_t(); +sector_t nondet_sector_t(); +u32 nondet_u32(); +char * nondet_pchar(); +enum __bool nondet_bool(); + + +// handling asm code + +void noop(); +#define asm(code, ...) noop() + + +// __CPROVER functions + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + + +// pthread +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create(pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg) +{ + __CPROVER_HIDE: + *__threadp = nondet_pthread_t(); + CPROVER_ASYNC_1: __start_routine(__arg); + return 0; +} +#endif diff --git a/ddverify/models/con2/include/ddverify/tasklet.h b/ddverify/models/con2/include/ddverify/tasklet.h new file mode 100644 index 000000000..52e9e64f6 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/tasklet.h @@ -0,0 +1,20 @@ +#ifndef _DDV_TASKLET_H_ +#define _DDV_TASKLET_H_ + +#include + +#define MAX_TASKLET_SUPPORT 10 + +short number_tasklet_registered = 0; + +struct ddv_tasklet { + struct tasklet_struct *tasklet; + unsigned short is_running; +}; + +struct ddv_tasklet tasklet_registered[MAX_TASKLET_SUPPORT]; + +void call_tasklet_functions(); + +#endif + diff --git a/ddverify/models/con2/include/ddverify/timer.h b/ddverify/models/con2/include/ddverify/timer.h new file mode 100644 index 000000000..929cd7fca --- /dev/null +++ b/ddverify/models/con2/include/ddverify/timer.h @@ -0,0 +1,17 @@ +#ifndef _DDV_TIMER_H_ +#define _DDV_TIMER_H_ + +#include + +#define MAX_TIMER_SUPPORT 5 + +short number_timer_registered = 0; + +struct ddv_timer { + struct timer_list *timer; +}; + +struct ddv_timer timer_registered[MAX_TIMER_SUPPORT]; + +void call_timer_functions(); +#endif diff --git a/ddverify/models/con2/include/ddverify/tty.h b/ddverify/models/con2/include/ddverify/tty.h new file mode 100644 index 000000000..de3b5226f --- /dev/null +++ b/ddverify/models/con2/include/ddverify/tty.h @@ -0,0 +1,16 @@ +#ifndef _DDV_TTY_H_ +#define _DDV_TTY_H_ + +#include +#include + +struct ddv_tty_driver { + struct tty_driver driver; + unsigned short allocated; + unsigned short registered; +}; + +struct ddv_tty_driver global_tty_driver; + +#endif + diff --git a/ddverify/models/con2/include/ddverify/workqueue.h b/ddverify/models/con2/include/ddverify/workqueue.h new file mode 100644 index 000000000..2db429169 --- /dev/null +++ b/ddverify/models/con2/include/ddverify/workqueue.h @@ -0,0 +1,12 @@ +#ifndef _DDV_WORKQUEUE_H_ +#define _DDV_WORKQUEUE_H_ + +#include + +#define MAX_WORKQUEUE_ELEMENTS_SUPPORT 10 + +struct work_struct *shared_workqueue[MAX_WORKQUEUE_ELEMENTS_SUPPORT]; + +void call_shared_workqueue_functions(); + +#endif diff --git a/ddverify/models/con2/include/linux/backing-dev.h b/ddverify/models/con2/include/linux/backing-dev.h new file mode 100644 index 000000000..1804ab33f --- /dev/null +++ b/ddverify/models/con2/include/linux/backing-dev.h @@ -0,0 +1,37 @@ +/* + * include/linux/backing-dev.h + * + * low-level device information and state which is propagated up through + * to high-level code. + */ + +#ifndef _LINUX_BACKING_DEV_H +#define _LINUX_BACKING_DEV_H + +struct backing_dev_info { + unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ + unsigned long state; /* Always use atomic bitops on this */ + unsigned int capabilities; /* Device capabilities */ +}; + + +/* + * Flags in backing_dev_info::capability + * - The first two flags control whether dirty pages will contribute to the + * VM's accounting and whether writepages() should be called for dirty pages + * (something that would not, for example, be appropriate for ramfs) + * - These flags let !MMU mmap() govern direct device mapping vs immediate + * copying more easily for MAP_PRIVATE, especially for ROM filesystems + */ +#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ +#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ +#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ +#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ +#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ +#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ +#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ +#define BDI_CAP_VMFLAGS \ + (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) + + +#endif /* _LINUX_BACKING_DEV_H */ diff --git a/ddverify/models/con2/include/linux/bcd.h b/ddverify/models/con2/include/linux/bcd.h new file mode 100644 index 000000000..c54530812 --- /dev/null +++ b/ddverify/models/con2/include/linux/bcd.h @@ -0,0 +1,20 @@ +/* Permission is hereby granted to copy, modify and redistribute this code + * in terms of the GNU Library General Public License, Version 2 or later, + * at your option. + */ + +/* macros to translate to/from binary and binary-coded decimal (frequently + * found in RTC chips). + */ + +#ifndef _BCD_H +#define _BCD_H + +#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) +#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) + +/* backwards compat */ +#define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) +#define BIN_TO_BCD(val) ((val)=BIN2BCD(val)) + +#endif /* _BCD_H */ diff --git a/ddverify/models/con2/include/linux/bio.h b/ddverify/models/con2/include/linux/bio.h new file mode 100644 index 000000000..159afe963 --- /dev/null +++ b/ddverify/models/con2/include/linux/bio.h @@ -0,0 +1,110 @@ +#ifndef __LINUX_BIO_H +#define __LINUX_BIO_H + +#include + +struct bio_vec { + struct page *bv_page; + unsigned int bv_len; + unsigned int bv_offset; +}; + +struct bio_set; +struct bio; +typedef int (bio_end_io_t) (struct bio *, unsigned int, int); +typedef void (bio_destructor_t) (struct bio *); + +struct bio { + sector_t bi_sector; + + struct bio *bi_next; /* request queue link */ + struct block_device *bi_bdev; + unsigned long bi_flags; /* status, command, etc */ + unsigned long bi_rw; + + unsigned short bi_vcnt; + unsigned short bi_idx; + + /* Number of segments in this BIO after + * physical address coalescing is performed. + */ + unsigned short bi_phys_segments; + + unsigned int bi_size; + struct bio_vec *bi_io_vec; + + bio_end_io_t *bi_end_io; + + void *bi_private; +}; + +/* + * bio flags + */ +#define BIO_UPTODATE 0 /* ok after I/O completion */ +#define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ +#define BIO_EOF 2 /* out-out-bounds error */ +#define BIO_SEG_VALID 3 /* nr_hw_seg valid */ +#define BIO_CLONED 4 /* doesn't own data */ +#define BIO_BOUNCED 5 /* bio is a bounce bio */ +#define BIO_USER_MAPPED 6 /* contains user pages */ +#define BIO_EOPNOTSUPP 7 /* not supported */ +#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) + +/* + * top 4 bits of bio flags indicate the pool this bio came from + */ +#define BIO_POOL_BITS (4) +#define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) +#define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) +#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) + +/* + * bio bi_rw flags + * + * bit 0 -- read (not set) or write (set) + * bit 1 -- rw-ahead when set + * bit 2 -- barrier + * bit 3 -- fail fast, don't want low level driver retries + * bit 4 -- synchronous I/O hint: the block layer will unplug immediately + */ +#define BIO_RW 0 +#define BIO_RW_AHEAD 1 +#define BIO_RW_BARRIER 2 +#define BIO_RW_FAILFAST 3 +#define BIO_RW_SYNC 4 + + +#define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)])) +#define bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_idx) +#define bio_page(bio) bio_iovec((bio))->bv_page +#define bio_offset(bio) bio_iovec((bio))->bv_offset +#define bio_sectors(bio) ((bio)->bi_size >> 9) +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +#define bio_data(bio) (page_address(bio_page((bio))) + bio_offset((bio))) +#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER)) +#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC)) +#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) +#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) +#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) + +/* + * drivers should not use the __ version unless they _really_ want to + * run through the entire bio and not just pending pieces + */ +#define __bio_for_each_segment(bvl, bio, i, start_idx) \ + for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ + i < (bio)->bi_vcnt; \ + bvl++, i++) + +#define bio_for_each_segment(bvl, bio, i) \ + __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx) + +void * __bio_kmap_atomic(struct bio *, int, enum km_type); +void __bio_kunmap_atomic(char *buffer, enum km_type); + +void bio_endio(struct bio *, unsigned int, int); +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +int bio_cur_sectors(struct bio *); + +#endif /* __LINUX_BIO_H */ diff --git a/ddverify/models/con2/include/linux/bitops.h b/ddverify/models/con2/include/linux/bitops.h new file mode 100644 index 000000000..3e24f9c39 --- /dev/null +++ b/ddverify/models/con2/include/linux/bitops.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_BITOPS_H +#define _LINUX_BITOPS_H + +#include + +#endif diff --git a/ddverify/models/con2/include/linux/blkdev.h b/ddverify/models/con2/include/linux/blkdev.h new file mode 100644 index 000000000..d31cd7561 --- /dev/null +++ b/ddverify/models/con2/include/linux/blkdev.h @@ -0,0 +1,239 @@ +#ifndef _LINUX_BLKDEV_H +#define _LINUX_BLKDEV_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include + +#include + +struct request_queue; +typedef struct request_queue request_queue_t; + +typedef void (request_fn_proc) (request_queue_t *q); +typedef int (make_request_fn) (request_queue_t *q, struct bio *bio); +typedef void (unplug_fn) (request_queue_t *); + +/* + * request command types + */ +enum rq_cmd_type_bits { + REQ_TYPE_FS = 1, /* fs request */ + REQ_TYPE_BLOCK_PC, /* scsi command */ + REQ_TYPE_SENSE, /* sense request */ + REQ_TYPE_PM_SUSPEND, /* suspend request */ + REQ_TYPE_PM_RESUME, /* resume request */ + REQ_TYPE_PM_SHUTDOWN, /* shutdown request */ + REQ_TYPE_FLUSH, /* flush request */ + REQ_TYPE_SPECIAL, /* driver defined type */ + REQ_TYPE_LINUX_BLOCK, /* generic block layer message */ + /* + * for ATA/ATAPI devices. this really doesn't belong here, ide should + * use REQ_TYPE_SPECIAL and use rq->cmd[0] with the range of driver + * private REQ_LB opcodes to differentiate what type of request this is + */ + REQ_TYPE_ATA_CMD, + REQ_TYPE_ATA_TASK, + REQ_TYPE_ATA_TASKFILE, + REQ_TYPE_ATA_PC, +}; + + +struct request_queue { + request_fn_proc *request_fn; + make_request_fn *make_request_fn; + unplug_fn *unplug_fn; + + struct backing_dev_info backing_dev_info; + void *queuedata; + + /* + * various queue flags, see QUEUE_* below + */ + unsigned long queue_flags; + + spinlock_t *queue_lock; + + unsigned short hardsect_size; + + int __ddv_genhd_no; + int __ddv_queue_alive; +}; + +#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ +#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ +#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */ +#define QUEUE_FLAG_READFULL 3 /* write queue has been filled */ +#define QUEUE_FLAG_WRITEFULL 4 /* read queue has been filled */ +#define QUEUE_FLAG_DEAD 5 /* queue being torn down */ +#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ +#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ +#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ + + + +#define BLK_MAX_CDB 16 + + +struct request { + struct list_head queuelist; + struct list_head donelist; + + request_queue_t *q; + + + unsigned long flags; /* see REQ_ bits below */ + + unsigned int cmd_flags; + enum rq_cmd_type_bits cmd_type; + + struct bio *bio; + + void *completion_data; + + struct gendisk *rq_disk; + sector_t sector; + unsigned long nr_sectors; /* no. of sectors left to submit */ + unsigned int current_nr_sectors; + char *buffer; + + int errors; + + unsigned short nr_phys_segments; + + unsigned char cmd[BLK_MAX_CDB]; +}; + + + +/* + * first three bits match BIO_RW* bits, important + */ +enum rq_flag_bits { + __REQ_RW, /* not set, read. set, write */ + __REQ_FAILFAST, /* no low level driver retries */ + __REQ_SORTED, /* elevator knows about this request */ + __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ + __REQ_HARDBARRIER, /* may not be passed by drive either */ + __REQ_FUA, /* forced unit access */ + __REQ_CMD, /* is a regular fs rw request */ + __REQ_NOMERGE, /* don't touch this for merging */ + __REQ_STARTED, /* drive already may have started this one */ + __REQ_DONTPREP, /* don't call prep for this one */ + __REQ_QUEUED, /* uses queueing */ + __REQ_ELVPRIV, /* elevator private data attached */ + /* + * for ATA/ATAPI devices + */ + __REQ_PC, /* packet command (special) */ + __REQ_BLOCK_PC, /* queued down pc from block layer */ + __REQ_SENSE, /* sense retrival */ + + __REQ_FAILED, /* set if the request failed */ + __REQ_QUIET, /* don't worry about errors */ + __REQ_SPECIAL, /* driver suplied command */ + __REQ_DRIVE_CMD, + __REQ_DRIVE_TASK, + __REQ_DRIVE_TASKFILE, + __REQ_PREEMPT, /* set for "ide_preempt" requests */ + __REQ_PM_SUSPEND, /* suspend request */ + __REQ_PM_RESUME, /* resume request */ + __REQ_PM_SHUTDOWN, /* shutdown request */ + __REQ_ORDERED_COLOR, /* is before or after barrier */ + __REQ_NR_BITS, /* stops here */ +}; + +#define REQ_RW (1 << __REQ_RW) +#define REQ_FAILFAST (1 << __REQ_FAILFAST) +#define REQ_SORTED (1 << __REQ_SORTED) +#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) +#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) +#define REQ_FUA (1 << __REQ_FUA) +#define REQ_CMD (1 << __REQ_CMD) +#define REQ_NOMERGE (1 << __REQ_NOMERGE) +#define REQ_STARTED (1 << __REQ_STARTED) +#define REQ_DONTPREP (1 << __REQ_DONTPREP) +#define REQ_QUEUED (1 << __REQ_QUEUED) +#define REQ_ELVPRIV (1 << __REQ_ELVPRIV) +#define REQ_PC (1 << __REQ_PC) +#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC) +#define REQ_SENSE (1 << __REQ_SENSE) +#define REQ_FAILED (1 << __REQ_FAILED) +#define REQ_QUIET (1 << __REQ_QUIET) +#define REQ_SPECIAL (1 << __REQ_SPECIAL) +#define REQ_DRIVE_CMD (1 << __REQ_DRIVE_CMD) +#define REQ_DRIVE_TASK (1 << __REQ_DRIVE_TASK) +#define REQ_DRIVE_TASKFILE (1 << __REQ_DRIVE_TASKFILE) +#define REQ_PREEMPT (1 << __REQ_PREEMPT) +#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) +#define REQ_PM_RESUME (1 << __REQ_PM_RESUME) +#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) +#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) + + +#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) +#define rq_data_dir(rq) ((rq)->cmd_flags & 1) + +#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) + +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_alloc_queue(gfp_t); +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_make_request(request_queue_t *, make_request_fn *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_hardsect_size(request_queue_t *, unsigned short); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_cleanup_queue(request_queue_t *); +// DDV: TODO +void blk_put_queue(request_queue_t *); + + +// DDV: TODO +void blk_plug_device(request_queue_t *); +// DDV: TODO +int blk_remove_plug(request_queue_t *); + +// DDV: TODO +void blkdev_dequeue_request(struct request *req); + +// DDV: TODO +int end_that_request_first(struct request *, int, int); +// DDV: TODO +int end_that_request_chunk(struct request *, int, int); +// DDV: TODO +void end_that_request_last(struct request *, int); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void end_request(struct request *req, int uptodate); +// DDV: TODO +void blk_complete_request(struct request *); + +// DDV: TODO +void blk_queue_bounce_limit(request_queue_t *, u64); + +// DDV: TODO +void blk_queue_max_phys_segments(request_queue_t *, unsigned short); +// DDV: TODO +void blk_queue_max_hw_segments(request_queue_t *, unsigned short); + +// DDV: TODO +int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); + +#define rq_for_each_bio(_bio, rq) \ + if ((rq->bio)) \ + for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next) + +#endif diff --git a/ddverify/models/con2/include/linux/blkpg.h b/ddverify/models/con2/include/linux/blkpg.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/blktrace_api.h b/ddverify/models/con2/include/linux/blktrace_api.h new file mode 100644 index 000000000..4a4b02e12 --- /dev/null +++ b/ddverify/models/con2/include/linux/blktrace_api.h @@ -0,0 +1,141 @@ +#ifndef BLKTRACE_H +#define BLKTRACE_H + +#include +//#include + +/* + * Trace categories + */ +enum blktrace_cat { + BLK_TC_READ = 1 << 0, /* reads */ + BLK_TC_WRITE = 1 << 1, /* writes */ + BLK_TC_BARRIER = 1 << 2, /* barrier */ + BLK_TC_SYNC = 1 << 3, /* sync IO */ + BLK_TC_QUEUE = 1 << 4, /* queueing/merging */ + BLK_TC_REQUEUE = 1 << 5, /* requeueing */ + BLK_TC_ISSUE = 1 << 6, /* issue */ + BLK_TC_COMPLETE = 1 << 7, /* completions */ + BLK_TC_FS = 1 << 8, /* fs requests */ + BLK_TC_PC = 1 << 9, /* pc requests */ + BLK_TC_NOTIFY = 1 << 10, /* special message */ + BLK_TC_AHEAD = 1 << 11, /* readahead */ + BLK_TC_META = 1 << 12, /* metadata */ + + BLK_TC_END = 1 << 15, /* only 16-bits, reminder */ +}; + +#define BLK_TC_SHIFT (16) +#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT) + +/* + * Basic trace actions + */ +enum blktrace_act { + __BLK_TA_QUEUE = 1, /* queued */ + __BLK_TA_BACKMERGE, /* back merged to existing rq */ + __BLK_TA_FRONTMERGE, /* front merge to existing rq */ + __BLK_TA_GETRQ, /* allocated new request */ + __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */ + __BLK_TA_REQUEUE, /* request requeued */ + __BLK_TA_ISSUE, /* sent to driver */ + __BLK_TA_COMPLETE, /* completed by driver */ + __BLK_TA_PLUG, /* queue was plugged */ + __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */ + __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */ + __BLK_TA_INSERT, /* insert request */ + __BLK_TA_SPLIT, /* bio was split */ + __BLK_TA_BOUNCE, /* bio was bounced */ + __BLK_TA_REMAP, /* bio was remapped */ +}; + +/* + * Trace actions in full. Additionally, read or write is masked + */ +#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE)) +#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE)) +#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE)) +#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SPLIT (__BLK_TA_SPLIT) +#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) +#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) + +#define BLK_IO_TRACE_MAGIC 0x65617400 +#define BLK_IO_TRACE_VERSION 0x07 + +/* + * The trace itself + */ +struct blk_io_trace { + u32 magic; /* MAGIC << 8 | version */ + u32 sequence; /* event number */ + u64 time; /* in microseconds */ + u64 sector; /* disk offset */ + u32 bytes; /* transfer length */ + u32 action; /* what happened */ + u32 pid; /* who did it */ + u32 device; /* device number */ + u32 cpu; /* on what cpu did it happen */ + u16 error; /* completion error */ + u16 pdu_len; /* length of data after this trace */ +}; + +/* + * The remap event + */ +struct blk_io_trace_remap { + __be32 device; + u32 __pad; + __be64 sector; +}; + +enum { + Blktrace_setup = 1, + Blktrace_running, + Blktrace_stopped, +}; + +struct blk_trace { + int trace_state; + struct rchan *rchan; + unsigned long *sequence; + u16 act_mask; + u64 start_lba; + u64 end_lba; + u32 pid; + u32 dev; + struct dentry *dir; + struct dentry *dropped_file; + atomic_t dropped; +}; + +/* + * User setup structure passed with BLKTRACESTART + */ +struct blk_user_trace_setup { + char name[BDEVNAME_SIZE]; /* output */ + u16 act_mask; /* input */ + u32 buf_size; /* input */ + u32 buf_nr; /* input */ + u64 start_lba; + u64 end_lba; + u32 pid; +}; + +#define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) +#define blk_trace_shutdown(q) do { } while (0) +#define blk_add_trace_rq(q, rq, what) do { } while (0) +#define blk_add_trace_bio(q, rq, what) do { } while (0) +#define blk_add_trace_generic(q, rq, rw, what) do { } while (0) +#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0) +#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0) + +#endif diff --git a/ddverify/models/con2/include/linux/buffer_head.h b/ddverify/models/con2/include/linux/buffer_head.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/byteorder/generic.h b/ddverify/models/con2/include/linux/byteorder/generic.h new file mode 100644 index 000000000..4dd8f5fb9 --- /dev/null +++ b/ddverify/models/con2/include/linux/byteorder/generic.h @@ -0,0 +1,46 @@ +#ifndef _LINUX_BYTEORDER_GENERIC_H +#define _LINUX_BYTEORDER_GENERIC_H + +#define cpu_to_le64 __cpu_to_le64 +#define le64_to_cpu __le64_to_cpu +#define cpu_to_le32 __cpu_to_le32 +#define le32_to_cpu __le32_to_cpu +#define cpu_to_le16 __cpu_to_le16 +#define le16_to_cpu __le16_to_cpu +#define cpu_to_be64 __cpu_to_be64 +#define be64_to_cpu __be64_to_cpu +#define cpu_to_be32 __cpu_to_be32 +#define be32_to_cpu __be32_to_cpu +#define cpu_to_be16 __cpu_to_be16 +#define be16_to_cpu __be16_to_cpu +#define cpu_to_le64p __cpu_to_le64p +#define le64_to_cpup __le64_to_cpup +#define cpu_to_le32p __cpu_to_le32p +#define le32_to_cpup __le32_to_cpup +#define cpu_to_le16p __cpu_to_le16p +#define le16_to_cpup __le16_to_cpup +#define cpu_to_be64p __cpu_to_be64p +#define be64_to_cpup __be64_to_cpup +#define cpu_to_be32p __cpu_to_be32p +#define be32_to_cpup __be32_to_cpup +#define cpu_to_be16p __cpu_to_be16p +#define be16_to_cpup __be16_to_cpup +#define cpu_to_le64s __cpu_to_le64s +#define le64_to_cpus __le64_to_cpus +#define cpu_to_le32s __cpu_to_le32s +#define le32_to_cpus __le32_to_cpus +#define cpu_to_le16s __cpu_to_le16s +#define le16_to_cpus __le16_to_cpus +#define cpu_to_be64s __cpu_to_be64s +#define be64_to_cpus __be64_to_cpus +#define cpu_to_be32s __cpu_to_be32s +#define be32_to_cpus __be32_to_cpus +#define cpu_to_be16s __cpu_to_be16s +#define be16_to_cpus __be16_to_cpus + +#define htonl(x) x +#define ntohl(x) x +#define htons(x) x +#define ntohs(x) x + +#endif /* _LINUX_BYTEORDER_GENERIC_H */ diff --git a/ddverify/models/con2/include/linux/byteorder/little_endian.h b/ddverify/models/con2/include/linux/byteorder/little_endian.h new file mode 100644 index 000000000..9925e2e4e --- /dev/null +++ b/ddverify/models/con2/include/linux/byteorder/little_endian.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H +#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H + +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN 1234 +#endif +#ifndef __LITTLE_ENDIAN_BITFIELD +#define __LITTLE_ENDIAN_BITFIELD +#endif + +#include +//#include + + +#define __cpu_to_le64(x) x +#define __le64_to_cpu(x) x +#define __cpu_to_le32(x) x +#define __le32_to_cpu(x) x +#define __cpu_to_le16(x) x +#define __le16_to_cpu(x) x +#define __cpu_to_be64(x) x +#define __be64_to_cpu(x) x +#define __cpu_to_be32(x) x +#define __be32_to_cpu(x) x +#define __cpu_to_be16(x) x +#define __be16_to_cpu(x) x + +#include + +#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ diff --git a/ddverify/models/con2/include/linux/cache.h b/ddverify/models/con2/include/linux/cache.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/capability.h b/ddverify/models/con2/include/linux/capability.h new file mode 100644 index 000000000..2d039b6e8 --- /dev/null +++ b/ddverify/models/con2/include/linux/capability.h @@ -0,0 +1,244 @@ +/* + * This is + * + * Andrew G. Morgan + * Alexander Kjeldaas + * with help from Aleph1, Roland Buresund and Andrew Main. + * + * See here for the libcap library ("POSIX draft" compliance): + * + * ftp://linux.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.2/ + */ + +#ifndef _LINUX_CAPABILITY_H +#define _LINUX_CAPABILITY_H + +#include +#include + +/** + ** POSIX-draft defined capabilities. + **/ + +/* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this + overrides the restriction of changing file ownership and group + ownership. */ + +#define CAP_CHOWN 0 + +/* Override all DAC access, including ACL execute access if + [_POSIX_ACL] is defined. Excluding DAC access covered by + CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_OVERRIDE 1 + +/* Overrides all DAC restrictions regarding read and search on files + and directories, including ACL restrictions if [_POSIX_ACL] is + defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_READ_SEARCH 2 + +/* Overrides all restrictions about allowed operations on files, where + file owner ID must be equal to the user ID, except where CAP_FSETID + is applicable. It doesn't override MAC and DAC restrictions. */ + +#define CAP_FOWNER 3 + +/* Overrides the following restrictions that the effective user ID + shall match the file owner ID when setting the S_ISUID and S_ISGID + bits on that file; that the effective group ID (or one of the + supplementary group IDs) shall match the file owner ID when setting + the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are + cleared on successful return from chown(2) (not implemented). */ + +#define CAP_FSETID 4 + +/* Used to decide between falling back on the old suser() or fsuser(). */ + +#define CAP_FS_MASK 0x1f + +/* Overrides the restriction that the real or effective user ID of a + process sending a signal must match the real or effective user ID + of the process receiving the signal. */ + +#define CAP_KILL 5 + +/* Allows setgid(2) manipulation */ +/* Allows setgroups(2) */ +/* Allows forged gids on socket credentials passing. */ + +#define CAP_SETGID 6 + +/* Allows set*uid(2) manipulation (including fsuid). */ +/* Allows forged pids on socket credentials passing. */ + +#define CAP_SETUID 7 + + +/** + ** Linux-specific capabilities + **/ + +/* Transfer any capability in your permitted set to any pid, + remove any capability in your permitted set from any pid */ + +#define CAP_SETPCAP 8 + +/* Allow modification of S_IMMUTABLE and S_APPEND file attributes */ + +#define CAP_LINUX_IMMUTABLE 9 + +/* Allows binding to TCP/UDP sockets below 1024 */ +/* Allows binding to ATM VCIs below 32 */ + +#define CAP_NET_BIND_SERVICE 10 + +/* Allow broadcasting, listen to multicast */ + +#define CAP_NET_BROADCAST 11 + +/* Allow interface configuration */ +/* Allow administration of IP firewall, masquerading and accounting */ +/* Allow setting debug option on sockets */ +/* Allow modification of routing tables */ +/* Allow setting arbitrary process / process group ownership on + sockets */ +/* Allow binding to any address for transparent proxying */ +/* Allow setting TOS (type of service) */ +/* Allow setting promiscuous mode */ +/* Allow clearing driver statistics */ +/* Allow multicasting */ +/* Allow read/write of device-specific registers */ +/* Allow activation of ATM control sockets */ + +#define CAP_NET_ADMIN 12 + +/* Allow use of RAW sockets */ +/* Allow use of PACKET sockets */ + +#define CAP_NET_RAW 13 + +/* Allow locking of shared memory segments */ +/* Allow mlock and mlockall (which doesn't really have anything to do + with IPC) */ + +#define CAP_IPC_LOCK 14 + +/* Override IPC ownership checks */ + +#define CAP_IPC_OWNER 15 + +/* Insert and remove kernel modules - modify kernel without limit */ +/* Modify cap_bset */ +#define CAP_SYS_MODULE 16 + +/* Allow ioperm/iopl access */ +/* Allow sending USB messages to any device via /proc/bus/usb */ + +#define CAP_SYS_RAWIO 17 + +/* Allow use of chroot() */ + +#define CAP_SYS_CHROOT 18 + +/* Allow ptrace() of any process */ + +#define CAP_SYS_PTRACE 19 + +/* Allow configuration of process accounting */ + +#define CAP_SYS_PACCT 20 + +/* Allow configuration of the secure attention key */ +/* Allow administration of the random device */ +/* Allow examination and configuration of disk quotas */ +/* Allow configuring the kernel's syslog (printk behaviour) */ +/* Allow setting the domainname */ +/* Allow setting the hostname */ +/* Allow calling bdflush() */ +/* Allow mount() and umount(), setting up new smb connection */ +/* Allow some autofs root ioctls */ +/* Allow nfsservctl */ +/* Allow VM86_REQUEST_IRQ */ +/* Allow to read/write pci config on alpha */ +/* Allow irix_prctl on mips (setstacksize) */ +/* Allow flushing all cache on m68k (sys_cacheflush) */ +/* Allow removing semaphores */ +/* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores + and shared memory */ +/* Allow locking/unlocking of shared memory segment */ +/* Allow turning swap on/off */ +/* Allow forged pids on socket credentials passing */ +/* Allow setting readahead and flushing buffers on block devices */ +/* Allow setting geometry in floppy driver */ +/* Allow turning DMA on/off in xd driver */ +/* Allow administration of md devices (mostly the above, but some + extra ioctls) */ +/* Allow tuning the ide driver */ +/* Allow access to the nvram device */ +/* Allow administration of apm_bios, serial and bttv (TV) device */ +/* Allow manufacturer commands in isdn CAPI support driver */ +/* Allow reading non-standardized portions of pci configuration space */ +/* Allow DDI debug ioctl on sbpcd driver */ +/* Allow setting up serial ports */ +/* Allow sending raw qic-117 commands */ +/* Allow enabling/disabling tagged queuing on SCSI controllers and sending + arbitrary SCSI commands */ +/* Allow setting encryption key on loopback filesystem */ +/* Allow setting zone reclaim policy */ + +#define CAP_SYS_ADMIN 21 + +/* Allow use of reboot() */ + +#define CAP_SYS_BOOT 22 + +/* Allow raising priority and setting priority on other (different + UID) processes */ +/* Allow use of FIFO and round-robin (realtime) scheduling on own + processes and setting the scheduling algorithm used by another + process. */ +/* Allow setting cpu affinity on other processes */ + +#define CAP_SYS_NICE 23 + +/* Override resource limits. Set resource limits. */ +/* Override quota limits. */ +/* Override reserved space on ext2 filesystem */ +/* Modify data journaling mode on ext3 filesystem (uses journaling + resources) */ +/* NOTE: ext2 honors fsuid when checking for resource overrides, so + you can override using fsuid too */ +/* Override size restrictions on IPC message queues */ +/* Allow more than 64hz interrupts from the real-time clock */ +/* Override max number of consoles on console allocation */ +/* Override max number of keymaps */ + +#define CAP_SYS_RESOURCE 24 + +/* Allow manipulation of system clock */ +/* Allow irix_stime on mips */ +/* Allow setting the real-time clock */ + +#define CAP_SYS_TIME 25 + +/* Allow configuration of tty devices */ +/* Allow vhangup() of tty */ + +#define CAP_SYS_TTY_CONFIG 26 + +/* Allow the privileged aspects of mknod() */ + +#define CAP_MKNOD 27 + +/* Allow taking of leases on files */ + +#define CAP_LEASE 28 + +#define CAP_AUDIT_WRITE 29 + +#define CAP_AUDIT_CONTROL 30 + +int capable(int cap); + +#endif /* !_LINUX_CAPABILITY_H */ diff --git a/ddverify/models/con2/include/linux/cdev.h b/ddverify/models/con2/include/linux/cdev.h new file mode 100644 index 000000000..92608a6ff --- /dev/null +++ b/ddverify/models/con2/include/linux/cdev.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_CDEV_H +#define _LINUX_CDEV_H + +struct cdev { + struct module *owner; + struct file_operations *ops; + dev_t dev; + unsigned int count; +}; + +void cdev_init(struct cdev *, struct file_operations *); + +struct cdev *cdev_alloc(void); + +void cdev_put(struct cdev *p); + +int cdev_add(struct cdev *, dev_t, unsigned); + +void cdev_del(struct cdev *); + +void cd_forget(struct inode *); + +#endif diff --git a/ddverify/models/con2/include/linux/cdrom.h b/ddverify/models/con2/include/linux/cdrom.h new file mode 100644 index 000000000..b68fdf1f3 --- /dev/null +++ b/ddverify/models/con2/include/linux/cdrom.h @@ -0,0 +1,1192 @@ +/* + * -- + * General header file for linux CD-ROM drivers + * Copyright (C) 1992 David Giller, rafetmad@oxy.edu + * 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de + * 1996 David van Leeuwen, david@tm.tno.nl + * 1997, 1998 Erik Andersen, andersee@debian.org + * 1998-2002 Jens Axboe, axboe@suse.de + */ + +#ifndef _LINUX_CDROM_H +#define _LINUX_CDROM_H + +#include + +/******************************************************* + * As of Linux 2.1.x, all Linux CD-ROM application programs will use this + * (and only this) include file. It is my hope to provide Linux with + * a uniform interface between software accessing CD-ROMs and the various + * device drivers that actually talk to the drives. There may still be + * 23 different kinds of strange CD-ROM drives, but at least there will + * now be one, and only one, Linux CD-ROM interface. + * + * Additionally, as of Linux 2.1.x, all Linux application programs + * should use the O_NONBLOCK option when opening a CD-ROM device + * for subsequent ioctl commands. This allows for neat system errors + * like "No medium found" or "Wrong medium type" upon attempting to + * mount or play an empty slot, mount an audio disc, or play a data disc. + * Generally, changing an application program to support O_NONBLOCK + * is as easy as the following: + * - drive = open("/dev/cdrom", O_RDONLY); + * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); + * It is worth the small change. + * + * Patches for many common CD programs (provided by David A. van Leeuwen) + * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/ + * + *******************************************************/ + +/* When a driver supports a certain function, but the cdrom drive we are + * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will + * borrow the "Operation not supported" error from the network folks to + * accomplish this. Maybe someday we will get a more targeted error code, + * but this will do for now... */ +#define EDRIVE_CANT_DO_THIS EOPNOTSUPP + +/******************************************************* + * The CD-ROM IOCTL commands -- these should be supported by + * all the various cdrom drivers. For the CD-ROM ioctls, we + * will commandeer byte 0x53, or 'S'. + *******************************************************/ +#define CDROMPAUSE 0x5301 /* Pause Audio Operation */ +#define CDROMRESUME 0x5302 /* Resume paused Audio Operation */ +#define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ +#define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index + (struct cdrom_ti) */ +#define CDROMREADTOCHDR 0x5305 /* Read TOC header + (struct cdrom_tochdr) */ +#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry + (struct cdrom_tocentry) */ +#define CDROMSTOP 0x5307 /* Stop the cdrom drive */ +#define CDROMSTART 0x5308 /* Start the cdrom drive */ +#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ +#define CDROMVOLCTRL 0x530a /* Control output volume + (struct cdrom_volctrl) */ +#define CDROMSUBCHNL 0x530b /* Read subchannel data + (struct cdrom_subchnl) */ +#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) + (struct cdrom_read) */ +#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) + (struct cdrom_read) */ +#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ +#define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ +#define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session + address of multi session disks + (struct cdrom_multisession) */ +#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" + if available (struct cdrom_mcn) */ +#define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated, + but here anyway for compatibility */ +#define CDROMRESET 0x5312 /* hard-reset the drive */ +#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting + (struct cdrom_volctrl) */ +#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) + (struct cdrom_read) */ +/* + * These ioctls are used only used in aztcd.c and optcd.c + */ +#define CDROMREADCOOKED 0x5315 /* read data in cooked mode */ +#define CDROMSEEK 0x5316 /* seek msf address */ + +/* + * This ioctl is only used by the scsi-cd driver. + It is for playing audio in logical block addressing mode. + */ +#define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ + +/* + * These ioctls are only used in optcd.c + */ +#define CDROMREADALL 0x5318 /* read all 2646 bytes */ + +/* + * These ioctls are (now) only in ide-cd.c for controlling + * drive spindown time. They should be implemented in the + * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, + * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... + * -Erik + */ +#define CDROMGETSPINDOWN 0x531d +#define CDROMSETSPINDOWN 0x531e + +/* + * These ioctls are implemented through the uniform CD-ROM driver + * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM + * drivers are eventually ported to the uniform CD-ROM driver interface. + */ +#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ +#define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */ +#define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */ +#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ +#define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */ +#define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */ +#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ +#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ +#define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */ +#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */ +#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */ +#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ + +/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386. + * Future CDROM ioctls should be kept below 0x537F + */ + +/* This ioctl is only used by sbpcd at the moment */ +#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ + /* conflict with SCSI_IOCTL_GET_IDLUN */ + +/* DVD-ROM Specific ioctls */ +#define DVD_READ_STRUCT 0x5390 /* Read structure */ +#define DVD_WRITE_STRUCT 0x5391 /* Write structure */ +#define DVD_AUTH 0x5392 /* Authentication */ + +#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */ +#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */ +#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */ + +/******************************************************* + * CDROM IOCTL structures + *******************************************************/ + +/* Address in MSF format */ +struct cdrom_msf0 +{ + __u8 minute; + __u8 second; + __u8 frame; +}; + +/* Address in either MSF or logical format */ +union cdrom_addr +{ + struct cdrom_msf0 msf; + int lba; +}; + +/* This struct is used by the CDROMPLAYMSF ioctl */ +struct cdrom_msf +{ + __u8 cdmsf_min0; /* start minute */ + __u8 cdmsf_sec0; /* start second */ + __u8 cdmsf_frame0; /* start frame */ + __u8 cdmsf_min1; /* end minute */ + __u8 cdmsf_sec1; /* end second */ + __u8 cdmsf_frame1; /* end frame */ +}; + +/* This struct is used by the CDROMPLAYTRKIND ioctl */ +struct cdrom_ti +{ + __u8 cdti_trk0; /* start track */ + __u8 cdti_ind0; /* start index */ + __u8 cdti_trk1; /* end track */ + __u8 cdti_ind1; /* end index */ +}; + +/* This struct is used by the CDROMREADTOCHDR ioctl */ +struct cdrom_tochdr +{ + __u8 cdth_trk0; /* start track */ + __u8 cdth_trk1; /* end track */ +}; + +/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */ +struct cdrom_volctrl +{ + __u8 channel0; + __u8 channel1; + __u8 channel2; + __u8 channel3; +}; + +/* This struct is used by the CDROMSUBCHNL ioctl */ +struct cdrom_subchnl +{ + __u8 cdsc_format; + __u8 cdsc_audiostatus; + __u8 cdsc_adr: 4; + __u8 cdsc_ctrl: 4; + __u8 cdsc_trk; + __u8 cdsc_ind; + union cdrom_addr cdsc_absaddr; + union cdrom_addr cdsc_reladdr; +}; + + +/* This struct is used by the CDROMREADTOCENTRY ioctl */ +struct cdrom_tocentry +{ + __u8 cdte_track; + __u8 cdte_adr :4; + __u8 cdte_ctrl :4; + __u8 cdte_format; + union cdrom_addr cdte_addr; + __u8 cdte_datamode; +}; + +/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */ +struct cdrom_read +{ + int cdread_lba; + char *cdread_bufaddr; + int cdread_buflen; +}; + +/* This struct is used by the CDROMREADAUDIO ioctl */ +struct cdrom_read_audio +{ + union cdrom_addr addr; /* frame address */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ + int nframes; /* number of 2352-byte-frames to read at once */ + __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */ +}; + +/* This struct is used with the CDROMMULTISESSION ioctl */ +struct cdrom_multisession +{ + union cdrom_addr addr; /* frame address: start-of-last-session + (not the new "frame 16"!). Only valid + if the "xa_flag" is true. */ + __u8 xa_flag; /* 1: "is XA disk" */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ +}; + +/* This struct is used with the CDROM_GET_MCN ioctl. + * Very few audio discs actually have Universal Product Code information, + * which should just be the Medium Catalog Number on the box. Also note + * that the way the codeis written on CD is _not_ uniform across all discs! + */ +struct cdrom_mcn +{ + __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */ +}; + +/* This is used by the CDROMPLAYBLK ioctl */ +struct cdrom_blk +{ + unsigned from; + unsigned short len; +}; + +#define CDROM_PACKET_SIZE 12 + +#define CGC_DATA_UNKNOWN 0 +#define CGC_DATA_WRITE 1 +#define CGC_DATA_READ 2 +#define CGC_DATA_NONE 3 + +/* for CDROM_PACKET_COMMAND ioctl */ +struct cdrom_generic_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char __user *buffer; + unsigned int buflen; + int stat; + struct request_sense __user *sense; + unsigned char data_direction; + int quiet; + int timeout; + void __user *reserved[1]; /* unused, actually */ +}; + +/* + * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, + * 2340, or 2352 bytes long. + +* Sector types of the standard CD-ROM data formats: + * + * format sector type user data size (bytes) + * ----------------------------------------------------------------------------- + * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW) + * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE) + * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0) + * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE) + * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes) + * + * + * The layout of the standard CD-ROM data formats: + * ----------------------------------------------------------------------------- + * - audio (red): | audio_sample_bytes | + * | 2352 | + * + * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC | + * | 12 - 4 - 2048 - 4 - 8 - 276 | + * + * - data (yellow, mode2): | sync - head - data | + * | 12 - 4 - 2336 | + * + * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC | + * | 12 - 4 - 8 - 2048 - 4 - 276 | + * + * - XA data (green, mode2 form2): | sync - head - sub - data - Spare | + * | 12 - 4 - 8 - 2324 - 4 | + * + */ + +/* Some generally useful CD-ROM information -- mostly based on the above */ +#define CD_MINS 74 /* max. minutes per CD, not really a limit */ +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ +#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ +#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ +#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ +#define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */ +#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ +#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */ +#define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */ +#define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */ +#define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */ +#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ +#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ +/* most drives don't deliver everything: */ +#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ +#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ + +#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */ +#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */ +#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */ + +/* CD-ROM address types (cdrom_tocentry.cdte_format) */ +#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ +#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ + +/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ +#define CDROM_DATA_TRACK 0x04 + +/* The leadout track is always 0xAA, regardless of # of tracks on disc */ +#define CDROM_LEADOUT 0xAA + +/* audio states (from SCSI-2, but seen with other drives, too) */ +#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ +#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ +#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ +#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ +#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ +#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ + +/* capability flags used with the uniform CD-ROM driver */ +#define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */ +#define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */ +#define CDC_LOCK 0x4 /* disable manual eject */ +#define CDC_SELECT_SPEED 0x8 /* programmable speed */ +#define CDC_SELECT_DISC 0x10 /* select disc from juke-box */ +#define CDC_MULTI_SESSION 0x20 /* read sessions>1 */ +#define CDC_MCN 0x40 /* Medium Catalog Number */ +#define CDC_MEDIA_CHANGED 0x80 /* media changed */ +#define CDC_PLAY_AUDIO 0x100 /* audio functions */ +#define CDC_RESET 0x200 /* hard reset device */ +#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */ +#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ +#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ +#define CDC_CD_R 0x2000 /* drive is a CD-R */ +#define CDC_CD_RW 0x4000 /* drive is a CD-RW */ +#define CDC_DVD 0x8000 /* drive is a DVD */ +#define CDC_DVD_R 0x10000 /* drive can write DVD-R */ +#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */ +#define CDC_MO_DRIVE 0x40000 /* drive is an MO device */ +#define CDC_MRW 0x80000 /* drive can read MRW */ +#define CDC_MRW_W 0x100000 /* drive can write MRW */ +#define CDC_RAM 0x200000 /* ok to open for WRITE */ + +/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ +#define CDS_NO_INFO 0 /* if not implemented */ +#define CDS_NO_DISC 1 +#define CDS_TRAY_OPEN 2 +#define CDS_DRIVE_NOT_READY 3 +#define CDS_DISC_OK 4 + +/* return values for the CDROM_DISC_STATUS ioctl */ +/* can also return CDS_NO_[INFO|DISC], from above */ +#define CDS_AUDIO 100 +#define CDS_DATA_1 101 +#define CDS_DATA_2 102 +#define CDS_XA_2_1 103 +#define CDS_XA_2_2 104 +#define CDS_MIXED 105 + +/* User-configurable behavior options for the uniform CD-ROM driver */ +#define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */ +#define CDO_AUTO_EJECT 0x2 /* open tray on last release() */ +#define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */ +#define CDO_LOCK 0x8 /* lock tray on open files */ +#define CDO_CHECK_TYPE 0x10 /* check type on open for data */ + +/* Special codes used when specifying changer slots. */ +#define CDSL_NONE ((int) (~0U>>1)-1) +#define CDSL_CURRENT ((int) (~0U>>1)) + +/* For partition based multisession access. IDE can handle 64 partitions + * per drive - SCSI CD-ROM's use minors to differentiate between the + * various drives, so we can't do multisessions the same way there. + * Use the -o session=x option to mount on them. + */ +#define CD_PART_MAX 64 +#define CD_PART_MASK (CD_PART_MAX - 1) + +/********************************************************************* + * Generic Packet commands, MMC commands, and such + *********************************************************************/ + + /* The generic packet command opcodes for CD/DVD Logical Units, + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +#define GPCMD_BLANK 0xa1 +#define GPCMD_CLOSE_TRACK 0x5b +#define GPCMD_FLUSH_CACHE 0x35 +#define GPCMD_FORMAT_UNIT 0x04 +#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a +#define GPCMD_GET_PERFORMANCE 0xac +#define GPCMD_INQUIRY 0x12 +#define GPCMD_LOAD_UNLOAD 0xa6 +#define GPCMD_MECHANISM_STATUS 0xbd +#define GPCMD_MODE_SELECT_10 0x55 +#define GPCMD_MODE_SENSE_10 0x5a +#define GPCMD_PAUSE_RESUME 0x4b +#define GPCMD_PLAY_AUDIO_10 0x45 +#define GPCMD_PLAY_AUDIO_MSF 0x47 +#define GPCMD_PLAY_AUDIO_TI 0x48 +#define GPCMD_PLAY_CD 0xbc +#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e +#define GPCMD_READ_10 0x28 +#define GPCMD_READ_12 0xa8 +#define GPCMD_READ_BUFFER_CAPACITY 0x5c +#define GPCMD_READ_CDVD_CAPACITY 0x25 +#define GPCMD_READ_CD 0xbe +#define GPCMD_READ_CD_MSF 0xb9 +#define GPCMD_READ_DISC_INFO 0x51 +#define GPCMD_READ_DVD_STRUCTURE 0xad +#define GPCMD_READ_FORMAT_CAPACITIES 0x23 +#define GPCMD_READ_HEADER 0x44 +#define GPCMD_READ_TRACK_RZONE_INFO 0x52 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_REPAIR_RZONE_TRACK 0x58 +#define GPCMD_REPORT_KEY 0xa4 +#define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_RESERVE_RZONE_TRACK 0x53 +#define GPCMD_SEND_CUE_SHEET 0x5d +#define GPCMD_SCAN 0xba +#define GPCMD_SEEK 0x2b +#define GPCMD_SEND_DVD_STRUCTURE 0xbf +#define GPCMD_SEND_EVENT 0xa2 +#define GPCMD_SEND_KEY 0xa3 +#define GPCMD_SEND_OPC 0x54 +#define GPCMD_SET_READ_AHEAD 0xa7 +#define GPCMD_SET_STREAMING 0xb6 +#define GPCMD_START_STOP_UNIT 0x1b +#define GPCMD_STOP_PLAY_SCAN 0x4e +#define GPCMD_TEST_UNIT_READY 0x00 +#define GPCMD_VERIFY_10 0x2f +#define GPCMD_WRITE_10 0x2a +#define GPCMD_WRITE_AND_VERIFY_10 0x2e +/* This is listed as optional in ATAPI 2.6, but is (curiously) + * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji + * Table 377 as an MMC command for SCSi devices though... Most ATAPI + * drives support it. */ +#define GPCMD_SET_SPEED 0xbb +/* This seems to be a SCSI specific CD-ROM opcode + * to play data at track/index */ +#define GPCMD_PLAYAUDIO_TI 0x48 +/* + * From MS Media Status Notification Support Specification. For + * older drives only. + */ +#define GPCMD_GET_MEDIA_STATUS 0xda + +/* Mode page codes for mode sense/set */ +#define GPMODE_VENDOR_PAGE 0x00 +#define GPMODE_R_W_ERROR_PAGE 0x01 +#define GPMODE_WRITE_PARMS_PAGE 0x05 +#define GPMODE_WCACHING_PAGE 0x08 +#define GPMODE_AUDIO_CTL_PAGE 0x0e +#define GPMODE_POWER_PAGE 0x1a +#define GPMODE_FAULT_FAIL_PAGE 0x1c +#define GPMODE_TO_PROTECT_PAGE 0x1d +#define GPMODE_CAPABILITIES_PAGE 0x2a +#define GPMODE_ALL_PAGES 0x3f +/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor + * of MODE_SENSE_POWER_PAGE */ +#define GPMODE_CDROM_PAGE 0x0d + + + +/* DVD struct types */ +#define DVD_STRUCT_PHYSICAL 0x00 +#define DVD_STRUCT_COPYRIGHT 0x01 +#define DVD_STRUCT_DISCKEY 0x02 +#define DVD_STRUCT_BCA 0x03 +#define DVD_STRUCT_MANUFACT 0x04 + +struct dvd_layer { + __u8 book_version : 4; + __u8 book_type : 4; + __u8 min_rate : 4; + __u8 disc_size : 4; + __u8 layer_type : 4; + __u8 track_path : 1; + __u8 nlayers : 2; + __u8 track_density : 4; + __u8 linear_density : 4; + __u8 bca : 1; + __u32 start_sector; + __u32 end_sector; + __u32 end_sector_l0; +}; + +#define DVD_LAYERS 4 + +struct dvd_physical { + __u8 type; + __u8 layer_num; + struct dvd_layer layer[DVD_LAYERS]; +}; + +struct dvd_copyright { + __u8 type; + + __u8 layer_num; + __u8 cpst; + __u8 rmi; +}; + +struct dvd_disckey { + __u8 type; + + unsigned agid : 2; + __u8 value[2048]; +}; + +struct dvd_bca { + __u8 type; + + int len; + __u8 value[188]; +}; + +struct dvd_manufact { + __u8 type; + + __u8 layer_num; + int len; + __u8 value[2048]; +}; + +typedef union { + __u8 type; + + struct dvd_physical physical; + struct dvd_copyright copyright; + struct dvd_disckey disckey; + struct dvd_bca bca; + struct dvd_manufact manufact; +} dvd_struct; + +/* + * DVD authentication ioctl + */ + +/* Authentication states */ +#define DVD_LU_SEND_AGID 0 +#define DVD_HOST_SEND_CHALLENGE 1 +#define DVD_LU_SEND_KEY1 2 +#define DVD_LU_SEND_CHALLENGE 3 +#define DVD_HOST_SEND_KEY2 4 + +/* Termination states */ +#define DVD_AUTH_ESTABLISHED 5 +#define DVD_AUTH_FAILURE 6 + +/* Other functions */ +#define DVD_LU_SEND_TITLE_KEY 7 +#define DVD_LU_SEND_ASF 8 +#define DVD_INVALIDATE_AGID 9 +#define DVD_LU_SEND_RPC_STATE 10 +#define DVD_HOST_SEND_RPC_STATE 11 + +/* State data */ +typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ +typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ + +struct dvd_lu_send_agid { + __u8 type; + unsigned agid : 2; +}; + +struct dvd_host_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +struct dvd_send_key { + __u8 type; + unsigned agid : 2; + + dvd_key key; +}; + +struct dvd_lu_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +#define DVD_CPM_NO_COPYRIGHT 0 +#define DVD_CPM_COPYRIGHTED 1 + +#define DVD_CP_SEC_NONE 0 +#define DVD_CP_SEC_EXIST 1 + +#define DVD_CGMS_UNRESTRICTED 0 +#define DVD_CGMS_SINGLE 2 +#define DVD_CGMS_RESTRICTED 3 + +struct dvd_lu_send_title_key { + __u8 type; + unsigned agid : 2; + + dvd_key title_key; + int lba; + unsigned cpm : 1; + unsigned cp_sec : 1; + unsigned cgms : 2; +}; + +struct dvd_lu_send_asf { + __u8 type; + unsigned agid : 2; + + unsigned asf : 1; +}; + +struct dvd_host_send_rpcstate { + __u8 type; + __u8 pdrc; +}; + +struct dvd_lu_send_rpcstate { + __u8 type : 2; + __u8 vra : 3; + __u8 ucca : 3; + __u8 region_mask; + __u8 rpc_scheme; +}; + +typedef union { + __u8 type; + + struct dvd_lu_send_agid lsa; + struct dvd_host_send_challenge hsc; + struct dvd_send_key lsk; + struct dvd_lu_send_challenge lsc; + struct dvd_send_key hsk; + struct dvd_lu_send_title_key lstk; + struct dvd_lu_send_asf lsasf; + struct dvd_host_send_rpcstate hrpcs; + struct dvd_lu_send_rpcstate lrpcs; +} dvd_authinfo; + +struct request_sense { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 valid : 1; + __u8 error_code : 7; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 error_code : 7; + __u8 valid : 1; +#endif + __u8 segment_number; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 ili : 1; + __u8 reserved2 : 1; + __u8 sense_key : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 sense_key : 4; + __u8 reserved2 : 1; + __u8 ili : 1; + __u8 reserved1 : 2; +#endif + __u8 information[4]; + __u8 add_sense_len; + __u8 command_info[4]; + __u8 asc; + __u8 ascq; + __u8 fruc; + __u8 sks[3]; + __u8 asb[46]; +}; + +/* + * feature profile + */ +#define CDF_RWRT 0x0020 /* "Random Writable" */ +#define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ +#define CDF_MRW 0x0028 + +/* + * media status bits + */ +#define CDM_MRW_NOTMRW 0 +#define CDM_MRW_BGFORMAT_INACTIVE 1 +#define CDM_MRW_BGFORMAT_ACTIVE 2 +#define CDM_MRW_BGFORMAT_COMPLETE 3 + +/* + * mrw address spaces + */ +#define MRW_LBA_DMA 0 +#define MRW_LBA_GAA 1 + +/* + * mrw mode pages (first is deprecated) -- probed at init time and + * cdi->mrw_mode_page is set + */ +#define MRW_MODE_PC_PRE1 0x2c +#define MRW_MODE_PC 0x03 + +struct mrw_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 write : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 write : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; + __u8 reserved4; + __u8 reserved5; +}; + +/* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */ +struct rwrt_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; + __u32 last_lba; + __u32 block_size; + __u16 blocking; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 page_present : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_present : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; +}; + +typedef struct { + __u16 disc_information_length; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 3; + __u8 erasable : 1; + __u8 border_status : 2; + __u8 disc_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 disc_status : 2; + __u8 border_status : 2; + __u8 erasable : 1; + __u8 reserved1 : 3; +#else +#error "Please fix " +#endif + __u8 n_first_track; + __u8 n_sessions_lsb; + __u8 first_track_lsb; + __u8 last_track_lsb; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 did_v : 1; + __u8 dbc_v : 1; + __u8 uru : 1; + __u8 reserved2 : 2; + __u8 dbit : 1; + __u8 mrw_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 mrw_status : 2; + __u8 dbit : 1; + __u8 reserved2 : 2; + __u8 uru : 1; + __u8 dbc_v : 1; + __u8 did_v : 1; +#endif + __u8 disc_type; + __u8 n_sessions_msb; + __u8 first_track_msb; + __u8 last_track_msb; + __u32 disc_id; + __u32 lead_in; + __u32 lead_out; + __u8 disc_bar_code[8]; + __u8 reserved3; + __u8 n_opc; +} disc_information; + +typedef struct { + __u16 track_information_length; + __u8 track_lsb; + __u8 session_lsb; + __u8 reserved1; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 2; + __u8 damage : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 rt : 1; + __u8 blank : 1; + __u8 packet : 1; + __u8 fp : 1; + __u8 data_mode : 4; + __u8 reserved3 : 6; + __u8 lra_v : 1; + __u8 nwa_v : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 track_mode : 4; + __u8 copy : 1; + __u8 damage : 1; + __u8 reserved2 : 2; + __u8 data_mode : 4; + __u8 fp : 1; + __u8 packet : 1; + __u8 blank : 1; + __u8 rt : 1; + __u8 nwa_v : 1; + __u8 lra_v : 1; + __u8 reserved3 : 6; +#endif + __u32 track_start; + __u32 next_writable; + __u32 free_blocks; + __u32 fixed_packet_size; + __u32 track_size; + __u32 last_rec_address; +} track_information; + +struct feature_header { + __u32 data_len; + __u8 reserved1; + __u8 reserved2; + __u16 curr_profile; +}; + +struct mode_page_header { + __u16 mode_data_length; + __u8 medium_type; + __u8 reserved1; + __u8 reserved2; + __u8 reserved3; + __u16 desc_length; +}; + +#ifdef __KERNEL__ +#include /* not really needed, later.. */ +#include + +struct packet_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char *buffer; + unsigned int buflen; + int stat; + struct request_sense *sense; + unsigned char data_direction; + int quiet; + int timeout; + void *reserved[1]; +}; + +/* + * _OLD will use PIO transfer on atapi devices, _BPC_* will use DMA + */ +#define CDDA_OLD 0 /* old style */ +#define CDDA_BPC_SINGLE 1 /* single frame block pc */ +#define CDDA_BPC_FULL 2 /* multi frame block pc */ + +/* Uniform cdrom data structures for cdrom.c */ +struct cdrom_device_info { + struct cdrom_device_ops *ops; /* link to device_ops */ + struct cdrom_device_info *next; /* next device_info for this major */ + struct gendisk *disk; /* matching block layer disk */ + void *handle; /* driver-dependent data */ +/* specifications */ + int mask; /* mask of capability: disables them */ + int speed; /* maximum speed for reading data */ + int capacity; /* number of discs in jukebox */ +/* device-related storage */ + int options : 30; /* options flags */ + unsigned mc_flags : 2; /* media change buffer flags */ + int use_count; /* number of times device opened */ + char name[20]; /* name of the device type */ +/* per-device flags */ + __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ + __u8 reserved : 6; /* not used yet */ + int cdda_method; /* see flags */ + __u8 last_sense; + __u8 media_written; /* dirty flag, DVD+RW bookkeeping */ + unsigned short mmc3_profile; /* current MMC3 profile */ + int for_data; + int (*exit)(struct cdrom_device_info *); + int mrw_mode_page; +}; + +struct cdrom_device_ops { +/* routines */ + int (*open) (struct cdrom_device_info *, int); + void (*release) (struct cdrom_device_info *); + int (*drive_status) (struct cdrom_device_info *, int); + int (*media_changed) (struct cdrom_device_info *, int); + int (*tray_move) (struct cdrom_device_info *, int); + int (*lock_door) (struct cdrom_device_info *, int); + int (*select_speed) (struct cdrom_device_info *, int); + int (*select_disc) (struct cdrom_device_info *, int); + int (*get_last_session) (struct cdrom_device_info *, + struct cdrom_multisession *); + int (*get_mcn) (struct cdrom_device_info *, + struct cdrom_mcn *); + /* hard reset device */ + int (*reset) (struct cdrom_device_info *); + /* play stuff */ + int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *); + /* dev-specific */ + int (*dev_ioctl) (struct cdrom_device_info *, + unsigned int, unsigned long); +/* driver specifications */ + const int capability; /* capability flags */ + int n_minors; /* number of active minor devices */ + /* handle uniform packets for scsi type devices (scsi,atapi) */ + int (*generic_packet) (struct cdrom_device_info *, + struct packet_command *); +}; + +/* the general block_device operations structure: */ +extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, + struct file *fp); +extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp); +extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi, + struct inode *ip, unsigned int cmd, unsigned long arg); +extern int cdrom_media_changed(struct cdrom_device_info *); + +extern int register_cdrom(struct cdrom_device_info *cdi); +extern int unregister_cdrom(struct cdrom_device_info *cdi); + +typedef struct { + int data; + int audio; + int cdi; + int xa; + long error; +} tracktype; + +extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written); +extern int cdrom_number_of_slots(struct cdrom_device_info *cdi); +extern int cdrom_mode_select(struct cdrom_device_info *cdi, + struct packet_command *cgc); +extern int cdrom_mode_sense(struct cdrom_device_info *cdi, + struct packet_command *cgc, + int page_code, int page_control); +extern void init_cdrom_command(struct packet_command *cgc, + void *buffer, int len, int type); + +/* The SCSI spec says there could be 256 slots. */ +#define CDROM_MAX_SLOTS 256 + +struct cdrom_mechstat_header { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 fault : 1; + __u8 changer_state : 2; + __u8 curslot : 5; + __u8 mech_state : 3; + __u8 door_open : 1; + __u8 reserved1 : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curslot : 5; + __u8 changer_state : 2; + __u8 fault : 1; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 mech_state : 3; +#endif + __u8 curlba[3]; + __u8 nslots; + __u16 slot_tablelen; +}; + +struct cdrom_slot { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 disc_present : 1; + __u8 reserved1 : 6; + __u8 change : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 change : 1; + __u8 reserved1 : 6; + __u8 disc_present : 1; +#endif + __u8 reserved2[3]; +}; + +struct cdrom_changer_info { + struct cdrom_mechstat_header hdr; + struct cdrom_slot slots[CDROM_MAX_SLOTS]; +}; + +typedef enum { + mechtype_caddy = 0, + mechtype_tray = 1, + mechtype_popup = 2, + mechtype_individual_changer = 4, + mechtype_cartridge_changer = 5 +} mechtype_t; + +typedef struct { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 ps : 1; + __u8 reserved1 : 1; + __u8 page_code : 6; + __u8 page_length; + __u8 reserved2 : 1; + __u8 bufe : 1; + __u8 ls_v : 1; + __u8 test_write : 1; + __u8 write_type : 4; + __u8 multi_session : 2; /* or border, DVD */ + __u8 fp : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 reserved3 : 4; + __u8 data_block_type : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_code : 6; + __u8 reserved1 : 1; + __u8 ps : 1; + __u8 page_length; + __u8 write_type : 4; + __u8 test_write : 1; + __u8 ls_v : 1; + __u8 bufe : 1; + __u8 reserved2 : 1; + __u8 track_mode : 4; + __u8 copy : 1; + __u8 fp : 1; + __u8 multi_session : 2; /* or border, DVD */ + __u8 data_block_type : 4; + __u8 reserved3 : 4; +#endif + __u8 link_size; + __u8 reserved4; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved5 : 2; + __u8 app_code : 6; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 app_code : 6; + __u8 reserved5 : 2; +#endif + __u8 session_format; + __u8 reserved6; + __u32 packet_size; + __u16 audio_pause; + __u8 mcn[16]; + __u8 isrc[16]; + __u8 subhdr0; + __u8 subhdr1; + __u8 subhdr2; + __u8 subhdr3; +} __attribute__((packed)) write_param_page; + +struct modesel_head +{ + __u8 reserved1; + __u8 medium; + __u8 reserved2; + __u8 block_desc_length; + __u8 density; + __u8 number_of_blocks_hi; + __u8 number_of_blocks_med; + __u8 number_of_blocks_lo; + __u8 reserved3; + __u8 block_length_hi; + __u8 block_length_med; + __u8 block_length_lo; +}; + +typedef struct { + __u16 report_key_length; + __u8 reserved1; + __u8 reserved2; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 type_code : 2; + __u8 vra : 3; + __u8 ucca : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ucca : 3; + __u8 vra : 3; + __u8 type_code : 2; +#endif + __u8 region_mask; + __u8 rpc_scheme; + __u8 reserved3; +} rpc_state_t; + +struct event_header { + __u16 data_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 nea : 1; + __u8 reserved1 : 4; + __u8 notification_class : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 notification_class : 3; + __u8 reserved1 : 4; + __u8 nea : 1; +#endif + __u8 supp_event_class; +}; + +struct media_event_desc { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 4; + __u8 media_event_code : 4; + __u8 reserved2 : 6; + __u8 media_present : 1; + __u8 door_open : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 media_event_code : 4; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 media_present : 1; + __u8 reserved2 : 6; +#endif + __u8 start_slot; + __u8 end_slot; +}; + +extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); + +#endif /* End of kernel only stuff */ + +#endif /* _LINUX_CDROM_H */ diff --git a/ddverify/models/con2/include/linux/compat.h b/ddverify/models/con2/include/linux/compat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/compiler.h b/ddverify/models/con2/include/linux/compiler.h new file mode 100644 index 000000000..3b8f75ea3 --- /dev/null +++ b/ddverify/models/con2/include/linux/compiler.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_COMPILER_H +#define __LINUX_COMPILER_H + +# define __user +# define __kernel +# define __safe +# define __force +# define __nocast +# define __iomem + +#ifndef __must_check +#define __must_check +#endif + +#define likely(x) x +#define unlikely(x) x + +void barrier(void); + +#endif diff --git a/ddverify/models/con2/include/linux/completion.h b/ddverify/models/con2/include/linux/completion.h new file mode 100644 index 000000000..011ec59af --- /dev/null +++ b/ddverify/models/con2/include/linux/completion.h @@ -0,0 +1,18 @@ +#ifndef __LINUX_COMPLETION_H +#define __LINUX_COMPLETION_H + +/* + * (C) Copyright 2001 Linus Torvalds + * + * Atomic wait-for-completion handler data structures. + * See kernel/sched.c for details. + */ + +#include + +struct completion { + unsigned int done; + wait_queue_head_t wait; +}; + +#endif diff --git a/ddverify/models/con2/include/linux/config.h b/ddverify/models/con2/include/linux/config.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/console.h b/ddverify/models/con2/include/linux/console.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/cpumask.h b/ddverify/models/con2/include/linux/cpumask.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/ctype.h b/ddverify/models/con2/include/linux/ctype.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/dcache.h b/ddverify/models/con2/include/linux/dcache.h new file mode 100644 index 000000000..2813f54c1 --- /dev/null +++ b/ddverify/models/con2/include/linux/dcache.h @@ -0,0 +1,9 @@ +#ifndef __LINUX_DCACHE_H +#define __LINUX_DCACHE_H + +struct dentry { + struct inode *d_inode; /* Where the name belongs to - NULL is + * negative */ +}; + +#endif /* __LINUX_DCACHE_H */ diff --git a/ddverify/models/con2/include/linux/delay.h b/ddverify/models/con2/include/linux/delay.h new file mode 100644 index 000000000..c3bb525bb --- /dev/null +++ b/ddverify/models/con2/include/linux/delay.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_DELAY_H +#define _LINUX_DELAY_H + +extern unsigned long loops_per_jiffy; + +#include + + +#ifndef mdelay +#define mdelay(n) do {} while(0) +#endif + +#ifndef ndelay +#define ndelay(x) do {} while(0) +#endif + +// DDV: This function does not need a body! +void msleep(unsigned int msecs); +// DDV: This function does not need a body! +unsigned long msleep_interruptible(unsigned int msecs); + +#endif /* defined(_LINUX_DELAY_H) */ diff --git a/ddverify/models/con2/include/linux/devfs_fs_kernel.h b/ddverify/models/con2/include/linux/devfs_fs_kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/device.h b/ddverify/models/con2/include/linux/device.h new file mode 100644 index 000000000..920ff5519 --- /dev/null +++ b/ddverify/models/con2/include/linux/device.h @@ -0,0 +1,112 @@ +/* + * device.h - generic, centralized driver model + * + * Copyright (c) 2001-2003 Patrick Mochel + * + * This file is released under the GPLv2 + * + * See Documentation/driver-model/ for more information. + */ + +#ifndef _DEVICE_H_ +#define _DEVICE_H_ + +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include + +struct device { + void *driver_data; /* data private to the driver */ + void (*release)(struct device * dev); +}; + +struct device_driver { + const char * name; +}; + + +struct class { + int someting; +}; + +struct class_device { + int something; +}; + +struct class_interface { + int something; +}; + +struct class_device_attribute { + struct attribute attr; + ssize_t (*show)(struct class_device *, char * buf); + ssize_t (*store)(struct class_device *, const char * buf, size_t count); +}; + +#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \ +struct class_device_attribute class_device_attr_##_name = \ + __ATTR(_name,_mode,_show,_store) + +extern struct class *class_create(struct module *owner, const char *name); +extern void class_destroy(struct class *cls); + +extern struct class_device *class_device_create(struct class *cls, + struct class_device *parent, + dev_t devt, + struct device *device, + const char *fmt, ...); +extern void class_device_destroy(struct class *cls, dev_t devt); + + +struct device_attribute { + struct attribute attr; + ssize_t (*show)(struct device *dev, struct device_attribute *attr, + char *buf); + ssize_t (*store)(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +}; + +#define DEVICE_ATTR(_name,_mode,_show,_store) \ +struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) + + +static inline void * dev_get_drvdata (struct device *dev) +{ + return dev->driver_data; +} + +static inline void dev_set_drvdata (struct device *dev, void *data) +{ + dev->driver_data = data; +} + +extern const char *dev_driver_string(struct device *dev); + + +#define dev_printk(level, dev, format, arg...) \ + printk("dev_printk") + +#ifdef DEBUG +#define dev_dbg(dev, format, arg...) \ + dev_printk(KERN_DEBUG , dev , format , ## arg) +#else +#define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) +#endif + +#define dev_err(dev, format, arg...) \ + dev_printk(KERN_ERR , dev , format , ## arg) +#define dev_info(dev, format, arg...) \ + dev_printk(KERN_INFO , dev , format , ## arg) +#define dev_warn(dev, format, arg...) \ + dev_printk(KERN_WARNING , dev , format , ## arg) +#define dev_notice(dev, format, arg...) \ + dev_printk(KERN_NOTICE , dev , format , ## arg) + +#endif /* _DEVICE_H_ */ diff --git a/ddverify/models/con2/include/linux/dma-mapping.h b/ddverify/models/con2/include/linux/dma-mapping.h new file mode 100644 index 000000000..9ea999ba9 --- /dev/null +++ b/ddverify/models/con2/include/linux/dma-mapping.h @@ -0,0 +1,19 @@ +#ifndef _ASM_LINUX_DMA_MAPPING_H +#define _ASM_LINUX_DMA_MAPPING_H + +#include +#include + + +#define DMA_64BIT_MASK (unsigned long long int)0xffffffffffffffff +#define DMA_48BIT_MASK (unsigned long long int)0x0000ffffffffffff +#define DMA_40BIT_MASK (unsigned long long int)0x000000ffffffffff +#define DMA_39BIT_MASK (unsigned long long int)0x0000007fffffffff +#define DMA_32BIT_MASK (unsigned long long int)0x00000000ffffffff +#define DMA_31BIT_MASK (unsigned long long int)0x000000007fffffff +#define DMA_30BIT_MASK (unsigned long long int)0x000000003fffffff +#define DMA_29BIT_MASK (unsigned long long int)0x000000001fffffff +#define DMA_28BIT_MASK (unsigned long long int)0x000000000fffffff +#define DMA_24BIT_MASK (unsigned long long int)0x0000000000ffffff + +#endif diff --git a/ddverify/models/con2/include/linux/elevator.h b/ddverify/models/con2/include/linux/elevator.h new file mode 100644 index 000000000..f0e7f6f17 --- /dev/null +++ b/ddverify/models/con2/include/linux/elevator.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_ELEVATOR_H +#define _LINUX_ELEVATOR_H + +struct request *elv_next_request(struct request_queue *q); + +#endif diff --git a/ddverify/models/con2/include/linux/err.h b/ddverify/models/con2/include/linux/err.h new file mode 100644 index 000000000..18c9cf814 --- /dev/null +++ b/ddverify/models/con2/include/linux/err.h @@ -0,0 +1,27 @@ +#ifndef _LINUX_ERR_H +#define _LINUX_ERR_H + +#include + +#include + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) (x) >= (unsigned long)-MAX_ERRNO + +static inline void *ERR_PTR(long error) +{ + return (void *) error; +} + +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline long IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + +#endif /* _LINUX_ERR_H */ diff --git a/ddverify/models/con2/include/linux/errno.h b/ddverify/models/con2/include/linux/errno.h new file mode 100644 index 000000000..91762481a --- /dev/null +++ b/ddverify/models/con2/include/linux/errno.h @@ -0,0 +1,25 @@ +#ifndef _LINUX_ERRNO_H +#define _LINUX_ERRNO_H + +#include + +/* Should never be seen by user programs */ +#define ERESTARTSYS 512 +#define ERESTARTNOINTR 513 +#define ERESTARTNOHAND 514 /* restart if no handler.. */ +#define ENOIOCTLCMD 515 /* No ioctl command */ +#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ + +/* Defined for the NFSv3 protocol */ +#define EBADHANDLE 521 /* Illegal NFS file handle */ +#define ENOTSYNC 522 /* Update synchronization mismatch */ +#define EBADCOOKIE 523 /* Cookie is stale */ +#define ENOTSUPP 524 /* Operation is not supported */ +#define ETOOSMALL 525 /* Buffer or request is too small */ +#define ESERVERFAULT 526 /* An untranslatable error occurred */ +#define EBADTYPE 527 /* Type not supported by server */ +#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ +#define EIOCBQUEUED 529 /* iocb queued, will get completion event */ +#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */ + +#endif diff --git a/ddverify/models/con2/include/linux/fcntl.h b/ddverify/models/con2/include/linux/fcntl.h new file mode 100644 index 000000000..9de3512e8 --- /dev/null +++ b/ddverify/models/con2/include/linux/fcntl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_FCNTL_H +#define _LINUX_FCNTL_H + +#include + +#endif diff --git a/ddverify/models/con2/include/linux/fd.h b/ddverify/models/con2/include/linux/fd.h new file mode 100644 index 000000000..5b5a51a4e --- /dev/null +++ b/ddverify/models/con2/include/linux/fd.h @@ -0,0 +1,373 @@ +#ifndef _LINUX_FD_H +#define _LINUX_FD_H + +#include +#include +/* New file layout: Now the ioctl definitions immediately follow the + * definitions of the structures that they use */ + +/* + * Geometry + */ +struct floppy_struct { + unsigned int size, /* nr of sectors total */ + sect, /* sectors per track */ + head, /* nr of heads */ + track, /* nr of tracks */ + stretch; /* !=0 means double track steps */ +#define FD_STRETCH 1 +#define FD_SWAPSIDES 2 +#define FD_ZEROBASED 4 + + unsigned char gap, /* gap1 size */ + + rate, /* data rate. |= 0x40 for perpendicular */ +#define FD_2M 0x4 +#define FD_SIZECODEMASK 0x38 +#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) +#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ + 512 : 128 << FD_SIZECODE(floppy) ) +#define FD_PERP 0x40 + + spec1, /* stepping rate, head unload time */ + fmt_gap; /* gap2 size */ + const char * name; /* used only for predefined formats */ +}; + + +/* commands needing write access have 0x40 set */ +/* commands needing super user access have 0x80 set */ + +#define FDCLRPRM _IO(2, 0x41) +/* clear user-defined parameters */ + +#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) +#define FDSETMEDIAPRM FDSETPRM +/* set user-defined parameters for current media */ + +#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) +#define FDGETPRM _IOR(2, 0x04, struct floppy_struct) +#define FDDEFMEDIAPRM FDDEFPRM +#define FDGETMEDIAPRM FDGETPRM +/* set/get disk parameters */ + + +#define FDMSGON _IO(2,0x45) +#define FDMSGOFF _IO(2,0x46) +/* issue/don't issue kernel messages on media type change */ + + +/* + * Formatting (obsolete) + */ +#define FD_FILL_BYTE 0xF6 /* format fill byte. */ + +struct format_descr { + unsigned int device,head,track; +}; + +#define FDFMTBEG _IO(2,0x47) +/* begin formatting a disk */ +#define FDFMTTRK _IOW(2,0x48, struct format_descr) +/* format the specified track */ +#define FDFMTEND _IO(2,0x49) +/* end formatting a disk */ + + +/* + * Error thresholds + */ +struct floppy_max_errors { + unsigned int + abort, /* number of errors to be reached before aborting */ + read_track, /* maximal number of errors permitted to read an + * entire track at once */ + reset, /* maximal number of errors before a reset is tried */ + recal, /* maximal number of errors before a recalibrate is + * tried */ + + /* + * Threshold for reporting FDC errors to the console. + * Setting this to zero may flood your screen when using + * ultra cheap floppies ;-) + */ + reporting; + +}; + +#define FDSETEMSGTRESH _IO(2,0x4a) +/* set fdc error reporting threshold */ + +#define FDFLUSH _IO(2,0x4b) +/* flush buffers for media; either for verifying media, or for + * handling a media change without closing the file descriptor */ + +#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors) +#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors) +/* set/get abortion and read_track threshold. See also floppy_drive_params + * structure */ + + +typedef char floppy_drive_name[16]; +#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name) +/* get drive type: 5 1/4 or 3 1/2 */ + + +/* + * Drive parameters (user modifiable) + */ +struct floppy_drive_params { + signed char cmos; /* CMOS type */ + + /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms + * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). + */ + unsigned long max_dtr; /* Step rate, usec */ + unsigned long hlt; /* Head load/settle time, msec */ + unsigned long hut; /* Head unload time (remnant of + * 8" drives) */ + unsigned long srt; /* Step rate, usec */ + + unsigned long spinup; /* time needed for spinup (expressed + * in jiffies) */ + unsigned long spindown; /* timeout needed for spindown */ + unsigned char spindown_offset; /* decides in which position the disk + * will stop */ + unsigned char select_delay; /* delay to wait after select */ + unsigned char rps; /* rotations per second */ + unsigned char tracks; /* maximum number of tracks */ + unsigned long timeout; /* timeout for interrupt requests */ + + unsigned char interleave_sect; /* if there are more sectors, use + * interleave */ + + struct floppy_max_errors max_errors; + + char flags; /* various flags, including ftd_msg */ +/* + * Announce successful media type detection and media information loss after + * disk changes. + * Also used to enable/disable printing of overrun warnings. + */ + +#define FTD_MSG 0x10 +#define FD_BROKEN_DCL 0x20 +#define FD_DEBUG 0x02 +#define FD_SILENT_DCL_CLEAR 0x4 +#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware + considerations */ + + char read_track; /* use readtrack during probing? */ + +/* + * Auto-detection. Each drive type has eight formats which are + * used in succession to try to read the disk. If the FDC cannot lock onto + * the disk, the next format is tried. This uses the variable 'probing'. + */ + short autodetect[8]; /* autodetected formats */ + + int checkfreq; /* how often should the drive be checked for disk + * changes */ + int native_format; /* native format of this drive */ +}; + +enum { + FD_NEED_TWADDLE_BIT, /* more magic */ + FD_VERIFY_BIT, /* inquire for write protection */ + FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet + * to clear media change status */ + FD_UNUSED_BIT, + FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ + FD_DISK_WRITABLE_BIT /* disk is writable */ +}; + +#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params) +#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params) +/* set/get drive parameters */ + + +/* + * Current drive state (not directly modifiable by user, readonly) + */ +struct floppy_drive_struct { + unsigned long flags; +/* values for these flags */ +#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT) +#define FD_VERIFY (1 << FD_VERIFY_BIT) +#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT) +#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT) +#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT) + + unsigned long spinup_date; + unsigned long select_date; + unsigned long first_read_date; + short probed_format; + short track; /* current track */ + short maxblock; /* id of highest block read */ + short maxtrack; /* id of highest half track read */ + int generation; /* how many diskchanges? */ + +/* + * (User-provided) media information is _not_ discarded after a media change + * if the corresponding keep_data flag is non-zero. Positive values are + * decremented after each probe. + */ + int keep_data; + + /* Prevent "aliased" accesses. */ + int fd_ref; + int fd_device; + unsigned long last_checked; /* when was the drive last checked for a disk + * change? */ + + char *dmabuf; + int bufblocks; +}; + +#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct) +#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct) +/* get drive state: GET returns the cached state, POLL polls for new state */ + + +/* + * reset FDC + */ +enum reset_mode { + FD_RESET_IF_NEEDED, /* reset only if the reset flags is set */ + FD_RESET_IF_RAWCMD, /* obsolete */ + FD_RESET_ALWAYS /* reset always */ +}; +#define FDRESET _IO(2, 0x54) + + +/* + * FDC state + */ +struct floppy_fdc_state { + int spec1; /* spec1 value last used */ + int spec2; /* spec2 value last used */ + int dtr; + unsigned char version; /* FDC version code */ + unsigned char dor; + unsigned long address; /* io address */ + unsigned int rawcmd:2; + unsigned int reset:1; + unsigned int need_configure:1; + unsigned int perp_mode:2; + unsigned int has_fifo:1; + unsigned int driver_version; /* version code for floppy driver */ +#define FD_DRIVER_VERSION 0x100 +/* user programs using the floppy API should use floppy_fdc_state to + * get the version number of the floppy driver that they are running + * on. If this version number is bigger than the one compiled into the + * user program (the FD_DRIVER_VERSION define), it should be prepared + * to bigger structures + */ + + unsigned char track[4]; + /* Position of the heads of the 4 units attached to this FDC, + * as stored on the FDC. In the future, the position as stored + * on the FDC might not agree with the actual physical + * position of these drive heads. By allowing such + * disagreement, it will be possible to reset the FDC without + * incurring the expensive cost of repositioning all heads. + * Right now, these positions are hard wired to 0. */ + +}; + +#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state) + + +/* + * Asynchronous Write error tracking + */ +struct floppy_write_errors { + /* Write error logging. + * + * These fields can be cleared with the FDWERRORCLR ioctl. + * Only writes that were attempted but failed due to a physical media + * error are logged. write(2) calls that fail and return an error code + * to the user process are not counted. + */ + + unsigned int write_errors; /* number of physical write errors + * encountered */ + + /* position of first and last write errors */ + unsigned long first_error_sector; + int first_error_generation; + unsigned long last_error_sector; + int last_error_generation; + + unsigned int badness; /* highest retry count for a read or write + * operation */ +}; + +#define FDWERRORCLR _IO(2, 0x56) +/* clear write error and badness information */ +#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors) +/* get write error and badness information */ + + +/* + * Raw commands + */ +/* new interface flag: now we can do them in batches */ +#define FDHAVEBATCHEDRAWCMD + +struct floppy_raw_cmd { + unsigned int flags; +#define FD_RAW_READ 1 +#define FD_RAW_WRITE 2 +#define FD_RAW_NO_MOTOR 4 +#define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */ +#define FD_RAW_INTR 8 /* wait for an interrupt */ +#define FD_RAW_SPIN 0x10 /* spin up the disk for this command */ +#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command + * completion */ +#define FD_RAW_NEED_DISK 0x40 /* this command needs a disk to be present */ +#define FD_RAW_NEED_SEEK 0x80 /* this command uses an implied seek (soft) */ + +/* more "in" flags */ +#define FD_RAW_MORE 0x100 /* more records follow */ +#define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */ +#define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */ +#define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure + * detection too */ + +/* more "out" flags */ +#define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */ +#define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */ + + void __user *data; + char *kernel_data; /* location of data buffer in the kernel */ + struct floppy_raw_cmd *next; /* used for chaining of raw cmd's + * within the kernel */ + long length; /* in: length of dma transfer. out: remaining bytes */ + long phys_length; /* physical length, if different from dma length */ + int buffer_length; /* length of allocated buffer */ + + unsigned char rate; + unsigned char cmd_count; + unsigned char cmd[16]; + unsigned char reply_count; + unsigned char reply[16]; + int track; + int resultcode; + + int reserved1; + int reserved2; +}; + +#define FDRAWCMD _IO(2, 0x58) +/* send a raw command to the fdc. Structure size not included, because of + * batches */ + +#define FDTWADDLE _IO(2, 0x59) +/* flicker motor-on bit before reading a sector. Experimental */ + + +#define FDEJECT _IO(2, 0x5a) +/* eject the disk */ + +#endif diff --git a/ddverify/models/con2/include/linux/fdreg.h b/ddverify/models/con2/include/linux/fdreg.h new file mode 100644 index 000000000..c2eeb63b7 --- /dev/null +++ b/ddverify/models/con2/include/linux/fdreg.h @@ -0,0 +1,137 @@ +#ifndef _LINUX_FDREG_H +#define _LINUX_FDREG_H +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ + +#ifdef FDPATCHES +#define FD_IOPORT fdc_state[fdc].address +#else +/* It would be a lot saner just to force fdc_state[fdc].address to always + be set ! FIXME */ +#define FD_IOPORT 0x3f0 +#endif + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS (4 + FD_IOPORT ) +#define FD_DATA (5 + FD_IOPORT ) + +/* Digital Output Register */ +#define FD_DOR (2 + FD_IOPORT ) + +/* Digital Input Register (read) */ +#define FD_DIR (7 + FD_IOPORT ) + +/* Diskette Control Register (write)*/ +#define FD_DCR (7 + FD_IOPORT ) + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment check error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Address Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_DS 0x08 /* drive is double-sided */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_RY 0x20 /* drive is ready */ +#define ST3_WP 0x40 /* Write Protect */ +#define ST3_FT 0x80 /* Drive Fault */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ +#define FD_FORMAT 0x4D /* format one track */ +#define FD_VERSION 0x10 /* get version code */ +#define FD_CONFIGURE 0x13 /* configure FIFO operation */ +#define FD_PERPENDICULAR 0x12 /* perpendicular r/w mode */ +#define FD_GETSTATUS 0x04 /* read ST3 */ +#define FD_DUMPREGS 0x0E /* dump the contents of the fdc regs */ +#define FD_READID 0xEA /* prints the header of a sector */ +#define FD_UNLOCK 0x14 /* Fifo config unlock */ +#define FD_LOCK 0x94 /* Fifo config lock */ +#define FD_RSEEK_OUT 0x8f /* seek out (i.e. to lower tracks) */ +#define FD_RSEEK_IN 0xcf /* seek in (i.e. to higher tracks) */ + +/* the following commands are new in the 82078. They are not used in the + * floppy driver, except the first three. These commands may be useful for apps + * which use the FDRAWCMD interface. For doc, get the 82078 spec sheets at + * http://www-techdoc.intel.com/docs/periph/fd_contr/datasheets/ */ + +#define FD_PARTID 0x18 /* part id ("extended" version cmd) */ +#define FD_SAVE 0x2e /* save fdc regs for later restore */ +#define FD_DRIVESPEC 0x8e /* drive specification: Access to the + * 2 Mbps data transfer rate for tape + * drives */ + +#define FD_RESTORE 0x4e /* later restore */ +#define FD_POWERDOWN 0x27 /* configure FDC's powersave features */ +#define FD_FORMAT_N_WRITE 0xef /* format and write in one go. */ +#define FD_OPTION 0x33 /* ISO format (which is a clean way to + * pack more sectors on a track) */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +/* FDC version return types */ +#define FDC_NONE 0x00 +#define FDC_UNKNOWN 0x10 /* DO NOT USE THIS TYPE EXCEPT IF IDENTIFICATION + FAILS EARLY */ +#define FDC_8272A 0x20 /* Intel 8272a, NEC 765 */ +#define FDC_765ED 0x30 /* Non-Intel 1MB-compatible FDC, can't detect */ +#define FDC_82072 0x40 /* Intel 82072; 8272a + FIFO + DUMPREGS */ +#define FDC_82072A 0x45 /* 82072A (on Sparcs) */ +#define FDC_82077_ORIG 0x51 /* Original version of 82077AA, sans LOCK */ +#define FDC_82077 0x52 /* 82077AA-1 */ +#define FDC_82078_UNKN 0x5f /* Unknown 82078 variant */ +#define FDC_82078 0x60 /* 44pin 82078 or 64pin 82078SL */ +#define FDC_82078_1 0x61 /* 82078-1 (2Mbps fdc) */ +#define FDC_S82078B 0x62 /* S82078B (first seen on Adaptec AVA-2825 VLB + * SCSI/EIDE/Floppy controller) */ +#define FDC_87306 0x63 /* National Semiconductor PC 87306 */ + +/* + * Beware: the fdc type list is roughly sorted by increasing features. + * Presence of features is tested by comparing the FDC version id with the + * "oldest" version that has the needed feature. + * If during FDC detection, an obscure test fails late in the sequence, don't + * assign FDC_UNKNOWN. Else the FDC will be treated as a dumb 8272a, or worse. + * This is especially true if the tests are unneeded. + */ + +#define FD_RESET_DELAY 20 +#endif diff --git a/ddverify/models/con2/include/linux/file.h b/ddverify/models/con2/include/linux/file.h new file mode 100644 index 000000000..df49c59d6 --- /dev/null +++ b/ddverify/models/con2/include/linux/file.h @@ -0,0 +1,14 @@ +#ifndef __LINUX_FILE_H +#define __LINUX_FILE_H + +#include +#include +#include +#include +//#include +#include + +extern void fput(struct file *); +extern struct file * fget(unsigned int fd); + +#endif /* __LINUX_FILE_H */ diff --git a/ddverify/models/con2/include/linux/firmware.h b/ddverify/models/con2/include/linux/firmware.h new file mode 100644 index 000000000..33d8f2087 --- /dev/null +++ b/ddverify/models/con2/include/linux/firmware.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_FIRMWARE_H +#define _LINUX_FIRMWARE_H +#include +#include +#define FIRMWARE_NAME_MAX 30 +#define FW_ACTION_NOHOTPLUG 0 +#define FW_ACTION_HOTPLUG 1 + +struct firmware { + size_t size; + u8 *data; +}; +struct device; +int request_firmware(const struct firmware **fw, const char *name, + struct device *device); +int request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, void *context, + void (*cont)(const struct firmware *fw, void *context)); + +void release_firmware(const struct firmware *fw); +#endif diff --git a/ddverify/models/con2/include/linux/fs.h b/ddverify/models/con2/include/linux/fs.h new file mode 100644 index 000000000..7314a5b99 --- /dev/null +++ b/ddverify/models/con2/include/linux/fs.h @@ -0,0 +1,238 @@ +#ifndef _LINUX_FS_H +#define _LINUX_FS_H + +/* + * This file has definitions for some important file table + * structures etc. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#undef NR_OPEN +#define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */ +#define INR_OPEN 1024 /* Initial setting for nfile rlimits */ + +#define BLOCK_SIZE_BITS 10 +#define BLOCK_SIZE (1<bi_rw & 1) + + +int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); +int register_chrdev_region(dev_t, unsigned, const char *); +void unregister_chrdev_region(dev_t, unsigned); + +int register_chrdev(unsigned int, const char *, struct file_operations *); +int unregister_chrdev(unsigned int, const char *); + +int chrdev_open(struct inode *, struct file *); +void chrdev_show(struct seq_file *,off_t); + +#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ + +int register_blkdev(unsigned int, const char *); +int unregister_blkdev(unsigned int, const char *); + + +void kill_fasync(struct fasync_struct **, int, int); + +static inline unsigned iminor(struct inode *inode) +{ + return MINOR(inode->i_rdev); +} + +static inline unsigned imajor(struct inode *inode) +{ + return MAJOR(inode->i_rdev); +} + +loff_t no_llseek(struct file *file, loff_t offset, int origin); + + +int check_disk_change(struct block_device *); + +/* + * return READ, READA, or WRITE + */ +#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK)) + +int nonseekable_open(struct inode * inode, struct file * filp); + +loff_t i_size_read(struct inode *inode); + +int set_blocksize(struct block_device *, int); +#endif diff --git a/ddverify/models/con2/include/linux/genhd.h b/ddverify/models/con2/include/linux/genhd.h new file mode 100644 index 000000000..46dd433cb --- /dev/null +++ b/ddverify/models/con2/include/linux/genhd.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_GENHD_H +#define _LINUX_GENHD_H + +#include +#include +#include +//#include +#include +#include + +#define GENHD_FL_REMOVABLE 1 +#define GENHD_FL_DRIVERFS 2 +#define GENHD_FL_CD 8 +#define GENHD_FL_UP 16 +#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 + +struct gendisk { + int major; /* major number of driver */ + int first_minor; + int minors; /* maximum number of minors, =1 for + * disks that can't be partitioned. */ + char disk_name[32]; /* name of major driver */ + struct block_device_operations *fops; + struct request_queue *queue; + void *private_data; + + int flags; + struct device *driverfs_dev; + char devfs_name[64]; /* devfs crap */ +}; + +// DDV: defined in file linux/block/genhd.c +void add_disk(struct gendisk *disk); +// DDV: defined in file linux/block/genhd.c +void del_gendisk(struct gendisk *gp); +// DDV: defined in file linux/block/genhd.c +struct gendisk *alloc_disk(int minors); +// DDV: TODO +void put_disk(struct gendisk *disk); +// DDV: TODO +extern struct kobject *get_disk(struct gendisk *disk); + +// DDV: TODO +void set_capacity(struct gendisk *disk, sector_t size); + +// DDV: TODO +void add_disk_randomness(struct gendisk *disk); +#endif diff --git a/ddverify/models/con2/include/linux/gfp.h b/ddverify/models/con2/include/linux/gfp.h new file mode 100644 index 000000000..d01d2dd5e --- /dev/null +++ b/ddverify/models/con2/include/linux/gfp.h @@ -0,0 +1,74 @@ +#ifndef __LINUX_GFP_H +#define __LINUX_GFP_H + +#include +#include +//#include +#include + +/* + * Action modifiers - doesn't change the zoning + * + * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt + * _might_ fail. This depends upon the particular VM implementation. + * + * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller + * cannot handle allocation failures. + * + * __GFP_NORETRY: The VM implementation must not retry indefinitely. + */ +#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */ +#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */ +#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */ +#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ +#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ +#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ +#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */ +#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */ +#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */ +#define __GFP_NO_GROW ((__force gfp_t)0x2000u)/* Slab internal usage */ +#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ +#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ +#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ +#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ + +#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ +#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) + +/* if you forget to add the bitmask here kernel will crash, period */ +#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ + __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ + __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ + __GFP_NOMEMALLOC|__GFP_HARDWALL) + +/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ +#define GFP_ATOMIC (__GFP_HIGH) +#define GFP_NOIO (__GFP_WAIT) +#define GFP_NOFS (__GFP_WAIT | __GFP_IO) +#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) +#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL) +#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \ + __GFP_HIGHMEM) + + +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_page(gfp_t gfp_mask); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long get_zeroed_page(gfp_t gfp_mask); + +// DDV: No body required +void free_pages(unsigned long addr, unsigned int order); +// DDV: No body required +void free_page(unsigned long addr); + +// DDV: Body defined in linux/mm/page_alloc.c +static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, + unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_page(gfp_t gfp_mask); + +#endif diff --git a/ddverify/models/con2/include/linux/hdreg.h b/ddverify/models/con2/include/linux/hdreg.h new file mode 100644 index 000000000..a57304a20 --- /dev/null +++ b/ddverify/models/con2/include/linux/hdreg.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_HDREG_H +#define _LINUX_HDREG_H + +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + unsigned short cylinders; + unsigned long start; +}; + +#define HDIO_GETGEO 0x0301 /* get device geometry */ + +#endif /* _LINUX_HDREG_H */ diff --git a/ddverify/models/con2/include/linux/highmem.h b/ddverify/models/con2/include/linux/highmem.h new file mode 100644 index 000000000..9ec708efa --- /dev/null +++ b/ddverify/models/con2/include/linux/highmem.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_HIGHMEM_H +#define _LINUX_HIGHMEM_H + +#include +#include + +#include + +#endif /* _LINUX_HIGHMEM_H */ diff --git a/ddverify/models/con2/include/linux/if.h b/ddverify/models/con2/include/linux/if.h new file mode 100644 index 000000000..544dc09d7 --- /dev/null +++ b/ddverify/models/con2/include/linux/if.h @@ -0,0 +1,8 @@ +#ifndef _LINUX_IF_H +#define _LINUX_IF_H + +#include /* for "__kernel_caddr_t" et al */ +#include /* for "struct sockaddr" et al */ +#include /* for "__user" et al */ + +#endif /* _LINUX_IF_H */ diff --git a/ddverify/models/con2/include/linux/in.h b/ddverify/models/con2/include/linux/in.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/init.h b/ddverify/models/con2/include/linux/init.h new file mode 100644 index 000000000..ee78bf673 --- /dev/null +++ b/ddverify/models/con2/include/linux/init.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_INIT_H +#define _LINUX_INIT_H + +#include +#include + +#define module_init(_function) int (* _ddv_tmp_init)(void) = _function +#define module_exit(_function) void (* _ddv_tmp_exit)(void) = _function + +#define __init +#define __initdata +#define __exitdata +#define __exit + +#define __devinit +#define __devinitdata +#define __devexit +#define __devexitdata +#define __devexit_p(x) x + +#define __setup(str, func) int (* _ddv_setup_function)(char *) = func + +#endif diff --git a/ddverify/models/con2/include/linux/interrupt.h b/ddverify/models/con2/include/linux/interrupt.h new file mode 100644 index 000000000..68c9dc998 --- /dev/null +++ b/ddverify/models/con2/include/linux/interrupt.h @@ -0,0 +1,96 @@ +/* interrupt.h */ +#ifndef _LINUX_INTERRUPT_H +#define _LINUX_INTERRUPT_H + +#include +#include +#include +#include + +/* + * These flags used only by the kernel as part of the + * irq handling routines. + * + * IRQF_DISABLED - keep irqs disabled when calling the action handler + * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator + * IRQF_SHARED - allow sharing the irq among several devices + * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur + * IRQF_TIMER - Flag to mark this interrupt as timer interrupt + */ +#define IRQF_DISABLED 0x00000020 +#define IRQF_SAMPLE_RANDOM 0x00000040 +#define IRQF_SHARED 0x00000080 +#define IRQF_PROBE_SHARED 0x00000100 +#define IRQF_TIMER 0x00000200 +#define IRQF_PERCPU 0x00000400 + + +typedef int irqreturn_t; + +#define IRQ_NONE (0) +#define IRQ_HANDLED (1) +#define IRQ_RETVAL(x) ((x) != 0) + +struct tasklet_struct +{ + atomic_t count; + void (*func)(unsigned long); + unsigned long data; + + int init; +}; + +#define DECLARE_TASKLET(name, func, data) \ + struct tasklet_struct name = { 0, func, data, 1 } + +#define DECLARE_TASKLET_DISABLED(name, func, data) \ + struct tasklet_struct name = { 1, func, data, 1 } + +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_schedule(struct tasklet_struct *t); + +static inline void tasklet_disable(struct tasklet_struct *t) +{ + t->count++; +} + +static inline void tasklet_enable(struct tasklet_struct *t) +{ + t->count++; +} + +// DDV: TODO +void tasklet_kill(struct tasklet_struct *t); +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data); + +#ifdef OLD_INTERRUPT_HANDLER +typedef irqreturn_t (*irq_handler_t)(int, void *); +#else +typedef irqreturn_t (*irq_handler_t)(int, void *, struct pt_regs *); +#endif + +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +int request_irq(unsigned int, irq_handler_t handler, + unsigned long, const char *, void *); +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +void free_irq(unsigned int, void *); + +// DDV: TODO +unsigned long probe_irq_on(void); +// DDV: TODO +int probe_irq_off(unsigned long); +// DDV: TODO +unsigned int probe_irq_mask(unsigned long); + +// DDV: TODO +void cli(void); +// DDV: TODO +void sti(void); +// DDV: TODO +void save_flags(unsigned long x); +// DDV: TODO +void restore_flags(unsigned long x); + +#endif diff --git a/ddverify/models/con2/include/linux/ioctl.h b/ddverify/models/con2/include/linux/ioctl.h new file mode 100644 index 000000000..6f08f2f94 --- /dev/null +++ b/ddverify/models/con2/include/linux/ioctl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_IOCTL_H +#define _LINUX_IOCTL_H + +#include + +#endif diff --git a/ddverify/models/con2/include/linux/ioport.h b/ddverify/models/con2/include/linux/ioport.h new file mode 100644 index 000000000..7df1143c6 --- /dev/null +++ b/ddverify/models/con2/include/linux/ioport.h @@ -0,0 +1,102 @@ +/* + * ioport.h Definitions of routines for detecting, reserving and + * allocating system resources. + * + * Authors: Linus Torvalds + */ + +#ifndef _LINUX_IOPORT_H +#define _LINUX_IOPORT_H + +#include + + +/* + * Resources are tree-like, allowing + * nesting etc.. + */ +struct resource { + const char *name; + unsigned long start, end; + unsigned long flags; +// struct resource *parent, *sibling, *child; +}; + + +/* + * IO resources have these defined flags. + */ +#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ + +#define IORESOURCE_IO 0x00000100 /* Resource type */ +#define IORESOURCE_MEM 0x00000200 +#define IORESOURCE_IRQ 0x00000400 +#define IORESOURCE_DMA 0x00000800 + +#define IORESOURCE_PREFETCH 0x00001000 /* No side effects */ +#define IORESOURCE_READONLY 0x00002000 +#define IORESOURCE_CACHEABLE 0x00004000 +#define IORESOURCE_RANGELENGTH 0x00008000 +#define IORESOURCE_SHADOWABLE 0x00010000 +#define IORESOURCE_BUS_HAS_VGA 0x00080000 + +#define IORESOURCE_DISABLED 0x10000000 +#define IORESOURCE_UNSET 0x20000000 +#define IORESOURCE_AUTO 0x40000000 +#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ + +/* ISA PnP IRQ specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_IRQ_HIGHEDGE (1<<0) +#define IORESOURCE_IRQ_LOWEDGE (1<<1) +#define IORESOURCE_IRQ_HIGHLEVEL (1<<2) +#define IORESOURCE_IRQ_LOWLEVEL (1<<3) +#define IORESOURCE_IRQ_SHAREABLE (1<<4) + +/* ISA PnP DMA specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_DMA_TYPE_MASK (3<<0) +#define IORESOURCE_DMA_8BIT (0<<0) +#define IORESOURCE_DMA_8AND16BIT (1<<0) +#define IORESOURCE_DMA_16BIT (2<<0) + +#define IORESOURCE_DMA_MASTER (1<<2) +#define IORESOURCE_DMA_BYTE (1<<3) +#define IORESOURCE_DMA_WORD (1<<4) + +#define IORESOURCE_DMA_SPEED_MASK (3<<6) +#define IORESOURCE_DMA_COMPATIBLE (0<<6) +#define IORESOURCE_DMA_TYPEA (1<<6) +#define IORESOURCE_DMA_TYPEB (2<<6) +#define IORESOURCE_DMA_TYPEF (3<<6) + +/* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */ +#define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */ +#define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */ +#define IORESOURCE_MEM_TYPE_MASK (3<<3) +#define IORESOURCE_MEM_8BIT (0<<3) +#define IORESOURCE_MEM_16BIT (1<<3) +#define IORESOURCE_MEM_8AND16BIT (2<<3) +#define IORESOURCE_MEM_32BIT (3<<3) +#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ +#define IORESOURCE_MEM_EXPANSIONROM (1<<6) + +/* PCI ROM control bits (IORESOURCE_BITS) */ +#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ +#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */ +#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */ + + +// DDV: Body defined in linux/kernel/resource.c +struct resource *request_region(unsigned long, unsigned long, const char *); +// DDV: Body defined in linux/kernel/resource.c +void release_region(unsigned long, unsigned long); + + +// DDV: TODO +struct resource *request_mem_region(unsigned long start, unsigned long len, const char *name); +// DDV: TODO +void release_mem_region(unsigned long start, unsigned long len); + + + +#endif /* _LINUX_IOPORT_H */ diff --git a/ddverify/models/con2/include/linux/jiffies.h b/ddverify/models/con2/include/linux/jiffies.h new file mode 100644 index 000000000..2d4a183ca --- /dev/null +++ b/ddverify/models/con2/include/linux/jiffies.h @@ -0,0 +1,84 @@ +#ifndef _LINUX_JIFFIES_H +#define _LINUX_JIFFIES_H + +#include +#include + +unsigned long jiffies; + +/* + * These inlines deal with timer wrapping correctly. You are + * strongly encouraged to use them + * 1. Because people otherwise forget + * 2. Because if the timer wrap changes in future you won't have to + * alter your driver code. + * + * time_after(a,b) returns true if the time a is after time b. + * + * Do this with "<0" and ">=0" to only test the sign of the result. A + * good compiler would generate better code (and a really good compiler + * wouldn't care). Gcc is currently neither. + */ +#define time_after(a,b) ((long)(b) - (long)(a) < 0) +#define time_before(a,b) time_after(b,a) +#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_before_eq(a,b) time_after_eq(b,a) + + +#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) + +/* + * Convert jiffies to milliseconds and back. + * + * Avoid unnecessary multiplications/divisions in the + * two most common HZ cases: + */ +static inline unsigned int jiffies_to_msecs(const unsigned long j) +{ +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (MSEC_PER_SEC / HZ) * j; +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); +#else + return (j * MSEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned int jiffies_to_usecs(const unsigned long j) +{ +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (USEC_PER_SEC / HZ) * j; +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); +#else + return (j * USEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned long msecs_to_jiffies(const unsigned int m) +{ + if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return m * (HZ / MSEC_PER_SEC); +#else + return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; +#endif +} + +static inline unsigned long usecs_to_jiffies(const unsigned int u) +{ + if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ); +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return u * (HZ / USEC_PER_SEC); +#else + return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC; +#endif +} + +#endif diff --git a/ddverify/models/con2/include/linux/kdb_kern.h b/ddverify/models/con2/include/linux/kdb_kern.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/kdev_t.h b/ddverify/models/con2/include/linux/kdev_t.h new file mode 100644 index 000000000..647632b51 --- /dev/null +++ b/ddverify/models/con2/include/linux/kdev_t.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_KDEV_T_H +#define _LINUX_KDEV_T_H + +#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK)) +#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi)) + +#endif diff --git a/ddverify/models/con2/include/linux/kernel.h b/ddverify/models/con2/include/linux/kernel.h new file mode 100644 index 000000000..a228a8a21 --- /dev/null +++ b/ddverify/models/con2/include/linux/kernel.h @@ -0,0 +1,115 @@ +#ifndef _LINUX_KERNEL_H +#define _LINUX_KERNEL_H + +/* + * 'kernel.h' contains some often-used function prototypes etc + */ + +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + +#define KERN_EMERG "<0>" /* system is unusable */ +#define KERN_ALERT "<1>" /* action must be taken immediately */ +#define KERN_CRIT "<2>" /* critical conditions */ +#define KERN_ERR "<3>" /* error conditions */ +#define KERN_WARNING "<4>" /* warning conditions */ +#define KERN_NOTICE "<5>" /* normal but significant condition */ +#define KERN_INFO "<6>" /* informational */ +#define KERN_DEBUG "<7>" /* debug-level messages */ + +unsigned long simple_strtoul(const char *,char **,unsigned int); +long simple_strtol(const char *,char **,unsigned int); +unsigned long long simple_strtoull(const char *,char **,unsigned int); +long long simple_strtoll(const char *,char **,unsigned int); + +int printk(const char * fmt, ...); +int sprintf(char * buf, const char * fmt, ...); +int snprintf(char * buf, size_t size, const char * fmt, ...); + +extern int cond_resched(void); + +extern int get_option(char **str, int *pint); +extern char *get_options(const char *str, int nints, int *ints); + +/* Values used for system_state */ +extern enum system_states { + SYSTEM_BOOTING, + SYSTEM_RUNNING, + SYSTEM_HALT, + SYSTEM_POWER_OFF, + SYSTEM_RESTART, + SYSTEM_SUSPEND_DISK, +} system_state; + +#define TAINT_PROPRIETARY_MODULE (1<<0) +#define TAINT_FORCED_MODULE (1<<1) +#define TAINT_UNSAFE_SMP (1<<2) +#define TAINT_FORCED_RMMOD (1<<3) +#define TAINT_MACHINE_CHECK (1<<4) +#define TAINT_BAD_PAGE (1<<5) + +extern void dump_stack(void); + +/* + * min()/max() macros that also do + * strict type-checking.. See the + * "unnecessary" pointer comparison. + */ +#define min(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + +#define max(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +/* + * ..and if you can't take the strict + * types, you can specify one yourself. + * + * Or not use min/max at all, of course. + */ +#define min_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) +#define max_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) + +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + +#define pr_debug(fmt,arg...) \ + do { } while (0) + +#define BUILD_BUG_ON(condition) \ + do { } while (0) + +#define BUILD_BUG_ON_ZERO(condition) \ + do { } while (0) + + +/* Trap pasters of __FUNCTION__ at compile-time */ +#define __FUNCTION__ (__func__) + +#endif diff --git a/ddverify/models/con2/include/linux/kobject.h b/ddverify/models/con2/include/linux/kobject.h new file mode 100644 index 000000000..4c1ba3fd0 --- /dev/null +++ b/ddverify/models/con2/include/linux/kobject.h @@ -0,0 +1,34 @@ +/* + * kobject.h - generic kernel object infrastructure. + * + * Copyright (c) 2002-2003 Patrick Mochel + * Copyright (c) 2002-2003 Open Source Development Labs + * + * This file is released under the GPLv2. + * + * + * Please read Documentation/kobject.txt before using the kobject + * interface, ESPECIALLY the parts about reference counts and object + * destructors. + */ + +#ifndef _KOBJECT_H_ +#define _KOBJECT_H_ + + +#include +#include +#include +#include +#include +//#include +//#include +#include +#include +#include + +struct kobject { + int something; +}; + +#endif /* _KOBJECT_H_ */ diff --git a/ddverify/models/con2/include/linux/kthread.h b/ddverify/models/con2/include/linux/kthread.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/list.h b/ddverify/models/con2/include/linux/list.h new file mode 100644 index 000000000..0132dfc43 --- /dev/null +++ b/ddverify/models/con2/include/linux/list.h @@ -0,0 +1,108 @@ +#ifndef _LINUX_LIST_H +#define _LINUX_LIST_H + +//#include +//#include +//#include +#include + +struct list_head { + struct list_head *next, *prev; +}; + +#define LIST_HEAD_INIT(name) { &(name), &(name) } + + +#define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + +static inline void INIT_LIST_HEAD(struct list_head *list) +{ + list->next = list; + list->prev = list; +} + +/** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop cursor. + * @head: the head for your list. + */ +#define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ +static inline void list_del_init(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); +} + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +#endif + + diff --git a/ddverify/models/con2/include/linux/major.h b/ddverify/models/con2/include/linux/major.h new file mode 100644 index 000000000..0a74c5292 --- /dev/null +++ b/ddverify/models/con2/include/linux/major.h @@ -0,0 +1,169 @@ +#ifndef _LINUX_MAJOR_H +#define _LINUX_MAJOR_H + +/* + * This file has definitions for major device numbers. + * For the device number assignments, see Documentation/devices.txt. + */ + +#define UNNAMED_MAJOR 0 +#define MEM_MAJOR 1 +#define RAMDISK_MAJOR 1 +#define FLOPPY_MAJOR 2 +#define PTY_MASTER_MAJOR 2 +#define IDE0_MAJOR 3 +#define HD_MAJOR IDE0_MAJOR +#define PTY_SLAVE_MAJOR 3 +#define TTY_MAJOR 4 +#define TTYAUX_MAJOR 5 +#define LP_MAJOR 6 +#define VCS_MAJOR 7 +#define LOOP_MAJOR 7 +#define SCSI_DISK0_MAJOR 8 +#define SCSI_TAPE_MAJOR 9 +#define MD_MAJOR 9 +#define MISC_MAJOR 10 +#define SCSI_CDROM_MAJOR 11 +#define MUX_MAJOR 11 /* PA-RISC only */ +#define XT_DISK_MAJOR 13 +#define INPUT_MAJOR 13 +#define SOUND_MAJOR 14 +#define CDU31A_CDROM_MAJOR 15 +#define JOYSTICK_MAJOR 15 +#define GOLDSTAR_CDROM_MAJOR 16 +#define OPTICS_CDROM_MAJOR 17 +#define SANYO_CDROM_MAJOR 18 +#define CYCLADES_MAJOR 19 +#define CYCLADESAUX_MAJOR 20 +#define MITSUMI_X_CDROM_MAJOR 20 +#define MFM_ACORN_MAJOR 21 /* ARM Linux /dev/mfm */ +#define SCSI_GENERIC_MAJOR 21 +#define IDE1_MAJOR 22 +#define DIGICU_MAJOR 22 +#define DIGI_MAJOR 23 +#define MITSUMI_CDROM_MAJOR 23 +#define CDU535_CDROM_MAJOR 24 +#define STL_SERIALMAJOR 24 +#define MATSUSHITA_CDROM_MAJOR 25 +#define STL_CALLOUTMAJOR 25 +#define MATSUSHITA_CDROM2_MAJOR 26 +#define QIC117_TAPE_MAJOR 27 +#define MATSUSHITA_CDROM3_MAJOR 27 +#define MATSUSHITA_CDROM4_MAJOR 28 +#define STL_SIOMEMMAJOR 28 +#define ACSI_MAJOR 28 +#define AZTECH_CDROM_MAJOR 29 +#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */ +#define CM206_CDROM_MAJOR 32 +#define IDE2_MAJOR 33 +#define IDE3_MAJOR 34 +#define Z8530_MAJOR 34 +#define XPRAM_MAJOR 35 /* Expanded storage on S/390: "slow ram"*/ +#define NETLINK_MAJOR 36 +#define PS2ESDI_MAJOR 36 +#define IDETAPE_MAJOR 37 +#define Z2RAM_MAJOR 37 +#define APBLOCK_MAJOR 38 /* AP1000 Block device */ +#define DDV_MAJOR 39 /* AP1000 DDV block device */ +#define NBD_MAJOR 43 /* Network block device */ +#define RISCOM8_NORMAL_MAJOR 48 +#define DAC960_MAJOR 48 /* 48..55 */ +#define RISCOM8_CALLOUT_MAJOR 49 +#define MKISS_MAJOR 55 +#define DSP56K_MAJOR 55 /* DSP56001 processor device */ + +#define IDE4_MAJOR 56 +#define IDE5_MAJOR 57 + +#define SCSI_DISK1_MAJOR 65 +#define SCSI_DISK2_MAJOR 66 +#define SCSI_DISK3_MAJOR 67 +#define SCSI_DISK4_MAJOR 68 +#define SCSI_DISK5_MAJOR 69 +#define SCSI_DISK6_MAJOR 70 +#define SCSI_DISK7_MAJOR 71 + +#define COMPAQ_SMART2_MAJOR 72 +#define COMPAQ_SMART2_MAJOR1 73 +#define COMPAQ_SMART2_MAJOR2 74 +#define COMPAQ_SMART2_MAJOR3 75 +#define COMPAQ_SMART2_MAJOR4 76 +#define COMPAQ_SMART2_MAJOR5 77 +#define COMPAQ_SMART2_MAJOR6 78 +#define COMPAQ_SMART2_MAJOR7 79 + +#define SPECIALIX_NORMAL_MAJOR 75 +#define SPECIALIX_CALLOUT_MAJOR 76 + +#define AURORA_MAJOR 79 + +#define I2O_MAJOR 80 /* 80->87 */ + +#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */ +#define SCSI_CHANGER_MAJOR 86 + +#define IDE6_MAJOR 88 +#define IDE7_MAJOR 89 +#define IDE8_MAJOR 90 +#define IDE9_MAJOR 91 + +#define DASD_MAJOR 94 + +#define MDISK_MAJOR 95 + +#define UBD_MAJOR 98 + +#define PP_MAJOR 99 +#define JSFD_MAJOR 99 + +#define PHONE_MAJOR 100 + +#define COMPAQ_CISS_MAJOR 104 +#define COMPAQ_CISS_MAJOR1 105 +#define COMPAQ_CISS_MAJOR2 106 +#define COMPAQ_CISS_MAJOR3 107 +#define COMPAQ_CISS_MAJOR4 108 +#define COMPAQ_CISS_MAJOR5 109 +#define COMPAQ_CISS_MAJOR6 110 +#define COMPAQ_CISS_MAJOR7 111 + +#define VIODASD_MAJOR 112 +#define VIOCD_MAJOR 113 + +#define ATARAID_MAJOR 114 + +#define SCSI_DISK8_MAJOR 128 +#define SCSI_DISK9_MAJOR 129 +#define SCSI_DISK10_MAJOR 130 +#define SCSI_DISK11_MAJOR 131 +#define SCSI_DISK12_MAJOR 132 +#define SCSI_DISK13_MAJOR 133 +#define SCSI_DISK14_MAJOR 134 +#define SCSI_DISK15_MAJOR 135 + +#define UNIX98_PTY_MASTER_MAJOR 128 +#define UNIX98_PTY_MAJOR_COUNT 8 +#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT) + +#define RTF_MAJOR 150 +#define RAW_MAJOR 162 + +#define USB_ACM_MAJOR 166 +#define USB_ACM_AUX_MAJOR 167 +#define USB_CHAR_MAJOR 180 + +#define VXVM_MAJOR 199 /* VERITAS volume i/o driver */ +#define VXSPEC_MAJOR 200 /* VERITAS volume config driver */ +#define VXDMP_MAJOR 201 /* VERITAS volume multipath driver */ + +#define MSR_MAJOR 202 +#define CPUID_MAJOR 203 + +#define OSST_MAJOR 206 /* OnStream-SCx0 SCSI tape */ + +#define IBM_TTY3270_MAJOR 227 +#define IBM_FS3270_MAJOR 228 + +#define VIOTAPE_MAJOR 230 + +#endif diff --git a/ddverify/models/con2/include/linux/mc146818rtc.h b/ddverify/models/con2/include/linux/mc146818rtc.h new file mode 100644 index 000000000..38ed29876 --- /dev/null +++ b/ddverify/models/con2/include/linux/mc146818rtc.h @@ -0,0 +1,87 @@ +#ifndef _MC146818RTC_H +#define _MC146818RTC_H + +#include +#include /* get the user-level API */ +#include /* register access macros */ + +#include /* spinlock_t */ +extern spinlock_t rtc_lock; /* serialize CMOS RAM access */ + +/********************************************************************** + * register summary + **********************************************************************/ +#define RTC_SECONDS 0 +#define RTC_SECONDS_ALARM 1 +#define RTC_MINUTES 2 +#define RTC_MINUTES_ALARM 3 +#define RTC_HOURS 4 +#define RTC_HOURS_ALARM 5 +/* RTC_*_alarm is always true if 2 MSBs are set */ +# define RTC_ALARM_DONT_CARE 0xC0 + +#define RTC_DAY_OF_WEEK 6 +#define RTC_DAY_OF_MONTH 7 +#define RTC_MONTH 8 +#define RTC_YEAR 9 + +/* control registers - Moto names + */ +#define RTC_REG_A 10 +#define RTC_REG_B 11 +#define RTC_REG_C 12 +#define RTC_REG_D 13 + +/********************************************************************** + * register details + **********************************************************************/ +#define RTC_FREQ_SELECT RTC_REG_A + +/* update-in-progress - set to "1" 244 microsecs before RTC goes off the bus, + * reset after update (may take 1.984ms @ 32768Hz RefClock) is complete, + * totalling to a max high interval of 2.228 ms. + */ +# define RTC_UIP 0x80 +# define RTC_DIV_CTL 0x70 + /* divider control: refclock values 4.194 / 1.049 MHz / 32.768 kHz */ +# define RTC_REF_CLCK_4MHZ 0x00 +# define RTC_REF_CLCK_1MHZ 0x10 +# define RTC_REF_CLCK_32KHZ 0x20 + /* 2 values for divider stage reset, others for "testing purposes only" */ +# define RTC_DIV_RESET1 0x60 +# define RTC_DIV_RESET2 0x70 + /* Periodic intr. / Square wave rate select. 0=none, 1=32.8kHz,... 15=2Hz */ +# define RTC_RATE_SELECT 0x0F + +/**********************************************************************/ +#define RTC_CONTROL RTC_REG_B +# define RTC_SET 0x80 /* disable updates for clock setting */ +# define RTC_PIE 0x40 /* periodic interrupt enable */ +# define RTC_AIE 0x20 /* alarm interrupt enable */ +# define RTC_UIE 0x10 /* update-finished interrupt enable */ +# define RTC_SQWE 0x08 /* enable square-wave output */ +# define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +# define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +# define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +/**********************************************************************/ +#define RTC_INTR_FLAGS RTC_REG_C +/* caution - cleared by read */ +# define RTC_IRQF 0x80 /* any of the following 3 is active */ +# define RTC_PF 0x40 +# define RTC_AF 0x20 +# define RTC_UF 0x10 + +/**********************************************************************/ +#define RTC_VALID RTC_REG_D +# define RTC_VRT 0x80 /* valid RAM and time */ +/**********************************************************************/ + +#ifndef ARCH_RTC_LOCATION /* Override by ? */ + +#define RTC_IO_EXTENT 0x8 +#define RTC_IOMAPPED 1 /* Default to I/O mapping. */ + +#endif /* ARCH_RTC_LOCATION */ + +#endif /* _MC146818RTC_H */ diff --git a/ddverify/models/con2/include/linux/mempool.h b/ddverify/models/con2/include/linux/mempool.h new file mode 100644 index 000000000..dd86176f1 --- /dev/null +++ b/ddverify/models/con2/include/linux/mempool.h @@ -0,0 +1,11 @@ +/* + * memory buffer pool support + */ +#ifndef _LINUX_MEMPOOL_H +#define _LINUX_MEMPOOL_H + +#include + + + +#endif /* _LINUX_MEMPOOL_H */ diff --git a/ddverify/models/con2/include/linux/miscdevice.h b/ddverify/models/con2/include/linux/miscdevice.h new file mode 100644 index 000000000..1b6241373 --- /dev/null +++ b/ddverify/models/con2/include/linux/miscdevice.h @@ -0,0 +1,43 @@ +#ifndef _LINUX_MISCDEVICE_H +#define _LINUX_MISCDEVICE_H +#include +#include + +#define PSMOUSE_MINOR 1 +#define MS_BUSMOUSE_MINOR 2 +#define ATIXL_BUSMOUSE_MINOR 3 +/*#define AMIGAMOUSE_MINOR 4 FIXME OBSOLETE */ +#define ATARIMOUSE_MINOR 5 +#define SUN_MOUSE_MINOR 6 +#define APOLLO_MOUSE_MINOR 7 +#define PC110PAD_MINOR 9 +/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */ +#define WATCHDOG_MINOR 130 /* Watchdog timer */ +#define TEMP_MINOR 131 /* Temperature Sensor */ +#define RTC_MINOR 135 +#define EFI_RTC_MINOR 136 /* EFI Time services */ +#define SUN_OPENPROM_MINOR 139 +#define DMAPI_MINOR 140 /* DMAPI */ +#define NVRAM_MINOR 144 +#define SGI_MMTIMER 153 +#define STORE_QUEUE_MINOR 155 +#define I2O_MINOR 166 +#define MICROCODE_MINOR 184 +#define MWAVE_MINOR 219 /* ACP/Mwave Modem */ +#define MPT_MINOR 220 +#define MISC_DYNAMIC_MINOR 255 + +#define TUN_MINOR 200 +#define HPET_MINOR 228 + + +struct miscdevice { + int minor; + const char *name; + struct file_operations *fops; +}; + +extern int misc_register(struct miscdevice * misc); +extern int misc_deregister(struct miscdevice * misc); + +#endif diff --git a/ddverify/models/con2/include/linux/mm.h b/ddverify/models/con2/include/linux/mm.h new file mode 100644 index 000000000..4bbf229f1 --- /dev/null +++ b/ddverify/models/con2/include/linux/mm.h @@ -0,0 +1,17 @@ +#ifndef _LINUX_MM_H +#define _LINUX_MM_H + +#include +#include +#include + +#include +#include +#include +#include + +#include + +void *page_address(struct page *page); + +#endif /* _LINUX_MM_H */ diff --git a/ddverify/models/con2/include/linux/mm_types.h b/ddverify/models/con2/include/linux/mm_types.h new file mode 100644 index 000000000..0645b00a5 --- /dev/null +++ b/ddverify/models/con2/include/linux/mm_types.h @@ -0,0 +1,14 @@ +#ifndef _LINUX_MM_TYPES_H +#define _LINUX_MM_TYPES_H + +#include +//#include +#include +#include + +struct page { + int something; +}; + +#endif /* _LINUX_MM_TYPES_H */ + diff --git a/ddverify/models/con2/include/linux/mman.h b/ddverify/models/con2/include/linux/mman.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/mmzone.h b/ddverify/models/con2/include/linux/mmzone.h new file mode 100644 index 000000000..709447587 --- /dev/null +++ b/ddverify/models/con2/include/linux/mmzone.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_MMZONE_H +#define _LINUX_MMZONE_H + +#include +#include +//#include +#include +//#include +#include +//#include +#include +//#include +#include + +#endif /* _LINUX_MMZONE_H */ + diff --git a/ddverify/models/con2/include/linux/mod_devicetable.h b/ddverify/models/con2/include/linux/mod_devicetable.h new file mode 100644 index 000000000..0c41094d7 --- /dev/null +++ b/ddverify/models/con2/include/linux/mod_devicetable.h @@ -0,0 +1,18 @@ +#ifndef LINUX_MOD_DEVICETABLE_H +#define LINUX_MOD_DEVICETABLE_H + +#include + +typedef unsigned long kernel_ulong_t; + +#define PCI_ANY_ID (~0) + +struct pci_device_id { + __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/ + __u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ + __u32 class, class_mask; /* (class,subclass,prog-if) triplet */ + kernel_ulong_t driver_data; /* Data private to the driver */ +}; + +#endif /* LINUX_MOD_DEVICETABLE_H */ + diff --git a/ddverify/models/con2/include/linux/module.h b/ddverify/models/con2/include/linux/module.h new file mode 100644 index 000000000..e911d572d --- /dev/null +++ b/ddverify/models/con2/include/linux/module.h @@ -0,0 +1,32 @@ +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H + +#include +#include +#include +#include +#include +#include + +#define MODULE_AUTHOR(_author) char _ddv_module_author[] = _author +#define MODULE_LICENSE(_license) char _ddv_module_license[] = _license +#define MODULE_DESCRIPTION(_description) char _ddv_module_description[] = _description +#define MODULE_SUPPORTED_DEVICE(_device) char _ddv_module_supported_device[] = _device +#define MODULE_PARM_DESC(_param, _description) char _ddv_module_param_##_param [] = _description +#define MODULE_ALIAS(_whatever) void +#define MODULE_ALIAS_CHARDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_BLOCKDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_MISCDEV(_dev) void +#define MODULE_DEVICE_TABLE(type,name) void + +#define THIS_MODULE ((struct module *) 0) + +struct module { + int something; +}; + +#define __MODULE_STRING(x) #x + +void __module_get(struct module *module); + +#endif diff --git a/ddverify/models/con2/include/linux/moduleparam.h b/ddverify/models/con2/include/linux/moduleparam.h new file mode 100644 index 000000000..8df1e77e0 --- /dev/null +++ b/ddverify/models/con2/include/linux/moduleparam.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_MODULE_PARAMS_H +#define _LINUX_MODULE_PARAMS_H + +#include +#include +#include + +#define module_param(var, type, arg) void +#define module_param_named(name, var, type, arg) void +#define module_param_array(name, type, nump, perm) void + +#endif diff --git a/ddverify/models/con2/include/linux/mutex.h b/ddverify/models/con2/include/linux/mutex.h new file mode 100644 index 000000000..7298d3300 --- /dev/null +++ b/ddverify/models/con2/include/linux/mutex.h @@ -0,0 +1,38 @@ +/* + * Mutexes: blocking mutual exclusion locks + * + * started by Ingo Molnar: + * + * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar + * + * This file contains the main data structure and API definitions. + */ +#ifndef __LINUX_MUTEX_H +#define __LINUX_MUTEX_H + +#include +#include +//#include +//#include + +#include + +struct mutex { + int locked; + int init; +}; + +#define __MUTEX_INITIALIZER(lockname) \ + { .locked = 0, .init = 1 } + +#define DEFINE_MUTEX(mutexname) \ + struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) + +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_init(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_lock(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_unlock(struct mutex *lock); + +#endif diff --git a/ddverify/models/con2/include/linux/net.h b/ddverify/models/con2/include/linux/net.h new file mode 100644 index 000000000..1339d2421 --- /dev/null +++ b/ddverify/models/con2/include/linux/net.h @@ -0,0 +1,19 @@ +#ifndef _LINUX_NET_H +#define _LINUX_NET_H + +struct socket { + const struct proto_ops *ops; + struct sock *sk; +}; + +struct proto_ops { + int (*shutdown) (struct socket *sock, int flags); +}; + +extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, size_t len); +extern int kernel_recvmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, + size_t len, int flags); + +#endif /* _LINUX_NET_H */ diff --git a/ddverify/models/con2/include/linux/netdevice.h b/ddverify/models/con2/include/linux/netdevice.h new file mode 100644 index 000000000..f90cdbfa3 --- /dev/null +++ b/ddverify/models/con2/include/linux/netdevice.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_NETDEVICE_H +#define _LINUX_NETDEVICE_H + +#include + +#endif /* _LINUX_DEV_H */ diff --git a/ddverify/models/con2/include/linux/notifier.h b/ddverify/models/con2/include/linux/notifier.h new file mode 100644 index 000000000..1029f233e --- /dev/null +++ b/ddverify/models/con2/include/linux/notifier.h @@ -0,0 +1,61 @@ +/* + * Routines to manage notifier chains for passing status changes to any + * interested routines. We need this instead of hard coded call lists so + * that modules can poke their nose into the innards. The network devices + * needed them so here they are for the rest of you. + * + * Alan Cox + */ + +#ifndef _LINUX_NOTIFIER_H +#define _LINUX_NOTIFIER_H +#include + + +struct notifier_block +{ + int (*notifier_call)(struct notifier_block *self, unsigned long, void *); + struct notifier_block *next; + int priority; +}; + +#define NOTIFY_DONE 0x0000 /* Don't care */ +#define NOTIFY_OK 0x0001 /* Suits me */ +#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ +#define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */ +/* + * Clean way to return from the notifier and stop further calls. + */ +#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) + +/* netdevice notifier chain */ +#define NETDEV_UP 0x0001 /* For now you can't veto a device up/down */ +#define NETDEV_DOWN 0x0002 +#define NETDEV_REBOOT 0x0003 /* Tell a protocol stack a network interface + detected a hardware crash and restarted + - we can use this eg to kick tcp sessions + once done */ +#define NETDEV_CHANGE 0x0004 /* Notify device state change */ +#define NETDEV_REGISTER 0x0005 +#define NETDEV_UNREGISTER 0x0006 +#define NETDEV_CHANGEMTU 0x0007 +#define NETDEV_CHANGEADDR 0x0008 +#define NETDEV_GOING_DOWN 0x0009 +#define NETDEV_CHANGENAME 0x000A +#define NETDEV_FEAT_CHANGE 0x000B + +#define SYS_DOWN 0x0001 /* Notify of system down */ +#define SYS_RESTART SYS_DOWN +#define SYS_HALT 0x0002 /* Notify of system halt */ +#define SYS_POWER_OFF 0x0003 /* Notify of system power off */ + +#define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */ + +#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ +#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ +#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ +#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ +#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ +#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ + +#endif /* _LINUX_NOTIFIER_H */ diff --git a/ddverify/models/con2/include/linux/pagemap.h b/ddverify/models/con2/include/linux/pagemap.h new file mode 100644 index 000000000..0525a9fc0 --- /dev/null +++ b/ddverify/models/con2/include/linux/pagemap.h @@ -0,0 +1,15 @@ +#ifndef _LINUX_PAGEMAP_H +#define _LINUX_PAGEMAP_H + +/* + * Copyright 1995 Linus Torvalds + */ +#include +#include +#include +#include +#include +#include +#include + +#endif /* _LINUX_PAGEMAP_H */ diff --git a/ddverify/models/con2/include/linux/parport.h b/ddverify/models/con2/include/linux/parport.h new file mode 100644 index 000000000..4e29e513d --- /dev/null +++ b/ddverify/models/con2/include/linux/parport.h @@ -0,0 +1,559 @@ +/* $Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea $ */ + +/* + * Any part of this program may be used in documents licensed under + * the GNU Free Documentation License, Version 1.1 or any later version + * published by the Free Software Foundation. + */ + +#ifndef _PARPORT_H_ +#define _PARPORT_H_ + +/* Start off with user-visible constants */ + +/* Maximum of 16 ports per machine */ +#define PARPORT_MAX 16 + +/* Magic numbers */ +#define PARPORT_IRQ_NONE -1 +#define PARPORT_DMA_NONE -1 +#define PARPORT_IRQ_AUTO -2 +#define PARPORT_DMA_AUTO -2 +#define PARPORT_DMA_NOFIFO -3 +#define PARPORT_DISABLE -2 +#define PARPORT_IRQ_PROBEONLY -3 +#define PARPORT_IOHI_AUTO -1 + +#define PARPORT_CONTROL_STROBE 0x1 +#define PARPORT_CONTROL_AUTOFD 0x2 +#define PARPORT_CONTROL_INIT 0x4 +#define PARPORT_CONTROL_SELECT 0x8 + +#define PARPORT_STATUS_ERROR 0x8 +#define PARPORT_STATUS_SELECT 0x10 +#define PARPORT_STATUS_PAPEROUT 0x20 +#define PARPORT_STATUS_ACK 0x40 +#define PARPORT_STATUS_BUSY 0x80 + +/* Type classes for Plug-and-Play probe. */ +typedef enum { + PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */ + PARPORT_CLASS_PRINTER, + PARPORT_CLASS_MODEM, + PARPORT_CLASS_NET, + PARPORT_CLASS_HDC, /* Hard disk controller */ + PARPORT_CLASS_PCMCIA, + PARPORT_CLASS_MEDIA, /* Multimedia device */ + PARPORT_CLASS_FDC, /* Floppy disk controller */ + PARPORT_CLASS_PORTS, + PARPORT_CLASS_SCANNER, + PARPORT_CLASS_DIGCAM, + PARPORT_CLASS_OTHER, /* Anything else */ + PARPORT_CLASS_UNSPEC, /* No CLS field in ID */ + PARPORT_CLASS_SCSIADAPTER +} parport_device_class; + +/* The "modes" entry in parport is a bit field representing the + capabilities of the hardware. */ +#define PARPORT_MODE_PCSPP (1<<0) /* IBM PC registers available. */ +#define PARPORT_MODE_TRISTATE (1<<1) /* Can tristate. */ +#define PARPORT_MODE_EPP (1<<2) /* Hardware EPP. */ +#define PARPORT_MODE_ECP (1<<3) /* Hardware ECP. */ +#define PARPORT_MODE_COMPAT (1<<4) /* Hardware 'printer protocol'. */ +#define PARPORT_MODE_DMA (1<<5) /* Hardware can DMA. */ +#define PARPORT_MODE_SAFEININT (1<<6) /* SPP registers accessible in IRQ. */ + +/* IEEE1284 modes: + Nibble mode, byte mode, ECP, ECPRLE and EPP are their own + 'extensibility request' values. Others are special. + 'Real' ECP modes must have the IEEE1284_MODE_ECP bit set. */ +#define IEEE1284_MODE_NIBBLE 0 +#define IEEE1284_MODE_BYTE (1<<0) +#define IEEE1284_MODE_COMPAT (1<<8) +#define IEEE1284_MODE_BECP (1<<9) /* Bounded ECP mode */ +#define IEEE1284_MODE_ECP (1<<4) +#define IEEE1284_MODE_ECPRLE (IEEE1284_MODE_ECP | (1<<5)) +#define IEEE1284_MODE_ECPSWE (1<<10) /* Software-emulated */ +#define IEEE1284_MODE_EPP (1<<6) +#define IEEE1284_MODE_EPPSL (1<<11) /* EPP 1.7 */ +#define IEEE1284_MODE_EPPSWE (1<<12) /* Software-emulated */ +#define IEEE1284_DEVICEID (1<<2) /* This is a flag */ +#define IEEE1284_EXT_LINK (1<<14) /* This flag causes the + * extensibility link to + * be requested, using + * bits 0-6. */ + +/* For the benefit of parport_read/write, you can use these with + * parport_negotiate to use address operations. They have no effect + * other than to make parport_read/write use address transfers. */ +#define IEEE1284_ADDR (1<<13) /* This is a flag */ +#define IEEE1284_DATA 0 /* So is this */ + +/* Flags for block transfer operations. */ +#define PARPORT_EPP_FAST (1<<0) /* Unreliable counts. */ +#define PARPORT_W91284PIC (1<<1) /* have a Warp9 w91284pic in the device */ + +#include +#include +#include +#include +#include +#include +#include + +/* Define this later. */ +struct parport; +struct pardevice; + +struct pc_parport_state { + unsigned int ctr; + unsigned int ecr; +}; + +struct ax_parport_state { + unsigned int ctr; + unsigned int ecr; + unsigned int dcsr; +}; + +/* used by both parport_amiga and parport_mfc3 */ +struct amiga_parport_state { + unsigned char data; /* ciaa.prb */ + unsigned char datadir; /* ciaa.ddrb */ + unsigned char status; /* ciab.pra & 7 */ + unsigned char statusdir;/* ciab.ddrb & 7 */ +}; + +struct ax88796_parport_state { + unsigned char cpr; +}; + +struct ip32_parport_state { + unsigned int dcr; + unsigned int ecr; +}; + +struct parport_state { + union { + struct pc_parport_state pc; + /* ARC has no state. */ + struct ax_parport_state ax; + struct amiga_parport_state amiga; + struct ax88796_parport_state ax88796; + /* Atari has not state. */ + struct ip32_parport_state ip32; + void *misc; + } u; +}; + +struct parport_operations { + /* IBM PC-style virtual registers. */ + void (*write_data)(struct parport *, unsigned char); + unsigned char (*read_data)(struct parport *); + + void (*write_control)(struct parport *, unsigned char); + unsigned char (*read_control)(struct parport *); + unsigned char (*frob_control)(struct parport *, unsigned char mask, + unsigned char val); + + unsigned char (*read_status)(struct parport *); + + /* IRQs. */ + void (*enable_irq)(struct parport *); + void (*disable_irq)(struct parport *); + + /* Data direction. */ + void (*data_forward) (struct parport *); + void (*data_reverse) (struct parport *); + + /* For core parport code. */ + void (*init_state)(struct pardevice *, struct parport_state *); + void (*save_state)(struct parport *, struct parport_state *); + void (*restore_state)(struct parport *, struct parport_state *); + + /* Block read/write */ + size_t (*epp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*epp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_addr) (struct parport *port, void *buf, size_t len, + int flags); + + size_t (*ecp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*ecp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*ecp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + + size_t (*compat_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*nibble_read_data) (struct parport *port, void *buf, + size_t len, int flags); + size_t (*byte_read_data) (struct parport *port, void *buf, + size_t len, int flags); + struct module *owner; +}; + +struct parport_device_info { + parport_device_class class; + const char *class_name; + const char *mfr; + const char *model; + const char *cmdset; + const char *description; +}; + +/* Each device can have two callback functions: + * 1) a preemption function, called by the resource manager to request + * that the driver relinquish control of the port. The driver should + * return zero if it agrees to release the port, and nonzero if it + * refuses. Do not call parport_release() - the kernel will do this + * implicitly. + * + * 2) a wake-up function, called by the resource manager to tell drivers + * that the port is available to be claimed. If a driver wants to use + * the port, it should call parport_claim() here. + */ + +/* A parallel port device */ +struct pardevice { + const char *name; + struct parport *port; + int daisy; + int (*preempt)(void *); + void (*wakeup)(void *); + void *private; + void (*irq_func)(int, void *); + unsigned int flags; + struct pardevice *next; + struct pardevice *prev; + struct parport_state *state; /* saved status over preemption */ + wait_queue_head_t wait_q; + unsigned long int time; + unsigned long int timeslice; + volatile long int timeout; + unsigned long waiting; /* long req'd for set_bit --RR */ + struct pardevice *waitprev; + struct pardevice *waitnext; + void * sysctl_table; +}; + +/* IEEE1284 information */ + +/* IEEE1284 phases. These are exposed to userland through ppdev IOCTL + * PP[GS]ETPHASE, so do not change existing values. */ +enum ieee1284_phase { + IEEE1284_PH_FWD_DATA, + IEEE1284_PH_FWD_IDLE, + IEEE1284_PH_TERMINATE, + IEEE1284_PH_NEGOTIATION, + IEEE1284_PH_HBUSY_DNA, + IEEE1284_PH_REV_IDLE, + IEEE1284_PH_HBUSY_DAVAIL, + IEEE1284_PH_REV_DATA, + IEEE1284_PH_ECP_SETUP, + IEEE1284_PH_ECP_FWD_TO_REV, + IEEE1284_PH_ECP_REV_TO_FWD, + IEEE1284_PH_ECP_DIR_UNKNOWN, +}; +struct ieee1284_info { + int mode; + volatile enum ieee1284_phase phase; + struct semaphore irq; +}; + +/* A parallel port */ +struct parport { + unsigned long base; /* base address */ + unsigned long base_hi; /* base address (hi - ECR) */ + unsigned int size; /* IO extent */ + const char *name; + unsigned int modes; + int irq; /* interrupt (or -1 for none) */ + int dma; + int muxport; /* which muxport (if any) this is */ + int portnum; /* which physical parallel port (not mux) */ + + struct parport *physport; + /* If this is a non-default mux + parport, i.e. we're a clone of a real + physical port, this is a pointer to that + port. The locking is only done in the + real port. For a clone port, the + following structure members are + meaningless: devices, cad, muxsel, + waithead, waittail, flags, pdir, + ieee1284, *_lock. + + It this is a default mux parport, or + there is no mux involved, this points to + ourself. */ + + struct pardevice *devices; + struct pardevice *cad; /* port owner */ + int daisy; /* currently selected daisy addr */ + int muxsel; /* currently selected mux port */ + + struct pardevice *waithead; + struct pardevice *waittail; + + struct list_head list; + unsigned int flags; + + void *sysctl_table; + struct parport_device_info probe_info[5]; /* 0-3 + non-IEEE1284.3 */ + struct ieee1284_info ieee1284; + + struct parport_operations *ops; + void *private_data; /* for lowlevel driver */ + + int number; /* port index - the `n' in `parportn' */ + spinlock_t pardevice_lock; + spinlock_t waitlist_lock; + rwlock_t cad_lock; + + int spintime; + atomic_t ref_count; + + struct list_head full_list; + struct parport *slaves[3]; +}; + +#define DEFAULT_SPIN_TIME 500 /* us */ + +struct parport_driver { + const char *name; + void (*attach) (struct parport *); + void (*detach) (struct parport *); + struct list_head list; +}; + +/* parport_register_port registers a new parallel port at the given + address (if one does not already exist) and returns a pointer to it. + This entails claiming the I/O region, IRQ and DMA. NULL is returned + if initialisation fails. */ +struct parport *parport_register_port(unsigned long base, int irq, int dma, + struct parport_operations *ops); + +/* Once a registered port is ready for high-level drivers to use, the + low-level driver that registered it should announce it. This will + call the high-level drivers' attach() functions (after things like + determining the IEEE 1284.3 topology of the port and collecting + DeviceIDs). */ +void parport_announce_port (struct parport *port); + +/* Unregister a port. */ +extern void parport_remove_port(struct parport *port); + +/* Register a new high-level driver. */ +extern int parport_register_driver (struct parport_driver *); + +/* Unregister a high-level driver. */ +extern void parport_unregister_driver (struct parport_driver *); + +/* If parport_register_driver doesn't fit your needs, perhaps + * parport_find_xxx does. */ +extern struct parport *parport_find_number (int); +extern struct parport *parport_find_base (unsigned long); + +/* Reference counting for ports. */ +extern struct parport *parport_get_port (struct parport *); +extern void parport_put_port (struct parport *); + +/* parport_register_device declares that a device is connected to a + port, and tells the kernel all it needs to know. + - pf is the preemption function (may be NULL for no callback) + - kf is the wake-up function (may be NULL for no callback) + - irq_func is the interrupt handler (may be NULL for no interrupts) + - handle is a user pointer that gets handed to callback functions. */ +struct pardevice *parport_register_device(struct parport *port, + const char *name, + int (*pf)(void *), void (*kf)(void *), + void (*irq_func)(int, void *), + int flags, void *handle); + +/* parport_unregister unlinks a device from the chain. */ +extern void parport_unregister_device(struct pardevice *dev); + +/* parport_claim tries to gain ownership of the port for a particular + driver. This may fail (return non-zero) if another driver is busy. + If this driver has registered an interrupt handler, it will be + enabled. */ +extern int parport_claim(struct pardevice *dev); + +/* parport_claim_or_block is the same, but sleeps if the port cannot + be claimed. Return value is 1 if it slept, 0 normally and -errno + on error. */ +extern int parport_claim_or_block(struct pardevice *dev); + +/* parport_release reverses a previous parport_claim. This can never + fail, though the effects are undefined (except that they are bad) + if you didn't previously own the port. Once you have released the + port you should make sure that neither your code nor the hardware + on the port tries to initiate any communication without first + re-claiming the port. If you mess with the port state (enabling + ECP for example) you should clean up before releasing the port. */ + +extern void parport_release(struct pardevice *dev); + +/** + * parport_yield - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim(), and the return value is the same as for + * parport_claim(). If it fails, the port is left unclaimed and it is + * the driver's responsibility to reclaim the port. + * + * The parport_yield() and parport_yield_blocking() functions are for + * marking points in the driver at which other drivers may claim the + * port and use their devices. Yielding the port is similar to + * releasing it and reclaiming it, but is more efficient because no + * action is taken if there are no other devices needing the port. In + * fact, nothing is done even if there are other devices waiting but + * the current device is still within its "timeslice". The default + * timeslice is half a second, but it can be adjusted via the /proc + * interface. + **/ +static __inline__ int parport_yield(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim(dev); +} + +/** + * parport_yield_blocking - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim_or_block(), and the return value is the same as for + * parport_claim_or_block(). + **/ +static __inline__ int parport_yield_blocking(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim_or_block(dev); +} + +/* Flags used to identify what a device does. */ +#define PARPORT_DEV_TRAN 0 /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_LURK (1<<0) /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_EXCL (1<<1) /* Need exclusive access. */ + +#define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */ + +/* IEEE1284 functions */ +extern void parport_ieee1284_interrupt (int, void *); +extern int parport_negotiate (struct parport *, int mode); +extern ssize_t parport_write (struct parport *, const void *buf, size_t len); +extern ssize_t parport_read (struct parport *, void *buf, size_t len); + +#define PARPORT_INACTIVITY_O_NONBLOCK 1 +extern long parport_set_timeout (struct pardevice *, long inactivity); + +extern int parport_wait_event (struct parport *, long timeout); +extern int parport_wait_peripheral (struct parport *port, + unsigned char mask, + unsigned char val); +extern int parport_poll_peripheral (struct parport *port, + unsigned char mask, + unsigned char val, + int usec); + +/* For architectural drivers */ +extern size_t parport_ieee1284_write_compat (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_read_nibble (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_read_byte (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_epp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_addr (struct parport *, + void *, size_t, int); + +/* IEEE1284.3 functions */ +extern int parport_daisy_init (struct parport *port); +extern void parport_daisy_fini (struct parport *port); +extern struct pardevice *parport_open (int devnum, const char *name, + int (*pf) (void *), + void (*kf) (void *), + void (*irqf) (int, void *), + int flags, void *handle); +extern void parport_close (struct pardevice *dev); +extern ssize_t parport_device_id (int devnum, char *buffer, size_t len); +extern int parport_device_num (int parport, int mux, int daisy); +extern void parport_daisy_deselect_all (struct parport *port); +extern int parport_daisy_select (struct parport *port, int daisy, int mode); + +/* Lowlevel drivers _can_ call this support function to handle irqs. */ +/* +static __inline__ void parport_generic_irq(int irq, struct parport *port) +{ + parport_ieee1284_interrupt (irq, port); + read_lock(&port->cad_lock); + if (port->cad && port->cad->irq_func) + port->cad->irq_func(irq, port->cad->private); + read_unlock(&port->cad_lock); +} +*/ + +/* Prototypes from parport_procfs */ +extern int parport_proc_register(struct parport *pp); +extern int parport_proc_unregister(struct parport *pp); +extern int parport_device_proc_register(struct pardevice *device); +extern int parport_device_proc_unregister(struct pardevice *device); + +/* If PC hardware is the only type supported, we can optimise a bit. */ +#if !defined(CONFIG_PARPORT_NOT_PC) + +#include +#define parport_write_data(p,x) parport_pc_write_data(p,x) +#define parport_read_data(p) parport_pc_read_data(p) +#define parport_write_control(p,x) parport_pc_write_control(p,x) +#define parport_read_control(p) parport_pc_read_control(p) +#define parport_frob_control(p,m,v) parport_pc_frob_control(p,m,v) +#define parport_read_status(p) parport_pc_read_status(p) +#define parport_enable_irq(p) parport_pc_enable_irq(p) +#define parport_disable_irq(p) parport_pc_disable_irq(p) +#define parport_data_forward(p) parport_pc_data_forward(p) +#define parport_data_reverse(p) parport_pc_data_reverse(p) + +#else /* !CONFIG_PARPORT_NOT_PC */ + +/* Generic operations vector through the dispatch table. */ +#define parport_write_data(p,x) (p)->ops->write_data(p,x) +#define parport_read_data(p) (p)->ops->read_data(p) +#define parport_write_control(p,x) (p)->ops->write_control(p,x) +#define parport_read_control(p) (p)->ops->read_control(p) +#define parport_frob_control(p,m,v) (p)->ops->frob_control(p,m,v) +#define parport_read_status(p) (p)->ops->read_status(p) +#define parport_enable_irq(p) (p)->ops->enable_irq(p) +#define parport_disable_irq(p) (p)->ops->disable_irq(p) +#define parport_data_forward(p) (p)->ops->data_forward(p) +#define parport_data_reverse(p) (p)->ops->data_reverse(p) + +#endif /* !CONFIG_PARPORT_NOT_PC */ + +#endif /* _PARPORT_H_ */ diff --git a/ddverify/models/con2/include/linux/parport_pc.h b/ddverify/models/con2/include/linux/parport_pc.h new file mode 100644 index 000000000..1c6df907d --- /dev/null +++ b/ddverify/models/con2/include/linux/parport_pc.h @@ -0,0 +1,42 @@ +#ifndef __LINUX_PARPORT_PC_H +#define __LINUX_PARPORT_PC_H + +#include + +/* --- register definitions ------------------------------- */ + +#define ECONTROL(p) ((p)->base_hi + 0x2) +#define CONFIGB(p) ((p)->base_hi + 0x1) +#define CONFIGA(p) ((p)->base_hi + 0x0) +#define FIFO(p) ((p)->base_hi + 0x0) +#define EPPDATA(p) ((p)->base + 0x4) +#define EPPADDR(p) ((p)->base + 0x3) +#define CONTROL(p) ((p)->base + 0x2) +#define STATUS(p) ((p)->base + 0x1) +#define DATA(p) ((p)->base + 0x0) + +struct parport_pc_private { + int something; +}; + +struct parport_pc_via_data +{ + int something; +}; + +void parport_pc_write_data(struct parport *p, unsigned char d); +unsigned char parport_pc_read_data(struct parport *p); +void parport_pc_data_reverse (struct parport *p); +void parport_pc_data_forward (struct parport *p); +void parport_pc_write_control (struct parport *p, unsigned char d); +unsigned char parport_pc_read_control(struct parport *p); +unsigned char parport_pc_frob_control (struct parport *p, + unsigned char mask, + unsigned char val); +unsigned char parport_pc_read_status(struct parport *p); +void parport_pc_disable_irq(struct parport *p); +void parport_pc_enable_irq(struct parport *p); +void parport_pc_release_resources(struct parport *p); +int parport_pc_claim_resources(struct parport *p); + +#endif diff --git a/ddverify/models/con2/include/linux/pci.h b/ddverify/models/con2/include/linux/pci.h new file mode 100644 index 000000000..e2076f1a4 --- /dev/null +++ b/ddverify/models/con2/include/linux/pci.h @@ -0,0 +1,176 @@ +#ifndef LINUX_PCI_H +#define LINUX_PCI_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Include the pci register defines */ +#include + +/* Include the ID list */ +#include + +/* + * The PCI interface treats multi-function devices as independent + * devices. The slot/function address of each device is encoded + * in a single byte as follows: + * + * 7:3 = slot + * 2:0 = function + */ +#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) +#define PCI_FUNC(devfn) ((devfn) & 0x07) + +/* This defines the direction arg to the DMA mapping routines. */ +#define PCI_DMA_BIDIRECTIONAL 0 +#define PCI_DMA_TODEVICE 1 +#define PCI_DMA_FROMDEVICE 2 +#define PCI_DMA_NONE 3 + +#define DEVICE_COUNT_COMPATIBLE 4 +#define DEVICE_COUNT_RESOURCE 12 + +typedef int __bitwise pci_power_t; + + +struct pci_dev { + struct pci_bus *bus; /* bus this device is on */ + + unsigned int devfn; /* encoded device & function index */ + unsigned short vendor; + unsigned short device; + + + u64 dma_mask; + + struct device dev; + + unsigned int irq; + struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ +}; + + +#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) + +struct pci_bus { + unsigned char number; /* bus number */ +}; + + +struct pci_driver { + char *name; + const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */ + int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ + void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ + int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ + int (*resume) (struct pci_dev *dev); /* Device woken up */ + int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ + void (*shutdown) (struct pci_dev *dev); +}; + +#define PCI_DEVICE(vend,dev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID + + +// DDV: Does not need a body! Return an arbitrary integer. +int pci_dev_present(const struct pci_device_id *ids); + +// DDV: Body for this function is defined in linux/pci.c +struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); + + +/* Similar to the helpers above, these manipulate per-pci_dev + * driver-specific data. They are really just a wrapper around + * the generic device structure functions of these calls. + */ +static inline void *pci_get_drvdata (struct pci_dev *pdev) +{ + return dev_get_drvdata(&pdev->dev); +} + +static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) +{ + dev_set_drvdata(&pdev->dev, data); +} + +int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); +int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); +int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); +int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); +int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); +int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); + +static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) +{ + return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) +{ + return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) +{ + return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) +{ + return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) +{ + return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) +{ + return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); +} + +int pci_set_dma_mask(struct pci_dev *dev, u64 mask); +void pci_set_master(struct pci_dev *dev); + + +// DDV: Body for this function is defined in linux/pci.c +int pci_register_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +void pci_unregister_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +int pci_enable_device(struct pci_dev *dev); +// DDV: No body for this function +void pci_disable_device(struct pci_dev *dev); + + +#define HAVE_PCI_REQ_REGIONS 2 +// DDV: Body for this function is defined in linux/pci.c +int pci_request_regions(struct pci_dev *, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_regions(struct pci_dev *); +// DDV: Body for this function is defined in linux/pci.c +int pci_request_region(struct pci_dev *, int, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_region(struct pci_dev *, int); + + +#include + +/* these helpers provide future and backwards compatibility + * for accessing popular PCI BAR info */ +#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) +#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) +#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) +#define pci_resource_len(dev,bar) \ + ((pci_resource_start((dev),(bar)) == 0 && \ + pci_resource_end((dev),(bar)) == \ + pci_resource_start((dev),(bar))) ? 0 : \ + \ + (pci_resource_end((dev),(bar)) - \ + pci_resource_start((dev),(bar)) + 1)) + +#endif /* LINUX_PCI_H */ diff --git a/ddverify/models/con2/include/linux/pci_ids.h b/ddverify/models/con2/include/linux/pci_ids.h new file mode 100644 index 000000000..a3a09cceb --- /dev/null +++ b/ddverify/models/con2/include/linux/pci_ids.h @@ -0,0 +1,2260 @@ +/* + * PCI Class, Vendor and Device IDs + * + * Please keep sorted. + */ + +/* Device classes and subclasses */ + +#define PCI_CLASS_NOT_DEFINED 0x0000 +#define PCI_CLASS_NOT_DEFINED_VGA 0x0001 + +#define PCI_BASE_CLASS_STORAGE 0x01 +#define PCI_CLASS_STORAGE_SCSI 0x0100 +#define PCI_CLASS_STORAGE_IDE 0x0101 +#define PCI_CLASS_STORAGE_FLOPPY 0x0102 +#define PCI_CLASS_STORAGE_IPI 0x0103 +#define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SAS 0x0107 +#define PCI_CLASS_STORAGE_OTHER 0x0180 + +#define PCI_BASE_CLASS_NETWORK 0x02 +#define PCI_CLASS_NETWORK_ETHERNET 0x0200 +#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 +#define PCI_CLASS_NETWORK_FDDI 0x0202 +#define PCI_CLASS_NETWORK_ATM 0x0203 +#define PCI_CLASS_NETWORK_OTHER 0x0280 + +#define PCI_BASE_CLASS_DISPLAY 0x03 +#define PCI_CLASS_DISPLAY_VGA 0x0300 +#define PCI_CLASS_DISPLAY_XGA 0x0301 +#define PCI_CLASS_DISPLAY_3D 0x0302 +#define PCI_CLASS_DISPLAY_OTHER 0x0380 + +#define PCI_BASE_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400 +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 +#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402 +#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480 + +#define PCI_BASE_CLASS_MEMORY 0x05 +#define PCI_CLASS_MEMORY_RAM 0x0500 +#define PCI_CLASS_MEMORY_FLASH 0x0501 +#define PCI_CLASS_MEMORY_OTHER 0x0580 + +#define PCI_BASE_CLASS_BRIDGE 0x06 +#define PCI_CLASS_BRIDGE_HOST 0x0600 +#define PCI_CLASS_BRIDGE_ISA 0x0601 +#define PCI_CLASS_BRIDGE_EISA 0x0602 +#define PCI_CLASS_BRIDGE_MC 0x0603 +#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_BRIDGE_PCMCIA 0x0605 +#define PCI_CLASS_BRIDGE_NUBUS 0x0606 +#define PCI_CLASS_BRIDGE_CARDBUS 0x0607 +#define PCI_CLASS_BRIDGE_RACEWAY 0x0608 +#define PCI_CLASS_BRIDGE_OTHER 0x0680 + +#define PCI_BASE_CLASS_COMMUNICATION 0x07 +#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700 +#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701 +#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702 +#define PCI_CLASS_COMMUNICATION_MODEM 0x0703 +#define PCI_CLASS_COMMUNICATION_OTHER 0x0780 + +#define PCI_BASE_CLASS_SYSTEM 0x08 +#define PCI_CLASS_SYSTEM_PIC 0x0800 +#define PCI_CLASS_SYSTEM_PIC_IOAPIC 0x080010 +#define PCI_CLASS_SYSTEM_PIC_IOXAPIC 0x080020 +#define PCI_CLASS_SYSTEM_DMA 0x0801 +#define PCI_CLASS_SYSTEM_TIMER 0x0802 +#define PCI_CLASS_SYSTEM_RTC 0x0803 +#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804 +#define PCI_CLASS_SYSTEM_OTHER 0x0880 + +#define PCI_BASE_CLASS_INPUT 0x09 +#define PCI_CLASS_INPUT_KEYBOARD 0x0900 +#define PCI_CLASS_INPUT_PEN 0x0901 +#define PCI_CLASS_INPUT_MOUSE 0x0902 +#define PCI_CLASS_INPUT_SCANNER 0x0903 +#define PCI_CLASS_INPUT_GAMEPORT 0x0904 +#define PCI_CLASS_INPUT_OTHER 0x0980 + +#define PCI_BASE_CLASS_DOCKING 0x0a +#define PCI_CLASS_DOCKING_GENERIC 0x0a00 +#define PCI_CLASS_DOCKING_OTHER 0x0a80 + +#define PCI_BASE_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_PROCESSOR_386 0x0b00 +#define PCI_CLASS_PROCESSOR_486 0x0b01 +#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02 +#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10 +#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20 +#define PCI_CLASS_PROCESSOR_MIPS 0x0b30 +#define PCI_CLASS_PROCESSOR_CO 0x0b40 + +#define PCI_BASE_CLASS_SERIAL 0x0c +#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00 +#define PCI_CLASS_SERIAL_ACCESS 0x0c01 +#define PCI_CLASS_SERIAL_SSA 0x0c02 +#define PCI_CLASS_SERIAL_USB 0x0c03 +#define PCI_CLASS_SERIAL_USB_UHCI 0x0c0300 +#define PCI_CLASS_SERIAL_USB_OHCI 0x0c0310 +#define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320 +#define PCI_CLASS_SERIAL_FIBER 0x0c04 +#define PCI_CLASS_SERIAL_SMBUS 0x0c05 + +#define PCI_BASE_CLASS_INTELLIGENT 0x0e +#define PCI_CLASS_INTELLIGENT_I2O 0x0e00 + +#define PCI_BASE_CLASS_SATELLITE 0x0f +#define PCI_CLASS_SATELLITE_TV 0x0f00 +#define PCI_CLASS_SATELLITE_AUDIO 0x0f01 +#define PCI_CLASS_SATELLITE_VOICE 0x0f03 +#define PCI_CLASS_SATELLITE_DATA 0x0f04 + +#define PCI_BASE_CLASS_CRYPT 0x10 +#define PCI_CLASS_CRYPT_NETWORK 0x1000 +#define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001 +#define PCI_CLASS_CRYPT_OTHER 0x1080 + +#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11 +#define PCI_CLASS_SP_DPIO 0x1100 +#define PCI_CLASS_SP_OTHER 0x1180 + +#define PCI_CLASS_OTHERS 0xff + +/* Vendors and devices. Sort key: vendor first, device next. */ + +#define PCI_VENDOR_ID_DYNALINK 0x0675 +#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702 + +#define PCI_VENDOR_ID_BERKOM 0x0871 +#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1 +#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2 +#define PCI_DEVICE_ID_BERKOM_A4T 0xffa4 +#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xffa8 + +#define PCI_VENDOR_ID_COMPAQ 0x0e11 +#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508 +#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc +#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10 +#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32 +#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34 +#define PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE 0xae33 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35 +#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40 +#define PCI_DEVICE_ID_COMPAQ_NETEL100PI 0xae43 +#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011 +#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060 +#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178 +#define PCI_DEVICE_ID_COMPAQ_CISSC 0x46 +#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150 + +#define PCI_VENDOR_ID_NCR 0x1000 +#define PCI_VENDOR_ID_LSI_LOGIC 0x1000 +#define PCI_DEVICE_ID_NCR_53C810 0x0001 +#define PCI_DEVICE_ID_NCR_53C820 0x0002 +#define PCI_DEVICE_ID_NCR_53C825 0x0003 +#define PCI_DEVICE_ID_NCR_53C815 0x0004 +#define PCI_DEVICE_ID_LSI_53C810AP 0x0005 +#define PCI_DEVICE_ID_NCR_53C860 0x0006 +#define PCI_DEVICE_ID_LSI_53C1510 0x000a +#define PCI_DEVICE_ID_NCR_53C896 0x000b +#define PCI_DEVICE_ID_NCR_53C895 0x000c +#define PCI_DEVICE_ID_NCR_53C885 0x000d +#define PCI_DEVICE_ID_NCR_53C875 0x000f +#define PCI_DEVICE_ID_NCR_53C1510 0x0010 +#define PCI_DEVICE_ID_LSI_53C895A 0x0012 +#define PCI_DEVICE_ID_LSI_53C875A 0x0013 +#define PCI_DEVICE_ID_LSI_53C1010_33 0x0020 +#define PCI_DEVICE_ID_LSI_53C1010_66 0x0021 +#define PCI_DEVICE_ID_LSI_53C1030 0x0030 +#define PCI_DEVICE_ID_LSI_1030_53C1035 0x0032 +#define PCI_DEVICE_ID_LSI_53C1035 0x0040 +#define PCI_DEVICE_ID_NCR_53C875J 0x008f +#define PCI_DEVICE_ID_LSI_FC909 0x0621 +#define PCI_DEVICE_ID_LSI_FC929 0x0622 +#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623 +#define PCI_DEVICE_ID_LSI_FC919 0x0624 +#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625 +#define PCI_DEVICE_ID_LSI_FC929X 0x0626 +#define PCI_DEVICE_ID_LSI_FC939X 0x0642 +#define PCI_DEVICE_ID_LSI_FC949X 0x0640 +#define PCI_DEVICE_ID_LSI_FC949ES 0x0646 +#define PCI_DEVICE_ID_LSI_FC919X 0x0628 +#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701 +#define PCI_DEVICE_ID_LSI_61C102 0x0901 +#define PCI_DEVICE_ID_LSI_63C815 0x1000 +#define PCI_DEVICE_ID_LSI_SAS1064 0x0050 +#define PCI_DEVICE_ID_LSI_SAS1064R 0x0411 +#define PCI_DEVICE_ID_LSI_SAS1066 0x005E +#define PCI_DEVICE_ID_LSI_SAS1068 0x0054 +#define PCI_DEVICE_ID_LSI_SAS1064A 0x005C +#define PCI_DEVICE_ID_LSI_SAS1064E 0x0056 +#define PCI_DEVICE_ID_LSI_SAS1066E 0x005A +#define PCI_DEVICE_ID_LSI_SAS1068E 0x0058 +#define PCI_DEVICE_ID_LSI_SAS1078 0x0060 + +#define PCI_VENDOR_ID_ATI 0x1002 +/* Mach64 */ +#define PCI_DEVICE_ID_ATI_68800 0x4158 +#define PCI_DEVICE_ID_ATI_215CT222 0x4354 +#define PCI_DEVICE_ID_ATI_210888CX 0x4358 +#define PCI_DEVICE_ID_ATI_215ET222 0x4554 +/* Mach64 / Rage */ +#define PCI_DEVICE_ID_ATI_215GB 0x4742 +#define PCI_DEVICE_ID_ATI_215GD 0x4744 +#define PCI_DEVICE_ID_ATI_215GI 0x4749 +#define PCI_DEVICE_ID_ATI_215GP 0x4750 +#define PCI_DEVICE_ID_ATI_215GQ 0x4751 +#define PCI_DEVICE_ID_ATI_215XL 0x4752 +#define PCI_DEVICE_ID_ATI_215GT 0x4754 +#define PCI_DEVICE_ID_ATI_215GTB 0x4755 +#define PCI_DEVICE_ID_ATI_215_IV 0x4756 +#define PCI_DEVICE_ID_ATI_215_IW 0x4757 +#define PCI_DEVICE_ID_ATI_215_IZ 0x475A +#define PCI_DEVICE_ID_ATI_210888GX 0x4758 +#define PCI_DEVICE_ID_ATI_215_LB 0x4c42 +#define PCI_DEVICE_ID_ATI_215_LD 0x4c44 +#define PCI_DEVICE_ID_ATI_215_LG 0x4c47 +#define PCI_DEVICE_ID_ATI_215_LI 0x4c49 +#define PCI_DEVICE_ID_ATI_215_LM 0x4c4D +#define PCI_DEVICE_ID_ATI_215_LN 0x4c4E +#define PCI_DEVICE_ID_ATI_215_LR 0x4c52 +#define PCI_DEVICE_ID_ATI_215_LS 0x4c53 +#define PCI_DEVICE_ID_ATI_264_LT 0x4c54 +/* Mach64 VT */ +#define PCI_DEVICE_ID_ATI_264VT 0x5654 +#define PCI_DEVICE_ID_ATI_264VU 0x5655 +#define PCI_DEVICE_ID_ATI_264VV 0x5656 +/* Rage128 GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245 +#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246 +#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x5247 +/* Rage128 VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b +#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c +#define PCI_DEVICE_ID_ATI_RAGE128_SE 0x5345 +#define PCI_DEVICE_ID_ATI_RAGE128_SF 0x5346 +#define PCI_DEVICE_ID_ATI_RAGE128_SG 0x5347 +#define PCI_DEVICE_ID_ATI_RAGE128_SH 0x5348 +#define PCI_DEVICE_ID_ATI_RAGE128_SK 0x534b +#define PCI_DEVICE_ID_ATI_RAGE128_SL 0x534c +#define PCI_DEVICE_ID_ATI_RAGE128_SM 0x534d +#define PCI_DEVICE_ID_ATI_RAGE128_SN 0x534e +/* Rage128 Ultra */ +#define PCI_DEVICE_ID_ATI_RAGE128_TF 0x5446 +#define PCI_DEVICE_ID_ATI_RAGE128_TL 0x544c +#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452 +#define PCI_DEVICE_ID_ATI_RAGE128_TS 0x5453 +#define PCI_DEVICE_ID_ATI_RAGE128_TT 0x5454 +#define PCI_DEVICE_ID_ATI_RAGE128_TU 0x5455 +/* Rage128 M3 */ +#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45 +#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46 +/* Rage128 M4 */ +#define PCI_DEVICE_ID_ATI_RAGE128_MF 0x4d46 +#define PCI_DEVICE_ID_ATI_RAGE128_ML 0x4d4c +/* Rage128 Pro GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_PA 0x5041 +#define PCI_DEVICE_ID_ATI_RAGE128_PB 0x5042 +#define PCI_DEVICE_ID_ATI_RAGE128_PC 0x5043 +#define PCI_DEVICE_ID_ATI_RAGE128_PD 0x5044 +#define PCI_DEVICE_ID_ATI_RAGE128_PE 0x5045 +#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046 +/* Rage128 Pro VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047 +#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048 +#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049 +#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A +#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B +#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C +#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D +#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E +#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F +#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050 +#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051 +#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052 +#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053 +#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054 +#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055 +#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056 +#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057 +#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058 +/* Rage128 M4 */ +/* Radeon R100 */ +#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144 +#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145 +#define PCI_DEVICE_ID_ATI_RADEON_QF 0x5146 +#define PCI_DEVICE_ID_ATI_RADEON_QG 0x5147 +/* Radeon RV100 (VE) */ +#define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 +#define PCI_DEVICE_ID_ATI_RADEON_QZ 0x515a +/* Radeon R200 (8500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QL 0x514c +#define PCI_DEVICE_ID_ATI_RADEON_QN 0x514e +#define PCI_DEVICE_ID_ATI_RADEON_QO 0x514f +#define PCI_DEVICE_ID_ATI_RADEON_Ql 0x516c +#define PCI_DEVICE_ID_ATI_RADEON_BB 0x4242 +/* Radeon R200 (9100) */ +#define PCI_DEVICE_ID_ATI_RADEON_QM 0x514d +/* Radeon RV200 (7500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157 +#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158 +/* Radeon NV-100 */ +/* Radeon RV250 (9000) */ +#define PCI_DEVICE_ID_ATI_RADEON_Id 0x4964 +#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965 +#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966 +#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967 +/* Radeon RV280 (9200) */ +#define PCI_DEVICE_ID_ATI_RADEON_Ya 0x5961 +#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964 +/* Radeon R300 (9500) */ +/* Radeon R300 (9700) */ +#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44 +#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45 +#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46 +#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47 +/* Radeon R350 (9800) */ +/* Radeon RV350 (9600) */ +/* Radeon M6 */ +#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59 +#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a +/* Radeon M7 */ +#define PCI_DEVICE_ID_ATI_RADEON_LW 0x4c57 +#define PCI_DEVICE_ID_ATI_RADEON_LX 0x4c58 +/* Radeon M9 */ +#define PCI_DEVICE_ID_ATI_RADEON_Ld 0x4c64 +#define PCI_DEVICE_ID_ATI_RADEON_Le 0x4c65 +#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66 +#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67 +/* Radeon */ +/* RadeonIGP */ +#define PCI_DEVICE_ID_ATI_RS100 0xcab0 +#define PCI_DEVICE_ID_ATI_RS200 0xcab2 +#define PCI_DEVICE_ID_ATI_RS200_B 0xcbb2 +#define PCI_DEVICE_ID_ATI_RS250 0xcab3 +#define PCI_DEVICE_ID_ATI_RS300_100 0x5830 +#define PCI_DEVICE_ID_ATI_RS300_133 0x5831 +#define PCI_DEVICE_ID_ATI_RS300_166 0x5832 +#define PCI_DEVICE_ID_ATI_RS300_200 0x5833 +#define PCI_DEVICE_ID_ATI_RS350_100 0x7830 +#define PCI_DEVICE_ID_ATI_RS350_133 0x7831 +#define PCI_DEVICE_ID_ATI_RS350_166 0x7832 +#define PCI_DEVICE_ID_ATI_RS350_200 0x7833 +#define PCI_DEVICE_ID_ATI_RS400_100 0x5a30 +#define PCI_DEVICE_ID_ATI_RS400_133 0x5a31 +#define PCI_DEVICE_ID_ATI_RS400_166 0x5a32 +#define PCI_DEVICE_ID_ATI_RS400_200 0x5a33 +#define PCI_DEVICE_ID_ATI_RS480 0x5950 +/* ATI IXP Chipset */ +#define PCI_DEVICE_ID_ATI_IXP200_IDE 0x4349 +#define PCI_DEVICE_ID_ATI_IXP300_IDE 0x4369 +#define PCI_DEVICE_ID_ATI_IXP300_SATA 0x436e +#define PCI_DEVICE_ID_ATI_IXP400_IDE 0x4376 +#define PCI_DEVICE_ID_ATI_IXP400_SATA 0x4379 + +#define PCI_VENDOR_ID_VLSI 0x1004 +#define PCI_DEVICE_ID_VLSI_82C592 0x0005 +#define PCI_DEVICE_ID_VLSI_82C593 0x0006 +#define PCI_DEVICE_ID_VLSI_82C594 0x0007 +#define PCI_DEVICE_ID_VLSI_82C597 0x0009 +#define PCI_DEVICE_ID_VLSI_82C541 0x000c +#define PCI_DEVICE_ID_VLSI_82C543 0x000d +#define PCI_DEVICE_ID_VLSI_82C532 0x0101 +#define PCI_DEVICE_ID_VLSI_82C534 0x0102 +#define PCI_DEVICE_ID_VLSI_82C535 0x0104 +#define PCI_DEVICE_ID_VLSI_82C147 0x0105 +#define PCI_DEVICE_ID_VLSI_VAS96011 0x0702 + +#define PCI_VENDOR_ID_ADL 0x1005 +#define PCI_DEVICE_ID_ADL_2301 0x2301 + +#define PCI_VENDOR_ID_NS 0x100b +#define PCI_DEVICE_ID_NS_87415 0x0002 +#define PCI_DEVICE_ID_NS_87560_LIO 0x000e +#define PCI_DEVICE_ID_NS_87560_USB 0x0012 +#define PCI_DEVICE_ID_NS_83815 0x0020 +#define PCI_DEVICE_ID_NS_83820 0x0022 +#define PCI_DEVICE_ID_NS_CS5535_ISA 0x002b +#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d +#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e +#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f +#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 +#define PCI_DEVICE_ID_NS_SATURN 0x0035 +#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 +#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 +#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502 +#define PCI_DEVICE_ID_NS_SCx200_AUDIO 0x0503 +#define PCI_DEVICE_ID_NS_SCx200_VIDEO 0x0504 +#define PCI_DEVICE_ID_NS_SCx200_XBUS 0x0505 +#define PCI_DEVICE_ID_NS_SC1100_BRIDGE 0x0510 +#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511 +#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 +#define PCI_DEVICE_ID_NS_87410 0xd001 + +#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 +#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b + +#define PCI_VENDOR_ID_TSENG 0x100c +#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 +#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205 +#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206 +#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207 +#define PCI_DEVICE_ID_TSENG_ET6000 0x3208 + +#define PCI_VENDOR_ID_WEITEK 0x100e +#define PCI_DEVICE_ID_WEITEK_P9000 0x9001 +#define PCI_DEVICE_ID_WEITEK_P9100 0x9100 + +#define PCI_VENDOR_ID_DEC 0x1011 +#define PCI_DEVICE_ID_DEC_BRD 0x0001 +#define PCI_DEVICE_ID_DEC_TULIP 0x0002 +#define PCI_DEVICE_ID_DEC_TGA 0x0004 +#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009 +#define PCI_DEVICE_ID_DEC_TGA2 0x000D +#define PCI_DEVICE_ID_DEC_FDDI 0x000F +#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014 +#define PCI_DEVICE_ID_DEC_21142 0x0019 +#define PCI_DEVICE_ID_DEC_21052 0x0021 +#define PCI_DEVICE_ID_DEC_21150 0x0022 +#define PCI_DEVICE_ID_DEC_21152 0x0024 +#define PCI_DEVICE_ID_DEC_21153 0x0025 +#define PCI_DEVICE_ID_DEC_21154 0x0026 +#define PCI_DEVICE_ID_DEC_21285 0x1065 +#define PCI_DEVICE_ID_COMPAQ_42XX 0x0046 + +#define PCI_VENDOR_ID_CIRRUS 0x1013 +#define PCI_DEVICE_ID_CIRRUS_7548 0x0038 +#define PCI_DEVICE_ID_CIRRUS_5430 0x00a0 +#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00a4 +#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00a8 +#define PCI_DEVICE_ID_CIRRUS_5436 0x00ac +#define PCI_DEVICE_ID_CIRRUS_5446 0x00b8 +#define PCI_DEVICE_ID_CIRRUS_5480 0x00bc +#define PCI_DEVICE_ID_CIRRUS_5462 0x00d0 +#define PCI_DEVICE_ID_CIRRUS_5464 0x00d4 +#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6 +#define PCI_DEVICE_ID_CIRRUS_6729 0x1100 +#define PCI_DEVICE_ID_CIRRUS_6832 0x1110 +#define PCI_DEVICE_ID_CIRRUS_7543 0x1202 +#define PCI_DEVICE_ID_CIRRUS_4610 0x6001 +#define PCI_DEVICE_ID_CIRRUS_4612 0x6003 +#define PCI_DEVICE_ID_CIRRUS_4615 0x6004 + +#define PCI_VENDOR_ID_IBM 0x1014 +#define PCI_DEVICE_ID_IBM_TR 0x0018 +#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e +#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc +#define PCI_DEVICE_ID_IBM_SNIPE 0x0180 +#define PCI_DEVICE_ID_IBM_CITRINE 0x028C +#define PCI_DEVICE_ID_IBM_GEMSTONE 0xB166 +#define PCI_DEVICE_ID_IBM_OBSIDIAN 0x02BD +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1 0x0031 +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2 0x0219 +#define PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX 0x021A +#define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251 +#define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252 + +#define PCI_VENDOR_ID_COMPEX2 0x101a /* pci.ids says "AT&T GIS (NCR)" */ +#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005 + +#define PCI_VENDOR_ID_WD 0x101c +#define PCI_DEVICE_ID_WD_90C 0xc24a + +#define PCI_VENDOR_ID_AMI 0x101e +#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960 +#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010 +#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060 + +#define PCI_VENDOR_ID_AMD 0x1022 +#define PCI_DEVICE_ID_AMD_K8_NB 0x1100 +#define PCI_DEVICE_ID_AMD_LANCE 0x2000 +#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001 +#define PCI_DEVICE_ID_AMD_SCSI 0x2020 +#define PCI_DEVICE_ID_AMD_SERENADE 0x36c0 +#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006 +#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007 +#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C +#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E +#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401 +#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409 +#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B +#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410 +#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411 +#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413 +#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440 +#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441 +#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443 +#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443 +#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445 +#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468 +#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469 +#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a +#define PCI_DEVICE_ID_AMD_8111_SMBUS 0x746b +#define PCI_DEVICE_ID_AMD_8111_AUDIO 0x746d +#define PCI_DEVICE_ID_AMD_8151_0 0x7454 +#define PCI_DEVICE_ID_AMD_8131_APIC 0x7450 +#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090 +#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091 +#define PCI_DEVICE_ID_AMD_CS5536_AUDIO 0x2093 +#define PCI_DEVICE_ID_AMD_CS5536_OHC 0x2094 +#define PCI_DEVICE_ID_AMD_CS5536_EHC 0x2095 +#define PCI_DEVICE_ID_AMD_CS5536_UDC 0x2096 +#define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097 +#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A + +#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 +#define PCI_DEVICE_ID_AMD_LX_AES 0x2082 + +#define PCI_VENDOR_ID_TRIDENT 0x1023 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001 +#define PCI_DEVICE_ID_TRIDENT_9320 0x9320 +#define PCI_DEVICE_ID_TRIDENT_9388 0x9388 +#define PCI_DEVICE_ID_TRIDENT_9397 0x9397 +#define PCI_DEVICE_ID_TRIDENT_939A 0x939A +#define PCI_DEVICE_ID_TRIDENT_9520 0x9520 +#define PCI_DEVICE_ID_TRIDENT_9525 0x9525 +#define PCI_DEVICE_ID_TRIDENT_9420 0x9420 +#define PCI_DEVICE_ID_TRIDENT_9440 0x9440 +#define PCI_DEVICE_ID_TRIDENT_9660 0x9660 +#define PCI_DEVICE_ID_TRIDENT_9750 0x9750 +#define PCI_DEVICE_ID_TRIDENT_9850 0x9850 +#define PCI_DEVICE_ID_TRIDENT_9880 0x9880 +#define PCI_DEVICE_ID_TRIDENT_8400 0x8400 +#define PCI_DEVICE_ID_TRIDENT_8420 0x8420 +#define PCI_DEVICE_ID_TRIDENT_8500 0x8500 + +#define PCI_VENDOR_ID_AI 0x1025 +#define PCI_DEVICE_ID_AI_M1435 0x1435 + +#define PCI_VENDOR_ID_DELL 0x1028 +#define PCI_DEVICE_ID_DELL_RACIII 0x0008 +#define PCI_DEVICE_ID_DELL_RAC4 0x0012 +#define PCI_DEVICE_ID_DELL_PERC5 0x0015 + +#define PCI_VENDOR_ID_MATROX 0x102B +#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518 +#define PCI_DEVICE_ID_MATROX_MIL 0x0519 +#define PCI_DEVICE_ID_MATROX_MYS 0x051A +#define PCI_DEVICE_ID_MATROX_MIL_2 0x051b +#define PCI_DEVICE_ID_MATROX_MYS_AGP 0x051e +#define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f +#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10 +#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000 +#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001 +#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 +#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 +#define PCI_DEVICE_ID_MATROX_G400 0x0525 +#define PCI_DEVICE_ID_MATROX_G550 0x2527 +#define PCI_DEVICE_ID_MATROX_VIA 0x4536 + +#define PCI_VENDOR_ID_CT 0x102c +#define PCI_DEVICE_ID_CT_69000 0x00c0 +#define PCI_DEVICE_ID_CT_65545 0x00d8 +#define PCI_DEVICE_ID_CT_65548 0x00dc +#define PCI_DEVICE_ID_CT_65550 0x00e0 +#define PCI_DEVICE_ID_CT_65554 0x00e4 +#define PCI_DEVICE_ID_CT_65555 0x00e5 + +#define PCI_VENDOR_ID_MIRO 0x1031 +#define PCI_DEVICE_ID_MIRO_36050 0x5601 +#define PCI_DEVICE_ID_MIRO_DC10PLUS 0x7efe +#define PCI_DEVICE_ID_MIRO_DC30PLUS 0xd801 + +#define PCI_VENDOR_ID_NEC 0x1033 +#define PCI_DEVICE_ID_NEC_CBUS_1 0x0001 /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_LOCAL 0x0002 /* Local Bridge */ +#define PCI_DEVICE_ID_NEC_ATM 0x0003 /* ATM LAN Controller */ +#define PCI_DEVICE_ID_NEC_R4000 0x0004 /* R4000 Bridge */ +#define PCI_DEVICE_ID_NEC_486 0x0005 /* 486 Like Peripheral Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_1 0x0006 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_UXBUS 0x0007 /* UX-Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_2 0x0008 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_GRAPH 0x0009 /* PCI-CoreGraph Bridge */ +#define PCI_DEVICE_ID_NEC_VL 0x0016 /* PCI-VL Bridge */ +#define PCI_DEVICE_ID_NEC_STARALPHA2 0x002c /* STAR ALPHA2 */ +#define PCI_DEVICE_ID_NEC_CBUS_2 0x002d /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_USB 0x0035 /* PCI-USB Host */ +#define PCI_DEVICE_ID_NEC_CBUS_3 0x003b +#define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e +#define PCI_DEVICE_ID_NEC_PCX2 0x0046 /* PowerVR */ +#define PCI_DEVICE_ID_NEC_NILE4 0x005a +#define PCI_DEVICE_ID_NEC_VRC5476 0x009b +#define PCI_DEVICE_ID_NEC_VRC4173 0x00a5 +#define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6 +#define PCI_DEVICE_ID_NEC_PC9821CS01 0x800c /* PC-9821-CS01 */ +#define PCI_DEVICE_ID_NEC_PC9821NRB06 0x800d /* PC-9821NR-B06 */ + +#define PCI_VENDOR_ID_FD 0x1036 +#define PCI_DEVICE_ID_FD_36C70 0x0000 + +#define PCI_VENDOR_ID_SI 0x1039 +#define PCI_DEVICE_ID_SI_5591_AGP 0x0001 +#define PCI_DEVICE_ID_SI_6202 0x0002 +#define PCI_DEVICE_ID_SI_503 0x0008 +#define PCI_DEVICE_ID_SI_ACPI 0x0009 +#define PCI_DEVICE_ID_SI_SMBUS 0x0016 +#define PCI_DEVICE_ID_SI_LPC 0x0018 +#define PCI_DEVICE_ID_SI_5597_VGA 0x0200 +#define PCI_DEVICE_ID_SI_6205 0x0205 +#define PCI_DEVICE_ID_SI_501 0x0406 +#define PCI_DEVICE_ID_SI_496 0x0496 +#define PCI_DEVICE_ID_SI_300 0x0300 +#define PCI_DEVICE_ID_SI_315H 0x0310 +#define PCI_DEVICE_ID_SI_315 0x0315 +#define PCI_DEVICE_ID_SI_315PRO 0x0325 +#define PCI_DEVICE_ID_SI_530 0x0530 +#define PCI_DEVICE_ID_SI_540 0x0540 +#define PCI_DEVICE_ID_SI_550 0x0550 +#define PCI_DEVICE_ID_SI_540_VGA 0x5300 +#define PCI_DEVICE_ID_SI_550_VGA 0x5315 +#define PCI_DEVICE_ID_SI_620 0x0620 +#define PCI_DEVICE_ID_SI_630 0x0630 +#define PCI_DEVICE_ID_SI_633 0x0633 +#define PCI_DEVICE_ID_SI_635 0x0635 +#define PCI_DEVICE_ID_SI_640 0x0640 +#define PCI_DEVICE_ID_SI_645 0x0645 +#define PCI_DEVICE_ID_SI_646 0x0646 +#define PCI_DEVICE_ID_SI_648 0x0648 +#define PCI_DEVICE_ID_SI_650 0x0650 +#define PCI_DEVICE_ID_SI_651 0x0651 +#define PCI_DEVICE_ID_SI_655 0x0655 +#define PCI_DEVICE_ID_SI_661 0x0661 +#define PCI_DEVICE_ID_SI_730 0x0730 +#define PCI_DEVICE_ID_SI_733 0x0733 +#define PCI_DEVICE_ID_SI_630_VGA 0x6300 +#define PCI_DEVICE_ID_SI_735 0x0735 +#define PCI_DEVICE_ID_SI_740 0x0740 +#define PCI_DEVICE_ID_SI_741 0x0741 +#define PCI_DEVICE_ID_SI_745 0x0745 +#define PCI_DEVICE_ID_SI_746 0x0746 +#define PCI_DEVICE_ID_SI_755 0x0755 +#define PCI_DEVICE_ID_SI_760 0x0760 +#define PCI_DEVICE_ID_SI_900 0x0900 +#define PCI_DEVICE_ID_SI_961 0x0961 +#define PCI_DEVICE_ID_SI_962 0x0962 +#define PCI_DEVICE_ID_SI_963 0x0963 +#define PCI_DEVICE_ID_SI_965 0x0965 +#define PCI_DEVICE_ID_SI_5511 0x5511 +#define PCI_DEVICE_ID_SI_5513 0x5513 +#define PCI_DEVICE_ID_SI_5518 0x5518 +#define PCI_DEVICE_ID_SI_5571 0x5571 +#define PCI_DEVICE_ID_SI_5581 0x5581 +#define PCI_DEVICE_ID_SI_5582 0x5582 +#define PCI_DEVICE_ID_SI_5591 0x5591 +#define PCI_DEVICE_ID_SI_5596 0x5596 +#define PCI_DEVICE_ID_SI_5597 0x5597 +#define PCI_DEVICE_ID_SI_5598 0x5598 +#define PCI_DEVICE_ID_SI_5600 0x5600 +#define PCI_DEVICE_ID_SI_7012 0x7012 +#define PCI_DEVICE_ID_SI_7013 0x7013 +#define PCI_DEVICE_ID_SI_7016 0x7016 +#define PCI_DEVICE_ID_SI_7018 0x7018 + +#define PCI_VENDOR_ID_HP 0x103c +#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX6 0x1006 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX4 0x1008 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX2 0x100a +#define PCI_DEVICE_ID_HP_TACHYON 0x1028 +#define PCI_DEVICE_ID_HP_TACHLITE 0x1029 +#define PCI_DEVICE_ID_HP_J2585A 0x1030 +#define PCI_DEVICE_ID_HP_J2585B 0x1031 +#define PCI_DEVICE_ID_HP_J2973A 0x1040 +#define PCI_DEVICE_ID_HP_J2970A 0x1042 +#define PCI_DEVICE_ID_HP_DIVA 0x1048 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA1 0x1049 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA2 0x104A +#define PCI_DEVICE_ID_HP_DIVA_MAESTRO 0x104B +#define PCI_DEVICE_ID_HP_REO_IOC 0x10f1 +#define PCI_DEVICE_ID_HP_VISUALIZE_FXE 0x108b +#define PCI_DEVICE_ID_HP_DIVA_HALFDOME 0x1223 +#define PCI_DEVICE_ID_HP_DIVA_KEYSTONE 0x1226 +#define PCI_DEVICE_ID_HP_DIVA_POWERBAR 0x1227 +#define PCI_DEVICE_ID_HP_ZX1_IOC 0x122a +#define PCI_DEVICE_ID_HP_PCIX_LBA 0x122e +#define PCI_DEVICE_ID_HP_SX1000_IOC 0x127c +#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282 +#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 +#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 +#define PCI_DEVICE_ID_HP_DIVA_HURRICANE 0x132a +#define PCI_DEVICE_ID_HP_CISSA 0x3220 +#define PCI_DEVICE_ID_HP_CISSC 0x3230 +#define PCI_DEVICE_ID_HP_CISSD 0x3238 +#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 + +#define PCI_VENDOR_ID_PCTECH 0x1042 +#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000 +#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001 +#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020 + +#define PCI_VENDOR_ID_ASUSTEK 0x1043 +#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675 + +#define PCI_VENDOR_ID_DPT 0x1044 +#define PCI_DEVICE_ID_DPT 0xa400 + +#define PCI_VENDOR_ID_OPTI 0x1045 +#define PCI_DEVICE_ID_OPTI_82C558 0xc558 +#define PCI_DEVICE_ID_OPTI_82C621 0xc621 +#define PCI_DEVICE_ID_OPTI_82C700 0xc700 +#define PCI_DEVICE_ID_OPTI_82C825 0xd568 + +#define PCI_VENDOR_ID_ELSA 0x1048 +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000 +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000 + + +#define PCI_VENDOR_ID_BUSLOGIC 0x104B +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140 +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040 +#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130 + +#define PCI_VENDOR_ID_TI 0x104c +#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 +#define PCI_DEVICE_ID_TI_4450 0x8011 +#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 +#define PCI_DEVICE_ID_TI_X515 0x8036 +#define PCI_DEVICE_ID_TI_1130 0xac12 +#define PCI_DEVICE_ID_TI_1031 0xac13 +#define PCI_DEVICE_ID_TI_1131 0xac15 +#define PCI_DEVICE_ID_TI_1250 0xac16 +#define PCI_DEVICE_ID_TI_1220 0xac17 +#define PCI_DEVICE_ID_TI_1221 0xac19 +#define PCI_DEVICE_ID_TI_1210 0xac1a +#define PCI_DEVICE_ID_TI_1450 0xac1b +#define PCI_DEVICE_ID_TI_1225 0xac1c +#define PCI_DEVICE_ID_TI_1251A 0xac1d +#define PCI_DEVICE_ID_TI_1211 0xac1e +#define PCI_DEVICE_ID_TI_1251B 0xac1f +#define PCI_DEVICE_ID_TI_4410 0xac41 +#define PCI_DEVICE_ID_TI_4451 0xac42 +#define PCI_DEVICE_ID_TI_4510 0xac44 +#define PCI_DEVICE_ID_TI_4520 0xac46 +#define PCI_DEVICE_ID_TI_7510 0xac47 +#define PCI_DEVICE_ID_TI_7610 0xac48 +#define PCI_DEVICE_ID_TI_7410 0xac49 +#define PCI_DEVICE_ID_TI_1410 0xac50 +#define PCI_DEVICE_ID_TI_1420 0xac51 +#define PCI_DEVICE_ID_TI_1451A 0xac52 +#define PCI_DEVICE_ID_TI_1620 0xac54 +#define PCI_DEVICE_ID_TI_1520 0xac55 +#define PCI_DEVICE_ID_TI_1510 0xac56 +#define PCI_DEVICE_ID_TI_X620 0xac8d +#define PCI_DEVICE_ID_TI_X420 0xac8e + +#define PCI_VENDOR_ID_SONY 0x104d + + +/* Winbond have two vendor IDs! See 0x10ad as well */ +#define PCI_VENDOR_ID_WINBOND2 0x1050 +#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a +#define PCI_DEVICE_ID_WINBOND2_6692 0x6692 + +#define PCI_VENDOR_ID_ANIGMA 0x1051 +#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100 + +#define PCI_VENDOR_ID_EFAR 0x1055 +#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130 +#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463 + +#define PCI_VENDOR_ID_MOTOROLA 0x1057 +#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001 +#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 +#define PCI_DEVICE_ID_MOTOROLA_MPC107 0x0004 +#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801 +#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802 +#define PCI_DEVICE_ID_MOTOROLA_HAWK 0x4803 +#define PCI_DEVICE_ID_MOTOROLA_HARRIER 0x480b +#define PCI_DEVICE_ID_MOTOROLA_MPC5200 0x5803 + +#define PCI_VENDOR_ID_PROMISE 0x105a +#define PCI_DEVICE_ID_PROMISE_20265 0x0d30 +#define PCI_DEVICE_ID_PROMISE_20267 0x4d30 +#define PCI_DEVICE_ID_PROMISE_20246 0x4d33 +#define PCI_DEVICE_ID_PROMISE_20262 0x4d38 +#define PCI_DEVICE_ID_PROMISE_20263 0x0D38 +#define PCI_DEVICE_ID_PROMISE_20268 0x4d68 +#define PCI_DEVICE_ID_PROMISE_20269 0x4d69 +#define PCI_DEVICE_ID_PROMISE_20270 0x6268 +#define PCI_DEVICE_ID_PROMISE_20271 0x6269 +#define PCI_DEVICE_ID_PROMISE_20275 0x1275 +#define PCI_DEVICE_ID_PROMISE_20276 0x5275 +#define PCI_DEVICE_ID_PROMISE_20277 0x7275 + + +#define PCI_VENDOR_ID_UMC 0x1060 +#define PCI_DEVICE_ID_UMC_UM8673F 0x0101 +#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a +#define PCI_DEVICE_ID_UMC_UM8886A 0x886a + + +#define PCI_VENDOR_ID_MYLEX 0x1069 +#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001 +#define PCI_DEVICE_ID_MYLEX_DAC960_PD 0x0002 +#define PCI_DEVICE_ID_MYLEX_DAC960_PG 0x0010 +#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020 +#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050 +#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56 +#define PCI_DEVICE_ID_MYLEX_DAC960_GEM 0xB166 + + +#define PCI_VENDOR_ID_APPLE 0x106b +#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001 +#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e +#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d +#define PCI_DEVICE_ID_APPLE_UNI_N_PCI15 0x002e +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032 +#define PCI_DEVICE_ID_APPLE_UNI_N_ATA 0x0033 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034 +#define PCI_DEVICE_ID_APPLE_IPID_ATA100 0x003b +#define PCI_DEVICE_ID_APPLE_K2_ATA100 0x0043 +#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b +#define PCI_DEVICE_ID_APPLE_K2_GMAC 0x004c +#define PCI_DEVICE_ID_APPLE_SH_ATA 0x0050 +#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051 +#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058 +#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059 +#define PCI_DEVICE_ID_APPLE_IPID2_AGP 0x0066 +#define PCI_DEVICE_ID_APPLE_IPID2_ATA 0x0069 +#define PCI_DEVICE_ID_APPLE_IPID2_FW 0x006a +#define PCI_DEVICE_ID_APPLE_IPID2_GMAC 0x006b +#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645 + +#define PCI_VENDOR_ID_YAMAHA 0x1073 +#define PCI_DEVICE_ID_YAMAHA_724 0x0004 +#define PCI_DEVICE_ID_YAMAHA_724F 0x000d +#define PCI_DEVICE_ID_YAMAHA_740 0x000a +#define PCI_DEVICE_ID_YAMAHA_740C 0x000c +#define PCI_DEVICE_ID_YAMAHA_744 0x0010 +#define PCI_DEVICE_ID_YAMAHA_754 0x0012 + + +#define PCI_VENDOR_ID_QLOGIC 0x1077 +#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020 +#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100 +#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200 +#define PCI_DEVICE_ID_QLOGIC_ISP2300 0x2300 +#define PCI_DEVICE_ID_QLOGIC_ISP2312 0x2312 +#define PCI_DEVICE_ID_QLOGIC_ISP2322 0x2322 +#define PCI_DEVICE_ID_QLOGIC_ISP6312 0x6312 +#define PCI_DEVICE_ID_QLOGIC_ISP6322 0x6322 +#define PCI_DEVICE_ID_QLOGIC_ISP2422 0x2422 +#define PCI_DEVICE_ID_QLOGIC_ISP2432 0x2432 +#define PCI_DEVICE_ID_QLOGIC_ISP2512 0x2512 +#define PCI_DEVICE_ID_QLOGIC_ISP2522 0x2522 + +#define PCI_VENDOR_ID_CYRIX 0x1078 +#define PCI_DEVICE_ID_CYRIX_5510 0x0000 +#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001 +#define PCI_DEVICE_ID_CYRIX_5520 0x0002 +#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100 +#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102 +#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103 +#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104 + + + +#define PCI_VENDOR_ID_CONTAQ 0x1080 +#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693 + + +#define PCI_VENDOR_ID_OLICOM 0x108d +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012 +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013 +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014 + +#define PCI_VENDOR_ID_SUN 0x108e +#define PCI_DEVICE_ID_SUN_EBUS 0x1000 +#define PCI_DEVICE_ID_SUN_HAPPYMEAL 0x1001 +#define PCI_DEVICE_ID_SUN_RIO_EBUS 0x1100 +#define PCI_DEVICE_ID_SUN_RIO_GEM 0x1101 +#define PCI_DEVICE_ID_SUN_RIO_1394 0x1102 +#define PCI_DEVICE_ID_SUN_RIO_USB 0x1103 +#define PCI_DEVICE_ID_SUN_GEM 0x2bad +#define PCI_DEVICE_ID_SUN_SIMBA 0x5000 +#define PCI_DEVICE_ID_SUN_PBM 0x8000 +#define PCI_DEVICE_ID_SUN_SCHIZO 0x8001 +#define PCI_DEVICE_ID_SUN_SABRE 0xa000 +#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001 +#define PCI_DEVICE_ID_SUN_TOMATILLO 0xa801 +#define PCI_DEVICE_ID_SUN_CASSINI 0xabba + +#define PCI_VENDOR_ID_CMD 0x1095 +#define PCI_DEVICE_ID_CMD_643 0x0643 +#define PCI_DEVICE_ID_CMD_646 0x0646 +#define PCI_DEVICE_ID_CMD_648 0x0648 +#define PCI_DEVICE_ID_CMD_649 0x0649 + +#define PCI_DEVICE_ID_SII_680 0x0680 +#define PCI_DEVICE_ID_SII_3112 0x3112 +#define PCI_DEVICE_ID_SII_1210SA 0x0240 + + +#define PCI_VENDOR_ID_BROOKTREE 0x109e +#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 +#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 + + +#define PCI_VENDOR_ID_SGI 0x10a9 +#define PCI_DEVICE_ID_SGI_IOC3 0x0003 +#define PCI_DEVICE_ID_SGI_IOC4 0x100a +#define PCI_VENDOR_ID_SGI_LITHIUM 0x1002 + + +#define PCI_VENDOR_ID_WINBOND 0x10ad +#define PCI_DEVICE_ID_WINBOND_82C105 0x0105 +#define PCI_DEVICE_ID_WINBOND_83C553 0x0565 + + +#define PCI_VENDOR_ID_PLX 0x10b5 +#define PCI_DEVICE_ID_PLX_R685 0x1030 +#define PCI_DEVICE_ID_PLX_ROMULUS 0x106a +#define PCI_DEVICE_ID_PLX_SPCOM800 0x1076 +#define PCI_DEVICE_ID_PLX_1077 0x1077 +#define PCI_DEVICE_ID_PLX_SPCOM200 0x1103 +#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151 +#define PCI_DEVICE_ID_PLX_R753 0x1152 +#define PCI_DEVICE_ID_PLX_OLITEC 0x1187 +#define PCI_DEVICE_ID_PLX_9050 0x9050 +#define PCI_DEVICE_ID_PLX_9080 0x9080 +#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001 + +#define PCI_VENDOR_ID_MADGE 0x10b6 +#define PCI_DEVICE_ID_MADGE_MK2 0x0002 + +#define PCI_VENDOR_ID_3COM 0x10b7 +#define PCI_DEVICE_ID_3COM_3C985 0x0001 +#define PCI_DEVICE_ID_3COM_3C940 0x1700 +#define PCI_DEVICE_ID_3COM_3C339 0x3390 +#define PCI_DEVICE_ID_3COM_3C359 0x3590 +#define PCI_DEVICE_ID_3COM_3C940B 0x80eb +#define PCI_DEVICE_ID_3COM_3CR990 0x9900 +#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902 +#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903 +#define PCI_DEVICE_ID_3COM_3CR990B 0x9904 +#define PCI_DEVICE_ID_3COM_3CR990_FX 0x9905 +#define PCI_DEVICE_ID_3COM_3CR990SVR95 0x9908 +#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909 +#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a + + +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1533 0x1533 +#define PCI_DEVICE_ID_AL_M1535 0x1535 +#define PCI_DEVICE_ID_AL_M1541 0x1541 +#define PCI_DEVICE_ID_AL_M1563 0x1563 +#define PCI_DEVICE_ID_AL_M1621 0x1621 +#define PCI_DEVICE_ID_AL_M1631 0x1631 +#define PCI_DEVICE_ID_AL_M1632 0x1632 +#define PCI_DEVICE_ID_AL_M1641 0x1641 +#define PCI_DEVICE_ID_AL_M1644 0x1644 +#define PCI_DEVICE_ID_AL_M1647 0x1647 +#define PCI_DEVICE_ID_AL_M1651 0x1651 +#define PCI_DEVICE_ID_AL_M1671 0x1671 +#define PCI_DEVICE_ID_AL_M1681 0x1681 +#define PCI_DEVICE_ID_AL_M1683 0x1683 +#define PCI_DEVICE_ID_AL_M1689 0x1689 +#define PCI_DEVICE_ID_AL_M5219 0x5219 +#define PCI_DEVICE_ID_AL_M5228 0x5228 +#define PCI_DEVICE_ID_AL_M5229 0x5229 +#define PCI_DEVICE_ID_AL_M5451 0x5451 +#define PCI_DEVICE_ID_AL_M7101 0x7101 + + + +#define PCI_VENDOR_ID_NEOMAGIC 0x10c8 +#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 +#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 +#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 + + +#define PCI_VENDOR_ID_TCONRAD 0x10da +#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508 + + +#define PCI_VENDOR_ID_NVIDIA 0x10de +#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020 +#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028 +#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029 +#define PCI_DEVICE_ID_NVIDIA_TNT_UNKNOWN 0x002a +#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C +#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS 0x0034 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE 0x0035 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA 0x0036 +#define PCI_DEVICE_ID_NVIDIA_NVENET_10 0x0037 +#define PCI_DEVICE_ID_NVIDIA_NVENET_11 0x0038 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2 0x003e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_ULTRA 0x0040 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800 0x0041 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_LE 0x0042 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x0045 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_4000 0x004E +#define PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS 0x0052 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE 0x0053 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA 0x0054 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2 0x0055 +#define PCI_DEVICE_ID_NVIDIA_NVENET_8 0x0056 +#define PCI_DEVICE_ID_NVIDIA_NVENET_9 0x0057 +#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065 +#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066 +#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069 +#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085 +#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086 +#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089 +#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a +#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GT 0x0090 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GTX 0x0091 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800 0x0098 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800_GTX 0x0099 +#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 +#define PCI_DEVICE_ID_GEFORCE_6800A 0x00c1 +#define PCI_DEVICE_ID_GEFORCE_6800A_LE 0x00c2 +#define PCI_DEVICE_ID_GEFORCE_GO_6800 0x00c8 +#define PCI_DEVICE_ID_GEFORCE_GO_6800_ULTRA 0x00c9 +#define PCI_DEVICE_ID_QUADRO_FX_GO1400 0x00cc +#define PCI_DEVICE_ID_QUADRO_FX_1400 0x00ce +#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 +#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9 +#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da +#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA 0x00e3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 +#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_ALT1 0x00f0 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT1 0x00f1 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT2 0x00f2 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6200_ALT1 0x00f3 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x00f9 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101 +#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO 0x0112 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600_GT 0x0140 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600 0x0141 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6610_XL 0x0145 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_540 0x014E +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200 0x014F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200_TURBOCACHE 0x0161 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200 0x0164 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250 0x0166 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200_1 0x0167 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250_1 0x0168 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460 0x0170 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440 0x0171 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420 0x0172 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_SE 0x0173 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO 0x0174 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO 0x0175 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32 0x0176 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_460_GO 0x0177 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL 0x0178 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64 0x0179 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_200 0x017A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL 0x017B +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL 0x017C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_410_GO_M16 0x017D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_8X 0x0181 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440SE_8X 0x0182 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420_8X 0x0183 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_4000 0x0185 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_448_GO 0x0186 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_488_GO 0x0187 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_580_XGL 0x0188 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_MAC 0x0189 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_280_NVS 0x018A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_380_XGL 0x018B +#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0 +#define PCI_DEVICE_ID_NVIDIA_NFORCE 0x01a4 +#define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc +#define PCI_DEVICE_ID_NVIDIA_MCP1_MODEM 0x01c1 +#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2 0x0202 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC 0x0203 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B 0x0211 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_LE 0x0212 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_GT 0x0215 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600 0x0250 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400 0x0251 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200 0x0253 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE 0x0265 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE 0x036E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA 0x037E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2 0x037F +#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268 +#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO 0x0286 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_980_XGL 0x0288 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_780_XGL 0x0289 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700_GOGL 0x028C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_ULTRA 0x0301 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800 0x0302 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_2000 0x0308 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1000 0x0309 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_ULTRA 0x0311 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600 0x0312 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600SE 0x0314 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5600 0x031A +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5650 0x031B +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO700 0x031C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200 0x0320 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_ULTRA 0x0321 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_1 0x0322 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200SE 0x0323 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5200 0x0324 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250 0x0325 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5500 0x0326 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5100 0x0327 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250_32 0x0328 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200 0x0329 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_NVS_280_PCI 0x032A +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_500 0x032B +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5300 0x032C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5100 0x032D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900_ULTRA 0x0330 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900 0x0331 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900XT 0x0332 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5950_ULTRA 0x0333 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900ZT 0x0334 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_3000 0x0338 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_700 0x033F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700_ULTRA 0x0341 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700 0x0342 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700LE 0x0343 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700VE 0x0344 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_1 0x0347 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_2 0x0348 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO1000 0x034C +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E +#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372 +#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 + +#define PCI_VENDOR_ID_IMS 0x10e0 +#define PCI_DEVICE_ID_IMS_TT128 0x9128 +#define PCI_DEVICE_ID_IMS_TT3D 0x9135 + + + + +#define PCI_VENDOR_ID_INTERG 0x10ea +#define PCI_DEVICE_ID_INTERG_1682 0x1682 +#define PCI_DEVICE_ID_INTERG_2000 0x2000 +#define PCI_DEVICE_ID_INTERG_2010 0x2010 +#define PCI_DEVICE_ID_INTERG_5000 0x5000 +#define PCI_DEVICE_ID_INTERG_5050 0x5050 + +#define PCI_VENDOR_ID_REALTEK 0x10ec +#define PCI_DEVICE_ID_REALTEK_8139 0x8139 + +#define PCI_VENDOR_ID_XILINX 0x10ee +#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0 +#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1 +#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2 +#define PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST 0x3fc3 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 + + +#define PCI_VENDOR_ID_INIT 0x1101 + +#define PCI_VENDOR_ID_CREATIVE 0x1102 /* duplicate: ECTIVA */ +#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002 + +#define PCI_VENDOR_ID_ECTIVA 0x1102 /* duplicate: CREATIVE */ +#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938 + +#define PCI_VENDOR_ID_TTI 0x1103 +#define PCI_DEVICE_ID_TTI_HPT343 0x0003 +#define PCI_DEVICE_ID_TTI_HPT366 0x0004 +#define PCI_DEVICE_ID_TTI_HPT372 0x0005 +#define PCI_DEVICE_ID_TTI_HPT302 0x0006 +#define PCI_DEVICE_ID_TTI_HPT371 0x0007 +#define PCI_DEVICE_ID_TTI_HPT374 0x0008 +#define PCI_DEVICE_ID_TTI_HPT372N 0x0009 /* apparently a 372N variant? */ + +#define PCI_VENDOR_ID_VIA 0x1106 +#define PCI_DEVICE_ID_VIA_8763_0 0x0198 +#define PCI_DEVICE_ID_VIA_8380_0 0x0204 +#define PCI_DEVICE_ID_VIA_3238_0 0x0238 +#define PCI_DEVICE_ID_VIA_PT880 0x0258 +#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 +#define PCI_DEVICE_ID_VIA_3269_0 0x0269 +#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 +#define PCI_DEVICE_ID_VIA_8363_0 0x0305 +#define PCI_DEVICE_ID_VIA_P4M800CE 0x0314 +#define PCI_DEVICE_ID_VIA_8371_0 0x0391 +#define PCI_DEVICE_ID_VIA_8501_0 0x0501 +#define PCI_DEVICE_ID_VIA_82C561 0x0561 +#define PCI_DEVICE_ID_VIA_82C586_1 0x0571 +#define PCI_DEVICE_ID_VIA_82C576 0x0576 +#define PCI_DEVICE_ID_VIA_82C586_0 0x0586 +#define PCI_DEVICE_ID_VIA_82C596 0x0596 +#define PCI_DEVICE_ID_VIA_82C597_0 0x0597 +#define PCI_DEVICE_ID_VIA_82C598_0 0x0598 +#define PCI_DEVICE_ID_VIA_8601_0 0x0601 +#define PCI_DEVICE_ID_VIA_8605_0 0x0605 +#define PCI_DEVICE_ID_VIA_82C686 0x0686 +#define PCI_DEVICE_ID_VIA_82C691_0 0x0691 +#define PCI_DEVICE_ID_VIA_82C576_1 0x1571 +#define PCI_DEVICE_ID_VIA_82C586_2 0x3038 +#define PCI_DEVICE_ID_VIA_82C586_3 0x3040 +#define PCI_DEVICE_ID_VIA_82C596_3 0x3050 +#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051 +#define PCI_DEVICE_ID_VIA_82C686_4 0x3057 +#define PCI_DEVICE_ID_VIA_82C686_5 0x3058 +#define PCI_DEVICE_ID_VIA_8233_5 0x3059 +#define PCI_DEVICE_ID_VIA_8233_0 0x3074 +#define PCI_DEVICE_ID_VIA_8633_0 0x3091 +#define PCI_DEVICE_ID_VIA_8367_0 0x3099 +#define PCI_DEVICE_ID_VIA_8653_0 0x3101 +#define PCI_DEVICE_ID_VIA_8622 0x3102 +#define PCI_DEVICE_ID_VIA_8233C_0 0x3109 +#define PCI_DEVICE_ID_VIA_8361 0x3112 +#define PCI_DEVICE_ID_VIA_XM266 0x3116 +#define PCI_DEVICE_ID_VIA_612X 0x3119 +#define PCI_DEVICE_ID_VIA_862X_0 0x3123 +#define PCI_DEVICE_ID_VIA_8753_0 0x3128 +#define PCI_DEVICE_ID_VIA_8233A 0x3147 +#define PCI_DEVICE_ID_VIA_8703_51_0 0x3148 +#define PCI_DEVICE_ID_VIA_8237_SATA 0x3149 +#define PCI_DEVICE_ID_VIA_XN266 0x3156 +#define PCI_DEVICE_ID_VIA_6410 0x3164 +#define PCI_DEVICE_ID_VIA_8754C_0 0x3168 +#define PCI_DEVICE_ID_VIA_8235 0x3177 +#define PCI_DEVICE_ID_VIA_8385_0 0x3188 +#define PCI_DEVICE_ID_VIA_8377_0 0x3189 +#define PCI_DEVICE_ID_VIA_8378_0 0x3205 +#define PCI_DEVICE_ID_VIA_8783_0 0x3208 +#define PCI_DEVICE_ID_VIA_8237 0x3227 +#define PCI_DEVICE_ID_VIA_8251 0x3287 +#define PCI_DEVICE_ID_VIA_3296_0 0x0296 +#define PCI_DEVICE_ID_VIA_8231 0x8231 +#define PCI_DEVICE_ID_VIA_8231_4 0x8235 +#define PCI_DEVICE_ID_VIA_8365_1 0x8305 +#define PCI_DEVICE_ID_VIA_8371_1 0x8391 +#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 +#define PCI_DEVICE_ID_VIA_838X_1 0xB188 +#define PCI_DEVICE_ID_VIA_83_87XX_1 0xB198 + +#define PCI_VENDOR_ID_SIEMENS 0x110A +#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102 + + +#define PCI_VENDOR_ID_VORTEX 0x1119 +#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000 +#define PCI_DEVICE_ID_VORTEX_GDT6000B 0x0001 +#define PCI_DEVICE_ID_VORTEX_GDT6x10 0x0002 +#define PCI_DEVICE_ID_VORTEX_GDT6x20 0x0003 +#define PCI_DEVICE_ID_VORTEX_GDT6530 0x0004 +#define PCI_DEVICE_ID_VORTEX_GDT6550 0x0005 +#define PCI_DEVICE_ID_VORTEX_GDT6x17 0x0006 +#define PCI_DEVICE_ID_VORTEX_GDT6x27 0x0007 +#define PCI_DEVICE_ID_VORTEX_GDT6537 0x0008 +#define PCI_DEVICE_ID_VORTEX_GDT6557 0x0009 +#define PCI_DEVICE_ID_VORTEX_GDT6x15 0x000a +#define PCI_DEVICE_ID_VORTEX_GDT6x25 0x000b +#define PCI_DEVICE_ID_VORTEX_GDT6535 0x000c +#define PCI_DEVICE_ID_VORTEX_GDT6555 0x000d +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x0100 +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x0101 +#define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x0102 +#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103 +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104 +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105 + +#define PCI_VENDOR_ID_EF 0x111a +#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000 +#define PCI_DEVICE_ID_EF_ATM_ASIC 0x0002 +#define PCI_VENDOR_ID_EF_ATM_LANAI2 0x0003 +#define PCI_VENDOR_ID_EF_ATM_LANAIHB 0x0005 + +#define PCI_VENDOR_ID_IDT 0x111d +#define PCI_DEVICE_ID_IDT_IDT77201 0x0001 + +#define PCI_VENDOR_ID_FORE 0x1127 +#define PCI_DEVICE_ID_FORE_PCA200E 0x0300 + + +#define PCI_VENDOR_ID_PHILIPS 0x1131 +#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146 +#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730 + +#define PCI_VENDOR_ID_EICON 0x1133 +#define PCI_DEVICE_ID_EICON_DIVA20 0xe002 +#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004 +#define PCI_DEVICE_ID_EICON_DIVA201 0xe005 +#define PCI_DEVICE_ID_EICON_DIVA202 0xe00b +#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010 +#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012 +#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013 +#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014 + +#define PCI_VENDOR_ID_ZIATECH 0x1138 +#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550 + + + +#define PCI_VENDOR_ID_SYSKONNECT 0x1148 +#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200 +#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300 +#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320 +#define PCI_DEVICE_ID_SYSKONNECT_9DXX 0x4400 +#define PCI_DEVICE_ID_SYSKONNECT_9MXX 0x4500 + + +#define PCI_VENDOR_ID_DIGI 0x114f +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070 +#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071 +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072 +#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073 +#define PCI_DEVICE_ID_NEO_2DB9 0x00C8 +#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 +#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA +#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB + + +#define PCI_VENDOR_ID_XIRCOM 0x115d +#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 +#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103 + + +#define PCI_VENDOR_ID_SERVERWORKS 0x1166 +#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008 +#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009 +#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017 +#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 +#define PCI_DEVICE_ID_SERVERWORKS_HT1000IDE 0x0214 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6LPC 0x0227 + +#define PCI_VENDOR_ID_SBE 0x1176 +#define PCI_DEVICE_ID_SBE_WANXL100 0x0301 +#define PCI_DEVICE_ID_SBE_WANXL200 0x0302 +#define PCI_DEVICE_ID_SBE_WANXL400 0x0104 + +#define PCI_VENDOR_ID_TOSHIBA 0x1179 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a +#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f +#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617 + +#define PCI_VENDOR_ID_TOSHIBA_2 0x102f +#define PCI_DEVICE_ID_TOSHIBA_TC35815CF 0x0030 +#define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC 0x0108 +#define PCI_DEVICE_ID_TOSHIBA_SPIDER_NET 0x01b3 + +#define PCI_VENDOR_ID_RICOH 0x1180 +#define PCI_DEVICE_ID_RICOH_RL5C465 0x0465 +#define PCI_DEVICE_ID_RICOH_RL5C466 0x0466 +#define PCI_DEVICE_ID_RICOH_RL5C475 0x0475 +#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476 +#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478 + +#define PCI_VENDOR_ID_DLINK 0x1186 +#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00 + +#define PCI_VENDOR_ID_ARTOP 0x1191 +#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005 +#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006 +#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007 +#define PCI_DEVICE_ID_ARTOP_ATP865 0x0008 +#define PCI_DEVICE_ID_ARTOP_ATP865R 0x0009 +#define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002 +#define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010 +#define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020 +#define PCI_DEVICE_ID_ARTOP_AEC7612S 0x8030 +#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040 +#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050 +#define PCI_DEVICE_ID_ARTOP_8060 0x8060 + +#define PCI_VENDOR_ID_ZEITNET 0x1193 +#define PCI_DEVICE_ID_ZEITNET_1221 0x0001 +#define PCI_DEVICE_ID_ZEITNET_1225 0x0002 + + +#define PCI_VENDOR_ID_FUJITSU_ME 0x119e +#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001 +#define PCI_DEVICE_ID_FUJITSU_FS50 0x0003 + +#define PCI_SUBVENDOR_ID_KEYSPAN 0x11a9 +#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334 + +#define PCI_VENDOR_ID_MARVELL 0x11ab +#define PCI_DEVICE_ID_MARVELL_GT64111 0x4146 +#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 +#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 +#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480 +#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652 +#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653 + + +#define PCI_VENDOR_ID_V3 0x11b0 +#define PCI_DEVICE_ID_V3_V960 0x0001 +#define PCI_DEVICE_ID_V3_V351 0x0002 + + +#define PCI_VENDOR_ID_ATT 0x11c1 +#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480 + + +#define PCI_VENDOR_ID_SPECIALIX 0x11cb +#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000 +#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000 +#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004 + + +#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4 +#define PCI_DEVICE_ID_AD1889JS 0x1889 + + +#define PCI_DEVICE_ID_SEGA_BBA 0x1234 + +#define PCI_VENDOR_ID_ZORAN 0x11de +#define PCI_DEVICE_ID_ZORAN_36057 0x6057 +#define PCI_DEVICE_ID_ZORAN_36120 0x6120 + + +#define PCI_VENDOR_ID_COMPEX 0x11f6 +#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112 + +#define PCI_VENDOR_ID_RP 0x11fe +#define PCI_DEVICE_ID_RP32INTF 0x0001 +#define PCI_DEVICE_ID_RP8INTF 0x0002 +#define PCI_DEVICE_ID_RP16INTF 0x0003 +#define PCI_DEVICE_ID_RP4QUAD 0x0004 +#define PCI_DEVICE_ID_RP8OCTA 0x0005 +#define PCI_DEVICE_ID_RP8J 0x0006 +#define PCI_DEVICE_ID_RP4J 0x0007 +#define PCI_DEVICE_ID_RP8SNI 0x0008 +#define PCI_DEVICE_ID_RP16SNI 0x0009 +#define PCI_DEVICE_ID_RPP4 0x000A +#define PCI_DEVICE_ID_RPP8 0x000B +#define PCI_DEVICE_ID_RP4M 0x000D +#define PCI_DEVICE_ID_RP2_232 0x000E +#define PCI_DEVICE_ID_RP2_422 0x000F +#define PCI_DEVICE_ID_URP32INTF 0x0801 +#define PCI_DEVICE_ID_URP8INTF 0x0802 +#define PCI_DEVICE_ID_URP16INTF 0x0803 +#define PCI_DEVICE_ID_URP8OCTA 0x0805 +#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C +#define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D +#define PCI_DEVICE_ID_CRP16INTF 0x0903 + +#define PCI_VENDOR_ID_CYCLADES 0x120e +#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100 +#define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101 +#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102 +#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103 +#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104 +#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105 +#define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200 +#define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201 +#define PCI_DEVICE_ID_PC300_RX_2 0x0300 +#define PCI_DEVICE_ID_PC300_RX_1 0x0301 +#define PCI_DEVICE_ID_PC300_TE_2 0x0310 +#define PCI_DEVICE_ID_PC300_TE_1 0x0311 +#define PCI_DEVICE_ID_PC300_TE_M_2 0x0320 +#define PCI_DEVICE_ID_PC300_TE_M_1 0x0321 + +#define PCI_VENDOR_ID_ESSENTIAL 0x120f +#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001 + +#define PCI_VENDOR_ID_O2 0x1217 +#define PCI_DEVICE_ID_O2_6729 0x6729 +#define PCI_DEVICE_ID_O2_6730 0x673a +#define PCI_DEVICE_ID_O2_6832 0x6832 +#define PCI_DEVICE_ID_O2_6836 0x6836 + +#define PCI_VENDOR_ID_3DFX 0x121a +#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001 +#define PCI_DEVICE_ID_3DFX_VOODOO2 0x0002 +#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003 +#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005 +#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009 + + + +#define PCI_VENDOR_ID_AVM 0x1244 +#define PCI_DEVICE_ID_AVM_B1 0x0700 +#define PCI_DEVICE_ID_AVM_C4 0x0800 +#define PCI_DEVICE_ID_AVM_A1 0x0a00 +#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00 +#define PCI_DEVICE_ID_AVM_C2 0x1100 +#define PCI_DEVICE_ID_AVM_T1 0x1200 + + +#define PCI_VENDOR_ID_STALLION 0x124d + +/* Allied Telesyn */ +#define PCI_VENDOR_ID_AT 0x1259 +#define PCI_SUBDEVICE_ID_AT_2700FX 0x2701 +#define PCI_SUBDEVICE_ID_AT_2701FX 0x2703 + +#define PCI_VENDOR_ID_ESS 0x125d +#define PCI_DEVICE_ID_ESS_ESS1968 0x1968 +#define PCI_DEVICE_ID_ESS_ESS1978 0x1978 +#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988 +#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989 +#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990 +#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992 +#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998 +#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999 +#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a +#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b + +#define PCI_VENDOR_ID_SATSAGEM 0x1267 +#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 + + +#define PCI_VENDOR_ID_ENSONIQ 0x1274 +#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 +#define PCI_DEVICE_ID_ENSONIQ_ES1370 0x5000 +#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371 + +#define PCI_VENDOR_ID_TRANSMETA 0x1279 +#define PCI_DEVICE_ID_EFFICEON 0x0060 + +#define PCI_VENDOR_ID_ROCKWELL 0x127A + +#define PCI_VENDOR_ID_ITE 0x1283 +#define PCI_DEVICE_ID_ITE_IT8172G 0x8172 +#define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801 +#define PCI_DEVICE_ID_ITE_8211 0x8211 +#define PCI_DEVICE_ID_ITE_8212 0x8212 +#define PCI_DEVICE_ID_ITE_8872 0x8872 +#define PCI_DEVICE_ID_ITE_IT8330G_0 0xe886 + +/* formerly Platform Tech */ +#define PCI_DEVICE_ID_ESS_ESS0100 0x0100 + +#define PCI_VENDOR_ID_ALTEON 0x12ae + + +#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232 0x0003 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485 0x0004 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4 0x0005 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485 0x0006 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2 0x0007 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485 0x0008 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6 0x0009 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_20MHZ 0x000C +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_PTM 0x000D +#define PCI_SUBDEVICE_ID_CONNECT_TECH_NT960PCI 0x0100 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_2 0x0201 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_4 0x0202 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_232 0x0300 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_232 0x0301 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_232 0x0302 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1 0x0310 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2 0x0311 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4 0x0312 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2 0x0320 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4 0x0321 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8 0x0322 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_485 0x0330 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_485 0x0331 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_485 0x0332 + + +#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2 +#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018 + +#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16 0x0011 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC 0x0041 +#define PCI_SUBVENDOR_ID_CHASE_PCIRAS 0x124D +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS4 0xF001 +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS8 0xF010 + +#define PCI_VENDOR_ID_AUREAL 0x12eb +#define PCI_DEVICE_ID_AUREAL_VORTEX_1 0x0001 +#define PCI_DEVICE_ID_AUREAL_VORTEX_2 0x0002 +#define PCI_DEVICE_ID_AUREAL_ADVANTAGE 0x0003 + +#define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8 +#define PCI_DEVICE_ID_LML_33R10 0x8a02 + + +#define PCI_VENDOR_ID_SIIG 0x131f +#define PCI_SUBVENDOR_ID_SIIG 0x131f +#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000 +#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001 +#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_550 0x1010 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_650 0x1011 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_850 0x1012 +#define PCI_DEVICE_ID_SIIG_1P_10x 0x1020 +#define PCI_DEVICE_ID_SIIG_2P_10x 0x1021 +#define PCI_DEVICE_ID_SIIG_2S_10x_550 0x1030 +#define PCI_DEVICE_ID_SIIG_2S_10x_650 0x1031 +#define PCI_DEVICE_ID_SIIG_2S_10x_850 0x1032 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_550 0x1034 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_650 0x1035 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_850 0x1036 +#define PCI_DEVICE_ID_SIIG_4S_10x_550 0x1050 +#define PCI_DEVICE_ID_SIIG_4S_10x_650 0x1051 +#define PCI_DEVICE_ID_SIIG_4S_10x_850 0x1052 +#define PCI_DEVICE_ID_SIIG_1S_20x_550 0x2000 +#define PCI_DEVICE_ID_SIIG_1S_20x_650 0x2001 +#define PCI_DEVICE_ID_SIIG_1S_20x_850 0x2002 +#define PCI_DEVICE_ID_SIIG_1P_20x 0x2020 +#define PCI_DEVICE_ID_SIIG_2P_20x 0x2021 +#define PCI_DEVICE_ID_SIIG_2S_20x_550 0x2030 +#define PCI_DEVICE_ID_SIIG_2S_20x_650 0x2031 +#define PCI_DEVICE_ID_SIIG_2S_20x_850 0x2032 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_550 0x2040 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_650 0x2041 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_850 0x2042 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_550 0x2010 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_650 0x2011 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_850 0x2012 +#define PCI_DEVICE_ID_SIIG_4S_20x_550 0x2050 +#define PCI_DEVICE_ID_SIIG_4S_20x_650 0x2051 +#define PCI_DEVICE_ID_SIIG_4S_20x_850 0x2052 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062 +#define PCI_DEVICE_ID_SIIG_8S_20x_550 0x2080 +#define PCI_DEVICE_ID_SIIG_8S_20x_650 0x2081 +#define PCI_DEVICE_ID_SIIG_8S_20x_850 0x2082 +#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050 + +#define PCI_VENDOR_ID_RADISYS 0x1331 + +#define PCI_VENDOR_ID_DOMEX 0x134a +#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001 + +#define PCI_VENDOR_ID_QUATECH 0x135C +#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010 +#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020 +#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050 +#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060 + +#define PCI_VENDOR_ID_SEALEVEL 0x135e +#define PCI_DEVICE_ID_SEALEVEL_U530 0x7101 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM2 0x7201 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM422 0x7402 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM232 0x7202 +#define PCI_DEVICE_ID_SEALEVEL_COMM4 0x7401 +#define PCI_DEVICE_ID_SEALEVEL_COMM8 0x7801 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM8 0x7804 + +#define PCI_VENDOR_ID_HYPERCOPE 0x1365 +#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050 +#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104 +#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106 +#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107 +#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108 + +#define PCI_VENDOR_ID_KAWASAKI 0x136b +#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01 + +#define PCI_VENDOR_ID_CNET 0x1371 +#define PCI_DEVICE_ID_CNET_GIGACARD 0x434e + +#define PCI_VENDOR_ID_LMC 0x1376 +#define PCI_DEVICE_ID_LMC_HSSI 0x0003 +#define PCI_DEVICE_ID_LMC_DS3 0x0004 +#define PCI_DEVICE_ID_LMC_SSI 0x0005 +#define PCI_DEVICE_ID_LMC_T1 0x0006 + + +#define PCI_VENDOR_ID_NETGEAR 0x1385 +#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a + +#define PCI_VENDOR_ID_APPLICOM 0x1389 +#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001 +#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002 +#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 + +#define PCI_VENDOR_ID_MOXA 0x1393 +#define PCI_DEVICE_ID_MOXA_RC7000 0x0001 +#define PCI_DEVICE_ID_MOXA_CP102 0x1020 +#define PCI_DEVICE_ID_MOXA_CP102UL 0x1021 +#define PCI_DEVICE_ID_MOXA_CP102U 0x1022 +#define PCI_DEVICE_ID_MOXA_C104 0x1040 +#define PCI_DEVICE_ID_MOXA_CP104U 0x1041 +#define PCI_DEVICE_ID_MOXA_CP104JU 0x1042 +#define PCI_DEVICE_ID_MOXA_CT114 0x1140 +#define PCI_DEVICE_ID_MOXA_CP114 0x1141 +#define PCI_DEVICE_ID_MOXA_CP118U 0x1180 +#define PCI_DEVICE_ID_MOXA_CP132 0x1320 +#define PCI_DEVICE_ID_MOXA_CP132U 0x1321 +#define PCI_DEVICE_ID_MOXA_CP134U 0x1340 +#define PCI_DEVICE_ID_MOXA_C168 0x1680 +#define PCI_DEVICE_ID_MOXA_CP168U 0x1681 + +#define PCI_VENDOR_ID_CCD 0x1397 +#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0 +#define PCI_DEVICE_ID_CCD_B000 0xb000 +#define PCI_DEVICE_ID_CCD_B006 0xb006 +#define PCI_DEVICE_ID_CCD_B007 0xb007 +#define PCI_DEVICE_ID_CCD_B008 0xb008 +#define PCI_DEVICE_ID_CCD_B009 0xb009 +#define PCI_DEVICE_ID_CCD_B00A 0xb00a +#define PCI_DEVICE_ID_CCD_B00B 0xb00b +#define PCI_DEVICE_ID_CCD_B00C 0xb00c +#define PCI_DEVICE_ID_CCD_B100 0xb100 +#define PCI_DEVICE_ID_CCD_B700 0xb700 +#define PCI_DEVICE_ID_CCD_B701 0xb701 + +#define PCI_VENDOR_ID_EXAR 0x13a8 +#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152 +#define PCI_DEVICE_ID_EXAR_XR17C154 0x0154 +#define PCI_DEVICE_ID_EXAR_XR17C158 0x0158 + +#define PCI_VENDOR_ID_MICROGATE 0x13c0 +#define PCI_DEVICE_ID_MICROGATE_USC 0x0010 +#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030 + +#define PCI_VENDOR_ID_3WARE 0x13C1 +#define PCI_DEVICE_ID_3WARE_1000 0x1000 +#define PCI_DEVICE_ID_3WARE_7000 0x1001 +#define PCI_DEVICE_ID_3WARE_9000 0x1002 + +#define PCI_VENDOR_ID_IOMEGA 0x13ca +#define PCI_DEVICE_ID_IOMEGA_BUZ 0x4231 + +#define PCI_VENDOR_ID_ABOCOM 0x13D1 +#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1 + +#define PCI_VENDOR_ID_CMEDIA 0x13f6 +#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100 +#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101 +#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111 +#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112 + +#define PCI_VENDOR_ID_LAVA 0x1407 +#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */ +#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_A 0x0180 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_B 0x0181 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200 /* 2x 16650 */ +#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500 /* 1x 16550 */ +#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600 /* 1x 16650 */ +#define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000 +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002 /* The Lava Dual Parallel is */ +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003 /* two PCI devices on a card */ +#define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800 + +#define PCI_VENDOR_ID_TIMEDIA 0x1409 +#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168 + +#define PCI_VENDOR_ID_ICE 0x1412 +#define PCI_DEVICE_ID_ICE_1712 0x1712 +#define PCI_DEVICE_ID_VT1724 0x1724 + +#define PCI_VENDOR_ID_OXSEMI 0x1415 +#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403 +#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501 +#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511 +#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513 +#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521 + +#define PCI_VENDOR_ID_SAMSUNG 0x144d + + +#define PCI_VENDOR_ID_TITAN 0x14D2 +#define PCI_DEVICE_ID_TITAN_010L 0x8001 +#define PCI_DEVICE_ID_TITAN_100L 0x8010 +#define PCI_DEVICE_ID_TITAN_110L 0x8011 +#define PCI_DEVICE_ID_TITAN_200L 0x8020 +#define PCI_DEVICE_ID_TITAN_210L 0x8021 +#define PCI_DEVICE_ID_TITAN_400L 0x8040 +#define PCI_DEVICE_ID_TITAN_800L 0x8080 +#define PCI_DEVICE_ID_TITAN_100 0xA001 +#define PCI_DEVICE_ID_TITAN_200 0xA005 +#define PCI_DEVICE_ID_TITAN_400 0xA003 +#define PCI_DEVICE_ID_TITAN_800B 0xA004 + +#define PCI_VENDOR_ID_PANACOM 0x14d4 +#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400 +#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402 + + +#define PCI_VENDOR_ID_AFAVLAB 0x14db +#define PCI_DEVICE_ID_AFAVLAB_P028 0x2180 +#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 +#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150 + +#define PCI_VENDOR_ID_BROADCOM 0x14e4 +#define PCI_DEVICE_ID_TIGON3_5752 0x1600 +#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 +#define PCI_DEVICE_ID_TIGON3_5700 0x1644 +#define PCI_DEVICE_ID_TIGON3_5701 0x1645 +#define PCI_DEVICE_ID_TIGON3_5702 0x1646 +#define PCI_DEVICE_ID_TIGON3_5703 0x1647 +#define PCI_DEVICE_ID_TIGON3_5704 0x1648 +#define PCI_DEVICE_ID_TIGON3_5704S_2 0x1649 +#define PCI_DEVICE_ID_NX2_5706 0x164a +#define PCI_DEVICE_ID_NX2_5708 0x164c +#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d +#define PCI_DEVICE_ID_TIGON3_5705 0x1653 +#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 +#define PCI_DEVICE_ID_TIGON3_5720 0x1658 +#define PCI_DEVICE_ID_TIGON3_5721 0x1659 +#define PCI_DEVICE_ID_TIGON3_5705M 0x165d +#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e +#define PCI_DEVICE_ID_TIGON3_5714 0x1668 +#define PCI_DEVICE_ID_TIGON3_5714S 0x1669 +#define PCI_DEVICE_ID_TIGON3_5780 0x166a +#define PCI_DEVICE_ID_TIGON3_5780S 0x166b +#define PCI_DEVICE_ID_TIGON3_5705F 0x166e +#define PCI_DEVICE_ID_TIGON3_5750 0x1676 +#define PCI_DEVICE_ID_TIGON3_5751 0x1677 +#define PCI_DEVICE_ID_TIGON3_5715 0x1678 +#define PCI_DEVICE_ID_TIGON3_5715S 0x1679 +#define PCI_DEVICE_ID_TIGON3_5750M 0x167c +#define PCI_DEVICE_ID_TIGON3_5751M 0x167d +#define PCI_DEVICE_ID_TIGON3_5751F 0x167e +#define PCI_DEVICE_ID_TIGON3_5782 0x1696 +#define PCI_DEVICE_ID_TIGON3_5788 0x169c +#define PCI_DEVICE_ID_TIGON3_5789 0x169d +#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6 +#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7 +#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8 +#define PCI_DEVICE_ID_NX2_5706S 0x16aa +#define PCI_DEVICE_ID_NX2_5708S 0x16ac +#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6 +#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7 +#define PCI_DEVICE_ID_TIGON3_5781 0x16dd +#define PCI_DEVICE_ID_TIGON3_5753 0x16f7 +#define PCI_DEVICE_ID_TIGON3_5753M 0x16fd +#define PCI_DEVICE_ID_TIGON3_5753F 0x16fe +#define PCI_DEVICE_ID_TIGON3_5901 0x170d +#define PCI_DEVICE_ID_BCM4401B1 0x170c +#define PCI_DEVICE_ID_TIGON3_5901_2 0x170e +#define PCI_DEVICE_ID_BCM4401 0x4401 +#define PCI_DEVICE_ID_BCM4401B0 0x4402 + +#define PCI_VENDOR_ID_TOPIC 0x151f +#define PCI_DEVICE_ID_TOPIC_TP560 0x0000 + +#define PCI_VENDOR_ID_ENE 0x1524 +#define PCI_DEVICE_ID_ENE_1211 0x1211 +#define PCI_DEVICE_ID_ENE_1225 0x1225 +#define PCI_DEVICE_ID_ENE_1410 0x1410 +#define PCI_DEVICE_ID_ENE_710 0x1411 +#define PCI_DEVICE_ID_ENE_712 0x1412 +#define PCI_DEVICE_ID_ENE_1420 0x1420 +#define PCI_DEVICE_ID_ENE_720 0x1421 +#define PCI_DEVICE_ID_ENE_722 0x1422 + +#define PCI_VENDOR_ID_CHELSIO 0x1425 + + +#define PCI_VENDOR_ID_SYBA 0x1592 +#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782 +#define PCI_DEVICE_ID_SYBA_1P_ECP 0x0783 + +#define PCI_VENDOR_ID_MORETON 0x15aa +#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000 + +#define PCI_VENDOR_ID_ZOLTRIX 0x15b0 +#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0 + +#define PCI_VENDOR_ID_MELLANOX 0x15b3 +#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 +#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278 +#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282 +#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c +#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 + +#define PCI_VENDOR_ID_PDC 0x15e9 + + +#define PCI_VENDOR_ID_FARSITE 0x1619 +#define PCI_DEVICE_ID_FARSITE_T2P 0x0400 +#define PCI_DEVICE_ID_FARSITE_T4P 0x0440 +#define PCI_DEVICE_ID_FARSITE_T1U 0x0610 +#define PCI_DEVICE_ID_FARSITE_T2U 0x0620 +#define PCI_DEVICE_ID_FARSITE_T4U 0x0640 +#define PCI_DEVICE_ID_FARSITE_TE1 0x1610 +#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612 + +#define PCI_VENDOR_ID_SIBYTE 0x166d +#define PCI_DEVICE_ID_BCM1250_HT 0x0002 + +#define PCI_VENDOR_ID_NETCELL 0x169c +#define PCI_DEVICE_ID_REVOLUTION 0x0044 + +#define PCI_VENDOR_ID_LINKSYS 0x1737 +#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064 + +#define PCI_VENDOR_ID_ALTIMA 0x173b +#define PCI_DEVICE_ID_ALTIMA_AC1000 0x03e8 +#define PCI_DEVICE_ID_ALTIMA_AC1001 0x03e9 +#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea +#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb + +#define PCI_VENDOR_ID_S2IO 0x17d5 +#define PCI_DEVICE_ID_S2IO_WIN 0x5731 +#define PCI_DEVICE_ID_S2IO_UNI 0x5831 +#define PCI_DEVICE_ID_HERC_WIN 0x5732 +#define PCI_DEVICE_ID_HERC_UNI 0x5832 + + +#define PCI_VENDOR_ID_SITECOM 0x182d +#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069 + +#define PCI_VENDOR_ID_TOPSPIN 0x1867 + +#define PCI_VENDOR_ID_TDI 0x192E +#define PCI_DEVICE_ID_TDI_EHCI 0x0101 + + +#define PCI_VENDOR_ID_TEKRAM 0x1de1 +#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 + +#define PCI_VENDOR_ID_HINT 0x3388 +#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013 + +#define PCI_VENDOR_ID_3DLABS 0x3d3d +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007 +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009 + + +#define PCI_VENDOR_ID_AKS 0x416c +#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100 + + + +#define PCI_VENDOR_ID_S3 0x5333 +#define PCI_DEVICE_ID_S3_TRIO 0x8811 +#define PCI_DEVICE_ID_S3_868 0x8880 +#define PCI_DEVICE_ID_S3_968 0x88f0 +#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 +#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04 +#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00 + +#define PCI_VENDOR_ID_DUNORD 0x5544 +#define PCI_DEVICE_ID_DUNORD_I3000 0x0001 + + +#define PCI_VENDOR_ID_DCI 0x6666 +#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001 +#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002 +#define PCI_DEVICE_ID_DCI_PCCOM2 0x0004 + +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_EESSC 0x0008 +#define PCI_DEVICE_ID_INTEL_PXHD_0 0x0320 +#define PCI_DEVICE_ID_INTEL_PXHD_1 0x0321 +#define PCI_DEVICE_ID_INTEL_PXH_0 0x0329 +#define PCI_DEVICE_ID_INTEL_PXH_1 0x032A +#define PCI_DEVICE_ID_INTEL_PXHV 0x032C +#define PCI_DEVICE_ID_INTEL_82375 0x0482 +#define PCI_DEVICE_ID_INTEL_82424 0x0483 +#define PCI_DEVICE_ID_INTEL_82378 0x0484 +#define PCI_DEVICE_ID_INTEL_I960 0x0960 +#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 +#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130 +#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 +#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 +#define PCI_DEVICE_ID_INTEL_7505_0 0x2550 +#define PCI_DEVICE_ID_INTEL_7205_0 0x255d +#define PCI_DEVICE_ID_INTEL_82437 0x122d +#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e +#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230 +#define PCI_DEVICE_ID_INTEL_82371MX 0x1234 +#define PCI_DEVICE_ID_INTEL_82441 0x1237 +#define PCI_DEVICE_ID_INTEL_82380FB 0x124b +#define PCI_DEVICE_ID_INTEL_82439 0x1250 +#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960 +#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 +#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 +#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 +#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 +#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 +#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415 +#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416 +#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418 +#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420 +#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421 +#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423 +#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425 +#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426 +#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428 +#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440 +#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443 +#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445 +#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448 +#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a +#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b +#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c +#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e +#define PCI_DEVICE_ID_INTEL_82801E_0 0x2450 +#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b +#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480 +#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483 +#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485 +#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486 +#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a +#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b +#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c +#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0 +#define PCI_DEVICE_ID_INTEL_82801DB_1 0x24c1 +#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3 +#define PCI_DEVICE_ID_INTEL_82801DB_5 0x24c5 +#define PCI_DEVICE_ID_INTEL_82801DB_6 0x24c6 +#define PCI_DEVICE_ID_INTEL_82801DB_9 0x24c9 +#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca +#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb +#define PCI_DEVICE_ID_INTEL_82801DB_12 0x24cc +#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0 +#define PCI_DEVICE_ID_INTEL_82801EB_1 0x24d1 +#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3 +#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5 +#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6 +#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db +#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd +#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1 +#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2 +#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4 +#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6 +#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab +#define PCI_DEVICE_ID_INTEL_82820_HB 0x2500 +#define PCI_DEVICE_ID_INTEL_82820_UP_HB 0x2501 +#define PCI_DEVICE_ID_INTEL_82850_HB 0x2530 +#define PCI_DEVICE_ID_INTEL_82860_HB 0x2531 +#define PCI_DEVICE_ID_INTEL_82845G_HB 0x2560 +#define PCI_DEVICE_ID_INTEL_82845G_IG 0x2562 +#define PCI_DEVICE_ID_INTEL_82865_HB 0x2570 +#define PCI_DEVICE_ID_INTEL_82865_IG 0x2572 +#define PCI_DEVICE_ID_INTEL_82875_HB 0x2578 +#define PCI_DEVICE_ID_INTEL_82915G_HB 0x2580 +#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 +#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 +#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 +#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 +#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 +#define PCI_DEVICE_ID_INTEL_82945GM_HB 0x27A0 +#define PCI_DEVICE_ID_INTEL_82945GM_IG 0x27A2 +#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 +#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 +#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 +#define PCI_DEVICE_ID_INTEL_ICH6_16 0x266a +#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d +#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e +#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f +#define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670 +#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698 +#define PCI_DEVICE_ID_INTEL_ESB2_17 0x269b +#define PCI_DEVICE_ID_INTEL_ESB2_18 0x269e +#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8 +#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9 +#define PCI_DEVICE_ID_INTEL_ICH7_30 0x27b0 +#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd +#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da +#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd +#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de +#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df +#define PCI_DEVICE_ID_INTEL_ICH8_0 0x2810 +#define PCI_DEVICE_ID_INTEL_ICH8_1 0x2811 +#define PCI_DEVICE_ID_INTEL_ICH8_2 0x2812 +#define PCI_DEVICE_ID_INTEL_ICH8_3 0x2814 +#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815 +#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e +#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850 +#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 +#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 +#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 +#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580 +#define PCI_DEVICE_ID_INTEL_82855GM_IG 0x3582 +#define PCI_DEVICE_ID_INTEL_E7520_MCH 0x3590 +#define PCI_DEVICE_ID_INTEL_E7320_MCH 0x3592 +#define PCI_DEVICE_ID_INTEL_MCH_PA 0x3595 +#define PCI_DEVICE_ID_INTEL_MCH_PA1 0x3596 +#define PCI_DEVICE_ID_INTEL_MCH_PB 0x3597 +#define PCI_DEVICE_ID_INTEL_MCH_PB1 0x3598 +#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599 +#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a +#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e +#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000 +#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010 +#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 +#define PCI_DEVICE_ID_INTEL_82437VX 0x7030 +#define PCI_DEVICE_ID_INTEL_82439TX 0x7100 +#define PCI_DEVICE_ID_INTEL_82371AB_0 0x7110 +#define PCI_DEVICE_ID_INTEL_82371AB 0x7111 +#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112 +#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113 +#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120 +#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121 +#define PCI_DEVICE_ID_INTEL_82810_MC3 0x7122 +#define PCI_DEVICE_ID_INTEL_82810_IG3 0x7123 +#define PCI_DEVICE_ID_INTEL_82810E_MC 0x7124 +#define PCI_DEVICE_ID_INTEL_82810E_IG 0x7125 +#define PCI_DEVICE_ID_INTEL_82443LX_0 0x7180 +#define PCI_DEVICE_ID_INTEL_82443LX_1 0x7181 +#define PCI_DEVICE_ID_INTEL_82443BX_0 0x7190 +#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191 +#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192 +#define PCI_DEVICE_ID_INTEL_440MX 0x7195 +#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196 +#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198 +#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199 +#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b +#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0 +#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 +#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 +#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 +#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 +#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca +#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb +#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea +#define PCI_DEVICE_ID_INTEL_IXP4XX 0x8500 +#define PCI_DEVICE_ID_INTEL_IXP2800 0x9004 +#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 + +#define PCI_VENDOR_ID_SCALEMP 0x8686 +#define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010 + +#define PCI_VENDOR_ID_COMPUTONE 0x8e0e +#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291 +#define PCI_DEVICE_ID_COMPUTONE_PG 0x0302 +#define PCI_SUBVENDOR_ID_COMPUTONE 0x8e0e +#define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG8 0x0002 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003 + +#define PCI_VENDOR_ID_KTI 0x8e2e + +#define PCI_VENDOR_ID_ADAPTEC 0x9004 +#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078 +#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178 +#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860 +#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078 +#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578 +#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038 +#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075 +#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078 +#define PCI_DEVICE_ID_ADAPTEC_7861 0x6178 +#define PCI_DEVICE_ID_ADAPTEC_7870 0x7078 +#define PCI_DEVICE_ID_ADAPTEC_7871 0x7178 +#define PCI_DEVICE_ID_ADAPTEC_7872 0x7278 +#define PCI_DEVICE_ID_ADAPTEC_7873 0x7378 +#define PCI_DEVICE_ID_ADAPTEC_7874 0x7478 +#define PCI_DEVICE_ID_ADAPTEC_7895 0x7895 +#define PCI_DEVICE_ID_ADAPTEC_7880 0x8078 +#define PCI_DEVICE_ID_ADAPTEC_7881 0x8178 +#define PCI_DEVICE_ID_ADAPTEC_7882 0x8278 +#define PCI_DEVICE_ID_ADAPTEC_7883 0x8378 +#define PCI_DEVICE_ID_ADAPTEC_7884 0x8478 +#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578 +#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678 +#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778 +#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878 + +#define PCI_VENDOR_ID_ADAPTEC2 0x9005 +#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010 +#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011 +#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013 +#define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f +#define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050 +#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051 +#define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f +#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080 +#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081 +#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083 +#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f +#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0 +#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1 +#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3 +#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf +#define PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN 0x0500 +#define PCI_DEVICE_ID_ADAPTEC2_SCAMP 0x0503 + + +#define PCI_VENDOR_ID_HOLTEK 0x9412 +#define PCI_DEVICE_ID_HOLTEK_6565 0x6565 + +#define PCI_VENDOR_ID_NETMOS 0x9710 +#define PCI_DEVICE_ID_NETMOS_9705 0x9705 +#define PCI_DEVICE_ID_NETMOS_9715 0x9715 +#define PCI_DEVICE_ID_NETMOS_9735 0x9735 +#define PCI_DEVICE_ID_NETMOS_9745 0x9745 +#define PCI_DEVICE_ID_NETMOS_9755 0x9755 +#define PCI_DEVICE_ID_NETMOS_9805 0x9805 +#define PCI_DEVICE_ID_NETMOS_9815 0x9815 +#define PCI_DEVICE_ID_NETMOS_9835 0x9835 +#define PCI_DEVICE_ID_NETMOS_9845 0x9845 +#define PCI_DEVICE_ID_NETMOS_9855 0x9855 + +#define PCI_SUBVENDOR_ID_EXSYS 0xd84d +#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014 +#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055 + +#define PCI_VENDOR_ID_TIGERJET 0xe159 +#define PCI_DEVICE_ID_TIGERJET_300 0x0001 +#define PCI_DEVICE_ID_TIGERJET_100 0x0002 + +#define PCI_VENDOR_ID_TTTECH 0x0357 +#define PCI_DEVICE_ID_TTTECH_MC322 0x000A + +#define PCI_VENDOR_ID_XILINX_RME 0xea60 +#define PCI_DEVICE_ID_RME_DIGI32 0x9896 +#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897 +#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898 + diff --git a/ddverify/models/con2/include/linux/pci_regs.h b/ddverify/models/con2/include/linux/pci_regs.h new file mode 100644 index 000000000..d27a78b71 --- /dev/null +++ b/ddverify/models/con2/include/linux/pci_regs.h @@ -0,0 +1,449 @@ +/* + * pci_regs.h + * + * PCI standard defines + * Copyright 1994, Drew Eckhardt + * Copyright 1997--1999 Martin Mares + * + * For more information, please consult the following manuals (look at + * http://www.pcisig.com/ for how to get them): + * + * PCI BIOS Specification + * PCI Local Bus Specification + * PCI to PCI Bridge Specification + * PCI System Design Guide + */ + +#ifndef LINUX_PCI_REGS_H +#define LINUX_PCI_REGS_H + +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes are standardized as follows: + */ +#define PCI_VENDOR_ID 0x00 /* 16 bits */ +#define PCI_DEVICE_ID 0x02 /* 16 bits */ +#define PCI_COMMAND 0x04 /* 16 bits */ +#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ +#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ + +#define PCI_STATUS 0x06 /* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ +#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ +#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVSEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +/* + * Base addresses specify locations in memory or I/O space. + * Decoded size can be determined by writing a value of + * 0xffffffff to the register, and reading it back. Only + * 1 bits are decoded. + */ +#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ +#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ +#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ +#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ +#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ +#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ +#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ +#define PCI_BASE_ADDRESS_SPACE_IO 0x01 +#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ +#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) +#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) +/* bit 1 is reserved if address_space = 1 */ + +/* Header type 0 (normal devices) */ +#define PCI_CARDBUS_CIS 0x28 +#define PCI_SUBSYSTEM_VENDOR_ID 0x2c +#define PCI_SUBSYSTEM_ID 0x2e +#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ +#define PCI_ROM_ADDRESS_ENABLE 0x01 +#define PCI_ROM_ADDRESS_MASK (~0x7ffUL) + +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ + +/* 0x35-0x3b are reserved */ +#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ +#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ +#define PCI_MIN_GNT 0x3e /* 8 bits */ +#define PCI_MAX_LAT 0x3f /* 8 bits */ + +/* Header type 1 (PCI-to-PCI bridges) */ +#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ +#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ +#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ +#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ +#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ +#define PCI_IO_LIMIT 0x1d +#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */ +#define PCI_IO_RANGE_TYPE_16 0x00 +#define PCI_IO_RANGE_TYPE_32 0x01 +#define PCI_IO_RANGE_MASK (~0x0fUL) +#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */ +#define PCI_MEMORY_BASE 0x20 /* Memory range behind */ +#define PCI_MEMORY_LIMIT 0x22 +#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL +#define PCI_MEMORY_RANGE_MASK (~0x0fUL) +#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ +#define PCI_PREF_MEMORY_LIMIT 0x26 +#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL +#define PCI_PREF_RANGE_TYPE_32 0x00 +#define PCI_PREF_RANGE_TYPE_64 0x01 +#define PCI_PREF_RANGE_MASK (~0x0fUL) +#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ +#define PCI_PREF_LIMIT_UPPER32 0x2c +#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ +#define PCI_IO_LIMIT_UPPER16 0x32 +/* 0x34 same as for htype 0 */ +/* 0x35-0x3b is reserved */ +#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_BRIDGE_CONTROL 0x3e +#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ +#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ +#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ +#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ +#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ +#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ +#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ + +/* Header type 2 (CardBus bridges) */ +#define PCI_CB_CAPABILITY_LIST 0x14 +/* 0x15 reserved */ +#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ +#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ +#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ +#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ +#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ +#define PCI_CB_MEMORY_BASE_0 0x1c +#define PCI_CB_MEMORY_LIMIT_0 0x20 +#define PCI_CB_MEMORY_BASE_1 0x24 +#define PCI_CB_MEMORY_LIMIT_1 0x28 +#define PCI_CB_IO_BASE_0 0x2c +#define PCI_CB_IO_BASE_0_HI 0x2e +#define PCI_CB_IO_LIMIT_0 0x30 +#define PCI_CB_IO_LIMIT_0_HI 0x32 +#define PCI_CB_IO_BASE_1 0x34 +#define PCI_CB_IO_BASE_1_HI 0x36 +#define PCI_CB_IO_LIMIT_1 0x38 +#define PCI_CB_IO_LIMIT_1_HI 0x3a +#define PCI_CB_IO_RANGE_MASK (~0x03UL) +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_CB_BRIDGE_CONTROL 0x3e +#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ +#define PCI_CB_BRIDGE_CTL_SERR 0x02 +#define PCI_CB_BRIDGE_CTL_ISA 0x04 +#define PCI_CB_BRIDGE_CTL_VGA 0x08 +#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 +#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ +#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 +#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 +#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 +#define PCI_CB_SUBSYSTEM_ID 0x42 +#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ +/* 0x48-0x7f reserved */ + +/* Capability lists */ + +#define PCI_CAP_LIST_ID 0 /* Capability ID */ +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ +#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ +#define PCI_CAP_ID_HT_IRQCONF 0x08 /* HyperTransport IRQ Configuration */ +#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ +#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + +/* Power Management Registers */ + +#define PCI_PM_PMC 2 /* PM Capabilities Register */ +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ +#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ +#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */ +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ +#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */ +#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */ +#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */ +#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ +#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ +#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ +#define PCI_PM_CTRL 4 /* PM control and status register */ +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_NO_SOFT_RESET 0x0004 /* No reset for D3hot->D0 */ +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ +#define PCI_PM_DATA_REGISTER 7 /* (??) */ +#define PCI_PM_SIZEOF 8 + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ +#define PCI_AGP_SIZEOF 12 + +/* Vital Product Data */ + +#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */ +#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */ +#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */ +#define PCI_VPD_DATA 4 /* 32-bits of data returned here */ + +/* Slot Identification */ + +#define PCI_SID_ESR 2 /* Expansion Slot Register */ +#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ +#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ +#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ + +/* Message Signalled Interrupts registers */ + +#define PCI_MSI_FLAGS 2 /* Various flags */ +#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ +#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ +#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ +#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ +#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */ +#define PCI_MSI_RFU 3 /* Rest of capability flags */ +#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ +#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ +#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ +#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ +#define PCI_MSI_MASK_BIT 16 /* Mask bits register */ + +/* CompactPCI Hotswap Register */ + +#define PCI_CHSWP_CSR 2 /* Control and Status Register */ +#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */ +#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */ +#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */ +#define PCI_CHSWP_LOO 0x08 /* LED On / Off */ +#define PCI_CHSWP_PI 0x30 /* Programming Interface */ +#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */ +#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */ + +/* PCI-X registers */ + +#define PCI_X_CMD 2 /* Modes & Features */ +#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */ +#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */ +#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */ +#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */ +#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */ +#define PCI_X_STATUS 4 /* PCI-X capabilities */ +#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */ +#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */ +#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */ +#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */ +#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */ +#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */ +#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */ +#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */ +#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */ +#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */ +#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */ +#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */ +#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */ + +/* PCI Express capability registers */ + +#define PCI_EXP_FLAGS 2 /* Capabilities register */ +#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */ +#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */ +#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */ +#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */ +#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */ +#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ +#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ +#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ +#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ +#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ +#define PCI_EXP_DEVCAP 4 /* Device capabilities */ +#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */ +#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */ +#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */ +#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */ +#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */ +#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ +#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ +#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ +#define PCI_EXP_DEVCTL 8 /* Device Control */ +#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ +#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ +#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */ +#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ +#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ +#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ +#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */ +#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ +#define PCI_EXP_DEVSTA 10 /* Device Status */ +#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ +#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ +#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */ +#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ +#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ +#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ +#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ +#define PCI_EXP_LNKCTL 16 /* Link Control */ +#define PCI_EXP_LNKSTA 18 /* Link Status */ +#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ +#define PCI_EXP_SLTCTL 24 /* Slot Control */ +#define PCI_EXP_SLTSTA 26 /* Slot Status */ +#define PCI_EXP_RTCTL 28 /* Root Control */ +#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */ +#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */ +#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */ +#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */ +#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ +#define PCI_EXP_RTCAP 30 /* Root Capabilities */ +#define PCI_EXP_RTSTA 32 /* Root Status */ + +/* Extended Capabilities (PCI-X 2.0 and Express) */ +#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) +#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf) +#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) + +#define PCI_EXT_CAP_ID_ERR 1 +#define PCI_EXT_CAP_ID_VC 2 +#define PCI_EXT_CAP_ID_DSN 3 +#define PCI_EXT_CAP_ID_PWR 4 + +/* Advanced Error Reporting */ +#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ +#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */ +#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */ +#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */ +#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */ +#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */ +#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */ +#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */ +#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */ +#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */ +#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */ +#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */ +#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */ + /* Same bits as above */ +#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */ +#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */ +#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */ +#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */ +#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */ +#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */ +#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */ +#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */ +#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */ +#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */ +#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ +#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ +#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */ +#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */ +#define PCI_ERR_ROOT_STATUS 48 +#define PCI_ERR_ROOT_COR_SRC 52 +#define PCI_ERR_ROOT_SRC 54 + +/* Virtual Channel */ +#define PCI_VC_PORT_REG1 4 +#define PCI_VC_PORT_REG2 8 +#define PCI_VC_PORT_CTRL 12 +#define PCI_VC_PORT_STATUS 14 +#define PCI_VC_RES_CAP 16 +#define PCI_VC_RES_CTRL 20 +#define PCI_VC_RES_STATUS 26 + +/* Power Budgeting */ +#define PCI_PWR_DSR 4 /* Data Select Register */ +#define PCI_PWR_DATA 8 /* Data Register */ +#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */ +#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */ +#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */ +#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */ +#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */ +#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */ +#define PCI_PWR_CAP 12 /* Capability */ +#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ + +#endif /* LINUX_PCI_REGS_H */ diff --git a/ddverify/models/con2/include/linux/percpu.h b/ddverify/models/con2/include/linux/percpu.h new file mode 100644 index 000000000..8e9945bd8 --- /dev/null +++ b/ddverify/models/con2/include/linux/percpu.h @@ -0,0 +1,10 @@ +#ifndef __LINUX_PERCPU_H +#define __LINUX_PERCPU_H + +#include +#include +//#include +#include +//#include + +#endif /* __LINUX_PERCPU_H */ diff --git a/ddverify/models/con2/include/linux/platform_device.h b/ddverify/models/con2/include/linux/platform_device.h new file mode 100644 index 000000000..97a8fed3f --- /dev/null +++ b/ddverify/models/con2/include/linux/platform_device.h @@ -0,0 +1,25 @@ +#ifndef _PLATFORM_DEVICE_H_ +#define _PLATFORM_DEVICE_H_ + +#include + +struct platform_device { + const char * name; + u32 id; + struct device dev; + u32 num_resources; + struct resource * resource; +}; + +struct platform_driver { + int (*probe)(struct platform_device *); + int (*remove)(struct platform_device *); + void (*shutdown)(struct platform_device *); + int (*suspend)(struct platform_device *, pm_message_t state); + int (*suspend_late)(struct platform_device *, pm_message_t state); + int (*resume_early)(struct platform_device *); + int (*resume)(struct platform_device *); + struct device_driver driver; +}; + +#endif /* _PLATFORM_DEVICE_H_ */ diff --git a/ddverify/models/con2/include/linux/pm.h b/ddverify/models/con2/include/linux/pm.h new file mode 100644 index 000000000..430226d01 --- /dev/null +++ b/ddverify/models/con2/include/linux/pm.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_PM_H +#define _LINUX_PM_H + +#include +#include +#include + +typedef struct pm_message { + int event; +} pm_message_t; + +#endif /* _LINUX_PM_H */ diff --git a/ddverify/models/con2/include/linux/pnp.h b/ddverify/models/con2/include/linux/pnp.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/poll.h b/ddverify/models/con2/include/linux/poll.h new file mode 100644 index 000000000..326affc5f --- /dev/null +++ b/ddverify/models/con2/include/linux/poll.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_POLL_H +#define _LINUX_POLL_H + +#include +#include +#include +#include +#include + +typedef struct poll_table_struct { + int something; +} poll_table; + +void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p); + +#endif /* _LINUX_POLL_H */ diff --git a/ddverify/models/con2/include/linux/posix_types.h b/ddverify/models/con2/include/linux/posix_types.h new file mode 100644 index 000000000..f60a473e2 --- /dev/null +++ b/ddverify/models/con2/include/linux/posix_types.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_POSIX_TYPES_H +#define _LINUX_POSIX_TYPES_H + +typedef int __kernel_key_t; +typedef int __kernel_mqd_t; + +#include + +#endif /* _LINUX_POSIX_TYPES_H */ diff --git a/ddverify/models/con2/include/linux/proc_fs.h b/ddverify/models/con2/include/linux/proc_fs.h new file mode 100644 index 000000000..48ffb5cf2 --- /dev/null +++ b/ddverify/models/con2/include/linux/proc_fs.h @@ -0,0 +1,29 @@ +#ifndef _LINUX_PROC_FS_H +#define _LINUX_PROC_FS_H + +#include +#include + +struct proc_dir_entry { + int something; +}; + +struct proc_dir_entry *proc_root_driver; + +typedef int (read_proc_t)(char *page, char **start, off_t off, + int count, int *eof, void *data); + +struct proc_dir_entry *create_proc_read_entry(const char *name, + mode_t mode, + struct proc_dir_entry *base, + read_proc_t *read_proc, + void * data); + +struct proc_dir_entry *create_proc_entry(const char *name, + mode_t mode, + struct proc_dir_entry *parent); + +void remove_proc_entry(const char *name, struct proc_dir_entry *parent); +struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); + +#endif diff --git a/ddverify/models/con2/include/linux/ptrace.h b/ddverify/models/con2/include/linux/ptrace.h new file mode 100644 index 000000000..e47ffb1ac --- /dev/null +++ b/ddverify/models/con2/include/linux/ptrace.h @@ -0,0 +1,80 @@ +#ifndef _LINUX_PTRACE_H +#define _LINUX_PTRACE_H +/* ptrace.h */ +/* structs and defines to help the user use the ptrace system call. */ + +/* has the defines to get at the registers. */ + +#define PTRACE_TRACEME 0 +#define PTRACE_PEEKTEXT 1 +#define PTRACE_PEEKDATA 2 +#define PTRACE_PEEKUSR 3 +#define PTRACE_POKETEXT 4 +#define PTRACE_POKEDATA 5 +#define PTRACE_POKEUSR 6 +#define PTRACE_CONT 7 +#define PTRACE_KILL 8 +#define PTRACE_SINGLESTEP 9 + +#define PTRACE_ATTACH 16 +#define PTRACE_DETACH 17 + +#define PTRACE_SYSCALL 24 + +/* 0x4200-0x4300 are reserved for architecture-independent additions. */ +#define PTRACE_SETOPTIONS 0x4200 +#define PTRACE_GETEVENTMSG 0x4201 +#define PTRACE_GETSIGINFO 0x4202 +#define PTRACE_SETSIGINFO 0x4203 + +/* options set using PTRACE_SETOPTIONS */ +#define PTRACE_O_TRACESYSGOOD 0x00000001 +#define PTRACE_O_TRACEFORK 0x00000002 +#define PTRACE_O_TRACEVFORK 0x00000004 +#define PTRACE_O_TRACECLONE 0x00000008 +#define PTRACE_O_TRACEEXEC 0x00000010 +#define PTRACE_O_TRACEVFORKDONE 0x00000020 +#define PTRACE_O_TRACEEXIT 0x00000040 + +#define PTRACE_O_MASK 0x0000007f + +/* Wait extended result codes for the above trace options. */ +#define PTRACE_EVENT_FORK 1 +#define PTRACE_EVENT_VFORK 2 +#define PTRACE_EVENT_CLONE 3 +#define PTRACE_EVENT_EXEC 4 +#define PTRACE_EVENT_VFORK_DONE 5 +#define PTRACE_EVENT_EXIT 6 + +/* + * Ptrace flags + * + * The owner ship rules for task->ptrace which holds the ptrace + * flags is simple. When a task is running it owns it's task->ptrace + * flags. When the a task is stopped the ptracer owns task->ptrace. + */ + +#define PT_PTRACED 0x00000001 +#define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ +#define PT_TRACESYSGOOD 0x00000004 +#define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */ +#define PT_TRACE_FORK 0x00000010 +#define PT_TRACE_VFORK 0x00000020 +#define PT_TRACE_CLONE 0x00000040 +#define PT_TRACE_EXEC 0x00000080 +#define PT_TRACE_VFORK_DONE 0x00000100 +#define PT_TRACE_EXIT 0x00000200 +#define PT_ATTACHED 0x00000400 /* parent != real_parent */ + +#define PT_TRACE_MASK 0x000003f4 + +/* single stepping state bits (used on ARM and PA-RISC) */ +#define PT_SINGLESTEP_BIT 31 +#define PT_SINGLESTEP (1< /* For unlikely. */ +#include /* For struct task_struct. */ + +#endif diff --git a/ddverify/models/con2/include/linux/reboot.h b/ddverify/models/con2/include/linux/reboot.h new file mode 100644 index 000000000..b1d2d7da1 --- /dev/null +++ b/ddverify/models/con2/include/linux/reboot.h @@ -0,0 +1,75 @@ +#ifndef _LINUX_REBOOT_H +#define _LINUX_REBOOT_H + +/* + * Magic values required to use _reboot() system call. + */ + +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_MAGIC2A 85072278 +#define LINUX_REBOOT_MAGIC2B 369367448 +#define LINUX_REBOOT_MAGIC2C 537993216 + + +/* + * Commands accepted by the _reboot() system call. + * + * RESTART Restart system using default command and mode. + * HALT Stop OS and give system control to ROM monitor, if any. + * CAD_ON Ctrl-Alt-Del sequence causes RESTART command. + * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task. + * POWER_OFF Stop OS and remove all power from system, if possible. + * RESTART2 Restart system using given command string. + * SW_SUSPEND Suspend system using software suspend if compiled in. + * KEXEC Restart system using a previously loaded Linux kernel + */ + +#define LINUX_REBOOT_CMD_RESTART 0x01234567 +#define LINUX_REBOOT_CMD_HALT 0xCDEF0123 +#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF +#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000 +#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 +#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2 +#define LINUX_REBOOT_CMD_KEXEC 0x45584543 + + +#include + +extern int register_reboot_notifier(struct notifier_block *); +extern int unregister_reboot_notifier(struct notifier_block *); + + +/* + * Architecture-specific implementations of sys_reboot commands. + */ + +extern void machine_restart(char *cmd); +extern void machine_halt(void); +extern void machine_power_off(void); + +extern void machine_shutdown(void); +struct pt_regs; +extern void machine_crash_shutdown(struct pt_regs *); + +/* + * Architecture independent implemenations of sys_reboot commands. + */ + +extern void kernel_shutdown_prepare(enum system_states state); + +extern void kernel_restart(char *cmd); +extern void kernel_halt(void); +extern void kernel_power_off(void); + +void ctrl_alt_del(void); + +/* + * Emergency restart, callable from an interrupt handler. + */ + +extern void emergency_restart(void); +//#include + +#endif /* _LINUX_REBOOT_H */ diff --git a/ddverify/models/con2/include/linux/rtc.h b/ddverify/models/con2/include/linux/rtc.h new file mode 100644 index 000000000..58ff91583 --- /dev/null +++ b/ddverify/models/con2/include/linux/rtc.h @@ -0,0 +1,219 @@ +/* + * Generic RTC interface. + * This version contains the part of the user interface to the Real Time Clock + * service. It is used with both the legacy mc146818 and also EFI + * Struct rtc_time and first 12 ioctl by Paul Gortmaker, 1996 - separated out + * from to this file for 2.4 kernels. + * + * Copyright (C) 1999 Hewlett-Packard Co. + * Copyright (C) 1999 Stephane Eranian + */ +#ifndef _LINUX_RTC_H_ +#define _LINUX_RTC_H_ + +/* + * The struct used to pass data via the following ioctl. Similar to the + * struct tm in , but it needs to be here so that the kernel + * source is self contained, allowing cross-compiles, etc. etc. + */ +struct rtc_time { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +/* + * This data structure is inspired by the EFI (v0.92) wakeup + * alarm API. + */ +struct rtc_wkalrm { + unsigned char enabled; + unsigned char pending; + struct rtc_time time; +}; + +/* + * Data structure to control PLL correction some better RTC feature + * pll_value is used to get or set current value of correction, + * the rest of the struct is used to query HW capabilities. + * This is modeled after the RTC used in Q40/Q60 computers but + * should be sufficiently flexible for other devices + * + * +ve pll_value means clock will run faster by + * pll_value*pll_posmult/pll_clock + * -ve pll_value means clock will run slower by + * pll_value*pll_negmult/pll_clock + */ + +struct rtc_pll_info { + /* int pll_ctrl; + int pll_value; + int pll_max; + int pll_min; + int pll_posmult; + int pll_negmult; + long pll_clock; +*/ + int something; +}; + +/* + * ioctl calls that are permitted to the /dev/rtc interface, if + * any of the RTC drivers are enabled. + */ + +#define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */ +#define RTC_AIE_OFF _IO('p', 0x02) /* ... off */ +#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */ +#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */ +#define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */ +#define RTC_PIE_OFF _IO('p', 0x06) /* ... off */ +#define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */ +#define RTC_WIE_OFF _IO('p', 0x10) /* ... off */ + +#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */ +#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */ +#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */ +#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */ +#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */ +#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */ +#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */ +#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */ + +#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/ +#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/ + +#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */ +#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */ + +/* interrupt flags */ +#define RTC_IRQF 0x80 /* any of the following is active */ +#define RTC_PF 0x40 +#define RTC_AF 0x20 +#define RTC_UF 0x10 + + +#include + +extern int rtc_month_days(unsigned int month, unsigned int year); +extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); +extern int rtc_valid_tm(struct rtc_time *tm); +extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); +extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); + +#include +#include +#include +#include +#include + +extern struct class *rtc_class; + +struct rtc_class_ops { + /* int (*open)(struct device *); + void (*release)(struct device *); + int (*ioctl)(struct device *, unsigned int, unsigned long); + int (*read_time)(struct device *, struct rtc_time *); + int (*set_time)(struct device *, struct rtc_time *); + int (*read_alarm)(struct device *, struct rtc_wkalrm *); + int (*set_alarm)(struct device *, struct rtc_wkalrm *); + int (*proc)(struct device *, struct seq_file *); + int (*set_mmss)(struct device *, unsigned long secs); + int (*irq_set_state)(struct device *, int enabled); + int (*irq_set_freq)(struct device *, int freq); + int (*read_callback)(struct device *, int data); + */ + int something; +}; + +#define RTC_DEVICE_NAME_SIZE 20 +struct rtc_task; + +struct rtc_device +{ + /* struct class_device class_dev; + struct module *owner; + + int id; + char name[RTC_DEVICE_NAME_SIZE]; + + const struct rtc_class_ops *ops; + struct mutex ops_lock; + + struct class_device *rtc_dev; + struct cdev char_dev; + struct mutex char_lock; + + unsigned long irq_data; + spinlock_t irq_lock; + wait_queue_head_t irq_queue; + struct fasync_struct *async_queue; + + struct rtc_task *irq_task; + spinlock_t irq_task_lock; + int irq_freq; + int max_user_freq; +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL + struct work_struct uie_task; + struct timer_list uie_timer; + unsigned int oldsecs; + unsigned int irq_active:1; + unsigned int stop_uie_polling:1; + unsigned int uie_task_active:1; + unsigned int uie_timer_active:1; +#endif + */ + int something; +}; +#define to_rtc_device(d) container_of(d, struct rtc_device, class_dev) + +extern struct rtc_device *rtc_device_register(const char *name, + struct device *dev, + const struct rtc_class_ops *ops, + struct module *owner); +extern void rtc_device_unregister(struct rtc_device *rdev); +extern int rtc_interface_register(struct class_interface *intf); + +extern int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_mmss(struct class_device *class_dev, unsigned long secs); +extern int rtc_read_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern int rtc_set_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern void rtc_update_irq(struct class_device *class_dev, + unsigned long num, unsigned long events); + +extern struct class_device *rtc_class_open(char *name); +extern void rtc_class_close(struct class_device *class_dev); + +extern int rtc_irq_register(struct class_device *class_dev, + struct rtc_task *task); +extern void rtc_irq_unregister(struct class_device *class_dev, + struct rtc_task *task); +extern int rtc_irq_set_state(struct class_device *class_dev, + struct rtc_task *task, int enabled); +extern int rtc_irq_set_freq(struct class_device *class_dev, + struct rtc_task *task, int freq); + +typedef struct rtc_task { + void (*func)(void *private_data); + void *private_data; +} rtc_task_t; + +int rtc_register(rtc_task_t *task); +int rtc_unregister(rtc_task_t *task); +int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); +void rtc_get_rtc_time(struct rtc_time *rtc_tm); +irqreturn_t rtc_interrupt(int irq, void *dev_id); + + +unsigned char rtc_read(unsigned char); +void rtc_write(unsigned char, unsigned char); +#endif /* _LINUX_RTC_H_ */ diff --git a/ddverify/models/con2/include/linux/scatterlist.h b/ddverify/models/con2/include/linux/scatterlist.h new file mode 100644 index 000000000..32da1e633 --- /dev/null +++ b/ddverify/models/con2/include/linux/scatterlist.h @@ -0,0 +1,24 @@ +#ifndef _LINUX_SCATTERLIST_H +#define _LINUX_SCATTERLIST_H + +#include +#include +#include + +/*static inline void sg_set_buf(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + sg->page = virt_to_page(buf); + sg->offset = offset_in_page(buf); + sg->length = buflen; +} + +static inline void sg_init_one(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + memset(sg, 0, sizeof(*sg)); + sg_set_buf(sg, buf, buflen); +} +*/ + +#endif /* _LINUX_SCATTERLIST_H */ diff --git a/ddverify/models/con2/include/linux/sched.h b/ddverify/models/con2/include/linux/sched.h new file mode 100644 index 000000000..c15cd8719 --- /dev/null +++ b/ddverify/models/con2/include/linux/sched.h @@ -0,0 +1,62 @@ +#ifndef _LINUX_SCHED_H +#define _LINUX_SCHED_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_STOPPED 4 +#define TASK_TRACED 8 + +#define TASK_COMM_LEN 16 + +struct sighand_struct { + spinlock_t siglock; +}; + +struct task_struct { + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + pid_t pid; + char comm[TASK_COMM_LEN]; + + sigset_t blocked, real_blocked; + + struct sighand_struct *sighand; +}; + +#include + +int signal_pending(struct task_struct *p); + +// DDV: Body is defined in linux/kernel/sched.c +void schedule(void); +// DDV: Body is defined in linux/kernel/sched.c +long schedule_timeout(long timeout); +// DDV: TODO +int need_resched(void); + +// DDV: TODO +extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); + +// DDV: TODO +void yield(void); + +// DDV: No body for this function +void set_current_state(int); + +// DDV: TODO +extern int kill_proc(pid_t, int, int); +// DDV: TODO +extern void recalc_sigpending(void); +#endif diff --git a/ddverify/models/con2/include/linux/seq_file.h b/ddverify/models/con2/include/linux/seq_file.h new file mode 100644 index 000000000..bb64052b9 --- /dev/null +++ b/ddverify/models/con2/include/linux/seq_file.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_SEQ_FILE_H +#define _LINUX_SEQ_FILE_H + +#include +#include +#include + +struct seq_operations; +struct file; +struct vfsmount; +struct dentry; +struct inode; + +struct seq_file { + int something; +}; + +struct seq_operations { + void * (*start) (struct seq_file *m, loff_t *pos); + void (*stop) (struct seq_file *m, void *v); + void * (*next) (struct seq_file *m, void *v, loff_t *pos); + int (*show) (struct seq_file *m, void *v); +}; + +int seq_open(struct file *, struct seq_operations *); +ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); +loff_t seq_lseek(struct file *, loff_t, int); +int seq_release(struct inode *, struct file *); +int seq_escape(struct seq_file *, const char *, const char *); +int seq_putc(struct seq_file *m, char c); +int seq_puts(struct seq_file *m, const char *s); + +int seq_printf(struct seq_file *, const char *, ...); + +#endif diff --git a/ddverify/models/con2/include/linux/serial.h b/ddverify/models/con2/include/linux/serial.h new file mode 100644 index 000000000..b532862fc --- /dev/null +++ b/ddverify/models/con2/include/linux/serial.h @@ -0,0 +1,131 @@ +/* + * include/linux/serial.h + * + * Copyright (C) 1992 by Theodore Ts'o. + * + * Redistribution of this file is permitted under the terms of the GNU + * Public License (GPL) + */ + +#ifndef _LINUX_SERIAL_H +#define _LINUX_SERIAL_H + +#include +#include + +#define SERIAL_XMIT_SIZE PAGE_SIZE + +struct serial_struct { + int type; + int line; + unsigned int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + unsigned short close_delay; + char io_type; + char reserved_char[1]; + int hub6; + unsigned short closing_wait; /* time to wait before closing */ + unsigned short closing_wait2; /* no longer used... */ + unsigned char *iomem_base; + unsigned short iomem_reg_shift; + unsigned int port_high; + unsigned long iomap_base; /* cookie passed into ioremap */ +}; + + +/* + * For the close wait times, 0 means wait forever for serial port to + * flush its output. 65535 means don't wait at all. + */ +#define ASYNC_CLOSING_WAIT_INF 0 +#define ASYNC_CLOSING_WAIT_NONE 65535 + + +/* + * These are the supported serial types. + */ +#define PORT_UNKNOWN 0 +#define PORT_8250 1 +#define PORT_16450 2 +#define PORT_16550 3 +#define PORT_16550A 4 +#define PORT_CIRRUS 5 /* usurped by cyclades.c */ +#define PORT_16650 6 +#define PORT_16650V2 7 +#define PORT_16750 8 +#define PORT_STARTECH 9 /* usurped by cyclades.c */ +#define PORT_16C950 10 /* Oxford Semiconductor */ +#define PORT_16654 11 +#define PORT_16850 12 +#define PORT_RSA 13 /* RSA-DV II/S card */ +#define PORT_MAX 13 + +#define SERIAL_IO_PORT 0 +#define SERIAL_IO_HUB6 1 +#define SERIAL_IO_MEM 2 + + + + +#define UART_CLEAR_FIFO 0x01 +#define UART_USE_FIFO 0x02 +#define UART_STARTECH 0x04 +#define UART_NATSEMI 0x08 + + +/* + * Definitions for async_struct (and serial_struct) flags field + */ +#define ASYNC_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes + on the callout port */ +#define ASYNC_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */ +#define ASYNC_SAK 0x0004 /* Secure Attention Key (Orange book) */ +#define ASYNC_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ + +#define ASYNC_SPD_MASK 0x1030 +#define ASYNC_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ + +#define ASYNC_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ +#define ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */ + +#define ASYNC_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ +#define ASYNC_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ +#define ASYNC_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ +#define ASYNC_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ +#define ASYNC_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ + +#define ASYNC_HARDPPS_CD 0x0800 /* Call hardpps when CD goes high */ + +#define ASYNC_SPD_SHI 0x1000 /* Use 230400 instead of 38400 bps */ +#define ASYNC_SPD_WARP 0x1010 /* Use 460800 instead of 38400 bps */ + +#define ASYNC_LOW_LATENCY 0x2000 /* Request low latency behaviour */ + +#define ASYNC_BUGGY_UART 0x4000 /* This is a buggy UART, skip some safety + * checks. Note: can be dangerous! */ + +#define ASYNC_AUTOPROBE 0x8000 /* Port was autoprobed by PCI or PNP code */ + +#define ASYNC_FLAGS 0x7FFF /* Possible legal async flags */ +#define ASYNC_USR_MASK 0x3430 /* Legal flags that non-privileged + * users can set or reset */ + +/* Internal flags used only by kernel/chr_drv/serial.c */ +#define ASYNC_INITIALIZED 0x80000000 /* Serial port was initialized */ +#define ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ +#define ASYNC_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ +#define ASYNC_CLOSING 0x08000000 /* Serial port is closing */ +#define ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */ +#define ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */ +#define ASYNC_SHARE_IRQ 0x01000000 /* for multifunction cards + --- no longer used */ +#define ASYNC_CONS_FLOW 0x00800000 /* flow control for console */ + +#define ASYNC_BOOT_ONLYMCA 0x00400000 /* Probe only if MCA bus */ +#define ASYNC_INTERNAL_FLAGS 0xFFC00000 /* Internal flags */ + +#endif /* _LINUX_SERIAL_H */ diff --git a/ddverify/models/con2/include/linux/signal.h b/ddverify/models/con2/include/linux/signal.h new file mode 100644 index 000000000..2b8814641 --- /dev/null +++ b/ddverify/models/con2/include/linux/signal.h @@ -0,0 +1,54 @@ +#ifndef _LINUX_SIGNAL_H +#define _LINUX_SIGNAL_H + +#include +#include + +#include +#include + +#include + +/* + * These values of sa_flags are used only by the kernel as part of the + * irq handling routines. + * + * SA_INTERRUPT is also used by the irq handling routines. + * SA_SHIRQ is for shared interrupt support on PCI and EISA. + */ +#define SA_PROBE SA_ONESHOT +#define SA_SAMPLE_RANDOM SA_RESTART +#define SA_SHIRQ 0x04000000 + +static inline void sigfillset(sigset_t *set) +{ + switch (_NSIG_WORDS) { + default: + memset(set, -1, sizeof(sigset_t)); + break; + case 2: set->sig[1] = -1; + case 1: set->sig[0] = -1; + break; + } +} + +/* Some extensions for manipulating the low 32 signals in particular. */ + +static inline void sigaddsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] |= mask; +} + +static inline void sigdelsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] &= ~mask; +} + +static inline int sigtestsetmask(sigset_t *set, unsigned long mask) +{ + return (set->sig[0] & mask) != 0; +} + +#define sigmask(sig) (1UL << ((sig) - 1)) + +#endif /* _LINUX_SIGNAL_H */ diff --git a/ddverify/models/con2/include/linux/skbuff.h b/ddverify/models/con2/include/linux/skbuff.h new file mode 100644 index 000000000..abc4822d9 --- /dev/null +++ b/ddverify/models/con2/include/linux/skbuff.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_SKBUFF_H +#define _LINUX_SKBUFF_H + +#include + +#endif /* _LINUX_SKBUFF_H */ diff --git a/ddverify/models/con2/include/linux/slab.h b/ddverify/models/con2/include/linux/slab.h new file mode 100644 index 000000000..edfc1e1ca --- /dev/null +++ b/ddverify/models/con2/include/linux/slab.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_SLAB_H +#define _LINUX_SLAB_H + +#include +#include + +// DDV: TODO +void kfree(const void *); +// DDV: Body is defined in linux/mm/slab.c +void *kmalloc(size_t size, gfp_t flags); +// DDV: Body is defined in linux/mm/slab.c +void *kzalloc(size_t size, gfp_t flags); +// DDV: TODO +unsigned int ksize(const void *); + +#endif diff --git a/ddverify/models/con2/include/linux/smp_lock.h b/ddverify/models/con2/include/linux/smp_lock.h new file mode 100644 index 000000000..fbd5463bc --- /dev/null +++ b/ddverify/models/con2/include/linux/smp_lock.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_SMPLOCK_H +#define __LINUX_SMPLOCK_H + +#include +#include + +spinlock_t kernel_lock; + +#define lock_kernel() spin_lock(&kernel_lock) +#define unlock_kernel() spin_unlock(&kernel_lock) + +#endif /* __LINUX_SMPLOCK_H */ diff --git a/ddverify/models/con2/include/linux/socket.h b/ddverify/models/con2/include/linux/socket.h new file mode 100644 index 000000000..365beed9c --- /dev/null +++ b/ddverify/models/con2/include/linux/socket.h @@ -0,0 +1,109 @@ +#ifndef _LINUX_SOCKET_H +#define _LINUX_SOCKET_H + +#include /* iovec support */ + +/* Supported address families. */ +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* AppleTalk DDP */ +#define AF_NETROM 6 /* Amateur Radio NET/ROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_ATMPVC 8 /* ATM PVCs */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_INET6 10 /* IP version 6 */ +#define AF_ROSE 11 /* Amateur Radio X.25 PLP */ +#define AF_DECnet 12 /* Reserved for DECnet project */ +#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ +#define AF_KEY 15 /* PF_KEY key management API */ +#define AF_NETLINK 16 +#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ +#define AF_PACKET 17 /* Packet family */ +#define AF_ASH 18 /* Ash */ +#define AF_ECONET 19 /* Acorn Econet */ +#define AF_ATMSVC 20 /* ATM SVCs */ +#define AF_SNA 22 /* Linux SNA Project (nutters!) */ +#define AF_IRDA 23 /* IRDA sockets */ +#define AF_PPPOX 24 /* PPPoX sockets */ +#define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_LLC 26 /* Linux LLC */ +#define AF_TIPC 30 /* TIPC sockets */ +#define AF_BLUETOOTH 31 /* Bluetooth sockets */ +#define AF_MAX 32 /* For now.. */ + +/* Protocol families, same as address families. */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL AF_LOCAL +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_ATMPVC AF_ATMPVC +#define PF_X25 AF_X25 +#define PF_INET6 AF_INET6 +#define PF_ROSE AF_ROSE +#define PF_DECnet AF_DECnet +#define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY +#define PF_KEY AF_KEY +#define PF_NETLINK AF_NETLINK +#define PF_ROUTE AF_ROUTE +#define PF_PACKET AF_PACKET +#define PF_ASH AF_ASH +#define PF_ECONET AF_ECONET +#define PF_ATMSVC AF_ATMSVC +#define PF_SNA AF_SNA +#define PF_IRDA AF_IRDA +#define PF_PPPOX AF_PPPOX +#define PF_WANPIPE AF_WANPIPE +#define PF_LLC AF_LLC +#define PF_TIPC AF_TIPC +#define PF_BLUETOOTH AF_BLUETOOTH +#define PF_MAX AF_MAX + +/* Maximum queue length specifiable by listen. */ +#define SOMAXCONN 128 + +/* Flags we can use with send/ and recv. + Added those for 1003.1g not all are supported yet + */ + +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 /* Confirm path validity */ +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ +#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ +#define MSG_MORE 0x8000 /* Sender will send more */ + +#define MSG_EOF MSG_FIN + +struct msghdr { + void * msg_name; /* Socket name */ + int msg_namelen; /* Length of name */ +// struct iovec * msg_iov; /* Data blocks */ + __kernel_size_t msg_iovlen; /* Number of blocks */ + void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + __kernel_size_t msg_controllen; /* Length of cmsg list */ + unsigned msg_flags; +}; + +#endif /* _LINUX_SOCKET_H */ diff --git a/ddverify/models/con2/include/linux/spinlock.h b/ddverify/models/con2/include/linux/spinlock.h new file mode 100644 index 000000000..71531ae4f --- /dev/null +++ b/ddverify/models/con2/include/linux/spinlock.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_SPINLOCK_H +#define __LINUX_SPINLOCK_H + +#include +#include + +// DDV: Bodies for all spinlock-functions are defined in linux/kernel/spinlock.c + +void spin_lock_init(spinlock_t *); +void spin_lock(spinlock_t *); +void spin_lock_irqsave(spinlock_t *, unsigned long); +void spin_lock_irq(spinlock_t *); +void spin_lock_bh(spinlock_t *); + +void spin_unlock(spinlock_t *); +void spin_unlock_irqrestore(spinlock_t *, unsigned long); +void spin_unlock_irq(spinlock_t *); +void spin_unlock_bh(spinlock_t *); + +#endif /* __LINUX_SPINLOCK_H */ diff --git a/ddverify/models/con2/include/linux/spinlock_types.h b/ddverify/models/con2/include/linux/spinlock_types.h new file mode 100644 index 000000000..86dd36d84 --- /dev/null +++ b/ddverify/models/con2/include/linux/spinlock_types.h @@ -0,0 +1,21 @@ +#ifndef __LINUX_SPINLOCK_TYPES_H +#define __LINUX_SPINLOCK_TYPES_H + +typedef struct { + int init; + int locked; +} spinlock_t; + +typedef struct { + int something; +} rwlock_t; + +# define __SPIN_LOCK_UNLOCKED \ + { .init = 1, \ + .locked = 0 } + +#define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED + +#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED + +#endif /* __LINUX_SPINLOCK_TYPES_H */ diff --git a/ddverify/models/con2/include/linux/stat.h b/ddverify/models/con2/include/linux/stat.h new file mode 100644 index 000000000..262124881 --- /dev/null +++ b/ddverify/models/con2/include/linux/stat.h @@ -0,0 +1,66 @@ +#ifndef _LINUX_STAT_H +#define _LINUX_STAT_H + +#include + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) + +#include +#include + +struct kstat { + unsigned long ino; + dev_t dev; +// umode_t mode; + unsigned int nlink; +// uid_t uid; +// gid_t gid; + dev_t rdev; + loff_t size; +// struct timespec atime; +// struct timespec mtime; +// struct timespec ctime; + unsigned long blksize; + unsigned long blocks; +}; + +#endif diff --git a/ddverify/models/con2/include/linux/stddef.h b/ddverify/models/con2/include/linux/stddef.h new file mode 100644 index 000000000..b3a2cadf9 --- /dev/null +++ b/ddverify/models/con2/include/linux/stddef.h @@ -0,0 +1,20 @@ +#ifndef _LINUX_STDDEF_H +#define _LINUX_STDDEF_H + +#include + +#undef NULL +#if defined(__cplusplus) +#define NULL 0 +#else +#define NULL ((void *)0) +#endif + +#undef offsetof +#ifdef __compiler_offsetof +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#endif diff --git a/ddverify/models/con2/include/linux/string.h b/ddverify/models/con2/include/linux/string.h new file mode 100644 index 000000000..9734c2052 --- /dev/null +++ b/ddverify/models/con2/include/linux/string.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_STRING_H_ +#define _LINUX_STRING_H_ + +#include +#include +#include + +extern char * strcpy(char *,const char *); +extern char * strncpy(char *,const char *, __kernel_size_t); +size_t strlcpy(char *, const char *, size_t); +extern char * strcat(char *, const char *); +extern char * strncat(char *, const char *, __kernel_size_t); +extern size_t strlcat(char *, const char *, __kernel_size_t); +extern int strcmp(const char *,const char *); +extern int strncmp(const char *,const char *,__kernel_size_t); +extern int strnicmp(const char *, const char *, __kernel_size_t); +extern char * strchr(const char *,int); +extern char * strnchr(const char *, size_t, int); +extern char * strrchr(const char *,int); +extern char * strstrip(char *); +extern char * strstr(const char *,const char *); +extern __kernel_size_t strlen(const char *); +extern __kernel_size_t strnlen(const char *,__kernel_size_t); +extern char * strpbrk(const char *,const char *); +extern char * strsep(char **,const char *); +extern __kernel_size_t strspn(const char *,const char *); +extern __kernel_size_t strcspn(const char *,const char *); + +extern void * memset(void *,int,__kernel_size_t); +extern void * memcpy(void *,const void *,__kernel_size_t); +extern void * memmove(void *,const void *,__kernel_size_t); +extern void * memscan(void *,int,__kernel_size_t); +extern int memcmp(const void *,const void *,__kernel_size_t); +extern void * memchr(const void *,int,__kernel_size_t); +#endif /* _LINUX_STRING_H_ */ diff --git a/ddverify/models/con2/include/linux/stringify.h b/ddverify/models/con2/include/linux/stringify.h new file mode 100644 index 000000000..0b4388356 --- /dev/null +++ b/ddverify/models/con2/include/linux/stringify.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H + +/* Indirect stringification. Doing two levels allows the parameter to be a + * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) + * converts to "bar". + */ + +#define __stringify_1(x) #x +#define __stringify(x) __stringify_1(x) + +#endif /* !__LINUX_STRINGIFY_H */ diff --git a/ddverify/models/con2/include/linux/suspend.h b/ddverify/models/con2/include/linux/suspend.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/swap.h b/ddverify/models/con2/include/linux/swap.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/sysfs.h b/ddverify/models/con2/include/linux/sysfs.h new file mode 100644 index 000000000..4e1dd65ae --- /dev/null +++ b/ddverify/models/con2/include/linux/sysfs.h @@ -0,0 +1,43 @@ +#ifndef _SYSFS_H_ +#define _SYSFS_H_ + +#include +#include + +struct kobject; +struct module; + +struct attribute { + const char * name; + struct module * owner; + mode_t mode; +}; + +struct attribute_group { + const char * name; + struct attribute ** attrs; +}; + + + +/** + * Use these macros to make defining attributes easier. See include/linux/device.h + * for examples.. + */ + +#define __ATTR(_name,_mode,_show,_store) { \ + .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \ + .show = _show, \ + .store = _store, \ +} + +#define __ATTR_RO(_name) { \ + .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \ + .show = _name##_show, \ +} + +#define __ATTR_NULL { .attr = { .name = NULL } } + +#define attr_name(_attr) (_attr).attr.name + +#endif /* _SYSFS_H_ */ diff --git a/ddverify/models/con2/include/linux/sysrq.h b/ddverify/models/con2/include/linux/sysrq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/linux/termios.h b/ddverify/models/con2/include/linux/termios.h new file mode 100644 index 000000000..758803c4c --- /dev/null +++ b/ddverify/models/con2/include/linux/termios.h @@ -0,0 +1,7 @@ +#ifndef _LINUX_TERMIOS_H +#define _LINUX_TERMIOS_H + +#include +#include + +#endif diff --git a/ddverify/models/con2/include/linux/time.h b/ddverify/models/con2/include/linux/time.h new file mode 100644 index 000000000..907f53e8e --- /dev/null +++ b/ddverify/models/con2/include/linux/time.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_TIME_H +#define _LINUX_TIME_H + +#include + +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; + + +/* Parameters used to convert the timespec values: */ +#define MSEC_PER_SEC 1000L +#define USEC_PER_MSEC 1000L +#define NSEC_PER_USEC 1000L +#define NSEC_PER_MSEC 1000000L +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L +#define FSEC_PER_SEC 1000000000000000L + + +void do_gettimeofday(struct timeval *tv); + +#endif + diff --git a/ddverify/models/con2/include/linux/timer.h b/ddverify/models/con2/include/linux/timer.h new file mode 100644 index 000000000..a531db358 --- /dev/null +++ b/ddverify/models/con2/include/linux/timer.h @@ -0,0 +1,34 @@ +#ifndef _LINUX_TIMER_H +#define _LINUX_TIMER_H + +struct timer_list { + unsigned long expires; + void (*function)(unsigned long); + unsigned long data; + + short __ddv_active; + short __ddv_init; +}; + +#define TIMER_INITIALIZER(_function, _expires, _data) { \ + .function = (_function), \ + .expires = (_expires), \ + .data = (_data), \ + .__ddv_init = 1, \ + } + + +#define DEFINE_TIMER(_name, _function, _expires, _data) \ + struct timer_list _name = \ + TIMER_INITIALIZER(_function, _expires, _data) + +// DDV: Bodies for the following functions are defined in linux/kernel/timer.c +void init_timer(struct timer_list * timer); +void add_timer_on(struct timer_list *timer, int cpu); +void add_timer(struct timer_list *timer); +int del_timer(struct timer_list * timer); +int mod_timer(struct timer_list *timer, unsigned long expires); + +#define del_timer_sync(t) del_timer(t) + +#endif diff --git a/ddverify/models/con2/include/linux/tty.h b/ddverify/models/con2/include/linux/tty.h new file mode 100644 index 000000000..5bde39f3c --- /dev/null +++ b/ddverify/models/con2/include/linux/tty.h @@ -0,0 +1,180 @@ +#ifndef _LINUX_TTY_H +#define _LINUX_TTY_H + +#include +#include +#include +#include +#include +#include +#include + +#include + + +/* + * The pty uses char_buf and flag_buf as a contiguous buffer + */ +#define PTY_BUF_SIZE 4*TTY_FLIPBUF_SIZE + +/* + * When a break, frame error, or parity error happens, these codes are + * stuffed into the flags buffer. + */ +#define TTY_NORMAL 0 +#define TTY_BREAK 1 +#define TTY_FRAME 2 +#define TTY_PARITY 3 +#define TTY_OVERRUN 4 + + +#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR]) +#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT]) +#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE]) +#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL]) +#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF]) +#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME]) +#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN]) +#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC]) +#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART]) +#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP]) +#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP]) +#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL]) +#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT]) +#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD]) +#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE]) +#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) +#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) + +#define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f)) +#define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f)) +#define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f)) +#define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f)) + +#define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK) +#define I_BRKINT(tty) _I_FLAG((tty),BRKINT) +#define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR) +#define I_PARMRK(tty) _I_FLAG((tty),PARMRK) +#define I_INPCK(tty) _I_FLAG((tty),INPCK) +#define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP) +#define I_INLCR(tty) _I_FLAG((tty),INLCR) +#define I_IGNCR(tty) _I_FLAG((tty),IGNCR) +#define I_ICRNL(tty) _I_FLAG((tty),ICRNL) +#define I_IUCLC(tty) _I_FLAG((tty),IUCLC) +#define I_IXON(tty) _I_FLAG((tty),IXON) +#define I_IXANY(tty) _I_FLAG((tty),IXANY) +#define I_IXOFF(tty) _I_FLAG((tty),IXOFF) +#define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL) +#define I_IUTF8(tty) _I_FLAG((tty),IUTF8) + +#define O_OPOST(tty) _O_FLAG((tty),OPOST) +#define O_OLCUC(tty) _O_FLAG((tty),OLCUC) +#define O_ONLCR(tty) _O_FLAG((tty),ONLCR) +#define O_OCRNL(tty) _O_FLAG((tty),OCRNL) +#define O_ONOCR(tty) _O_FLAG((tty),ONOCR) +#define O_ONLRET(tty) _O_FLAG((tty),ONLRET) +#define O_OFILL(tty) _O_FLAG((tty),OFILL) +#define O_OFDEL(tty) _O_FLAG((tty),OFDEL) +#define O_NLDLY(tty) _O_FLAG((tty),NLDLY) +#define O_CRDLY(tty) _O_FLAG((tty),CRDLY) +#define O_TABDLY(tty) _O_FLAG((tty),TABDLY) +#define O_BSDLY(tty) _O_FLAG((tty),BSDLY) +#define O_VTDLY(tty) _O_FLAG((tty),VTDLY) +#define O_FFDLY(tty) _O_FLAG((tty),FFDLY) + +#define C_BAUD(tty) _C_FLAG((tty),CBAUD) +#define C_CSIZE(tty) _C_FLAG((tty),CSIZE) +#define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB) +#define C_CREAD(tty) _C_FLAG((tty),CREAD) +#define C_PARENB(tty) _C_FLAG((tty),PARENB) +#define C_PARODD(tty) _C_FLAG((tty),PARODD) +#define C_HUPCL(tty) _C_FLAG((tty),HUPCL) +#define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL) +#define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD) +#define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS) + +#define L_ISIG(tty) _L_FLAG((tty),ISIG) +#define L_ICANON(tty) _L_FLAG((tty),ICANON) +#define L_XCASE(tty) _L_FLAG((tty),XCASE) +#define L_ECHO(tty) _L_FLAG((tty),ECHO) +#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) +#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) +#define L_ECHONL(tty) _L_FLAG((tty),ECHONL) +#define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH) +#define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP) +#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) +#define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT) +#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) +#define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO) +#define L_PENDIN(tty) _L_FLAG((tty),PENDIN) +#define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN) + + +struct tty_struct { + int magic; + struct tty_driver *driver; + int index; + struct termios *termios, *termios_locked; + char name[64]; + + unsigned long flags; + int count; + unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; + unsigned int receive_room; /* Bytes free for queue */ + + wait_queue_head_t write_wait; + wait_queue_head_t read_wait; + void *disc_data; + void *driver_data; + + unsigned char closing:1; +}; + + +/* tty magic number */ +#define TTY_MAGIC 0x5401 + +/* + * These bits are used in the flags field of the tty structure. + * + * So that interrupts won't be able to mess up the queues, + * copy_to_cooked must be atomic with respect to itself, as must + * tty->write. Thus, you must use the inline functions set_bit() and + * clear_bit() to make things atomic. + */ +#define TTY_THROTTLED 0 /* Call unthrottle() at threshold min */ +#define TTY_IO_ERROR 1 /* Canse an I/O error (may be no ldisc too) */ +#define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */ +#define TTY_EXCLUSIVE 3 /* Exclusive open mode */ +#define TTY_DEBUG 4 /* Debugging */ +#define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */ +#define TTY_PUSH 6 /* n_tty private */ +#define TTY_CLOSING 7 /* ->close() in progress */ +#define TTY_LDISC 9 /* Line discipline attached */ +#define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */ +#define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */ +#define TTY_PTY_LOCK 16 /* pty private */ +#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ +#define TTY_HUPPED 18 /* Post driver->hangup() */ + +extern struct termios tty_std_termios; + + +extern int tty_check_change(struct tty_struct * tty); +extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); +extern int tty_unregister_ldisc(int disc); +extern int tty_register_driver(struct tty_driver *driver); +extern int tty_unregister_driver(struct tty_driver *driver); + +extern void tty_wait_until_sent(struct tty_struct * tty, long timeout); + + +extern void tty_hangup(struct tty_struct * tty); +extern int tty_hung_up_p(struct file * filp); +extern void do_SAK(struct tty_struct *tty); +extern void tty_flip_buffer_push(struct tty_struct *tty); +extern int tty_get_baud_rate(struct tty_struct *tty); + +extern void tty_wakeup(struct tty_struct *tty); +extern void tty_ldisc_flush(struct tty_struct *tty); +#endif diff --git a/ddverify/models/con2/include/linux/tty_driver.h b/ddverify/models/con2/include/linux/tty_driver.h new file mode 100644 index 000000000..805c70977 --- /dev/null +++ b/ddverify/models/con2/include/linux/tty_driver.h @@ -0,0 +1,166 @@ +#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +// DDV: TODO +void put_tty_driver(struct tty_driver *driver); +// DDV: is defined in driver/char/tty_io.c +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ diff --git a/ddverify/models/con2/include/linux/tty_driver.h,v b/ddverify/models/con2/include/linux/tty_driver.h,v new file mode 100644 index 000000000..f5748324d --- /dev/null +++ b/ddverify/models/con2/include/linux/tty_driver.h,v @@ -0,0 +1,187 @@ +head 1.1; +access; +symbols; +locks; strict; +comment @ * @; + + +1.1 +date 2007.02.11.11.29.05; author thomaswi; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@Initial revision +@ +text +@#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: Body of this function is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +void put_tty_driver(struct tty_driver *driver); +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ +@ diff --git a/ddverify/models/con2/include/linux/tty_flip.h b/ddverify/models/con2/include/linux/tty_flip.h new file mode 100644 index 000000000..b0864fa14 --- /dev/null +++ b/ddverify/models/con2/include/linux/tty_flip.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_TTY_FLIP_H +#define _LINUX_TTY_FLIP_H + +int tty_buffer_request_room(struct tty_struct *tty, size_t size); +int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size); +int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); +int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); +int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); +void tty_schedule_flip(struct tty_struct *tty); + +inline int tty_insert_flip_char(struct tty_struct *tty, unsigned char ch, char flag); + +#endif /* _LINUX_TTY_FLIP_H */ diff --git a/ddverify/models/con2/include/linux/tty_ldisc.h b/ddverify/models/con2/include/linux/tty_ldisc.h new file mode 100644 index 000000000..35466133a --- /dev/null +++ b/ddverify/models/con2/include/linux/tty_ldisc.h @@ -0,0 +1,51 @@ +#ifndef _LINUX_TTY_LDISC_H +#define _LINUX_TTY_LDISC_H + + +#include +#include + +struct tty_ldisc { + int magic; + char *name; + int num; + int flags; + + /* + * The following routines are called from above. + */ + int (*open)(struct tty_struct *); + void (*close)(struct tty_struct *); + void (*flush_buffer)(struct tty_struct *tty); + ssize_t (*chars_in_buffer)(struct tty_struct *tty); + ssize_t (*read)(struct tty_struct * tty, struct file * file, + unsigned char __user * buf, size_t nr); + ssize_t (*write)(struct tty_struct * tty, struct file * file, + const unsigned char * buf, size_t nr); + int (*ioctl)(struct tty_struct * tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + unsigned int (*poll)(struct tty_struct *, struct file *, + struct poll_table_struct *); + int (*hangup)(struct tty_struct *tty); + + /* + * The following routines are called from below. + */ + void (*receive_buf)(struct tty_struct *, const unsigned char *cp, + char *fp, int count); + void (*write_wakeup)(struct tty_struct *); + + struct module *owner; + + int refcount; +}; + +#define TTY_LDISC_MAGIC 0x5403 + +#define LDISC_FLAG_DEFINED 0x00000001 + +#define MODULE_ALIAS_LDISC(ldisc) \ + MODULE_ALIAS("tty-ldisc-" __stringify(ldisc)) + +#endif /* _LINUX_TTY_LDISC_H */ diff --git a/ddverify/models/con2/include/linux/types.h b/ddverify/models/con2/include/linux/types.h new file mode 100644 index 000000000..b437e9baa --- /dev/null +++ b/ddverify/models/con2/include/linux/types.h @@ -0,0 +1,105 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#include +#include + +#define __bitwise + +typedef __u32 __kernel_dev_t; + +typedef __kernel_dev_t dev_t; +typedef __kernel_ino_t ino_t; +typedef __kernel_mode_t mode_t; +typedef __kernel_nlink_t nlink_t; +typedef __kernel_off_t off_t; +typedef __kernel_pid_t pid_t; +typedef __kernel_daddr_t daddr_t; +typedef __kernel_key_t key_t; +typedef __kernel_suseconds_t suseconds_t; +typedef __kernel_timer_t timer_t; +typedef __kernel_clockid_t clockid_t; +typedef __kernel_mqd_t mqd_t; + +typedef __kernel_uid32_t uid_t; +typedef __kernel_gid32_t gid_t; +typedef __kernel_uid16_t uid16_t; +typedef __kernel_gid16_t gid16_t; + + +typedef long long loff_t; + +/* + * The following typedefs are also protected by individual ifdefs for + * historical reasons: + */ +#ifndef _SIZE_T +#define _SIZE_T +typedef __kernel_size_t size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __kernel_ssize_t ssize_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef __kernel_ptrdiff_t ptrdiff_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef __kernel_time_t time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef __kernel_clock_t clock_t; +#endif + +#ifndef _CADDR_T +#define _CADDR_T +typedef __kernel_caddr_t caddr_t; +#endif + + +/* bsd */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +/* sysv */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + + +typedef __u8 uint8_t; +typedef __u16 uint16_t; +typedef __u32 uint32_t; + +typedef __u64 uint64_t; +typedef __u64 u_int64_t; +//typedef __s64 int64_t; + +typedef unsigned gfp_t; + +#ifndef HAVE_SECTOR_T +typedef unsigned long sector_t; +#endif + +#ifndef HAVE_BLKCNT_T +typedef unsigned long blkcnt_t; +#endif + +typedef __u16 __bitwise __le16; +typedef __u16 __bitwise __be16; +typedef __u32 __bitwise __le32; +typedef __u32 __bitwise __be32; +typedef __u64 __bitwise __le64; +typedef __u64 __bitwise __be64; + +#endif diff --git a/ddverify/models/con2/include/linux/uio.h b/ddverify/models/con2/include/linux/uio.h new file mode 100644 index 000000000..c59931d23 --- /dev/null +++ b/ddverify/models/con2/include/linux/uio.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_UIO_H +#define __LINUX_UIO_H + +#include +#include + +struct kvec { + void *iov_base; /* and that should *never* hold a userland pointer */ + size_t iov_len; +}; + +#endif diff --git a/ddverify/models/con2/include/linux/videodev.h b/ddverify/models/con2/include/linux/videodev.h new file mode 100644 index 000000000..2628e86ac --- /dev/null +++ b/ddverify/models/con2/include/linux/videodev.h @@ -0,0 +1,346 @@ +#ifndef __LINUX_VIDEODEV_H +#define __LINUX_VIDEODEV_H + +#include +#include +#include + +extern struct video_device* video_devdata(struct file*); + +static inline void *video_get_drvdata(struct video_device *dev) +{ + return dev->priv; +} + +static inline void video_set_drvdata(struct video_device *dev, void *data) +{ + dev->priv = data; +} + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +struct video_capability +{ + char name[32]; + int type; + int channels; /* Num channels */ + int audios; /* Num audio devices */ + int maxwidth; /* Supported width */ + int maxheight; /* And height */ + int minwidth; /* Supported width */ + int minheight; /* And height */ +}; + + +struct video_channel +{ + int channel; + char name[32]; + int tuners; + __u32 flags; +#define VIDEO_VC_TUNER 1 /* Channel has a tuner */ +#define VIDEO_VC_AUDIO 2 /* Channel has audio */ + __u16 type; +#define VIDEO_TYPE_TV 1 +#define VIDEO_TYPE_CAMERA 2 + __u16 norm; /* Norm set by channel */ +}; + + +struct video_tuner +{ + int tuner; + char name[32]; + unsigned long rangelow, rangehigh; /* Tuner range */ + __u32 flags; +#define VIDEO_TUNER_PAL 1 +#define VIDEO_TUNER_NTSC 2 +#define VIDEO_TUNER_SECAM 4 +#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */ +#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */ +#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */ +#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */ +#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */ + __u16 mode; /* PAL/NTSC/SECAM/OTHER */ +#define VIDEO_MODE_PAL 0 +#define VIDEO_MODE_NTSC 1 +#define VIDEO_MODE_SECAM 2 +#define VIDEO_MODE_AUTO 3 + __u16 signal; /* Signal strength 16bit scale */ +}; + + +struct video_picture +{ + __u16 brightness; + __u16 hue; + __u16 colour; + __u16 contrast; + __u16 whiteness; /* Black and white only */ + __u16 depth; /* Capture depth */ + __u16 palette; /* Palette in use */ +#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ +#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ +#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ +#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */ +#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */ +#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */ +#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */ +#define VIDEO_PALETTE_YUYV 8 +#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */ +#define VIDEO_PALETTE_YUV420 10 +#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */ +#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */ +#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */ +#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */ +#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */ +#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ +#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ +#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ +}; + +struct video_audio +{ + int audio; /* Audio channel */ + __u16 volume; /* If settable */ + __u16 bass, treble; + __u32 flags; +#define VIDEO_AUDIO_MUTE 1 +#define VIDEO_AUDIO_MUTABLE 2 +#define VIDEO_AUDIO_VOLUME 4 +#define VIDEO_AUDIO_BASS 8 +#define VIDEO_AUDIO_TREBLE 16 +#define VIDEO_AUDIO_BALANCE 32 + char name[16]; +#define VIDEO_SOUND_MONO 1 +#define VIDEO_SOUND_STEREO 2 +#define VIDEO_SOUND_LANG1 4 +#define VIDEO_SOUND_LANG2 8 + __u16 mode; + __u16 balance; /* Stereo balance */ + __u16 step; /* Step actual volume uses */ +}; + +struct video_clip +{ + __s32 x,y; + __s32 width, height; + struct video_clip *next; /* For user use/driver use only */ +}; + +struct video_window +{ + __u32 x,y; /* Position of window */ + __u32 width,height; /* Its size */ + __u32 chromakey; + __u32 flags; + struct video_clip __user *clips; /* Set only */ + int clipcount; +#define VIDEO_WINDOW_INTERLACE 1 +#define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */ +#define VIDEO_CLIP_BITMAP -1 +/* bitmap is 1024x625, a '1' bit represents a clipped pixel */ +#define VIDEO_CLIPMAP_SIZE (128 * 625) +}; + +struct video_capture +{ + __u32 x,y; /* Offsets into image */ + __u32 width, height; /* Area to capture */ + __u16 decimation; /* Decimation divider */ + __u16 flags; /* Flags for capture */ +#define VIDEO_CAPTURE_ODD 0 /* Temporal */ +#define VIDEO_CAPTURE_EVEN 1 +}; + +struct video_buffer +{ + void *base; + int height,width; + int depth; + int bytesperline; +}; + +struct video_mmap +{ + unsigned int frame; /* Frame (0 - n) for double buffer */ + int height,width; + unsigned int format; /* should be VIDEO_PALETTE_* */ +}; + +struct video_key +{ + __u8 key[8]; + __u32 flags; +}; + +struct video_mbuf +{ + int size; /* Total memory to map */ + int frames; /* Frames */ + int offsets[VIDEO_MAX_FRAME]; +}; + +#define VIDEO_NO_UNIT (-1) + +struct video_unit +{ + int video; /* Video minor */ + int vbi; /* VBI minor */ + int radio; /* Radio minor */ + int audio; /* Audio minor */ + int teletext; /* Teletext minor */ +}; + +struct vbi_format { + __u32 sampling_rate; /* in Hz */ + __u32 samples_per_line; + __u32 sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */ + __s32 start[2]; /* starting line for each frame */ + __u32 count[2]; /* count of lines for each frame */ + __u32 flags; +#define VBI_UNSYNC 1 /* can distingues between top/bottom field */ +#define VBI_INTERLACED 2 /* lines are interlaced */ +}; + +/* video_info is biased towards hardware mpeg encode/decode */ +/* but it could apply generically to any hardware compressor/decompressor */ +struct video_info +{ + __u32 frame_count; /* frames output since decode/encode began */ + __u32 h_size; /* current unscaled horizontal size */ + __u32 v_size; /* current unscaled veritcal size */ + __u32 smpte_timecode; /* current SMPTE timecode (for current GOP) */ + __u32 picture_type; /* current picture type */ + __u32 temporal_reference; /* current temporal reference */ + __u8 user_data[256]; /* user data last found in compressed stream */ + /* user_data[0] contains user data flags, user_data[1] has count */ +}; + +/* generic structure for setting playback modes */ +struct video_play_mode +{ + int mode; + int p1; + int p2; +}; + +/* for loading microcode / fpga programming */ +struct video_code +{ + char loadwhat[16]; /* name or tag of file being passed */ + int datasize; + __u8 *data; +}; + + +#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */ +#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */ +#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */ +#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */ +#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */ +#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */ +#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */ +#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */ +#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */ +#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */ +#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */ +#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */ +#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) */ +#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */ +#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */ +#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */ +#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */ +#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */ +#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */ +#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */ +#define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */ +#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */ +#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */ +#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */ +#define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */ +#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */ +#define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */ +#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */ +#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */ + + +#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */ + +/* VIDIOCSWRITEMODE */ +#define VID_WRITE_MPEG_AUD 0 +#define VID_WRITE_MPEG_VID 1 +#define VID_WRITE_OSD 2 +#define VID_WRITE_TTX 3 +#define VID_WRITE_CC 4 +#define VID_WRITE_MJPEG 5 + +/* VIDIOCSPLAYMODE */ +#define VID_PLAY_VID_OUT_MODE 0 + /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */ +#define VID_PLAY_GENLOCK 1 + /* p1: 0 = OFF, 1 = ON */ + /* p2: GENLOCK FINE DELAY value */ +#define VID_PLAY_NORMAL 2 +#define VID_PLAY_PAUSE 3 +#define VID_PLAY_SINGLE_FRAME 4 +#define VID_PLAY_FAST_FORWARD 5 +#define VID_PLAY_SLOW_MOTION 6 +#define VID_PLAY_IMMEDIATE_NORMAL 7 +#define VID_PLAY_SWITCH_CHANNELS 8 +#define VID_PLAY_FREEZE_FRAME 9 +#define VID_PLAY_STILL_MODE 10 +#define VID_PLAY_MASTER_MODE 11 + /* p1: see below */ +#define VID_PLAY_MASTER_NONE 1 +#define VID_PLAY_MASTER_VIDEO 2 +#define VID_PLAY_MASTER_AUDIO 3 +#define VID_PLAY_ACTIVE_SCANLINES 12 + /* p1 = first active; p2 = last active */ +#define VID_PLAY_RESET 13 +#define VID_PLAY_END_MARK 14 + + + +#define VID_HARDWARE_BT848 1 +#define VID_HARDWARE_QCAM_BW 2 +#define VID_HARDWARE_PMS 3 +#define VID_HARDWARE_QCAM_C 4 +#define VID_HARDWARE_PSEUDO 5 +#define VID_HARDWARE_SAA5249 6 +#define VID_HARDWARE_AZTECH 7 +#define VID_HARDWARE_SF16MI 8 +#define VID_HARDWARE_RTRACK 9 +#define VID_HARDWARE_ZOLTRIX 10 +#define VID_HARDWARE_SAA7146 11 +#define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */ +#define VID_HARDWARE_RTRACK2 13 +#define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */ +#define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */ +#define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */ +#define VID_HARDWARE_BROADWAY 17 /* Broadway project */ +#define VID_HARDWARE_GEMTEK 18 +#define VID_HARDWARE_TYPHOON 19 +#define VID_HARDWARE_VINO 20 /* SGI Indy Vino */ +#define VID_HARDWARE_CADET 21 /* Cadet radio */ +#define VID_HARDWARE_TRUST 22 /* Trust FM Radio */ +#define VID_HARDWARE_TERRATEC 23 /* TerraTec ActiveRadio */ +#define VID_HARDWARE_CPIA 24 +#define VID_HARDWARE_ZR36120 25 /* Zoran ZR36120/ZR36125 */ +#define VID_HARDWARE_ZR36067 26 /* Zoran ZR36067/36060 */ +#define VID_HARDWARE_OV511 27 +#define VID_HARDWARE_ZR356700 28 /* Zoran 36700 series */ +#define VID_HARDWARE_W9966 29 +#define VID_HARDWARE_SE401 30 /* SE401 USB webcams */ +#define VID_HARDWARE_PWC 31 /* Philips webcams */ +#define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */ +#define VID_HARDWARE_CPIA2 33 +#define VID_HARDWARE_VICAM 34 +#define VID_HARDWARE_SF16FMR2 35 +#define VID_HARDWARE_W9968CF 36 +#define VID_HARDWARE_SAA7114H 37 +#define VID_HARDWARE_SN9C102 38 +#define VID_HARDWARE_ARV 39 + +#endif /* __LINUX_VIDEODEV_H */ diff --git a/ddverify/models/con2/include/linux/videodev2.h b/ddverify/models/con2/include/linux/videodev2.h new file mode 100644 index 000000000..df5c46543 --- /dev/null +++ b/ddverify/models/con2/include/linux/videodev2.h @@ -0,0 +1,1351 @@ +/* + * Video for Linux Two + * + * Header file for v4l or V4L2 drivers and applications + * with public API. + * All kernel-specific stuff were moved to media/v4l2-dev.h, so + * no #if __KERNEL tests are allowed here + * + * See http://linuxtv.org for more info + * + * Author: Bill Dirks + * Justin Schoeman + * et al. + */ +#ifndef __LINUX_VIDEODEV2_H +#define __LINUX_VIDEODEV2_H +#ifdef __KERNEL__ +#include /* need struct timeval */ +#include /* need __user */ +#else +#define __user +#endif +#include + +/* + * Common stuff for both V4L1 and V4L2 + * Moved from videodev.h + */ +#define VIDEO_MAX_FRAME 32 + +#define VID_TYPE_CAPTURE 1 /* Can capture */ +#define VID_TYPE_TUNER 2 /* Can tune */ +#define VID_TYPE_TELETEXT 4 /* Does teletext */ +#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */ +#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */ +#define VID_TYPE_CLIPPING 32 /* Can clip */ +#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */ +#define VID_TYPE_SCALES 128 /* Scalable */ +#define VID_TYPE_MONOCHROME 256 /* Monochrome only */ +#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */ +#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */ +#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ +#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ +#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ + +/* + * M I S C E L L A N E O U S + */ + +/* Four-character-code (FOURCC) */ +#define v4l2_fourcc(a,b,c,d)\ + (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) + +/* + * E N U M S + */ +enum v4l2_field { + V4L2_FIELD_ANY = 0, /* driver can choose from none, + top, bottom, interlaced + depending on whatever it thinks + is approximate ... */ + V4L2_FIELD_NONE = 1, /* this device has no fields ... */ + V4L2_FIELD_TOP = 2, /* top field only */ + V4L2_FIELD_BOTTOM = 3, /* bottom field only */ + V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ + V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one + buffer, top-bottom order */ + V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ + V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into + separate buffers */ +}; +#define V4L2_FIELD_HAS_TOP(field) \ + ((field) == V4L2_FIELD_TOP ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTTOM(field) \ + ((field) == V4L2_FIELD_BOTTOM ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTH(field) \ + ((field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) + +enum v4l2_buf_type { + V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, + V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, + V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, + V4L2_BUF_TYPE_VBI_CAPTURE = 4, + V4L2_BUF_TYPE_VBI_OUTPUT = 5, +#if 1 + /* Experimental Sliced VBI */ + V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, + V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, +#endif + V4L2_BUF_TYPE_PRIVATE = 0x80, +}; + +enum v4l2_ctrl_type { + V4L2_CTRL_TYPE_INTEGER = 1, + V4L2_CTRL_TYPE_BOOLEAN = 2, + V4L2_CTRL_TYPE_MENU = 3, + V4L2_CTRL_TYPE_BUTTON = 4, + V4L2_CTRL_TYPE_INTEGER64 = 5, + V4L2_CTRL_TYPE_CTRL_CLASS = 6, +}; + +enum v4l2_tuner_type { + V4L2_TUNER_RADIO = 1, + V4L2_TUNER_ANALOG_TV = 2, + V4L2_TUNER_DIGITAL_TV = 3, +}; + +enum v4l2_memory { + V4L2_MEMORY_MMAP = 1, + V4L2_MEMORY_USERPTR = 2, + V4L2_MEMORY_OVERLAY = 3, +}; + +/* see also http://vektor.theorem.ca/graphics/ycbcr/ */ +enum v4l2_colorspace { + /* ITU-R 601 -- broadcast NTSC/PAL */ + V4L2_COLORSPACE_SMPTE170M = 1, + + /* 1125-Line (US) HDTV */ + V4L2_COLORSPACE_SMPTE240M = 2, + + /* HD and modern captures. */ + V4L2_COLORSPACE_REC709 = 3, + + /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */ + V4L2_COLORSPACE_BT878 = 4, + + /* These should be useful. Assume 601 extents. */ + V4L2_COLORSPACE_470_SYSTEM_M = 5, + V4L2_COLORSPACE_470_SYSTEM_BG = 6, + + /* I know there will be cameras that send this. So, this is + * unspecified chromaticities and full 0-255 on each of the + * Y'CbCr components + */ + V4L2_COLORSPACE_JPEG = 7, + + /* For RGB colourspaces, this is probably a good start. */ + V4L2_COLORSPACE_SRGB = 8, +}; + +enum v4l2_priority { + V4L2_PRIORITY_UNSET = 0, /* not initialized */ + V4L2_PRIORITY_BACKGROUND = 1, + V4L2_PRIORITY_INTERACTIVE = 2, + V4L2_PRIORITY_RECORD = 3, + V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE, +}; + +struct v4l2_rect { + __s32 left; + __s32 top; + __s32 width; + __s32 height; +}; + +struct v4l2_fract { + __u32 numerator; + __u32 denominator; +}; + +/* + * D R I V E R C A P A B I L I T I E S + */ +struct v4l2_capability +{ + __u8 driver[16]; /* i.e. "bttv" */ + __u8 card[32]; /* i.e. "Hauppauge WinTV" */ + __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ + __u32 version; /* should use KERNEL_VERSION() */ + __u32 capabilities; /* Device capabilities */ + __u32 reserved[4]; +}; + +/* Values for 'capabilities' field */ +#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ +#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ +#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ +#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ +#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ +#if 1 +#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ +#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ +#endif +#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ + +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ +#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ + +#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ +#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ +#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ + +/* + * V I D E O I M A G E F O R M A T + */ +struct v4l2_pix_format +{ + __u32 width; + __u32 height; + __u32 pixelformat; + enum v4l2_field field; + __u32 bytesperline; /* for padding, zero if unused */ + __u32 sizeimage; + enum v4l2_colorspace colorspace; + __u32 priv; /* private data, depends on pixelformat */ +}; + +/* Pixel format FOURCC depth Description */ +#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */ +#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */ +#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */ +#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */ +#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */ +#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */ +#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */ +#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ +#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ +#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ +#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ +#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ +#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */ +#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */ +#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */ + +/* two planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */ + +/* The following formats are not defined in the V4L2 specification */ +#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */ +#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ +#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ +#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */ + +/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ +#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ + +/* compressed formats */ +#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ +#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */ +#define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */ +#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG-1/2/4 */ + +/* Vendor-specific formats */ +#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */ +#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */ + +/* + * F O R M A T E N U M E R A T I O N + */ +struct v4l2_fmtdesc +{ + __u32 index; /* Format number */ + enum v4l2_buf_type type; /* buffer type */ + __u32 flags; + __u8 description[32]; /* Description string */ + __u32 pixelformat; /* Format fourcc */ + __u32 reserved[4]; +}; + +#define V4L2_FMT_FLAG_COMPRESSED 0x0001 + +#if 1 + /* Experimental Frame Size and frame rate enumeration */ +/* + * F R A M E S I Z E E N U M E R A T I O N + */ +enum v4l2_frmsizetypes +{ + V4L2_FRMSIZE_TYPE_DISCRETE = 1, + V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, + V4L2_FRMSIZE_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmsize_discrete +{ + __u32 width; /* Frame width [pixel] */ + __u32 height; /* Frame height [pixel] */ +}; + +struct v4l2_frmsize_stepwise +{ + __u32 min_width; /* Minimum frame width [pixel] */ + __u32 max_width; /* Maximum frame width [pixel] */ + __u32 step_width; /* Frame width step size [pixel] */ + __u32 min_height; /* Minimum frame height [pixel] */ + __u32 max_height; /* Maximum frame height [pixel] */ + __u32 step_height; /* Frame height step size [pixel] */ +}; + +struct v4l2_frmsizeenum +{ + __u32 index; /* Frame size number */ + __u32 pixel_format; /* Pixel format */ + __u32 type; /* Frame size type the device supports. */ + + union { /* Frame size */ + struct v4l2_frmsize_discrete discrete; + struct v4l2_frmsize_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; + +/* + * F R A M E R A T E E N U M E R A T I O N + */ +enum v4l2_frmivaltypes +{ + V4L2_FRMIVAL_TYPE_DISCRETE = 1, + V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, + V4L2_FRMIVAL_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmival_stepwise +{ + struct v4l2_fract min; /* Minimum frame interval [s] */ + struct v4l2_fract max; /* Maximum frame interval [s] */ + struct v4l2_fract step; /* Frame interval step size [s] */ +}; + +struct v4l2_frmivalenum +{ + __u32 index; /* Frame format index */ + __u32 pixel_format; /* Pixel format */ + __u32 width; /* Frame width */ + __u32 height; /* Frame height */ + __u32 type; /* Frame interval type the device supports. */ + + union { /* Frame interval */ + struct v4l2_fract discrete; + struct v4l2_frmival_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; +#endif + +/* + * T I M E C O D E + */ +struct v4l2_timecode +{ + __u32 type; + __u32 flags; + __u8 frames; + __u8 seconds; + __u8 minutes; + __u8 hours; + __u8 userbits[4]; +}; + +/* Type */ +#define V4L2_TC_TYPE_24FPS 1 +#define V4L2_TC_TYPE_25FPS 2 +#define V4L2_TC_TYPE_30FPS 3 +#define V4L2_TC_TYPE_50FPS 4 +#define V4L2_TC_TYPE_60FPS 5 + +/* Flags */ +#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */ +#define V4L2_TC_FLAG_COLORFRAME 0x0002 +#define V4L2_TC_USERBITS_field 0x000C +#define V4L2_TC_USERBITS_USERDEFINED 0x0000 +#define V4L2_TC_USERBITS_8BITCHARS 0x0008 +/* The above is based on SMPTE timecodes */ + +#ifdef __KERNEL__ +/* + * 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 + * + * ### WARNING: This experimental MPEG compression API is obsolete. + * ### It is replaced by the MPEG controls API. + * ### This old API will disappear in the near future! + * + */ +enum v4l2_bitrate_mode { + V4L2_BITRATE_NONE = 0, /* not specified */ + V4L2_BITRATE_CBR, /* constant bitrate */ + V4L2_BITRATE_VBR, /* variable bitrate */ +}; +struct v4l2_bitrate { + /* rates are specified in kbit/sec */ + enum v4l2_bitrate_mode mode; + __u32 min; + __u32 target; /* use this one for CBR */ + __u32 max; +}; + +enum v4l2_mpeg_streamtype { + V4L2_MPEG_SS_1, /* MPEG-1 system stream */ + V4L2_MPEG_PS_2, /* MPEG-2 program stream */ + V4L2_MPEG_TS_2, /* MPEG-2 transport stream */ + V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */ +}; +enum v4l2_mpeg_audiotype { + V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */ + V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */ + V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */ + V4L2_MPEG_AC3, /* AC3 */ + V4L2_MPEG_LPCM, /* LPCM */ +}; +enum v4l2_mpeg_videotype { + V4L2_MPEG_VI_1, /* MPEG-1 */ + V4L2_MPEG_VI_2, /* MPEG-2 */ +}; +enum v4l2_mpeg_aspectratio { + V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */ + V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */ + V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */ + V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */ +}; + +struct v4l2_mpeg_compression { + /* general */ + enum v4l2_mpeg_streamtype st_type; + struct v4l2_bitrate st_bitrate; + + /* transport streams */ + __u16 ts_pid_pmt; + __u16 ts_pid_audio; + __u16 ts_pid_video; + __u16 ts_pid_pcr; + + /* program stream */ + __u16 ps_size; + __u16 reserved_1; /* align */ + + /* audio */ + enum v4l2_mpeg_audiotype au_type; + struct v4l2_bitrate au_bitrate; + __u32 au_sample_rate; + __u8 au_pesid; + __u8 reserved_2[3]; /* align */ + + /* video */ + enum v4l2_mpeg_videotype vi_type; + enum v4l2_mpeg_aspectratio vi_aspect_ratio; + struct v4l2_bitrate vi_bitrate; + __u32 vi_frame_rate; + __u16 vi_frames_per_gop; + __u16 vi_bframes_count; + __u8 vi_pesid; + __u8 reserved_3[3]; /* align */ + + /* misc flags */ + __u32 closed_gops:1; + __u32 pulldown:1; + __u32 reserved_4:30; /* align */ + + /* I don't expect the above being perfect yet ;) */ + __u32 reserved_5[8]; +}; +#endif + +struct v4l2_jpegcompression +{ + int quality; + + int APPn; /* Number of APP segment to be written, + * must be 0..15 */ + int APP_len; /* Length of data in JPEG APPn segment */ + char APP_data[60]; /* Data in the JPEG APPn segment. */ + + int COM_len; /* Length of data in JPEG COM segment */ + char COM_data[60]; /* Data in JPEG COM segment */ + + __u32 jpeg_markers; /* Which markers should go into the JPEG + * output. Unless you exactly know what + * you do, leave them untouched. + * Inluding less markers will make the + * resulting code smaller, but there will + * be fewer aplications which can read it. + * The presence of the APP and COM marker + * is influenced by APP_len and COM_len + * ONLY, not by this property! */ + +#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ +#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ +#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ +#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ +#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will + * allways use APP0 */ +}; + +/* + * M E M O R Y - M A P P I N G B U F F E R S + */ +struct v4l2_requestbuffers +{ + __u32 count; + enum v4l2_buf_type type; + enum v4l2_memory memory; + __u32 reserved[2]; +}; + +struct v4l2_buffer +{ + __u32 index; + enum v4l2_buf_type type; + __u32 bytesused; + __u32 flags; + enum v4l2_field field; + struct timeval timestamp; + struct v4l2_timecode timecode; + __u32 sequence; + + /* memory location */ + enum v4l2_memory memory; + union { + __u32 offset; + unsigned long userptr; + } m; + __u32 length; + __u32 input; + __u32 reserved; +}; + +/* Flags for 'flags' field */ +#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */ +#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */ +#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */ +#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */ +#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */ +#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */ +#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ +#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */ + +/* + * O V E R L A Y P R E V I E W + */ +struct v4l2_framebuffer +{ + __u32 capability; + __u32 flags; +/* FIXME: in theory we should pass something like PCI device + memory + * region + offset instead of some physical address */ + void* base; + struct v4l2_pix_format fmt; +}; +/* Flags for the 'capability' field. Read only */ +#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 +#define V4L2_FBUF_CAP_CHROMAKEY 0x0002 +#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 +#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 +/* Flags for the 'flags' field. */ +#define V4L2_FBUF_FLAG_PRIMARY 0x0001 +#define V4L2_FBUF_FLAG_OVERLAY 0x0002 +#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 + +struct v4l2_clip +{ + struct v4l2_rect c; + struct v4l2_clip __user *next; +}; + +struct v4l2_window +{ + struct v4l2_rect w; + enum v4l2_field field; + __u32 chromakey; + struct v4l2_clip __user *clips; + __u32 clipcount; + void __user *bitmap; +}; + +/* + * C A P T U R E P A R A M E T E R S + */ +struct v4l2_captureparm +{ + __u32 capability; /* Supported modes */ + __u32 capturemode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in .1us units */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 readbuffers; /* # of buffers for read */ + __u32 reserved[4]; +}; + +/* Flags for 'capability' and 'capturemode' fields */ +#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ +#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ + +struct v4l2_outputparm +{ + __u32 capability; /* Supported modes */ + __u32 outputmode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in seconds */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 writebuffers; /* # of buffers for write */ + __u32 reserved[4]; +}; + +/* + * I N P U T I M A G E C R O P P I N G + */ +struct v4l2_cropcap { + enum v4l2_buf_type type; + struct v4l2_rect bounds; + struct v4l2_rect defrect; + struct v4l2_fract pixelaspect; +}; + +struct v4l2_crop { + enum v4l2_buf_type type; + struct v4l2_rect c; +}; + +/* + * A N A L O G V I D E O S T A N D A R D + */ + +typedef __u64 v4l2_std_id; + +/* one bit for each */ +#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001) +#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002) +#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004) +#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008) +#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010) +#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020) +#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040) +#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080) + +#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100) +#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200) +#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400) +#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800) + +#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) +#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) +#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) +#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) + +#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000) +#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000) +#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000) +#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000) +#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) +#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) +#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) +#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000) + +/* ATSC/HDTV */ +#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) +#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) + +/* some merged standards */ +#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) +#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) +#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) +#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) + +/* some common needed stuff */ +#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ + V4L2_STD_PAL_B1 |\ + V4L2_STD_PAL_G) +#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\ + V4L2_STD_PAL_D1 |\ + V4L2_STD_PAL_K) +#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ + V4L2_STD_PAL_DK |\ + V4L2_STD_PAL_H |\ + V4L2_STD_PAL_I) +#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\ + V4L2_STD_NTSC_M_JP |\ + V4L2_STD_NTSC_M_KR) +#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ + V4L2_STD_SECAM_K |\ + V4L2_STD_SECAM_K1) +#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\ + V4L2_STD_SECAM_G |\ + V4L2_STD_SECAM_H |\ + V4L2_STD_SECAM_DK |\ + V4L2_STD_SECAM_L |\ + V4L2_STD_SECAM_LC) + +#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ + V4L2_STD_PAL_60 |\ + V4L2_STD_NTSC |\ + V4L2_STD_NTSC_443) +#define V4L2_STD_625_50 (V4L2_STD_PAL |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc |\ + V4L2_STD_SECAM) +#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\ + V4L2_STD_ATSC_16_VSB) + +#define V4L2_STD_UNKNOWN 0 +#define V4L2_STD_ALL (V4L2_STD_525_60 |\ + V4L2_STD_625_50) + +struct v4l2_standard +{ + __u32 index; + v4l2_std_id id; + __u8 name[24]; + struct v4l2_fract frameperiod; /* Frames, not fields */ + __u32 framelines; + __u32 reserved[4]; +}; + +/* + * V I D E O I N P U T S + */ +struct v4l2_input +{ + __u32 index; /* Which input */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of input */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 tuner; /* Associated tuner */ + v4l2_std_id std; + __u32 status; + __u32 reserved[4]; +}; + +/* Values for the 'type' field */ +#define V4L2_INPUT_TYPE_TUNER 1 +#define V4L2_INPUT_TYPE_CAMERA 2 + +/* field 'status' - general */ +#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */ +#define V4L2_IN_ST_NO_SIGNAL 0x00000002 +#define V4L2_IN_ST_NO_COLOR 0x00000004 + +/* field 'status' - analog */ +#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ +#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ + +/* field 'status' - digital */ +#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */ +#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */ +#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */ + +/* field 'status' - VCR and set-top box */ +#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */ +#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ +#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ + +/* + * V I D E O O U T P U T S + */ +struct v4l2_output +{ + __u32 index; /* Which output */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of output */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 modulator; /* Associated modulator */ + v4l2_std_id std; + __u32 reserved[4]; +}; +/* Values for the 'type' field */ +#define V4L2_OUTPUT_TYPE_MODULATOR 1 +#define V4L2_OUTPUT_TYPE_ANALOG 2 +#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 + +/* + * C O N T R O L S + */ +struct v4l2_control +{ + __u32 id; + __s32 value; +}; + +struct v4l2_ext_control +{ + __u32 id; + __u32 reserved2[2]; + union { + __s32 value; + __s64 value64; + void *reserved; + }; +} __attribute__ ((packed)); + +struct v4l2_ext_controls +{ + __u32 ctrl_class; + __u32 count; + __u32 error_idx; + __u32 reserved[2]; + struct v4l2_ext_control *controls; +}; + +/* Values for ctrl_class field */ +#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ +#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ + +#define V4L2_CTRL_ID_MASK (0x0fffffff) +#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) +#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) + +/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ +struct v4l2_queryctrl +{ + __u32 id; + enum v4l2_ctrl_type type; + __u8 name[32]; /* Whatever */ + __s32 minimum; /* Note signedness */ + __s32 maximum; + __s32 step; + __s32 default_value; + __u32 flags; + __u32 reserved[2]; +}; + +/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ +struct v4l2_querymenu +{ + __u32 id; + __u32 index; + __u8 name[32]; /* Whatever */ + __u32 reserved; +}; + +/* Control flags */ +#define V4L2_CTRL_FLAG_DISABLED 0x0001 +#define V4L2_CTRL_FLAG_GRABBED 0x0002 +#define V4L2_CTRL_FLAG_READ_ONLY 0x0004 +#define V4L2_CTRL_FLAG_UPDATE 0x0008 +#define V4L2_CTRL_FLAG_INACTIVE 0x0010 +#define V4L2_CTRL_FLAG_SLIDER 0x0020 + +/* Query flag, to be ORed with the control ID */ +#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 + +/* User-class control IDs defined by V4L2 */ +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) +#define V4L2_CID_USER_BASE V4L2_CID_BASE +/* IDs reserved for driver specific controls */ +#define V4L2_CID_PRIVATE_BASE 0x08000000 + +#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) +#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) +#define V4L2_CID_SATURATION (V4L2_CID_BASE+2) +#define V4L2_CID_HUE (V4L2_CID_BASE+3) +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) +#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7) +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) +#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) +#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) +#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */ +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) +#define V4L2_CID_GAIN (V4L2_CID_BASE+19) +#define V4L2_CID_HFLIP (V4L2_CID_BASE+20) +#define V4L2_CID_VFLIP (V4L2_CID_BASE+21) +#define V4L2_CID_HCENTER (V4L2_CID_BASE+22) +#define V4L2_CID_VCENTER (V4L2_CID_BASE+23) +#define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */ + +/* MPEG-class control IDs defined by V4L2 */ +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) + +/* MPEG streams */ +#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) +enum v4l2_mpeg_stream_type { + V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */ +}; +#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) +#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) +#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) +#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) +#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) +enum v4l2_mpeg_stream_vbi_fmt { + V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ + V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */ +}; + +/* MPEG audio */ +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) +enum v4l2_mpeg_audio_sampling_freq { + V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) +enum v4l2_mpeg_audio_encoding { + V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, + V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, + V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) +enum v4l2_mpeg_audio_l1_bitrate { + V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, + V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2, + V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3, + V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4, + V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5, + V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6, + V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7, + V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8, + V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9, + V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10, + V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11, + V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, + V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) +enum v4l2_mpeg_audio_l2_bitrate { + V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, + V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2, + V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3, + V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4, + V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5, + V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6, + V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7, + V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8, + V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9, + V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10, + V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11, + V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, + V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) +enum v4l2_mpeg_audio_l3_bitrate { + V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, + V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2, + V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3, + V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4, + V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5, + V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6, + V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7, + V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8, + V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9, + V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10, + V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11, + V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, + V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) +enum v4l2_mpeg_audio_mode { + V4L2_MPEG_AUDIO_MODE_STEREO = 0, + V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, + V4L2_MPEG_AUDIO_MODE_DUAL = 2, + V4L2_MPEG_AUDIO_MODE_MONO = 3, +}; +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) +enum v4l2_mpeg_audio_mode_extension { + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3, +}; +#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) +enum v4l2_mpeg_audio_emphasis { + V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, + V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, + V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) +enum v4l2_mpeg_audio_crc { + V4L2_MPEG_AUDIO_CRC_NONE = 0, + V4L2_MPEG_AUDIO_CRC_CRC16 = 1, +}; + +/* MPEG video */ +#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) +enum v4l2_mpeg_video_encoding { + V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, + V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, +}; +#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) +enum v4l2_mpeg_video_aspect { + V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, + V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, + V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, + V4L2_MPEG_VIDEO_ASPECT_221x100 = 3, +}; +#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) +#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) +enum v4l2_mpeg_video_bitrate_mode { + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, +}; +#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) + +/* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) +enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2) +enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3) +enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4) +enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5) +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6) +enum v4l2_mpeg_cx2341x_video_median_filter_type { + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) + +/* + * T U N I N G + */ +struct v4l2_tuner +{ + __u32 index; + __u8 name[32]; + enum v4l2_tuner_type type; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 rxsubchans; + __u32 audmode; + __s32 signal; + __s32 afc; + __u32 reserved[4]; +}; + +struct v4l2_modulator +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 txsubchans; + __u32 reserved[4]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_TUNER_CAP_LOW 0x0001 +#define V4L2_TUNER_CAP_NORM 0x0002 +#define V4L2_TUNER_CAP_STEREO 0x0010 +#define V4L2_TUNER_CAP_LANG2 0x0020 +#define V4L2_TUNER_CAP_SAP 0x0020 +#define V4L2_TUNER_CAP_LANG1 0x0040 + +/* Flags for the 'rxsubchans' field */ +#define V4L2_TUNER_SUB_MONO 0x0001 +#define V4L2_TUNER_SUB_STEREO 0x0002 +#define V4L2_TUNER_SUB_LANG2 0x0004 +#define V4L2_TUNER_SUB_SAP 0x0004 +#define V4L2_TUNER_SUB_LANG1 0x0008 + +/* Values for the 'audmode' field */ +#define V4L2_TUNER_MODE_MONO 0x0000 +#define V4L2_TUNER_MODE_STEREO 0x0001 +#define V4L2_TUNER_MODE_LANG2 0x0002 +#define V4L2_TUNER_MODE_SAP 0x0002 +#define V4L2_TUNER_MODE_LANG1 0x0003 +#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 + +struct v4l2_frequency +{ + __u32 tuner; + enum v4l2_tuner_type type; + __u32 frequency; + __u32 reserved[8]; +}; + +/* + * A U D I O + */ +struct v4l2_audio +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_AUDCAP_STEREO 0x00001 +#define V4L2_AUDCAP_AVL 0x00002 + +/* Flags for the 'mode' field */ +#define V4L2_AUDMODE_AVL 0x00001 + +struct v4l2_audioout +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* + * D A T A S E R V I C E S ( V B I ) + * + * Data services API by Michael Schimek + */ + +/* Raw VBI */ +struct v4l2_vbi_format +{ + __u32 sampling_rate; /* in 1 Hz */ + __u32 offset; + __u32 samples_per_line; + __u32 sample_format; /* V4L2_PIX_FMT_* */ + __s32 start[2]; + __u32 count[2]; + __u32 flags; /* V4L2_VBI_* */ + __u32 reserved[2]; /* must be zero */ +}; + +/* VBI flags */ +#define V4L2_VBI_UNSYNC (1<< 0) +#define V4L2_VBI_INTERLACED (1<< 1) + +#if 1 +/* Sliced VBI + * + * This implements is a proposal V4L2 API to allow SLICED VBI + * required for some hardware encoders. It should change without + * notice in the definitive implementation. + */ + +struct v4l2_sliced_vbi_format +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + __u32 io_size; + __u32 reserved[2]; /* must be zero */ +}; + +/* Teletext World System Teletext + (WST), defined on ITU-R BT.653-2 */ +#define V4L2_SLICED_TELETEXT_B (0x0001) +/* Video Program System, defined on ETS 300 231*/ +#define V4L2_SLICED_VPS (0x0400) +/* Closed Caption, defined on EIA-608 */ +#define V4L2_SLICED_CAPTION_525 (0x1000) +/* Wide Screen System, defined on ITU-R BT1119.1 */ +#define V4L2_SLICED_WSS_625 (0x4000) + +#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) +#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) + + +struct v4l2_sliced_vbi_cap +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + enum v4l2_buf_type type; + __u32 reserved[3]; /* must be 0 */ +}; + +struct v4l2_sliced_vbi_data +{ + __u32 id; + __u32 field; /* 0: first field, 1: second field */ + __u32 line; /* 1-23 */ + __u32 reserved; /* must be 0 */ + __u8 data[48]; +}; +#endif + +/* + * A G G R E G A T E S T R U C T U R E S + */ + +/* Stream data format + */ +struct v4l2_format +{ + enum v4l2_buf_type type; + union + { + struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE + struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY + struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE +#if 1 + struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE +#endif + __u8 raw_data[200]; // user-defined + } fmt; +}; + + +/* Stream type-dependent parameters + */ +struct v4l2_streamparm +{ + enum v4l2_buf_type type; + union + { + struct v4l2_captureparm capture; + struct v4l2_outputparm output; + __u8 raw_data[200]; /* user-defined */ + } parm; +}; + +/* + * 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 + * + */ +#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) +#define VIDIOC_RESERVED _IO ('V', 1) +#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) +#define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) +#define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) +#ifdef __KERNEL__ +#define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) +#define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) +#endif +#define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) +#define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) +#define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) +#define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer) +#define VIDIOC_OVERLAY _IOW ('V', 14, int) +#define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer) +#define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer) +#define VIDIOC_STREAMON _IOW ('V', 18, int) +#define VIDIOC_STREAMOFF _IOW ('V', 19, int) +#define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm) +#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm) +#define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id) +#define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id) +#define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard) +#define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input) +#define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control) +#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control) +#define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner) +#define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner) +#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio) +#define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio) +#define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl) +#define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu) +#define VIDIOC_G_INPUT _IOR ('V', 38, int) +#define VIDIOC_S_INPUT _IOWR ('V', 39, int) +#define VIDIOC_G_OUTPUT _IOR ('V', 46, int) +#define VIDIOC_S_OUTPUT _IOWR ('V', 47, int) +#define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output) +#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout) +#define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout) +#define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator) +#define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator) +#define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency) +#define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency) +#define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap) +#define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop) +#define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop) +#define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression) +#define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression) +#define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id) +#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format) +#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio) +#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) +#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) +#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) +#if 1 +#define VIDIOC_G_SLICED_VBI_CAP _IOWR ('V', 69, struct v4l2_sliced_vbi_cap) +#endif +#define VIDIOC_LOG_STATUS _IO ('V', 70) +#define VIDIOC_G_EXT_CTRLS _IOWR ('V', 71, struct v4l2_ext_controls) +#define VIDIOC_S_EXT_CTRLS _IOWR ('V', 72, struct v4l2_ext_controls) +#define VIDIOC_TRY_EXT_CTRLS _IOWR ('V', 73, struct v4l2_ext_controls) +#if 1 +#define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) +#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) +#endif + +#ifdef __OLD_VIDIOC_ +/* for compatibility, will go away some day */ +#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) +#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) +#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control) +#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) +#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) +#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) +#endif + +#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ + +#endif /* __LINUX_VIDEODEV2_H */ + +/* + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/ddverify/models/con2/include/linux/vmalloc.h b/ddverify/models/con2/include/linux/vmalloc.h new file mode 100644 index 000000000..747bc9653 --- /dev/null +++ b/ddverify/models/con2/include/linux/vmalloc.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_VMALLOC_H +#define _LINUX_VMALLOC_H + +#include + +void *vmalloc(unsigned long size); +void vfree(void *addr); + +#endif /* _LINUX_VMALLOC_H */ diff --git a/ddverify/models/con2/include/linux/wait.h b/ddverify/models/con2/include/linux/wait.h new file mode 100644 index 000000000..91dc48dbf --- /dev/null +++ b/ddverify/models/con2/include/linux/wait.h @@ -0,0 +1,91 @@ +#ifndef _LINUX_WAIT_H +#define _LINUX_WAIT_H + +#include +#include +#include +#include +#include +#include + +struct __wait_queue { + int something; +}; +typedef struct __wait_queue wait_queue_t; + +struct __wait_queue_head { + int number_process_waiting; + int wakeup; + + int init; +}; +typedef struct __wait_queue_head wait_queue_head_t; + + +#define DECLARE_WAITQUEUE(name, tsk) wait_queue_t name +#define DECLARE_WAIT_QUEUE_HEAD(name) wait_queue_head_t name = { \ + .number_process_waiting = 0, \ + .wakeup = 0, \ + .init = 1} + + +#ifdef DDV_ASSERT_WAIT_QUEUE +#define assert_wait_queue(wq) __CPROVER_assert((wq)->init, "Wait queue is initialized!") +#else +#define assert_wait_queue(wq) do {} while(0) +#endif + +#define wait_event(wq, condition) \ +do { \ + if (condition) \ + break; \ + do { \ + wq.number_process_waiting++; \ + do { \ + } while(!wq.wakeup); \ + if (condition) \ + break; \ + do { \ + } while(wq.wakeup); \ + } while (1); \ +} while (0) + + +#define wait_event_interruptible(wq, condition) \ +({ \ + int __ret = 0; \ + __ret; \ +}) + + +#define DEFINE_WAIT(name) wait_queue_t name + +// DDV: Body is defined in linux/kernel/wait.c +void init_waitqueue_head(wait_queue_head_t *q); +// DDV: TODO +void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state); +// DDV: TODO +void finish_wait(wait_queue_head_t *q, wait_queue_t *wait); + +// DDV: Body is defined in linux/kernel/wait.c +void wake_up(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_all(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_interruptible(wait_queue_head_t *q); + +// DDV: TODO +void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); + +// DDV: TODO +int waitqueue_active(wait_queue_head_t *q); + +// DDV: Body is defined in linux/kernel/wait.c +void sleep_on(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void interruptible_sleep_on(wait_queue_head_t *q); +#endif diff --git a/ddverify/models/con2/include/linux/watchdog.h b/ddverify/models/con2/include/linux/watchdog.h new file mode 100644 index 000000000..afc7f8318 --- /dev/null +++ b/ddverify/models/con2/include/linux/watchdog.h @@ -0,0 +1,52 @@ +#ifndef _LINUX_WATCHDOG_H +#define _LINUX_WATCHDOG_H + +#include +#include + +#define WATCHDOG_IOCTL_BASE 'W' + +struct watchdog_info { + __u32 options; /* Options the card/driver supports */ + __u32 firmware_version; /* Firmware version of the card */ + __u8 identity[32]; /* Identity of the board */ +}; + +#define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info) +#define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int) +#define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int) +#define WDIOC_GETTEMP _IOR(WATCHDOG_IOCTL_BASE, 3, int) +#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int) +#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int) +#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) +#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) +#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int) +#define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int) +#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int) + +#define WDIOF_UNKNOWN -1 /* Unknown flag error */ +#define WDIOS_UNKNOWN -1 /* Unknown status error */ + +#define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */ +#define WDIOF_FANFAULT 0x0002 /* Fan failed */ +#define WDIOF_EXTERN1 0x0004 /* External relay 1 */ +#define WDIOF_EXTERN2 0x0008 /* External relay 2 */ +#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ +#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ +#define WDIOF_POWEROVER 0x0040 /* Power over voltage */ +#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ +#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ +#define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ +#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ + +#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ +#define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */ +#define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */ + +#ifdef CONFIG_WATCHDOG_NOWAYOUT +#define WATCHDOG_NOWAYOUT 1 +#else +#define WATCHDOG_NOWAYOUT 0 +#endif + +#endif /* ifndef _LINUX_WATCHDOG_H */ diff --git a/ddverify/models/con2/include/linux/workqueue.h b/ddverify/models/con2/include/linux/workqueue.h new file mode 100644 index 000000000..968ed7e62 --- /dev/null +++ b/ddverify/models/con2/include/linux/workqueue.h @@ -0,0 +1,50 @@ +/* + * workqueue.h --- work queue handling for Linux. + */ + +#ifndef _LINUX_WORKQUEUE_H +#define _LINUX_WORKQUEUE_H + +#include +//#include +#include + +struct work_struct { + unsigned long pending; + void (*func)(void *); + void *data; + + int init; +}; + +#define DECLARE_WORK(n, f, d) \ + struct work_struct n = { \ + .func = (f), \ + .data = (d), \ + .init = 1, \ + } + +/* + * initialize a work-struct's func and data pointers: + */ +#define PREPARE_WORK(_work, _func, _data) \ + do { \ + (_work)->func = _func; \ + (_work)->data = _data; \ + (_work)->init = 1; \ + } while (0) + +/* + * initialize all of a work-struct: + */ +#define INIT_WORK(_work, _func, _data) \ + do { \ + PREPARE_WORK((_work), (_func), (_data)); \ + } while (0) + +// DDV: Body for this function is defined in linux/kernel/workqueue.c +int schedule_work(struct work_struct *work); +// DDV: TODO +void flush_scheduled_work(void); + +#endif diff --git a/ddverify/models/con2/include/linux/writeback.h b/ddverify/models/con2/include/linux/writeback.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/con2/include/media/v4l2-common.h b/ddverify/models/con2/include/media/v4l2-common.h new file mode 100644 index 000000000..1863cce24 --- /dev/null +++ b/ddverify/models/con2/include/media/v4l2-common.h @@ -0,0 +1,6 @@ +#ifndef V4L2_COMMON_H_ +#define V4L2_COMMON_H_ + +#include + +#endif /* V4L2_COMMON_H_ */ diff --git a/ddverify/models/con2/include/media/v4l2-dev.h b/ddverify/models/con2/include/media/v4l2-dev.h new file mode 100644 index 000000000..94b52e78e --- /dev/null +++ b/ddverify/models/con2/include/media/v4l2-dev.h @@ -0,0 +1,255 @@ +#ifndef _V4L2_DEV_H +#define _V4L2_DEV_H + +#include +#include +#include +#include +#include +#include + + +#define VIDEO_MAJOR 81 +/* Minor device allocation */ +#define MINOR_VFL_TYPE_GRABBER_MIN 0 +#define MINOR_VFL_TYPE_GRABBER_MAX 63 +#define MINOR_VFL_TYPE_RADIO_MIN 64 +#define MINOR_VFL_TYPE_RADIO_MAX 127 +#define MINOR_VFL_TYPE_VTX_MIN 192 +#define MINOR_VFL_TYPE_VTX_MAX 223 +#define MINOR_VFL_TYPE_VBI_MIN 224 +#define MINOR_VFL_TYPE_VBI_MAX 255 + +#define VFL_TYPE_GRABBER 0 +#define VFL_TYPE_VBI 1 +#define VFL_TYPE_RADIO 2 +#define VFL_TYPE_VTX 3 + + + +struct video_device +{ + /* device ops */ + const struct file_operations *fops; + + /* device info */ + struct device *dev; + char name[32]; + int type; /* v4l1 */ + int type2; /* v4l2 */ + int hardware; + int minor; + + int debug; /* Activates debug level*/ + + /* Video standard vars */ + int tvnormsize; /* Size of tvnorm array */ + v4l2_std_id current_norm; /* Current tvnorm */ + struct v4l2_tvnorm *tvnorms; + + /* callbacks */ + void (*release)(struct video_device *vfd); + + /* ioctl callbacks */ + + /* VIDIOC_QUERYCAP handler */ + int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap); + + /* Priority handling */ + int (*vidioc_g_priority) (struct file *file, void *fh, + enum v4l2_priority *p); + int (*vidioc_s_priority) (struct file *file, void *fh, + enum v4l2_priority p); + + /* VIDIOC_ENUM_FMT handlers */ + int (*vidioc_enum_fmt_cap) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_overlay) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_capture) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_video_output)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + + /* VIDIOC_G_FMT handlers */ + int (*vidioc_g_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_S_FMT handlers */ + int (*vidioc_s_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + + int (*vidioc_s_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_TRY_FMT handlers */ + int (*vidioc_try_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* Buffer handlers */ + int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); + int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + + + int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); + + int (*vidioc_g_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + int (*vidioc_s_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + + /* Stream on/off */ + int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i); + int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i); + + /* Standard handling + G_STD and ENUMSTD are handled by videodev.c + */ + int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id a); + int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a); + + /* Input handling */ + int (*vidioc_enum_input)(struct file *file, void *fh, + struct v4l2_input *inp); + int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i); + + /* Output handling */ + int (*vidioc_enumoutput) (struct file *file, void *fh, + struct v4l2_output *a); + int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i); + + /* Control handling */ + int (*vidioc_queryctrl) (struct file *file, void *fh, + struct v4l2_queryctrl *a); + int (*vidioc_g_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_s_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_g_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_s_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_try_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_querymenu) (struct file *file, void *fh, + struct v4l2_querymenu *a); + + /* Audio ioctls */ + int (*vidioc_enumaudio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_g_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_s_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + + /* Audio out ioctls */ + int (*vidioc_enumaudout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_s_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + int (*vidioc_s_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + /* Crop ioctls */ + int (*vidioc_cropcap) (struct file *file, void *fh, + struct v4l2_cropcap *a); + int (*vidioc_g_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + int (*vidioc_s_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + /* Compression ioctls */ + int (*vidioc_g_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_s_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_g_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + int (*vidioc_s_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + + /* Stream type-dependent parameter ioctls */ + int (*vidioc_g_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + int (*vidioc_s_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + + /* Tuner ioctls */ + int (*vidioc_g_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_s_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_g_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + int (*vidioc_s_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + + /* Sliced VBI cap */ + int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh, + struct v4l2_sliced_vbi_cap *a); + + /* Log status ioctl */ + int (*vidioc_log_status) (struct file *file, void *fh); + + + struct module *owner; + + void *priv; + +}; + + + +extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, + unsigned long arg); + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +#endif /* _V4L2_DEV_H */ diff --git a/ddverify/models/con2/include/net/sock.h b/ddverify/models/con2/include/net/sock.h new file mode 100644 index 000000000..2eefd9c6c --- /dev/null +++ b/ddverify/models/con2/include/net/sock.h @@ -0,0 +1,29 @@ +#ifndef _SOCK_H +#define _SOCK_H + +#include +#include +#include +#include +//#include +#include +#include /* struct sk_buff */ +//#include + + +#define SHUTDOWN_MASK 3 +#define RCV_SHUTDOWN 1 +#define SEND_SHUTDOWN 2 + +#define SOCK_SNDBUF_LOCK 1 +#define SOCK_RCVBUF_LOCK 2 +#define SOCK_BINDADDR_LOCK 4 +#define SOCK_BINDPORT_LOCK 8 + +struct sock { + gfp_t sk_allocation; +}; + +struct socket *SOCKET_I(struct inode *inode); + +#endif /* _SOCK_H */ diff --git a/ddverify/models/con2/src/ddverify/cdev.c b/ddverify/models/con2/src/ddverify/cdev.c new file mode 100644 index 000000000..c608b16d5 --- /dev/null +++ b/ddverify/models/con2/src/ddverify/cdev.c @@ -0,0 +1,156 @@ +#include +#include +#include + +void call_cdev_functions() +{ + int cdev_no, function_no, result; + + loff_t loff_t_value; + int int_value; + unsigned int uint_value; + unsigned long ulong_value; + char char_value; + size_t size_t_value; + + if (number_cdev_registered == 0) { + return; + } + + cdev_no = nondet_ushort(); + __CPROVER_assume (0 <= cdev_no && cdev_no < number_cdev_registered); + + switch (nondet_ushort()) { + case 0: + if (cdev_registered[cdev_no].cdevp->ops->llseek) { + loff_t_value = nondet_loff_t(); + int_value = nondet_int(); + + (* cdev_registered[cdev_no].cdevp->ops->llseek)(&cdev_registered[cdev_no].filp, + loff_t_value, + int_value); + } + break; + case 1: + if (cdev_registered[cdev_no].cdevp->ops->read) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->read)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 2: + // aio_read - NOT SUPPORTED! + break; + case 3: + if (cdev_registered[cdev_no].cdevp->ops->write) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->write)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 4: + // aio_write - NOT SUPPORTED! + break; + case 5: + // readdir - NOT SUPPORTED! + break; + case 6: + // poll - NOT SUPPORTED! + break; + case 7: + if (cdev_registered[cdev_no].cdevp->ops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + + (* cdev_registered[cdev_no].cdevp->ops->ioctl)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp, + uint_value, + ulong_value); + } + + break; + case 8: + // unlocked_ioctl - NOT SUPPORTED! + break; + case 9: + // compat_ioctl - NOT SUPPORTED! + break; + case 10: + // mmap - NOT SUPPORTED! + break; + case 11: + if ((cdev_registered[cdev_no].cdevp->ops->open) && + (!cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->open)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 1; + } + } + break; + case 12: + // flush - NOT SUPPORTED! + break; + case 13: + if ((cdev_registered[cdev_no].cdevp->ops->release) && + (cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->release)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 0; + } + } + break; + case 14: + // fsync - NOT SUPPORTED! + break; + case 15: + // aio_fsync - NOT SUPPORTED! + break; + case 16: + // fasync - NOT SUPPORTED! + break; + case 17: + // lock - NOT SUPPORTED! + break; + case 18: + // readv - NOT SUPPORTED! + break; + case 19: + // writev - NOT SUPPORTED! + break; + case 20: + // sendfile - NOT SUPPORTED! + break; + case 21: + // sendpage - NOT SUPPORTED! + break; + case 22: + // get_unmapped_area - NOT SUPPORTED! + break; + case 23: + // check_flags - NOT SUPPORTED! + break; + case 24: + // dir_notify - NOT SUPPORTED! + break; + case 25: + // flock - NOT SUPPORTED! + break; + case 26: + // open_exec - NOT SUPPORTED! + break; + default: + break; + } +} diff --git a/ddverify/models/con2/src/ddverify/ddverify.c b/ddverify/models/con2/src/ddverify/ddverify.c new file mode 100644 index 000000000..2e086bebb --- /dev/null +++ b/ddverify/models/con2/src/ddverify/ddverify.c @@ -0,0 +1,116 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void init_kernel() +{ + int i; + + spin_lock_init(&kernel_lock); + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + shared_workqueue[i] = NULL; + } + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + tasklet_registered[i].tasklet = NULL; + tasklet_registered[i].is_running = 0; + } +} + +static void * ddv_2(void *arg) +{ + unsigned short random; + + do { + random = nondet_ushort(); + + switch (random) { + case 1: + switch_context(CONTEXT_INTERRUPT); + call_timer_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 2: + switch_context(CONTEXT_INTERRUPT); + call_interrupt_handler(); + switch_context(CONTEXT_PROCESS); + break; + + case 3: + switch_context(CONTEXT_PROCESS); + call_shared_workqueue_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 4: + switch_context(CONTEXT_INTERRUPT); + call_tasklet_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 5: + switch_context(CONTEXT_PROCESS); + call_pci_functions(); + switch_context(CONTEXT_PROCESS); + break; + + default: + break; + } + } while(random); +} + +void ddv() +{ + unsigned short random; + + pthread_t thread; + + pthread_create(&thread, NULL, ddv_2, NULL); + + do { + switch_context(CONTEXT_PROCESS); +#ifdef DRIVER_TYPE_CHAR + call_cdev_functions(); +#endif + +#ifdef DRIVER_TYPE_BLOCK + call_genhd_functions(); +#endif + } while (nondet_int()); +} + +int call_ddv() +{ + int err; + + switch_context(CONTEXT_PROCESS); + + init_kernel(); + + err = (* _ddv_module_init)(); + + if (err) { + return -1; + } + + + ddv(); + + switch_context(CONTEXT_PROCESS); + (* _ddv_module_exit)(); + + return 0; +} diff --git a/ddverify/models/con2/src/ddverify/genhd.c b/ddverify/models/con2/src/ddverify/genhd.c new file mode 100644 index 000000000..8938bbdd3 --- /dev/null +++ b/ddverify/models/con2/src/ddverify/genhd.c @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include + +create_request(int genhd_no) +{ + struct request rq; + + rq.cmd_type = REQ_TYPE_FS; + rq.rq_disk = genhd_registered[genhd_no].gd; + rq.sector = nondet_sector_t(); + rq.current_nr_sectors = nondet_uint(); + rq.buffer = nondet_pchar(); + + genhd_registered[genhd_no].current_request = rq; + genhd_registered[genhd_no].requests_open = 1; +} + +void call_rq_function(int genhd_no) +{ + if ((genhd_registered[genhd_no].gd->queue->request_fn != NULL) && + (genhd_registered[genhd_no].gd->queue->__ddv_queue_alive)) + { + spin_lock(genhd_registered[genhd_no].gd->queue->queue_lock); + + create_request(genhd_no); + genhd_registered[genhd_no].gd->queue->__ddv_genhd_no = genhd_no; + + (* genhd_registered[genhd_no].gd->queue->request_fn)(genhd_registered[genhd_no].gd->queue); + // do_cm206_request(genhd_registered[genhd_no].gd->queue); + + spin_unlock(genhd_registered[genhd_no].gd->queue->queue_lock); + + return; + } + + if (genhd_registered[genhd_no].gd->queue->make_request_fn) { + return; + } +} + +void call_genhd_functions() +{ + unsigned short genhd_no, function_no; + unsigned int uint_value; + unsigned long ulong_value; + int result; + + if (number_genhd_registered == 0) { + return; + } + + genhd_no = nondet_ushort(); + __CPROVER_assume (genhd_no < number_genhd_registered); + + + function_no = nondet_ushort(); + + switch (function_no) { + case 0: + call_rq_function(genhd_no); + break; + + case 1: + if (genhd_registered[genhd_no].gd->fops->open) { + genhd_registered[genhd_no].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[genhd_no].inode.i_bdev->bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->open)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 2: + if (genhd_registered[genhd_no].gd->fops->release) { + (* genhd_registered[genhd_no].gd->fops->release)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 3: + if (genhd_registered[genhd_no].gd->fops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + (* genhd_registered[genhd_no].gd->fops->ioctl)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file, + uint_value, + ulong_value); + } + break; + + case 4: + if (genhd_registered[genhd_no].gd->fops->media_changed) { + (* genhd_registered[genhd_no].gd->fops->media_changed)(genhd_registered[genhd_no].gd); + } + break; + + case 5: + if (genhd_registered[genhd_no].gd->fops->revalidate_disk) { + (* genhd_registered[genhd_no].gd->fops->revalidate_disk)(genhd_registered[genhd_no].gd); + } + break; + + case 6: + if (genhd_registered[genhd_no].gd->fops->getgeo) { + struct hd_geometry hdg; + struct block_device blk_dev; + + blk_dev.bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->getgeo)(&blk_dev, &hdg); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/con2/src/ddverify/interrupt.c b/ddverify/models/con2/src/ddverify/interrupt.c new file mode 100644 index 000000000..4a5ed1daf --- /dev/null +++ b/ddverify/models/con2/src/ddverify/interrupt.c @@ -0,0 +1,22 @@ +#include +#include + +#ifdef OLD_INTERRUPT_HANDLER +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id) +#else +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id, regs) +#endif + +void call_interrupt_handler() +{ + unsigned short i; + struct pt_regs regs; + + i = nondet_int(); + __CPROVER_assume(i < MAX_IRQ_SUPPORT); + + if (registered_irq[i].handler) { + __call_interrupt_handler((* registered_irq[i].handler), + (int)i, registered_irq[i].dev_id, ®s); + } +} diff --git a/ddverify/models/con2/src/ddverify/ioctl.c b/ddverify/models/con2/src/ddverify/ioctl.c new file mode 100644 index 000000000..2f95c45aa --- /dev/null +++ b/ddverify/models/con2/src/ddverify/ioctl.c @@ -0,0 +1,19 @@ +#include +#include + +/*void add_ioctl(unsigned int ioctl) +{ + if (number_ioctl_registered < MAX_IOCTL_SUPPORT) { + ioctl_registered[number_ioctl_registered] = ioctl; + number_ioctl_registered++; + } +} + +unsigned int get_ioctl_cmd() +{ + short cmd = nondet_short(); + __CPROVER_assume (cmd >= 0 && cmd < number_ioctl_registered); + + return ioctl_registered[cmd]; +} +*/ diff --git a/ddverify/models/con2/src/ddverify/pci.c b/ddverify/models/con2/src/ddverify/pci.c new file mode 100644 index 000000000..7f9df6bbb --- /dev/null +++ b/ddverify/models/con2/src/ddverify/pci.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include + +void create_pci_dev() +{ +} + +int pci_probe_device() +{ + int err; + unsigned int dev_id; + + registered_pci_driver.no_pci_device_id = 1; + + dev_id = nondet_uint(); + __CPROVER_assume(dev_id < registered_pci_driver.no_pci_device_id); + + err = (*registered_pci_driver.pci_driver->probe)(®istered_pci_driver.pci_dev, + ®istered_pci_driver.pci_driver->id_table[dev_id]); + + if (!err) { + registered_pci_driver.dev_initialized = 1; + } + + return err; +} + +void pci_remove_device() +{ + (*registered_pci_driver.pci_driver->remove)(®istered_pci_driver.pci_dev); + + registered_pci_driver.dev_initialized = 0; +} + +void call_pci_functions() +{ + switch (nondet_uint()) { + case 0: + if (!registered_pci_driver.dev_initialized) { + pci_probe_device(); + } + break; + + case 1: + if (registered_pci_driver.dev_initialized) { + pci_remove_device(); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/con2/src/ddverify/tasklet.c b/ddverify/models/con2/src/ddverify/tasklet.c new file mode 100644 index 000000000..776673eb8 --- /dev/null +++ b/ddverify/models/con2/src/ddverify/tasklet.c @@ -0,0 +1,15 @@ +#include + +void call_tasklet_functions() +{ + unsigned int i; + __CPROVER_assume(i < MAX_TASKLET_SUPPORT); + + if ((tasklet_registered[i].tasklet != NULL) && + (tasklet_registered[i].tasklet->count == 0)) { + tasklet_registered[i].is_running = 1; + (* tasklet_registered[i].tasklet->func)(tasklet_registered[i].tasklet->data); + tasklet_registered[i].is_running = 0; + tasklet_registered[i].tasklet = NULL; + } +} diff --git a/ddverify/models/con2/src/ddverify/timer.c b/ddverify/models/con2/src/ddverify/timer.c new file mode 100644 index 000000000..45c22052a --- /dev/null +++ b/ddverify/models/con2/src/ddverify/timer.c @@ -0,0 +1,13 @@ +#include +#include + +void call_timer_functions() +{ + unsigned short i = nondet_ushort(); + + __CPROVER_assume(i < number_timer_registered); + + if (timer_registered[i].timer->__ddv_active) { + (* timer_registered[i].timer->function)(timer_registered[i].timer->data); + } +} diff --git a/ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c b/ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c new file mode 100644 index 000000000..06fc72517 --- /dev/null +++ b/ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c @@ -0,0 +1,51 @@ +#include +#include +#include + +int __get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int __put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} + +unsigned long copy_from_user(void *to, void __user *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} diff --git a/ddverify/models/con2/src/linux/block/elevator.c b/ddverify/models/con2/src/linux/block/elevator.c new file mode 100644 index 000000000..8511b9dd9 --- /dev/null +++ b/ddverify/models/con2/src/linux/block/elevator.c @@ -0,0 +1,13 @@ +#include +#include + +struct request *elv_next_request(request_queue_t *q) +{ + int genhd_no = q->__ddv_genhd_no; + + if (genhd_registered[genhd_no].requests_open > 0) { + return genhd_registered[genhd_no].current_request; + } else { + return NULL; + } +} diff --git a/ddverify/models/con2/src/linux/block/genhd.c b/ddverify/models/con2/src/linux/block/genhd.c new file mode 100644 index 000000000..2cbcc717d --- /dev/null +++ b/ddverify/models/con2/src/linux/block/genhd.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +int register_blkdev(unsigned int major, const char *name) +{ + int result = nondet_int(); + + /*if ((major > 0) && (result > 0)) { + return major; + }*/ + + return result; +} + +int unregister_blkdev(unsigned int major, const char *name) +{ + return 0; +} + +struct gendisk *alloc_disk(int minors) +{ + struct gendisk * gd; + + if (number_fixed_genhd_used < MAX_GENHD_SUPPORT) { + gd = &fixed_gendisk[number_fixed_genhd_used]; + gd->minors = minors; + + number_fixed_genhd_used++; + + return gd; + } else { + return NULL; + } +} + +void add_disk(struct gendisk *disk) +{ + if (number_genhd_registered < MAX_GENHD_SUPPORT) { + genhd_registered[number_genhd_registered].gd = disk; + genhd_registered[number_genhd_registered].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[number_genhd_registered].inode.i_bdev->bd_disk = disk; + + number_genhd_registered++; + } +} + +void del_gendisk(struct gendisk *gp) +{ + int i; + + for (i = 0; i < number_genhd_registered; i++) { + if (genhd_registered[i].gd == gp) { + genhd_registered[i].gd = NULL; + } + } +} diff --git a/ddverify/models/con2/src/linux/block/ll_rw_blk.c b/ddverify/models/con2/src/linux/block/ll_rw_blk.c new file mode 100644 index 000000000..eb27f72a2 --- /dev/null +++ b/ddverify/models/con2/src/linux/block/ll_rw_blk.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include + +request_queue_t *get_fixed_request_queue() +{ + if (number_request_queue_used < MAX_REQUEST_QUEUE_SUPPORT) { + return &fixed_request_queue[number_request_queue_used++]; + } else { + return NULL; + } +} + +request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->queue_lock = lock; + queue->request_fn = rfn; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +request_queue_t *blk_alloc_queue(gfp_t gfp_mask) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->request_fn = NULL; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn) +{ + q->make_request_fn = mfn; +} + +void end_request(struct request *req, int uptodate) +{ + int genhd_no = req->rq_disk->queue->__ddv_genhd_no; + + genhd_registered[genhd_no].requests_open = 0; +} + + +void blk_queue_hardsect_size(request_queue_t *q, unsigned short size) +{ + q->hardsect_size = size; +} + +void blk_cleanup_queue(request_queue_t *q) +{ + q->__ddv_queue_alive = 0; +} diff --git a/ddverify/models/con2/src/linux/drivers/char/misc.c b/ddverify/models/con2/src/linux/drivers/char/misc.c new file mode 100644 index 000000000..1bcc5a5ac --- /dev/null +++ b/ddverify/models/con2/src/linux/drivers/char/misc.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +//#include +//#include +#include + +#include + +int misc_register(struct miscdevice * misc) +{ + int i; + dev_t dev; + + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + i = fixed_cdev_used; + fixed_cdev_used++; + + fixed_cdev[i].owner = THIS_MODULE; + fixed_cdev[i].ops = misc->fops; + + dev = MKDEV(MISC_MAJOR, misc->minor); + + return cdev_add(&fixed_cdev[i], dev, 0); + } else { + return -1; + } +} diff --git a/ddverify/models/con2/src/linux/drivers/char/tty_io.c b/ddverify/models/con2/src/linux/drivers/char/tty_io.c new file mode 100644 index 000000000..30fe841cc --- /dev/null +++ b/ddverify/models/con2/src/linux/drivers/char/tty_io.c @@ -0,0 +1,40 @@ +#include +#include + +struct tty_driver *alloc_tty_driver(int lines) +{ + if (!global_tty_driver.allocated) { + global_tty_driver.driver.magic = TTY_DRIVER_MAGIC; + global_tty_driver.driver.num = lines; + } else { + return NULL; + } +} + +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op) +{ + driver->open = op->open; + driver->close = op->close; + driver->write = op->write; + driver->put_char = op->put_char; + driver->flush_chars = op->flush_chars; + driver->write_room = op->write_room; + driver->chars_in_buffer = op->chars_in_buffer; + driver->ioctl = op->ioctl; + driver->set_termios = op->set_termios; + driver->throttle = op->throttle; + driver->unthrottle = op->unthrottle; + driver->stop = op->stop; + driver->start = op->start; + driver->hangup = op->hangup; + driver->break_ctl = op->break_ctl; + driver->flush_buffer = op->flush_buffer; + driver->set_ldisc = op->set_ldisc; + driver->wait_until_sent = op->wait_until_sent; + driver->send_xchar = op->send_xchar; + driver->read_proc = op->read_proc; + driver->write_proc = op->write_proc; + driver->tiocmget = op->tiocmget; + driver->tiocmset = op->tiocmset; +} diff --git a/ddverify/models/con2/src/linux/fs/char_dev.c b/ddverify/models/con2/src/linux/fs/char_dev.c new file mode 100644 index 000000000..8a0a278bf --- /dev/null +++ b/ddverify/models/con2/src/linux/fs/char_dev.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +#include +#include + +int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) +{ + int major; + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + major = nondet_uint(); + *dev = MKDEV(major, baseminor); + } + + return return_value; +} + +int register_chrdev_region(dev_t from, unsigned count, const char *name) +{ + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + return return_value; +} + +//void unregister_chrdev_region(dev_t, unsigned) {} + + +int register_chrdev(unsigned int major, const char *name, + struct file_operations *fops) +{ + struct cdev *cdev; + int err; + + major = register_chrdev_region(0, 256, name); + + cdev = cdev_alloc(); + cdev->owner = fops->owner; + cdev->ops = fops; + + err = cdev_add(cdev, MKDEV(major, 0), 256); + + if (err) { + kfree(cdev); + return err; + } + + return major; +} + + +int unregister_chrdev(unsigned int major, const char *name) +{ + return 0; +} + +struct cdev *cdev_alloc(void) +{ + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + return &fixed_cdev[fixed_cdev_used++]; + } +} + +void cdev_init(struct cdev *cdev, struct file_operations *fops) +{ + cdev->ops = fops; +} + +int cdev_add(struct cdev *p, dev_t dev, unsigned count) +{ + p->dev = dev; + p->count = count; + + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + if (number_cdev_registered < MAX_CDEV_SUPPORT) { + + cdev_registered[number_cdev_registered].cdevp = p; + cdev_registered[number_cdev_registered].inode.i_rdev = dev; + cdev_registered[number_cdev_registered].inode.i_cdev = p; + cdev_registered[number_cdev_registered].open = 0; + + number_cdev_registered++; + } else { + return -1; + } + } + + return return_value; +} + +void cdev_del(struct cdev *p) +{ + int i; + + for (i = 0; i < number_cdev_registered; i++) { + if (cdev_registered[i].cdevp == p) { + cdev_registered[i].cdevp = 0; + + return; + } + } +} diff --git a/ddverify/models/con2/src/linux/fs/proc/generic.c b/ddverify/models/con2/src/linux/fs/proc/generic.c new file mode 100644 index 000000000..d2d29e78b --- /dev/null +++ b/ddverify/models/con2/src/linux/fs/proc/generic.c @@ -0,0 +1,7 @@ +#include + +// struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, +// struct proc_dir_entry *parent) + + +// void remove_proc_entry(const char *name, struct proc_dir_entry *parent) diff --git a/ddverify/models/con2/src/linux/kernel/irq/manage.c b/ddverify/models/con2/src/linux/kernel/irq/manage.c new file mode 100644 index 000000000..54df106a0 --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/irq/manage.c @@ -0,0 +1,21 @@ +#include +#include + +int request_irq(unsigned int irq, irq_handler_t handler, + unsigned long irqflags, const char * devname, void *dev_id) +{ + if (nondet_int()) { + registered_irq[irq].handler = handler; + registered_irq[irq].dev_id = dev_id; + + return 0; + } else { + return -1; + } +} + +void free_irq(unsigned int irq, void *dev_id) +{ + registered_irq[irq].handler = NULL; + registered_irq[irq].dev_id = NULL; +} diff --git a/ddverify/models/con2/src/linux/kernel/mutex.c b/ddverify/models/con2/src/linux/kernel/mutex.c new file mode 100644 index 000000000..d6f77a7df --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/mutex.c @@ -0,0 +1,52 @@ +#include +#include + +void mutex_init(struct mutex *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(!lock->locked, "Locked mutex must not be reinitialized"); +#endif + lock->locked = 0; + lock->init = 1; + __CPROVER_atomic_end(); +} + + +void mutex_lock(struct mutex *lock) +{ + __CPROVER_HIDE: + +#ifdef DDV_ASSERT_MUTEX + __CPROVER_atomic_begin(); + assert_context_process(); + __CPROVER_assert(lock->init, "Mutex is not initialized"); + __CPROVER_atomic_end(); +#endif + + do + { + __CPROVER_atomic_begin(); + if(lock->locked == 0) + { + lock->locked = 1; + __CPROVER_atomic_end(); + return; + } + __CPROVER_atomic_end(); + } + while(1); +} + +void mutex_unlock(struct mutex *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(lock->locked, "Unlock a not locked mutex"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} diff --git a/ddverify/models/con2/src/linux/kernel/resource.c b/ddverify/models/con2/src/linux/kernel/resource.c new file mode 100644 index 000000000..c187db976 --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/resource.c @@ -0,0 +1,115 @@ +#include +#include +#include +#include + +struct resource *request_region(unsigned long start, unsigned long len, const char *name) +{ + unsigned int i; + struct resource *resource = (struct resource*)malloc(sizeof(struct resource)); + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 1; + // } + ddv_ioport_request_start = start; + ddv_ioport_request_len = len; + + return resource; +} + +void release_region(unsigned long start, unsigned long len) +{ + unsigned int i = 0; + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 0; + // } + + ddv_ioport_request_start = 0; + ddv_ioport_request_len = 0; +} + +unsigned char inb(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +void outb(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned short inw(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +void outw(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned inl(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +void outl(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + + +unsigned char inb_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +void outb_p(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned short inw_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +void outw_p(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned inl_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +void outl_p(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} diff --git a/ddverify/models/con2/src/linux/kernel/sched.c b/ddverify/models/con2/src/linux/kernel/sched.c new file mode 100644 index 000000000..9a23084b2 --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/sched.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include +#include + +void schedule() +{ + assert_context_process(); +} + +long schedule_timeout(long timeout) +{ + assert_context_process(); + + return nondet_long(); +} diff --git a/ddverify/models/con2/src/linux/kernel/semaphore.c b/ddverify/models/con2/src/linux/kernel/semaphore.c new file mode 100644 index 000000000..64b939542 --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/semaphore.c @@ -0,0 +1,116 @@ +#include +#include +#include + +// DDV: The count value is ignored because ddverify only supports binary semaphores! +void sema_init(struct semaphore *sem, int val) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + sem->init = 1; + sem->locked = 0; + __CPROVER_atomic_end(); +} + +void init_MUTEX(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + sem->init = 1; + sem->locked = 0; + __CPROVER_atomic_end(); +} + +void init_MUTEX_LOCKED(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + sem->init = 1; + sem->locked = 1; + __CPROVER_atomic_end(); +} + +void down(struct semaphore * sem) +{ +__CPROVER_HIDE: + +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_atomic_begin(); + assert_context_process(); + __CPROVER_assert(lock->init, "Semaphore is not initialized"); + __CPROVER_atomic_end(); +#endif + + do + { + __CPROVER_atomic_begin(); + if(sem->locked == 0) + { + sem->locked = 1; + __CPROVER_atomic_end(); + return; + } + __CPROVER_atomic_end(); + } + while(1); +} + +int down_interruptible(struct semaphore * sem) +{ +__CPROVER_HIDE: + +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_atomic_begin(); + assert_context_process(); + __CPROVER_assert(sem->init, "Semaphore is not initialized"); + __CPROVER_atomic_end(); +#endif + + do + { + __CPROVER_atomic_begin(); + if(sem->locked == 0) + { + sem->locked = 1; + __CPROVER_atomic_end(); + return 0; + } + if(nondet_int()){ + __CPROVER_atomic_end(); + return -1; + } + + __CPROVER_atomic_end(); + } + while(1); +} + +int down_trylock(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is not initialized"); +#endif + + if (sem->locked == 0) { + sem->locked = 1; + __CPROVER_atomic_end(); + return -1; + } + __CPROVER_atomic_end(); + return 0; +} + +void up(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->locked, "Unlock a not locked semaphore"); +#endif + sem->locked = 0; + __CPROVER_atomic_end(); +} diff --git a/ddverify/models/con2/src/linux/kernel/softirq.c b/ddverify/models/con2/src/linux/kernel/softirq.c new file mode 100644 index 000000000..bd7bd6f8a --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/softirq.c @@ -0,0 +1,39 @@ +#include +#include + +void tasklet_schedule(struct tasklet_struct *t) +{ + int i; + int next_free = -1; + +#ifdef DDV_ASSERT_TASKLET + __CPROVER_assert(t->init, "Tasklet is uninitialized!"); +#endif + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + if (tasklet_registered[i].tasklet == NULL) { + next_free = i; + } + if ((tasklet_registered[i].tasklet == t) && + (tasklet_registered[i].is_running == 0)) { + return; + } + } + + +#ifdef DDV_ASSERT_TASKLET + __CPROVER_assert(next_free != -1, "Number of supported tasklets is insufficient"); +#endif + + tasklet_registered[next_free].tasklet = t; + tasklet_registered[next_free].is_running = 0; +} + +void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data) +{ + t->count = 0; + t->init = 0; + t->func = func; + t->data = data; +} diff --git a/ddverify/models/con2/src/linux/kernel/spinlock.c b/ddverify/models/con2/src/linux/kernel/spinlock.c new file mode 100644 index 000000000..6024267bf --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/spinlock.c @@ -0,0 +1,150 @@ +#include +#include + +void spin_lock_init(spinlock_t * lock) +{ + lock->init = 1; + lock->locked = 0; +} + +void spin_lock(spinlock_t * lock) +{ + __CPROVER_HIDE: + +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_atomic_begin(); + __CPROVER_assert(lock->init, "Spinlock is not initialized"); + __CPROVER_atomic_end(); +#endif + + do + { + __CPROVER_atomic_begin(); + if(lock->locked == 0) + { + lock->locked = 1; + __CPROVER_atomic_end(); + return; + } + __CPROVER_atomic_end(); + } + while(1); +} + +void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: + +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_atomic_begin(); + __CPROVER_assert(lock->init, "Spinlock is not initialized"); + __CPROVER_atomic_end(); +#endif + + do + { + __CPROVER_atomic_begin(); + if(lock->locked == 0) + { + lock->locked = 1; + __CPROVER_atomic_end(); + return; + } + __CPROVER_atomic_end(); + } + while(1); +} + +void spin_lock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: + +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_atomic_begin(); + __CPROVER_assert(lock->init, "Spinlock is not initialized"); + __CPROVER_atomic_end(); +#endif + + do + { + __CPROVER_atomic_begin(); + if(lock->locked == 0) + { + lock->locked = 1; + __CPROVER_atomic_end(); + return; + } + __CPROVER_atomic_end(); + } + while(1); +} + +void spin_lock_bh(spinlock_t *lock) +{ + __CPROVER_HIDE: + +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_atomic_begin(); + __CPROVER_assert(lock->init, "Spinlock is not initialized"); + __CPROVER_atomic_end(); +#endif + + do + { + __CPROVER_atomic_begin(); + if(lock->locked == 0) + { + lock->locked = 1; + __CPROVER_atomic_end(); + return; + } + __CPROVER_atomic_end(); + } + while(1); +} + +void spin_unlock(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked == 1, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} + + +void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked == 1, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} + +void spin_unlock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked == 1, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} + +void spin_unlock_bh(spinlock_t *lock) +{ +__CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked == 1, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); + +} diff --git a/ddverify/models/con2/src/linux/kernel/timer.c b/ddverify/models/con2/src/linux/kernel/timer.c new file mode 100644 index 000000000..2018c2931 --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/timer.c @@ -0,0 +1,47 @@ +#include +#include + +void init_timer(struct timer_list * timer) +{ + if (number_timer_registered < MAX_TIMER_SUPPORT) { + timer->__ddv_active = 0; + timer->__ddv_init = 1; + timer_registered[number_timer_registered].timer = timer; + + number_timer_registered++; + } +} + + +void add_timer(struct timer_list *timer) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->__ddv_active = 1; +} + + +void add_timer_on(struct timer_list *timer, int cpu) +{ + // We do not care about the cpu number! + add_timer(timer); +} + + +int del_timer(struct timer_list * timer) +{ + timer->__ddv_active = 0; +} + + +int mod_timer(struct timer_list *timer, unsigned long expires) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->expires = expires; + timer->__ddv_active = 1; +} diff --git a/ddverify/models/con2/src/linux/kernel/wait.c b/ddverify/models/con2/src/linux/kernel/wait.c new file mode 100644 index 000000000..04822ab0b --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/wait.c @@ -0,0 +1,46 @@ +#include + +void init_waitqueue_head(wait_queue_head_t *q) +{ + q->init = 1; +} + +void wake_up(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void wake_up_all(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void wake_up_interruptible(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void interruptible_sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} diff --git a/ddverify/models/con2/src/linux/kernel/workqueue.c b/ddverify/models/con2/src/linux/kernel/workqueue.c new file mode 100644 index 000000000..26d035768 --- /dev/null +++ b/ddverify/models/con2/src/linux/kernel/workqueue.c @@ -0,0 +1,39 @@ +#include +#include +#include + +int schedule_work(struct work_struct *work) +{ + int i; + +#ifdef DDV_ASSERT_WORK_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(work->init, "Work queue is initalized"); +#endif + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + if (shared_workqueue[i] == work) { + return 0; + } + + if (shared_workqueue[i] == NULL) { + shared_workqueue[i] = work; + + return 1; + } + } + + + return -1; +} + +void call_shared_workqueue_functions() +{ + unsigned short i = nondet_ushort(); + __CPROVER_assume(i < MAX_WORKQUEUE_ELEMENTS_SUPPORT); + + if (shared_workqueue[i] != NULL) { + (*shared_workqueue[i]->func)(shared_workqueue[i]->data); + shared_workqueue[i] = NULL; + } +} diff --git a/ddverify/models/con2/src/linux/mm/page_alloc.c b/ddverify/models/con2/src/linux/mm/page_alloc.c new file mode 100644 index 000000000..40d236be0 --- /dev/null +++ b/ddverify/models/con2/src/linux/mm/page_alloc.c @@ -0,0 +1,52 @@ +#include +#include +#include + +unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +unsigned long __get_free_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +unsigned long get_zeroed_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, + unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +struct page * alloc_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} diff --git a/ddverify/models/con2/src/linux/mm/slab.c b/ddverify/models/con2/src/linux/mm/slab.c new file mode 100644 index 000000000..7b21afa25 --- /dev/null +++ b/ddverify/models/con2/src/linux/mm/slab.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +void * kmalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} + +void * kzalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} diff --git a/ddverify/models/con2/src/linux/mm/vmalloc.c b/ddverify/models/con2/src/linux/mm/vmalloc.c new file mode 100644 index 000000000..0edd579f7 --- /dev/null +++ b/ddverify/models/con2/src/linux/mm/vmalloc.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +void * vmalloc(unsigned long size) +{ + return malloc(size); +} diff --git a/ddverify/models/con2/src/linux/pci.c b/ddverify/models/con2/src/linux/pci.c new file mode 100644 index 000000000..26d58cee1 --- /dev/null +++ b/ddverify/models/con2/src/linux/pci.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include +#include + +int pci_enable_device(struct pci_dev *dev) +{ + int i; + + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + dev->resource[i].flags = IORESOURCE_IO; + dev->resource[i].start = nondet_uint(); + dev->resource[i].end = dev->resource[i].start + nondet_ushort(); + } +} + +struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) +{ + if (from == NULL) { + from = (struct pci_dev*)malloc(sizeof(struct pci_dev)); + } + + if (nondet_int()) { + from->vendor = nondet_ushort(); + from->device = nondet_ushort(); + from->irq = nondet_uint(); + __CPROVER_assume(from->irq < MAX_IRQ_SUPPORT); + + return from; + } else { + return NULL; + } +} + +int pci_register_driver(struct pci_driver *driver) +{ + if (nondet_int()) { + registered_pci_driver.pci_driver = driver; + registered_pci_driver.no_pci_device_id = sizeof(driver->id_table) / sizeof(struct pci_device_id); + registered_pci_driver.dev_initialized = 0; + + return 0; + } else { + return -1; + } +} + +void pci_unregister_driver(struct pci_driver *driver) +{ + registered_pci_driver.pci_driver = NULL; + registered_pci_driver.no_pci_device_id = 0; +} + +void pci_release_region(struct pci_dev *pdev, int bar) +{ + if (pci_resource_len(pdev, bar) == 0) + return; + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) + release_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) + release_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); +} + +int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) +{ + if (pci_resource_len(pdev, bar) == 0) + return 0; + + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) { + if (!request_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { + if (!request_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + + return 0; +} + + +void pci_release_regions(struct pci_dev *pdev) +{ + int i; + + for (i = 0; i < 6; i++) + pci_release_region(pdev, i); +} + + +int pci_request_regions(struct pci_dev *pdev, const char *res_name) +{ + int i; + + for (i = 0; i < 6; i++) + if(pci_request_region(pdev, i, res_name)) + goto err_out; + return 0; + + err_out: + while(--i >= 0) + pci_release_region(pdev, i); + + return -EBUSY; +} diff --git a/ddverify/models/seq1/include/asm-generic/bug.h b/ddverify/models/seq1/include/asm-generic/bug.h new file mode 100644 index 000000000..18a3c237d --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/bug.h @@ -0,0 +1,9 @@ +#ifndef _ASM_GENERIC_BUG_H +#define _ASM_GENERIC_BUG_H + +#include +#include + +#define BUG_ON(condition) __CPROVER_assume(condition) + +#endif diff --git a/ddverify/models/seq1/include/asm-generic/errno-base.h b/ddverify/models/seq1/include/asm-generic/errno-base.h new file mode 100644 index 000000000..651159785 --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/errno-base.h @@ -0,0 +1,39 @@ +#ifndef _ASM_GENERIC_ERRNO_BASE_H +#define _ASM_GENERIC_ERRNO_BASE_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#endif diff --git a/ddverify/models/seq1/include/asm-generic/errno.h b/ddverify/models/seq1/include/asm-generic/errno.h new file mode 100644 index 000000000..e8852c092 --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/errno.h @@ -0,0 +1,109 @@ +#ifndef _ASM_GENERIC_ERRNO_H +#define _ASM_GENERIC_ERRNO_H + +#include + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* for robust mutexes */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ + +#endif diff --git a/ddverify/models/seq1/include/asm-generic/fcntl.h b/ddverify/models/seq1/include/asm-generic/fcntl.h new file mode 100644 index 000000000..897b3f5a5 --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/fcntl.h @@ -0,0 +1,110 @@ +#ifndef _ASM_GENERIC_FCNTL_H +#define _ASM_GENERIC_FCNTL_H + +#include +#include + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 00000003 +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 +#ifndef O_CREAT +#define O_CREAT 00000100 /* not fcntl */ +#endif +#ifndef O_EXCL +#define O_EXCL 00000200 /* not fcntl */ +#endif +#ifndef O_NOCTTY +#define O_NOCTTY 00000400 /* not fcntl */ +#endif +#ifndef O_TRUNC +#define O_TRUNC 00001000 /* not fcntl */ +#endif +#ifndef O_APPEND +#define O_APPEND 00002000 +#endif +#ifndef O_NONBLOCK +#define O_NONBLOCK 00004000 +#endif +#ifndef O_SYNC +#define O_SYNC 00010000 +#endif +#ifndef FASYNC +#define FASYNC 00020000 /* fcntl, for BSD compatibility */ +#endif +#ifndef O_DIRECT +#define O_DIRECT 00040000 /* direct disk access hint */ +#endif +#ifndef O_LARGEFILE +#define O_LARGEFILE 00100000 +#endif +#ifndef O_DIRECTORY +#define O_DIRECTORY 00200000 /* must be a directory */ +#endif +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 00400000 /* don't follow links */ +#endif +#ifndef O_NOATIME +#define O_NOATIME 01000000 +#endif +#ifndef O_NDELAY +#define O_NDELAY O_NONBLOCK +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get close_on_exec */ +#define F_SETFD 2 /* set/clear close_on_exec */ +#define F_GETFL 3 /* get file->f_flags */ +#define F_SETFL 4 /* set file->f_flags */ +#ifndef F_GETLK +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#endif +#ifndef F_SETOWN +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ +#endif +#ifndef F_SETSIG +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ +#endif + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#ifndef F_RDLCK +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 +#endif + +/* for old implementation of bsd flock () */ +#ifndef F_EXLCK +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ +#endif + +/* for leases */ +#ifndef F_INPROGRESS +#define F_INPROGRESS 16 +#endif + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#define LOCK_MAND 32 /* This is a mandatory flock ... */ +#define LOCK_READ 64 /* which allows concurrent read operations */ +#define LOCK_WRITE 128 /* which allows concurrent write operations */ +#define LOCK_RW 192 /* which allows concurrent read & write ops */ + +#define F_LINUX_SPECIFIC_BASE 1024 + +#endif /* _ASM_GENERIC_FCNTL_H */ diff --git a/ddverify/models/seq1/include/asm-generic/ioctl.h b/ddverify/models/seq1/include/asm-generic/ioctl.h new file mode 100644 index 000000000..cd027298b --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/ioctl.h @@ -0,0 +1,80 @@ +#ifndef _ASM_GENERIC_IOCTL_H +#define _ASM_GENERIC_IOCTL_H + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The generic ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __invalid_size_argument_for_IOC; +#define _IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ + sizeof(t) : __invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#endif /* _ASM_GENERIC_IOCTL_H */ diff --git a/ddverify/models/seq1/include/asm-generic/pci-dma-compat.h b/ddverify/models/seq1/include/asm-generic/pci-dma-compat.h new file mode 100644 index 000000000..4bb451317 --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/pci-dma-compat.h @@ -0,0 +1,20 @@ +/* include this file if the platform implements the dma_ DMA Mapping API + * and wants to provide the pci_ DMA Mapping API in terms of it */ + +#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H +#define _ASM_GENERIC_PCI_DMA_COMPAT_H + +void * pci_alloc_consistent(struct pci_dev *hwdev, size_t size, + dma_addr_t *dma_handle); + +void pci_free_consistent(struct pci_dev *hwdev, size_t size, + void *vaddr, dma_addr_t dma_handle); + +dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction); +void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction); + +dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page, + unsigned long offset, size_t size, int direction); +void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, + size_t size, int direction); +#endif diff --git a/ddverify/models/seq1/include/asm-generic/rtc.h b/ddverify/models/seq1/include/asm-generic/rtc.h new file mode 100644 index 000000000..a8a13c916 --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/rtc.h @@ -0,0 +1,18 @@ +#ifndef __ASM_GENERIC_RTC_H__ +#define __ASM_GENERIC_RTC_H__ + +#include +#include + +#define RTC_PIE 0x40 /* periodic interrupt enable */ +#define RTC_AIE 0x20 /* alarm interrupt enable */ +#define RTC_UIE 0x10 /* update-finished interrupt enable */ + +/* some dummy definitions */ +#define RTC_BATT_BAD 0x100 /* battery bad */ +#define RTC_SQWE 0x08 /* enable square-wave output */ +#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +#endif diff --git a/ddverify/models/seq1/include/asm-generic/siginfo.h b/ddverify/models/seq1/include/asm-generic/siginfo.h new file mode 100644 index 000000000..383411b5c --- /dev/null +++ b/ddverify/models/seq1/include/asm-generic/siginfo.h @@ -0,0 +1,118 @@ +#ifndef _ASM_GENERIC_SIGINFO_H +#define _ASM_GENERIC_SIGINFO_H + +#include +#include + +/* + * This is the size (including padding) of the part of the + * struct siginfo that is before the union. + */ +#ifndef __ARCH_SI_PREAMBLE_SIZE +#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) +#endif + +#define SI_MAX_SIZE 128 +#ifndef SI_PAD_SIZE +#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) +#endif + +#ifndef __ARCH_SI_UID_T +#define __ARCH_SI_UID_T uid_t +#endif + +/* + * The default "si_band" type is "long", as specified by POSIX. + * However, some architectures want to override this to "int" + * for historical compatibility reasons, so we allow that. + */ +#ifndef __ARCH_SI_BAND_T +#define __ARCH_SI_BAND_T long +#endif + + +#define __SI_MASK 0xffff0000u +#define __SI_KILL (0 << 16) +#define __SI_TIMER (1 << 16) +#define __SI_POLL (2 << 16) +#define __SI_FAULT (3 << 16) +#define __SI_CHLD (4 << 16) +#define __SI_RT (5 << 16) +#define __SI_MESGQ (6 << 16) + + +/* + * SIGILL si_codes + */ +#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ +#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ +#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ +#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ +#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ +#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ +#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ +#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ +#define NSIGILL 8 + +/* + * SIGFPE si_codes + */ +#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ +#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ +#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ +#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ +#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ +#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ +#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ +#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ +#define NSIGFPE 8 + +/* + * SIGSEGV si_codes + */ +#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ +#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ +#define NSIGSEGV 2 + +/* + * SIGBUS si_codes + */ +#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ +#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ +#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ +#define NSIGBUS 3 + +/* + * SIGTRAP si_codes + */ +#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ +#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ +#define NSIGTRAP 2 + +/* + * SIGCHLD si_codes + */ +#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ +#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ +#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ +#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ +#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ +#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ +#define NSIGCHLD 6 + +/* + * SIGPOLL si_codes + */ +#define POLL_IN (__SI_POLL|1) /* data input available */ +#define POLL_OUT (__SI_POLL|2) /* output buffers available */ +#define POLL_MSG (__SI_POLL|3) /* input message available */ +#define POLL_ERR (__SI_POLL|4) /* i/o error */ +#define POLL_PRI (__SI_POLL|5) /* high priority input available */ +#define POLL_HUP (__SI_POLL|6) /* device disconnected */ +#define NSIGPOLL 6 + +typedef struct siginfo { + int something; +} siginfo_t; + +#endif diff --git a/ddverify/models/seq1/include/asm/atomic.h b/ddverify/models/seq1/include/asm/atomic.h new file mode 100644 index 000000000..226e1b397 --- /dev/null +++ b/ddverify/models/seq1/include/asm/atomic.h @@ -0,0 +1,169 @@ +#ifndef __ARCH_I386_ATOMIC__ +#define __ARCH_I386_ATOMIC__ + +#include + +typedef int atomic_t; + +#define ATOMIC_INIT(i) { (i) } + +/** + * atomic_read - read atomic variable + * @v: pointer of type atomic_t + * + * Atomically reads the value of @v. + */ +#define atomic_read(v) (*v) + +/** + * atomic_set - set atomic variable + * @v: pointer of type atomic_t + * @i: required value + * + * Atomically sets the value of @v to @i. + */ +#define atomic_set(v,i) (*v) = i + +/** + * atomic_add - add integer to atomic variable + * @i: integer value to add + * @v: pointer of type atomic_t + * + * Atomically adds @i to @v. + */ +static __inline__ void atomic_add(int i, atomic_t *v) +{ + (*v) = (*v) + i; +} + +/** + * atomic_sub - subtract the atomic variable + * @i: integer value to subtract + * @v: pointer of type atomic_t + * + * Atomically subtracts @i from @v. + */ +static __inline__ void atomic_sub(int i, atomic_t *v) +{ + (*v) = (*v) - i; +} + +/** + * atomic_inc - increment atomic variable + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1. + */ +static __inline__ void atomic_inc(atomic_t *v) +{ + (*v)++; +} + +/** + * atomic_dec - decrement atomic variable + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1. + */ +static __inline__ void atomic_dec(atomic_t *v) +{ + (*v)--; +} + +/** + * atomic_dec_and_test - decrement and test + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1 and + * returns true if the result is 0, or false for all other + * cases. + */ +static __inline__ int atomic_dec_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)--; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_inc_and_test - increment and test + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1 + * and returns true if the result is zero, or false for all + * other cases. + */ +static __inline__ int atomic_inc_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)++; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_negative - add and test if negative + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns true + * if the result is negative, or false when + * result is greater than or equal to zero. + */ +static __inline__ int atomic_add_negative(int i, atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v) = (*v) + i; + if ((*v) < 0) { + ret = 1; + } else { + ret = 0; + } + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_return - add and return + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns @i + @v + */ +static __inline__ int atomic_add_return(int i, atomic_t *v) +{ + return (*v) + i; +} + +static __inline__ int atomic_sub_return(int i, atomic_t *v) +{ + return (*v) - i; +} + +#define atomic_inc_return(v) (atomic_add_return(1,v)) +#define atomic_dec_return(v) (atomic_sub_return(1,v)) + +#endif diff --git a/ddverify/models/seq1/include/asm/bitops.h b/ddverify/models/seq1/include/asm/bitops.h new file mode 100644 index 000000000..6b4e2116a --- /dev/null +++ b/ddverify/models/seq1/include/asm/bitops.h @@ -0,0 +1,13 @@ +#ifndef _I386_BITOPS_H +#define _I386_BITOPS_H + +void set_bit(int nr, unsigned long * addr); + +int test_and_set_bit(int nr, unsigned long * addr); +int test_and_clear_bit(int nr, unsigned long * addr); +int test_and_change_bit(int nr, unsigned long* addr); +int test_bit(int nr, const void * addr); +void clear_bit(int nr, volatile unsigned long * addr); +int find_first_zero_bit(const unsigned long *addr, unsigned size); + +#endif /* _I386_BITOPS_H */ diff --git a/ddverify/models/seq1/include/asm/bug.h b/ddverify/models/seq1/include/asm/bug.h new file mode 100644 index 000000000..9536f4539 --- /dev/null +++ b/ddverify/models/seq1/include/asm/bug.h @@ -0,0 +1,7 @@ +#ifndef _I386_BUG_H +#define _I386_BUG_H + +#include +#include +#endif + diff --git a/ddverify/models/seq1/include/asm/byteorder.h b/ddverify/models/seq1/include/asm/byteorder.h new file mode 100644 index 000000000..20edb1dfa --- /dev/null +++ b/ddverify/models/seq1/include/asm/byteorder.h @@ -0,0 +1,9 @@ +#ifndef _I386_BYTEORDER_H +#define _I386_BYTEORDER_H + +#include +#include + +#include + +#endif /* _I386_BYTEORDER_H */ diff --git a/ddverify/models/seq1/include/asm/current.h b/ddverify/models/seq1/include/asm/current.h new file mode 100644 index 000000000..f124ae985 --- /dev/null +++ b/ddverify/models/seq1/include/asm/current.h @@ -0,0 +1,14 @@ +#ifndef _I386_CURRENT_H +#define _I386_CURRENT_H + +//#include +#include + +struct task_struct; + +struct task_struct *get_current(void); + +#define current get_current() + +#endif /* !(_I386_CURRENT_H) */ + diff --git a/ddverify/models/seq1/include/asm/delay.h b/ddverify/models/seq1/include/asm/delay.h new file mode 100644 index 000000000..153e9bc14 --- /dev/null +++ b/ddverify/models/seq1/include/asm/delay.h @@ -0,0 +1,6 @@ +#ifndef _I386_DELAY_H +#define _I386_DELAY_H + +void udelay(int); + +#endif /* defined(_I386_DELAY_H) */ diff --git a/ddverify/models/seq1/include/asm/dma.h b/ddverify/models/seq1/include/asm/dma.h new file mode 100644 index 000000000..1e1f3855e --- /dev/null +++ b/ddverify/models/seq1/include/asm/dma.h @@ -0,0 +1,72 @@ +#ifndef _ASM_DMA_H +#define _ASM_DMA_H + +#include /* And spinlocks */ +#include /* need byte IO */ +#include + +#define MAX_DMA_CHANNELS 8 + +/* The maximum address that we can perform a DMA transfer to on this platform */ +#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000) + +/* 8237 DMA controllers */ +#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ +#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ + +/* DMA controller registers */ +#define DMA1_CMD_REG 0x08 /* command register (w) */ +#define DMA1_STAT_REG 0x08 /* status register (r) */ +#define DMA1_REQ_REG 0x09 /* request register (w) */ +#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ +#define DMA1_MODE_REG 0x0B /* mode register (w) */ +#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ +#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ +#define DMA1_RESET_REG 0x0D /* Master Clear (w) */ +#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ +#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ + +#define DMA2_CMD_REG 0xD0 /* command register (w) */ +#define DMA2_STAT_REG 0xD0 /* status register (r) */ +#define DMA2_REQ_REG 0xD2 /* request register (w) */ +#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ +#define DMA2_MODE_REG 0xD6 /* mode register (w) */ +#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ +#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ +#define DMA2_RESET_REG 0xDA /* Master Clear (w) */ +#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ +#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ + +#define DMA_ADDR_0 0x00 /* DMA address registers */ +#define DMA_ADDR_1 0x02 +#define DMA_ADDR_2 0x04 +#define DMA_ADDR_3 0x06 +#define DMA_ADDR_4 0xC0 +#define DMA_ADDR_5 0xC4 +#define DMA_ADDR_6 0xC8 +#define DMA_ADDR_7 0xCC + +#define DMA_CNT_0 0x01 /* DMA count registers */ +#define DMA_CNT_1 0x03 +#define DMA_CNT_2 0x05 +#define DMA_CNT_3 0x07 +#define DMA_CNT_4 0xC2 +#define DMA_CNT_5 0xC6 +#define DMA_CNT_6 0xCA +#define DMA_CNT_7 0xCE + +#define DMA_PAGE_0 0x87 /* DMA page registers */ +#define DMA_PAGE_1 0x83 +#define DMA_PAGE_2 0x81 +#define DMA_PAGE_3 0x82 +#define DMA_PAGE_5 0x8B +#define DMA_PAGE_6 0x89 +#define DMA_PAGE_7 0x8A + +#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ +#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ +#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ + +#define DMA_AUTOINIT 0x10 + +#endif /* _ASM_DMA_H */ diff --git a/ddverify/models/seq1/include/asm/errno.h b/ddverify/models/seq1/include/asm/errno.h new file mode 100644 index 000000000..969b34374 --- /dev/null +++ b/ddverify/models/seq1/include/asm/errno.h @@ -0,0 +1,6 @@ +#ifndef _I386_ERRNO_H +#define _I386_ERRNO_H + +#include + +#endif diff --git a/ddverify/models/seq1/include/asm/fcntl.h b/ddverify/models/seq1/include/asm/fcntl.h new file mode 100644 index 000000000..46ab12db5 --- /dev/null +++ b/ddverify/models/seq1/include/asm/fcntl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/seq1/include/asm/floppy.h b/ddverify/models/seq1/include/asm/floppy.h new file mode 100644 index 000000000..fdbf1c705 --- /dev/null +++ b/ddverify/models/seq1/include/asm/floppy.h @@ -0,0 +1,45 @@ +#ifndef __ASM_I386_FLOPPY_H +#define __ASM_I386_FLOPPY_H + +#include + +static int FDC1 = 0x3f0; +static int FDC2 = -1; + + +/* + * Floppy types are stored in the rtc's CMOS RAM and so rtc_lock + * is needed to prevent corrupted CMOS RAM in case "insmod floppy" + * coincides with another rtc CMOS user. Paul G. + */ +/*#define FLOPPY0_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = (CMOS_READ(0x10) >> 4) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) + +#define FLOPPY1_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = CMOS_READ(0x10) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) +*/ +#define FLOPPY0_TYPE (CMOS_READ(0x10) >> 4) & 15 +#define FLOPPY1_TYPE CMOS_READ(0x10) & 15 + +#define N_FDC 2 +#define N_DRIVE 8 + +#define FLOPPY_MOTOR_MASK 0xf0 + +#define AUTO_DMA + +#define EXTRA_FLOPPY_PARAMS + +#endif /* __ASM_I386_FLOPPY_H */ diff --git a/ddverify/models/seq1/include/asm/highmem.h b/ddverify/models/seq1/include/asm/highmem.h new file mode 100644 index 000000000..c9c362c4f --- /dev/null +++ b/ddverify/models/seq1/include/asm/highmem.h @@ -0,0 +1,17 @@ +#ifndef _ASM_HIGHMEM_H +#define _ASM_HIGHMEM_H + +#include +//#include +#include +//#include + + +void *kmap(struct page *page); +void kunmap(struct page *page); +void *kmap_atomic(struct page *page, enum km_type type); +void kunmap_atomic(void *kvaddr, enum km_type type); +void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); +struct page *kmap_atomic_to_page(void *ptr); + +#endif /* _ASM_HIGHMEM_H */ diff --git a/ddverify/models/seq1/include/asm/io.h b/ddverify/models/seq1/include/asm/io.h new file mode 100644 index 000000000..703139060 --- /dev/null +++ b/ddverify/models/seq1/include/asm/io.h @@ -0,0 +1,69 @@ +#ifndef _ASM_IO_H +#define _ASM_IO_H + +void * phys_to_virt(unsigned long); + +#define bus_to_virt phys_to_virt + +void *ioremap(unsigned long offset, unsigned long size); +void *ioremap_nocache(unsigned long offset, unsigned long size); +void iounmap(void *addr); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb(unsigned int); +void outb(unsigned char byte, unsigned int); +unsigned short inw(unsigned int); +void outw(unsigned short word, unsigned int); +unsigned inl(unsigned int); +void outl(unsigned doubleword, unsigned int); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb_p(unsigned int); +void outb_p(unsigned char byte, unsigned int); +unsigned short inw_p(unsigned int); +void outw_p(unsigned short word, unsigned int); +unsigned inl_p(unsigned int); +void outl_p(unsigned doubleword, unsigned int); + + + +unsigned insb(unsigned int, void *addr, unsigned long count); +void outsb(unsigned int, void *addr, unsigned long count); + +unsigned insw(unsigned int, void *addr, unsigned long count); +void outsw(unsigned int, void *addr, unsigned long count); + +unsigned insl(unsigned int, void *addr, unsigned long count); +void outsl(unsigned int, void *addr, unsigned long count); + + + +unsigned int ioread8(void *addr); +unsigned int ioread16(void *addr); +unsigned int ioread32(void *addr); + +void iowrite8(u8 value, void *addr); +void iowrite16(u16 value, void *addr); +void iowrite32(u32 value, void *addr); + +void ioread8_rep(void *addr, void *buf, unsigned long count); +void ioread16_rep(void *addr, void *buf, unsigned long count); +void ioread32_rep(void *addr, void *buf, unsigned long count); + +void iowrite8_rep(void *addr, const void *buf, unsigned long count); +void iowrite16_rep(void *addr, const void *buf, unsigned long count); +void iowrite32_rep(void *addr, const void *buf, unsigned long count); + +// DDV: no bodies required for these functions: +unsigned char readb(const void *); +unsigned short readw(const void *); +unsigned int readl(const void *); + +// DDV: no bodies required for these functions: +void writeb(unsigned char, void *); +void writew(unsigned short, void *); +void writel(unsigned int, void *); + +#endif diff --git a/ddverify/models/seq1/include/asm/ioctl.h b/ddverify/models/seq1/include/asm/ioctl.h new file mode 100644 index 000000000..b279fe06d --- /dev/null +++ b/ddverify/models/seq1/include/asm/ioctl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/seq1/include/asm/ioctls.h b/ddverify/models/seq1/include/asm/ioctls.h new file mode 100644 index 000000000..4157abdb1 --- /dev/null +++ b/ddverify/models/seq1/include/asm/ioctls.h @@ -0,0 +1,91 @@ +#ifndef __ARCH_CRIS_IOCTLS_H__ +#define __ARCH_CRIS_IOCTLS_H__ + +/* verbatim copy of asm-i386/ioctls.h */ + +#include + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TCGETS2 _IOR('T',0x2A, struct termios2) +#define TCSETS2 _IOW('T',0x2B, struct termios2) +#define TCSETSW2 _IOW('T',0x2C, struct termios2) +#define TCSETSF2 _IOW('T',0x2D, struct termios2) +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ +#define FIOQSIZE 0x5460 + +#define TIOCSERSETRS485 0x5461 /* enable rs-485 */ +#define TIOCSERWRRS485 0x5462 /* write rs-485 */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif diff --git a/ddverify/models/seq1/include/asm/irq.h b/ddverify/models/seq1/include/asm/irq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/asm/kmap_types.h b/ddverify/models/seq1/include/asm/kmap_types.h new file mode 100644 index 000000000..fd2cdabbd --- /dev/null +++ b/ddverify/models/seq1/include/asm/kmap_types.h @@ -0,0 +1,23 @@ +#ifndef _ASM_KMAP_TYPES_H +#define _ASM_KMAP_TYPES_H + +enum km_type { + KM_BOUNCE_READ, + KM_SKB_SUNRPC_DATA, + KM_SKB_DATA_SOFTIRQ, + KM_USER0, + KM_USER1, + KM_BIO_SRC_IRQ, + KM_BIO_DST_IRQ, + KM_PTE0, + KM_PTE1, + KM_IRQ0, + KM_IRQ1, + KM_SOFTIRQ0, + KM_SOFTIRQ1, + KM_KDB, + KM_DUMP, + KM_TYPE_NR +}; + +#endif diff --git a/ddverify/models/seq1/include/asm/leds.h b/ddverify/models/seq1/include/asm/leds.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/asm/mach-types.h b/ddverify/models/seq1/include/asm/mach-types.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/asm/mc146818rtc.h b/ddverify/models/seq1/include/asm/mc146818rtc.h new file mode 100644 index 000000000..0c97cfb90 --- /dev/null +++ b/ddverify/models/seq1/include/asm/mc146818rtc.h @@ -0,0 +1,34 @@ +/* + * Machine dependent access functions for RTC registers. + */ +#ifndef _ASM_MC146818RTC_H +#define _ASM_MC146818RTC_H + +#include +#include +#include + +#ifndef RTC_PORT +#define RTC_PORT(x) (0x70 + (x)) +#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ +#endif + +#define lock_cmos_prefix(reg) do {} while (0) +#define lock_cmos_suffix(reg) do {} while (0) +#define lock_cmos(reg) +#define unlock_cmos() +#define do_i_have_lock_cmos() 0 +#define current_lock_cmos_reg() 0 + +/* + * The yet supported machines all access the RTC index register via + * an ISA port access but the way to access the date register differs ... + */ +#define CMOS_READ(addr) rtc_cmos_read(addr) +#define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr) +unsigned char rtc_cmos_read(unsigned char addr); +void rtc_cmos_write(unsigned char val, unsigned char addr); + +#define RTC_IRQ 8 + +#endif /* _ASM_MC146818RTC_H */ diff --git a/ddverify/models/seq1/include/asm/msr.h b/ddverify/models/seq1/include/asm/msr.h new file mode 100644 index 000000000..adf72e79e --- /dev/null +++ b/ddverify/models/seq1/include/asm/msr.h @@ -0,0 +1,10 @@ +#ifndef __ASM_MSR_H +#define __ASM_MSR_H + +#define rdmsr(msr, val1, val2) \ + do { \ + val1 = nondet_u32(); \ + val2 = nondet_u32(); \ + } while(0); + +#endif diff --git a/ddverify/models/seq1/include/asm/page.h b/ddverify/models/seq1/include/asm/page.h new file mode 100644 index 000000000..b2bc603c9 --- /dev/null +++ b/ddverify/models/seq1/include/asm/page.h @@ -0,0 +1,24 @@ +#ifndef _I386_PAGE_H +#define _I386_PAGE_H + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +//#include + + +// DDV: taken from arch/i386/defconfig +#define CONFIG_PAGE_OFFSET 0xC0000000 +// DDV: taken from arch/i386/defconfig +#define CONFIG_PHYSICAL_START 0x100000 + +#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET) +#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START) + +#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) +#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) +#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) + +#endif /* _I386_PAGE_H */ diff --git a/ddverify/models/seq1/include/asm/param.h b/ddverify/models/seq1/include/asm/param.h new file mode 100644 index 000000000..6148b8ddf --- /dev/null +++ b/ddverify/models/seq1/include/asm/param.h @@ -0,0 +1,8 @@ +#ifndef _ASMi386_PARAM_H +#define _ASMi386_PARAM_H + +#ifndef HZ +#define HZ 100 +#endif + +#endif diff --git a/ddverify/models/seq1/include/asm/pci.h b/ddverify/models/seq1/include/asm/pci.h new file mode 100644 index 000000000..c41fd10d2 --- /dev/null +++ b/ddverify/models/seq1/include/asm/pci.h @@ -0,0 +1,17 @@ +#ifndef __i386_PCI_H +#define __i386_PCI_H + +#include /* for struct page */ + +#include +#include +#include +#include +#include + + + +#include + + +#endif /* __i386_PCI_H */ diff --git a/ddverify/models/seq1/include/asm/poll.h b/ddverify/models/seq1/include/asm/poll.h new file mode 100644 index 000000000..905fb4d78 --- /dev/null +++ b/ddverify/models/seq1/include/asm/poll.h @@ -0,0 +1,20 @@ +#ifndef __i386_POLL_H +#define __i386_POLL_H + +/* These are specified by iBCS2 */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +/* The rest seem to be more-or-less nonstandard. Check them! */ +#define POLLRDNORM 0x0040 +#define POLLRDBAND 0x0080 +#define POLLWRNORM 0x0100 +#define POLLWRBAND 0x0200 +#define POLLMSG 0x0400 +#define POLLREMOVE 0x1000 + +#endif diff --git a/ddverify/models/seq1/include/asm/posix_types.h b/ddverify/models/seq1/include/asm/posix_types.h new file mode 100644 index 000000000..798ec0819 --- /dev/null +++ b/ddverify/models/seq1/include/asm/posix_types.h @@ -0,0 +1,32 @@ +#ifndef __ARCH_I386_POSIX_TYPES_H +#define __ARCH_I386_POSIX_TYPES_H + +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; + +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; +typedef unsigned short __kernel_old_dev_t; + + +#endif diff --git a/ddverify/models/seq1/include/asm/processor.h b/ddverify/models/seq1/include/asm/processor.h new file mode 100644 index 000000000..b6dedb7ad --- /dev/null +++ b/ddverify/models/seq1/include/asm/processor.h @@ -0,0 +1,6 @@ +#ifndef __ASM_I386_PROCESSOR_H +#define __ASM_I386_PROCESSOR_H + +#include + +#endif /* __ASM_I386_PROCESSOR_H */ diff --git a/ddverify/models/seq1/include/asm/ptrace.h b/ddverify/models/seq1/include/asm/ptrace.h new file mode 100644 index 000000000..69130f62a --- /dev/null +++ b/ddverify/models/seq1/include/asm/ptrace.h @@ -0,0 +1,8 @@ +#ifndef _I386_PTRACE_H +#define _I386_PTRACE_H + +struct pt_regs { + int something; +}; + +#endif diff --git a/ddverify/models/seq1/include/asm/rtc.h b/ddverify/models/seq1/include/asm/rtc.h new file mode 100644 index 000000000..3d2d9102e --- /dev/null +++ b/ddverify/models/seq1/include/asm/rtc.h @@ -0,0 +1,7 @@ +#ifndef __ASM_RTC_H__ +#define __ASM_RTC_H__ + +#include + +#endif + diff --git a/ddverify/models/seq1/include/asm/scatterlist.h b/ddverify/models/seq1/include/asm/scatterlist.h new file mode 100644 index 000000000..55d6c953a --- /dev/null +++ b/ddverify/models/seq1/include/asm/scatterlist.h @@ -0,0 +1,21 @@ +#ifndef _I386_SCATTERLIST_H +#define _I386_SCATTERLIST_H + +struct scatterlist { + struct page *page; + unsigned int offset; + dma_addr_t dma_address; + unsigned int length; +}; + +/* These macros should be used after a pci_map_sg call has been done + * to get bus addresses of each of the SG entries and their lengths. + * You should only work with the number of sg entries pci_map_sg + * returns. + */ +#define sg_dma_address(sg) ((sg)->dma_address) +#define sg_dma_len(sg) ((sg)->length) + +#define ISA_DMA_THRESHOLD (0x00ffffff) + +#endif /* !(_I386_SCATTERLIST_H) */ diff --git a/ddverify/models/seq1/include/asm/semaphore.h b/ddverify/models/seq1/include/asm/semaphore.h new file mode 100644 index 000000000..5d574f8a9 --- /dev/null +++ b/ddverify/models/seq1/include/asm/semaphore.h @@ -0,0 +1,37 @@ +#ifndef _I386_SEMAPHORE_H +#define _I386_SEMAPHORE_H + +struct semaphore { + int init; + int locked; +}; + + +#define __SEMAPHORE_INITIALIZER(name, n) \ +{ \ + .init = 1, \ + .locked = n \ +} + +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) + +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,0) +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,1) + +// DDV: Body is defined in linux/kernel/semaphore.c +void sema_init(struct semaphore *sem, int val); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX_LOCKED(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void down(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_interruptible(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_trylock(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void up(struct semaphore * sem); + +#endif diff --git a/ddverify/models/seq1/include/asm/siginfo.h b/ddverify/models/seq1/include/asm/siginfo.h new file mode 100644 index 000000000..fe18f98fc --- /dev/null +++ b/ddverify/models/seq1/include/asm/siginfo.h @@ -0,0 +1,6 @@ +#ifndef _I386_SIGINFO_H +#define _I386_SIGINFO_H + +#include + +#endif diff --git a/ddverify/models/seq1/include/asm/signal.h b/ddverify/models/seq1/include/asm/signal.h new file mode 100644 index 000000000..d85fd7a75 --- /dev/null +++ b/ddverify/models/seq1/include/asm/signal.h @@ -0,0 +1,86 @@ +#ifndef _ASMi386_SIGNAL_H +#define _ASMi386_SIGNAL_H + +#define _NSIG 64 +#define _NSIG_BPW 32 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef unsigned long old_sigset_t; /* at least 32 bits */ + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG + + +/* + * SA_FLAGS values: + * + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_NODEFER prevents the current signal from being masked in the handler. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#define SA_NOCLDSTOP 0x00000001u +#define SA_NOCLDWAIT 0x00000002u +#define SA_SIGINFO 0x00000004u +#define SA_ONSTACK 0x08000000u +#define SA_RESTART 0x10000000u +#define SA_NODEFER 0x40000000u +#define SA_RESETHAND 0x80000000u + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND +#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */ + +#define SA_RESTORER 0x04000000 + + +#endif diff --git a/ddverify/models/seq1/include/asm/stat.h b/ddverify/models/seq1/include/asm/stat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/asm/string.h b/ddverify/models/seq1/include/asm/string.h new file mode 100644 index 000000000..6b1131c19 --- /dev/null +++ b/ddverify/models/seq1/include/asm/string.h @@ -0,0 +1,6 @@ +#ifndef _I386_STRING_H_ +#define _I386_STRING_H_ + +void *memset(void *s, int c, size_t n); + +#endif diff --git a/ddverify/models/seq1/include/asm/system.h b/ddverify/models/seq1/include/asm/system.h new file mode 100644 index 000000000..1d6f962e6 --- /dev/null +++ b/ddverify/models/seq1/include/asm/system.h @@ -0,0 +1,9 @@ +#ifndef __ASM_SYSTEM_H +#define __ASM_SYSTEM_H + +void rmb(void); +void read_barrier_depends(void); +void wmb(void); +void mb(void); + +#endif diff --git a/ddverify/models/seq1/include/asm/termbits.h b/ddverify/models/seq1/include/asm/termbits.h new file mode 100644 index 000000000..3606b9897 --- /dev/null +++ b/ddverify/models/seq1/include/asm/termbits.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_I386_TERMBITS_H__ +#define __ARCH_I386_TERMBITS_H__ + +#include + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +#endif diff --git a/ddverify/models/seq1/include/asm/termios.h b/ddverify/models/seq1/include/asm/termios.h new file mode 100644 index 000000000..8f71467a2 --- /dev/null +++ b/ddverify/models/seq1/include/asm/termios.h @@ -0,0 +1,54 @@ +#ifndef _I386_TERMIOS_H +#define _I386_TERMIOS_H + +#include +#include + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 /* X.25 async */ +#define N_6PACK 7 +#define N_MASC 8 /* Reserved for Mobitex module */ +#define N_R3964 9 /* Reserved for Simatic R3964 module */ +#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */ +#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */ +#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */ +#define N_HDLC 13 /* synchronous HDLC */ +#define N_SYNC_PPP 14 /* synchronous PPP */ +#define N_HCI 15 /* Bluetooth HCI UART */ + +#endif /* _I386_TERMIOS_H */ diff --git a/ddverify/models/seq1/include/asm/types.h b/ddverify/models/seq1/include/asm/types.h new file mode 100644 index 000000000..39b35bb5e --- /dev/null +++ b/ddverify/models/seq1/include/asm/types.h @@ -0,0 +1,35 @@ +#ifndef _I386_TYPES_H +#define _I386_TYPES_H + +typedef unsigned short umode_t; + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +typedef __signed__ long long __s64; +typedef unsigned long long __u64; + +#define BITS_PER_LONG 32 + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +typedef u32 dma_addr_t; +typedef u64 dma64_addr_t; + +#endif diff --git a/ddverify/models/seq1/include/asm/uaccess.h b/ddverify/models/seq1/include/asm/uaccess.h new file mode 100644 index 000000000..a764a014c --- /dev/null +++ b/ddverify/models/seq1/include/asm/uaccess.h @@ -0,0 +1,55 @@ +#ifndef __i386_UACCESS_H +#define __i386_UACCESS_H + +/* + * User space memory access functions + */ +#include +#include +#include +#include + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +/** + * access_ok: - Checks if a user space pointer is valid + * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that + * %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe + * to write to a block, it is always safe to read from it. + * @addr: User space pointer to start of block to check + * @size: Size of block to check + * + * Context: User context only. This function may sleep. + * + * Checks if a pointer to a block of memory in user space is valid. + * + * Returns true (nonzero) if the memory block may be valid, false (zero) + * if it is definitely invalid. + * + * Note that, depending on architecture, this function probably just + * checks that the pointer is in the user space range - after calling + * this function, memory access functions may still return -EFAULT. + */ +// #define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0)) +int access_ok(int type, const void *addr, unsigned long size); + + +// DDV-TODO: get_user and put_user are defined as macros!!! if bug030 is fixed, this should be done here. + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __get_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int get_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __put_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int put_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n); +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_from_user(void *to, void __user *from, unsigned long n); + +#endif /* __i386_UACCESS_H */ diff --git a/ddverify/models/seq1/include/ddverify/blkdev.h b/ddverify/models/seq1/include/ddverify/blkdev.h new file mode 100644 index 000000000..aa65ce957 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/blkdev.h @@ -0,0 +1,10 @@ +#ifndef _DDV_BLKDEV_H_ +#define _DDV_BLKDEV_H_ + +#define MAX_REQUEST_QUEUE_SUPPORT 10 + +request_queue_t fixed_request_queue[MAX_REQUEST_QUEUE_SUPPORT]; + +int number_request_queue_used = 0; + +#endif diff --git a/ddverify/models/seq1/include/ddverify/cdev.h b/ddverify/models/seq1/include/ddverify/cdev.h new file mode 100644 index 000000000..e79a6b9f2 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/cdev.h @@ -0,0 +1,26 @@ +#ifndef _DDV_CDEV_H +#define _DDV_CDEV_H + +#include +#include + +#define MAX_CDEV_SUPPORT 1 + +#include + +short number_cdev_registered = 0; + +struct ddv_cdev { + struct cdev *cdevp; + + struct file filp; + struct inode inode; + + int open; +}; + +struct ddv_cdev cdev_registered[MAX_CDEV_SUPPORT]; + +void call_cdev_functions(); + +#endif diff --git a/ddverify/models/seq1/include/ddverify/ddverify.h b/ddverify/models/seq1/include/ddverify/ddverify.h new file mode 100644 index 000000000..f6d8a06fe --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/ddverify.h @@ -0,0 +1,47 @@ +#ifndef _DDVERIFY_H +#define _DDVERIFY_H + +enum __bool { false, true }; + +#ifndef NULL +#define NULL ((void *)0) +#endif + + +int current_execution_context; + +#define CONTEXT_PROCESS 1 +#define CONTEXT_INTERRUPT 2 + +#define switch_context(x) current_execution_context = x + +#ifdef DDV_ASSERT_CONTEXT + +static inline assert_context_process() +{ + __CPROVER_assert(current_execution_context == CONTEXT_PROCESS, "Process context"); +} + +static inline assert_context_interrupt() +{ + __CPROVER_assert(current_execution_context == CONTEXT_INTERRUPT, "Interrupt context"); +} + +#else + +static inline assert_context_process() +{ +} + +static inline assert_context_interrupt() +{ +} + +#endif /* DDV_ASSERT_CONTEXT */ + +int (* _ddv_module_init)(void); +void (* _ddv_module_exit)(void); + +int call_ddv(); + +#endif diff --git a/ddverify/models/seq1/include/ddverify/fixed_cdev.h b/ddverify/models/seq1/include/ddverify/fixed_cdev.h new file mode 100644 index 000000000..347972b25 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/fixed_cdev.h @@ -0,0 +1,15 @@ +#ifndef _DDV_FIXED_CDEV_H_ +#define _DDV_FIXED_CDEV_H_ + +#include +#include +#include + +// Used in function misc_register and cdev_alloc. Instead allocating a cdev structure, +// a cdev structure from this array is used. This make the verification process much +// simpler. + +struct cdev fixed_cdev[MAX_CDEV_SUPPORT]; +int fixed_cdev_used = 0; + +#endif diff --git a/ddverify/models/seq1/include/ddverify/genhd.h b/ddverify/models/seq1/include/ddverify/genhd.h new file mode 100644 index 000000000..3d0161e60 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/genhd.h @@ -0,0 +1,29 @@ +#ifndef _DDV_GENHD_H +#define _DDV_GENHD_H + +#include +#include +#include + +#include + +#define MAX_GENHD_SUPPORT 10 + +short number_genhd_registered = 0; +short number_fixed_genhd_used = 0; + +struct ddv_genhd { + struct gendisk *gd; + + struct inode inode; + struct file file; + struct request current_request; + int requests_open; +}; + +struct gendisk fixed_gendisk[MAX_GENHD_SUPPORT]; +struct ddv_genhd genhd_registered[MAX_GENHD_SUPPORT]; + +void call_genhd_functions(); + +#endif diff --git a/ddverify/models/seq1/include/ddverify/interrupt.h b/ddverify/models/seq1/include/ddverify/interrupt.h new file mode 100644 index 000000000..bca87a686 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/interrupt.h @@ -0,0 +1,19 @@ +#ifndef _DDV_INTERRUPT_H +#define _DDV_INTERRUPT_H + +#include +#include + +#define MAX_IRQ_SUPPORT 16 + +struct registered_irq { + irq_handler_t handler; + void *dev_id; +}; + +struct registered_irq registered_irq[MAX_IRQ_SUPPORT]; + +void call_interrupt_handler(); + +#endif + diff --git a/ddverify/models/seq1/include/ddverify/ioctl.h b/ddverify/models/seq1/include/ddverify/ioctl.h new file mode 100644 index 000000000..76312e082 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/ioctl.h @@ -0,0 +1,15 @@ +#ifndef _DDV_IOCTL_H +#define _DDV_IOCTL_H + +/*#define MAX_IOCTL_SUPPORT 20 + +short number_ioctl_registered = 0; + +typedef unsigned int ddv_ioctl; + +ddv_ioctl ioctl_registered[MAX_IOCTL_SUPPORT]; + +void add_ioctl(unsigned int); +unsigned int get_ioctl_cmd(); +*/ +#endif diff --git a/ddverify/models/seq1/include/ddverify/ioport.h b/ddverify/models/seq1/include/ddverify/ioport.h new file mode 100644 index 000000000..e04ff487b --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/ioport.h @@ -0,0 +1,24 @@ +#ifndef _DDV_IOPORT_H +#define _DDV_IOPORT_H + +#include + +//#define NUMBER_IO_PORTS 65536 + +//ushort ddv_ioport[NUMBER_IO_PORTS - 1]; + +#ifdef DDV_ASSERT_IO + +// __CPROVER_assert(ddv_ioport[port], "Used I/O Port was requested") + +#define ddv_correct_port_use(port) \ +__CPROVER_assert(port >= ddv_ioport_request_start && port < ddv_ioport_request_start + ddv_ioport_request_len, "I/O port is requested") + +#else + +#define ddv_correct_port_use(port) \ + do { } while(0) + +#endif /* DDV_ASSERT_IO */ + +#endif diff --git a/ddverify/models/seq1/include/ddverify/miscdevice.h b/ddverify/models/seq1/include/ddverify/miscdevice.h new file mode 100644 index 000000000..43b174d28 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/miscdevice.h @@ -0,0 +1,7 @@ +#ifndef _DDV_MISCDEVICE_H +#define _DDV_MISCDEVICE_H + +#include + +#endif + diff --git a/ddverify/models/seq1/include/ddverify/pci.h b/ddverify/models/seq1/include/ddverify/pci.h new file mode 100644 index 000000000..d2ece19a8 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/pci.h @@ -0,0 +1,22 @@ +#ifndef _DDV_PCI_H_ +#define _DDV_PCI_H_ + +#include + +struct ddv_pci_driver { + struct pci_driver *pci_driver; + struct pci_dev pci_dev; + + unsigned int no_pci_device_id; + int dev_initialized; +}; + +struct ddv_pci_driver registered_pci_driver; + +int pci_probe_device(); +void pci_remove_device(); + +void call_pci_functions(); + + +#endif diff --git a/ddverify/models/seq1/include/ddverify/pthread.h b/ddverify/models/seq1/include/ddverify/pthread.h new file mode 100644 index 000000000..64c351ee6 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/pthread.h @@ -0,0 +1,253 @@ +#ifndef __POSIX_PTHREAD_H +#define __POSIX_PTHREAD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NULL +#define NULL ((void *)0) +#endif + +/* Types */ +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +struct __pthread_mutex_t_struct +{ + _Bool locked; +}; + +struct __pthread_mutexattr_t_struct +{ + int dummy; +}; + +struct __pthread_spinlock_t_struct +{ + int dummy; +}; + +struct __pthread_barrier_t_struct +{ + int dummy; +}; + +struct __pthread_barrierattr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; +typedef struct __pthread_mutex_t_struct pthread_mutex_t; +typedef struct __pthread_mutexattr_t_struct pthread_mutexattr_t; +typedef struct __pthread_spinlock_t_struct pthread_spinlock_t; +typedef struct __pthread_barrier_t_struct pthread_barrier_t; +typedef struct __pthread_barrierattr_t_struct pthread_barrierattr_t; + +/* Initializers */ + +#define PTHREAD_MUTEX_INITIALIZER {0} + +/* Attributes */ + +enum +{ + PTHREAD_CREATE_JOINABLE, +#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE + PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED +}; + +enum +{ + PTHREAD_INHERIT_SCHED, +#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED + PTHREAD_EXPLICIT_SCHED +#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED +}; + +enum +{ + PTHREAD_SCOPE_SYSTEM, +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM + PTHREAD_SCOPE_PROCESS +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +}; + +enum +{ + PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_ADAPTIVE_NP, + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +}; + +enum +{ + PTHREAD_PROCESS_PRIVATE, +#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE + PTHREAD_PROCESS_SHARED +#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED +}; + +enum +{ + PTHREAD_RWLOCK_PREFER_READER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, + PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP +}; + +#define PTHREAD_ONCE_INIT 0 + +/* -1 is distinct from 0 and all errno constants */ +#define PTHREAD_BARRIER_SERIAL_THREAD -1 + +enum +{ + PTHREAD_CANCEL_ENABLE, +#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE + PTHREAD_CANCEL_DISABLE +#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +}; +enum +{ + PTHREAD_CANCEL_DEFERRED, +#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED + PTHREAD_CANCEL_ASYNCHRONOUS +#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS +}; +#define PTHREAD_CANCELED ((void *) -1) + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create( + pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg); + +extern pthread_t pthread_self(void); +extern int pthread_equal(pthread_t __thread1, pthread_t __thread2); +extern void pthread_exit(void *__retval); +extern int pthread_join(pthread_t __th, void **__thread_return); +extern int pthread_detach(pthread_t __th); +extern int pthread_attr_init(pthread_attr_t *__attr); +extern int pthread_attr_destroy(pthread_attr_t *__attr); +extern int pthread_attr_setdetachstate(pthread_attr_t *__attr, int __detachstate); +extern int pthread_attr_getdetachstate(__const pthread_attr_t *__attr, int *__detachstate); +extern int pthread_attr_setschedparam(pthread_attr_t *__attr, __const struct sched_param *__param); +extern int pthread_attr_getschedparam(__const pthread_attr_t *__attr, struct sched_param *__param); +extern int pthread_attr_setschedpolicy(pthread_attr_t *__attr, int __policy); +extern int pthread_attr_getschedpolicy(__const pthread_attr_t *__attr, int *__policy); +extern int pthread_attr_setinheritsched(pthread_attr_t *__attr, int __inherit); +extern int pthread_attr_getinheritsched(__const pthread_attr_t *__attr, int *__inherit); +extern int pthread_attr_setscope(pthread_attr_t *__attr, int __scope); +extern int pthread_attr_getscope(__const pthread_attr_t *__attr, int *__scope); +extern int pthread_attr_setguardsize(pthread_attr_t *__attr, size_t __guardsize); +extern int pthread_attr_getguardsize(__const pthread_attr_t *__attr, size_t *__guardsize); +extern int pthread_attr_setstackaddr(pthread_attr_t *__attr, void *__stackaddr); +extern int pthread_attr_getstackaddr(__const pthread_attr_t *__attr, void **__stackaddr); +extern int pthread_attr_setstack(pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize); +extern int pthread_attr_getstack(__const pthread_attr_t *__attr, + void **__stackaddr, + size_t *__stacksize); +extern int pthread_attr_setstacksize(pthread_attr_t *__attr, size_t __stacksize); +extern int pthread_attr_getstacksize(__const pthread_attr_t *, size_t *__stacksize); + +extern int pthread_getattr_np(pthread_t __th, pthread_attr_t *__attr); + +extern int pthread_setschedparam(pthread_t __target_thread, int __policy, + __const struct sched_param *__param); + +extern int pthread_getschedparam(pthread_t __target_thread, + int *__policy, + struct sched_param *__param); + +extern int pthread_getconcurrency(void); +extern int pthread_setconcurrency(int __level); +extern int pthread_yield(void); + +extern inline int pthread_mutex_init( + pthread_mutex_t *__mutex, + __const pthread_mutexattr_t *__mutex_attr) +{ + pthread_mutex_t i=PTHREAD_MUTEX_INITIALIZER; + *__mutex=i; +} + +extern inline int pthread_mutex_destroy(pthread_mutex_t *__mutex) +{ +} + +extern int pthread_mutex_trylock(pthread_mutex_t *__mutex); + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + +extern inline int pthread_mutex_lock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + __CPROVER_assume(!__mutex->locked); + __mutex->locked=1; + __CPROVER_atomic_end(); + return 0; // we never fail +} + +extern inline int pthread_mutex_unlock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_assert(__mutex->locked, "pthread_mutex_unlock without lock"); + __mutex->locked=0; + return 0; // we never fail +} + +extern int pthread_spin_init(pthread_spinlock_t *__lock, int __pshared); +extern int pthread_spin_destroy(pthread_spinlock_t *__lock); +extern int pthread_spin_lock(pthread_spinlock_t *__lock); +extern int pthread_spin_trylock(pthread_spinlock_t *__lock); +extern int pthread_spin_unlock(pthread_spinlock_t *__lock); +extern int pthread_barrier_init(pthread_barrier_t *__barrier, + __const pthread_barrierattr_t *__attr, unsigned int __count); + +extern int pthread_barrier_destroy(pthread_barrier_t *__barrier); +extern int pthread_barrierattr_init(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_destroy(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_getpshared(__const pthread_barrierattr_t *__attr, + int *__pshared); + +extern int pthread_barrierattr_setpshared(pthread_barrierattr_t *__attr, int __pshared); +extern int pthread_barrier_wait(pthread_barrier_t *__barrier); + +extern int pthread_setcancelstate(int __state, int *__oldstate); +extern int pthread_setcanceltype(int __type, int *__oldtype); +extern int pthread_cancel(pthread_t __cancelthread); +extern void pthread_testcancel(void); + +extern int pthread_atfork(void (*__prepare)(void), + void (*__parent)(void), + void (*__child)(void)); + +extern void pthread_kill_other_threads_np(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ddverify/models/seq1/include/ddverify/satabs.h b/ddverify/models/seq1/include/ddverify/satabs.h new file mode 100644 index 000000000..6841c1210 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/satabs.h @@ -0,0 +1,71 @@ +#ifndef _SATABS_H +#define _SATABS_H + +#include +#include +#include + +// memory management + +void *malloc(size_t size); + + +// nondeterministic functions + +short nondet_short(); +unsigned short nondet_ushort(); +int nondet_int(); +unsigned int nondet_uint(); +long nondet_long(); +unsigned long nondet_ulong(); +char nondet_char(); +unsigned char nondet_uchar(); +unsigned nondet_unsigned(); +loff_t nondet_loff_t(); +size_t nondet_size_t(); +sector_t nondet_sector_t(); +u32 nondet_u32(); +char * nondet_pchar(); +enum __bool nondet_bool(); + + +// handling asm code + +void noop(); +#define asm(code, ...) noop() + + +// __CPROVER functions + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + +/* +// pthread +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create(pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg) +{ + __CPROVER_HIDE: + *__threadp = nondet_pthread_t(); + CPROVER_ASYNC_1: __start_routine(__arg); + return 0; +} +*/ +#endif diff --git a/ddverify/models/seq1/include/ddverify/tasklet.h b/ddverify/models/seq1/include/ddverify/tasklet.h new file mode 100644 index 000000000..be3ff2d91 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/tasklet.h @@ -0,0 +1,20 @@ +#ifndef _DDV_TASKLET_H_ +#define _DDV_TASKLET_H_ + +#include + +#define MAX_TASKLET_SUPPORT 1 + +short number_tasklet_registered = 0; + +struct ddv_tasklet { + struct tasklet_struct *tasklet; + unsigned short is_running; +}; + +struct ddv_tasklet tasklet_registered[MAX_TASKLET_SUPPORT]; + +void call_tasklet_functions(); + +#endif + diff --git a/ddverify/models/seq1/include/ddverify/timer.h b/ddverify/models/seq1/include/ddverify/timer.h new file mode 100644 index 000000000..004dddee6 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/timer.h @@ -0,0 +1,17 @@ +#ifndef _DDV_TIMER_H_ +#define _DDV_TIMER_H_ + +#include + +#define MAX_TIMER_SUPPORT 1 + +short number_timer_registered = 0; + +struct ddv_timer { + struct timer_list *timer; +}; + +struct ddv_timer timer_registered[MAX_TIMER_SUPPORT]; + +void call_timer_functions(); +#endif diff --git a/ddverify/models/seq1/include/ddverify/tty.h b/ddverify/models/seq1/include/ddverify/tty.h new file mode 100644 index 000000000..de3b5226f --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/tty.h @@ -0,0 +1,16 @@ +#ifndef _DDV_TTY_H_ +#define _DDV_TTY_H_ + +#include +#include + +struct ddv_tty_driver { + struct tty_driver driver; + unsigned short allocated; + unsigned short registered; +}; + +struct ddv_tty_driver global_tty_driver; + +#endif + diff --git a/ddverify/models/seq1/include/ddverify/workqueue.h b/ddverify/models/seq1/include/ddverify/workqueue.h new file mode 100644 index 000000000..2db429169 --- /dev/null +++ b/ddverify/models/seq1/include/ddverify/workqueue.h @@ -0,0 +1,12 @@ +#ifndef _DDV_WORKQUEUE_H_ +#define _DDV_WORKQUEUE_H_ + +#include + +#define MAX_WORKQUEUE_ELEMENTS_SUPPORT 10 + +struct work_struct *shared_workqueue[MAX_WORKQUEUE_ELEMENTS_SUPPORT]; + +void call_shared_workqueue_functions(); + +#endif diff --git a/ddverify/models/seq1/include/linux/backing-dev.h b/ddverify/models/seq1/include/linux/backing-dev.h new file mode 100644 index 000000000..1804ab33f --- /dev/null +++ b/ddverify/models/seq1/include/linux/backing-dev.h @@ -0,0 +1,37 @@ +/* + * include/linux/backing-dev.h + * + * low-level device information and state which is propagated up through + * to high-level code. + */ + +#ifndef _LINUX_BACKING_DEV_H +#define _LINUX_BACKING_DEV_H + +struct backing_dev_info { + unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ + unsigned long state; /* Always use atomic bitops on this */ + unsigned int capabilities; /* Device capabilities */ +}; + + +/* + * Flags in backing_dev_info::capability + * - The first two flags control whether dirty pages will contribute to the + * VM's accounting and whether writepages() should be called for dirty pages + * (something that would not, for example, be appropriate for ramfs) + * - These flags let !MMU mmap() govern direct device mapping vs immediate + * copying more easily for MAP_PRIVATE, especially for ROM filesystems + */ +#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ +#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ +#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ +#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ +#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ +#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ +#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ +#define BDI_CAP_VMFLAGS \ + (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) + + +#endif /* _LINUX_BACKING_DEV_H */ diff --git a/ddverify/models/seq1/include/linux/bcd.h b/ddverify/models/seq1/include/linux/bcd.h new file mode 100644 index 000000000..c54530812 --- /dev/null +++ b/ddverify/models/seq1/include/linux/bcd.h @@ -0,0 +1,20 @@ +/* Permission is hereby granted to copy, modify and redistribute this code + * in terms of the GNU Library General Public License, Version 2 or later, + * at your option. + */ + +/* macros to translate to/from binary and binary-coded decimal (frequently + * found in RTC chips). + */ + +#ifndef _BCD_H +#define _BCD_H + +#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) +#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) + +/* backwards compat */ +#define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) +#define BIN_TO_BCD(val) ((val)=BIN2BCD(val)) + +#endif /* _BCD_H */ diff --git a/ddverify/models/seq1/include/linux/bio.h b/ddverify/models/seq1/include/linux/bio.h new file mode 100644 index 000000000..159afe963 --- /dev/null +++ b/ddverify/models/seq1/include/linux/bio.h @@ -0,0 +1,110 @@ +#ifndef __LINUX_BIO_H +#define __LINUX_BIO_H + +#include + +struct bio_vec { + struct page *bv_page; + unsigned int bv_len; + unsigned int bv_offset; +}; + +struct bio_set; +struct bio; +typedef int (bio_end_io_t) (struct bio *, unsigned int, int); +typedef void (bio_destructor_t) (struct bio *); + +struct bio { + sector_t bi_sector; + + struct bio *bi_next; /* request queue link */ + struct block_device *bi_bdev; + unsigned long bi_flags; /* status, command, etc */ + unsigned long bi_rw; + + unsigned short bi_vcnt; + unsigned short bi_idx; + + /* Number of segments in this BIO after + * physical address coalescing is performed. + */ + unsigned short bi_phys_segments; + + unsigned int bi_size; + struct bio_vec *bi_io_vec; + + bio_end_io_t *bi_end_io; + + void *bi_private; +}; + +/* + * bio flags + */ +#define BIO_UPTODATE 0 /* ok after I/O completion */ +#define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ +#define BIO_EOF 2 /* out-out-bounds error */ +#define BIO_SEG_VALID 3 /* nr_hw_seg valid */ +#define BIO_CLONED 4 /* doesn't own data */ +#define BIO_BOUNCED 5 /* bio is a bounce bio */ +#define BIO_USER_MAPPED 6 /* contains user pages */ +#define BIO_EOPNOTSUPP 7 /* not supported */ +#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) + +/* + * top 4 bits of bio flags indicate the pool this bio came from + */ +#define BIO_POOL_BITS (4) +#define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) +#define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) +#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) + +/* + * bio bi_rw flags + * + * bit 0 -- read (not set) or write (set) + * bit 1 -- rw-ahead when set + * bit 2 -- barrier + * bit 3 -- fail fast, don't want low level driver retries + * bit 4 -- synchronous I/O hint: the block layer will unplug immediately + */ +#define BIO_RW 0 +#define BIO_RW_AHEAD 1 +#define BIO_RW_BARRIER 2 +#define BIO_RW_FAILFAST 3 +#define BIO_RW_SYNC 4 + + +#define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)])) +#define bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_idx) +#define bio_page(bio) bio_iovec((bio))->bv_page +#define bio_offset(bio) bio_iovec((bio))->bv_offset +#define bio_sectors(bio) ((bio)->bi_size >> 9) +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +#define bio_data(bio) (page_address(bio_page((bio))) + bio_offset((bio))) +#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER)) +#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC)) +#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) +#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) +#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) + +/* + * drivers should not use the __ version unless they _really_ want to + * run through the entire bio and not just pending pieces + */ +#define __bio_for_each_segment(bvl, bio, i, start_idx) \ + for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ + i < (bio)->bi_vcnt; \ + bvl++, i++) + +#define bio_for_each_segment(bvl, bio, i) \ + __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx) + +void * __bio_kmap_atomic(struct bio *, int, enum km_type); +void __bio_kunmap_atomic(char *buffer, enum km_type); + +void bio_endio(struct bio *, unsigned int, int); +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +int bio_cur_sectors(struct bio *); + +#endif /* __LINUX_BIO_H */ diff --git a/ddverify/models/seq1/include/linux/bitops.h b/ddverify/models/seq1/include/linux/bitops.h new file mode 100644 index 000000000..3e24f9c39 --- /dev/null +++ b/ddverify/models/seq1/include/linux/bitops.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_BITOPS_H +#define _LINUX_BITOPS_H + +#include + +#endif diff --git a/ddverify/models/seq1/include/linux/blkdev.h b/ddverify/models/seq1/include/linux/blkdev.h new file mode 100644 index 000000000..d31cd7561 --- /dev/null +++ b/ddverify/models/seq1/include/linux/blkdev.h @@ -0,0 +1,239 @@ +#ifndef _LINUX_BLKDEV_H +#define _LINUX_BLKDEV_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include + +#include + +struct request_queue; +typedef struct request_queue request_queue_t; + +typedef void (request_fn_proc) (request_queue_t *q); +typedef int (make_request_fn) (request_queue_t *q, struct bio *bio); +typedef void (unplug_fn) (request_queue_t *); + +/* + * request command types + */ +enum rq_cmd_type_bits { + REQ_TYPE_FS = 1, /* fs request */ + REQ_TYPE_BLOCK_PC, /* scsi command */ + REQ_TYPE_SENSE, /* sense request */ + REQ_TYPE_PM_SUSPEND, /* suspend request */ + REQ_TYPE_PM_RESUME, /* resume request */ + REQ_TYPE_PM_SHUTDOWN, /* shutdown request */ + REQ_TYPE_FLUSH, /* flush request */ + REQ_TYPE_SPECIAL, /* driver defined type */ + REQ_TYPE_LINUX_BLOCK, /* generic block layer message */ + /* + * for ATA/ATAPI devices. this really doesn't belong here, ide should + * use REQ_TYPE_SPECIAL and use rq->cmd[0] with the range of driver + * private REQ_LB opcodes to differentiate what type of request this is + */ + REQ_TYPE_ATA_CMD, + REQ_TYPE_ATA_TASK, + REQ_TYPE_ATA_TASKFILE, + REQ_TYPE_ATA_PC, +}; + + +struct request_queue { + request_fn_proc *request_fn; + make_request_fn *make_request_fn; + unplug_fn *unplug_fn; + + struct backing_dev_info backing_dev_info; + void *queuedata; + + /* + * various queue flags, see QUEUE_* below + */ + unsigned long queue_flags; + + spinlock_t *queue_lock; + + unsigned short hardsect_size; + + int __ddv_genhd_no; + int __ddv_queue_alive; +}; + +#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ +#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ +#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */ +#define QUEUE_FLAG_READFULL 3 /* write queue has been filled */ +#define QUEUE_FLAG_WRITEFULL 4 /* read queue has been filled */ +#define QUEUE_FLAG_DEAD 5 /* queue being torn down */ +#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ +#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ +#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ + + + +#define BLK_MAX_CDB 16 + + +struct request { + struct list_head queuelist; + struct list_head donelist; + + request_queue_t *q; + + + unsigned long flags; /* see REQ_ bits below */ + + unsigned int cmd_flags; + enum rq_cmd_type_bits cmd_type; + + struct bio *bio; + + void *completion_data; + + struct gendisk *rq_disk; + sector_t sector; + unsigned long nr_sectors; /* no. of sectors left to submit */ + unsigned int current_nr_sectors; + char *buffer; + + int errors; + + unsigned short nr_phys_segments; + + unsigned char cmd[BLK_MAX_CDB]; +}; + + + +/* + * first three bits match BIO_RW* bits, important + */ +enum rq_flag_bits { + __REQ_RW, /* not set, read. set, write */ + __REQ_FAILFAST, /* no low level driver retries */ + __REQ_SORTED, /* elevator knows about this request */ + __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ + __REQ_HARDBARRIER, /* may not be passed by drive either */ + __REQ_FUA, /* forced unit access */ + __REQ_CMD, /* is a regular fs rw request */ + __REQ_NOMERGE, /* don't touch this for merging */ + __REQ_STARTED, /* drive already may have started this one */ + __REQ_DONTPREP, /* don't call prep for this one */ + __REQ_QUEUED, /* uses queueing */ + __REQ_ELVPRIV, /* elevator private data attached */ + /* + * for ATA/ATAPI devices + */ + __REQ_PC, /* packet command (special) */ + __REQ_BLOCK_PC, /* queued down pc from block layer */ + __REQ_SENSE, /* sense retrival */ + + __REQ_FAILED, /* set if the request failed */ + __REQ_QUIET, /* don't worry about errors */ + __REQ_SPECIAL, /* driver suplied command */ + __REQ_DRIVE_CMD, + __REQ_DRIVE_TASK, + __REQ_DRIVE_TASKFILE, + __REQ_PREEMPT, /* set for "ide_preempt" requests */ + __REQ_PM_SUSPEND, /* suspend request */ + __REQ_PM_RESUME, /* resume request */ + __REQ_PM_SHUTDOWN, /* shutdown request */ + __REQ_ORDERED_COLOR, /* is before or after barrier */ + __REQ_NR_BITS, /* stops here */ +}; + +#define REQ_RW (1 << __REQ_RW) +#define REQ_FAILFAST (1 << __REQ_FAILFAST) +#define REQ_SORTED (1 << __REQ_SORTED) +#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) +#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) +#define REQ_FUA (1 << __REQ_FUA) +#define REQ_CMD (1 << __REQ_CMD) +#define REQ_NOMERGE (1 << __REQ_NOMERGE) +#define REQ_STARTED (1 << __REQ_STARTED) +#define REQ_DONTPREP (1 << __REQ_DONTPREP) +#define REQ_QUEUED (1 << __REQ_QUEUED) +#define REQ_ELVPRIV (1 << __REQ_ELVPRIV) +#define REQ_PC (1 << __REQ_PC) +#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC) +#define REQ_SENSE (1 << __REQ_SENSE) +#define REQ_FAILED (1 << __REQ_FAILED) +#define REQ_QUIET (1 << __REQ_QUIET) +#define REQ_SPECIAL (1 << __REQ_SPECIAL) +#define REQ_DRIVE_CMD (1 << __REQ_DRIVE_CMD) +#define REQ_DRIVE_TASK (1 << __REQ_DRIVE_TASK) +#define REQ_DRIVE_TASKFILE (1 << __REQ_DRIVE_TASKFILE) +#define REQ_PREEMPT (1 << __REQ_PREEMPT) +#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) +#define REQ_PM_RESUME (1 << __REQ_PM_RESUME) +#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) +#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) + + +#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) +#define rq_data_dir(rq) ((rq)->cmd_flags & 1) + +#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) + +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_alloc_queue(gfp_t); +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_make_request(request_queue_t *, make_request_fn *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_hardsect_size(request_queue_t *, unsigned short); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_cleanup_queue(request_queue_t *); +// DDV: TODO +void blk_put_queue(request_queue_t *); + + +// DDV: TODO +void blk_plug_device(request_queue_t *); +// DDV: TODO +int blk_remove_plug(request_queue_t *); + +// DDV: TODO +void blkdev_dequeue_request(struct request *req); + +// DDV: TODO +int end_that_request_first(struct request *, int, int); +// DDV: TODO +int end_that_request_chunk(struct request *, int, int); +// DDV: TODO +void end_that_request_last(struct request *, int); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void end_request(struct request *req, int uptodate); +// DDV: TODO +void blk_complete_request(struct request *); + +// DDV: TODO +void blk_queue_bounce_limit(request_queue_t *, u64); + +// DDV: TODO +void blk_queue_max_phys_segments(request_queue_t *, unsigned short); +// DDV: TODO +void blk_queue_max_hw_segments(request_queue_t *, unsigned short); + +// DDV: TODO +int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); + +#define rq_for_each_bio(_bio, rq) \ + if ((rq->bio)) \ + for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next) + +#endif diff --git a/ddverify/models/seq1/include/linux/blkpg.h b/ddverify/models/seq1/include/linux/blkpg.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/blktrace_api.h b/ddverify/models/seq1/include/linux/blktrace_api.h new file mode 100644 index 000000000..4a4b02e12 --- /dev/null +++ b/ddverify/models/seq1/include/linux/blktrace_api.h @@ -0,0 +1,141 @@ +#ifndef BLKTRACE_H +#define BLKTRACE_H + +#include +//#include + +/* + * Trace categories + */ +enum blktrace_cat { + BLK_TC_READ = 1 << 0, /* reads */ + BLK_TC_WRITE = 1 << 1, /* writes */ + BLK_TC_BARRIER = 1 << 2, /* barrier */ + BLK_TC_SYNC = 1 << 3, /* sync IO */ + BLK_TC_QUEUE = 1 << 4, /* queueing/merging */ + BLK_TC_REQUEUE = 1 << 5, /* requeueing */ + BLK_TC_ISSUE = 1 << 6, /* issue */ + BLK_TC_COMPLETE = 1 << 7, /* completions */ + BLK_TC_FS = 1 << 8, /* fs requests */ + BLK_TC_PC = 1 << 9, /* pc requests */ + BLK_TC_NOTIFY = 1 << 10, /* special message */ + BLK_TC_AHEAD = 1 << 11, /* readahead */ + BLK_TC_META = 1 << 12, /* metadata */ + + BLK_TC_END = 1 << 15, /* only 16-bits, reminder */ +}; + +#define BLK_TC_SHIFT (16) +#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT) + +/* + * Basic trace actions + */ +enum blktrace_act { + __BLK_TA_QUEUE = 1, /* queued */ + __BLK_TA_BACKMERGE, /* back merged to existing rq */ + __BLK_TA_FRONTMERGE, /* front merge to existing rq */ + __BLK_TA_GETRQ, /* allocated new request */ + __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */ + __BLK_TA_REQUEUE, /* request requeued */ + __BLK_TA_ISSUE, /* sent to driver */ + __BLK_TA_COMPLETE, /* completed by driver */ + __BLK_TA_PLUG, /* queue was plugged */ + __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */ + __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */ + __BLK_TA_INSERT, /* insert request */ + __BLK_TA_SPLIT, /* bio was split */ + __BLK_TA_BOUNCE, /* bio was bounced */ + __BLK_TA_REMAP, /* bio was remapped */ +}; + +/* + * Trace actions in full. Additionally, read or write is masked + */ +#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE)) +#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE)) +#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE)) +#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SPLIT (__BLK_TA_SPLIT) +#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) +#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) + +#define BLK_IO_TRACE_MAGIC 0x65617400 +#define BLK_IO_TRACE_VERSION 0x07 + +/* + * The trace itself + */ +struct blk_io_trace { + u32 magic; /* MAGIC << 8 | version */ + u32 sequence; /* event number */ + u64 time; /* in microseconds */ + u64 sector; /* disk offset */ + u32 bytes; /* transfer length */ + u32 action; /* what happened */ + u32 pid; /* who did it */ + u32 device; /* device number */ + u32 cpu; /* on what cpu did it happen */ + u16 error; /* completion error */ + u16 pdu_len; /* length of data after this trace */ +}; + +/* + * The remap event + */ +struct blk_io_trace_remap { + __be32 device; + u32 __pad; + __be64 sector; +}; + +enum { + Blktrace_setup = 1, + Blktrace_running, + Blktrace_stopped, +}; + +struct blk_trace { + int trace_state; + struct rchan *rchan; + unsigned long *sequence; + u16 act_mask; + u64 start_lba; + u64 end_lba; + u32 pid; + u32 dev; + struct dentry *dir; + struct dentry *dropped_file; + atomic_t dropped; +}; + +/* + * User setup structure passed with BLKTRACESTART + */ +struct blk_user_trace_setup { + char name[BDEVNAME_SIZE]; /* output */ + u16 act_mask; /* input */ + u32 buf_size; /* input */ + u32 buf_nr; /* input */ + u64 start_lba; + u64 end_lba; + u32 pid; +}; + +#define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) +#define blk_trace_shutdown(q) do { } while (0) +#define blk_add_trace_rq(q, rq, what) do { } while (0) +#define blk_add_trace_bio(q, rq, what) do { } while (0) +#define blk_add_trace_generic(q, rq, rw, what) do { } while (0) +#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0) +#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0) + +#endif diff --git a/ddverify/models/seq1/include/linux/buffer_head.h b/ddverify/models/seq1/include/linux/buffer_head.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/byteorder/generic.h b/ddverify/models/seq1/include/linux/byteorder/generic.h new file mode 100644 index 000000000..4dd8f5fb9 --- /dev/null +++ b/ddverify/models/seq1/include/linux/byteorder/generic.h @@ -0,0 +1,46 @@ +#ifndef _LINUX_BYTEORDER_GENERIC_H +#define _LINUX_BYTEORDER_GENERIC_H + +#define cpu_to_le64 __cpu_to_le64 +#define le64_to_cpu __le64_to_cpu +#define cpu_to_le32 __cpu_to_le32 +#define le32_to_cpu __le32_to_cpu +#define cpu_to_le16 __cpu_to_le16 +#define le16_to_cpu __le16_to_cpu +#define cpu_to_be64 __cpu_to_be64 +#define be64_to_cpu __be64_to_cpu +#define cpu_to_be32 __cpu_to_be32 +#define be32_to_cpu __be32_to_cpu +#define cpu_to_be16 __cpu_to_be16 +#define be16_to_cpu __be16_to_cpu +#define cpu_to_le64p __cpu_to_le64p +#define le64_to_cpup __le64_to_cpup +#define cpu_to_le32p __cpu_to_le32p +#define le32_to_cpup __le32_to_cpup +#define cpu_to_le16p __cpu_to_le16p +#define le16_to_cpup __le16_to_cpup +#define cpu_to_be64p __cpu_to_be64p +#define be64_to_cpup __be64_to_cpup +#define cpu_to_be32p __cpu_to_be32p +#define be32_to_cpup __be32_to_cpup +#define cpu_to_be16p __cpu_to_be16p +#define be16_to_cpup __be16_to_cpup +#define cpu_to_le64s __cpu_to_le64s +#define le64_to_cpus __le64_to_cpus +#define cpu_to_le32s __cpu_to_le32s +#define le32_to_cpus __le32_to_cpus +#define cpu_to_le16s __cpu_to_le16s +#define le16_to_cpus __le16_to_cpus +#define cpu_to_be64s __cpu_to_be64s +#define be64_to_cpus __be64_to_cpus +#define cpu_to_be32s __cpu_to_be32s +#define be32_to_cpus __be32_to_cpus +#define cpu_to_be16s __cpu_to_be16s +#define be16_to_cpus __be16_to_cpus + +#define htonl(x) x +#define ntohl(x) x +#define htons(x) x +#define ntohs(x) x + +#endif /* _LINUX_BYTEORDER_GENERIC_H */ diff --git a/ddverify/models/seq1/include/linux/byteorder/little_endian.h b/ddverify/models/seq1/include/linux/byteorder/little_endian.h new file mode 100644 index 000000000..9925e2e4e --- /dev/null +++ b/ddverify/models/seq1/include/linux/byteorder/little_endian.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H +#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H + +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN 1234 +#endif +#ifndef __LITTLE_ENDIAN_BITFIELD +#define __LITTLE_ENDIAN_BITFIELD +#endif + +#include +//#include + + +#define __cpu_to_le64(x) x +#define __le64_to_cpu(x) x +#define __cpu_to_le32(x) x +#define __le32_to_cpu(x) x +#define __cpu_to_le16(x) x +#define __le16_to_cpu(x) x +#define __cpu_to_be64(x) x +#define __be64_to_cpu(x) x +#define __cpu_to_be32(x) x +#define __be32_to_cpu(x) x +#define __cpu_to_be16(x) x +#define __be16_to_cpu(x) x + +#include + +#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ diff --git a/ddverify/models/seq1/include/linux/cache.h b/ddverify/models/seq1/include/linux/cache.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/capability.h b/ddverify/models/seq1/include/linux/capability.h new file mode 100644 index 000000000..2d039b6e8 --- /dev/null +++ b/ddverify/models/seq1/include/linux/capability.h @@ -0,0 +1,244 @@ +/* + * This is + * + * Andrew G. Morgan + * Alexander Kjeldaas + * with help from Aleph1, Roland Buresund and Andrew Main. + * + * See here for the libcap library ("POSIX draft" compliance): + * + * ftp://linux.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.2/ + */ + +#ifndef _LINUX_CAPABILITY_H +#define _LINUX_CAPABILITY_H + +#include +#include + +/** + ** POSIX-draft defined capabilities. + **/ + +/* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this + overrides the restriction of changing file ownership and group + ownership. */ + +#define CAP_CHOWN 0 + +/* Override all DAC access, including ACL execute access if + [_POSIX_ACL] is defined. Excluding DAC access covered by + CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_OVERRIDE 1 + +/* Overrides all DAC restrictions regarding read and search on files + and directories, including ACL restrictions if [_POSIX_ACL] is + defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_READ_SEARCH 2 + +/* Overrides all restrictions about allowed operations on files, where + file owner ID must be equal to the user ID, except where CAP_FSETID + is applicable. It doesn't override MAC and DAC restrictions. */ + +#define CAP_FOWNER 3 + +/* Overrides the following restrictions that the effective user ID + shall match the file owner ID when setting the S_ISUID and S_ISGID + bits on that file; that the effective group ID (or one of the + supplementary group IDs) shall match the file owner ID when setting + the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are + cleared on successful return from chown(2) (not implemented). */ + +#define CAP_FSETID 4 + +/* Used to decide between falling back on the old suser() or fsuser(). */ + +#define CAP_FS_MASK 0x1f + +/* Overrides the restriction that the real or effective user ID of a + process sending a signal must match the real or effective user ID + of the process receiving the signal. */ + +#define CAP_KILL 5 + +/* Allows setgid(2) manipulation */ +/* Allows setgroups(2) */ +/* Allows forged gids on socket credentials passing. */ + +#define CAP_SETGID 6 + +/* Allows set*uid(2) manipulation (including fsuid). */ +/* Allows forged pids on socket credentials passing. */ + +#define CAP_SETUID 7 + + +/** + ** Linux-specific capabilities + **/ + +/* Transfer any capability in your permitted set to any pid, + remove any capability in your permitted set from any pid */ + +#define CAP_SETPCAP 8 + +/* Allow modification of S_IMMUTABLE and S_APPEND file attributes */ + +#define CAP_LINUX_IMMUTABLE 9 + +/* Allows binding to TCP/UDP sockets below 1024 */ +/* Allows binding to ATM VCIs below 32 */ + +#define CAP_NET_BIND_SERVICE 10 + +/* Allow broadcasting, listen to multicast */ + +#define CAP_NET_BROADCAST 11 + +/* Allow interface configuration */ +/* Allow administration of IP firewall, masquerading and accounting */ +/* Allow setting debug option on sockets */ +/* Allow modification of routing tables */ +/* Allow setting arbitrary process / process group ownership on + sockets */ +/* Allow binding to any address for transparent proxying */ +/* Allow setting TOS (type of service) */ +/* Allow setting promiscuous mode */ +/* Allow clearing driver statistics */ +/* Allow multicasting */ +/* Allow read/write of device-specific registers */ +/* Allow activation of ATM control sockets */ + +#define CAP_NET_ADMIN 12 + +/* Allow use of RAW sockets */ +/* Allow use of PACKET sockets */ + +#define CAP_NET_RAW 13 + +/* Allow locking of shared memory segments */ +/* Allow mlock and mlockall (which doesn't really have anything to do + with IPC) */ + +#define CAP_IPC_LOCK 14 + +/* Override IPC ownership checks */ + +#define CAP_IPC_OWNER 15 + +/* Insert and remove kernel modules - modify kernel without limit */ +/* Modify cap_bset */ +#define CAP_SYS_MODULE 16 + +/* Allow ioperm/iopl access */ +/* Allow sending USB messages to any device via /proc/bus/usb */ + +#define CAP_SYS_RAWIO 17 + +/* Allow use of chroot() */ + +#define CAP_SYS_CHROOT 18 + +/* Allow ptrace() of any process */ + +#define CAP_SYS_PTRACE 19 + +/* Allow configuration of process accounting */ + +#define CAP_SYS_PACCT 20 + +/* Allow configuration of the secure attention key */ +/* Allow administration of the random device */ +/* Allow examination and configuration of disk quotas */ +/* Allow configuring the kernel's syslog (printk behaviour) */ +/* Allow setting the domainname */ +/* Allow setting the hostname */ +/* Allow calling bdflush() */ +/* Allow mount() and umount(), setting up new smb connection */ +/* Allow some autofs root ioctls */ +/* Allow nfsservctl */ +/* Allow VM86_REQUEST_IRQ */ +/* Allow to read/write pci config on alpha */ +/* Allow irix_prctl on mips (setstacksize) */ +/* Allow flushing all cache on m68k (sys_cacheflush) */ +/* Allow removing semaphores */ +/* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores + and shared memory */ +/* Allow locking/unlocking of shared memory segment */ +/* Allow turning swap on/off */ +/* Allow forged pids on socket credentials passing */ +/* Allow setting readahead and flushing buffers on block devices */ +/* Allow setting geometry in floppy driver */ +/* Allow turning DMA on/off in xd driver */ +/* Allow administration of md devices (mostly the above, but some + extra ioctls) */ +/* Allow tuning the ide driver */ +/* Allow access to the nvram device */ +/* Allow administration of apm_bios, serial and bttv (TV) device */ +/* Allow manufacturer commands in isdn CAPI support driver */ +/* Allow reading non-standardized portions of pci configuration space */ +/* Allow DDI debug ioctl on sbpcd driver */ +/* Allow setting up serial ports */ +/* Allow sending raw qic-117 commands */ +/* Allow enabling/disabling tagged queuing on SCSI controllers and sending + arbitrary SCSI commands */ +/* Allow setting encryption key on loopback filesystem */ +/* Allow setting zone reclaim policy */ + +#define CAP_SYS_ADMIN 21 + +/* Allow use of reboot() */ + +#define CAP_SYS_BOOT 22 + +/* Allow raising priority and setting priority on other (different + UID) processes */ +/* Allow use of FIFO and round-robin (realtime) scheduling on own + processes and setting the scheduling algorithm used by another + process. */ +/* Allow setting cpu affinity on other processes */ + +#define CAP_SYS_NICE 23 + +/* Override resource limits. Set resource limits. */ +/* Override quota limits. */ +/* Override reserved space on ext2 filesystem */ +/* Modify data journaling mode on ext3 filesystem (uses journaling + resources) */ +/* NOTE: ext2 honors fsuid when checking for resource overrides, so + you can override using fsuid too */ +/* Override size restrictions on IPC message queues */ +/* Allow more than 64hz interrupts from the real-time clock */ +/* Override max number of consoles on console allocation */ +/* Override max number of keymaps */ + +#define CAP_SYS_RESOURCE 24 + +/* Allow manipulation of system clock */ +/* Allow irix_stime on mips */ +/* Allow setting the real-time clock */ + +#define CAP_SYS_TIME 25 + +/* Allow configuration of tty devices */ +/* Allow vhangup() of tty */ + +#define CAP_SYS_TTY_CONFIG 26 + +/* Allow the privileged aspects of mknod() */ + +#define CAP_MKNOD 27 + +/* Allow taking of leases on files */ + +#define CAP_LEASE 28 + +#define CAP_AUDIT_WRITE 29 + +#define CAP_AUDIT_CONTROL 30 + +int capable(int cap); + +#endif /* !_LINUX_CAPABILITY_H */ diff --git a/ddverify/models/seq1/include/linux/cdev.h b/ddverify/models/seq1/include/linux/cdev.h new file mode 100644 index 000000000..92608a6ff --- /dev/null +++ b/ddverify/models/seq1/include/linux/cdev.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_CDEV_H +#define _LINUX_CDEV_H + +struct cdev { + struct module *owner; + struct file_operations *ops; + dev_t dev; + unsigned int count; +}; + +void cdev_init(struct cdev *, struct file_operations *); + +struct cdev *cdev_alloc(void); + +void cdev_put(struct cdev *p); + +int cdev_add(struct cdev *, dev_t, unsigned); + +void cdev_del(struct cdev *); + +void cd_forget(struct inode *); + +#endif diff --git a/ddverify/models/seq1/include/linux/cdrom.h b/ddverify/models/seq1/include/linux/cdrom.h new file mode 100644 index 000000000..b68fdf1f3 --- /dev/null +++ b/ddverify/models/seq1/include/linux/cdrom.h @@ -0,0 +1,1192 @@ +/* + * -- + * General header file for linux CD-ROM drivers + * Copyright (C) 1992 David Giller, rafetmad@oxy.edu + * 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de + * 1996 David van Leeuwen, david@tm.tno.nl + * 1997, 1998 Erik Andersen, andersee@debian.org + * 1998-2002 Jens Axboe, axboe@suse.de + */ + +#ifndef _LINUX_CDROM_H +#define _LINUX_CDROM_H + +#include + +/******************************************************* + * As of Linux 2.1.x, all Linux CD-ROM application programs will use this + * (and only this) include file. It is my hope to provide Linux with + * a uniform interface between software accessing CD-ROMs and the various + * device drivers that actually talk to the drives. There may still be + * 23 different kinds of strange CD-ROM drives, but at least there will + * now be one, and only one, Linux CD-ROM interface. + * + * Additionally, as of Linux 2.1.x, all Linux application programs + * should use the O_NONBLOCK option when opening a CD-ROM device + * for subsequent ioctl commands. This allows for neat system errors + * like "No medium found" or "Wrong medium type" upon attempting to + * mount or play an empty slot, mount an audio disc, or play a data disc. + * Generally, changing an application program to support O_NONBLOCK + * is as easy as the following: + * - drive = open("/dev/cdrom", O_RDONLY); + * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); + * It is worth the small change. + * + * Patches for many common CD programs (provided by David A. van Leeuwen) + * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/ + * + *******************************************************/ + +/* When a driver supports a certain function, but the cdrom drive we are + * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will + * borrow the "Operation not supported" error from the network folks to + * accomplish this. Maybe someday we will get a more targeted error code, + * but this will do for now... */ +#define EDRIVE_CANT_DO_THIS EOPNOTSUPP + +/******************************************************* + * The CD-ROM IOCTL commands -- these should be supported by + * all the various cdrom drivers. For the CD-ROM ioctls, we + * will commandeer byte 0x53, or 'S'. + *******************************************************/ +#define CDROMPAUSE 0x5301 /* Pause Audio Operation */ +#define CDROMRESUME 0x5302 /* Resume paused Audio Operation */ +#define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ +#define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index + (struct cdrom_ti) */ +#define CDROMREADTOCHDR 0x5305 /* Read TOC header + (struct cdrom_tochdr) */ +#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry + (struct cdrom_tocentry) */ +#define CDROMSTOP 0x5307 /* Stop the cdrom drive */ +#define CDROMSTART 0x5308 /* Start the cdrom drive */ +#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ +#define CDROMVOLCTRL 0x530a /* Control output volume + (struct cdrom_volctrl) */ +#define CDROMSUBCHNL 0x530b /* Read subchannel data + (struct cdrom_subchnl) */ +#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) + (struct cdrom_read) */ +#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) + (struct cdrom_read) */ +#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ +#define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ +#define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session + address of multi session disks + (struct cdrom_multisession) */ +#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" + if available (struct cdrom_mcn) */ +#define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated, + but here anyway for compatibility */ +#define CDROMRESET 0x5312 /* hard-reset the drive */ +#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting + (struct cdrom_volctrl) */ +#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) + (struct cdrom_read) */ +/* + * These ioctls are used only used in aztcd.c and optcd.c + */ +#define CDROMREADCOOKED 0x5315 /* read data in cooked mode */ +#define CDROMSEEK 0x5316 /* seek msf address */ + +/* + * This ioctl is only used by the scsi-cd driver. + It is for playing audio in logical block addressing mode. + */ +#define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ + +/* + * These ioctls are only used in optcd.c + */ +#define CDROMREADALL 0x5318 /* read all 2646 bytes */ + +/* + * These ioctls are (now) only in ide-cd.c for controlling + * drive spindown time. They should be implemented in the + * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, + * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... + * -Erik + */ +#define CDROMGETSPINDOWN 0x531d +#define CDROMSETSPINDOWN 0x531e + +/* + * These ioctls are implemented through the uniform CD-ROM driver + * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM + * drivers are eventually ported to the uniform CD-ROM driver interface. + */ +#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ +#define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */ +#define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */ +#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ +#define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */ +#define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */ +#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ +#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ +#define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */ +#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */ +#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */ +#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ + +/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386. + * Future CDROM ioctls should be kept below 0x537F + */ + +/* This ioctl is only used by sbpcd at the moment */ +#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ + /* conflict with SCSI_IOCTL_GET_IDLUN */ + +/* DVD-ROM Specific ioctls */ +#define DVD_READ_STRUCT 0x5390 /* Read structure */ +#define DVD_WRITE_STRUCT 0x5391 /* Write structure */ +#define DVD_AUTH 0x5392 /* Authentication */ + +#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */ +#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */ +#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */ + +/******************************************************* + * CDROM IOCTL structures + *******************************************************/ + +/* Address in MSF format */ +struct cdrom_msf0 +{ + __u8 minute; + __u8 second; + __u8 frame; +}; + +/* Address in either MSF or logical format */ +union cdrom_addr +{ + struct cdrom_msf0 msf; + int lba; +}; + +/* This struct is used by the CDROMPLAYMSF ioctl */ +struct cdrom_msf +{ + __u8 cdmsf_min0; /* start minute */ + __u8 cdmsf_sec0; /* start second */ + __u8 cdmsf_frame0; /* start frame */ + __u8 cdmsf_min1; /* end minute */ + __u8 cdmsf_sec1; /* end second */ + __u8 cdmsf_frame1; /* end frame */ +}; + +/* This struct is used by the CDROMPLAYTRKIND ioctl */ +struct cdrom_ti +{ + __u8 cdti_trk0; /* start track */ + __u8 cdti_ind0; /* start index */ + __u8 cdti_trk1; /* end track */ + __u8 cdti_ind1; /* end index */ +}; + +/* This struct is used by the CDROMREADTOCHDR ioctl */ +struct cdrom_tochdr +{ + __u8 cdth_trk0; /* start track */ + __u8 cdth_trk1; /* end track */ +}; + +/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */ +struct cdrom_volctrl +{ + __u8 channel0; + __u8 channel1; + __u8 channel2; + __u8 channel3; +}; + +/* This struct is used by the CDROMSUBCHNL ioctl */ +struct cdrom_subchnl +{ + __u8 cdsc_format; + __u8 cdsc_audiostatus; + __u8 cdsc_adr: 4; + __u8 cdsc_ctrl: 4; + __u8 cdsc_trk; + __u8 cdsc_ind; + union cdrom_addr cdsc_absaddr; + union cdrom_addr cdsc_reladdr; +}; + + +/* This struct is used by the CDROMREADTOCENTRY ioctl */ +struct cdrom_tocentry +{ + __u8 cdte_track; + __u8 cdte_adr :4; + __u8 cdte_ctrl :4; + __u8 cdte_format; + union cdrom_addr cdte_addr; + __u8 cdte_datamode; +}; + +/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */ +struct cdrom_read +{ + int cdread_lba; + char *cdread_bufaddr; + int cdread_buflen; +}; + +/* This struct is used by the CDROMREADAUDIO ioctl */ +struct cdrom_read_audio +{ + union cdrom_addr addr; /* frame address */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ + int nframes; /* number of 2352-byte-frames to read at once */ + __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */ +}; + +/* This struct is used with the CDROMMULTISESSION ioctl */ +struct cdrom_multisession +{ + union cdrom_addr addr; /* frame address: start-of-last-session + (not the new "frame 16"!). Only valid + if the "xa_flag" is true. */ + __u8 xa_flag; /* 1: "is XA disk" */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ +}; + +/* This struct is used with the CDROM_GET_MCN ioctl. + * Very few audio discs actually have Universal Product Code information, + * which should just be the Medium Catalog Number on the box. Also note + * that the way the codeis written on CD is _not_ uniform across all discs! + */ +struct cdrom_mcn +{ + __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */ +}; + +/* This is used by the CDROMPLAYBLK ioctl */ +struct cdrom_blk +{ + unsigned from; + unsigned short len; +}; + +#define CDROM_PACKET_SIZE 12 + +#define CGC_DATA_UNKNOWN 0 +#define CGC_DATA_WRITE 1 +#define CGC_DATA_READ 2 +#define CGC_DATA_NONE 3 + +/* for CDROM_PACKET_COMMAND ioctl */ +struct cdrom_generic_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char __user *buffer; + unsigned int buflen; + int stat; + struct request_sense __user *sense; + unsigned char data_direction; + int quiet; + int timeout; + void __user *reserved[1]; /* unused, actually */ +}; + +/* + * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, + * 2340, or 2352 bytes long. + +* Sector types of the standard CD-ROM data formats: + * + * format sector type user data size (bytes) + * ----------------------------------------------------------------------------- + * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW) + * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE) + * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0) + * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE) + * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes) + * + * + * The layout of the standard CD-ROM data formats: + * ----------------------------------------------------------------------------- + * - audio (red): | audio_sample_bytes | + * | 2352 | + * + * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC | + * | 12 - 4 - 2048 - 4 - 8 - 276 | + * + * - data (yellow, mode2): | sync - head - data | + * | 12 - 4 - 2336 | + * + * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC | + * | 12 - 4 - 8 - 2048 - 4 - 276 | + * + * - XA data (green, mode2 form2): | sync - head - sub - data - Spare | + * | 12 - 4 - 8 - 2324 - 4 | + * + */ + +/* Some generally useful CD-ROM information -- mostly based on the above */ +#define CD_MINS 74 /* max. minutes per CD, not really a limit */ +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ +#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ +#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ +#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ +#define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */ +#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ +#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */ +#define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */ +#define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */ +#define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */ +#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ +#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ +/* most drives don't deliver everything: */ +#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ +#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ + +#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */ +#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */ +#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */ + +/* CD-ROM address types (cdrom_tocentry.cdte_format) */ +#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ +#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ + +/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ +#define CDROM_DATA_TRACK 0x04 + +/* The leadout track is always 0xAA, regardless of # of tracks on disc */ +#define CDROM_LEADOUT 0xAA + +/* audio states (from SCSI-2, but seen with other drives, too) */ +#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ +#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ +#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ +#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ +#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ +#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ + +/* capability flags used with the uniform CD-ROM driver */ +#define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */ +#define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */ +#define CDC_LOCK 0x4 /* disable manual eject */ +#define CDC_SELECT_SPEED 0x8 /* programmable speed */ +#define CDC_SELECT_DISC 0x10 /* select disc from juke-box */ +#define CDC_MULTI_SESSION 0x20 /* read sessions>1 */ +#define CDC_MCN 0x40 /* Medium Catalog Number */ +#define CDC_MEDIA_CHANGED 0x80 /* media changed */ +#define CDC_PLAY_AUDIO 0x100 /* audio functions */ +#define CDC_RESET 0x200 /* hard reset device */ +#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */ +#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ +#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ +#define CDC_CD_R 0x2000 /* drive is a CD-R */ +#define CDC_CD_RW 0x4000 /* drive is a CD-RW */ +#define CDC_DVD 0x8000 /* drive is a DVD */ +#define CDC_DVD_R 0x10000 /* drive can write DVD-R */ +#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */ +#define CDC_MO_DRIVE 0x40000 /* drive is an MO device */ +#define CDC_MRW 0x80000 /* drive can read MRW */ +#define CDC_MRW_W 0x100000 /* drive can write MRW */ +#define CDC_RAM 0x200000 /* ok to open for WRITE */ + +/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ +#define CDS_NO_INFO 0 /* if not implemented */ +#define CDS_NO_DISC 1 +#define CDS_TRAY_OPEN 2 +#define CDS_DRIVE_NOT_READY 3 +#define CDS_DISC_OK 4 + +/* return values for the CDROM_DISC_STATUS ioctl */ +/* can also return CDS_NO_[INFO|DISC], from above */ +#define CDS_AUDIO 100 +#define CDS_DATA_1 101 +#define CDS_DATA_2 102 +#define CDS_XA_2_1 103 +#define CDS_XA_2_2 104 +#define CDS_MIXED 105 + +/* User-configurable behavior options for the uniform CD-ROM driver */ +#define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */ +#define CDO_AUTO_EJECT 0x2 /* open tray on last release() */ +#define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */ +#define CDO_LOCK 0x8 /* lock tray on open files */ +#define CDO_CHECK_TYPE 0x10 /* check type on open for data */ + +/* Special codes used when specifying changer slots. */ +#define CDSL_NONE ((int) (~0U>>1)-1) +#define CDSL_CURRENT ((int) (~0U>>1)) + +/* For partition based multisession access. IDE can handle 64 partitions + * per drive - SCSI CD-ROM's use minors to differentiate between the + * various drives, so we can't do multisessions the same way there. + * Use the -o session=x option to mount on them. + */ +#define CD_PART_MAX 64 +#define CD_PART_MASK (CD_PART_MAX - 1) + +/********************************************************************* + * Generic Packet commands, MMC commands, and such + *********************************************************************/ + + /* The generic packet command opcodes for CD/DVD Logical Units, + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +#define GPCMD_BLANK 0xa1 +#define GPCMD_CLOSE_TRACK 0x5b +#define GPCMD_FLUSH_CACHE 0x35 +#define GPCMD_FORMAT_UNIT 0x04 +#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a +#define GPCMD_GET_PERFORMANCE 0xac +#define GPCMD_INQUIRY 0x12 +#define GPCMD_LOAD_UNLOAD 0xa6 +#define GPCMD_MECHANISM_STATUS 0xbd +#define GPCMD_MODE_SELECT_10 0x55 +#define GPCMD_MODE_SENSE_10 0x5a +#define GPCMD_PAUSE_RESUME 0x4b +#define GPCMD_PLAY_AUDIO_10 0x45 +#define GPCMD_PLAY_AUDIO_MSF 0x47 +#define GPCMD_PLAY_AUDIO_TI 0x48 +#define GPCMD_PLAY_CD 0xbc +#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e +#define GPCMD_READ_10 0x28 +#define GPCMD_READ_12 0xa8 +#define GPCMD_READ_BUFFER_CAPACITY 0x5c +#define GPCMD_READ_CDVD_CAPACITY 0x25 +#define GPCMD_READ_CD 0xbe +#define GPCMD_READ_CD_MSF 0xb9 +#define GPCMD_READ_DISC_INFO 0x51 +#define GPCMD_READ_DVD_STRUCTURE 0xad +#define GPCMD_READ_FORMAT_CAPACITIES 0x23 +#define GPCMD_READ_HEADER 0x44 +#define GPCMD_READ_TRACK_RZONE_INFO 0x52 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_REPAIR_RZONE_TRACK 0x58 +#define GPCMD_REPORT_KEY 0xa4 +#define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_RESERVE_RZONE_TRACK 0x53 +#define GPCMD_SEND_CUE_SHEET 0x5d +#define GPCMD_SCAN 0xba +#define GPCMD_SEEK 0x2b +#define GPCMD_SEND_DVD_STRUCTURE 0xbf +#define GPCMD_SEND_EVENT 0xa2 +#define GPCMD_SEND_KEY 0xa3 +#define GPCMD_SEND_OPC 0x54 +#define GPCMD_SET_READ_AHEAD 0xa7 +#define GPCMD_SET_STREAMING 0xb6 +#define GPCMD_START_STOP_UNIT 0x1b +#define GPCMD_STOP_PLAY_SCAN 0x4e +#define GPCMD_TEST_UNIT_READY 0x00 +#define GPCMD_VERIFY_10 0x2f +#define GPCMD_WRITE_10 0x2a +#define GPCMD_WRITE_AND_VERIFY_10 0x2e +/* This is listed as optional in ATAPI 2.6, but is (curiously) + * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji + * Table 377 as an MMC command for SCSi devices though... Most ATAPI + * drives support it. */ +#define GPCMD_SET_SPEED 0xbb +/* This seems to be a SCSI specific CD-ROM opcode + * to play data at track/index */ +#define GPCMD_PLAYAUDIO_TI 0x48 +/* + * From MS Media Status Notification Support Specification. For + * older drives only. + */ +#define GPCMD_GET_MEDIA_STATUS 0xda + +/* Mode page codes for mode sense/set */ +#define GPMODE_VENDOR_PAGE 0x00 +#define GPMODE_R_W_ERROR_PAGE 0x01 +#define GPMODE_WRITE_PARMS_PAGE 0x05 +#define GPMODE_WCACHING_PAGE 0x08 +#define GPMODE_AUDIO_CTL_PAGE 0x0e +#define GPMODE_POWER_PAGE 0x1a +#define GPMODE_FAULT_FAIL_PAGE 0x1c +#define GPMODE_TO_PROTECT_PAGE 0x1d +#define GPMODE_CAPABILITIES_PAGE 0x2a +#define GPMODE_ALL_PAGES 0x3f +/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor + * of MODE_SENSE_POWER_PAGE */ +#define GPMODE_CDROM_PAGE 0x0d + + + +/* DVD struct types */ +#define DVD_STRUCT_PHYSICAL 0x00 +#define DVD_STRUCT_COPYRIGHT 0x01 +#define DVD_STRUCT_DISCKEY 0x02 +#define DVD_STRUCT_BCA 0x03 +#define DVD_STRUCT_MANUFACT 0x04 + +struct dvd_layer { + __u8 book_version : 4; + __u8 book_type : 4; + __u8 min_rate : 4; + __u8 disc_size : 4; + __u8 layer_type : 4; + __u8 track_path : 1; + __u8 nlayers : 2; + __u8 track_density : 4; + __u8 linear_density : 4; + __u8 bca : 1; + __u32 start_sector; + __u32 end_sector; + __u32 end_sector_l0; +}; + +#define DVD_LAYERS 4 + +struct dvd_physical { + __u8 type; + __u8 layer_num; + struct dvd_layer layer[DVD_LAYERS]; +}; + +struct dvd_copyright { + __u8 type; + + __u8 layer_num; + __u8 cpst; + __u8 rmi; +}; + +struct dvd_disckey { + __u8 type; + + unsigned agid : 2; + __u8 value[2048]; +}; + +struct dvd_bca { + __u8 type; + + int len; + __u8 value[188]; +}; + +struct dvd_manufact { + __u8 type; + + __u8 layer_num; + int len; + __u8 value[2048]; +}; + +typedef union { + __u8 type; + + struct dvd_physical physical; + struct dvd_copyright copyright; + struct dvd_disckey disckey; + struct dvd_bca bca; + struct dvd_manufact manufact; +} dvd_struct; + +/* + * DVD authentication ioctl + */ + +/* Authentication states */ +#define DVD_LU_SEND_AGID 0 +#define DVD_HOST_SEND_CHALLENGE 1 +#define DVD_LU_SEND_KEY1 2 +#define DVD_LU_SEND_CHALLENGE 3 +#define DVD_HOST_SEND_KEY2 4 + +/* Termination states */ +#define DVD_AUTH_ESTABLISHED 5 +#define DVD_AUTH_FAILURE 6 + +/* Other functions */ +#define DVD_LU_SEND_TITLE_KEY 7 +#define DVD_LU_SEND_ASF 8 +#define DVD_INVALIDATE_AGID 9 +#define DVD_LU_SEND_RPC_STATE 10 +#define DVD_HOST_SEND_RPC_STATE 11 + +/* State data */ +typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ +typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ + +struct dvd_lu_send_agid { + __u8 type; + unsigned agid : 2; +}; + +struct dvd_host_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +struct dvd_send_key { + __u8 type; + unsigned agid : 2; + + dvd_key key; +}; + +struct dvd_lu_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +#define DVD_CPM_NO_COPYRIGHT 0 +#define DVD_CPM_COPYRIGHTED 1 + +#define DVD_CP_SEC_NONE 0 +#define DVD_CP_SEC_EXIST 1 + +#define DVD_CGMS_UNRESTRICTED 0 +#define DVD_CGMS_SINGLE 2 +#define DVD_CGMS_RESTRICTED 3 + +struct dvd_lu_send_title_key { + __u8 type; + unsigned agid : 2; + + dvd_key title_key; + int lba; + unsigned cpm : 1; + unsigned cp_sec : 1; + unsigned cgms : 2; +}; + +struct dvd_lu_send_asf { + __u8 type; + unsigned agid : 2; + + unsigned asf : 1; +}; + +struct dvd_host_send_rpcstate { + __u8 type; + __u8 pdrc; +}; + +struct dvd_lu_send_rpcstate { + __u8 type : 2; + __u8 vra : 3; + __u8 ucca : 3; + __u8 region_mask; + __u8 rpc_scheme; +}; + +typedef union { + __u8 type; + + struct dvd_lu_send_agid lsa; + struct dvd_host_send_challenge hsc; + struct dvd_send_key lsk; + struct dvd_lu_send_challenge lsc; + struct dvd_send_key hsk; + struct dvd_lu_send_title_key lstk; + struct dvd_lu_send_asf lsasf; + struct dvd_host_send_rpcstate hrpcs; + struct dvd_lu_send_rpcstate lrpcs; +} dvd_authinfo; + +struct request_sense { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 valid : 1; + __u8 error_code : 7; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 error_code : 7; + __u8 valid : 1; +#endif + __u8 segment_number; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 ili : 1; + __u8 reserved2 : 1; + __u8 sense_key : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 sense_key : 4; + __u8 reserved2 : 1; + __u8 ili : 1; + __u8 reserved1 : 2; +#endif + __u8 information[4]; + __u8 add_sense_len; + __u8 command_info[4]; + __u8 asc; + __u8 ascq; + __u8 fruc; + __u8 sks[3]; + __u8 asb[46]; +}; + +/* + * feature profile + */ +#define CDF_RWRT 0x0020 /* "Random Writable" */ +#define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ +#define CDF_MRW 0x0028 + +/* + * media status bits + */ +#define CDM_MRW_NOTMRW 0 +#define CDM_MRW_BGFORMAT_INACTIVE 1 +#define CDM_MRW_BGFORMAT_ACTIVE 2 +#define CDM_MRW_BGFORMAT_COMPLETE 3 + +/* + * mrw address spaces + */ +#define MRW_LBA_DMA 0 +#define MRW_LBA_GAA 1 + +/* + * mrw mode pages (first is deprecated) -- probed at init time and + * cdi->mrw_mode_page is set + */ +#define MRW_MODE_PC_PRE1 0x2c +#define MRW_MODE_PC 0x03 + +struct mrw_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 write : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 write : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; + __u8 reserved4; + __u8 reserved5; +}; + +/* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */ +struct rwrt_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; + __u32 last_lba; + __u32 block_size; + __u16 blocking; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 page_present : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_present : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; +}; + +typedef struct { + __u16 disc_information_length; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 3; + __u8 erasable : 1; + __u8 border_status : 2; + __u8 disc_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 disc_status : 2; + __u8 border_status : 2; + __u8 erasable : 1; + __u8 reserved1 : 3; +#else +#error "Please fix " +#endif + __u8 n_first_track; + __u8 n_sessions_lsb; + __u8 first_track_lsb; + __u8 last_track_lsb; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 did_v : 1; + __u8 dbc_v : 1; + __u8 uru : 1; + __u8 reserved2 : 2; + __u8 dbit : 1; + __u8 mrw_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 mrw_status : 2; + __u8 dbit : 1; + __u8 reserved2 : 2; + __u8 uru : 1; + __u8 dbc_v : 1; + __u8 did_v : 1; +#endif + __u8 disc_type; + __u8 n_sessions_msb; + __u8 first_track_msb; + __u8 last_track_msb; + __u32 disc_id; + __u32 lead_in; + __u32 lead_out; + __u8 disc_bar_code[8]; + __u8 reserved3; + __u8 n_opc; +} disc_information; + +typedef struct { + __u16 track_information_length; + __u8 track_lsb; + __u8 session_lsb; + __u8 reserved1; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 2; + __u8 damage : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 rt : 1; + __u8 blank : 1; + __u8 packet : 1; + __u8 fp : 1; + __u8 data_mode : 4; + __u8 reserved3 : 6; + __u8 lra_v : 1; + __u8 nwa_v : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 track_mode : 4; + __u8 copy : 1; + __u8 damage : 1; + __u8 reserved2 : 2; + __u8 data_mode : 4; + __u8 fp : 1; + __u8 packet : 1; + __u8 blank : 1; + __u8 rt : 1; + __u8 nwa_v : 1; + __u8 lra_v : 1; + __u8 reserved3 : 6; +#endif + __u32 track_start; + __u32 next_writable; + __u32 free_blocks; + __u32 fixed_packet_size; + __u32 track_size; + __u32 last_rec_address; +} track_information; + +struct feature_header { + __u32 data_len; + __u8 reserved1; + __u8 reserved2; + __u16 curr_profile; +}; + +struct mode_page_header { + __u16 mode_data_length; + __u8 medium_type; + __u8 reserved1; + __u8 reserved2; + __u8 reserved3; + __u16 desc_length; +}; + +#ifdef __KERNEL__ +#include /* not really needed, later.. */ +#include + +struct packet_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char *buffer; + unsigned int buflen; + int stat; + struct request_sense *sense; + unsigned char data_direction; + int quiet; + int timeout; + void *reserved[1]; +}; + +/* + * _OLD will use PIO transfer on atapi devices, _BPC_* will use DMA + */ +#define CDDA_OLD 0 /* old style */ +#define CDDA_BPC_SINGLE 1 /* single frame block pc */ +#define CDDA_BPC_FULL 2 /* multi frame block pc */ + +/* Uniform cdrom data structures for cdrom.c */ +struct cdrom_device_info { + struct cdrom_device_ops *ops; /* link to device_ops */ + struct cdrom_device_info *next; /* next device_info for this major */ + struct gendisk *disk; /* matching block layer disk */ + void *handle; /* driver-dependent data */ +/* specifications */ + int mask; /* mask of capability: disables them */ + int speed; /* maximum speed for reading data */ + int capacity; /* number of discs in jukebox */ +/* device-related storage */ + int options : 30; /* options flags */ + unsigned mc_flags : 2; /* media change buffer flags */ + int use_count; /* number of times device opened */ + char name[20]; /* name of the device type */ +/* per-device flags */ + __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ + __u8 reserved : 6; /* not used yet */ + int cdda_method; /* see flags */ + __u8 last_sense; + __u8 media_written; /* dirty flag, DVD+RW bookkeeping */ + unsigned short mmc3_profile; /* current MMC3 profile */ + int for_data; + int (*exit)(struct cdrom_device_info *); + int mrw_mode_page; +}; + +struct cdrom_device_ops { +/* routines */ + int (*open) (struct cdrom_device_info *, int); + void (*release) (struct cdrom_device_info *); + int (*drive_status) (struct cdrom_device_info *, int); + int (*media_changed) (struct cdrom_device_info *, int); + int (*tray_move) (struct cdrom_device_info *, int); + int (*lock_door) (struct cdrom_device_info *, int); + int (*select_speed) (struct cdrom_device_info *, int); + int (*select_disc) (struct cdrom_device_info *, int); + int (*get_last_session) (struct cdrom_device_info *, + struct cdrom_multisession *); + int (*get_mcn) (struct cdrom_device_info *, + struct cdrom_mcn *); + /* hard reset device */ + int (*reset) (struct cdrom_device_info *); + /* play stuff */ + int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *); + /* dev-specific */ + int (*dev_ioctl) (struct cdrom_device_info *, + unsigned int, unsigned long); +/* driver specifications */ + const int capability; /* capability flags */ + int n_minors; /* number of active minor devices */ + /* handle uniform packets for scsi type devices (scsi,atapi) */ + int (*generic_packet) (struct cdrom_device_info *, + struct packet_command *); +}; + +/* the general block_device operations structure: */ +extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, + struct file *fp); +extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp); +extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi, + struct inode *ip, unsigned int cmd, unsigned long arg); +extern int cdrom_media_changed(struct cdrom_device_info *); + +extern int register_cdrom(struct cdrom_device_info *cdi); +extern int unregister_cdrom(struct cdrom_device_info *cdi); + +typedef struct { + int data; + int audio; + int cdi; + int xa; + long error; +} tracktype; + +extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written); +extern int cdrom_number_of_slots(struct cdrom_device_info *cdi); +extern int cdrom_mode_select(struct cdrom_device_info *cdi, + struct packet_command *cgc); +extern int cdrom_mode_sense(struct cdrom_device_info *cdi, + struct packet_command *cgc, + int page_code, int page_control); +extern void init_cdrom_command(struct packet_command *cgc, + void *buffer, int len, int type); + +/* The SCSI spec says there could be 256 slots. */ +#define CDROM_MAX_SLOTS 256 + +struct cdrom_mechstat_header { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 fault : 1; + __u8 changer_state : 2; + __u8 curslot : 5; + __u8 mech_state : 3; + __u8 door_open : 1; + __u8 reserved1 : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curslot : 5; + __u8 changer_state : 2; + __u8 fault : 1; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 mech_state : 3; +#endif + __u8 curlba[3]; + __u8 nslots; + __u16 slot_tablelen; +}; + +struct cdrom_slot { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 disc_present : 1; + __u8 reserved1 : 6; + __u8 change : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 change : 1; + __u8 reserved1 : 6; + __u8 disc_present : 1; +#endif + __u8 reserved2[3]; +}; + +struct cdrom_changer_info { + struct cdrom_mechstat_header hdr; + struct cdrom_slot slots[CDROM_MAX_SLOTS]; +}; + +typedef enum { + mechtype_caddy = 0, + mechtype_tray = 1, + mechtype_popup = 2, + mechtype_individual_changer = 4, + mechtype_cartridge_changer = 5 +} mechtype_t; + +typedef struct { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 ps : 1; + __u8 reserved1 : 1; + __u8 page_code : 6; + __u8 page_length; + __u8 reserved2 : 1; + __u8 bufe : 1; + __u8 ls_v : 1; + __u8 test_write : 1; + __u8 write_type : 4; + __u8 multi_session : 2; /* or border, DVD */ + __u8 fp : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 reserved3 : 4; + __u8 data_block_type : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_code : 6; + __u8 reserved1 : 1; + __u8 ps : 1; + __u8 page_length; + __u8 write_type : 4; + __u8 test_write : 1; + __u8 ls_v : 1; + __u8 bufe : 1; + __u8 reserved2 : 1; + __u8 track_mode : 4; + __u8 copy : 1; + __u8 fp : 1; + __u8 multi_session : 2; /* or border, DVD */ + __u8 data_block_type : 4; + __u8 reserved3 : 4; +#endif + __u8 link_size; + __u8 reserved4; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved5 : 2; + __u8 app_code : 6; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 app_code : 6; + __u8 reserved5 : 2; +#endif + __u8 session_format; + __u8 reserved6; + __u32 packet_size; + __u16 audio_pause; + __u8 mcn[16]; + __u8 isrc[16]; + __u8 subhdr0; + __u8 subhdr1; + __u8 subhdr2; + __u8 subhdr3; +} __attribute__((packed)) write_param_page; + +struct modesel_head +{ + __u8 reserved1; + __u8 medium; + __u8 reserved2; + __u8 block_desc_length; + __u8 density; + __u8 number_of_blocks_hi; + __u8 number_of_blocks_med; + __u8 number_of_blocks_lo; + __u8 reserved3; + __u8 block_length_hi; + __u8 block_length_med; + __u8 block_length_lo; +}; + +typedef struct { + __u16 report_key_length; + __u8 reserved1; + __u8 reserved2; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 type_code : 2; + __u8 vra : 3; + __u8 ucca : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ucca : 3; + __u8 vra : 3; + __u8 type_code : 2; +#endif + __u8 region_mask; + __u8 rpc_scheme; + __u8 reserved3; +} rpc_state_t; + +struct event_header { + __u16 data_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 nea : 1; + __u8 reserved1 : 4; + __u8 notification_class : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 notification_class : 3; + __u8 reserved1 : 4; + __u8 nea : 1; +#endif + __u8 supp_event_class; +}; + +struct media_event_desc { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 4; + __u8 media_event_code : 4; + __u8 reserved2 : 6; + __u8 media_present : 1; + __u8 door_open : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 media_event_code : 4; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 media_present : 1; + __u8 reserved2 : 6; +#endif + __u8 start_slot; + __u8 end_slot; +}; + +extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); + +#endif /* End of kernel only stuff */ + +#endif /* _LINUX_CDROM_H */ diff --git a/ddverify/models/seq1/include/linux/compat.h b/ddverify/models/seq1/include/linux/compat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/compiler.h b/ddverify/models/seq1/include/linux/compiler.h new file mode 100644 index 000000000..3b8f75ea3 --- /dev/null +++ b/ddverify/models/seq1/include/linux/compiler.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_COMPILER_H +#define __LINUX_COMPILER_H + +# define __user +# define __kernel +# define __safe +# define __force +# define __nocast +# define __iomem + +#ifndef __must_check +#define __must_check +#endif + +#define likely(x) x +#define unlikely(x) x + +void barrier(void); + +#endif diff --git a/ddverify/models/seq1/include/linux/completion.h b/ddverify/models/seq1/include/linux/completion.h new file mode 100644 index 000000000..011ec59af --- /dev/null +++ b/ddverify/models/seq1/include/linux/completion.h @@ -0,0 +1,18 @@ +#ifndef __LINUX_COMPLETION_H +#define __LINUX_COMPLETION_H + +/* + * (C) Copyright 2001 Linus Torvalds + * + * Atomic wait-for-completion handler data structures. + * See kernel/sched.c for details. + */ + +#include + +struct completion { + unsigned int done; + wait_queue_head_t wait; +}; + +#endif diff --git a/ddverify/models/seq1/include/linux/config.h b/ddverify/models/seq1/include/linux/config.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/console.h b/ddverify/models/seq1/include/linux/console.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/cpumask.h b/ddverify/models/seq1/include/linux/cpumask.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/ctype.h b/ddverify/models/seq1/include/linux/ctype.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/dcache.h b/ddverify/models/seq1/include/linux/dcache.h new file mode 100644 index 000000000..2813f54c1 --- /dev/null +++ b/ddverify/models/seq1/include/linux/dcache.h @@ -0,0 +1,9 @@ +#ifndef __LINUX_DCACHE_H +#define __LINUX_DCACHE_H + +struct dentry { + struct inode *d_inode; /* Where the name belongs to - NULL is + * negative */ +}; + +#endif /* __LINUX_DCACHE_H */ diff --git a/ddverify/models/seq1/include/linux/delay.h b/ddverify/models/seq1/include/linux/delay.h new file mode 100644 index 000000000..c3bb525bb --- /dev/null +++ b/ddverify/models/seq1/include/linux/delay.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_DELAY_H +#define _LINUX_DELAY_H + +extern unsigned long loops_per_jiffy; + +#include + + +#ifndef mdelay +#define mdelay(n) do {} while(0) +#endif + +#ifndef ndelay +#define ndelay(x) do {} while(0) +#endif + +// DDV: This function does not need a body! +void msleep(unsigned int msecs); +// DDV: This function does not need a body! +unsigned long msleep_interruptible(unsigned int msecs); + +#endif /* defined(_LINUX_DELAY_H) */ diff --git a/ddverify/models/seq1/include/linux/devfs_fs_kernel.h b/ddverify/models/seq1/include/linux/devfs_fs_kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/device.h b/ddverify/models/seq1/include/linux/device.h new file mode 100644 index 000000000..920ff5519 --- /dev/null +++ b/ddverify/models/seq1/include/linux/device.h @@ -0,0 +1,112 @@ +/* + * device.h - generic, centralized driver model + * + * Copyright (c) 2001-2003 Patrick Mochel + * + * This file is released under the GPLv2 + * + * See Documentation/driver-model/ for more information. + */ + +#ifndef _DEVICE_H_ +#define _DEVICE_H_ + +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include + +struct device { + void *driver_data; /* data private to the driver */ + void (*release)(struct device * dev); +}; + +struct device_driver { + const char * name; +}; + + +struct class { + int someting; +}; + +struct class_device { + int something; +}; + +struct class_interface { + int something; +}; + +struct class_device_attribute { + struct attribute attr; + ssize_t (*show)(struct class_device *, char * buf); + ssize_t (*store)(struct class_device *, const char * buf, size_t count); +}; + +#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \ +struct class_device_attribute class_device_attr_##_name = \ + __ATTR(_name,_mode,_show,_store) + +extern struct class *class_create(struct module *owner, const char *name); +extern void class_destroy(struct class *cls); + +extern struct class_device *class_device_create(struct class *cls, + struct class_device *parent, + dev_t devt, + struct device *device, + const char *fmt, ...); +extern void class_device_destroy(struct class *cls, dev_t devt); + + +struct device_attribute { + struct attribute attr; + ssize_t (*show)(struct device *dev, struct device_attribute *attr, + char *buf); + ssize_t (*store)(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +}; + +#define DEVICE_ATTR(_name,_mode,_show,_store) \ +struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) + + +static inline void * dev_get_drvdata (struct device *dev) +{ + return dev->driver_data; +} + +static inline void dev_set_drvdata (struct device *dev, void *data) +{ + dev->driver_data = data; +} + +extern const char *dev_driver_string(struct device *dev); + + +#define dev_printk(level, dev, format, arg...) \ + printk("dev_printk") + +#ifdef DEBUG +#define dev_dbg(dev, format, arg...) \ + dev_printk(KERN_DEBUG , dev , format , ## arg) +#else +#define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) +#endif + +#define dev_err(dev, format, arg...) \ + dev_printk(KERN_ERR , dev , format , ## arg) +#define dev_info(dev, format, arg...) \ + dev_printk(KERN_INFO , dev , format , ## arg) +#define dev_warn(dev, format, arg...) \ + dev_printk(KERN_WARNING , dev , format , ## arg) +#define dev_notice(dev, format, arg...) \ + dev_printk(KERN_NOTICE , dev , format , ## arg) + +#endif /* _DEVICE_H_ */ diff --git a/ddverify/models/seq1/include/linux/dma-mapping.h b/ddverify/models/seq1/include/linux/dma-mapping.h new file mode 100644 index 000000000..9ea999ba9 --- /dev/null +++ b/ddverify/models/seq1/include/linux/dma-mapping.h @@ -0,0 +1,19 @@ +#ifndef _ASM_LINUX_DMA_MAPPING_H +#define _ASM_LINUX_DMA_MAPPING_H + +#include +#include + + +#define DMA_64BIT_MASK (unsigned long long int)0xffffffffffffffff +#define DMA_48BIT_MASK (unsigned long long int)0x0000ffffffffffff +#define DMA_40BIT_MASK (unsigned long long int)0x000000ffffffffff +#define DMA_39BIT_MASK (unsigned long long int)0x0000007fffffffff +#define DMA_32BIT_MASK (unsigned long long int)0x00000000ffffffff +#define DMA_31BIT_MASK (unsigned long long int)0x000000007fffffff +#define DMA_30BIT_MASK (unsigned long long int)0x000000003fffffff +#define DMA_29BIT_MASK (unsigned long long int)0x000000001fffffff +#define DMA_28BIT_MASK (unsigned long long int)0x000000000fffffff +#define DMA_24BIT_MASK (unsigned long long int)0x0000000000ffffff + +#endif diff --git a/ddverify/models/seq1/include/linux/elevator.h b/ddverify/models/seq1/include/linux/elevator.h new file mode 100644 index 000000000..f0e7f6f17 --- /dev/null +++ b/ddverify/models/seq1/include/linux/elevator.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_ELEVATOR_H +#define _LINUX_ELEVATOR_H + +struct request *elv_next_request(struct request_queue *q); + +#endif diff --git a/ddverify/models/seq1/include/linux/err.h b/ddverify/models/seq1/include/linux/err.h new file mode 100644 index 000000000..18c9cf814 --- /dev/null +++ b/ddverify/models/seq1/include/linux/err.h @@ -0,0 +1,27 @@ +#ifndef _LINUX_ERR_H +#define _LINUX_ERR_H + +#include + +#include + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) (x) >= (unsigned long)-MAX_ERRNO + +static inline void *ERR_PTR(long error) +{ + return (void *) error; +} + +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline long IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + +#endif /* _LINUX_ERR_H */ diff --git a/ddverify/models/seq1/include/linux/errno.h b/ddverify/models/seq1/include/linux/errno.h new file mode 100644 index 000000000..91762481a --- /dev/null +++ b/ddverify/models/seq1/include/linux/errno.h @@ -0,0 +1,25 @@ +#ifndef _LINUX_ERRNO_H +#define _LINUX_ERRNO_H + +#include + +/* Should never be seen by user programs */ +#define ERESTARTSYS 512 +#define ERESTARTNOINTR 513 +#define ERESTARTNOHAND 514 /* restart if no handler.. */ +#define ENOIOCTLCMD 515 /* No ioctl command */ +#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ + +/* Defined for the NFSv3 protocol */ +#define EBADHANDLE 521 /* Illegal NFS file handle */ +#define ENOTSYNC 522 /* Update synchronization mismatch */ +#define EBADCOOKIE 523 /* Cookie is stale */ +#define ENOTSUPP 524 /* Operation is not supported */ +#define ETOOSMALL 525 /* Buffer or request is too small */ +#define ESERVERFAULT 526 /* An untranslatable error occurred */ +#define EBADTYPE 527 /* Type not supported by server */ +#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ +#define EIOCBQUEUED 529 /* iocb queued, will get completion event */ +#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */ + +#endif diff --git a/ddverify/models/seq1/include/linux/fcntl.h b/ddverify/models/seq1/include/linux/fcntl.h new file mode 100644 index 000000000..9de3512e8 --- /dev/null +++ b/ddverify/models/seq1/include/linux/fcntl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_FCNTL_H +#define _LINUX_FCNTL_H + +#include + +#endif diff --git a/ddverify/models/seq1/include/linux/fd.h b/ddverify/models/seq1/include/linux/fd.h new file mode 100644 index 000000000..5b5a51a4e --- /dev/null +++ b/ddverify/models/seq1/include/linux/fd.h @@ -0,0 +1,373 @@ +#ifndef _LINUX_FD_H +#define _LINUX_FD_H + +#include +#include +/* New file layout: Now the ioctl definitions immediately follow the + * definitions of the structures that they use */ + +/* + * Geometry + */ +struct floppy_struct { + unsigned int size, /* nr of sectors total */ + sect, /* sectors per track */ + head, /* nr of heads */ + track, /* nr of tracks */ + stretch; /* !=0 means double track steps */ +#define FD_STRETCH 1 +#define FD_SWAPSIDES 2 +#define FD_ZEROBASED 4 + + unsigned char gap, /* gap1 size */ + + rate, /* data rate. |= 0x40 for perpendicular */ +#define FD_2M 0x4 +#define FD_SIZECODEMASK 0x38 +#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) +#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ + 512 : 128 << FD_SIZECODE(floppy) ) +#define FD_PERP 0x40 + + spec1, /* stepping rate, head unload time */ + fmt_gap; /* gap2 size */ + const char * name; /* used only for predefined formats */ +}; + + +/* commands needing write access have 0x40 set */ +/* commands needing super user access have 0x80 set */ + +#define FDCLRPRM _IO(2, 0x41) +/* clear user-defined parameters */ + +#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) +#define FDSETMEDIAPRM FDSETPRM +/* set user-defined parameters for current media */ + +#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) +#define FDGETPRM _IOR(2, 0x04, struct floppy_struct) +#define FDDEFMEDIAPRM FDDEFPRM +#define FDGETMEDIAPRM FDGETPRM +/* set/get disk parameters */ + + +#define FDMSGON _IO(2,0x45) +#define FDMSGOFF _IO(2,0x46) +/* issue/don't issue kernel messages on media type change */ + + +/* + * Formatting (obsolete) + */ +#define FD_FILL_BYTE 0xF6 /* format fill byte. */ + +struct format_descr { + unsigned int device,head,track; +}; + +#define FDFMTBEG _IO(2,0x47) +/* begin formatting a disk */ +#define FDFMTTRK _IOW(2,0x48, struct format_descr) +/* format the specified track */ +#define FDFMTEND _IO(2,0x49) +/* end formatting a disk */ + + +/* + * Error thresholds + */ +struct floppy_max_errors { + unsigned int + abort, /* number of errors to be reached before aborting */ + read_track, /* maximal number of errors permitted to read an + * entire track at once */ + reset, /* maximal number of errors before a reset is tried */ + recal, /* maximal number of errors before a recalibrate is + * tried */ + + /* + * Threshold for reporting FDC errors to the console. + * Setting this to zero may flood your screen when using + * ultra cheap floppies ;-) + */ + reporting; + +}; + +#define FDSETEMSGTRESH _IO(2,0x4a) +/* set fdc error reporting threshold */ + +#define FDFLUSH _IO(2,0x4b) +/* flush buffers for media; either for verifying media, or for + * handling a media change without closing the file descriptor */ + +#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors) +#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors) +/* set/get abortion and read_track threshold. See also floppy_drive_params + * structure */ + + +typedef char floppy_drive_name[16]; +#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name) +/* get drive type: 5 1/4 or 3 1/2 */ + + +/* + * Drive parameters (user modifiable) + */ +struct floppy_drive_params { + signed char cmos; /* CMOS type */ + + /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms + * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). + */ + unsigned long max_dtr; /* Step rate, usec */ + unsigned long hlt; /* Head load/settle time, msec */ + unsigned long hut; /* Head unload time (remnant of + * 8" drives) */ + unsigned long srt; /* Step rate, usec */ + + unsigned long spinup; /* time needed for spinup (expressed + * in jiffies) */ + unsigned long spindown; /* timeout needed for spindown */ + unsigned char spindown_offset; /* decides in which position the disk + * will stop */ + unsigned char select_delay; /* delay to wait after select */ + unsigned char rps; /* rotations per second */ + unsigned char tracks; /* maximum number of tracks */ + unsigned long timeout; /* timeout for interrupt requests */ + + unsigned char interleave_sect; /* if there are more sectors, use + * interleave */ + + struct floppy_max_errors max_errors; + + char flags; /* various flags, including ftd_msg */ +/* + * Announce successful media type detection and media information loss after + * disk changes. + * Also used to enable/disable printing of overrun warnings. + */ + +#define FTD_MSG 0x10 +#define FD_BROKEN_DCL 0x20 +#define FD_DEBUG 0x02 +#define FD_SILENT_DCL_CLEAR 0x4 +#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware + considerations */ + + char read_track; /* use readtrack during probing? */ + +/* + * Auto-detection. Each drive type has eight formats which are + * used in succession to try to read the disk. If the FDC cannot lock onto + * the disk, the next format is tried. This uses the variable 'probing'. + */ + short autodetect[8]; /* autodetected formats */ + + int checkfreq; /* how often should the drive be checked for disk + * changes */ + int native_format; /* native format of this drive */ +}; + +enum { + FD_NEED_TWADDLE_BIT, /* more magic */ + FD_VERIFY_BIT, /* inquire for write protection */ + FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet + * to clear media change status */ + FD_UNUSED_BIT, + FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ + FD_DISK_WRITABLE_BIT /* disk is writable */ +}; + +#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params) +#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params) +/* set/get drive parameters */ + + +/* + * Current drive state (not directly modifiable by user, readonly) + */ +struct floppy_drive_struct { + unsigned long flags; +/* values for these flags */ +#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT) +#define FD_VERIFY (1 << FD_VERIFY_BIT) +#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT) +#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT) +#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT) + + unsigned long spinup_date; + unsigned long select_date; + unsigned long first_read_date; + short probed_format; + short track; /* current track */ + short maxblock; /* id of highest block read */ + short maxtrack; /* id of highest half track read */ + int generation; /* how many diskchanges? */ + +/* + * (User-provided) media information is _not_ discarded after a media change + * if the corresponding keep_data flag is non-zero. Positive values are + * decremented after each probe. + */ + int keep_data; + + /* Prevent "aliased" accesses. */ + int fd_ref; + int fd_device; + unsigned long last_checked; /* when was the drive last checked for a disk + * change? */ + + char *dmabuf; + int bufblocks; +}; + +#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct) +#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct) +/* get drive state: GET returns the cached state, POLL polls for new state */ + + +/* + * reset FDC + */ +enum reset_mode { + FD_RESET_IF_NEEDED, /* reset only if the reset flags is set */ + FD_RESET_IF_RAWCMD, /* obsolete */ + FD_RESET_ALWAYS /* reset always */ +}; +#define FDRESET _IO(2, 0x54) + + +/* + * FDC state + */ +struct floppy_fdc_state { + int spec1; /* spec1 value last used */ + int spec2; /* spec2 value last used */ + int dtr; + unsigned char version; /* FDC version code */ + unsigned char dor; + unsigned long address; /* io address */ + unsigned int rawcmd:2; + unsigned int reset:1; + unsigned int need_configure:1; + unsigned int perp_mode:2; + unsigned int has_fifo:1; + unsigned int driver_version; /* version code for floppy driver */ +#define FD_DRIVER_VERSION 0x100 +/* user programs using the floppy API should use floppy_fdc_state to + * get the version number of the floppy driver that they are running + * on. If this version number is bigger than the one compiled into the + * user program (the FD_DRIVER_VERSION define), it should be prepared + * to bigger structures + */ + + unsigned char track[4]; + /* Position of the heads of the 4 units attached to this FDC, + * as stored on the FDC. In the future, the position as stored + * on the FDC might not agree with the actual physical + * position of these drive heads. By allowing such + * disagreement, it will be possible to reset the FDC without + * incurring the expensive cost of repositioning all heads. + * Right now, these positions are hard wired to 0. */ + +}; + +#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state) + + +/* + * Asynchronous Write error tracking + */ +struct floppy_write_errors { + /* Write error logging. + * + * These fields can be cleared with the FDWERRORCLR ioctl. + * Only writes that were attempted but failed due to a physical media + * error are logged. write(2) calls that fail and return an error code + * to the user process are not counted. + */ + + unsigned int write_errors; /* number of physical write errors + * encountered */ + + /* position of first and last write errors */ + unsigned long first_error_sector; + int first_error_generation; + unsigned long last_error_sector; + int last_error_generation; + + unsigned int badness; /* highest retry count for a read or write + * operation */ +}; + +#define FDWERRORCLR _IO(2, 0x56) +/* clear write error and badness information */ +#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors) +/* get write error and badness information */ + + +/* + * Raw commands + */ +/* new interface flag: now we can do them in batches */ +#define FDHAVEBATCHEDRAWCMD + +struct floppy_raw_cmd { + unsigned int flags; +#define FD_RAW_READ 1 +#define FD_RAW_WRITE 2 +#define FD_RAW_NO_MOTOR 4 +#define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */ +#define FD_RAW_INTR 8 /* wait for an interrupt */ +#define FD_RAW_SPIN 0x10 /* spin up the disk for this command */ +#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command + * completion */ +#define FD_RAW_NEED_DISK 0x40 /* this command needs a disk to be present */ +#define FD_RAW_NEED_SEEK 0x80 /* this command uses an implied seek (soft) */ + +/* more "in" flags */ +#define FD_RAW_MORE 0x100 /* more records follow */ +#define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */ +#define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */ +#define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure + * detection too */ + +/* more "out" flags */ +#define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */ +#define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */ + + void __user *data; + char *kernel_data; /* location of data buffer in the kernel */ + struct floppy_raw_cmd *next; /* used for chaining of raw cmd's + * within the kernel */ + long length; /* in: length of dma transfer. out: remaining bytes */ + long phys_length; /* physical length, if different from dma length */ + int buffer_length; /* length of allocated buffer */ + + unsigned char rate; + unsigned char cmd_count; + unsigned char cmd[16]; + unsigned char reply_count; + unsigned char reply[16]; + int track; + int resultcode; + + int reserved1; + int reserved2; +}; + +#define FDRAWCMD _IO(2, 0x58) +/* send a raw command to the fdc. Structure size not included, because of + * batches */ + +#define FDTWADDLE _IO(2, 0x59) +/* flicker motor-on bit before reading a sector. Experimental */ + + +#define FDEJECT _IO(2, 0x5a) +/* eject the disk */ + +#endif diff --git a/ddverify/models/seq1/include/linux/fdreg.h b/ddverify/models/seq1/include/linux/fdreg.h new file mode 100644 index 000000000..c2eeb63b7 --- /dev/null +++ b/ddverify/models/seq1/include/linux/fdreg.h @@ -0,0 +1,137 @@ +#ifndef _LINUX_FDREG_H +#define _LINUX_FDREG_H +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ + +#ifdef FDPATCHES +#define FD_IOPORT fdc_state[fdc].address +#else +/* It would be a lot saner just to force fdc_state[fdc].address to always + be set ! FIXME */ +#define FD_IOPORT 0x3f0 +#endif + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS (4 + FD_IOPORT ) +#define FD_DATA (5 + FD_IOPORT ) + +/* Digital Output Register */ +#define FD_DOR (2 + FD_IOPORT ) + +/* Digital Input Register (read) */ +#define FD_DIR (7 + FD_IOPORT ) + +/* Diskette Control Register (write)*/ +#define FD_DCR (7 + FD_IOPORT ) + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment check error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Address Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_DS 0x08 /* drive is double-sided */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_RY 0x20 /* drive is ready */ +#define ST3_WP 0x40 /* Write Protect */ +#define ST3_FT 0x80 /* Drive Fault */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ +#define FD_FORMAT 0x4D /* format one track */ +#define FD_VERSION 0x10 /* get version code */ +#define FD_CONFIGURE 0x13 /* configure FIFO operation */ +#define FD_PERPENDICULAR 0x12 /* perpendicular r/w mode */ +#define FD_GETSTATUS 0x04 /* read ST3 */ +#define FD_DUMPREGS 0x0E /* dump the contents of the fdc regs */ +#define FD_READID 0xEA /* prints the header of a sector */ +#define FD_UNLOCK 0x14 /* Fifo config unlock */ +#define FD_LOCK 0x94 /* Fifo config lock */ +#define FD_RSEEK_OUT 0x8f /* seek out (i.e. to lower tracks) */ +#define FD_RSEEK_IN 0xcf /* seek in (i.e. to higher tracks) */ + +/* the following commands are new in the 82078. They are not used in the + * floppy driver, except the first three. These commands may be useful for apps + * which use the FDRAWCMD interface. For doc, get the 82078 spec sheets at + * http://www-techdoc.intel.com/docs/periph/fd_contr/datasheets/ */ + +#define FD_PARTID 0x18 /* part id ("extended" version cmd) */ +#define FD_SAVE 0x2e /* save fdc regs for later restore */ +#define FD_DRIVESPEC 0x8e /* drive specification: Access to the + * 2 Mbps data transfer rate for tape + * drives */ + +#define FD_RESTORE 0x4e /* later restore */ +#define FD_POWERDOWN 0x27 /* configure FDC's powersave features */ +#define FD_FORMAT_N_WRITE 0xef /* format and write in one go. */ +#define FD_OPTION 0x33 /* ISO format (which is a clean way to + * pack more sectors on a track) */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +/* FDC version return types */ +#define FDC_NONE 0x00 +#define FDC_UNKNOWN 0x10 /* DO NOT USE THIS TYPE EXCEPT IF IDENTIFICATION + FAILS EARLY */ +#define FDC_8272A 0x20 /* Intel 8272a, NEC 765 */ +#define FDC_765ED 0x30 /* Non-Intel 1MB-compatible FDC, can't detect */ +#define FDC_82072 0x40 /* Intel 82072; 8272a + FIFO + DUMPREGS */ +#define FDC_82072A 0x45 /* 82072A (on Sparcs) */ +#define FDC_82077_ORIG 0x51 /* Original version of 82077AA, sans LOCK */ +#define FDC_82077 0x52 /* 82077AA-1 */ +#define FDC_82078_UNKN 0x5f /* Unknown 82078 variant */ +#define FDC_82078 0x60 /* 44pin 82078 or 64pin 82078SL */ +#define FDC_82078_1 0x61 /* 82078-1 (2Mbps fdc) */ +#define FDC_S82078B 0x62 /* S82078B (first seen on Adaptec AVA-2825 VLB + * SCSI/EIDE/Floppy controller) */ +#define FDC_87306 0x63 /* National Semiconductor PC 87306 */ + +/* + * Beware: the fdc type list is roughly sorted by increasing features. + * Presence of features is tested by comparing the FDC version id with the + * "oldest" version that has the needed feature. + * If during FDC detection, an obscure test fails late in the sequence, don't + * assign FDC_UNKNOWN. Else the FDC will be treated as a dumb 8272a, or worse. + * This is especially true if the tests are unneeded. + */ + +#define FD_RESET_DELAY 20 +#endif diff --git a/ddverify/models/seq1/include/linux/file.h b/ddverify/models/seq1/include/linux/file.h new file mode 100644 index 000000000..df49c59d6 --- /dev/null +++ b/ddverify/models/seq1/include/linux/file.h @@ -0,0 +1,14 @@ +#ifndef __LINUX_FILE_H +#define __LINUX_FILE_H + +#include +#include +#include +#include +//#include +#include + +extern void fput(struct file *); +extern struct file * fget(unsigned int fd); + +#endif /* __LINUX_FILE_H */ diff --git a/ddverify/models/seq1/include/linux/firmware.h b/ddverify/models/seq1/include/linux/firmware.h new file mode 100644 index 000000000..33d8f2087 --- /dev/null +++ b/ddverify/models/seq1/include/linux/firmware.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_FIRMWARE_H +#define _LINUX_FIRMWARE_H +#include +#include +#define FIRMWARE_NAME_MAX 30 +#define FW_ACTION_NOHOTPLUG 0 +#define FW_ACTION_HOTPLUG 1 + +struct firmware { + size_t size; + u8 *data; +}; +struct device; +int request_firmware(const struct firmware **fw, const char *name, + struct device *device); +int request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, void *context, + void (*cont)(const struct firmware *fw, void *context)); + +void release_firmware(const struct firmware *fw); +#endif diff --git a/ddverify/models/seq1/include/linux/fs.h b/ddverify/models/seq1/include/linux/fs.h new file mode 100644 index 000000000..7314a5b99 --- /dev/null +++ b/ddverify/models/seq1/include/linux/fs.h @@ -0,0 +1,238 @@ +#ifndef _LINUX_FS_H +#define _LINUX_FS_H + +/* + * This file has definitions for some important file table + * structures etc. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#undef NR_OPEN +#define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */ +#define INR_OPEN 1024 /* Initial setting for nfile rlimits */ + +#define BLOCK_SIZE_BITS 10 +#define BLOCK_SIZE (1<bi_rw & 1) + + +int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); +int register_chrdev_region(dev_t, unsigned, const char *); +void unregister_chrdev_region(dev_t, unsigned); + +int register_chrdev(unsigned int, const char *, struct file_operations *); +int unregister_chrdev(unsigned int, const char *); + +int chrdev_open(struct inode *, struct file *); +void chrdev_show(struct seq_file *,off_t); + +#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ + +int register_blkdev(unsigned int, const char *); +int unregister_blkdev(unsigned int, const char *); + + +void kill_fasync(struct fasync_struct **, int, int); + +static inline unsigned iminor(struct inode *inode) +{ + return MINOR(inode->i_rdev); +} + +static inline unsigned imajor(struct inode *inode) +{ + return MAJOR(inode->i_rdev); +} + +loff_t no_llseek(struct file *file, loff_t offset, int origin); + + +int check_disk_change(struct block_device *); + +/* + * return READ, READA, or WRITE + */ +#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK)) + +int nonseekable_open(struct inode * inode, struct file * filp); + +loff_t i_size_read(struct inode *inode); + +int set_blocksize(struct block_device *, int); +#endif diff --git a/ddverify/models/seq1/include/linux/genhd.h b/ddverify/models/seq1/include/linux/genhd.h new file mode 100644 index 000000000..46dd433cb --- /dev/null +++ b/ddverify/models/seq1/include/linux/genhd.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_GENHD_H +#define _LINUX_GENHD_H + +#include +#include +#include +//#include +#include +#include + +#define GENHD_FL_REMOVABLE 1 +#define GENHD_FL_DRIVERFS 2 +#define GENHD_FL_CD 8 +#define GENHD_FL_UP 16 +#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 + +struct gendisk { + int major; /* major number of driver */ + int first_minor; + int minors; /* maximum number of minors, =1 for + * disks that can't be partitioned. */ + char disk_name[32]; /* name of major driver */ + struct block_device_operations *fops; + struct request_queue *queue; + void *private_data; + + int flags; + struct device *driverfs_dev; + char devfs_name[64]; /* devfs crap */ +}; + +// DDV: defined in file linux/block/genhd.c +void add_disk(struct gendisk *disk); +// DDV: defined in file linux/block/genhd.c +void del_gendisk(struct gendisk *gp); +// DDV: defined in file linux/block/genhd.c +struct gendisk *alloc_disk(int minors); +// DDV: TODO +void put_disk(struct gendisk *disk); +// DDV: TODO +extern struct kobject *get_disk(struct gendisk *disk); + +// DDV: TODO +void set_capacity(struct gendisk *disk, sector_t size); + +// DDV: TODO +void add_disk_randomness(struct gendisk *disk); +#endif diff --git a/ddverify/models/seq1/include/linux/gfp.h b/ddverify/models/seq1/include/linux/gfp.h new file mode 100644 index 000000000..d01d2dd5e --- /dev/null +++ b/ddverify/models/seq1/include/linux/gfp.h @@ -0,0 +1,74 @@ +#ifndef __LINUX_GFP_H +#define __LINUX_GFP_H + +#include +#include +//#include +#include + +/* + * Action modifiers - doesn't change the zoning + * + * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt + * _might_ fail. This depends upon the particular VM implementation. + * + * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller + * cannot handle allocation failures. + * + * __GFP_NORETRY: The VM implementation must not retry indefinitely. + */ +#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */ +#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */ +#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */ +#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ +#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ +#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ +#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */ +#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */ +#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */ +#define __GFP_NO_GROW ((__force gfp_t)0x2000u)/* Slab internal usage */ +#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ +#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ +#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ +#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ + +#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ +#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) + +/* if you forget to add the bitmask here kernel will crash, period */ +#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ + __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ + __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ + __GFP_NOMEMALLOC|__GFP_HARDWALL) + +/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ +#define GFP_ATOMIC (__GFP_HIGH) +#define GFP_NOIO (__GFP_WAIT) +#define GFP_NOFS (__GFP_WAIT | __GFP_IO) +#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) +#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL) +#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \ + __GFP_HIGHMEM) + + +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_page(gfp_t gfp_mask); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long get_zeroed_page(gfp_t gfp_mask); + +// DDV: No body required +void free_pages(unsigned long addr, unsigned int order); +// DDV: No body required +void free_page(unsigned long addr); + +// DDV: Body defined in linux/mm/page_alloc.c +static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, + unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_page(gfp_t gfp_mask); + +#endif diff --git a/ddverify/models/seq1/include/linux/hdreg.h b/ddverify/models/seq1/include/linux/hdreg.h new file mode 100644 index 000000000..a57304a20 --- /dev/null +++ b/ddverify/models/seq1/include/linux/hdreg.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_HDREG_H +#define _LINUX_HDREG_H + +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + unsigned short cylinders; + unsigned long start; +}; + +#define HDIO_GETGEO 0x0301 /* get device geometry */ + +#endif /* _LINUX_HDREG_H */ diff --git a/ddverify/models/seq1/include/linux/highmem.h b/ddverify/models/seq1/include/linux/highmem.h new file mode 100644 index 000000000..9ec708efa --- /dev/null +++ b/ddverify/models/seq1/include/linux/highmem.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_HIGHMEM_H +#define _LINUX_HIGHMEM_H + +#include +#include + +#include + +#endif /* _LINUX_HIGHMEM_H */ diff --git a/ddverify/models/seq1/include/linux/if.h b/ddverify/models/seq1/include/linux/if.h new file mode 100644 index 000000000..544dc09d7 --- /dev/null +++ b/ddverify/models/seq1/include/linux/if.h @@ -0,0 +1,8 @@ +#ifndef _LINUX_IF_H +#define _LINUX_IF_H + +#include /* for "__kernel_caddr_t" et al */ +#include /* for "struct sockaddr" et al */ +#include /* for "__user" et al */ + +#endif /* _LINUX_IF_H */ diff --git a/ddverify/models/seq1/include/linux/in.h b/ddverify/models/seq1/include/linux/in.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/init.h b/ddverify/models/seq1/include/linux/init.h new file mode 100644 index 000000000..ee78bf673 --- /dev/null +++ b/ddverify/models/seq1/include/linux/init.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_INIT_H +#define _LINUX_INIT_H + +#include +#include + +#define module_init(_function) int (* _ddv_tmp_init)(void) = _function +#define module_exit(_function) void (* _ddv_tmp_exit)(void) = _function + +#define __init +#define __initdata +#define __exitdata +#define __exit + +#define __devinit +#define __devinitdata +#define __devexit +#define __devexitdata +#define __devexit_p(x) x + +#define __setup(str, func) int (* _ddv_setup_function)(char *) = func + +#endif diff --git a/ddverify/models/seq1/include/linux/interrupt.h b/ddverify/models/seq1/include/linux/interrupt.h new file mode 100644 index 000000000..68c9dc998 --- /dev/null +++ b/ddverify/models/seq1/include/linux/interrupt.h @@ -0,0 +1,96 @@ +/* interrupt.h */ +#ifndef _LINUX_INTERRUPT_H +#define _LINUX_INTERRUPT_H + +#include +#include +#include +#include + +/* + * These flags used only by the kernel as part of the + * irq handling routines. + * + * IRQF_DISABLED - keep irqs disabled when calling the action handler + * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator + * IRQF_SHARED - allow sharing the irq among several devices + * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur + * IRQF_TIMER - Flag to mark this interrupt as timer interrupt + */ +#define IRQF_DISABLED 0x00000020 +#define IRQF_SAMPLE_RANDOM 0x00000040 +#define IRQF_SHARED 0x00000080 +#define IRQF_PROBE_SHARED 0x00000100 +#define IRQF_TIMER 0x00000200 +#define IRQF_PERCPU 0x00000400 + + +typedef int irqreturn_t; + +#define IRQ_NONE (0) +#define IRQ_HANDLED (1) +#define IRQ_RETVAL(x) ((x) != 0) + +struct tasklet_struct +{ + atomic_t count; + void (*func)(unsigned long); + unsigned long data; + + int init; +}; + +#define DECLARE_TASKLET(name, func, data) \ + struct tasklet_struct name = { 0, func, data, 1 } + +#define DECLARE_TASKLET_DISABLED(name, func, data) \ + struct tasklet_struct name = { 1, func, data, 1 } + +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_schedule(struct tasklet_struct *t); + +static inline void tasklet_disable(struct tasklet_struct *t) +{ + t->count++; +} + +static inline void tasklet_enable(struct tasklet_struct *t) +{ + t->count++; +} + +// DDV: TODO +void tasklet_kill(struct tasklet_struct *t); +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data); + +#ifdef OLD_INTERRUPT_HANDLER +typedef irqreturn_t (*irq_handler_t)(int, void *); +#else +typedef irqreturn_t (*irq_handler_t)(int, void *, struct pt_regs *); +#endif + +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +int request_irq(unsigned int, irq_handler_t handler, + unsigned long, const char *, void *); +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +void free_irq(unsigned int, void *); + +// DDV: TODO +unsigned long probe_irq_on(void); +// DDV: TODO +int probe_irq_off(unsigned long); +// DDV: TODO +unsigned int probe_irq_mask(unsigned long); + +// DDV: TODO +void cli(void); +// DDV: TODO +void sti(void); +// DDV: TODO +void save_flags(unsigned long x); +// DDV: TODO +void restore_flags(unsigned long x); + +#endif diff --git a/ddverify/models/seq1/include/linux/ioctl.h b/ddverify/models/seq1/include/linux/ioctl.h new file mode 100644 index 000000000..6f08f2f94 --- /dev/null +++ b/ddverify/models/seq1/include/linux/ioctl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_IOCTL_H +#define _LINUX_IOCTL_H + +#include + +#endif diff --git a/ddverify/models/seq1/include/linux/ioport.h b/ddverify/models/seq1/include/linux/ioport.h new file mode 100644 index 000000000..7df1143c6 --- /dev/null +++ b/ddverify/models/seq1/include/linux/ioport.h @@ -0,0 +1,102 @@ +/* + * ioport.h Definitions of routines for detecting, reserving and + * allocating system resources. + * + * Authors: Linus Torvalds + */ + +#ifndef _LINUX_IOPORT_H +#define _LINUX_IOPORT_H + +#include + + +/* + * Resources are tree-like, allowing + * nesting etc.. + */ +struct resource { + const char *name; + unsigned long start, end; + unsigned long flags; +// struct resource *parent, *sibling, *child; +}; + + +/* + * IO resources have these defined flags. + */ +#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ + +#define IORESOURCE_IO 0x00000100 /* Resource type */ +#define IORESOURCE_MEM 0x00000200 +#define IORESOURCE_IRQ 0x00000400 +#define IORESOURCE_DMA 0x00000800 + +#define IORESOURCE_PREFETCH 0x00001000 /* No side effects */ +#define IORESOURCE_READONLY 0x00002000 +#define IORESOURCE_CACHEABLE 0x00004000 +#define IORESOURCE_RANGELENGTH 0x00008000 +#define IORESOURCE_SHADOWABLE 0x00010000 +#define IORESOURCE_BUS_HAS_VGA 0x00080000 + +#define IORESOURCE_DISABLED 0x10000000 +#define IORESOURCE_UNSET 0x20000000 +#define IORESOURCE_AUTO 0x40000000 +#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ + +/* ISA PnP IRQ specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_IRQ_HIGHEDGE (1<<0) +#define IORESOURCE_IRQ_LOWEDGE (1<<1) +#define IORESOURCE_IRQ_HIGHLEVEL (1<<2) +#define IORESOURCE_IRQ_LOWLEVEL (1<<3) +#define IORESOURCE_IRQ_SHAREABLE (1<<4) + +/* ISA PnP DMA specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_DMA_TYPE_MASK (3<<0) +#define IORESOURCE_DMA_8BIT (0<<0) +#define IORESOURCE_DMA_8AND16BIT (1<<0) +#define IORESOURCE_DMA_16BIT (2<<0) + +#define IORESOURCE_DMA_MASTER (1<<2) +#define IORESOURCE_DMA_BYTE (1<<3) +#define IORESOURCE_DMA_WORD (1<<4) + +#define IORESOURCE_DMA_SPEED_MASK (3<<6) +#define IORESOURCE_DMA_COMPATIBLE (0<<6) +#define IORESOURCE_DMA_TYPEA (1<<6) +#define IORESOURCE_DMA_TYPEB (2<<6) +#define IORESOURCE_DMA_TYPEF (3<<6) + +/* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */ +#define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */ +#define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */ +#define IORESOURCE_MEM_TYPE_MASK (3<<3) +#define IORESOURCE_MEM_8BIT (0<<3) +#define IORESOURCE_MEM_16BIT (1<<3) +#define IORESOURCE_MEM_8AND16BIT (2<<3) +#define IORESOURCE_MEM_32BIT (3<<3) +#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ +#define IORESOURCE_MEM_EXPANSIONROM (1<<6) + +/* PCI ROM control bits (IORESOURCE_BITS) */ +#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ +#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */ +#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */ + + +// DDV: Body defined in linux/kernel/resource.c +struct resource *request_region(unsigned long, unsigned long, const char *); +// DDV: Body defined in linux/kernel/resource.c +void release_region(unsigned long, unsigned long); + + +// DDV: TODO +struct resource *request_mem_region(unsigned long start, unsigned long len, const char *name); +// DDV: TODO +void release_mem_region(unsigned long start, unsigned long len); + + + +#endif /* _LINUX_IOPORT_H */ diff --git a/ddverify/models/seq1/include/linux/jiffies.h b/ddverify/models/seq1/include/linux/jiffies.h new file mode 100644 index 000000000..2d4a183ca --- /dev/null +++ b/ddverify/models/seq1/include/linux/jiffies.h @@ -0,0 +1,84 @@ +#ifndef _LINUX_JIFFIES_H +#define _LINUX_JIFFIES_H + +#include +#include + +unsigned long jiffies; + +/* + * These inlines deal with timer wrapping correctly. You are + * strongly encouraged to use them + * 1. Because people otherwise forget + * 2. Because if the timer wrap changes in future you won't have to + * alter your driver code. + * + * time_after(a,b) returns true if the time a is after time b. + * + * Do this with "<0" and ">=0" to only test the sign of the result. A + * good compiler would generate better code (and a really good compiler + * wouldn't care). Gcc is currently neither. + */ +#define time_after(a,b) ((long)(b) - (long)(a) < 0) +#define time_before(a,b) time_after(b,a) +#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_before_eq(a,b) time_after_eq(b,a) + + +#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) + +/* + * Convert jiffies to milliseconds and back. + * + * Avoid unnecessary multiplications/divisions in the + * two most common HZ cases: + */ +static inline unsigned int jiffies_to_msecs(const unsigned long j) +{ +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (MSEC_PER_SEC / HZ) * j; +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); +#else + return (j * MSEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned int jiffies_to_usecs(const unsigned long j) +{ +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (USEC_PER_SEC / HZ) * j; +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); +#else + return (j * USEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned long msecs_to_jiffies(const unsigned int m) +{ + if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return m * (HZ / MSEC_PER_SEC); +#else + return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; +#endif +} + +static inline unsigned long usecs_to_jiffies(const unsigned int u) +{ + if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ); +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return u * (HZ / USEC_PER_SEC); +#else + return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC; +#endif +} + +#endif diff --git a/ddverify/models/seq1/include/linux/kdb_kern.h b/ddverify/models/seq1/include/linux/kdb_kern.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/kdev_t.h b/ddverify/models/seq1/include/linux/kdev_t.h new file mode 100644 index 000000000..647632b51 --- /dev/null +++ b/ddverify/models/seq1/include/linux/kdev_t.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_KDEV_T_H +#define _LINUX_KDEV_T_H + +#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK)) +#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi)) + +#endif diff --git a/ddverify/models/seq1/include/linux/kernel.h b/ddverify/models/seq1/include/linux/kernel.h new file mode 100644 index 000000000..a228a8a21 --- /dev/null +++ b/ddverify/models/seq1/include/linux/kernel.h @@ -0,0 +1,115 @@ +#ifndef _LINUX_KERNEL_H +#define _LINUX_KERNEL_H + +/* + * 'kernel.h' contains some often-used function prototypes etc + */ + +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + +#define KERN_EMERG "<0>" /* system is unusable */ +#define KERN_ALERT "<1>" /* action must be taken immediately */ +#define KERN_CRIT "<2>" /* critical conditions */ +#define KERN_ERR "<3>" /* error conditions */ +#define KERN_WARNING "<4>" /* warning conditions */ +#define KERN_NOTICE "<5>" /* normal but significant condition */ +#define KERN_INFO "<6>" /* informational */ +#define KERN_DEBUG "<7>" /* debug-level messages */ + +unsigned long simple_strtoul(const char *,char **,unsigned int); +long simple_strtol(const char *,char **,unsigned int); +unsigned long long simple_strtoull(const char *,char **,unsigned int); +long long simple_strtoll(const char *,char **,unsigned int); + +int printk(const char * fmt, ...); +int sprintf(char * buf, const char * fmt, ...); +int snprintf(char * buf, size_t size, const char * fmt, ...); + +extern int cond_resched(void); + +extern int get_option(char **str, int *pint); +extern char *get_options(const char *str, int nints, int *ints); + +/* Values used for system_state */ +extern enum system_states { + SYSTEM_BOOTING, + SYSTEM_RUNNING, + SYSTEM_HALT, + SYSTEM_POWER_OFF, + SYSTEM_RESTART, + SYSTEM_SUSPEND_DISK, +} system_state; + +#define TAINT_PROPRIETARY_MODULE (1<<0) +#define TAINT_FORCED_MODULE (1<<1) +#define TAINT_UNSAFE_SMP (1<<2) +#define TAINT_FORCED_RMMOD (1<<3) +#define TAINT_MACHINE_CHECK (1<<4) +#define TAINT_BAD_PAGE (1<<5) + +extern void dump_stack(void); + +/* + * min()/max() macros that also do + * strict type-checking.. See the + * "unnecessary" pointer comparison. + */ +#define min(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + +#define max(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +/* + * ..and if you can't take the strict + * types, you can specify one yourself. + * + * Or not use min/max at all, of course. + */ +#define min_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) +#define max_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) + +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + +#define pr_debug(fmt,arg...) \ + do { } while (0) + +#define BUILD_BUG_ON(condition) \ + do { } while (0) + +#define BUILD_BUG_ON_ZERO(condition) \ + do { } while (0) + + +/* Trap pasters of __FUNCTION__ at compile-time */ +#define __FUNCTION__ (__func__) + +#endif diff --git a/ddverify/models/seq1/include/linux/kobject.h b/ddverify/models/seq1/include/linux/kobject.h new file mode 100644 index 000000000..4c1ba3fd0 --- /dev/null +++ b/ddverify/models/seq1/include/linux/kobject.h @@ -0,0 +1,34 @@ +/* + * kobject.h - generic kernel object infrastructure. + * + * Copyright (c) 2002-2003 Patrick Mochel + * Copyright (c) 2002-2003 Open Source Development Labs + * + * This file is released under the GPLv2. + * + * + * Please read Documentation/kobject.txt before using the kobject + * interface, ESPECIALLY the parts about reference counts and object + * destructors. + */ + +#ifndef _KOBJECT_H_ +#define _KOBJECT_H_ + + +#include +#include +#include +#include +#include +//#include +//#include +#include +#include +#include + +struct kobject { + int something; +}; + +#endif /* _KOBJECT_H_ */ diff --git a/ddverify/models/seq1/include/linux/kthread.h b/ddverify/models/seq1/include/linux/kthread.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/list.h b/ddverify/models/seq1/include/linux/list.h new file mode 100644 index 000000000..0132dfc43 --- /dev/null +++ b/ddverify/models/seq1/include/linux/list.h @@ -0,0 +1,108 @@ +#ifndef _LINUX_LIST_H +#define _LINUX_LIST_H + +//#include +//#include +//#include +#include + +struct list_head { + struct list_head *next, *prev; +}; + +#define LIST_HEAD_INIT(name) { &(name), &(name) } + + +#define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + +static inline void INIT_LIST_HEAD(struct list_head *list) +{ + list->next = list; + list->prev = list; +} + +/** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop cursor. + * @head: the head for your list. + */ +#define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ +static inline void list_del_init(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); +} + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +#endif + + diff --git a/ddverify/models/seq1/include/linux/major.h b/ddverify/models/seq1/include/linux/major.h new file mode 100644 index 000000000..0a74c5292 --- /dev/null +++ b/ddverify/models/seq1/include/linux/major.h @@ -0,0 +1,169 @@ +#ifndef _LINUX_MAJOR_H +#define _LINUX_MAJOR_H + +/* + * This file has definitions for major device numbers. + * For the device number assignments, see Documentation/devices.txt. + */ + +#define UNNAMED_MAJOR 0 +#define MEM_MAJOR 1 +#define RAMDISK_MAJOR 1 +#define FLOPPY_MAJOR 2 +#define PTY_MASTER_MAJOR 2 +#define IDE0_MAJOR 3 +#define HD_MAJOR IDE0_MAJOR +#define PTY_SLAVE_MAJOR 3 +#define TTY_MAJOR 4 +#define TTYAUX_MAJOR 5 +#define LP_MAJOR 6 +#define VCS_MAJOR 7 +#define LOOP_MAJOR 7 +#define SCSI_DISK0_MAJOR 8 +#define SCSI_TAPE_MAJOR 9 +#define MD_MAJOR 9 +#define MISC_MAJOR 10 +#define SCSI_CDROM_MAJOR 11 +#define MUX_MAJOR 11 /* PA-RISC only */ +#define XT_DISK_MAJOR 13 +#define INPUT_MAJOR 13 +#define SOUND_MAJOR 14 +#define CDU31A_CDROM_MAJOR 15 +#define JOYSTICK_MAJOR 15 +#define GOLDSTAR_CDROM_MAJOR 16 +#define OPTICS_CDROM_MAJOR 17 +#define SANYO_CDROM_MAJOR 18 +#define CYCLADES_MAJOR 19 +#define CYCLADESAUX_MAJOR 20 +#define MITSUMI_X_CDROM_MAJOR 20 +#define MFM_ACORN_MAJOR 21 /* ARM Linux /dev/mfm */ +#define SCSI_GENERIC_MAJOR 21 +#define IDE1_MAJOR 22 +#define DIGICU_MAJOR 22 +#define DIGI_MAJOR 23 +#define MITSUMI_CDROM_MAJOR 23 +#define CDU535_CDROM_MAJOR 24 +#define STL_SERIALMAJOR 24 +#define MATSUSHITA_CDROM_MAJOR 25 +#define STL_CALLOUTMAJOR 25 +#define MATSUSHITA_CDROM2_MAJOR 26 +#define QIC117_TAPE_MAJOR 27 +#define MATSUSHITA_CDROM3_MAJOR 27 +#define MATSUSHITA_CDROM4_MAJOR 28 +#define STL_SIOMEMMAJOR 28 +#define ACSI_MAJOR 28 +#define AZTECH_CDROM_MAJOR 29 +#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */ +#define CM206_CDROM_MAJOR 32 +#define IDE2_MAJOR 33 +#define IDE3_MAJOR 34 +#define Z8530_MAJOR 34 +#define XPRAM_MAJOR 35 /* Expanded storage on S/390: "slow ram"*/ +#define NETLINK_MAJOR 36 +#define PS2ESDI_MAJOR 36 +#define IDETAPE_MAJOR 37 +#define Z2RAM_MAJOR 37 +#define APBLOCK_MAJOR 38 /* AP1000 Block device */ +#define DDV_MAJOR 39 /* AP1000 DDV block device */ +#define NBD_MAJOR 43 /* Network block device */ +#define RISCOM8_NORMAL_MAJOR 48 +#define DAC960_MAJOR 48 /* 48..55 */ +#define RISCOM8_CALLOUT_MAJOR 49 +#define MKISS_MAJOR 55 +#define DSP56K_MAJOR 55 /* DSP56001 processor device */ + +#define IDE4_MAJOR 56 +#define IDE5_MAJOR 57 + +#define SCSI_DISK1_MAJOR 65 +#define SCSI_DISK2_MAJOR 66 +#define SCSI_DISK3_MAJOR 67 +#define SCSI_DISK4_MAJOR 68 +#define SCSI_DISK5_MAJOR 69 +#define SCSI_DISK6_MAJOR 70 +#define SCSI_DISK7_MAJOR 71 + +#define COMPAQ_SMART2_MAJOR 72 +#define COMPAQ_SMART2_MAJOR1 73 +#define COMPAQ_SMART2_MAJOR2 74 +#define COMPAQ_SMART2_MAJOR3 75 +#define COMPAQ_SMART2_MAJOR4 76 +#define COMPAQ_SMART2_MAJOR5 77 +#define COMPAQ_SMART2_MAJOR6 78 +#define COMPAQ_SMART2_MAJOR7 79 + +#define SPECIALIX_NORMAL_MAJOR 75 +#define SPECIALIX_CALLOUT_MAJOR 76 + +#define AURORA_MAJOR 79 + +#define I2O_MAJOR 80 /* 80->87 */ + +#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */ +#define SCSI_CHANGER_MAJOR 86 + +#define IDE6_MAJOR 88 +#define IDE7_MAJOR 89 +#define IDE8_MAJOR 90 +#define IDE9_MAJOR 91 + +#define DASD_MAJOR 94 + +#define MDISK_MAJOR 95 + +#define UBD_MAJOR 98 + +#define PP_MAJOR 99 +#define JSFD_MAJOR 99 + +#define PHONE_MAJOR 100 + +#define COMPAQ_CISS_MAJOR 104 +#define COMPAQ_CISS_MAJOR1 105 +#define COMPAQ_CISS_MAJOR2 106 +#define COMPAQ_CISS_MAJOR3 107 +#define COMPAQ_CISS_MAJOR4 108 +#define COMPAQ_CISS_MAJOR5 109 +#define COMPAQ_CISS_MAJOR6 110 +#define COMPAQ_CISS_MAJOR7 111 + +#define VIODASD_MAJOR 112 +#define VIOCD_MAJOR 113 + +#define ATARAID_MAJOR 114 + +#define SCSI_DISK8_MAJOR 128 +#define SCSI_DISK9_MAJOR 129 +#define SCSI_DISK10_MAJOR 130 +#define SCSI_DISK11_MAJOR 131 +#define SCSI_DISK12_MAJOR 132 +#define SCSI_DISK13_MAJOR 133 +#define SCSI_DISK14_MAJOR 134 +#define SCSI_DISK15_MAJOR 135 + +#define UNIX98_PTY_MASTER_MAJOR 128 +#define UNIX98_PTY_MAJOR_COUNT 8 +#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT) + +#define RTF_MAJOR 150 +#define RAW_MAJOR 162 + +#define USB_ACM_MAJOR 166 +#define USB_ACM_AUX_MAJOR 167 +#define USB_CHAR_MAJOR 180 + +#define VXVM_MAJOR 199 /* VERITAS volume i/o driver */ +#define VXSPEC_MAJOR 200 /* VERITAS volume config driver */ +#define VXDMP_MAJOR 201 /* VERITAS volume multipath driver */ + +#define MSR_MAJOR 202 +#define CPUID_MAJOR 203 + +#define OSST_MAJOR 206 /* OnStream-SCx0 SCSI tape */ + +#define IBM_TTY3270_MAJOR 227 +#define IBM_FS3270_MAJOR 228 + +#define VIOTAPE_MAJOR 230 + +#endif diff --git a/ddverify/models/seq1/include/linux/mc146818rtc.h b/ddverify/models/seq1/include/linux/mc146818rtc.h new file mode 100644 index 000000000..38ed29876 --- /dev/null +++ b/ddverify/models/seq1/include/linux/mc146818rtc.h @@ -0,0 +1,87 @@ +#ifndef _MC146818RTC_H +#define _MC146818RTC_H + +#include +#include /* get the user-level API */ +#include /* register access macros */ + +#include /* spinlock_t */ +extern spinlock_t rtc_lock; /* serialize CMOS RAM access */ + +/********************************************************************** + * register summary + **********************************************************************/ +#define RTC_SECONDS 0 +#define RTC_SECONDS_ALARM 1 +#define RTC_MINUTES 2 +#define RTC_MINUTES_ALARM 3 +#define RTC_HOURS 4 +#define RTC_HOURS_ALARM 5 +/* RTC_*_alarm is always true if 2 MSBs are set */ +# define RTC_ALARM_DONT_CARE 0xC0 + +#define RTC_DAY_OF_WEEK 6 +#define RTC_DAY_OF_MONTH 7 +#define RTC_MONTH 8 +#define RTC_YEAR 9 + +/* control registers - Moto names + */ +#define RTC_REG_A 10 +#define RTC_REG_B 11 +#define RTC_REG_C 12 +#define RTC_REG_D 13 + +/********************************************************************** + * register details + **********************************************************************/ +#define RTC_FREQ_SELECT RTC_REG_A + +/* update-in-progress - set to "1" 244 microsecs before RTC goes off the bus, + * reset after update (may take 1.984ms @ 32768Hz RefClock) is complete, + * totalling to a max high interval of 2.228 ms. + */ +# define RTC_UIP 0x80 +# define RTC_DIV_CTL 0x70 + /* divider control: refclock values 4.194 / 1.049 MHz / 32.768 kHz */ +# define RTC_REF_CLCK_4MHZ 0x00 +# define RTC_REF_CLCK_1MHZ 0x10 +# define RTC_REF_CLCK_32KHZ 0x20 + /* 2 values for divider stage reset, others for "testing purposes only" */ +# define RTC_DIV_RESET1 0x60 +# define RTC_DIV_RESET2 0x70 + /* Periodic intr. / Square wave rate select. 0=none, 1=32.8kHz,... 15=2Hz */ +# define RTC_RATE_SELECT 0x0F + +/**********************************************************************/ +#define RTC_CONTROL RTC_REG_B +# define RTC_SET 0x80 /* disable updates for clock setting */ +# define RTC_PIE 0x40 /* periodic interrupt enable */ +# define RTC_AIE 0x20 /* alarm interrupt enable */ +# define RTC_UIE 0x10 /* update-finished interrupt enable */ +# define RTC_SQWE 0x08 /* enable square-wave output */ +# define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +# define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +# define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +/**********************************************************************/ +#define RTC_INTR_FLAGS RTC_REG_C +/* caution - cleared by read */ +# define RTC_IRQF 0x80 /* any of the following 3 is active */ +# define RTC_PF 0x40 +# define RTC_AF 0x20 +# define RTC_UF 0x10 + +/**********************************************************************/ +#define RTC_VALID RTC_REG_D +# define RTC_VRT 0x80 /* valid RAM and time */ +/**********************************************************************/ + +#ifndef ARCH_RTC_LOCATION /* Override by ? */ + +#define RTC_IO_EXTENT 0x8 +#define RTC_IOMAPPED 1 /* Default to I/O mapping. */ + +#endif /* ARCH_RTC_LOCATION */ + +#endif /* _MC146818RTC_H */ diff --git a/ddverify/models/seq1/include/linux/mempool.h b/ddverify/models/seq1/include/linux/mempool.h new file mode 100644 index 000000000..dd86176f1 --- /dev/null +++ b/ddverify/models/seq1/include/linux/mempool.h @@ -0,0 +1,11 @@ +/* + * memory buffer pool support + */ +#ifndef _LINUX_MEMPOOL_H +#define _LINUX_MEMPOOL_H + +#include + + + +#endif /* _LINUX_MEMPOOL_H */ diff --git a/ddverify/models/seq1/include/linux/miscdevice.h b/ddverify/models/seq1/include/linux/miscdevice.h new file mode 100644 index 000000000..1b6241373 --- /dev/null +++ b/ddverify/models/seq1/include/linux/miscdevice.h @@ -0,0 +1,43 @@ +#ifndef _LINUX_MISCDEVICE_H +#define _LINUX_MISCDEVICE_H +#include +#include + +#define PSMOUSE_MINOR 1 +#define MS_BUSMOUSE_MINOR 2 +#define ATIXL_BUSMOUSE_MINOR 3 +/*#define AMIGAMOUSE_MINOR 4 FIXME OBSOLETE */ +#define ATARIMOUSE_MINOR 5 +#define SUN_MOUSE_MINOR 6 +#define APOLLO_MOUSE_MINOR 7 +#define PC110PAD_MINOR 9 +/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */ +#define WATCHDOG_MINOR 130 /* Watchdog timer */ +#define TEMP_MINOR 131 /* Temperature Sensor */ +#define RTC_MINOR 135 +#define EFI_RTC_MINOR 136 /* EFI Time services */ +#define SUN_OPENPROM_MINOR 139 +#define DMAPI_MINOR 140 /* DMAPI */ +#define NVRAM_MINOR 144 +#define SGI_MMTIMER 153 +#define STORE_QUEUE_MINOR 155 +#define I2O_MINOR 166 +#define MICROCODE_MINOR 184 +#define MWAVE_MINOR 219 /* ACP/Mwave Modem */ +#define MPT_MINOR 220 +#define MISC_DYNAMIC_MINOR 255 + +#define TUN_MINOR 200 +#define HPET_MINOR 228 + + +struct miscdevice { + int minor; + const char *name; + struct file_operations *fops; +}; + +extern int misc_register(struct miscdevice * misc); +extern int misc_deregister(struct miscdevice * misc); + +#endif diff --git a/ddverify/models/seq1/include/linux/mm.h b/ddverify/models/seq1/include/linux/mm.h new file mode 100644 index 000000000..4bbf229f1 --- /dev/null +++ b/ddverify/models/seq1/include/linux/mm.h @@ -0,0 +1,17 @@ +#ifndef _LINUX_MM_H +#define _LINUX_MM_H + +#include +#include +#include + +#include +#include +#include +#include + +#include + +void *page_address(struct page *page); + +#endif /* _LINUX_MM_H */ diff --git a/ddverify/models/seq1/include/linux/mm_types.h b/ddverify/models/seq1/include/linux/mm_types.h new file mode 100644 index 000000000..0645b00a5 --- /dev/null +++ b/ddverify/models/seq1/include/linux/mm_types.h @@ -0,0 +1,14 @@ +#ifndef _LINUX_MM_TYPES_H +#define _LINUX_MM_TYPES_H + +#include +//#include +#include +#include + +struct page { + int something; +}; + +#endif /* _LINUX_MM_TYPES_H */ + diff --git a/ddverify/models/seq1/include/linux/mman.h b/ddverify/models/seq1/include/linux/mman.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/mmzone.h b/ddverify/models/seq1/include/linux/mmzone.h new file mode 100644 index 000000000..709447587 --- /dev/null +++ b/ddverify/models/seq1/include/linux/mmzone.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_MMZONE_H +#define _LINUX_MMZONE_H + +#include +#include +//#include +#include +//#include +#include +//#include +#include +//#include +#include + +#endif /* _LINUX_MMZONE_H */ + diff --git a/ddverify/models/seq1/include/linux/mod_devicetable.h b/ddverify/models/seq1/include/linux/mod_devicetable.h new file mode 100644 index 000000000..0c41094d7 --- /dev/null +++ b/ddverify/models/seq1/include/linux/mod_devicetable.h @@ -0,0 +1,18 @@ +#ifndef LINUX_MOD_DEVICETABLE_H +#define LINUX_MOD_DEVICETABLE_H + +#include + +typedef unsigned long kernel_ulong_t; + +#define PCI_ANY_ID (~0) + +struct pci_device_id { + __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/ + __u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ + __u32 class, class_mask; /* (class,subclass,prog-if) triplet */ + kernel_ulong_t driver_data; /* Data private to the driver */ +}; + +#endif /* LINUX_MOD_DEVICETABLE_H */ + diff --git a/ddverify/models/seq1/include/linux/module.h b/ddverify/models/seq1/include/linux/module.h new file mode 100644 index 000000000..e911d572d --- /dev/null +++ b/ddverify/models/seq1/include/linux/module.h @@ -0,0 +1,32 @@ +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H + +#include +#include +#include +#include +#include +#include + +#define MODULE_AUTHOR(_author) char _ddv_module_author[] = _author +#define MODULE_LICENSE(_license) char _ddv_module_license[] = _license +#define MODULE_DESCRIPTION(_description) char _ddv_module_description[] = _description +#define MODULE_SUPPORTED_DEVICE(_device) char _ddv_module_supported_device[] = _device +#define MODULE_PARM_DESC(_param, _description) char _ddv_module_param_##_param [] = _description +#define MODULE_ALIAS(_whatever) void +#define MODULE_ALIAS_CHARDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_BLOCKDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_MISCDEV(_dev) void +#define MODULE_DEVICE_TABLE(type,name) void + +#define THIS_MODULE ((struct module *) 0) + +struct module { + int something; +}; + +#define __MODULE_STRING(x) #x + +void __module_get(struct module *module); + +#endif diff --git a/ddverify/models/seq1/include/linux/moduleparam.h b/ddverify/models/seq1/include/linux/moduleparam.h new file mode 100644 index 000000000..8df1e77e0 --- /dev/null +++ b/ddverify/models/seq1/include/linux/moduleparam.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_MODULE_PARAMS_H +#define _LINUX_MODULE_PARAMS_H + +#include +#include +#include + +#define module_param(var, type, arg) void +#define module_param_named(name, var, type, arg) void +#define module_param_array(name, type, nump, perm) void + +#endif diff --git a/ddverify/models/seq1/include/linux/mutex.h b/ddverify/models/seq1/include/linux/mutex.h new file mode 100644 index 000000000..7298d3300 --- /dev/null +++ b/ddverify/models/seq1/include/linux/mutex.h @@ -0,0 +1,38 @@ +/* + * Mutexes: blocking mutual exclusion locks + * + * started by Ingo Molnar: + * + * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar + * + * This file contains the main data structure and API definitions. + */ +#ifndef __LINUX_MUTEX_H +#define __LINUX_MUTEX_H + +#include +#include +//#include +//#include + +#include + +struct mutex { + int locked; + int init; +}; + +#define __MUTEX_INITIALIZER(lockname) \ + { .locked = 0, .init = 1 } + +#define DEFINE_MUTEX(mutexname) \ + struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) + +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_init(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_lock(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_unlock(struct mutex *lock); + +#endif diff --git a/ddverify/models/seq1/include/linux/net.h b/ddverify/models/seq1/include/linux/net.h new file mode 100644 index 000000000..1339d2421 --- /dev/null +++ b/ddverify/models/seq1/include/linux/net.h @@ -0,0 +1,19 @@ +#ifndef _LINUX_NET_H +#define _LINUX_NET_H + +struct socket { + const struct proto_ops *ops; + struct sock *sk; +}; + +struct proto_ops { + int (*shutdown) (struct socket *sock, int flags); +}; + +extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, size_t len); +extern int kernel_recvmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, + size_t len, int flags); + +#endif /* _LINUX_NET_H */ diff --git a/ddverify/models/seq1/include/linux/netdevice.h b/ddverify/models/seq1/include/linux/netdevice.h new file mode 100644 index 000000000..f90cdbfa3 --- /dev/null +++ b/ddverify/models/seq1/include/linux/netdevice.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_NETDEVICE_H +#define _LINUX_NETDEVICE_H + +#include + +#endif /* _LINUX_DEV_H */ diff --git a/ddverify/models/seq1/include/linux/notifier.h b/ddverify/models/seq1/include/linux/notifier.h new file mode 100644 index 000000000..1029f233e --- /dev/null +++ b/ddverify/models/seq1/include/linux/notifier.h @@ -0,0 +1,61 @@ +/* + * Routines to manage notifier chains for passing status changes to any + * interested routines. We need this instead of hard coded call lists so + * that modules can poke their nose into the innards. The network devices + * needed them so here they are for the rest of you. + * + * Alan Cox + */ + +#ifndef _LINUX_NOTIFIER_H +#define _LINUX_NOTIFIER_H +#include + + +struct notifier_block +{ + int (*notifier_call)(struct notifier_block *self, unsigned long, void *); + struct notifier_block *next; + int priority; +}; + +#define NOTIFY_DONE 0x0000 /* Don't care */ +#define NOTIFY_OK 0x0001 /* Suits me */ +#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ +#define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */ +/* + * Clean way to return from the notifier and stop further calls. + */ +#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) + +/* netdevice notifier chain */ +#define NETDEV_UP 0x0001 /* For now you can't veto a device up/down */ +#define NETDEV_DOWN 0x0002 +#define NETDEV_REBOOT 0x0003 /* Tell a protocol stack a network interface + detected a hardware crash and restarted + - we can use this eg to kick tcp sessions + once done */ +#define NETDEV_CHANGE 0x0004 /* Notify device state change */ +#define NETDEV_REGISTER 0x0005 +#define NETDEV_UNREGISTER 0x0006 +#define NETDEV_CHANGEMTU 0x0007 +#define NETDEV_CHANGEADDR 0x0008 +#define NETDEV_GOING_DOWN 0x0009 +#define NETDEV_CHANGENAME 0x000A +#define NETDEV_FEAT_CHANGE 0x000B + +#define SYS_DOWN 0x0001 /* Notify of system down */ +#define SYS_RESTART SYS_DOWN +#define SYS_HALT 0x0002 /* Notify of system halt */ +#define SYS_POWER_OFF 0x0003 /* Notify of system power off */ + +#define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */ + +#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ +#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ +#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ +#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ +#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ +#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ + +#endif /* _LINUX_NOTIFIER_H */ diff --git a/ddverify/models/seq1/include/linux/pagemap.h b/ddverify/models/seq1/include/linux/pagemap.h new file mode 100644 index 000000000..0525a9fc0 --- /dev/null +++ b/ddverify/models/seq1/include/linux/pagemap.h @@ -0,0 +1,15 @@ +#ifndef _LINUX_PAGEMAP_H +#define _LINUX_PAGEMAP_H + +/* + * Copyright 1995 Linus Torvalds + */ +#include +#include +#include +#include +#include +#include +#include + +#endif /* _LINUX_PAGEMAP_H */ diff --git a/ddverify/models/seq1/include/linux/parport.h b/ddverify/models/seq1/include/linux/parport.h new file mode 100644 index 000000000..4e29e513d --- /dev/null +++ b/ddverify/models/seq1/include/linux/parport.h @@ -0,0 +1,559 @@ +/* $Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea $ */ + +/* + * Any part of this program may be used in documents licensed under + * the GNU Free Documentation License, Version 1.1 or any later version + * published by the Free Software Foundation. + */ + +#ifndef _PARPORT_H_ +#define _PARPORT_H_ + +/* Start off with user-visible constants */ + +/* Maximum of 16 ports per machine */ +#define PARPORT_MAX 16 + +/* Magic numbers */ +#define PARPORT_IRQ_NONE -1 +#define PARPORT_DMA_NONE -1 +#define PARPORT_IRQ_AUTO -2 +#define PARPORT_DMA_AUTO -2 +#define PARPORT_DMA_NOFIFO -3 +#define PARPORT_DISABLE -2 +#define PARPORT_IRQ_PROBEONLY -3 +#define PARPORT_IOHI_AUTO -1 + +#define PARPORT_CONTROL_STROBE 0x1 +#define PARPORT_CONTROL_AUTOFD 0x2 +#define PARPORT_CONTROL_INIT 0x4 +#define PARPORT_CONTROL_SELECT 0x8 + +#define PARPORT_STATUS_ERROR 0x8 +#define PARPORT_STATUS_SELECT 0x10 +#define PARPORT_STATUS_PAPEROUT 0x20 +#define PARPORT_STATUS_ACK 0x40 +#define PARPORT_STATUS_BUSY 0x80 + +/* Type classes for Plug-and-Play probe. */ +typedef enum { + PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */ + PARPORT_CLASS_PRINTER, + PARPORT_CLASS_MODEM, + PARPORT_CLASS_NET, + PARPORT_CLASS_HDC, /* Hard disk controller */ + PARPORT_CLASS_PCMCIA, + PARPORT_CLASS_MEDIA, /* Multimedia device */ + PARPORT_CLASS_FDC, /* Floppy disk controller */ + PARPORT_CLASS_PORTS, + PARPORT_CLASS_SCANNER, + PARPORT_CLASS_DIGCAM, + PARPORT_CLASS_OTHER, /* Anything else */ + PARPORT_CLASS_UNSPEC, /* No CLS field in ID */ + PARPORT_CLASS_SCSIADAPTER +} parport_device_class; + +/* The "modes" entry in parport is a bit field representing the + capabilities of the hardware. */ +#define PARPORT_MODE_PCSPP (1<<0) /* IBM PC registers available. */ +#define PARPORT_MODE_TRISTATE (1<<1) /* Can tristate. */ +#define PARPORT_MODE_EPP (1<<2) /* Hardware EPP. */ +#define PARPORT_MODE_ECP (1<<3) /* Hardware ECP. */ +#define PARPORT_MODE_COMPAT (1<<4) /* Hardware 'printer protocol'. */ +#define PARPORT_MODE_DMA (1<<5) /* Hardware can DMA. */ +#define PARPORT_MODE_SAFEININT (1<<6) /* SPP registers accessible in IRQ. */ + +/* IEEE1284 modes: + Nibble mode, byte mode, ECP, ECPRLE and EPP are their own + 'extensibility request' values. Others are special. + 'Real' ECP modes must have the IEEE1284_MODE_ECP bit set. */ +#define IEEE1284_MODE_NIBBLE 0 +#define IEEE1284_MODE_BYTE (1<<0) +#define IEEE1284_MODE_COMPAT (1<<8) +#define IEEE1284_MODE_BECP (1<<9) /* Bounded ECP mode */ +#define IEEE1284_MODE_ECP (1<<4) +#define IEEE1284_MODE_ECPRLE (IEEE1284_MODE_ECP | (1<<5)) +#define IEEE1284_MODE_ECPSWE (1<<10) /* Software-emulated */ +#define IEEE1284_MODE_EPP (1<<6) +#define IEEE1284_MODE_EPPSL (1<<11) /* EPP 1.7 */ +#define IEEE1284_MODE_EPPSWE (1<<12) /* Software-emulated */ +#define IEEE1284_DEVICEID (1<<2) /* This is a flag */ +#define IEEE1284_EXT_LINK (1<<14) /* This flag causes the + * extensibility link to + * be requested, using + * bits 0-6. */ + +/* For the benefit of parport_read/write, you can use these with + * parport_negotiate to use address operations. They have no effect + * other than to make parport_read/write use address transfers. */ +#define IEEE1284_ADDR (1<<13) /* This is a flag */ +#define IEEE1284_DATA 0 /* So is this */ + +/* Flags for block transfer operations. */ +#define PARPORT_EPP_FAST (1<<0) /* Unreliable counts. */ +#define PARPORT_W91284PIC (1<<1) /* have a Warp9 w91284pic in the device */ + +#include +#include +#include +#include +#include +#include +#include + +/* Define this later. */ +struct parport; +struct pardevice; + +struct pc_parport_state { + unsigned int ctr; + unsigned int ecr; +}; + +struct ax_parport_state { + unsigned int ctr; + unsigned int ecr; + unsigned int dcsr; +}; + +/* used by both parport_amiga and parport_mfc3 */ +struct amiga_parport_state { + unsigned char data; /* ciaa.prb */ + unsigned char datadir; /* ciaa.ddrb */ + unsigned char status; /* ciab.pra & 7 */ + unsigned char statusdir;/* ciab.ddrb & 7 */ +}; + +struct ax88796_parport_state { + unsigned char cpr; +}; + +struct ip32_parport_state { + unsigned int dcr; + unsigned int ecr; +}; + +struct parport_state { + union { + struct pc_parport_state pc; + /* ARC has no state. */ + struct ax_parport_state ax; + struct amiga_parport_state amiga; + struct ax88796_parport_state ax88796; + /* Atari has not state. */ + struct ip32_parport_state ip32; + void *misc; + } u; +}; + +struct parport_operations { + /* IBM PC-style virtual registers. */ + void (*write_data)(struct parport *, unsigned char); + unsigned char (*read_data)(struct parport *); + + void (*write_control)(struct parport *, unsigned char); + unsigned char (*read_control)(struct parport *); + unsigned char (*frob_control)(struct parport *, unsigned char mask, + unsigned char val); + + unsigned char (*read_status)(struct parport *); + + /* IRQs. */ + void (*enable_irq)(struct parport *); + void (*disable_irq)(struct parport *); + + /* Data direction. */ + void (*data_forward) (struct parport *); + void (*data_reverse) (struct parport *); + + /* For core parport code. */ + void (*init_state)(struct pardevice *, struct parport_state *); + void (*save_state)(struct parport *, struct parport_state *); + void (*restore_state)(struct parport *, struct parport_state *); + + /* Block read/write */ + size_t (*epp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*epp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_addr) (struct parport *port, void *buf, size_t len, + int flags); + + size_t (*ecp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*ecp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*ecp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + + size_t (*compat_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*nibble_read_data) (struct parport *port, void *buf, + size_t len, int flags); + size_t (*byte_read_data) (struct parport *port, void *buf, + size_t len, int flags); + struct module *owner; +}; + +struct parport_device_info { + parport_device_class class; + const char *class_name; + const char *mfr; + const char *model; + const char *cmdset; + const char *description; +}; + +/* Each device can have two callback functions: + * 1) a preemption function, called by the resource manager to request + * that the driver relinquish control of the port. The driver should + * return zero if it agrees to release the port, and nonzero if it + * refuses. Do not call parport_release() - the kernel will do this + * implicitly. + * + * 2) a wake-up function, called by the resource manager to tell drivers + * that the port is available to be claimed. If a driver wants to use + * the port, it should call parport_claim() here. + */ + +/* A parallel port device */ +struct pardevice { + const char *name; + struct parport *port; + int daisy; + int (*preempt)(void *); + void (*wakeup)(void *); + void *private; + void (*irq_func)(int, void *); + unsigned int flags; + struct pardevice *next; + struct pardevice *prev; + struct parport_state *state; /* saved status over preemption */ + wait_queue_head_t wait_q; + unsigned long int time; + unsigned long int timeslice; + volatile long int timeout; + unsigned long waiting; /* long req'd for set_bit --RR */ + struct pardevice *waitprev; + struct pardevice *waitnext; + void * sysctl_table; +}; + +/* IEEE1284 information */ + +/* IEEE1284 phases. These are exposed to userland through ppdev IOCTL + * PP[GS]ETPHASE, so do not change existing values. */ +enum ieee1284_phase { + IEEE1284_PH_FWD_DATA, + IEEE1284_PH_FWD_IDLE, + IEEE1284_PH_TERMINATE, + IEEE1284_PH_NEGOTIATION, + IEEE1284_PH_HBUSY_DNA, + IEEE1284_PH_REV_IDLE, + IEEE1284_PH_HBUSY_DAVAIL, + IEEE1284_PH_REV_DATA, + IEEE1284_PH_ECP_SETUP, + IEEE1284_PH_ECP_FWD_TO_REV, + IEEE1284_PH_ECP_REV_TO_FWD, + IEEE1284_PH_ECP_DIR_UNKNOWN, +}; +struct ieee1284_info { + int mode; + volatile enum ieee1284_phase phase; + struct semaphore irq; +}; + +/* A parallel port */ +struct parport { + unsigned long base; /* base address */ + unsigned long base_hi; /* base address (hi - ECR) */ + unsigned int size; /* IO extent */ + const char *name; + unsigned int modes; + int irq; /* interrupt (or -1 for none) */ + int dma; + int muxport; /* which muxport (if any) this is */ + int portnum; /* which physical parallel port (not mux) */ + + struct parport *physport; + /* If this is a non-default mux + parport, i.e. we're a clone of a real + physical port, this is a pointer to that + port. The locking is only done in the + real port. For a clone port, the + following structure members are + meaningless: devices, cad, muxsel, + waithead, waittail, flags, pdir, + ieee1284, *_lock. + + It this is a default mux parport, or + there is no mux involved, this points to + ourself. */ + + struct pardevice *devices; + struct pardevice *cad; /* port owner */ + int daisy; /* currently selected daisy addr */ + int muxsel; /* currently selected mux port */ + + struct pardevice *waithead; + struct pardevice *waittail; + + struct list_head list; + unsigned int flags; + + void *sysctl_table; + struct parport_device_info probe_info[5]; /* 0-3 + non-IEEE1284.3 */ + struct ieee1284_info ieee1284; + + struct parport_operations *ops; + void *private_data; /* for lowlevel driver */ + + int number; /* port index - the `n' in `parportn' */ + spinlock_t pardevice_lock; + spinlock_t waitlist_lock; + rwlock_t cad_lock; + + int spintime; + atomic_t ref_count; + + struct list_head full_list; + struct parport *slaves[3]; +}; + +#define DEFAULT_SPIN_TIME 500 /* us */ + +struct parport_driver { + const char *name; + void (*attach) (struct parport *); + void (*detach) (struct parport *); + struct list_head list; +}; + +/* parport_register_port registers a new parallel port at the given + address (if one does not already exist) and returns a pointer to it. + This entails claiming the I/O region, IRQ and DMA. NULL is returned + if initialisation fails. */ +struct parport *parport_register_port(unsigned long base, int irq, int dma, + struct parport_operations *ops); + +/* Once a registered port is ready for high-level drivers to use, the + low-level driver that registered it should announce it. This will + call the high-level drivers' attach() functions (after things like + determining the IEEE 1284.3 topology of the port and collecting + DeviceIDs). */ +void parport_announce_port (struct parport *port); + +/* Unregister a port. */ +extern void parport_remove_port(struct parport *port); + +/* Register a new high-level driver. */ +extern int parport_register_driver (struct parport_driver *); + +/* Unregister a high-level driver. */ +extern void parport_unregister_driver (struct parport_driver *); + +/* If parport_register_driver doesn't fit your needs, perhaps + * parport_find_xxx does. */ +extern struct parport *parport_find_number (int); +extern struct parport *parport_find_base (unsigned long); + +/* Reference counting for ports. */ +extern struct parport *parport_get_port (struct parport *); +extern void parport_put_port (struct parport *); + +/* parport_register_device declares that a device is connected to a + port, and tells the kernel all it needs to know. + - pf is the preemption function (may be NULL for no callback) + - kf is the wake-up function (may be NULL for no callback) + - irq_func is the interrupt handler (may be NULL for no interrupts) + - handle is a user pointer that gets handed to callback functions. */ +struct pardevice *parport_register_device(struct parport *port, + const char *name, + int (*pf)(void *), void (*kf)(void *), + void (*irq_func)(int, void *), + int flags, void *handle); + +/* parport_unregister unlinks a device from the chain. */ +extern void parport_unregister_device(struct pardevice *dev); + +/* parport_claim tries to gain ownership of the port for a particular + driver. This may fail (return non-zero) if another driver is busy. + If this driver has registered an interrupt handler, it will be + enabled. */ +extern int parport_claim(struct pardevice *dev); + +/* parport_claim_or_block is the same, but sleeps if the port cannot + be claimed. Return value is 1 if it slept, 0 normally and -errno + on error. */ +extern int parport_claim_or_block(struct pardevice *dev); + +/* parport_release reverses a previous parport_claim. This can never + fail, though the effects are undefined (except that they are bad) + if you didn't previously own the port. Once you have released the + port you should make sure that neither your code nor the hardware + on the port tries to initiate any communication without first + re-claiming the port. If you mess with the port state (enabling + ECP for example) you should clean up before releasing the port. */ + +extern void parport_release(struct pardevice *dev); + +/** + * parport_yield - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim(), and the return value is the same as for + * parport_claim(). If it fails, the port is left unclaimed and it is + * the driver's responsibility to reclaim the port. + * + * The parport_yield() and parport_yield_blocking() functions are for + * marking points in the driver at which other drivers may claim the + * port and use their devices. Yielding the port is similar to + * releasing it and reclaiming it, but is more efficient because no + * action is taken if there are no other devices needing the port. In + * fact, nothing is done even if there are other devices waiting but + * the current device is still within its "timeslice". The default + * timeslice is half a second, but it can be adjusted via the /proc + * interface. + **/ +static __inline__ int parport_yield(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim(dev); +} + +/** + * parport_yield_blocking - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim_or_block(), and the return value is the same as for + * parport_claim_or_block(). + **/ +static __inline__ int parport_yield_blocking(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim_or_block(dev); +} + +/* Flags used to identify what a device does. */ +#define PARPORT_DEV_TRAN 0 /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_LURK (1<<0) /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_EXCL (1<<1) /* Need exclusive access. */ + +#define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */ + +/* IEEE1284 functions */ +extern void parport_ieee1284_interrupt (int, void *); +extern int parport_negotiate (struct parport *, int mode); +extern ssize_t parport_write (struct parport *, const void *buf, size_t len); +extern ssize_t parport_read (struct parport *, void *buf, size_t len); + +#define PARPORT_INACTIVITY_O_NONBLOCK 1 +extern long parport_set_timeout (struct pardevice *, long inactivity); + +extern int parport_wait_event (struct parport *, long timeout); +extern int parport_wait_peripheral (struct parport *port, + unsigned char mask, + unsigned char val); +extern int parport_poll_peripheral (struct parport *port, + unsigned char mask, + unsigned char val, + int usec); + +/* For architectural drivers */ +extern size_t parport_ieee1284_write_compat (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_read_nibble (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_read_byte (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_epp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_addr (struct parport *, + void *, size_t, int); + +/* IEEE1284.3 functions */ +extern int parport_daisy_init (struct parport *port); +extern void parport_daisy_fini (struct parport *port); +extern struct pardevice *parport_open (int devnum, const char *name, + int (*pf) (void *), + void (*kf) (void *), + void (*irqf) (int, void *), + int flags, void *handle); +extern void parport_close (struct pardevice *dev); +extern ssize_t parport_device_id (int devnum, char *buffer, size_t len); +extern int parport_device_num (int parport, int mux, int daisy); +extern void parport_daisy_deselect_all (struct parport *port); +extern int parport_daisy_select (struct parport *port, int daisy, int mode); + +/* Lowlevel drivers _can_ call this support function to handle irqs. */ +/* +static __inline__ void parport_generic_irq(int irq, struct parport *port) +{ + parport_ieee1284_interrupt (irq, port); + read_lock(&port->cad_lock); + if (port->cad && port->cad->irq_func) + port->cad->irq_func(irq, port->cad->private); + read_unlock(&port->cad_lock); +} +*/ + +/* Prototypes from parport_procfs */ +extern int parport_proc_register(struct parport *pp); +extern int parport_proc_unregister(struct parport *pp); +extern int parport_device_proc_register(struct pardevice *device); +extern int parport_device_proc_unregister(struct pardevice *device); + +/* If PC hardware is the only type supported, we can optimise a bit. */ +#if !defined(CONFIG_PARPORT_NOT_PC) + +#include +#define parport_write_data(p,x) parport_pc_write_data(p,x) +#define parport_read_data(p) parport_pc_read_data(p) +#define parport_write_control(p,x) parport_pc_write_control(p,x) +#define parport_read_control(p) parport_pc_read_control(p) +#define parport_frob_control(p,m,v) parport_pc_frob_control(p,m,v) +#define parport_read_status(p) parport_pc_read_status(p) +#define parport_enable_irq(p) parport_pc_enable_irq(p) +#define parport_disable_irq(p) parport_pc_disable_irq(p) +#define parport_data_forward(p) parport_pc_data_forward(p) +#define parport_data_reverse(p) parport_pc_data_reverse(p) + +#else /* !CONFIG_PARPORT_NOT_PC */ + +/* Generic operations vector through the dispatch table. */ +#define parport_write_data(p,x) (p)->ops->write_data(p,x) +#define parport_read_data(p) (p)->ops->read_data(p) +#define parport_write_control(p,x) (p)->ops->write_control(p,x) +#define parport_read_control(p) (p)->ops->read_control(p) +#define parport_frob_control(p,m,v) (p)->ops->frob_control(p,m,v) +#define parport_read_status(p) (p)->ops->read_status(p) +#define parport_enable_irq(p) (p)->ops->enable_irq(p) +#define parport_disable_irq(p) (p)->ops->disable_irq(p) +#define parport_data_forward(p) (p)->ops->data_forward(p) +#define parport_data_reverse(p) (p)->ops->data_reverse(p) + +#endif /* !CONFIG_PARPORT_NOT_PC */ + +#endif /* _PARPORT_H_ */ diff --git a/ddverify/models/seq1/include/linux/parport_pc.h b/ddverify/models/seq1/include/linux/parport_pc.h new file mode 100644 index 000000000..1c6df907d --- /dev/null +++ b/ddverify/models/seq1/include/linux/parport_pc.h @@ -0,0 +1,42 @@ +#ifndef __LINUX_PARPORT_PC_H +#define __LINUX_PARPORT_PC_H + +#include + +/* --- register definitions ------------------------------- */ + +#define ECONTROL(p) ((p)->base_hi + 0x2) +#define CONFIGB(p) ((p)->base_hi + 0x1) +#define CONFIGA(p) ((p)->base_hi + 0x0) +#define FIFO(p) ((p)->base_hi + 0x0) +#define EPPDATA(p) ((p)->base + 0x4) +#define EPPADDR(p) ((p)->base + 0x3) +#define CONTROL(p) ((p)->base + 0x2) +#define STATUS(p) ((p)->base + 0x1) +#define DATA(p) ((p)->base + 0x0) + +struct parport_pc_private { + int something; +}; + +struct parport_pc_via_data +{ + int something; +}; + +void parport_pc_write_data(struct parport *p, unsigned char d); +unsigned char parport_pc_read_data(struct parport *p); +void parport_pc_data_reverse (struct parport *p); +void parport_pc_data_forward (struct parport *p); +void parport_pc_write_control (struct parport *p, unsigned char d); +unsigned char parport_pc_read_control(struct parport *p); +unsigned char parport_pc_frob_control (struct parport *p, + unsigned char mask, + unsigned char val); +unsigned char parport_pc_read_status(struct parport *p); +void parport_pc_disable_irq(struct parport *p); +void parport_pc_enable_irq(struct parport *p); +void parport_pc_release_resources(struct parport *p); +int parport_pc_claim_resources(struct parport *p); + +#endif diff --git a/ddverify/models/seq1/include/linux/pci.h b/ddverify/models/seq1/include/linux/pci.h new file mode 100644 index 000000000..e2076f1a4 --- /dev/null +++ b/ddverify/models/seq1/include/linux/pci.h @@ -0,0 +1,176 @@ +#ifndef LINUX_PCI_H +#define LINUX_PCI_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Include the pci register defines */ +#include + +/* Include the ID list */ +#include + +/* + * The PCI interface treats multi-function devices as independent + * devices. The slot/function address of each device is encoded + * in a single byte as follows: + * + * 7:3 = slot + * 2:0 = function + */ +#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) +#define PCI_FUNC(devfn) ((devfn) & 0x07) + +/* This defines the direction arg to the DMA mapping routines. */ +#define PCI_DMA_BIDIRECTIONAL 0 +#define PCI_DMA_TODEVICE 1 +#define PCI_DMA_FROMDEVICE 2 +#define PCI_DMA_NONE 3 + +#define DEVICE_COUNT_COMPATIBLE 4 +#define DEVICE_COUNT_RESOURCE 12 + +typedef int __bitwise pci_power_t; + + +struct pci_dev { + struct pci_bus *bus; /* bus this device is on */ + + unsigned int devfn; /* encoded device & function index */ + unsigned short vendor; + unsigned short device; + + + u64 dma_mask; + + struct device dev; + + unsigned int irq; + struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ +}; + + +#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) + +struct pci_bus { + unsigned char number; /* bus number */ +}; + + +struct pci_driver { + char *name; + const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */ + int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ + void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ + int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ + int (*resume) (struct pci_dev *dev); /* Device woken up */ + int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ + void (*shutdown) (struct pci_dev *dev); +}; + +#define PCI_DEVICE(vend,dev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID + + +// DDV: Does not need a body! Return an arbitrary integer. +int pci_dev_present(const struct pci_device_id *ids); + +// DDV: Body for this function is defined in linux/pci.c +struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); + + +/* Similar to the helpers above, these manipulate per-pci_dev + * driver-specific data. They are really just a wrapper around + * the generic device structure functions of these calls. + */ +static inline void *pci_get_drvdata (struct pci_dev *pdev) +{ + return dev_get_drvdata(&pdev->dev); +} + +static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) +{ + dev_set_drvdata(&pdev->dev, data); +} + +int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); +int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); +int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); +int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); +int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); +int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); + +static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) +{ + return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) +{ + return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) +{ + return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) +{ + return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) +{ + return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) +{ + return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); +} + +int pci_set_dma_mask(struct pci_dev *dev, u64 mask); +void pci_set_master(struct pci_dev *dev); + + +// DDV: Body for this function is defined in linux/pci.c +int pci_register_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +void pci_unregister_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +int pci_enable_device(struct pci_dev *dev); +// DDV: No body for this function +void pci_disable_device(struct pci_dev *dev); + + +#define HAVE_PCI_REQ_REGIONS 2 +// DDV: Body for this function is defined in linux/pci.c +int pci_request_regions(struct pci_dev *, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_regions(struct pci_dev *); +// DDV: Body for this function is defined in linux/pci.c +int pci_request_region(struct pci_dev *, int, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_region(struct pci_dev *, int); + + +#include + +/* these helpers provide future and backwards compatibility + * for accessing popular PCI BAR info */ +#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) +#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) +#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) +#define pci_resource_len(dev,bar) \ + ((pci_resource_start((dev),(bar)) == 0 && \ + pci_resource_end((dev),(bar)) == \ + pci_resource_start((dev),(bar))) ? 0 : \ + \ + (pci_resource_end((dev),(bar)) - \ + pci_resource_start((dev),(bar)) + 1)) + +#endif /* LINUX_PCI_H */ diff --git a/ddverify/models/seq1/include/linux/pci_ids.h b/ddverify/models/seq1/include/linux/pci_ids.h new file mode 100644 index 000000000..a3a09cceb --- /dev/null +++ b/ddverify/models/seq1/include/linux/pci_ids.h @@ -0,0 +1,2260 @@ +/* + * PCI Class, Vendor and Device IDs + * + * Please keep sorted. + */ + +/* Device classes and subclasses */ + +#define PCI_CLASS_NOT_DEFINED 0x0000 +#define PCI_CLASS_NOT_DEFINED_VGA 0x0001 + +#define PCI_BASE_CLASS_STORAGE 0x01 +#define PCI_CLASS_STORAGE_SCSI 0x0100 +#define PCI_CLASS_STORAGE_IDE 0x0101 +#define PCI_CLASS_STORAGE_FLOPPY 0x0102 +#define PCI_CLASS_STORAGE_IPI 0x0103 +#define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SAS 0x0107 +#define PCI_CLASS_STORAGE_OTHER 0x0180 + +#define PCI_BASE_CLASS_NETWORK 0x02 +#define PCI_CLASS_NETWORK_ETHERNET 0x0200 +#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 +#define PCI_CLASS_NETWORK_FDDI 0x0202 +#define PCI_CLASS_NETWORK_ATM 0x0203 +#define PCI_CLASS_NETWORK_OTHER 0x0280 + +#define PCI_BASE_CLASS_DISPLAY 0x03 +#define PCI_CLASS_DISPLAY_VGA 0x0300 +#define PCI_CLASS_DISPLAY_XGA 0x0301 +#define PCI_CLASS_DISPLAY_3D 0x0302 +#define PCI_CLASS_DISPLAY_OTHER 0x0380 + +#define PCI_BASE_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400 +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 +#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402 +#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480 + +#define PCI_BASE_CLASS_MEMORY 0x05 +#define PCI_CLASS_MEMORY_RAM 0x0500 +#define PCI_CLASS_MEMORY_FLASH 0x0501 +#define PCI_CLASS_MEMORY_OTHER 0x0580 + +#define PCI_BASE_CLASS_BRIDGE 0x06 +#define PCI_CLASS_BRIDGE_HOST 0x0600 +#define PCI_CLASS_BRIDGE_ISA 0x0601 +#define PCI_CLASS_BRIDGE_EISA 0x0602 +#define PCI_CLASS_BRIDGE_MC 0x0603 +#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_BRIDGE_PCMCIA 0x0605 +#define PCI_CLASS_BRIDGE_NUBUS 0x0606 +#define PCI_CLASS_BRIDGE_CARDBUS 0x0607 +#define PCI_CLASS_BRIDGE_RACEWAY 0x0608 +#define PCI_CLASS_BRIDGE_OTHER 0x0680 + +#define PCI_BASE_CLASS_COMMUNICATION 0x07 +#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700 +#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701 +#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702 +#define PCI_CLASS_COMMUNICATION_MODEM 0x0703 +#define PCI_CLASS_COMMUNICATION_OTHER 0x0780 + +#define PCI_BASE_CLASS_SYSTEM 0x08 +#define PCI_CLASS_SYSTEM_PIC 0x0800 +#define PCI_CLASS_SYSTEM_PIC_IOAPIC 0x080010 +#define PCI_CLASS_SYSTEM_PIC_IOXAPIC 0x080020 +#define PCI_CLASS_SYSTEM_DMA 0x0801 +#define PCI_CLASS_SYSTEM_TIMER 0x0802 +#define PCI_CLASS_SYSTEM_RTC 0x0803 +#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804 +#define PCI_CLASS_SYSTEM_OTHER 0x0880 + +#define PCI_BASE_CLASS_INPUT 0x09 +#define PCI_CLASS_INPUT_KEYBOARD 0x0900 +#define PCI_CLASS_INPUT_PEN 0x0901 +#define PCI_CLASS_INPUT_MOUSE 0x0902 +#define PCI_CLASS_INPUT_SCANNER 0x0903 +#define PCI_CLASS_INPUT_GAMEPORT 0x0904 +#define PCI_CLASS_INPUT_OTHER 0x0980 + +#define PCI_BASE_CLASS_DOCKING 0x0a +#define PCI_CLASS_DOCKING_GENERIC 0x0a00 +#define PCI_CLASS_DOCKING_OTHER 0x0a80 + +#define PCI_BASE_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_PROCESSOR_386 0x0b00 +#define PCI_CLASS_PROCESSOR_486 0x0b01 +#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02 +#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10 +#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20 +#define PCI_CLASS_PROCESSOR_MIPS 0x0b30 +#define PCI_CLASS_PROCESSOR_CO 0x0b40 + +#define PCI_BASE_CLASS_SERIAL 0x0c +#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00 +#define PCI_CLASS_SERIAL_ACCESS 0x0c01 +#define PCI_CLASS_SERIAL_SSA 0x0c02 +#define PCI_CLASS_SERIAL_USB 0x0c03 +#define PCI_CLASS_SERIAL_USB_UHCI 0x0c0300 +#define PCI_CLASS_SERIAL_USB_OHCI 0x0c0310 +#define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320 +#define PCI_CLASS_SERIAL_FIBER 0x0c04 +#define PCI_CLASS_SERIAL_SMBUS 0x0c05 + +#define PCI_BASE_CLASS_INTELLIGENT 0x0e +#define PCI_CLASS_INTELLIGENT_I2O 0x0e00 + +#define PCI_BASE_CLASS_SATELLITE 0x0f +#define PCI_CLASS_SATELLITE_TV 0x0f00 +#define PCI_CLASS_SATELLITE_AUDIO 0x0f01 +#define PCI_CLASS_SATELLITE_VOICE 0x0f03 +#define PCI_CLASS_SATELLITE_DATA 0x0f04 + +#define PCI_BASE_CLASS_CRYPT 0x10 +#define PCI_CLASS_CRYPT_NETWORK 0x1000 +#define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001 +#define PCI_CLASS_CRYPT_OTHER 0x1080 + +#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11 +#define PCI_CLASS_SP_DPIO 0x1100 +#define PCI_CLASS_SP_OTHER 0x1180 + +#define PCI_CLASS_OTHERS 0xff + +/* Vendors and devices. Sort key: vendor first, device next. */ + +#define PCI_VENDOR_ID_DYNALINK 0x0675 +#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702 + +#define PCI_VENDOR_ID_BERKOM 0x0871 +#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1 +#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2 +#define PCI_DEVICE_ID_BERKOM_A4T 0xffa4 +#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xffa8 + +#define PCI_VENDOR_ID_COMPAQ 0x0e11 +#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508 +#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc +#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10 +#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32 +#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34 +#define PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE 0xae33 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35 +#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40 +#define PCI_DEVICE_ID_COMPAQ_NETEL100PI 0xae43 +#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011 +#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060 +#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178 +#define PCI_DEVICE_ID_COMPAQ_CISSC 0x46 +#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150 + +#define PCI_VENDOR_ID_NCR 0x1000 +#define PCI_VENDOR_ID_LSI_LOGIC 0x1000 +#define PCI_DEVICE_ID_NCR_53C810 0x0001 +#define PCI_DEVICE_ID_NCR_53C820 0x0002 +#define PCI_DEVICE_ID_NCR_53C825 0x0003 +#define PCI_DEVICE_ID_NCR_53C815 0x0004 +#define PCI_DEVICE_ID_LSI_53C810AP 0x0005 +#define PCI_DEVICE_ID_NCR_53C860 0x0006 +#define PCI_DEVICE_ID_LSI_53C1510 0x000a +#define PCI_DEVICE_ID_NCR_53C896 0x000b +#define PCI_DEVICE_ID_NCR_53C895 0x000c +#define PCI_DEVICE_ID_NCR_53C885 0x000d +#define PCI_DEVICE_ID_NCR_53C875 0x000f +#define PCI_DEVICE_ID_NCR_53C1510 0x0010 +#define PCI_DEVICE_ID_LSI_53C895A 0x0012 +#define PCI_DEVICE_ID_LSI_53C875A 0x0013 +#define PCI_DEVICE_ID_LSI_53C1010_33 0x0020 +#define PCI_DEVICE_ID_LSI_53C1010_66 0x0021 +#define PCI_DEVICE_ID_LSI_53C1030 0x0030 +#define PCI_DEVICE_ID_LSI_1030_53C1035 0x0032 +#define PCI_DEVICE_ID_LSI_53C1035 0x0040 +#define PCI_DEVICE_ID_NCR_53C875J 0x008f +#define PCI_DEVICE_ID_LSI_FC909 0x0621 +#define PCI_DEVICE_ID_LSI_FC929 0x0622 +#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623 +#define PCI_DEVICE_ID_LSI_FC919 0x0624 +#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625 +#define PCI_DEVICE_ID_LSI_FC929X 0x0626 +#define PCI_DEVICE_ID_LSI_FC939X 0x0642 +#define PCI_DEVICE_ID_LSI_FC949X 0x0640 +#define PCI_DEVICE_ID_LSI_FC949ES 0x0646 +#define PCI_DEVICE_ID_LSI_FC919X 0x0628 +#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701 +#define PCI_DEVICE_ID_LSI_61C102 0x0901 +#define PCI_DEVICE_ID_LSI_63C815 0x1000 +#define PCI_DEVICE_ID_LSI_SAS1064 0x0050 +#define PCI_DEVICE_ID_LSI_SAS1064R 0x0411 +#define PCI_DEVICE_ID_LSI_SAS1066 0x005E +#define PCI_DEVICE_ID_LSI_SAS1068 0x0054 +#define PCI_DEVICE_ID_LSI_SAS1064A 0x005C +#define PCI_DEVICE_ID_LSI_SAS1064E 0x0056 +#define PCI_DEVICE_ID_LSI_SAS1066E 0x005A +#define PCI_DEVICE_ID_LSI_SAS1068E 0x0058 +#define PCI_DEVICE_ID_LSI_SAS1078 0x0060 + +#define PCI_VENDOR_ID_ATI 0x1002 +/* Mach64 */ +#define PCI_DEVICE_ID_ATI_68800 0x4158 +#define PCI_DEVICE_ID_ATI_215CT222 0x4354 +#define PCI_DEVICE_ID_ATI_210888CX 0x4358 +#define PCI_DEVICE_ID_ATI_215ET222 0x4554 +/* Mach64 / Rage */ +#define PCI_DEVICE_ID_ATI_215GB 0x4742 +#define PCI_DEVICE_ID_ATI_215GD 0x4744 +#define PCI_DEVICE_ID_ATI_215GI 0x4749 +#define PCI_DEVICE_ID_ATI_215GP 0x4750 +#define PCI_DEVICE_ID_ATI_215GQ 0x4751 +#define PCI_DEVICE_ID_ATI_215XL 0x4752 +#define PCI_DEVICE_ID_ATI_215GT 0x4754 +#define PCI_DEVICE_ID_ATI_215GTB 0x4755 +#define PCI_DEVICE_ID_ATI_215_IV 0x4756 +#define PCI_DEVICE_ID_ATI_215_IW 0x4757 +#define PCI_DEVICE_ID_ATI_215_IZ 0x475A +#define PCI_DEVICE_ID_ATI_210888GX 0x4758 +#define PCI_DEVICE_ID_ATI_215_LB 0x4c42 +#define PCI_DEVICE_ID_ATI_215_LD 0x4c44 +#define PCI_DEVICE_ID_ATI_215_LG 0x4c47 +#define PCI_DEVICE_ID_ATI_215_LI 0x4c49 +#define PCI_DEVICE_ID_ATI_215_LM 0x4c4D +#define PCI_DEVICE_ID_ATI_215_LN 0x4c4E +#define PCI_DEVICE_ID_ATI_215_LR 0x4c52 +#define PCI_DEVICE_ID_ATI_215_LS 0x4c53 +#define PCI_DEVICE_ID_ATI_264_LT 0x4c54 +/* Mach64 VT */ +#define PCI_DEVICE_ID_ATI_264VT 0x5654 +#define PCI_DEVICE_ID_ATI_264VU 0x5655 +#define PCI_DEVICE_ID_ATI_264VV 0x5656 +/* Rage128 GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245 +#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246 +#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x5247 +/* Rage128 VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b +#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c +#define PCI_DEVICE_ID_ATI_RAGE128_SE 0x5345 +#define PCI_DEVICE_ID_ATI_RAGE128_SF 0x5346 +#define PCI_DEVICE_ID_ATI_RAGE128_SG 0x5347 +#define PCI_DEVICE_ID_ATI_RAGE128_SH 0x5348 +#define PCI_DEVICE_ID_ATI_RAGE128_SK 0x534b +#define PCI_DEVICE_ID_ATI_RAGE128_SL 0x534c +#define PCI_DEVICE_ID_ATI_RAGE128_SM 0x534d +#define PCI_DEVICE_ID_ATI_RAGE128_SN 0x534e +/* Rage128 Ultra */ +#define PCI_DEVICE_ID_ATI_RAGE128_TF 0x5446 +#define PCI_DEVICE_ID_ATI_RAGE128_TL 0x544c +#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452 +#define PCI_DEVICE_ID_ATI_RAGE128_TS 0x5453 +#define PCI_DEVICE_ID_ATI_RAGE128_TT 0x5454 +#define PCI_DEVICE_ID_ATI_RAGE128_TU 0x5455 +/* Rage128 M3 */ +#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45 +#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46 +/* Rage128 M4 */ +#define PCI_DEVICE_ID_ATI_RAGE128_MF 0x4d46 +#define PCI_DEVICE_ID_ATI_RAGE128_ML 0x4d4c +/* Rage128 Pro GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_PA 0x5041 +#define PCI_DEVICE_ID_ATI_RAGE128_PB 0x5042 +#define PCI_DEVICE_ID_ATI_RAGE128_PC 0x5043 +#define PCI_DEVICE_ID_ATI_RAGE128_PD 0x5044 +#define PCI_DEVICE_ID_ATI_RAGE128_PE 0x5045 +#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046 +/* Rage128 Pro VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047 +#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048 +#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049 +#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A +#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B +#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C +#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D +#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E +#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F +#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050 +#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051 +#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052 +#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053 +#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054 +#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055 +#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056 +#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057 +#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058 +/* Rage128 M4 */ +/* Radeon R100 */ +#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144 +#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145 +#define PCI_DEVICE_ID_ATI_RADEON_QF 0x5146 +#define PCI_DEVICE_ID_ATI_RADEON_QG 0x5147 +/* Radeon RV100 (VE) */ +#define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 +#define PCI_DEVICE_ID_ATI_RADEON_QZ 0x515a +/* Radeon R200 (8500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QL 0x514c +#define PCI_DEVICE_ID_ATI_RADEON_QN 0x514e +#define PCI_DEVICE_ID_ATI_RADEON_QO 0x514f +#define PCI_DEVICE_ID_ATI_RADEON_Ql 0x516c +#define PCI_DEVICE_ID_ATI_RADEON_BB 0x4242 +/* Radeon R200 (9100) */ +#define PCI_DEVICE_ID_ATI_RADEON_QM 0x514d +/* Radeon RV200 (7500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157 +#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158 +/* Radeon NV-100 */ +/* Radeon RV250 (9000) */ +#define PCI_DEVICE_ID_ATI_RADEON_Id 0x4964 +#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965 +#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966 +#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967 +/* Radeon RV280 (9200) */ +#define PCI_DEVICE_ID_ATI_RADEON_Ya 0x5961 +#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964 +/* Radeon R300 (9500) */ +/* Radeon R300 (9700) */ +#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44 +#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45 +#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46 +#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47 +/* Radeon R350 (9800) */ +/* Radeon RV350 (9600) */ +/* Radeon M6 */ +#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59 +#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a +/* Radeon M7 */ +#define PCI_DEVICE_ID_ATI_RADEON_LW 0x4c57 +#define PCI_DEVICE_ID_ATI_RADEON_LX 0x4c58 +/* Radeon M9 */ +#define PCI_DEVICE_ID_ATI_RADEON_Ld 0x4c64 +#define PCI_DEVICE_ID_ATI_RADEON_Le 0x4c65 +#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66 +#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67 +/* Radeon */ +/* RadeonIGP */ +#define PCI_DEVICE_ID_ATI_RS100 0xcab0 +#define PCI_DEVICE_ID_ATI_RS200 0xcab2 +#define PCI_DEVICE_ID_ATI_RS200_B 0xcbb2 +#define PCI_DEVICE_ID_ATI_RS250 0xcab3 +#define PCI_DEVICE_ID_ATI_RS300_100 0x5830 +#define PCI_DEVICE_ID_ATI_RS300_133 0x5831 +#define PCI_DEVICE_ID_ATI_RS300_166 0x5832 +#define PCI_DEVICE_ID_ATI_RS300_200 0x5833 +#define PCI_DEVICE_ID_ATI_RS350_100 0x7830 +#define PCI_DEVICE_ID_ATI_RS350_133 0x7831 +#define PCI_DEVICE_ID_ATI_RS350_166 0x7832 +#define PCI_DEVICE_ID_ATI_RS350_200 0x7833 +#define PCI_DEVICE_ID_ATI_RS400_100 0x5a30 +#define PCI_DEVICE_ID_ATI_RS400_133 0x5a31 +#define PCI_DEVICE_ID_ATI_RS400_166 0x5a32 +#define PCI_DEVICE_ID_ATI_RS400_200 0x5a33 +#define PCI_DEVICE_ID_ATI_RS480 0x5950 +/* ATI IXP Chipset */ +#define PCI_DEVICE_ID_ATI_IXP200_IDE 0x4349 +#define PCI_DEVICE_ID_ATI_IXP300_IDE 0x4369 +#define PCI_DEVICE_ID_ATI_IXP300_SATA 0x436e +#define PCI_DEVICE_ID_ATI_IXP400_IDE 0x4376 +#define PCI_DEVICE_ID_ATI_IXP400_SATA 0x4379 + +#define PCI_VENDOR_ID_VLSI 0x1004 +#define PCI_DEVICE_ID_VLSI_82C592 0x0005 +#define PCI_DEVICE_ID_VLSI_82C593 0x0006 +#define PCI_DEVICE_ID_VLSI_82C594 0x0007 +#define PCI_DEVICE_ID_VLSI_82C597 0x0009 +#define PCI_DEVICE_ID_VLSI_82C541 0x000c +#define PCI_DEVICE_ID_VLSI_82C543 0x000d +#define PCI_DEVICE_ID_VLSI_82C532 0x0101 +#define PCI_DEVICE_ID_VLSI_82C534 0x0102 +#define PCI_DEVICE_ID_VLSI_82C535 0x0104 +#define PCI_DEVICE_ID_VLSI_82C147 0x0105 +#define PCI_DEVICE_ID_VLSI_VAS96011 0x0702 + +#define PCI_VENDOR_ID_ADL 0x1005 +#define PCI_DEVICE_ID_ADL_2301 0x2301 + +#define PCI_VENDOR_ID_NS 0x100b +#define PCI_DEVICE_ID_NS_87415 0x0002 +#define PCI_DEVICE_ID_NS_87560_LIO 0x000e +#define PCI_DEVICE_ID_NS_87560_USB 0x0012 +#define PCI_DEVICE_ID_NS_83815 0x0020 +#define PCI_DEVICE_ID_NS_83820 0x0022 +#define PCI_DEVICE_ID_NS_CS5535_ISA 0x002b +#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d +#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e +#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f +#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 +#define PCI_DEVICE_ID_NS_SATURN 0x0035 +#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 +#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 +#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502 +#define PCI_DEVICE_ID_NS_SCx200_AUDIO 0x0503 +#define PCI_DEVICE_ID_NS_SCx200_VIDEO 0x0504 +#define PCI_DEVICE_ID_NS_SCx200_XBUS 0x0505 +#define PCI_DEVICE_ID_NS_SC1100_BRIDGE 0x0510 +#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511 +#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 +#define PCI_DEVICE_ID_NS_87410 0xd001 + +#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 +#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b + +#define PCI_VENDOR_ID_TSENG 0x100c +#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 +#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205 +#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206 +#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207 +#define PCI_DEVICE_ID_TSENG_ET6000 0x3208 + +#define PCI_VENDOR_ID_WEITEK 0x100e +#define PCI_DEVICE_ID_WEITEK_P9000 0x9001 +#define PCI_DEVICE_ID_WEITEK_P9100 0x9100 + +#define PCI_VENDOR_ID_DEC 0x1011 +#define PCI_DEVICE_ID_DEC_BRD 0x0001 +#define PCI_DEVICE_ID_DEC_TULIP 0x0002 +#define PCI_DEVICE_ID_DEC_TGA 0x0004 +#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009 +#define PCI_DEVICE_ID_DEC_TGA2 0x000D +#define PCI_DEVICE_ID_DEC_FDDI 0x000F +#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014 +#define PCI_DEVICE_ID_DEC_21142 0x0019 +#define PCI_DEVICE_ID_DEC_21052 0x0021 +#define PCI_DEVICE_ID_DEC_21150 0x0022 +#define PCI_DEVICE_ID_DEC_21152 0x0024 +#define PCI_DEVICE_ID_DEC_21153 0x0025 +#define PCI_DEVICE_ID_DEC_21154 0x0026 +#define PCI_DEVICE_ID_DEC_21285 0x1065 +#define PCI_DEVICE_ID_COMPAQ_42XX 0x0046 + +#define PCI_VENDOR_ID_CIRRUS 0x1013 +#define PCI_DEVICE_ID_CIRRUS_7548 0x0038 +#define PCI_DEVICE_ID_CIRRUS_5430 0x00a0 +#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00a4 +#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00a8 +#define PCI_DEVICE_ID_CIRRUS_5436 0x00ac +#define PCI_DEVICE_ID_CIRRUS_5446 0x00b8 +#define PCI_DEVICE_ID_CIRRUS_5480 0x00bc +#define PCI_DEVICE_ID_CIRRUS_5462 0x00d0 +#define PCI_DEVICE_ID_CIRRUS_5464 0x00d4 +#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6 +#define PCI_DEVICE_ID_CIRRUS_6729 0x1100 +#define PCI_DEVICE_ID_CIRRUS_6832 0x1110 +#define PCI_DEVICE_ID_CIRRUS_7543 0x1202 +#define PCI_DEVICE_ID_CIRRUS_4610 0x6001 +#define PCI_DEVICE_ID_CIRRUS_4612 0x6003 +#define PCI_DEVICE_ID_CIRRUS_4615 0x6004 + +#define PCI_VENDOR_ID_IBM 0x1014 +#define PCI_DEVICE_ID_IBM_TR 0x0018 +#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e +#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc +#define PCI_DEVICE_ID_IBM_SNIPE 0x0180 +#define PCI_DEVICE_ID_IBM_CITRINE 0x028C +#define PCI_DEVICE_ID_IBM_GEMSTONE 0xB166 +#define PCI_DEVICE_ID_IBM_OBSIDIAN 0x02BD +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1 0x0031 +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2 0x0219 +#define PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX 0x021A +#define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251 +#define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252 + +#define PCI_VENDOR_ID_COMPEX2 0x101a /* pci.ids says "AT&T GIS (NCR)" */ +#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005 + +#define PCI_VENDOR_ID_WD 0x101c +#define PCI_DEVICE_ID_WD_90C 0xc24a + +#define PCI_VENDOR_ID_AMI 0x101e +#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960 +#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010 +#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060 + +#define PCI_VENDOR_ID_AMD 0x1022 +#define PCI_DEVICE_ID_AMD_K8_NB 0x1100 +#define PCI_DEVICE_ID_AMD_LANCE 0x2000 +#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001 +#define PCI_DEVICE_ID_AMD_SCSI 0x2020 +#define PCI_DEVICE_ID_AMD_SERENADE 0x36c0 +#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006 +#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007 +#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C +#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E +#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401 +#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409 +#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B +#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410 +#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411 +#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413 +#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440 +#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441 +#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443 +#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443 +#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445 +#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468 +#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469 +#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a +#define PCI_DEVICE_ID_AMD_8111_SMBUS 0x746b +#define PCI_DEVICE_ID_AMD_8111_AUDIO 0x746d +#define PCI_DEVICE_ID_AMD_8151_0 0x7454 +#define PCI_DEVICE_ID_AMD_8131_APIC 0x7450 +#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090 +#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091 +#define PCI_DEVICE_ID_AMD_CS5536_AUDIO 0x2093 +#define PCI_DEVICE_ID_AMD_CS5536_OHC 0x2094 +#define PCI_DEVICE_ID_AMD_CS5536_EHC 0x2095 +#define PCI_DEVICE_ID_AMD_CS5536_UDC 0x2096 +#define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097 +#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A + +#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 +#define PCI_DEVICE_ID_AMD_LX_AES 0x2082 + +#define PCI_VENDOR_ID_TRIDENT 0x1023 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001 +#define PCI_DEVICE_ID_TRIDENT_9320 0x9320 +#define PCI_DEVICE_ID_TRIDENT_9388 0x9388 +#define PCI_DEVICE_ID_TRIDENT_9397 0x9397 +#define PCI_DEVICE_ID_TRIDENT_939A 0x939A +#define PCI_DEVICE_ID_TRIDENT_9520 0x9520 +#define PCI_DEVICE_ID_TRIDENT_9525 0x9525 +#define PCI_DEVICE_ID_TRIDENT_9420 0x9420 +#define PCI_DEVICE_ID_TRIDENT_9440 0x9440 +#define PCI_DEVICE_ID_TRIDENT_9660 0x9660 +#define PCI_DEVICE_ID_TRIDENT_9750 0x9750 +#define PCI_DEVICE_ID_TRIDENT_9850 0x9850 +#define PCI_DEVICE_ID_TRIDENT_9880 0x9880 +#define PCI_DEVICE_ID_TRIDENT_8400 0x8400 +#define PCI_DEVICE_ID_TRIDENT_8420 0x8420 +#define PCI_DEVICE_ID_TRIDENT_8500 0x8500 + +#define PCI_VENDOR_ID_AI 0x1025 +#define PCI_DEVICE_ID_AI_M1435 0x1435 + +#define PCI_VENDOR_ID_DELL 0x1028 +#define PCI_DEVICE_ID_DELL_RACIII 0x0008 +#define PCI_DEVICE_ID_DELL_RAC4 0x0012 +#define PCI_DEVICE_ID_DELL_PERC5 0x0015 + +#define PCI_VENDOR_ID_MATROX 0x102B +#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518 +#define PCI_DEVICE_ID_MATROX_MIL 0x0519 +#define PCI_DEVICE_ID_MATROX_MYS 0x051A +#define PCI_DEVICE_ID_MATROX_MIL_2 0x051b +#define PCI_DEVICE_ID_MATROX_MYS_AGP 0x051e +#define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f +#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10 +#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000 +#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001 +#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 +#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 +#define PCI_DEVICE_ID_MATROX_G400 0x0525 +#define PCI_DEVICE_ID_MATROX_G550 0x2527 +#define PCI_DEVICE_ID_MATROX_VIA 0x4536 + +#define PCI_VENDOR_ID_CT 0x102c +#define PCI_DEVICE_ID_CT_69000 0x00c0 +#define PCI_DEVICE_ID_CT_65545 0x00d8 +#define PCI_DEVICE_ID_CT_65548 0x00dc +#define PCI_DEVICE_ID_CT_65550 0x00e0 +#define PCI_DEVICE_ID_CT_65554 0x00e4 +#define PCI_DEVICE_ID_CT_65555 0x00e5 + +#define PCI_VENDOR_ID_MIRO 0x1031 +#define PCI_DEVICE_ID_MIRO_36050 0x5601 +#define PCI_DEVICE_ID_MIRO_DC10PLUS 0x7efe +#define PCI_DEVICE_ID_MIRO_DC30PLUS 0xd801 + +#define PCI_VENDOR_ID_NEC 0x1033 +#define PCI_DEVICE_ID_NEC_CBUS_1 0x0001 /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_LOCAL 0x0002 /* Local Bridge */ +#define PCI_DEVICE_ID_NEC_ATM 0x0003 /* ATM LAN Controller */ +#define PCI_DEVICE_ID_NEC_R4000 0x0004 /* R4000 Bridge */ +#define PCI_DEVICE_ID_NEC_486 0x0005 /* 486 Like Peripheral Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_1 0x0006 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_UXBUS 0x0007 /* UX-Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_2 0x0008 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_GRAPH 0x0009 /* PCI-CoreGraph Bridge */ +#define PCI_DEVICE_ID_NEC_VL 0x0016 /* PCI-VL Bridge */ +#define PCI_DEVICE_ID_NEC_STARALPHA2 0x002c /* STAR ALPHA2 */ +#define PCI_DEVICE_ID_NEC_CBUS_2 0x002d /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_USB 0x0035 /* PCI-USB Host */ +#define PCI_DEVICE_ID_NEC_CBUS_3 0x003b +#define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e +#define PCI_DEVICE_ID_NEC_PCX2 0x0046 /* PowerVR */ +#define PCI_DEVICE_ID_NEC_NILE4 0x005a +#define PCI_DEVICE_ID_NEC_VRC5476 0x009b +#define PCI_DEVICE_ID_NEC_VRC4173 0x00a5 +#define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6 +#define PCI_DEVICE_ID_NEC_PC9821CS01 0x800c /* PC-9821-CS01 */ +#define PCI_DEVICE_ID_NEC_PC9821NRB06 0x800d /* PC-9821NR-B06 */ + +#define PCI_VENDOR_ID_FD 0x1036 +#define PCI_DEVICE_ID_FD_36C70 0x0000 + +#define PCI_VENDOR_ID_SI 0x1039 +#define PCI_DEVICE_ID_SI_5591_AGP 0x0001 +#define PCI_DEVICE_ID_SI_6202 0x0002 +#define PCI_DEVICE_ID_SI_503 0x0008 +#define PCI_DEVICE_ID_SI_ACPI 0x0009 +#define PCI_DEVICE_ID_SI_SMBUS 0x0016 +#define PCI_DEVICE_ID_SI_LPC 0x0018 +#define PCI_DEVICE_ID_SI_5597_VGA 0x0200 +#define PCI_DEVICE_ID_SI_6205 0x0205 +#define PCI_DEVICE_ID_SI_501 0x0406 +#define PCI_DEVICE_ID_SI_496 0x0496 +#define PCI_DEVICE_ID_SI_300 0x0300 +#define PCI_DEVICE_ID_SI_315H 0x0310 +#define PCI_DEVICE_ID_SI_315 0x0315 +#define PCI_DEVICE_ID_SI_315PRO 0x0325 +#define PCI_DEVICE_ID_SI_530 0x0530 +#define PCI_DEVICE_ID_SI_540 0x0540 +#define PCI_DEVICE_ID_SI_550 0x0550 +#define PCI_DEVICE_ID_SI_540_VGA 0x5300 +#define PCI_DEVICE_ID_SI_550_VGA 0x5315 +#define PCI_DEVICE_ID_SI_620 0x0620 +#define PCI_DEVICE_ID_SI_630 0x0630 +#define PCI_DEVICE_ID_SI_633 0x0633 +#define PCI_DEVICE_ID_SI_635 0x0635 +#define PCI_DEVICE_ID_SI_640 0x0640 +#define PCI_DEVICE_ID_SI_645 0x0645 +#define PCI_DEVICE_ID_SI_646 0x0646 +#define PCI_DEVICE_ID_SI_648 0x0648 +#define PCI_DEVICE_ID_SI_650 0x0650 +#define PCI_DEVICE_ID_SI_651 0x0651 +#define PCI_DEVICE_ID_SI_655 0x0655 +#define PCI_DEVICE_ID_SI_661 0x0661 +#define PCI_DEVICE_ID_SI_730 0x0730 +#define PCI_DEVICE_ID_SI_733 0x0733 +#define PCI_DEVICE_ID_SI_630_VGA 0x6300 +#define PCI_DEVICE_ID_SI_735 0x0735 +#define PCI_DEVICE_ID_SI_740 0x0740 +#define PCI_DEVICE_ID_SI_741 0x0741 +#define PCI_DEVICE_ID_SI_745 0x0745 +#define PCI_DEVICE_ID_SI_746 0x0746 +#define PCI_DEVICE_ID_SI_755 0x0755 +#define PCI_DEVICE_ID_SI_760 0x0760 +#define PCI_DEVICE_ID_SI_900 0x0900 +#define PCI_DEVICE_ID_SI_961 0x0961 +#define PCI_DEVICE_ID_SI_962 0x0962 +#define PCI_DEVICE_ID_SI_963 0x0963 +#define PCI_DEVICE_ID_SI_965 0x0965 +#define PCI_DEVICE_ID_SI_5511 0x5511 +#define PCI_DEVICE_ID_SI_5513 0x5513 +#define PCI_DEVICE_ID_SI_5518 0x5518 +#define PCI_DEVICE_ID_SI_5571 0x5571 +#define PCI_DEVICE_ID_SI_5581 0x5581 +#define PCI_DEVICE_ID_SI_5582 0x5582 +#define PCI_DEVICE_ID_SI_5591 0x5591 +#define PCI_DEVICE_ID_SI_5596 0x5596 +#define PCI_DEVICE_ID_SI_5597 0x5597 +#define PCI_DEVICE_ID_SI_5598 0x5598 +#define PCI_DEVICE_ID_SI_5600 0x5600 +#define PCI_DEVICE_ID_SI_7012 0x7012 +#define PCI_DEVICE_ID_SI_7013 0x7013 +#define PCI_DEVICE_ID_SI_7016 0x7016 +#define PCI_DEVICE_ID_SI_7018 0x7018 + +#define PCI_VENDOR_ID_HP 0x103c +#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX6 0x1006 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX4 0x1008 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX2 0x100a +#define PCI_DEVICE_ID_HP_TACHYON 0x1028 +#define PCI_DEVICE_ID_HP_TACHLITE 0x1029 +#define PCI_DEVICE_ID_HP_J2585A 0x1030 +#define PCI_DEVICE_ID_HP_J2585B 0x1031 +#define PCI_DEVICE_ID_HP_J2973A 0x1040 +#define PCI_DEVICE_ID_HP_J2970A 0x1042 +#define PCI_DEVICE_ID_HP_DIVA 0x1048 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA1 0x1049 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA2 0x104A +#define PCI_DEVICE_ID_HP_DIVA_MAESTRO 0x104B +#define PCI_DEVICE_ID_HP_REO_IOC 0x10f1 +#define PCI_DEVICE_ID_HP_VISUALIZE_FXE 0x108b +#define PCI_DEVICE_ID_HP_DIVA_HALFDOME 0x1223 +#define PCI_DEVICE_ID_HP_DIVA_KEYSTONE 0x1226 +#define PCI_DEVICE_ID_HP_DIVA_POWERBAR 0x1227 +#define PCI_DEVICE_ID_HP_ZX1_IOC 0x122a +#define PCI_DEVICE_ID_HP_PCIX_LBA 0x122e +#define PCI_DEVICE_ID_HP_SX1000_IOC 0x127c +#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282 +#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 +#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 +#define PCI_DEVICE_ID_HP_DIVA_HURRICANE 0x132a +#define PCI_DEVICE_ID_HP_CISSA 0x3220 +#define PCI_DEVICE_ID_HP_CISSC 0x3230 +#define PCI_DEVICE_ID_HP_CISSD 0x3238 +#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 + +#define PCI_VENDOR_ID_PCTECH 0x1042 +#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000 +#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001 +#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020 + +#define PCI_VENDOR_ID_ASUSTEK 0x1043 +#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675 + +#define PCI_VENDOR_ID_DPT 0x1044 +#define PCI_DEVICE_ID_DPT 0xa400 + +#define PCI_VENDOR_ID_OPTI 0x1045 +#define PCI_DEVICE_ID_OPTI_82C558 0xc558 +#define PCI_DEVICE_ID_OPTI_82C621 0xc621 +#define PCI_DEVICE_ID_OPTI_82C700 0xc700 +#define PCI_DEVICE_ID_OPTI_82C825 0xd568 + +#define PCI_VENDOR_ID_ELSA 0x1048 +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000 +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000 + + +#define PCI_VENDOR_ID_BUSLOGIC 0x104B +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140 +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040 +#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130 + +#define PCI_VENDOR_ID_TI 0x104c +#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 +#define PCI_DEVICE_ID_TI_4450 0x8011 +#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 +#define PCI_DEVICE_ID_TI_X515 0x8036 +#define PCI_DEVICE_ID_TI_1130 0xac12 +#define PCI_DEVICE_ID_TI_1031 0xac13 +#define PCI_DEVICE_ID_TI_1131 0xac15 +#define PCI_DEVICE_ID_TI_1250 0xac16 +#define PCI_DEVICE_ID_TI_1220 0xac17 +#define PCI_DEVICE_ID_TI_1221 0xac19 +#define PCI_DEVICE_ID_TI_1210 0xac1a +#define PCI_DEVICE_ID_TI_1450 0xac1b +#define PCI_DEVICE_ID_TI_1225 0xac1c +#define PCI_DEVICE_ID_TI_1251A 0xac1d +#define PCI_DEVICE_ID_TI_1211 0xac1e +#define PCI_DEVICE_ID_TI_1251B 0xac1f +#define PCI_DEVICE_ID_TI_4410 0xac41 +#define PCI_DEVICE_ID_TI_4451 0xac42 +#define PCI_DEVICE_ID_TI_4510 0xac44 +#define PCI_DEVICE_ID_TI_4520 0xac46 +#define PCI_DEVICE_ID_TI_7510 0xac47 +#define PCI_DEVICE_ID_TI_7610 0xac48 +#define PCI_DEVICE_ID_TI_7410 0xac49 +#define PCI_DEVICE_ID_TI_1410 0xac50 +#define PCI_DEVICE_ID_TI_1420 0xac51 +#define PCI_DEVICE_ID_TI_1451A 0xac52 +#define PCI_DEVICE_ID_TI_1620 0xac54 +#define PCI_DEVICE_ID_TI_1520 0xac55 +#define PCI_DEVICE_ID_TI_1510 0xac56 +#define PCI_DEVICE_ID_TI_X620 0xac8d +#define PCI_DEVICE_ID_TI_X420 0xac8e + +#define PCI_VENDOR_ID_SONY 0x104d + + +/* Winbond have two vendor IDs! See 0x10ad as well */ +#define PCI_VENDOR_ID_WINBOND2 0x1050 +#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a +#define PCI_DEVICE_ID_WINBOND2_6692 0x6692 + +#define PCI_VENDOR_ID_ANIGMA 0x1051 +#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100 + +#define PCI_VENDOR_ID_EFAR 0x1055 +#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130 +#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463 + +#define PCI_VENDOR_ID_MOTOROLA 0x1057 +#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001 +#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 +#define PCI_DEVICE_ID_MOTOROLA_MPC107 0x0004 +#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801 +#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802 +#define PCI_DEVICE_ID_MOTOROLA_HAWK 0x4803 +#define PCI_DEVICE_ID_MOTOROLA_HARRIER 0x480b +#define PCI_DEVICE_ID_MOTOROLA_MPC5200 0x5803 + +#define PCI_VENDOR_ID_PROMISE 0x105a +#define PCI_DEVICE_ID_PROMISE_20265 0x0d30 +#define PCI_DEVICE_ID_PROMISE_20267 0x4d30 +#define PCI_DEVICE_ID_PROMISE_20246 0x4d33 +#define PCI_DEVICE_ID_PROMISE_20262 0x4d38 +#define PCI_DEVICE_ID_PROMISE_20263 0x0D38 +#define PCI_DEVICE_ID_PROMISE_20268 0x4d68 +#define PCI_DEVICE_ID_PROMISE_20269 0x4d69 +#define PCI_DEVICE_ID_PROMISE_20270 0x6268 +#define PCI_DEVICE_ID_PROMISE_20271 0x6269 +#define PCI_DEVICE_ID_PROMISE_20275 0x1275 +#define PCI_DEVICE_ID_PROMISE_20276 0x5275 +#define PCI_DEVICE_ID_PROMISE_20277 0x7275 + + +#define PCI_VENDOR_ID_UMC 0x1060 +#define PCI_DEVICE_ID_UMC_UM8673F 0x0101 +#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a +#define PCI_DEVICE_ID_UMC_UM8886A 0x886a + + +#define PCI_VENDOR_ID_MYLEX 0x1069 +#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001 +#define PCI_DEVICE_ID_MYLEX_DAC960_PD 0x0002 +#define PCI_DEVICE_ID_MYLEX_DAC960_PG 0x0010 +#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020 +#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050 +#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56 +#define PCI_DEVICE_ID_MYLEX_DAC960_GEM 0xB166 + + +#define PCI_VENDOR_ID_APPLE 0x106b +#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001 +#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e +#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d +#define PCI_DEVICE_ID_APPLE_UNI_N_PCI15 0x002e +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032 +#define PCI_DEVICE_ID_APPLE_UNI_N_ATA 0x0033 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034 +#define PCI_DEVICE_ID_APPLE_IPID_ATA100 0x003b +#define PCI_DEVICE_ID_APPLE_K2_ATA100 0x0043 +#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b +#define PCI_DEVICE_ID_APPLE_K2_GMAC 0x004c +#define PCI_DEVICE_ID_APPLE_SH_ATA 0x0050 +#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051 +#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058 +#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059 +#define PCI_DEVICE_ID_APPLE_IPID2_AGP 0x0066 +#define PCI_DEVICE_ID_APPLE_IPID2_ATA 0x0069 +#define PCI_DEVICE_ID_APPLE_IPID2_FW 0x006a +#define PCI_DEVICE_ID_APPLE_IPID2_GMAC 0x006b +#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645 + +#define PCI_VENDOR_ID_YAMAHA 0x1073 +#define PCI_DEVICE_ID_YAMAHA_724 0x0004 +#define PCI_DEVICE_ID_YAMAHA_724F 0x000d +#define PCI_DEVICE_ID_YAMAHA_740 0x000a +#define PCI_DEVICE_ID_YAMAHA_740C 0x000c +#define PCI_DEVICE_ID_YAMAHA_744 0x0010 +#define PCI_DEVICE_ID_YAMAHA_754 0x0012 + + +#define PCI_VENDOR_ID_QLOGIC 0x1077 +#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020 +#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100 +#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200 +#define PCI_DEVICE_ID_QLOGIC_ISP2300 0x2300 +#define PCI_DEVICE_ID_QLOGIC_ISP2312 0x2312 +#define PCI_DEVICE_ID_QLOGIC_ISP2322 0x2322 +#define PCI_DEVICE_ID_QLOGIC_ISP6312 0x6312 +#define PCI_DEVICE_ID_QLOGIC_ISP6322 0x6322 +#define PCI_DEVICE_ID_QLOGIC_ISP2422 0x2422 +#define PCI_DEVICE_ID_QLOGIC_ISP2432 0x2432 +#define PCI_DEVICE_ID_QLOGIC_ISP2512 0x2512 +#define PCI_DEVICE_ID_QLOGIC_ISP2522 0x2522 + +#define PCI_VENDOR_ID_CYRIX 0x1078 +#define PCI_DEVICE_ID_CYRIX_5510 0x0000 +#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001 +#define PCI_DEVICE_ID_CYRIX_5520 0x0002 +#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100 +#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102 +#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103 +#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104 + + + +#define PCI_VENDOR_ID_CONTAQ 0x1080 +#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693 + + +#define PCI_VENDOR_ID_OLICOM 0x108d +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012 +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013 +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014 + +#define PCI_VENDOR_ID_SUN 0x108e +#define PCI_DEVICE_ID_SUN_EBUS 0x1000 +#define PCI_DEVICE_ID_SUN_HAPPYMEAL 0x1001 +#define PCI_DEVICE_ID_SUN_RIO_EBUS 0x1100 +#define PCI_DEVICE_ID_SUN_RIO_GEM 0x1101 +#define PCI_DEVICE_ID_SUN_RIO_1394 0x1102 +#define PCI_DEVICE_ID_SUN_RIO_USB 0x1103 +#define PCI_DEVICE_ID_SUN_GEM 0x2bad +#define PCI_DEVICE_ID_SUN_SIMBA 0x5000 +#define PCI_DEVICE_ID_SUN_PBM 0x8000 +#define PCI_DEVICE_ID_SUN_SCHIZO 0x8001 +#define PCI_DEVICE_ID_SUN_SABRE 0xa000 +#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001 +#define PCI_DEVICE_ID_SUN_TOMATILLO 0xa801 +#define PCI_DEVICE_ID_SUN_CASSINI 0xabba + +#define PCI_VENDOR_ID_CMD 0x1095 +#define PCI_DEVICE_ID_CMD_643 0x0643 +#define PCI_DEVICE_ID_CMD_646 0x0646 +#define PCI_DEVICE_ID_CMD_648 0x0648 +#define PCI_DEVICE_ID_CMD_649 0x0649 + +#define PCI_DEVICE_ID_SII_680 0x0680 +#define PCI_DEVICE_ID_SII_3112 0x3112 +#define PCI_DEVICE_ID_SII_1210SA 0x0240 + + +#define PCI_VENDOR_ID_BROOKTREE 0x109e +#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 +#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 + + +#define PCI_VENDOR_ID_SGI 0x10a9 +#define PCI_DEVICE_ID_SGI_IOC3 0x0003 +#define PCI_DEVICE_ID_SGI_IOC4 0x100a +#define PCI_VENDOR_ID_SGI_LITHIUM 0x1002 + + +#define PCI_VENDOR_ID_WINBOND 0x10ad +#define PCI_DEVICE_ID_WINBOND_82C105 0x0105 +#define PCI_DEVICE_ID_WINBOND_83C553 0x0565 + + +#define PCI_VENDOR_ID_PLX 0x10b5 +#define PCI_DEVICE_ID_PLX_R685 0x1030 +#define PCI_DEVICE_ID_PLX_ROMULUS 0x106a +#define PCI_DEVICE_ID_PLX_SPCOM800 0x1076 +#define PCI_DEVICE_ID_PLX_1077 0x1077 +#define PCI_DEVICE_ID_PLX_SPCOM200 0x1103 +#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151 +#define PCI_DEVICE_ID_PLX_R753 0x1152 +#define PCI_DEVICE_ID_PLX_OLITEC 0x1187 +#define PCI_DEVICE_ID_PLX_9050 0x9050 +#define PCI_DEVICE_ID_PLX_9080 0x9080 +#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001 + +#define PCI_VENDOR_ID_MADGE 0x10b6 +#define PCI_DEVICE_ID_MADGE_MK2 0x0002 + +#define PCI_VENDOR_ID_3COM 0x10b7 +#define PCI_DEVICE_ID_3COM_3C985 0x0001 +#define PCI_DEVICE_ID_3COM_3C940 0x1700 +#define PCI_DEVICE_ID_3COM_3C339 0x3390 +#define PCI_DEVICE_ID_3COM_3C359 0x3590 +#define PCI_DEVICE_ID_3COM_3C940B 0x80eb +#define PCI_DEVICE_ID_3COM_3CR990 0x9900 +#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902 +#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903 +#define PCI_DEVICE_ID_3COM_3CR990B 0x9904 +#define PCI_DEVICE_ID_3COM_3CR990_FX 0x9905 +#define PCI_DEVICE_ID_3COM_3CR990SVR95 0x9908 +#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909 +#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a + + +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1533 0x1533 +#define PCI_DEVICE_ID_AL_M1535 0x1535 +#define PCI_DEVICE_ID_AL_M1541 0x1541 +#define PCI_DEVICE_ID_AL_M1563 0x1563 +#define PCI_DEVICE_ID_AL_M1621 0x1621 +#define PCI_DEVICE_ID_AL_M1631 0x1631 +#define PCI_DEVICE_ID_AL_M1632 0x1632 +#define PCI_DEVICE_ID_AL_M1641 0x1641 +#define PCI_DEVICE_ID_AL_M1644 0x1644 +#define PCI_DEVICE_ID_AL_M1647 0x1647 +#define PCI_DEVICE_ID_AL_M1651 0x1651 +#define PCI_DEVICE_ID_AL_M1671 0x1671 +#define PCI_DEVICE_ID_AL_M1681 0x1681 +#define PCI_DEVICE_ID_AL_M1683 0x1683 +#define PCI_DEVICE_ID_AL_M1689 0x1689 +#define PCI_DEVICE_ID_AL_M5219 0x5219 +#define PCI_DEVICE_ID_AL_M5228 0x5228 +#define PCI_DEVICE_ID_AL_M5229 0x5229 +#define PCI_DEVICE_ID_AL_M5451 0x5451 +#define PCI_DEVICE_ID_AL_M7101 0x7101 + + + +#define PCI_VENDOR_ID_NEOMAGIC 0x10c8 +#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 +#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 +#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 + + +#define PCI_VENDOR_ID_TCONRAD 0x10da +#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508 + + +#define PCI_VENDOR_ID_NVIDIA 0x10de +#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020 +#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028 +#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029 +#define PCI_DEVICE_ID_NVIDIA_TNT_UNKNOWN 0x002a +#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C +#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS 0x0034 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE 0x0035 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA 0x0036 +#define PCI_DEVICE_ID_NVIDIA_NVENET_10 0x0037 +#define PCI_DEVICE_ID_NVIDIA_NVENET_11 0x0038 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2 0x003e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_ULTRA 0x0040 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800 0x0041 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_LE 0x0042 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x0045 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_4000 0x004E +#define PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS 0x0052 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE 0x0053 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA 0x0054 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2 0x0055 +#define PCI_DEVICE_ID_NVIDIA_NVENET_8 0x0056 +#define PCI_DEVICE_ID_NVIDIA_NVENET_9 0x0057 +#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065 +#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066 +#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069 +#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085 +#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086 +#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089 +#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a +#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GT 0x0090 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GTX 0x0091 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800 0x0098 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800_GTX 0x0099 +#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 +#define PCI_DEVICE_ID_GEFORCE_6800A 0x00c1 +#define PCI_DEVICE_ID_GEFORCE_6800A_LE 0x00c2 +#define PCI_DEVICE_ID_GEFORCE_GO_6800 0x00c8 +#define PCI_DEVICE_ID_GEFORCE_GO_6800_ULTRA 0x00c9 +#define PCI_DEVICE_ID_QUADRO_FX_GO1400 0x00cc +#define PCI_DEVICE_ID_QUADRO_FX_1400 0x00ce +#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 +#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9 +#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da +#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA 0x00e3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 +#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_ALT1 0x00f0 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT1 0x00f1 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT2 0x00f2 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6200_ALT1 0x00f3 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x00f9 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101 +#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO 0x0112 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600_GT 0x0140 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600 0x0141 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6610_XL 0x0145 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_540 0x014E +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200 0x014F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200_TURBOCACHE 0x0161 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200 0x0164 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250 0x0166 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200_1 0x0167 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250_1 0x0168 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460 0x0170 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440 0x0171 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420 0x0172 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_SE 0x0173 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO 0x0174 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO 0x0175 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32 0x0176 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_460_GO 0x0177 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL 0x0178 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64 0x0179 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_200 0x017A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL 0x017B +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL 0x017C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_410_GO_M16 0x017D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_8X 0x0181 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440SE_8X 0x0182 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420_8X 0x0183 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_4000 0x0185 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_448_GO 0x0186 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_488_GO 0x0187 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_580_XGL 0x0188 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_MAC 0x0189 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_280_NVS 0x018A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_380_XGL 0x018B +#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0 +#define PCI_DEVICE_ID_NVIDIA_NFORCE 0x01a4 +#define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc +#define PCI_DEVICE_ID_NVIDIA_MCP1_MODEM 0x01c1 +#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2 0x0202 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC 0x0203 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B 0x0211 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_LE 0x0212 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_GT 0x0215 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600 0x0250 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400 0x0251 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200 0x0253 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE 0x0265 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE 0x036E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA 0x037E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2 0x037F +#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268 +#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO 0x0286 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_980_XGL 0x0288 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_780_XGL 0x0289 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700_GOGL 0x028C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_ULTRA 0x0301 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800 0x0302 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_2000 0x0308 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1000 0x0309 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_ULTRA 0x0311 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600 0x0312 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600SE 0x0314 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5600 0x031A +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5650 0x031B +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO700 0x031C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200 0x0320 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_ULTRA 0x0321 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_1 0x0322 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200SE 0x0323 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5200 0x0324 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250 0x0325 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5500 0x0326 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5100 0x0327 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250_32 0x0328 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200 0x0329 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_NVS_280_PCI 0x032A +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_500 0x032B +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5300 0x032C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5100 0x032D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900_ULTRA 0x0330 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900 0x0331 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900XT 0x0332 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5950_ULTRA 0x0333 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900ZT 0x0334 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_3000 0x0338 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_700 0x033F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700_ULTRA 0x0341 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700 0x0342 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700LE 0x0343 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700VE 0x0344 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_1 0x0347 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_2 0x0348 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO1000 0x034C +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E +#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372 +#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 + +#define PCI_VENDOR_ID_IMS 0x10e0 +#define PCI_DEVICE_ID_IMS_TT128 0x9128 +#define PCI_DEVICE_ID_IMS_TT3D 0x9135 + + + + +#define PCI_VENDOR_ID_INTERG 0x10ea +#define PCI_DEVICE_ID_INTERG_1682 0x1682 +#define PCI_DEVICE_ID_INTERG_2000 0x2000 +#define PCI_DEVICE_ID_INTERG_2010 0x2010 +#define PCI_DEVICE_ID_INTERG_5000 0x5000 +#define PCI_DEVICE_ID_INTERG_5050 0x5050 + +#define PCI_VENDOR_ID_REALTEK 0x10ec +#define PCI_DEVICE_ID_REALTEK_8139 0x8139 + +#define PCI_VENDOR_ID_XILINX 0x10ee +#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0 +#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1 +#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2 +#define PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST 0x3fc3 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 + + +#define PCI_VENDOR_ID_INIT 0x1101 + +#define PCI_VENDOR_ID_CREATIVE 0x1102 /* duplicate: ECTIVA */ +#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002 + +#define PCI_VENDOR_ID_ECTIVA 0x1102 /* duplicate: CREATIVE */ +#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938 + +#define PCI_VENDOR_ID_TTI 0x1103 +#define PCI_DEVICE_ID_TTI_HPT343 0x0003 +#define PCI_DEVICE_ID_TTI_HPT366 0x0004 +#define PCI_DEVICE_ID_TTI_HPT372 0x0005 +#define PCI_DEVICE_ID_TTI_HPT302 0x0006 +#define PCI_DEVICE_ID_TTI_HPT371 0x0007 +#define PCI_DEVICE_ID_TTI_HPT374 0x0008 +#define PCI_DEVICE_ID_TTI_HPT372N 0x0009 /* apparently a 372N variant? */ + +#define PCI_VENDOR_ID_VIA 0x1106 +#define PCI_DEVICE_ID_VIA_8763_0 0x0198 +#define PCI_DEVICE_ID_VIA_8380_0 0x0204 +#define PCI_DEVICE_ID_VIA_3238_0 0x0238 +#define PCI_DEVICE_ID_VIA_PT880 0x0258 +#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 +#define PCI_DEVICE_ID_VIA_3269_0 0x0269 +#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 +#define PCI_DEVICE_ID_VIA_8363_0 0x0305 +#define PCI_DEVICE_ID_VIA_P4M800CE 0x0314 +#define PCI_DEVICE_ID_VIA_8371_0 0x0391 +#define PCI_DEVICE_ID_VIA_8501_0 0x0501 +#define PCI_DEVICE_ID_VIA_82C561 0x0561 +#define PCI_DEVICE_ID_VIA_82C586_1 0x0571 +#define PCI_DEVICE_ID_VIA_82C576 0x0576 +#define PCI_DEVICE_ID_VIA_82C586_0 0x0586 +#define PCI_DEVICE_ID_VIA_82C596 0x0596 +#define PCI_DEVICE_ID_VIA_82C597_0 0x0597 +#define PCI_DEVICE_ID_VIA_82C598_0 0x0598 +#define PCI_DEVICE_ID_VIA_8601_0 0x0601 +#define PCI_DEVICE_ID_VIA_8605_0 0x0605 +#define PCI_DEVICE_ID_VIA_82C686 0x0686 +#define PCI_DEVICE_ID_VIA_82C691_0 0x0691 +#define PCI_DEVICE_ID_VIA_82C576_1 0x1571 +#define PCI_DEVICE_ID_VIA_82C586_2 0x3038 +#define PCI_DEVICE_ID_VIA_82C586_3 0x3040 +#define PCI_DEVICE_ID_VIA_82C596_3 0x3050 +#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051 +#define PCI_DEVICE_ID_VIA_82C686_4 0x3057 +#define PCI_DEVICE_ID_VIA_82C686_5 0x3058 +#define PCI_DEVICE_ID_VIA_8233_5 0x3059 +#define PCI_DEVICE_ID_VIA_8233_0 0x3074 +#define PCI_DEVICE_ID_VIA_8633_0 0x3091 +#define PCI_DEVICE_ID_VIA_8367_0 0x3099 +#define PCI_DEVICE_ID_VIA_8653_0 0x3101 +#define PCI_DEVICE_ID_VIA_8622 0x3102 +#define PCI_DEVICE_ID_VIA_8233C_0 0x3109 +#define PCI_DEVICE_ID_VIA_8361 0x3112 +#define PCI_DEVICE_ID_VIA_XM266 0x3116 +#define PCI_DEVICE_ID_VIA_612X 0x3119 +#define PCI_DEVICE_ID_VIA_862X_0 0x3123 +#define PCI_DEVICE_ID_VIA_8753_0 0x3128 +#define PCI_DEVICE_ID_VIA_8233A 0x3147 +#define PCI_DEVICE_ID_VIA_8703_51_0 0x3148 +#define PCI_DEVICE_ID_VIA_8237_SATA 0x3149 +#define PCI_DEVICE_ID_VIA_XN266 0x3156 +#define PCI_DEVICE_ID_VIA_6410 0x3164 +#define PCI_DEVICE_ID_VIA_8754C_0 0x3168 +#define PCI_DEVICE_ID_VIA_8235 0x3177 +#define PCI_DEVICE_ID_VIA_8385_0 0x3188 +#define PCI_DEVICE_ID_VIA_8377_0 0x3189 +#define PCI_DEVICE_ID_VIA_8378_0 0x3205 +#define PCI_DEVICE_ID_VIA_8783_0 0x3208 +#define PCI_DEVICE_ID_VIA_8237 0x3227 +#define PCI_DEVICE_ID_VIA_8251 0x3287 +#define PCI_DEVICE_ID_VIA_3296_0 0x0296 +#define PCI_DEVICE_ID_VIA_8231 0x8231 +#define PCI_DEVICE_ID_VIA_8231_4 0x8235 +#define PCI_DEVICE_ID_VIA_8365_1 0x8305 +#define PCI_DEVICE_ID_VIA_8371_1 0x8391 +#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 +#define PCI_DEVICE_ID_VIA_838X_1 0xB188 +#define PCI_DEVICE_ID_VIA_83_87XX_1 0xB198 + +#define PCI_VENDOR_ID_SIEMENS 0x110A +#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102 + + +#define PCI_VENDOR_ID_VORTEX 0x1119 +#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000 +#define PCI_DEVICE_ID_VORTEX_GDT6000B 0x0001 +#define PCI_DEVICE_ID_VORTEX_GDT6x10 0x0002 +#define PCI_DEVICE_ID_VORTEX_GDT6x20 0x0003 +#define PCI_DEVICE_ID_VORTEX_GDT6530 0x0004 +#define PCI_DEVICE_ID_VORTEX_GDT6550 0x0005 +#define PCI_DEVICE_ID_VORTEX_GDT6x17 0x0006 +#define PCI_DEVICE_ID_VORTEX_GDT6x27 0x0007 +#define PCI_DEVICE_ID_VORTEX_GDT6537 0x0008 +#define PCI_DEVICE_ID_VORTEX_GDT6557 0x0009 +#define PCI_DEVICE_ID_VORTEX_GDT6x15 0x000a +#define PCI_DEVICE_ID_VORTEX_GDT6x25 0x000b +#define PCI_DEVICE_ID_VORTEX_GDT6535 0x000c +#define PCI_DEVICE_ID_VORTEX_GDT6555 0x000d +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x0100 +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x0101 +#define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x0102 +#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103 +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104 +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105 + +#define PCI_VENDOR_ID_EF 0x111a +#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000 +#define PCI_DEVICE_ID_EF_ATM_ASIC 0x0002 +#define PCI_VENDOR_ID_EF_ATM_LANAI2 0x0003 +#define PCI_VENDOR_ID_EF_ATM_LANAIHB 0x0005 + +#define PCI_VENDOR_ID_IDT 0x111d +#define PCI_DEVICE_ID_IDT_IDT77201 0x0001 + +#define PCI_VENDOR_ID_FORE 0x1127 +#define PCI_DEVICE_ID_FORE_PCA200E 0x0300 + + +#define PCI_VENDOR_ID_PHILIPS 0x1131 +#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146 +#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730 + +#define PCI_VENDOR_ID_EICON 0x1133 +#define PCI_DEVICE_ID_EICON_DIVA20 0xe002 +#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004 +#define PCI_DEVICE_ID_EICON_DIVA201 0xe005 +#define PCI_DEVICE_ID_EICON_DIVA202 0xe00b +#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010 +#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012 +#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013 +#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014 + +#define PCI_VENDOR_ID_ZIATECH 0x1138 +#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550 + + + +#define PCI_VENDOR_ID_SYSKONNECT 0x1148 +#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200 +#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300 +#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320 +#define PCI_DEVICE_ID_SYSKONNECT_9DXX 0x4400 +#define PCI_DEVICE_ID_SYSKONNECT_9MXX 0x4500 + + +#define PCI_VENDOR_ID_DIGI 0x114f +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070 +#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071 +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072 +#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073 +#define PCI_DEVICE_ID_NEO_2DB9 0x00C8 +#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 +#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA +#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB + + +#define PCI_VENDOR_ID_XIRCOM 0x115d +#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 +#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103 + + +#define PCI_VENDOR_ID_SERVERWORKS 0x1166 +#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008 +#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009 +#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017 +#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 +#define PCI_DEVICE_ID_SERVERWORKS_HT1000IDE 0x0214 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6LPC 0x0227 + +#define PCI_VENDOR_ID_SBE 0x1176 +#define PCI_DEVICE_ID_SBE_WANXL100 0x0301 +#define PCI_DEVICE_ID_SBE_WANXL200 0x0302 +#define PCI_DEVICE_ID_SBE_WANXL400 0x0104 + +#define PCI_VENDOR_ID_TOSHIBA 0x1179 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a +#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f +#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617 + +#define PCI_VENDOR_ID_TOSHIBA_2 0x102f +#define PCI_DEVICE_ID_TOSHIBA_TC35815CF 0x0030 +#define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC 0x0108 +#define PCI_DEVICE_ID_TOSHIBA_SPIDER_NET 0x01b3 + +#define PCI_VENDOR_ID_RICOH 0x1180 +#define PCI_DEVICE_ID_RICOH_RL5C465 0x0465 +#define PCI_DEVICE_ID_RICOH_RL5C466 0x0466 +#define PCI_DEVICE_ID_RICOH_RL5C475 0x0475 +#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476 +#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478 + +#define PCI_VENDOR_ID_DLINK 0x1186 +#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00 + +#define PCI_VENDOR_ID_ARTOP 0x1191 +#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005 +#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006 +#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007 +#define PCI_DEVICE_ID_ARTOP_ATP865 0x0008 +#define PCI_DEVICE_ID_ARTOP_ATP865R 0x0009 +#define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002 +#define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010 +#define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020 +#define PCI_DEVICE_ID_ARTOP_AEC7612S 0x8030 +#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040 +#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050 +#define PCI_DEVICE_ID_ARTOP_8060 0x8060 + +#define PCI_VENDOR_ID_ZEITNET 0x1193 +#define PCI_DEVICE_ID_ZEITNET_1221 0x0001 +#define PCI_DEVICE_ID_ZEITNET_1225 0x0002 + + +#define PCI_VENDOR_ID_FUJITSU_ME 0x119e +#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001 +#define PCI_DEVICE_ID_FUJITSU_FS50 0x0003 + +#define PCI_SUBVENDOR_ID_KEYSPAN 0x11a9 +#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334 + +#define PCI_VENDOR_ID_MARVELL 0x11ab +#define PCI_DEVICE_ID_MARVELL_GT64111 0x4146 +#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 +#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 +#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480 +#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652 +#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653 + + +#define PCI_VENDOR_ID_V3 0x11b0 +#define PCI_DEVICE_ID_V3_V960 0x0001 +#define PCI_DEVICE_ID_V3_V351 0x0002 + + +#define PCI_VENDOR_ID_ATT 0x11c1 +#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480 + + +#define PCI_VENDOR_ID_SPECIALIX 0x11cb +#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000 +#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000 +#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004 + + +#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4 +#define PCI_DEVICE_ID_AD1889JS 0x1889 + + +#define PCI_DEVICE_ID_SEGA_BBA 0x1234 + +#define PCI_VENDOR_ID_ZORAN 0x11de +#define PCI_DEVICE_ID_ZORAN_36057 0x6057 +#define PCI_DEVICE_ID_ZORAN_36120 0x6120 + + +#define PCI_VENDOR_ID_COMPEX 0x11f6 +#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112 + +#define PCI_VENDOR_ID_RP 0x11fe +#define PCI_DEVICE_ID_RP32INTF 0x0001 +#define PCI_DEVICE_ID_RP8INTF 0x0002 +#define PCI_DEVICE_ID_RP16INTF 0x0003 +#define PCI_DEVICE_ID_RP4QUAD 0x0004 +#define PCI_DEVICE_ID_RP8OCTA 0x0005 +#define PCI_DEVICE_ID_RP8J 0x0006 +#define PCI_DEVICE_ID_RP4J 0x0007 +#define PCI_DEVICE_ID_RP8SNI 0x0008 +#define PCI_DEVICE_ID_RP16SNI 0x0009 +#define PCI_DEVICE_ID_RPP4 0x000A +#define PCI_DEVICE_ID_RPP8 0x000B +#define PCI_DEVICE_ID_RP4M 0x000D +#define PCI_DEVICE_ID_RP2_232 0x000E +#define PCI_DEVICE_ID_RP2_422 0x000F +#define PCI_DEVICE_ID_URP32INTF 0x0801 +#define PCI_DEVICE_ID_URP8INTF 0x0802 +#define PCI_DEVICE_ID_URP16INTF 0x0803 +#define PCI_DEVICE_ID_URP8OCTA 0x0805 +#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C +#define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D +#define PCI_DEVICE_ID_CRP16INTF 0x0903 + +#define PCI_VENDOR_ID_CYCLADES 0x120e +#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100 +#define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101 +#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102 +#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103 +#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104 +#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105 +#define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200 +#define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201 +#define PCI_DEVICE_ID_PC300_RX_2 0x0300 +#define PCI_DEVICE_ID_PC300_RX_1 0x0301 +#define PCI_DEVICE_ID_PC300_TE_2 0x0310 +#define PCI_DEVICE_ID_PC300_TE_1 0x0311 +#define PCI_DEVICE_ID_PC300_TE_M_2 0x0320 +#define PCI_DEVICE_ID_PC300_TE_M_1 0x0321 + +#define PCI_VENDOR_ID_ESSENTIAL 0x120f +#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001 + +#define PCI_VENDOR_ID_O2 0x1217 +#define PCI_DEVICE_ID_O2_6729 0x6729 +#define PCI_DEVICE_ID_O2_6730 0x673a +#define PCI_DEVICE_ID_O2_6832 0x6832 +#define PCI_DEVICE_ID_O2_6836 0x6836 + +#define PCI_VENDOR_ID_3DFX 0x121a +#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001 +#define PCI_DEVICE_ID_3DFX_VOODOO2 0x0002 +#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003 +#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005 +#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009 + + + +#define PCI_VENDOR_ID_AVM 0x1244 +#define PCI_DEVICE_ID_AVM_B1 0x0700 +#define PCI_DEVICE_ID_AVM_C4 0x0800 +#define PCI_DEVICE_ID_AVM_A1 0x0a00 +#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00 +#define PCI_DEVICE_ID_AVM_C2 0x1100 +#define PCI_DEVICE_ID_AVM_T1 0x1200 + + +#define PCI_VENDOR_ID_STALLION 0x124d + +/* Allied Telesyn */ +#define PCI_VENDOR_ID_AT 0x1259 +#define PCI_SUBDEVICE_ID_AT_2700FX 0x2701 +#define PCI_SUBDEVICE_ID_AT_2701FX 0x2703 + +#define PCI_VENDOR_ID_ESS 0x125d +#define PCI_DEVICE_ID_ESS_ESS1968 0x1968 +#define PCI_DEVICE_ID_ESS_ESS1978 0x1978 +#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988 +#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989 +#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990 +#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992 +#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998 +#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999 +#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a +#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b + +#define PCI_VENDOR_ID_SATSAGEM 0x1267 +#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 + + +#define PCI_VENDOR_ID_ENSONIQ 0x1274 +#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 +#define PCI_DEVICE_ID_ENSONIQ_ES1370 0x5000 +#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371 + +#define PCI_VENDOR_ID_TRANSMETA 0x1279 +#define PCI_DEVICE_ID_EFFICEON 0x0060 + +#define PCI_VENDOR_ID_ROCKWELL 0x127A + +#define PCI_VENDOR_ID_ITE 0x1283 +#define PCI_DEVICE_ID_ITE_IT8172G 0x8172 +#define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801 +#define PCI_DEVICE_ID_ITE_8211 0x8211 +#define PCI_DEVICE_ID_ITE_8212 0x8212 +#define PCI_DEVICE_ID_ITE_8872 0x8872 +#define PCI_DEVICE_ID_ITE_IT8330G_0 0xe886 + +/* formerly Platform Tech */ +#define PCI_DEVICE_ID_ESS_ESS0100 0x0100 + +#define PCI_VENDOR_ID_ALTEON 0x12ae + + +#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232 0x0003 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485 0x0004 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4 0x0005 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485 0x0006 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2 0x0007 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485 0x0008 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6 0x0009 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_20MHZ 0x000C +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_PTM 0x000D +#define PCI_SUBDEVICE_ID_CONNECT_TECH_NT960PCI 0x0100 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_2 0x0201 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_4 0x0202 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_232 0x0300 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_232 0x0301 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_232 0x0302 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1 0x0310 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2 0x0311 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4 0x0312 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2 0x0320 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4 0x0321 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8 0x0322 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_485 0x0330 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_485 0x0331 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_485 0x0332 + + +#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2 +#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018 + +#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16 0x0011 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC 0x0041 +#define PCI_SUBVENDOR_ID_CHASE_PCIRAS 0x124D +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS4 0xF001 +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS8 0xF010 + +#define PCI_VENDOR_ID_AUREAL 0x12eb +#define PCI_DEVICE_ID_AUREAL_VORTEX_1 0x0001 +#define PCI_DEVICE_ID_AUREAL_VORTEX_2 0x0002 +#define PCI_DEVICE_ID_AUREAL_ADVANTAGE 0x0003 + +#define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8 +#define PCI_DEVICE_ID_LML_33R10 0x8a02 + + +#define PCI_VENDOR_ID_SIIG 0x131f +#define PCI_SUBVENDOR_ID_SIIG 0x131f +#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000 +#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001 +#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_550 0x1010 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_650 0x1011 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_850 0x1012 +#define PCI_DEVICE_ID_SIIG_1P_10x 0x1020 +#define PCI_DEVICE_ID_SIIG_2P_10x 0x1021 +#define PCI_DEVICE_ID_SIIG_2S_10x_550 0x1030 +#define PCI_DEVICE_ID_SIIG_2S_10x_650 0x1031 +#define PCI_DEVICE_ID_SIIG_2S_10x_850 0x1032 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_550 0x1034 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_650 0x1035 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_850 0x1036 +#define PCI_DEVICE_ID_SIIG_4S_10x_550 0x1050 +#define PCI_DEVICE_ID_SIIG_4S_10x_650 0x1051 +#define PCI_DEVICE_ID_SIIG_4S_10x_850 0x1052 +#define PCI_DEVICE_ID_SIIG_1S_20x_550 0x2000 +#define PCI_DEVICE_ID_SIIG_1S_20x_650 0x2001 +#define PCI_DEVICE_ID_SIIG_1S_20x_850 0x2002 +#define PCI_DEVICE_ID_SIIG_1P_20x 0x2020 +#define PCI_DEVICE_ID_SIIG_2P_20x 0x2021 +#define PCI_DEVICE_ID_SIIG_2S_20x_550 0x2030 +#define PCI_DEVICE_ID_SIIG_2S_20x_650 0x2031 +#define PCI_DEVICE_ID_SIIG_2S_20x_850 0x2032 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_550 0x2040 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_650 0x2041 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_850 0x2042 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_550 0x2010 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_650 0x2011 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_850 0x2012 +#define PCI_DEVICE_ID_SIIG_4S_20x_550 0x2050 +#define PCI_DEVICE_ID_SIIG_4S_20x_650 0x2051 +#define PCI_DEVICE_ID_SIIG_4S_20x_850 0x2052 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062 +#define PCI_DEVICE_ID_SIIG_8S_20x_550 0x2080 +#define PCI_DEVICE_ID_SIIG_8S_20x_650 0x2081 +#define PCI_DEVICE_ID_SIIG_8S_20x_850 0x2082 +#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050 + +#define PCI_VENDOR_ID_RADISYS 0x1331 + +#define PCI_VENDOR_ID_DOMEX 0x134a +#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001 + +#define PCI_VENDOR_ID_QUATECH 0x135C +#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010 +#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020 +#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050 +#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060 + +#define PCI_VENDOR_ID_SEALEVEL 0x135e +#define PCI_DEVICE_ID_SEALEVEL_U530 0x7101 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM2 0x7201 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM422 0x7402 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM232 0x7202 +#define PCI_DEVICE_ID_SEALEVEL_COMM4 0x7401 +#define PCI_DEVICE_ID_SEALEVEL_COMM8 0x7801 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM8 0x7804 + +#define PCI_VENDOR_ID_HYPERCOPE 0x1365 +#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050 +#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104 +#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106 +#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107 +#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108 + +#define PCI_VENDOR_ID_KAWASAKI 0x136b +#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01 + +#define PCI_VENDOR_ID_CNET 0x1371 +#define PCI_DEVICE_ID_CNET_GIGACARD 0x434e + +#define PCI_VENDOR_ID_LMC 0x1376 +#define PCI_DEVICE_ID_LMC_HSSI 0x0003 +#define PCI_DEVICE_ID_LMC_DS3 0x0004 +#define PCI_DEVICE_ID_LMC_SSI 0x0005 +#define PCI_DEVICE_ID_LMC_T1 0x0006 + + +#define PCI_VENDOR_ID_NETGEAR 0x1385 +#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a + +#define PCI_VENDOR_ID_APPLICOM 0x1389 +#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001 +#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002 +#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 + +#define PCI_VENDOR_ID_MOXA 0x1393 +#define PCI_DEVICE_ID_MOXA_RC7000 0x0001 +#define PCI_DEVICE_ID_MOXA_CP102 0x1020 +#define PCI_DEVICE_ID_MOXA_CP102UL 0x1021 +#define PCI_DEVICE_ID_MOXA_CP102U 0x1022 +#define PCI_DEVICE_ID_MOXA_C104 0x1040 +#define PCI_DEVICE_ID_MOXA_CP104U 0x1041 +#define PCI_DEVICE_ID_MOXA_CP104JU 0x1042 +#define PCI_DEVICE_ID_MOXA_CT114 0x1140 +#define PCI_DEVICE_ID_MOXA_CP114 0x1141 +#define PCI_DEVICE_ID_MOXA_CP118U 0x1180 +#define PCI_DEVICE_ID_MOXA_CP132 0x1320 +#define PCI_DEVICE_ID_MOXA_CP132U 0x1321 +#define PCI_DEVICE_ID_MOXA_CP134U 0x1340 +#define PCI_DEVICE_ID_MOXA_C168 0x1680 +#define PCI_DEVICE_ID_MOXA_CP168U 0x1681 + +#define PCI_VENDOR_ID_CCD 0x1397 +#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0 +#define PCI_DEVICE_ID_CCD_B000 0xb000 +#define PCI_DEVICE_ID_CCD_B006 0xb006 +#define PCI_DEVICE_ID_CCD_B007 0xb007 +#define PCI_DEVICE_ID_CCD_B008 0xb008 +#define PCI_DEVICE_ID_CCD_B009 0xb009 +#define PCI_DEVICE_ID_CCD_B00A 0xb00a +#define PCI_DEVICE_ID_CCD_B00B 0xb00b +#define PCI_DEVICE_ID_CCD_B00C 0xb00c +#define PCI_DEVICE_ID_CCD_B100 0xb100 +#define PCI_DEVICE_ID_CCD_B700 0xb700 +#define PCI_DEVICE_ID_CCD_B701 0xb701 + +#define PCI_VENDOR_ID_EXAR 0x13a8 +#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152 +#define PCI_DEVICE_ID_EXAR_XR17C154 0x0154 +#define PCI_DEVICE_ID_EXAR_XR17C158 0x0158 + +#define PCI_VENDOR_ID_MICROGATE 0x13c0 +#define PCI_DEVICE_ID_MICROGATE_USC 0x0010 +#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030 + +#define PCI_VENDOR_ID_3WARE 0x13C1 +#define PCI_DEVICE_ID_3WARE_1000 0x1000 +#define PCI_DEVICE_ID_3WARE_7000 0x1001 +#define PCI_DEVICE_ID_3WARE_9000 0x1002 + +#define PCI_VENDOR_ID_IOMEGA 0x13ca +#define PCI_DEVICE_ID_IOMEGA_BUZ 0x4231 + +#define PCI_VENDOR_ID_ABOCOM 0x13D1 +#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1 + +#define PCI_VENDOR_ID_CMEDIA 0x13f6 +#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100 +#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101 +#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111 +#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112 + +#define PCI_VENDOR_ID_LAVA 0x1407 +#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */ +#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_A 0x0180 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_B 0x0181 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200 /* 2x 16650 */ +#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500 /* 1x 16550 */ +#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600 /* 1x 16650 */ +#define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000 +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002 /* The Lava Dual Parallel is */ +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003 /* two PCI devices on a card */ +#define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800 + +#define PCI_VENDOR_ID_TIMEDIA 0x1409 +#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168 + +#define PCI_VENDOR_ID_ICE 0x1412 +#define PCI_DEVICE_ID_ICE_1712 0x1712 +#define PCI_DEVICE_ID_VT1724 0x1724 + +#define PCI_VENDOR_ID_OXSEMI 0x1415 +#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403 +#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501 +#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511 +#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513 +#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521 + +#define PCI_VENDOR_ID_SAMSUNG 0x144d + + +#define PCI_VENDOR_ID_TITAN 0x14D2 +#define PCI_DEVICE_ID_TITAN_010L 0x8001 +#define PCI_DEVICE_ID_TITAN_100L 0x8010 +#define PCI_DEVICE_ID_TITAN_110L 0x8011 +#define PCI_DEVICE_ID_TITAN_200L 0x8020 +#define PCI_DEVICE_ID_TITAN_210L 0x8021 +#define PCI_DEVICE_ID_TITAN_400L 0x8040 +#define PCI_DEVICE_ID_TITAN_800L 0x8080 +#define PCI_DEVICE_ID_TITAN_100 0xA001 +#define PCI_DEVICE_ID_TITAN_200 0xA005 +#define PCI_DEVICE_ID_TITAN_400 0xA003 +#define PCI_DEVICE_ID_TITAN_800B 0xA004 + +#define PCI_VENDOR_ID_PANACOM 0x14d4 +#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400 +#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402 + + +#define PCI_VENDOR_ID_AFAVLAB 0x14db +#define PCI_DEVICE_ID_AFAVLAB_P028 0x2180 +#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 +#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150 + +#define PCI_VENDOR_ID_BROADCOM 0x14e4 +#define PCI_DEVICE_ID_TIGON3_5752 0x1600 +#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 +#define PCI_DEVICE_ID_TIGON3_5700 0x1644 +#define PCI_DEVICE_ID_TIGON3_5701 0x1645 +#define PCI_DEVICE_ID_TIGON3_5702 0x1646 +#define PCI_DEVICE_ID_TIGON3_5703 0x1647 +#define PCI_DEVICE_ID_TIGON3_5704 0x1648 +#define PCI_DEVICE_ID_TIGON3_5704S_2 0x1649 +#define PCI_DEVICE_ID_NX2_5706 0x164a +#define PCI_DEVICE_ID_NX2_5708 0x164c +#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d +#define PCI_DEVICE_ID_TIGON3_5705 0x1653 +#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 +#define PCI_DEVICE_ID_TIGON3_5720 0x1658 +#define PCI_DEVICE_ID_TIGON3_5721 0x1659 +#define PCI_DEVICE_ID_TIGON3_5705M 0x165d +#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e +#define PCI_DEVICE_ID_TIGON3_5714 0x1668 +#define PCI_DEVICE_ID_TIGON3_5714S 0x1669 +#define PCI_DEVICE_ID_TIGON3_5780 0x166a +#define PCI_DEVICE_ID_TIGON3_5780S 0x166b +#define PCI_DEVICE_ID_TIGON3_5705F 0x166e +#define PCI_DEVICE_ID_TIGON3_5750 0x1676 +#define PCI_DEVICE_ID_TIGON3_5751 0x1677 +#define PCI_DEVICE_ID_TIGON3_5715 0x1678 +#define PCI_DEVICE_ID_TIGON3_5715S 0x1679 +#define PCI_DEVICE_ID_TIGON3_5750M 0x167c +#define PCI_DEVICE_ID_TIGON3_5751M 0x167d +#define PCI_DEVICE_ID_TIGON3_5751F 0x167e +#define PCI_DEVICE_ID_TIGON3_5782 0x1696 +#define PCI_DEVICE_ID_TIGON3_5788 0x169c +#define PCI_DEVICE_ID_TIGON3_5789 0x169d +#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6 +#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7 +#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8 +#define PCI_DEVICE_ID_NX2_5706S 0x16aa +#define PCI_DEVICE_ID_NX2_5708S 0x16ac +#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6 +#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7 +#define PCI_DEVICE_ID_TIGON3_5781 0x16dd +#define PCI_DEVICE_ID_TIGON3_5753 0x16f7 +#define PCI_DEVICE_ID_TIGON3_5753M 0x16fd +#define PCI_DEVICE_ID_TIGON3_5753F 0x16fe +#define PCI_DEVICE_ID_TIGON3_5901 0x170d +#define PCI_DEVICE_ID_BCM4401B1 0x170c +#define PCI_DEVICE_ID_TIGON3_5901_2 0x170e +#define PCI_DEVICE_ID_BCM4401 0x4401 +#define PCI_DEVICE_ID_BCM4401B0 0x4402 + +#define PCI_VENDOR_ID_TOPIC 0x151f +#define PCI_DEVICE_ID_TOPIC_TP560 0x0000 + +#define PCI_VENDOR_ID_ENE 0x1524 +#define PCI_DEVICE_ID_ENE_1211 0x1211 +#define PCI_DEVICE_ID_ENE_1225 0x1225 +#define PCI_DEVICE_ID_ENE_1410 0x1410 +#define PCI_DEVICE_ID_ENE_710 0x1411 +#define PCI_DEVICE_ID_ENE_712 0x1412 +#define PCI_DEVICE_ID_ENE_1420 0x1420 +#define PCI_DEVICE_ID_ENE_720 0x1421 +#define PCI_DEVICE_ID_ENE_722 0x1422 + +#define PCI_VENDOR_ID_CHELSIO 0x1425 + + +#define PCI_VENDOR_ID_SYBA 0x1592 +#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782 +#define PCI_DEVICE_ID_SYBA_1P_ECP 0x0783 + +#define PCI_VENDOR_ID_MORETON 0x15aa +#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000 + +#define PCI_VENDOR_ID_ZOLTRIX 0x15b0 +#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0 + +#define PCI_VENDOR_ID_MELLANOX 0x15b3 +#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 +#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278 +#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282 +#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c +#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 + +#define PCI_VENDOR_ID_PDC 0x15e9 + + +#define PCI_VENDOR_ID_FARSITE 0x1619 +#define PCI_DEVICE_ID_FARSITE_T2P 0x0400 +#define PCI_DEVICE_ID_FARSITE_T4P 0x0440 +#define PCI_DEVICE_ID_FARSITE_T1U 0x0610 +#define PCI_DEVICE_ID_FARSITE_T2U 0x0620 +#define PCI_DEVICE_ID_FARSITE_T4U 0x0640 +#define PCI_DEVICE_ID_FARSITE_TE1 0x1610 +#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612 + +#define PCI_VENDOR_ID_SIBYTE 0x166d +#define PCI_DEVICE_ID_BCM1250_HT 0x0002 + +#define PCI_VENDOR_ID_NETCELL 0x169c +#define PCI_DEVICE_ID_REVOLUTION 0x0044 + +#define PCI_VENDOR_ID_LINKSYS 0x1737 +#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064 + +#define PCI_VENDOR_ID_ALTIMA 0x173b +#define PCI_DEVICE_ID_ALTIMA_AC1000 0x03e8 +#define PCI_DEVICE_ID_ALTIMA_AC1001 0x03e9 +#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea +#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb + +#define PCI_VENDOR_ID_S2IO 0x17d5 +#define PCI_DEVICE_ID_S2IO_WIN 0x5731 +#define PCI_DEVICE_ID_S2IO_UNI 0x5831 +#define PCI_DEVICE_ID_HERC_WIN 0x5732 +#define PCI_DEVICE_ID_HERC_UNI 0x5832 + + +#define PCI_VENDOR_ID_SITECOM 0x182d +#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069 + +#define PCI_VENDOR_ID_TOPSPIN 0x1867 + +#define PCI_VENDOR_ID_TDI 0x192E +#define PCI_DEVICE_ID_TDI_EHCI 0x0101 + + +#define PCI_VENDOR_ID_TEKRAM 0x1de1 +#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 + +#define PCI_VENDOR_ID_HINT 0x3388 +#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013 + +#define PCI_VENDOR_ID_3DLABS 0x3d3d +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007 +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009 + + +#define PCI_VENDOR_ID_AKS 0x416c +#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100 + + + +#define PCI_VENDOR_ID_S3 0x5333 +#define PCI_DEVICE_ID_S3_TRIO 0x8811 +#define PCI_DEVICE_ID_S3_868 0x8880 +#define PCI_DEVICE_ID_S3_968 0x88f0 +#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 +#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04 +#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00 + +#define PCI_VENDOR_ID_DUNORD 0x5544 +#define PCI_DEVICE_ID_DUNORD_I3000 0x0001 + + +#define PCI_VENDOR_ID_DCI 0x6666 +#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001 +#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002 +#define PCI_DEVICE_ID_DCI_PCCOM2 0x0004 + +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_EESSC 0x0008 +#define PCI_DEVICE_ID_INTEL_PXHD_0 0x0320 +#define PCI_DEVICE_ID_INTEL_PXHD_1 0x0321 +#define PCI_DEVICE_ID_INTEL_PXH_0 0x0329 +#define PCI_DEVICE_ID_INTEL_PXH_1 0x032A +#define PCI_DEVICE_ID_INTEL_PXHV 0x032C +#define PCI_DEVICE_ID_INTEL_82375 0x0482 +#define PCI_DEVICE_ID_INTEL_82424 0x0483 +#define PCI_DEVICE_ID_INTEL_82378 0x0484 +#define PCI_DEVICE_ID_INTEL_I960 0x0960 +#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 +#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130 +#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 +#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 +#define PCI_DEVICE_ID_INTEL_7505_0 0x2550 +#define PCI_DEVICE_ID_INTEL_7205_0 0x255d +#define PCI_DEVICE_ID_INTEL_82437 0x122d +#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e +#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230 +#define PCI_DEVICE_ID_INTEL_82371MX 0x1234 +#define PCI_DEVICE_ID_INTEL_82441 0x1237 +#define PCI_DEVICE_ID_INTEL_82380FB 0x124b +#define PCI_DEVICE_ID_INTEL_82439 0x1250 +#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960 +#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 +#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 +#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 +#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 +#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 +#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415 +#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416 +#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418 +#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420 +#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421 +#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423 +#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425 +#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426 +#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428 +#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440 +#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443 +#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445 +#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448 +#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a +#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b +#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c +#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e +#define PCI_DEVICE_ID_INTEL_82801E_0 0x2450 +#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b +#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480 +#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483 +#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485 +#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486 +#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a +#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b +#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c +#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0 +#define PCI_DEVICE_ID_INTEL_82801DB_1 0x24c1 +#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3 +#define PCI_DEVICE_ID_INTEL_82801DB_5 0x24c5 +#define PCI_DEVICE_ID_INTEL_82801DB_6 0x24c6 +#define PCI_DEVICE_ID_INTEL_82801DB_9 0x24c9 +#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca +#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb +#define PCI_DEVICE_ID_INTEL_82801DB_12 0x24cc +#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0 +#define PCI_DEVICE_ID_INTEL_82801EB_1 0x24d1 +#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3 +#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5 +#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6 +#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db +#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd +#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1 +#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2 +#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4 +#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6 +#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab +#define PCI_DEVICE_ID_INTEL_82820_HB 0x2500 +#define PCI_DEVICE_ID_INTEL_82820_UP_HB 0x2501 +#define PCI_DEVICE_ID_INTEL_82850_HB 0x2530 +#define PCI_DEVICE_ID_INTEL_82860_HB 0x2531 +#define PCI_DEVICE_ID_INTEL_82845G_HB 0x2560 +#define PCI_DEVICE_ID_INTEL_82845G_IG 0x2562 +#define PCI_DEVICE_ID_INTEL_82865_HB 0x2570 +#define PCI_DEVICE_ID_INTEL_82865_IG 0x2572 +#define PCI_DEVICE_ID_INTEL_82875_HB 0x2578 +#define PCI_DEVICE_ID_INTEL_82915G_HB 0x2580 +#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 +#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 +#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 +#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 +#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 +#define PCI_DEVICE_ID_INTEL_82945GM_HB 0x27A0 +#define PCI_DEVICE_ID_INTEL_82945GM_IG 0x27A2 +#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 +#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 +#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 +#define PCI_DEVICE_ID_INTEL_ICH6_16 0x266a +#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d +#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e +#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f +#define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670 +#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698 +#define PCI_DEVICE_ID_INTEL_ESB2_17 0x269b +#define PCI_DEVICE_ID_INTEL_ESB2_18 0x269e +#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8 +#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9 +#define PCI_DEVICE_ID_INTEL_ICH7_30 0x27b0 +#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd +#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da +#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd +#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de +#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df +#define PCI_DEVICE_ID_INTEL_ICH8_0 0x2810 +#define PCI_DEVICE_ID_INTEL_ICH8_1 0x2811 +#define PCI_DEVICE_ID_INTEL_ICH8_2 0x2812 +#define PCI_DEVICE_ID_INTEL_ICH8_3 0x2814 +#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815 +#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e +#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850 +#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 +#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 +#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 +#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580 +#define PCI_DEVICE_ID_INTEL_82855GM_IG 0x3582 +#define PCI_DEVICE_ID_INTEL_E7520_MCH 0x3590 +#define PCI_DEVICE_ID_INTEL_E7320_MCH 0x3592 +#define PCI_DEVICE_ID_INTEL_MCH_PA 0x3595 +#define PCI_DEVICE_ID_INTEL_MCH_PA1 0x3596 +#define PCI_DEVICE_ID_INTEL_MCH_PB 0x3597 +#define PCI_DEVICE_ID_INTEL_MCH_PB1 0x3598 +#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599 +#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a +#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e +#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000 +#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010 +#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 +#define PCI_DEVICE_ID_INTEL_82437VX 0x7030 +#define PCI_DEVICE_ID_INTEL_82439TX 0x7100 +#define PCI_DEVICE_ID_INTEL_82371AB_0 0x7110 +#define PCI_DEVICE_ID_INTEL_82371AB 0x7111 +#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112 +#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113 +#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120 +#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121 +#define PCI_DEVICE_ID_INTEL_82810_MC3 0x7122 +#define PCI_DEVICE_ID_INTEL_82810_IG3 0x7123 +#define PCI_DEVICE_ID_INTEL_82810E_MC 0x7124 +#define PCI_DEVICE_ID_INTEL_82810E_IG 0x7125 +#define PCI_DEVICE_ID_INTEL_82443LX_0 0x7180 +#define PCI_DEVICE_ID_INTEL_82443LX_1 0x7181 +#define PCI_DEVICE_ID_INTEL_82443BX_0 0x7190 +#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191 +#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192 +#define PCI_DEVICE_ID_INTEL_440MX 0x7195 +#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196 +#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198 +#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199 +#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b +#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0 +#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 +#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 +#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 +#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 +#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca +#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb +#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea +#define PCI_DEVICE_ID_INTEL_IXP4XX 0x8500 +#define PCI_DEVICE_ID_INTEL_IXP2800 0x9004 +#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 + +#define PCI_VENDOR_ID_SCALEMP 0x8686 +#define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010 + +#define PCI_VENDOR_ID_COMPUTONE 0x8e0e +#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291 +#define PCI_DEVICE_ID_COMPUTONE_PG 0x0302 +#define PCI_SUBVENDOR_ID_COMPUTONE 0x8e0e +#define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG8 0x0002 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003 + +#define PCI_VENDOR_ID_KTI 0x8e2e + +#define PCI_VENDOR_ID_ADAPTEC 0x9004 +#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078 +#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178 +#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860 +#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078 +#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578 +#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038 +#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075 +#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078 +#define PCI_DEVICE_ID_ADAPTEC_7861 0x6178 +#define PCI_DEVICE_ID_ADAPTEC_7870 0x7078 +#define PCI_DEVICE_ID_ADAPTEC_7871 0x7178 +#define PCI_DEVICE_ID_ADAPTEC_7872 0x7278 +#define PCI_DEVICE_ID_ADAPTEC_7873 0x7378 +#define PCI_DEVICE_ID_ADAPTEC_7874 0x7478 +#define PCI_DEVICE_ID_ADAPTEC_7895 0x7895 +#define PCI_DEVICE_ID_ADAPTEC_7880 0x8078 +#define PCI_DEVICE_ID_ADAPTEC_7881 0x8178 +#define PCI_DEVICE_ID_ADAPTEC_7882 0x8278 +#define PCI_DEVICE_ID_ADAPTEC_7883 0x8378 +#define PCI_DEVICE_ID_ADAPTEC_7884 0x8478 +#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578 +#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678 +#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778 +#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878 + +#define PCI_VENDOR_ID_ADAPTEC2 0x9005 +#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010 +#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011 +#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013 +#define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f +#define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050 +#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051 +#define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f +#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080 +#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081 +#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083 +#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f +#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0 +#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1 +#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3 +#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf +#define PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN 0x0500 +#define PCI_DEVICE_ID_ADAPTEC2_SCAMP 0x0503 + + +#define PCI_VENDOR_ID_HOLTEK 0x9412 +#define PCI_DEVICE_ID_HOLTEK_6565 0x6565 + +#define PCI_VENDOR_ID_NETMOS 0x9710 +#define PCI_DEVICE_ID_NETMOS_9705 0x9705 +#define PCI_DEVICE_ID_NETMOS_9715 0x9715 +#define PCI_DEVICE_ID_NETMOS_9735 0x9735 +#define PCI_DEVICE_ID_NETMOS_9745 0x9745 +#define PCI_DEVICE_ID_NETMOS_9755 0x9755 +#define PCI_DEVICE_ID_NETMOS_9805 0x9805 +#define PCI_DEVICE_ID_NETMOS_9815 0x9815 +#define PCI_DEVICE_ID_NETMOS_9835 0x9835 +#define PCI_DEVICE_ID_NETMOS_9845 0x9845 +#define PCI_DEVICE_ID_NETMOS_9855 0x9855 + +#define PCI_SUBVENDOR_ID_EXSYS 0xd84d +#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014 +#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055 + +#define PCI_VENDOR_ID_TIGERJET 0xe159 +#define PCI_DEVICE_ID_TIGERJET_300 0x0001 +#define PCI_DEVICE_ID_TIGERJET_100 0x0002 + +#define PCI_VENDOR_ID_TTTECH 0x0357 +#define PCI_DEVICE_ID_TTTECH_MC322 0x000A + +#define PCI_VENDOR_ID_XILINX_RME 0xea60 +#define PCI_DEVICE_ID_RME_DIGI32 0x9896 +#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897 +#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898 + diff --git a/ddverify/models/seq1/include/linux/pci_regs.h b/ddverify/models/seq1/include/linux/pci_regs.h new file mode 100644 index 000000000..d27a78b71 --- /dev/null +++ b/ddverify/models/seq1/include/linux/pci_regs.h @@ -0,0 +1,449 @@ +/* + * pci_regs.h + * + * PCI standard defines + * Copyright 1994, Drew Eckhardt + * Copyright 1997--1999 Martin Mares + * + * For more information, please consult the following manuals (look at + * http://www.pcisig.com/ for how to get them): + * + * PCI BIOS Specification + * PCI Local Bus Specification + * PCI to PCI Bridge Specification + * PCI System Design Guide + */ + +#ifndef LINUX_PCI_REGS_H +#define LINUX_PCI_REGS_H + +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes are standardized as follows: + */ +#define PCI_VENDOR_ID 0x00 /* 16 bits */ +#define PCI_DEVICE_ID 0x02 /* 16 bits */ +#define PCI_COMMAND 0x04 /* 16 bits */ +#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ +#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ + +#define PCI_STATUS 0x06 /* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ +#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ +#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVSEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +/* + * Base addresses specify locations in memory or I/O space. + * Decoded size can be determined by writing a value of + * 0xffffffff to the register, and reading it back. Only + * 1 bits are decoded. + */ +#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ +#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ +#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ +#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ +#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ +#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ +#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ +#define PCI_BASE_ADDRESS_SPACE_IO 0x01 +#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ +#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) +#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) +/* bit 1 is reserved if address_space = 1 */ + +/* Header type 0 (normal devices) */ +#define PCI_CARDBUS_CIS 0x28 +#define PCI_SUBSYSTEM_VENDOR_ID 0x2c +#define PCI_SUBSYSTEM_ID 0x2e +#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ +#define PCI_ROM_ADDRESS_ENABLE 0x01 +#define PCI_ROM_ADDRESS_MASK (~0x7ffUL) + +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ + +/* 0x35-0x3b are reserved */ +#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ +#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ +#define PCI_MIN_GNT 0x3e /* 8 bits */ +#define PCI_MAX_LAT 0x3f /* 8 bits */ + +/* Header type 1 (PCI-to-PCI bridges) */ +#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ +#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ +#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ +#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ +#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ +#define PCI_IO_LIMIT 0x1d +#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */ +#define PCI_IO_RANGE_TYPE_16 0x00 +#define PCI_IO_RANGE_TYPE_32 0x01 +#define PCI_IO_RANGE_MASK (~0x0fUL) +#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */ +#define PCI_MEMORY_BASE 0x20 /* Memory range behind */ +#define PCI_MEMORY_LIMIT 0x22 +#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL +#define PCI_MEMORY_RANGE_MASK (~0x0fUL) +#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ +#define PCI_PREF_MEMORY_LIMIT 0x26 +#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL +#define PCI_PREF_RANGE_TYPE_32 0x00 +#define PCI_PREF_RANGE_TYPE_64 0x01 +#define PCI_PREF_RANGE_MASK (~0x0fUL) +#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ +#define PCI_PREF_LIMIT_UPPER32 0x2c +#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ +#define PCI_IO_LIMIT_UPPER16 0x32 +/* 0x34 same as for htype 0 */ +/* 0x35-0x3b is reserved */ +#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_BRIDGE_CONTROL 0x3e +#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ +#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ +#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ +#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ +#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ +#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ +#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ + +/* Header type 2 (CardBus bridges) */ +#define PCI_CB_CAPABILITY_LIST 0x14 +/* 0x15 reserved */ +#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ +#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ +#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ +#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ +#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ +#define PCI_CB_MEMORY_BASE_0 0x1c +#define PCI_CB_MEMORY_LIMIT_0 0x20 +#define PCI_CB_MEMORY_BASE_1 0x24 +#define PCI_CB_MEMORY_LIMIT_1 0x28 +#define PCI_CB_IO_BASE_0 0x2c +#define PCI_CB_IO_BASE_0_HI 0x2e +#define PCI_CB_IO_LIMIT_0 0x30 +#define PCI_CB_IO_LIMIT_0_HI 0x32 +#define PCI_CB_IO_BASE_1 0x34 +#define PCI_CB_IO_BASE_1_HI 0x36 +#define PCI_CB_IO_LIMIT_1 0x38 +#define PCI_CB_IO_LIMIT_1_HI 0x3a +#define PCI_CB_IO_RANGE_MASK (~0x03UL) +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_CB_BRIDGE_CONTROL 0x3e +#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ +#define PCI_CB_BRIDGE_CTL_SERR 0x02 +#define PCI_CB_BRIDGE_CTL_ISA 0x04 +#define PCI_CB_BRIDGE_CTL_VGA 0x08 +#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 +#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ +#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 +#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 +#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 +#define PCI_CB_SUBSYSTEM_ID 0x42 +#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ +/* 0x48-0x7f reserved */ + +/* Capability lists */ + +#define PCI_CAP_LIST_ID 0 /* Capability ID */ +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ +#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ +#define PCI_CAP_ID_HT_IRQCONF 0x08 /* HyperTransport IRQ Configuration */ +#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ +#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + +/* Power Management Registers */ + +#define PCI_PM_PMC 2 /* PM Capabilities Register */ +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ +#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ +#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */ +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ +#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */ +#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */ +#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */ +#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ +#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ +#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ +#define PCI_PM_CTRL 4 /* PM control and status register */ +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_NO_SOFT_RESET 0x0004 /* No reset for D3hot->D0 */ +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ +#define PCI_PM_DATA_REGISTER 7 /* (??) */ +#define PCI_PM_SIZEOF 8 + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ +#define PCI_AGP_SIZEOF 12 + +/* Vital Product Data */ + +#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */ +#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */ +#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */ +#define PCI_VPD_DATA 4 /* 32-bits of data returned here */ + +/* Slot Identification */ + +#define PCI_SID_ESR 2 /* Expansion Slot Register */ +#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ +#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ +#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ + +/* Message Signalled Interrupts registers */ + +#define PCI_MSI_FLAGS 2 /* Various flags */ +#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ +#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ +#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ +#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ +#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */ +#define PCI_MSI_RFU 3 /* Rest of capability flags */ +#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ +#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ +#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ +#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ +#define PCI_MSI_MASK_BIT 16 /* Mask bits register */ + +/* CompactPCI Hotswap Register */ + +#define PCI_CHSWP_CSR 2 /* Control and Status Register */ +#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */ +#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */ +#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */ +#define PCI_CHSWP_LOO 0x08 /* LED On / Off */ +#define PCI_CHSWP_PI 0x30 /* Programming Interface */ +#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */ +#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */ + +/* PCI-X registers */ + +#define PCI_X_CMD 2 /* Modes & Features */ +#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */ +#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */ +#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */ +#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */ +#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */ +#define PCI_X_STATUS 4 /* PCI-X capabilities */ +#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */ +#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */ +#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */ +#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */ +#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */ +#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */ +#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */ +#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */ +#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */ +#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */ +#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */ +#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */ +#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */ + +/* PCI Express capability registers */ + +#define PCI_EXP_FLAGS 2 /* Capabilities register */ +#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */ +#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */ +#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */ +#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */ +#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */ +#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ +#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ +#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ +#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ +#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ +#define PCI_EXP_DEVCAP 4 /* Device capabilities */ +#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */ +#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */ +#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */ +#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */ +#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */ +#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ +#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ +#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ +#define PCI_EXP_DEVCTL 8 /* Device Control */ +#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ +#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ +#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */ +#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ +#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ +#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ +#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */ +#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ +#define PCI_EXP_DEVSTA 10 /* Device Status */ +#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ +#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ +#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */ +#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ +#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ +#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ +#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ +#define PCI_EXP_LNKCTL 16 /* Link Control */ +#define PCI_EXP_LNKSTA 18 /* Link Status */ +#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ +#define PCI_EXP_SLTCTL 24 /* Slot Control */ +#define PCI_EXP_SLTSTA 26 /* Slot Status */ +#define PCI_EXP_RTCTL 28 /* Root Control */ +#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */ +#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */ +#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */ +#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */ +#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ +#define PCI_EXP_RTCAP 30 /* Root Capabilities */ +#define PCI_EXP_RTSTA 32 /* Root Status */ + +/* Extended Capabilities (PCI-X 2.0 and Express) */ +#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) +#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf) +#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) + +#define PCI_EXT_CAP_ID_ERR 1 +#define PCI_EXT_CAP_ID_VC 2 +#define PCI_EXT_CAP_ID_DSN 3 +#define PCI_EXT_CAP_ID_PWR 4 + +/* Advanced Error Reporting */ +#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ +#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */ +#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */ +#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */ +#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */ +#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */ +#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */ +#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */ +#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */ +#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */ +#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */ +#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */ +#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */ + /* Same bits as above */ +#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */ +#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */ +#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */ +#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */ +#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */ +#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */ +#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */ +#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */ +#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */ +#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */ +#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ +#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ +#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */ +#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */ +#define PCI_ERR_ROOT_STATUS 48 +#define PCI_ERR_ROOT_COR_SRC 52 +#define PCI_ERR_ROOT_SRC 54 + +/* Virtual Channel */ +#define PCI_VC_PORT_REG1 4 +#define PCI_VC_PORT_REG2 8 +#define PCI_VC_PORT_CTRL 12 +#define PCI_VC_PORT_STATUS 14 +#define PCI_VC_RES_CAP 16 +#define PCI_VC_RES_CTRL 20 +#define PCI_VC_RES_STATUS 26 + +/* Power Budgeting */ +#define PCI_PWR_DSR 4 /* Data Select Register */ +#define PCI_PWR_DATA 8 /* Data Register */ +#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */ +#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */ +#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */ +#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */ +#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */ +#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */ +#define PCI_PWR_CAP 12 /* Capability */ +#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ + +#endif /* LINUX_PCI_REGS_H */ diff --git a/ddverify/models/seq1/include/linux/percpu.h b/ddverify/models/seq1/include/linux/percpu.h new file mode 100644 index 000000000..8e9945bd8 --- /dev/null +++ b/ddverify/models/seq1/include/linux/percpu.h @@ -0,0 +1,10 @@ +#ifndef __LINUX_PERCPU_H +#define __LINUX_PERCPU_H + +#include +#include +//#include +#include +//#include + +#endif /* __LINUX_PERCPU_H */ diff --git a/ddverify/models/seq1/include/linux/platform_device.h b/ddverify/models/seq1/include/linux/platform_device.h new file mode 100644 index 000000000..97a8fed3f --- /dev/null +++ b/ddverify/models/seq1/include/linux/platform_device.h @@ -0,0 +1,25 @@ +#ifndef _PLATFORM_DEVICE_H_ +#define _PLATFORM_DEVICE_H_ + +#include + +struct platform_device { + const char * name; + u32 id; + struct device dev; + u32 num_resources; + struct resource * resource; +}; + +struct platform_driver { + int (*probe)(struct platform_device *); + int (*remove)(struct platform_device *); + void (*shutdown)(struct platform_device *); + int (*suspend)(struct platform_device *, pm_message_t state); + int (*suspend_late)(struct platform_device *, pm_message_t state); + int (*resume_early)(struct platform_device *); + int (*resume)(struct platform_device *); + struct device_driver driver; +}; + +#endif /* _PLATFORM_DEVICE_H_ */ diff --git a/ddverify/models/seq1/include/linux/pm.h b/ddverify/models/seq1/include/linux/pm.h new file mode 100644 index 000000000..430226d01 --- /dev/null +++ b/ddverify/models/seq1/include/linux/pm.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_PM_H +#define _LINUX_PM_H + +#include +#include +#include + +typedef struct pm_message { + int event; +} pm_message_t; + +#endif /* _LINUX_PM_H */ diff --git a/ddverify/models/seq1/include/linux/pnp.h b/ddverify/models/seq1/include/linux/pnp.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/poll.h b/ddverify/models/seq1/include/linux/poll.h new file mode 100644 index 000000000..326affc5f --- /dev/null +++ b/ddverify/models/seq1/include/linux/poll.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_POLL_H +#define _LINUX_POLL_H + +#include +#include +#include +#include +#include + +typedef struct poll_table_struct { + int something; +} poll_table; + +void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p); + +#endif /* _LINUX_POLL_H */ diff --git a/ddverify/models/seq1/include/linux/posix_types.h b/ddverify/models/seq1/include/linux/posix_types.h new file mode 100644 index 000000000..f60a473e2 --- /dev/null +++ b/ddverify/models/seq1/include/linux/posix_types.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_POSIX_TYPES_H +#define _LINUX_POSIX_TYPES_H + +typedef int __kernel_key_t; +typedef int __kernel_mqd_t; + +#include + +#endif /* _LINUX_POSIX_TYPES_H */ diff --git a/ddverify/models/seq1/include/linux/proc_fs.h b/ddverify/models/seq1/include/linux/proc_fs.h new file mode 100644 index 000000000..48ffb5cf2 --- /dev/null +++ b/ddverify/models/seq1/include/linux/proc_fs.h @@ -0,0 +1,29 @@ +#ifndef _LINUX_PROC_FS_H +#define _LINUX_PROC_FS_H + +#include +#include + +struct proc_dir_entry { + int something; +}; + +struct proc_dir_entry *proc_root_driver; + +typedef int (read_proc_t)(char *page, char **start, off_t off, + int count, int *eof, void *data); + +struct proc_dir_entry *create_proc_read_entry(const char *name, + mode_t mode, + struct proc_dir_entry *base, + read_proc_t *read_proc, + void * data); + +struct proc_dir_entry *create_proc_entry(const char *name, + mode_t mode, + struct proc_dir_entry *parent); + +void remove_proc_entry(const char *name, struct proc_dir_entry *parent); +struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); + +#endif diff --git a/ddverify/models/seq1/include/linux/ptrace.h b/ddverify/models/seq1/include/linux/ptrace.h new file mode 100644 index 000000000..e47ffb1ac --- /dev/null +++ b/ddverify/models/seq1/include/linux/ptrace.h @@ -0,0 +1,80 @@ +#ifndef _LINUX_PTRACE_H +#define _LINUX_PTRACE_H +/* ptrace.h */ +/* structs and defines to help the user use the ptrace system call. */ + +/* has the defines to get at the registers. */ + +#define PTRACE_TRACEME 0 +#define PTRACE_PEEKTEXT 1 +#define PTRACE_PEEKDATA 2 +#define PTRACE_PEEKUSR 3 +#define PTRACE_POKETEXT 4 +#define PTRACE_POKEDATA 5 +#define PTRACE_POKEUSR 6 +#define PTRACE_CONT 7 +#define PTRACE_KILL 8 +#define PTRACE_SINGLESTEP 9 + +#define PTRACE_ATTACH 16 +#define PTRACE_DETACH 17 + +#define PTRACE_SYSCALL 24 + +/* 0x4200-0x4300 are reserved for architecture-independent additions. */ +#define PTRACE_SETOPTIONS 0x4200 +#define PTRACE_GETEVENTMSG 0x4201 +#define PTRACE_GETSIGINFO 0x4202 +#define PTRACE_SETSIGINFO 0x4203 + +/* options set using PTRACE_SETOPTIONS */ +#define PTRACE_O_TRACESYSGOOD 0x00000001 +#define PTRACE_O_TRACEFORK 0x00000002 +#define PTRACE_O_TRACEVFORK 0x00000004 +#define PTRACE_O_TRACECLONE 0x00000008 +#define PTRACE_O_TRACEEXEC 0x00000010 +#define PTRACE_O_TRACEVFORKDONE 0x00000020 +#define PTRACE_O_TRACEEXIT 0x00000040 + +#define PTRACE_O_MASK 0x0000007f + +/* Wait extended result codes for the above trace options. */ +#define PTRACE_EVENT_FORK 1 +#define PTRACE_EVENT_VFORK 2 +#define PTRACE_EVENT_CLONE 3 +#define PTRACE_EVENT_EXEC 4 +#define PTRACE_EVENT_VFORK_DONE 5 +#define PTRACE_EVENT_EXIT 6 + +/* + * Ptrace flags + * + * The owner ship rules for task->ptrace which holds the ptrace + * flags is simple. When a task is running it owns it's task->ptrace + * flags. When the a task is stopped the ptracer owns task->ptrace. + */ + +#define PT_PTRACED 0x00000001 +#define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ +#define PT_TRACESYSGOOD 0x00000004 +#define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */ +#define PT_TRACE_FORK 0x00000010 +#define PT_TRACE_VFORK 0x00000020 +#define PT_TRACE_CLONE 0x00000040 +#define PT_TRACE_EXEC 0x00000080 +#define PT_TRACE_VFORK_DONE 0x00000100 +#define PT_TRACE_EXIT 0x00000200 +#define PT_ATTACHED 0x00000400 /* parent != real_parent */ + +#define PT_TRACE_MASK 0x000003f4 + +/* single stepping state bits (used on ARM and PA-RISC) */ +#define PT_SINGLESTEP_BIT 31 +#define PT_SINGLESTEP (1< /* For unlikely. */ +#include /* For struct task_struct. */ + +#endif diff --git a/ddverify/models/seq1/include/linux/reboot.h b/ddverify/models/seq1/include/linux/reboot.h new file mode 100644 index 000000000..b1d2d7da1 --- /dev/null +++ b/ddverify/models/seq1/include/linux/reboot.h @@ -0,0 +1,75 @@ +#ifndef _LINUX_REBOOT_H +#define _LINUX_REBOOT_H + +/* + * Magic values required to use _reboot() system call. + */ + +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_MAGIC2A 85072278 +#define LINUX_REBOOT_MAGIC2B 369367448 +#define LINUX_REBOOT_MAGIC2C 537993216 + + +/* + * Commands accepted by the _reboot() system call. + * + * RESTART Restart system using default command and mode. + * HALT Stop OS and give system control to ROM monitor, if any. + * CAD_ON Ctrl-Alt-Del sequence causes RESTART command. + * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task. + * POWER_OFF Stop OS and remove all power from system, if possible. + * RESTART2 Restart system using given command string. + * SW_SUSPEND Suspend system using software suspend if compiled in. + * KEXEC Restart system using a previously loaded Linux kernel + */ + +#define LINUX_REBOOT_CMD_RESTART 0x01234567 +#define LINUX_REBOOT_CMD_HALT 0xCDEF0123 +#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF +#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000 +#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 +#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2 +#define LINUX_REBOOT_CMD_KEXEC 0x45584543 + + +#include + +extern int register_reboot_notifier(struct notifier_block *); +extern int unregister_reboot_notifier(struct notifier_block *); + + +/* + * Architecture-specific implementations of sys_reboot commands. + */ + +extern void machine_restart(char *cmd); +extern void machine_halt(void); +extern void machine_power_off(void); + +extern void machine_shutdown(void); +struct pt_regs; +extern void machine_crash_shutdown(struct pt_regs *); + +/* + * Architecture independent implemenations of sys_reboot commands. + */ + +extern void kernel_shutdown_prepare(enum system_states state); + +extern void kernel_restart(char *cmd); +extern void kernel_halt(void); +extern void kernel_power_off(void); + +void ctrl_alt_del(void); + +/* + * Emergency restart, callable from an interrupt handler. + */ + +extern void emergency_restart(void); +//#include + +#endif /* _LINUX_REBOOT_H */ diff --git a/ddverify/models/seq1/include/linux/rtc.h b/ddverify/models/seq1/include/linux/rtc.h new file mode 100644 index 000000000..58ff91583 --- /dev/null +++ b/ddverify/models/seq1/include/linux/rtc.h @@ -0,0 +1,219 @@ +/* + * Generic RTC interface. + * This version contains the part of the user interface to the Real Time Clock + * service. It is used with both the legacy mc146818 and also EFI + * Struct rtc_time and first 12 ioctl by Paul Gortmaker, 1996 - separated out + * from to this file for 2.4 kernels. + * + * Copyright (C) 1999 Hewlett-Packard Co. + * Copyright (C) 1999 Stephane Eranian + */ +#ifndef _LINUX_RTC_H_ +#define _LINUX_RTC_H_ + +/* + * The struct used to pass data via the following ioctl. Similar to the + * struct tm in , but it needs to be here so that the kernel + * source is self contained, allowing cross-compiles, etc. etc. + */ +struct rtc_time { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +/* + * This data structure is inspired by the EFI (v0.92) wakeup + * alarm API. + */ +struct rtc_wkalrm { + unsigned char enabled; + unsigned char pending; + struct rtc_time time; +}; + +/* + * Data structure to control PLL correction some better RTC feature + * pll_value is used to get or set current value of correction, + * the rest of the struct is used to query HW capabilities. + * This is modeled after the RTC used in Q40/Q60 computers but + * should be sufficiently flexible for other devices + * + * +ve pll_value means clock will run faster by + * pll_value*pll_posmult/pll_clock + * -ve pll_value means clock will run slower by + * pll_value*pll_negmult/pll_clock + */ + +struct rtc_pll_info { + /* int pll_ctrl; + int pll_value; + int pll_max; + int pll_min; + int pll_posmult; + int pll_negmult; + long pll_clock; +*/ + int something; +}; + +/* + * ioctl calls that are permitted to the /dev/rtc interface, if + * any of the RTC drivers are enabled. + */ + +#define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */ +#define RTC_AIE_OFF _IO('p', 0x02) /* ... off */ +#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */ +#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */ +#define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */ +#define RTC_PIE_OFF _IO('p', 0x06) /* ... off */ +#define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */ +#define RTC_WIE_OFF _IO('p', 0x10) /* ... off */ + +#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */ +#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */ +#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */ +#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */ +#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */ +#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */ +#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */ +#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */ + +#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/ +#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/ + +#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */ +#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */ + +/* interrupt flags */ +#define RTC_IRQF 0x80 /* any of the following is active */ +#define RTC_PF 0x40 +#define RTC_AF 0x20 +#define RTC_UF 0x10 + + +#include + +extern int rtc_month_days(unsigned int month, unsigned int year); +extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); +extern int rtc_valid_tm(struct rtc_time *tm); +extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); +extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); + +#include +#include +#include +#include +#include + +extern struct class *rtc_class; + +struct rtc_class_ops { + /* int (*open)(struct device *); + void (*release)(struct device *); + int (*ioctl)(struct device *, unsigned int, unsigned long); + int (*read_time)(struct device *, struct rtc_time *); + int (*set_time)(struct device *, struct rtc_time *); + int (*read_alarm)(struct device *, struct rtc_wkalrm *); + int (*set_alarm)(struct device *, struct rtc_wkalrm *); + int (*proc)(struct device *, struct seq_file *); + int (*set_mmss)(struct device *, unsigned long secs); + int (*irq_set_state)(struct device *, int enabled); + int (*irq_set_freq)(struct device *, int freq); + int (*read_callback)(struct device *, int data); + */ + int something; +}; + +#define RTC_DEVICE_NAME_SIZE 20 +struct rtc_task; + +struct rtc_device +{ + /* struct class_device class_dev; + struct module *owner; + + int id; + char name[RTC_DEVICE_NAME_SIZE]; + + const struct rtc_class_ops *ops; + struct mutex ops_lock; + + struct class_device *rtc_dev; + struct cdev char_dev; + struct mutex char_lock; + + unsigned long irq_data; + spinlock_t irq_lock; + wait_queue_head_t irq_queue; + struct fasync_struct *async_queue; + + struct rtc_task *irq_task; + spinlock_t irq_task_lock; + int irq_freq; + int max_user_freq; +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL + struct work_struct uie_task; + struct timer_list uie_timer; + unsigned int oldsecs; + unsigned int irq_active:1; + unsigned int stop_uie_polling:1; + unsigned int uie_task_active:1; + unsigned int uie_timer_active:1; +#endif + */ + int something; +}; +#define to_rtc_device(d) container_of(d, struct rtc_device, class_dev) + +extern struct rtc_device *rtc_device_register(const char *name, + struct device *dev, + const struct rtc_class_ops *ops, + struct module *owner); +extern void rtc_device_unregister(struct rtc_device *rdev); +extern int rtc_interface_register(struct class_interface *intf); + +extern int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_mmss(struct class_device *class_dev, unsigned long secs); +extern int rtc_read_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern int rtc_set_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern void rtc_update_irq(struct class_device *class_dev, + unsigned long num, unsigned long events); + +extern struct class_device *rtc_class_open(char *name); +extern void rtc_class_close(struct class_device *class_dev); + +extern int rtc_irq_register(struct class_device *class_dev, + struct rtc_task *task); +extern void rtc_irq_unregister(struct class_device *class_dev, + struct rtc_task *task); +extern int rtc_irq_set_state(struct class_device *class_dev, + struct rtc_task *task, int enabled); +extern int rtc_irq_set_freq(struct class_device *class_dev, + struct rtc_task *task, int freq); + +typedef struct rtc_task { + void (*func)(void *private_data); + void *private_data; +} rtc_task_t; + +int rtc_register(rtc_task_t *task); +int rtc_unregister(rtc_task_t *task); +int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); +void rtc_get_rtc_time(struct rtc_time *rtc_tm); +irqreturn_t rtc_interrupt(int irq, void *dev_id); + + +unsigned char rtc_read(unsigned char); +void rtc_write(unsigned char, unsigned char); +#endif /* _LINUX_RTC_H_ */ diff --git a/ddverify/models/seq1/include/linux/scatterlist.h b/ddverify/models/seq1/include/linux/scatterlist.h new file mode 100644 index 000000000..32da1e633 --- /dev/null +++ b/ddverify/models/seq1/include/linux/scatterlist.h @@ -0,0 +1,24 @@ +#ifndef _LINUX_SCATTERLIST_H +#define _LINUX_SCATTERLIST_H + +#include +#include +#include + +/*static inline void sg_set_buf(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + sg->page = virt_to_page(buf); + sg->offset = offset_in_page(buf); + sg->length = buflen; +} + +static inline void sg_init_one(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + memset(sg, 0, sizeof(*sg)); + sg_set_buf(sg, buf, buflen); +} +*/ + +#endif /* _LINUX_SCATTERLIST_H */ diff --git a/ddverify/models/seq1/include/linux/sched.h b/ddverify/models/seq1/include/linux/sched.h new file mode 100644 index 000000000..c15cd8719 --- /dev/null +++ b/ddverify/models/seq1/include/linux/sched.h @@ -0,0 +1,62 @@ +#ifndef _LINUX_SCHED_H +#define _LINUX_SCHED_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_STOPPED 4 +#define TASK_TRACED 8 + +#define TASK_COMM_LEN 16 + +struct sighand_struct { + spinlock_t siglock; +}; + +struct task_struct { + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + pid_t pid; + char comm[TASK_COMM_LEN]; + + sigset_t blocked, real_blocked; + + struct sighand_struct *sighand; +}; + +#include + +int signal_pending(struct task_struct *p); + +// DDV: Body is defined in linux/kernel/sched.c +void schedule(void); +// DDV: Body is defined in linux/kernel/sched.c +long schedule_timeout(long timeout); +// DDV: TODO +int need_resched(void); + +// DDV: TODO +extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); + +// DDV: TODO +void yield(void); + +// DDV: No body for this function +void set_current_state(int); + +// DDV: TODO +extern int kill_proc(pid_t, int, int); +// DDV: TODO +extern void recalc_sigpending(void); +#endif diff --git a/ddverify/models/seq1/include/linux/seq_file.h b/ddverify/models/seq1/include/linux/seq_file.h new file mode 100644 index 000000000..bb64052b9 --- /dev/null +++ b/ddverify/models/seq1/include/linux/seq_file.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_SEQ_FILE_H +#define _LINUX_SEQ_FILE_H + +#include +#include +#include + +struct seq_operations; +struct file; +struct vfsmount; +struct dentry; +struct inode; + +struct seq_file { + int something; +}; + +struct seq_operations { + void * (*start) (struct seq_file *m, loff_t *pos); + void (*stop) (struct seq_file *m, void *v); + void * (*next) (struct seq_file *m, void *v, loff_t *pos); + int (*show) (struct seq_file *m, void *v); +}; + +int seq_open(struct file *, struct seq_operations *); +ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); +loff_t seq_lseek(struct file *, loff_t, int); +int seq_release(struct inode *, struct file *); +int seq_escape(struct seq_file *, const char *, const char *); +int seq_putc(struct seq_file *m, char c); +int seq_puts(struct seq_file *m, const char *s); + +int seq_printf(struct seq_file *, const char *, ...); + +#endif diff --git a/ddverify/models/seq1/include/linux/serial.h b/ddverify/models/seq1/include/linux/serial.h new file mode 100644 index 000000000..b532862fc --- /dev/null +++ b/ddverify/models/seq1/include/linux/serial.h @@ -0,0 +1,131 @@ +/* + * include/linux/serial.h + * + * Copyright (C) 1992 by Theodore Ts'o. + * + * Redistribution of this file is permitted under the terms of the GNU + * Public License (GPL) + */ + +#ifndef _LINUX_SERIAL_H +#define _LINUX_SERIAL_H + +#include +#include + +#define SERIAL_XMIT_SIZE PAGE_SIZE + +struct serial_struct { + int type; + int line; + unsigned int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + unsigned short close_delay; + char io_type; + char reserved_char[1]; + int hub6; + unsigned short closing_wait; /* time to wait before closing */ + unsigned short closing_wait2; /* no longer used... */ + unsigned char *iomem_base; + unsigned short iomem_reg_shift; + unsigned int port_high; + unsigned long iomap_base; /* cookie passed into ioremap */ +}; + + +/* + * For the close wait times, 0 means wait forever for serial port to + * flush its output. 65535 means don't wait at all. + */ +#define ASYNC_CLOSING_WAIT_INF 0 +#define ASYNC_CLOSING_WAIT_NONE 65535 + + +/* + * These are the supported serial types. + */ +#define PORT_UNKNOWN 0 +#define PORT_8250 1 +#define PORT_16450 2 +#define PORT_16550 3 +#define PORT_16550A 4 +#define PORT_CIRRUS 5 /* usurped by cyclades.c */ +#define PORT_16650 6 +#define PORT_16650V2 7 +#define PORT_16750 8 +#define PORT_STARTECH 9 /* usurped by cyclades.c */ +#define PORT_16C950 10 /* Oxford Semiconductor */ +#define PORT_16654 11 +#define PORT_16850 12 +#define PORT_RSA 13 /* RSA-DV II/S card */ +#define PORT_MAX 13 + +#define SERIAL_IO_PORT 0 +#define SERIAL_IO_HUB6 1 +#define SERIAL_IO_MEM 2 + + + + +#define UART_CLEAR_FIFO 0x01 +#define UART_USE_FIFO 0x02 +#define UART_STARTECH 0x04 +#define UART_NATSEMI 0x08 + + +/* + * Definitions for async_struct (and serial_struct) flags field + */ +#define ASYNC_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes + on the callout port */ +#define ASYNC_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */ +#define ASYNC_SAK 0x0004 /* Secure Attention Key (Orange book) */ +#define ASYNC_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ + +#define ASYNC_SPD_MASK 0x1030 +#define ASYNC_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ + +#define ASYNC_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ +#define ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */ + +#define ASYNC_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ +#define ASYNC_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ +#define ASYNC_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ +#define ASYNC_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ +#define ASYNC_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ + +#define ASYNC_HARDPPS_CD 0x0800 /* Call hardpps when CD goes high */ + +#define ASYNC_SPD_SHI 0x1000 /* Use 230400 instead of 38400 bps */ +#define ASYNC_SPD_WARP 0x1010 /* Use 460800 instead of 38400 bps */ + +#define ASYNC_LOW_LATENCY 0x2000 /* Request low latency behaviour */ + +#define ASYNC_BUGGY_UART 0x4000 /* This is a buggy UART, skip some safety + * checks. Note: can be dangerous! */ + +#define ASYNC_AUTOPROBE 0x8000 /* Port was autoprobed by PCI or PNP code */ + +#define ASYNC_FLAGS 0x7FFF /* Possible legal async flags */ +#define ASYNC_USR_MASK 0x3430 /* Legal flags that non-privileged + * users can set or reset */ + +/* Internal flags used only by kernel/chr_drv/serial.c */ +#define ASYNC_INITIALIZED 0x80000000 /* Serial port was initialized */ +#define ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ +#define ASYNC_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ +#define ASYNC_CLOSING 0x08000000 /* Serial port is closing */ +#define ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */ +#define ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */ +#define ASYNC_SHARE_IRQ 0x01000000 /* for multifunction cards + --- no longer used */ +#define ASYNC_CONS_FLOW 0x00800000 /* flow control for console */ + +#define ASYNC_BOOT_ONLYMCA 0x00400000 /* Probe only if MCA bus */ +#define ASYNC_INTERNAL_FLAGS 0xFFC00000 /* Internal flags */ + +#endif /* _LINUX_SERIAL_H */ diff --git a/ddverify/models/seq1/include/linux/signal.h b/ddverify/models/seq1/include/linux/signal.h new file mode 100644 index 000000000..2b8814641 --- /dev/null +++ b/ddverify/models/seq1/include/linux/signal.h @@ -0,0 +1,54 @@ +#ifndef _LINUX_SIGNAL_H +#define _LINUX_SIGNAL_H + +#include +#include + +#include +#include + +#include + +/* + * These values of sa_flags are used only by the kernel as part of the + * irq handling routines. + * + * SA_INTERRUPT is also used by the irq handling routines. + * SA_SHIRQ is for shared interrupt support on PCI and EISA. + */ +#define SA_PROBE SA_ONESHOT +#define SA_SAMPLE_RANDOM SA_RESTART +#define SA_SHIRQ 0x04000000 + +static inline void sigfillset(sigset_t *set) +{ + switch (_NSIG_WORDS) { + default: + memset(set, -1, sizeof(sigset_t)); + break; + case 2: set->sig[1] = -1; + case 1: set->sig[0] = -1; + break; + } +} + +/* Some extensions for manipulating the low 32 signals in particular. */ + +static inline void sigaddsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] |= mask; +} + +static inline void sigdelsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] &= ~mask; +} + +static inline int sigtestsetmask(sigset_t *set, unsigned long mask) +{ + return (set->sig[0] & mask) != 0; +} + +#define sigmask(sig) (1UL << ((sig) - 1)) + +#endif /* _LINUX_SIGNAL_H */ diff --git a/ddverify/models/seq1/include/linux/skbuff.h b/ddverify/models/seq1/include/linux/skbuff.h new file mode 100644 index 000000000..abc4822d9 --- /dev/null +++ b/ddverify/models/seq1/include/linux/skbuff.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_SKBUFF_H +#define _LINUX_SKBUFF_H + +#include + +#endif /* _LINUX_SKBUFF_H */ diff --git a/ddverify/models/seq1/include/linux/slab.h b/ddverify/models/seq1/include/linux/slab.h new file mode 100644 index 000000000..edfc1e1ca --- /dev/null +++ b/ddverify/models/seq1/include/linux/slab.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_SLAB_H +#define _LINUX_SLAB_H + +#include +#include + +// DDV: TODO +void kfree(const void *); +// DDV: Body is defined in linux/mm/slab.c +void *kmalloc(size_t size, gfp_t flags); +// DDV: Body is defined in linux/mm/slab.c +void *kzalloc(size_t size, gfp_t flags); +// DDV: TODO +unsigned int ksize(const void *); + +#endif diff --git a/ddverify/models/seq1/include/linux/smp_lock.h b/ddverify/models/seq1/include/linux/smp_lock.h new file mode 100644 index 000000000..fbd5463bc --- /dev/null +++ b/ddverify/models/seq1/include/linux/smp_lock.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_SMPLOCK_H +#define __LINUX_SMPLOCK_H + +#include +#include + +spinlock_t kernel_lock; + +#define lock_kernel() spin_lock(&kernel_lock) +#define unlock_kernel() spin_unlock(&kernel_lock) + +#endif /* __LINUX_SMPLOCK_H */ diff --git a/ddverify/models/seq1/include/linux/socket.h b/ddverify/models/seq1/include/linux/socket.h new file mode 100644 index 000000000..365beed9c --- /dev/null +++ b/ddverify/models/seq1/include/linux/socket.h @@ -0,0 +1,109 @@ +#ifndef _LINUX_SOCKET_H +#define _LINUX_SOCKET_H + +#include /* iovec support */ + +/* Supported address families. */ +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* AppleTalk DDP */ +#define AF_NETROM 6 /* Amateur Radio NET/ROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_ATMPVC 8 /* ATM PVCs */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_INET6 10 /* IP version 6 */ +#define AF_ROSE 11 /* Amateur Radio X.25 PLP */ +#define AF_DECnet 12 /* Reserved for DECnet project */ +#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ +#define AF_KEY 15 /* PF_KEY key management API */ +#define AF_NETLINK 16 +#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ +#define AF_PACKET 17 /* Packet family */ +#define AF_ASH 18 /* Ash */ +#define AF_ECONET 19 /* Acorn Econet */ +#define AF_ATMSVC 20 /* ATM SVCs */ +#define AF_SNA 22 /* Linux SNA Project (nutters!) */ +#define AF_IRDA 23 /* IRDA sockets */ +#define AF_PPPOX 24 /* PPPoX sockets */ +#define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_LLC 26 /* Linux LLC */ +#define AF_TIPC 30 /* TIPC sockets */ +#define AF_BLUETOOTH 31 /* Bluetooth sockets */ +#define AF_MAX 32 /* For now.. */ + +/* Protocol families, same as address families. */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL AF_LOCAL +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_ATMPVC AF_ATMPVC +#define PF_X25 AF_X25 +#define PF_INET6 AF_INET6 +#define PF_ROSE AF_ROSE +#define PF_DECnet AF_DECnet +#define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY +#define PF_KEY AF_KEY +#define PF_NETLINK AF_NETLINK +#define PF_ROUTE AF_ROUTE +#define PF_PACKET AF_PACKET +#define PF_ASH AF_ASH +#define PF_ECONET AF_ECONET +#define PF_ATMSVC AF_ATMSVC +#define PF_SNA AF_SNA +#define PF_IRDA AF_IRDA +#define PF_PPPOX AF_PPPOX +#define PF_WANPIPE AF_WANPIPE +#define PF_LLC AF_LLC +#define PF_TIPC AF_TIPC +#define PF_BLUETOOTH AF_BLUETOOTH +#define PF_MAX AF_MAX + +/* Maximum queue length specifiable by listen. */ +#define SOMAXCONN 128 + +/* Flags we can use with send/ and recv. + Added those for 1003.1g not all are supported yet + */ + +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 /* Confirm path validity */ +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ +#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ +#define MSG_MORE 0x8000 /* Sender will send more */ + +#define MSG_EOF MSG_FIN + +struct msghdr { + void * msg_name; /* Socket name */ + int msg_namelen; /* Length of name */ +// struct iovec * msg_iov; /* Data blocks */ + __kernel_size_t msg_iovlen; /* Number of blocks */ + void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + __kernel_size_t msg_controllen; /* Length of cmsg list */ + unsigned msg_flags; +}; + +#endif /* _LINUX_SOCKET_H */ diff --git a/ddverify/models/seq1/include/linux/spinlock.h b/ddverify/models/seq1/include/linux/spinlock.h new file mode 100644 index 000000000..71531ae4f --- /dev/null +++ b/ddverify/models/seq1/include/linux/spinlock.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_SPINLOCK_H +#define __LINUX_SPINLOCK_H + +#include +#include + +// DDV: Bodies for all spinlock-functions are defined in linux/kernel/spinlock.c + +void spin_lock_init(spinlock_t *); +void spin_lock(spinlock_t *); +void spin_lock_irqsave(spinlock_t *, unsigned long); +void spin_lock_irq(spinlock_t *); +void spin_lock_bh(spinlock_t *); + +void spin_unlock(spinlock_t *); +void spin_unlock_irqrestore(spinlock_t *, unsigned long); +void spin_unlock_irq(spinlock_t *); +void spin_unlock_bh(spinlock_t *); + +#endif /* __LINUX_SPINLOCK_H */ diff --git a/ddverify/models/seq1/include/linux/spinlock_types.h b/ddverify/models/seq1/include/linux/spinlock_types.h new file mode 100644 index 000000000..86dd36d84 --- /dev/null +++ b/ddverify/models/seq1/include/linux/spinlock_types.h @@ -0,0 +1,21 @@ +#ifndef __LINUX_SPINLOCK_TYPES_H +#define __LINUX_SPINLOCK_TYPES_H + +typedef struct { + int init; + int locked; +} spinlock_t; + +typedef struct { + int something; +} rwlock_t; + +# define __SPIN_LOCK_UNLOCKED \ + { .init = 1, \ + .locked = 0 } + +#define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED + +#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED + +#endif /* __LINUX_SPINLOCK_TYPES_H */ diff --git a/ddverify/models/seq1/include/linux/stat.h b/ddverify/models/seq1/include/linux/stat.h new file mode 100644 index 000000000..262124881 --- /dev/null +++ b/ddverify/models/seq1/include/linux/stat.h @@ -0,0 +1,66 @@ +#ifndef _LINUX_STAT_H +#define _LINUX_STAT_H + +#include + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) + +#include +#include + +struct kstat { + unsigned long ino; + dev_t dev; +// umode_t mode; + unsigned int nlink; +// uid_t uid; +// gid_t gid; + dev_t rdev; + loff_t size; +// struct timespec atime; +// struct timespec mtime; +// struct timespec ctime; + unsigned long blksize; + unsigned long blocks; +}; + +#endif diff --git a/ddverify/models/seq1/include/linux/stddef.h b/ddverify/models/seq1/include/linux/stddef.h new file mode 100644 index 000000000..b3a2cadf9 --- /dev/null +++ b/ddverify/models/seq1/include/linux/stddef.h @@ -0,0 +1,20 @@ +#ifndef _LINUX_STDDEF_H +#define _LINUX_STDDEF_H + +#include + +#undef NULL +#if defined(__cplusplus) +#define NULL 0 +#else +#define NULL ((void *)0) +#endif + +#undef offsetof +#ifdef __compiler_offsetof +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#endif diff --git a/ddverify/models/seq1/include/linux/string.h b/ddverify/models/seq1/include/linux/string.h new file mode 100644 index 000000000..9734c2052 --- /dev/null +++ b/ddverify/models/seq1/include/linux/string.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_STRING_H_ +#define _LINUX_STRING_H_ + +#include +#include +#include + +extern char * strcpy(char *,const char *); +extern char * strncpy(char *,const char *, __kernel_size_t); +size_t strlcpy(char *, const char *, size_t); +extern char * strcat(char *, const char *); +extern char * strncat(char *, const char *, __kernel_size_t); +extern size_t strlcat(char *, const char *, __kernel_size_t); +extern int strcmp(const char *,const char *); +extern int strncmp(const char *,const char *,__kernel_size_t); +extern int strnicmp(const char *, const char *, __kernel_size_t); +extern char * strchr(const char *,int); +extern char * strnchr(const char *, size_t, int); +extern char * strrchr(const char *,int); +extern char * strstrip(char *); +extern char * strstr(const char *,const char *); +extern __kernel_size_t strlen(const char *); +extern __kernel_size_t strnlen(const char *,__kernel_size_t); +extern char * strpbrk(const char *,const char *); +extern char * strsep(char **,const char *); +extern __kernel_size_t strspn(const char *,const char *); +extern __kernel_size_t strcspn(const char *,const char *); + +extern void * memset(void *,int,__kernel_size_t); +extern void * memcpy(void *,const void *,__kernel_size_t); +extern void * memmove(void *,const void *,__kernel_size_t); +extern void * memscan(void *,int,__kernel_size_t); +extern int memcmp(const void *,const void *,__kernel_size_t); +extern void * memchr(const void *,int,__kernel_size_t); +#endif /* _LINUX_STRING_H_ */ diff --git a/ddverify/models/seq1/include/linux/stringify.h b/ddverify/models/seq1/include/linux/stringify.h new file mode 100644 index 000000000..0b4388356 --- /dev/null +++ b/ddverify/models/seq1/include/linux/stringify.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H + +/* Indirect stringification. Doing two levels allows the parameter to be a + * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) + * converts to "bar". + */ + +#define __stringify_1(x) #x +#define __stringify(x) __stringify_1(x) + +#endif /* !__LINUX_STRINGIFY_H */ diff --git a/ddverify/models/seq1/include/linux/suspend.h b/ddverify/models/seq1/include/linux/suspend.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/swap.h b/ddverify/models/seq1/include/linux/swap.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/sysfs.h b/ddverify/models/seq1/include/linux/sysfs.h new file mode 100644 index 000000000..4e1dd65ae --- /dev/null +++ b/ddverify/models/seq1/include/linux/sysfs.h @@ -0,0 +1,43 @@ +#ifndef _SYSFS_H_ +#define _SYSFS_H_ + +#include +#include + +struct kobject; +struct module; + +struct attribute { + const char * name; + struct module * owner; + mode_t mode; +}; + +struct attribute_group { + const char * name; + struct attribute ** attrs; +}; + + + +/** + * Use these macros to make defining attributes easier. See include/linux/device.h + * for examples.. + */ + +#define __ATTR(_name,_mode,_show,_store) { \ + .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \ + .show = _show, \ + .store = _store, \ +} + +#define __ATTR_RO(_name) { \ + .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \ + .show = _name##_show, \ +} + +#define __ATTR_NULL { .attr = { .name = NULL } } + +#define attr_name(_attr) (_attr).attr.name + +#endif /* _SYSFS_H_ */ diff --git a/ddverify/models/seq1/include/linux/sysrq.h b/ddverify/models/seq1/include/linux/sysrq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/linux/termios.h b/ddverify/models/seq1/include/linux/termios.h new file mode 100644 index 000000000..758803c4c --- /dev/null +++ b/ddverify/models/seq1/include/linux/termios.h @@ -0,0 +1,7 @@ +#ifndef _LINUX_TERMIOS_H +#define _LINUX_TERMIOS_H + +#include +#include + +#endif diff --git a/ddverify/models/seq1/include/linux/threads.h b/ddverify/models/seq1/include/linux/threads.h new file mode 100644 index 000000000..ce23e273e --- /dev/null +++ b/ddverify/models/seq1/include/linux/threads.h @@ -0,0 +1,4 @@ +#ifndef _LINUX_THREADS_H +#define _LINUX_THREADS_H + +#endif diff --git a/ddverify/models/seq1/include/linux/time.h b/ddverify/models/seq1/include/linux/time.h new file mode 100644 index 000000000..907f53e8e --- /dev/null +++ b/ddverify/models/seq1/include/linux/time.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_TIME_H +#define _LINUX_TIME_H + +#include + +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; + + +/* Parameters used to convert the timespec values: */ +#define MSEC_PER_SEC 1000L +#define USEC_PER_MSEC 1000L +#define NSEC_PER_USEC 1000L +#define NSEC_PER_MSEC 1000000L +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L +#define FSEC_PER_SEC 1000000000000000L + + +void do_gettimeofday(struct timeval *tv); + +#endif + diff --git a/ddverify/models/seq1/include/linux/timer.h b/ddverify/models/seq1/include/linux/timer.h new file mode 100644 index 000000000..a531db358 --- /dev/null +++ b/ddverify/models/seq1/include/linux/timer.h @@ -0,0 +1,34 @@ +#ifndef _LINUX_TIMER_H +#define _LINUX_TIMER_H + +struct timer_list { + unsigned long expires; + void (*function)(unsigned long); + unsigned long data; + + short __ddv_active; + short __ddv_init; +}; + +#define TIMER_INITIALIZER(_function, _expires, _data) { \ + .function = (_function), \ + .expires = (_expires), \ + .data = (_data), \ + .__ddv_init = 1, \ + } + + +#define DEFINE_TIMER(_name, _function, _expires, _data) \ + struct timer_list _name = \ + TIMER_INITIALIZER(_function, _expires, _data) + +// DDV: Bodies for the following functions are defined in linux/kernel/timer.c +void init_timer(struct timer_list * timer); +void add_timer_on(struct timer_list *timer, int cpu); +void add_timer(struct timer_list *timer); +int del_timer(struct timer_list * timer); +int mod_timer(struct timer_list *timer, unsigned long expires); + +#define del_timer_sync(t) del_timer(t) + +#endif diff --git a/ddverify/models/seq1/include/linux/tty.h b/ddverify/models/seq1/include/linux/tty.h new file mode 100644 index 000000000..5bde39f3c --- /dev/null +++ b/ddverify/models/seq1/include/linux/tty.h @@ -0,0 +1,180 @@ +#ifndef _LINUX_TTY_H +#define _LINUX_TTY_H + +#include +#include +#include +#include +#include +#include +#include + +#include + + +/* + * The pty uses char_buf and flag_buf as a contiguous buffer + */ +#define PTY_BUF_SIZE 4*TTY_FLIPBUF_SIZE + +/* + * When a break, frame error, or parity error happens, these codes are + * stuffed into the flags buffer. + */ +#define TTY_NORMAL 0 +#define TTY_BREAK 1 +#define TTY_FRAME 2 +#define TTY_PARITY 3 +#define TTY_OVERRUN 4 + + +#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR]) +#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT]) +#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE]) +#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL]) +#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF]) +#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME]) +#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN]) +#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC]) +#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART]) +#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP]) +#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP]) +#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL]) +#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT]) +#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD]) +#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE]) +#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) +#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) + +#define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f)) +#define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f)) +#define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f)) +#define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f)) + +#define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK) +#define I_BRKINT(tty) _I_FLAG((tty),BRKINT) +#define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR) +#define I_PARMRK(tty) _I_FLAG((tty),PARMRK) +#define I_INPCK(tty) _I_FLAG((tty),INPCK) +#define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP) +#define I_INLCR(tty) _I_FLAG((tty),INLCR) +#define I_IGNCR(tty) _I_FLAG((tty),IGNCR) +#define I_ICRNL(tty) _I_FLAG((tty),ICRNL) +#define I_IUCLC(tty) _I_FLAG((tty),IUCLC) +#define I_IXON(tty) _I_FLAG((tty),IXON) +#define I_IXANY(tty) _I_FLAG((tty),IXANY) +#define I_IXOFF(tty) _I_FLAG((tty),IXOFF) +#define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL) +#define I_IUTF8(tty) _I_FLAG((tty),IUTF8) + +#define O_OPOST(tty) _O_FLAG((tty),OPOST) +#define O_OLCUC(tty) _O_FLAG((tty),OLCUC) +#define O_ONLCR(tty) _O_FLAG((tty),ONLCR) +#define O_OCRNL(tty) _O_FLAG((tty),OCRNL) +#define O_ONOCR(tty) _O_FLAG((tty),ONOCR) +#define O_ONLRET(tty) _O_FLAG((tty),ONLRET) +#define O_OFILL(tty) _O_FLAG((tty),OFILL) +#define O_OFDEL(tty) _O_FLAG((tty),OFDEL) +#define O_NLDLY(tty) _O_FLAG((tty),NLDLY) +#define O_CRDLY(tty) _O_FLAG((tty),CRDLY) +#define O_TABDLY(tty) _O_FLAG((tty),TABDLY) +#define O_BSDLY(tty) _O_FLAG((tty),BSDLY) +#define O_VTDLY(tty) _O_FLAG((tty),VTDLY) +#define O_FFDLY(tty) _O_FLAG((tty),FFDLY) + +#define C_BAUD(tty) _C_FLAG((tty),CBAUD) +#define C_CSIZE(tty) _C_FLAG((tty),CSIZE) +#define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB) +#define C_CREAD(tty) _C_FLAG((tty),CREAD) +#define C_PARENB(tty) _C_FLAG((tty),PARENB) +#define C_PARODD(tty) _C_FLAG((tty),PARODD) +#define C_HUPCL(tty) _C_FLAG((tty),HUPCL) +#define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL) +#define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD) +#define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS) + +#define L_ISIG(tty) _L_FLAG((tty),ISIG) +#define L_ICANON(tty) _L_FLAG((tty),ICANON) +#define L_XCASE(tty) _L_FLAG((tty),XCASE) +#define L_ECHO(tty) _L_FLAG((tty),ECHO) +#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) +#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) +#define L_ECHONL(tty) _L_FLAG((tty),ECHONL) +#define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH) +#define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP) +#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) +#define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT) +#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) +#define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO) +#define L_PENDIN(tty) _L_FLAG((tty),PENDIN) +#define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN) + + +struct tty_struct { + int magic; + struct tty_driver *driver; + int index; + struct termios *termios, *termios_locked; + char name[64]; + + unsigned long flags; + int count; + unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; + unsigned int receive_room; /* Bytes free for queue */ + + wait_queue_head_t write_wait; + wait_queue_head_t read_wait; + void *disc_data; + void *driver_data; + + unsigned char closing:1; +}; + + +/* tty magic number */ +#define TTY_MAGIC 0x5401 + +/* + * These bits are used in the flags field of the tty structure. + * + * So that interrupts won't be able to mess up the queues, + * copy_to_cooked must be atomic with respect to itself, as must + * tty->write. Thus, you must use the inline functions set_bit() and + * clear_bit() to make things atomic. + */ +#define TTY_THROTTLED 0 /* Call unthrottle() at threshold min */ +#define TTY_IO_ERROR 1 /* Canse an I/O error (may be no ldisc too) */ +#define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */ +#define TTY_EXCLUSIVE 3 /* Exclusive open mode */ +#define TTY_DEBUG 4 /* Debugging */ +#define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */ +#define TTY_PUSH 6 /* n_tty private */ +#define TTY_CLOSING 7 /* ->close() in progress */ +#define TTY_LDISC 9 /* Line discipline attached */ +#define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */ +#define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */ +#define TTY_PTY_LOCK 16 /* pty private */ +#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ +#define TTY_HUPPED 18 /* Post driver->hangup() */ + +extern struct termios tty_std_termios; + + +extern int tty_check_change(struct tty_struct * tty); +extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); +extern int tty_unregister_ldisc(int disc); +extern int tty_register_driver(struct tty_driver *driver); +extern int tty_unregister_driver(struct tty_driver *driver); + +extern void tty_wait_until_sent(struct tty_struct * tty, long timeout); + + +extern void tty_hangup(struct tty_struct * tty); +extern int tty_hung_up_p(struct file * filp); +extern void do_SAK(struct tty_struct *tty); +extern void tty_flip_buffer_push(struct tty_struct *tty); +extern int tty_get_baud_rate(struct tty_struct *tty); + +extern void tty_wakeup(struct tty_struct *tty); +extern void tty_ldisc_flush(struct tty_struct *tty); +#endif diff --git a/ddverify/models/seq1/include/linux/tty_driver.h b/ddverify/models/seq1/include/linux/tty_driver.h new file mode 100644 index 000000000..805c70977 --- /dev/null +++ b/ddverify/models/seq1/include/linux/tty_driver.h @@ -0,0 +1,166 @@ +#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +// DDV: TODO +void put_tty_driver(struct tty_driver *driver); +// DDV: is defined in driver/char/tty_io.c +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ diff --git a/ddverify/models/seq1/include/linux/tty_driver.h,v b/ddverify/models/seq1/include/linux/tty_driver.h,v new file mode 100644 index 000000000..f5748324d --- /dev/null +++ b/ddverify/models/seq1/include/linux/tty_driver.h,v @@ -0,0 +1,187 @@ +head 1.1; +access; +symbols; +locks; strict; +comment @ * @; + + +1.1 +date 2007.02.11.11.29.05; author thomaswi; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@Initial revision +@ +text +@#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: Body of this function is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +void put_tty_driver(struct tty_driver *driver); +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ +@ diff --git a/ddverify/models/seq1/include/linux/tty_flip.h b/ddverify/models/seq1/include/linux/tty_flip.h new file mode 100644 index 000000000..b0864fa14 --- /dev/null +++ b/ddverify/models/seq1/include/linux/tty_flip.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_TTY_FLIP_H +#define _LINUX_TTY_FLIP_H + +int tty_buffer_request_room(struct tty_struct *tty, size_t size); +int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size); +int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); +int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); +int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); +void tty_schedule_flip(struct tty_struct *tty); + +inline int tty_insert_flip_char(struct tty_struct *tty, unsigned char ch, char flag); + +#endif /* _LINUX_TTY_FLIP_H */ diff --git a/ddverify/models/seq1/include/linux/tty_ldisc.h b/ddverify/models/seq1/include/linux/tty_ldisc.h new file mode 100644 index 000000000..35466133a --- /dev/null +++ b/ddverify/models/seq1/include/linux/tty_ldisc.h @@ -0,0 +1,51 @@ +#ifndef _LINUX_TTY_LDISC_H +#define _LINUX_TTY_LDISC_H + + +#include +#include + +struct tty_ldisc { + int magic; + char *name; + int num; + int flags; + + /* + * The following routines are called from above. + */ + int (*open)(struct tty_struct *); + void (*close)(struct tty_struct *); + void (*flush_buffer)(struct tty_struct *tty); + ssize_t (*chars_in_buffer)(struct tty_struct *tty); + ssize_t (*read)(struct tty_struct * tty, struct file * file, + unsigned char __user * buf, size_t nr); + ssize_t (*write)(struct tty_struct * tty, struct file * file, + const unsigned char * buf, size_t nr); + int (*ioctl)(struct tty_struct * tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + unsigned int (*poll)(struct tty_struct *, struct file *, + struct poll_table_struct *); + int (*hangup)(struct tty_struct *tty); + + /* + * The following routines are called from below. + */ + void (*receive_buf)(struct tty_struct *, const unsigned char *cp, + char *fp, int count); + void (*write_wakeup)(struct tty_struct *); + + struct module *owner; + + int refcount; +}; + +#define TTY_LDISC_MAGIC 0x5403 + +#define LDISC_FLAG_DEFINED 0x00000001 + +#define MODULE_ALIAS_LDISC(ldisc) \ + MODULE_ALIAS("tty-ldisc-" __stringify(ldisc)) + +#endif /* _LINUX_TTY_LDISC_H */ diff --git a/ddverify/models/seq1/include/linux/types.h b/ddverify/models/seq1/include/linux/types.h new file mode 100644 index 000000000..b437e9baa --- /dev/null +++ b/ddverify/models/seq1/include/linux/types.h @@ -0,0 +1,105 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#include +#include + +#define __bitwise + +typedef __u32 __kernel_dev_t; + +typedef __kernel_dev_t dev_t; +typedef __kernel_ino_t ino_t; +typedef __kernel_mode_t mode_t; +typedef __kernel_nlink_t nlink_t; +typedef __kernel_off_t off_t; +typedef __kernel_pid_t pid_t; +typedef __kernel_daddr_t daddr_t; +typedef __kernel_key_t key_t; +typedef __kernel_suseconds_t suseconds_t; +typedef __kernel_timer_t timer_t; +typedef __kernel_clockid_t clockid_t; +typedef __kernel_mqd_t mqd_t; + +typedef __kernel_uid32_t uid_t; +typedef __kernel_gid32_t gid_t; +typedef __kernel_uid16_t uid16_t; +typedef __kernel_gid16_t gid16_t; + + +typedef long long loff_t; + +/* + * The following typedefs are also protected by individual ifdefs for + * historical reasons: + */ +#ifndef _SIZE_T +#define _SIZE_T +typedef __kernel_size_t size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __kernel_ssize_t ssize_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef __kernel_ptrdiff_t ptrdiff_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef __kernel_time_t time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef __kernel_clock_t clock_t; +#endif + +#ifndef _CADDR_T +#define _CADDR_T +typedef __kernel_caddr_t caddr_t; +#endif + + +/* bsd */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +/* sysv */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + + +typedef __u8 uint8_t; +typedef __u16 uint16_t; +typedef __u32 uint32_t; + +typedef __u64 uint64_t; +typedef __u64 u_int64_t; +//typedef __s64 int64_t; + +typedef unsigned gfp_t; + +#ifndef HAVE_SECTOR_T +typedef unsigned long sector_t; +#endif + +#ifndef HAVE_BLKCNT_T +typedef unsigned long blkcnt_t; +#endif + +typedef __u16 __bitwise __le16; +typedef __u16 __bitwise __be16; +typedef __u32 __bitwise __le32; +typedef __u32 __bitwise __be32; +typedef __u64 __bitwise __le64; +typedef __u64 __bitwise __be64; + +#endif diff --git a/ddverify/models/seq1/include/linux/uio.h b/ddverify/models/seq1/include/linux/uio.h new file mode 100644 index 000000000..c59931d23 --- /dev/null +++ b/ddverify/models/seq1/include/linux/uio.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_UIO_H +#define __LINUX_UIO_H + +#include +#include + +struct kvec { + void *iov_base; /* and that should *never* hold a userland pointer */ + size_t iov_len; +}; + +#endif diff --git a/ddverify/models/seq1/include/linux/videodev.h b/ddverify/models/seq1/include/linux/videodev.h new file mode 100644 index 000000000..2628e86ac --- /dev/null +++ b/ddverify/models/seq1/include/linux/videodev.h @@ -0,0 +1,346 @@ +#ifndef __LINUX_VIDEODEV_H +#define __LINUX_VIDEODEV_H + +#include +#include +#include + +extern struct video_device* video_devdata(struct file*); + +static inline void *video_get_drvdata(struct video_device *dev) +{ + return dev->priv; +} + +static inline void video_set_drvdata(struct video_device *dev, void *data) +{ + dev->priv = data; +} + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +struct video_capability +{ + char name[32]; + int type; + int channels; /* Num channels */ + int audios; /* Num audio devices */ + int maxwidth; /* Supported width */ + int maxheight; /* And height */ + int minwidth; /* Supported width */ + int minheight; /* And height */ +}; + + +struct video_channel +{ + int channel; + char name[32]; + int tuners; + __u32 flags; +#define VIDEO_VC_TUNER 1 /* Channel has a tuner */ +#define VIDEO_VC_AUDIO 2 /* Channel has audio */ + __u16 type; +#define VIDEO_TYPE_TV 1 +#define VIDEO_TYPE_CAMERA 2 + __u16 norm; /* Norm set by channel */ +}; + + +struct video_tuner +{ + int tuner; + char name[32]; + unsigned long rangelow, rangehigh; /* Tuner range */ + __u32 flags; +#define VIDEO_TUNER_PAL 1 +#define VIDEO_TUNER_NTSC 2 +#define VIDEO_TUNER_SECAM 4 +#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */ +#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */ +#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */ +#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */ +#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */ + __u16 mode; /* PAL/NTSC/SECAM/OTHER */ +#define VIDEO_MODE_PAL 0 +#define VIDEO_MODE_NTSC 1 +#define VIDEO_MODE_SECAM 2 +#define VIDEO_MODE_AUTO 3 + __u16 signal; /* Signal strength 16bit scale */ +}; + + +struct video_picture +{ + __u16 brightness; + __u16 hue; + __u16 colour; + __u16 contrast; + __u16 whiteness; /* Black and white only */ + __u16 depth; /* Capture depth */ + __u16 palette; /* Palette in use */ +#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ +#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ +#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ +#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */ +#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */ +#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */ +#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */ +#define VIDEO_PALETTE_YUYV 8 +#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */ +#define VIDEO_PALETTE_YUV420 10 +#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */ +#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */ +#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */ +#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */ +#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */ +#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ +#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ +#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ +}; + +struct video_audio +{ + int audio; /* Audio channel */ + __u16 volume; /* If settable */ + __u16 bass, treble; + __u32 flags; +#define VIDEO_AUDIO_MUTE 1 +#define VIDEO_AUDIO_MUTABLE 2 +#define VIDEO_AUDIO_VOLUME 4 +#define VIDEO_AUDIO_BASS 8 +#define VIDEO_AUDIO_TREBLE 16 +#define VIDEO_AUDIO_BALANCE 32 + char name[16]; +#define VIDEO_SOUND_MONO 1 +#define VIDEO_SOUND_STEREO 2 +#define VIDEO_SOUND_LANG1 4 +#define VIDEO_SOUND_LANG2 8 + __u16 mode; + __u16 balance; /* Stereo balance */ + __u16 step; /* Step actual volume uses */ +}; + +struct video_clip +{ + __s32 x,y; + __s32 width, height; + struct video_clip *next; /* For user use/driver use only */ +}; + +struct video_window +{ + __u32 x,y; /* Position of window */ + __u32 width,height; /* Its size */ + __u32 chromakey; + __u32 flags; + struct video_clip __user *clips; /* Set only */ + int clipcount; +#define VIDEO_WINDOW_INTERLACE 1 +#define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */ +#define VIDEO_CLIP_BITMAP -1 +/* bitmap is 1024x625, a '1' bit represents a clipped pixel */ +#define VIDEO_CLIPMAP_SIZE (128 * 625) +}; + +struct video_capture +{ + __u32 x,y; /* Offsets into image */ + __u32 width, height; /* Area to capture */ + __u16 decimation; /* Decimation divider */ + __u16 flags; /* Flags for capture */ +#define VIDEO_CAPTURE_ODD 0 /* Temporal */ +#define VIDEO_CAPTURE_EVEN 1 +}; + +struct video_buffer +{ + void *base; + int height,width; + int depth; + int bytesperline; +}; + +struct video_mmap +{ + unsigned int frame; /* Frame (0 - n) for double buffer */ + int height,width; + unsigned int format; /* should be VIDEO_PALETTE_* */ +}; + +struct video_key +{ + __u8 key[8]; + __u32 flags; +}; + +struct video_mbuf +{ + int size; /* Total memory to map */ + int frames; /* Frames */ + int offsets[VIDEO_MAX_FRAME]; +}; + +#define VIDEO_NO_UNIT (-1) + +struct video_unit +{ + int video; /* Video minor */ + int vbi; /* VBI minor */ + int radio; /* Radio minor */ + int audio; /* Audio minor */ + int teletext; /* Teletext minor */ +}; + +struct vbi_format { + __u32 sampling_rate; /* in Hz */ + __u32 samples_per_line; + __u32 sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */ + __s32 start[2]; /* starting line for each frame */ + __u32 count[2]; /* count of lines for each frame */ + __u32 flags; +#define VBI_UNSYNC 1 /* can distingues between top/bottom field */ +#define VBI_INTERLACED 2 /* lines are interlaced */ +}; + +/* video_info is biased towards hardware mpeg encode/decode */ +/* but it could apply generically to any hardware compressor/decompressor */ +struct video_info +{ + __u32 frame_count; /* frames output since decode/encode began */ + __u32 h_size; /* current unscaled horizontal size */ + __u32 v_size; /* current unscaled veritcal size */ + __u32 smpte_timecode; /* current SMPTE timecode (for current GOP) */ + __u32 picture_type; /* current picture type */ + __u32 temporal_reference; /* current temporal reference */ + __u8 user_data[256]; /* user data last found in compressed stream */ + /* user_data[0] contains user data flags, user_data[1] has count */ +}; + +/* generic structure for setting playback modes */ +struct video_play_mode +{ + int mode; + int p1; + int p2; +}; + +/* for loading microcode / fpga programming */ +struct video_code +{ + char loadwhat[16]; /* name or tag of file being passed */ + int datasize; + __u8 *data; +}; + + +#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */ +#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */ +#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */ +#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */ +#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */ +#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */ +#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */ +#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */ +#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */ +#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */ +#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */ +#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */ +#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) */ +#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */ +#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */ +#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */ +#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */ +#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */ +#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */ +#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */ +#define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */ +#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */ +#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */ +#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */ +#define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */ +#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */ +#define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */ +#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */ +#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */ + + +#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */ + +/* VIDIOCSWRITEMODE */ +#define VID_WRITE_MPEG_AUD 0 +#define VID_WRITE_MPEG_VID 1 +#define VID_WRITE_OSD 2 +#define VID_WRITE_TTX 3 +#define VID_WRITE_CC 4 +#define VID_WRITE_MJPEG 5 + +/* VIDIOCSPLAYMODE */ +#define VID_PLAY_VID_OUT_MODE 0 + /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */ +#define VID_PLAY_GENLOCK 1 + /* p1: 0 = OFF, 1 = ON */ + /* p2: GENLOCK FINE DELAY value */ +#define VID_PLAY_NORMAL 2 +#define VID_PLAY_PAUSE 3 +#define VID_PLAY_SINGLE_FRAME 4 +#define VID_PLAY_FAST_FORWARD 5 +#define VID_PLAY_SLOW_MOTION 6 +#define VID_PLAY_IMMEDIATE_NORMAL 7 +#define VID_PLAY_SWITCH_CHANNELS 8 +#define VID_PLAY_FREEZE_FRAME 9 +#define VID_PLAY_STILL_MODE 10 +#define VID_PLAY_MASTER_MODE 11 + /* p1: see below */ +#define VID_PLAY_MASTER_NONE 1 +#define VID_PLAY_MASTER_VIDEO 2 +#define VID_PLAY_MASTER_AUDIO 3 +#define VID_PLAY_ACTIVE_SCANLINES 12 + /* p1 = first active; p2 = last active */ +#define VID_PLAY_RESET 13 +#define VID_PLAY_END_MARK 14 + + + +#define VID_HARDWARE_BT848 1 +#define VID_HARDWARE_QCAM_BW 2 +#define VID_HARDWARE_PMS 3 +#define VID_HARDWARE_QCAM_C 4 +#define VID_HARDWARE_PSEUDO 5 +#define VID_HARDWARE_SAA5249 6 +#define VID_HARDWARE_AZTECH 7 +#define VID_HARDWARE_SF16MI 8 +#define VID_HARDWARE_RTRACK 9 +#define VID_HARDWARE_ZOLTRIX 10 +#define VID_HARDWARE_SAA7146 11 +#define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */ +#define VID_HARDWARE_RTRACK2 13 +#define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */ +#define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */ +#define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */ +#define VID_HARDWARE_BROADWAY 17 /* Broadway project */ +#define VID_HARDWARE_GEMTEK 18 +#define VID_HARDWARE_TYPHOON 19 +#define VID_HARDWARE_VINO 20 /* SGI Indy Vino */ +#define VID_HARDWARE_CADET 21 /* Cadet radio */ +#define VID_HARDWARE_TRUST 22 /* Trust FM Radio */ +#define VID_HARDWARE_TERRATEC 23 /* TerraTec ActiveRadio */ +#define VID_HARDWARE_CPIA 24 +#define VID_HARDWARE_ZR36120 25 /* Zoran ZR36120/ZR36125 */ +#define VID_HARDWARE_ZR36067 26 /* Zoran ZR36067/36060 */ +#define VID_HARDWARE_OV511 27 +#define VID_HARDWARE_ZR356700 28 /* Zoran 36700 series */ +#define VID_HARDWARE_W9966 29 +#define VID_HARDWARE_SE401 30 /* SE401 USB webcams */ +#define VID_HARDWARE_PWC 31 /* Philips webcams */ +#define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */ +#define VID_HARDWARE_CPIA2 33 +#define VID_HARDWARE_VICAM 34 +#define VID_HARDWARE_SF16FMR2 35 +#define VID_HARDWARE_W9968CF 36 +#define VID_HARDWARE_SAA7114H 37 +#define VID_HARDWARE_SN9C102 38 +#define VID_HARDWARE_ARV 39 + +#endif /* __LINUX_VIDEODEV_H */ diff --git a/ddverify/models/seq1/include/linux/videodev2.h b/ddverify/models/seq1/include/linux/videodev2.h new file mode 100644 index 000000000..df5c46543 --- /dev/null +++ b/ddverify/models/seq1/include/linux/videodev2.h @@ -0,0 +1,1351 @@ +/* + * Video for Linux Two + * + * Header file for v4l or V4L2 drivers and applications + * with public API. + * All kernel-specific stuff were moved to media/v4l2-dev.h, so + * no #if __KERNEL tests are allowed here + * + * See http://linuxtv.org for more info + * + * Author: Bill Dirks + * Justin Schoeman + * et al. + */ +#ifndef __LINUX_VIDEODEV2_H +#define __LINUX_VIDEODEV2_H +#ifdef __KERNEL__ +#include /* need struct timeval */ +#include /* need __user */ +#else +#define __user +#endif +#include + +/* + * Common stuff for both V4L1 and V4L2 + * Moved from videodev.h + */ +#define VIDEO_MAX_FRAME 32 + +#define VID_TYPE_CAPTURE 1 /* Can capture */ +#define VID_TYPE_TUNER 2 /* Can tune */ +#define VID_TYPE_TELETEXT 4 /* Does teletext */ +#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */ +#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */ +#define VID_TYPE_CLIPPING 32 /* Can clip */ +#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */ +#define VID_TYPE_SCALES 128 /* Scalable */ +#define VID_TYPE_MONOCHROME 256 /* Monochrome only */ +#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */ +#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */ +#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ +#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ +#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ + +/* + * M I S C E L L A N E O U S + */ + +/* Four-character-code (FOURCC) */ +#define v4l2_fourcc(a,b,c,d)\ + (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) + +/* + * E N U M S + */ +enum v4l2_field { + V4L2_FIELD_ANY = 0, /* driver can choose from none, + top, bottom, interlaced + depending on whatever it thinks + is approximate ... */ + V4L2_FIELD_NONE = 1, /* this device has no fields ... */ + V4L2_FIELD_TOP = 2, /* top field only */ + V4L2_FIELD_BOTTOM = 3, /* bottom field only */ + V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ + V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one + buffer, top-bottom order */ + V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ + V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into + separate buffers */ +}; +#define V4L2_FIELD_HAS_TOP(field) \ + ((field) == V4L2_FIELD_TOP ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTTOM(field) \ + ((field) == V4L2_FIELD_BOTTOM ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTH(field) \ + ((field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) + +enum v4l2_buf_type { + V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, + V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, + V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, + V4L2_BUF_TYPE_VBI_CAPTURE = 4, + V4L2_BUF_TYPE_VBI_OUTPUT = 5, +#if 1 + /* Experimental Sliced VBI */ + V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, + V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, +#endif + V4L2_BUF_TYPE_PRIVATE = 0x80, +}; + +enum v4l2_ctrl_type { + V4L2_CTRL_TYPE_INTEGER = 1, + V4L2_CTRL_TYPE_BOOLEAN = 2, + V4L2_CTRL_TYPE_MENU = 3, + V4L2_CTRL_TYPE_BUTTON = 4, + V4L2_CTRL_TYPE_INTEGER64 = 5, + V4L2_CTRL_TYPE_CTRL_CLASS = 6, +}; + +enum v4l2_tuner_type { + V4L2_TUNER_RADIO = 1, + V4L2_TUNER_ANALOG_TV = 2, + V4L2_TUNER_DIGITAL_TV = 3, +}; + +enum v4l2_memory { + V4L2_MEMORY_MMAP = 1, + V4L2_MEMORY_USERPTR = 2, + V4L2_MEMORY_OVERLAY = 3, +}; + +/* see also http://vektor.theorem.ca/graphics/ycbcr/ */ +enum v4l2_colorspace { + /* ITU-R 601 -- broadcast NTSC/PAL */ + V4L2_COLORSPACE_SMPTE170M = 1, + + /* 1125-Line (US) HDTV */ + V4L2_COLORSPACE_SMPTE240M = 2, + + /* HD and modern captures. */ + V4L2_COLORSPACE_REC709 = 3, + + /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */ + V4L2_COLORSPACE_BT878 = 4, + + /* These should be useful. Assume 601 extents. */ + V4L2_COLORSPACE_470_SYSTEM_M = 5, + V4L2_COLORSPACE_470_SYSTEM_BG = 6, + + /* I know there will be cameras that send this. So, this is + * unspecified chromaticities and full 0-255 on each of the + * Y'CbCr components + */ + V4L2_COLORSPACE_JPEG = 7, + + /* For RGB colourspaces, this is probably a good start. */ + V4L2_COLORSPACE_SRGB = 8, +}; + +enum v4l2_priority { + V4L2_PRIORITY_UNSET = 0, /* not initialized */ + V4L2_PRIORITY_BACKGROUND = 1, + V4L2_PRIORITY_INTERACTIVE = 2, + V4L2_PRIORITY_RECORD = 3, + V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE, +}; + +struct v4l2_rect { + __s32 left; + __s32 top; + __s32 width; + __s32 height; +}; + +struct v4l2_fract { + __u32 numerator; + __u32 denominator; +}; + +/* + * D R I V E R C A P A B I L I T I E S + */ +struct v4l2_capability +{ + __u8 driver[16]; /* i.e. "bttv" */ + __u8 card[32]; /* i.e. "Hauppauge WinTV" */ + __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ + __u32 version; /* should use KERNEL_VERSION() */ + __u32 capabilities; /* Device capabilities */ + __u32 reserved[4]; +}; + +/* Values for 'capabilities' field */ +#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ +#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ +#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ +#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ +#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ +#if 1 +#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ +#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ +#endif +#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ + +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ +#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ + +#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ +#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ +#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ + +/* + * V I D E O I M A G E F O R M A T + */ +struct v4l2_pix_format +{ + __u32 width; + __u32 height; + __u32 pixelformat; + enum v4l2_field field; + __u32 bytesperline; /* for padding, zero if unused */ + __u32 sizeimage; + enum v4l2_colorspace colorspace; + __u32 priv; /* private data, depends on pixelformat */ +}; + +/* Pixel format FOURCC depth Description */ +#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */ +#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */ +#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */ +#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */ +#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */ +#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */ +#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */ +#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ +#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ +#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ +#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ +#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ +#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */ +#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */ +#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */ + +/* two planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */ + +/* The following formats are not defined in the V4L2 specification */ +#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */ +#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ +#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ +#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */ + +/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ +#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ + +/* compressed formats */ +#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ +#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */ +#define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */ +#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG-1/2/4 */ + +/* Vendor-specific formats */ +#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */ +#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */ + +/* + * F O R M A T E N U M E R A T I O N + */ +struct v4l2_fmtdesc +{ + __u32 index; /* Format number */ + enum v4l2_buf_type type; /* buffer type */ + __u32 flags; + __u8 description[32]; /* Description string */ + __u32 pixelformat; /* Format fourcc */ + __u32 reserved[4]; +}; + +#define V4L2_FMT_FLAG_COMPRESSED 0x0001 + +#if 1 + /* Experimental Frame Size and frame rate enumeration */ +/* + * F R A M E S I Z E E N U M E R A T I O N + */ +enum v4l2_frmsizetypes +{ + V4L2_FRMSIZE_TYPE_DISCRETE = 1, + V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, + V4L2_FRMSIZE_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmsize_discrete +{ + __u32 width; /* Frame width [pixel] */ + __u32 height; /* Frame height [pixel] */ +}; + +struct v4l2_frmsize_stepwise +{ + __u32 min_width; /* Minimum frame width [pixel] */ + __u32 max_width; /* Maximum frame width [pixel] */ + __u32 step_width; /* Frame width step size [pixel] */ + __u32 min_height; /* Minimum frame height [pixel] */ + __u32 max_height; /* Maximum frame height [pixel] */ + __u32 step_height; /* Frame height step size [pixel] */ +}; + +struct v4l2_frmsizeenum +{ + __u32 index; /* Frame size number */ + __u32 pixel_format; /* Pixel format */ + __u32 type; /* Frame size type the device supports. */ + + union { /* Frame size */ + struct v4l2_frmsize_discrete discrete; + struct v4l2_frmsize_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; + +/* + * F R A M E R A T E E N U M E R A T I O N + */ +enum v4l2_frmivaltypes +{ + V4L2_FRMIVAL_TYPE_DISCRETE = 1, + V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, + V4L2_FRMIVAL_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmival_stepwise +{ + struct v4l2_fract min; /* Minimum frame interval [s] */ + struct v4l2_fract max; /* Maximum frame interval [s] */ + struct v4l2_fract step; /* Frame interval step size [s] */ +}; + +struct v4l2_frmivalenum +{ + __u32 index; /* Frame format index */ + __u32 pixel_format; /* Pixel format */ + __u32 width; /* Frame width */ + __u32 height; /* Frame height */ + __u32 type; /* Frame interval type the device supports. */ + + union { /* Frame interval */ + struct v4l2_fract discrete; + struct v4l2_frmival_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; +#endif + +/* + * T I M E C O D E + */ +struct v4l2_timecode +{ + __u32 type; + __u32 flags; + __u8 frames; + __u8 seconds; + __u8 minutes; + __u8 hours; + __u8 userbits[4]; +}; + +/* Type */ +#define V4L2_TC_TYPE_24FPS 1 +#define V4L2_TC_TYPE_25FPS 2 +#define V4L2_TC_TYPE_30FPS 3 +#define V4L2_TC_TYPE_50FPS 4 +#define V4L2_TC_TYPE_60FPS 5 + +/* Flags */ +#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */ +#define V4L2_TC_FLAG_COLORFRAME 0x0002 +#define V4L2_TC_USERBITS_field 0x000C +#define V4L2_TC_USERBITS_USERDEFINED 0x0000 +#define V4L2_TC_USERBITS_8BITCHARS 0x0008 +/* The above is based on SMPTE timecodes */ + +#ifdef __KERNEL__ +/* + * 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 + * + * ### WARNING: This experimental MPEG compression API is obsolete. + * ### It is replaced by the MPEG controls API. + * ### This old API will disappear in the near future! + * + */ +enum v4l2_bitrate_mode { + V4L2_BITRATE_NONE = 0, /* not specified */ + V4L2_BITRATE_CBR, /* constant bitrate */ + V4L2_BITRATE_VBR, /* variable bitrate */ +}; +struct v4l2_bitrate { + /* rates are specified in kbit/sec */ + enum v4l2_bitrate_mode mode; + __u32 min; + __u32 target; /* use this one for CBR */ + __u32 max; +}; + +enum v4l2_mpeg_streamtype { + V4L2_MPEG_SS_1, /* MPEG-1 system stream */ + V4L2_MPEG_PS_2, /* MPEG-2 program stream */ + V4L2_MPEG_TS_2, /* MPEG-2 transport stream */ + V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */ +}; +enum v4l2_mpeg_audiotype { + V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */ + V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */ + V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */ + V4L2_MPEG_AC3, /* AC3 */ + V4L2_MPEG_LPCM, /* LPCM */ +}; +enum v4l2_mpeg_videotype { + V4L2_MPEG_VI_1, /* MPEG-1 */ + V4L2_MPEG_VI_2, /* MPEG-2 */ +}; +enum v4l2_mpeg_aspectratio { + V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */ + V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */ + V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */ + V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */ +}; + +struct v4l2_mpeg_compression { + /* general */ + enum v4l2_mpeg_streamtype st_type; + struct v4l2_bitrate st_bitrate; + + /* transport streams */ + __u16 ts_pid_pmt; + __u16 ts_pid_audio; + __u16 ts_pid_video; + __u16 ts_pid_pcr; + + /* program stream */ + __u16 ps_size; + __u16 reserved_1; /* align */ + + /* audio */ + enum v4l2_mpeg_audiotype au_type; + struct v4l2_bitrate au_bitrate; + __u32 au_sample_rate; + __u8 au_pesid; + __u8 reserved_2[3]; /* align */ + + /* video */ + enum v4l2_mpeg_videotype vi_type; + enum v4l2_mpeg_aspectratio vi_aspect_ratio; + struct v4l2_bitrate vi_bitrate; + __u32 vi_frame_rate; + __u16 vi_frames_per_gop; + __u16 vi_bframes_count; + __u8 vi_pesid; + __u8 reserved_3[3]; /* align */ + + /* misc flags */ + __u32 closed_gops:1; + __u32 pulldown:1; + __u32 reserved_4:30; /* align */ + + /* I don't expect the above being perfect yet ;) */ + __u32 reserved_5[8]; +}; +#endif + +struct v4l2_jpegcompression +{ + int quality; + + int APPn; /* Number of APP segment to be written, + * must be 0..15 */ + int APP_len; /* Length of data in JPEG APPn segment */ + char APP_data[60]; /* Data in the JPEG APPn segment. */ + + int COM_len; /* Length of data in JPEG COM segment */ + char COM_data[60]; /* Data in JPEG COM segment */ + + __u32 jpeg_markers; /* Which markers should go into the JPEG + * output. Unless you exactly know what + * you do, leave them untouched. + * Inluding less markers will make the + * resulting code smaller, but there will + * be fewer aplications which can read it. + * The presence of the APP and COM marker + * is influenced by APP_len and COM_len + * ONLY, not by this property! */ + +#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ +#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ +#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ +#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ +#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will + * allways use APP0 */ +}; + +/* + * M E M O R Y - M A P P I N G B U F F E R S + */ +struct v4l2_requestbuffers +{ + __u32 count; + enum v4l2_buf_type type; + enum v4l2_memory memory; + __u32 reserved[2]; +}; + +struct v4l2_buffer +{ + __u32 index; + enum v4l2_buf_type type; + __u32 bytesused; + __u32 flags; + enum v4l2_field field; + struct timeval timestamp; + struct v4l2_timecode timecode; + __u32 sequence; + + /* memory location */ + enum v4l2_memory memory; + union { + __u32 offset; + unsigned long userptr; + } m; + __u32 length; + __u32 input; + __u32 reserved; +}; + +/* Flags for 'flags' field */ +#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */ +#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */ +#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */ +#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */ +#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */ +#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */ +#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ +#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */ + +/* + * O V E R L A Y P R E V I E W + */ +struct v4l2_framebuffer +{ + __u32 capability; + __u32 flags; +/* FIXME: in theory we should pass something like PCI device + memory + * region + offset instead of some physical address */ + void* base; + struct v4l2_pix_format fmt; +}; +/* Flags for the 'capability' field. Read only */ +#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 +#define V4L2_FBUF_CAP_CHROMAKEY 0x0002 +#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 +#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 +/* Flags for the 'flags' field. */ +#define V4L2_FBUF_FLAG_PRIMARY 0x0001 +#define V4L2_FBUF_FLAG_OVERLAY 0x0002 +#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 + +struct v4l2_clip +{ + struct v4l2_rect c; + struct v4l2_clip __user *next; +}; + +struct v4l2_window +{ + struct v4l2_rect w; + enum v4l2_field field; + __u32 chromakey; + struct v4l2_clip __user *clips; + __u32 clipcount; + void __user *bitmap; +}; + +/* + * C A P T U R E P A R A M E T E R S + */ +struct v4l2_captureparm +{ + __u32 capability; /* Supported modes */ + __u32 capturemode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in .1us units */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 readbuffers; /* # of buffers for read */ + __u32 reserved[4]; +}; + +/* Flags for 'capability' and 'capturemode' fields */ +#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ +#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ + +struct v4l2_outputparm +{ + __u32 capability; /* Supported modes */ + __u32 outputmode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in seconds */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 writebuffers; /* # of buffers for write */ + __u32 reserved[4]; +}; + +/* + * I N P U T I M A G E C R O P P I N G + */ +struct v4l2_cropcap { + enum v4l2_buf_type type; + struct v4l2_rect bounds; + struct v4l2_rect defrect; + struct v4l2_fract pixelaspect; +}; + +struct v4l2_crop { + enum v4l2_buf_type type; + struct v4l2_rect c; +}; + +/* + * A N A L O G V I D E O S T A N D A R D + */ + +typedef __u64 v4l2_std_id; + +/* one bit for each */ +#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001) +#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002) +#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004) +#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008) +#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010) +#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020) +#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040) +#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080) + +#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100) +#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200) +#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400) +#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800) + +#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) +#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) +#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) +#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) + +#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000) +#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000) +#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000) +#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000) +#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) +#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) +#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) +#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000) + +/* ATSC/HDTV */ +#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) +#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) + +/* some merged standards */ +#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) +#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) +#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) +#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) + +/* some common needed stuff */ +#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ + V4L2_STD_PAL_B1 |\ + V4L2_STD_PAL_G) +#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\ + V4L2_STD_PAL_D1 |\ + V4L2_STD_PAL_K) +#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ + V4L2_STD_PAL_DK |\ + V4L2_STD_PAL_H |\ + V4L2_STD_PAL_I) +#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\ + V4L2_STD_NTSC_M_JP |\ + V4L2_STD_NTSC_M_KR) +#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ + V4L2_STD_SECAM_K |\ + V4L2_STD_SECAM_K1) +#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\ + V4L2_STD_SECAM_G |\ + V4L2_STD_SECAM_H |\ + V4L2_STD_SECAM_DK |\ + V4L2_STD_SECAM_L |\ + V4L2_STD_SECAM_LC) + +#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ + V4L2_STD_PAL_60 |\ + V4L2_STD_NTSC |\ + V4L2_STD_NTSC_443) +#define V4L2_STD_625_50 (V4L2_STD_PAL |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc |\ + V4L2_STD_SECAM) +#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\ + V4L2_STD_ATSC_16_VSB) + +#define V4L2_STD_UNKNOWN 0 +#define V4L2_STD_ALL (V4L2_STD_525_60 |\ + V4L2_STD_625_50) + +struct v4l2_standard +{ + __u32 index; + v4l2_std_id id; + __u8 name[24]; + struct v4l2_fract frameperiod; /* Frames, not fields */ + __u32 framelines; + __u32 reserved[4]; +}; + +/* + * V I D E O I N P U T S + */ +struct v4l2_input +{ + __u32 index; /* Which input */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of input */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 tuner; /* Associated tuner */ + v4l2_std_id std; + __u32 status; + __u32 reserved[4]; +}; + +/* Values for the 'type' field */ +#define V4L2_INPUT_TYPE_TUNER 1 +#define V4L2_INPUT_TYPE_CAMERA 2 + +/* field 'status' - general */ +#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */ +#define V4L2_IN_ST_NO_SIGNAL 0x00000002 +#define V4L2_IN_ST_NO_COLOR 0x00000004 + +/* field 'status' - analog */ +#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ +#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ + +/* field 'status' - digital */ +#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */ +#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */ +#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */ + +/* field 'status' - VCR and set-top box */ +#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */ +#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ +#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ + +/* + * V I D E O O U T P U T S + */ +struct v4l2_output +{ + __u32 index; /* Which output */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of output */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 modulator; /* Associated modulator */ + v4l2_std_id std; + __u32 reserved[4]; +}; +/* Values for the 'type' field */ +#define V4L2_OUTPUT_TYPE_MODULATOR 1 +#define V4L2_OUTPUT_TYPE_ANALOG 2 +#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 + +/* + * C O N T R O L S + */ +struct v4l2_control +{ + __u32 id; + __s32 value; +}; + +struct v4l2_ext_control +{ + __u32 id; + __u32 reserved2[2]; + union { + __s32 value; + __s64 value64; + void *reserved; + }; +} __attribute__ ((packed)); + +struct v4l2_ext_controls +{ + __u32 ctrl_class; + __u32 count; + __u32 error_idx; + __u32 reserved[2]; + struct v4l2_ext_control *controls; +}; + +/* Values for ctrl_class field */ +#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ +#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ + +#define V4L2_CTRL_ID_MASK (0x0fffffff) +#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) +#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) + +/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ +struct v4l2_queryctrl +{ + __u32 id; + enum v4l2_ctrl_type type; + __u8 name[32]; /* Whatever */ + __s32 minimum; /* Note signedness */ + __s32 maximum; + __s32 step; + __s32 default_value; + __u32 flags; + __u32 reserved[2]; +}; + +/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ +struct v4l2_querymenu +{ + __u32 id; + __u32 index; + __u8 name[32]; /* Whatever */ + __u32 reserved; +}; + +/* Control flags */ +#define V4L2_CTRL_FLAG_DISABLED 0x0001 +#define V4L2_CTRL_FLAG_GRABBED 0x0002 +#define V4L2_CTRL_FLAG_READ_ONLY 0x0004 +#define V4L2_CTRL_FLAG_UPDATE 0x0008 +#define V4L2_CTRL_FLAG_INACTIVE 0x0010 +#define V4L2_CTRL_FLAG_SLIDER 0x0020 + +/* Query flag, to be ORed with the control ID */ +#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 + +/* User-class control IDs defined by V4L2 */ +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) +#define V4L2_CID_USER_BASE V4L2_CID_BASE +/* IDs reserved for driver specific controls */ +#define V4L2_CID_PRIVATE_BASE 0x08000000 + +#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) +#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) +#define V4L2_CID_SATURATION (V4L2_CID_BASE+2) +#define V4L2_CID_HUE (V4L2_CID_BASE+3) +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) +#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7) +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) +#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) +#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) +#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */ +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) +#define V4L2_CID_GAIN (V4L2_CID_BASE+19) +#define V4L2_CID_HFLIP (V4L2_CID_BASE+20) +#define V4L2_CID_VFLIP (V4L2_CID_BASE+21) +#define V4L2_CID_HCENTER (V4L2_CID_BASE+22) +#define V4L2_CID_VCENTER (V4L2_CID_BASE+23) +#define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */ + +/* MPEG-class control IDs defined by V4L2 */ +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) + +/* MPEG streams */ +#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) +enum v4l2_mpeg_stream_type { + V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */ +}; +#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) +#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) +#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) +#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) +#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) +enum v4l2_mpeg_stream_vbi_fmt { + V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ + V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */ +}; + +/* MPEG audio */ +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) +enum v4l2_mpeg_audio_sampling_freq { + V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) +enum v4l2_mpeg_audio_encoding { + V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, + V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, + V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) +enum v4l2_mpeg_audio_l1_bitrate { + V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, + V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2, + V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3, + V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4, + V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5, + V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6, + V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7, + V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8, + V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9, + V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10, + V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11, + V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, + V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) +enum v4l2_mpeg_audio_l2_bitrate { + V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, + V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2, + V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3, + V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4, + V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5, + V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6, + V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7, + V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8, + V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9, + V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10, + V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11, + V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, + V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) +enum v4l2_mpeg_audio_l3_bitrate { + V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, + V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2, + V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3, + V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4, + V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5, + V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6, + V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7, + V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8, + V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9, + V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10, + V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11, + V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, + V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) +enum v4l2_mpeg_audio_mode { + V4L2_MPEG_AUDIO_MODE_STEREO = 0, + V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, + V4L2_MPEG_AUDIO_MODE_DUAL = 2, + V4L2_MPEG_AUDIO_MODE_MONO = 3, +}; +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) +enum v4l2_mpeg_audio_mode_extension { + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3, +}; +#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) +enum v4l2_mpeg_audio_emphasis { + V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, + V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, + V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) +enum v4l2_mpeg_audio_crc { + V4L2_MPEG_AUDIO_CRC_NONE = 0, + V4L2_MPEG_AUDIO_CRC_CRC16 = 1, +}; + +/* MPEG video */ +#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) +enum v4l2_mpeg_video_encoding { + V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, + V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, +}; +#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) +enum v4l2_mpeg_video_aspect { + V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, + V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, + V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, + V4L2_MPEG_VIDEO_ASPECT_221x100 = 3, +}; +#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) +#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) +enum v4l2_mpeg_video_bitrate_mode { + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, +}; +#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) + +/* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) +enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2) +enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3) +enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4) +enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5) +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6) +enum v4l2_mpeg_cx2341x_video_median_filter_type { + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) + +/* + * T U N I N G + */ +struct v4l2_tuner +{ + __u32 index; + __u8 name[32]; + enum v4l2_tuner_type type; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 rxsubchans; + __u32 audmode; + __s32 signal; + __s32 afc; + __u32 reserved[4]; +}; + +struct v4l2_modulator +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 txsubchans; + __u32 reserved[4]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_TUNER_CAP_LOW 0x0001 +#define V4L2_TUNER_CAP_NORM 0x0002 +#define V4L2_TUNER_CAP_STEREO 0x0010 +#define V4L2_TUNER_CAP_LANG2 0x0020 +#define V4L2_TUNER_CAP_SAP 0x0020 +#define V4L2_TUNER_CAP_LANG1 0x0040 + +/* Flags for the 'rxsubchans' field */ +#define V4L2_TUNER_SUB_MONO 0x0001 +#define V4L2_TUNER_SUB_STEREO 0x0002 +#define V4L2_TUNER_SUB_LANG2 0x0004 +#define V4L2_TUNER_SUB_SAP 0x0004 +#define V4L2_TUNER_SUB_LANG1 0x0008 + +/* Values for the 'audmode' field */ +#define V4L2_TUNER_MODE_MONO 0x0000 +#define V4L2_TUNER_MODE_STEREO 0x0001 +#define V4L2_TUNER_MODE_LANG2 0x0002 +#define V4L2_TUNER_MODE_SAP 0x0002 +#define V4L2_TUNER_MODE_LANG1 0x0003 +#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 + +struct v4l2_frequency +{ + __u32 tuner; + enum v4l2_tuner_type type; + __u32 frequency; + __u32 reserved[8]; +}; + +/* + * A U D I O + */ +struct v4l2_audio +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_AUDCAP_STEREO 0x00001 +#define V4L2_AUDCAP_AVL 0x00002 + +/* Flags for the 'mode' field */ +#define V4L2_AUDMODE_AVL 0x00001 + +struct v4l2_audioout +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* + * D A T A S E R V I C E S ( V B I ) + * + * Data services API by Michael Schimek + */ + +/* Raw VBI */ +struct v4l2_vbi_format +{ + __u32 sampling_rate; /* in 1 Hz */ + __u32 offset; + __u32 samples_per_line; + __u32 sample_format; /* V4L2_PIX_FMT_* */ + __s32 start[2]; + __u32 count[2]; + __u32 flags; /* V4L2_VBI_* */ + __u32 reserved[2]; /* must be zero */ +}; + +/* VBI flags */ +#define V4L2_VBI_UNSYNC (1<< 0) +#define V4L2_VBI_INTERLACED (1<< 1) + +#if 1 +/* Sliced VBI + * + * This implements is a proposal V4L2 API to allow SLICED VBI + * required for some hardware encoders. It should change without + * notice in the definitive implementation. + */ + +struct v4l2_sliced_vbi_format +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + __u32 io_size; + __u32 reserved[2]; /* must be zero */ +}; + +/* Teletext World System Teletext + (WST), defined on ITU-R BT.653-2 */ +#define V4L2_SLICED_TELETEXT_B (0x0001) +/* Video Program System, defined on ETS 300 231*/ +#define V4L2_SLICED_VPS (0x0400) +/* Closed Caption, defined on EIA-608 */ +#define V4L2_SLICED_CAPTION_525 (0x1000) +/* Wide Screen System, defined on ITU-R BT1119.1 */ +#define V4L2_SLICED_WSS_625 (0x4000) + +#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) +#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) + + +struct v4l2_sliced_vbi_cap +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + enum v4l2_buf_type type; + __u32 reserved[3]; /* must be 0 */ +}; + +struct v4l2_sliced_vbi_data +{ + __u32 id; + __u32 field; /* 0: first field, 1: second field */ + __u32 line; /* 1-23 */ + __u32 reserved; /* must be 0 */ + __u8 data[48]; +}; +#endif + +/* + * A G G R E G A T E S T R U C T U R E S + */ + +/* Stream data format + */ +struct v4l2_format +{ + enum v4l2_buf_type type; + union + { + struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE + struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY + struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE +#if 1 + struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE +#endif + __u8 raw_data[200]; // user-defined + } fmt; +}; + + +/* Stream type-dependent parameters + */ +struct v4l2_streamparm +{ + enum v4l2_buf_type type; + union + { + struct v4l2_captureparm capture; + struct v4l2_outputparm output; + __u8 raw_data[200]; /* user-defined */ + } parm; +}; + +/* + * 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 + * + */ +#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) +#define VIDIOC_RESERVED _IO ('V', 1) +#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) +#define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) +#define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) +#ifdef __KERNEL__ +#define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) +#define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) +#endif +#define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) +#define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) +#define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) +#define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer) +#define VIDIOC_OVERLAY _IOW ('V', 14, int) +#define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer) +#define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer) +#define VIDIOC_STREAMON _IOW ('V', 18, int) +#define VIDIOC_STREAMOFF _IOW ('V', 19, int) +#define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm) +#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm) +#define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id) +#define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id) +#define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard) +#define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input) +#define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control) +#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control) +#define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner) +#define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner) +#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio) +#define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio) +#define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl) +#define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu) +#define VIDIOC_G_INPUT _IOR ('V', 38, int) +#define VIDIOC_S_INPUT _IOWR ('V', 39, int) +#define VIDIOC_G_OUTPUT _IOR ('V', 46, int) +#define VIDIOC_S_OUTPUT _IOWR ('V', 47, int) +#define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output) +#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout) +#define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout) +#define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator) +#define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator) +#define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency) +#define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency) +#define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap) +#define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop) +#define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop) +#define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression) +#define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression) +#define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id) +#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format) +#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio) +#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) +#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) +#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) +#if 1 +#define VIDIOC_G_SLICED_VBI_CAP _IOWR ('V', 69, struct v4l2_sliced_vbi_cap) +#endif +#define VIDIOC_LOG_STATUS _IO ('V', 70) +#define VIDIOC_G_EXT_CTRLS _IOWR ('V', 71, struct v4l2_ext_controls) +#define VIDIOC_S_EXT_CTRLS _IOWR ('V', 72, struct v4l2_ext_controls) +#define VIDIOC_TRY_EXT_CTRLS _IOWR ('V', 73, struct v4l2_ext_controls) +#if 1 +#define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) +#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) +#endif + +#ifdef __OLD_VIDIOC_ +/* for compatibility, will go away some day */ +#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) +#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) +#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control) +#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) +#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) +#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) +#endif + +#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ + +#endif /* __LINUX_VIDEODEV2_H */ + +/* + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/ddverify/models/seq1/include/linux/vmalloc.h b/ddverify/models/seq1/include/linux/vmalloc.h new file mode 100644 index 000000000..747bc9653 --- /dev/null +++ b/ddverify/models/seq1/include/linux/vmalloc.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_VMALLOC_H +#define _LINUX_VMALLOC_H + +#include + +void *vmalloc(unsigned long size); +void vfree(void *addr); + +#endif /* _LINUX_VMALLOC_H */ diff --git a/ddverify/models/seq1/include/linux/wait.h b/ddverify/models/seq1/include/linux/wait.h new file mode 100644 index 000000000..c5176bff3 --- /dev/null +++ b/ddverify/models/seq1/include/linux/wait.h @@ -0,0 +1,89 @@ +#ifndef _LINUX_WAIT_H +#define _LINUX_WAIT_H + +#include +#include +#include +#include +#include +#include + +struct __wait_queue { + int something; +}; +typedef struct __wait_queue wait_queue_t; + +struct __wait_queue_head { + int number_process_waiting; + int wakeup; + + int init; +}; +typedef struct __wait_queue_head wait_queue_head_t; + + +#define DECLARE_WAITQUEUE(name, tsk) wait_queue_t name +#define DECLARE_WAIT_QUEUE_HEAD(name) wait_queue_head_t name = { \ + .number_process_waiting = 0, \ + .wakeup = 0, \ + .init = 1} + + +#ifdef DDV_ASSERT_WAIT_QUEUE +#define assert_wait_queue(wq) __CPROVER_assert((wq)->init, "Wait queue is initialized!") +#else +#define assert_wait_queue(wq) do {} while(0) +#endif + +#define wait_event(wq, condition) \ + do { \ + __CPROVER_HIDE: \ + assert_wait_queue(wq); \ + __CPROVER_assume(condition); \ + } while(0) + + +#define wait_event_interruptible(wq, condition) \ +({ \ + int __ret; \ + \ + __CPROVER_HIDE: \ + assert_wait_queue(wq); \ + if (nondet_int()) { \ + __ret = 0; \ + } else { \ + __ret = 1; \ + } \ + \ + __ret; \ +}) + +// DDV: Body is defined in linux/kernel/wait.c +void init_waitqueue_head(wait_queue_head_t *q); +// DDV: TODO +void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state); +// DDV: TODO +void finish_wait(wait_queue_head_t *q, wait_queue_t *wait); + +// DDV: Body is defined in linux/kernel/wait.c +void wake_up(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_all(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_interruptible(wait_queue_head_t *q); + +// DDV: TODO +void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); + +// DDV: TODO +int waitqueue_active(wait_queue_head_t *q); + +// DDV: Body is defined in linux/kernel/wait.c +void sleep_on(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void interruptible_sleep_on(wait_queue_head_t *q); +#endif diff --git a/ddverify/models/seq1/include/linux/watchdog.h b/ddverify/models/seq1/include/linux/watchdog.h new file mode 100644 index 000000000..afc7f8318 --- /dev/null +++ b/ddverify/models/seq1/include/linux/watchdog.h @@ -0,0 +1,52 @@ +#ifndef _LINUX_WATCHDOG_H +#define _LINUX_WATCHDOG_H + +#include +#include + +#define WATCHDOG_IOCTL_BASE 'W' + +struct watchdog_info { + __u32 options; /* Options the card/driver supports */ + __u32 firmware_version; /* Firmware version of the card */ + __u8 identity[32]; /* Identity of the board */ +}; + +#define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info) +#define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int) +#define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int) +#define WDIOC_GETTEMP _IOR(WATCHDOG_IOCTL_BASE, 3, int) +#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int) +#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int) +#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) +#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) +#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int) +#define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int) +#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int) + +#define WDIOF_UNKNOWN -1 /* Unknown flag error */ +#define WDIOS_UNKNOWN -1 /* Unknown status error */ + +#define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */ +#define WDIOF_FANFAULT 0x0002 /* Fan failed */ +#define WDIOF_EXTERN1 0x0004 /* External relay 1 */ +#define WDIOF_EXTERN2 0x0008 /* External relay 2 */ +#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ +#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ +#define WDIOF_POWEROVER 0x0040 /* Power over voltage */ +#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ +#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ +#define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ +#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ + +#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ +#define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */ +#define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */ + +#ifdef CONFIG_WATCHDOG_NOWAYOUT +#define WATCHDOG_NOWAYOUT 1 +#else +#define WATCHDOG_NOWAYOUT 0 +#endif + +#endif /* ifndef _LINUX_WATCHDOG_H */ diff --git a/ddverify/models/seq1/include/linux/workqueue.h b/ddverify/models/seq1/include/linux/workqueue.h new file mode 100644 index 000000000..968ed7e62 --- /dev/null +++ b/ddverify/models/seq1/include/linux/workqueue.h @@ -0,0 +1,50 @@ +/* + * workqueue.h --- work queue handling for Linux. + */ + +#ifndef _LINUX_WORKQUEUE_H +#define _LINUX_WORKQUEUE_H + +#include +//#include +#include + +struct work_struct { + unsigned long pending; + void (*func)(void *); + void *data; + + int init; +}; + +#define DECLARE_WORK(n, f, d) \ + struct work_struct n = { \ + .func = (f), \ + .data = (d), \ + .init = 1, \ + } + +/* + * initialize a work-struct's func and data pointers: + */ +#define PREPARE_WORK(_work, _func, _data) \ + do { \ + (_work)->func = _func; \ + (_work)->data = _data; \ + (_work)->init = 1; \ + } while (0) + +/* + * initialize all of a work-struct: + */ +#define INIT_WORK(_work, _func, _data) \ + do { \ + PREPARE_WORK((_work), (_func), (_data)); \ + } while (0) + +// DDV: Body for this function is defined in linux/kernel/workqueue.c +int schedule_work(struct work_struct *work); +// DDV: TODO +void flush_scheduled_work(void); + +#endif diff --git a/ddverify/models/seq1/include/linux/writeback.h b/ddverify/models/seq1/include/linux/writeback.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/seq1/include/media/v4l2-common.h b/ddverify/models/seq1/include/media/v4l2-common.h new file mode 100644 index 000000000..1863cce24 --- /dev/null +++ b/ddverify/models/seq1/include/media/v4l2-common.h @@ -0,0 +1,6 @@ +#ifndef V4L2_COMMON_H_ +#define V4L2_COMMON_H_ + +#include + +#endif /* V4L2_COMMON_H_ */ diff --git a/ddverify/models/seq1/include/media/v4l2-dev.h b/ddverify/models/seq1/include/media/v4l2-dev.h new file mode 100644 index 000000000..94b52e78e --- /dev/null +++ b/ddverify/models/seq1/include/media/v4l2-dev.h @@ -0,0 +1,255 @@ +#ifndef _V4L2_DEV_H +#define _V4L2_DEV_H + +#include +#include +#include +#include +#include +#include + + +#define VIDEO_MAJOR 81 +/* Minor device allocation */ +#define MINOR_VFL_TYPE_GRABBER_MIN 0 +#define MINOR_VFL_TYPE_GRABBER_MAX 63 +#define MINOR_VFL_TYPE_RADIO_MIN 64 +#define MINOR_VFL_TYPE_RADIO_MAX 127 +#define MINOR_VFL_TYPE_VTX_MIN 192 +#define MINOR_VFL_TYPE_VTX_MAX 223 +#define MINOR_VFL_TYPE_VBI_MIN 224 +#define MINOR_VFL_TYPE_VBI_MAX 255 + +#define VFL_TYPE_GRABBER 0 +#define VFL_TYPE_VBI 1 +#define VFL_TYPE_RADIO 2 +#define VFL_TYPE_VTX 3 + + + +struct video_device +{ + /* device ops */ + const struct file_operations *fops; + + /* device info */ + struct device *dev; + char name[32]; + int type; /* v4l1 */ + int type2; /* v4l2 */ + int hardware; + int minor; + + int debug; /* Activates debug level*/ + + /* Video standard vars */ + int tvnormsize; /* Size of tvnorm array */ + v4l2_std_id current_norm; /* Current tvnorm */ + struct v4l2_tvnorm *tvnorms; + + /* callbacks */ + void (*release)(struct video_device *vfd); + + /* ioctl callbacks */ + + /* VIDIOC_QUERYCAP handler */ + int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap); + + /* Priority handling */ + int (*vidioc_g_priority) (struct file *file, void *fh, + enum v4l2_priority *p); + int (*vidioc_s_priority) (struct file *file, void *fh, + enum v4l2_priority p); + + /* VIDIOC_ENUM_FMT handlers */ + int (*vidioc_enum_fmt_cap) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_overlay) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_capture) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_video_output)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + + /* VIDIOC_G_FMT handlers */ + int (*vidioc_g_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_S_FMT handlers */ + int (*vidioc_s_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + + int (*vidioc_s_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_TRY_FMT handlers */ + int (*vidioc_try_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* Buffer handlers */ + int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); + int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + + + int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); + + int (*vidioc_g_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + int (*vidioc_s_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + + /* Stream on/off */ + int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i); + int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i); + + /* Standard handling + G_STD and ENUMSTD are handled by videodev.c + */ + int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id a); + int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a); + + /* Input handling */ + int (*vidioc_enum_input)(struct file *file, void *fh, + struct v4l2_input *inp); + int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i); + + /* Output handling */ + int (*vidioc_enumoutput) (struct file *file, void *fh, + struct v4l2_output *a); + int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i); + + /* Control handling */ + int (*vidioc_queryctrl) (struct file *file, void *fh, + struct v4l2_queryctrl *a); + int (*vidioc_g_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_s_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_g_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_s_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_try_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_querymenu) (struct file *file, void *fh, + struct v4l2_querymenu *a); + + /* Audio ioctls */ + int (*vidioc_enumaudio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_g_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_s_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + + /* Audio out ioctls */ + int (*vidioc_enumaudout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_s_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + int (*vidioc_s_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + /* Crop ioctls */ + int (*vidioc_cropcap) (struct file *file, void *fh, + struct v4l2_cropcap *a); + int (*vidioc_g_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + int (*vidioc_s_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + /* Compression ioctls */ + int (*vidioc_g_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_s_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_g_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + int (*vidioc_s_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + + /* Stream type-dependent parameter ioctls */ + int (*vidioc_g_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + int (*vidioc_s_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + + /* Tuner ioctls */ + int (*vidioc_g_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_s_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_g_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + int (*vidioc_s_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + + /* Sliced VBI cap */ + int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh, + struct v4l2_sliced_vbi_cap *a); + + /* Log status ioctl */ + int (*vidioc_log_status) (struct file *file, void *fh); + + + struct module *owner; + + void *priv; + +}; + + + +extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, + unsigned long arg); + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +#endif /* _V4L2_DEV_H */ diff --git a/ddverify/models/seq1/include/net/sock.h b/ddverify/models/seq1/include/net/sock.h new file mode 100644 index 000000000..2eefd9c6c --- /dev/null +++ b/ddverify/models/seq1/include/net/sock.h @@ -0,0 +1,29 @@ +#ifndef _SOCK_H +#define _SOCK_H + +#include +#include +#include +#include +//#include +#include +#include /* struct sk_buff */ +//#include + + +#define SHUTDOWN_MASK 3 +#define RCV_SHUTDOWN 1 +#define SEND_SHUTDOWN 2 + +#define SOCK_SNDBUF_LOCK 1 +#define SOCK_RCVBUF_LOCK 2 +#define SOCK_BINDADDR_LOCK 4 +#define SOCK_BINDPORT_LOCK 8 + +struct sock { + gfp_t sk_allocation; +}; + +struct socket *SOCKET_I(struct inode *inode); + +#endif /* _SOCK_H */ diff --git a/ddverify/models/seq1/src/ddverify/cdev.c b/ddverify/models/seq1/src/ddverify/cdev.c new file mode 100644 index 000000000..c608b16d5 --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/cdev.c @@ -0,0 +1,156 @@ +#include +#include +#include + +void call_cdev_functions() +{ + int cdev_no, function_no, result; + + loff_t loff_t_value; + int int_value; + unsigned int uint_value; + unsigned long ulong_value; + char char_value; + size_t size_t_value; + + if (number_cdev_registered == 0) { + return; + } + + cdev_no = nondet_ushort(); + __CPROVER_assume (0 <= cdev_no && cdev_no < number_cdev_registered); + + switch (nondet_ushort()) { + case 0: + if (cdev_registered[cdev_no].cdevp->ops->llseek) { + loff_t_value = nondet_loff_t(); + int_value = nondet_int(); + + (* cdev_registered[cdev_no].cdevp->ops->llseek)(&cdev_registered[cdev_no].filp, + loff_t_value, + int_value); + } + break; + case 1: + if (cdev_registered[cdev_no].cdevp->ops->read) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->read)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 2: + // aio_read - NOT SUPPORTED! + break; + case 3: + if (cdev_registered[cdev_no].cdevp->ops->write) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->write)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 4: + // aio_write - NOT SUPPORTED! + break; + case 5: + // readdir - NOT SUPPORTED! + break; + case 6: + // poll - NOT SUPPORTED! + break; + case 7: + if (cdev_registered[cdev_no].cdevp->ops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + + (* cdev_registered[cdev_no].cdevp->ops->ioctl)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp, + uint_value, + ulong_value); + } + + break; + case 8: + // unlocked_ioctl - NOT SUPPORTED! + break; + case 9: + // compat_ioctl - NOT SUPPORTED! + break; + case 10: + // mmap - NOT SUPPORTED! + break; + case 11: + if ((cdev_registered[cdev_no].cdevp->ops->open) && + (!cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->open)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 1; + } + } + break; + case 12: + // flush - NOT SUPPORTED! + break; + case 13: + if ((cdev_registered[cdev_no].cdevp->ops->release) && + (cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->release)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 0; + } + } + break; + case 14: + // fsync - NOT SUPPORTED! + break; + case 15: + // aio_fsync - NOT SUPPORTED! + break; + case 16: + // fasync - NOT SUPPORTED! + break; + case 17: + // lock - NOT SUPPORTED! + break; + case 18: + // readv - NOT SUPPORTED! + break; + case 19: + // writev - NOT SUPPORTED! + break; + case 20: + // sendfile - NOT SUPPORTED! + break; + case 21: + // sendpage - NOT SUPPORTED! + break; + case 22: + // get_unmapped_area - NOT SUPPORTED! + break; + case 23: + // check_flags - NOT SUPPORTED! + break; + case 24: + // dir_notify - NOT SUPPORTED! + break; + case 25: + // flock - NOT SUPPORTED! + break; + case 26: + // open_exec - NOT SUPPORTED! + break; + default: + break; + } +} diff --git a/ddverify/models/seq1/src/ddverify/ddverify.c b/ddverify/models/seq1/src/ddverify/ddverify.c new file mode 100644 index 000000000..b30fc325d --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/ddverify.c @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void init_kernel() +{ + int i; + + spin_lock_init(&kernel_lock); + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + shared_workqueue[i] = NULL; + } + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + tasklet_registered[i].tasklet = NULL; + tasklet_registered[i].is_running = 0; + } +} + +void ddv() +{ + unsigned short random; + + do { + random = nondet_ushort(); + + switch (random) { + case 1: + switch_context(CONTEXT_PROCESS); +#ifdef DRIVER_TYPE_CHAR + call_cdev_functions(); +#endif + +#ifdef DRIVER_TYPE_BLOCK + call_genhd_functions(); +#endif + break; + + case 2: + switch_context(CONTEXT_INTERRUPT); + call_timer_functions(); + break; + + case 3: + switch_context(CONTEXT_INTERRUPT); + call_interrupt_handler(); + break; + + case 4: + switch_context(CONTEXT_PROCESS); + call_shared_workqueue_functions(); + break; + + case 5: + switch_context(CONTEXT_INTERRUPT); + call_tasklet_functions(); + break; + +#ifdef DRIVER_TYPE_PCI + case 6: + switch_context(CONTEXT_PROCESS); + call_pci_functions(); + break; +#endif + + default: + break; + } + } while(random); +} + +int call_ddv() +{ + int err; + + switch_context(CONTEXT_PROCESS); + + init_kernel(); + + err = (* _ddv_module_init)(); + + if (err) { + return -1; + } + + ddv(); + + switch_context(CONTEXT_PROCESS); + (* _ddv_module_exit)(); + + return 0; +} diff --git a/ddverify/models/seq1/src/ddverify/genhd.c b/ddverify/models/seq1/src/ddverify/genhd.c new file mode 100644 index 000000000..8938bbdd3 --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/genhd.c @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include + +create_request(int genhd_no) +{ + struct request rq; + + rq.cmd_type = REQ_TYPE_FS; + rq.rq_disk = genhd_registered[genhd_no].gd; + rq.sector = nondet_sector_t(); + rq.current_nr_sectors = nondet_uint(); + rq.buffer = nondet_pchar(); + + genhd_registered[genhd_no].current_request = rq; + genhd_registered[genhd_no].requests_open = 1; +} + +void call_rq_function(int genhd_no) +{ + if ((genhd_registered[genhd_no].gd->queue->request_fn != NULL) && + (genhd_registered[genhd_no].gd->queue->__ddv_queue_alive)) + { + spin_lock(genhd_registered[genhd_no].gd->queue->queue_lock); + + create_request(genhd_no); + genhd_registered[genhd_no].gd->queue->__ddv_genhd_no = genhd_no; + + (* genhd_registered[genhd_no].gd->queue->request_fn)(genhd_registered[genhd_no].gd->queue); + // do_cm206_request(genhd_registered[genhd_no].gd->queue); + + spin_unlock(genhd_registered[genhd_no].gd->queue->queue_lock); + + return; + } + + if (genhd_registered[genhd_no].gd->queue->make_request_fn) { + return; + } +} + +void call_genhd_functions() +{ + unsigned short genhd_no, function_no; + unsigned int uint_value; + unsigned long ulong_value; + int result; + + if (number_genhd_registered == 0) { + return; + } + + genhd_no = nondet_ushort(); + __CPROVER_assume (genhd_no < number_genhd_registered); + + + function_no = nondet_ushort(); + + switch (function_no) { + case 0: + call_rq_function(genhd_no); + break; + + case 1: + if (genhd_registered[genhd_no].gd->fops->open) { + genhd_registered[genhd_no].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[genhd_no].inode.i_bdev->bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->open)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 2: + if (genhd_registered[genhd_no].gd->fops->release) { + (* genhd_registered[genhd_no].gd->fops->release)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 3: + if (genhd_registered[genhd_no].gd->fops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + (* genhd_registered[genhd_no].gd->fops->ioctl)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file, + uint_value, + ulong_value); + } + break; + + case 4: + if (genhd_registered[genhd_no].gd->fops->media_changed) { + (* genhd_registered[genhd_no].gd->fops->media_changed)(genhd_registered[genhd_no].gd); + } + break; + + case 5: + if (genhd_registered[genhd_no].gd->fops->revalidate_disk) { + (* genhd_registered[genhd_no].gd->fops->revalidate_disk)(genhd_registered[genhd_no].gd); + } + break; + + case 6: + if (genhd_registered[genhd_no].gd->fops->getgeo) { + struct hd_geometry hdg; + struct block_device blk_dev; + + blk_dev.bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->getgeo)(&blk_dev, &hdg); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/seq1/src/ddverify/interrupt.c b/ddverify/models/seq1/src/ddverify/interrupt.c new file mode 100644 index 000000000..4a5ed1daf --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/interrupt.c @@ -0,0 +1,22 @@ +#include +#include + +#ifdef OLD_INTERRUPT_HANDLER +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id) +#else +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id, regs) +#endif + +void call_interrupt_handler() +{ + unsigned short i; + struct pt_regs regs; + + i = nondet_int(); + __CPROVER_assume(i < MAX_IRQ_SUPPORT); + + if (registered_irq[i].handler) { + __call_interrupt_handler((* registered_irq[i].handler), + (int)i, registered_irq[i].dev_id, ®s); + } +} diff --git a/ddverify/models/seq1/src/ddverify/ioctl.c b/ddverify/models/seq1/src/ddverify/ioctl.c new file mode 100644 index 000000000..2f95c45aa --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/ioctl.c @@ -0,0 +1,19 @@ +#include +#include + +/*void add_ioctl(unsigned int ioctl) +{ + if (number_ioctl_registered < MAX_IOCTL_SUPPORT) { + ioctl_registered[number_ioctl_registered] = ioctl; + number_ioctl_registered++; + } +} + +unsigned int get_ioctl_cmd() +{ + short cmd = nondet_short(); + __CPROVER_assume (cmd >= 0 && cmd < number_ioctl_registered); + + return ioctl_registered[cmd]; +} +*/ diff --git a/ddverify/models/seq1/src/ddverify/pci.c b/ddverify/models/seq1/src/ddverify/pci.c new file mode 100644 index 000000000..7f9df6bbb --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/pci.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include + +void create_pci_dev() +{ +} + +int pci_probe_device() +{ + int err; + unsigned int dev_id; + + registered_pci_driver.no_pci_device_id = 1; + + dev_id = nondet_uint(); + __CPROVER_assume(dev_id < registered_pci_driver.no_pci_device_id); + + err = (*registered_pci_driver.pci_driver->probe)(®istered_pci_driver.pci_dev, + ®istered_pci_driver.pci_driver->id_table[dev_id]); + + if (!err) { + registered_pci_driver.dev_initialized = 1; + } + + return err; +} + +void pci_remove_device() +{ + (*registered_pci_driver.pci_driver->remove)(®istered_pci_driver.pci_dev); + + registered_pci_driver.dev_initialized = 0; +} + +void call_pci_functions() +{ + switch (nondet_uint()) { + case 0: + if (!registered_pci_driver.dev_initialized) { + pci_probe_device(); + } + break; + + case 1: + if (registered_pci_driver.dev_initialized) { + pci_remove_device(); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/seq1/src/ddverify/tasklet.c b/ddverify/models/seq1/src/ddverify/tasklet.c new file mode 100644 index 000000000..776673eb8 --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/tasklet.c @@ -0,0 +1,15 @@ +#include + +void call_tasklet_functions() +{ + unsigned int i; + __CPROVER_assume(i < MAX_TASKLET_SUPPORT); + + if ((tasklet_registered[i].tasklet != NULL) && + (tasklet_registered[i].tasklet->count == 0)) { + tasklet_registered[i].is_running = 1; + (* tasklet_registered[i].tasklet->func)(tasklet_registered[i].tasklet->data); + tasklet_registered[i].is_running = 0; + tasklet_registered[i].tasklet = NULL; + } +} diff --git a/ddverify/models/seq1/src/ddverify/timer.c b/ddverify/models/seq1/src/ddverify/timer.c new file mode 100644 index 000000000..45c22052a --- /dev/null +++ b/ddverify/models/seq1/src/ddverify/timer.c @@ -0,0 +1,13 @@ +#include +#include + +void call_timer_functions() +{ + unsigned short i = nondet_ushort(); + + __CPROVER_assume(i < number_timer_registered); + + if (timer_registered[i].timer->__ddv_active) { + (* timer_registered[i].timer->function)(timer_registered[i].timer->data); + } +} diff --git a/ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c b/ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c new file mode 100644 index 000000000..06fc72517 --- /dev/null +++ b/ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c @@ -0,0 +1,51 @@ +#include +#include +#include + +int __get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int __put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +int put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} + +unsigned long copy_from_user(void *to, void __user *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} diff --git a/ddverify/models/seq1/src/linux/block/elevator.c b/ddverify/models/seq1/src/linux/block/elevator.c new file mode 100644 index 000000000..8511b9dd9 --- /dev/null +++ b/ddverify/models/seq1/src/linux/block/elevator.c @@ -0,0 +1,13 @@ +#include +#include + +struct request *elv_next_request(request_queue_t *q) +{ + int genhd_no = q->__ddv_genhd_no; + + if (genhd_registered[genhd_no].requests_open > 0) { + return genhd_registered[genhd_no].current_request; + } else { + return NULL; + } +} diff --git a/ddverify/models/seq1/src/linux/block/genhd.c b/ddverify/models/seq1/src/linux/block/genhd.c new file mode 100644 index 000000000..2cbcc717d --- /dev/null +++ b/ddverify/models/seq1/src/linux/block/genhd.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +int register_blkdev(unsigned int major, const char *name) +{ + int result = nondet_int(); + + /*if ((major > 0) && (result > 0)) { + return major; + }*/ + + return result; +} + +int unregister_blkdev(unsigned int major, const char *name) +{ + return 0; +} + +struct gendisk *alloc_disk(int minors) +{ + struct gendisk * gd; + + if (number_fixed_genhd_used < MAX_GENHD_SUPPORT) { + gd = &fixed_gendisk[number_fixed_genhd_used]; + gd->minors = minors; + + number_fixed_genhd_used++; + + return gd; + } else { + return NULL; + } +} + +void add_disk(struct gendisk *disk) +{ + if (number_genhd_registered < MAX_GENHD_SUPPORT) { + genhd_registered[number_genhd_registered].gd = disk; + genhd_registered[number_genhd_registered].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[number_genhd_registered].inode.i_bdev->bd_disk = disk; + + number_genhd_registered++; + } +} + +void del_gendisk(struct gendisk *gp) +{ + int i; + + for (i = 0; i < number_genhd_registered; i++) { + if (genhd_registered[i].gd == gp) { + genhd_registered[i].gd = NULL; + } + } +} diff --git a/ddverify/models/seq1/src/linux/block/ll_rw_blk.c b/ddverify/models/seq1/src/linux/block/ll_rw_blk.c new file mode 100644 index 000000000..eb27f72a2 --- /dev/null +++ b/ddverify/models/seq1/src/linux/block/ll_rw_blk.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include + +request_queue_t *get_fixed_request_queue() +{ + if (number_request_queue_used < MAX_REQUEST_QUEUE_SUPPORT) { + return &fixed_request_queue[number_request_queue_used++]; + } else { + return NULL; + } +} + +request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->queue_lock = lock; + queue->request_fn = rfn; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +request_queue_t *blk_alloc_queue(gfp_t gfp_mask) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->request_fn = NULL; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn) +{ + q->make_request_fn = mfn; +} + +void end_request(struct request *req, int uptodate) +{ + int genhd_no = req->rq_disk->queue->__ddv_genhd_no; + + genhd_registered[genhd_no].requests_open = 0; +} + + +void blk_queue_hardsect_size(request_queue_t *q, unsigned short size) +{ + q->hardsect_size = size; +} + +void blk_cleanup_queue(request_queue_t *q) +{ + q->__ddv_queue_alive = 0; +} diff --git a/ddverify/models/seq1/src/linux/drivers/char/misc.c b/ddverify/models/seq1/src/linux/drivers/char/misc.c new file mode 100644 index 000000000..1bcc5a5ac --- /dev/null +++ b/ddverify/models/seq1/src/linux/drivers/char/misc.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +//#include +//#include +#include + +#include + +int misc_register(struct miscdevice * misc) +{ + int i; + dev_t dev; + + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + i = fixed_cdev_used; + fixed_cdev_used++; + + fixed_cdev[i].owner = THIS_MODULE; + fixed_cdev[i].ops = misc->fops; + + dev = MKDEV(MISC_MAJOR, misc->minor); + + return cdev_add(&fixed_cdev[i], dev, 0); + } else { + return -1; + } +} diff --git a/ddverify/models/seq1/src/linux/drivers/char/tty_io.c b/ddverify/models/seq1/src/linux/drivers/char/tty_io.c new file mode 100644 index 000000000..30fe841cc --- /dev/null +++ b/ddverify/models/seq1/src/linux/drivers/char/tty_io.c @@ -0,0 +1,40 @@ +#include +#include + +struct tty_driver *alloc_tty_driver(int lines) +{ + if (!global_tty_driver.allocated) { + global_tty_driver.driver.magic = TTY_DRIVER_MAGIC; + global_tty_driver.driver.num = lines; + } else { + return NULL; + } +} + +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op) +{ + driver->open = op->open; + driver->close = op->close; + driver->write = op->write; + driver->put_char = op->put_char; + driver->flush_chars = op->flush_chars; + driver->write_room = op->write_room; + driver->chars_in_buffer = op->chars_in_buffer; + driver->ioctl = op->ioctl; + driver->set_termios = op->set_termios; + driver->throttle = op->throttle; + driver->unthrottle = op->unthrottle; + driver->stop = op->stop; + driver->start = op->start; + driver->hangup = op->hangup; + driver->break_ctl = op->break_ctl; + driver->flush_buffer = op->flush_buffer; + driver->set_ldisc = op->set_ldisc; + driver->wait_until_sent = op->wait_until_sent; + driver->send_xchar = op->send_xchar; + driver->read_proc = op->read_proc; + driver->write_proc = op->write_proc; + driver->tiocmget = op->tiocmget; + driver->tiocmset = op->tiocmset; +} diff --git a/ddverify/models/seq1/src/linux/fs/char_dev.c b/ddverify/models/seq1/src/linux/fs/char_dev.c new file mode 100644 index 000000000..8a0a278bf --- /dev/null +++ b/ddverify/models/seq1/src/linux/fs/char_dev.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +#include +#include + +int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) +{ + int major; + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + major = nondet_uint(); + *dev = MKDEV(major, baseminor); + } + + return return_value; +} + +int register_chrdev_region(dev_t from, unsigned count, const char *name) +{ + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + return return_value; +} + +//void unregister_chrdev_region(dev_t, unsigned) {} + + +int register_chrdev(unsigned int major, const char *name, + struct file_operations *fops) +{ + struct cdev *cdev; + int err; + + major = register_chrdev_region(0, 256, name); + + cdev = cdev_alloc(); + cdev->owner = fops->owner; + cdev->ops = fops; + + err = cdev_add(cdev, MKDEV(major, 0), 256); + + if (err) { + kfree(cdev); + return err; + } + + return major; +} + + +int unregister_chrdev(unsigned int major, const char *name) +{ + return 0; +} + +struct cdev *cdev_alloc(void) +{ + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + return &fixed_cdev[fixed_cdev_used++]; + } +} + +void cdev_init(struct cdev *cdev, struct file_operations *fops) +{ + cdev->ops = fops; +} + +int cdev_add(struct cdev *p, dev_t dev, unsigned count) +{ + p->dev = dev; + p->count = count; + + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + if (number_cdev_registered < MAX_CDEV_SUPPORT) { + + cdev_registered[number_cdev_registered].cdevp = p; + cdev_registered[number_cdev_registered].inode.i_rdev = dev; + cdev_registered[number_cdev_registered].inode.i_cdev = p; + cdev_registered[number_cdev_registered].open = 0; + + number_cdev_registered++; + } else { + return -1; + } + } + + return return_value; +} + +void cdev_del(struct cdev *p) +{ + int i; + + for (i = 0; i < number_cdev_registered; i++) { + if (cdev_registered[i].cdevp == p) { + cdev_registered[i].cdevp = 0; + + return; + } + } +} diff --git a/ddverify/models/seq1/src/linux/fs/proc/generic.c b/ddverify/models/seq1/src/linux/fs/proc/generic.c new file mode 100644 index 000000000..d2d29e78b --- /dev/null +++ b/ddverify/models/seq1/src/linux/fs/proc/generic.c @@ -0,0 +1,7 @@ +#include + +// struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, +// struct proc_dir_entry *parent) + + +// void remove_proc_entry(const char *name, struct proc_dir_entry *parent) diff --git a/ddverify/models/seq1/src/linux/fs/read_write.c b/ddverify/models/seq1/src/linux/fs/read_write.c new file mode 100644 index 000000000..66bce0a93 --- /dev/null +++ b/ddverify/models/seq1/src/linux/fs/read_write.c @@ -0,0 +1,9 @@ +#include + +#define ESPIPE 29 + +loff_t no_llseek(struct file *file, loff_t offset, int origin) +{ + return -ESPIPE; +} + diff --git a/ddverify/models/seq1/src/linux/kernel/irq/manage.c b/ddverify/models/seq1/src/linux/kernel/irq/manage.c new file mode 100644 index 000000000..54df106a0 --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/irq/manage.c @@ -0,0 +1,21 @@ +#include +#include + +int request_irq(unsigned int irq, irq_handler_t handler, + unsigned long irqflags, const char * devname, void *dev_id) +{ + if (nondet_int()) { + registered_irq[irq].handler = handler; + registered_irq[irq].dev_id = dev_id; + + return 0; + } else { + return -1; + } +} + +void free_irq(unsigned int irq, void *dev_id) +{ + registered_irq[irq].handler = NULL; + registered_irq[irq].dev_id = NULL; +} diff --git a/ddverify/models/seq1/src/linux/kernel/mutex.c b/ddverify/models/seq1/src/linux/kernel/mutex.c new file mode 100644 index 000000000..d2cc26058 --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/mutex.c @@ -0,0 +1,35 @@ +#include +#include + +void mutex_init(struct mutex *lock) +{ + __CPROVER_HIDE: +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(!lock->locked, "Locked mutex must not be reinitialized"); +#endif + lock->locked = 0; + lock->init = 1; +} + +void mutex_lock(struct mutex *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(lock->init, "Mutex is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked mutex"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void mutex_unlock(struct mutex *lock) +{ + __CPROVER_HIDE: + assert_context_process(); +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(lock->locked, "Unlock a not locked mutex"); +#endif + lock->locked = 0; +} diff --git a/ddverify/models/seq1/src/linux/kernel/resource.c b/ddverify/models/seq1/src/linux/kernel/resource.c new file mode 100644 index 000000000..8734ef490 --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/resource.c @@ -0,0 +1,118 @@ +#include +#include +#include +#include + +int ddv_ioport_request_start; +int ddv_ioport_request_len; + +struct resource *request_region(unsigned long start, unsigned long len, const char *name) +{ + unsigned int i; + struct resource *resource = (struct resource*)malloc(sizeof(struct resource)); + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 1; + // } + ddv_ioport_request_start = start; + ddv_ioport_request_len = len; + + return resource; +} + +void release_region(unsigned long start, unsigned long len) +{ + unsigned int i = 0; + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 0; + // } + + ddv_ioport_request_start = 0; + ddv_ioport_request_len = 0; +} + +unsigned char inb(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +void outb(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned short inw(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +void outw(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned inl(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +void outl(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + + +unsigned char inb_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +void outb_p(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned short inw_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +void outw_p(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +unsigned inl_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +void outl_p(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} diff --git a/ddverify/models/seq1/src/linux/kernel/sched.c b/ddverify/models/seq1/src/linux/kernel/sched.c new file mode 100644 index 000000000..9a23084b2 --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/sched.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include +#include + +void schedule() +{ + assert_context_process(); +} + +long schedule_timeout(long timeout) +{ + assert_context_process(); + + return nondet_long(); +} diff --git a/ddverify/models/seq1/src/linux/kernel/semaphore.c b/ddverify/models/seq1/src/linux/kernel/semaphore.c new file mode 100644 index 000000000..7ea94e8fc --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/semaphore.c @@ -0,0 +1,86 @@ +#include +#include +#include + +// DDV: The count value is ignored because ddverify only supports binary semaphores! +void sema_init(struct semaphore *sem, int val) +{ + sem->init = 1; + sem->locked = 0; +} + +void init_MUTEX(struct semaphore * sem) +{ + sem->init = 1; + sem->locked = 0; +} + +void init_MUTEX_LOCKED(struct semaphore * sem) +{ + sem->init = 1; + sem->locked = 1; +} + +void down(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); + __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); +#endif + sem->locked = 1; + __CPROVER_atomic_end(); +} + +int down_interruptible(struct semaphore * sem) +{ + if (nondet_int()) { + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); + __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); +#endif + sem->locked = 1; + __CPROVER_atomic_end(); + + return 0; + } else { + return -1; + } +} + +int down_trylock(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); + +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); +#endif + + if (sem->locked == 0) { + sem->locked = 1; + return 0; + } else { + return 1; + } + + __CPROVER_atomic_end(); + + return 0; +} + +void up(struct semaphore * sem) +{ + __CPROVER_HIDE: + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->locked, "Unlock a not locked semaphore"); +#endif + sem->locked = 0; +} diff --git a/ddverify/models/seq1/src/linux/kernel/softirq.c b/ddverify/models/seq1/src/linux/kernel/softirq.c new file mode 100644 index 000000000..4a6c5e988 --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/softirq.c @@ -0,0 +1,38 @@ +#include +#include + +void tasklet_schedule(struct tasklet_struct *t) +{ + int i; + int next_free = -1; + +#ifdef DDV_ASSERT_TASKLET + __CPROVER_assert(t->init, "Tasklet is initialized!"); +#endif + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + if (tasklet_registered[i].tasklet == NULL) { + next_free = i; + } + if ((tasklet_registered[i].tasklet == t) && + (tasklet_registered[i].is_running == 0)) { + return; + } + } + + if (next_free == -1) { +// __CPROVER_assert(0, "Number of supported tasklets is sufficient"); + } + + tasklet_registered[next_free].tasklet = t; + tasklet_registered[next_free].is_running = 0; +} + +void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data) +{ + t->count = 0; + t->init = 0; + t->func = func; + t->data = data; +} diff --git a/ddverify/models/seq1/src/linux/kernel/spinlock.c b/ddverify/models/seq1/src/linux/kernel/spinlock.c new file mode 100644 index 000000000..b9f5d37fe --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/spinlock.c @@ -0,0 +1,93 @@ +#include +#include + +void spin_lock_init(spinlock_t * lock) +{ + lock->init = 1; + lock->locked = 0; +} + +void spin_lock(spinlock_t * lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_lock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_lock_bh(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +void spin_unlock(spinlock_t *lock) +{ + __CPROVER_HIDE: +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; +} + + +void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; +} + +void spin_unlock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; +} + +void spin_unlock_bh(spinlock_t *lock) +{ + __CPROVER_HIDE: +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; +} diff --git a/ddverify/models/seq1/src/linux/kernel/timer.c b/ddverify/models/seq1/src/linux/kernel/timer.c new file mode 100644 index 000000000..2018c2931 --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/timer.c @@ -0,0 +1,47 @@ +#include +#include + +void init_timer(struct timer_list * timer) +{ + if (number_timer_registered < MAX_TIMER_SUPPORT) { + timer->__ddv_active = 0; + timer->__ddv_init = 1; + timer_registered[number_timer_registered].timer = timer; + + number_timer_registered++; + } +} + + +void add_timer(struct timer_list *timer) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->__ddv_active = 1; +} + + +void add_timer_on(struct timer_list *timer, int cpu) +{ + // We do not care about the cpu number! + add_timer(timer); +} + + +int del_timer(struct timer_list * timer) +{ + timer->__ddv_active = 0; +} + + +int mod_timer(struct timer_list *timer, unsigned long expires) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->expires = expires; + timer->__ddv_active = 1; +} diff --git a/ddverify/models/seq1/src/linux/kernel/wait.c b/ddverify/models/seq1/src/linux/kernel/wait.c new file mode 100644 index 000000000..04822ab0b --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/wait.c @@ -0,0 +1,46 @@ +#include + +void init_waitqueue_head(wait_queue_head_t *q) +{ + q->init = 1; +} + +void wake_up(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void wake_up_all(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void wake_up_interruptible(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +void interruptible_sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} diff --git a/ddverify/models/seq1/src/linux/kernel/workqueue.c b/ddverify/models/seq1/src/linux/kernel/workqueue.c new file mode 100644 index 000000000..26d035768 --- /dev/null +++ b/ddverify/models/seq1/src/linux/kernel/workqueue.c @@ -0,0 +1,39 @@ +#include +#include +#include + +int schedule_work(struct work_struct *work) +{ + int i; + +#ifdef DDV_ASSERT_WORK_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(work->init, "Work queue is initalized"); +#endif + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + if (shared_workqueue[i] == work) { + return 0; + } + + if (shared_workqueue[i] == NULL) { + shared_workqueue[i] = work; + + return 1; + } + } + + + return -1; +} + +void call_shared_workqueue_functions() +{ + unsigned short i = nondet_ushort(); + __CPROVER_assume(i < MAX_WORKQUEUE_ELEMENTS_SUPPORT); + + if (shared_workqueue[i] != NULL) { + (*shared_workqueue[i]->func)(shared_workqueue[i]->data); + shared_workqueue[i] = NULL; + } +} diff --git a/ddverify/models/seq1/src/linux/mm/page_alloc.c b/ddverify/models/seq1/src/linux/mm/page_alloc.c new file mode 100644 index 000000000..40d236be0 --- /dev/null +++ b/ddverify/models/seq1/src/linux/mm/page_alloc.c @@ -0,0 +1,52 @@ +#include +#include +#include + +unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +unsigned long __get_free_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +unsigned long get_zeroed_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, + unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +struct page * alloc_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} diff --git a/ddverify/models/seq1/src/linux/mm/slab.c b/ddverify/models/seq1/src/linux/mm/slab.c new file mode 100644 index 000000000..7b21afa25 --- /dev/null +++ b/ddverify/models/seq1/src/linux/mm/slab.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +void * kmalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} + +void * kzalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} diff --git a/ddverify/models/seq1/src/linux/mm/vmalloc.c b/ddverify/models/seq1/src/linux/mm/vmalloc.c new file mode 100644 index 000000000..0edd579f7 --- /dev/null +++ b/ddverify/models/seq1/src/linux/mm/vmalloc.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +void * vmalloc(unsigned long size) +{ + return malloc(size); +} diff --git a/ddverify/models/seq1/src/linux/pci.c b/ddverify/models/seq1/src/linux/pci.c new file mode 100644 index 000000000..26d58cee1 --- /dev/null +++ b/ddverify/models/seq1/src/linux/pci.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include +#include + +int pci_enable_device(struct pci_dev *dev) +{ + int i; + + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + dev->resource[i].flags = IORESOURCE_IO; + dev->resource[i].start = nondet_uint(); + dev->resource[i].end = dev->resource[i].start + nondet_ushort(); + } +} + +struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) +{ + if (from == NULL) { + from = (struct pci_dev*)malloc(sizeof(struct pci_dev)); + } + + if (nondet_int()) { + from->vendor = nondet_ushort(); + from->device = nondet_ushort(); + from->irq = nondet_uint(); + __CPROVER_assume(from->irq < MAX_IRQ_SUPPORT); + + return from; + } else { + return NULL; + } +} + +int pci_register_driver(struct pci_driver *driver) +{ + if (nondet_int()) { + registered_pci_driver.pci_driver = driver; + registered_pci_driver.no_pci_device_id = sizeof(driver->id_table) / sizeof(struct pci_device_id); + registered_pci_driver.dev_initialized = 0; + + return 0; + } else { + return -1; + } +} + +void pci_unregister_driver(struct pci_driver *driver) +{ + registered_pci_driver.pci_driver = NULL; + registered_pci_driver.no_pci_device_id = 0; +} + +void pci_release_region(struct pci_dev *pdev, int bar) +{ + if (pci_resource_len(pdev, bar) == 0) + return; + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) + release_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) + release_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); +} + +int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) +{ + if (pci_resource_len(pdev, bar) == 0) + return 0; + + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) { + if (!request_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { + if (!request_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + + return 0; +} + + +void pci_release_regions(struct pci_dev *pdev) +{ + int i; + + for (i = 0; i < 6; i++) + pci_release_region(pdev, i); +} + + +int pci_request_regions(struct pci_dev *pdev, const char *res_name) +{ + int i; + + for (i = 0; i < 6; i++) + if(pci_request_region(pdev, i, res_name)) + goto err_out; + return 0; + + err_out: + while(--i >= 0) + pci_release_region(pdev, i); + + return -EBUSY; +} diff --git a/ddverify/readme.txt b/ddverify/readme.txt new file mode 100644 index 000000000..303538142 --- /dev/null +++ b/ddverify/readme.txt @@ -0,0 +1,35 @@ +This package contains a compiled version of DDVerify and Satabs. + +1. INSTALL +----------------------- +To install DDVerify the following steps must be done: +- set the environment variable DDV_PATH to this directory +- add the binary directory of DDVerify to the PATH. +- you need to install either Boppo or Cadence SMV. + +2. EXECUTE +----------------------- +Type "ddverify --help" to get more +information about ddverify. + + +3. COMPILE +----------------------- +To recompile DDVerify go to the bin/ directory of DDVerify and run: + + gcc ddverfiy.c -o ddverify + +4. RUN CASE STUDIES +----------------------- +The directory case_studies/ contains 31 device drivers that can be used with +DDVerify. Note that we are aware of many issues when trying to verify +the benchmarks with satabs. We offer this collection as it is for research +purpose. + +5. CONTACT INFORMATION +----------------------- +If you need more information about DDVerify or you have any comments, please +contact: + + nicolas.blanc@inf.ethz.ch + From e6712d65991d09d08e5cc1d85aa45319d693111b Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 11 Apr 2022 17:30:22 +0300 Subject: [PATCH 02/24] Import ddverify-2010-04-30 From http://www.cprover.org/ddverify/. --- ddverify/bin/ddverify.c | 61 ++++++++++--------- ddverify/bin/ddverify.h | 2 +- .../con1/src/linux/arch/i386/lib/usercopy.c | 12 ++-- ddverify/models/con1/src/linux/kernel/mutex.c | 6 +- .../models/con1/src/linux/kernel/resource.c | 29 +++++---- .../models/con1/src/linux/kernel/semaphore.c | 14 ++--- .../models/con1/src/linux/kernel/softirq.c | 4 +- .../models/con1/src/linux/kernel/spinlock.c | 19 +++--- ddverify/models/con1/src/linux/kernel/timer.c | 14 ++--- ddverify/models/con1/src/linux/kernel/wait.c | 12 ++-- .../models/con1/src/linux/kernel/workqueue.c | 2 +- .../models/con1/src/linux/mm/page_alloc.c | 14 ++--- ddverify/models/con1/src/linux/pci.c | 18 +++--- .../con2/src/linux/arch/i386/lib/usercopy.c | 12 ++-- ddverify/models/con2/src/linux/fs/char_dev.c | 20 +++--- ddverify/models/con2/src/linux/kernel/mutex.c | 7 +-- .../models/con2/src/linux/kernel/resource.c | 29 +++++---- .../models/con2/src/linux/kernel/semaphore.c | 14 ++--- .../models/con2/src/linux/kernel/softirq.c | 7 ++- .../models/con2/src/linux/kernel/spinlock.c | 19 +++--- ddverify/models/con2/src/linux/kernel/timer.c | 14 ++--- ddverify/models/con2/src/linux/kernel/wait.c | 12 ++-- .../models/con2/src/linux/kernel/workqueue.c | 4 +- .../models/con2/src/linux/mm/page_alloc.c | 14 ++--- ddverify/models/con2/src/linux/pci.c | 18 +++--- .../seq1/src/linux/arch/i386/lib/usercopy.c | 12 ++-- ddverify/models/seq1/src/linux/fs/char_dev.c | 21 +++---- ddverify/models/seq1/src/linux/kernel/mutex.c | 6 +- .../models/seq1/src/linux/kernel/resource.c | 29 +++++---- .../models/seq1/src/linux/kernel/semaphore.c | 14 ++--- .../models/seq1/src/linux/kernel/softirq.c | 7 ++- .../models/seq1/src/linux/kernel/spinlock.c | 19 +++--- ddverify/models/seq1/src/linux/kernel/timer.c | 14 ++--- ddverify/models/seq1/src/linux/kernel/wait.c | 12 ++-- .../models/seq1/src/linux/kernel/workqueue.c | 4 +- .../models/seq1/src/linux/mm/page_alloc.c | 14 ++--- ddverify/models/seq1/src/linux/pci.c | 18 +++--- ddverify/readme.txt | 17 ++++-- 38 files changed, 274 insertions(+), 290 deletions(-) diff --git a/ddverify/bin/ddverify.c b/ddverify/bin/ddverify.c index 483b8e351..12c87bed7 100644 --- a/ddverify/bin/ddverify.c +++ b/ddverify/bin/ddverify.c @@ -80,7 +80,7 @@ getline(char **lineptr, size_t *n, FILE *stream) void print_msg(char *msg) { - fprintf(stdout, msg); + fprintf(stdout, "%s", msg); fflush(stdout); } @@ -260,7 +260,7 @@ void write_cc_file() close(fh); fp = fopen(output_cc_file, "a"); - fprintf(fp, content); + fprintf(fp, "%s", content); fclose(fp); } else { fprintf(stderr, "Error: Could not create c file!\n"); @@ -361,7 +361,7 @@ void write_compile_script() close(fh); fp = fopen(output_compile_file, "a"); - fprintf(fp, script); + fprintf(fp, "%s", script); fclose(fp); } else { fprintf(stderr, "Error: Could not create compile script!\n"); @@ -382,14 +382,14 @@ void write_tool_script() strcat(script, (tool==SATABS)?"satabs":"cbmc"); strcat(script, " $* "); - if (!check_bounds) { - strcat(script, " --no-bounds-check "); + if (check_bounds) { + strcat(script, " --bounds-check "); } - if (!check_pointer) { - strcat(script, " --no-pointer-check "); + if (check_pointer) { + strcat(script, " --pointer-check "); } - if (!check_div_by_zero) { - strcat(script, " --no-div-by-zero-check "); + if (check_div_by_zero) { + strcat(script, " --div-by-zero-check "); } switch (word_width) { @@ -461,7 +461,7 @@ void write_tool_script() close(fh); fp = fopen(output_tool_file, "a"); - fprintf(fp, script); + fprintf(fp, "%s", script); fclose(fp); } else { fprintf(stderr, "Error: Could not create Satabs script!\n"); @@ -473,7 +473,7 @@ void read_output_file() { int ret, line_nr; size_t t = 0; - char *buffer = NULL; + char *buffer = NULL, *ptr; char **lineptr = &buffer; FILE *fp = fopen(".ddv_output_2", "r"); @@ -488,8 +488,9 @@ void read_output_file() while((ret = getline(lineptr, &t, fp)) > 0) { switch (line_nr % 6) { case 0: - claim[number_claims].number = atoi(buffer); - + claim[number_claims].claim_id = buffer; + ptr=strchr(buffer, '\n'); if(ptr!=NULL) *ptr=0; + ptr=strchr(buffer, '\r'); if(ptr!=NULL) *ptr=0; break; case 1: claim[number_claims].file = buffer; @@ -532,26 +533,26 @@ void prove_claims_satabs() char **lineptr = &buffer; for (i = 0; i < number_claims; i++) { - sprintf(tmp, "claim %d ", (i + 1)); + sprintf(tmp, "claim %d of %d ", (i + 1), number_claims); print_msg(tmp); if (strcmp(claim[i].claim, "TRUE") == 0) { printf("SUCCESSFULL 0 \n"); } else { - sprintf(cmd, "./ddv_satabs --claim %d > .claim_out_%d 2>&1", - claim[i].number, claim[i].number); + sprintf(cmd, "./ddv_satabs --claim %s > .claim_out_%s 2>&1", + claim[i].claim_id, claim[i].claim_id); ret = system(cmd); ret = WEXITSTATUS(ret); if(ret==0 || ret==10) { - sprintf(cmd, "awk -f %sawk/get_verification_result .claim_out_%d", - ddv_path, claim[i].number); + sprintf(cmd, "awk -f %sawk/get_verification_result .claim_out_%s", + ddv_path, claim[i].claim_id); system(cmd); } else if(ret==11) { print_msg("TOO_MANY_ITERATIONS\t"); - sprintf(cmd, "awk -f %sawk/get_too_many_iterations_result .claim_out_%d", - ddv_path, claim[i].number); + sprintf(cmd, "awk -f %sawk/get_too_many_iterations_result .claim_out_%s", + ddv_path, claim[i].claim_id); system(cmd); } else { print_msg("ERROR\n"); @@ -579,13 +580,13 @@ void prove_claims_cbmc() if (strcmp(claim[i].claim, "TRUE") == 0) { printf("SUCCESSFULL 0 \n"); } else { - sprintf(cmd, "./ddv_cbmc --claim %d > .claim_out_%d 2>&1", - claim[i].number, claim[i].number); + sprintf(cmd, "./ddv_cbmc --claim %s > .claim_out_%s 2>&1", + claim[i].claim_id, claim[i].claim_id); ret = system(cmd); ret = WEXITSTATUS(ret); if(ret==0 || ret==10) { - sprintf(cmd, "awk -f %sawk/get_verification_result .claim_out_%d", - ddv_path, claim[i].number); + sprintf(cmd, "awk -f %sawk/get_verification_result .claim_out_%s", + ddv_path, claim[i].claim_id); system(cmd); } else { @@ -601,14 +602,14 @@ void run_satabs() { char cmd[1000]; - print_msg("Run satabs .."); + print_msg("Running satabs .."); if (system("./ddv_satabs --show-claims > .ddv_output_1") == 0) { fprintf(stderr, "\nError: Could not start Satabs!\n"); exit(-1); } print_msg(".\n"); - print_msg("Parse satabs output .."); + print_msg("Parsing satabs output .."); sprintf(cmd, "awk -f %sawk/convert_satabs_output .ddv_output_1 > .ddv_output_2", ddv_path); system(cmd); print_msg(".\n"); @@ -624,14 +625,14 @@ void run_cbmc() { char cmd[1000]; - print_msg("Run CBMC .."); + print_msg("Running CBMC .."); if (system("./ddv_cbmc --show-claims > .ddv_output_1") != 0) { fprintf(stderr, "\nError: Could not start CBMC!\n"); exit(-1); } print_msg(".\n"); - print_msg("Parse CBMC output .."); + print_msg("Parsing CBMC output .."); sprintf(cmd, "awk -f %sawk/convert_satabs_output .ddv_output_1 > .ddv_output_2", ddv_path); system(cmd); print_msg(".\n"); @@ -838,7 +839,7 @@ void parse_file() if (strcmp(module_init, "") == 0) { strcpy(tmp, *lineptr); strncpy(module_init, &tmp[12], - strlen(tmp) - 12 - ((int)strlen(tmp) - ((int)strchr(tmp, ')') - (int)tmp))); + strlen(tmp) - 12 - (strlen(tmp) - (strchr(tmp, ')') - tmp))); } continue; @@ -850,7 +851,7 @@ void parse_file() if (strcmp(module_exit, "") == 0) { strcpy(tmp, *lineptr); strncpy(module_exit, &tmp[12], - strlen(tmp) - 12 - ((int)strlen(tmp) - ((int)strchr(tmp, ')') - (int)tmp))); + strlen(tmp) - 12 - (strlen(tmp) - (strchr(tmp, ')') - tmp))); } continue; diff --git a/ddverify/bin/ddverify.h b/ddverify/bin/ddverify.h index 21ec5303e..7be4170bf 100644 --- a/ddverify/bin/ddverify.h +++ b/ddverify/bin/ddverify.h @@ -141,7 +141,7 @@ tool_choice tool = SATABS; int cbmc_slicing = 1; struct claim { - unsigned int number; + char *claim_id; char *file; unsigned int line; char *text; diff --git a/ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c b/ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c index 06fc72517..f8ef11568 100644 --- a/ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c +++ b/ddverify/models/con1/src/linux/arch/i386/lib/usercopy.c @@ -2,7 +2,7 @@ #include #include -int __get_user(int size, void *ptr) +inline int __get_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -10,7 +10,7 @@ int __get_user(int size, void *ptr) return nondet_int(); } -int get_user(int size, void *ptr) +inline int get_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -18,7 +18,7 @@ int get_user(int size, void *ptr) return nondet_int(); } -int __put_user(int size, void *ptr) +inline int __put_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -26,7 +26,7 @@ int __put_user(int size, void *ptr) return nondet_int(); } -int put_user(int size, void *ptr) +inline int put_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -34,7 +34,7 @@ int put_user(int size, void *ptr) return nondet_int(); } -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) { __CPROVER_HIDE: assert_context_process(); @@ -42,7 +42,7 @@ unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) return nondet_ulong(); } -unsigned long copy_from_user(void *to, void __user *from, unsigned long n) +inline unsigned long copy_from_user(void *to, void __user *from, unsigned long n) { __CPROVER_HIDE: assert_context_process(); diff --git a/ddverify/models/con1/src/linux/kernel/mutex.c b/ddverify/models/con1/src/linux/kernel/mutex.c index 9254af9d1..345196152 100644 --- a/ddverify/models/con1/src/linux/kernel/mutex.c +++ b/ddverify/models/con1/src/linux/kernel/mutex.c @@ -1,7 +1,7 @@ #include #include -void mutex_init(struct mutex *lock) +inline void mutex_init(struct mutex *lock) { __CPROVER_HIDE: #ifdef DDV_ASSERT_MUTEX @@ -11,7 +11,7 @@ void mutex_init(struct mutex *lock) lock->init = 1; } -void mutex_lock(struct mutex *lock) +inline void mutex_lock(struct mutex *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -24,7 +24,7 @@ void mutex_lock(struct mutex *lock) __CPROVER_atomic_end(); } -void mutex_unlock(struct mutex *lock) +inline void mutex_unlock(struct mutex *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); diff --git a/ddverify/models/con1/src/linux/kernel/resource.c b/ddverify/models/con1/src/linux/kernel/resource.c index c187db976..4818f4e47 100644 --- a/ddverify/models/con1/src/linux/kernel/resource.c +++ b/ddverify/models/con1/src/linux/kernel/resource.c @@ -3,7 +3,7 @@ #include #include -struct resource *request_region(unsigned long start, unsigned long len, const char *name) +inline struct resource *request_region(unsigned long start, unsigned long len, const char *name) { unsigned int i; struct resource *resource = (struct resource*)malloc(sizeof(struct resource)); @@ -17,7 +17,7 @@ struct resource *request_region(unsigned long start, unsigned long len, const ch return resource; } -void release_region(unsigned long start, unsigned long len) +inline void release_region(unsigned long start, unsigned long len) { unsigned int i = 0; @@ -29,7 +29,7 @@ void release_region(unsigned long start, unsigned long len) ddv_ioport_request_len = 0; } -unsigned char inb(unsigned int port) +inline unsigned char inb(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -37,13 +37,13 @@ unsigned char inb(unsigned int port) return nondet_uchar(); } -void outb(unsigned char byte, unsigned int port) +inline void outb(unsigned char byte, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned short inw(unsigned int port) +inline unsigned short inw(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -51,13 +51,13 @@ unsigned short inw(unsigned int port) return nondet_ushort(); } -void outw(unsigned short word, unsigned int port) +inline void outw(unsigned short word, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned inl(unsigned int port) +inline unsigned inl(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -65,14 +65,13 @@ unsigned inl(unsigned int port) return nondet_unsigned(); } -void outl(unsigned doubleword, unsigned int port) +inline void outl(unsigned doubleword, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } - -unsigned char inb_p(unsigned int port) +inline unsigned char inb_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -80,13 +79,13 @@ unsigned char inb_p(unsigned int port) return nondet_uchar(); } -void outb_p(unsigned char byte, unsigned int port) +inline void outb_p(unsigned char byte, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned short inw_p(unsigned int port) +inline unsigned short inw_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -94,13 +93,13 @@ unsigned short inw_p(unsigned int port) return nondet_ushort(); } -void outw_p(unsigned short word, unsigned int port) +inline void outw_p(unsigned short word, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned inl_p(unsigned int port) +inline unsigned inl_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -108,7 +107,7 @@ unsigned inl_p(unsigned int port) return nondet_unsigned(); } -void outl_p(unsigned doubleword, unsigned int port) +inline void outl_p(unsigned doubleword, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); diff --git a/ddverify/models/con1/src/linux/kernel/semaphore.c b/ddverify/models/con1/src/linux/kernel/semaphore.c index 7ea94e8fc..d14ca0398 100644 --- a/ddverify/models/con1/src/linux/kernel/semaphore.c +++ b/ddverify/models/con1/src/linux/kernel/semaphore.c @@ -3,25 +3,25 @@ #include // DDV: The count value is ignored because ddverify only supports binary semaphores! -void sema_init(struct semaphore *sem, int val) +inline void sema_init(struct semaphore *sem, int val) { sem->init = 1; sem->locked = 0; } -void init_MUTEX(struct semaphore * sem) +inline void init_MUTEX(struct semaphore * sem) { sem->init = 1; sem->locked = 0; } -void init_MUTEX_LOCKED(struct semaphore * sem) +inline void init_MUTEX_LOCKED(struct semaphore * sem) { sem->init = 1; sem->locked = 1; } -void down(struct semaphore * sem) +inline void down(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -34,7 +34,7 @@ void down(struct semaphore * sem) __CPROVER_atomic_end(); } -int down_interruptible(struct semaphore * sem) +inline int down_interruptible(struct semaphore * sem) { if (nondet_int()) { __CPROVER_HIDE: @@ -53,7 +53,7 @@ int down_interruptible(struct semaphore * sem) } } -int down_trylock(struct semaphore * sem) +inline int down_trylock(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -75,7 +75,7 @@ int down_trylock(struct semaphore * sem) return 0; } -void up(struct semaphore * sem) +inline void up(struct semaphore * sem) { __CPROVER_HIDE: assert_context_process(); diff --git a/ddverify/models/con1/src/linux/kernel/softirq.c b/ddverify/models/con1/src/linux/kernel/softirq.c index 4a6c5e988..a65be7976 100644 --- a/ddverify/models/con1/src/linux/kernel/softirq.c +++ b/ddverify/models/con1/src/linux/kernel/softirq.c @@ -1,7 +1,7 @@ #include #include -void tasklet_schedule(struct tasklet_struct *t) +inline void tasklet_schedule(struct tasklet_struct *t) { int i; int next_free = -1; @@ -28,7 +28,7 @@ void tasklet_schedule(struct tasklet_struct *t) tasklet_registered[next_free].is_running = 0; } -void tasklet_init(struct tasklet_struct *t, +inline void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data) { t->count = 0; diff --git a/ddverify/models/con1/src/linux/kernel/spinlock.c b/ddverify/models/con1/src/linux/kernel/spinlock.c index 34b709927..44eaec19b 100644 --- a/ddverify/models/con1/src/linux/kernel/spinlock.c +++ b/ddverify/models/con1/src/linux/kernel/spinlock.c @@ -1,13 +1,13 @@ #include #include -void spin_lock_init(spinlock_t * lock) +inline void spin_lock_init(spinlock_t * lock) { lock->init = 1; lock->locked = 0; } -void spin_lock(spinlock_t * lock) +inline void spin_lock(spinlock_t * lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -19,7 +19,7 @@ void spin_lock(spinlock_t * lock) __CPROVER_atomic_end(); } -void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) +inline void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -31,7 +31,7 @@ void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) __CPROVER_atomic_end(); } -void spin_lock_irq(spinlock_t *lock) +inline void spin_lock_irq(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -43,7 +43,7 @@ void spin_lock_irq(spinlock_t *lock) __CPROVER_atomic_end(); } -void spin_lock_bh(spinlock_t *lock) +inline void spin_lock_bh(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -55,7 +55,7 @@ void spin_lock_bh(spinlock_t *lock) __CPROVER_atomic_end(); } -void spin_unlock(spinlock_t *lock) +inline void spin_unlock(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -65,8 +65,7 @@ void spin_unlock(spinlock_t *lock) lock->locked = 0; } - -void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) +inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -77,7 +76,7 @@ void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) __CPROVER_atomic_end(); } -void spin_unlock_irq(spinlock_t *lock) +inline void spin_unlock_irq(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -88,7 +87,7 @@ void spin_unlock_irq(spinlock_t *lock) __CPROVER_atomic_end(); } -void spin_unlock_bh(spinlock_t *lock) +inline void spin_unlock_bh(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); diff --git a/ddverify/models/con1/src/linux/kernel/timer.c b/ddverify/models/con1/src/linux/kernel/timer.c index 2018c2931..fd2f92f95 100644 --- a/ddverify/models/con1/src/linux/kernel/timer.c +++ b/ddverify/models/con1/src/linux/kernel/timer.c @@ -1,7 +1,7 @@ #include #include -void init_timer(struct timer_list * timer) +inline void init_timer(struct timer_list * timer) { if (number_timer_registered < MAX_TIMER_SUPPORT) { timer->__ddv_active = 0; @@ -12,8 +12,7 @@ void init_timer(struct timer_list * timer) } } - -void add_timer(struct timer_list *timer) +inline void add_timer(struct timer_list *timer) { #ifdef DDV_ASSERT_TIMER __CPROVER_HIDE: @@ -22,21 +21,18 @@ void add_timer(struct timer_list *timer) timer->__ddv_active = 1; } - -void add_timer_on(struct timer_list *timer, int cpu) +inline void add_timer_on(struct timer_list *timer, int cpu) { // We do not care about the cpu number! add_timer(timer); } - -int del_timer(struct timer_list * timer) +inline int del_timer(struct timer_list * timer) { timer->__ddv_active = 0; } - -int mod_timer(struct timer_list *timer, unsigned long expires) +inline int mod_timer(struct timer_list *timer, unsigned long expires) { #ifdef DDV_ASSERT_TIMER __CPROVER_HIDE: diff --git a/ddverify/models/con1/src/linux/kernel/wait.c b/ddverify/models/con1/src/linux/kernel/wait.c index 04822ab0b..cc986589f 100644 --- a/ddverify/models/con1/src/linux/kernel/wait.c +++ b/ddverify/models/con1/src/linux/kernel/wait.c @@ -1,11 +1,11 @@ #include -void init_waitqueue_head(wait_queue_head_t *q) +inline void init_waitqueue_head(wait_queue_head_t *q) { q->init = 1; } -void wake_up(wait_queue_head_t *q) +inline void wake_up(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -13,7 +13,7 @@ void wake_up(wait_queue_head_t *q) #endif } -void wake_up_all(wait_queue_head_t *q) +inline void wake_up_all(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -21,7 +21,7 @@ void wake_up_all(wait_queue_head_t *q) #endif } -void wake_up_interruptible(wait_queue_head_t *q) +inline void wake_up_interruptible(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -29,7 +29,7 @@ void wake_up_interruptible(wait_queue_head_t *q) #endif } -void sleep_on(wait_queue_head_t *q) +inline void sleep_on(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -37,7 +37,7 @@ void sleep_on(wait_queue_head_t *q) #endif } -void interruptible_sleep_on(wait_queue_head_t *q) +inline void interruptible_sleep_on(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: diff --git a/ddverify/models/con1/src/linux/kernel/workqueue.c b/ddverify/models/con1/src/linux/kernel/workqueue.c index 26d035768..aae5e6910 100644 --- a/ddverify/models/con1/src/linux/kernel/workqueue.c +++ b/ddverify/models/con1/src/linux/kernel/workqueue.c @@ -2,7 +2,7 @@ #include #include -int schedule_work(struct work_struct *work) +inline int schedule_work(struct work_struct *work) { int i; diff --git a/ddverify/models/con1/src/linux/mm/page_alloc.c b/ddverify/models/con1/src/linux/mm/page_alloc.c index 40d236be0..4d1ed67c9 100644 --- a/ddverify/models/con1/src/linux/mm/page_alloc.c +++ b/ddverify/models/con1/src/linux/mm/page_alloc.c @@ -2,7 +2,7 @@ #include #include -unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) +inline unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -10,7 +10,7 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) } } -unsigned long __get_free_page(gfp_t gfp_mask) +inline unsigned long __get_free_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -18,7 +18,7 @@ unsigned long __get_free_page(gfp_t gfp_mask) } } -unsigned long get_zeroed_page(gfp_t gfp_mask) +inline unsigned long get_zeroed_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -26,8 +26,8 @@ unsigned long get_zeroed_page(gfp_t gfp_mask) } } -static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, - unsigned int order) +inline static struct page *alloc_pages_node( + int nid, gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -35,7 +35,7 @@ static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, } } -struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) +inline struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -43,7 +43,7 @@ struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) } } -struct page * alloc_page(gfp_t gfp_mask) +inline struct page * alloc_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { diff --git a/ddverify/models/con1/src/linux/pci.c b/ddverify/models/con1/src/linux/pci.c index 26d58cee1..8853d1e3e 100644 --- a/ddverify/models/con1/src/linux/pci.c +++ b/ddverify/models/con1/src/linux/pci.c @@ -5,7 +5,7 @@ #include #include -int pci_enable_device(struct pci_dev *dev) +inline int pci_enable_device(struct pci_dev *dev) { int i; @@ -16,7 +16,7 @@ int pci_enable_device(struct pci_dev *dev) } } -struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) +inline struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) { if (from == NULL) { from = (struct pci_dev*)malloc(sizeof(struct pci_dev)); @@ -34,7 +34,7 @@ struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) } } -int pci_register_driver(struct pci_driver *driver) +inline int pci_register_driver(struct pci_driver *driver) { if (nondet_int()) { registered_pci_driver.pci_driver = driver; @@ -47,13 +47,13 @@ int pci_register_driver(struct pci_driver *driver) } } -void pci_unregister_driver(struct pci_driver *driver) +inline void pci_unregister_driver(struct pci_driver *driver) { registered_pci_driver.pci_driver = NULL; registered_pci_driver.no_pci_device_id = 0; } -void pci_release_region(struct pci_dev *pdev, int bar) +inline void pci_release_region(struct pci_dev *pdev, int bar) { if (pci_resource_len(pdev, bar) == 0) return; @@ -65,7 +65,7 @@ void pci_release_region(struct pci_dev *pdev, int bar) pci_resource_len(pdev, bar)); } -int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) +inline int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) { if (pci_resource_len(pdev, bar) == 0) return 0; @@ -84,8 +84,7 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) return 0; } - -void pci_release_regions(struct pci_dev *pdev) +inline void pci_release_regions(struct pci_dev *pdev) { int i; @@ -93,8 +92,7 @@ void pci_release_regions(struct pci_dev *pdev) pci_release_region(pdev, i); } - -int pci_request_regions(struct pci_dev *pdev, const char *res_name) +inline int pci_request_regions(struct pci_dev *pdev, const char *res_name) { int i; diff --git a/ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c b/ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c index 06fc72517..f8ef11568 100644 --- a/ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c +++ b/ddverify/models/con2/src/linux/arch/i386/lib/usercopy.c @@ -2,7 +2,7 @@ #include #include -int __get_user(int size, void *ptr) +inline int __get_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -10,7 +10,7 @@ int __get_user(int size, void *ptr) return nondet_int(); } -int get_user(int size, void *ptr) +inline int get_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -18,7 +18,7 @@ int get_user(int size, void *ptr) return nondet_int(); } -int __put_user(int size, void *ptr) +inline int __put_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -26,7 +26,7 @@ int __put_user(int size, void *ptr) return nondet_int(); } -int put_user(int size, void *ptr) +inline int put_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -34,7 +34,7 @@ int put_user(int size, void *ptr) return nondet_int(); } -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) { __CPROVER_HIDE: assert_context_process(); @@ -42,7 +42,7 @@ unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) return nondet_ulong(); } -unsigned long copy_from_user(void *to, void __user *from, unsigned long n) +inline unsigned long copy_from_user(void *to, void __user *from, unsigned long n) { __CPROVER_HIDE: assert_context_process(); diff --git a/ddverify/models/con2/src/linux/fs/char_dev.c b/ddverify/models/con2/src/linux/fs/char_dev.c index 8a0a278bf..e23bebfc5 100644 --- a/ddverify/models/con2/src/linux/fs/char_dev.c +++ b/ddverify/models/con2/src/linux/fs/char_dev.c @@ -6,7 +6,7 @@ #include #include -int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) +inline int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) { int major; int return_value = nondet_int(); @@ -20,7 +20,7 @@ int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const ch return return_value; } -int register_chrdev_region(dev_t from, unsigned count, const char *name) +inline int register_chrdev_region(dev_t from, unsigned count, const char *name) { int return_value = nondet_int(); __CPROVER_assume((return_value == 0) || (return_value == -1)); @@ -30,9 +30,8 @@ int register_chrdev_region(dev_t from, unsigned count, const char *name) //void unregister_chrdev_region(dev_t, unsigned) {} - -int register_chrdev(unsigned int major, const char *name, - struct file_operations *fops) +inline int register_chrdev( + unsigned int major, const char *name, struct file_operations *fops) { struct cdev *cdev; int err; @@ -53,25 +52,24 @@ int register_chrdev(unsigned int major, const char *name, return major; } - -int unregister_chrdev(unsigned int major, const char *name) +inline int unregister_chrdev(unsigned int major, const char *name) { return 0; } -struct cdev *cdev_alloc(void) +inline struct cdev *cdev_alloc(void) { if (fixed_cdev_used < MAX_CDEV_SUPPORT) { return &fixed_cdev[fixed_cdev_used++]; } } -void cdev_init(struct cdev *cdev, struct file_operations *fops) +inline void cdev_init(struct cdev *cdev, struct file_operations *fops) { cdev->ops = fops; } -int cdev_add(struct cdev *p, dev_t dev, unsigned count) +inline int cdev_add(struct cdev *p, dev_t dev, unsigned count) { p->dev = dev; p->count = count; @@ -96,7 +94,7 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count) return return_value; } -void cdev_del(struct cdev *p) +inline void cdev_del(struct cdev *p) { int i; diff --git a/ddverify/models/con2/src/linux/kernel/mutex.c b/ddverify/models/con2/src/linux/kernel/mutex.c index d6f77a7df..26eafef57 100644 --- a/ddverify/models/con2/src/linux/kernel/mutex.c +++ b/ddverify/models/con2/src/linux/kernel/mutex.c @@ -1,7 +1,7 @@ #include #include -void mutex_init(struct mutex *lock) +inline void mutex_init(struct mutex *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -13,8 +13,7 @@ void mutex_init(struct mutex *lock) __CPROVER_atomic_end(); } - -void mutex_lock(struct mutex *lock) +inline void mutex_lock(struct mutex *lock) { __CPROVER_HIDE: @@ -39,7 +38,7 @@ void mutex_lock(struct mutex *lock) while(1); } -void mutex_unlock(struct mutex *lock) +inline void mutex_unlock(struct mutex *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); diff --git a/ddverify/models/con2/src/linux/kernel/resource.c b/ddverify/models/con2/src/linux/kernel/resource.c index c187db976..4818f4e47 100644 --- a/ddverify/models/con2/src/linux/kernel/resource.c +++ b/ddverify/models/con2/src/linux/kernel/resource.c @@ -3,7 +3,7 @@ #include #include -struct resource *request_region(unsigned long start, unsigned long len, const char *name) +inline struct resource *request_region(unsigned long start, unsigned long len, const char *name) { unsigned int i; struct resource *resource = (struct resource*)malloc(sizeof(struct resource)); @@ -17,7 +17,7 @@ struct resource *request_region(unsigned long start, unsigned long len, const ch return resource; } -void release_region(unsigned long start, unsigned long len) +inline void release_region(unsigned long start, unsigned long len) { unsigned int i = 0; @@ -29,7 +29,7 @@ void release_region(unsigned long start, unsigned long len) ddv_ioport_request_len = 0; } -unsigned char inb(unsigned int port) +inline unsigned char inb(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -37,13 +37,13 @@ unsigned char inb(unsigned int port) return nondet_uchar(); } -void outb(unsigned char byte, unsigned int port) +inline void outb(unsigned char byte, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned short inw(unsigned int port) +inline unsigned short inw(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -51,13 +51,13 @@ unsigned short inw(unsigned int port) return nondet_ushort(); } -void outw(unsigned short word, unsigned int port) +inline void outw(unsigned short word, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned inl(unsigned int port) +inline unsigned inl(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -65,14 +65,13 @@ unsigned inl(unsigned int port) return nondet_unsigned(); } -void outl(unsigned doubleword, unsigned int port) +inline void outl(unsigned doubleword, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } - -unsigned char inb_p(unsigned int port) +inline unsigned char inb_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -80,13 +79,13 @@ unsigned char inb_p(unsigned int port) return nondet_uchar(); } -void outb_p(unsigned char byte, unsigned int port) +inline void outb_p(unsigned char byte, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned short inw_p(unsigned int port) +inline unsigned short inw_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -94,13 +93,13 @@ unsigned short inw_p(unsigned int port) return nondet_ushort(); } -void outw_p(unsigned short word, unsigned int port) +inline void outw_p(unsigned short word, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned inl_p(unsigned int port) +inline unsigned inl_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -108,7 +107,7 @@ unsigned inl_p(unsigned int port) return nondet_unsigned(); } -void outl_p(unsigned doubleword, unsigned int port) +inline void outl_p(unsigned doubleword, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); diff --git a/ddverify/models/con2/src/linux/kernel/semaphore.c b/ddverify/models/con2/src/linux/kernel/semaphore.c index 64b939542..c48711d44 100644 --- a/ddverify/models/con2/src/linux/kernel/semaphore.c +++ b/ddverify/models/con2/src/linux/kernel/semaphore.c @@ -3,7 +3,7 @@ #include // DDV: The count value is ignored because ddverify only supports binary semaphores! -void sema_init(struct semaphore *sem, int val) +inline void sema_init(struct semaphore *sem, int val) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -12,7 +12,7 @@ void sema_init(struct semaphore *sem, int val) __CPROVER_atomic_end(); } -void init_MUTEX(struct semaphore * sem) +inline void init_MUTEX(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -21,7 +21,7 @@ void init_MUTEX(struct semaphore * sem) __CPROVER_atomic_end(); } -void init_MUTEX_LOCKED(struct semaphore * sem) +inline void init_MUTEX_LOCKED(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -30,7 +30,7 @@ void init_MUTEX_LOCKED(struct semaphore * sem) __CPROVER_atomic_end(); } -void down(struct semaphore * sem) +inline void down(struct semaphore * sem) { __CPROVER_HIDE: @@ -55,7 +55,7 @@ void down(struct semaphore * sem) while(1); } -int down_interruptible(struct semaphore * sem) +inline int down_interruptible(struct semaphore * sem) { __CPROVER_HIDE: @@ -85,7 +85,7 @@ int down_interruptible(struct semaphore * sem) while(1); } -int down_trylock(struct semaphore * sem) +inline int down_trylock(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -103,7 +103,7 @@ int down_trylock(struct semaphore * sem) return 0; } -void up(struct semaphore * sem) +inline void up(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); diff --git a/ddverify/models/con2/src/linux/kernel/softirq.c b/ddverify/models/con2/src/linux/kernel/softirq.c index bd7bd6f8a..f9d29910e 100644 --- a/ddverify/models/con2/src/linux/kernel/softirq.c +++ b/ddverify/models/con2/src/linux/kernel/softirq.c @@ -1,7 +1,7 @@ #include #include -void tasklet_schedule(struct tasklet_struct *t) +inline void tasklet_schedule(struct tasklet_struct *t) { int i; int next_free = -1; @@ -29,8 +29,9 @@ void tasklet_schedule(struct tasklet_struct *t) tasklet_registered[next_free].is_running = 0; } -void tasklet_init(struct tasklet_struct *t, - void (*func)(unsigned long), unsigned long data) +inline void tasklet_init( + struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data) { t->count = 0; t->init = 0; diff --git a/ddverify/models/con2/src/linux/kernel/spinlock.c b/ddverify/models/con2/src/linux/kernel/spinlock.c index 6024267bf..628d013a8 100644 --- a/ddverify/models/con2/src/linux/kernel/spinlock.c +++ b/ddverify/models/con2/src/linux/kernel/spinlock.c @@ -1,13 +1,13 @@ #include #include -void spin_lock_init(spinlock_t * lock) +inline void spin_lock_init(spinlock_t * lock) { lock->init = 1; lock->locked = 0; } -void spin_lock(spinlock_t * lock) +inline void spin_lock(spinlock_t * lock) { __CPROVER_HIDE: @@ -31,7 +31,7 @@ void spin_lock(spinlock_t * lock) while(1); } -void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) +inline void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) { __CPROVER_HIDE: @@ -55,7 +55,7 @@ void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) while(1); } -void spin_lock_irq(spinlock_t *lock) +inline void spin_lock_irq(spinlock_t *lock) { __CPROVER_HIDE: @@ -79,7 +79,7 @@ void spin_lock_irq(spinlock_t *lock) while(1); } -void spin_lock_bh(spinlock_t *lock) +inline void spin_lock_bh(spinlock_t *lock) { __CPROVER_HIDE: @@ -103,7 +103,7 @@ void spin_lock_bh(spinlock_t *lock) while(1); } -void spin_unlock(spinlock_t *lock) +inline void spin_unlock(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -114,8 +114,7 @@ void spin_unlock(spinlock_t *lock) __CPROVER_atomic_end(); } - -void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) +inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -126,7 +125,7 @@ void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) __CPROVER_atomic_end(); } -void spin_unlock_irq(spinlock_t *lock) +inline void spin_unlock_irq(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -137,7 +136,7 @@ void spin_unlock_irq(spinlock_t *lock) __CPROVER_atomic_end(); } -void spin_unlock_bh(spinlock_t *lock) +inline void spin_unlock_bh(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); diff --git a/ddverify/models/con2/src/linux/kernel/timer.c b/ddverify/models/con2/src/linux/kernel/timer.c index 2018c2931..fd2f92f95 100644 --- a/ddverify/models/con2/src/linux/kernel/timer.c +++ b/ddverify/models/con2/src/linux/kernel/timer.c @@ -1,7 +1,7 @@ #include #include -void init_timer(struct timer_list * timer) +inline void init_timer(struct timer_list * timer) { if (number_timer_registered < MAX_TIMER_SUPPORT) { timer->__ddv_active = 0; @@ -12,8 +12,7 @@ void init_timer(struct timer_list * timer) } } - -void add_timer(struct timer_list *timer) +inline void add_timer(struct timer_list *timer) { #ifdef DDV_ASSERT_TIMER __CPROVER_HIDE: @@ -22,21 +21,18 @@ void add_timer(struct timer_list *timer) timer->__ddv_active = 1; } - -void add_timer_on(struct timer_list *timer, int cpu) +inline void add_timer_on(struct timer_list *timer, int cpu) { // We do not care about the cpu number! add_timer(timer); } - -int del_timer(struct timer_list * timer) +inline int del_timer(struct timer_list * timer) { timer->__ddv_active = 0; } - -int mod_timer(struct timer_list *timer, unsigned long expires) +inline int mod_timer(struct timer_list *timer, unsigned long expires) { #ifdef DDV_ASSERT_TIMER __CPROVER_HIDE: diff --git a/ddverify/models/con2/src/linux/kernel/wait.c b/ddverify/models/con2/src/linux/kernel/wait.c index 04822ab0b..cc986589f 100644 --- a/ddverify/models/con2/src/linux/kernel/wait.c +++ b/ddverify/models/con2/src/linux/kernel/wait.c @@ -1,11 +1,11 @@ #include -void init_waitqueue_head(wait_queue_head_t *q) +inline void init_waitqueue_head(wait_queue_head_t *q) { q->init = 1; } -void wake_up(wait_queue_head_t *q) +inline void wake_up(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -13,7 +13,7 @@ void wake_up(wait_queue_head_t *q) #endif } -void wake_up_all(wait_queue_head_t *q) +inline void wake_up_all(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -21,7 +21,7 @@ void wake_up_all(wait_queue_head_t *q) #endif } -void wake_up_interruptible(wait_queue_head_t *q) +inline void wake_up_interruptible(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -29,7 +29,7 @@ void wake_up_interruptible(wait_queue_head_t *q) #endif } -void sleep_on(wait_queue_head_t *q) +inline void sleep_on(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -37,7 +37,7 @@ void sleep_on(wait_queue_head_t *q) #endif } -void interruptible_sleep_on(wait_queue_head_t *q) +inline void interruptible_sleep_on(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: diff --git a/ddverify/models/con2/src/linux/kernel/workqueue.c b/ddverify/models/con2/src/linux/kernel/workqueue.c index 26d035768..90cf4b93f 100644 --- a/ddverify/models/con2/src/linux/kernel/workqueue.c +++ b/ddverify/models/con2/src/linux/kernel/workqueue.c @@ -2,7 +2,7 @@ #include #include -int schedule_work(struct work_struct *work) +inline int schedule_work(struct work_struct *work) { int i; @@ -27,7 +27,7 @@ int schedule_work(struct work_struct *work) return -1; } -void call_shared_workqueue_functions() +inline void call_shared_workqueue_functions() { unsigned short i = nondet_ushort(); __CPROVER_assume(i < MAX_WORKQUEUE_ELEMENTS_SUPPORT); diff --git a/ddverify/models/con2/src/linux/mm/page_alloc.c b/ddverify/models/con2/src/linux/mm/page_alloc.c index 40d236be0..4d1ed67c9 100644 --- a/ddverify/models/con2/src/linux/mm/page_alloc.c +++ b/ddverify/models/con2/src/linux/mm/page_alloc.c @@ -2,7 +2,7 @@ #include #include -unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) +inline unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -10,7 +10,7 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) } } -unsigned long __get_free_page(gfp_t gfp_mask) +inline unsigned long __get_free_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -18,7 +18,7 @@ unsigned long __get_free_page(gfp_t gfp_mask) } } -unsigned long get_zeroed_page(gfp_t gfp_mask) +inline unsigned long get_zeroed_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -26,8 +26,8 @@ unsigned long get_zeroed_page(gfp_t gfp_mask) } } -static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, - unsigned int order) +inline static struct page *alloc_pages_node( + int nid, gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -35,7 +35,7 @@ static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, } } -struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) +inline struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -43,7 +43,7 @@ struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) } } -struct page * alloc_page(gfp_t gfp_mask) +inline struct page * alloc_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { diff --git a/ddverify/models/con2/src/linux/pci.c b/ddverify/models/con2/src/linux/pci.c index 26d58cee1..8853d1e3e 100644 --- a/ddverify/models/con2/src/linux/pci.c +++ b/ddverify/models/con2/src/linux/pci.c @@ -5,7 +5,7 @@ #include #include -int pci_enable_device(struct pci_dev *dev) +inline int pci_enable_device(struct pci_dev *dev) { int i; @@ -16,7 +16,7 @@ int pci_enable_device(struct pci_dev *dev) } } -struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) +inline struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) { if (from == NULL) { from = (struct pci_dev*)malloc(sizeof(struct pci_dev)); @@ -34,7 +34,7 @@ struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) } } -int pci_register_driver(struct pci_driver *driver) +inline int pci_register_driver(struct pci_driver *driver) { if (nondet_int()) { registered_pci_driver.pci_driver = driver; @@ -47,13 +47,13 @@ int pci_register_driver(struct pci_driver *driver) } } -void pci_unregister_driver(struct pci_driver *driver) +inline void pci_unregister_driver(struct pci_driver *driver) { registered_pci_driver.pci_driver = NULL; registered_pci_driver.no_pci_device_id = 0; } -void pci_release_region(struct pci_dev *pdev, int bar) +inline void pci_release_region(struct pci_dev *pdev, int bar) { if (pci_resource_len(pdev, bar) == 0) return; @@ -65,7 +65,7 @@ void pci_release_region(struct pci_dev *pdev, int bar) pci_resource_len(pdev, bar)); } -int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) +inline int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) { if (pci_resource_len(pdev, bar) == 0) return 0; @@ -84,8 +84,7 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) return 0; } - -void pci_release_regions(struct pci_dev *pdev) +inline void pci_release_regions(struct pci_dev *pdev) { int i; @@ -93,8 +92,7 @@ void pci_release_regions(struct pci_dev *pdev) pci_release_region(pdev, i); } - -int pci_request_regions(struct pci_dev *pdev, const char *res_name) +inline int pci_request_regions(struct pci_dev *pdev, const char *res_name) { int i; diff --git a/ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c b/ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c index 06fc72517..f8ef11568 100644 --- a/ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c +++ b/ddverify/models/seq1/src/linux/arch/i386/lib/usercopy.c @@ -2,7 +2,7 @@ #include #include -int __get_user(int size, void *ptr) +inline int __get_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -10,7 +10,7 @@ int __get_user(int size, void *ptr) return nondet_int(); } -int get_user(int size, void *ptr) +inline int get_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -18,7 +18,7 @@ int get_user(int size, void *ptr) return nondet_int(); } -int __put_user(int size, void *ptr) +inline int __put_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -26,7 +26,7 @@ int __put_user(int size, void *ptr) return nondet_int(); } -int put_user(int size, void *ptr) +inline int put_user(int size, void *ptr) { __CPROVER_HIDE: assert_context_process(); @@ -34,7 +34,7 @@ int put_user(int size, void *ptr) return nondet_int(); } -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) { __CPROVER_HIDE: assert_context_process(); @@ -42,7 +42,7 @@ unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) return nondet_ulong(); } -unsigned long copy_from_user(void *to, void __user *from, unsigned long n) +inline unsigned long copy_from_user(void *to, void __user *from, unsigned long n) { __CPROVER_HIDE: assert_context_process(); diff --git a/ddverify/models/seq1/src/linux/fs/char_dev.c b/ddverify/models/seq1/src/linux/fs/char_dev.c index 8a0a278bf..fb90533e8 100644 --- a/ddverify/models/seq1/src/linux/fs/char_dev.c +++ b/ddverify/models/seq1/src/linux/fs/char_dev.c @@ -6,7 +6,7 @@ #include #include -int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) +inline int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) { int major; int return_value = nondet_int(); @@ -20,7 +20,7 @@ int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const ch return return_value; } -int register_chrdev_region(dev_t from, unsigned count, const char *name) +inline int register_chrdev_region(dev_t from, unsigned count, const char *name) { int return_value = nondet_int(); __CPROVER_assume((return_value == 0) || (return_value == -1)); @@ -30,9 +30,9 @@ int register_chrdev_region(dev_t from, unsigned count, const char *name) //void unregister_chrdev_region(dev_t, unsigned) {} - -int register_chrdev(unsigned int major, const char *name, - struct file_operations *fops) +inline int register_chrdev( + unsigned int major, const char *name, + struct file_operations *fops) { struct cdev *cdev; int err; @@ -53,25 +53,24 @@ int register_chrdev(unsigned int major, const char *name, return major; } - -int unregister_chrdev(unsigned int major, const char *name) +inline int unregister_chrdev(unsigned int major, const char *name) { return 0; } -struct cdev *cdev_alloc(void) +inline struct cdev *cdev_alloc(void) { if (fixed_cdev_used < MAX_CDEV_SUPPORT) { return &fixed_cdev[fixed_cdev_used++]; } } -void cdev_init(struct cdev *cdev, struct file_operations *fops) +inline void cdev_init(struct cdev *cdev, struct file_operations *fops) { cdev->ops = fops; } -int cdev_add(struct cdev *p, dev_t dev, unsigned count) +inline int cdev_add(struct cdev *p, dev_t dev, unsigned count) { p->dev = dev; p->count = count; @@ -96,7 +95,7 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count) return return_value; } -void cdev_del(struct cdev *p) +inline void cdev_del(struct cdev *p) { int i; diff --git a/ddverify/models/seq1/src/linux/kernel/mutex.c b/ddverify/models/seq1/src/linux/kernel/mutex.c index d2cc26058..0f02bc77e 100644 --- a/ddverify/models/seq1/src/linux/kernel/mutex.c +++ b/ddverify/models/seq1/src/linux/kernel/mutex.c @@ -1,7 +1,7 @@ #include #include -void mutex_init(struct mutex *lock) +inline void mutex_init(struct mutex *lock) { __CPROVER_HIDE: #ifdef DDV_ASSERT_MUTEX @@ -11,7 +11,7 @@ void mutex_init(struct mutex *lock) lock->init = 1; } -void mutex_lock(struct mutex *lock) +inline void mutex_lock(struct mutex *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -24,7 +24,7 @@ void mutex_lock(struct mutex *lock) __CPROVER_atomic_end(); } -void mutex_unlock(struct mutex *lock) +inline void mutex_unlock(struct mutex *lock) { __CPROVER_HIDE: assert_context_process(); diff --git a/ddverify/models/seq1/src/linux/kernel/resource.c b/ddverify/models/seq1/src/linux/kernel/resource.c index 8734ef490..af6949502 100644 --- a/ddverify/models/seq1/src/linux/kernel/resource.c +++ b/ddverify/models/seq1/src/linux/kernel/resource.c @@ -6,7 +6,7 @@ int ddv_ioport_request_start; int ddv_ioport_request_len; -struct resource *request_region(unsigned long start, unsigned long len, const char *name) +inline struct resource *request_region(unsigned long start, unsigned long len, const char *name) { unsigned int i; struct resource *resource = (struct resource*)malloc(sizeof(struct resource)); @@ -20,7 +20,7 @@ struct resource *request_region(unsigned long start, unsigned long len, const ch return resource; } -void release_region(unsigned long start, unsigned long len) +inline void release_region(unsigned long start, unsigned long len) { unsigned int i = 0; @@ -32,7 +32,7 @@ void release_region(unsigned long start, unsigned long len) ddv_ioport_request_len = 0; } -unsigned char inb(unsigned int port) +inline unsigned char inb(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -40,13 +40,13 @@ unsigned char inb(unsigned int port) return nondet_uchar(); } -void outb(unsigned char byte, unsigned int port) +inline void outb(unsigned char byte, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned short inw(unsigned int port) +inline unsigned short inw(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -54,13 +54,13 @@ unsigned short inw(unsigned int port) return nondet_ushort(); } -void outw(unsigned short word, unsigned int port) +inline void outw(unsigned short word, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned inl(unsigned int port) +inline unsigned inl(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -68,14 +68,13 @@ unsigned inl(unsigned int port) return nondet_unsigned(); } -void outl(unsigned doubleword, unsigned int port) +inline void outl(unsigned doubleword, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } - -unsigned char inb_p(unsigned int port) +inline unsigned char inb_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -83,13 +82,13 @@ unsigned char inb_p(unsigned int port) return nondet_uchar(); } -void outb_p(unsigned char byte, unsigned int port) +inline void outb_p(unsigned char byte, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned short inw_p(unsigned int port) +inline unsigned short inw_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -97,13 +96,13 @@ unsigned short inw_p(unsigned int port) return nondet_ushort(); } -void outw_p(unsigned short word, unsigned int port) +inline void outw_p(unsigned short word, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); } -unsigned inl_p(unsigned int port) +inline unsigned inl_p(unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); @@ -111,7 +110,7 @@ unsigned inl_p(unsigned int port) return nondet_unsigned(); } -void outl_p(unsigned doubleword, unsigned int port) +inline void outl_p(unsigned doubleword, unsigned int port) { __CPROVER_HIDE: ddv_correct_port_use(port); diff --git a/ddverify/models/seq1/src/linux/kernel/semaphore.c b/ddverify/models/seq1/src/linux/kernel/semaphore.c index 7ea94e8fc..d14ca0398 100644 --- a/ddverify/models/seq1/src/linux/kernel/semaphore.c +++ b/ddverify/models/seq1/src/linux/kernel/semaphore.c @@ -3,25 +3,25 @@ #include // DDV: The count value is ignored because ddverify only supports binary semaphores! -void sema_init(struct semaphore *sem, int val) +inline void sema_init(struct semaphore *sem, int val) { sem->init = 1; sem->locked = 0; } -void init_MUTEX(struct semaphore * sem) +inline void init_MUTEX(struct semaphore * sem) { sem->init = 1; sem->locked = 0; } -void init_MUTEX_LOCKED(struct semaphore * sem) +inline void init_MUTEX_LOCKED(struct semaphore * sem) { sem->init = 1; sem->locked = 1; } -void down(struct semaphore * sem) +inline void down(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -34,7 +34,7 @@ void down(struct semaphore * sem) __CPROVER_atomic_end(); } -int down_interruptible(struct semaphore * sem) +inline int down_interruptible(struct semaphore * sem) { if (nondet_int()) { __CPROVER_HIDE: @@ -53,7 +53,7 @@ int down_interruptible(struct semaphore * sem) } } -int down_trylock(struct semaphore * sem) +inline int down_trylock(struct semaphore * sem) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -75,7 +75,7 @@ int down_trylock(struct semaphore * sem) return 0; } -void up(struct semaphore * sem) +inline void up(struct semaphore * sem) { __CPROVER_HIDE: assert_context_process(); diff --git a/ddverify/models/seq1/src/linux/kernel/softirq.c b/ddverify/models/seq1/src/linux/kernel/softirq.c index 4a6c5e988..d10ed8685 100644 --- a/ddverify/models/seq1/src/linux/kernel/softirq.c +++ b/ddverify/models/seq1/src/linux/kernel/softirq.c @@ -1,7 +1,7 @@ #include #include -void tasklet_schedule(struct tasklet_struct *t) +inline void tasklet_schedule(struct tasklet_struct *t) { int i; int next_free = -1; @@ -28,8 +28,9 @@ void tasklet_schedule(struct tasklet_struct *t) tasklet_registered[next_free].is_running = 0; } -void tasklet_init(struct tasklet_struct *t, - void (*func)(unsigned long), unsigned long data) +inline void tasklet_init( + struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data) { t->count = 0; t->init = 0; diff --git a/ddverify/models/seq1/src/linux/kernel/spinlock.c b/ddverify/models/seq1/src/linux/kernel/spinlock.c index b9f5d37fe..29f5729d3 100644 --- a/ddverify/models/seq1/src/linux/kernel/spinlock.c +++ b/ddverify/models/seq1/src/linux/kernel/spinlock.c @@ -1,13 +1,13 @@ #include #include -void spin_lock_init(spinlock_t * lock) +inline void spin_lock_init(spinlock_t * lock) { lock->init = 1; lock->locked = 0; } -void spin_lock(spinlock_t * lock) +inline void spin_lock(spinlock_t * lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -19,7 +19,7 @@ void spin_lock(spinlock_t * lock) __CPROVER_atomic_end(); } -void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) +inline void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -31,7 +31,7 @@ void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) __CPROVER_atomic_end(); } -void spin_lock_irq(spinlock_t *lock) +inline void spin_lock_irq(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -43,7 +43,7 @@ void spin_lock_irq(spinlock_t *lock) __CPROVER_atomic_end(); } -void spin_lock_bh(spinlock_t *lock) +inline void spin_lock_bh(spinlock_t *lock) { __CPROVER_HIDE: __CPROVER_atomic_begin(); @@ -55,7 +55,7 @@ void spin_lock_bh(spinlock_t *lock) __CPROVER_atomic_end(); } -void spin_unlock(spinlock_t *lock) +inline void spin_unlock(spinlock_t *lock) { __CPROVER_HIDE: #ifdef DDV_ASSERT_SPINLOCK @@ -64,8 +64,7 @@ void spin_unlock(spinlock_t *lock) lock->locked = 0; } - -void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) +inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) { __CPROVER_HIDE: #ifdef DDV_ASSERT_SPINLOCK @@ -74,7 +73,7 @@ void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) lock->locked = 0; } -void spin_unlock_irq(spinlock_t *lock) +inline void spin_unlock_irq(spinlock_t *lock) { __CPROVER_HIDE: #ifdef DDV_ASSERT_SPINLOCK @@ -83,7 +82,7 @@ void spin_unlock_irq(spinlock_t *lock) lock->locked = 0; } -void spin_unlock_bh(spinlock_t *lock) +inline void spin_unlock_bh(spinlock_t *lock) { __CPROVER_HIDE: #ifdef DDV_ASSERT_SPINLOCK diff --git a/ddverify/models/seq1/src/linux/kernel/timer.c b/ddverify/models/seq1/src/linux/kernel/timer.c index 2018c2931..fd2f92f95 100644 --- a/ddverify/models/seq1/src/linux/kernel/timer.c +++ b/ddverify/models/seq1/src/linux/kernel/timer.c @@ -1,7 +1,7 @@ #include #include -void init_timer(struct timer_list * timer) +inline void init_timer(struct timer_list * timer) { if (number_timer_registered < MAX_TIMER_SUPPORT) { timer->__ddv_active = 0; @@ -12,8 +12,7 @@ void init_timer(struct timer_list * timer) } } - -void add_timer(struct timer_list *timer) +inline void add_timer(struct timer_list *timer) { #ifdef DDV_ASSERT_TIMER __CPROVER_HIDE: @@ -22,21 +21,18 @@ void add_timer(struct timer_list *timer) timer->__ddv_active = 1; } - -void add_timer_on(struct timer_list *timer, int cpu) +inline void add_timer_on(struct timer_list *timer, int cpu) { // We do not care about the cpu number! add_timer(timer); } - -int del_timer(struct timer_list * timer) +inline int del_timer(struct timer_list * timer) { timer->__ddv_active = 0; } - -int mod_timer(struct timer_list *timer, unsigned long expires) +inline int mod_timer(struct timer_list *timer, unsigned long expires) { #ifdef DDV_ASSERT_TIMER __CPROVER_HIDE: diff --git a/ddverify/models/seq1/src/linux/kernel/wait.c b/ddverify/models/seq1/src/linux/kernel/wait.c index 04822ab0b..cc986589f 100644 --- a/ddverify/models/seq1/src/linux/kernel/wait.c +++ b/ddverify/models/seq1/src/linux/kernel/wait.c @@ -1,11 +1,11 @@ #include -void init_waitqueue_head(wait_queue_head_t *q) +inline void init_waitqueue_head(wait_queue_head_t *q) { q->init = 1; } -void wake_up(wait_queue_head_t *q) +inline void wake_up(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -13,7 +13,7 @@ void wake_up(wait_queue_head_t *q) #endif } -void wake_up_all(wait_queue_head_t *q) +inline void wake_up_all(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -21,7 +21,7 @@ void wake_up_all(wait_queue_head_t *q) #endif } -void wake_up_interruptible(wait_queue_head_t *q) +inline void wake_up_interruptible(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -29,7 +29,7 @@ void wake_up_interruptible(wait_queue_head_t *q) #endif } -void sleep_on(wait_queue_head_t *q) +inline void sleep_on(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: @@ -37,7 +37,7 @@ void sleep_on(wait_queue_head_t *q) #endif } -void interruptible_sleep_on(wait_queue_head_t *q) +inline void interruptible_sleep_on(wait_queue_head_t *q) { #ifdef DDV_ASSERT_WAIT_QUEUE __CPROVER_HIDE: diff --git a/ddverify/models/seq1/src/linux/kernel/workqueue.c b/ddverify/models/seq1/src/linux/kernel/workqueue.c index 26d035768..90cf4b93f 100644 --- a/ddverify/models/seq1/src/linux/kernel/workqueue.c +++ b/ddverify/models/seq1/src/linux/kernel/workqueue.c @@ -2,7 +2,7 @@ #include #include -int schedule_work(struct work_struct *work) +inline int schedule_work(struct work_struct *work) { int i; @@ -27,7 +27,7 @@ int schedule_work(struct work_struct *work) return -1; } -void call_shared_workqueue_functions() +inline void call_shared_workqueue_functions() { unsigned short i = nondet_ushort(); __CPROVER_assume(i < MAX_WORKQUEUE_ELEMENTS_SUPPORT); diff --git a/ddverify/models/seq1/src/linux/mm/page_alloc.c b/ddverify/models/seq1/src/linux/mm/page_alloc.c index 40d236be0..4d1ed67c9 100644 --- a/ddverify/models/seq1/src/linux/mm/page_alloc.c +++ b/ddverify/models/seq1/src/linux/mm/page_alloc.c @@ -2,7 +2,7 @@ #include #include -unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) +inline unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -10,7 +10,7 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) } } -unsigned long __get_free_page(gfp_t gfp_mask) +inline unsigned long __get_free_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -18,7 +18,7 @@ unsigned long __get_free_page(gfp_t gfp_mask) } } -unsigned long get_zeroed_page(gfp_t gfp_mask) +inline unsigned long get_zeroed_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -26,8 +26,8 @@ unsigned long get_zeroed_page(gfp_t gfp_mask) } } -static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, - unsigned int order) +inline static struct page *alloc_pages_node( + int nid, gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -35,7 +35,7 @@ static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, } } -struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) +inline struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { @@ -43,7 +43,7 @@ struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) } } -struct page * alloc_page(gfp_t gfp_mask) +inline struct page * alloc_page(gfp_t gfp_mask) { __CPROVER_HIDE: if (gfp_mask & __GFP_WAIT) { diff --git a/ddverify/models/seq1/src/linux/pci.c b/ddverify/models/seq1/src/linux/pci.c index 26d58cee1..8853d1e3e 100644 --- a/ddverify/models/seq1/src/linux/pci.c +++ b/ddverify/models/seq1/src/linux/pci.c @@ -5,7 +5,7 @@ #include #include -int pci_enable_device(struct pci_dev *dev) +inline int pci_enable_device(struct pci_dev *dev) { int i; @@ -16,7 +16,7 @@ int pci_enable_device(struct pci_dev *dev) } } -struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) +inline struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) { if (from == NULL) { from = (struct pci_dev*)malloc(sizeof(struct pci_dev)); @@ -34,7 +34,7 @@ struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) } } -int pci_register_driver(struct pci_driver *driver) +inline int pci_register_driver(struct pci_driver *driver) { if (nondet_int()) { registered_pci_driver.pci_driver = driver; @@ -47,13 +47,13 @@ int pci_register_driver(struct pci_driver *driver) } } -void pci_unregister_driver(struct pci_driver *driver) +inline void pci_unregister_driver(struct pci_driver *driver) { registered_pci_driver.pci_driver = NULL; registered_pci_driver.no_pci_device_id = 0; } -void pci_release_region(struct pci_dev *pdev, int bar) +inline void pci_release_region(struct pci_dev *pdev, int bar) { if (pci_resource_len(pdev, bar) == 0) return; @@ -65,7 +65,7 @@ void pci_release_region(struct pci_dev *pdev, int bar) pci_resource_len(pdev, bar)); } -int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) +inline int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) { if (pci_resource_len(pdev, bar) == 0) return 0; @@ -84,8 +84,7 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) return 0; } - -void pci_release_regions(struct pci_dev *pdev) +inline void pci_release_regions(struct pci_dev *pdev) { int i; @@ -93,8 +92,7 @@ void pci_release_regions(struct pci_dev *pdev) pci_release_region(pdev, i); } - -int pci_request_regions(struct pci_dev *pdev, const char *res_name) +inline int pci_request_regions(struct pci_dev *pdev, const char *res_name) { int i; diff --git a/ddverify/readme.txt b/ddverify/readme.txt index 303538142..ff8f36a58 100644 --- a/ddverify/readme.txt +++ b/ddverify/readme.txt @@ -2,34 +2,43 @@ This package contains a compiled version of DDVerify and Satabs. 1. INSTALL ----------------------- + To install DDVerify the following steps must be done: - set the environment variable DDV_PATH to this directory - add the binary directory of DDVerify to the PATH. - you need to install either Boppo or Cadence SMV. + 2. EXECUTE ----------------------- + Type "ddverify --help" to get more information about ddverify. 3. COMPILE ----------------------- + To recompile DDVerify go to the bin/ directory of DDVerify and run: gcc ddverfiy.c -o ddverify + 4. RUN CASE STUDIES ----------------------- -The directory case_studies/ contains 31 device drivers that can be used with -DDVerify. Note that we are aware of many issues when trying to verify -the benchmarks with satabs. We offer this collection as it is for research -purpose. + +The directory case_studies/ contains 31 device drivers that can be used with +DDVerify, extracted from Linux 2.6.19. Note that we are aware of many +issues when trying to verify the benchmarks with satabs. We offer this +collection as it is for research purpose. + 5. CONTACT INFORMATION ----------------------- + If you need more information about DDVerify or you have any comments, please contact: + kroening@comlab.ox.ac.uk nicolas.blanc@inf.ethz.ch From efa91b352c76bdced243cf74d0943389f8886821 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 11 Apr 2022 17:37:57 +0300 Subject: [PATCH 03/24] Add ddverify/.gitignore --- ddverify/.gitignore | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 ddverify/.gitignore diff --git a/ddverify/.gitignore b/ddverify/.gitignore new file mode 100644 index 000000000..0b0a9afb0 --- /dev/null +++ b/ddverify/.gitignore @@ -0,0 +1,13 @@ +# ddverify binary +bin/ddverify + +# ddverify outputs +__main.c +compile +ddv_satabs +ddv_cbmc +.ddv_output_* +.claim_out_* + +# compilation outputs +*.o From be273469d884167036723e9b023ce5080219cb2f Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 11 Apr 2022 17:42:07 +0300 Subject: [PATCH 04/24] Port some ddverify seq1 model changes to con1 --- ddverify/models/con1/include/linux/threads.h | 4 ++++ ddverify/models/con1/src/linux/fs/read_write.c | 9 +++++++++ ddverify/models/con1/src/linux/kernel/resource.c | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 ddverify/models/con1/include/linux/threads.h create mode 100644 ddverify/models/con1/src/linux/fs/read_write.c diff --git a/ddverify/models/con1/include/linux/threads.h b/ddverify/models/con1/include/linux/threads.h new file mode 100644 index 000000000..ce23e273e --- /dev/null +++ b/ddverify/models/con1/include/linux/threads.h @@ -0,0 +1,4 @@ +#ifndef _LINUX_THREADS_H +#define _LINUX_THREADS_H + +#endif diff --git a/ddverify/models/con1/src/linux/fs/read_write.c b/ddverify/models/con1/src/linux/fs/read_write.c new file mode 100644 index 000000000..66bce0a93 --- /dev/null +++ b/ddverify/models/con1/src/linux/fs/read_write.c @@ -0,0 +1,9 @@ +#include + +#define ESPIPE 29 + +loff_t no_llseek(struct file *file, loff_t offset, int origin) +{ + return -ESPIPE; +} + diff --git a/ddverify/models/con1/src/linux/kernel/resource.c b/ddverify/models/con1/src/linux/kernel/resource.c index 4818f4e47..af6949502 100644 --- a/ddverify/models/con1/src/linux/kernel/resource.c +++ b/ddverify/models/con1/src/linux/kernel/resource.c @@ -3,6 +3,9 @@ #include #include +int ddv_ioport_request_start; +int ddv_ioport_request_len; + inline struct resource *request_region(unsigned long start, unsigned long len, const char *name) { unsigned int i; From 26e55a8ab6bb1d878ac43a86f3bdbee833289f20 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 11 Apr 2022 17:44:58 +0300 Subject: [PATCH 05/24] Add missing stubs to ddverify/bin/ddverify.h --- ddverify/bin/ddverify.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ddverify/bin/ddverify.h b/ddverify/bin/ddverify.h index 7be4170bf..9bff9eda2 100644 --- a/ddverify/bin/ddverify.h +++ b/ddverify/bin/ddverify.h @@ -80,11 +80,13 @@ const char ddv_files[][STR_LENGTH] = {"ddverify/ddverify.c", "ddverify/timer.c", "linux/pci.c", "linux/arch/i386/lib/usercopy.c", + "linux/block/elevator.c", "linux/block/genhd.c", "linux/block/ll_rw_blk.c", "linux/drivers/char/misc.c", "linux/drivers/char/tty_io.c", "linux/fs/char_dev.c", + "linux/fs/read_write.c", "linux/kernel/mutex.c", "linux/kernel/resource.c", "linux/kernel/sched.c", From 1bd6fae881f16d9d1a0af13f0b19b1b624e332e1 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 10:50:33 +0300 Subject: [PATCH 06/24] Generate main harnesses and Goblint confs for ddverify drivers --- ddverify/.gitignore | 3 + .../case_studies/block/cciss/cciss.main.c | 10 +++ .../block/cpqarray/cpqarray.main.c | 10 +++ .../case_studies/block/floppy/floppy.main.c | 10 +++ ddverify/case_studies/block/nbd/nbd.main.c | 10 +++ ddverify/case_studies/block/umem/umem.main.c | 10 +++ .../case_studies/cdrom/aztcd/aztcd.main.c | 10 +++ .../case_studies/cdrom/cdu31a/cdu31a.main.c | 10 +++ .../case_studies/cdrom/cm206/cm206.main.c | 10 +++ .../char/applicom/applicom.main.c | 10 +++ .../char/cs5535_gpio/cs5535_gpio.main.c | 10 +++ .../case_studies/char/ds1286/ds1286.main.c | 10 +++ .../case_studies/char/efirtc/efirtc.main.c | 10 +++ .../char/generic_nvram/generic_nvram.main.c | 10 +++ .../case_studies/char/genrtc/genrtc.main.c | 10 +++ .../char/nwbutton/nwbutton.main.c | 10 +++ .../case_studies/char/toshiba/toshiba.main.c | 10 +++ .../char/watchdog/i8xx_tco/i8xx_tco.main.c | 10 +++ .../char/watchdog/ib700wdt/ib700wdt.main.c | 10 +++ .../char/watchdog/machzwd/machzwd.main.c | 10 +++ .../char/watchdog/mixcomwd/mixcomwd.main.c | 10 +++ .../char/watchdog/pcwd/pcwd.main.c | 10 +++ .../char/watchdog/pcwd_pci/pcwd_pci.main.c | 10 +++ .../watchdog/sbc60xxwdt/sbc60xxwdt.main.c | 10 +++ .../char/watchdog/sc1200wdt/sc1200wdt.main.c | 10 +++ .../char/watchdog/sc520_wdt/sc520_wdt.main.c | 10 +++ .../smsc37b787_wdt/smsc37b787_wdt.main.c | 10 +++ .../watchdog/w83877f_wdt/w83877f_wdt.main.c | 10 +++ .../watchdog/w83977f_wdt/w83977f_wdt.main.c | 10 +++ .../case_studies/char/watchdog/wdt/wdt.main.c | 10 +++ .../char/watchdog/wdt977/wdt977.main.c | 10 +++ .../char/watchdog/wdt_pci/wdt_pci.main.c | 10 +++ ddverify/goblint/conf/applicom.json | 48 +++++++++++ ddverify/goblint/conf/aztcd.json | 47 +++++++++++ ddverify/goblint/conf/cciss.json | 49 +++++++++++ ddverify/goblint/conf/cdu31a.json | 47 +++++++++++ ddverify/goblint/conf/cm206.json | 47 +++++++++++ ddverify/goblint/conf/cpqarray.json | 48 +++++++++++ ddverify/goblint/conf/cs5535_gpio.json | 48 +++++++++++ ddverify/goblint/conf/ds1286.json | 47 +++++++++++ ddverify/goblint/conf/efirtc.json | 47 +++++++++++ ddverify/goblint/conf/floppy.json | 47 +++++++++++ ddverify/goblint/conf/generic_nvram.json | 47 +++++++++++ ddverify/goblint/conf/genrtc.json | 47 +++++++++++ ddverify/goblint/conf/i8xx_tco.json | 48 +++++++++++ ddverify/goblint/conf/ib700wdt.json | 47 +++++++++++ ddverify/goblint/conf/machzwd.json | 47 +++++++++++ ddverify/goblint/conf/mixcomwd.json | 47 +++++++++++ ddverify/goblint/conf/nbd.json | 47 +++++++++++ ddverify/goblint/conf/nwbutton.json | 47 +++++++++++ ddverify/goblint/conf/pcwd.json | 47 +++++++++++ ddverify/goblint/conf/pcwd_pci.json | 48 +++++++++++ ddverify/goblint/conf/sbc60xxwdt.json | 47 +++++++++++ ddverify/goblint/conf/sc1200wdt.json | 48 +++++++++++ ddverify/goblint/conf/sc520_wdt.json | 47 +++++++++++ ddverify/goblint/conf/smsc37b787_wdt.json | 47 +++++++++++ ddverify/goblint/conf/toshiba.json | 47 +++++++++++ ddverify/goblint/conf/umem.json | 48 +++++++++++ ddverify/goblint/conf/w83877f_wdt.json | 47 +++++++++++ ddverify/goblint/conf/w83977f_wdt.json | 47 +++++++++++ ddverify/goblint/conf/wdt.json | 47 +++++++++++ ddverify/goblint/conf/wdt977.json | 47 +++++++++++ ddverify/goblint/conf/wdt_pci.json | 48 +++++++++++ ddverify/goblint/ddverify.py | 83 +++++++++++++++++++ ddverify/goblint/ddverify.sh | 42 ++++++++++ 65 files changed, 1905 insertions(+) create mode 100644 ddverify/case_studies/block/cciss/cciss.main.c create mode 100644 ddverify/case_studies/block/cpqarray/cpqarray.main.c create mode 100644 ddverify/case_studies/block/floppy/floppy.main.c create mode 100644 ddverify/case_studies/block/nbd/nbd.main.c create mode 100644 ddverify/case_studies/block/umem/umem.main.c create mode 100644 ddverify/case_studies/cdrom/aztcd/aztcd.main.c create mode 100644 ddverify/case_studies/cdrom/cdu31a/cdu31a.main.c create mode 100644 ddverify/case_studies/cdrom/cm206/cm206.main.c create mode 100644 ddverify/case_studies/char/applicom/applicom.main.c create mode 100644 ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.main.c create mode 100644 ddverify/case_studies/char/ds1286/ds1286.main.c create mode 100644 ddverify/case_studies/char/efirtc/efirtc.main.c create mode 100644 ddverify/case_studies/char/generic_nvram/generic_nvram.main.c create mode 100644 ddverify/case_studies/char/genrtc/genrtc.main.c create mode 100644 ddverify/case_studies/char/nwbutton/nwbutton.main.c create mode 100644 ddverify/case_studies/char/toshiba/toshiba.main.c create mode 100644 ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.main.c create mode 100644 ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/machzwd/machzwd.main.c create mode 100644 ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.main.c create mode 100644 ddverify/case_studies/char/watchdog/pcwd/pcwd.main.c create mode 100644 ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.main.c create mode 100644 ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/wdt/wdt.main.c create mode 100644 ddverify/case_studies/char/watchdog/wdt977/wdt977.main.c create mode 100644 ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.main.c create mode 100644 ddverify/goblint/conf/applicom.json create mode 100644 ddverify/goblint/conf/aztcd.json create mode 100644 ddverify/goblint/conf/cciss.json create mode 100644 ddverify/goblint/conf/cdu31a.json create mode 100644 ddverify/goblint/conf/cm206.json create mode 100644 ddverify/goblint/conf/cpqarray.json create mode 100644 ddverify/goblint/conf/cs5535_gpio.json create mode 100644 ddverify/goblint/conf/ds1286.json create mode 100644 ddverify/goblint/conf/efirtc.json create mode 100644 ddverify/goblint/conf/floppy.json create mode 100644 ddverify/goblint/conf/generic_nvram.json create mode 100644 ddverify/goblint/conf/genrtc.json create mode 100644 ddverify/goblint/conf/i8xx_tco.json create mode 100644 ddverify/goblint/conf/ib700wdt.json create mode 100644 ddverify/goblint/conf/machzwd.json create mode 100644 ddverify/goblint/conf/mixcomwd.json create mode 100644 ddverify/goblint/conf/nbd.json create mode 100644 ddverify/goblint/conf/nwbutton.json create mode 100644 ddverify/goblint/conf/pcwd.json create mode 100644 ddverify/goblint/conf/pcwd_pci.json create mode 100644 ddverify/goblint/conf/sbc60xxwdt.json create mode 100644 ddverify/goblint/conf/sc1200wdt.json create mode 100644 ddverify/goblint/conf/sc520_wdt.json create mode 100644 ddverify/goblint/conf/smsc37b787_wdt.json create mode 100644 ddverify/goblint/conf/toshiba.json create mode 100644 ddverify/goblint/conf/umem.json create mode 100644 ddverify/goblint/conf/w83877f_wdt.json create mode 100644 ddverify/goblint/conf/w83977f_wdt.json create mode 100644 ddverify/goblint/conf/wdt.json create mode 100644 ddverify/goblint/conf/wdt977.json create mode 100644 ddverify/goblint/conf/wdt_pci.json create mode 100755 ddverify/goblint/ddverify.py create mode 100755 ddverify/goblint/ddverify.sh diff --git a/ddverify/.gitignore b/ddverify/.gitignore index 0b0a9afb0..9d91c5f95 100644 --- a/ddverify/.gitignore +++ b/ddverify/.gitignore @@ -11,3 +11,6 @@ ddv_cbmc # compilation outputs *.o + +# goblint confs +!goblint diff --git a/ddverify/case_studies/block/cciss/cciss.main.c b/ddverify/case_studies/block/cciss/cciss.main.c new file mode 100644 index 000000000..7176ae35b --- /dev/null +++ b/ddverify/case_studies/block/cciss/cciss.main.c @@ -0,0 +1,10 @@ +#include +#include "cciss.c" + +int main() { + _ddv_module_init = cciss_init; + _ddv_module_exit = cciss_cleanup; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/block/cpqarray/cpqarray.main.c b/ddverify/case_studies/block/cpqarray/cpqarray.main.c new file mode 100644 index 000000000..8eec7f322 --- /dev/null +++ b/ddverify/case_studies/block/cpqarray/cpqarray.main.c @@ -0,0 +1,10 @@ +#include +#include "cpqarray.c" + +int main() { + _ddv_module_init = cpqarray_init; + _ddv_module_exit = cpqarray_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/block/floppy/floppy.main.c b/ddverify/case_studies/block/floppy/floppy.main.c new file mode 100644 index 000000000..b0375ce1d --- /dev/null +++ b/ddverify/case_studies/block/floppy/floppy.main.c @@ -0,0 +1,10 @@ +#include +#include "floppy.c" + +int main() { + _ddv_module_init = floppy_init; + _ddv_module_exit = cleanup_module; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/block/nbd/nbd.main.c b/ddverify/case_studies/block/nbd/nbd.main.c new file mode 100644 index 000000000..550753702 --- /dev/null +++ b/ddverify/case_studies/block/nbd/nbd.main.c @@ -0,0 +1,10 @@ +#include +#include "nbd.c" + +int main() { + _ddv_module_init = nbd_init; + _ddv_module_exit = nbd_cleanup; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/block/umem/umem.main.c b/ddverify/case_studies/block/umem/umem.main.c new file mode 100644 index 000000000..99653fceb --- /dev/null +++ b/ddverify/case_studies/block/umem/umem.main.c @@ -0,0 +1,10 @@ +#include +#include "umem.c" + +int main() { + _ddv_module_init = mm_init; + _ddv_module_exit = mm_cleanup; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/cdrom/aztcd/aztcd.main.c b/ddverify/case_studies/cdrom/aztcd/aztcd.main.c new file mode 100644 index 000000000..1afe94087 --- /dev/null +++ b/ddverify/case_studies/cdrom/aztcd/aztcd.main.c @@ -0,0 +1,10 @@ +#include +#include "aztcd.c" + +int main() { + _ddv_module_init = aztcd_init; + _ddv_module_exit = aztcd_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/cdrom/cdu31a/cdu31a.main.c b/ddverify/case_studies/cdrom/cdu31a/cdu31a.main.c new file mode 100644 index 000000000..dbc3f33d3 --- /dev/null +++ b/ddverify/case_studies/cdrom/cdu31a/cdu31a.main.c @@ -0,0 +1,10 @@ +#include +#include "cdu31a.c" + +int main() { + _ddv_module_init = cdu31a_init; + _ddv_module_exit = cdu31a_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/cdrom/cm206/cm206.main.c b/ddverify/case_studies/cdrom/cm206/cm206.main.c new file mode 100644 index 000000000..012184b66 --- /dev/null +++ b/ddverify/case_studies/cdrom/cm206/cm206.main.c @@ -0,0 +1,10 @@ +#include +#include "cm206.c" + +int main() { + _ddv_module_init = __cm206_init; + _ddv_module_exit = cm206_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/applicom/applicom.main.c b/ddverify/case_studies/char/applicom/applicom.main.c new file mode 100644 index 000000000..595dd5555 --- /dev/null +++ b/ddverify/case_studies/char/applicom/applicom.main.c @@ -0,0 +1,10 @@ +#include +#include "applicom.c" + +int main() { + _ddv_module_init = applicom_init; + _ddv_module_exit = applicom_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.main.c b/ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.main.c new file mode 100644 index 000000000..635898683 --- /dev/null +++ b/ddverify/case_studies/char/cs5535_gpio/cs5535_gpio.main.c @@ -0,0 +1,10 @@ +#include +#include "cs5535_gpio.c" + +int main() { + _ddv_module_init = cs5535_gpio_init; + _ddv_module_exit = cs5535_gpio_cleanup; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/ds1286/ds1286.main.c b/ddverify/case_studies/char/ds1286/ds1286.main.c new file mode 100644 index 000000000..df1ac12d4 --- /dev/null +++ b/ddverify/case_studies/char/ds1286/ds1286.main.c @@ -0,0 +1,10 @@ +#include +#include "ds1286.c" + +int main() { + _ddv_module_init = ds1286_init; + _ddv_module_exit = ds1286_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/efirtc/efirtc.main.c b/ddverify/case_studies/char/efirtc/efirtc.main.c new file mode 100644 index 000000000..5ba18d096 --- /dev/null +++ b/ddverify/case_studies/char/efirtc/efirtc.main.c @@ -0,0 +1,10 @@ +#include +#include "efirtc.c" + +int main() { + _ddv_module_init = efi_rtc_init; + _ddv_module_exit = efi_rtc_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/generic_nvram/generic_nvram.main.c b/ddverify/case_studies/char/generic_nvram/generic_nvram.main.c new file mode 100644 index 000000000..358045c83 --- /dev/null +++ b/ddverify/case_studies/char/generic_nvram/generic_nvram.main.c @@ -0,0 +1,10 @@ +#include +#include "generic_nvram.c" + +int main() { + _ddv_module_init = nvram_init; + _ddv_module_exit = nvram_cleanup; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/genrtc/genrtc.main.c b/ddverify/case_studies/char/genrtc/genrtc.main.c new file mode 100644 index 000000000..71989d0de --- /dev/null +++ b/ddverify/case_studies/char/genrtc/genrtc.main.c @@ -0,0 +1,10 @@ +#include +#include "genrtc.c" + +int main() { + _ddv_module_init = rtc_generic_init; + _ddv_module_exit = rtc_generic_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/nwbutton/nwbutton.main.c b/ddverify/case_studies/char/nwbutton/nwbutton.main.c new file mode 100644 index 000000000..d205e84dc --- /dev/null +++ b/ddverify/case_studies/char/nwbutton/nwbutton.main.c @@ -0,0 +1,10 @@ +#include +#include "nwbutton.c" + +int main() { + _ddv_module_init = nwbutton_init; + _ddv_module_exit = nwbutton_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/toshiba/toshiba.main.c b/ddverify/case_studies/char/toshiba/toshiba.main.c new file mode 100644 index 000000000..558c1170e --- /dev/null +++ b/ddverify/case_studies/char/toshiba/toshiba.main.c @@ -0,0 +1,10 @@ +#include +#include "toshiba.c" + +int main() { + _ddv_module_init = toshiba_init; + _ddv_module_exit = toshiba_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.main.c b/ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.main.c new file mode 100644 index 000000000..87490a48a --- /dev/null +++ b/ddverify/case_studies/char/watchdog/i8xx_tco/i8xx_tco.main.c @@ -0,0 +1,10 @@ +#include +#include "i8xx_tco.c" + +int main() { + _ddv_module_init = watchdog_init; + _ddv_module_exit = watchdog_cleanup; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.main.c b/ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.main.c new file mode 100644 index 000000000..cfec2720f --- /dev/null +++ b/ddverify/case_studies/char/watchdog/ib700wdt/ib700wdt.main.c @@ -0,0 +1,10 @@ +#include +#include "ib700wdt.c" + +int main() { + _ddv_module_init = ibwdt_init; + _ddv_module_exit = ibwdt_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/machzwd/machzwd.main.c b/ddverify/case_studies/char/watchdog/machzwd/machzwd.main.c new file mode 100644 index 000000000..77cfad1f9 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/machzwd/machzwd.main.c @@ -0,0 +1,10 @@ +#include +#include "machzwd.c" + +int main() { + _ddv_module_init = zf_init; + _ddv_module_exit = zf_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.main.c b/ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.main.c new file mode 100644 index 000000000..db41c3d86 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/mixcomwd/mixcomwd.main.c @@ -0,0 +1,10 @@ +#include +#include "mixcomwd.c" + +int main() { + _ddv_module_init = mixcomwd_init; + _ddv_module_exit = mixcomwd_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/pcwd/pcwd.main.c b/ddverify/case_studies/char/watchdog/pcwd/pcwd.main.c new file mode 100644 index 000000000..4e8870223 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/pcwd/pcwd.main.c @@ -0,0 +1,10 @@ +#include +#include "pcwd.c" + +int main() { + _ddv_module_init = pcwd_init_module; + _ddv_module_exit = pcwd_cleanup_module; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.main.c b/ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.main.c new file mode 100644 index 000000000..9b8389d7e --- /dev/null +++ b/ddverify/case_studies/char/watchdog/pcwd_pci/pcwd_pci.main.c @@ -0,0 +1,10 @@ +#include +#include "pcwd_pci.c" + +int main() { + _ddv_module_init = pcipcwd_init_module; + _ddv_module_exit = pcipcwd_cleanup_module; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.main.c b/ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.main.c new file mode 100644 index 000000000..8d1e35937 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.main.c @@ -0,0 +1,10 @@ +#include +#include "sbc60xxwdt.c" + +int main() { + _ddv_module_init = sbc60xxwdt_init; + _ddv_module_exit = sbc60xxwdt_unload; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.main.c b/ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.main.c new file mode 100644 index 000000000..6e520cadc --- /dev/null +++ b/ddverify/case_studies/char/watchdog/sc1200wdt/sc1200wdt.main.c @@ -0,0 +1,10 @@ +#include +#include "sc1200wdt.c" + +int main() { + _ddv_module_init = sc1200wdt_init; + _ddv_module_exit = sc1200wdt_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.main.c b/ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.main.c new file mode 100644 index 000000000..4ec53d78e --- /dev/null +++ b/ddverify/case_studies/char/watchdog/sc520_wdt/sc520_wdt.main.c @@ -0,0 +1,10 @@ +#include +#include "sc520_wdt.c" + +int main() { + _ddv_module_init = sc520_wdt_init; + _ddv_module_exit = sc520_wdt_unload; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.main.c b/ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.main.c new file mode 100644 index 000000000..d464cc9db --- /dev/null +++ b/ddverify/case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.main.c @@ -0,0 +1,10 @@ +#include +#include "smsc37b787_wdt.c" + +int main() { + _ddv_module_init = wb_smsc_wdt_init; + _ddv_module_exit = wb_smsc_wdt_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.main.c b/ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.main.c new file mode 100644 index 000000000..56cd4d1d2 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.main.c @@ -0,0 +1,10 @@ +#include +#include "w83877f_wdt.c" + +int main() { + _ddv_module_init = w83877f_wdt_init; + _ddv_module_exit = w83877f_wdt_unload; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.main.c b/ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.main.c new file mode 100644 index 000000000..9557da2e5 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.main.c @@ -0,0 +1,10 @@ +#include +#include "w83977f_wdt.c" + +int main() { + _ddv_module_init = w83977f_wdt_init; + _ddv_module_exit = w83977f_wdt_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/wdt/wdt.main.c b/ddverify/case_studies/char/watchdog/wdt/wdt.main.c new file mode 100644 index 000000000..bacb08b0f --- /dev/null +++ b/ddverify/case_studies/char/watchdog/wdt/wdt.main.c @@ -0,0 +1,10 @@ +#include +#include "wdt.c" + +int main() { + _ddv_module_init = wdt_init; + _ddv_module_exit = wdt_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/wdt977/wdt977.main.c b/ddverify/case_studies/char/watchdog/wdt977/wdt977.main.c new file mode 100644 index 000000000..7ddc4a32c --- /dev/null +++ b/ddverify/case_studies/char/watchdog/wdt977/wdt977.main.c @@ -0,0 +1,10 @@ +#include +#include "wdt977.c" + +int main() { + _ddv_module_init = wd977_init; + _ddv_module_exit = wd977_exit; + call_ddv(); + + return 0; +} diff --git a/ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.main.c b/ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.main.c new file mode 100644 index 000000000..41048be14 --- /dev/null +++ b/ddverify/case_studies/char/watchdog/wdt_pci/wdt_pci.main.c @@ -0,0 +1,10 @@ +#include +#include "wdt_pci.c" + +int main() { + _ddv_module_init = wdtpci_init; + _ddv_module_exit = wdtpci_cleanup; + call_ddv(); + + return 0; +} diff --git a/ddverify/goblint/conf/applicom.json b/ddverify/goblint/conf/applicom.json new file mode 100644 index 000000000..5dc9a1f2b --- /dev/null +++ b/ddverify/goblint/conf/applicom.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/char/applicom/applicom.main.c", + "case_studies/char/applicom/applicom.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/aztcd.json b/ddverify/goblint/conf/aztcd.json new file mode 100644 index 000000000..9454da005 --- /dev/null +++ b/ddverify/goblint/conf/aztcd.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/cdrom/aztcd/aztcd.main.c", + "case_studies/cdrom/aztcd/aztcd.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/cciss.json b/ddverify/goblint/conf/cciss.json new file mode 100644 index 000000000..ec1c1a91e --- /dev/null +++ b/ddverify/goblint/conf/cciss.json @@ -0,0 +1,49 @@ +{ + "files": [ + "case_studies/block/cciss/cciss.main.c", + "case_studies/block/cciss/cciss.c", + "case_studies/block/cciss/cciss_scsi.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/cdu31a.json b/ddverify/goblint/conf/cdu31a.json new file mode 100644 index 000000000..a26e84549 --- /dev/null +++ b/ddverify/goblint/conf/cdu31a.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/cdrom/cdu31a/cdu31a.main.c", + "case_studies/cdrom/cdu31a/cdu31a.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/cm206.json b/ddverify/goblint/conf/cm206.json new file mode 100644 index 000000000..8a37e27a0 --- /dev/null +++ b/ddverify/goblint/conf/cm206.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/cdrom/cm206/cm206.main.c", + "case_studies/cdrom/cm206/cm206.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json new file mode 100644 index 000000000..96da01ebc --- /dev/null +++ b/ddverify/goblint/conf/cpqarray.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/block/cpqarray/cpqarray.main.c", + "case_studies/block/cpqarray/cpqarray.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/cs5535_gpio.json b/ddverify/goblint/conf/cs5535_gpio.json new file mode 100644 index 000000000..5c12d72c0 --- /dev/null +++ b/ddverify/goblint/conf/cs5535_gpio.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/char/cs5535_gpio/cs5535_gpio.main.c", + "case_studies/char/cs5535_gpio/cs5535_gpio.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/ds1286.json b/ddverify/goblint/conf/ds1286.json new file mode 100644 index 000000000..a43a1dbbc --- /dev/null +++ b/ddverify/goblint/conf/ds1286.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/ds1286/ds1286.main.c", + "case_studies/char/ds1286/ds1286.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/efirtc.json b/ddverify/goblint/conf/efirtc.json new file mode 100644 index 000000000..95ff7f966 --- /dev/null +++ b/ddverify/goblint/conf/efirtc.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/efirtc/efirtc.main.c", + "case_studies/char/efirtc/efirtc.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/floppy.json b/ddverify/goblint/conf/floppy.json new file mode 100644 index 000000000..df3cd0a49 --- /dev/null +++ b/ddverify/goblint/conf/floppy.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/block/floppy/floppy.main.c", + "case_studies/block/floppy/floppy.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/generic_nvram.json b/ddverify/goblint/conf/generic_nvram.json new file mode 100644 index 000000000..c12787a86 --- /dev/null +++ b/ddverify/goblint/conf/generic_nvram.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/generic_nvram/generic_nvram.main.c", + "case_studies/char/generic_nvram/generic_nvram.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/genrtc.json b/ddverify/goblint/conf/genrtc.json new file mode 100644 index 000000000..f7a9c5e16 --- /dev/null +++ b/ddverify/goblint/conf/genrtc.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/genrtc/genrtc.main.c", + "case_studies/char/genrtc/genrtc.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/i8xx_tco.json b/ddverify/goblint/conf/i8xx_tco.json new file mode 100644 index 000000000..4ed9193bb --- /dev/null +++ b/ddverify/goblint/conf/i8xx_tco.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/char/watchdog/i8xx_tco/i8xx_tco.main.c", + "case_studies/char/watchdog/i8xx_tco/i8xx_tco.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/ib700wdt.json b/ddverify/goblint/conf/ib700wdt.json new file mode 100644 index 000000000..7271a0770 --- /dev/null +++ b/ddverify/goblint/conf/ib700wdt.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/ib700wdt/ib700wdt.main.c", + "case_studies/char/watchdog/ib700wdt/ib700wdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/machzwd.json b/ddverify/goblint/conf/machzwd.json new file mode 100644 index 000000000..772553686 --- /dev/null +++ b/ddverify/goblint/conf/machzwd.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/machzwd/machzwd.main.c", + "case_studies/char/watchdog/machzwd/machzwd.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/mixcomwd.json b/ddverify/goblint/conf/mixcomwd.json new file mode 100644 index 000000000..517e3bb0b --- /dev/null +++ b/ddverify/goblint/conf/mixcomwd.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/mixcomwd/mixcomwd.main.c", + "case_studies/char/watchdog/mixcomwd/mixcomwd.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/nbd.json b/ddverify/goblint/conf/nbd.json new file mode 100644 index 000000000..57880ef34 --- /dev/null +++ b/ddverify/goblint/conf/nbd.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/block/nbd/nbd.main.c", + "case_studies/block/nbd/nbd.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/nwbutton.json b/ddverify/goblint/conf/nwbutton.json new file mode 100644 index 000000000..6c09c7849 --- /dev/null +++ b/ddverify/goblint/conf/nwbutton.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/nwbutton/nwbutton.main.c", + "case_studies/char/nwbutton/nwbutton.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/pcwd.json b/ddverify/goblint/conf/pcwd.json new file mode 100644 index 000000000..128e1e9de --- /dev/null +++ b/ddverify/goblint/conf/pcwd.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/pcwd/pcwd.main.c", + "case_studies/char/watchdog/pcwd/pcwd.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/pcwd_pci.json b/ddverify/goblint/conf/pcwd_pci.json new file mode 100644 index 000000000..a16d80ec7 --- /dev/null +++ b/ddverify/goblint/conf/pcwd_pci.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/char/watchdog/pcwd_pci/pcwd_pci.main.c", + "case_studies/char/watchdog/pcwd_pci/pcwd_pci.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/sbc60xxwdt.json b/ddverify/goblint/conf/sbc60xxwdt.json new file mode 100644 index 000000000..0fdaa4b76 --- /dev/null +++ b/ddverify/goblint/conf/sbc60xxwdt.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.main.c", + "case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/sc1200wdt.json b/ddverify/goblint/conf/sc1200wdt.json new file mode 100644 index 000000000..a4c3bac8f --- /dev/null +++ b/ddverify/goblint/conf/sc1200wdt.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/char/watchdog/sc1200wdt/sc1200wdt.main.c", + "case_studies/char/watchdog/sc1200wdt/sc1200wdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/sc520_wdt.json b/ddverify/goblint/conf/sc520_wdt.json new file mode 100644 index 000000000..a17e75497 --- /dev/null +++ b/ddverify/goblint/conf/sc520_wdt.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/sc520_wdt/sc520_wdt.main.c", + "case_studies/char/watchdog/sc520_wdt/sc520_wdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/smsc37b787_wdt.json b/ddverify/goblint/conf/smsc37b787_wdt.json new file mode 100644 index 000000000..dd3e983c7 --- /dev/null +++ b/ddverify/goblint/conf/smsc37b787_wdt.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.main.c", + "case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/toshiba.json b/ddverify/goblint/conf/toshiba.json new file mode 100644 index 000000000..bd103f605 --- /dev/null +++ b/ddverify/goblint/conf/toshiba.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/toshiba/toshiba.main.c", + "case_studies/char/toshiba/toshiba.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/umem.json b/ddverify/goblint/conf/umem.json new file mode 100644 index 000000000..9cecf9d78 --- /dev/null +++ b/ddverify/goblint/conf/umem.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/block/umem/umem.main.c", + "case_studies/block/umem/umem.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_BLOCK", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/w83877f_wdt.json b/ddverify/goblint/conf/w83877f_wdt.json new file mode 100644 index 000000000..65cdc07fb --- /dev/null +++ b/ddverify/goblint/conf/w83877f_wdt.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.main.c", + "case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/w83977f_wdt.json b/ddverify/goblint/conf/w83977f_wdt.json new file mode 100644 index 000000000..771ba86a6 --- /dev/null +++ b/ddverify/goblint/conf/w83977f_wdt.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.main.c", + "case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt.json b/ddverify/goblint/conf/wdt.json new file mode 100644 index 000000000..0d54e635b --- /dev/null +++ b/ddverify/goblint/conf/wdt.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/wdt/wdt.main.c", + "case_studies/char/watchdog/wdt/wdt.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt977.json b/ddverify/goblint/conf/wdt977.json new file mode 100644 index 000000000..35b43c22e --- /dev/null +++ b/ddverify/goblint/conf/wdt977.json @@ -0,0 +1,47 @@ +{ + "files": [ + "case_studies/char/watchdog/wdt977/wdt977.main.c", + "case_studies/char/watchdog/wdt977/wdt977.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt_pci.json b/ddverify/goblint/conf/wdt_pci.json new file mode 100644 index 000000000..8ac9ace94 --- /dev/null +++ b/ddverify/goblint/conf/wdt_pci.json @@ -0,0 +1,48 @@ +{ + "files": [ + "case_studies/char/watchdog/wdt_pci/wdt_pci.main.c", + "case_studies/char/watchdog/wdt_pci/wdt_pci.c", + "models/con1/src/ddverify/cdev.c", + "models/con1/src/ddverify/ddverify.c", + "models/con1/src/ddverify/genhd.c", + "models/con1/src/ddverify/interrupt.c", + "models/con1/src/ddverify/ioctl.c", + "models/con1/src/ddverify/pci.c", + "models/con1/src/ddverify/tasklet.c", + "models/con1/src/ddverify/timer.c", + "models/con1/src/linux/arch/i386/lib/usercopy.c", + "models/con1/src/linux/block/elevator.c", + "models/con1/src/linux/block/genhd.c", + "models/con1/src/linux/block/ll_rw_blk.c", + "models/con1/src/linux/drivers/char/misc.c", + "models/con1/src/linux/drivers/char/tty_io.c", + "models/con1/src/linux/fs/char_dev.c", + "models/con1/src/linux/fs/proc/generic.c", + "models/con1/src/linux/fs/read_write.c", + "models/con1/src/linux/kernel/irq/manage.c", + "models/con1/src/linux/kernel/mutex.c", + "models/con1/src/linux/kernel/resource.c", + "models/con1/src/linux/kernel/sched.c", + "models/con1/src/linux/kernel/semaphore.c", + "models/con1/src/linux/kernel/softirq.c", + "models/con1/src/linux/kernel/spinlock.c", + "models/con1/src/linux/kernel/timer.c", + "models/con1/src/linux/kernel/wait.c", + "models/con1/src/linux/kernel/workqueue.c", + "models/con1/src/linux/mm/page_alloc.c", + "models/con1/src/linux/mm/slab.c", + "models/con1/src/linux/mm/vmalloc.c", + "models/con1/src/linux/pci.c" + ], + "pre": { + "includes": [ + "models/con1/include" + ], + "cppflags": [ + "-D__KERNEL__", + "-DMODULE", + "-DDRIVER_TYPE_CHAR", + "-DDRIVER_TYPE_PCI" + ] + } +} \ No newline at end of file diff --git a/ddverify/goblint/ddverify.py b/ddverify/goblint/ddverify.py new file mode 100755 index 000000000..e11e5c509 --- /dev/null +++ b/ddverify/goblint/ddverify.py @@ -0,0 +1,83 @@ +#!/usr/bin/python3 + +import sys +from pathlib import Path +from enum import Enum +import re +import json + + +module_path = Path(sys.argv[1]) +print(module_path) +other_paths = list(map(Path, sys.argv[2:])) + +module_init = None +module_exit = None + +class DriverType(Enum): + CHAR = 1 + BLOCK = 2 + +driver_type = None +driver_type_pci = False + +with module_path.open() as module_file: + for line in module_file: + m = re.match(r"^ *module_init\(([^)]*)\)", line) + if m: + module_init = m.group(1) + m = re.match(r"^ *module_exit\(([^)]*)\)", line) + if m: + module_exit = m.group(1) + m = re.match(r"^ *#include(.*)", line) + if m: + include = m.group(1) + if "" in include or "" in include: + driver_type = DriverType.CHAR + if "" in include: + driver_type = DriverType.BLOCK + if "" in include: + driver_type_pci = True + +assert module_init is not None +assert module_exit is not None +assert driver_type is not None + + +main_path = module_path.with_suffix(".main.c") +with main_path.open("w") as main_file: + main_file.write(f"""#include +#include "{module_path.name}" + +int main() {{ + _ddv_module_init = {module_init}; + _ddv_module_exit = {module_exit}; + call_ddv(); + + return 0; +}} +""") + +model_path = Path("models/con1") + +files = [main_path, module_path] + other_paths + sorted((model_path / "src").glob("**/*.c")) + +cppflags = ["-D__KERNEL__", "-DMODULE"] +if driver_type == DriverType.CHAR: + cppflags.append("-DDRIVER_TYPE_CHAR") +elif driver_type == DriverType.BLOCK: + cppflags.append("-DDRIVER_TYPE_BLOCK") +if driver_type_pci: # no elif! + cppflags.append("-DDRIVER_TYPE_PCI") + +goblint_conf = { + "files": list(map(str, files)), + "pre": { + "includes": [str(model_path / "include")], + "cppflags": cppflags + } +} + +conf_path = Path("goblint") / "conf" / (module_path.stem + ".json") +with open(conf_path, "w") as conf_file: + json.dump(goblint_conf, conf_file, indent=4) diff --git a/ddverify/goblint/ddverify.sh b/ddverify/goblint/ddverify.sh new file mode 100755 index 000000000..d58588e40 --- /dev/null +++ b/ddverify/goblint/ddverify.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# block +./goblint/ddverify.py case_studies/block/cciss/cciss.c case_studies/block/cciss/cciss_scsi.c +./goblint/ddverify.py case_studies/block/cpqarray/cpqarray.c +./goblint/ddverify.py case_studies/block/floppy/floppy.c +./goblint/ddverify.py case_studies/block/nbd/nbd.c +./goblint/ddverify.py case_studies/block/umem/umem.c + +# cdrom +./goblint/ddverify.py case_studies/cdrom/aztcd/aztcd.c +./goblint/ddverify.py case_studies/cdrom/cdu31a/cdu31a.c +./goblint/ddverify.py case_studies/cdrom/cm206/cm206.c + +# char +./goblint/ddverify.py case_studies/char/applicom/applicom.c +./goblint/ddverify.py case_studies/char/cs5535_gpio/cs5535_gpio.c +./goblint/ddverify.py case_studies/char/ds1286/ds1286.c +# no driver type +# ./goblint/ddverify.py case_studies/char/dtlk/dtlk.c +./goblint/ddverify.py case_studies/char/efirtc/efirtc.c +./goblint/ddverify.py case_studies/char/generic_nvram/generic_nvram.c +./goblint/ddverify.py case_studies/char/genrtc/genrtc.c +./goblint/ddverify.py case_studies/char/nwbutton/nwbutton.c +./goblint/ddverify.py case_studies/char/toshiba/toshiba.c + +# char/watchdog +./goblint/ddverify.py case_studies/char/watchdog/i8xx_tco/i8xx_tco.c +./goblint/ddverify.py case_studies/char/watchdog/ib700wdt/ib700wdt.c +./goblint/ddverify.py case_studies/char/watchdog/machzwd/machzwd.c +./goblint/ddverify.py case_studies/char/watchdog/mixcomwd/mixcomwd.c +./goblint/ddverify.py case_studies/char/watchdog/pcwd/pcwd.c +./goblint/ddverify.py case_studies/char/watchdog/pcwd_pci/pcwd_pci.c +./goblint/ddverify.py case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c +./goblint/ddverify.py case_studies/char/watchdog/sc520_wdt/sc520_wdt.c +./goblint/ddverify.py case_studies/char/watchdog/sc1200wdt/sc1200wdt.c +./goblint/ddverify.py case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c +./goblint/ddverify.py case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c +./goblint/ddverify.py case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c +./goblint/ddverify.py case_studies/char/watchdog/wdt/wdt.c +./goblint/ddverify.py case_studies/char/watchdog/wdt_pci/wdt_pci.c +./goblint/ddverify.py case_studies/char/watchdog/wdt977/wdt977.c From 37bf6bc2baf585892d8cf7e035757d765beab61b Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 10:51:53 +0300 Subject: [PATCH 07/24] Fix type cast in ddverify elevator stub --- ddverify/models/con1/src/linux/block/elevator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddverify/models/con1/src/linux/block/elevator.c b/ddverify/models/con1/src/linux/block/elevator.c index 8511b9dd9..4bd2ac41f 100644 --- a/ddverify/models/con1/src/linux/block/elevator.c +++ b/ddverify/models/con1/src/linux/block/elevator.c @@ -6,7 +6,7 @@ struct request *elv_next_request(request_queue_t *q) int genhd_no = q->__ddv_genhd_no; if (genhd_registered[genhd_no].requests_open > 0) { - return genhd_registered[genhd_no].current_request; + return &genhd_registered[genhd_no].current_request; } else { return NULL; } From cd22bffe1b1f5e81cdd7a523a45ff43f71624be7 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 10:53:33 +0300 Subject: [PATCH 08/24] Copy ddverify con1 model to goblint model --- ddverify/goblint/conf/applicom.json | 64 +- ddverify/goblint/conf/aztcd.json | 64 +- ddverify/goblint/conf/cciss.json | 64 +- ddverify/goblint/conf/cdu31a.json | 64 +- ddverify/goblint/conf/cm206.json | 64 +- ddverify/goblint/conf/cpqarray.json | 64 +- ddverify/goblint/conf/cs5535_gpio.json | 64 +- ddverify/goblint/conf/ds1286.json | 64 +- ddverify/goblint/conf/efirtc.json | 64 +- ddverify/goblint/conf/floppy.json | 64 +- ddverify/goblint/conf/generic_nvram.json | 64 +- ddverify/goblint/conf/genrtc.json | 64 +- ddverify/goblint/conf/i8xx_tco.json | 64 +- ddverify/goblint/conf/ib700wdt.json | 64 +- ddverify/goblint/conf/machzwd.json | 64 +- ddverify/goblint/conf/mixcomwd.json | 64 +- ddverify/goblint/conf/nbd.json | 64 +- ddverify/goblint/conf/nwbutton.json | 64 +- ddverify/goblint/conf/pcwd.json | 64 +- ddverify/goblint/conf/pcwd_pci.json | 64 +- ddverify/goblint/conf/sbc60xxwdt.json | 64 +- ddverify/goblint/conf/sc1200wdt.json | 64 +- ddverify/goblint/conf/sc520_wdt.json | 64 +- ddverify/goblint/conf/smsc37b787_wdt.json | 64 +- ddverify/goblint/conf/toshiba.json | 64 +- ddverify/goblint/conf/umem.json | 64 +- ddverify/goblint/conf/w83877f_wdt.json | 64 +- ddverify/goblint/conf/w83977f_wdt.json | 64 +- ddverify/goblint/conf/wdt.json | 64 +- ddverify/goblint/conf/wdt977.json | 64 +- ddverify/goblint/conf/wdt_pci.json | 64 +- ddverify/goblint/ddverify.py | 2 +- .../models/goblint/include/asm-generic/bug.h | 9 + .../goblint/include/asm-generic/errno-base.h | 39 + .../goblint/include/asm-generic/errno.h | 109 + .../goblint/include/asm-generic/fcntl.h | 110 + .../goblint/include/asm-generic/ioctl.h | 80 + .../include/asm-generic/pci-dma-compat.h | 20 + .../models/goblint/include/asm-generic/rtc.h | 18 + .../goblint/include/asm-generic/siginfo.h | 118 + ddverify/models/goblint/include/asm/atomic.h | 169 ++ ddverify/models/goblint/include/asm/bitops.h | 13 + ddverify/models/goblint/include/asm/bug.h | 7 + .../models/goblint/include/asm/byteorder.h | 9 + ddverify/models/goblint/include/asm/current.h | 14 + ddverify/models/goblint/include/asm/delay.h | 6 + ddverify/models/goblint/include/asm/dma.h | 72 + ddverify/models/goblint/include/asm/errno.h | 6 + ddverify/models/goblint/include/asm/fcntl.h | 1 + ddverify/models/goblint/include/asm/floppy.h | 45 + ddverify/models/goblint/include/asm/highmem.h | 17 + ddverify/models/goblint/include/asm/io.h | 69 + ddverify/models/goblint/include/asm/ioctl.h | 1 + ddverify/models/goblint/include/asm/ioctls.h | 91 + ddverify/models/goblint/include/asm/irq.h | 0 .../models/goblint/include/asm/kmap_types.h | 23 + ddverify/models/goblint/include/asm/leds.h | 0 .../models/goblint/include/asm/mach-types.h | 0 .../models/goblint/include/asm/mc146818rtc.h | 34 + ddverify/models/goblint/include/asm/msr.h | 10 + ddverify/models/goblint/include/asm/page.h | 24 + ddverify/models/goblint/include/asm/param.h | 8 + ddverify/models/goblint/include/asm/pci.h | 17 + ddverify/models/goblint/include/asm/poll.h | 20 + .../models/goblint/include/asm/posix_types.h | 32 + .../models/goblint/include/asm/processor.h | 6 + ddverify/models/goblint/include/asm/ptrace.h | 8 + ddverify/models/goblint/include/asm/rtc.h | 7 + .../models/goblint/include/asm/scatterlist.h | 21 + .../models/goblint/include/asm/semaphore.h | 37 + ddverify/models/goblint/include/asm/siginfo.h | 6 + ddverify/models/goblint/include/asm/signal.h | 86 + ddverify/models/goblint/include/asm/stat.h | 0 ddverify/models/goblint/include/asm/string.h | 6 + ddverify/models/goblint/include/asm/system.h | 9 + .../models/goblint/include/asm/termbits.h | 20 + ddverify/models/goblint/include/asm/termios.h | 54 + ddverify/models/goblint/include/asm/types.h | 35 + ddverify/models/goblint/include/asm/uaccess.h | 55 + .../models/goblint/include/ddverify/blkdev.h | 10 + .../models/goblint/include/ddverify/cdev.h | 26 + .../goblint/include/ddverify/ddverify.h | 47 + .../goblint/include/ddverify/fixed_cdev.h | 15 + .../models/goblint/include/ddverify/genhd.h | 29 + .../goblint/include/ddverify/interrupt.h | 19 + .../models/goblint/include/ddverify/ioctl.h | 15 + .../models/goblint/include/ddverify/ioport.h | 27 + .../goblint/include/ddverify/miscdevice.h | 7 + .../models/goblint/include/ddverify/pci.h | 22 + .../models/goblint/include/ddverify/pthread.h | 253 ++ .../models/goblint/include/ddverify/satabs.h | 69 + .../models/goblint/include/ddverify/tasklet.h | 20 + .../models/goblint/include/ddverify/timer.h | 17 + .../models/goblint/include/ddverify/tty.h | 16 + .../goblint/include/ddverify/workqueue.h | 12 + .../goblint/include/linux/backing-dev.h | 37 + ddverify/models/goblint/include/linux/bcd.h | 20 + ddverify/models/goblint/include/linux/bio.h | 110 + .../models/goblint/include/linux/bitops.h | 6 + .../models/goblint/include/linux/blkdev.h | 239 ++ ddverify/models/goblint/include/linux/blkpg.h | 0 .../goblint/include/linux/blktrace_api.h | 141 + .../goblint/include/linux/buffer_head.h | 0 .../goblint/include/linux/byteorder/generic.h | 46 + .../include/linux/byteorder/little_endian.h | 30 + ddverify/models/goblint/include/linux/cache.h | 0 .../models/goblint/include/linux/capability.h | 244 ++ ddverify/models/goblint/include/linux/cdev.h | 23 + ddverify/models/goblint/include/linux/cdrom.h | 1192 +++++++++ .../models/goblint/include/linux/compat.h | 0 .../models/goblint/include/linux/compiler.h | 20 + .../models/goblint/include/linux/completion.h | 18 + .../models/goblint/include/linux/config.h | 0 .../models/goblint/include/linux/console.h | 0 .../models/goblint/include/linux/cpumask.h | 0 ddverify/models/goblint/include/linux/ctype.h | 0 .../models/goblint/include/linux/dcache.h | 9 + ddverify/models/goblint/include/linux/delay.h | 22 + .../goblint/include/linux/devfs_fs_kernel.h | 0 .../models/goblint/include/linux/device.h | 112 + .../goblint/include/linux/dma-mapping.h | 19 + .../models/goblint/include/linux/elevator.h | 6 + ddverify/models/goblint/include/linux/err.h | 27 + ddverify/models/goblint/include/linux/errno.h | 25 + ddverify/models/goblint/include/linux/fcntl.h | 6 + ddverify/models/goblint/include/linux/fd.h | 373 +++ ddverify/models/goblint/include/linux/fdreg.h | 137 + ddverify/models/goblint/include/linux/file.h | 14 + .../models/goblint/include/linux/firmware.h | 22 + ddverify/models/goblint/include/linux/fs.h | 238 ++ ddverify/models/goblint/include/linux/genhd.h | 48 + ddverify/models/goblint/include/linux/gfp.h | 74 + ddverify/models/goblint/include/linux/hdreg.h | 13 + .../models/goblint/include/linux/highmem.h | 9 + ddverify/models/goblint/include/linux/if.h | 8 + ddverify/models/goblint/include/linux/in.h | 0 ddverify/models/goblint/include/linux/init.h | 23 + .../models/goblint/include/linux/interrupt.h | 96 + ddverify/models/goblint/include/linux/ioctl.h | 6 + .../models/goblint/include/linux/ioport.h | 102 + .../models/goblint/include/linux/jiffies.h | 84 + .../models/goblint/include/linux/kdb_kern.h | 0 .../models/goblint/include/linux/kdev_t.h | 11 + .../models/goblint/include/linux/kernel.h | 115 + .../models/goblint/include/linux/kobject.h | 34 + .../models/goblint/include/linux/kthread.h | 0 ddverify/models/goblint/include/linux/list.h | 108 + ddverify/models/goblint/include/linux/major.h | 169 ++ .../goblint/include/linux/mc146818rtc.h | 87 + .../models/goblint/include/linux/mempool.h | 11 + .../models/goblint/include/linux/miscdevice.h | 43 + ddverify/models/goblint/include/linux/mm.h | 17 + .../models/goblint/include/linux/mm_types.h | 14 + ddverify/models/goblint/include/linux/mman.h | 0 .../models/goblint/include/linux/mmzone.h | 16 + .../goblint/include/linux/mod_devicetable.h | 18 + .../models/goblint/include/linux/module.h | 32 + .../goblint/include/linux/moduleparam.h | 12 + ddverify/models/goblint/include/linux/mutex.h | 38 + ddverify/models/goblint/include/linux/net.h | 19 + .../models/goblint/include/linux/netdevice.h | 6 + .../models/goblint/include/linux/notifier.h | 61 + .../models/goblint/include/linux/pagemap.h | 15 + .../models/goblint/include/linux/parport.h | 559 ++++ .../models/goblint/include/linux/parport_pc.h | 42 + ddverify/models/goblint/include/linux/pci.h | 176 ++ .../models/goblint/include/linux/pci_ids.h | 2260 +++++++++++++++++ .../models/goblint/include/linux/pci_regs.h | 449 ++++ .../models/goblint/include/linux/percpu.h | 10 + .../goblint/include/linux/platform_device.h | 25 + ddverify/models/goblint/include/linux/pm.h | 12 + ddverify/models/goblint/include/linux/pnp.h | 0 ddverify/models/goblint/include/linux/poll.h | 16 + .../goblint/include/linux/posix_types.h | 9 + .../models/goblint/include/linux/proc_fs.h | 29 + .../models/goblint/include/linux/ptrace.h | 80 + .../models/goblint/include/linux/reboot.h | 75 + ddverify/models/goblint/include/linux/rtc.h | 219 ++ .../goblint/include/linux/scatterlist.h | 24 + ddverify/models/goblint/include/linux/sched.h | 62 + .../models/goblint/include/linux/seq_file.h | 35 + .../models/goblint/include/linux/serial.h | 131 + .../models/goblint/include/linux/signal.h | 54 + .../models/goblint/include/linux/skbuff.h | 6 + ddverify/models/goblint/include/linux/slab.h | 16 + .../models/goblint/include/linux/smp_lock.h | 12 + .../models/goblint/include/linux/socket.h | 109 + .../models/goblint/include/linux/spinlock.h | 20 + .../goblint/include/linux/spinlock_types.h | 21 + ddverify/models/goblint/include/linux/stat.h | 66 + .../models/goblint/include/linux/stddef.h | 20 + .../models/goblint/include/linux/string.h | 35 + .../models/goblint/include/linux/stringify.h | 12 + .../models/goblint/include/linux/suspend.h | 0 ddverify/models/goblint/include/linux/swap.h | 0 ddverify/models/goblint/include/linux/sysfs.h | 43 + ddverify/models/goblint/include/linux/sysrq.h | 0 .../models/goblint/include/linux/termios.h | 7 + .../models/goblint/include/linux/threads.h | 4 + ddverify/models/goblint/include/linux/time.h | 30 + ddverify/models/goblint/include/linux/timer.h | 34 + ddverify/models/goblint/include/linux/tty.h | 180 ++ .../models/goblint/include/linux/tty_driver.h | 166 ++ .../goblint/include/linux/tty_driver.h,v | 187 ++ .../models/goblint/include/linux/tty_flip.h | 13 + .../models/goblint/include/linux/tty_ldisc.h | 51 + ddverify/models/goblint/include/linux/types.h | 105 + ddverify/models/goblint/include/linux/uio.h | 12 + .../models/goblint/include/linux/videodev.h | 346 +++ .../models/goblint/include/linux/videodev2.h | 1351 ++++++++++ .../models/goblint/include/linux/vmalloc.h | 9 + ddverify/models/goblint/include/linux/wait.h | 91 + .../models/goblint/include/linux/watchdog.h | 52 + .../models/goblint/include/linux/workqueue.h | 50 + .../models/goblint/include/linux/writeback.h | 0 .../goblint/include/media/v4l2-common.h | 6 + .../models/goblint/include/media/v4l2-dev.h | 255 ++ ddverify/models/goblint/include/net/sock.h | 29 + ddverify/models/goblint/src/ddverify/cdev.c | 156 ++ .../models/goblint/src/ddverify/ddverify.c | 116 + ddverify/models/goblint/src/ddverify/genhd.c | 120 + .../models/goblint/src/ddverify/interrupt.c | 22 + ddverify/models/goblint/src/ddverify/ioctl.c | 19 + ddverify/models/goblint/src/ddverify/pci.c | 56 + .../models/goblint/src/ddverify/tasklet.c | 15 + ddverify/models/goblint/src/ddverify/timer.c | 13 + .../src/linux/arch/i386/lib/usercopy.c | 51 + .../models/goblint/src/linux/block/elevator.c | 13 + .../models/goblint/src/linux/block/genhd.c | 58 + .../goblint/src/linux/block/ll_rw_blk.c | 72 + .../goblint/src/linux/drivers/char/misc.c | 36 + .../goblint/src/linux/drivers/char/tty_io.c | 40 + .../models/goblint/src/linux/fs/char_dev.c | 110 + .../goblint/src/linux/fs/proc/generic.c | 7 + .../models/goblint/src/linux/fs/read_write.c | 9 + .../goblint/src/linux/kernel/irq/manage.c | 21 + .../models/goblint/src/linux/kernel/mutex.c | 37 + .../goblint/src/linux/kernel/resource.c | 117 + .../models/goblint/src/linux/kernel/sched.c | 18 + .../goblint/src/linux/kernel/semaphore.c | 86 + .../models/goblint/src/linux/kernel/softirq.c | 38 + .../goblint/src/linux/kernel/spinlock.c | 99 + .../models/goblint/src/linux/kernel/timer.c | 43 + .../models/goblint/src/linux/kernel/wait.c | 46 + .../goblint/src/linux/kernel/workqueue.c | 39 + .../models/goblint/src/linux/mm/page_alloc.c | 52 + ddverify/models/goblint/src/linux/mm/slab.c | 22 + .../models/goblint/src/linux/mm/vmalloc.c | 9 + ddverify/models/goblint/src/linux/pci.c | 109 + 249 files changed, 16817 insertions(+), 993 deletions(-) create mode 100644 ddverify/models/goblint/include/asm-generic/bug.h create mode 100644 ddverify/models/goblint/include/asm-generic/errno-base.h create mode 100644 ddverify/models/goblint/include/asm-generic/errno.h create mode 100644 ddverify/models/goblint/include/asm-generic/fcntl.h create mode 100644 ddverify/models/goblint/include/asm-generic/ioctl.h create mode 100644 ddverify/models/goblint/include/asm-generic/pci-dma-compat.h create mode 100644 ddverify/models/goblint/include/asm-generic/rtc.h create mode 100644 ddverify/models/goblint/include/asm-generic/siginfo.h create mode 100644 ddverify/models/goblint/include/asm/atomic.h create mode 100644 ddverify/models/goblint/include/asm/bitops.h create mode 100644 ddverify/models/goblint/include/asm/bug.h create mode 100644 ddverify/models/goblint/include/asm/byteorder.h create mode 100644 ddverify/models/goblint/include/asm/current.h create mode 100644 ddverify/models/goblint/include/asm/delay.h create mode 100644 ddverify/models/goblint/include/asm/dma.h create mode 100644 ddverify/models/goblint/include/asm/errno.h create mode 100644 ddverify/models/goblint/include/asm/fcntl.h create mode 100644 ddverify/models/goblint/include/asm/floppy.h create mode 100644 ddverify/models/goblint/include/asm/highmem.h create mode 100644 ddverify/models/goblint/include/asm/io.h create mode 100644 ddverify/models/goblint/include/asm/ioctl.h create mode 100644 ddverify/models/goblint/include/asm/ioctls.h create mode 100644 ddverify/models/goblint/include/asm/irq.h create mode 100644 ddverify/models/goblint/include/asm/kmap_types.h create mode 100644 ddverify/models/goblint/include/asm/leds.h create mode 100644 ddverify/models/goblint/include/asm/mach-types.h create mode 100644 ddverify/models/goblint/include/asm/mc146818rtc.h create mode 100644 ddverify/models/goblint/include/asm/msr.h create mode 100644 ddverify/models/goblint/include/asm/page.h create mode 100644 ddverify/models/goblint/include/asm/param.h create mode 100644 ddverify/models/goblint/include/asm/pci.h create mode 100644 ddverify/models/goblint/include/asm/poll.h create mode 100644 ddverify/models/goblint/include/asm/posix_types.h create mode 100644 ddverify/models/goblint/include/asm/processor.h create mode 100644 ddverify/models/goblint/include/asm/ptrace.h create mode 100644 ddverify/models/goblint/include/asm/rtc.h create mode 100644 ddverify/models/goblint/include/asm/scatterlist.h create mode 100644 ddverify/models/goblint/include/asm/semaphore.h create mode 100644 ddverify/models/goblint/include/asm/siginfo.h create mode 100644 ddverify/models/goblint/include/asm/signal.h create mode 100644 ddverify/models/goblint/include/asm/stat.h create mode 100644 ddverify/models/goblint/include/asm/string.h create mode 100644 ddverify/models/goblint/include/asm/system.h create mode 100644 ddverify/models/goblint/include/asm/termbits.h create mode 100644 ddverify/models/goblint/include/asm/termios.h create mode 100644 ddverify/models/goblint/include/asm/types.h create mode 100644 ddverify/models/goblint/include/asm/uaccess.h create mode 100644 ddverify/models/goblint/include/ddverify/blkdev.h create mode 100644 ddverify/models/goblint/include/ddverify/cdev.h create mode 100644 ddverify/models/goblint/include/ddverify/ddverify.h create mode 100644 ddverify/models/goblint/include/ddverify/fixed_cdev.h create mode 100644 ddverify/models/goblint/include/ddverify/genhd.h create mode 100644 ddverify/models/goblint/include/ddverify/interrupt.h create mode 100644 ddverify/models/goblint/include/ddverify/ioctl.h create mode 100644 ddverify/models/goblint/include/ddverify/ioport.h create mode 100644 ddverify/models/goblint/include/ddverify/miscdevice.h create mode 100644 ddverify/models/goblint/include/ddverify/pci.h create mode 100644 ddverify/models/goblint/include/ddverify/pthread.h create mode 100644 ddverify/models/goblint/include/ddverify/satabs.h create mode 100644 ddverify/models/goblint/include/ddverify/tasklet.h create mode 100644 ddverify/models/goblint/include/ddverify/timer.h create mode 100644 ddverify/models/goblint/include/ddverify/tty.h create mode 100644 ddverify/models/goblint/include/ddverify/workqueue.h create mode 100644 ddverify/models/goblint/include/linux/backing-dev.h create mode 100644 ddverify/models/goblint/include/linux/bcd.h create mode 100644 ddverify/models/goblint/include/linux/bio.h create mode 100644 ddverify/models/goblint/include/linux/bitops.h create mode 100644 ddverify/models/goblint/include/linux/blkdev.h create mode 100644 ddverify/models/goblint/include/linux/blkpg.h create mode 100644 ddverify/models/goblint/include/linux/blktrace_api.h create mode 100644 ddverify/models/goblint/include/linux/buffer_head.h create mode 100644 ddverify/models/goblint/include/linux/byteorder/generic.h create mode 100644 ddverify/models/goblint/include/linux/byteorder/little_endian.h create mode 100644 ddverify/models/goblint/include/linux/cache.h create mode 100644 ddverify/models/goblint/include/linux/capability.h create mode 100644 ddverify/models/goblint/include/linux/cdev.h create mode 100644 ddverify/models/goblint/include/linux/cdrom.h create mode 100644 ddverify/models/goblint/include/linux/compat.h create mode 100644 ddverify/models/goblint/include/linux/compiler.h create mode 100644 ddverify/models/goblint/include/linux/completion.h create mode 100644 ddverify/models/goblint/include/linux/config.h create mode 100644 ddverify/models/goblint/include/linux/console.h create mode 100644 ddverify/models/goblint/include/linux/cpumask.h create mode 100644 ddverify/models/goblint/include/linux/ctype.h create mode 100644 ddverify/models/goblint/include/linux/dcache.h create mode 100644 ddverify/models/goblint/include/linux/delay.h create mode 100644 ddverify/models/goblint/include/linux/devfs_fs_kernel.h create mode 100644 ddverify/models/goblint/include/linux/device.h create mode 100644 ddverify/models/goblint/include/linux/dma-mapping.h create mode 100644 ddverify/models/goblint/include/linux/elevator.h create mode 100644 ddverify/models/goblint/include/linux/err.h create mode 100644 ddverify/models/goblint/include/linux/errno.h create mode 100644 ddverify/models/goblint/include/linux/fcntl.h create mode 100644 ddverify/models/goblint/include/linux/fd.h create mode 100644 ddverify/models/goblint/include/linux/fdreg.h create mode 100644 ddverify/models/goblint/include/linux/file.h create mode 100644 ddverify/models/goblint/include/linux/firmware.h create mode 100644 ddverify/models/goblint/include/linux/fs.h create mode 100644 ddverify/models/goblint/include/linux/genhd.h create mode 100644 ddverify/models/goblint/include/linux/gfp.h create mode 100644 ddverify/models/goblint/include/linux/hdreg.h create mode 100644 ddverify/models/goblint/include/linux/highmem.h create mode 100644 ddverify/models/goblint/include/linux/if.h create mode 100644 ddverify/models/goblint/include/linux/in.h create mode 100644 ddverify/models/goblint/include/linux/init.h create mode 100644 ddverify/models/goblint/include/linux/interrupt.h create mode 100644 ddverify/models/goblint/include/linux/ioctl.h create mode 100644 ddverify/models/goblint/include/linux/ioport.h create mode 100644 ddverify/models/goblint/include/linux/jiffies.h create mode 100644 ddverify/models/goblint/include/linux/kdb_kern.h create mode 100644 ddverify/models/goblint/include/linux/kdev_t.h create mode 100644 ddverify/models/goblint/include/linux/kernel.h create mode 100644 ddverify/models/goblint/include/linux/kobject.h create mode 100644 ddverify/models/goblint/include/linux/kthread.h create mode 100644 ddverify/models/goblint/include/linux/list.h create mode 100644 ddverify/models/goblint/include/linux/major.h create mode 100644 ddverify/models/goblint/include/linux/mc146818rtc.h create mode 100644 ddverify/models/goblint/include/linux/mempool.h create mode 100644 ddverify/models/goblint/include/linux/miscdevice.h create mode 100644 ddverify/models/goblint/include/linux/mm.h create mode 100644 ddverify/models/goblint/include/linux/mm_types.h create mode 100644 ddverify/models/goblint/include/linux/mman.h create mode 100644 ddverify/models/goblint/include/linux/mmzone.h create mode 100644 ddverify/models/goblint/include/linux/mod_devicetable.h create mode 100644 ddverify/models/goblint/include/linux/module.h create mode 100644 ddverify/models/goblint/include/linux/moduleparam.h create mode 100644 ddverify/models/goblint/include/linux/mutex.h create mode 100644 ddverify/models/goblint/include/linux/net.h create mode 100644 ddverify/models/goblint/include/linux/netdevice.h create mode 100644 ddverify/models/goblint/include/linux/notifier.h create mode 100644 ddverify/models/goblint/include/linux/pagemap.h create mode 100644 ddverify/models/goblint/include/linux/parport.h create mode 100644 ddverify/models/goblint/include/linux/parport_pc.h create mode 100644 ddverify/models/goblint/include/linux/pci.h create mode 100644 ddverify/models/goblint/include/linux/pci_ids.h create mode 100644 ddverify/models/goblint/include/linux/pci_regs.h create mode 100644 ddverify/models/goblint/include/linux/percpu.h create mode 100644 ddverify/models/goblint/include/linux/platform_device.h create mode 100644 ddverify/models/goblint/include/linux/pm.h create mode 100644 ddverify/models/goblint/include/linux/pnp.h create mode 100644 ddverify/models/goblint/include/linux/poll.h create mode 100644 ddverify/models/goblint/include/linux/posix_types.h create mode 100644 ddverify/models/goblint/include/linux/proc_fs.h create mode 100644 ddverify/models/goblint/include/linux/ptrace.h create mode 100644 ddverify/models/goblint/include/linux/reboot.h create mode 100644 ddverify/models/goblint/include/linux/rtc.h create mode 100644 ddverify/models/goblint/include/linux/scatterlist.h create mode 100644 ddverify/models/goblint/include/linux/sched.h create mode 100644 ddverify/models/goblint/include/linux/seq_file.h create mode 100644 ddverify/models/goblint/include/linux/serial.h create mode 100644 ddverify/models/goblint/include/linux/signal.h create mode 100644 ddverify/models/goblint/include/linux/skbuff.h create mode 100644 ddverify/models/goblint/include/linux/slab.h create mode 100644 ddverify/models/goblint/include/linux/smp_lock.h create mode 100644 ddverify/models/goblint/include/linux/socket.h create mode 100644 ddverify/models/goblint/include/linux/spinlock.h create mode 100644 ddverify/models/goblint/include/linux/spinlock_types.h create mode 100644 ddverify/models/goblint/include/linux/stat.h create mode 100644 ddverify/models/goblint/include/linux/stddef.h create mode 100644 ddverify/models/goblint/include/linux/string.h create mode 100644 ddverify/models/goblint/include/linux/stringify.h create mode 100644 ddverify/models/goblint/include/linux/suspend.h create mode 100644 ddverify/models/goblint/include/linux/swap.h create mode 100644 ddverify/models/goblint/include/linux/sysfs.h create mode 100644 ddverify/models/goblint/include/linux/sysrq.h create mode 100644 ddverify/models/goblint/include/linux/termios.h create mode 100644 ddverify/models/goblint/include/linux/threads.h create mode 100644 ddverify/models/goblint/include/linux/time.h create mode 100644 ddverify/models/goblint/include/linux/timer.h create mode 100644 ddverify/models/goblint/include/linux/tty.h create mode 100644 ddverify/models/goblint/include/linux/tty_driver.h create mode 100644 ddverify/models/goblint/include/linux/tty_driver.h,v create mode 100644 ddverify/models/goblint/include/linux/tty_flip.h create mode 100644 ddverify/models/goblint/include/linux/tty_ldisc.h create mode 100644 ddverify/models/goblint/include/linux/types.h create mode 100644 ddverify/models/goblint/include/linux/uio.h create mode 100644 ddverify/models/goblint/include/linux/videodev.h create mode 100644 ddverify/models/goblint/include/linux/videodev2.h create mode 100644 ddverify/models/goblint/include/linux/vmalloc.h create mode 100644 ddverify/models/goblint/include/linux/wait.h create mode 100644 ddverify/models/goblint/include/linux/watchdog.h create mode 100644 ddverify/models/goblint/include/linux/workqueue.h create mode 100644 ddverify/models/goblint/include/linux/writeback.h create mode 100644 ddverify/models/goblint/include/media/v4l2-common.h create mode 100644 ddverify/models/goblint/include/media/v4l2-dev.h create mode 100644 ddverify/models/goblint/include/net/sock.h create mode 100644 ddverify/models/goblint/src/ddverify/cdev.c create mode 100644 ddverify/models/goblint/src/ddverify/ddverify.c create mode 100644 ddverify/models/goblint/src/ddverify/genhd.c create mode 100644 ddverify/models/goblint/src/ddverify/interrupt.c create mode 100644 ddverify/models/goblint/src/ddverify/ioctl.c create mode 100644 ddverify/models/goblint/src/ddverify/pci.c create mode 100644 ddverify/models/goblint/src/ddverify/tasklet.c create mode 100644 ddverify/models/goblint/src/ddverify/timer.c create mode 100644 ddverify/models/goblint/src/linux/arch/i386/lib/usercopy.c create mode 100644 ddverify/models/goblint/src/linux/block/elevator.c create mode 100644 ddverify/models/goblint/src/linux/block/genhd.c create mode 100644 ddverify/models/goblint/src/linux/block/ll_rw_blk.c create mode 100644 ddverify/models/goblint/src/linux/drivers/char/misc.c create mode 100644 ddverify/models/goblint/src/linux/drivers/char/tty_io.c create mode 100644 ddverify/models/goblint/src/linux/fs/char_dev.c create mode 100644 ddverify/models/goblint/src/linux/fs/proc/generic.c create mode 100644 ddverify/models/goblint/src/linux/fs/read_write.c create mode 100644 ddverify/models/goblint/src/linux/kernel/irq/manage.c create mode 100644 ddverify/models/goblint/src/linux/kernel/mutex.c create mode 100644 ddverify/models/goblint/src/linux/kernel/resource.c create mode 100644 ddverify/models/goblint/src/linux/kernel/sched.c create mode 100644 ddverify/models/goblint/src/linux/kernel/semaphore.c create mode 100644 ddverify/models/goblint/src/linux/kernel/softirq.c create mode 100644 ddverify/models/goblint/src/linux/kernel/spinlock.c create mode 100644 ddverify/models/goblint/src/linux/kernel/timer.c create mode 100644 ddverify/models/goblint/src/linux/kernel/wait.c create mode 100644 ddverify/models/goblint/src/linux/kernel/workqueue.c create mode 100644 ddverify/models/goblint/src/linux/mm/page_alloc.c create mode 100644 ddverify/models/goblint/src/linux/mm/slab.c create mode 100644 ddverify/models/goblint/src/linux/mm/vmalloc.c create mode 100644 ddverify/models/goblint/src/linux/pci.c diff --git a/ddverify/goblint/conf/applicom.json b/ddverify/goblint/conf/applicom.json index 5dc9a1f2b..3c68ff9c2 100644 --- a/ddverify/goblint/conf/applicom.json +++ b/ddverify/goblint/conf/applicom.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/applicom/applicom.main.c", "case_studies/char/applicom/applicom.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/aztcd.json b/ddverify/goblint/conf/aztcd.json index 9454da005..9f3c5234b 100644 --- a/ddverify/goblint/conf/aztcd.json +++ b/ddverify/goblint/conf/aztcd.json @@ -2,41 +2,41 @@ "files": [ "case_studies/cdrom/aztcd/aztcd.main.c", "case_studies/cdrom/aztcd/aztcd.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/cciss.json b/ddverify/goblint/conf/cciss.json index ec1c1a91e..75a08fd86 100644 --- a/ddverify/goblint/conf/cciss.json +++ b/ddverify/goblint/conf/cciss.json @@ -3,41 +3,41 @@ "case_studies/block/cciss/cciss.main.c", "case_studies/block/cciss/cciss.c", "case_studies/block/cciss/cciss_scsi.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/cdu31a.json b/ddverify/goblint/conf/cdu31a.json index a26e84549..d9bf7216e 100644 --- a/ddverify/goblint/conf/cdu31a.json +++ b/ddverify/goblint/conf/cdu31a.json @@ -2,41 +2,41 @@ "files": [ "case_studies/cdrom/cdu31a/cdu31a.main.c", "case_studies/cdrom/cdu31a/cdu31a.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/cm206.json b/ddverify/goblint/conf/cm206.json index 8a37e27a0..6be68bab9 100644 --- a/ddverify/goblint/conf/cm206.json +++ b/ddverify/goblint/conf/cm206.json @@ -2,41 +2,41 @@ "files": [ "case_studies/cdrom/cm206/cm206.main.c", "case_studies/cdrom/cm206/cm206.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json index 96da01ebc..ed4b4b730 100644 --- a/ddverify/goblint/conf/cpqarray.json +++ b/ddverify/goblint/conf/cpqarray.json @@ -2,41 +2,41 @@ "files": [ "case_studies/block/cpqarray/cpqarray.main.c", "case_studies/block/cpqarray/cpqarray.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/cs5535_gpio.json b/ddverify/goblint/conf/cs5535_gpio.json index 5c12d72c0..f730603f1 100644 --- a/ddverify/goblint/conf/cs5535_gpio.json +++ b/ddverify/goblint/conf/cs5535_gpio.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/cs5535_gpio/cs5535_gpio.main.c", "case_studies/char/cs5535_gpio/cs5535_gpio.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/ds1286.json b/ddverify/goblint/conf/ds1286.json index a43a1dbbc..14e2a0e96 100644 --- a/ddverify/goblint/conf/ds1286.json +++ b/ddverify/goblint/conf/ds1286.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/ds1286/ds1286.main.c", "case_studies/char/ds1286/ds1286.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/efirtc.json b/ddverify/goblint/conf/efirtc.json index 95ff7f966..6299a62bc 100644 --- a/ddverify/goblint/conf/efirtc.json +++ b/ddverify/goblint/conf/efirtc.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/efirtc/efirtc.main.c", "case_studies/char/efirtc/efirtc.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/floppy.json b/ddverify/goblint/conf/floppy.json index df3cd0a49..3e04fca42 100644 --- a/ddverify/goblint/conf/floppy.json +++ b/ddverify/goblint/conf/floppy.json @@ -2,41 +2,41 @@ "files": [ "case_studies/block/floppy/floppy.main.c", "case_studies/block/floppy/floppy.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/generic_nvram.json b/ddverify/goblint/conf/generic_nvram.json index c12787a86..e84d4fab7 100644 --- a/ddverify/goblint/conf/generic_nvram.json +++ b/ddverify/goblint/conf/generic_nvram.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/generic_nvram/generic_nvram.main.c", "case_studies/char/generic_nvram/generic_nvram.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/genrtc.json b/ddverify/goblint/conf/genrtc.json index f7a9c5e16..932761a6a 100644 --- a/ddverify/goblint/conf/genrtc.json +++ b/ddverify/goblint/conf/genrtc.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/genrtc/genrtc.main.c", "case_studies/char/genrtc/genrtc.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/i8xx_tco.json b/ddverify/goblint/conf/i8xx_tco.json index 4ed9193bb..d82c49f51 100644 --- a/ddverify/goblint/conf/i8xx_tco.json +++ b/ddverify/goblint/conf/i8xx_tco.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/i8xx_tco/i8xx_tco.main.c", "case_studies/char/watchdog/i8xx_tco/i8xx_tco.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/ib700wdt.json b/ddverify/goblint/conf/ib700wdt.json index 7271a0770..481b57354 100644 --- a/ddverify/goblint/conf/ib700wdt.json +++ b/ddverify/goblint/conf/ib700wdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/ib700wdt/ib700wdt.main.c", "case_studies/char/watchdog/ib700wdt/ib700wdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/machzwd.json b/ddverify/goblint/conf/machzwd.json index 772553686..05aedd8fe 100644 --- a/ddverify/goblint/conf/machzwd.json +++ b/ddverify/goblint/conf/machzwd.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/machzwd/machzwd.main.c", "case_studies/char/watchdog/machzwd/machzwd.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/mixcomwd.json b/ddverify/goblint/conf/mixcomwd.json index 517e3bb0b..7e6497507 100644 --- a/ddverify/goblint/conf/mixcomwd.json +++ b/ddverify/goblint/conf/mixcomwd.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/mixcomwd/mixcomwd.main.c", "case_studies/char/watchdog/mixcomwd/mixcomwd.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/nbd.json b/ddverify/goblint/conf/nbd.json index 57880ef34..050f2d58e 100644 --- a/ddverify/goblint/conf/nbd.json +++ b/ddverify/goblint/conf/nbd.json @@ -2,41 +2,41 @@ "files": [ "case_studies/block/nbd/nbd.main.c", "case_studies/block/nbd/nbd.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/nwbutton.json b/ddverify/goblint/conf/nwbutton.json index 6c09c7849..c5de6f4ab 100644 --- a/ddverify/goblint/conf/nwbutton.json +++ b/ddverify/goblint/conf/nwbutton.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/nwbutton/nwbutton.main.c", "case_studies/char/nwbutton/nwbutton.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/pcwd.json b/ddverify/goblint/conf/pcwd.json index 128e1e9de..0dcc3effb 100644 --- a/ddverify/goblint/conf/pcwd.json +++ b/ddverify/goblint/conf/pcwd.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/pcwd/pcwd.main.c", "case_studies/char/watchdog/pcwd/pcwd.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/pcwd_pci.json b/ddverify/goblint/conf/pcwd_pci.json index a16d80ec7..76adbe2ab 100644 --- a/ddverify/goblint/conf/pcwd_pci.json +++ b/ddverify/goblint/conf/pcwd_pci.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/pcwd_pci/pcwd_pci.main.c", "case_studies/char/watchdog/pcwd_pci/pcwd_pci.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/sbc60xxwdt.json b/ddverify/goblint/conf/sbc60xxwdt.json index 0fdaa4b76..b2812954b 100644 --- a/ddverify/goblint/conf/sbc60xxwdt.json +++ b/ddverify/goblint/conf/sbc60xxwdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.main.c", "case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/sc1200wdt.json b/ddverify/goblint/conf/sc1200wdt.json index a4c3bac8f..83dd7e507 100644 --- a/ddverify/goblint/conf/sc1200wdt.json +++ b/ddverify/goblint/conf/sc1200wdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/sc1200wdt/sc1200wdt.main.c", "case_studies/char/watchdog/sc1200wdt/sc1200wdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/sc520_wdt.json b/ddverify/goblint/conf/sc520_wdt.json index a17e75497..df06a5137 100644 --- a/ddverify/goblint/conf/sc520_wdt.json +++ b/ddverify/goblint/conf/sc520_wdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/sc520_wdt/sc520_wdt.main.c", "case_studies/char/watchdog/sc520_wdt/sc520_wdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/smsc37b787_wdt.json b/ddverify/goblint/conf/smsc37b787_wdt.json index dd3e983c7..fa3d5f28b 100644 --- a/ddverify/goblint/conf/smsc37b787_wdt.json +++ b/ddverify/goblint/conf/smsc37b787_wdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.main.c", "case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/toshiba.json b/ddverify/goblint/conf/toshiba.json index bd103f605..c52bf530b 100644 --- a/ddverify/goblint/conf/toshiba.json +++ b/ddverify/goblint/conf/toshiba.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/toshiba/toshiba.main.c", "case_studies/char/toshiba/toshiba.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/umem.json b/ddverify/goblint/conf/umem.json index 9cecf9d78..0aac8aa72 100644 --- a/ddverify/goblint/conf/umem.json +++ b/ddverify/goblint/conf/umem.json @@ -2,41 +2,41 @@ "files": [ "case_studies/block/umem/umem.main.c", "case_studies/block/umem/umem.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/w83877f_wdt.json b/ddverify/goblint/conf/w83877f_wdt.json index 65cdc07fb..f9794aaaf 100644 --- a/ddverify/goblint/conf/w83877f_wdt.json +++ b/ddverify/goblint/conf/w83877f_wdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.main.c", "case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/w83977f_wdt.json b/ddverify/goblint/conf/w83977f_wdt.json index 771ba86a6..4dc977b57 100644 --- a/ddverify/goblint/conf/w83977f_wdt.json +++ b/ddverify/goblint/conf/w83977f_wdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.main.c", "case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/wdt.json b/ddverify/goblint/conf/wdt.json index 0d54e635b..4abecd452 100644 --- a/ddverify/goblint/conf/wdt.json +++ b/ddverify/goblint/conf/wdt.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/wdt/wdt.main.c", "case_studies/char/watchdog/wdt/wdt.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/wdt977.json b/ddverify/goblint/conf/wdt977.json index 35b43c22e..e9f758083 100644 --- a/ddverify/goblint/conf/wdt977.json +++ b/ddverify/goblint/conf/wdt977.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/wdt977/wdt977.main.c", "case_studies/char/watchdog/wdt977/wdt977.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/conf/wdt_pci.json b/ddverify/goblint/conf/wdt_pci.json index 8ac9ace94..86ea99ee5 100644 --- a/ddverify/goblint/conf/wdt_pci.json +++ b/ddverify/goblint/conf/wdt_pci.json @@ -2,41 +2,41 @@ "files": [ "case_studies/char/watchdog/wdt_pci/wdt_pci.main.c", "case_studies/char/watchdog/wdt_pci/wdt_pci.c", - "models/con1/src/ddverify/cdev.c", - "models/con1/src/ddverify/ddverify.c", - "models/con1/src/ddverify/genhd.c", - "models/con1/src/ddverify/interrupt.c", - "models/con1/src/ddverify/ioctl.c", - "models/con1/src/ddverify/pci.c", - "models/con1/src/ddverify/tasklet.c", - "models/con1/src/ddverify/timer.c", - "models/con1/src/linux/arch/i386/lib/usercopy.c", - "models/con1/src/linux/block/elevator.c", - "models/con1/src/linux/block/genhd.c", - "models/con1/src/linux/block/ll_rw_blk.c", - "models/con1/src/linux/drivers/char/misc.c", - "models/con1/src/linux/drivers/char/tty_io.c", - "models/con1/src/linux/fs/char_dev.c", - "models/con1/src/linux/fs/proc/generic.c", - "models/con1/src/linux/fs/read_write.c", - "models/con1/src/linux/kernel/irq/manage.c", - "models/con1/src/linux/kernel/mutex.c", - "models/con1/src/linux/kernel/resource.c", - "models/con1/src/linux/kernel/sched.c", - "models/con1/src/linux/kernel/semaphore.c", - "models/con1/src/linux/kernel/softirq.c", - "models/con1/src/linux/kernel/spinlock.c", - "models/con1/src/linux/kernel/timer.c", - "models/con1/src/linux/kernel/wait.c", - "models/con1/src/linux/kernel/workqueue.c", - "models/con1/src/linux/mm/page_alloc.c", - "models/con1/src/linux/mm/slab.c", - "models/con1/src/linux/mm/vmalloc.c", - "models/con1/src/linux/pci.c" + "models/goblint/src/ddverify/cdev.c", + "models/goblint/src/ddverify/ddverify.c", + "models/goblint/src/ddverify/genhd.c", + "models/goblint/src/ddverify/interrupt.c", + "models/goblint/src/ddverify/ioctl.c", + "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/tasklet.c", + "models/goblint/src/ddverify/timer.c", + "models/goblint/src/linux/arch/i386/lib/usercopy.c", + "models/goblint/src/linux/block/elevator.c", + "models/goblint/src/linux/block/genhd.c", + "models/goblint/src/linux/block/ll_rw_blk.c", + "models/goblint/src/linux/drivers/char/misc.c", + "models/goblint/src/linux/drivers/char/tty_io.c", + "models/goblint/src/linux/fs/char_dev.c", + "models/goblint/src/linux/fs/proc/generic.c", + "models/goblint/src/linux/fs/read_write.c", + "models/goblint/src/linux/kernel/irq/manage.c", + "models/goblint/src/linux/kernel/mutex.c", + "models/goblint/src/linux/kernel/resource.c", + "models/goblint/src/linux/kernel/sched.c", + "models/goblint/src/linux/kernel/semaphore.c", + "models/goblint/src/linux/kernel/softirq.c", + "models/goblint/src/linux/kernel/spinlock.c", + "models/goblint/src/linux/kernel/timer.c", + "models/goblint/src/linux/kernel/wait.c", + "models/goblint/src/linux/kernel/workqueue.c", + "models/goblint/src/linux/mm/page_alloc.c", + "models/goblint/src/linux/mm/slab.c", + "models/goblint/src/linux/mm/vmalloc.c", + "models/goblint/src/linux/pci.c" ], "pre": { "includes": [ - "models/con1/include" + "models/goblint/include" ], "cppflags": [ "-D__KERNEL__", diff --git a/ddverify/goblint/ddverify.py b/ddverify/goblint/ddverify.py index e11e5c509..fc9e340fc 100755 --- a/ddverify/goblint/ddverify.py +++ b/ddverify/goblint/ddverify.py @@ -58,7 +58,7 @@ class DriverType(Enum): }} """) -model_path = Path("models/con1") +model_path = Path("models/goblint") files = [main_path, module_path] + other_paths + sorted((model_path / "src").glob("**/*.c")) diff --git a/ddverify/models/goblint/include/asm-generic/bug.h b/ddverify/models/goblint/include/asm-generic/bug.h new file mode 100644 index 000000000..18a3c237d --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/bug.h @@ -0,0 +1,9 @@ +#ifndef _ASM_GENERIC_BUG_H +#define _ASM_GENERIC_BUG_H + +#include +#include + +#define BUG_ON(condition) __CPROVER_assume(condition) + +#endif diff --git a/ddverify/models/goblint/include/asm-generic/errno-base.h b/ddverify/models/goblint/include/asm-generic/errno-base.h new file mode 100644 index 000000000..651159785 --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/errno-base.h @@ -0,0 +1,39 @@ +#ifndef _ASM_GENERIC_ERRNO_BASE_H +#define _ASM_GENERIC_ERRNO_BASE_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#endif diff --git a/ddverify/models/goblint/include/asm-generic/errno.h b/ddverify/models/goblint/include/asm-generic/errno.h new file mode 100644 index 000000000..e8852c092 --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/errno.h @@ -0,0 +1,109 @@ +#ifndef _ASM_GENERIC_ERRNO_H +#define _ASM_GENERIC_ERRNO_H + +#include + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* for robust mutexes */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ + +#endif diff --git a/ddverify/models/goblint/include/asm-generic/fcntl.h b/ddverify/models/goblint/include/asm-generic/fcntl.h new file mode 100644 index 000000000..897b3f5a5 --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/fcntl.h @@ -0,0 +1,110 @@ +#ifndef _ASM_GENERIC_FCNTL_H +#define _ASM_GENERIC_FCNTL_H + +#include +#include + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 00000003 +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 +#ifndef O_CREAT +#define O_CREAT 00000100 /* not fcntl */ +#endif +#ifndef O_EXCL +#define O_EXCL 00000200 /* not fcntl */ +#endif +#ifndef O_NOCTTY +#define O_NOCTTY 00000400 /* not fcntl */ +#endif +#ifndef O_TRUNC +#define O_TRUNC 00001000 /* not fcntl */ +#endif +#ifndef O_APPEND +#define O_APPEND 00002000 +#endif +#ifndef O_NONBLOCK +#define O_NONBLOCK 00004000 +#endif +#ifndef O_SYNC +#define O_SYNC 00010000 +#endif +#ifndef FASYNC +#define FASYNC 00020000 /* fcntl, for BSD compatibility */ +#endif +#ifndef O_DIRECT +#define O_DIRECT 00040000 /* direct disk access hint */ +#endif +#ifndef O_LARGEFILE +#define O_LARGEFILE 00100000 +#endif +#ifndef O_DIRECTORY +#define O_DIRECTORY 00200000 /* must be a directory */ +#endif +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 00400000 /* don't follow links */ +#endif +#ifndef O_NOATIME +#define O_NOATIME 01000000 +#endif +#ifndef O_NDELAY +#define O_NDELAY O_NONBLOCK +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get close_on_exec */ +#define F_SETFD 2 /* set/clear close_on_exec */ +#define F_GETFL 3 /* get file->f_flags */ +#define F_SETFL 4 /* set file->f_flags */ +#ifndef F_GETLK +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#endif +#ifndef F_SETOWN +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ +#endif +#ifndef F_SETSIG +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ +#endif + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#ifndef F_RDLCK +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 +#endif + +/* for old implementation of bsd flock () */ +#ifndef F_EXLCK +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ +#endif + +/* for leases */ +#ifndef F_INPROGRESS +#define F_INPROGRESS 16 +#endif + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#define LOCK_MAND 32 /* This is a mandatory flock ... */ +#define LOCK_READ 64 /* which allows concurrent read operations */ +#define LOCK_WRITE 128 /* which allows concurrent write operations */ +#define LOCK_RW 192 /* which allows concurrent read & write ops */ + +#define F_LINUX_SPECIFIC_BASE 1024 + +#endif /* _ASM_GENERIC_FCNTL_H */ diff --git a/ddverify/models/goblint/include/asm-generic/ioctl.h b/ddverify/models/goblint/include/asm-generic/ioctl.h new file mode 100644 index 000000000..cd027298b --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/ioctl.h @@ -0,0 +1,80 @@ +#ifndef _ASM_GENERIC_IOCTL_H +#define _ASM_GENERIC_IOCTL_H + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The generic ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits. + */ +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __invalid_size_argument_for_IOC; +#define _IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ + sizeof(t) : __invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#endif /* _ASM_GENERIC_IOCTL_H */ diff --git a/ddverify/models/goblint/include/asm-generic/pci-dma-compat.h b/ddverify/models/goblint/include/asm-generic/pci-dma-compat.h new file mode 100644 index 000000000..4bb451317 --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/pci-dma-compat.h @@ -0,0 +1,20 @@ +/* include this file if the platform implements the dma_ DMA Mapping API + * and wants to provide the pci_ DMA Mapping API in terms of it */ + +#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H +#define _ASM_GENERIC_PCI_DMA_COMPAT_H + +void * pci_alloc_consistent(struct pci_dev *hwdev, size_t size, + dma_addr_t *dma_handle); + +void pci_free_consistent(struct pci_dev *hwdev, size_t size, + void *vaddr, dma_addr_t dma_handle); + +dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction); +void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction); + +dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page, + unsigned long offset, size_t size, int direction); +void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, + size_t size, int direction); +#endif diff --git a/ddverify/models/goblint/include/asm-generic/rtc.h b/ddverify/models/goblint/include/asm-generic/rtc.h new file mode 100644 index 000000000..a8a13c916 --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/rtc.h @@ -0,0 +1,18 @@ +#ifndef __ASM_GENERIC_RTC_H__ +#define __ASM_GENERIC_RTC_H__ + +#include +#include + +#define RTC_PIE 0x40 /* periodic interrupt enable */ +#define RTC_AIE 0x20 /* alarm interrupt enable */ +#define RTC_UIE 0x10 /* update-finished interrupt enable */ + +/* some dummy definitions */ +#define RTC_BATT_BAD 0x100 /* battery bad */ +#define RTC_SQWE 0x08 /* enable square-wave output */ +#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +#endif diff --git a/ddverify/models/goblint/include/asm-generic/siginfo.h b/ddverify/models/goblint/include/asm-generic/siginfo.h new file mode 100644 index 000000000..383411b5c --- /dev/null +++ b/ddverify/models/goblint/include/asm-generic/siginfo.h @@ -0,0 +1,118 @@ +#ifndef _ASM_GENERIC_SIGINFO_H +#define _ASM_GENERIC_SIGINFO_H + +#include +#include + +/* + * This is the size (including padding) of the part of the + * struct siginfo that is before the union. + */ +#ifndef __ARCH_SI_PREAMBLE_SIZE +#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) +#endif + +#define SI_MAX_SIZE 128 +#ifndef SI_PAD_SIZE +#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) +#endif + +#ifndef __ARCH_SI_UID_T +#define __ARCH_SI_UID_T uid_t +#endif + +/* + * The default "si_band" type is "long", as specified by POSIX. + * However, some architectures want to override this to "int" + * for historical compatibility reasons, so we allow that. + */ +#ifndef __ARCH_SI_BAND_T +#define __ARCH_SI_BAND_T long +#endif + + +#define __SI_MASK 0xffff0000u +#define __SI_KILL (0 << 16) +#define __SI_TIMER (1 << 16) +#define __SI_POLL (2 << 16) +#define __SI_FAULT (3 << 16) +#define __SI_CHLD (4 << 16) +#define __SI_RT (5 << 16) +#define __SI_MESGQ (6 << 16) + + +/* + * SIGILL si_codes + */ +#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ +#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ +#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ +#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ +#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ +#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ +#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ +#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ +#define NSIGILL 8 + +/* + * SIGFPE si_codes + */ +#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ +#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ +#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ +#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ +#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ +#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ +#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ +#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ +#define NSIGFPE 8 + +/* + * SIGSEGV si_codes + */ +#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ +#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ +#define NSIGSEGV 2 + +/* + * SIGBUS si_codes + */ +#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ +#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ +#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ +#define NSIGBUS 3 + +/* + * SIGTRAP si_codes + */ +#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ +#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ +#define NSIGTRAP 2 + +/* + * SIGCHLD si_codes + */ +#define CLD_EXITED (__SI_CHLD|1) /* child has exited */ +#define CLD_KILLED (__SI_CHLD|2) /* child was killed */ +#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ +#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ +#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ +#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ +#define NSIGCHLD 6 + +/* + * SIGPOLL si_codes + */ +#define POLL_IN (__SI_POLL|1) /* data input available */ +#define POLL_OUT (__SI_POLL|2) /* output buffers available */ +#define POLL_MSG (__SI_POLL|3) /* input message available */ +#define POLL_ERR (__SI_POLL|4) /* i/o error */ +#define POLL_PRI (__SI_POLL|5) /* high priority input available */ +#define POLL_HUP (__SI_POLL|6) /* device disconnected */ +#define NSIGPOLL 6 + +typedef struct siginfo { + int something; +} siginfo_t; + +#endif diff --git a/ddverify/models/goblint/include/asm/atomic.h b/ddverify/models/goblint/include/asm/atomic.h new file mode 100644 index 000000000..226e1b397 --- /dev/null +++ b/ddverify/models/goblint/include/asm/atomic.h @@ -0,0 +1,169 @@ +#ifndef __ARCH_I386_ATOMIC__ +#define __ARCH_I386_ATOMIC__ + +#include + +typedef int atomic_t; + +#define ATOMIC_INIT(i) { (i) } + +/** + * atomic_read - read atomic variable + * @v: pointer of type atomic_t + * + * Atomically reads the value of @v. + */ +#define atomic_read(v) (*v) + +/** + * atomic_set - set atomic variable + * @v: pointer of type atomic_t + * @i: required value + * + * Atomically sets the value of @v to @i. + */ +#define atomic_set(v,i) (*v) = i + +/** + * atomic_add - add integer to atomic variable + * @i: integer value to add + * @v: pointer of type atomic_t + * + * Atomically adds @i to @v. + */ +static __inline__ void atomic_add(int i, atomic_t *v) +{ + (*v) = (*v) + i; +} + +/** + * atomic_sub - subtract the atomic variable + * @i: integer value to subtract + * @v: pointer of type atomic_t + * + * Atomically subtracts @i from @v. + */ +static __inline__ void atomic_sub(int i, atomic_t *v) +{ + (*v) = (*v) - i; +} + +/** + * atomic_inc - increment atomic variable + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1. + */ +static __inline__ void atomic_inc(atomic_t *v) +{ + (*v)++; +} + +/** + * atomic_dec - decrement atomic variable + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1. + */ +static __inline__ void atomic_dec(atomic_t *v) +{ + (*v)--; +} + +/** + * atomic_dec_and_test - decrement and test + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1 and + * returns true if the result is 0, or false for all other + * cases. + */ +static __inline__ int atomic_dec_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)--; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_inc_and_test - increment and test + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1 + * and returns true if the result is zero, or false for all + * other cases. + */ +static __inline__ int atomic_inc_and_test(atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v)++; + if ((*v) == 0) { + ret = 1; + } else { + ret = 0; + }; + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_negative - add and test if negative + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns true + * if the result is negative, or false when + * result is greater than or equal to zero. + */ +static __inline__ int atomic_add_negative(int i, atomic_t *v) +{ + int ret; + + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + (*v) = (*v) + i; + if ((*v) < 0) { + ret = 1; + } else { + ret = 0; + } + __CPROVER_atomic_end(); + + return ret; +} + +/** + * atomic_add_return - add and return + * @v: pointer of type atomic_t + * @i: integer value to add + * + * Atomically adds @i to @v and returns @i + @v + */ +static __inline__ int atomic_add_return(int i, atomic_t *v) +{ + return (*v) + i; +} + +static __inline__ int atomic_sub_return(int i, atomic_t *v) +{ + return (*v) - i; +} + +#define atomic_inc_return(v) (atomic_add_return(1,v)) +#define atomic_dec_return(v) (atomic_sub_return(1,v)) + +#endif diff --git a/ddverify/models/goblint/include/asm/bitops.h b/ddverify/models/goblint/include/asm/bitops.h new file mode 100644 index 000000000..6b4e2116a --- /dev/null +++ b/ddverify/models/goblint/include/asm/bitops.h @@ -0,0 +1,13 @@ +#ifndef _I386_BITOPS_H +#define _I386_BITOPS_H + +void set_bit(int nr, unsigned long * addr); + +int test_and_set_bit(int nr, unsigned long * addr); +int test_and_clear_bit(int nr, unsigned long * addr); +int test_and_change_bit(int nr, unsigned long* addr); +int test_bit(int nr, const void * addr); +void clear_bit(int nr, volatile unsigned long * addr); +int find_first_zero_bit(const unsigned long *addr, unsigned size); + +#endif /* _I386_BITOPS_H */ diff --git a/ddverify/models/goblint/include/asm/bug.h b/ddverify/models/goblint/include/asm/bug.h new file mode 100644 index 000000000..9536f4539 --- /dev/null +++ b/ddverify/models/goblint/include/asm/bug.h @@ -0,0 +1,7 @@ +#ifndef _I386_BUG_H +#define _I386_BUG_H + +#include +#include +#endif + diff --git a/ddverify/models/goblint/include/asm/byteorder.h b/ddverify/models/goblint/include/asm/byteorder.h new file mode 100644 index 000000000..20edb1dfa --- /dev/null +++ b/ddverify/models/goblint/include/asm/byteorder.h @@ -0,0 +1,9 @@ +#ifndef _I386_BYTEORDER_H +#define _I386_BYTEORDER_H + +#include +#include + +#include + +#endif /* _I386_BYTEORDER_H */ diff --git a/ddverify/models/goblint/include/asm/current.h b/ddverify/models/goblint/include/asm/current.h new file mode 100644 index 000000000..f124ae985 --- /dev/null +++ b/ddverify/models/goblint/include/asm/current.h @@ -0,0 +1,14 @@ +#ifndef _I386_CURRENT_H +#define _I386_CURRENT_H + +//#include +#include + +struct task_struct; + +struct task_struct *get_current(void); + +#define current get_current() + +#endif /* !(_I386_CURRENT_H) */ + diff --git a/ddverify/models/goblint/include/asm/delay.h b/ddverify/models/goblint/include/asm/delay.h new file mode 100644 index 000000000..153e9bc14 --- /dev/null +++ b/ddverify/models/goblint/include/asm/delay.h @@ -0,0 +1,6 @@ +#ifndef _I386_DELAY_H +#define _I386_DELAY_H + +void udelay(int); + +#endif /* defined(_I386_DELAY_H) */ diff --git a/ddverify/models/goblint/include/asm/dma.h b/ddverify/models/goblint/include/asm/dma.h new file mode 100644 index 000000000..1e1f3855e --- /dev/null +++ b/ddverify/models/goblint/include/asm/dma.h @@ -0,0 +1,72 @@ +#ifndef _ASM_DMA_H +#define _ASM_DMA_H + +#include /* And spinlocks */ +#include /* need byte IO */ +#include + +#define MAX_DMA_CHANNELS 8 + +/* The maximum address that we can perform a DMA transfer to on this platform */ +#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000) + +/* 8237 DMA controllers */ +#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ +#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ + +/* DMA controller registers */ +#define DMA1_CMD_REG 0x08 /* command register (w) */ +#define DMA1_STAT_REG 0x08 /* status register (r) */ +#define DMA1_REQ_REG 0x09 /* request register (w) */ +#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ +#define DMA1_MODE_REG 0x0B /* mode register (w) */ +#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ +#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ +#define DMA1_RESET_REG 0x0D /* Master Clear (w) */ +#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ +#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ + +#define DMA2_CMD_REG 0xD0 /* command register (w) */ +#define DMA2_STAT_REG 0xD0 /* status register (r) */ +#define DMA2_REQ_REG 0xD2 /* request register (w) */ +#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ +#define DMA2_MODE_REG 0xD6 /* mode register (w) */ +#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ +#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ +#define DMA2_RESET_REG 0xDA /* Master Clear (w) */ +#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ +#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ + +#define DMA_ADDR_0 0x00 /* DMA address registers */ +#define DMA_ADDR_1 0x02 +#define DMA_ADDR_2 0x04 +#define DMA_ADDR_3 0x06 +#define DMA_ADDR_4 0xC0 +#define DMA_ADDR_5 0xC4 +#define DMA_ADDR_6 0xC8 +#define DMA_ADDR_7 0xCC + +#define DMA_CNT_0 0x01 /* DMA count registers */ +#define DMA_CNT_1 0x03 +#define DMA_CNT_2 0x05 +#define DMA_CNT_3 0x07 +#define DMA_CNT_4 0xC2 +#define DMA_CNT_5 0xC6 +#define DMA_CNT_6 0xCA +#define DMA_CNT_7 0xCE + +#define DMA_PAGE_0 0x87 /* DMA page registers */ +#define DMA_PAGE_1 0x83 +#define DMA_PAGE_2 0x81 +#define DMA_PAGE_3 0x82 +#define DMA_PAGE_5 0x8B +#define DMA_PAGE_6 0x89 +#define DMA_PAGE_7 0x8A + +#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ +#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ +#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ + +#define DMA_AUTOINIT 0x10 + +#endif /* _ASM_DMA_H */ diff --git a/ddverify/models/goblint/include/asm/errno.h b/ddverify/models/goblint/include/asm/errno.h new file mode 100644 index 000000000..969b34374 --- /dev/null +++ b/ddverify/models/goblint/include/asm/errno.h @@ -0,0 +1,6 @@ +#ifndef _I386_ERRNO_H +#define _I386_ERRNO_H + +#include + +#endif diff --git a/ddverify/models/goblint/include/asm/fcntl.h b/ddverify/models/goblint/include/asm/fcntl.h new file mode 100644 index 000000000..46ab12db5 --- /dev/null +++ b/ddverify/models/goblint/include/asm/fcntl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/goblint/include/asm/floppy.h b/ddverify/models/goblint/include/asm/floppy.h new file mode 100644 index 000000000..fdbf1c705 --- /dev/null +++ b/ddverify/models/goblint/include/asm/floppy.h @@ -0,0 +1,45 @@ +#ifndef __ASM_I386_FLOPPY_H +#define __ASM_I386_FLOPPY_H + +#include + +static int FDC1 = 0x3f0; +static int FDC2 = -1; + + +/* + * Floppy types are stored in the rtc's CMOS RAM and so rtc_lock + * is needed to prevent corrupted CMOS RAM in case "insmod floppy" + * coincides with another rtc CMOS user. Paul G. + */ +/*#define FLOPPY0_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = (CMOS_READ(0x10) >> 4) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) + +#define FLOPPY1_TYPE ({ \ + unsigned long flags; \ + unsigned char val; \ + spin_lock_irqsave(&rtc_lock, flags); \ + val = CMOS_READ(0x10) & 15; \ + spin_unlock_irqrestore(&rtc_lock, flags); \ + val; \ +}) +*/ +#define FLOPPY0_TYPE (CMOS_READ(0x10) >> 4) & 15 +#define FLOPPY1_TYPE CMOS_READ(0x10) & 15 + +#define N_FDC 2 +#define N_DRIVE 8 + +#define FLOPPY_MOTOR_MASK 0xf0 + +#define AUTO_DMA + +#define EXTRA_FLOPPY_PARAMS + +#endif /* __ASM_I386_FLOPPY_H */ diff --git a/ddverify/models/goblint/include/asm/highmem.h b/ddverify/models/goblint/include/asm/highmem.h new file mode 100644 index 000000000..c9c362c4f --- /dev/null +++ b/ddverify/models/goblint/include/asm/highmem.h @@ -0,0 +1,17 @@ +#ifndef _ASM_HIGHMEM_H +#define _ASM_HIGHMEM_H + +#include +//#include +#include +//#include + + +void *kmap(struct page *page); +void kunmap(struct page *page); +void *kmap_atomic(struct page *page, enum km_type type); +void kunmap_atomic(void *kvaddr, enum km_type type); +void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); +struct page *kmap_atomic_to_page(void *ptr); + +#endif /* _ASM_HIGHMEM_H */ diff --git a/ddverify/models/goblint/include/asm/io.h b/ddverify/models/goblint/include/asm/io.h new file mode 100644 index 000000000..703139060 --- /dev/null +++ b/ddverify/models/goblint/include/asm/io.h @@ -0,0 +1,69 @@ +#ifndef _ASM_IO_H +#define _ASM_IO_H + +void * phys_to_virt(unsigned long); + +#define bus_to_virt phys_to_virt + +void *ioremap(unsigned long offset, unsigned long size); +void *ioremap_nocache(unsigned long offset, unsigned long size); +void iounmap(void *addr); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb(unsigned int); +void outb(unsigned char byte, unsigned int); +unsigned short inw(unsigned int); +void outw(unsigned short word, unsigned int); +unsigned inl(unsigned int); +void outl(unsigned doubleword, unsigned int); + + +// DDV: Bodies for these functions are defined in linux/kernel/resource.c +unsigned char inb_p(unsigned int); +void outb_p(unsigned char byte, unsigned int); +unsigned short inw_p(unsigned int); +void outw_p(unsigned short word, unsigned int); +unsigned inl_p(unsigned int); +void outl_p(unsigned doubleword, unsigned int); + + + +unsigned insb(unsigned int, void *addr, unsigned long count); +void outsb(unsigned int, void *addr, unsigned long count); + +unsigned insw(unsigned int, void *addr, unsigned long count); +void outsw(unsigned int, void *addr, unsigned long count); + +unsigned insl(unsigned int, void *addr, unsigned long count); +void outsl(unsigned int, void *addr, unsigned long count); + + + +unsigned int ioread8(void *addr); +unsigned int ioread16(void *addr); +unsigned int ioread32(void *addr); + +void iowrite8(u8 value, void *addr); +void iowrite16(u16 value, void *addr); +void iowrite32(u32 value, void *addr); + +void ioread8_rep(void *addr, void *buf, unsigned long count); +void ioread16_rep(void *addr, void *buf, unsigned long count); +void ioread32_rep(void *addr, void *buf, unsigned long count); + +void iowrite8_rep(void *addr, const void *buf, unsigned long count); +void iowrite16_rep(void *addr, const void *buf, unsigned long count); +void iowrite32_rep(void *addr, const void *buf, unsigned long count); + +// DDV: no bodies required for these functions: +unsigned char readb(const void *); +unsigned short readw(const void *); +unsigned int readl(const void *); + +// DDV: no bodies required for these functions: +void writeb(unsigned char, void *); +void writew(unsigned short, void *); +void writel(unsigned int, void *); + +#endif diff --git a/ddverify/models/goblint/include/asm/ioctl.h b/ddverify/models/goblint/include/asm/ioctl.h new file mode 100644 index 000000000..b279fe06d --- /dev/null +++ b/ddverify/models/goblint/include/asm/ioctl.h @@ -0,0 +1 @@ +#include diff --git a/ddverify/models/goblint/include/asm/ioctls.h b/ddverify/models/goblint/include/asm/ioctls.h new file mode 100644 index 000000000..4157abdb1 --- /dev/null +++ b/ddverify/models/goblint/include/asm/ioctls.h @@ -0,0 +1,91 @@ +#ifndef __ARCH_CRIS_IOCTLS_H__ +#define __ARCH_CRIS_IOCTLS_H__ + +/* verbatim copy of asm-i386/ioctls.h */ + +#include + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TCGETS2 _IOR('T',0x2A, struct termios2) +#define TCSETS2 _IOW('T',0x2B, struct termios2) +#define TCSETSW2 _IOW('T',0x2C, struct termios2) +#define TCSETSF2 _IOW('T',0x2D, struct termios2) +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ +#define FIOQSIZE 0x5460 + +#define TIOCSERSETRS485 0x5461 /* enable rs-485 */ +#define TIOCSERWRRS485 0x5462 /* write rs-485 */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif diff --git a/ddverify/models/goblint/include/asm/irq.h b/ddverify/models/goblint/include/asm/irq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/asm/kmap_types.h b/ddverify/models/goblint/include/asm/kmap_types.h new file mode 100644 index 000000000..fd2cdabbd --- /dev/null +++ b/ddverify/models/goblint/include/asm/kmap_types.h @@ -0,0 +1,23 @@ +#ifndef _ASM_KMAP_TYPES_H +#define _ASM_KMAP_TYPES_H + +enum km_type { + KM_BOUNCE_READ, + KM_SKB_SUNRPC_DATA, + KM_SKB_DATA_SOFTIRQ, + KM_USER0, + KM_USER1, + KM_BIO_SRC_IRQ, + KM_BIO_DST_IRQ, + KM_PTE0, + KM_PTE1, + KM_IRQ0, + KM_IRQ1, + KM_SOFTIRQ0, + KM_SOFTIRQ1, + KM_KDB, + KM_DUMP, + KM_TYPE_NR +}; + +#endif diff --git a/ddverify/models/goblint/include/asm/leds.h b/ddverify/models/goblint/include/asm/leds.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/asm/mach-types.h b/ddverify/models/goblint/include/asm/mach-types.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/asm/mc146818rtc.h b/ddverify/models/goblint/include/asm/mc146818rtc.h new file mode 100644 index 000000000..0c97cfb90 --- /dev/null +++ b/ddverify/models/goblint/include/asm/mc146818rtc.h @@ -0,0 +1,34 @@ +/* + * Machine dependent access functions for RTC registers. + */ +#ifndef _ASM_MC146818RTC_H +#define _ASM_MC146818RTC_H + +#include +#include +#include + +#ifndef RTC_PORT +#define RTC_PORT(x) (0x70 + (x)) +#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ +#endif + +#define lock_cmos_prefix(reg) do {} while (0) +#define lock_cmos_suffix(reg) do {} while (0) +#define lock_cmos(reg) +#define unlock_cmos() +#define do_i_have_lock_cmos() 0 +#define current_lock_cmos_reg() 0 + +/* + * The yet supported machines all access the RTC index register via + * an ISA port access but the way to access the date register differs ... + */ +#define CMOS_READ(addr) rtc_cmos_read(addr) +#define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr) +unsigned char rtc_cmos_read(unsigned char addr); +void rtc_cmos_write(unsigned char val, unsigned char addr); + +#define RTC_IRQ 8 + +#endif /* _ASM_MC146818RTC_H */ diff --git a/ddverify/models/goblint/include/asm/msr.h b/ddverify/models/goblint/include/asm/msr.h new file mode 100644 index 000000000..adf72e79e --- /dev/null +++ b/ddverify/models/goblint/include/asm/msr.h @@ -0,0 +1,10 @@ +#ifndef __ASM_MSR_H +#define __ASM_MSR_H + +#define rdmsr(msr, val1, val2) \ + do { \ + val1 = nondet_u32(); \ + val2 = nondet_u32(); \ + } while(0); + +#endif diff --git a/ddverify/models/goblint/include/asm/page.h b/ddverify/models/goblint/include/asm/page.h new file mode 100644 index 000000000..b2bc603c9 --- /dev/null +++ b/ddverify/models/goblint/include/asm/page.h @@ -0,0 +1,24 @@ +#ifndef _I386_PAGE_H +#define _I386_PAGE_H + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +//#include + + +// DDV: taken from arch/i386/defconfig +#define CONFIG_PAGE_OFFSET 0xC0000000 +// DDV: taken from arch/i386/defconfig +#define CONFIG_PHYSICAL_START 0x100000 + +#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET) +#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START) + +#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) +#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) +#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) + +#endif /* _I386_PAGE_H */ diff --git a/ddverify/models/goblint/include/asm/param.h b/ddverify/models/goblint/include/asm/param.h new file mode 100644 index 000000000..6148b8ddf --- /dev/null +++ b/ddverify/models/goblint/include/asm/param.h @@ -0,0 +1,8 @@ +#ifndef _ASMi386_PARAM_H +#define _ASMi386_PARAM_H + +#ifndef HZ +#define HZ 100 +#endif + +#endif diff --git a/ddverify/models/goblint/include/asm/pci.h b/ddverify/models/goblint/include/asm/pci.h new file mode 100644 index 000000000..c41fd10d2 --- /dev/null +++ b/ddverify/models/goblint/include/asm/pci.h @@ -0,0 +1,17 @@ +#ifndef __i386_PCI_H +#define __i386_PCI_H + +#include /* for struct page */ + +#include +#include +#include +#include +#include + + + +#include + + +#endif /* __i386_PCI_H */ diff --git a/ddverify/models/goblint/include/asm/poll.h b/ddverify/models/goblint/include/asm/poll.h new file mode 100644 index 000000000..905fb4d78 --- /dev/null +++ b/ddverify/models/goblint/include/asm/poll.h @@ -0,0 +1,20 @@ +#ifndef __i386_POLL_H +#define __i386_POLL_H + +/* These are specified by iBCS2 */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +/* The rest seem to be more-or-less nonstandard. Check them! */ +#define POLLRDNORM 0x0040 +#define POLLRDBAND 0x0080 +#define POLLWRNORM 0x0100 +#define POLLWRBAND 0x0200 +#define POLLMSG 0x0400 +#define POLLREMOVE 0x1000 + +#endif diff --git a/ddverify/models/goblint/include/asm/posix_types.h b/ddverify/models/goblint/include/asm/posix_types.h new file mode 100644 index 000000000..798ec0819 --- /dev/null +++ b/ddverify/models/goblint/include/asm/posix_types.h @@ -0,0 +1,32 @@ +#ifndef __ARCH_I386_POSIX_TYPES_H +#define __ARCH_I386_POSIX_TYPES_H + +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; + +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; +typedef unsigned short __kernel_old_dev_t; + + +#endif diff --git a/ddverify/models/goblint/include/asm/processor.h b/ddverify/models/goblint/include/asm/processor.h new file mode 100644 index 000000000..b6dedb7ad --- /dev/null +++ b/ddverify/models/goblint/include/asm/processor.h @@ -0,0 +1,6 @@ +#ifndef __ASM_I386_PROCESSOR_H +#define __ASM_I386_PROCESSOR_H + +#include + +#endif /* __ASM_I386_PROCESSOR_H */ diff --git a/ddverify/models/goblint/include/asm/ptrace.h b/ddverify/models/goblint/include/asm/ptrace.h new file mode 100644 index 000000000..69130f62a --- /dev/null +++ b/ddverify/models/goblint/include/asm/ptrace.h @@ -0,0 +1,8 @@ +#ifndef _I386_PTRACE_H +#define _I386_PTRACE_H + +struct pt_regs { + int something; +}; + +#endif diff --git a/ddverify/models/goblint/include/asm/rtc.h b/ddverify/models/goblint/include/asm/rtc.h new file mode 100644 index 000000000..3d2d9102e --- /dev/null +++ b/ddverify/models/goblint/include/asm/rtc.h @@ -0,0 +1,7 @@ +#ifndef __ASM_RTC_H__ +#define __ASM_RTC_H__ + +#include + +#endif + diff --git a/ddverify/models/goblint/include/asm/scatterlist.h b/ddverify/models/goblint/include/asm/scatterlist.h new file mode 100644 index 000000000..55d6c953a --- /dev/null +++ b/ddverify/models/goblint/include/asm/scatterlist.h @@ -0,0 +1,21 @@ +#ifndef _I386_SCATTERLIST_H +#define _I386_SCATTERLIST_H + +struct scatterlist { + struct page *page; + unsigned int offset; + dma_addr_t dma_address; + unsigned int length; +}; + +/* These macros should be used after a pci_map_sg call has been done + * to get bus addresses of each of the SG entries and their lengths. + * You should only work with the number of sg entries pci_map_sg + * returns. + */ +#define sg_dma_address(sg) ((sg)->dma_address) +#define sg_dma_len(sg) ((sg)->length) + +#define ISA_DMA_THRESHOLD (0x00ffffff) + +#endif /* !(_I386_SCATTERLIST_H) */ diff --git a/ddverify/models/goblint/include/asm/semaphore.h b/ddverify/models/goblint/include/asm/semaphore.h new file mode 100644 index 000000000..5d574f8a9 --- /dev/null +++ b/ddverify/models/goblint/include/asm/semaphore.h @@ -0,0 +1,37 @@ +#ifndef _I386_SEMAPHORE_H +#define _I386_SEMAPHORE_H + +struct semaphore { + int init; + int locked; +}; + + +#define __SEMAPHORE_INITIALIZER(name, n) \ +{ \ + .init = 1, \ + .locked = n \ +} + +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) + +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,0) +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,1) + +// DDV: Body is defined in linux/kernel/semaphore.c +void sema_init(struct semaphore *sem, int val); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void init_MUTEX_LOCKED(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void down(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_interruptible(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +int down_trylock(struct semaphore * sem); +// DDV: Body is defined in linux/kernel/semaphore.c +void up(struct semaphore * sem); + +#endif diff --git a/ddverify/models/goblint/include/asm/siginfo.h b/ddverify/models/goblint/include/asm/siginfo.h new file mode 100644 index 000000000..fe18f98fc --- /dev/null +++ b/ddverify/models/goblint/include/asm/siginfo.h @@ -0,0 +1,6 @@ +#ifndef _I386_SIGINFO_H +#define _I386_SIGINFO_H + +#include + +#endif diff --git a/ddverify/models/goblint/include/asm/signal.h b/ddverify/models/goblint/include/asm/signal.h new file mode 100644 index 000000000..d85fd7a75 --- /dev/null +++ b/ddverify/models/goblint/include/asm/signal.h @@ -0,0 +1,86 @@ +#ifndef _ASMi386_SIGNAL_H +#define _ASMi386_SIGNAL_H + +#define _NSIG 64 +#define _NSIG_BPW 32 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef unsigned long old_sigset_t; /* at least 32 bits */ + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG + + +/* + * SA_FLAGS values: + * + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_NODEFER prevents the current signal from being masked in the handler. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#define SA_NOCLDSTOP 0x00000001u +#define SA_NOCLDWAIT 0x00000002u +#define SA_SIGINFO 0x00000004u +#define SA_ONSTACK 0x08000000u +#define SA_RESTART 0x10000000u +#define SA_NODEFER 0x40000000u +#define SA_RESETHAND 0x80000000u + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND +#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */ + +#define SA_RESTORER 0x04000000 + + +#endif diff --git a/ddverify/models/goblint/include/asm/stat.h b/ddverify/models/goblint/include/asm/stat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/asm/string.h b/ddverify/models/goblint/include/asm/string.h new file mode 100644 index 000000000..6b1131c19 --- /dev/null +++ b/ddverify/models/goblint/include/asm/string.h @@ -0,0 +1,6 @@ +#ifndef _I386_STRING_H_ +#define _I386_STRING_H_ + +void *memset(void *s, int c, size_t n); + +#endif diff --git a/ddverify/models/goblint/include/asm/system.h b/ddverify/models/goblint/include/asm/system.h new file mode 100644 index 000000000..1d6f962e6 --- /dev/null +++ b/ddverify/models/goblint/include/asm/system.h @@ -0,0 +1,9 @@ +#ifndef __ASM_SYSTEM_H +#define __ASM_SYSTEM_H + +void rmb(void); +void read_barrier_depends(void); +void wmb(void); +void mb(void); + +#endif diff --git a/ddverify/models/goblint/include/asm/termbits.h b/ddverify/models/goblint/include/asm/termbits.h new file mode 100644 index 000000000..3606b9897 --- /dev/null +++ b/ddverify/models/goblint/include/asm/termbits.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_I386_TERMBITS_H__ +#define __ARCH_I386_TERMBITS_H__ + +#include + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +#endif diff --git a/ddverify/models/goblint/include/asm/termios.h b/ddverify/models/goblint/include/asm/termios.h new file mode 100644 index 000000000..8f71467a2 --- /dev/null +++ b/ddverify/models/goblint/include/asm/termios.h @@ -0,0 +1,54 @@ +#ifndef _I386_TERMIOS_H +#define _I386_TERMIOS_H + +#include +#include + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 /* X.25 async */ +#define N_6PACK 7 +#define N_MASC 8 /* Reserved for Mobitex module */ +#define N_R3964 9 /* Reserved for Simatic R3964 module */ +#define N_PROFIBUS_FDL 10 /* Reserved for Profibus */ +#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */ +#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */ +#define N_HDLC 13 /* synchronous HDLC */ +#define N_SYNC_PPP 14 /* synchronous PPP */ +#define N_HCI 15 /* Bluetooth HCI UART */ + +#endif /* _I386_TERMIOS_H */ diff --git a/ddverify/models/goblint/include/asm/types.h b/ddverify/models/goblint/include/asm/types.h new file mode 100644 index 000000000..39b35bb5e --- /dev/null +++ b/ddverify/models/goblint/include/asm/types.h @@ -0,0 +1,35 @@ +#ifndef _I386_TYPES_H +#define _I386_TYPES_H + +typedef unsigned short umode_t; + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +typedef __signed__ long long __s64; +typedef unsigned long long __u64; + +#define BITS_PER_LONG 32 + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +typedef u32 dma_addr_t; +typedef u64 dma64_addr_t; + +#endif diff --git a/ddverify/models/goblint/include/asm/uaccess.h b/ddverify/models/goblint/include/asm/uaccess.h new file mode 100644 index 000000000..a764a014c --- /dev/null +++ b/ddverify/models/goblint/include/asm/uaccess.h @@ -0,0 +1,55 @@ +#ifndef __i386_UACCESS_H +#define __i386_UACCESS_H + +/* + * User space memory access functions + */ +#include +#include +#include +#include + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +/** + * access_ok: - Checks if a user space pointer is valid + * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that + * %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe + * to write to a block, it is always safe to read from it. + * @addr: User space pointer to start of block to check + * @size: Size of block to check + * + * Context: User context only. This function may sleep. + * + * Checks if a pointer to a block of memory in user space is valid. + * + * Returns true (nonzero) if the memory block may be valid, false (zero) + * if it is definitely invalid. + * + * Note that, depending on architecture, this function probably just + * checks that the pointer is in the user space range - after calling + * this function, memory access functions may still return -EFAULT. + */ +// #define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0)) +int access_ok(int type, const void *addr, unsigned long size); + + +// DDV-TODO: get_user and put_user are defined as macros!!! if bug030 is fixed, this should be done here. + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __get_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int get_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +int __put_user(int size, void *ptr); +// DDV: Body is defined in arch/i386/lib/usercopy.c +int put_user(int size, void *ptr); + +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n); +// DDV: Body is defined in arch/i386/lib/usercopy.c +unsigned long copy_from_user(void *to, void __user *from, unsigned long n); + +#endif /* __i386_UACCESS_H */ diff --git a/ddverify/models/goblint/include/ddverify/blkdev.h b/ddverify/models/goblint/include/ddverify/blkdev.h new file mode 100644 index 000000000..aa65ce957 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/blkdev.h @@ -0,0 +1,10 @@ +#ifndef _DDV_BLKDEV_H_ +#define _DDV_BLKDEV_H_ + +#define MAX_REQUEST_QUEUE_SUPPORT 10 + +request_queue_t fixed_request_queue[MAX_REQUEST_QUEUE_SUPPORT]; + +int number_request_queue_used = 0; + +#endif diff --git a/ddverify/models/goblint/include/ddverify/cdev.h b/ddverify/models/goblint/include/ddverify/cdev.h new file mode 100644 index 000000000..b4fa43cbe --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/cdev.h @@ -0,0 +1,26 @@ +#ifndef _DDV_CDEV_H +#define _DDV_CDEV_H + +#include +#include + +#define MAX_CDEV_SUPPORT 10 + +#include + +short number_cdev_registered = 0; + +struct ddv_cdev { + struct cdev *cdevp; + + struct file filp; + struct inode inode; + + int open; +}; + +struct ddv_cdev cdev_registered[MAX_CDEV_SUPPORT]; + +void call_cdev_functions(); + +#endif diff --git a/ddverify/models/goblint/include/ddverify/ddverify.h b/ddverify/models/goblint/include/ddverify/ddverify.h new file mode 100644 index 000000000..f6d8a06fe --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/ddverify.h @@ -0,0 +1,47 @@ +#ifndef _DDVERIFY_H +#define _DDVERIFY_H + +enum __bool { false, true }; + +#ifndef NULL +#define NULL ((void *)0) +#endif + + +int current_execution_context; + +#define CONTEXT_PROCESS 1 +#define CONTEXT_INTERRUPT 2 + +#define switch_context(x) current_execution_context = x + +#ifdef DDV_ASSERT_CONTEXT + +static inline assert_context_process() +{ + __CPROVER_assert(current_execution_context == CONTEXT_PROCESS, "Process context"); +} + +static inline assert_context_interrupt() +{ + __CPROVER_assert(current_execution_context == CONTEXT_INTERRUPT, "Interrupt context"); +} + +#else + +static inline assert_context_process() +{ +} + +static inline assert_context_interrupt() +{ +} + +#endif /* DDV_ASSERT_CONTEXT */ + +int (* _ddv_module_init)(void); +void (* _ddv_module_exit)(void); + +int call_ddv(); + +#endif diff --git a/ddverify/models/goblint/include/ddverify/fixed_cdev.h b/ddverify/models/goblint/include/ddverify/fixed_cdev.h new file mode 100644 index 000000000..347972b25 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/fixed_cdev.h @@ -0,0 +1,15 @@ +#ifndef _DDV_FIXED_CDEV_H_ +#define _DDV_FIXED_CDEV_H_ + +#include +#include +#include + +// Used in function misc_register and cdev_alloc. Instead allocating a cdev structure, +// a cdev structure from this array is used. This make the verification process much +// simpler. + +struct cdev fixed_cdev[MAX_CDEV_SUPPORT]; +int fixed_cdev_used = 0; + +#endif diff --git a/ddverify/models/goblint/include/ddverify/genhd.h b/ddverify/models/goblint/include/ddverify/genhd.h new file mode 100644 index 000000000..3d0161e60 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/genhd.h @@ -0,0 +1,29 @@ +#ifndef _DDV_GENHD_H +#define _DDV_GENHD_H + +#include +#include +#include + +#include + +#define MAX_GENHD_SUPPORT 10 + +short number_genhd_registered = 0; +short number_fixed_genhd_used = 0; + +struct ddv_genhd { + struct gendisk *gd; + + struct inode inode; + struct file file; + struct request current_request; + int requests_open; +}; + +struct gendisk fixed_gendisk[MAX_GENHD_SUPPORT]; +struct ddv_genhd genhd_registered[MAX_GENHD_SUPPORT]; + +void call_genhd_functions(); + +#endif diff --git a/ddverify/models/goblint/include/ddverify/interrupt.h b/ddverify/models/goblint/include/ddverify/interrupt.h new file mode 100644 index 000000000..bca87a686 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/interrupt.h @@ -0,0 +1,19 @@ +#ifndef _DDV_INTERRUPT_H +#define _DDV_INTERRUPT_H + +#include +#include + +#define MAX_IRQ_SUPPORT 16 + +struct registered_irq { + irq_handler_t handler; + void *dev_id; +}; + +struct registered_irq registered_irq[MAX_IRQ_SUPPORT]; + +void call_interrupt_handler(); + +#endif + diff --git a/ddverify/models/goblint/include/ddverify/ioctl.h b/ddverify/models/goblint/include/ddverify/ioctl.h new file mode 100644 index 000000000..76312e082 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/ioctl.h @@ -0,0 +1,15 @@ +#ifndef _DDV_IOCTL_H +#define _DDV_IOCTL_H + +/*#define MAX_IOCTL_SUPPORT 20 + +short number_ioctl_registered = 0; + +typedef unsigned int ddv_ioctl; + +ddv_ioctl ioctl_registered[MAX_IOCTL_SUPPORT]; + +void add_ioctl(unsigned int); +unsigned int get_ioctl_cmd(); +*/ +#endif diff --git a/ddverify/models/goblint/include/ddverify/ioport.h b/ddverify/models/goblint/include/ddverify/ioport.h new file mode 100644 index 000000000..d96407ad7 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/ioport.h @@ -0,0 +1,27 @@ +#ifndef _DDV_IOPORT_H +#define _DDV_IOPORT_H + +#include + +//#define NUMBER_IO_PORTS 65536 + +//ushort ddv_ioport[NUMBER_IO_PORTS - 1]; + +int ddv_ioport_request_start; +int ddv_ioport_request_len; + +#ifdef DDV_ASSERT_IO + +// __CPROVER_assert(ddv_ioport[port], "Used I/O Port was requested") + +#define ddv_correct_port_use(port) \ +__CPROVER_assert(port >= ddv_ioport_request_start && port < ddv_ioport_request_start + ddv_ioport_request_len, "I/O port is requested") + +#else + +#define ddv_correct_port_use(port) \ + do { } while(0) + +#endif /* DDV_ASSERT_IO */ + +#endif diff --git a/ddverify/models/goblint/include/ddverify/miscdevice.h b/ddverify/models/goblint/include/ddverify/miscdevice.h new file mode 100644 index 000000000..43b174d28 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/miscdevice.h @@ -0,0 +1,7 @@ +#ifndef _DDV_MISCDEVICE_H +#define _DDV_MISCDEVICE_H + +#include + +#endif + diff --git a/ddverify/models/goblint/include/ddverify/pci.h b/ddverify/models/goblint/include/ddverify/pci.h new file mode 100644 index 000000000..d2ece19a8 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/pci.h @@ -0,0 +1,22 @@ +#ifndef _DDV_PCI_H_ +#define _DDV_PCI_H_ + +#include + +struct ddv_pci_driver { + struct pci_driver *pci_driver; + struct pci_dev pci_dev; + + unsigned int no_pci_device_id; + int dev_initialized; +}; + +struct ddv_pci_driver registered_pci_driver; + +int pci_probe_device(); +void pci_remove_device(); + +void call_pci_functions(); + + +#endif diff --git a/ddverify/models/goblint/include/ddverify/pthread.h b/ddverify/models/goblint/include/ddverify/pthread.h new file mode 100644 index 000000000..64c351ee6 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/pthread.h @@ -0,0 +1,253 @@ +#ifndef __POSIX_PTHREAD_H +#define __POSIX_PTHREAD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NULL +#define NULL ((void *)0) +#endif + +/* Types */ +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +struct __pthread_mutex_t_struct +{ + _Bool locked; +}; + +struct __pthread_mutexattr_t_struct +{ + int dummy; +}; + +struct __pthread_spinlock_t_struct +{ + int dummy; +}; + +struct __pthread_barrier_t_struct +{ + int dummy; +}; + +struct __pthread_barrierattr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; +typedef struct __pthread_mutex_t_struct pthread_mutex_t; +typedef struct __pthread_mutexattr_t_struct pthread_mutexattr_t; +typedef struct __pthread_spinlock_t_struct pthread_spinlock_t; +typedef struct __pthread_barrier_t_struct pthread_barrier_t; +typedef struct __pthread_barrierattr_t_struct pthread_barrierattr_t; + +/* Initializers */ + +#define PTHREAD_MUTEX_INITIALIZER {0} + +/* Attributes */ + +enum +{ + PTHREAD_CREATE_JOINABLE, +#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE + PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED +}; + +enum +{ + PTHREAD_INHERIT_SCHED, +#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED + PTHREAD_EXPLICIT_SCHED +#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED +}; + +enum +{ + PTHREAD_SCOPE_SYSTEM, +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM + PTHREAD_SCOPE_PROCESS +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +}; + +enum +{ + PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_ADAPTIVE_NP, + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +}; + +enum +{ + PTHREAD_PROCESS_PRIVATE, +#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE + PTHREAD_PROCESS_SHARED +#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED +}; + +enum +{ + PTHREAD_RWLOCK_PREFER_READER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NP, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, + PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP +}; + +#define PTHREAD_ONCE_INIT 0 + +/* -1 is distinct from 0 and all errno constants */ +#define PTHREAD_BARRIER_SERIAL_THREAD -1 + +enum +{ + PTHREAD_CANCEL_ENABLE, +#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE + PTHREAD_CANCEL_DISABLE +#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +}; +enum +{ + PTHREAD_CANCEL_DEFERRED, +#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED + PTHREAD_CANCEL_ASYNCHRONOUS +#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS +}; +#define PTHREAD_CANCELED ((void *) -1) + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create( + pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg); + +extern pthread_t pthread_self(void); +extern int pthread_equal(pthread_t __thread1, pthread_t __thread2); +extern void pthread_exit(void *__retval); +extern int pthread_join(pthread_t __th, void **__thread_return); +extern int pthread_detach(pthread_t __th); +extern int pthread_attr_init(pthread_attr_t *__attr); +extern int pthread_attr_destroy(pthread_attr_t *__attr); +extern int pthread_attr_setdetachstate(pthread_attr_t *__attr, int __detachstate); +extern int pthread_attr_getdetachstate(__const pthread_attr_t *__attr, int *__detachstate); +extern int pthread_attr_setschedparam(pthread_attr_t *__attr, __const struct sched_param *__param); +extern int pthread_attr_getschedparam(__const pthread_attr_t *__attr, struct sched_param *__param); +extern int pthread_attr_setschedpolicy(pthread_attr_t *__attr, int __policy); +extern int pthread_attr_getschedpolicy(__const pthread_attr_t *__attr, int *__policy); +extern int pthread_attr_setinheritsched(pthread_attr_t *__attr, int __inherit); +extern int pthread_attr_getinheritsched(__const pthread_attr_t *__attr, int *__inherit); +extern int pthread_attr_setscope(pthread_attr_t *__attr, int __scope); +extern int pthread_attr_getscope(__const pthread_attr_t *__attr, int *__scope); +extern int pthread_attr_setguardsize(pthread_attr_t *__attr, size_t __guardsize); +extern int pthread_attr_getguardsize(__const pthread_attr_t *__attr, size_t *__guardsize); +extern int pthread_attr_setstackaddr(pthread_attr_t *__attr, void *__stackaddr); +extern int pthread_attr_getstackaddr(__const pthread_attr_t *__attr, void **__stackaddr); +extern int pthread_attr_setstack(pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize); +extern int pthread_attr_getstack(__const pthread_attr_t *__attr, + void **__stackaddr, + size_t *__stacksize); +extern int pthread_attr_setstacksize(pthread_attr_t *__attr, size_t __stacksize); +extern int pthread_attr_getstacksize(__const pthread_attr_t *, size_t *__stacksize); + +extern int pthread_getattr_np(pthread_t __th, pthread_attr_t *__attr); + +extern int pthread_setschedparam(pthread_t __target_thread, int __policy, + __const struct sched_param *__param); + +extern int pthread_getschedparam(pthread_t __target_thread, + int *__policy, + struct sched_param *__param); + +extern int pthread_getconcurrency(void); +extern int pthread_setconcurrency(int __level); +extern int pthread_yield(void); + +extern inline int pthread_mutex_init( + pthread_mutex_t *__mutex, + __const pthread_mutexattr_t *__mutex_attr) +{ + pthread_mutex_t i=PTHREAD_MUTEX_INITIALIZER; + *__mutex=i; +} + +extern inline int pthread_mutex_destroy(pthread_mutex_t *__mutex) +{ +} + +extern int pthread_mutex_trylock(pthread_mutex_t *__mutex); + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + +extern inline int pthread_mutex_lock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + __CPROVER_assume(!__mutex->locked); + __mutex->locked=1; + __CPROVER_atomic_end(); + return 0; // we never fail +} + +extern inline int pthread_mutex_unlock(pthread_mutex_t *__mutex) +{ + __CPROVER_HIDE: + __CPROVER_assert(__mutex->locked, "pthread_mutex_unlock without lock"); + __mutex->locked=0; + return 0; // we never fail +} + +extern int pthread_spin_init(pthread_spinlock_t *__lock, int __pshared); +extern int pthread_spin_destroy(pthread_spinlock_t *__lock); +extern int pthread_spin_lock(pthread_spinlock_t *__lock); +extern int pthread_spin_trylock(pthread_spinlock_t *__lock); +extern int pthread_spin_unlock(pthread_spinlock_t *__lock); +extern int pthread_barrier_init(pthread_barrier_t *__barrier, + __const pthread_barrierattr_t *__attr, unsigned int __count); + +extern int pthread_barrier_destroy(pthread_barrier_t *__barrier); +extern int pthread_barrierattr_init(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_destroy(pthread_barrierattr_t *__attr); +extern int pthread_barrierattr_getpshared(__const pthread_barrierattr_t *__attr, + int *__pshared); + +extern int pthread_barrierattr_setpshared(pthread_barrierattr_t *__attr, int __pshared); +extern int pthread_barrier_wait(pthread_barrier_t *__barrier); + +extern int pthread_setcancelstate(int __state, int *__oldstate); +extern int pthread_setcanceltype(int __type, int *__oldtype); +extern int pthread_cancel(pthread_t __cancelthread); +extern void pthread_testcancel(void); + +extern int pthread_atfork(void (*__prepare)(void), + void (*__parent)(void), + void (*__child)(void)); + +extern void pthread_kill_other_threads_np(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ddverify/models/goblint/include/ddverify/satabs.h b/ddverify/models/goblint/include/ddverify/satabs.h new file mode 100644 index 000000000..bb40b9867 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/satabs.h @@ -0,0 +1,69 @@ +#ifndef _SATABS_H +#define _SATABS_H + +#include +#include + +// memory management + +void *malloc(size_t size); + + +// nondeterministic functions + +short nondet_short(); +unsigned short nondet_ushort(); +int nondet_int(); +unsigned int nondet_uint(); +long nondet_long(); +unsigned long nondet_ulong(); +char nondet_char(); +unsigned char nondet_uchar(); +unsigned nondet_unsigned(); +loff_t nondet_loff_t(); +size_t nondet_size_t(); +sector_t nondet_sector_t(); +u32 nondet_u32(); +char * nondet_pchar(); +enum __bool nondet_bool(); + + +// handling asm code + +void noop(); +#define asm(code, ...) noop() + + +// __CPROVER functions + +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + + +// pthread +struct __pthread_t_struct +{ + int id; +}; + +struct __pthread_attr_t_struct +{ + int dummy; +}; + +typedef struct __pthread_t_struct pthread_t; +typedef struct __pthread_attr_t_struct pthread_attr_t; + +pthread_t nondet_pthread_t(); + +extern inline int pthread_create(pthread_t *__threadp, + __const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg) +{ + __CPROVER_HIDE: + *__threadp = nondet_pthread_t(); + CPROVER_ASYNC_1: __start_routine(__arg); + return 0; +} +#endif diff --git a/ddverify/models/goblint/include/ddverify/tasklet.h b/ddverify/models/goblint/include/ddverify/tasklet.h new file mode 100644 index 000000000..52e9e64f6 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/tasklet.h @@ -0,0 +1,20 @@ +#ifndef _DDV_TASKLET_H_ +#define _DDV_TASKLET_H_ + +#include + +#define MAX_TASKLET_SUPPORT 10 + +short number_tasklet_registered = 0; + +struct ddv_tasklet { + struct tasklet_struct *tasklet; + unsigned short is_running; +}; + +struct ddv_tasklet tasklet_registered[MAX_TASKLET_SUPPORT]; + +void call_tasklet_functions(); + +#endif + diff --git a/ddverify/models/goblint/include/ddverify/timer.h b/ddverify/models/goblint/include/ddverify/timer.h new file mode 100644 index 000000000..929cd7fca --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/timer.h @@ -0,0 +1,17 @@ +#ifndef _DDV_TIMER_H_ +#define _DDV_TIMER_H_ + +#include + +#define MAX_TIMER_SUPPORT 5 + +short number_timer_registered = 0; + +struct ddv_timer { + struct timer_list *timer; +}; + +struct ddv_timer timer_registered[MAX_TIMER_SUPPORT]; + +void call_timer_functions(); +#endif diff --git a/ddverify/models/goblint/include/ddverify/tty.h b/ddverify/models/goblint/include/ddverify/tty.h new file mode 100644 index 000000000..de3b5226f --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/tty.h @@ -0,0 +1,16 @@ +#ifndef _DDV_TTY_H_ +#define _DDV_TTY_H_ + +#include +#include + +struct ddv_tty_driver { + struct tty_driver driver; + unsigned short allocated; + unsigned short registered; +}; + +struct ddv_tty_driver global_tty_driver; + +#endif + diff --git a/ddverify/models/goblint/include/ddverify/workqueue.h b/ddverify/models/goblint/include/ddverify/workqueue.h new file mode 100644 index 000000000..2db429169 --- /dev/null +++ b/ddverify/models/goblint/include/ddverify/workqueue.h @@ -0,0 +1,12 @@ +#ifndef _DDV_WORKQUEUE_H_ +#define _DDV_WORKQUEUE_H_ + +#include + +#define MAX_WORKQUEUE_ELEMENTS_SUPPORT 10 + +struct work_struct *shared_workqueue[MAX_WORKQUEUE_ELEMENTS_SUPPORT]; + +void call_shared_workqueue_functions(); + +#endif diff --git a/ddverify/models/goblint/include/linux/backing-dev.h b/ddverify/models/goblint/include/linux/backing-dev.h new file mode 100644 index 000000000..1804ab33f --- /dev/null +++ b/ddverify/models/goblint/include/linux/backing-dev.h @@ -0,0 +1,37 @@ +/* + * include/linux/backing-dev.h + * + * low-level device information and state which is propagated up through + * to high-level code. + */ + +#ifndef _LINUX_BACKING_DEV_H +#define _LINUX_BACKING_DEV_H + +struct backing_dev_info { + unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ + unsigned long state; /* Always use atomic bitops on this */ + unsigned int capabilities; /* Device capabilities */ +}; + + +/* + * Flags in backing_dev_info::capability + * - The first two flags control whether dirty pages will contribute to the + * VM's accounting and whether writepages() should be called for dirty pages + * (something that would not, for example, be appropriate for ramfs) + * - These flags let !MMU mmap() govern direct device mapping vs immediate + * copying more easily for MAP_PRIVATE, especially for ROM filesystems + */ +#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ +#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ +#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ +#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ +#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ +#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ +#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ +#define BDI_CAP_VMFLAGS \ + (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) + + +#endif /* _LINUX_BACKING_DEV_H */ diff --git a/ddverify/models/goblint/include/linux/bcd.h b/ddverify/models/goblint/include/linux/bcd.h new file mode 100644 index 000000000..c54530812 --- /dev/null +++ b/ddverify/models/goblint/include/linux/bcd.h @@ -0,0 +1,20 @@ +/* Permission is hereby granted to copy, modify and redistribute this code + * in terms of the GNU Library General Public License, Version 2 or later, + * at your option. + */ + +/* macros to translate to/from binary and binary-coded decimal (frequently + * found in RTC chips). + */ + +#ifndef _BCD_H +#define _BCD_H + +#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) +#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) + +/* backwards compat */ +#define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) +#define BIN_TO_BCD(val) ((val)=BIN2BCD(val)) + +#endif /* _BCD_H */ diff --git a/ddverify/models/goblint/include/linux/bio.h b/ddverify/models/goblint/include/linux/bio.h new file mode 100644 index 000000000..159afe963 --- /dev/null +++ b/ddverify/models/goblint/include/linux/bio.h @@ -0,0 +1,110 @@ +#ifndef __LINUX_BIO_H +#define __LINUX_BIO_H + +#include + +struct bio_vec { + struct page *bv_page; + unsigned int bv_len; + unsigned int bv_offset; +}; + +struct bio_set; +struct bio; +typedef int (bio_end_io_t) (struct bio *, unsigned int, int); +typedef void (bio_destructor_t) (struct bio *); + +struct bio { + sector_t bi_sector; + + struct bio *bi_next; /* request queue link */ + struct block_device *bi_bdev; + unsigned long bi_flags; /* status, command, etc */ + unsigned long bi_rw; + + unsigned short bi_vcnt; + unsigned short bi_idx; + + /* Number of segments in this BIO after + * physical address coalescing is performed. + */ + unsigned short bi_phys_segments; + + unsigned int bi_size; + struct bio_vec *bi_io_vec; + + bio_end_io_t *bi_end_io; + + void *bi_private; +}; + +/* + * bio flags + */ +#define BIO_UPTODATE 0 /* ok after I/O completion */ +#define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ +#define BIO_EOF 2 /* out-out-bounds error */ +#define BIO_SEG_VALID 3 /* nr_hw_seg valid */ +#define BIO_CLONED 4 /* doesn't own data */ +#define BIO_BOUNCED 5 /* bio is a bounce bio */ +#define BIO_USER_MAPPED 6 /* contains user pages */ +#define BIO_EOPNOTSUPP 7 /* not supported */ +#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) + +/* + * top 4 bits of bio flags indicate the pool this bio came from + */ +#define BIO_POOL_BITS (4) +#define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) +#define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) +#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) + +/* + * bio bi_rw flags + * + * bit 0 -- read (not set) or write (set) + * bit 1 -- rw-ahead when set + * bit 2 -- barrier + * bit 3 -- fail fast, don't want low level driver retries + * bit 4 -- synchronous I/O hint: the block layer will unplug immediately + */ +#define BIO_RW 0 +#define BIO_RW_AHEAD 1 +#define BIO_RW_BARRIER 2 +#define BIO_RW_FAILFAST 3 +#define BIO_RW_SYNC 4 + + +#define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)])) +#define bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_idx) +#define bio_page(bio) bio_iovec((bio))->bv_page +#define bio_offset(bio) bio_iovec((bio))->bv_offset +#define bio_sectors(bio) ((bio)->bi_size >> 9) +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +#define bio_data(bio) (page_address(bio_page((bio))) + bio_offset((bio))) +#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER)) +#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC)) +#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) +#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) +#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) + +/* + * drivers should not use the __ version unless they _really_ want to + * run through the entire bio and not just pending pieces + */ +#define __bio_for_each_segment(bvl, bio, i, start_idx) \ + for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ + i < (bio)->bi_vcnt; \ + bvl++, i++) + +#define bio_for_each_segment(bvl, bio, i) \ + __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx) + +void * __bio_kmap_atomic(struct bio *, int, enum km_type); +void __bio_kunmap_atomic(char *buffer, enum km_type); + +void bio_endio(struct bio *, unsigned int, int); +//#define bio_cur_sectors(bio) (bio_iovec(bio)->bv_len >> 9) +int bio_cur_sectors(struct bio *); + +#endif /* __LINUX_BIO_H */ diff --git a/ddverify/models/goblint/include/linux/bitops.h b/ddverify/models/goblint/include/linux/bitops.h new file mode 100644 index 000000000..3e24f9c39 --- /dev/null +++ b/ddverify/models/goblint/include/linux/bitops.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_BITOPS_H +#define _LINUX_BITOPS_H + +#include + +#endif diff --git a/ddverify/models/goblint/include/linux/blkdev.h b/ddverify/models/goblint/include/linux/blkdev.h new file mode 100644 index 000000000..d31cd7561 --- /dev/null +++ b/ddverify/models/goblint/include/linux/blkdev.h @@ -0,0 +1,239 @@ +#ifndef _LINUX_BLKDEV_H +#define _LINUX_BLKDEV_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include + +#include + +struct request_queue; +typedef struct request_queue request_queue_t; + +typedef void (request_fn_proc) (request_queue_t *q); +typedef int (make_request_fn) (request_queue_t *q, struct bio *bio); +typedef void (unplug_fn) (request_queue_t *); + +/* + * request command types + */ +enum rq_cmd_type_bits { + REQ_TYPE_FS = 1, /* fs request */ + REQ_TYPE_BLOCK_PC, /* scsi command */ + REQ_TYPE_SENSE, /* sense request */ + REQ_TYPE_PM_SUSPEND, /* suspend request */ + REQ_TYPE_PM_RESUME, /* resume request */ + REQ_TYPE_PM_SHUTDOWN, /* shutdown request */ + REQ_TYPE_FLUSH, /* flush request */ + REQ_TYPE_SPECIAL, /* driver defined type */ + REQ_TYPE_LINUX_BLOCK, /* generic block layer message */ + /* + * for ATA/ATAPI devices. this really doesn't belong here, ide should + * use REQ_TYPE_SPECIAL and use rq->cmd[0] with the range of driver + * private REQ_LB opcodes to differentiate what type of request this is + */ + REQ_TYPE_ATA_CMD, + REQ_TYPE_ATA_TASK, + REQ_TYPE_ATA_TASKFILE, + REQ_TYPE_ATA_PC, +}; + + +struct request_queue { + request_fn_proc *request_fn; + make_request_fn *make_request_fn; + unplug_fn *unplug_fn; + + struct backing_dev_info backing_dev_info; + void *queuedata; + + /* + * various queue flags, see QUEUE_* below + */ + unsigned long queue_flags; + + spinlock_t *queue_lock; + + unsigned short hardsect_size; + + int __ddv_genhd_no; + int __ddv_queue_alive; +}; + +#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ +#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ +#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */ +#define QUEUE_FLAG_READFULL 3 /* write queue has been filled */ +#define QUEUE_FLAG_WRITEFULL 4 /* read queue has been filled */ +#define QUEUE_FLAG_DEAD 5 /* queue being torn down */ +#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ +#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ +#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ + + + +#define BLK_MAX_CDB 16 + + +struct request { + struct list_head queuelist; + struct list_head donelist; + + request_queue_t *q; + + + unsigned long flags; /* see REQ_ bits below */ + + unsigned int cmd_flags; + enum rq_cmd_type_bits cmd_type; + + struct bio *bio; + + void *completion_data; + + struct gendisk *rq_disk; + sector_t sector; + unsigned long nr_sectors; /* no. of sectors left to submit */ + unsigned int current_nr_sectors; + char *buffer; + + int errors; + + unsigned short nr_phys_segments; + + unsigned char cmd[BLK_MAX_CDB]; +}; + + + +/* + * first three bits match BIO_RW* bits, important + */ +enum rq_flag_bits { + __REQ_RW, /* not set, read. set, write */ + __REQ_FAILFAST, /* no low level driver retries */ + __REQ_SORTED, /* elevator knows about this request */ + __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ + __REQ_HARDBARRIER, /* may not be passed by drive either */ + __REQ_FUA, /* forced unit access */ + __REQ_CMD, /* is a regular fs rw request */ + __REQ_NOMERGE, /* don't touch this for merging */ + __REQ_STARTED, /* drive already may have started this one */ + __REQ_DONTPREP, /* don't call prep for this one */ + __REQ_QUEUED, /* uses queueing */ + __REQ_ELVPRIV, /* elevator private data attached */ + /* + * for ATA/ATAPI devices + */ + __REQ_PC, /* packet command (special) */ + __REQ_BLOCK_PC, /* queued down pc from block layer */ + __REQ_SENSE, /* sense retrival */ + + __REQ_FAILED, /* set if the request failed */ + __REQ_QUIET, /* don't worry about errors */ + __REQ_SPECIAL, /* driver suplied command */ + __REQ_DRIVE_CMD, + __REQ_DRIVE_TASK, + __REQ_DRIVE_TASKFILE, + __REQ_PREEMPT, /* set for "ide_preempt" requests */ + __REQ_PM_SUSPEND, /* suspend request */ + __REQ_PM_RESUME, /* resume request */ + __REQ_PM_SHUTDOWN, /* shutdown request */ + __REQ_ORDERED_COLOR, /* is before or after barrier */ + __REQ_NR_BITS, /* stops here */ +}; + +#define REQ_RW (1 << __REQ_RW) +#define REQ_FAILFAST (1 << __REQ_FAILFAST) +#define REQ_SORTED (1 << __REQ_SORTED) +#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) +#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) +#define REQ_FUA (1 << __REQ_FUA) +#define REQ_CMD (1 << __REQ_CMD) +#define REQ_NOMERGE (1 << __REQ_NOMERGE) +#define REQ_STARTED (1 << __REQ_STARTED) +#define REQ_DONTPREP (1 << __REQ_DONTPREP) +#define REQ_QUEUED (1 << __REQ_QUEUED) +#define REQ_ELVPRIV (1 << __REQ_ELVPRIV) +#define REQ_PC (1 << __REQ_PC) +#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC) +#define REQ_SENSE (1 << __REQ_SENSE) +#define REQ_FAILED (1 << __REQ_FAILED) +#define REQ_QUIET (1 << __REQ_QUIET) +#define REQ_SPECIAL (1 << __REQ_SPECIAL) +#define REQ_DRIVE_CMD (1 << __REQ_DRIVE_CMD) +#define REQ_DRIVE_TASK (1 << __REQ_DRIVE_TASK) +#define REQ_DRIVE_TASKFILE (1 << __REQ_DRIVE_TASKFILE) +#define REQ_PREEMPT (1 << __REQ_PREEMPT) +#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) +#define REQ_PM_RESUME (1 << __REQ_PM_RESUME) +#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) +#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) + + +#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) +#define rq_data_dir(rq) ((rq)->cmd_flags & 1) + +#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) + +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_alloc_queue(gfp_t); +// DDV: Body is defined in linux/block/ll_rw_blk.c +request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_make_request(request_queue_t *, make_request_fn *); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_queue_hardsect_size(request_queue_t *, unsigned short); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void blk_cleanup_queue(request_queue_t *); +// DDV: TODO +void blk_put_queue(request_queue_t *); + + +// DDV: TODO +void blk_plug_device(request_queue_t *); +// DDV: TODO +int blk_remove_plug(request_queue_t *); + +// DDV: TODO +void blkdev_dequeue_request(struct request *req); + +// DDV: TODO +int end_that_request_first(struct request *, int, int); +// DDV: TODO +int end_that_request_chunk(struct request *, int, int); +// DDV: TODO +void end_that_request_last(struct request *, int); +// DDV: Body is defined in linux/block/ll_rw_blk.c +void end_request(struct request *req, int uptodate); +// DDV: TODO +void blk_complete_request(struct request *); + +// DDV: TODO +void blk_queue_bounce_limit(request_queue_t *, u64); + +// DDV: TODO +void blk_queue_max_phys_segments(request_queue_t *, unsigned short); +// DDV: TODO +void blk_queue_max_hw_segments(request_queue_t *, unsigned short); + +// DDV: TODO +int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); + +#define rq_for_each_bio(_bio, rq) \ + if ((rq->bio)) \ + for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next) + +#endif diff --git a/ddverify/models/goblint/include/linux/blkpg.h b/ddverify/models/goblint/include/linux/blkpg.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/blktrace_api.h b/ddverify/models/goblint/include/linux/blktrace_api.h new file mode 100644 index 000000000..4a4b02e12 --- /dev/null +++ b/ddverify/models/goblint/include/linux/blktrace_api.h @@ -0,0 +1,141 @@ +#ifndef BLKTRACE_H +#define BLKTRACE_H + +#include +//#include + +/* + * Trace categories + */ +enum blktrace_cat { + BLK_TC_READ = 1 << 0, /* reads */ + BLK_TC_WRITE = 1 << 1, /* writes */ + BLK_TC_BARRIER = 1 << 2, /* barrier */ + BLK_TC_SYNC = 1 << 3, /* sync IO */ + BLK_TC_QUEUE = 1 << 4, /* queueing/merging */ + BLK_TC_REQUEUE = 1 << 5, /* requeueing */ + BLK_TC_ISSUE = 1 << 6, /* issue */ + BLK_TC_COMPLETE = 1 << 7, /* completions */ + BLK_TC_FS = 1 << 8, /* fs requests */ + BLK_TC_PC = 1 << 9, /* pc requests */ + BLK_TC_NOTIFY = 1 << 10, /* special message */ + BLK_TC_AHEAD = 1 << 11, /* readahead */ + BLK_TC_META = 1 << 12, /* metadata */ + + BLK_TC_END = 1 << 15, /* only 16-bits, reminder */ +}; + +#define BLK_TC_SHIFT (16) +#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT) + +/* + * Basic trace actions + */ +enum blktrace_act { + __BLK_TA_QUEUE = 1, /* queued */ + __BLK_TA_BACKMERGE, /* back merged to existing rq */ + __BLK_TA_FRONTMERGE, /* front merge to existing rq */ + __BLK_TA_GETRQ, /* allocated new request */ + __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */ + __BLK_TA_REQUEUE, /* request requeued */ + __BLK_TA_ISSUE, /* sent to driver */ + __BLK_TA_COMPLETE, /* completed by driver */ + __BLK_TA_PLUG, /* queue was plugged */ + __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */ + __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */ + __BLK_TA_INSERT, /* insert request */ + __BLK_TA_SPLIT, /* bio was split */ + __BLK_TA_BOUNCE, /* bio was bounced */ + __BLK_TA_REMAP, /* bio was remapped */ +}; + +/* + * Trace actions in full. Additionally, read or write is masked + */ +#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE)) +#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE)) +#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE)) +#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE)) +#define BLK_TA_SPLIT (__BLK_TA_SPLIT) +#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) +#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) + +#define BLK_IO_TRACE_MAGIC 0x65617400 +#define BLK_IO_TRACE_VERSION 0x07 + +/* + * The trace itself + */ +struct blk_io_trace { + u32 magic; /* MAGIC << 8 | version */ + u32 sequence; /* event number */ + u64 time; /* in microseconds */ + u64 sector; /* disk offset */ + u32 bytes; /* transfer length */ + u32 action; /* what happened */ + u32 pid; /* who did it */ + u32 device; /* device number */ + u32 cpu; /* on what cpu did it happen */ + u16 error; /* completion error */ + u16 pdu_len; /* length of data after this trace */ +}; + +/* + * The remap event + */ +struct blk_io_trace_remap { + __be32 device; + u32 __pad; + __be64 sector; +}; + +enum { + Blktrace_setup = 1, + Blktrace_running, + Blktrace_stopped, +}; + +struct blk_trace { + int trace_state; + struct rchan *rchan; + unsigned long *sequence; + u16 act_mask; + u64 start_lba; + u64 end_lba; + u32 pid; + u32 dev; + struct dentry *dir; + struct dentry *dropped_file; + atomic_t dropped; +}; + +/* + * User setup structure passed with BLKTRACESTART + */ +struct blk_user_trace_setup { + char name[BDEVNAME_SIZE]; /* output */ + u16 act_mask; /* input */ + u32 buf_size; /* input */ + u32 buf_nr; /* input */ + u64 start_lba; + u64 end_lba; + u32 pid; +}; + +#define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) +#define blk_trace_shutdown(q) do { } while (0) +#define blk_add_trace_rq(q, rq, what) do { } while (0) +#define blk_add_trace_bio(q, rq, what) do { } while (0) +#define blk_add_trace_generic(q, rq, rw, what) do { } while (0) +#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0) +#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0) + +#endif diff --git a/ddverify/models/goblint/include/linux/buffer_head.h b/ddverify/models/goblint/include/linux/buffer_head.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/byteorder/generic.h b/ddverify/models/goblint/include/linux/byteorder/generic.h new file mode 100644 index 000000000..4dd8f5fb9 --- /dev/null +++ b/ddverify/models/goblint/include/linux/byteorder/generic.h @@ -0,0 +1,46 @@ +#ifndef _LINUX_BYTEORDER_GENERIC_H +#define _LINUX_BYTEORDER_GENERIC_H + +#define cpu_to_le64 __cpu_to_le64 +#define le64_to_cpu __le64_to_cpu +#define cpu_to_le32 __cpu_to_le32 +#define le32_to_cpu __le32_to_cpu +#define cpu_to_le16 __cpu_to_le16 +#define le16_to_cpu __le16_to_cpu +#define cpu_to_be64 __cpu_to_be64 +#define be64_to_cpu __be64_to_cpu +#define cpu_to_be32 __cpu_to_be32 +#define be32_to_cpu __be32_to_cpu +#define cpu_to_be16 __cpu_to_be16 +#define be16_to_cpu __be16_to_cpu +#define cpu_to_le64p __cpu_to_le64p +#define le64_to_cpup __le64_to_cpup +#define cpu_to_le32p __cpu_to_le32p +#define le32_to_cpup __le32_to_cpup +#define cpu_to_le16p __cpu_to_le16p +#define le16_to_cpup __le16_to_cpup +#define cpu_to_be64p __cpu_to_be64p +#define be64_to_cpup __be64_to_cpup +#define cpu_to_be32p __cpu_to_be32p +#define be32_to_cpup __be32_to_cpup +#define cpu_to_be16p __cpu_to_be16p +#define be16_to_cpup __be16_to_cpup +#define cpu_to_le64s __cpu_to_le64s +#define le64_to_cpus __le64_to_cpus +#define cpu_to_le32s __cpu_to_le32s +#define le32_to_cpus __le32_to_cpus +#define cpu_to_le16s __cpu_to_le16s +#define le16_to_cpus __le16_to_cpus +#define cpu_to_be64s __cpu_to_be64s +#define be64_to_cpus __be64_to_cpus +#define cpu_to_be32s __cpu_to_be32s +#define be32_to_cpus __be32_to_cpus +#define cpu_to_be16s __cpu_to_be16s +#define be16_to_cpus __be16_to_cpus + +#define htonl(x) x +#define ntohl(x) x +#define htons(x) x +#define ntohs(x) x + +#endif /* _LINUX_BYTEORDER_GENERIC_H */ diff --git a/ddverify/models/goblint/include/linux/byteorder/little_endian.h b/ddverify/models/goblint/include/linux/byteorder/little_endian.h new file mode 100644 index 000000000..9925e2e4e --- /dev/null +++ b/ddverify/models/goblint/include/linux/byteorder/little_endian.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H +#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H + +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN 1234 +#endif +#ifndef __LITTLE_ENDIAN_BITFIELD +#define __LITTLE_ENDIAN_BITFIELD +#endif + +#include +//#include + + +#define __cpu_to_le64(x) x +#define __le64_to_cpu(x) x +#define __cpu_to_le32(x) x +#define __le32_to_cpu(x) x +#define __cpu_to_le16(x) x +#define __le16_to_cpu(x) x +#define __cpu_to_be64(x) x +#define __be64_to_cpu(x) x +#define __cpu_to_be32(x) x +#define __be32_to_cpu(x) x +#define __cpu_to_be16(x) x +#define __be16_to_cpu(x) x + +#include + +#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ diff --git a/ddverify/models/goblint/include/linux/cache.h b/ddverify/models/goblint/include/linux/cache.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/capability.h b/ddverify/models/goblint/include/linux/capability.h new file mode 100644 index 000000000..2d039b6e8 --- /dev/null +++ b/ddverify/models/goblint/include/linux/capability.h @@ -0,0 +1,244 @@ +/* + * This is + * + * Andrew G. Morgan + * Alexander Kjeldaas + * with help from Aleph1, Roland Buresund and Andrew Main. + * + * See here for the libcap library ("POSIX draft" compliance): + * + * ftp://linux.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.2/ + */ + +#ifndef _LINUX_CAPABILITY_H +#define _LINUX_CAPABILITY_H + +#include +#include + +/** + ** POSIX-draft defined capabilities. + **/ + +/* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this + overrides the restriction of changing file ownership and group + ownership. */ + +#define CAP_CHOWN 0 + +/* Override all DAC access, including ACL execute access if + [_POSIX_ACL] is defined. Excluding DAC access covered by + CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_OVERRIDE 1 + +/* Overrides all DAC restrictions regarding read and search on files + and directories, including ACL restrictions if [_POSIX_ACL] is + defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */ + +#define CAP_DAC_READ_SEARCH 2 + +/* Overrides all restrictions about allowed operations on files, where + file owner ID must be equal to the user ID, except where CAP_FSETID + is applicable. It doesn't override MAC and DAC restrictions. */ + +#define CAP_FOWNER 3 + +/* Overrides the following restrictions that the effective user ID + shall match the file owner ID when setting the S_ISUID and S_ISGID + bits on that file; that the effective group ID (or one of the + supplementary group IDs) shall match the file owner ID when setting + the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are + cleared on successful return from chown(2) (not implemented). */ + +#define CAP_FSETID 4 + +/* Used to decide between falling back on the old suser() or fsuser(). */ + +#define CAP_FS_MASK 0x1f + +/* Overrides the restriction that the real or effective user ID of a + process sending a signal must match the real or effective user ID + of the process receiving the signal. */ + +#define CAP_KILL 5 + +/* Allows setgid(2) manipulation */ +/* Allows setgroups(2) */ +/* Allows forged gids on socket credentials passing. */ + +#define CAP_SETGID 6 + +/* Allows set*uid(2) manipulation (including fsuid). */ +/* Allows forged pids on socket credentials passing. */ + +#define CAP_SETUID 7 + + +/** + ** Linux-specific capabilities + **/ + +/* Transfer any capability in your permitted set to any pid, + remove any capability in your permitted set from any pid */ + +#define CAP_SETPCAP 8 + +/* Allow modification of S_IMMUTABLE and S_APPEND file attributes */ + +#define CAP_LINUX_IMMUTABLE 9 + +/* Allows binding to TCP/UDP sockets below 1024 */ +/* Allows binding to ATM VCIs below 32 */ + +#define CAP_NET_BIND_SERVICE 10 + +/* Allow broadcasting, listen to multicast */ + +#define CAP_NET_BROADCAST 11 + +/* Allow interface configuration */ +/* Allow administration of IP firewall, masquerading and accounting */ +/* Allow setting debug option on sockets */ +/* Allow modification of routing tables */ +/* Allow setting arbitrary process / process group ownership on + sockets */ +/* Allow binding to any address for transparent proxying */ +/* Allow setting TOS (type of service) */ +/* Allow setting promiscuous mode */ +/* Allow clearing driver statistics */ +/* Allow multicasting */ +/* Allow read/write of device-specific registers */ +/* Allow activation of ATM control sockets */ + +#define CAP_NET_ADMIN 12 + +/* Allow use of RAW sockets */ +/* Allow use of PACKET sockets */ + +#define CAP_NET_RAW 13 + +/* Allow locking of shared memory segments */ +/* Allow mlock and mlockall (which doesn't really have anything to do + with IPC) */ + +#define CAP_IPC_LOCK 14 + +/* Override IPC ownership checks */ + +#define CAP_IPC_OWNER 15 + +/* Insert and remove kernel modules - modify kernel without limit */ +/* Modify cap_bset */ +#define CAP_SYS_MODULE 16 + +/* Allow ioperm/iopl access */ +/* Allow sending USB messages to any device via /proc/bus/usb */ + +#define CAP_SYS_RAWIO 17 + +/* Allow use of chroot() */ + +#define CAP_SYS_CHROOT 18 + +/* Allow ptrace() of any process */ + +#define CAP_SYS_PTRACE 19 + +/* Allow configuration of process accounting */ + +#define CAP_SYS_PACCT 20 + +/* Allow configuration of the secure attention key */ +/* Allow administration of the random device */ +/* Allow examination and configuration of disk quotas */ +/* Allow configuring the kernel's syslog (printk behaviour) */ +/* Allow setting the domainname */ +/* Allow setting the hostname */ +/* Allow calling bdflush() */ +/* Allow mount() and umount(), setting up new smb connection */ +/* Allow some autofs root ioctls */ +/* Allow nfsservctl */ +/* Allow VM86_REQUEST_IRQ */ +/* Allow to read/write pci config on alpha */ +/* Allow irix_prctl on mips (setstacksize) */ +/* Allow flushing all cache on m68k (sys_cacheflush) */ +/* Allow removing semaphores */ +/* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores + and shared memory */ +/* Allow locking/unlocking of shared memory segment */ +/* Allow turning swap on/off */ +/* Allow forged pids on socket credentials passing */ +/* Allow setting readahead and flushing buffers on block devices */ +/* Allow setting geometry in floppy driver */ +/* Allow turning DMA on/off in xd driver */ +/* Allow administration of md devices (mostly the above, but some + extra ioctls) */ +/* Allow tuning the ide driver */ +/* Allow access to the nvram device */ +/* Allow administration of apm_bios, serial and bttv (TV) device */ +/* Allow manufacturer commands in isdn CAPI support driver */ +/* Allow reading non-standardized portions of pci configuration space */ +/* Allow DDI debug ioctl on sbpcd driver */ +/* Allow setting up serial ports */ +/* Allow sending raw qic-117 commands */ +/* Allow enabling/disabling tagged queuing on SCSI controllers and sending + arbitrary SCSI commands */ +/* Allow setting encryption key on loopback filesystem */ +/* Allow setting zone reclaim policy */ + +#define CAP_SYS_ADMIN 21 + +/* Allow use of reboot() */ + +#define CAP_SYS_BOOT 22 + +/* Allow raising priority and setting priority on other (different + UID) processes */ +/* Allow use of FIFO and round-robin (realtime) scheduling on own + processes and setting the scheduling algorithm used by another + process. */ +/* Allow setting cpu affinity on other processes */ + +#define CAP_SYS_NICE 23 + +/* Override resource limits. Set resource limits. */ +/* Override quota limits. */ +/* Override reserved space on ext2 filesystem */ +/* Modify data journaling mode on ext3 filesystem (uses journaling + resources) */ +/* NOTE: ext2 honors fsuid when checking for resource overrides, so + you can override using fsuid too */ +/* Override size restrictions on IPC message queues */ +/* Allow more than 64hz interrupts from the real-time clock */ +/* Override max number of consoles on console allocation */ +/* Override max number of keymaps */ + +#define CAP_SYS_RESOURCE 24 + +/* Allow manipulation of system clock */ +/* Allow irix_stime on mips */ +/* Allow setting the real-time clock */ + +#define CAP_SYS_TIME 25 + +/* Allow configuration of tty devices */ +/* Allow vhangup() of tty */ + +#define CAP_SYS_TTY_CONFIG 26 + +/* Allow the privileged aspects of mknod() */ + +#define CAP_MKNOD 27 + +/* Allow taking of leases on files */ + +#define CAP_LEASE 28 + +#define CAP_AUDIT_WRITE 29 + +#define CAP_AUDIT_CONTROL 30 + +int capable(int cap); + +#endif /* !_LINUX_CAPABILITY_H */ diff --git a/ddverify/models/goblint/include/linux/cdev.h b/ddverify/models/goblint/include/linux/cdev.h new file mode 100644 index 000000000..92608a6ff --- /dev/null +++ b/ddverify/models/goblint/include/linux/cdev.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_CDEV_H +#define _LINUX_CDEV_H + +struct cdev { + struct module *owner; + struct file_operations *ops; + dev_t dev; + unsigned int count; +}; + +void cdev_init(struct cdev *, struct file_operations *); + +struct cdev *cdev_alloc(void); + +void cdev_put(struct cdev *p); + +int cdev_add(struct cdev *, dev_t, unsigned); + +void cdev_del(struct cdev *); + +void cd_forget(struct inode *); + +#endif diff --git a/ddverify/models/goblint/include/linux/cdrom.h b/ddverify/models/goblint/include/linux/cdrom.h new file mode 100644 index 000000000..b68fdf1f3 --- /dev/null +++ b/ddverify/models/goblint/include/linux/cdrom.h @@ -0,0 +1,1192 @@ +/* + * -- + * General header file for linux CD-ROM drivers + * Copyright (C) 1992 David Giller, rafetmad@oxy.edu + * 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de + * 1996 David van Leeuwen, david@tm.tno.nl + * 1997, 1998 Erik Andersen, andersee@debian.org + * 1998-2002 Jens Axboe, axboe@suse.de + */ + +#ifndef _LINUX_CDROM_H +#define _LINUX_CDROM_H + +#include + +/******************************************************* + * As of Linux 2.1.x, all Linux CD-ROM application programs will use this + * (and only this) include file. It is my hope to provide Linux with + * a uniform interface between software accessing CD-ROMs and the various + * device drivers that actually talk to the drives. There may still be + * 23 different kinds of strange CD-ROM drives, but at least there will + * now be one, and only one, Linux CD-ROM interface. + * + * Additionally, as of Linux 2.1.x, all Linux application programs + * should use the O_NONBLOCK option when opening a CD-ROM device + * for subsequent ioctl commands. This allows for neat system errors + * like "No medium found" or "Wrong medium type" upon attempting to + * mount or play an empty slot, mount an audio disc, or play a data disc. + * Generally, changing an application program to support O_NONBLOCK + * is as easy as the following: + * - drive = open("/dev/cdrom", O_RDONLY); + * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); + * It is worth the small change. + * + * Patches for many common CD programs (provided by David A. van Leeuwen) + * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/ + * + *******************************************************/ + +/* When a driver supports a certain function, but the cdrom drive we are + * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will + * borrow the "Operation not supported" error from the network folks to + * accomplish this. Maybe someday we will get a more targeted error code, + * but this will do for now... */ +#define EDRIVE_CANT_DO_THIS EOPNOTSUPP + +/******************************************************* + * The CD-ROM IOCTL commands -- these should be supported by + * all the various cdrom drivers. For the CD-ROM ioctls, we + * will commandeer byte 0x53, or 'S'. + *******************************************************/ +#define CDROMPAUSE 0x5301 /* Pause Audio Operation */ +#define CDROMRESUME 0x5302 /* Resume paused Audio Operation */ +#define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ +#define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index + (struct cdrom_ti) */ +#define CDROMREADTOCHDR 0x5305 /* Read TOC header + (struct cdrom_tochdr) */ +#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry + (struct cdrom_tocentry) */ +#define CDROMSTOP 0x5307 /* Stop the cdrom drive */ +#define CDROMSTART 0x5308 /* Start the cdrom drive */ +#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ +#define CDROMVOLCTRL 0x530a /* Control output volume + (struct cdrom_volctrl) */ +#define CDROMSUBCHNL 0x530b /* Read subchannel data + (struct cdrom_subchnl) */ +#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) + (struct cdrom_read) */ +#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) + (struct cdrom_read) */ +#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ +#define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ +#define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session + address of multi session disks + (struct cdrom_multisession) */ +#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" + if available (struct cdrom_mcn) */ +#define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated, + but here anyway for compatibility */ +#define CDROMRESET 0x5312 /* hard-reset the drive */ +#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting + (struct cdrom_volctrl) */ +#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) + (struct cdrom_read) */ +/* + * These ioctls are used only used in aztcd.c and optcd.c + */ +#define CDROMREADCOOKED 0x5315 /* read data in cooked mode */ +#define CDROMSEEK 0x5316 /* seek msf address */ + +/* + * This ioctl is only used by the scsi-cd driver. + It is for playing audio in logical block addressing mode. + */ +#define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ + +/* + * These ioctls are only used in optcd.c + */ +#define CDROMREADALL 0x5318 /* read all 2646 bytes */ + +/* + * These ioctls are (now) only in ide-cd.c for controlling + * drive spindown time. They should be implemented in the + * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, + * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... + * -Erik + */ +#define CDROMGETSPINDOWN 0x531d +#define CDROMSETSPINDOWN 0x531e + +/* + * These ioctls are implemented through the uniform CD-ROM driver + * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM + * drivers are eventually ported to the uniform CD-ROM driver interface. + */ +#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ +#define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */ +#define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */ +#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ +#define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */ +#define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */ +#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ +#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ +#define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */ +#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */ +#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */ +#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ + +/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386. + * Future CDROM ioctls should be kept below 0x537F + */ + +/* This ioctl is only used by sbpcd at the moment */ +#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ + /* conflict with SCSI_IOCTL_GET_IDLUN */ + +/* DVD-ROM Specific ioctls */ +#define DVD_READ_STRUCT 0x5390 /* Read structure */ +#define DVD_WRITE_STRUCT 0x5391 /* Write structure */ +#define DVD_AUTH 0x5392 /* Authentication */ + +#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */ +#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */ +#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */ + +/******************************************************* + * CDROM IOCTL structures + *******************************************************/ + +/* Address in MSF format */ +struct cdrom_msf0 +{ + __u8 minute; + __u8 second; + __u8 frame; +}; + +/* Address in either MSF or logical format */ +union cdrom_addr +{ + struct cdrom_msf0 msf; + int lba; +}; + +/* This struct is used by the CDROMPLAYMSF ioctl */ +struct cdrom_msf +{ + __u8 cdmsf_min0; /* start minute */ + __u8 cdmsf_sec0; /* start second */ + __u8 cdmsf_frame0; /* start frame */ + __u8 cdmsf_min1; /* end minute */ + __u8 cdmsf_sec1; /* end second */ + __u8 cdmsf_frame1; /* end frame */ +}; + +/* This struct is used by the CDROMPLAYTRKIND ioctl */ +struct cdrom_ti +{ + __u8 cdti_trk0; /* start track */ + __u8 cdti_ind0; /* start index */ + __u8 cdti_trk1; /* end track */ + __u8 cdti_ind1; /* end index */ +}; + +/* This struct is used by the CDROMREADTOCHDR ioctl */ +struct cdrom_tochdr +{ + __u8 cdth_trk0; /* start track */ + __u8 cdth_trk1; /* end track */ +}; + +/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */ +struct cdrom_volctrl +{ + __u8 channel0; + __u8 channel1; + __u8 channel2; + __u8 channel3; +}; + +/* This struct is used by the CDROMSUBCHNL ioctl */ +struct cdrom_subchnl +{ + __u8 cdsc_format; + __u8 cdsc_audiostatus; + __u8 cdsc_adr: 4; + __u8 cdsc_ctrl: 4; + __u8 cdsc_trk; + __u8 cdsc_ind; + union cdrom_addr cdsc_absaddr; + union cdrom_addr cdsc_reladdr; +}; + + +/* This struct is used by the CDROMREADTOCENTRY ioctl */ +struct cdrom_tocentry +{ + __u8 cdte_track; + __u8 cdte_adr :4; + __u8 cdte_ctrl :4; + __u8 cdte_format; + union cdrom_addr cdte_addr; + __u8 cdte_datamode; +}; + +/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */ +struct cdrom_read +{ + int cdread_lba; + char *cdread_bufaddr; + int cdread_buflen; +}; + +/* This struct is used by the CDROMREADAUDIO ioctl */ +struct cdrom_read_audio +{ + union cdrom_addr addr; /* frame address */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ + int nframes; /* number of 2352-byte-frames to read at once */ + __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */ +}; + +/* This struct is used with the CDROMMULTISESSION ioctl */ +struct cdrom_multisession +{ + union cdrom_addr addr; /* frame address: start-of-last-session + (not the new "frame 16"!). Only valid + if the "xa_flag" is true. */ + __u8 xa_flag; /* 1: "is XA disk" */ + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ +}; + +/* This struct is used with the CDROM_GET_MCN ioctl. + * Very few audio discs actually have Universal Product Code information, + * which should just be the Medium Catalog Number on the box. Also note + * that the way the codeis written on CD is _not_ uniform across all discs! + */ +struct cdrom_mcn +{ + __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */ +}; + +/* This is used by the CDROMPLAYBLK ioctl */ +struct cdrom_blk +{ + unsigned from; + unsigned short len; +}; + +#define CDROM_PACKET_SIZE 12 + +#define CGC_DATA_UNKNOWN 0 +#define CGC_DATA_WRITE 1 +#define CGC_DATA_READ 2 +#define CGC_DATA_NONE 3 + +/* for CDROM_PACKET_COMMAND ioctl */ +struct cdrom_generic_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char __user *buffer; + unsigned int buflen; + int stat; + struct request_sense __user *sense; + unsigned char data_direction; + int quiet; + int timeout; + void __user *reserved[1]; /* unused, actually */ +}; + +/* + * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, + * 2340, or 2352 bytes long. + +* Sector types of the standard CD-ROM data formats: + * + * format sector type user data size (bytes) + * ----------------------------------------------------------------------------- + * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW) + * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE) + * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0) + * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE) + * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes) + * + * + * The layout of the standard CD-ROM data formats: + * ----------------------------------------------------------------------------- + * - audio (red): | audio_sample_bytes | + * | 2352 | + * + * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC | + * | 12 - 4 - 2048 - 4 - 8 - 276 | + * + * - data (yellow, mode2): | sync - head - data | + * | 12 - 4 - 2336 | + * + * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC | + * | 12 - 4 - 8 - 2048 - 4 - 276 | + * + * - XA data (green, mode2 form2): | sync - head - sub - data - Spare | + * | 12 - 4 - 8 - 2324 - 4 | + * + */ + +/* Some generally useful CD-ROM information -- mostly based on the above */ +#define CD_MINS 74 /* max. minutes per CD, not really a limit */ +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ +#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ +#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ +#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ +#define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */ +#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ +#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */ +#define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */ +#define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */ +#define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */ +#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ +#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ +/* most drives don't deliver everything: */ +#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ +#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ + +#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */ +#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */ +#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */ + +/* CD-ROM address types (cdrom_tocentry.cdte_format) */ +#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ +#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ + +/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ +#define CDROM_DATA_TRACK 0x04 + +/* The leadout track is always 0xAA, regardless of # of tracks on disc */ +#define CDROM_LEADOUT 0xAA + +/* audio states (from SCSI-2, but seen with other drives, too) */ +#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ +#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ +#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ +#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ +#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ +#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ + +/* capability flags used with the uniform CD-ROM driver */ +#define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */ +#define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */ +#define CDC_LOCK 0x4 /* disable manual eject */ +#define CDC_SELECT_SPEED 0x8 /* programmable speed */ +#define CDC_SELECT_DISC 0x10 /* select disc from juke-box */ +#define CDC_MULTI_SESSION 0x20 /* read sessions>1 */ +#define CDC_MCN 0x40 /* Medium Catalog Number */ +#define CDC_MEDIA_CHANGED 0x80 /* media changed */ +#define CDC_PLAY_AUDIO 0x100 /* audio functions */ +#define CDC_RESET 0x200 /* hard reset device */ +#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */ +#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ +#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ +#define CDC_CD_R 0x2000 /* drive is a CD-R */ +#define CDC_CD_RW 0x4000 /* drive is a CD-RW */ +#define CDC_DVD 0x8000 /* drive is a DVD */ +#define CDC_DVD_R 0x10000 /* drive can write DVD-R */ +#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */ +#define CDC_MO_DRIVE 0x40000 /* drive is an MO device */ +#define CDC_MRW 0x80000 /* drive can read MRW */ +#define CDC_MRW_W 0x100000 /* drive can write MRW */ +#define CDC_RAM 0x200000 /* ok to open for WRITE */ + +/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ +#define CDS_NO_INFO 0 /* if not implemented */ +#define CDS_NO_DISC 1 +#define CDS_TRAY_OPEN 2 +#define CDS_DRIVE_NOT_READY 3 +#define CDS_DISC_OK 4 + +/* return values for the CDROM_DISC_STATUS ioctl */ +/* can also return CDS_NO_[INFO|DISC], from above */ +#define CDS_AUDIO 100 +#define CDS_DATA_1 101 +#define CDS_DATA_2 102 +#define CDS_XA_2_1 103 +#define CDS_XA_2_2 104 +#define CDS_MIXED 105 + +/* User-configurable behavior options for the uniform CD-ROM driver */ +#define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */ +#define CDO_AUTO_EJECT 0x2 /* open tray on last release() */ +#define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */ +#define CDO_LOCK 0x8 /* lock tray on open files */ +#define CDO_CHECK_TYPE 0x10 /* check type on open for data */ + +/* Special codes used when specifying changer slots. */ +#define CDSL_NONE ((int) (~0U>>1)-1) +#define CDSL_CURRENT ((int) (~0U>>1)) + +/* For partition based multisession access. IDE can handle 64 partitions + * per drive - SCSI CD-ROM's use minors to differentiate between the + * various drives, so we can't do multisessions the same way there. + * Use the -o session=x option to mount on them. + */ +#define CD_PART_MAX 64 +#define CD_PART_MASK (CD_PART_MAX - 1) + +/********************************************************************* + * Generic Packet commands, MMC commands, and such + *********************************************************************/ + + /* The generic packet command opcodes for CD/DVD Logical Units, + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +#define GPCMD_BLANK 0xa1 +#define GPCMD_CLOSE_TRACK 0x5b +#define GPCMD_FLUSH_CACHE 0x35 +#define GPCMD_FORMAT_UNIT 0x04 +#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a +#define GPCMD_GET_PERFORMANCE 0xac +#define GPCMD_INQUIRY 0x12 +#define GPCMD_LOAD_UNLOAD 0xa6 +#define GPCMD_MECHANISM_STATUS 0xbd +#define GPCMD_MODE_SELECT_10 0x55 +#define GPCMD_MODE_SENSE_10 0x5a +#define GPCMD_PAUSE_RESUME 0x4b +#define GPCMD_PLAY_AUDIO_10 0x45 +#define GPCMD_PLAY_AUDIO_MSF 0x47 +#define GPCMD_PLAY_AUDIO_TI 0x48 +#define GPCMD_PLAY_CD 0xbc +#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e +#define GPCMD_READ_10 0x28 +#define GPCMD_READ_12 0xa8 +#define GPCMD_READ_BUFFER_CAPACITY 0x5c +#define GPCMD_READ_CDVD_CAPACITY 0x25 +#define GPCMD_READ_CD 0xbe +#define GPCMD_READ_CD_MSF 0xb9 +#define GPCMD_READ_DISC_INFO 0x51 +#define GPCMD_READ_DVD_STRUCTURE 0xad +#define GPCMD_READ_FORMAT_CAPACITIES 0x23 +#define GPCMD_READ_HEADER 0x44 +#define GPCMD_READ_TRACK_RZONE_INFO 0x52 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_REPAIR_RZONE_TRACK 0x58 +#define GPCMD_REPORT_KEY 0xa4 +#define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_RESERVE_RZONE_TRACK 0x53 +#define GPCMD_SEND_CUE_SHEET 0x5d +#define GPCMD_SCAN 0xba +#define GPCMD_SEEK 0x2b +#define GPCMD_SEND_DVD_STRUCTURE 0xbf +#define GPCMD_SEND_EVENT 0xa2 +#define GPCMD_SEND_KEY 0xa3 +#define GPCMD_SEND_OPC 0x54 +#define GPCMD_SET_READ_AHEAD 0xa7 +#define GPCMD_SET_STREAMING 0xb6 +#define GPCMD_START_STOP_UNIT 0x1b +#define GPCMD_STOP_PLAY_SCAN 0x4e +#define GPCMD_TEST_UNIT_READY 0x00 +#define GPCMD_VERIFY_10 0x2f +#define GPCMD_WRITE_10 0x2a +#define GPCMD_WRITE_AND_VERIFY_10 0x2e +/* This is listed as optional in ATAPI 2.6, but is (curiously) + * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji + * Table 377 as an MMC command for SCSi devices though... Most ATAPI + * drives support it. */ +#define GPCMD_SET_SPEED 0xbb +/* This seems to be a SCSI specific CD-ROM opcode + * to play data at track/index */ +#define GPCMD_PLAYAUDIO_TI 0x48 +/* + * From MS Media Status Notification Support Specification. For + * older drives only. + */ +#define GPCMD_GET_MEDIA_STATUS 0xda + +/* Mode page codes for mode sense/set */ +#define GPMODE_VENDOR_PAGE 0x00 +#define GPMODE_R_W_ERROR_PAGE 0x01 +#define GPMODE_WRITE_PARMS_PAGE 0x05 +#define GPMODE_WCACHING_PAGE 0x08 +#define GPMODE_AUDIO_CTL_PAGE 0x0e +#define GPMODE_POWER_PAGE 0x1a +#define GPMODE_FAULT_FAIL_PAGE 0x1c +#define GPMODE_TO_PROTECT_PAGE 0x1d +#define GPMODE_CAPABILITIES_PAGE 0x2a +#define GPMODE_ALL_PAGES 0x3f +/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor + * of MODE_SENSE_POWER_PAGE */ +#define GPMODE_CDROM_PAGE 0x0d + + + +/* DVD struct types */ +#define DVD_STRUCT_PHYSICAL 0x00 +#define DVD_STRUCT_COPYRIGHT 0x01 +#define DVD_STRUCT_DISCKEY 0x02 +#define DVD_STRUCT_BCA 0x03 +#define DVD_STRUCT_MANUFACT 0x04 + +struct dvd_layer { + __u8 book_version : 4; + __u8 book_type : 4; + __u8 min_rate : 4; + __u8 disc_size : 4; + __u8 layer_type : 4; + __u8 track_path : 1; + __u8 nlayers : 2; + __u8 track_density : 4; + __u8 linear_density : 4; + __u8 bca : 1; + __u32 start_sector; + __u32 end_sector; + __u32 end_sector_l0; +}; + +#define DVD_LAYERS 4 + +struct dvd_physical { + __u8 type; + __u8 layer_num; + struct dvd_layer layer[DVD_LAYERS]; +}; + +struct dvd_copyright { + __u8 type; + + __u8 layer_num; + __u8 cpst; + __u8 rmi; +}; + +struct dvd_disckey { + __u8 type; + + unsigned agid : 2; + __u8 value[2048]; +}; + +struct dvd_bca { + __u8 type; + + int len; + __u8 value[188]; +}; + +struct dvd_manufact { + __u8 type; + + __u8 layer_num; + int len; + __u8 value[2048]; +}; + +typedef union { + __u8 type; + + struct dvd_physical physical; + struct dvd_copyright copyright; + struct dvd_disckey disckey; + struct dvd_bca bca; + struct dvd_manufact manufact; +} dvd_struct; + +/* + * DVD authentication ioctl + */ + +/* Authentication states */ +#define DVD_LU_SEND_AGID 0 +#define DVD_HOST_SEND_CHALLENGE 1 +#define DVD_LU_SEND_KEY1 2 +#define DVD_LU_SEND_CHALLENGE 3 +#define DVD_HOST_SEND_KEY2 4 + +/* Termination states */ +#define DVD_AUTH_ESTABLISHED 5 +#define DVD_AUTH_FAILURE 6 + +/* Other functions */ +#define DVD_LU_SEND_TITLE_KEY 7 +#define DVD_LU_SEND_ASF 8 +#define DVD_INVALIDATE_AGID 9 +#define DVD_LU_SEND_RPC_STATE 10 +#define DVD_HOST_SEND_RPC_STATE 11 + +/* State data */ +typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ +typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ + +struct dvd_lu_send_agid { + __u8 type; + unsigned agid : 2; +}; + +struct dvd_host_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +struct dvd_send_key { + __u8 type; + unsigned agid : 2; + + dvd_key key; +}; + +struct dvd_lu_send_challenge { + __u8 type; + unsigned agid : 2; + + dvd_challenge chal; +}; + +#define DVD_CPM_NO_COPYRIGHT 0 +#define DVD_CPM_COPYRIGHTED 1 + +#define DVD_CP_SEC_NONE 0 +#define DVD_CP_SEC_EXIST 1 + +#define DVD_CGMS_UNRESTRICTED 0 +#define DVD_CGMS_SINGLE 2 +#define DVD_CGMS_RESTRICTED 3 + +struct dvd_lu_send_title_key { + __u8 type; + unsigned agid : 2; + + dvd_key title_key; + int lba; + unsigned cpm : 1; + unsigned cp_sec : 1; + unsigned cgms : 2; +}; + +struct dvd_lu_send_asf { + __u8 type; + unsigned agid : 2; + + unsigned asf : 1; +}; + +struct dvd_host_send_rpcstate { + __u8 type; + __u8 pdrc; +}; + +struct dvd_lu_send_rpcstate { + __u8 type : 2; + __u8 vra : 3; + __u8 ucca : 3; + __u8 region_mask; + __u8 rpc_scheme; +}; + +typedef union { + __u8 type; + + struct dvd_lu_send_agid lsa; + struct dvd_host_send_challenge hsc; + struct dvd_send_key lsk; + struct dvd_lu_send_challenge lsc; + struct dvd_send_key hsk; + struct dvd_lu_send_title_key lstk; + struct dvd_lu_send_asf lsasf; + struct dvd_host_send_rpcstate hrpcs; + struct dvd_lu_send_rpcstate lrpcs; +} dvd_authinfo; + +struct request_sense { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 valid : 1; + __u8 error_code : 7; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 error_code : 7; + __u8 valid : 1; +#endif + __u8 segment_number; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 ili : 1; + __u8 reserved2 : 1; + __u8 sense_key : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 sense_key : 4; + __u8 reserved2 : 1; + __u8 ili : 1; + __u8 reserved1 : 2; +#endif + __u8 information[4]; + __u8 add_sense_len; + __u8 command_info[4]; + __u8 asc; + __u8 ascq; + __u8 fruc; + __u8 sks[3]; + __u8 asb[46]; +}; + +/* + * feature profile + */ +#define CDF_RWRT 0x0020 /* "Random Writable" */ +#define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ +#define CDF_MRW 0x0028 + +/* + * media status bits + */ +#define CDM_MRW_NOTMRW 0 +#define CDM_MRW_BGFORMAT_INACTIVE 1 +#define CDM_MRW_BGFORMAT_ACTIVE 2 +#define CDM_MRW_BGFORMAT_COMPLETE 3 + +/* + * mrw address spaces + */ +#define MRW_LBA_DMA 0 +#define MRW_LBA_GAA 1 + +/* + * mrw mode pages (first is deprecated) -- probed at init time and + * cdi->mrw_mode_page is set + */ +#define MRW_MODE_PC_PRE1 0x2c +#define MRW_MODE_PC 0x03 + +struct mrw_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 write : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 write : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; + __u8 reserved4; + __u8 reserved5; +}; + +/* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */ +struct rwrt_feature_desc { + __u16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; + __u32 last_lba; + __u32 block_size; + __u16 blocking; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 7; + __u8 page_present : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_present : 1; + __u8 reserved2 : 7; +#endif + __u8 reserved3; +}; + +typedef struct { + __u16 disc_information_length; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 3; + __u8 erasable : 1; + __u8 border_status : 2; + __u8 disc_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 disc_status : 2; + __u8 border_status : 2; + __u8 erasable : 1; + __u8 reserved1 : 3; +#else +#error "Please fix " +#endif + __u8 n_first_track; + __u8 n_sessions_lsb; + __u8 first_track_lsb; + __u8 last_track_lsb; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 did_v : 1; + __u8 dbc_v : 1; + __u8 uru : 1; + __u8 reserved2 : 2; + __u8 dbit : 1; + __u8 mrw_status : 2; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 mrw_status : 2; + __u8 dbit : 1; + __u8 reserved2 : 2; + __u8 uru : 1; + __u8 dbc_v : 1; + __u8 did_v : 1; +#endif + __u8 disc_type; + __u8 n_sessions_msb; + __u8 first_track_msb; + __u8 last_track_msb; + __u32 disc_id; + __u32 lead_in; + __u32 lead_out; + __u8 disc_bar_code[8]; + __u8 reserved3; + __u8 n_opc; +} disc_information; + +typedef struct { + __u16 track_information_length; + __u8 track_lsb; + __u8 session_lsb; + __u8 reserved1; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved2 : 2; + __u8 damage : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 rt : 1; + __u8 blank : 1; + __u8 packet : 1; + __u8 fp : 1; + __u8 data_mode : 4; + __u8 reserved3 : 6; + __u8 lra_v : 1; + __u8 nwa_v : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 track_mode : 4; + __u8 copy : 1; + __u8 damage : 1; + __u8 reserved2 : 2; + __u8 data_mode : 4; + __u8 fp : 1; + __u8 packet : 1; + __u8 blank : 1; + __u8 rt : 1; + __u8 nwa_v : 1; + __u8 lra_v : 1; + __u8 reserved3 : 6; +#endif + __u32 track_start; + __u32 next_writable; + __u32 free_blocks; + __u32 fixed_packet_size; + __u32 track_size; + __u32 last_rec_address; +} track_information; + +struct feature_header { + __u32 data_len; + __u8 reserved1; + __u8 reserved2; + __u16 curr_profile; +}; + +struct mode_page_header { + __u16 mode_data_length; + __u8 medium_type; + __u8 reserved1; + __u8 reserved2; + __u8 reserved3; + __u16 desc_length; +}; + +#ifdef __KERNEL__ +#include /* not really needed, later.. */ +#include + +struct packet_command +{ + unsigned char cmd[CDROM_PACKET_SIZE]; + unsigned char *buffer; + unsigned int buflen; + int stat; + struct request_sense *sense; + unsigned char data_direction; + int quiet; + int timeout; + void *reserved[1]; +}; + +/* + * _OLD will use PIO transfer on atapi devices, _BPC_* will use DMA + */ +#define CDDA_OLD 0 /* old style */ +#define CDDA_BPC_SINGLE 1 /* single frame block pc */ +#define CDDA_BPC_FULL 2 /* multi frame block pc */ + +/* Uniform cdrom data structures for cdrom.c */ +struct cdrom_device_info { + struct cdrom_device_ops *ops; /* link to device_ops */ + struct cdrom_device_info *next; /* next device_info for this major */ + struct gendisk *disk; /* matching block layer disk */ + void *handle; /* driver-dependent data */ +/* specifications */ + int mask; /* mask of capability: disables them */ + int speed; /* maximum speed for reading data */ + int capacity; /* number of discs in jukebox */ +/* device-related storage */ + int options : 30; /* options flags */ + unsigned mc_flags : 2; /* media change buffer flags */ + int use_count; /* number of times device opened */ + char name[20]; /* name of the device type */ +/* per-device flags */ + __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ + __u8 reserved : 6; /* not used yet */ + int cdda_method; /* see flags */ + __u8 last_sense; + __u8 media_written; /* dirty flag, DVD+RW bookkeeping */ + unsigned short mmc3_profile; /* current MMC3 profile */ + int for_data; + int (*exit)(struct cdrom_device_info *); + int mrw_mode_page; +}; + +struct cdrom_device_ops { +/* routines */ + int (*open) (struct cdrom_device_info *, int); + void (*release) (struct cdrom_device_info *); + int (*drive_status) (struct cdrom_device_info *, int); + int (*media_changed) (struct cdrom_device_info *, int); + int (*tray_move) (struct cdrom_device_info *, int); + int (*lock_door) (struct cdrom_device_info *, int); + int (*select_speed) (struct cdrom_device_info *, int); + int (*select_disc) (struct cdrom_device_info *, int); + int (*get_last_session) (struct cdrom_device_info *, + struct cdrom_multisession *); + int (*get_mcn) (struct cdrom_device_info *, + struct cdrom_mcn *); + /* hard reset device */ + int (*reset) (struct cdrom_device_info *); + /* play stuff */ + int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *); + /* dev-specific */ + int (*dev_ioctl) (struct cdrom_device_info *, + unsigned int, unsigned long); +/* driver specifications */ + const int capability; /* capability flags */ + int n_minors; /* number of active minor devices */ + /* handle uniform packets for scsi type devices (scsi,atapi) */ + int (*generic_packet) (struct cdrom_device_info *, + struct packet_command *); +}; + +/* the general block_device operations structure: */ +extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, + struct file *fp); +extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp); +extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi, + struct inode *ip, unsigned int cmd, unsigned long arg); +extern int cdrom_media_changed(struct cdrom_device_info *); + +extern int register_cdrom(struct cdrom_device_info *cdi); +extern int unregister_cdrom(struct cdrom_device_info *cdi); + +typedef struct { + int data; + int audio; + int cdi; + int xa; + long error; +} tracktype; + +extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written); +extern int cdrom_number_of_slots(struct cdrom_device_info *cdi); +extern int cdrom_mode_select(struct cdrom_device_info *cdi, + struct packet_command *cgc); +extern int cdrom_mode_sense(struct cdrom_device_info *cdi, + struct packet_command *cgc, + int page_code, int page_control); +extern void init_cdrom_command(struct packet_command *cgc, + void *buffer, int len, int type); + +/* The SCSI spec says there could be 256 slots. */ +#define CDROM_MAX_SLOTS 256 + +struct cdrom_mechstat_header { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 fault : 1; + __u8 changer_state : 2; + __u8 curslot : 5; + __u8 mech_state : 3; + __u8 door_open : 1; + __u8 reserved1 : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curslot : 5; + __u8 changer_state : 2; + __u8 fault : 1; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 mech_state : 3; +#endif + __u8 curlba[3]; + __u8 nslots; + __u16 slot_tablelen; +}; + +struct cdrom_slot { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 disc_present : 1; + __u8 reserved1 : 6; + __u8 change : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 change : 1; + __u8 reserved1 : 6; + __u8 disc_present : 1; +#endif + __u8 reserved2[3]; +}; + +struct cdrom_changer_info { + struct cdrom_mechstat_header hdr; + struct cdrom_slot slots[CDROM_MAX_SLOTS]; +}; + +typedef enum { + mechtype_caddy = 0, + mechtype_tray = 1, + mechtype_popup = 2, + mechtype_individual_changer = 4, + mechtype_cartridge_changer = 5 +} mechtype_t; + +typedef struct { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 ps : 1; + __u8 reserved1 : 1; + __u8 page_code : 6; + __u8 page_length; + __u8 reserved2 : 1; + __u8 bufe : 1; + __u8 ls_v : 1; + __u8 test_write : 1; + __u8 write_type : 4; + __u8 multi_session : 2; /* or border, DVD */ + __u8 fp : 1; + __u8 copy : 1; + __u8 track_mode : 4; + __u8 reserved3 : 4; + __u8 data_block_type : 4; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 page_code : 6; + __u8 reserved1 : 1; + __u8 ps : 1; + __u8 page_length; + __u8 write_type : 4; + __u8 test_write : 1; + __u8 ls_v : 1; + __u8 bufe : 1; + __u8 reserved2 : 1; + __u8 track_mode : 4; + __u8 copy : 1; + __u8 fp : 1; + __u8 multi_session : 2; /* or border, DVD */ + __u8 data_block_type : 4; + __u8 reserved3 : 4; +#endif + __u8 link_size; + __u8 reserved4; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved5 : 2; + __u8 app_code : 6; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 app_code : 6; + __u8 reserved5 : 2; +#endif + __u8 session_format; + __u8 reserved6; + __u32 packet_size; + __u16 audio_pause; + __u8 mcn[16]; + __u8 isrc[16]; + __u8 subhdr0; + __u8 subhdr1; + __u8 subhdr2; + __u8 subhdr3; +} __attribute__((packed)) write_param_page; + +struct modesel_head +{ + __u8 reserved1; + __u8 medium; + __u8 reserved2; + __u8 block_desc_length; + __u8 density; + __u8 number_of_blocks_hi; + __u8 number_of_blocks_med; + __u8 number_of_blocks_lo; + __u8 reserved3; + __u8 block_length_hi; + __u8 block_length_med; + __u8 block_length_lo; +}; + +typedef struct { + __u16 report_key_length; + __u8 reserved1; + __u8 reserved2; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 type_code : 2; + __u8 vra : 3; + __u8 ucca : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ucca : 3; + __u8 vra : 3; + __u8 type_code : 2; +#endif + __u8 region_mask; + __u8 rpc_scheme; + __u8 reserved3; +} rpc_state_t; + +struct event_header { + __u16 data_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 nea : 1; + __u8 reserved1 : 4; + __u8 notification_class : 3; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 notification_class : 3; + __u8 reserved1 : 4; + __u8 nea : 1; +#endif + __u8 supp_event_class; +}; + +struct media_event_desc { +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 4; + __u8 media_event_code : 4; + __u8 reserved2 : 6; + __u8 media_present : 1; + __u8 door_open : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 media_event_code : 4; + __u8 reserved1 : 4; + __u8 door_open : 1; + __u8 media_present : 1; + __u8 reserved2 : 6; +#endif + __u8 start_slot; + __u8 end_slot; +}; + +extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); + +#endif /* End of kernel only stuff */ + +#endif /* _LINUX_CDROM_H */ diff --git a/ddverify/models/goblint/include/linux/compat.h b/ddverify/models/goblint/include/linux/compat.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/compiler.h b/ddverify/models/goblint/include/linux/compiler.h new file mode 100644 index 000000000..3b8f75ea3 --- /dev/null +++ b/ddverify/models/goblint/include/linux/compiler.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_COMPILER_H +#define __LINUX_COMPILER_H + +# define __user +# define __kernel +# define __safe +# define __force +# define __nocast +# define __iomem + +#ifndef __must_check +#define __must_check +#endif + +#define likely(x) x +#define unlikely(x) x + +void barrier(void); + +#endif diff --git a/ddverify/models/goblint/include/linux/completion.h b/ddverify/models/goblint/include/linux/completion.h new file mode 100644 index 000000000..011ec59af --- /dev/null +++ b/ddverify/models/goblint/include/linux/completion.h @@ -0,0 +1,18 @@ +#ifndef __LINUX_COMPLETION_H +#define __LINUX_COMPLETION_H + +/* + * (C) Copyright 2001 Linus Torvalds + * + * Atomic wait-for-completion handler data structures. + * See kernel/sched.c for details. + */ + +#include + +struct completion { + unsigned int done; + wait_queue_head_t wait; +}; + +#endif diff --git a/ddverify/models/goblint/include/linux/config.h b/ddverify/models/goblint/include/linux/config.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/console.h b/ddverify/models/goblint/include/linux/console.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/cpumask.h b/ddverify/models/goblint/include/linux/cpumask.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/ctype.h b/ddverify/models/goblint/include/linux/ctype.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/dcache.h b/ddverify/models/goblint/include/linux/dcache.h new file mode 100644 index 000000000..2813f54c1 --- /dev/null +++ b/ddverify/models/goblint/include/linux/dcache.h @@ -0,0 +1,9 @@ +#ifndef __LINUX_DCACHE_H +#define __LINUX_DCACHE_H + +struct dentry { + struct inode *d_inode; /* Where the name belongs to - NULL is + * negative */ +}; + +#endif /* __LINUX_DCACHE_H */ diff --git a/ddverify/models/goblint/include/linux/delay.h b/ddverify/models/goblint/include/linux/delay.h new file mode 100644 index 000000000..c3bb525bb --- /dev/null +++ b/ddverify/models/goblint/include/linux/delay.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_DELAY_H +#define _LINUX_DELAY_H + +extern unsigned long loops_per_jiffy; + +#include + + +#ifndef mdelay +#define mdelay(n) do {} while(0) +#endif + +#ifndef ndelay +#define ndelay(x) do {} while(0) +#endif + +// DDV: This function does not need a body! +void msleep(unsigned int msecs); +// DDV: This function does not need a body! +unsigned long msleep_interruptible(unsigned int msecs); + +#endif /* defined(_LINUX_DELAY_H) */ diff --git a/ddverify/models/goblint/include/linux/devfs_fs_kernel.h b/ddverify/models/goblint/include/linux/devfs_fs_kernel.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/device.h b/ddverify/models/goblint/include/linux/device.h new file mode 100644 index 000000000..920ff5519 --- /dev/null +++ b/ddverify/models/goblint/include/linux/device.h @@ -0,0 +1,112 @@ +/* + * device.h - generic, centralized driver model + * + * Copyright (c) 2001-2003 Patrick Mochel + * + * This file is released under the GPLv2 + * + * See Documentation/driver-model/ for more information. + */ + +#ifndef _DEVICE_H_ +#define _DEVICE_H_ + +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include + +struct device { + void *driver_data; /* data private to the driver */ + void (*release)(struct device * dev); +}; + +struct device_driver { + const char * name; +}; + + +struct class { + int someting; +}; + +struct class_device { + int something; +}; + +struct class_interface { + int something; +}; + +struct class_device_attribute { + struct attribute attr; + ssize_t (*show)(struct class_device *, char * buf); + ssize_t (*store)(struct class_device *, const char * buf, size_t count); +}; + +#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \ +struct class_device_attribute class_device_attr_##_name = \ + __ATTR(_name,_mode,_show,_store) + +extern struct class *class_create(struct module *owner, const char *name); +extern void class_destroy(struct class *cls); + +extern struct class_device *class_device_create(struct class *cls, + struct class_device *parent, + dev_t devt, + struct device *device, + const char *fmt, ...); +extern void class_device_destroy(struct class *cls, dev_t devt); + + +struct device_attribute { + struct attribute attr; + ssize_t (*show)(struct device *dev, struct device_attribute *attr, + char *buf); + ssize_t (*store)(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +}; + +#define DEVICE_ATTR(_name,_mode,_show,_store) \ +struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) + + +static inline void * dev_get_drvdata (struct device *dev) +{ + return dev->driver_data; +} + +static inline void dev_set_drvdata (struct device *dev, void *data) +{ + dev->driver_data = data; +} + +extern const char *dev_driver_string(struct device *dev); + + +#define dev_printk(level, dev, format, arg...) \ + printk("dev_printk") + +#ifdef DEBUG +#define dev_dbg(dev, format, arg...) \ + dev_printk(KERN_DEBUG , dev , format , ## arg) +#else +#define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) +#endif + +#define dev_err(dev, format, arg...) \ + dev_printk(KERN_ERR , dev , format , ## arg) +#define dev_info(dev, format, arg...) \ + dev_printk(KERN_INFO , dev , format , ## arg) +#define dev_warn(dev, format, arg...) \ + dev_printk(KERN_WARNING , dev , format , ## arg) +#define dev_notice(dev, format, arg...) \ + dev_printk(KERN_NOTICE , dev , format , ## arg) + +#endif /* _DEVICE_H_ */ diff --git a/ddverify/models/goblint/include/linux/dma-mapping.h b/ddverify/models/goblint/include/linux/dma-mapping.h new file mode 100644 index 000000000..9ea999ba9 --- /dev/null +++ b/ddverify/models/goblint/include/linux/dma-mapping.h @@ -0,0 +1,19 @@ +#ifndef _ASM_LINUX_DMA_MAPPING_H +#define _ASM_LINUX_DMA_MAPPING_H + +#include +#include + + +#define DMA_64BIT_MASK (unsigned long long int)0xffffffffffffffff +#define DMA_48BIT_MASK (unsigned long long int)0x0000ffffffffffff +#define DMA_40BIT_MASK (unsigned long long int)0x000000ffffffffff +#define DMA_39BIT_MASK (unsigned long long int)0x0000007fffffffff +#define DMA_32BIT_MASK (unsigned long long int)0x00000000ffffffff +#define DMA_31BIT_MASK (unsigned long long int)0x000000007fffffff +#define DMA_30BIT_MASK (unsigned long long int)0x000000003fffffff +#define DMA_29BIT_MASK (unsigned long long int)0x000000001fffffff +#define DMA_28BIT_MASK (unsigned long long int)0x000000000fffffff +#define DMA_24BIT_MASK (unsigned long long int)0x0000000000ffffff + +#endif diff --git a/ddverify/models/goblint/include/linux/elevator.h b/ddverify/models/goblint/include/linux/elevator.h new file mode 100644 index 000000000..f0e7f6f17 --- /dev/null +++ b/ddverify/models/goblint/include/linux/elevator.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_ELEVATOR_H +#define _LINUX_ELEVATOR_H + +struct request *elv_next_request(struct request_queue *q); + +#endif diff --git a/ddverify/models/goblint/include/linux/err.h b/ddverify/models/goblint/include/linux/err.h new file mode 100644 index 000000000..18c9cf814 --- /dev/null +++ b/ddverify/models/goblint/include/linux/err.h @@ -0,0 +1,27 @@ +#ifndef _LINUX_ERR_H +#define _LINUX_ERR_H + +#include + +#include + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) (x) >= (unsigned long)-MAX_ERRNO + +static inline void *ERR_PTR(long error) +{ + return (void *) error; +} + +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline long IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + +#endif /* _LINUX_ERR_H */ diff --git a/ddverify/models/goblint/include/linux/errno.h b/ddverify/models/goblint/include/linux/errno.h new file mode 100644 index 000000000..91762481a --- /dev/null +++ b/ddverify/models/goblint/include/linux/errno.h @@ -0,0 +1,25 @@ +#ifndef _LINUX_ERRNO_H +#define _LINUX_ERRNO_H + +#include + +/* Should never be seen by user programs */ +#define ERESTARTSYS 512 +#define ERESTARTNOINTR 513 +#define ERESTARTNOHAND 514 /* restart if no handler.. */ +#define ENOIOCTLCMD 515 /* No ioctl command */ +#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ + +/* Defined for the NFSv3 protocol */ +#define EBADHANDLE 521 /* Illegal NFS file handle */ +#define ENOTSYNC 522 /* Update synchronization mismatch */ +#define EBADCOOKIE 523 /* Cookie is stale */ +#define ENOTSUPP 524 /* Operation is not supported */ +#define ETOOSMALL 525 /* Buffer or request is too small */ +#define ESERVERFAULT 526 /* An untranslatable error occurred */ +#define EBADTYPE 527 /* Type not supported by server */ +#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ +#define EIOCBQUEUED 529 /* iocb queued, will get completion event */ +#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */ + +#endif diff --git a/ddverify/models/goblint/include/linux/fcntl.h b/ddverify/models/goblint/include/linux/fcntl.h new file mode 100644 index 000000000..9de3512e8 --- /dev/null +++ b/ddverify/models/goblint/include/linux/fcntl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_FCNTL_H +#define _LINUX_FCNTL_H + +#include + +#endif diff --git a/ddverify/models/goblint/include/linux/fd.h b/ddverify/models/goblint/include/linux/fd.h new file mode 100644 index 000000000..5b5a51a4e --- /dev/null +++ b/ddverify/models/goblint/include/linux/fd.h @@ -0,0 +1,373 @@ +#ifndef _LINUX_FD_H +#define _LINUX_FD_H + +#include +#include +/* New file layout: Now the ioctl definitions immediately follow the + * definitions of the structures that they use */ + +/* + * Geometry + */ +struct floppy_struct { + unsigned int size, /* nr of sectors total */ + sect, /* sectors per track */ + head, /* nr of heads */ + track, /* nr of tracks */ + stretch; /* !=0 means double track steps */ +#define FD_STRETCH 1 +#define FD_SWAPSIDES 2 +#define FD_ZEROBASED 4 + + unsigned char gap, /* gap1 size */ + + rate, /* data rate. |= 0x40 for perpendicular */ +#define FD_2M 0x4 +#define FD_SIZECODEMASK 0x38 +#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) +#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ + 512 : 128 << FD_SIZECODE(floppy) ) +#define FD_PERP 0x40 + + spec1, /* stepping rate, head unload time */ + fmt_gap; /* gap2 size */ + const char * name; /* used only for predefined formats */ +}; + + +/* commands needing write access have 0x40 set */ +/* commands needing super user access have 0x80 set */ + +#define FDCLRPRM _IO(2, 0x41) +/* clear user-defined parameters */ + +#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) +#define FDSETMEDIAPRM FDSETPRM +/* set user-defined parameters for current media */ + +#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) +#define FDGETPRM _IOR(2, 0x04, struct floppy_struct) +#define FDDEFMEDIAPRM FDDEFPRM +#define FDGETMEDIAPRM FDGETPRM +/* set/get disk parameters */ + + +#define FDMSGON _IO(2,0x45) +#define FDMSGOFF _IO(2,0x46) +/* issue/don't issue kernel messages on media type change */ + + +/* + * Formatting (obsolete) + */ +#define FD_FILL_BYTE 0xF6 /* format fill byte. */ + +struct format_descr { + unsigned int device,head,track; +}; + +#define FDFMTBEG _IO(2,0x47) +/* begin formatting a disk */ +#define FDFMTTRK _IOW(2,0x48, struct format_descr) +/* format the specified track */ +#define FDFMTEND _IO(2,0x49) +/* end formatting a disk */ + + +/* + * Error thresholds + */ +struct floppy_max_errors { + unsigned int + abort, /* number of errors to be reached before aborting */ + read_track, /* maximal number of errors permitted to read an + * entire track at once */ + reset, /* maximal number of errors before a reset is tried */ + recal, /* maximal number of errors before a recalibrate is + * tried */ + + /* + * Threshold for reporting FDC errors to the console. + * Setting this to zero may flood your screen when using + * ultra cheap floppies ;-) + */ + reporting; + +}; + +#define FDSETEMSGTRESH _IO(2,0x4a) +/* set fdc error reporting threshold */ + +#define FDFLUSH _IO(2,0x4b) +/* flush buffers for media; either for verifying media, or for + * handling a media change without closing the file descriptor */ + +#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors) +#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors) +/* set/get abortion and read_track threshold. See also floppy_drive_params + * structure */ + + +typedef char floppy_drive_name[16]; +#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name) +/* get drive type: 5 1/4 or 3 1/2 */ + + +/* + * Drive parameters (user modifiable) + */ +struct floppy_drive_params { + signed char cmos; /* CMOS type */ + + /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms + * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). + */ + unsigned long max_dtr; /* Step rate, usec */ + unsigned long hlt; /* Head load/settle time, msec */ + unsigned long hut; /* Head unload time (remnant of + * 8" drives) */ + unsigned long srt; /* Step rate, usec */ + + unsigned long spinup; /* time needed for spinup (expressed + * in jiffies) */ + unsigned long spindown; /* timeout needed for spindown */ + unsigned char spindown_offset; /* decides in which position the disk + * will stop */ + unsigned char select_delay; /* delay to wait after select */ + unsigned char rps; /* rotations per second */ + unsigned char tracks; /* maximum number of tracks */ + unsigned long timeout; /* timeout for interrupt requests */ + + unsigned char interleave_sect; /* if there are more sectors, use + * interleave */ + + struct floppy_max_errors max_errors; + + char flags; /* various flags, including ftd_msg */ +/* + * Announce successful media type detection and media information loss after + * disk changes. + * Also used to enable/disable printing of overrun warnings. + */ + +#define FTD_MSG 0x10 +#define FD_BROKEN_DCL 0x20 +#define FD_DEBUG 0x02 +#define FD_SILENT_DCL_CLEAR 0x4 +#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware + considerations */ + + char read_track; /* use readtrack during probing? */ + +/* + * Auto-detection. Each drive type has eight formats which are + * used in succession to try to read the disk. If the FDC cannot lock onto + * the disk, the next format is tried. This uses the variable 'probing'. + */ + short autodetect[8]; /* autodetected formats */ + + int checkfreq; /* how often should the drive be checked for disk + * changes */ + int native_format; /* native format of this drive */ +}; + +enum { + FD_NEED_TWADDLE_BIT, /* more magic */ + FD_VERIFY_BIT, /* inquire for write protection */ + FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet + * to clear media change status */ + FD_UNUSED_BIT, + FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ + FD_DISK_WRITABLE_BIT /* disk is writable */ +}; + +#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params) +#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params) +/* set/get drive parameters */ + + +/* + * Current drive state (not directly modifiable by user, readonly) + */ +struct floppy_drive_struct { + unsigned long flags; +/* values for these flags */ +#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT) +#define FD_VERIFY (1 << FD_VERIFY_BIT) +#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT) +#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT) +#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT) + + unsigned long spinup_date; + unsigned long select_date; + unsigned long first_read_date; + short probed_format; + short track; /* current track */ + short maxblock; /* id of highest block read */ + short maxtrack; /* id of highest half track read */ + int generation; /* how many diskchanges? */ + +/* + * (User-provided) media information is _not_ discarded after a media change + * if the corresponding keep_data flag is non-zero. Positive values are + * decremented after each probe. + */ + int keep_data; + + /* Prevent "aliased" accesses. */ + int fd_ref; + int fd_device; + unsigned long last_checked; /* when was the drive last checked for a disk + * change? */ + + char *dmabuf; + int bufblocks; +}; + +#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct) +#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct) +/* get drive state: GET returns the cached state, POLL polls for new state */ + + +/* + * reset FDC + */ +enum reset_mode { + FD_RESET_IF_NEEDED, /* reset only if the reset flags is set */ + FD_RESET_IF_RAWCMD, /* obsolete */ + FD_RESET_ALWAYS /* reset always */ +}; +#define FDRESET _IO(2, 0x54) + + +/* + * FDC state + */ +struct floppy_fdc_state { + int spec1; /* spec1 value last used */ + int spec2; /* spec2 value last used */ + int dtr; + unsigned char version; /* FDC version code */ + unsigned char dor; + unsigned long address; /* io address */ + unsigned int rawcmd:2; + unsigned int reset:1; + unsigned int need_configure:1; + unsigned int perp_mode:2; + unsigned int has_fifo:1; + unsigned int driver_version; /* version code for floppy driver */ +#define FD_DRIVER_VERSION 0x100 +/* user programs using the floppy API should use floppy_fdc_state to + * get the version number of the floppy driver that they are running + * on. If this version number is bigger than the one compiled into the + * user program (the FD_DRIVER_VERSION define), it should be prepared + * to bigger structures + */ + + unsigned char track[4]; + /* Position of the heads of the 4 units attached to this FDC, + * as stored on the FDC. In the future, the position as stored + * on the FDC might not agree with the actual physical + * position of these drive heads. By allowing such + * disagreement, it will be possible to reset the FDC without + * incurring the expensive cost of repositioning all heads. + * Right now, these positions are hard wired to 0. */ + +}; + +#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state) + + +/* + * Asynchronous Write error tracking + */ +struct floppy_write_errors { + /* Write error logging. + * + * These fields can be cleared with the FDWERRORCLR ioctl. + * Only writes that were attempted but failed due to a physical media + * error are logged. write(2) calls that fail and return an error code + * to the user process are not counted. + */ + + unsigned int write_errors; /* number of physical write errors + * encountered */ + + /* position of first and last write errors */ + unsigned long first_error_sector; + int first_error_generation; + unsigned long last_error_sector; + int last_error_generation; + + unsigned int badness; /* highest retry count for a read or write + * operation */ +}; + +#define FDWERRORCLR _IO(2, 0x56) +/* clear write error and badness information */ +#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors) +/* get write error and badness information */ + + +/* + * Raw commands + */ +/* new interface flag: now we can do them in batches */ +#define FDHAVEBATCHEDRAWCMD + +struct floppy_raw_cmd { + unsigned int flags; +#define FD_RAW_READ 1 +#define FD_RAW_WRITE 2 +#define FD_RAW_NO_MOTOR 4 +#define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */ +#define FD_RAW_INTR 8 /* wait for an interrupt */ +#define FD_RAW_SPIN 0x10 /* spin up the disk for this command */ +#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command + * completion */ +#define FD_RAW_NEED_DISK 0x40 /* this command needs a disk to be present */ +#define FD_RAW_NEED_SEEK 0x80 /* this command uses an implied seek (soft) */ + +/* more "in" flags */ +#define FD_RAW_MORE 0x100 /* more records follow */ +#define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */ +#define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */ +#define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure + * detection too */ + +/* more "out" flags */ +#define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */ +#define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */ + + void __user *data; + char *kernel_data; /* location of data buffer in the kernel */ + struct floppy_raw_cmd *next; /* used for chaining of raw cmd's + * within the kernel */ + long length; /* in: length of dma transfer. out: remaining bytes */ + long phys_length; /* physical length, if different from dma length */ + int buffer_length; /* length of allocated buffer */ + + unsigned char rate; + unsigned char cmd_count; + unsigned char cmd[16]; + unsigned char reply_count; + unsigned char reply[16]; + int track; + int resultcode; + + int reserved1; + int reserved2; +}; + +#define FDRAWCMD _IO(2, 0x58) +/* send a raw command to the fdc. Structure size not included, because of + * batches */ + +#define FDTWADDLE _IO(2, 0x59) +/* flicker motor-on bit before reading a sector. Experimental */ + + +#define FDEJECT _IO(2, 0x5a) +/* eject the disk */ + +#endif diff --git a/ddverify/models/goblint/include/linux/fdreg.h b/ddverify/models/goblint/include/linux/fdreg.h new file mode 100644 index 000000000..c2eeb63b7 --- /dev/null +++ b/ddverify/models/goblint/include/linux/fdreg.h @@ -0,0 +1,137 @@ +#ifndef _LINUX_FDREG_H +#define _LINUX_FDREG_H +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ + +#ifdef FDPATCHES +#define FD_IOPORT fdc_state[fdc].address +#else +/* It would be a lot saner just to force fdc_state[fdc].address to always + be set ! FIXME */ +#define FD_IOPORT 0x3f0 +#endif + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS (4 + FD_IOPORT ) +#define FD_DATA (5 + FD_IOPORT ) + +/* Digital Output Register */ +#define FD_DOR (2 + FD_IOPORT ) + +/* Digital Input Register (read) */ +#define FD_DIR (7 + FD_IOPORT ) + +/* Diskette Control Register (write)*/ +#define FD_DCR (7 + FD_IOPORT ) + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment check error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Address Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_DS 0x08 /* drive is double-sided */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_RY 0x20 /* drive is ready */ +#define ST3_WP 0x40 /* Write Protect */ +#define ST3_FT 0x80 /* Drive Fault */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ +#define FD_FORMAT 0x4D /* format one track */ +#define FD_VERSION 0x10 /* get version code */ +#define FD_CONFIGURE 0x13 /* configure FIFO operation */ +#define FD_PERPENDICULAR 0x12 /* perpendicular r/w mode */ +#define FD_GETSTATUS 0x04 /* read ST3 */ +#define FD_DUMPREGS 0x0E /* dump the contents of the fdc regs */ +#define FD_READID 0xEA /* prints the header of a sector */ +#define FD_UNLOCK 0x14 /* Fifo config unlock */ +#define FD_LOCK 0x94 /* Fifo config lock */ +#define FD_RSEEK_OUT 0x8f /* seek out (i.e. to lower tracks) */ +#define FD_RSEEK_IN 0xcf /* seek in (i.e. to higher tracks) */ + +/* the following commands are new in the 82078. They are not used in the + * floppy driver, except the first three. These commands may be useful for apps + * which use the FDRAWCMD interface. For doc, get the 82078 spec sheets at + * http://www-techdoc.intel.com/docs/periph/fd_contr/datasheets/ */ + +#define FD_PARTID 0x18 /* part id ("extended" version cmd) */ +#define FD_SAVE 0x2e /* save fdc regs for later restore */ +#define FD_DRIVESPEC 0x8e /* drive specification: Access to the + * 2 Mbps data transfer rate for tape + * drives */ + +#define FD_RESTORE 0x4e /* later restore */ +#define FD_POWERDOWN 0x27 /* configure FDC's powersave features */ +#define FD_FORMAT_N_WRITE 0xef /* format and write in one go. */ +#define FD_OPTION 0x33 /* ISO format (which is a clean way to + * pack more sectors on a track) */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +/* FDC version return types */ +#define FDC_NONE 0x00 +#define FDC_UNKNOWN 0x10 /* DO NOT USE THIS TYPE EXCEPT IF IDENTIFICATION + FAILS EARLY */ +#define FDC_8272A 0x20 /* Intel 8272a, NEC 765 */ +#define FDC_765ED 0x30 /* Non-Intel 1MB-compatible FDC, can't detect */ +#define FDC_82072 0x40 /* Intel 82072; 8272a + FIFO + DUMPREGS */ +#define FDC_82072A 0x45 /* 82072A (on Sparcs) */ +#define FDC_82077_ORIG 0x51 /* Original version of 82077AA, sans LOCK */ +#define FDC_82077 0x52 /* 82077AA-1 */ +#define FDC_82078_UNKN 0x5f /* Unknown 82078 variant */ +#define FDC_82078 0x60 /* 44pin 82078 or 64pin 82078SL */ +#define FDC_82078_1 0x61 /* 82078-1 (2Mbps fdc) */ +#define FDC_S82078B 0x62 /* S82078B (first seen on Adaptec AVA-2825 VLB + * SCSI/EIDE/Floppy controller) */ +#define FDC_87306 0x63 /* National Semiconductor PC 87306 */ + +/* + * Beware: the fdc type list is roughly sorted by increasing features. + * Presence of features is tested by comparing the FDC version id with the + * "oldest" version that has the needed feature. + * If during FDC detection, an obscure test fails late in the sequence, don't + * assign FDC_UNKNOWN. Else the FDC will be treated as a dumb 8272a, or worse. + * This is especially true if the tests are unneeded. + */ + +#define FD_RESET_DELAY 20 +#endif diff --git a/ddverify/models/goblint/include/linux/file.h b/ddverify/models/goblint/include/linux/file.h new file mode 100644 index 000000000..df49c59d6 --- /dev/null +++ b/ddverify/models/goblint/include/linux/file.h @@ -0,0 +1,14 @@ +#ifndef __LINUX_FILE_H +#define __LINUX_FILE_H + +#include +#include +#include +#include +//#include +#include + +extern void fput(struct file *); +extern struct file * fget(unsigned int fd); + +#endif /* __LINUX_FILE_H */ diff --git a/ddverify/models/goblint/include/linux/firmware.h b/ddverify/models/goblint/include/linux/firmware.h new file mode 100644 index 000000000..33d8f2087 --- /dev/null +++ b/ddverify/models/goblint/include/linux/firmware.h @@ -0,0 +1,22 @@ +#ifndef _LINUX_FIRMWARE_H +#define _LINUX_FIRMWARE_H +#include +#include +#define FIRMWARE_NAME_MAX 30 +#define FW_ACTION_NOHOTPLUG 0 +#define FW_ACTION_HOTPLUG 1 + +struct firmware { + size_t size; + u8 *data; +}; +struct device; +int request_firmware(const struct firmware **fw, const char *name, + struct device *device); +int request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, void *context, + void (*cont)(const struct firmware *fw, void *context)); + +void release_firmware(const struct firmware *fw); +#endif diff --git a/ddverify/models/goblint/include/linux/fs.h b/ddverify/models/goblint/include/linux/fs.h new file mode 100644 index 000000000..7314a5b99 --- /dev/null +++ b/ddverify/models/goblint/include/linux/fs.h @@ -0,0 +1,238 @@ +#ifndef _LINUX_FS_H +#define _LINUX_FS_H + +/* + * This file has definitions for some important file table + * structures etc. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#undef NR_OPEN +#define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */ +#define INR_OPEN 1024 /* Initial setting for nfile rlimits */ + +#define BLOCK_SIZE_BITS 10 +#define BLOCK_SIZE (1<bi_rw & 1) + + +int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); +int register_chrdev_region(dev_t, unsigned, const char *); +void unregister_chrdev_region(dev_t, unsigned); + +int register_chrdev(unsigned int, const char *, struct file_operations *); +int unregister_chrdev(unsigned int, const char *); + +int chrdev_open(struct inode *, struct file *); +void chrdev_show(struct seq_file *,off_t); + +#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ + +int register_blkdev(unsigned int, const char *); +int unregister_blkdev(unsigned int, const char *); + + +void kill_fasync(struct fasync_struct **, int, int); + +static inline unsigned iminor(struct inode *inode) +{ + return MINOR(inode->i_rdev); +} + +static inline unsigned imajor(struct inode *inode) +{ + return MAJOR(inode->i_rdev); +} + +loff_t no_llseek(struct file *file, loff_t offset, int origin); + + +int check_disk_change(struct block_device *); + +/* + * return READ, READA, or WRITE + */ +#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK)) + +int nonseekable_open(struct inode * inode, struct file * filp); + +loff_t i_size_read(struct inode *inode); + +int set_blocksize(struct block_device *, int); +#endif diff --git a/ddverify/models/goblint/include/linux/genhd.h b/ddverify/models/goblint/include/linux/genhd.h new file mode 100644 index 000000000..46dd433cb --- /dev/null +++ b/ddverify/models/goblint/include/linux/genhd.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_GENHD_H +#define _LINUX_GENHD_H + +#include +#include +#include +//#include +#include +#include + +#define GENHD_FL_REMOVABLE 1 +#define GENHD_FL_DRIVERFS 2 +#define GENHD_FL_CD 8 +#define GENHD_FL_UP 16 +#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 + +struct gendisk { + int major; /* major number of driver */ + int first_minor; + int minors; /* maximum number of minors, =1 for + * disks that can't be partitioned. */ + char disk_name[32]; /* name of major driver */ + struct block_device_operations *fops; + struct request_queue *queue; + void *private_data; + + int flags; + struct device *driverfs_dev; + char devfs_name[64]; /* devfs crap */ +}; + +// DDV: defined in file linux/block/genhd.c +void add_disk(struct gendisk *disk); +// DDV: defined in file linux/block/genhd.c +void del_gendisk(struct gendisk *gp); +// DDV: defined in file linux/block/genhd.c +struct gendisk *alloc_disk(int minors); +// DDV: TODO +void put_disk(struct gendisk *disk); +// DDV: TODO +extern struct kobject *get_disk(struct gendisk *disk); + +// DDV: TODO +void set_capacity(struct gendisk *disk, sector_t size); + +// DDV: TODO +void add_disk_randomness(struct gendisk *disk); +#endif diff --git a/ddverify/models/goblint/include/linux/gfp.h b/ddverify/models/goblint/include/linux/gfp.h new file mode 100644 index 000000000..d01d2dd5e --- /dev/null +++ b/ddverify/models/goblint/include/linux/gfp.h @@ -0,0 +1,74 @@ +#ifndef __LINUX_GFP_H +#define __LINUX_GFP_H + +#include +#include +//#include +#include + +/* + * Action modifiers - doesn't change the zoning + * + * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt + * _might_ fail. This depends upon the particular VM implementation. + * + * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller + * cannot handle allocation failures. + * + * __GFP_NORETRY: The VM implementation must not retry indefinitely. + */ +#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */ +#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */ +#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */ +#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ +#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ +#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ +#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */ +#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */ +#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */ +#define __GFP_NO_GROW ((__force gfp_t)0x2000u)/* Slab internal usage */ +#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ +#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ +#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ +#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ + +#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ +#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) + +/* if you forget to add the bitmask here kernel will crash, period */ +#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ + __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ + __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ + __GFP_NOMEMALLOC|__GFP_HARDWALL) + +/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ +#define GFP_ATOMIC (__GFP_HIGH) +#define GFP_NOIO (__GFP_WAIT) +#define GFP_NOFS (__GFP_WAIT | __GFP_IO) +#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) +#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL) +#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \ + __GFP_HIGHMEM) + + +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long __get_free_page(gfp_t gfp_mask); +// DDV: Body defined in linux/mm/page_alloc.c +unsigned long get_zeroed_page(gfp_t gfp_mask); + +// DDV: No body required +void free_pages(unsigned long addr, unsigned int order); +// DDV: No body required +void free_page(unsigned long addr); + +// DDV: Body defined in linux/mm/page_alloc.c +static struct page *alloc_pages_node(int nid, gfp_t gfp_mask, + unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_pages(gfp_t gfp_mask, unsigned int order); +// DDV: Body defined in linux/mm/page_alloc.c +struct page * alloc_page(gfp_t gfp_mask); + +#endif diff --git a/ddverify/models/goblint/include/linux/hdreg.h b/ddverify/models/goblint/include/linux/hdreg.h new file mode 100644 index 000000000..a57304a20 --- /dev/null +++ b/ddverify/models/goblint/include/linux/hdreg.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_HDREG_H +#define _LINUX_HDREG_H + +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + unsigned short cylinders; + unsigned long start; +}; + +#define HDIO_GETGEO 0x0301 /* get device geometry */ + +#endif /* _LINUX_HDREG_H */ diff --git a/ddverify/models/goblint/include/linux/highmem.h b/ddverify/models/goblint/include/linux/highmem.h new file mode 100644 index 000000000..9ec708efa --- /dev/null +++ b/ddverify/models/goblint/include/linux/highmem.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_HIGHMEM_H +#define _LINUX_HIGHMEM_H + +#include +#include + +#include + +#endif /* _LINUX_HIGHMEM_H */ diff --git a/ddverify/models/goblint/include/linux/if.h b/ddverify/models/goblint/include/linux/if.h new file mode 100644 index 000000000..544dc09d7 --- /dev/null +++ b/ddverify/models/goblint/include/linux/if.h @@ -0,0 +1,8 @@ +#ifndef _LINUX_IF_H +#define _LINUX_IF_H + +#include /* for "__kernel_caddr_t" et al */ +#include /* for "struct sockaddr" et al */ +#include /* for "__user" et al */ + +#endif /* _LINUX_IF_H */ diff --git a/ddverify/models/goblint/include/linux/in.h b/ddverify/models/goblint/include/linux/in.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/init.h b/ddverify/models/goblint/include/linux/init.h new file mode 100644 index 000000000..ee78bf673 --- /dev/null +++ b/ddverify/models/goblint/include/linux/init.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_INIT_H +#define _LINUX_INIT_H + +#include +#include + +#define module_init(_function) int (* _ddv_tmp_init)(void) = _function +#define module_exit(_function) void (* _ddv_tmp_exit)(void) = _function + +#define __init +#define __initdata +#define __exitdata +#define __exit + +#define __devinit +#define __devinitdata +#define __devexit +#define __devexitdata +#define __devexit_p(x) x + +#define __setup(str, func) int (* _ddv_setup_function)(char *) = func + +#endif diff --git a/ddverify/models/goblint/include/linux/interrupt.h b/ddverify/models/goblint/include/linux/interrupt.h new file mode 100644 index 000000000..68c9dc998 --- /dev/null +++ b/ddverify/models/goblint/include/linux/interrupt.h @@ -0,0 +1,96 @@ +/* interrupt.h */ +#ifndef _LINUX_INTERRUPT_H +#define _LINUX_INTERRUPT_H + +#include +#include +#include +#include + +/* + * These flags used only by the kernel as part of the + * irq handling routines. + * + * IRQF_DISABLED - keep irqs disabled when calling the action handler + * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator + * IRQF_SHARED - allow sharing the irq among several devices + * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur + * IRQF_TIMER - Flag to mark this interrupt as timer interrupt + */ +#define IRQF_DISABLED 0x00000020 +#define IRQF_SAMPLE_RANDOM 0x00000040 +#define IRQF_SHARED 0x00000080 +#define IRQF_PROBE_SHARED 0x00000100 +#define IRQF_TIMER 0x00000200 +#define IRQF_PERCPU 0x00000400 + + +typedef int irqreturn_t; + +#define IRQ_NONE (0) +#define IRQ_HANDLED (1) +#define IRQ_RETVAL(x) ((x) != 0) + +struct tasklet_struct +{ + atomic_t count; + void (*func)(unsigned long); + unsigned long data; + + int init; +}; + +#define DECLARE_TASKLET(name, func, data) \ + struct tasklet_struct name = { 0, func, data, 1 } + +#define DECLARE_TASKLET_DISABLED(name, func, data) \ + struct tasklet_struct name = { 1, func, data, 1 } + +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_schedule(struct tasklet_struct *t); + +static inline void tasklet_disable(struct tasklet_struct *t) +{ + t->count++; +} + +static inline void tasklet_enable(struct tasklet_struct *t) +{ + t->count++; +} + +// DDV: TODO +void tasklet_kill(struct tasklet_struct *t); +// DDV: Body is defined in linux/kernel/softirq.c +void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data); + +#ifdef OLD_INTERRUPT_HANDLER +typedef irqreturn_t (*irq_handler_t)(int, void *); +#else +typedef irqreturn_t (*irq_handler_t)(int, void *, struct pt_regs *); +#endif + +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +int request_irq(unsigned int, irq_handler_t handler, + unsigned long, const char *, void *); +// DDV: Body for this function is defined in linux/kernel/irq/manage.c +void free_irq(unsigned int, void *); + +// DDV: TODO +unsigned long probe_irq_on(void); +// DDV: TODO +int probe_irq_off(unsigned long); +// DDV: TODO +unsigned int probe_irq_mask(unsigned long); + +// DDV: TODO +void cli(void); +// DDV: TODO +void sti(void); +// DDV: TODO +void save_flags(unsigned long x); +// DDV: TODO +void restore_flags(unsigned long x); + +#endif diff --git a/ddverify/models/goblint/include/linux/ioctl.h b/ddverify/models/goblint/include/linux/ioctl.h new file mode 100644 index 000000000..6f08f2f94 --- /dev/null +++ b/ddverify/models/goblint/include/linux/ioctl.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_IOCTL_H +#define _LINUX_IOCTL_H + +#include + +#endif diff --git a/ddverify/models/goblint/include/linux/ioport.h b/ddverify/models/goblint/include/linux/ioport.h new file mode 100644 index 000000000..7df1143c6 --- /dev/null +++ b/ddverify/models/goblint/include/linux/ioport.h @@ -0,0 +1,102 @@ +/* + * ioport.h Definitions of routines for detecting, reserving and + * allocating system resources. + * + * Authors: Linus Torvalds + */ + +#ifndef _LINUX_IOPORT_H +#define _LINUX_IOPORT_H + +#include + + +/* + * Resources are tree-like, allowing + * nesting etc.. + */ +struct resource { + const char *name; + unsigned long start, end; + unsigned long flags; +// struct resource *parent, *sibling, *child; +}; + + +/* + * IO resources have these defined flags. + */ +#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ + +#define IORESOURCE_IO 0x00000100 /* Resource type */ +#define IORESOURCE_MEM 0x00000200 +#define IORESOURCE_IRQ 0x00000400 +#define IORESOURCE_DMA 0x00000800 + +#define IORESOURCE_PREFETCH 0x00001000 /* No side effects */ +#define IORESOURCE_READONLY 0x00002000 +#define IORESOURCE_CACHEABLE 0x00004000 +#define IORESOURCE_RANGELENGTH 0x00008000 +#define IORESOURCE_SHADOWABLE 0x00010000 +#define IORESOURCE_BUS_HAS_VGA 0x00080000 + +#define IORESOURCE_DISABLED 0x10000000 +#define IORESOURCE_UNSET 0x20000000 +#define IORESOURCE_AUTO 0x40000000 +#define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ + +/* ISA PnP IRQ specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_IRQ_HIGHEDGE (1<<0) +#define IORESOURCE_IRQ_LOWEDGE (1<<1) +#define IORESOURCE_IRQ_HIGHLEVEL (1<<2) +#define IORESOURCE_IRQ_LOWLEVEL (1<<3) +#define IORESOURCE_IRQ_SHAREABLE (1<<4) + +/* ISA PnP DMA specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_DMA_TYPE_MASK (3<<0) +#define IORESOURCE_DMA_8BIT (0<<0) +#define IORESOURCE_DMA_8AND16BIT (1<<0) +#define IORESOURCE_DMA_16BIT (2<<0) + +#define IORESOURCE_DMA_MASTER (1<<2) +#define IORESOURCE_DMA_BYTE (1<<3) +#define IORESOURCE_DMA_WORD (1<<4) + +#define IORESOURCE_DMA_SPEED_MASK (3<<6) +#define IORESOURCE_DMA_COMPATIBLE (0<<6) +#define IORESOURCE_DMA_TYPEA (1<<6) +#define IORESOURCE_DMA_TYPEB (2<<6) +#define IORESOURCE_DMA_TYPEF (3<<6) + +/* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */ +#define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */ +#define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */ +#define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */ +#define IORESOURCE_MEM_TYPE_MASK (3<<3) +#define IORESOURCE_MEM_8BIT (0<<3) +#define IORESOURCE_MEM_16BIT (1<<3) +#define IORESOURCE_MEM_8AND16BIT (2<<3) +#define IORESOURCE_MEM_32BIT (3<<3) +#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ +#define IORESOURCE_MEM_EXPANSIONROM (1<<6) + +/* PCI ROM control bits (IORESOURCE_BITS) */ +#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ +#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */ +#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */ + + +// DDV: Body defined in linux/kernel/resource.c +struct resource *request_region(unsigned long, unsigned long, const char *); +// DDV: Body defined in linux/kernel/resource.c +void release_region(unsigned long, unsigned long); + + +// DDV: TODO +struct resource *request_mem_region(unsigned long start, unsigned long len, const char *name); +// DDV: TODO +void release_mem_region(unsigned long start, unsigned long len); + + + +#endif /* _LINUX_IOPORT_H */ diff --git a/ddverify/models/goblint/include/linux/jiffies.h b/ddverify/models/goblint/include/linux/jiffies.h new file mode 100644 index 000000000..2d4a183ca --- /dev/null +++ b/ddverify/models/goblint/include/linux/jiffies.h @@ -0,0 +1,84 @@ +#ifndef _LINUX_JIFFIES_H +#define _LINUX_JIFFIES_H + +#include +#include + +unsigned long jiffies; + +/* + * These inlines deal with timer wrapping correctly. You are + * strongly encouraged to use them + * 1. Because people otherwise forget + * 2. Because if the timer wrap changes in future you won't have to + * alter your driver code. + * + * time_after(a,b) returns true if the time a is after time b. + * + * Do this with "<0" and ">=0" to only test the sign of the result. A + * good compiler would generate better code (and a really good compiler + * wouldn't care). Gcc is currently neither. + */ +#define time_after(a,b) ((long)(b) - (long)(a) < 0) +#define time_before(a,b) time_after(b,a) +#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_before_eq(a,b) time_after_eq(b,a) + + +#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) + +/* + * Convert jiffies to milliseconds and back. + * + * Avoid unnecessary multiplications/divisions in the + * two most common HZ cases: + */ +static inline unsigned int jiffies_to_msecs(const unsigned long j) +{ +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (MSEC_PER_SEC / HZ) * j; +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); +#else + return (j * MSEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned int jiffies_to_usecs(const unsigned long j) +{ +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (USEC_PER_SEC / HZ) * j; +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); +#else + return (j * USEC_PER_SEC) / HZ; +#endif +} + +static inline unsigned long msecs_to_jiffies(const unsigned int m) +{ + if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return m * (HZ / MSEC_PER_SEC); +#else + return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; +#endif +} + +static inline unsigned long usecs_to_jiffies(const unsigned int u) +{ + if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; +#if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) + return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ); +#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) + return u * (HZ / USEC_PER_SEC); +#else + return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC; +#endif +} + +#endif diff --git a/ddverify/models/goblint/include/linux/kdb_kern.h b/ddverify/models/goblint/include/linux/kdb_kern.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/kdev_t.h b/ddverify/models/goblint/include/linux/kdev_t.h new file mode 100644 index 000000000..647632b51 --- /dev/null +++ b/ddverify/models/goblint/include/linux/kdev_t.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_KDEV_T_H +#define _LINUX_KDEV_T_H + +#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK)) +#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi)) + +#endif diff --git a/ddverify/models/goblint/include/linux/kernel.h b/ddverify/models/goblint/include/linux/kernel.h new file mode 100644 index 000000000..a228a8a21 --- /dev/null +++ b/ddverify/models/goblint/include/linux/kernel.h @@ -0,0 +1,115 @@ +#ifndef _LINUX_KERNEL_H +#define _LINUX_KERNEL_H + +/* + * 'kernel.h' contains some often-used function prototypes etc + */ + +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + +#define KERN_EMERG "<0>" /* system is unusable */ +#define KERN_ALERT "<1>" /* action must be taken immediately */ +#define KERN_CRIT "<2>" /* critical conditions */ +#define KERN_ERR "<3>" /* error conditions */ +#define KERN_WARNING "<4>" /* warning conditions */ +#define KERN_NOTICE "<5>" /* normal but significant condition */ +#define KERN_INFO "<6>" /* informational */ +#define KERN_DEBUG "<7>" /* debug-level messages */ + +unsigned long simple_strtoul(const char *,char **,unsigned int); +long simple_strtol(const char *,char **,unsigned int); +unsigned long long simple_strtoull(const char *,char **,unsigned int); +long long simple_strtoll(const char *,char **,unsigned int); + +int printk(const char * fmt, ...); +int sprintf(char * buf, const char * fmt, ...); +int snprintf(char * buf, size_t size, const char * fmt, ...); + +extern int cond_resched(void); + +extern int get_option(char **str, int *pint); +extern char *get_options(const char *str, int nints, int *ints); + +/* Values used for system_state */ +extern enum system_states { + SYSTEM_BOOTING, + SYSTEM_RUNNING, + SYSTEM_HALT, + SYSTEM_POWER_OFF, + SYSTEM_RESTART, + SYSTEM_SUSPEND_DISK, +} system_state; + +#define TAINT_PROPRIETARY_MODULE (1<<0) +#define TAINT_FORCED_MODULE (1<<1) +#define TAINT_UNSAFE_SMP (1<<2) +#define TAINT_FORCED_RMMOD (1<<3) +#define TAINT_MACHINE_CHECK (1<<4) +#define TAINT_BAD_PAGE (1<<5) + +extern void dump_stack(void); + +/* + * min()/max() macros that also do + * strict type-checking.. See the + * "unnecessary" pointer comparison. + */ +#define min(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + +#define max(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +/* + * ..and if you can't take the strict + * types, you can specify one yourself. + * + * Or not use min/max at all, of course. + */ +#define min_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) +#define max_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) + +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + +#define pr_debug(fmt,arg...) \ + do { } while (0) + +#define BUILD_BUG_ON(condition) \ + do { } while (0) + +#define BUILD_BUG_ON_ZERO(condition) \ + do { } while (0) + + +/* Trap pasters of __FUNCTION__ at compile-time */ +#define __FUNCTION__ (__func__) + +#endif diff --git a/ddverify/models/goblint/include/linux/kobject.h b/ddverify/models/goblint/include/linux/kobject.h new file mode 100644 index 000000000..4c1ba3fd0 --- /dev/null +++ b/ddverify/models/goblint/include/linux/kobject.h @@ -0,0 +1,34 @@ +/* + * kobject.h - generic kernel object infrastructure. + * + * Copyright (c) 2002-2003 Patrick Mochel + * Copyright (c) 2002-2003 Open Source Development Labs + * + * This file is released under the GPLv2. + * + * + * Please read Documentation/kobject.txt before using the kobject + * interface, ESPECIALLY the parts about reference counts and object + * destructors. + */ + +#ifndef _KOBJECT_H_ +#define _KOBJECT_H_ + + +#include +#include +#include +#include +#include +//#include +//#include +#include +#include +#include + +struct kobject { + int something; +}; + +#endif /* _KOBJECT_H_ */ diff --git a/ddverify/models/goblint/include/linux/kthread.h b/ddverify/models/goblint/include/linux/kthread.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/list.h b/ddverify/models/goblint/include/linux/list.h new file mode 100644 index 000000000..0132dfc43 --- /dev/null +++ b/ddverify/models/goblint/include/linux/list.h @@ -0,0 +1,108 @@ +#ifndef _LINUX_LIST_H +#define _LINUX_LIST_H + +//#include +//#include +//#include +#include + +struct list_head { + struct list_head *next, *prev; +}; + +#define LIST_HEAD_INIT(name) { &(name), &(name) } + + +#define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + +static inline void INIT_LIST_HEAD(struct list_head *list) +{ + list->next = list; + list->prev = list; +} + +/** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop cursor. + * @head: the head for your list. + */ +#define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ +static inline void list_del_init(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); +} + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +#endif + + diff --git a/ddverify/models/goblint/include/linux/major.h b/ddverify/models/goblint/include/linux/major.h new file mode 100644 index 000000000..0a74c5292 --- /dev/null +++ b/ddverify/models/goblint/include/linux/major.h @@ -0,0 +1,169 @@ +#ifndef _LINUX_MAJOR_H +#define _LINUX_MAJOR_H + +/* + * This file has definitions for major device numbers. + * For the device number assignments, see Documentation/devices.txt. + */ + +#define UNNAMED_MAJOR 0 +#define MEM_MAJOR 1 +#define RAMDISK_MAJOR 1 +#define FLOPPY_MAJOR 2 +#define PTY_MASTER_MAJOR 2 +#define IDE0_MAJOR 3 +#define HD_MAJOR IDE0_MAJOR +#define PTY_SLAVE_MAJOR 3 +#define TTY_MAJOR 4 +#define TTYAUX_MAJOR 5 +#define LP_MAJOR 6 +#define VCS_MAJOR 7 +#define LOOP_MAJOR 7 +#define SCSI_DISK0_MAJOR 8 +#define SCSI_TAPE_MAJOR 9 +#define MD_MAJOR 9 +#define MISC_MAJOR 10 +#define SCSI_CDROM_MAJOR 11 +#define MUX_MAJOR 11 /* PA-RISC only */ +#define XT_DISK_MAJOR 13 +#define INPUT_MAJOR 13 +#define SOUND_MAJOR 14 +#define CDU31A_CDROM_MAJOR 15 +#define JOYSTICK_MAJOR 15 +#define GOLDSTAR_CDROM_MAJOR 16 +#define OPTICS_CDROM_MAJOR 17 +#define SANYO_CDROM_MAJOR 18 +#define CYCLADES_MAJOR 19 +#define CYCLADESAUX_MAJOR 20 +#define MITSUMI_X_CDROM_MAJOR 20 +#define MFM_ACORN_MAJOR 21 /* ARM Linux /dev/mfm */ +#define SCSI_GENERIC_MAJOR 21 +#define IDE1_MAJOR 22 +#define DIGICU_MAJOR 22 +#define DIGI_MAJOR 23 +#define MITSUMI_CDROM_MAJOR 23 +#define CDU535_CDROM_MAJOR 24 +#define STL_SERIALMAJOR 24 +#define MATSUSHITA_CDROM_MAJOR 25 +#define STL_CALLOUTMAJOR 25 +#define MATSUSHITA_CDROM2_MAJOR 26 +#define QIC117_TAPE_MAJOR 27 +#define MATSUSHITA_CDROM3_MAJOR 27 +#define MATSUSHITA_CDROM4_MAJOR 28 +#define STL_SIOMEMMAJOR 28 +#define ACSI_MAJOR 28 +#define AZTECH_CDROM_MAJOR 29 +#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */ +#define CM206_CDROM_MAJOR 32 +#define IDE2_MAJOR 33 +#define IDE3_MAJOR 34 +#define Z8530_MAJOR 34 +#define XPRAM_MAJOR 35 /* Expanded storage on S/390: "slow ram"*/ +#define NETLINK_MAJOR 36 +#define PS2ESDI_MAJOR 36 +#define IDETAPE_MAJOR 37 +#define Z2RAM_MAJOR 37 +#define APBLOCK_MAJOR 38 /* AP1000 Block device */ +#define DDV_MAJOR 39 /* AP1000 DDV block device */ +#define NBD_MAJOR 43 /* Network block device */ +#define RISCOM8_NORMAL_MAJOR 48 +#define DAC960_MAJOR 48 /* 48..55 */ +#define RISCOM8_CALLOUT_MAJOR 49 +#define MKISS_MAJOR 55 +#define DSP56K_MAJOR 55 /* DSP56001 processor device */ + +#define IDE4_MAJOR 56 +#define IDE5_MAJOR 57 + +#define SCSI_DISK1_MAJOR 65 +#define SCSI_DISK2_MAJOR 66 +#define SCSI_DISK3_MAJOR 67 +#define SCSI_DISK4_MAJOR 68 +#define SCSI_DISK5_MAJOR 69 +#define SCSI_DISK6_MAJOR 70 +#define SCSI_DISK7_MAJOR 71 + +#define COMPAQ_SMART2_MAJOR 72 +#define COMPAQ_SMART2_MAJOR1 73 +#define COMPAQ_SMART2_MAJOR2 74 +#define COMPAQ_SMART2_MAJOR3 75 +#define COMPAQ_SMART2_MAJOR4 76 +#define COMPAQ_SMART2_MAJOR5 77 +#define COMPAQ_SMART2_MAJOR6 78 +#define COMPAQ_SMART2_MAJOR7 79 + +#define SPECIALIX_NORMAL_MAJOR 75 +#define SPECIALIX_CALLOUT_MAJOR 76 + +#define AURORA_MAJOR 79 + +#define I2O_MAJOR 80 /* 80->87 */ + +#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */ +#define SCSI_CHANGER_MAJOR 86 + +#define IDE6_MAJOR 88 +#define IDE7_MAJOR 89 +#define IDE8_MAJOR 90 +#define IDE9_MAJOR 91 + +#define DASD_MAJOR 94 + +#define MDISK_MAJOR 95 + +#define UBD_MAJOR 98 + +#define PP_MAJOR 99 +#define JSFD_MAJOR 99 + +#define PHONE_MAJOR 100 + +#define COMPAQ_CISS_MAJOR 104 +#define COMPAQ_CISS_MAJOR1 105 +#define COMPAQ_CISS_MAJOR2 106 +#define COMPAQ_CISS_MAJOR3 107 +#define COMPAQ_CISS_MAJOR4 108 +#define COMPAQ_CISS_MAJOR5 109 +#define COMPAQ_CISS_MAJOR6 110 +#define COMPAQ_CISS_MAJOR7 111 + +#define VIODASD_MAJOR 112 +#define VIOCD_MAJOR 113 + +#define ATARAID_MAJOR 114 + +#define SCSI_DISK8_MAJOR 128 +#define SCSI_DISK9_MAJOR 129 +#define SCSI_DISK10_MAJOR 130 +#define SCSI_DISK11_MAJOR 131 +#define SCSI_DISK12_MAJOR 132 +#define SCSI_DISK13_MAJOR 133 +#define SCSI_DISK14_MAJOR 134 +#define SCSI_DISK15_MAJOR 135 + +#define UNIX98_PTY_MASTER_MAJOR 128 +#define UNIX98_PTY_MAJOR_COUNT 8 +#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT) + +#define RTF_MAJOR 150 +#define RAW_MAJOR 162 + +#define USB_ACM_MAJOR 166 +#define USB_ACM_AUX_MAJOR 167 +#define USB_CHAR_MAJOR 180 + +#define VXVM_MAJOR 199 /* VERITAS volume i/o driver */ +#define VXSPEC_MAJOR 200 /* VERITAS volume config driver */ +#define VXDMP_MAJOR 201 /* VERITAS volume multipath driver */ + +#define MSR_MAJOR 202 +#define CPUID_MAJOR 203 + +#define OSST_MAJOR 206 /* OnStream-SCx0 SCSI tape */ + +#define IBM_TTY3270_MAJOR 227 +#define IBM_FS3270_MAJOR 228 + +#define VIOTAPE_MAJOR 230 + +#endif diff --git a/ddverify/models/goblint/include/linux/mc146818rtc.h b/ddverify/models/goblint/include/linux/mc146818rtc.h new file mode 100644 index 000000000..38ed29876 --- /dev/null +++ b/ddverify/models/goblint/include/linux/mc146818rtc.h @@ -0,0 +1,87 @@ +#ifndef _MC146818RTC_H +#define _MC146818RTC_H + +#include +#include /* get the user-level API */ +#include /* register access macros */ + +#include /* spinlock_t */ +extern spinlock_t rtc_lock; /* serialize CMOS RAM access */ + +/********************************************************************** + * register summary + **********************************************************************/ +#define RTC_SECONDS 0 +#define RTC_SECONDS_ALARM 1 +#define RTC_MINUTES 2 +#define RTC_MINUTES_ALARM 3 +#define RTC_HOURS 4 +#define RTC_HOURS_ALARM 5 +/* RTC_*_alarm is always true if 2 MSBs are set */ +# define RTC_ALARM_DONT_CARE 0xC0 + +#define RTC_DAY_OF_WEEK 6 +#define RTC_DAY_OF_MONTH 7 +#define RTC_MONTH 8 +#define RTC_YEAR 9 + +/* control registers - Moto names + */ +#define RTC_REG_A 10 +#define RTC_REG_B 11 +#define RTC_REG_C 12 +#define RTC_REG_D 13 + +/********************************************************************** + * register details + **********************************************************************/ +#define RTC_FREQ_SELECT RTC_REG_A + +/* update-in-progress - set to "1" 244 microsecs before RTC goes off the bus, + * reset after update (may take 1.984ms @ 32768Hz RefClock) is complete, + * totalling to a max high interval of 2.228 ms. + */ +# define RTC_UIP 0x80 +# define RTC_DIV_CTL 0x70 + /* divider control: refclock values 4.194 / 1.049 MHz / 32.768 kHz */ +# define RTC_REF_CLCK_4MHZ 0x00 +# define RTC_REF_CLCK_1MHZ 0x10 +# define RTC_REF_CLCK_32KHZ 0x20 + /* 2 values for divider stage reset, others for "testing purposes only" */ +# define RTC_DIV_RESET1 0x60 +# define RTC_DIV_RESET2 0x70 + /* Periodic intr. / Square wave rate select. 0=none, 1=32.8kHz,... 15=2Hz */ +# define RTC_RATE_SELECT 0x0F + +/**********************************************************************/ +#define RTC_CONTROL RTC_REG_B +# define RTC_SET 0x80 /* disable updates for clock setting */ +# define RTC_PIE 0x40 /* periodic interrupt enable */ +# define RTC_AIE 0x20 /* alarm interrupt enable */ +# define RTC_UIE 0x10 /* update-finished interrupt enable */ +# define RTC_SQWE 0x08 /* enable square-wave output */ +# define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +# define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +# define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +/**********************************************************************/ +#define RTC_INTR_FLAGS RTC_REG_C +/* caution - cleared by read */ +# define RTC_IRQF 0x80 /* any of the following 3 is active */ +# define RTC_PF 0x40 +# define RTC_AF 0x20 +# define RTC_UF 0x10 + +/**********************************************************************/ +#define RTC_VALID RTC_REG_D +# define RTC_VRT 0x80 /* valid RAM and time */ +/**********************************************************************/ + +#ifndef ARCH_RTC_LOCATION /* Override by ? */ + +#define RTC_IO_EXTENT 0x8 +#define RTC_IOMAPPED 1 /* Default to I/O mapping. */ + +#endif /* ARCH_RTC_LOCATION */ + +#endif /* _MC146818RTC_H */ diff --git a/ddverify/models/goblint/include/linux/mempool.h b/ddverify/models/goblint/include/linux/mempool.h new file mode 100644 index 000000000..dd86176f1 --- /dev/null +++ b/ddverify/models/goblint/include/linux/mempool.h @@ -0,0 +1,11 @@ +/* + * memory buffer pool support + */ +#ifndef _LINUX_MEMPOOL_H +#define _LINUX_MEMPOOL_H + +#include + + + +#endif /* _LINUX_MEMPOOL_H */ diff --git a/ddverify/models/goblint/include/linux/miscdevice.h b/ddverify/models/goblint/include/linux/miscdevice.h new file mode 100644 index 000000000..1b6241373 --- /dev/null +++ b/ddverify/models/goblint/include/linux/miscdevice.h @@ -0,0 +1,43 @@ +#ifndef _LINUX_MISCDEVICE_H +#define _LINUX_MISCDEVICE_H +#include +#include + +#define PSMOUSE_MINOR 1 +#define MS_BUSMOUSE_MINOR 2 +#define ATIXL_BUSMOUSE_MINOR 3 +/*#define AMIGAMOUSE_MINOR 4 FIXME OBSOLETE */ +#define ATARIMOUSE_MINOR 5 +#define SUN_MOUSE_MINOR 6 +#define APOLLO_MOUSE_MINOR 7 +#define PC110PAD_MINOR 9 +/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */ +#define WATCHDOG_MINOR 130 /* Watchdog timer */ +#define TEMP_MINOR 131 /* Temperature Sensor */ +#define RTC_MINOR 135 +#define EFI_RTC_MINOR 136 /* EFI Time services */ +#define SUN_OPENPROM_MINOR 139 +#define DMAPI_MINOR 140 /* DMAPI */ +#define NVRAM_MINOR 144 +#define SGI_MMTIMER 153 +#define STORE_QUEUE_MINOR 155 +#define I2O_MINOR 166 +#define MICROCODE_MINOR 184 +#define MWAVE_MINOR 219 /* ACP/Mwave Modem */ +#define MPT_MINOR 220 +#define MISC_DYNAMIC_MINOR 255 + +#define TUN_MINOR 200 +#define HPET_MINOR 228 + + +struct miscdevice { + int minor; + const char *name; + struct file_operations *fops; +}; + +extern int misc_register(struct miscdevice * misc); +extern int misc_deregister(struct miscdevice * misc); + +#endif diff --git a/ddverify/models/goblint/include/linux/mm.h b/ddverify/models/goblint/include/linux/mm.h new file mode 100644 index 000000000..4bbf229f1 --- /dev/null +++ b/ddverify/models/goblint/include/linux/mm.h @@ -0,0 +1,17 @@ +#ifndef _LINUX_MM_H +#define _LINUX_MM_H + +#include +#include +#include + +#include +#include +#include +#include + +#include + +void *page_address(struct page *page); + +#endif /* _LINUX_MM_H */ diff --git a/ddverify/models/goblint/include/linux/mm_types.h b/ddverify/models/goblint/include/linux/mm_types.h new file mode 100644 index 000000000..0645b00a5 --- /dev/null +++ b/ddverify/models/goblint/include/linux/mm_types.h @@ -0,0 +1,14 @@ +#ifndef _LINUX_MM_TYPES_H +#define _LINUX_MM_TYPES_H + +#include +//#include +#include +#include + +struct page { + int something; +}; + +#endif /* _LINUX_MM_TYPES_H */ + diff --git a/ddverify/models/goblint/include/linux/mman.h b/ddverify/models/goblint/include/linux/mman.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/mmzone.h b/ddverify/models/goblint/include/linux/mmzone.h new file mode 100644 index 000000000..709447587 --- /dev/null +++ b/ddverify/models/goblint/include/linux/mmzone.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_MMZONE_H +#define _LINUX_MMZONE_H + +#include +#include +//#include +#include +//#include +#include +//#include +#include +//#include +#include + +#endif /* _LINUX_MMZONE_H */ + diff --git a/ddverify/models/goblint/include/linux/mod_devicetable.h b/ddverify/models/goblint/include/linux/mod_devicetable.h new file mode 100644 index 000000000..0c41094d7 --- /dev/null +++ b/ddverify/models/goblint/include/linux/mod_devicetable.h @@ -0,0 +1,18 @@ +#ifndef LINUX_MOD_DEVICETABLE_H +#define LINUX_MOD_DEVICETABLE_H + +#include + +typedef unsigned long kernel_ulong_t; + +#define PCI_ANY_ID (~0) + +struct pci_device_id { + __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/ + __u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ + __u32 class, class_mask; /* (class,subclass,prog-if) triplet */ + kernel_ulong_t driver_data; /* Data private to the driver */ +}; + +#endif /* LINUX_MOD_DEVICETABLE_H */ + diff --git a/ddverify/models/goblint/include/linux/module.h b/ddverify/models/goblint/include/linux/module.h new file mode 100644 index 000000000..e911d572d --- /dev/null +++ b/ddverify/models/goblint/include/linux/module.h @@ -0,0 +1,32 @@ +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H + +#include +#include +#include +#include +#include +#include + +#define MODULE_AUTHOR(_author) char _ddv_module_author[] = _author +#define MODULE_LICENSE(_license) char _ddv_module_license[] = _license +#define MODULE_DESCRIPTION(_description) char _ddv_module_description[] = _description +#define MODULE_SUPPORTED_DEVICE(_device) char _ddv_module_supported_device[] = _device +#define MODULE_PARM_DESC(_param, _description) char _ddv_module_param_##_param [] = _description +#define MODULE_ALIAS(_whatever) void +#define MODULE_ALIAS_CHARDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_BLOCKDEV_MAJOR(_major) int _ddv_module_param_major = _major +#define MODULE_ALIAS_MISCDEV(_dev) void +#define MODULE_DEVICE_TABLE(type,name) void + +#define THIS_MODULE ((struct module *) 0) + +struct module { + int something; +}; + +#define __MODULE_STRING(x) #x + +void __module_get(struct module *module); + +#endif diff --git a/ddverify/models/goblint/include/linux/moduleparam.h b/ddverify/models/goblint/include/linux/moduleparam.h new file mode 100644 index 000000000..8df1e77e0 --- /dev/null +++ b/ddverify/models/goblint/include/linux/moduleparam.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_MODULE_PARAMS_H +#define _LINUX_MODULE_PARAMS_H + +#include +#include +#include + +#define module_param(var, type, arg) void +#define module_param_named(name, var, type, arg) void +#define module_param_array(name, type, nump, perm) void + +#endif diff --git a/ddverify/models/goblint/include/linux/mutex.h b/ddverify/models/goblint/include/linux/mutex.h new file mode 100644 index 000000000..7298d3300 --- /dev/null +++ b/ddverify/models/goblint/include/linux/mutex.h @@ -0,0 +1,38 @@ +/* + * Mutexes: blocking mutual exclusion locks + * + * started by Ingo Molnar: + * + * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar + * + * This file contains the main data structure and API definitions. + */ +#ifndef __LINUX_MUTEX_H +#define __LINUX_MUTEX_H + +#include +#include +//#include +//#include + +#include + +struct mutex { + int locked; + int init; +}; + +#define __MUTEX_INITIALIZER(lockname) \ + { .locked = 0, .init = 1 } + +#define DEFINE_MUTEX(mutexname) \ + struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) + +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_init(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_lock(struct mutex *lock); +// DDV: Body for this function is defined in linux/kernel.mutex.c +void mutex_unlock(struct mutex *lock); + +#endif diff --git a/ddverify/models/goblint/include/linux/net.h b/ddverify/models/goblint/include/linux/net.h new file mode 100644 index 000000000..1339d2421 --- /dev/null +++ b/ddverify/models/goblint/include/linux/net.h @@ -0,0 +1,19 @@ +#ifndef _LINUX_NET_H +#define _LINUX_NET_H + +struct socket { + const struct proto_ops *ops; + struct sock *sk; +}; + +struct proto_ops { + int (*shutdown) (struct socket *sock, int flags); +}; + +extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, size_t len); +extern int kernel_recvmsg(struct socket *sock, struct msghdr *msg, + struct kvec *vec, size_t num, + size_t len, int flags); + +#endif /* _LINUX_NET_H */ diff --git a/ddverify/models/goblint/include/linux/netdevice.h b/ddverify/models/goblint/include/linux/netdevice.h new file mode 100644 index 000000000..f90cdbfa3 --- /dev/null +++ b/ddverify/models/goblint/include/linux/netdevice.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_NETDEVICE_H +#define _LINUX_NETDEVICE_H + +#include + +#endif /* _LINUX_DEV_H */ diff --git a/ddverify/models/goblint/include/linux/notifier.h b/ddverify/models/goblint/include/linux/notifier.h new file mode 100644 index 000000000..1029f233e --- /dev/null +++ b/ddverify/models/goblint/include/linux/notifier.h @@ -0,0 +1,61 @@ +/* + * Routines to manage notifier chains for passing status changes to any + * interested routines. We need this instead of hard coded call lists so + * that modules can poke their nose into the innards. The network devices + * needed them so here they are for the rest of you. + * + * Alan Cox + */ + +#ifndef _LINUX_NOTIFIER_H +#define _LINUX_NOTIFIER_H +#include + + +struct notifier_block +{ + int (*notifier_call)(struct notifier_block *self, unsigned long, void *); + struct notifier_block *next; + int priority; +}; + +#define NOTIFY_DONE 0x0000 /* Don't care */ +#define NOTIFY_OK 0x0001 /* Suits me */ +#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ +#define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */ +/* + * Clean way to return from the notifier and stop further calls. + */ +#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) + +/* netdevice notifier chain */ +#define NETDEV_UP 0x0001 /* For now you can't veto a device up/down */ +#define NETDEV_DOWN 0x0002 +#define NETDEV_REBOOT 0x0003 /* Tell a protocol stack a network interface + detected a hardware crash and restarted + - we can use this eg to kick tcp sessions + once done */ +#define NETDEV_CHANGE 0x0004 /* Notify device state change */ +#define NETDEV_REGISTER 0x0005 +#define NETDEV_UNREGISTER 0x0006 +#define NETDEV_CHANGEMTU 0x0007 +#define NETDEV_CHANGEADDR 0x0008 +#define NETDEV_GOING_DOWN 0x0009 +#define NETDEV_CHANGENAME 0x000A +#define NETDEV_FEAT_CHANGE 0x000B + +#define SYS_DOWN 0x0001 /* Notify of system down */ +#define SYS_RESTART SYS_DOWN +#define SYS_HALT 0x0002 /* Notify of system halt */ +#define SYS_POWER_OFF 0x0003 /* Notify of system power off */ + +#define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */ + +#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ +#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ +#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ +#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ +#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ +#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ + +#endif /* _LINUX_NOTIFIER_H */ diff --git a/ddverify/models/goblint/include/linux/pagemap.h b/ddverify/models/goblint/include/linux/pagemap.h new file mode 100644 index 000000000..0525a9fc0 --- /dev/null +++ b/ddverify/models/goblint/include/linux/pagemap.h @@ -0,0 +1,15 @@ +#ifndef _LINUX_PAGEMAP_H +#define _LINUX_PAGEMAP_H + +/* + * Copyright 1995 Linus Torvalds + */ +#include +#include +#include +#include +#include +#include +#include + +#endif /* _LINUX_PAGEMAP_H */ diff --git a/ddverify/models/goblint/include/linux/parport.h b/ddverify/models/goblint/include/linux/parport.h new file mode 100644 index 000000000..4e29e513d --- /dev/null +++ b/ddverify/models/goblint/include/linux/parport.h @@ -0,0 +1,559 @@ +/* $Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea $ */ + +/* + * Any part of this program may be used in documents licensed under + * the GNU Free Documentation License, Version 1.1 or any later version + * published by the Free Software Foundation. + */ + +#ifndef _PARPORT_H_ +#define _PARPORT_H_ + +/* Start off with user-visible constants */ + +/* Maximum of 16 ports per machine */ +#define PARPORT_MAX 16 + +/* Magic numbers */ +#define PARPORT_IRQ_NONE -1 +#define PARPORT_DMA_NONE -1 +#define PARPORT_IRQ_AUTO -2 +#define PARPORT_DMA_AUTO -2 +#define PARPORT_DMA_NOFIFO -3 +#define PARPORT_DISABLE -2 +#define PARPORT_IRQ_PROBEONLY -3 +#define PARPORT_IOHI_AUTO -1 + +#define PARPORT_CONTROL_STROBE 0x1 +#define PARPORT_CONTROL_AUTOFD 0x2 +#define PARPORT_CONTROL_INIT 0x4 +#define PARPORT_CONTROL_SELECT 0x8 + +#define PARPORT_STATUS_ERROR 0x8 +#define PARPORT_STATUS_SELECT 0x10 +#define PARPORT_STATUS_PAPEROUT 0x20 +#define PARPORT_STATUS_ACK 0x40 +#define PARPORT_STATUS_BUSY 0x80 + +/* Type classes for Plug-and-Play probe. */ +typedef enum { + PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */ + PARPORT_CLASS_PRINTER, + PARPORT_CLASS_MODEM, + PARPORT_CLASS_NET, + PARPORT_CLASS_HDC, /* Hard disk controller */ + PARPORT_CLASS_PCMCIA, + PARPORT_CLASS_MEDIA, /* Multimedia device */ + PARPORT_CLASS_FDC, /* Floppy disk controller */ + PARPORT_CLASS_PORTS, + PARPORT_CLASS_SCANNER, + PARPORT_CLASS_DIGCAM, + PARPORT_CLASS_OTHER, /* Anything else */ + PARPORT_CLASS_UNSPEC, /* No CLS field in ID */ + PARPORT_CLASS_SCSIADAPTER +} parport_device_class; + +/* The "modes" entry in parport is a bit field representing the + capabilities of the hardware. */ +#define PARPORT_MODE_PCSPP (1<<0) /* IBM PC registers available. */ +#define PARPORT_MODE_TRISTATE (1<<1) /* Can tristate. */ +#define PARPORT_MODE_EPP (1<<2) /* Hardware EPP. */ +#define PARPORT_MODE_ECP (1<<3) /* Hardware ECP. */ +#define PARPORT_MODE_COMPAT (1<<4) /* Hardware 'printer protocol'. */ +#define PARPORT_MODE_DMA (1<<5) /* Hardware can DMA. */ +#define PARPORT_MODE_SAFEININT (1<<6) /* SPP registers accessible in IRQ. */ + +/* IEEE1284 modes: + Nibble mode, byte mode, ECP, ECPRLE and EPP are their own + 'extensibility request' values. Others are special. + 'Real' ECP modes must have the IEEE1284_MODE_ECP bit set. */ +#define IEEE1284_MODE_NIBBLE 0 +#define IEEE1284_MODE_BYTE (1<<0) +#define IEEE1284_MODE_COMPAT (1<<8) +#define IEEE1284_MODE_BECP (1<<9) /* Bounded ECP mode */ +#define IEEE1284_MODE_ECP (1<<4) +#define IEEE1284_MODE_ECPRLE (IEEE1284_MODE_ECP | (1<<5)) +#define IEEE1284_MODE_ECPSWE (1<<10) /* Software-emulated */ +#define IEEE1284_MODE_EPP (1<<6) +#define IEEE1284_MODE_EPPSL (1<<11) /* EPP 1.7 */ +#define IEEE1284_MODE_EPPSWE (1<<12) /* Software-emulated */ +#define IEEE1284_DEVICEID (1<<2) /* This is a flag */ +#define IEEE1284_EXT_LINK (1<<14) /* This flag causes the + * extensibility link to + * be requested, using + * bits 0-6. */ + +/* For the benefit of parport_read/write, you can use these with + * parport_negotiate to use address operations. They have no effect + * other than to make parport_read/write use address transfers. */ +#define IEEE1284_ADDR (1<<13) /* This is a flag */ +#define IEEE1284_DATA 0 /* So is this */ + +/* Flags for block transfer operations. */ +#define PARPORT_EPP_FAST (1<<0) /* Unreliable counts. */ +#define PARPORT_W91284PIC (1<<1) /* have a Warp9 w91284pic in the device */ + +#include +#include +#include +#include +#include +#include +#include + +/* Define this later. */ +struct parport; +struct pardevice; + +struct pc_parport_state { + unsigned int ctr; + unsigned int ecr; +}; + +struct ax_parport_state { + unsigned int ctr; + unsigned int ecr; + unsigned int dcsr; +}; + +/* used by both parport_amiga and parport_mfc3 */ +struct amiga_parport_state { + unsigned char data; /* ciaa.prb */ + unsigned char datadir; /* ciaa.ddrb */ + unsigned char status; /* ciab.pra & 7 */ + unsigned char statusdir;/* ciab.ddrb & 7 */ +}; + +struct ax88796_parport_state { + unsigned char cpr; +}; + +struct ip32_parport_state { + unsigned int dcr; + unsigned int ecr; +}; + +struct parport_state { + union { + struct pc_parport_state pc; + /* ARC has no state. */ + struct ax_parport_state ax; + struct amiga_parport_state amiga; + struct ax88796_parport_state ax88796; + /* Atari has not state. */ + struct ip32_parport_state ip32; + void *misc; + } u; +}; + +struct parport_operations { + /* IBM PC-style virtual registers. */ + void (*write_data)(struct parport *, unsigned char); + unsigned char (*read_data)(struct parport *); + + void (*write_control)(struct parport *, unsigned char); + unsigned char (*read_control)(struct parport *); + unsigned char (*frob_control)(struct parport *, unsigned char mask, + unsigned char val); + + unsigned char (*read_status)(struct parport *); + + /* IRQs. */ + void (*enable_irq)(struct parport *); + void (*disable_irq)(struct parport *); + + /* Data direction. */ + void (*data_forward) (struct parport *); + void (*data_reverse) (struct parport *); + + /* For core parport code. */ + void (*init_state)(struct pardevice *, struct parport_state *); + void (*save_state)(struct parport *, struct parport_state *); + void (*restore_state)(struct parport *, struct parport_state *); + + /* Block read/write */ + size_t (*epp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*epp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*epp_read_addr) (struct parport *port, void *buf, size_t len, + int flags); + + size_t (*ecp_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*ecp_read_data) (struct parport *port, void *buf, size_t len, + int flags); + size_t (*ecp_write_addr) (struct parport *port, const void *buf, + size_t len, int flags); + + size_t (*compat_write_data) (struct parport *port, const void *buf, + size_t len, int flags); + size_t (*nibble_read_data) (struct parport *port, void *buf, + size_t len, int flags); + size_t (*byte_read_data) (struct parport *port, void *buf, + size_t len, int flags); + struct module *owner; +}; + +struct parport_device_info { + parport_device_class class; + const char *class_name; + const char *mfr; + const char *model; + const char *cmdset; + const char *description; +}; + +/* Each device can have two callback functions: + * 1) a preemption function, called by the resource manager to request + * that the driver relinquish control of the port. The driver should + * return zero if it agrees to release the port, and nonzero if it + * refuses. Do not call parport_release() - the kernel will do this + * implicitly. + * + * 2) a wake-up function, called by the resource manager to tell drivers + * that the port is available to be claimed. If a driver wants to use + * the port, it should call parport_claim() here. + */ + +/* A parallel port device */ +struct pardevice { + const char *name; + struct parport *port; + int daisy; + int (*preempt)(void *); + void (*wakeup)(void *); + void *private; + void (*irq_func)(int, void *); + unsigned int flags; + struct pardevice *next; + struct pardevice *prev; + struct parport_state *state; /* saved status over preemption */ + wait_queue_head_t wait_q; + unsigned long int time; + unsigned long int timeslice; + volatile long int timeout; + unsigned long waiting; /* long req'd for set_bit --RR */ + struct pardevice *waitprev; + struct pardevice *waitnext; + void * sysctl_table; +}; + +/* IEEE1284 information */ + +/* IEEE1284 phases. These are exposed to userland through ppdev IOCTL + * PP[GS]ETPHASE, so do not change existing values. */ +enum ieee1284_phase { + IEEE1284_PH_FWD_DATA, + IEEE1284_PH_FWD_IDLE, + IEEE1284_PH_TERMINATE, + IEEE1284_PH_NEGOTIATION, + IEEE1284_PH_HBUSY_DNA, + IEEE1284_PH_REV_IDLE, + IEEE1284_PH_HBUSY_DAVAIL, + IEEE1284_PH_REV_DATA, + IEEE1284_PH_ECP_SETUP, + IEEE1284_PH_ECP_FWD_TO_REV, + IEEE1284_PH_ECP_REV_TO_FWD, + IEEE1284_PH_ECP_DIR_UNKNOWN, +}; +struct ieee1284_info { + int mode; + volatile enum ieee1284_phase phase; + struct semaphore irq; +}; + +/* A parallel port */ +struct parport { + unsigned long base; /* base address */ + unsigned long base_hi; /* base address (hi - ECR) */ + unsigned int size; /* IO extent */ + const char *name; + unsigned int modes; + int irq; /* interrupt (or -1 for none) */ + int dma; + int muxport; /* which muxport (if any) this is */ + int portnum; /* which physical parallel port (not mux) */ + + struct parport *physport; + /* If this is a non-default mux + parport, i.e. we're a clone of a real + physical port, this is a pointer to that + port. The locking is only done in the + real port. For a clone port, the + following structure members are + meaningless: devices, cad, muxsel, + waithead, waittail, flags, pdir, + ieee1284, *_lock. + + It this is a default mux parport, or + there is no mux involved, this points to + ourself. */ + + struct pardevice *devices; + struct pardevice *cad; /* port owner */ + int daisy; /* currently selected daisy addr */ + int muxsel; /* currently selected mux port */ + + struct pardevice *waithead; + struct pardevice *waittail; + + struct list_head list; + unsigned int flags; + + void *sysctl_table; + struct parport_device_info probe_info[5]; /* 0-3 + non-IEEE1284.3 */ + struct ieee1284_info ieee1284; + + struct parport_operations *ops; + void *private_data; /* for lowlevel driver */ + + int number; /* port index - the `n' in `parportn' */ + spinlock_t pardevice_lock; + spinlock_t waitlist_lock; + rwlock_t cad_lock; + + int spintime; + atomic_t ref_count; + + struct list_head full_list; + struct parport *slaves[3]; +}; + +#define DEFAULT_SPIN_TIME 500 /* us */ + +struct parport_driver { + const char *name; + void (*attach) (struct parport *); + void (*detach) (struct parport *); + struct list_head list; +}; + +/* parport_register_port registers a new parallel port at the given + address (if one does not already exist) and returns a pointer to it. + This entails claiming the I/O region, IRQ and DMA. NULL is returned + if initialisation fails. */ +struct parport *parport_register_port(unsigned long base, int irq, int dma, + struct parport_operations *ops); + +/* Once a registered port is ready for high-level drivers to use, the + low-level driver that registered it should announce it. This will + call the high-level drivers' attach() functions (after things like + determining the IEEE 1284.3 topology of the port and collecting + DeviceIDs). */ +void parport_announce_port (struct parport *port); + +/* Unregister a port. */ +extern void parport_remove_port(struct parport *port); + +/* Register a new high-level driver. */ +extern int parport_register_driver (struct parport_driver *); + +/* Unregister a high-level driver. */ +extern void parport_unregister_driver (struct parport_driver *); + +/* If parport_register_driver doesn't fit your needs, perhaps + * parport_find_xxx does. */ +extern struct parport *parport_find_number (int); +extern struct parport *parport_find_base (unsigned long); + +/* Reference counting for ports. */ +extern struct parport *parport_get_port (struct parport *); +extern void parport_put_port (struct parport *); + +/* parport_register_device declares that a device is connected to a + port, and tells the kernel all it needs to know. + - pf is the preemption function (may be NULL for no callback) + - kf is the wake-up function (may be NULL for no callback) + - irq_func is the interrupt handler (may be NULL for no interrupts) + - handle is a user pointer that gets handed to callback functions. */ +struct pardevice *parport_register_device(struct parport *port, + const char *name, + int (*pf)(void *), void (*kf)(void *), + void (*irq_func)(int, void *), + int flags, void *handle); + +/* parport_unregister unlinks a device from the chain. */ +extern void parport_unregister_device(struct pardevice *dev); + +/* parport_claim tries to gain ownership of the port for a particular + driver. This may fail (return non-zero) if another driver is busy. + If this driver has registered an interrupt handler, it will be + enabled. */ +extern int parport_claim(struct pardevice *dev); + +/* parport_claim_or_block is the same, but sleeps if the port cannot + be claimed. Return value is 1 if it slept, 0 normally and -errno + on error. */ +extern int parport_claim_or_block(struct pardevice *dev); + +/* parport_release reverses a previous parport_claim. This can never + fail, though the effects are undefined (except that they are bad) + if you didn't previously own the port. Once you have released the + port you should make sure that neither your code nor the hardware + on the port tries to initiate any communication without first + re-claiming the port. If you mess with the port state (enabling + ECP for example) you should clean up before releasing the port. */ + +extern void parport_release(struct pardevice *dev); + +/** + * parport_yield - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim(), and the return value is the same as for + * parport_claim(). If it fails, the port is left unclaimed and it is + * the driver's responsibility to reclaim the port. + * + * The parport_yield() and parport_yield_blocking() functions are for + * marking points in the driver at which other drivers may claim the + * port and use their devices. Yielding the port is similar to + * releasing it and reclaiming it, but is more efficient because no + * action is taken if there are no other devices needing the port. In + * fact, nothing is done even if there are other devices waiting but + * the current device is still within its "timeslice". The default + * timeslice is half a second, but it can be adjusted via the /proc + * interface. + **/ +static __inline__ int parport_yield(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim(dev); +} + +/** + * parport_yield_blocking - relinquish a parallel port temporarily + * @dev: a device on the parallel port + * + * This function relinquishes the port if it would be helpful to other + * drivers to do so. Afterwards it tries to reclaim the port using + * parport_claim_or_block(), and the return value is the same as for + * parport_claim_or_block(). + **/ +static __inline__ int parport_yield_blocking(struct pardevice *dev) +{ + unsigned long int timeslip = (jiffies - dev->time); + if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) + return 0; + parport_release(dev); + return parport_claim_or_block(dev); +} + +/* Flags used to identify what a device does. */ +#define PARPORT_DEV_TRAN 0 /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_LURK (1<<0) /* WARNING !! DEPRECATED !! */ +#define PARPORT_DEV_EXCL (1<<1) /* Need exclusive access. */ + +#define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */ + +/* IEEE1284 functions */ +extern void parport_ieee1284_interrupt (int, void *); +extern int parport_negotiate (struct parport *, int mode); +extern ssize_t parport_write (struct parport *, const void *buf, size_t len); +extern ssize_t parport_read (struct parport *, void *buf, size_t len); + +#define PARPORT_INACTIVITY_O_NONBLOCK 1 +extern long parport_set_timeout (struct pardevice *, long inactivity); + +extern int parport_wait_event (struct parport *, long timeout); +extern int parport_wait_peripheral (struct parport *port, + unsigned char mask, + unsigned char val); +extern int parport_poll_peripheral (struct parport *port, + unsigned char mask, + unsigned char val, + int usec); + +/* For architectural drivers */ +extern size_t parport_ieee1284_write_compat (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_read_nibble (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_read_byte (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_ecp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_write_data (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_data (struct parport *, + void *, size_t, int); +extern size_t parport_ieee1284_epp_write_addr (struct parport *, + const void *, size_t, int); +extern size_t parport_ieee1284_epp_read_addr (struct parport *, + void *, size_t, int); + +/* IEEE1284.3 functions */ +extern int parport_daisy_init (struct parport *port); +extern void parport_daisy_fini (struct parport *port); +extern struct pardevice *parport_open (int devnum, const char *name, + int (*pf) (void *), + void (*kf) (void *), + void (*irqf) (int, void *), + int flags, void *handle); +extern void parport_close (struct pardevice *dev); +extern ssize_t parport_device_id (int devnum, char *buffer, size_t len); +extern int parport_device_num (int parport, int mux, int daisy); +extern void parport_daisy_deselect_all (struct parport *port); +extern int parport_daisy_select (struct parport *port, int daisy, int mode); + +/* Lowlevel drivers _can_ call this support function to handle irqs. */ +/* +static __inline__ void parport_generic_irq(int irq, struct parport *port) +{ + parport_ieee1284_interrupt (irq, port); + read_lock(&port->cad_lock); + if (port->cad && port->cad->irq_func) + port->cad->irq_func(irq, port->cad->private); + read_unlock(&port->cad_lock); +} +*/ + +/* Prototypes from parport_procfs */ +extern int parport_proc_register(struct parport *pp); +extern int parport_proc_unregister(struct parport *pp); +extern int parport_device_proc_register(struct pardevice *device); +extern int parport_device_proc_unregister(struct pardevice *device); + +/* If PC hardware is the only type supported, we can optimise a bit. */ +#if !defined(CONFIG_PARPORT_NOT_PC) + +#include +#define parport_write_data(p,x) parport_pc_write_data(p,x) +#define parport_read_data(p) parport_pc_read_data(p) +#define parport_write_control(p,x) parport_pc_write_control(p,x) +#define parport_read_control(p) parport_pc_read_control(p) +#define parport_frob_control(p,m,v) parport_pc_frob_control(p,m,v) +#define parport_read_status(p) parport_pc_read_status(p) +#define parport_enable_irq(p) parport_pc_enable_irq(p) +#define parport_disable_irq(p) parport_pc_disable_irq(p) +#define parport_data_forward(p) parport_pc_data_forward(p) +#define parport_data_reverse(p) parport_pc_data_reverse(p) + +#else /* !CONFIG_PARPORT_NOT_PC */ + +/* Generic operations vector through the dispatch table. */ +#define parport_write_data(p,x) (p)->ops->write_data(p,x) +#define parport_read_data(p) (p)->ops->read_data(p) +#define parport_write_control(p,x) (p)->ops->write_control(p,x) +#define parport_read_control(p) (p)->ops->read_control(p) +#define parport_frob_control(p,m,v) (p)->ops->frob_control(p,m,v) +#define parport_read_status(p) (p)->ops->read_status(p) +#define parport_enable_irq(p) (p)->ops->enable_irq(p) +#define parport_disable_irq(p) (p)->ops->disable_irq(p) +#define parport_data_forward(p) (p)->ops->data_forward(p) +#define parport_data_reverse(p) (p)->ops->data_reverse(p) + +#endif /* !CONFIG_PARPORT_NOT_PC */ + +#endif /* _PARPORT_H_ */ diff --git a/ddverify/models/goblint/include/linux/parport_pc.h b/ddverify/models/goblint/include/linux/parport_pc.h new file mode 100644 index 000000000..1c6df907d --- /dev/null +++ b/ddverify/models/goblint/include/linux/parport_pc.h @@ -0,0 +1,42 @@ +#ifndef __LINUX_PARPORT_PC_H +#define __LINUX_PARPORT_PC_H + +#include + +/* --- register definitions ------------------------------- */ + +#define ECONTROL(p) ((p)->base_hi + 0x2) +#define CONFIGB(p) ((p)->base_hi + 0x1) +#define CONFIGA(p) ((p)->base_hi + 0x0) +#define FIFO(p) ((p)->base_hi + 0x0) +#define EPPDATA(p) ((p)->base + 0x4) +#define EPPADDR(p) ((p)->base + 0x3) +#define CONTROL(p) ((p)->base + 0x2) +#define STATUS(p) ((p)->base + 0x1) +#define DATA(p) ((p)->base + 0x0) + +struct parport_pc_private { + int something; +}; + +struct parport_pc_via_data +{ + int something; +}; + +void parport_pc_write_data(struct parport *p, unsigned char d); +unsigned char parport_pc_read_data(struct parport *p); +void parport_pc_data_reverse (struct parport *p); +void parport_pc_data_forward (struct parport *p); +void parport_pc_write_control (struct parport *p, unsigned char d); +unsigned char parport_pc_read_control(struct parport *p); +unsigned char parport_pc_frob_control (struct parport *p, + unsigned char mask, + unsigned char val); +unsigned char parport_pc_read_status(struct parport *p); +void parport_pc_disable_irq(struct parport *p); +void parport_pc_enable_irq(struct parport *p); +void parport_pc_release_resources(struct parport *p); +int parport_pc_claim_resources(struct parport *p); + +#endif diff --git a/ddverify/models/goblint/include/linux/pci.h b/ddverify/models/goblint/include/linux/pci.h new file mode 100644 index 000000000..e2076f1a4 --- /dev/null +++ b/ddverify/models/goblint/include/linux/pci.h @@ -0,0 +1,176 @@ +#ifndef LINUX_PCI_H +#define LINUX_PCI_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Include the pci register defines */ +#include + +/* Include the ID list */ +#include + +/* + * The PCI interface treats multi-function devices as independent + * devices. The slot/function address of each device is encoded + * in a single byte as follows: + * + * 7:3 = slot + * 2:0 = function + */ +#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) +#define PCI_FUNC(devfn) ((devfn) & 0x07) + +/* This defines the direction arg to the DMA mapping routines. */ +#define PCI_DMA_BIDIRECTIONAL 0 +#define PCI_DMA_TODEVICE 1 +#define PCI_DMA_FROMDEVICE 2 +#define PCI_DMA_NONE 3 + +#define DEVICE_COUNT_COMPATIBLE 4 +#define DEVICE_COUNT_RESOURCE 12 + +typedef int __bitwise pci_power_t; + + +struct pci_dev { + struct pci_bus *bus; /* bus this device is on */ + + unsigned int devfn; /* encoded device & function index */ + unsigned short vendor; + unsigned short device; + + + u64 dma_mask; + + struct device dev; + + unsigned int irq; + struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ +}; + + +#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) + +struct pci_bus { + unsigned char number; /* bus number */ +}; + + +struct pci_driver { + char *name; + const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */ + int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ + void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ + int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ + int (*resume) (struct pci_dev *dev); /* Device woken up */ + int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ + void (*shutdown) (struct pci_dev *dev); +}; + +#define PCI_DEVICE(vend,dev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID + + +// DDV: Does not need a body! Return an arbitrary integer. +int pci_dev_present(const struct pci_device_id *ids); + +// DDV: Body for this function is defined in linux/pci.c +struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); + + +/* Similar to the helpers above, these manipulate per-pci_dev + * driver-specific data. They are really just a wrapper around + * the generic device structure functions of these calls. + */ +static inline void *pci_get_drvdata (struct pci_dev *pdev) +{ + return dev_get_drvdata(&pdev->dev); +} + +static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) +{ + dev_set_drvdata(&pdev->dev, data); +} + +int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); +int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); +int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); +int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); +int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); +int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); + +static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) +{ + return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) +{ + return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) +{ + return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) +{ + return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) +{ + return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); +} +static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) +{ + return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); +} + +int pci_set_dma_mask(struct pci_dev *dev, u64 mask); +void pci_set_master(struct pci_dev *dev); + + +// DDV: Body for this function is defined in linux/pci.c +int pci_register_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +void pci_unregister_driver(struct pci_driver *); +// DDV: Body for this function is defined in linux/pci.c +int pci_enable_device(struct pci_dev *dev); +// DDV: No body for this function +void pci_disable_device(struct pci_dev *dev); + + +#define HAVE_PCI_REQ_REGIONS 2 +// DDV: Body for this function is defined in linux/pci.c +int pci_request_regions(struct pci_dev *, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_regions(struct pci_dev *); +// DDV: Body for this function is defined in linux/pci.c +int pci_request_region(struct pci_dev *, int, const char *); +// DDV: Body for this function is defined in linux/pci.c +void pci_release_region(struct pci_dev *, int); + + +#include + +/* these helpers provide future and backwards compatibility + * for accessing popular PCI BAR info */ +#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) +#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) +#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) +#define pci_resource_len(dev,bar) \ + ((pci_resource_start((dev),(bar)) == 0 && \ + pci_resource_end((dev),(bar)) == \ + pci_resource_start((dev),(bar))) ? 0 : \ + \ + (pci_resource_end((dev),(bar)) - \ + pci_resource_start((dev),(bar)) + 1)) + +#endif /* LINUX_PCI_H */ diff --git a/ddverify/models/goblint/include/linux/pci_ids.h b/ddverify/models/goblint/include/linux/pci_ids.h new file mode 100644 index 000000000..a3a09cceb --- /dev/null +++ b/ddverify/models/goblint/include/linux/pci_ids.h @@ -0,0 +1,2260 @@ +/* + * PCI Class, Vendor and Device IDs + * + * Please keep sorted. + */ + +/* Device classes and subclasses */ + +#define PCI_CLASS_NOT_DEFINED 0x0000 +#define PCI_CLASS_NOT_DEFINED_VGA 0x0001 + +#define PCI_BASE_CLASS_STORAGE 0x01 +#define PCI_CLASS_STORAGE_SCSI 0x0100 +#define PCI_CLASS_STORAGE_IDE 0x0101 +#define PCI_CLASS_STORAGE_FLOPPY 0x0102 +#define PCI_CLASS_STORAGE_IPI 0x0103 +#define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SAS 0x0107 +#define PCI_CLASS_STORAGE_OTHER 0x0180 + +#define PCI_BASE_CLASS_NETWORK 0x02 +#define PCI_CLASS_NETWORK_ETHERNET 0x0200 +#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 +#define PCI_CLASS_NETWORK_FDDI 0x0202 +#define PCI_CLASS_NETWORK_ATM 0x0203 +#define PCI_CLASS_NETWORK_OTHER 0x0280 + +#define PCI_BASE_CLASS_DISPLAY 0x03 +#define PCI_CLASS_DISPLAY_VGA 0x0300 +#define PCI_CLASS_DISPLAY_XGA 0x0301 +#define PCI_CLASS_DISPLAY_3D 0x0302 +#define PCI_CLASS_DISPLAY_OTHER 0x0380 + +#define PCI_BASE_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400 +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 +#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402 +#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480 + +#define PCI_BASE_CLASS_MEMORY 0x05 +#define PCI_CLASS_MEMORY_RAM 0x0500 +#define PCI_CLASS_MEMORY_FLASH 0x0501 +#define PCI_CLASS_MEMORY_OTHER 0x0580 + +#define PCI_BASE_CLASS_BRIDGE 0x06 +#define PCI_CLASS_BRIDGE_HOST 0x0600 +#define PCI_CLASS_BRIDGE_ISA 0x0601 +#define PCI_CLASS_BRIDGE_EISA 0x0602 +#define PCI_CLASS_BRIDGE_MC 0x0603 +#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_BRIDGE_PCMCIA 0x0605 +#define PCI_CLASS_BRIDGE_NUBUS 0x0606 +#define PCI_CLASS_BRIDGE_CARDBUS 0x0607 +#define PCI_CLASS_BRIDGE_RACEWAY 0x0608 +#define PCI_CLASS_BRIDGE_OTHER 0x0680 + +#define PCI_BASE_CLASS_COMMUNICATION 0x07 +#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700 +#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701 +#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702 +#define PCI_CLASS_COMMUNICATION_MODEM 0x0703 +#define PCI_CLASS_COMMUNICATION_OTHER 0x0780 + +#define PCI_BASE_CLASS_SYSTEM 0x08 +#define PCI_CLASS_SYSTEM_PIC 0x0800 +#define PCI_CLASS_SYSTEM_PIC_IOAPIC 0x080010 +#define PCI_CLASS_SYSTEM_PIC_IOXAPIC 0x080020 +#define PCI_CLASS_SYSTEM_DMA 0x0801 +#define PCI_CLASS_SYSTEM_TIMER 0x0802 +#define PCI_CLASS_SYSTEM_RTC 0x0803 +#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804 +#define PCI_CLASS_SYSTEM_OTHER 0x0880 + +#define PCI_BASE_CLASS_INPUT 0x09 +#define PCI_CLASS_INPUT_KEYBOARD 0x0900 +#define PCI_CLASS_INPUT_PEN 0x0901 +#define PCI_CLASS_INPUT_MOUSE 0x0902 +#define PCI_CLASS_INPUT_SCANNER 0x0903 +#define PCI_CLASS_INPUT_GAMEPORT 0x0904 +#define PCI_CLASS_INPUT_OTHER 0x0980 + +#define PCI_BASE_CLASS_DOCKING 0x0a +#define PCI_CLASS_DOCKING_GENERIC 0x0a00 +#define PCI_CLASS_DOCKING_OTHER 0x0a80 + +#define PCI_BASE_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_PROCESSOR_386 0x0b00 +#define PCI_CLASS_PROCESSOR_486 0x0b01 +#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02 +#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10 +#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20 +#define PCI_CLASS_PROCESSOR_MIPS 0x0b30 +#define PCI_CLASS_PROCESSOR_CO 0x0b40 + +#define PCI_BASE_CLASS_SERIAL 0x0c +#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00 +#define PCI_CLASS_SERIAL_ACCESS 0x0c01 +#define PCI_CLASS_SERIAL_SSA 0x0c02 +#define PCI_CLASS_SERIAL_USB 0x0c03 +#define PCI_CLASS_SERIAL_USB_UHCI 0x0c0300 +#define PCI_CLASS_SERIAL_USB_OHCI 0x0c0310 +#define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320 +#define PCI_CLASS_SERIAL_FIBER 0x0c04 +#define PCI_CLASS_SERIAL_SMBUS 0x0c05 + +#define PCI_BASE_CLASS_INTELLIGENT 0x0e +#define PCI_CLASS_INTELLIGENT_I2O 0x0e00 + +#define PCI_BASE_CLASS_SATELLITE 0x0f +#define PCI_CLASS_SATELLITE_TV 0x0f00 +#define PCI_CLASS_SATELLITE_AUDIO 0x0f01 +#define PCI_CLASS_SATELLITE_VOICE 0x0f03 +#define PCI_CLASS_SATELLITE_DATA 0x0f04 + +#define PCI_BASE_CLASS_CRYPT 0x10 +#define PCI_CLASS_CRYPT_NETWORK 0x1000 +#define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001 +#define PCI_CLASS_CRYPT_OTHER 0x1080 + +#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11 +#define PCI_CLASS_SP_DPIO 0x1100 +#define PCI_CLASS_SP_OTHER 0x1180 + +#define PCI_CLASS_OTHERS 0xff + +/* Vendors and devices. Sort key: vendor first, device next. */ + +#define PCI_VENDOR_ID_DYNALINK 0x0675 +#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702 + +#define PCI_VENDOR_ID_BERKOM 0x0871 +#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1 +#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2 +#define PCI_DEVICE_ID_BERKOM_A4T 0xffa4 +#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xffa8 + +#define PCI_VENDOR_ID_COMPAQ 0x0e11 +#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508 +#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc +#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10 +#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32 +#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34 +#define PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE 0xae33 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35 +#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40 +#define PCI_DEVICE_ID_COMPAQ_NETEL100PI 0xae43 +#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011 +#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060 +#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178 +#define PCI_DEVICE_ID_COMPAQ_CISSC 0x46 +#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130 +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150 + +#define PCI_VENDOR_ID_NCR 0x1000 +#define PCI_VENDOR_ID_LSI_LOGIC 0x1000 +#define PCI_DEVICE_ID_NCR_53C810 0x0001 +#define PCI_DEVICE_ID_NCR_53C820 0x0002 +#define PCI_DEVICE_ID_NCR_53C825 0x0003 +#define PCI_DEVICE_ID_NCR_53C815 0x0004 +#define PCI_DEVICE_ID_LSI_53C810AP 0x0005 +#define PCI_DEVICE_ID_NCR_53C860 0x0006 +#define PCI_DEVICE_ID_LSI_53C1510 0x000a +#define PCI_DEVICE_ID_NCR_53C896 0x000b +#define PCI_DEVICE_ID_NCR_53C895 0x000c +#define PCI_DEVICE_ID_NCR_53C885 0x000d +#define PCI_DEVICE_ID_NCR_53C875 0x000f +#define PCI_DEVICE_ID_NCR_53C1510 0x0010 +#define PCI_DEVICE_ID_LSI_53C895A 0x0012 +#define PCI_DEVICE_ID_LSI_53C875A 0x0013 +#define PCI_DEVICE_ID_LSI_53C1010_33 0x0020 +#define PCI_DEVICE_ID_LSI_53C1010_66 0x0021 +#define PCI_DEVICE_ID_LSI_53C1030 0x0030 +#define PCI_DEVICE_ID_LSI_1030_53C1035 0x0032 +#define PCI_DEVICE_ID_LSI_53C1035 0x0040 +#define PCI_DEVICE_ID_NCR_53C875J 0x008f +#define PCI_DEVICE_ID_LSI_FC909 0x0621 +#define PCI_DEVICE_ID_LSI_FC929 0x0622 +#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623 +#define PCI_DEVICE_ID_LSI_FC919 0x0624 +#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625 +#define PCI_DEVICE_ID_LSI_FC929X 0x0626 +#define PCI_DEVICE_ID_LSI_FC939X 0x0642 +#define PCI_DEVICE_ID_LSI_FC949X 0x0640 +#define PCI_DEVICE_ID_LSI_FC949ES 0x0646 +#define PCI_DEVICE_ID_LSI_FC919X 0x0628 +#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701 +#define PCI_DEVICE_ID_LSI_61C102 0x0901 +#define PCI_DEVICE_ID_LSI_63C815 0x1000 +#define PCI_DEVICE_ID_LSI_SAS1064 0x0050 +#define PCI_DEVICE_ID_LSI_SAS1064R 0x0411 +#define PCI_DEVICE_ID_LSI_SAS1066 0x005E +#define PCI_DEVICE_ID_LSI_SAS1068 0x0054 +#define PCI_DEVICE_ID_LSI_SAS1064A 0x005C +#define PCI_DEVICE_ID_LSI_SAS1064E 0x0056 +#define PCI_DEVICE_ID_LSI_SAS1066E 0x005A +#define PCI_DEVICE_ID_LSI_SAS1068E 0x0058 +#define PCI_DEVICE_ID_LSI_SAS1078 0x0060 + +#define PCI_VENDOR_ID_ATI 0x1002 +/* Mach64 */ +#define PCI_DEVICE_ID_ATI_68800 0x4158 +#define PCI_DEVICE_ID_ATI_215CT222 0x4354 +#define PCI_DEVICE_ID_ATI_210888CX 0x4358 +#define PCI_DEVICE_ID_ATI_215ET222 0x4554 +/* Mach64 / Rage */ +#define PCI_DEVICE_ID_ATI_215GB 0x4742 +#define PCI_DEVICE_ID_ATI_215GD 0x4744 +#define PCI_DEVICE_ID_ATI_215GI 0x4749 +#define PCI_DEVICE_ID_ATI_215GP 0x4750 +#define PCI_DEVICE_ID_ATI_215GQ 0x4751 +#define PCI_DEVICE_ID_ATI_215XL 0x4752 +#define PCI_DEVICE_ID_ATI_215GT 0x4754 +#define PCI_DEVICE_ID_ATI_215GTB 0x4755 +#define PCI_DEVICE_ID_ATI_215_IV 0x4756 +#define PCI_DEVICE_ID_ATI_215_IW 0x4757 +#define PCI_DEVICE_ID_ATI_215_IZ 0x475A +#define PCI_DEVICE_ID_ATI_210888GX 0x4758 +#define PCI_DEVICE_ID_ATI_215_LB 0x4c42 +#define PCI_DEVICE_ID_ATI_215_LD 0x4c44 +#define PCI_DEVICE_ID_ATI_215_LG 0x4c47 +#define PCI_DEVICE_ID_ATI_215_LI 0x4c49 +#define PCI_DEVICE_ID_ATI_215_LM 0x4c4D +#define PCI_DEVICE_ID_ATI_215_LN 0x4c4E +#define PCI_DEVICE_ID_ATI_215_LR 0x4c52 +#define PCI_DEVICE_ID_ATI_215_LS 0x4c53 +#define PCI_DEVICE_ID_ATI_264_LT 0x4c54 +/* Mach64 VT */ +#define PCI_DEVICE_ID_ATI_264VT 0x5654 +#define PCI_DEVICE_ID_ATI_264VU 0x5655 +#define PCI_DEVICE_ID_ATI_264VV 0x5656 +/* Rage128 GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245 +#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246 +#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x5247 +/* Rage128 VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b +#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c +#define PCI_DEVICE_ID_ATI_RAGE128_SE 0x5345 +#define PCI_DEVICE_ID_ATI_RAGE128_SF 0x5346 +#define PCI_DEVICE_ID_ATI_RAGE128_SG 0x5347 +#define PCI_DEVICE_ID_ATI_RAGE128_SH 0x5348 +#define PCI_DEVICE_ID_ATI_RAGE128_SK 0x534b +#define PCI_DEVICE_ID_ATI_RAGE128_SL 0x534c +#define PCI_DEVICE_ID_ATI_RAGE128_SM 0x534d +#define PCI_DEVICE_ID_ATI_RAGE128_SN 0x534e +/* Rage128 Ultra */ +#define PCI_DEVICE_ID_ATI_RAGE128_TF 0x5446 +#define PCI_DEVICE_ID_ATI_RAGE128_TL 0x544c +#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452 +#define PCI_DEVICE_ID_ATI_RAGE128_TS 0x5453 +#define PCI_DEVICE_ID_ATI_RAGE128_TT 0x5454 +#define PCI_DEVICE_ID_ATI_RAGE128_TU 0x5455 +/* Rage128 M3 */ +#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45 +#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46 +/* Rage128 M4 */ +#define PCI_DEVICE_ID_ATI_RAGE128_MF 0x4d46 +#define PCI_DEVICE_ID_ATI_RAGE128_ML 0x4d4c +/* Rage128 Pro GL */ +#define PCI_DEVICE_ID_ATI_RAGE128_PA 0x5041 +#define PCI_DEVICE_ID_ATI_RAGE128_PB 0x5042 +#define PCI_DEVICE_ID_ATI_RAGE128_PC 0x5043 +#define PCI_DEVICE_ID_ATI_RAGE128_PD 0x5044 +#define PCI_DEVICE_ID_ATI_RAGE128_PE 0x5045 +#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046 +/* Rage128 Pro VR */ +#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047 +#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048 +#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049 +#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A +#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B +#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C +#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D +#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E +#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F +#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050 +#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051 +#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052 +#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053 +#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054 +#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055 +#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056 +#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057 +#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058 +/* Rage128 M4 */ +/* Radeon R100 */ +#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144 +#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145 +#define PCI_DEVICE_ID_ATI_RADEON_QF 0x5146 +#define PCI_DEVICE_ID_ATI_RADEON_QG 0x5147 +/* Radeon RV100 (VE) */ +#define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 +#define PCI_DEVICE_ID_ATI_RADEON_QZ 0x515a +/* Radeon R200 (8500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QL 0x514c +#define PCI_DEVICE_ID_ATI_RADEON_QN 0x514e +#define PCI_DEVICE_ID_ATI_RADEON_QO 0x514f +#define PCI_DEVICE_ID_ATI_RADEON_Ql 0x516c +#define PCI_DEVICE_ID_ATI_RADEON_BB 0x4242 +/* Radeon R200 (9100) */ +#define PCI_DEVICE_ID_ATI_RADEON_QM 0x514d +/* Radeon RV200 (7500) */ +#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157 +#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158 +/* Radeon NV-100 */ +/* Radeon RV250 (9000) */ +#define PCI_DEVICE_ID_ATI_RADEON_Id 0x4964 +#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965 +#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966 +#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967 +/* Radeon RV280 (9200) */ +#define PCI_DEVICE_ID_ATI_RADEON_Ya 0x5961 +#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964 +/* Radeon R300 (9500) */ +/* Radeon R300 (9700) */ +#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44 +#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45 +#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46 +#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47 +/* Radeon R350 (9800) */ +/* Radeon RV350 (9600) */ +/* Radeon M6 */ +#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59 +#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a +/* Radeon M7 */ +#define PCI_DEVICE_ID_ATI_RADEON_LW 0x4c57 +#define PCI_DEVICE_ID_ATI_RADEON_LX 0x4c58 +/* Radeon M9 */ +#define PCI_DEVICE_ID_ATI_RADEON_Ld 0x4c64 +#define PCI_DEVICE_ID_ATI_RADEON_Le 0x4c65 +#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66 +#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67 +/* Radeon */ +/* RadeonIGP */ +#define PCI_DEVICE_ID_ATI_RS100 0xcab0 +#define PCI_DEVICE_ID_ATI_RS200 0xcab2 +#define PCI_DEVICE_ID_ATI_RS200_B 0xcbb2 +#define PCI_DEVICE_ID_ATI_RS250 0xcab3 +#define PCI_DEVICE_ID_ATI_RS300_100 0x5830 +#define PCI_DEVICE_ID_ATI_RS300_133 0x5831 +#define PCI_DEVICE_ID_ATI_RS300_166 0x5832 +#define PCI_DEVICE_ID_ATI_RS300_200 0x5833 +#define PCI_DEVICE_ID_ATI_RS350_100 0x7830 +#define PCI_DEVICE_ID_ATI_RS350_133 0x7831 +#define PCI_DEVICE_ID_ATI_RS350_166 0x7832 +#define PCI_DEVICE_ID_ATI_RS350_200 0x7833 +#define PCI_DEVICE_ID_ATI_RS400_100 0x5a30 +#define PCI_DEVICE_ID_ATI_RS400_133 0x5a31 +#define PCI_DEVICE_ID_ATI_RS400_166 0x5a32 +#define PCI_DEVICE_ID_ATI_RS400_200 0x5a33 +#define PCI_DEVICE_ID_ATI_RS480 0x5950 +/* ATI IXP Chipset */ +#define PCI_DEVICE_ID_ATI_IXP200_IDE 0x4349 +#define PCI_DEVICE_ID_ATI_IXP300_IDE 0x4369 +#define PCI_DEVICE_ID_ATI_IXP300_SATA 0x436e +#define PCI_DEVICE_ID_ATI_IXP400_IDE 0x4376 +#define PCI_DEVICE_ID_ATI_IXP400_SATA 0x4379 + +#define PCI_VENDOR_ID_VLSI 0x1004 +#define PCI_DEVICE_ID_VLSI_82C592 0x0005 +#define PCI_DEVICE_ID_VLSI_82C593 0x0006 +#define PCI_DEVICE_ID_VLSI_82C594 0x0007 +#define PCI_DEVICE_ID_VLSI_82C597 0x0009 +#define PCI_DEVICE_ID_VLSI_82C541 0x000c +#define PCI_DEVICE_ID_VLSI_82C543 0x000d +#define PCI_DEVICE_ID_VLSI_82C532 0x0101 +#define PCI_DEVICE_ID_VLSI_82C534 0x0102 +#define PCI_DEVICE_ID_VLSI_82C535 0x0104 +#define PCI_DEVICE_ID_VLSI_82C147 0x0105 +#define PCI_DEVICE_ID_VLSI_VAS96011 0x0702 + +#define PCI_VENDOR_ID_ADL 0x1005 +#define PCI_DEVICE_ID_ADL_2301 0x2301 + +#define PCI_VENDOR_ID_NS 0x100b +#define PCI_DEVICE_ID_NS_87415 0x0002 +#define PCI_DEVICE_ID_NS_87560_LIO 0x000e +#define PCI_DEVICE_ID_NS_87560_USB 0x0012 +#define PCI_DEVICE_ID_NS_83815 0x0020 +#define PCI_DEVICE_ID_NS_83820 0x0022 +#define PCI_DEVICE_ID_NS_CS5535_ISA 0x002b +#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d +#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e +#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f +#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 +#define PCI_DEVICE_ID_NS_SATURN 0x0035 +#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 +#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 +#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502 +#define PCI_DEVICE_ID_NS_SCx200_AUDIO 0x0503 +#define PCI_DEVICE_ID_NS_SCx200_VIDEO 0x0504 +#define PCI_DEVICE_ID_NS_SCx200_XBUS 0x0505 +#define PCI_DEVICE_ID_NS_SC1100_BRIDGE 0x0510 +#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511 +#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 +#define PCI_DEVICE_ID_NS_87410 0xd001 + +#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 +#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b + +#define PCI_VENDOR_ID_TSENG 0x100c +#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 +#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205 +#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206 +#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207 +#define PCI_DEVICE_ID_TSENG_ET6000 0x3208 + +#define PCI_VENDOR_ID_WEITEK 0x100e +#define PCI_DEVICE_ID_WEITEK_P9000 0x9001 +#define PCI_DEVICE_ID_WEITEK_P9100 0x9100 + +#define PCI_VENDOR_ID_DEC 0x1011 +#define PCI_DEVICE_ID_DEC_BRD 0x0001 +#define PCI_DEVICE_ID_DEC_TULIP 0x0002 +#define PCI_DEVICE_ID_DEC_TGA 0x0004 +#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009 +#define PCI_DEVICE_ID_DEC_TGA2 0x000D +#define PCI_DEVICE_ID_DEC_FDDI 0x000F +#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014 +#define PCI_DEVICE_ID_DEC_21142 0x0019 +#define PCI_DEVICE_ID_DEC_21052 0x0021 +#define PCI_DEVICE_ID_DEC_21150 0x0022 +#define PCI_DEVICE_ID_DEC_21152 0x0024 +#define PCI_DEVICE_ID_DEC_21153 0x0025 +#define PCI_DEVICE_ID_DEC_21154 0x0026 +#define PCI_DEVICE_ID_DEC_21285 0x1065 +#define PCI_DEVICE_ID_COMPAQ_42XX 0x0046 + +#define PCI_VENDOR_ID_CIRRUS 0x1013 +#define PCI_DEVICE_ID_CIRRUS_7548 0x0038 +#define PCI_DEVICE_ID_CIRRUS_5430 0x00a0 +#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00a4 +#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00a8 +#define PCI_DEVICE_ID_CIRRUS_5436 0x00ac +#define PCI_DEVICE_ID_CIRRUS_5446 0x00b8 +#define PCI_DEVICE_ID_CIRRUS_5480 0x00bc +#define PCI_DEVICE_ID_CIRRUS_5462 0x00d0 +#define PCI_DEVICE_ID_CIRRUS_5464 0x00d4 +#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6 +#define PCI_DEVICE_ID_CIRRUS_6729 0x1100 +#define PCI_DEVICE_ID_CIRRUS_6832 0x1110 +#define PCI_DEVICE_ID_CIRRUS_7543 0x1202 +#define PCI_DEVICE_ID_CIRRUS_4610 0x6001 +#define PCI_DEVICE_ID_CIRRUS_4612 0x6003 +#define PCI_DEVICE_ID_CIRRUS_4615 0x6004 + +#define PCI_VENDOR_ID_IBM 0x1014 +#define PCI_DEVICE_ID_IBM_TR 0x0018 +#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e +#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc +#define PCI_DEVICE_ID_IBM_SNIPE 0x0180 +#define PCI_DEVICE_ID_IBM_CITRINE 0x028C +#define PCI_DEVICE_ID_IBM_GEMSTONE 0xB166 +#define PCI_DEVICE_ID_IBM_OBSIDIAN 0x02BD +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1 0x0031 +#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2 0x0219 +#define PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX 0x021A +#define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251 +#define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252 + +#define PCI_VENDOR_ID_COMPEX2 0x101a /* pci.ids says "AT&T GIS (NCR)" */ +#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005 + +#define PCI_VENDOR_ID_WD 0x101c +#define PCI_DEVICE_ID_WD_90C 0xc24a + +#define PCI_VENDOR_ID_AMI 0x101e +#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960 +#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010 +#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060 + +#define PCI_VENDOR_ID_AMD 0x1022 +#define PCI_DEVICE_ID_AMD_K8_NB 0x1100 +#define PCI_DEVICE_ID_AMD_LANCE 0x2000 +#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001 +#define PCI_DEVICE_ID_AMD_SCSI 0x2020 +#define PCI_DEVICE_ID_AMD_SERENADE 0x36c0 +#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006 +#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007 +#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C +#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E +#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401 +#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409 +#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B +#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410 +#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411 +#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413 +#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440 +#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441 +#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443 +#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443 +#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445 +#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468 +#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469 +#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a +#define PCI_DEVICE_ID_AMD_8111_SMBUS 0x746b +#define PCI_DEVICE_ID_AMD_8111_AUDIO 0x746d +#define PCI_DEVICE_ID_AMD_8151_0 0x7454 +#define PCI_DEVICE_ID_AMD_8131_APIC 0x7450 +#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090 +#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091 +#define PCI_DEVICE_ID_AMD_CS5536_AUDIO 0x2093 +#define PCI_DEVICE_ID_AMD_CS5536_OHC 0x2094 +#define PCI_DEVICE_ID_AMD_CS5536_EHC 0x2095 +#define PCI_DEVICE_ID_AMD_CS5536_UDC 0x2096 +#define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097 +#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A + +#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 +#define PCI_DEVICE_ID_AMD_LX_AES 0x2082 + +#define PCI_VENDOR_ID_TRIDENT 0x1023 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000 +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001 +#define PCI_DEVICE_ID_TRIDENT_9320 0x9320 +#define PCI_DEVICE_ID_TRIDENT_9388 0x9388 +#define PCI_DEVICE_ID_TRIDENT_9397 0x9397 +#define PCI_DEVICE_ID_TRIDENT_939A 0x939A +#define PCI_DEVICE_ID_TRIDENT_9520 0x9520 +#define PCI_DEVICE_ID_TRIDENT_9525 0x9525 +#define PCI_DEVICE_ID_TRIDENT_9420 0x9420 +#define PCI_DEVICE_ID_TRIDENT_9440 0x9440 +#define PCI_DEVICE_ID_TRIDENT_9660 0x9660 +#define PCI_DEVICE_ID_TRIDENT_9750 0x9750 +#define PCI_DEVICE_ID_TRIDENT_9850 0x9850 +#define PCI_DEVICE_ID_TRIDENT_9880 0x9880 +#define PCI_DEVICE_ID_TRIDENT_8400 0x8400 +#define PCI_DEVICE_ID_TRIDENT_8420 0x8420 +#define PCI_DEVICE_ID_TRIDENT_8500 0x8500 + +#define PCI_VENDOR_ID_AI 0x1025 +#define PCI_DEVICE_ID_AI_M1435 0x1435 + +#define PCI_VENDOR_ID_DELL 0x1028 +#define PCI_DEVICE_ID_DELL_RACIII 0x0008 +#define PCI_DEVICE_ID_DELL_RAC4 0x0012 +#define PCI_DEVICE_ID_DELL_PERC5 0x0015 + +#define PCI_VENDOR_ID_MATROX 0x102B +#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518 +#define PCI_DEVICE_ID_MATROX_MIL 0x0519 +#define PCI_DEVICE_ID_MATROX_MYS 0x051A +#define PCI_DEVICE_ID_MATROX_MIL_2 0x051b +#define PCI_DEVICE_ID_MATROX_MYS_AGP 0x051e +#define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f +#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10 +#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000 +#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001 +#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 +#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 +#define PCI_DEVICE_ID_MATROX_G400 0x0525 +#define PCI_DEVICE_ID_MATROX_G550 0x2527 +#define PCI_DEVICE_ID_MATROX_VIA 0x4536 + +#define PCI_VENDOR_ID_CT 0x102c +#define PCI_DEVICE_ID_CT_69000 0x00c0 +#define PCI_DEVICE_ID_CT_65545 0x00d8 +#define PCI_DEVICE_ID_CT_65548 0x00dc +#define PCI_DEVICE_ID_CT_65550 0x00e0 +#define PCI_DEVICE_ID_CT_65554 0x00e4 +#define PCI_DEVICE_ID_CT_65555 0x00e5 + +#define PCI_VENDOR_ID_MIRO 0x1031 +#define PCI_DEVICE_ID_MIRO_36050 0x5601 +#define PCI_DEVICE_ID_MIRO_DC10PLUS 0x7efe +#define PCI_DEVICE_ID_MIRO_DC30PLUS 0xd801 + +#define PCI_VENDOR_ID_NEC 0x1033 +#define PCI_DEVICE_ID_NEC_CBUS_1 0x0001 /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_LOCAL 0x0002 /* Local Bridge */ +#define PCI_DEVICE_ID_NEC_ATM 0x0003 /* ATM LAN Controller */ +#define PCI_DEVICE_ID_NEC_R4000 0x0004 /* R4000 Bridge */ +#define PCI_DEVICE_ID_NEC_486 0x0005 /* 486 Like Peripheral Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_1 0x0006 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_UXBUS 0x0007 /* UX-Bus Bridge */ +#define PCI_DEVICE_ID_NEC_ACCEL_2 0x0008 /* Graphic Accelerator */ +#define PCI_DEVICE_ID_NEC_GRAPH 0x0009 /* PCI-CoreGraph Bridge */ +#define PCI_DEVICE_ID_NEC_VL 0x0016 /* PCI-VL Bridge */ +#define PCI_DEVICE_ID_NEC_STARALPHA2 0x002c /* STAR ALPHA2 */ +#define PCI_DEVICE_ID_NEC_CBUS_2 0x002d /* PCI-Cbus Bridge */ +#define PCI_DEVICE_ID_NEC_USB 0x0035 /* PCI-USB Host */ +#define PCI_DEVICE_ID_NEC_CBUS_3 0x003b +#define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e +#define PCI_DEVICE_ID_NEC_PCX2 0x0046 /* PowerVR */ +#define PCI_DEVICE_ID_NEC_NILE4 0x005a +#define PCI_DEVICE_ID_NEC_VRC5476 0x009b +#define PCI_DEVICE_ID_NEC_VRC4173 0x00a5 +#define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6 +#define PCI_DEVICE_ID_NEC_PC9821CS01 0x800c /* PC-9821-CS01 */ +#define PCI_DEVICE_ID_NEC_PC9821NRB06 0x800d /* PC-9821NR-B06 */ + +#define PCI_VENDOR_ID_FD 0x1036 +#define PCI_DEVICE_ID_FD_36C70 0x0000 + +#define PCI_VENDOR_ID_SI 0x1039 +#define PCI_DEVICE_ID_SI_5591_AGP 0x0001 +#define PCI_DEVICE_ID_SI_6202 0x0002 +#define PCI_DEVICE_ID_SI_503 0x0008 +#define PCI_DEVICE_ID_SI_ACPI 0x0009 +#define PCI_DEVICE_ID_SI_SMBUS 0x0016 +#define PCI_DEVICE_ID_SI_LPC 0x0018 +#define PCI_DEVICE_ID_SI_5597_VGA 0x0200 +#define PCI_DEVICE_ID_SI_6205 0x0205 +#define PCI_DEVICE_ID_SI_501 0x0406 +#define PCI_DEVICE_ID_SI_496 0x0496 +#define PCI_DEVICE_ID_SI_300 0x0300 +#define PCI_DEVICE_ID_SI_315H 0x0310 +#define PCI_DEVICE_ID_SI_315 0x0315 +#define PCI_DEVICE_ID_SI_315PRO 0x0325 +#define PCI_DEVICE_ID_SI_530 0x0530 +#define PCI_DEVICE_ID_SI_540 0x0540 +#define PCI_DEVICE_ID_SI_550 0x0550 +#define PCI_DEVICE_ID_SI_540_VGA 0x5300 +#define PCI_DEVICE_ID_SI_550_VGA 0x5315 +#define PCI_DEVICE_ID_SI_620 0x0620 +#define PCI_DEVICE_ID_SI_630 0x0630 +#define PCI_DEVICE_ID_SI_633 0x0633 +#define PCI_DEVICE_ID_SI_635 0x0635 +#define PCI_DEVICE_ID_SI_640 0x0640 +#define PCI_DEVICE_ID_SI_645 0x0645 +#define PCI_DEVICE_ID_SI_646 0x0646 +#define PCI_DEVICE_ID_SI_648 0x0648 +#define PCI_DEVICE_ID_SI_650 0x0650 +#define PCI_DEVICE_ID_SI_651 0x0651 +#define PCI_DEVICE_ID_SI_655 0x0655 +#define PCI_DEVICE_ID_SI_661 0x0661 +#define PCI_DEVICE_ID_SI_730 0x0730 +#define PCI_DEVICE_ID_SI_733 0x0733 +#define PCI_DEVICE_ID_SI_630_VGA 0x6300 +#define PCI_DEVICE_ID_SI_735 0x0735 +#define PCI_DEVICE_ID_SI_740 0x0740 +#define PCI_DEVICE_ID_SI_741 0x0741 +#define PCI_DEVICE_ID_SI_745 0x0745 +#define PCI_DEVICE_ID_SI_746 0x0746 +#define PCI_DEVICE_ID_SI_755 0x0755 +#define PCI_DEVICE_ID_SI_760 0x0760 +#define PCI_DEVICE_ID_SI_900 0x0900 +#define PCI_DEVICE_ID_SI_961 0x0961 +#define PCI_DEVICE_ID_SI_962 0x0962 +#define PCI_DEVICE_ID_SI_963 0x0963 +#define PCI_DEVICE_ID_SI_965 0x0965 +#define PCI_DEVICE_ID_SI_5511 0x5511 +#define PCI_DEVICE_ID_SI_5513 0x5513 +#define PCI_DEVICE_ID_SI_5518 0x5518 +#define PCI_DEVICE_ID_SI_5571 0x5571 +#define PCI_DEVICE_ID_SI_5581 0x5581 +#define PCI_DEVICE_ID_SI_5582 0x5582 +#define PCI_DEVICE_ID_SI_5591 0x5591 +#define PCI_DEVICE_ID_SI_5596 0x5596 +#define PCI_DEVICE_ID_SI_5597 0x5597 +#define PCI_DEVICE_ID_SI_5598 0x5598 +#define PCI_DEVICE_ID_SI_5600 0x5600 +#define PCI_DEVICE_ID_SI_7012 0x7012 +#define PCI_DEVICE_ID_SI_7013 0x7013 +#define PCI_DEVICE_ID_SI_7016 0x7016 +#define PCI_DEVICE_ID_SI_7018 0x7018 + +#define PCI_VENDOR_ID_HP 0x103c +#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX6 0x1006 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX4 0x1008 +#define PCI_DEVICE_ID_HP_VISUALIZE_FX2 0x100a +#define PCI_DEVICE_ID_HP_TACHYON 0x1028 +#define PCI_DEVICE_ID_HP_TACHLITE 0x1029 +#define PCI_DEVICE_ID_HP_J2585A 0x1030 +#define PCI_DEVICE_ID_HP_J2585B 0x1031 +#define PCI_DEVICE_ID_HP_J2973A 0x1040 +#define PCI_DEVICE_ID_HP_J2970A 0x1042 +#define PCI_DEVICE_ID_HP_DIVA 0x1048 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA1 0x1049 +#define PCI_DEVICE_ID_HP_DIVA_TOSCA2 0x104A +#define PCI_DEVICE_ID_HP_DIVA_MAESTRO 0x104B +#define PCI_DEVICE_ID_HP_REO_IOC 0x10f1 +#define PCI_DEVICE_ID_HP_VISUALIZE_FXE 0x108b +#define PCI_DEVICE_ID_HP_DIVA_HALFDOME 0x1223 +#define PCI_DEVICE_ID_HP_DIVA_KEYSTONE 0x1226 +#define PCI_DEVICE_ID_HP_DIVA_POWERBAR 0x1227 +#define PCI_DEVICE_ID_HP_ZX1_IOC 0x122a +#define PCI_DEVICE_ID_HP_PCIX_LBA 0x122e +#define PCI_DEVICE_ID_HP_SX1000_IOC 0x127c +#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282 +#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 +#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 +#define PCI_DEVICE_ID_HP_DIVA_HURRICANE 0x132a +#define PCI_DEVICE_ID_HP_CISSA 0x3220 +#define PCI_DEVICE_ID_HP_CISSC 0x3230 +#define PCI_DEVICE_ID_HP_CISSD 0x3238 +#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 + +#define PCI_VENDOR_ID_PCTECH 0x1042 +#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000 +#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001 +#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020 + +#define PCI_VENDOR_ID_ASUSTEK 0x1043 +#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675 + +#define PCI_VENDOR_ID_DPT 0x1044 +#define PCI_DEVICE_ID_DPT 0xa400 + +#define PCI_VENDOR_ID_OPTI 0x1045 +#define PCI_DEVICE_ID_OPTI_82C558 0xc558 +#define PCI_DEVICE_ID_OPTI_82C621 0xc621 +#define PCI_DEVICE_ID_OPTI_82C700 0xc700 +#define PCI_DEVICE_ID_OPTI_82C825 0xd568 + +#define PCI_VENDOR_ID_ELSA 0x1048 +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000 +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000 + + +#define PCI_VENDOR_ID_BUSLOGIC 0x104B +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140 +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040 +#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130 + +#define PCI_VENDOR_ID_TI 0x104c +#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 +#define PCI_DEVICE_ID_TI_4450 0x8011 +#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 +#define PCI_DEVICE_ID_TI_X515 0x8036 +#define PCI_DEVICE_ID_TI_1130 0xac12 +#define PCI_DEVICE_ID_TI_1031 0xac13 +#define PCI_DEVICE_ID_TI_1131 0xac15 +#define PCI_DEVICE_ID_TI_1250 0xac16 +#define PCI_DEVICE_ID_TI_1220 0xac17 +#define PCI_DEVICE_ID_TI_1221 0xac19 +#define PCI_DEVICE_ID_TI_1210 0xac1a +#define PCI_DEVICE_ID_TI_1450 0xac1b +#define PCI_DEVICE_ID_TI_1225 0xac1c +#define PCI_DEVICE_ID_TI_1251A 0xac1d +#define PCI_DEVICE_ID_TI_1211 0xac1e +#define PCI_DEVICE_ID_TI_1251B 0xac1f +#define PCI_DEVICE_ID_TI_4410 0xac41 +#define PCI_DEVICE_ID_TI_4451 0xac42 +#define PCI_DEVICE_ID_TI_4510 0xac44 +#define PCI_DEVICE_ID_TI_4520 0xac46 +#define PCI_DEVICE_ID_TI_7510 0xac47 +#define PCI_DEVICE_ID_TI_7610 0xac48 +#define PCI_DEVICE_ID_TI_7410 0xac49 +#define PCI_DEVICE_ID_TI_1410 0xac50 +#define PCI_DEVICE_ID_TI_1420 0xac51 +#define PCI_DEVICE_ID_TI_1451A 0xac52 +#define PCI_DEVICE_ID_TI_1620 0xac54 +#define PCI_DEVICE_ID_TI_1520 0xac55 +#define PCI_DEVICE_ID_TI_1510 0xac56 +#define PCI_DEVICE_ID_TI_X620 0xac8d +#define PCI_DEVICE_ID_TI_X420 0xac8e + +#define PCI_VENDOR_ID_SONY 0x104d + + +/* Winbond have two vendor IDs! See 0x10ad as well */ +#define PCI_VENDOR_ID_WINBOND2 0x1050 +#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a +#define PCI_DEVICE_ID_WINBOND2_6692 0x6692 + +#define PCI_VENDOR_ID_ANIGMA 0x1051 +#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100 + +#define PCI_VENDOR_ID_EFAR 0x1055 +#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130 +#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463 + +#define PCI_VENDOR_ID_MOTOROLA 0x1057 +#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001 +#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 +#define PCI_DEVICE_ID_MOTOROLA_MPC107 0x0004 +#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801 +#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802 +#define PCI_DEVICE_ID_MOTOROLA_HAWK 0x4803 +#define PCI_DEVICE_ID_MOTOROLA_HARRIER 0x480b +#define PCI_DEVICE_ID_MOTOROLA_MPC5200 0x5803 + +#define PCI_VENDOR_ID_PROMISE 0x105a +#define PCI_DEVICE_ID_PROMISE_20265 0x0d30 +#define PCI_DEVICE_ID_PROMISE_20267 0x4d30 +#define PCI_DEVICE_ID_PROMISE_20246 0x4d33 +#define PCI_DEVICE_ID_PROMISE_20262 0x4d38 +#define PCI_DEVICE_ID_PROMISE_20263 0x0D38 +#define PCI_DEVICE_ID_PROMISE_20268 0x4d68 +#define PCI_DEVICE_ID_PROMISE_20269 0x4d69 +#define PCI_DEVICE_ID_PROMISE_20270 0x6268 +#define PCI_DEVICE_ID_PROMISE_20271 0x6269 +#define PCI_DEVICE_ID_PROMISE_20275 0x1275 +#define PCI_DEVICE_ID_PROMISE_20276 0x5275 +#define PCI_DEVICE_ID_PROMISE_20277 0x7275 + + +#define PCI_VENDOR_ID_UMC 0x1060 +#define PCI_DEVICE_ID_UMC_UM8673F 0x0101 +#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a +#define PCI_DEVICE_ID_UMC_UM8886A 0x886a + + +#define PCI_VENDOR_ID_MYLEX 0x1069 +#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001 +#define PCI_DEVICE_ID_MYLEX_DAC960_PD 0x0002 +#define PCI_DEVICE_ID_MYLEX_DAC960_PG 0x0010 +#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020 +#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050 +#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56 +#define PCI_DEVICE_ID_MYLEX_DAC960_GEM 0xB166 + + +#define PCI_VENDOR_ID_APPLE 0x106b +#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001 +#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e +#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 +#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d +#define PCI_DEVICE_ID_APPLE_UNI_N_PCI15 0x002e +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032 +#define PCI_DEVICE_ID_APPLE_UNI_N_ATA 0x0033 +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034 +#define PCI_DEVICE_ID_APPLE_IPID_ATA100 0x003b +#define PCI_DEVICE_ID_APPLE_K2_ATA100 0x0043 +#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b +#define PCI_DEVICE_ID_APPLE_K2_GMAC 0x004c +#define PCI_DEVICE_ID_APPLE_SH_ATA 0x0050 +#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051 +#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058 +#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059 +#define PCI_DEVICE_ID_APPLE_IPID2_AGP 0x0066 +#define PCI_DEVICE_ID_APPLE_IPID2_ATA 0x0069 +#define PCI_DEVICE_ID_APPLE_IPID2_FW 0x006a +#define PCI_DEVICE_ID_APPLE_IPID2_GMAC 0x006b +#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645 + +#define PCI_VENDOR_ID_YAMAHA 0x1073 +#define PCI_DEVICE_ID_YAMAHA_724 0x0004 +#define PCI_DEVICE_ID_YAMAHA_724F 0x000d +#define PCI_DEVICE_ID_YAMAHA_740 0x000a +#define PCI_DEVICE_ID_YAMAHA_740C 0x000c +#define PCI_DEVICE_ID_YAMAHA_744 0x0010 +#define PCI_DEVICE_ID_YAMAHA_754 0x0012 + + +#define PCI_VENDOR_ID_QLOGIC 0x1077 +#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020 +#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100 +#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200 +#define PCI_DEVICE_ID_QLOGIC_ISP2300 0x2300 +#define PCI_DEVICE_ID_QLOGIC_ISP2312 0x2312 +#define PCI_DEVICE_ID_QLOGIC_ISP2322 0x2322 +#define PCI_DEVICE_ID_QLOGIC_ISP6312 0x6312 +#define PCI_DEVICE_ID_QLOGIC_ISP6322 0x6322 +#define PCI_DEVICE_ID_QLOGIC_ISP2422 0x2422 +#define PCI_DEVICE_ID_QLOGIC_ISP2432 0x2432 +#define PCI_DEVICE_ID_QLOGIC_ISP2512 0x2512 +#define PCI_DEVICE_ID_QLOGIC_ISP2522 0x2522 + +#define PCI_VENDOR_ID_CYRIX 0x1078 +#define PCI_DEVICE_ID_CYRIX_5510 0x0000 +#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001 +#define PCI_DEVICE_ID_CYRIX_5520 0x0002 +#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100 +#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102 +#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103 +#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104 + + + +#define PCI_VENDOR_ID_CONTAQ 0x1080 +#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693 + + +#define PCI_VENDOR_ID_OLICOM 0x108d +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012 +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013 +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014 + +#define PCI_VENDOR_ID_SUN 0x108e +#define PCI_DEVICE_ID_SUN_EBUS 0x1000 +#define PCI_DEVICE_ID_SUN_HAPPYMEAL 0x1001 +#define PCI_DEVICE_ID_SUN_RIO_EBUS 0x1100 +#define PCI_DEVICE_ID_SUN_RIO_GEM 0x1101 +#define PCI_DEVICE_ID_SUN_RIO_1394 0x1102 +#define PCI_DEVICE_ID_SUN_RIO_USB 0x1103 +#define PCI_DEVICE_ID_SUN_GEM 0x2bad +#define PCI_DEVICE_ID_SUN_SIMBA 0x5000 +#define PCI_DEVICE_ID_SUN_PBM 0x8000 +#define PCI_DEVICE_ID_SUN_SCHIZO 0x8001 +#define PCI_DEVICE_ID_SUN_SABRE 0xa000 +#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001 +#define PCI_DEVICE_ID_SUN_TOMATILLO 0xa801 +#define PCI_DEVICE_ID_SUN_CASSINI 0xabba + +#define PCI_VENDOR_ID_CMD 0x1095 +#define PCI_DEVICE_ID_CMD_643 0x0643 +#define PCI_DEVICE_ID_CMD_646 0x0646 +#define PCI_DEVICE_ID_CMD_648 0x0648 +#define PCI_DEVICE_ID_CMD_649 0x0649 + +#define PCI_DEVICE_ID_SII_680 0x0680 +#define PCI_DEVICE_ID_SII_3112 0x3112 +#define PCI_DEVICE_ID_SII_1210SA 0x0240 + + +#define PCI_VENDOR_ID_BROOKTREE 0x109e +#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 +#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 + + +#define PCI_VENDOR_ID_SGI 0x10a9 +#define PCI_DEVICE_ID_SGI_IOC3 0x0003 +#define PCI_DEVICE_ID_SGI_IOC4 0x100a +#define PCI_VENDOR_ID_SGI_LITHIUM 0x1002 + + +#define PCI_VENDOR_ID_WINBOND 0x10ad +#define PCI_DEVICE_ID_WINBOND_82C105 0x0105 +#define PCI_DEVICE_ID_WINBOND_83C553 0x0565 + + +#define PCI_VENDOR_ID_PLX 0x10b5 +#define PCI_DEVICE_ID_PLX_R685 0x1030 +#define PCI_DEVICE_ID_PLX_ROMULUS 0x106a +#define PCI_DEVICE_ID_PLX_SPCOM800 0x1076 +#define PCI_DEVICE_ID_PLX_1077 0x1077 +#define PCI_DEVICE_ID_PLX_SPCOM200 0x1103 +#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151 +#define PCI_DEVICE_ID_PLX_R753 0x1152 +#define PCI_DEVICE_ID_PLX_OLITEC 0x1187 +#define PCI_DEVICE_ID_PLX_9050 0x9050 +#define PCI_DEVICE_ID_PLX_9080 0x9080 +#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001 + +#define PCI_VENDOR_ID_MADGE 0x10b6 +#define PCI_DEVICE_ID_MADGE_MK2 0x0002 + +#define PCI_VENDOR_ID_3COM 0x10b7 +#define PCI_DEVICE_ID_3COM_3C985 0x0001 +#define PCI_DEVICE_ID_3COM_3C940 0x1700 +#define PCI_DEVICE_ID_3COM_3C339 0x3390 +#define PCI_DEVICE_ID_3COM_3C359 0x3590 +#define PCI_DEVICE_ID_3COM_3C940B 0x80eb +#define PCI_DEVICE_ID_3COM_3CR990 0x9900 +#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902 +#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903 +#define PCI_DEVICE_ID_3COM_3CR990B 0x9904 +#define PCI_DEVICE_ID_3COM_3CR990_FX 0x9905 +#define PCI_DEVICE_ID_3COM_3CR990SVR95 0x9908 +#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909 +#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a + + +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1533 0x1533 +#define PCI_DEVICE_ID_AL_M1535 0x1535 +#define PCI_DEVICE_ID_AL_M1541 0x1541 +#define PCI_DEVICE_ID_AL_M1563 0x1563 +#define PCI_DEVICE_ID_AL_M1621 0x1621 +#define PCI_DEVICE_ID_AL_M1631 0x1631 +#define PCI_DEVICE_ID_AL_M1632 0x1632 +#define PCI_DEVICE_ID_AL_M1641 0x1641 +#define PCI_DEVICE_ID_AL_M1644 0x1644 +#define PCI_DEVICE_ID_AL_M1647 0x1647 +#define PCI_DEVICE_ID_AL_M1651 0x1651 +#define PCI_DEVICE_ID_AL_M1671 0x1671 +#define PCI_DEVICE_ID_AL_M1681 0x1681 +#define PCI_DEVICE_ID_AL_M1683 0x1683 +#define PCI_DEVICE_ID_AL_M1689 0x1689 +#define PCI_DEVICE_ID_AL_M5219 0x5219 +#define PCI_DEVICE_ID_AL_M5228 0x5228 +#define PCI_DEVICE_ID_AL_M5229 0x5229 +#define PCI_DEVICE_ID_AL_M5451 0x5451 +#define PCI_DEVICE_ID_AL_M7101 0x7101 + + + +#define PCI_VENDOR_ID_NEOMAGIC 0x10c8 +#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 +#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 +#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 + + +#define PCI_VENDOR_ID_TCONRAD 0x10da +#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508 + + +#define PCI_VENDOR_ID_NVIDIA 0x10de +#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020 +#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028 +#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029 +#define PCI_DEVICE_ID_NVIDIA_TNT_UNKNOWN 0x002a +#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C +#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS 0x0034 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE 0x0035 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA 0x0036 +#define PCI_DEVICE_ID_NVIDIA_NVENET_10 0x0037 +#define PCI_DEVICE_ID_NVIDIA_NVENET_11 0x0038 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2 0x003e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_ULTRA 0x0040 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800 0x0041 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_LE 0x0042 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x0045 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_4000 0x004E +#define PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS 0x0052 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE 0x0053 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA 0x0054 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2 0x0055 +#define PCI_DEVICE_ID_NVIDIA_NVENET_8 0x0056 +#define PCI_DEVICE_ID_NVIDIA_NVENET_9 0x0057 +#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065 +#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066 +#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069 +#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085 +#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086 +#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089 +#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a +#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c +#define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GT 0x0090 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_7800_GTX 0x0091 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800 0x0098 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_7800_GTX 0x0099 +#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 +#define PCI_DEVICE_ID_GEFORCE_6800A 0x00c1 +#define PCI_DEVICE_ID_GEFORCE_6800A_LE 0x00c2 +#define PCI_DEVICE_ID_GEFORCE_GO_6800 0x00c8 +#define PCI_DEVICE_ID_GEFORCE_GO_6800_ULTRA 0x00c9 +#define PCI_DEVICE_ID_QUADRO_FX_GO1400 0x00cc +#define PCI_DEVICE_ID_QUADRO_FX_1400 0x00ce +#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 +#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9 +#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da +#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA 0x00e3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 +#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_ALT1 0x00f0 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT1 0x00f1 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6600_ALT2 0x00f2 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6200_ALT1 0x00f3 +#define PCIE_DEVICE_ID_NVIDIA_GEFORCE_6800_GT 0x00f9 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101 +#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO 0x0112 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600_GT 0x0140 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6600 0x0141 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6610_XL 0x0145 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_540 0x014E +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200 0x014F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152 +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6200_TURBOCACHE 0x0161 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200 0x0164 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250 0x0166 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6200_1 0x0167 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_GO_6250_1 0x0168 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460 0x0170 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440 0x0171 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420 0x0172 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_SE 0x0173 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO 0x0174 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO 0x0175 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32 0x0176 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_460_GO 0x0177 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL 0x0178 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64 0x0179 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_200 0x017A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL 0x017B +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL 0x017C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_410_GO_M16 0x017D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440_8X 0x0181 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440SE_8X 0x0182 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420_8X 0x0183 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_4000 0x0185 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_448_GO 0x0186 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_488_GO 0x0187 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_580_XGL 0x0188 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_MAC 0x0189 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_280_NVS 0x018A +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_380_XGL 0x018B +#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0 +#define PCI_DEVICE_ID_NVIDIA_NFORCE 0x01a4 +#define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc +#define PCI_DEVICE_ID_NVIDIA_MCP1_MODEM 0x01c1 +#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2 0x0202 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC 0x0203 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B 0x0211 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_LE 0x0212 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_6800B_GT 0x0215 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600 0x0250 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400 0x0251 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200 0x0253 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE 0x0265 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE 0x036E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA 0x037E +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2 0x037F +#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268 +#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO 0x0286 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_980_XGL 0x0288 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_780_XGL 0x0289 +#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700_GOGL 0x028C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_ULTRA 0x0301 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800 0x0302 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_2000 0x0308 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1000 0x0309 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_ULTRA 0x0311 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600 0x0312 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600SE 0x0314 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5600 0x031A +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5650 0x031B +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO700 0x031C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200 0x0320 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_ULTRA 0x0321 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_1 0x0322 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200SE 0x0323 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5200 0x0324 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250 0x0325 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5500 0x0326 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5100 0x0327 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5250_32 0x0328 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200 0x0329 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_NVS_280_PCI 0x032A +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_500 0x032B +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5300 0x032C +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5100 0x032D +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900_ULTRA 0x0330 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900 0x0331 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900XT 0x0332 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5950_ULTRA 0x0333 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5900ZT 0x0334 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_3000 0x0338 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_700 0x033F +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700_ULTRA 0x0341 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700 0x0342 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700LE 0x0343 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5700VE 0x0344 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_1 0x0347 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_2 0x0348 +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO1000 0x034C +#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E +#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372 +#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 + +#define PCI_VENDOR_ID_IMS 0x10e0 +#define PCI_DEVICE_ID_IMS_TT128 0x9128 +#define PCI_DEVICE_ID_IMS_TT3D 0x9135 + + + + +#define PCI_VENDOR_ID_INTERG 0x10ea +#define PCI_DEVICE_ID_INTERG_1682 0x1682 +#define PCI_DEVICE_ID_INTERG_2000 0x2000 +#define PCI_DEVICE_ID_INTERG_2010 0x2010 +#define PCI_DEVICE_ID_INTERG_5000 0x5000 +#define PCI_DEVICE_ID_INTERG_5050 0x5050 + +#define PCI_VENDOR_ID_REALTEK 0x10ec +#define PCI_DEVICE_ID_REALTEK_8139 0x8139 + +#define PCI_VENDOR_ID_XILINX 0x10ee +#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0 +#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1 +#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2 +#define PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST 0x3fc3 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 + + +#define PCI_VENDOR_ID_INIT 0x1101 + +#define PCI_VENDOR_ID_CREATIVE 0x1102 /* duplicate: ECTIVA */ +#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002 + +#define PCI_VENDOR_ID_ECTIVA 0x1102 /* duplicate: CREATIVE */ +#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938 + +#define PCI_VENDOR_ID_TTI 0x1103 +#define PCI_DEVICE_ID_TTI_HPT343 0x0003 +#define PCI_DEVICE_ID_TTI_HPT366 0x0004 +#define PCI_DEVICE_ID_TTI_HPT372 0x0005 +#define PCI_DEVICE_ID_TTI_HPT302 0x0006 +#define PCI_DEVICE_ID_TTI_HPT371 0x0007 +#define PCI_DEVICE_ID_TTI_HPT374 0x0008 +#define PCI_DEVICE_ID_TTI_HPT372N 0x0009 /* apparently a 372N variant? */ + +#define PCI_VENDOR_ID_VIA 0x1106 +#define PCI_DEVICE_ID_VIA_8763_0 0x0198 +#define PCI_DEVICE_ID_VIA_8380_0 0x0204 +#define PCI_DEVICE_ID_VIA_3238_0 0x0238 +#define PCI_DEVICE_ID_VIA_PT880 0x0258 +#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 +#define PCI_DEVICE_ID_VIA_3269_0 0x0269 +#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 +#define PCI_DEVICE_ID_VIA_8363_0 0x0305 +#define PCI_DEVICE_ID_VIA_P4M800CE 0x0314 +#define PCI_DEVICE_ID_VIA_8371_0 0x0391 +#define PCI_DEVICE_ID_VIA_8501_0 0x0501 +#define PCI_DEVICE_ID_VIA_82C561 0x0561 +#define PCI_DEVICE_ID_VIA_82C586_1 0x0571 +#define PCI_DEVICE_ID_VIA_82C576 0x0576 +#define PCI_DEVICE_ID_VIA_82C586_0 0x0586 +#define PCI_DEVICE_ID_VIA_82C596 0x0596 +#define PCI_DEVICE_ID_VIA_82C597_0 0x0597 +#define PCI_DEVICE_ID_VIA_82C598_0 0x0598 +#define PCI_DEVICE_ID_VIA_8601_0 0x0601 +#define PCI_DEVICE_ID_VIA_8605_0 0x0605 +#define PCI_DEVICE_ID_VIA_82C686 0x0686 +#define PCI_DEVICE_ID_VIA_82C691_0 0x0691 +#define PCI_DEVICE_ID_VIA_82C576_1 0x1571 +#define PCI_DEVICE_ID_VIA_82C586_2 0x3038 +#define PCI_DEVICE_ID_VIA_82C586_3 0x3040 +#define PCI_DEVICE_ID_VIA_82C596_3 0x3050 +#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051 +#define PCI_DEVICE_ID_VIA_82C686_4 0x3057 +#define PCI_DEVICE_ID_VIA_82C686_5 0x3058 +#define PCI_DEVICE_ID_VIA_8233_5 0x3059 +#define PCI_DEVICE_ID_VIA_8233_0 0x3074 +#define PCI_DEVICE_ID_VIA_8633_0 0x3091 +#define PCI_DEVICE_ID_VIA_8367_0 0x3099 +#define PCI_DEVICE_ID_VIA_8653_0 0x3101 +#define PCI_DEVICE_ID_VIA_8622 0x3102 +#define PCI_DEVICE_ID_VIA_8233C_0 0x3109 +#define PCI_DEVICE_ID_VIA_8361 0x3112 +#define PCI_DEVICE_ID_VIA_XM266 0x3116 +#define PCI_DEVICE_ID_VIA_612X 0x3119 +#define PCI_DEVICE_ID_VIA_862X_0 0x3123 +#define PCI_DEVICE_ID_VIA_8753_0 0x3128 +#define PCI_DEVICE_ID_VIA_8233A 0x3147 +#define PCI_DEVICE_ID_VIA_8703_51_0 0x3148 +#define PCI_DEVICE_ID_VIA_8237_SATA 0x3149 +#define PCI_DEVICE_ID_VIA_XN266 0x3156 +#define PCI_DEVICE_ID_VIA_6410 0x3164 +#define PCI_DEVICE_ID_VIA_8754C_0 0x3168 +#define PCI_DEVICE_ID_VIA_8235 0x3177 +#define PCI_DEVICE_ID_VIA_8385_0 0x3188 +#define PCI_DEVICE_ID_VIA_8377_0 0x3189 +#define PCI_DEVICE_ID_VIA_8378_0 0x3205 +#define PCI_DEVICE_ID_VIA_8783_0 0x3208 +#define PCI_DEVICE_ID_VIA_8237 0x3227 +#define PCI_DEVICE_ID_VIA_8251 0x3287 +#define PCI_DEVICE_ID_VIA_3296_0 0x0296 +#define PCI_DEVICE_ID_VIA_8231 0x8231 +#define PCI_DEVICE_ID_VIA_8231_4 0x8235 +#define PCI_DEVICE_ID_VIA_8365_1 0x8305 +#define PCI_DEVICE_ID_VIA_8371_1 0x8391 +#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 +#define PCI_DEVICE_ID_VIA_838X_1 0xB188 +#define PCI_DEVICE_ID_VIA_83_87XX_1 0xB198 + +#define PCI_VENDOR_ID_SIEMENS 0x110A +#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102 + + +#define PCI_VENDOR_ID_VORTEX 0x1119 +#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000 +#define PCI_DEVICE_ID_VORTEX_GDT6000B 0x0001 +#define PCI_DEVICE_ID_VORTEX_GDT6x10 0x0002 +#define PCI_DEVICE_ID_VORTEX_GDT6x20 0x0003 +#define PCI_DEVICE_ID_VORTEX_GDT6530 0x0004 +#define PCI_DEVICE_ID_VORTEX_GDT6550 0x0005 +#define PCI_DEVICE_ID_VORTEX_GDT6x17 0x0006 +#define PCI_DEVICE_ID_VORTEX_GDT6x27 0x0007 +#define PCI_DEVICE_ID_VORTEX_GDT6537 0x0008 +#define PCI_DEVICE_ID_VORTEX_GDT6557 0x0009 +#define PCI_DEVICE_ID_VORTEX_GDT6x15 0x000a +#define PCI_DEVICE_ID_VORTEX_GDT6x25 0x000b +#define PCI_DEVICE_ID_VORTEX_GDT6535 0x000c +#define PCI_DEVICE_ID_VORTEX_GDT6555 0x000d +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x0100 +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x0101 +#define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x0102 +#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103 +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104 +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105 + +#define PCI_VENDOR_ID_EF 0x111a +#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000 +#define PCI_DEVICE_ID_EF_ATM_ASIC 0x0002 +#define PCI_VENDOR_ID_EF_ATM_LANAI2 0x0003 +#define PCI_VENDOR_ID_EF_ATM_LANAIHB 0x0005 + +#define PCI_VENDOR_ID_IDT 0x111d +#define PCI_DEVICE_ID_IDT_IDT77201 0x0001 + +#define PCI_VENDOR_ID_FORE 0x1127 +#define PCI_DEVICE_ID_FORE_PCA200E 0x0300 + + +#define PCI_VENDOR_ID_PHILIPS 0x1131 +#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146 +#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730 + +#define PCI_VENDOR_ID_EICON 0x1133 +#define PCI_DEVICE_ID_EICON_DIVA20 0xe002 +#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004 +#define PCI_DEVICE_ID_EICON_DIVA201 0xe005 +#define PCI_DEVICE_ID_EICON_DIVA202 0xe00b +#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010 +#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012 +#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013 +#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014 + +#define PCI_VENDOR_ID_ZIATECH 0x1138 +#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550 + + + +#define PCI_VENDOR_ID_SYSKONNECT 0x1148 +#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200 +#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300 +#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320 +#define PCI_DEVICE_ID_SYSKONNECT_9DXX 0x4400 +#define PCI_DEVICE_ID_SYSKONNECT_9MXX 0x4500 + + +#define PCI_VENDOR_ID_DIGI 0x114f +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070 +#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071 +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072 +#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073 +#define PCI_DEVICE_ID_NEO_2DB9 0x00C8 +#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 +#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA +#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB + + +#define PCI_VENDOR_ID_XIRCOM 0x115d +#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 +#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103 + + +#define PCI_VENDOR_ID_SERVERWORKS 0x1166 +#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008 +#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009 +#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017 +#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 +#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211 +#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 +#define PCI_DEVICE_ID_SERVERWORKS_HT1000IDE 0x0214 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217 +#define PCI_DEVICE_ID_SERVERWORKS_CSB6LPC 0x0227 + +#define PCI_VENDOR_ID_SBE 0x1176 +#define PCI_DEVICE_ID_SBE_WANXL100 0x0301 +#define PCI_DEVICE_ID_SBE_WANXL200 0x0302 +#define PCI_DEVICE_ID_SBE_WANXL400 0x0104 + +#define PCI_VENDOR_ID_TOSHIBA 0x1179 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103 +#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a +#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f +#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617 + +#define PCI_VENDOR_ID_TOSHIBA_2 0x102f +#define PCI_DEVICE_ID_TOSHIBA_TC35815CF 0x0030 +#define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC 0x0108 +#define PCI_DEVICE_ID_TOSHIBA_SPIDER_NET 0x01b3 + +#define PCI_VENDOR_ID_RICOH 0x1180 +#define PCI_DEVICE_ID_RICOH_RL5C465 0x0465 +#define PCI_DEVICE_ID_RICOH_RL5C466 0x0466 +#define PCI_DEVICE_ID_RICOH_RL5C475 0x0475 +#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476 +#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478 + +#define PCI_VENDOR_ID_DLINK 0x1186 +#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00 + +#define PCI_VENDOR_ID_ARTOP 0x1191 +#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005 +#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006 +#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007 +#define PCI_DEVICE_ID_ARTOP_ATP865 0x0008 +#define PCI_DEVICE_ID_ARTOP_ATP865R 0x0009 +#define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002 +#define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010 +#define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020 +#define PCI_DEVICE_ID_ARTOP_AEC7612S 0x8030 +#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040 +#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050 +#define PCI_DEVICE_ID_ARTOP_8060 0x8060 + +#define PCI_VENDOR_ID_ZEITNET 0x1193 +#define PCI_DEVICE_ID_ZEITNET_1221 0x0001 +#define PCI_DEVICE_ID_ZEITNET_1225 0x0002 + + +#define PCI_VENDOR_ID_FUJITSU_ME 0x119e +#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001 +#define PCI_DEVICE_ID_FUJITSU_FS50 0x0003 + +#define PCI_SUBVENDOR_ID_KEYSPAN 0x11a9 +#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334 + +#define PCI_VENDOR_ID_MARVELL 0x11ab +#define PCI_DEVICE_ID_MARVELL_GT64111 0x4146 +#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 +#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 +#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480 +#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652 +#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653 + + +#define PCI_VENDOR_ID_V3 0x11b0 +#define PCI_DEVICE_ID_V3_V960 0x0001 +#define PCI_DEVICE_ID_V3_V351 0x0002 + + +#define PCI_VENDOR_ID_ATT 0x11c1 +#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480 + + +#define PCI_VENDOR_ID_SPECIALIX 0x11cb +#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000 +#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000 +#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004 + + +#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4 +#define PCI_DEVICE_ID_AD1889JS 0x1889 + + +#define PCI_DEVICE_ID_SEGA_BBA 0x1234 + +#define PCI_VENDOR_ID_ZORAN 0x11de +#define PCI_DEVICE_ID_ZORAN_36057 0x6057 +#define PCI_DEVICE_ID_ZORAN_36120 0x6120 + + +#define PCI_VENDOR_ID_COMPEX 0x11f6 +#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112 + +#define PCI_VENDOR_ID_RP 0x11fe +#define PCI_DEVICE_ID_RP32INTF 0x0001 +#define PCI_DEVICE_ID_RP8INTF 0x0002 +#define PCI_DEVICE_ID_RP16INTF 0x0003 +#define PCI_DEVICE_ID_RP4QUAD 0x0004 +#define PCI_DEVICE_ID_RP8OCTA 0x0005 +#define PCI_DEVICE_ID_RP8J 0x0006 +#define PCI_DEVICE_ID_RP4J 0x0007 +#define PCI_DEVICE_ID_RP8SNI 0x0008 +#define PCI_DEVICE_ID_RP16SNI 0x0009 +#define PCI_DEVICE_ID_RPP4 0x000A +#define PCI_DEVICE_ID_RPP8 0x000B +#define PCI_DEVICE_ID_RP4M 0x000D +#define PCI_DEVICE_ID_RP2_232 0x000E +#define PCI_DEVICE_ID_RP2_422 0x000F +#define PCI_DEVICE_ID_URP32INTF 0x0801 +#define PCI_DEVICE_ID_URP8INTF 0x0802 +#define PCI_DEVICE_ID_URP16INTF 0x0803 +#define PCI_DEVICE_ID_URP8OCTA 0x0805 +#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C +#define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D +#define PCI_DEVICE_ID_CRP16INTF 0x0903 + +#define PCI_VENDOR_ID_CYCLADES 0x120e +#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100 +#define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101 +#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102 +#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103 +#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104 +#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105 +#define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200 +#define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201 +#define PCI_DEVICE_ID_PC300_RX_2 0x0300 +#define PCI_DEVICE_ID_PC300_RX_1 0x0301 +#define PCI_DEVICE_ID_PC300_TE_2 0x0310 +#define PCI_DEVICE_ID_PC300_TE_1 0x0311 +#define PCI_DEVICE_ID_PC300_TE_M_2 0x0320 +#define PCI_DEVICE_ID_PC300_TE_M_1 0x0321 + +#define PCI_VENDOR_ID_ESSENTIAL 0x120f +#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001 + +#define PCI_VENDOR_ID_O2 0x1217 +#define PCI_DEVICE_ID_O2_6729 0x6729 +#define PCI_DEVICE_ID_O2_6730 0x673a +#define PCI_DEVICE_ID_O2_6832 0x6832 +#define PCI_DEVICE_ID_O2_6836 0x6836 + +#define PCI_VENDOR_ID_3DFX 0x121a +#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001 +#define PCI_DEVICE_ID_3DFX_VOODOO2 0x0002 +#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003 +#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005 +#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009 + + + +#define PCI_VENDOR_ID_AVM 0x1244 +#define PCI_DEVICE_ID_AVM_B1 0x0700 +#define PCI_DEVICE_ID_AVM_C4 0x0800 +#define PCI_DEVICE_ID_AVM_A1 0x0a00 +#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00 +#define PCI_DEVICE_ID_AVM_C2 0x1100 +#define PCI_DEVICE_ID_AVM_T1 0x1200 + + +#define PCI_VENDOR_ID_STALLION 0x124d + +/* Allied Telesyn */ +#define PCI_VENDOR_ID_AT 0x1259 +#define PCI_SUBDEVICE_ID_AT_2700FX 0x2701 +#define PCI_SUBDEVICE_ID_AT_2701FX 0x2703 + +#define PCI_VENDOR_ID_ESS 0x125d +#define PCI_DEVICE_ID_ESS_ESS1968 0x1968 +#define PCI_DEVICE_ID_ESS_ESS1978 0x1978 +#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988 +#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989 +#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990 +#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992 +#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998 +#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999 +#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a +#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b + +#define PCI_VENDOR_ID_SATSAGEM 0x1267 +#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 + + +#define PCI_VENDOR_ID_ENSONIQ 0x1274 +#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 +#define PCI_DEVICE_ID_ENSONIQ_ES1370 0x5000 +#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371 + +#define PCI_VENDOR_ID_TRANSMETA 0x1279 +#define PCI_DEVICE_ID_EFFICEON 0x0060 + +#define PCI_VENDOR_ID_ROCKWELL 0x127A + +#define PCI_VENDOR_ID_ITE 0x1283 +#define PCI_DEVICE_ID_ITE_IT8172G 0x8172 +#define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801 +#define PCI_DEVICE_ID_ITE_8211 0x8211 +#define PCI_DEVICE_ID_ITE_8212 0x8212 +#define PCI_DEVICE_ID_ITE_8872 0x8872 +#define PCI_DEVICE_ID_ITE_IT8330G_0 0xe886 + +/* formerly Platform Tech */ +#define PCI_DEVICE_ID_ESS_ESS0100 0x0100 + +#define PCI_VENDOR_ID_ALTEON 0x12ae + + +#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232 0x0003 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485 0x0004 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4 0x0005 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485 0x0006 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2 0x0007 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485 0x0008 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6 0x0009 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_20MHZ 0x000C +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_PTM 0x000D +#define PCI_SUBDEVICE_ID_CONNECT_TECH_NT960PCI 0x0100 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_2 0x0201 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_4 0x0202 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_232 0x0300 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_232 0x0301 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_232 0x0302 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1 0x0310 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2 0x0311 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4 0x0312 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2 0x0320 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4 0x0321 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8 0x0322 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_485 0x0330 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_485 0x0331 +#define PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_485 0x0332 + + +#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2 +#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018 + +#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16 0x0011 +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC 0x0041 +#define PCI_SUBVENDOR_ID_CHASE_PCIRAS 0x124D +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS4 0xF001 +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS8 0xF010 + +#define PCI_VENDOR_ID_AUREAL 0x12eb +#define PCI_DEVICE_ID_AUREAL_VORTEX_1 0x0001 +#define PCI_DEVICE_ID_AUREAL_VORTEX_2 0x0002 +#define PCI_DEVICE_ID_AUREAL_ADVANTAGE 0x0003 + +#define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8 +#define PCI_DEVICE_ID_LML_33R10 0x8a02 + + +#define PCI_VENDOR_ID_SIIG 0x131f +#define PCI_SUBVENDOR_ID_SIIG 0x131f +#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000 +#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001 +#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_550 0x1010 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_650 0x1011 +#define PCI_DEVICE_ID_SIIG_1S1P_10x_850 0x1012 +#define PCI_DEVICE_ID_SIIG_1P_10x 0x1020 +#define PCI_DEVICE_ID_SIIG_2P_10x 0x1021 +#define PCI_DEVICE_ID_SIIG_2S_10x_550 0x1030 +#define PCI_DEVICE_ID_SIIG_2S_10x_650 0x1031 +#define PCI_DEVICE_ID_SIIG_2S_10x_850 0x1032 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_550 0x1034 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_650 0x1035 +#define PCI_DEVICE_ID_SIIG_2S1P_10x_850 0x1036 +#define PCI_DEVICE_ID_SIIG_4S_10x_550 0x1050 +#define PCI_DEVICE_ID_SIIG_4S_10x_650 0x1051 +#define PCI_DEVICE_ID_SIIG_4S_10x_850 0x1052 +#define PCI_DEVICE_ID_SIIG_1S_20x_550 0x2000 +#define PCI_DEVICE_ID_SIIG_1S_20x_650 0x2001 +#define PCI_DEVICE_ID_SIIG_1S_20x_850 0x2002 +#define PCI_DEVICE_ID_SIIG_1P_20x 0x2020 +#define PCI_DEVICE_ID_SIIG_2P_20x 0x2021 +#define PCI_DEVICE_ID_SIIG_2S_20x_550 0x2030 +#define PCI_DEVICE_ID_SIIG_2S_20x_650 0x2031 +#define PCI_DEVICE_ID_SIIG_2S_20x_850 0x2032 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_550 0x2040 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_650 0x2041 +#define PCI_DEVICE_ID_SIIG_2P1S_20x_850 0x2042 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_550 0x2010 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_650 0x2011 +#define PCI_DEVICE_ID_SIIG_1S1P_20x_850 0x2012 +#define PCI_DEVICE_ID_SIIG_4S_20x_550 0x2050 +#define PCI_DEVICE_ID_SIIG_4S_20x_650 0x2051 +#define PCI_DEVICE_ID_SIIG_4S_20x_850 0x2052 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061 +#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062 +#define PCI_DEVICE_ID_SIIG_8S_20x_550 0x2080 +#define PCI_DEVICE_ID_SIIG_8S_20x_650 0x2081 +#define PCI_DEVICE_ID_SIIG_8S_20x_850 0x2082 +#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050 + +#define PCI_VENDOR_ID_RADISYS 0x1331 + +#define PCI_VENDOR_ID_DOMEX 0x134a +#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001 + +#define PCI_VENDOR_ID_QUATECH 0x135C +#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010 +#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020 +#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050 +#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060 + +#define PCI_VENDOR_ID_SEALEVEL 0x135e +#define PCI_DEVICE_ID_SEALEVEL_U530 0x7101 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM2 0x7201 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM422 0x7402 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM232 0x7202 +#define PCI_DEVICE_ID_SEALEVEL_COMM4 0x7401 +#define PCI_DEVICE_ID_SEALEVEL_COMM8 0x7801 +#define PCI_DEVICE_ID_SEALEVEL_UCOMM8 0x7804 + +#define PCI_VENDOR_ID_HYPERCOPE 0x1365 +#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050 +#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104 +#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106 +#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107 +#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108 + +#define PCI_VENDOR_ID_KAWASAKI 0x136b +#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01 + +#define PCI_VENDOR_ID_CNET 0x1371 +#define PCI_DEVICE_ID_CNET_GIGACARD 0x434e + +#define PCI_VENDOR_ID_LMC 0x1376 +#define PCI_DEVICE_ID_LMC_HSSI 0x0003 +#define PCI_DEVICE_ID_LMC_DS3 0x0004 +#define PCI_DEVICE_ID_LMC_SSI 0x0005 +#define PCI_DEVICE_ID_LMC_T1 0x0006 + + +#define PCI_VENDOR_ID_NETGEAR 0x1385 +#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a + +#define PCI_VENDOR_ID_APPLICOM 0x1389 +#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001 +#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002 +#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 + +#define PCI_VENDOR_ID_MOXA 0x1393 +#define PCI_DEVICE_ID_MOXA_RC7000 0x0001 +#define PCI_DEVICE_ID_MOXA_CP102 0x1020 +#define PCI_DEVICE_ID_MOXA_CP102UL 0x1021 +#define PCI_DEVICE_ID_MOXA_CP102U 0x1022 +#define PCI_DEVICE_ID_MOXA_C104 0x1040 +#define PCI_DEVICE_ID_MOXA_CP104U 0x1041 +#define PCI_DEVICE_ID_MOXA_CP104JU 0x1042 +#define PCI_DEVICE_ID_MOXA_CT114 0x1140 +#define PCI_DEVICE_ID_MOXA_CP114 0x1141 +#define PCI_DEVICE_ID_MOXA_CP118U 0x1180 +#define PCI_DEVICE_ID_MOXA_CP132 0x1320 +#define PCI_DEVICE_ID_MOXA_CP132U 0x1321 +#define PCI_DEVICE_ID_MOXA_CP134U 0x1340 +#define PCI_DEVICE_ID_MOXA_C168 0x1680 +#define PCI_DEVICE_ID_MOXA_CP168U 0x1681 + +#define PCI_VENDOR_ID_CCD 0x1397 +#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0 +#define PCI_DEVICE_ID_CCD_B000 0xb000 +#define PCI_DEVICE_ID_CCD_B006 0xb006 +#define PCI_DEVICE_ID_CCD_B007 0xb007 +#define PCI_DEVICE_ID_CCD_B008 0xb008 +#define PCI_DEVICE_ID_CCD_B009 0xb009 +#define PCI_DEVICE_ID_CCD_B00A 0xb00a +#define PCI_DEVICE_ID_CCD_B00B 0xb00b +#define PCI_DEVICE_ID_CCD_B00C 0xb00c +#define PCI_DEVICE_ID_CCD_B100 0xb100 +#define PCI_DEVICE_ID_CCD_B700 0xb700 +#define PCI_DEVICE_ID_CCD_B701 0xb701 + +#define PCI_VENDOR_ID_EXAR 0x13a8 +#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152 +#define PCI_DEVICE_ID_EXAR_XR17C154 0x0154 +#define PCI_DEVICE_ID_EXAR_XR17C158 0x0158 + +#define PCI_VENDOR_ID_MICROGATE 0x13c0 +#define PCI_DEVICE_ID_MICROGATE_USC 0x0010 +#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030 + +#define PCI_VENDOR_ID_3WARE 0x13C1 +#define PCI_DEVICE_ID_3WARE_1000 0x1000 +#define PCI_DEVICE_ID_3WARE_7000 0x1001 +#define PCI_DEVICE_ID_3WARE_9000 0x1002 + +#define PCI_VENDOR_ID_IOMEGA 0x13ca +#define PCI_DEVICE_ID_IOMEGA_BUZ 0x4231 + +#define PCI_VENDOR_ID_ABOCOM 0x13D1 +#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1 + +#define PCI_VENDOR_ID_CMEDIA 0x13f6 +#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100 +#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101 +#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111 +#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112 + +#define PCI_VENDOR_ID_LAVA 0x1407 +#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */ +#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102 /* 2x 16550, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_A 0x0180 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_OCTO_B 0x0181 /* 4x 16550A, half of 8 port */ +#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200 /* 2x 16650 */ +#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202 /* 2x 16650, half of 4 port */ +#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500 /* 1x 16550 */ +#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600 /* 1x 16650 */ +#define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000 +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002 /* The Lava Dual Parallel is */ +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003 /* two PCI devices on a card */ +#define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800 + +#define PCI_VENDOR_ID_TIMEDIA 0x1409 +#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168 + +#define PCI_VENDOR_ID_ICE 0x1412 +#define PCI_DEVICE_ID_ICE_1712 0x1712 +#define PCI_DEVICE_ID_VT1724 0x1724 + +#define PCI_VENDOR_ID_OXSEMI 0x1415 +#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403 +#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501 +#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511 +#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513 +#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521 + +#define PCI_VENDOR_ID_SAMSUNG 0x144d + + +#define PCI_VENDOR_ID_TITAN 0x14D2 +#define PCI_DEVICE_ID_TITAN_010L 0x8001 +#define PCI_DEVICE_ID_TITAN_100L 0x8010 +#define PCI_DEVICE_ID_TITAN_110L 0x8011 +#define PCI_DEVICE_ID_TITAN_200L 0x8020 +#define PCI_DEVICE_ID_TITAN_210L 0x8021 +#define PCI_DEVICE_ID_TITAN_400L 0x8040 +#define PCI_DEVICE_ID_TITAN_800L 0x8080 +#define PCI_DEVICE_ID_TITAN_100 0xA001 +#define PCI_DEVICE_ID_TITAN_200 0xA005 +#define PCI_DEVICE_ID_TITAN_400 0xA003 +#define PCI_DEVICE_ID_TITAN_800B 0xA004 + +#define PCI_VENDOR_ID_PANACOM 0x14d4 +#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400 +#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402 + + +#define PCI_VENDOR_ID_AFAVLAB 0x14db +#define PCI_DEVICE_ID_AFAVLAB_P028 0x2180 +#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 +#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150 + +#define PCI_VENDOR_ID_BROADCOM 0x14e4 +#define PCI_DEVICE_ID_TIGON3_5752 0x1600 +#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 +#define PCI_DEVICE_ID_TIGON3_5700 0x1644 +#define PCI_DEVICE_ID_TIGON3_5701 0x1645 +#define PCI_DEVICE_ID_TIGON3_5702 0x1646 +#define PCI_DEVICE_ID_TIGON3_5703 0x1647 +#define PCI_DEVICE_ID_TIGON3_5704 0x1648 +#define PCI_DEVICE_ID_TIGON3_5704S_2 0x1649 +#define PCI_DEVICE_ID_NX2_5706 0x164a +#define PCI_DEVICE_ID_NX2_5708 0x164c +#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d +#define PCI_DEVICE_ID_TIGON3_5705 0x1653 +#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 +#define PCI_DEVICE_ID_TIGON3_5720 0x1658 +#define PCI_DEVICE_ID_TIGON3_5721 0x1659 +#define PCI_DEVICE_ID_TIGON3_5705M 0x165d +#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e +#define PCI_DEVICE_ID_TIGON3_5714 0x1668 +#define PCI_DEVICE_ID_TIGON3_5714S 0x1669 +#define PCI_DEVICE_ID_TIGON3_5780 0x166a +#define PCI_DEVICE_ID_TIGON3_5780S 0x166b +#define PCI_DEVICE_ID_TIGON3_5705F 0x166e +#define PCI_DEVICE_ID_TIGON3_5750 0x1676 +#define PCI_DEVICE_ID_TIGON3_5751 0x1677 +#define PCI_DEVICE_ID_TIGON3_5715 0x1678 +#define PCI_DEVICE_ID_TIGON3_5715S 0x1679 +#define PCI_DEVICE_ID_TIGON3_5750M 0x167c +#define PCI_DEVICE_ID_TIGON3_5751M 0x167d +#define PCI_DEVICE_ID_TIGON3_5751F 0x167e +#define PCI_DEVICE_ID_TIGON3_5782 0x1696 +#define PCI_DEVICE_ID_TIGON3_5788 0x169c +#define PCI_DEVICE_ID_TIGON3_5789 0x169d +#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6 +#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7 +#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8 +#define PCI_DEVICE_ID_NX2_5706S 0x16aa +#define PCI_DEVICE_ID_NX2_5708S 0x16ac +#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6 +#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7 +#define PCI_DEVICE_ID_TIGON3_5781 0x16dd +#define PCI_DEVICE_ID_TIGON3_5753 0x16f7 +#define PCI_DEVICE_ID_TIGON3_5753M 0x16fd +#define PCI_DEVICE_ID_TIGON3_5753F 0x16fe +#define PCI_DEVICE_ID_TIGON3_5901 0x170d +#define PCI_DEVICE_ID_BCM4401B1 0x170c +#define PCI_DEVICE_ID_TIGON3_5901_2 0x170e +#define PCI_DEVICE_ID_BCM4401 0x4401 +#define PCI_DEVICE_ID_BCM4401B0 0x4402 + +#define PCI_VENDOR_ID_TOPIC 0x151f +#define PCI_DEVICE_ID_TOPIC_TP560 0x0000 + +#define PCI_VENDOR_ID_ENE 0x1524 +#define PCI_DEVICE_ID_ENE_1211 0x1211 +#define PCI_DEVICE_ID_ENE_1225 0x1225 +#define PCI_DEVICE_ID_ENE_1410 0x1410 +#define PCI_DEVICE_ID_ENE_710 0x1411 +#define PCI_DEVICE_ID_ENE_712 0x1412 +#define PCI_DEVICE_ID_ENE_1420 0x1420 +#define PCI_DEVICE_ID_ENE_720 0x1421 +#define PCI_DEVICE_ID_ENE_722 0x1422 + +#define PCI_VENDOR_ID_CHELSIO 0x1425 + + +#define PCI_VENDOR_ID_SYBA 0x1592 +#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782 +#define PCI_DEVICE_ID_SYBA_1P_ECP 0x0783 + +#define PCI_VENDOR_ID_MORETON 0x15aa +#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000 + +#define PCI_VENDOR_ID_ZOLTRIX 0x15b0 +#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0 + +#define PCI_VENDOR_ID_MELLANOX 0x15b3 +#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 +#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278 +#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282 +#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c +#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 + +#define PCI_VENDOR_ID_PDC 0x15e9 + + +#define PCI_VENDOR_ID_FARSITE 0x1619 +#define PCI_DEVICE_ID_FARSITE_T2P 0x0400 +#define PCI_DEVICE_ID_FARSITE_T4P 0x0440 +#define PCI_DEVICE_ID_FARSITE_T1U 0x0610 +#define PCI_DEVICE_ID_FARSITE_T2U 0x0620 +#define PCI_DEVICE_ID_FARSITE_T4U 0x0640 +#define PCI_DEVICE_ID_FARSITE_TE1 0x1610 +#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612 + +#define PCI_VENDOR_ID_SIBYTE 0x166d +#define PCI_DEVICE_ID_BCM1250_HT 0x0002 + +#define PCI_VENDOR_ID_NETCELL 0x169c +#define PCI_DEVICE_ID_REVOLUTION 0x0044 + +#define PCI_VENDOR_ID_LINKSYS 0x1737 +#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064 + +#define PCI_VENDOR_ID_ALTIMA 0x173b +#define PCI_DEVICE_ID_ALTIMA_AC1000 0x03e8 +#define PCI_DEVICE_ID_ALTIMA_AC1001 0x03e9 +#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea +#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb + +#define PCI_VENDOR_ID_S2IO 0x17d5 +#define PCI_DEVICE_ID_S2IO_WIN 0x5731 +#define PCI_DEVICE_ID_S2IO_UNI 0x5831 +#define PCI_DEVICE_ID_HERC_WIN 0x5732 +#define PCI_DEVICE_ID_HERC_UNI 0x5832 + + +#define PCI_VENDOR_ID_SITECOM 0x182d +#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069 + +#define PCI_VENDOR_ID_TOPSPIN 0x1867 + +#define PCI_VENDOR_ID_TDI 0x192E +#define PCI_DEVICE_ID_TDI_EHCI 0x0101 + + +#define PCI_VENDOR_ID_TEKRAM 0x1de1 +#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 + +#define PCI_VENDOR_ID_HINT 0x3388 +#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013 + +#define PCI_VENDOR_ID_3DLABS 0x3d3d +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007 +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009 + + +#define PCI_VENDOR_ID_AKS 0x416c +#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100 + + + +#define PCI_VENDOR_ID_S3 0x5333 +#define PCI_DEVICE_ID_S3_TRIO 0x8811 +#define PCI_DEVICE_ID_S3_868 0x8880 +#define PCI_DEVICE_ID_S3_968 0x88f0 +#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 +#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04 +#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00 + +#define PCI_VENDOR_ID_DUNORD 0x5544 +#define PCI_DEVICE_ID_DUNORD_I3000 0x0001 + + +#define PCI_VENDOR_ID_DCI 0x6666 +#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001 +#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002 +#define PCI_DEVICE_ID_DCI_PCCOM2 0x0004 + +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_EESSC 0x0008 +#define PCI_DEVICE_ID_INTEL_PXHD_0 0x0320 +#define PCI_DEVICE_ID_INTEL_PXHD_1 0x0321 +#define PCI_DEVICE_ID_INTEL_PXH_0 0x0329 +#define PCI_DEVICE_ID_INTEL_PXH_1 0x032A +#define PCI_DEVICE_ID_INTEL_PXHV 0x032C +#define PCI_DEVICE_ID_INTEL_82375 0x0482 +#define PCI_DEVICE_ID_INTEL_82424 0x0483 +#define PCI_DEVICE_ID_INTEL_82378 0x0484 +#define PCI_DEVICE_ID_INTEL_I960 0x0960 +#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 +#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130 +#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 +#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 +#define PCI_DEVICE_ID_INTEL_7505_0 0x2550 +#define PCI_DEVICE_ID_INTEL_7205_0 0x255d +#define PCI_DEVICE_ID_INTEL_82437 0x122d +#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e +#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230 +#define PCI_DEVICE_ID_INTEL_82371MX 0x1234 +#define PCI_DEVICE_ID_INTEL_82441 0x1237 +#define PCI_DEVICE_ID_INTEL_82380FB 0x124b +#define PCI_DEVICE_ID_INTEL_82439 0x1250 +#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960 +#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 +#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 +#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 +#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 +#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 +#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415 +#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416 +#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418 +#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420 +#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421 +#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423 +#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425 +#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426 +#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428 +#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440 +#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443 +#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445 +#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448 +#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a +#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b +#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c +#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e +#define PCI_DEVICE_ID_INTEL_82801E_0 0x2450 +#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b +#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480 +#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483 +#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485 +#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486 +#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a +#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b +#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c +#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0 +#define PCI_DEVICE_ID_INTEL_82801DB_1 0x24c1 +#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3 +#define PCI_DEVICE_ID_INTEL_82801DB_5 0x24c5 +#define PCI_DEVICE_ID_INTEL_82801DB_6 0x24c6 +#define PCI_DEVICE_ID_INTEL_82801DB_9 0x24c9 +#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca +#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb +#define PCI_DEVICE_ID_INTEL_82801DB_12 0x24cc +#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0 +#define PCI_DEVICE_ID_INTEL_82801EB_1 0x24d1 +#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3 +#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5 +#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6 +#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db +#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd +#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1 +#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2 +#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4 +#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6 +#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab +#define PCI_DEVICE_ID_INTEL_82820_HB 0x2500 +#define PCI_DEVICE_ID_INTEL_82820_UP_HB 0x2501 +#define PCI_DEVICE_ID_INTEL_82850_HB 0x2530 +#define PCI_DEVICE_ID_INTEL_82860_HB 0x2531 +#define PCI_DEVICE_ID_INTEL_82845G_HB 0x2560 +#define PCI_DEVICE_ID_INTEL_82845G_IG 0x2562 +#define PCI_DEVICE_ID_INTEL_82865_HB 0x2570 +#define PCI_DEVICE_ID_INTEL_82865_IG 0x2572 +#define PCI_DEVICE_ID_INTEL_82875_HB 0x2578 +#define PCI_DEVICE_ID_INTEL_82915G_HB 0x2580 +#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 +#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 +#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 +#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 +#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 +#define PCI_DEVICE_ID_INTEL_82945GM_HB 0x27A0 +#define PCI_DEVICE_ID_INTEL_82945GM_IG 0x27A2 +#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 +#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 +#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 +#define PCI_DEVICE_ID_INTEL_ICH6_16 0x266a +#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d +#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e +#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f +#define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670 +#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698 +#define PCI_DEVICE_ID_INTEL_ESB2_17 0x269b +#define PCI_DEVICE_ID_INTEL_ESB2_18 0x269e +#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8 +#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9 +#define PCI_DEVICE_ID_INTEL_ICH7_30 0x27b0 +#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd +#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da +#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd +#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de +#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df +#define PCI_DEVICE_ID_INTEL_ICH8_0 0x2810 +#define PCI_DEVICE_ID_INTEL_ICH8_1 0x2811 +#define PCI_DEVICE_ID_INTEL_ICH8_2 0x2812 +#define PCI_DEVICE_ID_INTEL_ICH8_3 0x2814 +#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815 +#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e +#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850 +#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 +#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 +#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 +#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580 +#define PCI_DEVICE_ID_INTEL_82855GM_IG 0x3582 +#define PCI_DEVICE_ID_INTEL_E7520_MCH 0x3590 +#define PCI_DEVICE_ID_INTEL_E7320_MCH 0x3592 +#define PCI_DEVICE_ID_INTEL_MCH_PA 0x3595 +#define PCI_DEVICE_ID_INTEL_MCH_PA1 0x3596 +#define PCI_DEVICE_ID_INTEL_MCH_PB 0x3597 +#define PCI_DEVICE_ID_INTEL_MCH_PB1 0x3598 +#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599 +#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a +#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e +#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000 +#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010 +#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 +#define PCI_DEVICE_ID_INTEL_82437VX 0x7030 +#define PCI_DEVICE_ID_INTEL_82439TX 0x7100 +#define PCI_DEVICE_ID_INTEL_82371AB_0 0x7110 +#define PCI_DEVICE_ID_INTEL_82371AB 0x7111 +#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112 +#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113 +#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120 +#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121 +#define PCI_DEVICE_ID_INTEL_82810_MC3 0x7122 +#define PCI_DEVICE_ID_INTEL_82810_IG3 0x7123 +#define PCI_DEVICE_ID_INTEL_82810E_MC 0x7124 +#define PCI_DEVICE_ID_INTEL_82810E_IG 0x7125 +#define PCI_DEVICE_ID_INTEL_82443LX_0 0x7180 +#define PCI_DEVICE_ID_INTEL_82443LX_1 0x7181 +#define PCI_DEVICE_ID_INTEL_82443BX_0 0x7190 +#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191 +#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192 +#define PCI_DEVICE_ID_INTEL_440MX 0x7195 +#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196 +#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198 +#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199 +#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b +#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0 +#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 +#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 +#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 +#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 +#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca +#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb +#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea +#define PCI_DEVICE_ID_INTEL_IXP4XX 0x8500 +#define PCI_DEVICE_ID_INTEL_IXP2800 0x9004 +#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 + +#define PCI_VENDOR_ID_SCALEMP 0x8686 +#define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010 + +#define PCI_VENDOR_ID_COMPUTONE 0x8e0e +#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291 +#define PCI_DEVICE_ID_COMPUTONE_PG 0x0302 +#define PCI_SUBVENDOR_ID_COMPUTONE 0x8e0e +#define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG8 0x0002 +#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003 + +#define PCI_VENDOR_ID_KTI 0x8e2e + +#define PCI_VENDOR_ID_ADAPTEC 0x9004 +#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078 +#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178 +#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860 +#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078 +#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578 +#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038 +#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075 +#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078 +#define PCI_DEVICE_ID_ADAPTEC_7861 0x6178 +#define PCI_DEVICE_ID_ADAPTEC_7870 0x7078 +#define PCI_DEVICE_ID_ADAPTEC_7871 0x7178 +#define PCI_DEVICE_ID_ADAPTEC_7872 0x7278 +#define PCI_DEVICE_ID_ADAPTEC_7873 0x7378 +#define PCI_DEVICE_ID_ADAPTEC_7874 0x7478 +#define PCI_DEVICE_ID_ADAPTEC_7895 0x7895 +#define PCI_DEVICE_ID_ADAPTEC_7880 0x8078 +#define PCI_DEVICE_ID_ADAPTEC_7881 0x8178 +#define PCI_DEVICE_ID_ADAPTEC_7882 0x8278 +#define PCI_DEVICE_ID_ADAPTEC_7883 0x8378 +#define PCI_DEVICE_ID_ADAPTEC_7884 0x8478 +#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578 +#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678 +#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778 +#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878 + +#define PCI_VENDOR_ID_ADAPTEC2 0x9005 +#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010 +#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011 +#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013 +#define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f +#define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050 +#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051 +#define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f +#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080 +#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081 +#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083 +#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f +#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0 +#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1 +#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3 +#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf +#define PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN 0x0500 +#define PCI_DEVICE_ID_ADAPTEC2_SCAMP 0x0503 + + +#define PCI_VENDOR_ID_HOLTEK 0x9412 +#define PCI_DEVICE_ID_HOLTEK_6565 0x6565 + +#define PCI_VENDOR_ID_NETMOS 0x9710 +#define PCI_DEVICE_ID_NETMOS_9705 0x9705 +#define PCI_DEVICE_ID_NETMOS_9715 0x9715 +#define PCI_DEVICE_ID_NETMOS_9735 0x9735 +#define PCI_DEVICE_ID_NETMOS_9745 0x9745 +#define PCI_DEVICE_ID_NETMOS_9755 0x9755 +#define PCI_DEVICE_ID_NETMOS_9805 0x9805 +#define PCI_DEVICE_ID_NETMOS_9815 0x9815 +#define PCI_DEVICE_ID_NETMOS_9835 0x9835 +#define PCI_DEVICE_ID_NETMOS_9845 0x9845 +#define PCI_DEVICE_ID_NETMOS_9855 0x9855 + +#define PCI_SUBVENDOR_ID_EXSYS 0xd84d +#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014 +#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055 + +#define PCI_VENDOR_ID_TIGERJET 0xe159 +#define PCI_DEVICE_ID_TIGERJET_300 0x0001 +#define PCI_DEVICE_ID_TIGERJET_100 0x0002 + +#define PCI_VENDOR_ID_TTTECH 0x0357 +#define PCI_DEVICE_ID_TTTECH_MC322 0x000A + +#define PCI_VENDOR_ID_XILINX_RME 0xea60 +#define PCI_DEVICE_ID_RME_DIGI32 0x9896 +#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897 +#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898 + diff --git a/ddverify/models/goblint/include/linux/pci_regs.h b/ddverify/models/goblint/include/linux/pci_regs.h new file mode 100644 index 000000000..d27a78b71 --- /dev/null +++ b/ddverify/models/goblint/include/linux/pci_regs.h @@ -0,0 +1,449 @@ +/* + * pci_regs.h + * + * PCI standard defines + * Copyright 1994, Drew Eckhardt + * Copyright 1997--1999 Martin Mares + * + * For more information, please consult the following manuals (look at + * http://www.pcisig.com/ for how to get them): + * + * PCI BIOS Specification + * PCI Local Bus Specification + * PCI to PCI Bridge Specification + * PCI System Design Guide + */ + +#ifndef LINUX_PCI_REGS_H +#define LINUX_PCI_REGS_H + +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes are standardized as follows: + */ +#define PCI_VENDOR_ID 0x00 /* 16 bits */ +#define PCI_DEVICE_ID 0x02 /* 16 bits */ +#define PCI_COMMAND 0x04 /* 16 bits */ +#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ +#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ + +#define PCI_STATUS 0x06 /* 16 bits */ +#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ +#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ +#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVSEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +/* + * Base addresses specify locations in memory or I/O space. + * Decoded size can be determined by writing a value of + * 0xffffffff to the register, and reading it back. Only + * 1 bits are decoded. + */ +#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ +#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ +#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ +#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ +#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ +#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ +#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ +#define PCI_BASE_ADDRESS_SPACE_IO 0x01 +#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ +#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) +#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) +/* bit 1 is reserved if address_space = 1 */ + +/* Header type 0 (normal devices) */ +#define PCI_CARDBUS_CIS 0x28 +#define PCI_SUBSYSTEM_VENDOR_ID 0x2c +#define PCI_SUBSYSTEM_ID 0x2e +#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ +#define PCI_ROM_ADDRESS_ENABLE 0x01 +#define PCI_ROM_ADDRESS_MASK (~0x7ffUL) + +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ + +/* 0x35-0x3b are reserved */ +#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ +#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ +#define PCI_MIN_GNT 0x3e /* 8 bits */ +#define PCI_MAX_LAT 0x3f /* 8 bits */ + +/* Header type 1 (PCI-to-PCI bridges) */ +#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ +#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ +#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ +#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ +#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ +#define PCI_IO_LIMIT 0x1d +#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */ +#define PCI_IO_RANGE_TYPE_16 0x00 +#define PCI_IO_RANGE_TYPE_32 0x01 +#define PCI_IO_RANGE_MASK (~0x0fUL) +#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */ +#define PCI_MEMORY_BASE 0x20 /* Memory range behind */ +#define PCI_MEMORY_LIMIT 0x22 +#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL +#define PCI_MEMORY_RANGE_MASK (~0x0fUL) +#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ +#define PCI_PREF_MEMORY_LIMIT 0x26 +#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL +#define PCI_PREF_RANGE_TYPE_32 0x00 +#define PCI_PREF_RANGE_TYPE_64 0x01 +#define PCI_PREF_RANGE_MASK (~0x0fUL) +#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ +#define PCI_PREF_LIMIT_UPPER32 0x2c +#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ +#define PCI_IO_LIMIT_UPPER16 0x32 +/* 0x34 same as for htype 0 */ +/* 0x35-0x3b is reserved */ +#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_BRIDGE_CONTROL 0x3e +#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ +#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ +#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ +#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ +#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ +#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ +#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ + +/* Header type 2 (CardBus bridges) */ +#define PCI_CB_CAPABILITY_LIST 0x14 +/* 0x15 reserved */ +#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ +#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ +#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ +#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ +#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ +#define PCI_CB_MEMORY_BASE_0 0x1c +#define PCI_CB_MEMORY_LIMIT_0 0x20 +#define PCI_CB_MEMORY_BASE_1 0x24 +#define PCI_CB_MEMORY_LIMIT_1 0x28 +#define PCI_CB_IO_BASE_0 0x2c +#define PCI_CB_IO_BASE_0_HI 0x2e +#define PCI_CB_IO_LIMIT_0 0x30 +#define PCI_CB_IO_LIMIT_0_HI 0x32 +#define PCI_CB_IO_BASE_1 0x34 +#define PCI_CB_IO_BASE_1_HI 0x36 +#define PCI_CB_IO_LIMIT_1 0x38 +#define PCI_CB_IO_LIMIT_1_HI 0x3a +#define PCI_CB_IO_RANGE_MASK (~0x03UL) +/* 0x3c-0x3d are same as for htype 0 */ +#define PCI_CB_BRIDGE_CONTROL 0x3e +#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ +#define PCI_CB_BRIDGE_CTL_SERR 0x02 +#define PCI_CB_BRIDGE_CTL_ISA 0x04 +#define PCI_CB_BRIDGE_CTL_VGA 0x08 +#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 +#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ +#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ +#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 +#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 +#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 +#define PCI_CB_SUBSYSTEM_ID 0x42 +#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ +/* 0x48-0x7f reserved */ + +/* Capability lists */ + +#define PCI_CAP_LIST_ID 0 /* Capability ID */ +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ +#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ +#define PCI_CAP_ID_HT_IRQCONF 0x08 /* HyperTransport IRQ Configuration */ +#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ +#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + +/* Power Management Registers */ + +#define PCI_PM_PMC 2 /* PM Capabilities Register */ +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ +#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ +#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */ +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ +#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */ +#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */ +#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */ +#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */ +#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */ +#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */ +#define PCI_PM_CTRL 4 /* PM control and status register */ +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_NO_SOFT_RESET 0x0004 /* No reset for D3hot->D0 */ +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ +#define PCI_PM_DATA_REGISTER 7 /* (??) */ +#define PCI_PM_SIZEOF 8 + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */ +#define PCI_AGP_SIZEOF 12 + +/* Vital Product Data */ + +#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */ +#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */ +#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */ +#define PCI_VPD_DATA 4 /* 32-bits of data returned here */ + +/* Slot Identification */ + +#define PCI_SID_ESR 2 /* Expansion Slot Register */ +#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ +#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ +#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ + +/* Message Signalled Interrupts registers */ + +#define PCI_MSI_FLAGS 2 /* Various flags */ +#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ +#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ +#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ +#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ +#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */ +#define PCI_MSI_RFU 3 /* Rest of capability flags */ +#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ +#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ +#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ +#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ +#define PCI_MSI_MASK_BIT 16 /* Mask bits register */ + +/* CompactPCI Hotswap Register */ + +#define PCI_CHSWP_CSR 2 /* Control and Status Register */ +#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */ +#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */ +#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */ +#define PCI_CHSWP_LOO 0x08 /* LED On / Off */ +#define PCI_CHSWP_PI 0x30 /* Programming Interface */ +#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */ +#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */ + +/* PCI-X registers */ + +#define PCI_X_CMD 2 /* Modes & Features */ +#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */ +#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */ +#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */ +#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */ +#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */ +#define PCI_X_STATUS 4 /* PCI-X capabilities */ +#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */ +#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */ +#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */ +#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */ +#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */ +#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */ +#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */ +#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */ +#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */ +#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */ +#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */ +#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */ +#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */ + +/* PCI Express capability registers */ + +#define PCI_EXP_FLAGS 2 /* Capabilities register */ +#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */ +#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */ +#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */ +#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */ +#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */ +#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ +#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ +#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ +#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ +#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ +#define PCI_EXP_DEVCAP 4 /* Device capabilities */ +#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */ +#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */ +#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */ +#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */ +#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */ +#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ +#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ +#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ +#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ +#define PCI_EXP_DEVCTL 8 /* Device Control */ +#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ +#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */ +#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ +#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */ +#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ +#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ +#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ +#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */ +#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ +#define PCI_EXP_DEVSTA 10 /* Device Status */ +#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ +#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ +#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */ +#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ +#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ +#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ +#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ +#define PCI_EXP_LNKCTL 16 /* Link Control */ +#define PCI_EXP_LNKSTA 18 /* Link Status */ +#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ +#define PCI_EXP_SLTCTL 24 /* Slot Control */ +#define PCI_EXP_SLTSTA 26 /* Slot Status */ +#define PCI_EXP_RTCTL 28 /* Root Control */ +#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */ +#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */ +#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */ +#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */ +#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ +#define PCI_EXP_RTCAP 30 /* Root Capabilities */ +#define PCI_EXP_RTSTA 32 /* Root Status */ + +/* Extended Capabilities (PCI-X 2.0 and Express) */ +#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) +#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf) +#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) + +#define PCI_EXT_CAP_ID_ERR 1 +#define PCI_EXT_CAP_ID_VC 2 +#define PCI_EXT_CAP_ID_DSN 3 +#define PCI_EXT_CAP_ID_PWR 4 + +/* Advanced Error Reporting */ +#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ +#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */ +#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */ +#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */ +#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */ +#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */ +#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */ +#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */ +#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */ +#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */ +#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */ +#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */ +#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */ + /* Same bits as above */ +#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */ +#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */ +#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */ +#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */ +#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */ +#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */ +#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */ + /* Same bits as above */ +#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */ +#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */ +#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */ +#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */ +#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ +#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ +#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */ +#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */ +#define PCI_ERR_ROOT_STATUS 48 +#define PCI_ERR_ROOT_COR_SRC 52 +#define PCI_ERR_ROOT_SRC 54 + +/* Virtual Channel */ +#define PCI_VC_PORT_REG1 4 +#define PCI_VC_PORT_REG2 8 +#define PCI_VC_PORT_CTRL 12 +#define PCI_VC_PORT_STATUS 14 +#define PCI_VC_RES_CAP 16 +#define PCI_VC_RES_CTRL 20 +#define PCI_VC_RES_STATUS 26 + +/* Power Budgeting */ +#define PCI_PWR_DSR 4 /* Data Select Register */ +#define PCI_PWR_DATA 8 /* Data Register */ +#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */ +#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */ +#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */ +#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */ +#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */ +#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */ +#define PCI_PWR_CAP 12 /* Capability */ +#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ + +#endif /* LINUX_PCI_REGS_H */ diff --git a/ddverify/models/goblint/include/linux/percpu.h b/ddverify/models/goblint/include/linux/percpu.h new file mode 100644 index 000000000..8e9945bd8 --- /dev/null +++ b/ddverify/models/goblint/include/linux/percpu.h @@ -0,0 +1,10 @@ +#ifndef __LINUX_PERCPU_H +#define __LINUX_PERCPU_H + +#include +#include +//#include +#include +//#include + +#endif /* __LINUX_PERCPU_H */ diff --git a/ddverify/models/goblint/include/linux/platform_device.h b/ddverify/models/goblint/include/linux/platform_device.h new file mode 100644 index 000000000..97a8fed3f --- /dev/null +++ b/ddverify/models/goblint/include/linux/platform_device.h @@ -0,0 +1,25 @@ +#ifndef _PLATFORM_DEVICE_H_ +#define _PLATFORM_DEVICE_H_ + +#include + +struct platform_device { + const char * name; + u32 id; + struct device dev; + u32 num_resources; + struct resource * resource; +}; + +struct platform_driver { + int (*probe)(struct platform_device *); + int (*remove)(struct platform_device *); + void (*shutdown)(struct platform_device *); + int (*suspend)(struct platform_device *, pm_message_t state); + int (*suspend_late)(struct platform_device *, pm_message_t state); + int (*resume_early)(struct platform_device *); + int (*resume)(struct platform_device *); + struct device_driver driver; +}; + +#endif /* _PLATFORM_DEVICE_H_ */ diff --git a/ddverify/models/goblint/include/linux/pm.h b/ddverify/models/goblint/include/linux/pm.h new file mode 100644 index 000000000..430226d01 --- /dev/null +++ b/ddverify/models/goblint/include/linux/pm.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_PM_H +#define _LINUX_PM_H + +#include +#include +#include + +typedef struct pm_message { + int event; +} pm_message_t; + +#endif /* _LINUX_PM_H */ diff --git a/ddverify/models/goblint/include/linux/pnp.h b/ddverify/models/goblint/include/linux/pnp.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/poll.h b/ddverify/models/goblint/include/linux/poll.h new file mode 100644 index 000000000..326affc5f --- /dev/null +++ b/ddverify/models/goblint/include/linux/poll.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_POLL_H +#define _LINUX_POLL_H + +#include +#include +#include +#include +#include + +typedef struct poll_table_struct { + int something; +} poll_table; + +void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p); + +#endif /* _LINUX_POLL_H */ diff --git a/ddverify/models/goblint/include/linux/posix_types.h b/ddverify/models/goblint/include/linux/posix_types.h new file mode 100644 index 000000000..f60a473e2 --- /dev/null +++ b/ddverify/models/goblint/include/linux/posix_types.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_POSIX_TYPES_H +#define _LINUX_POSIX_TYPES_H + +typedef int __kernel_key_t; +typedef int __kernel_mqd_t; + +#include + +#endif /* _LINUX_POSIX_TYPES_H */ diff --git a/ddverify/models/goblint/include/linux/proc_fs.h b/ddverify/models/goblint/include/linux/proc_fs.h new file mode 100644 index 000000000..48ffb5cf2 --- /dev/null +++ b/ddverify/models/goblint/include/linux/proc_fs.h @@ -0,0 +1,29 @@ +#ifndef _LINUX_PROC_FS_H +#define _LINUX_PROC_FS_H + +#include +#include + +struct proc_dir_entry { + int something; +}; + +struct proc_dir_entry *proc_root_driver; + +typedef int (read_proc_t)(char *page, char **start, off_t off, + int count, int *eof, void *data); + +struct proc_dir_entry *create_proc_read_entry(const char *name, + mode_t mode, + struct proc_dir_entry *base, + read_proc_t *read_proc, + void * data); + +struct proc_dir_entry *create_proc_entry(const char *name, + mode_t mode, + struct proc_dir_entry *parent); + +void remove_proc_entry(const char *name, struct proc_dir_entry *parent); +struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); + +#endif diff --git a/ddverify/models/goblint/include/linux/ptrace.h b/ddverify/models/goblint/include/linux/ptrace.h new file mode 100644 index 000000000..e47ffb1ac --- /dev/null +++ b/ddverify/models/goblint/include/linux/ptrace.h @@ -0,0 +1,80 @@ +#ifndef _LINUX_PTRACE_H +#define _LINUX_PTRACE_H +/* ptrace.h */ +/* structs and defines to help the user use the ptrace system call. */ + +/* has the defines to get at the registers. */ + +#define PTRACE_TRACEME 0 +#define PTRACE_PEEKTEXT 1 +#define PTRACE_PEEKDATA 2 +#define PTRACE_PEEKUSR 3 +#define PTRACE_POKETEXT 4 +#define PTRACE_POKEDATA 5 +#define PTRACE_POKEUSR 6 +#define PTRACE_CONT 7 +#define PTRACE_KILL 8 +#define PTRACE_SINGLESTEP 9 + +#define PTRACE_ATTACH 16 +#define PTRACE_DETACH 17 + +#define PTRACE_SYSCALL 24 + +/* 0x4200-0x4300 are reserved for architecture-independent additions. */ +#define PTRACE_SETOPTIONS 0x4200 +#define PTRACE_GETEVENTMSG 0x4201 +#define PTRACE_GETSIGINFO 0x4202 +#define PTRACE_SETSIGINFO 0x4203 + +/* options set using PTRACE_SETOPTIONS */ +#define PTRACE_O_TRACESYSGOOD 0x00000001 +#define PTRACE_O_TRACEFORK 0x00000002 +#define PTRACE_O_TRACEVFORK 0x00000004 +#define PTRACE_O_TRACECLONE 0x00000008 +#define PTRACE_O_TRACEEXEC 0x00000010 +#define PTRACE_O_TRACEVFORKDONE 0x00000020 +#define PTRACE_O_TRACEEXIT 0x00000040 + +#define PTRACE_O_MASK 0x0000007f + +/* Wait extended result codes for the above trace options. */ +#define PTRACE_EVENT_FORK 1 +#define PTRACE_EVENT_VFORK 2 +#define PTRACE_EVENT_CLONE 3 +#define PTRACE_EVENT_EXEC 4 +#define PTRACE_EVENT_VFORK_DONE 5 +#define PTRACE_EVENT_EXIT 6 + +/* + * Ptrace flags + * + * The owner ship rules for task->ptrace which holds the ptrace + * flags is simple. When a task is running it owns it's task->ptrace + * flags. When the a task is stopped the ptracer owns task->ptrace. + */ + +#define PT_PTRACED 0x00000001 +#define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ +#define PT_TRACESYSGOOD 0x00000004 +#define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */ +#define PT_TRACE_FORK 0x00000010 +#define PT_TRACE_VFORK 0x00000020 +#define PT_TRACE_CLONE 0x00000040 +#define PT_TRACE_EXEC 0x00000080 +#define PT_TRACE_VFORK_DONE 0x00000100 +#define PT_TRACE_EXIT 0x00000200 +#define PT_ATTACHED 0x00000400 /* parent != real_parent */ + +#define PT_TRACE_MASK 0x000003f4 + +/* single stepping state bits (used on ARM and PA-RISC) */ +#define PT_SINGLESTEP_BIT 31 +#define PT_SINGLESTEP (1< /* For unlikely. */ +#include /* For struct task_struct. */ + +#endif diff --git a/ddverify/models/goblint/include/linux/reboot.h b/ddverify/models/goblint/include/linux/reboot.h new file mode 100644 index 000000000..b1d2d7da1 --- /dev/null +++ b/ddverify/models/goblint/include/linux/reboot.h @@ -0,0 +1,75 @@ +#ifndef _LINUX_REBOOT_H +#define _LINUX_REBOOT_H + +/* + * Magic values required to use _reboot() system call. + */ + +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_MAGIC2A 85072278 +#define LINUX_REBOOT_MAGIC2B 369367448 +#define LINUX_REBOOT_MAGIC2C 537993216 + + +/* + * Commands accepted by the _reboot() system call. + * + * RESTART Restart system using default command and mode. + * HALT Stop OS and give system control to ROM monitor, if any. + * CAD_ON Ctrl-Alt-Del sequence causes RESTART command. + * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task. + * POWER_OFF Stop OS and remove all power from system, if possible. + * RESTART2 Restart system using given command string. + * SW_SUSPEND Suspend system using software suspend if compiled in. + * KEXEC Restart system using a previously loaded Linux kernel + */ + +#define LINUX_REBOOT_CMD_RESTART 0x01234567 +#define LINUX_REBOOT_CMD_HALT 0xCDEF0123 +#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF +#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000 +#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 +#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2 +#define LINUX_REBOOT_CMD_KEXEC 0x45584543 + + +#include + +extern int register_reboot_notifier(struct notifier_block *); +extern int unregister_reboot_notifier(struct notifier_block *); + + +/* + * Architecture-specific implementations of sys_reboot commands. + */ + +extern void machine_restart(char *cmd); +extern void machine_halt(void); +extern void machine_power_off(void); + +extern void machine_shutdown(void); +struct pt_regs; +extern void machine_crash_shutdown(struct pt_regs *); + +/* + * Architecture independent implemenations of sys_reboot commands. + */ + +extern void kernel_shutdown_prepare(enum system_states state); + +extern void kernel_restart(char *cmd); +extern void kernel_halt(void); +extern void kernel_power_off(void); + +void ctrl_alt_del(void); + +/* + * Emergency restart, callable from an interrupt handler. + */ + +extern void emergency_restart(void); +//#include + +#endif /* _LINUX_REBOOT_H */ diff --git a/ddverify/models/goblint/include/linux/rtc.h b/ddverify/models/goblint/include/linux/rtc.h new file mode 100644 index 000000000..58ff91583 --- /dev/null +++ b/ddverify/models/goblint/include/linux/rtc.h @@ -0,0 +1,219 @@ +/* + * Generic RTC interface. + * This version contains the part of the user interface to the Real Time Clock + * service. It is used with both the legacy mc146818 and also EFI + * Struct rtc_time and first 12 ioctl by Paul Gortmaker, 1996 - separated out + * from to this file for 2.4 kernels. + * + * Copyright (C) 1999 Hewlett-Packard Co. + * Copyright (C) 1999 Stephane Eranian + */ +#ifndef _LINUX_RTC_H_ +#define _LINUX_RTC_H_ + +/* + * The struct used to pass data via the following ioctl. Similar to the + * struct tm in , but it needs to be here so that the kernel + * source is self contained, allowing cross-compiles, etc. etc. + */ +struct rtc_time { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +/* + * This data structure is inspired by the EFI (v0.92) wakeup + * alarm API. + */ +struct rtc_wkalrm { + unsigned char enabled; + unsigned char pending; + struct rtc_time time; +}; + +/* + * Data structure to control PLL correction some better RTC feature + * pll_value is used to get or set current value of correction, + * the rest of the struct is used to query HW capabilities. + * This is modeled after the RTC used in Q40/Q60 computers but + * should be sufficiently flexible for other devices + * + * +ve pll_value means clock will run faster by + * pll_value*pll_posmult/pll_clock + * -ve pll_value means clock will run slower by + * pll_value*pll_negmult/pll_clock + */ + +struct rtc_pll_info { + /* int pll_ctrl; + int pll_value; + int pll_max; + int pll_min; + int pll_posmult; + int pll_negmult; + long pll_clock; +*/ + int something; +}; + +/* + * ioctl calls that are permitted to the /dev/rtc interface, if + * any of the RTC drivers are enabled. + */ + +#define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */ +#define RTC_AIE_OFF _IO('p', 0x02) /* ... off */ +#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */ +#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */ +#define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */ +#define RTC_PIE_OFF _IO('p', 0x06) /* ... off */ +#define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */ +#define RTC_WIE_OFF _IO('p', 0x10) /* ... off */ + +#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */ +#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */ +#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */ +#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */ +#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */ +#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */ +#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */ +#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */ + +#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/ +#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/ + +#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */ +#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */ + +/* interrupt flags */ +#define RTC_IRQF 0x80 /* any of the following is active */ +#define RTC_PF 0x40 +#define RTC_AF 0x20 +#define RTC_UF 0x10 + + +#include + +extern int rtc_month_days(unsigned int month, unsigned int year); +extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); +extern int rtc_valid_tm(struct rtc_time *tm); +extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); +extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); + +#include +#include +#include +#include +#include + +extern struct class *rtc_class; + +struct rtc_class_ops { + /* int (*open)(struct device *); + void (*release)(struct device *); + int (*ioctl)(struct device *, unsigned int, unsigned long); + int (*read_time)(struct device *, struct rtc_time *); + int (*set_time)(struct device *, struct rtc_time *); + int (*read_alarm)(struct device *, struct rtc_wkalrm *); + int (*set_alarm)(struct device *, struct rtc_wkalrm *); + int (*proc)(struct device *, struct seq_file *); + int (*set_mmss)(struct device *, unsigned long secs); + int (*irq_set_state)(struct device *, int enabled); + int (*irq_set_freq)(struct device *, int freq); + int (*read_callback)(struct device *, int data); + */ + int something; +}; + +#define RTC_DEVICE_NAME_SIZE 20 +struct rtc_task; + +struct rtc_device +{ + /* struct class_device class_dev; + struct module *owner; + + int id; + char name[RTC_DEVICE_NAME_SIZE]; + + const struct rtc_class_ops *ops; + struct mutex ops_lock; + + struct class_device *rtc_dev; + struct cdev char_dev; + struct mutex char_lock; + + unsigned long irq_data; + spinlock_t irq_lock; + wait_queue_head_t irq_queue; + struct fasync_struct *async_queue; + + struct rtc_task *irq_task; + spinlock_t irq_task_lock; + int irq_freq; + int max_user_freq; +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL + struct work_struct uie_task; + struct timer_list uie_timer; + unsigned int oldsecs; + unsigned int irq_active:1; + unsigned int stop_uie_polling:1; + unsigned int uie_task_active:1; + unsigned int uie_timer_active:1; +#endif + */ + int something; +}; +#define to_rtc_device(d) container_of(d, struct rtc_device, class_dev) + +extern struct rtc_device *rtc_device_register(const char *name, + struct device *dev, + const struct rtc_class_ops *ops, + struct module *owner); +extern void rtc_device_unregister(struct rtc_device *rdev); +extern int rtc_interface_register(struct class_interface *intf); + +extern int rtc_read_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_time(struct class_device *class_dev, struct rtc_time *tm); +extern int rtc_set_mmss(struct class_device *class_dev, unsigned long secs); +extern int rtc_read_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern int rtc_set_alarm(struct class_device *class_dev, + struct rtc_wkalrm *alrm); +extern void rtc_update_irq(struct class_device *class_dev, + unsigned long num, unsigned long events); + +extern struct class_device *rtc_class_open(char *name); +extern void rtc_class_close(struct class_device *class_dev); + +extern int rtc_irq_register(struct class_device *class_dev, + struct rtc_task *task); +extern void rtc_irq_unregister(struct class_device *class_dev, + struct rtc_task *task); +extern int rtc_irq_set_state(struct class_device *class_dev, + struct rtc_task *task, int enabled); +extern int rtc_irq_set_freq(struct class_device *class_dev, + struct rtc_task *task, int freq); + +typedef struct rtc_task { + void (*func)(void *private_data); + void *private_data; +} rtc_task_t; + +int rtc_register(rtc_task_t *task); +int rtc_unregister(rtc_task_t *task); +int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); +void rtc_get_rtc_time(struct rtc_time *rtc_tm); +irqreturn_t rtc_interrupt(int irq, void *dev_id); + + +unsigned char rtc_read(unsigned char); +void rtc_write(unsigned char, unsigned char); +#endif /* _LINUX_RTC_H_ */ diff --git a/ddverify/models/goblint/include/linux/scatterlist.h b/ddverify/models/goblint/include/linux/scatterlist.h new file mode 100644 index 000000000..32da1e633 --- /dev/null +++ b/ddverify/models/goblint/include/linux/scatterlist.h @@ -0,0 +1,24 @@ +#ifndef _LINUX_SCATTERLIST_H +#define _LINUX_SCATTERLIST_H + +#include +#include +#include + +/*static inline void sg_set_buf(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + sg->page = virt_to_page(buf); + sg->offset = offset_in_page(buf); + sg->length = buflen; +} + +static inline void sg_init_one(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + memset(sg, 0, sizeof(*sg)); + sg_set_buf(sg, buf, buflen); +} +*/ + +#endif /* _LINUX_SCATTERLIST_H */ diff --git a/ddverify/models/goblint/include/linux/sched.h b/ddverify/models/goblint/include/linux/sched.h new file mode 100644 index 000000000..c15cd8719 --- /dev/null +++ b/ddverify/models/goblint/include/linux/sched.h @@ -0,0 +1,62 @@ +#ifndef _LINUX_SCHED_H +#define _LINUX_SCHED_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_STOPPED 4 +#define TASK_TRACED 8 + +#define TASK_COMM_LEN 16 + +struct sighand_struct { + spinlock_t siglock; +}; + +struct task_struct { + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + pid_t pid; + char comm[TASK_COMM_LEN]; + + sigset_t blocked, real_blocked; + + struct sighand_struct *sighand; +}; + +#include + +int signal_pending(struct task_struct *p); + +// DDV: Body is defined in linux/kernel/sched.c +void schedule(void); +// DDV: Body is defined in linux/kernel/sched.c +long schedule_timeout(long timeout); +// DDV: TODO +int need_resched(void); + +// DDV: TODO +extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); + +// DDV: TODO +void yield(void); + +// DDV: No body for this function +void set_current_state(int); + +// DDV: TODO +extern int kill_proc(pid_t, int, int); +// DDV: TODO +extern void recalc_sigpending(void); +#endif diff --git a/ddverify/models/goblint/include/linux/seq_file.h b/ddverify/models/goblint/include/linux/seq_file.h new file mode 100644 index 000000000..bb64052b9 --- /dev/null +++ b/ddverify/models/goblint/include/linux/seq_file.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_SEQ_FILE_H +#define _LINUX_SEQ_FILE_H + +#include +#include +#include + +struct seq_operations; +struct file; +struct vfsmount; +struct dentry; +struct inode; + +struct seq_file { + int something; +}; + +struct seq_operations { + void * (*start) (struct seq_file *m, loff_t *pos); + void (*stop) (struct seq_file *m, void *v); + void * (*next) (struct seq_file *m, void *v, loff_t *pos); + int (*show) (struct seq_file *m, void *v); +}; + +int seq_open(struct file *, struct seq_operations *); +ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); +loff_t seq_lseek(struct file *, loff_t, int); +int seq_release(struct inode *, struct file *); +int seq_escape(struct seq_file *, const char *, const char *); +int seq_putc(struct seq_file *m, char c); +int seq_puts(struct seq_file *m, const char *s); + +int seq_printf(struct seq_file *, const char *, ...); + +#endif diff --git a/ddverify/models/goblint/include/linux/serial.h b/ddverify/models/goblint/include/linux/serial.h new file mode 100644 index 000000000..b532862fc --- /dev/null +++ b/ddverify/models/goblint/include/linux/serial.h @@ -0,0 +1,131 @@ +/* + * include/linux/serial.h + * + * Copyright (C) 1992 by Theodore Ts'o. + * + * Redistribution of this file is permitted under the terms of the GNU + * Public License (GPL) + */ + +#ifndef _LINUX_SERIAL_H +#define _LINUX_SERIAL_H + +#include +#include + +#define SERIAL_XMIT_SIZE PAGE_SIZE + +struct serial_struct { + int type; + int line; + unsigned int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + unsigned short close_delay; + char io_type; + char reserved_char[1]; + int hub6; + unsigned short closing_wait; /* time to wait before closing */ + unsigned short closing_wait2; /* no longer used... */ + unsigned char *iomem_base; + unsigned short iomem_reg_shift; + unsigned int port_high; + unsigned long iomap_base; /* cookie passed into ioremap */ +}; + + +/* + * For the close wait times, 0 means wait forever for serial port to + * flush its output. 65535 means don't wait at all. + */ +#define ASYNC_CLOSING_WAIT_INF 0 +#define ASYNC_CLOSING_WAIT_NONE 65535 + + +/* + * These are the supported serial types. + */ +#define PORT_UNKNOWN 0 +#define PORT_8250 1 +#define PORT_16450 2 +#define PORT_16550 3 +#define PORT_16550A 4 +#define PORT_CIRRUS 5 /* usurped by cyclades.c */ +#define PORT_16650 6 +#define PORT_16650V2 7 +#define PORT_16750 8 +#define PORT_STARTECH 9 /* usurped by cyclades.c */ +#define PORT_16C950 10 /* Oxford Semiconductor */ +#define PORT_16654 11 +#define PORT_16850 12 +#define PORT_RSA 13 /* RSA-DV II/S card */ +#define PORT_MAX 13 + +#define SERIAL_IO_PORT 0 +#define SERIAL_IO_HUB6 1 +#define SERIAL_IO_MEM 2 + + + + +#define UART_CLEAR_FIFO 0x01 +#define UART_USE_FIFO 0x02 +#define UART_STARTECH 0x04 +#define UART_NATSEMI 0x08 + + +/* + * Definitions for async_struct (and serial_struct) flags field + */ +#define ASYNC_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes + on the callout port */ +#define ASYNC_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */ +#define ASYNC_SAK 0x0004 /* Secure Attention Key (Orange book) */ +#define ASYNC_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ + +#define ASYNC_SPD_MASK 0x1030 +#define ASYNC_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ + +#define ASYNC_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ +#define ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */ + +#define ASYNC_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ +#define ASYNC_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ +#define ASYNC_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ +#define ASYNC_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ +#define ASYNC_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ + +#define ASYNC_HARDPPS_CD 0x0800 /* Call hardpps when CD goes high */ + +#define ASYNC_SPD_SHI 0x1000 /* Use 230400 instead of 38400 bps */ +#define ASYNC_SPD_WARP 0x1010 /* Use 460800 instead of 38400 bps */ + +#define ASYNC_LOW_LATENCY 0x2000 /* Request low latency behaviour */ + +#define ASYNC_BUGGY_UART 0x4000 /* This is a buggy UART, skip some safety + * checks. Note: can be dangerous! */ + +#define ASYNC_AUTOPROBE 0x8000 /* Port was autoprobed by PCI or PNP code */ + +#define ASYNC_FLAGS 0x7FFF /* Possible legal async flags */ +#define ASYNC_USR_MASK 0x3430 /* Legal flags that non-privileged + * users can set or reset */ + +/* Internal flags used only by kernel/chr_drv/serial.c */ +#define ASYNC_INITIALIZED 0x80000000 /* Serial port was initialized */ +#define ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ +#define ASYNC_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ +#define ASYNC_CLOSING 0x08000000 /* Serial port is closing */ +#define ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */ +#define ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */ +#define ASYNC_SHARE_IRQ 0x01000000 /* for multifunction cards + --- no longer used */ +#define ASYNC_CONS_FLOW 0x00800000 /* flow control for console */ + +#define ASYNC_BOOT_ONLYMCA 0x00400000 /* Probe only if MCA bus */ +#define ASYNC_INTERNAL_FLAGS 0xFFC00000 /* Internal flags */ + +#endif /* _LINUX_SERIAL_H */ diff --git a/ddverify/models/goblint/include/linux/signal.h b/ddverify/models/goblint/include/linux/signal.h new file mode 100644 index 000000000..2b8814641 --- /dev/null +++ b/ddverify/models/goblint/include/linux/signal.h @@ -0,0 +1,54 @@ +#ifndef _LINUX_SIGNAL_H +#define _LINUX_SIGNAL_H + +#include +#include + +#include +#include + +#include + +/* + * These values of sa_flags are used only by the kernel as part of the + * irq handling routines. + * + * SA_INTERRUPT is also used by the irq handling routines. + * SA_SHIRQ is for shared interrupt support on PCI and EISA. + */ +#define SA_PROBE SA_ONESHOT +#define SA_SAMPLE_RANDOM SA_RESTART +#define SA_SHIRQ 0x04000000 + +static inline void sigfillset(sigset_t *set) +{ + switch (_NSIG_WORDS) { + default: + memset(set, -1, sizeof(sigset_t)); + break; + case 2: set->sig[1] = -1; + case 1: set->sig[0] = -1; + break; + } +} + +/* Some extensions for manipulating the low 32 signals in particular. */ + +static inline void sigaddsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] |= mask; +} + +static inline void sigdelsetmask(sigset_t *set, unsigned long mask) +{ + set->sig[0] &= ~mask; +} + +static inline int sigtestsetmask(sigset_t *set, unsigned long mask) +{ + return (set->sig[0] & mask) != 0; +} + +#define sigmask(sig) (1UL << ((sig) - 1)) + +#endif /* _LINUX_SIGNAL_H */ diff --git a/ddverify/models/goblint/include/linux/skbuff.h b/ddverify/models/goblint/include/linux/skbuff.h new file mode 100644 index 000000000..abc4822d9 --- /dev/null +++ b/ddverify/models/goblint/include/linux/skbuff.h @@ -0,0 +1,6 @@ +#ifndef _LINUX_SKBUFF_H +#define _LINUX_SKBUFF_H + +#include + +#endif /* _LINUX_SKBUFF_H */ diff --git a/ddverify/models/goblint/include/linux/slab.h b/ddverify/models/goblint/include/linux/slab.h new file mode 100644 index 000000000..edfc1e1ca --- /dev/null +++ b/ddverify/models/goblint/include/linux/slab.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_SLAB_H +#define _LINUX_SLAB_H + +#include +#include + +// DDV: TODO +void kfree(const void *); +// DDV: Body is defined in linux/mm/slab.c +void *kmalloc(size_t size, gfp_t flags); +// DDV: Body is defined in linux/mm/slab.c +void *kzalloc(size_t size, gfp_t flags); +// DDV: TODO +unsigned int ksize(const void *); + +#endif diff --git a/ddverify/models/goblint/include/linux/smp_lock.h b/ddverify/models/goblint/include/linux/smp_lock.h new file mode 100644 index 000000000..fbd5463bc --- /dev/null +++ b/ddverify/models/goblint/include/linux/smp_lock.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_SMPLOCK_H +#define __LINUX_SMPLOCK_H + +#include +#include + +spinlock_t kernel_lock; + +#define lock_kernel() spin_lock(&kernel_lock) +#define unlock_kernel() spin_unlock(&kernel_lock) + +#endif /* __LINUX_SMPLOCK_H */ diff --git a/ddverify/models/goblint/include/linux/socket.h b/ddverify/models/goblint/include/linux/socket.h new file mode 100644 index 000000000..365beed9c --- /dev/null +++ b/ddverify/models/goblint/include/linux/socket.h @@ -0,0 +1,109 @@ +#ifndef _LINUX_SOCKET_H +#define _LINUX_SOCKET_H + +#include /* iovec support */ + +/* Supported address families. */ +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* AppleTalk DDP */ +#define AF_NETROM 6 /* Amateur Radio NET/ROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_ATMPVC 8 /* ATM PVCs */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_INET6 10 /* IP version 6 */ +#define AF_ROSE 11 /* Amateur Radio X.25 PLP */ +#define AF_DECnet 12 /* Reserved for DECnet project */ +#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ +#define AF_KEY 15 /* PF_KEY key management API */ +#define AF_NETLINK 16 +#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ +#define AF_PACKET 17 /* Packet family */ +#define AF_ASH 18 /* Ash */ +#define AF_ECONET 19 /* Acorn Econet */ +#define AF_ATMSVC 20 /* ATM SVCs */ +#define AF_SNA 22 /* Linux SNA Project (nutters!) */ +#define AF_IRDA 23 /* IRDA sockets */ +#define AF_PPPOX 24 /* PPPoX sockets */ +#define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_LLC 26 /* Linux LLC */ +#define AF_TIPC 30 /* TIPC sockets */ +#define AF_BLUETOOTH 31 /* Bluetooth sockets */ +#define AF_MAX 32 /* For now.. */ + +/* Protocol families, same as address families. */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL AF_LOCAL +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_ATMPVC AF_ATMPVC +#define PF_X25 AF_X25 +#define PF_INET6 AF_INET6 +#define PF_ROSE AF_ROSE +#define PF_DECnet AF_DECnet +#define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY +#define PF_KEY AF_KEY +#define PF_NETLINK AF_NETLINK +#define PF_ROUTE AF_ROUTE +#define PF_PACKET AF_PACKET +#define PF_ASH AF_ASH +#define PF_ECONET AF_ECONET +#define PF_ATMSVC AF_ATMSVC +#define PF_SNA AF_SNA +#define PF_IRDA AF_IRDA +#define PF_PPPOX AF_PPPOX +#define PF_WANPIPE AF_WANPIPE +#define PF_LLC AF_LLC +#define PF_TIPC AF_TIPC +#define PF_BLUETOOTH AF_BLUETOOTH +#define PF_MAX AF_MAX + +/* Maximum queue length specifiable by listen. */ +#define SOMAXCONN 128 + +/* Flags we can use with send/ and recv. + Added those for 1003.1g not all are supported yet + */ + +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 /* Confirm path validity */ +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ +#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ +#define MSG_MORE 0x8000 /* Sender will send more */ + +#define MSG_EOF MSG_FIN + +struct msghdr { + void * msg_name; /* Socket name */ + int msg_namelen; /* Length of name */ +// struct iovec * msg_iov; /* Data blocks */ + __kernel_size_t msg_iovlen; /* Number of blocks */ + void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + __kernel_size_t msg_controllen; /* Length of cmsg list */ + unsigned msg_flags; +}; + +#endif /* _LINUX_SOCKET_H */ diff --git a/ddverify/models/goblint/include/linux/spinlock.h b/ddverify/models/goblint/include/linux/spinlock.h new file mode 100644 index 000000000..71531ae4f --- /dev/null +++ b/ddverify/models/goblint/include/linux/spinlock.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_SPINLOCK_H +#define __LINUX_SPINLOCK_H + +#include +#include + +// DDV: Bodies for all spinlock-functions are defined in linux/kernel/spinlock.c + +void spin_lock_init(spinlock_t *); +void spin_lock(spinlock_t *); +void spin_lock_irqsave(spinlock_t *, unsigned long); +void spin_lock_irq(spinlock_t *); +void spin_lock_bh(spinlock_t *); + +void spin_unlock(spinlock_t *); +void spin_unlock_irqrestore(spinlock_t *, unsigned long); +void spin_unlock_irq(spinlock_t *); +void spin_unlock_bh(spinlock_t *); + +#endif /* __LINUX_SPINLOCK_H */ diff --git a/ddverify/models/goblint/include/linux/spinlock_types.h b/ddverify/models/goblint/include/linux/spinlock_types.h new file mode 100644 index 000000000..86dd36d84 --- /dev/null +++ b/ddverify/models/goblint/include/linux/spinlock_types.h @@ -0,0 +1,21 @@ +#ifndef __LINUX_SPINLOCK_TYPES_H +#define __LINUX_SPINLOCK_TYPES_H + +typedef struct { + int init; + int locked; +} spinlock_t; + +typedef struct { + int something; +} rwlock_t; + +# define __SPIN_LOCK_UNLOCKED \ + { .init = 1, \ + .locked = 0 } + +#define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED + +#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED + +#endif /* __LINUX_SPINLOCK_TYPES_H */ diff --git a/ddverify/models/goblint/include/linux/stat.h b/ddverify/models/goblint/include/linux/stat.h new file mode 100644 index 000000000..262124881 --- /dev/null +++ b/ddverify/models/goblint/include/linux/stat.h @@ -0,0 +1,66 @@ +#ifndef _LINUX_STAT_H +#define _LINUX_STAT_H + +#include + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) + +#include +#include + +struct kstat { + unsigned long ino; + dev_t dev; +// umode_t mode; + unsigned int nlink; +// uid_t uid; +// gid_t gid; + dev_t rdev; + loff_t size; +// struct timespec atime; +// struct timespec mtime; +// struct timespec ctime; + unsigned long blksize; + unsigned long blocks; +}; + +#endif diff --git a/ddverify/models/goblint/include/linux/stddef.h b/ddverify/models/goblint/include/linux/stddef.h new file mode 100644 index 000000000..b3a2cadf9 --- /dev/null +++ b/ddverify/models/goblint/include/linux/stddef.h @@ -0,0 +1,20 @@ +#ifndef _LINUX_STDDEF_H +#define _LINUX_STDDEF_H + +#include + +#undef NULL +#if defined(__cplusplus) +#define NULL 0 +#else +#define NULL ((void *)0) +#endif + +#undef offsetof +#ifdef __compiler_offsetof +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#endif diff --git a/ddverify/models/goblint/include/linux/string.h b/ddverify/models/goblint/include/linux/string.h new file mode 100644 index 000000000..9734c2052 --- /dev/null +++ b/ddverify/models/goblint/include/linux/string.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_STRING_H_ +#define _LINUX_STRING_H_ + +#include +#include +#include + +extern char * strcpy(char *,const char *); +extern char * strncpy(char *,const char *, __kernel_size_t); +size_t strlcpy(char *, const char *, size_t); +extern char * strcat(char *, const char *); +extern char * strncat(char *, const char *, __kernel_size_t); +extern size_t strlcat(char *, const char *, __kernel_size_t); +extern int strcmp(const char *,const char *); +extern int strncmp(const char *,const char *,__kernel_size_t); +extern int strnicmp(const char *, const char *, __kernel_size_t); +extern char * strchr(const char *,int); +extern char * strnchr(const char *, size_t, int); +extern char * strrchr(const char *,int); +extern char * strstrip(char *); +extern char * strstr(const char *,const char *); +extern __kernel_size_t strlen(const char *); +extern __kernel_size_t strnlen(const char *,__kernel_size_t); +extern char * strpbrk(const char *,const char *); +extern char * strsep(char **,const char *); +extern __kernel_size_t strspn(const char *,const char *); +extern __kernel_size_t strcspn(const char *,const char *); + +extern void * memset(void *,int,__kernel_size_t); +extern void * memcpy(void *,const void *,__kernel_size_t); +extern void * memmove(void *,const void *,__kernel_size_t); +extern void * memscan(void *,int,__kernel_size_t); +extern int memcmp(const void *,const void *,__kernel_size_t); +extern void * memchr(const void *,int,__kernel_size_t); +#endif /* _LINUX_STRING_H_ */ diff --git a/ddverify/models/goblint/include/linux/stringify.h b/ddverify/models/goblint/include/linux/stringify.h new file mode 100644 index 000000000..0b4388356 --- /dev/null +++ b/ddverify/models/goblint/include/linux/stringify.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H + +/* Indirect stringification. Doing two levels allows the parameter to be a + * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) + * converts to "bar". + */ + +#define __stringify_1(x) #x +#define __stringify(x) __stringify_1(x) + +#endif /* !__LINUX_STRINGIFY_H */ diff --git a/ddverify/models/goblint/include/linux/suspend.h b/ddverify/models/goblint/include/linux/suspend.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/swap.h b/ddverify/models/goblint/include/linux/swap.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/sysfs.h b/ddverify/models/goblint/include/linux/sysfs.h new file mode 100644 index 000000000..4e1dd65ae --- /dev/null +++ b/ddverify/models/goblint/include/linux/sysfs.h @@ -0,0 +1,43 @@ +#ifndef _SYSFS_H_ +#define _SYSFS_H_ + +#include +#include + +struct kobject; +struct module; + +struct attribute { + const char * name; + struct module * owner; + mode_t mode; +}; + +struct attribute_group { + const char * name; + struct attribute ** attrs; +}; + + + +/** + * Use these macros to make defining attributes easier. See include/linux/device.h + * for examples.. + */ + +#define __ATTR(_name,_mode,_show,_store) { \ + .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \ + .show = _show, \ + .store = _store, \ +} + +#define __ATTR_RO(_name) { \ + .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \ + .show = _name##_show, \ +} + +#define __ATTR_NULL { .attr = { .name = NULL } } + +#define attr_name(_attr) (_attr).attr.name + +#endif /* _SYSFS_H_ */ diff --git a/ddverify/models/goblint/include/linux/sysrq.h b/ddverify/models/goblint/include/linux/sysrq.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/linux/termios.h b/ddverify/models/goblint/include/linux/termios.h new file mode 100644 index 000000000..758803c4c --- /dev/null +++ b/ddverify/models/goblint/include/linux/termios.h @@ -0,0 +1,7 @@ +#ifndef _LINUX_TERMIOS_H +#define _LINUX_TERMIOS_H + +#include +#include + +#endif diff --git a/ddverify/models/goblint/include/linux/threads.h b/ddverify/models/goblint/include/linux/threads.h new file mode 100644 index 000000000..ce23e273e --- /dev/null +++ b/ddverify/models/goblint/include/linux/threads.h @@ -0,0 +1,4 @@ +#ifndef _LINUX_THREADS_H +#define _LINUX_THREADS_H + +#endif diff --git a/ddverify/models/goblint/include/linux/time.h b/ddverify/models/goblint/include/linux/time.h new file mode 100644 index 000000000..907f53e8e --- /dev/null +++ b/ddverify/models/goblint/include/linux/time.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_TIME_H +#define _LINUX_TIME_H + +#include + +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; + + +/* Parameters used to convert the timespec values: */ +#define MSEC_PER_SEC 1000L +#define USEC_PER_MSEC 1000L +#define NSEC_PER_USEC 1000L +#define NSEC_PER_MSEC 1000000L +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L +#define FSEC_PER_SEC 1000000000000000L + + +void do_gettimeofday(struct timeval *tv); + +#endif + diff --git a/ddverify/models/goblint/include/linux/timer.h b/ddverify/models/goblint/include/linux/timer.h new file mode 100644 index 000000000..a531db358 --- /dev/null +++ b/ddverify/models/goblint/include/linux/timer.h @@ -0,0 +1,34 @@ +#ifndef _LINUX_TIMER_H +#define _LINUX_TIMER_H + +struct timer_list { + unsigned long expires; + void (*function)(unsigned long); + unsigned long data; + + short __ddv_active; + short __ddv_init; +}; + +#define TIMER_INITIALIZER(_function, _expires, _data) { \ + .function = (_function), \ + .expires = (_expires), \ + .data = (_data), \ + .__ddv_init = 1, \ + } + + +#define DEFINE_TIMER(_name, _function, _expires, _data) \ + struct timer_list _name = \ + TIMER_INITIALIZER(_function, _expires, _data) + +// DDV: Bodies for the following functions are defined in linux/kernel/timer.c +void init_timer(struct timer_list * timer); +void add_timer_on(struct timer_list *timer, int cpu); +void add_timer(struct timer_list *timer); +int del_timer(struct timer_list * timer); +int mod_timer(struct timer_list *timer, unsigned long expires); + +#define del_timer_sync(t) del_timer(t) + +#endif diff --git a/ddverify/models/goblint/include/linux/tty.h b/ddverify/models/goblint/include/linux/tty.h new file mode 100644 index 000000000..5bde39f3c --- /dev/null +++ b/ddverify/models/goblint/include/linux/tty.h @@ -0,0 +1,180 @@ +#ifndef _LINUX_TTY_H +#define _LINUX_TTY_H + +#include +#include +#include +#include +#include +#include +#include + +#include + + +/* + * The pty uses char_buf and flag_buf as a contiguous buffer + */ +#define PTY_BUF_SIZE 4*TTY_FLIPBUF_SIZE + +/* + * When a break, frame error, or parity error happens, these codes are + * stuffed into the flags buffer. + */ +#define TTY_NORMAL 0 +#define TTY_BREAK 1 +#define TTY_FRAME 2 +#define TTY_PARITY 3 +#define TTY_OVERRUN 4 + + +#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR]) +#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT]) +#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE]) +#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL]) +#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF]) +#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME]) +#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN]) +#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC]) +#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART]) +#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP]) +#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP]) +#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL]) +#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT]) +#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD]) +#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE]) +#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) +#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) + +#define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f)) +#define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f)) +#define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f)) +#define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f)) + +#define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK) +#define I_BRKINT(tty) _I_FLAG((tty),BRKINT) +#define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR) +#define I_PARMRK(tty) _I_FLAG((tty),PARMRK) +#define I_INPCK(tty) _I_FLAG((tty),INPCK) +#define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP) +#define I_INLCR(tty) _I_FLAG((tty),INLCR) +#define I_IGNCR(tty) _I_FLAG((tty),IGNCR) +#define I_ICRNL(tty) _I_FLAG((tty),ICRNL) +#define I_IUCLC(tty) _I_FLAG((tty),IUCLC) +#define I_IXON(tty) _I_FLAG((tty),IXON) +#define I_IXANY(tty) _I_FLAG((tty),IXANY) +#define I_IXOFF(tty) _I_FLAG((tty),IXOFF) +#define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL) +#define I_IUTF8(tty) _I_FLAG((tty),IUTF8) + +#define O_OPOST(tty) _O_FLAG((tty),OPOST) +#define O_OLCUC(tty) _O_FLAG((tty),OLCUC) +#define O_ONLCR(tty) _O_FLAG((tty),ONLCR) +#define O_OCRNL(tty) _O_FLAG((tty),OCRNL) +#define O_ONOCR(tty) _O_FLAG((tty),ONOCR) +#define O_ONLRET(tty) _O_FLAG((tty),ONLRET) +#define O_OFILL(tty) _O_FLAG((tty),OFILL) +#define O_OFDEL(tty) _O_FLAG((tty),OFDEL) +#define O_NLDLY(tty) _O_FLAG((tty),NLDLY) +#define O_CRDLY(tty) _O_FLAG((tty),CRDLY) +#define O_TABDLY(tty) _O_FLAG((tty),TABDLY) +#define O_BSDLY(tty) _O_FLAG((tty),BSDLY) +#define O_VTDLY(tty) _O_FLAG((tty),VTDLY) +#define O_FFDLY(tty) _O_FLAG((tty),FFDLY) + +#define C_BAUD(tty) _C_FLAG((tty),CBAUD) +#define C_CSIZE(tty) _C_FLAG((tty),CSIZE) +#define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB) +#define C_CREAD(tty) _C_FLAG((tty),CREAD) +#define C_PARENB(tty) _C_FLAG((tty),PARENB) +#define C_PARODD(tty) _C_FLAG((tty),PARODD) +#define C_HUPCL(tty) _C_FLAG((tty),HUPCL) +#define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL) +#define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD) +#define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS) + +#define L_ISIG(tty) _L_FLAG((tty),ISIG) +#define L_ICANON(tty) _L_FLAG((tty),ICANON) +#define L_XCASE(tty) _L_FLAG((tty),XCASE) +#define L_ECHO(tty) _L_FLAG((tty),ECHO) +#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) +#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) +#define L_ECHONL(tty) _L_FLAG((tty),ECHONL) +#define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH) +#define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP) +#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) +#define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT) +#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) +#define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO) +#define L_PENDIN(tty) _L_FLAG((tty),PENDIN) +#define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN) + + +struct tty_struct { + int magic; + struct tty_driver *driver; + int index; + struct termios *termios, *termios_locked; + char name[64]; + + unsigned long flags; + int count; + unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; + unsigned int receive_room; /* Bytes free for queue */ + + wait_queue_head_t write_wait; + wait_queue_head_t read_wait; + void *disc_data; + void *driver_data; + + unsigned char closing:1; +}; + + +/* tty magic number */ +#define TTY_MAGIC 0x5401 + +/* + * These bits are used in the flags field of the tty structure. + * + * So that interrupts won't be able to mess up the queues, + * copy_to_cooked must be atomic with respect to itself, as must + * tty->write. Thus, you must use the inline functions set_bit() and + * clear_bit() to make things atomic. + */ +#define TTY_THROTTLED 0 /* Call unthrottle() at threshold min */ +#define TTY_IO_ERROR 1 /* Canse an I/O error (may be no ldisc too) */ +#define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */ +#define TTY_EXCLUSIVE 3 /* Exclusive open mode */ +#define TTY_DEBUG 4 /* Debugging */ +#define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */ +#define TTY_PUSH 6 /* n_tty private */ +#define TTY_CLOSING 7 /* ->close() in progress */ +#define TTY_LDISC 9 /* Line discipline attached */ +#define TTY_HW_COOK_OUT 14 /* Hardware can do output cooking */ +#define TTY_HW_COOK_IN 15 /* Hardware can do input cooking */ +#define TTY_PTY_LOCK 16 /* pty private */ +#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ +#define TTY_HUPPED 18 /* Post driver->hangup() */ + +extern struct termios tty_std_termios; + + +extern int tty_check_change(struct tty_struct * tty); +extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); +extern int tty_unregister_ldisc(int disc); +extern int tty_register_driver(struct tty_driver *driver); +extern int tty_unregister_driver(struct tty_driver *driver); + +extern void tty_wait_until_sent(struct tty_struct * tty, long timeout); + + +extern void tty_hangup(struct tty_struct * tty); +extern int tty_hung_up_p(struct file * filp); +extern void do_SAK(struct tty_struct *tty); +extern void tty_flip_buffer_push(struct tty_struct *tty); +extern int tty_get_baud_rate(struct tty_struct *tty); + +extern void tty_wakeup(struct tty_struct *tty); +extern void tty_ldisc_flush(struct tty_struct *tty); +#endif diff --git a/ddverify/models/goblint/include/linux/tty_driver.h b/ddverify/models/goblint/include/linux/tty_driver.h new file mode 100644 index 000000000..805c70977 --- /dev/null +++ b/ddverify/models/goblint/include/linux/tty_driver.h @@ -0,0 +1,166 @@ +#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +// DDV: TODO +void put_tty_driver(struct tty_driver *driver); +// DDV: is defined in driver/char/tty_io.c +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ diff --git a/ddverify/models/goblint/include/linux/tty_driver.h,v b/ddverify/models/goblint/include/linux/tty_driver.h,v new file mode 100644 index 000000000..f5748324d --- /dev/null +++ b/ddverify/models/goblint/include/linux/tty_driver.h,v @@ -0,0 +1,187 @@ +head 1.1; +access; +symbols; +locks; strict; +comment @ * @; + + +1.1 +date 2007.02.11.11.29.05; author thomaswi; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@Initial revision +@ +text +@#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + + +#include +#include +#include + +struct tty_struct; + + +struct tty_operations { + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + +struct tty_driver { + int magic; /* magic number for this structure */ + struct cdev cdev; + struct module *owner; + const char *driver_name; + const char *name; + int name_base; /* offset of printed name */ + int major; /* major device number */ + int minor_start; /* start of minor device number */ + int minor_num; /* number of *possible* devices */ + int num; /* number of devices allocated */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int refcount; /* for loadable tty drivers */ + struct proc_dir_entry *proc_entry; /* /proc fs entry */ + + /* + * Interface routines from the upper tty layer to the tty + * driver. Will be replaced with struct tty_operations. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, + const unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*break_ctl)(struct tty_struct *tty, int state); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + void (*wait_until_sent)(struct tty_struct *tty, int timeout); + void (*send_xchar)(struct tty_struct *tty, char ch); + int (*read_proc)(char *page, char **start, off_t off, + int count, int *eof, void *data); + int (*write_proc)(struct file *file, const char __user *buffer, + unsigned long count, void *data); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +}; + + +// DDV: Body of this function is defined in driver/char/tty_io.c +struct tty_driver *alloc_tty_driver(int lines); +void put_tty_driver(struct tty_driver *driver); +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op); + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need + * to be registered with a call to tty_register_driver() when the + * device is found in the system and unregistered with a call to + * tty_unregister_device() so the devices will be show up + * properly in sysfs. If not set, driver->num entries will be + * created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices + * that can appear and disappear while the main tty driver is + * registered with the tty core. + * + * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead + * use dynamic memory keyed through the devpts filesystem. This + * is only applicable to the pty driver. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ +@ diff --git a/ddverify/models/goblint/include/linux/tty_flip.h b/ddverify/models/goblint/include/linux/tty_flip.h new file mode 100644 index 000000000..b0864fa14 --- /dev/null +++ b/ddverify/models/goblint/include/linux/tty_flip.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_TTY_FLIP_H +#define _LINUX_TTY_FLIP_H + +int tty_buffer_request_room(struct tty_struct *tty, size_t size); +int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size); +int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); +int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); +int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); +void tty_schedule_flip(struct tty_struct *tty); + +inline int tty_insert_flip_char(struct tty_struct *tty, unsigned char ch, char flag); + +#endif /* _LINUX_TTY_FLIP_H */ diff --git a/ddverify/models/goblint/include/linux/tty_ldisc.h b/ddverify/models/goblint/include/linux/tty_ldisc.h new file mode 100644 index 000000000..35466133a --- /dev/null +++ b/ddverify/models/goblint/include/linux/tty_ldisc.h @@ -0,0 +1,51 @@ +#ifndef _LINUX_TTY_LDISC_H +#define _LINUX_TTY_LDISC_H + + +#include +#include + +struct tty_ldisc { + int magic; + char *name; + int num; + int flags; + + /* + * The following routines are called from above. + */ + int (*open)(struct tty_struct *); + void (*close)(struct tty_struct *); + void (*flush_buffer)(struct tty_struct *tty); + ssize_t (*chars_in_buffer)(struct tty_struct *tty); + ssize_t (*read)(struct tty_struct * tty, struct file * file, + unsigned char __user * buf, size_t nr); + ssize_t (*write)(struct tty_struct * tty, struct file * file, + const unsigned char * buf, size_t nr); + int (*ioctl)(struct tty_struct * tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + unsigned int (*poll)(struct tty_struct *, struct file *, + struct poll_table_struct *); + int (*hangup)(struct tty_struct *tty); + + /* + * The following routines are called from below. + */ + void (*receive_buf)(struct tty_struct *, const unsigned char *cp, + char *fp, int count); + void (*write_wakeup)(struct tty_struct *); + + struct module *owner; + + int refcount; +}; + +#define TTY_LDISC_MAGIC 0x5403 + +#define LDISC_FLAG_DEFINED 0x00000001 + +#define MODULE_ALIAS_LDISC(ldisc) \ + MODULE_ALIAS("tty-ldisc-" __stringify(ldisc)) + +#endif /* _LINUX_TTY_LDISC_H */ diff --git a/ddverify/models/goblint/include/linux/types.h b/ddverify/models/goblint/include/linux/types.h new file mode 100644 index 000000000..b437e9baa --- /dev/null +++ b/ddverify/models/goblint/include/linux/types.h @@ -0,0 +1,105 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#include +#include + +#define __bitwise + +typedef __u32 __kernel_dev_t; + +typedef __kernel_dev_t dev_t; +typedef __kernel_ino_t ino_t; +typedef __kernel_mode_t mode_t; +typedef __kernel_nlink_t nlink_t; +typedef __kernel_off_t off_t; +typedef __kernel_pid_t pid_t; +typedef __kernel_daddr_t daddr_t; +typedef __kernel_key_t key_t; +typedef __kernel_suseconds_t suseconds_t; +typedef __kernel_timer_t timer_t; +typedef __kernel_clockid_t clockid_t; +typedef __kernel_mqd_t mqd_t; + +typedef __kernel_uid32_t uid_t; +typedef __kernel_gid32_t gid_t; +typedef __kernel_uid16_t uid16_t; +typedef __kernel_gid16_t gid16_t; + + +typedef long long loff_t; + +/* + * The following typedefs are also protected by individual ifdefs for + * historical reasons: + */ +#ifndef _SIZE_T +#define _SIZE_T +typedef __kernel_size_t size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __kernel_ssize_t ssize_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef __kernel_ptrdiff_t ptrdiff_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef __kernel_time_t time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef __kernel_clock_t clock_t; +#endif + +#ifndef _CADDR_T +#define _CADDR_T +typedef __kernel_caddr_t caddr_t; +#endif + + +/* bsd */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +/* sysv */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + + +typedef __u8 uint8_t; +typedef __u16 uint16_t; +typedef __u32 uint32_t; + +typedef __u64 uint64_t; +typedef __u64 u_int64_t; +//typedef __s64 int64_t; + +typedef unsigned gfp_t; + +#ifndef HAVE_SECTOR_T +typedef unsigned long sector_t; +#endif + +#ifndef HAVE_BLKCNT_T +typedef unsigned long blkcnt_t; +#endif + +typedef __u16 __bitwise __le16; +typedef __u16 __bitwise __be16; +typedef __u32 __bitwise __le32; +typedef __u32 __bitwise __be32; +typedef __u64 __bitwise __le64; +typedef __u64 __bitwise __be64; + +#endif diff --git a/ddverify/models/goblint/include/linux/uio.h b/ddverify/models/goblint/include/linux/uio.h new file mode 100644 index 000000000..c59931d23 --- /dev/null +++ b/ddverify/models/goblint/include/linux/uio.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_UIO_H +#define __LINUX_UIO_H + +#include +#include + +struct kvec { + void *iov_base; /* and that should *never* hold a userland pointer */ + size_t iov_len; +}; + +#endif diff --git a/ddverify/models/goblint/include/linux/videodev.h b/ddverify/models/goblint/include/linux/videodev.h new file mode 100644 index 000000000..2628e86ac --- /dev/null +++ b/ddverify/models/goblint/include/linux/videodev.h @@ -0,0 +1,346 @@ +#ifndef __LINUX_VIDEODEV_H +#define __LINUX_VIDEODEV_H + +#include +#include +#include + +extern struct video_device* video_devdata(struct file*); + +static inline void *video_get_drvdata(struct video_device *dev) +{ + return dev->priv; +} + +static inline void video_set_drvdata(struct video_device *dev, void *data) +{ + dev->priv = data; +} + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +struct video_capability +{ + char name[32]; + int type; + int channels; /* Num channels */ + int audios; /* Num audio devices */ + int maxwidth; /* Supported width */ + int maxheight; /* And height */ + int minwidth; /* Supported width */ + int minheight; /* And height */ +}; + + +struct video_channel +{ + int channel; + char name[32]; + int tuners; + __u32 flags; +#define VIDEO_VC_TUNER 1 /* Channel has a tuner */ +#define VIDEO_VC_AUDIO 2 /* Channel has audio */ + __u16 type; +#define VIDEO_TYPE_TV 1 +#define VIDEO_TYPE_CAMERA 2 + __u16 norm; /* Norm set by channel */ +}; + + +struct video_tuner +{ + int tuner; + char name[32]; + unsigned long rangelow, rangehigh; /* Tuner range */ + __u32 flags; +#define VIDEO_TUNER_PAL 1 +#define VIDEO_TUNER_NTSC 2 +#define VIDEO_TUNER_SECAM 4 +#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */ +#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */ +#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */ +#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */ +#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */ + __u16 mode; /* PAL/NTSC/SECAM/OTHER */ +#define VIDEO_MODE_PAL 0 +#define VIDEO_MODE_NTSC 1 +#define VIDEO_MODE_SECAM 2 +#define VIDEO_MODE_AUTO 3 + __u16 signal; /* Signal strength 16bit scale */ +}; + + +struct video_picture +{ + __u16 brightness; + __u16 hue; + __u16 colour; + __u16 contrast; + __u16 whiteness; /* Black and white only */ + __u16 depth; /* Capture depth */ + __u16 palette; /* Palette in use */ +#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ +#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ +#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ +#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */ +#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */ +#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */ +#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */ +#define VIDEO_PALETTE_YUYV 8 +#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */ +#define VIDEO_PALETTE_YUV420 10 +#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */ +#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */ +#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */ +#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */ +#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */ +#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ +#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ +#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ +}; + +struct video_audio +{ + int audio; /* Audio channel */ + __u16 volume; /* If settable */ + __u16 bass, treble; + __u32 flags; +#define VIDEO_AUDIO_MUTE 1 +#define VIDEO_AUDIO_MUTABLE 2 +#define VIDEO_AUDIO_VOLUME 4 +#define VIDEO_AUDIO_BASS 8 +#define VIDEO_AUDIO_TREBLE 16 +#define VIDEO_AUDIO_BALANCE 32 + char name[16]; +#define VIDEO_SOUND_MONO 1 +#define VIDEO_SOUND_STEREO 2 +#define VIDEO_SOUND_LANG1 4 +#define VIDEO_SOUND_LANG2 8 + __u16 mode; + __u16 balance; /* Stereo balance */ + __u16 step; /* Step actual volume uses */ +}; + +struct video_clip +{ + __s32 x,y; + __s32 width, height; + struct video_clip *next; /* For user use/driver use only */ +}; + +struct video_window +{ + __u32 x,y; /* Position of window */ + __u32 width,height; /* Its size */ + __u32 chromakey; + __u32 flags; + struct video_clip __user *clips; /* Set only */ + int clipcount; +#define VIDEO_WINDOW_INTERLACE 1 +#define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */ +#define VIDEO_CLIP_BITMAP -1 +/* bitmap is 1024x625, a '1' bit represents a clipped pixel */ +#define VIDEO_CLIPMAP_SIZE (128 * 625) +}; + +struct video_capture +{ + __u32 x,y; /* Offsets into image */ + __u32 width, height; /* Area to capture */ + __u16 decimation; /* Decimation divider */ + __u16 flags; /* Flags for capture */ +#define VIDEO_CAPTURE_ODD 0 /* Temporal */ +#define VIDEO_CAPTURE_EVEN 1 +}; + +struct video_buffer +{ + void *base; + int height,width; + int depth; + int bytesperline; +}; + +struct video_mmap +{ + unsigned int frame; /* Frame (0 - n) for double buffer */ + int height,width; + unsigned int format; /* should be VIDEO_PALETTE_* */ +}; + +struct video_key +{ + __u8 key[8]; + __u32 flags; +}; + +struct video_mbuf +{ + int size; /* Total memory to map */ + int frames; /* Frames */ + int offsets[VIDEO_MAX_FRAME]; +}; + +#define VIDEO_NO_UNIT (-1) + +struct video_unit +{ + int video; /* Video minor */ + int vbi; /* VBI minor */ + int radio; /* Radio minor */ + int audio; /* Audio minor */ + int teletext; /* Teletext minor */ +}; + +struct vbi_format { + __u32 sampling_rate; /* in Hz */ + __u32 samples_per_line; + __u32 sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */ + __s32 start[2]; /* starting line for each frame */ + __u32 count[2]; /* count of lines for each frame */ + __u32 flags; +#define VBI_UNSYNC 1 /* can distingues between top/bottom field */ +#define VBI_INTERLACED 2 /* lines are interlaced */ +}; + +/* video_info is biased towards hardware mpeg encode/decode */ +/* but it could apply generically to any hardware compressor/decompressor */ +struct video_info +{ + __u32 frame_count; /* frames output since decode/encode began */ + __u32 h_size; /* current unscaled horizontal size */ + __u32 v_size; /* current unscaled veritcal size */ + __u32 smpte_timecode; /* current SMPTE timecode (for current GOP) */ + __u32 picture_type; /* current picture type */ + __u32 temporal_reference; /* current temporal reference */ + __u8 user_data[256]; /* user data last found in compressed stream */ + /* user_data[0] contains user data flags, user_data[1] has count */ +}; + +/* generic structure for setting playback modes */ +struct video_play_mode +{ + int mode; + int p1; + int p2; +}; + +/* for loading microcode / fpga programming */ +struct video_code +{ + char loadwhat[16]; /* name or tag of file being passed */ + int datasize; + __u8 *data; +}; + + +#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */ +#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */ +#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */ +#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */ +#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */ +#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */ +#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */ +#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */ +#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */ +#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */ +#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */ +#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */ +#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) */ +#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */ +#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */ +#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */ +#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */ +#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */ +#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */ +#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */ +#define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */ +#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */ +#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */ +#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */ +#define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */ +#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */ +#define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */ +#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */ +#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */ + + +#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */ + +/* VIDIOCSWRITEMODE */ +#define VID_WRITE_MPEG_AUD 0 +#define VID_WRITE_MPEG_VID 1 +#define VID_WRITE_OSD 2 +#define VID_WRITE_TTX 3 +#define VID_WRITE_CC 4 +#define VID_WRITE_MJPEG 5 + +/* VIDIOCSPLAYMODE */ +#define VID_PLAY_VID_OUT_MODE 0 + /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */ +#define VID_PLAY_GENLOCK 1 + /* p1: 0 = OFF, 1 = ON */ + /* p2: GENLOCK FINE DELAY value */ +#define VID_PLAY_NORMAL 2 +#define VID_PLAY_PAUSE 3 +#define VID_PLAY_SINGLE_FRAME 4 +#define VID_PLAY_FAST_FORWARD 5 +#define VID_PLAY_SLOW_MOTION 6 +#define VID_PLAY_IMMEDIATE_NORMAL 7 +#define VID_PLAY_SWITCH_CHANNELS 8 +#define VID_PLAY_FREEZE_FRAME 9 +#define VID_PLAY_STILL_MODE 10 +#define VID_PLAY_MASTER_MODE 11 + /* p1: see below */ +#define VID_PLAY_MASTER_NONE 1 +#define VID_PLAY_MASTER_VIDEO 2 +#define VID_PLAY_MASTER_AUDIO 3 +#define VID_PLAY_ACTIVE_SCANLINES 12 + /* p1 = first active; p2 = last active */ +#define VID_PLAY_RESET 13 +#define VID_PLAY_END_MARK 14 + + + +#define VID_HARDWARE_BT848 1 +#define VID_HARDWARE_QCAM_BW 2 +#define VID_HARDWARE_PMS 3 +#define VID_HARDWARE_QCAM_C 4 +#define VID_HARDWARE_PSEUDO 5 +#define VID_HARDWARE_SAA5249 6 +#define VID_HARDWARE_AZTECH 7 +#define VID_HARDWARE_SF16MI 8 +#define VID_HARDWARE_RTRACK 9 +#define VID_HARDWARE_ZOLTRIX 10 +#define VID_HARDWARE_SAA7146 11 +#define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */ +#define VID_HARDWARE_RTRACK2 13 +#define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */ +#define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */ +#define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */ +#define VID_HARDWARE_BROADWAY 17 /* Broadway project */ +#define VID_HARDWARE_GEMTEK 18 +#define VID_HARDWARE_TYPHOON 19 +#define VID_HARDWARE_VINO 20 /* SGI Indy Vino */ +#define VID_HARDWARE_CADET 21 /* Cadet radio */ +#define VID_HARDWARE_TRUST 22 /* Trust FM Radio */ +#define VID_HARDWARE_TERRATEC 23 /* TerraTec ActiveRadio */ +#define VID_HARDWARE_CPIA 24 +#define VID_HARDWARE_ZR36120 25 /* Zoran ZR36120/ZR36125 */ +#define VID_HARDWARE_ZR36067 26 /* Zoran ZR36067/36060 */ +#define VID_HARDWARE_OV511 27 +#define VID_HARDWARE_ZR356700 28 /* Zoran 36700 series */ +#define VID_HARDWARE_W9966 29 +#define VID_HARDWARE_SE401 30 /* SE401 USB webcams */ +#define VID_HARDWARE_PWC 31 /* Philips webcams */ +#define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */ +#define VID_HARDWARE_CPIA2 33 +#define VID_HARDWARE_VICAM 34 +#define VID_HARDWARE_SF16FMR2 35 +#define VID_HARDWARE_W9968CF 36 +#define VID_HARDWARE_SAA7114H 37 +#define VID_HARDWARE_SN9C102 38 +#define VID_HARDWARE_ARV 39 + +#endif /* __LINUX_VIDEODEV_H */ diff --git a/ddverify/models/goblint/include/linux/videodev2.h b/ddverify/models/goblint/include/linux/videodev2.h new file mode 100644 index 000000000..df5c46543 --- /dev/null +++ b/ddverify/models/goblint/include/linux/videodev2.h @@ -0,0 +1,1351 @@ +/* + * Video for Linux Two + * + * Header file for v4l or V4L2 drivers and applications + * with public API. + * All kernel-specific stuff were moved to media/v4l2-dev.h, so + * no #if __KERNEL tests are allowed here + * + * See http://linuxtv.org for more info + * + * Author: Bill Dirks + * Justin Schoeman + * et al. + */ +#ifndef __LINUX_VIDEODEV2_H +#define __LINUX_VIDEODEV2_H +#ifdef __KERNEL__ +#include /* need struct timeval */ +#include /* need __user */ +#else +#define __user +#endif +#include + +/* + * Common stuff for both V4L1 and V4L2 + * Moved from videodev.h + */ +#define VIDEO_MAX_FRAME 32 + +#define VID_TYPE_CAPTURE 1 /* Can capture */ +#define VID_TYPE_TUNER 2 /* Can tune */ +#define VID_TYPE_TELETEXT 4 /* Does teletext */ +#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */ +#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */ +#define VID_TYPE_CLIPPING 32 /* Can clip */ +#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */ +#define VID_TYPE_SCALES 128 /* Scalable */ +#define VID_TYPE_MONOCHROME 256 /* Monochrome only */ +#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */ +#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */ +#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ +#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ +#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ + +/* + * M I S C E L L A N E O U S + */ + +/* Four-character-code (FOURCC) */ +#define v4l2_fourcc(a,b,c,d)\ + (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) + +/* + * E N U M S + */ +enum v4l2_field { + V4L2_FIELD_ANY = 0, /* driver can choose from none, + top, bottom, interlaced + depending on whatever it thinks + is approximate ... */ + V4L2_FIELD_NONE = 1, /* this device has no fields ... */ + V4L2_FIELD_TOP = 2, /* top field only */ + V4L2_FIELD_BOTTOM = 3, /* bottom field only */ + V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ + V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one + buffer, top-bottom order */ + V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ + V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into + separate buffers */ +}; +#define V4L2_FIELD_HAS_TOP(field) \ + ((field) == V4L2_FIELD_TOP ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTTOM(field) \ + ((field) == V4L2_FIELD_BOTTOM ||\ + (field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) +#define V4L2_FIELD_HAS_BOTH(field) \ + ((field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) + +enum v4l2_buf_type { + V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, + V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, + V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, + V4L2_BUF_TYPE_VBI_CAPTURE = 4, + V4L2_BUF_TYPE_VBI_OUTPUT = 5, +#if 1 + /* Experimental Sliced VBI */ + V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, + V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, +#endif + V4L2_BUF_TYPE_PRIVATE = 0x80, +}; + +enum v4l2_ctrl_type { + V4L2_CTRL_TYPE_INTEGER = 1, + V4L2_CTRL_TYPE_BOOLEAN = 2, + V4L2_CTRL_TYPE_MENU = 3, + V4L2_CTRL_TYPE_BUTTON = 4, + V4L2_CTRL_TYPE_INTEGER64 = 5, + V4L2_CTRL_TYPE_CTRL_CLASS = 6, +}; + +enum v4l2_tuner_type { + V4L2_TUNER_RADIO = 1, + V4L2_TUNER_ANALOG_TV = 2, + V4L2_TUNER_DIGITAL_TV = 3, +}; + +enum v4l2_memory { + V4L2_MEMORY_MMAP = 1, + V4L2_MEMORY_USERPTR = 2, + V4L2_MEMORY_OVERLAY = 3, +}; + +/* see also http://vektor.theorem.ca/graphics/ycbcr/ */ +enum v4l2_colorspace { + /* ITU-R 601 -- broadcast NTSC/PAL */ + V4L2_COLORSPACE_SMPTE170M = 1, + + /* 1125-Line (US) HDTV */ + V4L2_COLORSPACE_SMPTE240M = 2, + + /* HD and modern captures. */ + V4L2_COLORSPACE_REC709 = 3, + + /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */ + V4L2_COLORSPACE_BT878 = 4, + + /* These should be useful. Assume 601 extents. */ + V4L2_COLORSPACE_470_SYSTEM_M = 5, + V4L2_COLORSPACE_470_SYSTEM_BG = 6, + + /* I know there will be cameras that send this. So, this is + * unspecified chromaticities and full 0-255 on each of the + * Y'CbCr components + */ + V4L2_COLORSPACE_JPEG = 7, + + /* For RGB colourspaces, this is probably a good start. */ + V4L2_COLORSPACE_SRGB = 8, +}; + +enum v4l2_priority { + V4L2_PRIORITY_UNSET = 0, /* not initialized */ + V4L2_PRIORITY_BACKGROUND = 1, + V4L2_PRIORITY_INTERACTIVE = 2, + V4L2_PRIORITY_RECORD = 3, + V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE, +}; + +struct v4l2_rect { + __s32 left; + __s32 top; + __s32 width; + __s32 height; +}; + +struct v4l2_fract { + __u32 numerator; + __u32 denominator; +}; + +/* + * D R I V E R C A P A B I L I T I E S + */ +struct v4l2_capability +{ + __u8 driver[16]; /* i.e. "bttv" */ + __u8 card[32]; /* i.e. "Hauppauge WinTV" */ + __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ + __u32 version; /* should use KERNEL_VERSION() */ + __u32 capabilities; /* Device capabilities */ + __u32 reserved[4]; +}; + +/* Values for 'capabilities' field */ +#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */ +#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */ +#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ +#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ +#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ +#if 1 +#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ +#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ +#endif +#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ + +#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ +#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ +#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ + +#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ +#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ +#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ + +/* + * V I D E O I M A G E F O R M A T + */ +struct v4l2_pix_format +{ + __u32 width; + __u32 height; + __u32 pixelformat; + enum v4l2_field field; + __u32 bytesperline; /* for padding, zero if unused */ + __u32 sizeimage; + enum v4l2_colorspace colorspace; + __u32 priv; /* private data, depends on pixelformat */ +}; + +/* Pixel format FOURCC depth Description */ +#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */ +#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */ +#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */ +#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */ +#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */ +#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */ +#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */ +#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ +#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ +#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ +#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ +#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ +#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */ +#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */ +#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */ + +/* two planes -- one Y, one Cr + Cb interleaved */ +#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */ + +/* The following formats are not defined in the V4L2 specification */ +#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */ +#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ +#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ +#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ +#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */ + +/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ +#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ + +/* compressed formats */ +#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ +#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */ +#define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */ +#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG-1/2/4 */ + +/* Vendor-specific formats */ +#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */ +#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */ + +/* + * F O R M A T E N U M E R A T I O N + */ +struct v4l2_fmtdesc +{ + __u32 index; /* Format number */ + enum v4l2_buf_type type; /* buffer type */ + __u32 flags; + __u8 description[32]; /* Description string */ + __u32 pixelformat; /* Format fourcc */ + __u32 reserved[4]; +}; + +#define V4L2_FMT_FLAG_COMPRESSED 0x0001 + +#if 1 + /* Experimental Frame Size and frame rate enumeration */ +/* + * F R A M E S I Z E E N U M E R A T I O N + */ +enum v4l2_frmsizetypes +{ + V4L2_FRMSIZE_TYPE_DISCRETE = 1, + V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, + V4L2_FRMSIZE_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmsize_discrete +{ + __u32 width; /* Frame width [pixel] */ + __u32 height; /* Frame height [pixel] */ +}; + +struct v4l2_frmsize_stepwise +{ + __u32 min_width; /* Minimum frame width [pixel] */ + __u32 max_width; /* Maximum frame width [pixel] */ + __u32 step_width; /* Frame width step size [pixel] */ + __u32 min_height; /* Minimum frame height [pixel] */ + __u32 max_height; /* Maximum frame height [pixel] */ + __u32 step_height; /* Frame height step size [pixel] */ +}; + +struct v4l2_frmsizeenum +{ + __u32 index; /* Frame size number */ + __u32 pixel_format; /* Pixel format */ + __u32 type; /* Frame size type the device supports. */ + + union { /* Frame size */ + struct v4l2_frmsize_discrete discrete; + struct v4l2_frmsize_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; + +/* + * F R A M E R A T E E N U M E R A T I O N + */ +enum v4l2_frmivaltypes +{ + V4L2_FRMIVAL_TYPE_DISCRETE = 1, + V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, + V4L2_FRMIVAL_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmival_stepwise +{ + struct v4l2_fract min; /* Minimum frame interval [s] */ + struct v4l2_fract max; /* Maximum frame interval [s] */ + struct v4l2_fract step; /* Frame interval step size [s] */ +}; + +struct v4l2_frmivalenum +{ + __u32 index; /* Frame format index */ + __u32 pixel_format; /* Pixel format */ + __u32 width; /* Frame width */ + __u32 height; /* Frame height */ + __u32 type; /* Frame interval type the device supports. */ + + union { /* Frame interval */ + struct v4l2_fract discrete; + struct v4l2_frmival_stepwise stepwise; + }; + + __u32 reserved[2]; /* Reserved space for future use */ +}; +#endif + +/* + * T I M E C O D E + */ +struct v4l2_timecode +{ + __u32 type; + __u32 flags; + __u8 frames; + __u8 seconds; + __u8 minutes; + __u8 hours; + __u8 userbits[4]; +}; + +/* Type */ +#define V4L2_TC_TYPE_24FPS 1 +#define V4L2_TC_TYPE_25FPS 2 +#define V4L2_TC_TYPE_30FPS 3 +#define V4L2_TC_TYPE_50FPS 4 +#define V4L2_TC_TYPE_60FPS 5 + +/* Flags */ +#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */ +#define V4L2_TC_FLAG_COLORFRAME 0x0002 +#define V4L2_TC_USERBITS_field 0x000C +#define V4L2_TC_USERBITS_USERDEFINED 0x0000 +#define V4L2_TC_USERBITS_8BITCHARS 0x0008 +/* The above is based on SMPTE timecodes */ + +#ifdef __KERNEL__ +/* + * 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 + * + * ### WARNING: This experimental MPEG compression API is obsolete. + * ### It is replaced by the MPEG controls API. + * ### This old API will disappear in the near future! + * + */ +enum v4l2_bitrate_mode { + V4L2_BITRATE_NONE = 0, /* not specified */ + V4L2_BITRATE_CBR, /* constant bitrate */ + V4L2_BITRATE_VBR, /* variable bitrate */ +}; +struct v4l2_bitrate { + /* rates are specified in kbit/sec */ + enum v4l2_bitrate_mode mode; + __u32 min; + __u32 target; /* use this one for CBR */ + __u32 max; +}; + +enum v4l2_mpeg_streamtype { + V4L2_MPEG_SS_1, /* MPEG-1 system stream */ + V4L2_MPEG_PS_2, /* MPEG-2 program stream */ + V4L2_MPEG_TS_2, /* MPEG-2 transport stream */ + V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */ +}; +enum v4l2_mpeg_audiotype { + V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */ + V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */ + V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */ + V4L2_MPEG_AC3, /* AC3 */ + V4L2_MPEG_LPCM, /* LPCM */ +}; +enum v4l2_mpeg_videotype { + V4L2_MPEG_VI_1, /* MPEG-1 */ + V4L2_MPEG_VI_2, /* MPEG-2 */ +}; +enum v4l2_mpeg_aspectratio { + V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */ + V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */ + V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */ + V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */ +}; + +struct v4l2_mpeg_compression { + /* general */ + enum v4l2_mpeg_streamtype st_type; + struct v4l2_bitrate st_bitrate; + + /* transport streams */ + __u16 ts_pid_pmt; + __u16 ts_pid_audio; + __u16 ts_pid_video; + __u16 ts_pid_pcr; + + /* program stream */ + __u16 ps_size; + __u16 reserved_1; /* align */ + + /* audio */ + enum v4l2_mpeg_audiotype au_type; + struct v4l2_bitrate au_bitrate; + __u32 au_sample_rate; + __u8 au_pesid; + __u8 reserved_2[3]; /* align */ + + /* video */ + enum v4l2_mpeg_videotype vi_type; + enum v4l2_mpeg_aspectratio vi_aspect_ratio; + struct v4l2_bitrate vi_bitrate; + __u32 vi_frame_rate; + __u16 vi_frames_per_gop; + __u16 vi_bframes_count; + __u8 vi_pesid; + __u8 reserved_3[3]; /* align */ + + /* misc flags */ + __u32 closed_gops:1; + __u32 pulldown:1; + __u32 reserved_4:30; /* align */ + + /* I don't expect the above being perfect yet ;) */ + __u32 reserved_5[8]; +}; +#endif + +struct v4l2_jpegcompression +{ + int quality; + + int APPn; /* Number of APP segment to be written, + * must be 0..15 */ + int APP_len; /* Length of data in JPEG APPn segment */ + char APP_data[60]; /* Data in the JPEG APPn segment. */ + + int COM_len; /* Length of data in JPEG COM segment */ + char COM_data[60]; /* Data in JPEG COM segment */ + + __u32 jpeg_markers; /* Which markers should go into the JPEG + * output. Unless you exactly know what + * you do, leave them untouched. + * Inluding less markers will make the + * resulting code smaller, but there will + * be fewer aplications which can read it. + * The presence of the APP and COM marker + * is influenced by APP_len and COM_len + * ONLY, not by this property! */ + +#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ +#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ +#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ +#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ +#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will + * allways use APP0 */ +}; + +/* + * M E M O R Y - M A P P I N G B U F F E R S + */ +struct v4l2_requestbuffers +{ + __u32 count; + enum v4l2_buf_type type; + enum v4l2_memory memory; + __u32 reserved[2]; +}; + +struct v4l2_buffer +{ + __u32 index; + enum v4l2_buf_type type; + __u32 bytesused; + __u32 flags; + enum v4l2_field field; + struct timeval timestamp; + struct v4l2_timecode timecode; + __u32 sequence; + + /* memory location */ + enum v4l2_memory memory; + union { + __u32 offset; + unsigned long userptr; + } m; + __u32 length; + __u32 input; + __u32 reserved; +}; + +/* Flags for 'flags' field */ +#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */ +#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */ +#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */ +#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */ +#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */ +#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */ +#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ +#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */ + +/* + * O V E R L A Y P R E V I E W + */ +struct v4l2_framebuffer +{ + __u32 capability; + __u32 flags; +/* FIXME: in theory we should pass something like PCI device + memory + * region + offset instead of some physical address */ + void* base; + struct v4l2_pix_format fmt; +}; +/* Flags for the 'capability' field. Read only */ +#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001 +#define V4L2_FBUF_CAP_CHROMAKEY 0x0002 +#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 +#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 +/* Flags for the 'flags' field. */ +#define V4L2_FBUF_FLAG_PRIMARY 0x0001 +#define V4L2_FBUF_FLAG_OVERLAY 0x0002 +#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 + +struct v4l2_clip +{ + struct v4l2_rect c; + struct v4l2_clip __user *next; +}; + +struct v4l2_window +{ + struct v4l2_rect w; + enum v4l2_field field; + __u32 chromakey; + struct v4l2_clip __user *clips; + __u32 clipcount; + void __user *bitmap; +}; + +/* + * C A P T U R E P A R A M E T E R S + */ +struct v4l2_captureparm +{ + __u32 capability; /* Supported modes */ + __u32 capturemode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in .1us units */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 readbuffers; /* # of buffers for read */ + __u32 reserved[4]; +}; + +/* Flags for 'capability' and 'capturemode' fields */ +#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ +#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ + +struct v4l2_outputparm +{ + __u32 capability; /* Supported modes */ + __u32 outputmode; /* Current mode */ + struct v4l2_fract timeperframe; /* Time per frame in seconds */ + __u32 extendedmode; /* Driver-specific extensions */ + __u32 writebuffers; /* # of buffers for write */ + __u32 reserved[4]; +}; + +/* + * I N P U T I M A G E C R O P P I N G + */ +struct v4l2_cropcap { + enum v4l2_buf_type type; + struct v4l2_rect bounds; + struct v4l2_rect defrect; + struct v4l2_fract pixelaspect; +}; + +struct v4l2_crop { + enum v4l2_buf_type type; + struct v4l2_rect c; +}; + +/* + * A N A L O G V I D E O S T A N D A R D + */ + +typedef __u64 v4l2_std_id; + +/* one bit for each */ +#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001) +#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002) +#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004) +#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008) +#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010) +#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020) +#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040) +#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080) + +#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100) +#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200) +#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400) +#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800) + +#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000) +#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000) +#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000) +#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000) + +#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000) +#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000) +#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000) +#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000) +#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) +#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) +#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) +#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000) + +/* ATSC/HDTV */ +#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) +#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) + +/* some merged standards */ +#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) +#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) +#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) +#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK) + +/* some common needed stuff */ +#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\ + V4L2_STD_PAL_B1 |\ + V4L2_STD_PAL_G) +#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\ + V4L2_STD_PAL_D1 |\ + V4L2_STD_PAL_K) +#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ + V4L2_STD_PAL_DK |\ + V4L2_STD_PAL_H |\ + V4L2_STD_PAL_I) +#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\ + V4L2_STD_NTSC_M_JP |\ + V4L2_STD_NTSC_M_KR) +#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\ + V4L2_STD_SECAM_K |\ + V4L2_STD_SECAM_K1) +#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\ + V4L2_STD_SECAM_G |\ + V4L2_STD_SECAM_H |\ + V4L2_STD_SECAM_DK |\ + V4L2_STD_SECAM_L |\ + V4L2_STD_SECAM_LC) + +#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\ + V4L2_STD_PAL_60 |\ + V4L2_STD_NTSC |\ + V4L2_STD_NTSC_443) +#define V4L2_STD_625_50 (V4L2_STD_PAL |\ + V4L2_STD_PAL_N |\ + V4L2_STD_PAL_Nc |\ + V4L2_STD_SECAM) +#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\ + V4L2_STD_ATSC_16_VSB) + +#define V4L2_STD_UNKNOWN 0 +#define V4L2_STD_ALL (V4L2_STD_525_60 |\ + V4L2_STD_625_50) + +struct v4l2_standard +{ + __u32 index; + v4l2_std_id id; + __u8 name[24]; + struct v4l2_fract frameperiod; /* Frames, not fields */ + __u32 framelines; + __u32 reserved[4]; +}; + +/* + * V I D E O I N P U T S + */ +struct v4l2_input +{ + __u32 index; /* Which input */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of input */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 tuner; /* Associated tuner */ + v4l2_std_id std; + __u32 status; + __u32 reserved[4]; +}; + +/* Values for the 'type' field */ +#define V4L2_INPUT_TYPE_TUNER 1 +#define V4L2_INPUT_TYPE_CAMERA 2 + +/* field 'status' - general */ +#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */ +#define V4L2_IN_ST_NO_SIGNAL 0x00000002 +#define V4L2_IN_ST_NO_COLOR 0x00000004 + +/* field 'status' - analog */ +#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ +#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ + +/* field 'status' - digital */ +#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */ +#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */ +#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */ + +/* field 'status' - VCR and set-top box */ +#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */ +#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ +#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ + +/* + * V I D E O O U T P U T S + */ +struct v4l2_output +{ + __u32 index; /* Which output */ + __u8 name[32]; /* Label */ + __u32 type; /* Type of output */ + __u32 audioset; /* Associated audios (bitfield) */ + __u32 modulator; /* Associated modulator */ + v4l2_std_id std; + __u32 reserved[4]; +}; +/* Values for the 'type' field */ +#define V4L2_OUTPUT_TYPE_MODULATOR 1 +#define V4L2_OUTPUT_TYPE_ANALOG 2 +#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 + +/* + * C O N T R O L S + */ +struct v4l2_control +{ + __u32 id; + __s32 value; +}; + +struct v4l2_ext_control +{ + __u32 id; + __u32 reserved2[2]; + union { + __s32 value; + __s64 value64; + void *reserved; + }; +} __attribute__ ((packed)); + +struct v4l2_ext_controls +{ + __u32 ctrl_class; + __u32 count; + __u32 error_idx; + __u32 reserved[2]; + struct v4l2_ext_control *controls; +}; + +/* Values for ctrl_class field */ +#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ +#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ + +#define V4L2_CTRL_ID_MASK (0x0fffffff) +#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) +#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) + +/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ +struct v4l2_queryctrl +{ + __u32 id; + enum v4l2_ctrl_type type; + __u8 name[32]; /* Whatever */ + __s32 minimum; /* Note signedness */ + __s32 maximum; + __s32 step; + __s32 default_value; + __u32 flags; + __u32 reserved[2]; +}; + +/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ +struct v4l2_querymenu +{ + __u32 id; + __u32 index; + __u8 name[32]; /* Whatever */ + __u32 reserved; +}; + +/* Control flags */ +#define V4L2_CTRL_FLAG_DISABLED 0x0001 +#define V4L2_CTRL_FLAG_GRABBED 0x0002 +#define V4L2_CTRL_FLAG_READ_ONLY 0x0004 +#define V4L2_CTRL_FLAG_UPDATE 0x0008 +#define V4L2_CTRL_FLAG_INACTIVE 0x0010 +#define V4L2_CTRL_FLAG_SLIDER 0x0020 + +/* Query flag, to be ORed with the control ID */ +#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 + +/* User-class control IDs defined by V4L2 */ +#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) +#define V4L2_CID_USER_BASE V4L2_CID_BASE +/* IDs reserved for driver specific controls */ +#define V4L2_CID_PRIVATE_BASE 0x08000000 + +#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) +#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0) +#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1) +#define V4L2_CID_SATURATION (V4L2_CID_BASE+2) +#define V4L2_CID_HUE (V4L2_CID_BASE+3) +#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5) +#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6) +#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7) +#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) +#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) +#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) +#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) +#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) +#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) +#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) +#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) +#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) +#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */ +#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) +#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) +#define V4L2_CID_GAIN (V4L2_CID_BASE+19) +#define V4L2_CID_HFLIP (V4L2_CID_BASE+20) +#define V4L2_CID_VFLIP (V4L2_CID_BASE+21) +#define V4L2_CID_HCENTER (V4L2_CID_BASE+22) +#define V4L2_CID_VCENTER (V4L2_CID_BASE+23) +#define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */ + +/* MPEG-class control IDs defined by V4L2 */ +#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) +#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) + +/* MPEG streams */ +#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0) +enum v4l2_mpeg_stream_type { + V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */ + V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */ +}; +#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1) +#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2) +#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3) +#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4) +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5) +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6) +#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7) +enum v4l2_mpeg_stream_vbi_fmt { + V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */ + V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */ +}; + +/* MPEG audio */ +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100) +enum v4l2_mpeg_audio_sampling_freq { + V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101) +enum v4l2_mpeg_audio_encoding { + V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, + V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, + V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) +enum v4l2_mpeg_audio_l1_bitrate { + V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1, + V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2, + V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3, + V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4, + V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5, + V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6, + V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7, + V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8, + V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9, + V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10, + V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11, + V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12, + V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103) +enum v4l2_mpeg_audio_l2_bitrate { + V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1, + V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2, + V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3, + V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4, + V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5, + V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6, + V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7, + V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8, + V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9, + V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10, + V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11, + V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12, + V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104) +enum v4l2_mpeg_audio_l3_bitrate { + V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0, + V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1, + V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2, + V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3, + V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4, + V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5, + V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6, + V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7, + V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8, + V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9, + V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10, + V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11, + V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12, + V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13, +}; +#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105) +enum v4l2_mpeg_audio_mode { + V4L2_MPEG_AUDIO_MODE_STEREO = 0, + V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1, + V4L2_MPEG_AUDIO_MODE_DUAL = 2, + V4L2_MPEG_AUDIO_MODE_MONO = 3, +}; +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106) +enum v4l2_mpeg_audio_mode_extension { + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2, + V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3, +}; +#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107) +enum v4l2_mpeg_audio_emphasis { + V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0, + V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1, + V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2, +}; +#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108) +enum v4l2_mpeg_audio_crc { + V4L2_MPEG_AUDIO_CRC_NONE = 0, + V4L2_MPEG_AUDIO_CRC_CRC16 = 1, +}; + +/* MPEG video */ +#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) +enum v4l2_mpeg_video_encoding { + V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, + V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, +}; +#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) +enum v4l2_mpeg_video_aspect { + V4L2_MPEG_VIDEO_ASPECT_1x1 = 0, + V4L2_MPEG_VIDEO_ASPECT_4x3 = 1, + V4L2_MPEG_VIDEO_ASPECT_16x9 = 2, + V4L2_MPEG_VIDEO_ASPECT_221x100 = 3, +}; +#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202) +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203) +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204) +#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205) +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206) +enum v4l2_mpeg_video_bitrate_mode { + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0, + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, +}; +#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) + +/* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ +#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) +enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2) +enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3, + V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3) +enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type { + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4) +enum v4l2_mpeg_cx2341x_video_temporal_filter_mode { + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0, + V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5) +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6) +enum v4l2_mpeg_cx2341x_video_median_filter_type { + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3, + V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4, +}; +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) + +/* + * T U N I N G + */ +struct v4l2_tuner +{ + __u32 index; + __u8 name[32]; + enum v4l2_tuner_type type; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 rxsubchans; + __u32 audmode; + __s32 signal; + __s32 afc; + __u32 reserved[4]; +}; + +struct v4l2_modulator +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 rangelow; + __u32 rangehigh; + __u32 txsubchans; + __u32 reserved[4]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_TUNER_CAP_LOW 0x0001 +#define V4L2_TUNER_CAP_NORM 0x0002 +#define V4L2_TUNER_CAP_STEREO 0x0010 +#define V4L2_TUNER_CAP_LANG2 0x0020 +#define V4L2_TUNER_CAP_SAP 0x0020 +#define V4L2_TUNER_CAP_LANG1 0x0040 + +/* Flags for the 'rxsubchans' field */ +#define V4L2_TUNER_SUB_MONO 0x0001 +#define V4L2_TUNER_SUB_STEREO 0x0002 +#define V4L2_TUNER_SUB_LANG2 0x0004 +#define V4L2_TUNER_SUB_SAP 0x0004 +#define V4L2_TUNER_SUB_LANG1 0x0008 + +/* Values for the 'audmode' field */ +#define V4L2_TUNER_MODE_MONO 0x0000 +#define V4L2_TUNER_MODE_STEREO 0x0001 +#define V4L2_TUNER_MODE_LANG2 0x0002 +#define V4L2_TUNER_MODE_SAP 0x0002 +#define V4L2_TUNER_MODE_LANG1 0x0003 +#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 + +struct v4l2_frequency +{ + __u32 tuner; + enum v4l2_tuner_type type; + __u32 frequency; + __u32 reserved[8]; +}; + +/* + * A U D I O + */ +struct v4l2_audio +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* Flags for the 'capability' field */ +#define V4L2_AUDCAP_STEREO 0x00001 +#define V4L2_AUDCAP_AVL 0x00002 + +/* Flags for the 'mode' field */ +#define V4L2_AUDMODE_AVL 0x00001 + +struct v4l2_audioout +{ + __u32 index; + __u8 name[32]; + __u32 capability; + __u32 mode; + __u32 reserved[2]; +}; + +/* + * D A T A S E R V I C E S ( V B I ) + * + * Data services API by Michael Schimek + */ + +/* Raw VBI */ +struct v4l2_vbi_format +{ + __u32 sampling_rate; /* in 1 Hz */ + __u32 offset; + __u32 samples_per_line; + __u32 sample_format; /* V4L2_PIX_FMT_* */ + __s32 start[2]; + __u32 count[2]; + __u32 flags; /* V4L2_VBI_* */ + __u32 reserved[2]; /* must be zero */ +}; + +/* VBI flags */ +#define V4L2_VBI_UNSYNC (1<< 0) +#define V4L2_VBI_INTERLACED (1<< 1) + +#if 1 +/* Sliced VBI + * + * This implements is a proposal V4L2 API to allow SLICED VBI + * required for some hardware encoders. It should change without + * notice in the definitive implementation. + */ + +struct v4l2_sliced_vbi_format +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + __u32 io_size; + __u32 reserved[2]; /* must be zero */ +}; + +/* Teletext World System Teletext + (WST), defined on ITU-R BT.653-2 */ +#define V4L2_SLICED_TELETEXT_B (0x0001) +/* Video Program System, defined on ETS 300 231*/ +#define V4L2_SLICED_VPS (0x0400) +/* Closed Caption, defined on EIA-608 */ +#define V4L2_SLICED_CAPTION_525 (0x1000) +/* Wide Screen System, defined on ITU-R BT1119.1 */ +#define V4L2_SLICED_WSS_625 (0x4000) + +#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) +#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) + + +struct v4l2_sliced_vbi_cap +{ + __u16 service_set; + /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field + service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field + (equals frame lines 313-336 for 625 line video + standards, 263-286 for 525 line standards) */ + __u16 service_lines[2][24]; + enum v4l2_buf_type type; + __u32 reserved[3]; /* must be 0 */ +}; + +struct v4l2_sliced_vbi_data +{ + __u32 id; + __u32 field; /* 0: first field, 1: second field */ + __u32 line; /* 1-23 */ + __u32 reserved; /* must be 0 */ + __u8 data[48]; +}; +#endif + +/* + * A G G R E G A T E S T R U C T U R E S + */ + +/* Stream data format + */ +struct v4l2_format +{ + enum v4l2_buf_type type; + union + { + struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE + struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY + struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE +#if 1 + struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE +#endif + __u8 raw_data[200]; // user-defined + } fmt; +}; + + +/* Stream type-dependent parameters + */ +struct v4l2_streamparm +{ + enum v4l2_buf_type type; + union + { + struct v4l2_captureparm capture; + struct v4l2_outputparm output; + __u8 raw_data[200]; /* user-defined */ + } parm; +}; + +/* + * 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 + * + */ +#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) +#define VIDIOC_RESERVED _IO ('V', 1) +#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) +#define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) +#define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) +#ifdef __KERNEL__ +#define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) +#define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) +#endif +#define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) +#define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) +#define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) +#define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer) +#define VIDIOC_OVERLAY _IOW ('V', 14, int) +#define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer) +#define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer) +#define VIDIOC_STREAMON _IOW ('V', 18, int) +#define VIDIOC_STREAMOFF _IOW ('V', 19, int) +#define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm) +#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm) +#define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id) +#define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id) +#define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard) +#define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input) +#define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control) +#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control) +#define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner) +#define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner) +#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio) +#define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio) +#define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl) +#define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu) +#define VIDIOC_G_INPUT _IOR ('V', 38, int) +#define VIDIOC_S_INPUT _IOWR ('V', 39, int) +#define VIDIOC_G_OUTPUT _IOR ('V', 46, int) +#define VIDIOC_S_OUTPUT _IOWR ('V', 47, int) +#define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output) +#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout) +#define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout) +#define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator) +#define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator) +#define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency) +#define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency) +#define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap) +#define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop) +#define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop) +#define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression) +#define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression) +#define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id) +#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format) +#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio) +#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) +#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) +#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) +#if 1 +#define VIDIOC_G_SLICED_VBI_CAP _IOWR ('V', 69, struct v4l2_sliced_vbi_cap) +#endif +#define VIDIOC_LOG_STATUS _IO ('V', 70) +#define VIDIOC_G_EXT_CTRLS _IOWR ('V', 71, struct v4l2_ext_controls) +#define VIDIOC_S_EXT_CTRLS _IOWR ('V', 72, struct v4l2_ext_controls) +#define VIDIOC_TRY_EXT_CTRLS _IOWR ('V', 73, struct v4l2_ext_controls) +#if 1 +#define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) +#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) +#endif + +#ifdef __OLD_VIDIOC_ +/* for compatibility, will go away some day */ +#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) +#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) +#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control) +#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) +#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) +#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) +#endif + +#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ + +#endif /* __LINUX_VIDEODEV2_H */ + +/* + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/ddverify/models/goblint/include/linux/vmalloc.h b/ddverify/models/goblint/include/linux/vmalloc.h new file mode 100644 index 000000000..747bc9653 --- /dev/null +++ b/ddverify/models/goblint/include/linux/vmalloc.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_VMALLOC_H +#define _LINUX_VMALLOC_H + +#include + +void *vmalloc(unsigned long size); +void vfree(void *addr); + +#endif /* _LINUX_VMALLOC_H */ diff --git a/ddverify/models/goblint/include/linux/wait.h b/ddverify/models/goblint/include/linux/wait.h new file mode 100644 index 000000000..91dc48dbf --- /dev/null +++ b/ddverify/models/goblint/include/linux/wait.h @@ -0,0 +1,91 @@ +#ifndef _LINUX_WAIT_H +#define _LINUX_WAIT_H + +#include +#include +#include +#include +#include +#include + +struct __wait_queue { + int something; +}; +typedef struct __wait_queue wait_queue_t; + +struct __wait_queue_head { + int number_process_waiting; + int wakeup; + + int init; +}; +typedef struct __wait_queue_head wait_queue_head_t; + + +#define DECLARE_WAITQUEUE(name, tsk) wait_queue_t name +#define DECLARE_WAIT_QUEUE_HEAD(name) wait_queue_head_t name = { \ + .number_process_waiting = 0, \ + .wakeup = 0, \ + .init = 1} + + +#ifdef DDV_ASSERT_WAIT_QUEUE +#define assert_wait_queue(wq) __CPROVER_assert((wq)->init, "Wait queue is initialized!") +#else +#define assert_wait_queue(wq) do {} while(0) +#endif + +#define wait_event(wq, condition) \ +do { \ + if (condition) \ + break; \ + do { \ + wq.number_process_waiting++; \ + do { \ + } while(!wq.wakeup); \ + if (condition) \ + break; \ + do { \ + } while(wq.wakeup); \ + } while (1); \ +} while (0) + + +#define wait_event_interruptible(wq, condition) \ +({ \ + int __ret = 0; \ + __ret; \ +}) + + +#define DEFINE_WAIT(name) wait_queue_t name + +// DDV: Body is defined in linux/kernel/wait.c +void init_waitqueue_head(wait_queue_head_t *q); +// DDV: TODO +void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state); +// DDV: TODO +void finish_wait(wait_queue_head_t *q, wait_queue_t *wait); + +// DDV: Body is defined in linux/kernel/wait.c +void wake_up(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_all(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void wake_up_interruptible(wait_queue_head_t *q); + +// DDV: TODO +void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait); +// DDV: TODO +void remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait); + +// DDV: TODO +int waitqueue_active(wait_queue_head_t *q); + +// DDV: Body is defined in linux/kernel/wait.c +void sleep_on(wait_queue_head_t *q); +// DDV: Body is defined in linux/kernel/wait.c +void interruptible_sleep_on(wait_queue_head_t *q); +#endif diff --git a/ddverify/models/goblint/include/linux/watchdog.h b/ddverify/models/goblint/include/linux/watchdog.h new file mode 100644 index 000000000..afc7f8318 --- /dev/null +++ b/ddverify/models/goblint/include/linux/watchdog.h @@ -0,0 +1,52 @@ +#ifndef _LINUX_WATCHDOG_H +#define _LINUX_WATCHDOG_H + +#include +#include + +#define WATCHDOG_IOCTL_BASE 'W' + +struct watchdog_info { + __u32 options; /* Options the card/driver supports */ + __u32 firmware_version; /* Firmware version of the card */ + __u8 identity[32]; /* Identity of the board */ +}; + +#define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info) +#define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int) +#define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int) +#define WDIOC_GETTEMP _IOR(WATCHDOG_IOCTL_BASE, 3, int) +#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int) +#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int) +#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) +#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) +#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int) +#define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int) +#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int) + +#define WDIOF_UNKNOWN -1 /* Unknown flag error */ +#define WDIOS_UNKNOWN -1 /* Unknown status error */ + +#define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */ +#define WDIOF_FANFAULT 0x0002 /* Fan failed */ +#define WDIOF_EXTERN1 0x0004 /* External relay 1 */ +#define WDIOF_EXTERN2 0x0008 /* External relay 2 */ +#define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ +#define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ +#define WDIOF_POWEROVER 0x0040 /* Power over voltage */ +#define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ +#define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ +#define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ +#define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ + +#define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ +#define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */ +#define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */ + +#ifdef CONFIG_WATCHDOG_NOWAYOUT +#define WATCHDOG_NOWAYOUT 1 +#else +#define WATCHDOG_NOWAYOUT 0 +#endif + +#endif /* ifndef _LINUX_WATCHDOG_H */ diff --git a/ddverify/models/goblint/include/linux/workqueue.h b/ddverify/models/goblint/include/linux/workqueue.h new file mode 100644 index 000000000..968ed7e62 --- /dev/null +++ b/ddverify/models/goblint/include/linux/workqueue.h @@ -0,0 +1,50 @@ +/* + * workqueue.h --- work queue handling for Linux. + */ + +#ifndef _LINUX_WORKQUEUE_H +#define _LINUX_WORKQUEUE_H + +#include +//#include +#include + +struct work_struct { + unsigned long pending; + void (*func)(void *); + void *data; + + int init; +}; + +#define DECLARE_WORK(n, f, d) \ + struct work_struct n = { \ + .func = (f), \ + .data = (d), \ + .init = 1, \ + } + +/* + * initialize a work-struct's func and data pointers: + */ +#define PREPARE_WORK(_work, _func, _data) \ + do { \ + (_work)->func = _func; \ + (_work)->data = _data; \ + (_work)->init = 1; \ + } while (0) + +/* + * initialize all of a work-struct: + */ +#define INIT_WORK(_work, _func, _data) \ + do { \ + PREPARE_WORK((_work), (_func), (_data)); \ + } while (0) + +// DDV: Body for this function is defined in linux/kernel/workqueue.c +int schedule_work(struct work_struct *work); +// DDV: TODO +void flush_scheduled_work(void); + +#endif diff --git a/ddverify/models/goblint/include/linux/writeback.h b/ddverify/models/goblint/include/linux/writeback.h new file mode 100644 index 000000000..e69de29bb diff --git a/ddverify/models/goblint/include/media/v4l2-common.h b/ddverify/models/goblint/include/media/v4l2-common.h new file mode 100644 index 000000000..1863cce24 --- /dev/null +++ b/ddverify/models/goblint/include/media/v4l2-common.h @@ -0,0 +1,6 @@ +#ifndef V4L2_COMMON_H_ +#define V4L2_COMMON_H_ + +#include + +#endif /* V4L2_COMMON_H_ */ diff --git a/ddverify/models/goblint/include/media/v4l2-dev.h b/ddverify/models/goblint/include/media/v4l2-dev.h new file mode 100644 index 000000000..94b52e78e --- /dev/null +++ b/ddverify/models/goblint/include/media/v4l2-dev.h @@ -0,0 +1,255 @@ +#ifndef _V4L2_DEV_H +#define _V4L2_DEV_H + +#include +#include +#include +#include +#include +#include + + +#define VIDEO_MAJOR 81 +/* Minor device allocation */ +#define MINOR_VFL_TYPE_GRABBER_MIN 0 +#define MINOR_VFL_TYPE_GRABBER_MAX 63 +#define MINOR_VFL_TYPE_RADIO_MIN 64 +#define MINOR_VFL_TYPE_RADIO_MAX 127 +#define MINOR_VFL_TYPE_VTX_MIN 192 +#define MINOR_VFL_TYPE_VTX_MAX 223 +#define MINOR_VFL_TYPE_VBI_MIN 224 +#define MINOR_VFL_TYPE_VBI_MAX 255 + +#define VFL_TYPE_GRABBER 0 +#define VFL_TYPE_VBI 1 +#define VFL_TYPE_RADIO 2 +#define VFL_TYPE_VTX 3 + + + +struct video_device +{ + /* device ops */ + const struct file_operations *fops; + + /* device info */ + struct device *dev; + char name[32]; + int type; /* v4l1 */ + int type2; /* v4l2 */ + int hardware; + int minor; + + int debug; /* Activates debug level*/ + + /* Video standard vars */ + int tvnormsize; /* Size of tvnorm array */ + v4l2_std_id current_norm; /* Current tvnorm */ + struct v4l2_tvnorm *tvnorms; + + /* callbacks */ + void (*release)(struct video_device *vfd); + + /* ioctl callbacks */ + + /* VIDIOC_QUERYCAP handler */ + int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap); + + /* Priority handling */ + int (*vidioc_g_priority) (struct file *file, void *fh, + enum v4l2_priority *p); + int (*vidioc_s_priority) (struct file *file, void *fh, + enum v4l2_priority p); + + /* VIDIOC_ENUM_FMT handlers */ + int (*vidioc_enum_fmt_cap) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_overlay) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_capture) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_video_output)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_fmtdesc *f); + int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, + struct v4l2_fmtdesc *f); + + /* VIDIOC_G_FMT handlers */ + int (*vidioc_g_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_S_FMT handlers */ + int (*vidioc_s_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + + int (*vidioc_s_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* VIDIOC_TRY_FMT handlers */ + int (*vidioc_try_fmt_cap) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_overlay) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_output) (struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_vbi_capture)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_video_output)(struct file *file, void *fh, + struct v4l2_format *f); + int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, + struct v4l2_format *f); + + /* Buffer handlers */ + int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); + int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b); + + + int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); + + int (*vidioc_g_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + int (*vidioc_s_fbuf) (struct file *file, void *fh, + struct v4l2_framebuffer *a); + + /* Stream on/off */ + int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i); + int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i); + + /* Standard handling + G_STD and ENUMSTD are handled by videodev.c + */ + int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id a); + int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a); + + /* Input handling */ + int (*vidioc_enum_input)(struct file *file, void *fh, + struct v4l2_input *inp); + int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i); + + /* Output handling */ + int (*vidioc_enumoutput) (struct file *file, void *fh, + struct v4l2_output *a); + int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i); + int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i); + + /* Control handling */ + int (*vidioc_queryctrl) (struct file *file, void *fh, + struct v4l2_queryctrl *a); + int (*vidioc_g_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_s_ctrl) (struct file *file, void *fh, + struct v4l2_control *a); + int (*vidioc_g_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_s_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_try_ext_ctrls) (struct file *file, void *fh, + struct v4l2_ext_controls *a); + int (*vidioc_querymenu) (struct file *file, void *fh, + struct v4l2_querymenu *a); + + /* Audio ioctls */ + int (*vidioc_enumaudio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_g_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + int (*vidioc_s_audio) (struct file *file, void *fh, + struct v4l2_audio *a); + + /* Audio out ioctls */ + int (*vidioc_enumaudout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_s_audout) (struct file *file, void *fh, + struct v4l2_audioout *a); + int (*vidioc_g_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + int (*vidioc_s_modulator) (struct file *file, void *fh, + struct v4l2_modulator *a); + /* Crop ioctls */ + int (*vidioc_cropcap) (struct file *file, void *fh, + struct v4l2_cropcap *a); + int (*vidioc_g_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + int (*vidioc_s_crop) (struct file *file, void *fh, + struct v4l2_crop *a); + /* Compression ioctls */ + int (*vidioc_g_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_s_mpegcomp) (struct file *file, void *fh, + struct v4l2_mpeg_compression *a); + int (*vidioc_g_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + int (*vidioc_s_jpegcomp) (struct file *file, void *fh, + struct v4l2_jpegcompression *a); + + /* Stream type-dependent parameter ioctls */ + int (*vidioc_g_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + int (*vidioc_s_parm) (struct file *file, void *fh, + struct v4l2_streamparm *a); + + /* Tuner ioctls */ + int (*vidioc_g_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_s_tuner) (struct file *file, void *fh, + struct v4l2_tuner *a); + int (*vidioc_g_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + int (*vidioc_s_frequency) (struct file *file, void *fh, + struct v4l2_frequency *a); + + /* Sliced VBI cap */ + int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh, + struct v4l2_sliced_vbi_cap *a); + + /* Log status ioctl */ + int (*vidioc_log_status) (struct file *file, void *fh); + + + struct module *owner; + + void *priv; + +}; + + + +extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, + unsigned long arg); + +extern int video_exclusive_open(struct inode *inode, struct file *file); +extern int video_exclusive_release(struct inode *inode, struct file *file); + +#endif /* _V4L2_DEV_H */ diff --git a/ddverify/models/goblint/include/net/sock.h b/ddverify/models/goblint/include/net/sock.h new file mode 100644 index 000000000..2eefd9c6c --- /dev/null +++ b/ddverify/models/goblint/include/net/sock.h @@ -0,0 +1,29 @@ +#ifndef _SOCK_H +#define _SOCK_H + +#include +#include +#include +#include +//#include +#include +#include /* struct sk_buff */ +//#include + + +#define SHUTDOWN_MASK 3 +#define RCV_SHUTDOWN 1 +#define SEND_SHUTDOWN 2 + +#define SOCK_SNDBUF_LOCK 1 +#define SOCK_RCVBUF_LOCK 2 +#define SOCK_BINDADDR_LOCK 4 +#define SOCK_BINDPORT_LOCK 8 + +struct sock { + gfp_t sk_allocation; +}; + +struct socket *SOCKET_I(struct inode *inode); + +#endif /* _SOCK_H */ diff --git a/ddverify/models/goblint/src/ddverify/cdev.c b/ddverify/models/goblint/src/ddverify/cdev.c new file mode 100644 index 000000000..c608b16d5 --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/cdev.c @@ -0,0 +1,156 @@ +#include +#include +#include + +void call_cdev_functions() +{ + int cdev_no, function_no, result; + + loff_t loff_t_value; + int int_value; + unsigned int uint_value; + unsigned long ulong_value; + char char_value; + size_t size_t_value; + + if (number_cdev_registered == 0) { + return; + } + + cdev_no = nondet_ushort(); + __CPROVER_assume (0 <= cdev_no && cdev_no < number_cdev_registered); + + switch (nondet_ushort()) { + case 0: + if (cdev_registered[cdev_no].cdevp->ops->llseek) { + loff_t_value = nondet_loff_t(); + int_value = nondet_int(); + + (* cdev_registered[cdev_no].cdevp->ops->llseek)(&cdev_registered[cdev_no].filp, + loff_t_value, + int_value); + } + break; + case 1: + if (cdev_registered[cdev_no].cdevp->ops->read) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->read)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 2: + // aio_read - NOT SUPPORTED! + break; + case 3: + if (cdev_registered[cdev_no].cdevp->ops->write) { + char_value = nondet_char(); + size_t_value = nondet_size_t(); + + (* cdev_registered[cdev_no].cdevp->ops->write)(&cdev_registered[cdev_no].filp, + &char_value, + size_t_value, + &loff_t_value); + } + break; + case 4: + // aio_write - NOT SUPPORTED! + break; + case 5: + // readdir - NOT SUPPORTED! + break; + case 6: + // poll - NOT SUPPORTED! + break; + case 7: + if (cdev_registered[cdev_no].cdevp->ops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + + (* cdev_registered[cdev_no].cdevp->ops->ioctl)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp, + uint_value, + ulong_value); + } + + break; + case 8: + // unlocked_ioctl - NOT SUPPORTED! + break; + case 9: + // compat_ioctl - NOT SUPPORTED! + break; + case 10: + // mmap - NOT SUPPORTED! + break; + case 11: + if ((cdev_registered[cdev_no].cdevp->ops->open) && + (!cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->open)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 1; + } + } + break; + case 12: + // flush - NOT SUPPORTED! + break; + case 13: + if ((cdev_registered[cdev_no].cdevp->ops->release) && + (cdev_registered[cdev_no].open)) { + result = (* cdev_registered[cdev_no].cdevp->ops->release)(&cdev_registered[cdev_no].inode, + &cdev_registered[cdev_no].filp); + + if (!result) { + cdev_registered[cdev_no].open = 0; + } + } + break; + case 14: + // fsync - NOT SUPPORTED! + break; + case 15: + // aio_fsync - NOT SUPPORTED! + break; + case 16: + // fasync - NOT SUPPORTED! + break; + case 17: + // lock - NOT SUPPORTED! + break; + case 18: + // readv - NOT SUPPORTED! + break; + case 19: + // writev - NOT SUPPORTED! + break; + case 20: + // sendfile - NOT SUPPORTED! + break; + case 21: + // sendpage - NOT SUPPORTED! + break; + case 22: + // get_unmapped_area - NOT SUPPORTED! + break; + case 23: + // check_flags - NOT SUPPORTED! + break; + case 24: + // dir_notify - NOT SUPPORTED! + break; + case 25: + // flock - NOT SUPPORTED! + break; + case 26: + // open_exec - NOT SUPPORTED! + break; + default: + break; + } +} diff --git a/ddverify/models/goblint/src/ddverify/ddverify.c b/ddverify/models/goblint/src/ddverify/ddverify.c new file mode 100644 index 000000000..2e086bebb --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/ddverify.c @@ -0,0 +1,116 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void init_kernel() +{ + int i; + + spin_lock_init(&kernel_lock); + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + shared_workqueue[i] = NULL; + } + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + tasklet_registered[i].tasklet = NULL; + tasklet_registered[i].is_running = 0; + } +} + +static void * ddv_2(void *arg) +{ + unsigned short random; + + do { + random = nondet_ushort(); + + switch (random) { + case 1: + switch_context(CONTEXT_INTERRUPT); + call_timer_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 2: + switch_context(CONTEXT_INTERRUPT); + call_interrupt_handler(); + switch_context(CONTEXT_PROCESS); + break; + + case 3: + switch_context(CONTEXT_PROCESS); + call_shared_workqueue_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 4: + switch_context(CONTEXT_INTERRUPT); + call_tasklet_functions(); + switch_context(CONTEXT_PROCESS); + break; + + case 5: + switch_context(CONTEXT_PROCESS); + call_pci_functions(); + switch_context(CONTEXT_PROCESS); + break; + + default: + break; + } + } while(random); +} + +void ddv() +{ + unsigned short random; + + pthread_t thread; + + pthread_create(&thread, NULL, ddv_2, NULL); + + do { + switch_context(CONTEXT_PROCESS); +#ifdef DRIVER_TYPE_CHAR + call_cdev_functions(); +#endif + +#ifdef DRIVER_TYPE_BLOCK + call_genhd_functions(); +#endif + } while (nondet_int()); +} + +int call_ddv() +{ + int err; + + switch_context(CONTEXT_PROCESS); + + init_kernel(); + + err = (* _ddv_module_init)(); + + if (err) { + return -1; + } + + + ddv(); + + switch_context(CONTEXT_PROCESS); + (* _ddv_module_exit)(); + + return 0; +} diff --git a/ddverify/models/goblint/src/ddverify/genhd.c b/ddverify/models/goblint/src/ddverify/genhd.c new file mode 100644 index 000000000..8938bbdd3 --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/genhd.c @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include + +create_request(int genhd_no) +{ + struct request rq; + + rq.cmd_type = REQ_TYPE_FS; + rq.rq_disk = genhd_registered[genhd_no].gd; + rq.sector = nondet_sector_t(); + rq.current_nr_sectors = nondet_uint(); + rq.buffer = nondet_pchar(); + + genhd_registered[genhd_no].current_request = rq; + genhd_registered[genhd_no].requests_open = 1; +} + +void call_rq_function(int genhd_no) +{ + if ((genhd_registered[genhd_no].gd->queue->request_fn != NULL) && + (genhd_registered[genhd_no].gd->queue->__ddv_queue_alive)) + { + spin_lock(genhd_registered[genhd_no].gd->queue->queue_lock); + + create_request(genhd_no); + genhd_registered[genhd_no].gd->queue->__ddv_genhd_no = genhd_no; + + (* genhd_registered[genhd_no].gd->queue->request_fn)(genhd_registered[genhd_no].gd->queue); + // do_cm206_request(genhd_registered[genhd_no].gd->queue); + + spin_unlock(genhd_registered[genhd_no].gd->queue->queue_lock); + + return; + } + + if (genhd_registered[genhd_no].gd->queue->make_request_fn) { + return; + } +} + +void call_genhd_functions() +{ + unsigned short genhd_no, function_no; + unsigned int uint_value; + unsigned long ulong_value; + int result; + + if (number_genhd_registered == 0) { + return; + } + + genhd_no = nondet_ushort(); + __CPROVER_assume (genhd_no < number_genhd_registered); + + + function_no = nondet_ushort(); + + switch (function_no) { + case 0: + call_rq_function(genhd_no); + break; + + case 1: + if (genhd_registered[genhd_no].gd->fops->open) { + genhd_registered[genhd_no].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[genhd_no].inode.i_bdev->bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->open)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 2: + if (genhd_registered[genhd_no].gd->fops->release) { + (* genhd_registered[genhd_no].gd->fops->release)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file); + } + break; + + case 3: + if (genhd_registered[genhd_no].gd->fops->ioctl) { + uint_value = nondet_uint(); + ulong_value = nondet_ulong(); + (* genhd_registered[genhd_no].gd->fops->ioctl)(&genhd_registered[genhd_no].inode, + &genhd_registered[genhd_no].file, + uint_value, + ulong_value); + } + break; + + case 4: + if (genhd_registered[genhd_no].gd->fops->media_changed) { + (* genhd_registered[genhd_no].gd->fops->media_changed)(genhd_registered[genhd_no].gd); + } + break; + + case 5: + if (genhd_registered[genhd_no].gd->fops->revalidate_disk) { + (* genhd_registered[genhd_no].gd->fops->revalidate_disk)(genhd_registered[genhd_no].gd); + } + break; + + case 6: + if (genhd_registered[genhd_no].gd->fops->getgeo) { + struct hd_geometry hdg; + struct block_device blk_dev; + + blk_dev.bd_disk = genhd_registered[genhd_no].gd; + + (* genhd_registered[genhd_no].gd->fops->getgeo)(&blk_dev, &hdg); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/goblint/src/ddverify/interrupt.c b/ddverify/models/goblint/src/ddverify/interrupt.c new file mode 100644 index 000000000..4a5ed1daf --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/interrupt.c @@ -0,0 +1,22 @@ +#include +#include + +#ifdef OLD_INTERRUPT_HANDLER +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id) +#else +#define __call_interrupt_handler(funct, irq, dev_id, regs) funct(irq, dev_id, regs) +#endif + +void call_interrupt_handler() +{ + unsigned short i; + struct pt_regs regs; + + i = nondet_int(); + __CPROVER_assume(i < MAX_IRQ_SUPPORT); + + if (registered_irq[i].handler) { + __call_interrupt_handler((* registered_irq[i].handler), + (int)i, registered_irq[i].dev_id, ®s); + } +} diff --git a/ddverify/models/goblint/src/ddverify/ioctl.c b/ddverify/models/goblint/src/ddverify/ioctl.c new file mode 100644 index 000000000..2f95c45aa --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/ioctl.c @@ -0,0 +1,19 @@ +#include +#include + +/*void add_ioctl(unsigned int ioctl) +{ + if (number_ioctl_registered < MAX_IOCTL_SUPPORT) { + ioctl_registered[number_ioctl_registered] = ioctl; + number_ioctl_registered++; + } +} + +unsigned int get_ioctl_cmd() +{ + short cmd = nondet_short(); + __CPROVER_assume (cmd >= 0 && cmd < number_ioctl_registered); + + return ioctl_registered[cmd]; +} +*/ diff --git a/ddverify/models/goblint/src/ddverify/pci.c b/ddverify/models/goblint/src/ddverify/pci.c new file mode 100644 index 000000000..7f9df6bbb --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/pci.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include + +void create_pci_dev() +{ +} + +int pci_probe_device() +{ + int err; + unsigned int dev_id; + + registered_pci_driver.no_pci_device_id = 1; + + dev_id = nondet_uint(); + __CPROVER_assume(dev_id < registered_pci_driver.no_pci_device_id); + + err = (*registered_pci_driver.pci_driver->probe)(®istered_pci_driver.pci_dev, + ®istered_pci_driver.pci_driver->id_table[dev_id]); + + if (!err) { + registered_pci_driver.dev_initialized = 1; + } + + return err; +} + +void pci_remove_device() +{ + (*registered_pci_driver.pci_driver->remove)(®istered_pci_driver.pci_dev); + + registered_pci_driver.dev_initialized = 0; +} + +void call_pci_functions() +{ + switch (nondet_uint()) { + case 0: + if (!registered_pci_driver.dev_initialized) { + pci_probe_device(); + } + break; + + case 1: + if (registered_pci_driver.dev_initialized) { + pci_remove_device(); + } + break; + + default: + break; + } +} diff --git a/ddverify/models/goblint/src/ddverify/tasklet.c b/ddverify/models/goblint/src/ddverify/tasklet.c new file mode 100644 index 000000000..776673eb8 --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/tasklet.c @@ -0,0 +1,15 @@ +#include + +void call_tasklet_functions() +{ + unsigned int i; + __CPROVER_assume(i < MAX_TASKLET_SUPPORT); + + if ((tasklet_registered[i].tasklet != NULL) && + (tasklet_registered[i].tasklet->count == 0)) { + tasklet_registered[i].is_running = 1; + (* tasklet_registered[i].tasklet->func)(tasklet_registered[i].tasklet->data); + tasklet_registered[i].is_running = 0; + tasklet_registered[i].tasklet = NULL; + } +} diff --git a/ddverify/models/goblint/src/ddverify/timer.c b/ddverify/models/goblint/src/ddverify/timer.c new file mode 100644 index 000000000..45c22052a --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/timer.c @@ -0,0 +1,13 @@ +#include +#include + +void call_timer_functions() +{ + unsigned short i = nondet_ushort(); + + __CPROVER_assume(i < number_timer_registered); + + if (timer_registered[i].timer->__ddv_active) { + (* timer_registered[i].timer->function)(timer_registered[i].timer->data); + } +} diff --git a/ddverify/models/goblint/src/linux/arch/i386/lib/usercopy.c b/ddverify/models/goblint/src/linux/arch/i386/lib/usercopy.c new file mode 100644 index 000000000..f8ef11568 --- /dev/null +++ b/ddverify/models/goblint/src/linux/arch/i386/lib/usercopy.c @@ -0,0 +1,51 @@ +#include +#include +#include + +inline int __get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +inline int get_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +inline int __put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +inline int put_user(int size, void *ptr) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_int(); +} + +inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} + +inline unsigned long copy_from_user(void *to, void __user *from, unsigned long n) +{ + __CPROVER_HIDE: + assert_context_process(); + + return nondet_ulong(); +} diff --git a/ddverify/models/goblint/src/linux/block/elevator.c b/ddverify/models/goblint/src/linux/block/elevator.c new file mode 100644 index 000000000..4bd2ac41f --- /dev/null +++ b/ddverify/models/goblint/src/linux/block/elevator.c @@ -0,0 +1,13 @@ +#include +#include + +struct request *elv_next_request(request_queue_t *q) +{ + int genhd_no = q->__ddv_genhd_no; + + if (genhd_registered[genhd_no].requests_open > 0) { + return &genhd_registered[genhd_no].current_request; + } else { + return NULL; + } +} diff --git a/ddverify/models/goblint/src/linux/block/genhd.c b/ddverify/models/goblint/src/linux/block/genhd.c new file mode 100644 index 000000000..2cbcc717d --- /dev/null +++ b/ddverify/models/goblint/src/linux/block/genhd.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +int register_blkdev(unsigned int major, const char *name) +{ + int result = nondet_int(); + + /*if ((major > 0) && (result > 0)) { + return major; + }*/ + + return result; +} + +int unregister_blkdev(unsigned int major, const char *name) +{ + return 0; +} + +struct gendisk *alloc_disk(int minors) +{ + struct gendisk * gd; + + if (number_fixed_genhd_used < MAX_GENHD_SUPPORT) { + gd = &fixed_gendisk[number_fixed_genhd_used]; + gd->minors = minors; + + number_fixed_genhd_used++; + + return gd; + } else { + return NULL; + } +} + +void add_disk(struct gendisk *disk) +{ + if (number_genhd_registered < MAX_GENHD_SUPPORT) { + genhd_registered[number_genhd_registered].gd = disk; + genhd_registered[number_genhd_registered].inode.i_bdev = (struct block_device*)malloc(sizeof(struct block_device)); + genhd_registered[number_genhd_registered].inode.i_bdev->bd_disk = disk; + + number_genhd_registered++; + } +} + +void del_gendisk(struct gendisk *gp) +{ + int i; + + for (i = 0; i < number_genhd_registered; i++) { + if (genhd_registered[i].gd == gp) { + genhd_registered[i].gd = NULL; + } + } +} diff --git a/ddverify/models/goblint/src/linux/block/ll_rw_blk.c b/ddverify/models/goblint/src/linux/block/ll_rw_blk.c new file mode 100644 index 000000000..eb27f72a2 --- /dev/null +++ b/ddverify/models/goblint/src/linux/block/ll_rw_blk.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include + +request_queue_t *get_fixed_request_queue() +{ + if (number_request_queue_used < MAX_REQUEST_QUEUE_SUPPORT) { + return &fixed_request_queue[number_request_queue_used++]; + } else { + return NULL; + } +} + +request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->queue_lock = lock; + queue->request_fn = rfn; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +request_queue_t *blk_alloc_queue(gfp_t gfp_mask) +{ + request_queue_t *queue; + + if (nondet_int()) { + queue = get_fixed_request_queue(); + + queue->request_fn = NULL; + queue->make_request_fn = NULL; + queue->__ddv_queue_alive = 1; + + return queue; + } else { + return NULL; + } +} + +void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn) +{ + q->make_request_fn = mfn; +} + +void end_request(struct request *req, int uptodate) +{ + int genhd_no = req->rq_disk->queue->__ddv_genhd_no; + + genhd_registered[genhd_no].requests_open = 0; +} + + +void blk_queue_hardsect_size(request_queue_t *q, unsigned short size) +{ + q->hardsect_size = size; +} + +void blk_cleanup_queue(request_queue_t *q) +{ + q->__ddv_queue_alive = 0; +} diff --git a/ddverify/models/goblint/src/linux/drivers/char/misc.c b/ddverify/models/goblint/src/linux/drivers/char/misc.c new file mode 100644 index 000000000..1bcc5a5ac --- /dev/null +++ b/ddverify/models/goblint/src/linux/drivers/char/misc.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +//#include +//#include +#include + +#include + +int misc_register(struct miscdevice * misc) +{ + int i; + dev_t dev; + + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + i = fixed_cdev_used; + fixed_cdev_used++; + + fixed_cdev[i].owner = THIS_MODULE; + fixed_cdev[i].ops = misc->fops; + + dev = MKDEV(MISC_MAJOR, misc->minor); + + return cdev_add(&fixed_cdev[i], dev, 0); + } else { + return -1; + } +} diff --git a/ddverify/models/goblint/src/linux/drivers/char/tty_io.c b/ddverify/models/goblint/src/linux/drivers/char/tty_io.c new file mode 100644 index 000000000..30fe841cc --- /dev/null +++ b/ddverify/models/goblint/src/linux/drivers/char/tty_io.c @@ -0,0 +1,40 @@ +#include +#include + +struct tty_driver *alloc_tty_driver(int lines) +{ + if (!global_tty_driver.allocated) { + global_tty_driver.driver.magic = TTY_DRIVER_MAGIC; + global_tty_driver.driver.num = lines; + } else { + return NULL; + } +} + +void tty_set_operations(struct tty_driver *driver, + const struct tty_operations *op) +{ + driver->open = op->open; + driver->close = op->close; + driver->write = op->write; + driver->put_char = op->put_char; + driver->flush_chars = op->flush_chars; + driver->write_room = op->write_room; + driver->chars_in_buffer = op->chars_in_buffer; + driver->ioctl = op->ioctl; + driver->set_termios = op->set_termios; + driver->throttle = op->throttle; + driver->unthrottle = op->unthrottle; + driver->stop = op->stop; + driver->start = op->start; + driver->hangup = op->hangup; + driver->break_ctl = op->break_ctl; + driver->flush_buffer = op->flush_buffer; + driver->set_ldisc = op->set_ldisc; + driver->wait_until_sent = op->wait_until_sent; + driver->send_xchar = op->send_xchar; + driver->read_proc = op->read_proc; + driver->write_proc = op->write_proc; + driver->tiocmget = op->tiocmget; + driver->tiocmset = op->tiocmset; +} diff --git a/ddverify/models/goblint/src/linux/fs/char_dev.c b/ddverify/models/goblint/src/linux/fs/char_dev.c new file mode 100644 index 000000000..8a0a278bf --- /dev/null +++ b/ddverify/models/goblint/src/linux/fs/char_dev.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +#include +#include + +int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) +{ + int major; + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + major = nondet_uint(); + *dev = MKDEV(major, baseminor); + } + + return return_value; +} + +int register_chrdev_region(dev_t from, unsigned count, const char *name) +{ + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + return return_value; +} + +//void unregister_chrdev_region(dev_t, unsigned) {} + + +int register_chrdev(unsigned int major, const char *name, + struct file_operations *fops) +{ + struct cdev *cdev; + int err; + + major = register_chrdev_region(0, 256, name); + + cdev = cdev_alloc(); + cdev->owner = fops->owner; + cdev->ops = fops; + + err = cdev_add(cdev, MKDEV(major, 0), 256); + + if (err) { + kfree(cdev); + return err; + } + + return major; +} + + +int unregister_chrdev(unsigned int major, const char *name) +{ + return 0; +} + +struct cdev *cdev_alloc(void) +{ + if (fixed_cdev_used < MAX_CDEV_SUPPORT) { + return &fixed_cdev[fixed_cdev_used++]; + } +} + +void cdev_init(struct cdev *cdev, struct file_operations *fops) +{ + cdev->ops = fops; +} + +int cdev_add(struct cdev *p, dev_t dev, unsigned count) +{ + p->dev = dev; + p->count = count; + + int return_value = nondet_int(); + __CPROVER_assume((return_value == 0) || (return_value == -1)); + + if (return_value == 0) { + if (number_cdev_registered < MAX_CDEV_SUPPORT) { + + cdev_registered[number_cdev_registered].cdevp = p; + cdev_registered[number_cdev_registered].inode.i_rdev = dev; + cdev_registered[number_cdev_registered].inode.i_cdev = p; + cdev_registered[number_cdev_registered].open = 0; + + number_cdev_registered++; + } else { + return -1; + } + } + + return return_value; +} + +void cdev_del(struct cdev *p) +{ + int i; + + for (i = 0; i < number_cdev_registered; i++) { + if (cdev_registered[i].cdevp == p) { + cdev_registered[i].cdevp = 0; + + return; + } + } +} diff --git a/ddverify/models/goblint/src/linux/fs/proc/generic.c b/ddverify/models/goblint/src/linux/fs/proc/generic.c new file mode 100644 index 000000000..d2d29e78b --- /dev/null +++ b/ddverify/models/goblint/src/linux/fs/proc/generic.c @@ -0,0 +1,7 @@ +#include + +// struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, +// struct proc_dir_entry *parent) + + +// void remove_proc_entry(const char *name, struct proc_dir_entry *parent) diff --git a/ddverify/models/goblint/src/linux/fs/read_write.c b/ddverify/models/goblint/src/linux/fs/read_write.c new file mode 100644 index 000000000..66bce0a93 --- /dev/null +++ b/ddverify/models/goblint/src/linux/fs/read_write.c @@ -0,0 +1,9 @@ +#include + +#define ESPIPE 29 + +loff_t no_llseek(struct file *file, loff_t offset, int origin) +{ + return -ESPIPE; +} + diff --git a/ddverify/models/goblint/src/linux/kernel/irq/manage.c b/ddverify/models/goblint/src/linux/kernel/irq/manage.c new file mode 100644 index 000000000..54df106a0 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/irq/manage.c @@ -0,0 +1,21 @@ +#include +#include + +int request_irq(unsigned int irq, irq_handler_t handler, + unsigned long irqflags, const char * devname, void *dev_id) +{ + if (nondet_int()) { + registered_irq[irq].handler = handler; + registered_irq[irq].dev_id = dev_id; + + return 0; + } else { + return -1; + } +} + +void free_irq(unsigned int irq, void *dev_id) +{ + registered_irq[irq].handler = NULL; + registered_irq[irq].dev_id = NULL; +} diff --git a/ddverify/models/goblint/src/linux/kernel/mutex.c b/ddverify/models/goblint/src/linux/kernel/mutex.c new file mode 100644 index 000000000..345196152 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/mutex.c @@ -0,0 +1,37 @@ +#include +#include + +inline void mutex_init(struct mutex *lock) +{ + __CPROVER_HIDE: +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(!lock->locked, "Locked mutex must not be reinitialized"); +#endif + lock->locked = 0; + lock->init = 1; +} + +inline void mutex_lock(struct mutex *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(lock->init, "Mutex is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked mutex"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +inline void mutex_unlock(struct mutex *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_MUTEX + __CPROVER_assert(lock->locked, "Unlock a not locked mutex"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} diff --git a/ddverify/models/goblint/src/linux/kernel/resource.c b/ddverify/models/goblint/src/linux/kernel/resource.c new file mode 100644 index 000000000..af6949502 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/resource.c @@ -0,0 +1,117 @@ +#include +#include +#include +#include + +int ddv_ioport_request_start; +int ddv_ioport_request_len; + +inline struct resource *request_region(unsigned long start, unsigned long len, const char *name) +{ + unsigned int i; + struct resource *resource = (struct resource*)malloc(sizeof(struct resource)); + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 1; + // } + ddv_ioport_request_start = start; + ddv_ioport_request_len = len; + + return resource; +} + +inline void release_region(unsigned long start, unsigned long len) +{ + unsigned int i = 0; + + // for (i = start; i < start + len; i++) { + // ddv_ioport[i] = 0; + // } + + ddv_ioport_request_start = 0; + ddv_ioport_request_len = 0; +} + +inline unsigned char inb(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +inline void outb(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +inline unsigned short inw(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +inline void outw(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +inline unsigned inl(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +inline void outl(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +inline unsigned char inb_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_uchar(); +} + +inline void outb_p(unsigned char byte, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +inline unsigned short inw_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_ushort(); +} + +inline void outw_p(unsigned short word, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} + +inline unsigned inl_p(unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); + + return nondet_unsigned(); +} + +inline void outl_p(unsigned doubleword, unsigned int port) +{ + __CPROVER_HIDE: + ddv_correct_port_use(port); +} diff --git a/ddverify/models/goblint/src/linux/kernel/sched.c b/ddverify/models/goblint/src/linux/kernel/sched.c new file mode 100644 index 000000000..9a23084b2 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/sched.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include +#include + +void schedule() +{ + assert_context_process(); +} + +long schedule_timeout(long timeout) +{ + assert_context_process(); + + return nondet_long(); +} diff --git a/ddverify/models/goblint/src/linux/kernel/semaphore.c b/ddverify/models/goblint/src/linux/kernel/semaphore.c new file mode 100644 index 000000000..d14ca0398 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/semaphore.c @@ -0,0 +1,86 @@ +#include +#include +#include + +// DDV: The count value is ignored because ddverify only supports binary semaphores! +inline void sema_init(struct semaphore *sem, int val) +{ + sem->init = 1; + sem->locked = 0; +} + +inline void init_MUTEX(struct semaphore * sem) +{ + sem->init = 1; + sem->locked = 0; +} + +inline void init_MUTEX_LOCKED(struct semaphore * sem) +{ + sem->init = 1; + sem->locked = 1; +} + +inline void down(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); + __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); +#endif + sem->locked = 1; + __CPROVER_atomic_end(); +} + +inline int down_interruptible(struct semaphore * sem) +{ + if (nondet_int()) { + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); + __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); +#endif + sem->locked = 1; + __CPROVER_atomic_end(); + + return 0; + } else { + return -1; + } +} + +inline int down_trylock(struct semaphore * sem) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); + assert_context_process(); + +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->init, "Semaphore is initialized"); +#endif + + if (sem->locked == 0) { + sem->locked = 1; + return 0; + } else { + return 1; + } + + __CPROVER_atomic_end(); + + return 0; +} + +inline void up(struct semaphore * sem) +{ + __CPROVER_HIDE: + assert_context_process(); +#ifdef DDV_ASSERT_SEMAPHORE + __CPROVER_assert(sem->locked, "Unlock a not locked semaphore"); +#endif + sem->locked = 0; +} diff --git a/ddverify/models/goblint/src/linux/kernel/softirq.c b/ddverify/models/goblint/src/linux/kernel/softirq.c new file mode 100644 index 000000000..a65be7976 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/softirq.c @@ -0,0 +1,38 @@ +#include +#include + +inline void tasklet_schedule(struct tasklet_struct *t) +{ + int i; + int next_free = -1; + +#ifdef DDV_ASSERT_TASKLET + __CPROVER_assert(t->init, "Tasklet is initialized!"); +#endif + + for (i = 0; i < MAX_TASKLET_SUPPORT; i++) { + if (tasklet_registered[i].tasklet == NULL) { + next_free = i; + } + if ((tasklet_registered[i].tasklet == t) && + (tasklet_registered[i].is_running == 0)) { + return; + } + } + + if (next_free == -1) { +// __CPROVER_assert(0, "Number of supported tasklets is sufficient"); + } + + tasklet_registered[next_free].tasklet = t; + tasklet_registered[next_free].is_running = 0; +} + +inline void tasklet_init(struct tasklet_struct *t, + void (*func)(unsigned long), unsigned long data) +{ + t->count = 0; + t->init = 0; + t->func = func; + t->data = data; +} diff --git a/ddverify/models/goblint/src/linux/kernel/spinlock.c b/ddverify/models/goblint/src/linux/kernel/spinlock.c new file mode 100644 index 000000000..44eaec19b --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/spinlock.c @@ -0,0 +1,99 @@ +#include +#include + +inline void spin_lock_init(spinlock_t * lock) +{ + lock->init = 1; + lock->locked = 0; +} + +inline void spin_lock(spinlock_t * lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +inline void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +inline void spin_lock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +inline void spin_lock_bh(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->init, "Spinlock is initialized"); + __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); +#endif + lock->locked = 1; + __CPROVER_atomic_end(); +} + +inline void spin_unlock(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; +} + +inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} + +inline void spin_unlock_irq(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} + +inline void spin_unlock_bh(spinlock_t *lock) +{ + __CPROVER_HIDE: + __CPROVER_atomic_begin(); +#ifdef DDV_ASSERT_SPINLOCK + __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); +#endif + lock->locked = 0; + __CPROVER_atomic_end(); +} diff --git a/ddverify/models/goblint/src/linux/kernel/timer.c b/ddverify/models/goblint/src/linux/kernel/timer.c new file mode 100644 index 000000000..fd2f92f95 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/timer.c @@ -0,0 +1,43 @@ +#include +#include + +inline void init_timer(struct timer_list * timer) +{ + if (number_timer_registered < MAX_TIMER_SUPPORT) { + timer->__ddv_active = 0; + timer->__ddv_init = 1; + timer_registered[number_timer_registered].timer = timer; + + number_timer_registered++; + } +} + +inline void add_timer(struct timer_list *timer) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->__ddv_active = 1; +} + +inline void add_timer_on(struct timer_list *timer, int cpu) +{ + // We do not care about the cpu number! + add_timer(timer); +} + +inline int del_timer(struct timer_list * timer) +{ + timer->__ddv_active = 0; +} + +inline int mod_timer(struct timer_list *timer, unsigned long expires) +{ +#ifdef DDV_ASSERT_TIMER + __CPROVER_HIDE: + __CPROVER_assert(timer->__ddv_init, "Timer is initialized"); +#endif + timer->expires = expires; + timer->__ddv_active = 1; +} diff --git a/ddverify/models/goblint/src/linux/kernel/wait.c b/ddverify/models/goblint/src/linux/kernel/wait.c new file mode 100644 index 000000000..cc986589f --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/wait.c @@ -0,0 +1,46 @@ +#include + +inline void init_waitqueue_head(wait_queue_head_t *q) +{ + q->init = 1; +} + +inline void wake_up(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +inline void wake_up_all(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +inline void wake_up_interruptible(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +inline void sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} + +inline void interruptible_sleep_on(wait_queue_head_t *q) +{ +#ifdef DDV_ASSERT_WAIT_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(q->init, "Wait queue is initialized!"); +#endif +} diff --git a/ddverify/models/goblint/src/linux/kernel/workqueue.c b/ddverify/models/goblint/src/linux/kernel/workqueue.c new file mode 100644 index 000000000..aae5e6910 --- /dev/null +++ b/ddverify/models/goblint/src/linux/kernel/workqueue.c @@ -0,0 +1,39 @@ +#include +#include +#include + +inline int schedule_work(struct work_struct *work) +{ + int i; + +#ifdef DDV_ASSERT_WORK_QUEUE + __CPROVER_HIDE: + __CPROVER_assert(work->init, "Work queue is initalized"); +#endif + + for (i = 0; i < MAX_WORKQUEUE_ELEMENTS_SUPPORT; i++) { + if (shared_workqueue[i] == work) { + return 0; + } + + if (shared_workqueue[i] == NULL) { + shared_workqueue[i] = work; + + return 1; + } + } + + + return -1; +} + +void call_shared_workqueue_functions() +{ + unsigned short i = nondet_ushort(); + __CPROVER_assume(i < MAX_WORKQUEUE_ELEMENTS_SUPPORT); + + if (shared_workqueue[i] != NULL) { + (*shared_workqueue[i]->func)(shared_workqueue[i]->data); + shared_workqueue[i] = NULL; + } +} diff --git a/ddverify/models/goblint/src/linux/mm/page_alloc.c b/ddverify/models/goblint/src/linux/mm/page_alloc.c new file mode 100644 index 000000000..4d1ed67c9 --- /dev/null +++ b/ddverify/models/goblint/src/linux/mm/page_alloc.c @@ -0,0 +1,52 @@ +#include +#include +#include + +inline unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +inline unsigned long __get_free_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +inline unsigned long get_zeroed_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +inline static struct page *alloc_pages_node( + int nid, gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +inline struct page * alloc_pages(gfp_t gfp_mask, unsigned int order) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} + +inline struct page * alloc_page(gfp_t gfp_mask) +{ + __CPROVER_HIDE: + if (gfp_mask & __GFP_WAIT) { + assert_context_process(); + } +} diff --git a/ddverify/models/goblint/src/linux/mm/slab.c b/ddverify/models/goblint/src/linux/mm/slab.c new file mode 100644 index 000000000..7b21afa25 --- /dev/null +++ b/ddverify/models/goblint/src/linux/mm/slab.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +void * kmalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} + +void * kzalloc(size_t size, gfp_t flags) +{ + if (flags & __GFP_WAIT) { + assert_context_process(); + } + + return malloc(size); +} diff --git a/ddverify/models/goblint/src/linux/mm/vmalloc.c b/ddverify/models/goblint/src/linux/mm/vmalloc.c new file mode 100644 index 000000000..0edd579f7 --- /dev/null +++ b/ddverify/models/goblint/src/linux/mm/vmalloc.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +void * vmalloc(unsigned long size) +{ + return malloc(size); +} diff --git a/ddverify/models/goblint/src/linux/pci.c b/ddverify/models/goblint/src/linux/pci.c new file mode 100644 index 000000000..8853d1e3e --- /dev/null +++ b/ddverify/models/goblint/src/linux/pci.c @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#include +#include + +inline int pci_enable_device(struct pci_dev *dev) +{ + int i; + + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + dev->resource[i].flags = IORESOURCE_IO; + dev->resource[i].start = nondet_uint(); + dev->resource[i].end = dev->resource[i].start + nondet_ushort(); + } +} + +inline struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from) +{ + if (from == NULL) { + from = (struct pci_dev*)malloc(sizeof(struct pci_dev)); + } + + if (nondet_int()) { + from->vendor = nondet_ushort(); + from->device = nondet_ushort(); + from->irq = nondet_uint(); + __CPROVER_assume(from->irq < MAX_IRQ_SUPPORT); + + return from; + } else { + return NULL; + } +} + +inline int pci_register_driver(struct pci_driver *driver) +{ + if (nondet_int()) { + registered_pci_driver.pci_driver = driver; + registered_pci_driver.no_pci_device_id = sizeof(driver->id_table) / sizeof(struct pci_device_id); + registered_pci_driver.dev_initialized = 0; + + return 0; + } else { + return -1; + } +} + +inline void pci_unregister_driver(struct pci_driver *driver) +{ + registered_pci_driver.pci_driver = NULL; + registered_pci_driver.no_pci_device_id = 0; +} + +inline void pci_release_region(struct pci_dev *pdev, int bar) +{ + if (pci_resource_len(pdev, bar) == 0) + return; + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) + release_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) + release_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); +} + +inline int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) +{ + if (pci_resource_len(pdev, bar) == 0) + return 0; + + if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) { + if (!request_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { + if (!request_mem_region(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar), res_name)) + return -EBUSY; + } + + return 0; +} + +inline void pci_release_regions(struct pci_dev *pdev) +{ + int i; + + for (i = 0; i < 6; i++) + pci_release_region(pdev, i); +} + +inline int pci_request_regions(struct pci_dev *pdev, const char *res_name) +{ + int i; + + for (i = 0; i < 6; i++) + if(pci_request_region(pdev, i, res_name)) + goto err_out; + return 0; + + err_out: + while(--i >= 0) + pci_release_region(pdev, i); + + return -EBUSY; +} From ce930620437c7fcdfab4358cb3d261fc14ec3cbc Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 11:03:07 +0300 Subject: [PATCH 09/24] Replace ddverify pthread stubs with real pthread --- ddverify/goblint/conf/applicom.json | 1 + ddverify/goblint/conf/aztcd.json | 1 + ddverify/goblint/conf/cciss.json | 1 + ddverify/goblint/conf/cdu31a.json | 1 + ddverify/goblint/conf/cm206.json | 1 + ddverify/goblint/conf/cpqarray.json | 1 + ddverify/goblint/conf/cs5535_gpio.json | 1 + ddverify/goblint/conf/ds1286.json | 1 + ddverify/goblint/conf/efirtc.json | 1 + ddverify/goblint/conf/floppy.json | 1 + ddverify/goblint/conf/generic_nvram.json | 1 + ddverify/goblint/conf/genrtc.json | 1 + ddverify/goblint/conf/i8xx_tco.json | 1 + ddverify/goblint/conf/ib700wdt.json | 1 + ddverify/goblint/conf/machzwd.json | 1 + ddverify/goblint/conf/mixcomwd.json | 1 + ddverify/goblint/conf/nbd.json | 1 + ddverify/goblint/conf/nwbutton.json | 1 + ddverify/goblint/conf/pcwd.json | 1 + ddverify/goblint/conf/pcwd_pci.json | 1 + ddverify/goblint/conf/sbc60xxwdt.json | 1 + ddverify/goblint/conf/sc1200wdt.json | 1 + ddverify/goblint/conf/sc520_wdt.json | 1 + ddverify/goblint/conf/smsc37b787_wdt.json | 1 + ddverify/goblint/conf/toshiba.json | 1 + ddverify/goblint/conf/umem.json | 1 + ddverify/goblint/conf/w83877f_wdt.json | 1 + ddverify/goblint/conf/w83977f_wdt.json | 1 + ddverify/goblint/conf/wdt.json | 1 + ddverify/goblint/conf/wdt977.json | 1 + ddverify/goblint/conf/wdt_pci.json | 1 + ddverify/goblint/ddverify.py | 3 +- .../models/goblint/include/ddverify/pthread.h | 253 ------------------ .../models/goblint/include/ddverify/satabs.h | 27 -- .../models/goblint/src/ddverify/ddverify.c | 3 +- 35 files changed, 35 insertions(+), 282 deletions(-) delete mode 100644 ddverify/models/goblint/include/ddverify/pthread.h diff --git a/ddverify/goblint/conf/applicom.json b/ddverify/goblint/conf/applicom.json index 3c68ff9c2..c95802f37 100644 --- a/ddverify/goblint/conf/applicom.json +++ b/ddverify/goblint/conf/applicom.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR", diff --git a/ddverify/goblint/conf/aztcd.json b/ddverify/goblint/conf/aztcd.json index 9f3c5234b..3c648e044 100644 --- a/ddverify/goblint/conf/aztcd.json +++ b/ddverify/goblint/conf/aztcd.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK" diff --git a/ddverify/goblint/conf/cciss.json b/ddverify/goblint/conf/cciss.json index 75a08fd86..f0180839b 100644 --- a/ddverify/goblint/conf/cciss.json +++ b/ddverify/goblint/conf/cciss.json @@ -40,6 +40,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK", diff --git a/ddverify/goblint/conf/cdu31a.json b/ddverify/goblint/conf/cdu31a.json index d9bf7216e..dc8781315 100644 --- a/ddverify/goblint/conf/cdu31a.json +++ b/ddverify/goblint/conf/cdu31a.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK" diff --git a/ddverify/goblint/conf/cm206.json b/ddverify/goblint/conf/cm206.json index 6be68bab9..e2f7382dd 100644 --- a/ddverify/goblint/conf/cm206.json +++ b/ddverify/goblint/conf/cm206.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK" diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json index ed4b4b730..01f1c2ce6 100644 --- a/ddverify/goblint/conf/cpqarray.json +++ b/ddverify/goblint/conf/cpqarray.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK", diff --git a/ddverify/goblint/conf/cs5535_gpio.json b/ddverify/goblint/conf/cs5535_gpio.json index f730603f1..f33d9807b 100644 --- a/ddverify/goblint/conf/cs5535_gpio.json +++ b/ddverify/goblint/conf/cs5535_gpio.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR", diff --git a/ddverify/goblint/conf/ds1286.json b/ddverify/goblint/conf/ds1286.json index 14e2a0e96..7b1f17906 100644 --- a/ddverify/goblint/conf/ds1286.json +++ b/ddverify/goblint/conf/ds1286.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/efirtc.json b/ddverify/goblint/conf/efirtc.json index 6299a62bc..000cb1e03 100644 --- a/ddverify/goblint/conf/efirtc.json +++ b/ddverify/goblint/conf/efirtc.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/floppy.json b/ddverify/goblint/conf/floppy.json index 3e04fca42..e9e501675 100644 --- a/ddverify/goblint/conf/floppy.json +++ b/ddverify/goblint/conf/floppy.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK" diff --git a/ddverify/goblint/conf/generic_nvram.json b/ddverify/goblint/conf/generic_nvram.json index e84d4fab7..cef5ce0fb 100644 --- a/ddverify/goblint/conf/generic_nvram.json +++ b/ddverify/goblint/conf/generic_nvram.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/genrtc.json b/ddverify/goblint/conf/genrtc.json index 932761a6a..2845ca565 100644 --- a/ddverify/goblint/conf/genrtc.json +++ b/ddverify/goblint/conf/genrtc.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/i8xx_tco.json b/ddverify/goblint/conf/i8xx_tco.json index d82c49f51..65f50df02 100644 --- a/ddverify/goblint/conf/i8xx_tco.json +++ b/ddverify/goblint/conf/i8xx_tco.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR", diff --git a/ddverify/goblint/conf/ib700wdt.json b/ddverify/goblint/conf/ib700wdt.json index 481b57354..935bf7876 100644 --- a/ddverify/goblint/conf/ib700wdt.json +++ b/ddverify/goblint/conf/ib700wdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/machzwd.json b/ddverify/goblint/conf/machzwd.json index 05aedd8fe..0d7b0d37f 100644 --- a/ddverify/goblint/conf/machzwd.json +++ b/ddverify/goblint/conf/machzwd.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/mixcomwd.json b/ddverify/goblint/conf/mixcomwd.json index 7e6497507..9e09513af 100644 --- a/ddverify/goblint/conf/mixcomwd.json +++ b/ddverify/goblint/conf/mixcomwd.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/nbd.json b/ddverify/goblint/conf/nbd.json index 050f2d58e..c2720a269 100644 --- a/ddverify/goblint/conf/nbd.json +++ b/ddverify/goblint/conf/nbd.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK" diff --git a/ddverify/goblint/conf/nwbutton.json b/ddverify/goblint/conf/nwbutton.json index c5de6f4ab..ca2b8340e 100644 --- a/ddverify/goblint/conf/nwbutton.json +++ b/ddverify/goblint/conf/nwbutton.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/pcwd.json b/ddverify/goblint/conf/pcwd.json index 0dcc3effb..3bcd8d4a5 100644 --- a/ddverify/goblint/conf/pcwd.json +++ b/ddverify/goblint/conf/pcwd.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/pcwd_pci.json b/ddverify/goblint/conf/pcwd_pci.json index 76adbe2ab..cb38f3df5 100644 --- a/ddverify/goblint/conf/pcwd_pci.json +++ b/ddverify/goblint/conf/pcwd_pci.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR", diff --git a/ddverify/goblint/conf/sbc60xxwdt.json b/ddverify/goblint/conf/sbc60xxwdt.json index b2812954b..30f4b2032 100644 --- a/ddverify/goblint/conf/sbc60xxwdt.json +++ b/ddverify/goblint/conf/sbc60xxwdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/sc1200wdt.json b/ddverify/goblint/conf/sc1200wdt.json index 83dd7e507..8ad9cf712 100644 --- a/ddverify/goblint/conf/sc1200wdt.json +++ b/ddverify/goblint/conf/sc1200wdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR", diff --git a/ddverify/goblint/conf/sc520_wdt.json b/ddverify/goblint/conf/sc520_wdt.json index df06a5137..557661077 100644 --- a/ddverify/goblint/conf/sc520_wdt.json +++ b/ddverify/goblint/conf/sc520_wdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/smsc37b787_wdt.json b/ddverify/goblint/conf/smsc37b787_wdt.json index fa3d5f28b..1f87237d6 100644 --- a/ddverify/goblint/conf/smsc37b787_wdt.json +++ b/ddverify/goblint/conf/smsc37b787_wdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/toshiba.json b/ddverify/goblint/conf/toshiba.json index c52bf530b..3d86f0f0b 100644 --- a/ddverify/goblint/conf/toshiba.json +++ b/ddverify/goblint/conf/toshiba.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/umem.json b/ddverify/goblint/conf/umem.json index 0aac8aa72..cb11aee92 100644 --- a/ddverify/goblint/conf/umem.json +++ b/ddverify/goblint/conf/umem.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK", diff --git a/ddverify/goblint/conf/w83877f_wdt.json b/ddverify/goblint/conf/w83877f_wdt.json index f9794aaaf..9afe60dc5 100644 --- a/ddverify/goblint/conf/w83877f_wdt.json +++ b/ddverify/goblint/conf/w83877f_wdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/w83977f_wdt.json b/ddverify/goblint/conf/w83977f_wdt.json index 4dc977b57..7b25c8384 100644 --- a/ddverify/goblint/conf/w83977f_wdt.json +++ b/ddverify/goblint/conf/w83977f_wdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/wdt.json b/ddverify/goblint/conf/wdt.json index 4abecd452..333ed7ed1 100644 --- a/ddverify/goblint/conf/wdt.json +++ b/ddverify/goblint/conf/wdt.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/wdt977.json b/ddverify/goblint/conf/wdt977.json index e9f758083..af043365f 100644 --- a/ddverify/goblint/conf/wdt977.json +++ b/ddverify/goblint/conf/wdt977.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR" diff --git a/ddverify/goblint/conf/wdt_pci.json b/ddverify/goblint/conf/wdt_pci.json index 86ea99ee5..811856cea 100644 --- a/ddverify/goblint/conf/wdt_pci.json +++ b/ddverify/goblint/conf/wdt_pci.json @@ -39,6 +39,7 @@ "models/goblint/include" ], "cppflags": [ + "-m32", "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_CHAR", diff --git a/ddverify/goblint/ddverify.py b/ddverify/goblint/ddverify.py index fc9e340fc..d80c6d0b6 100755 --- a/ddverify/goblint/ddverify.py +++ b/ddverify/goblint/ddverify.py @@ -62,7 +62,8 @@ class DriverType(Enum): files = [main_path, module_path] + other_paths + sorted((model_path / "src").glob("**/*.c")) -cppflags = ["-D__KERNEL__", "-DMODULE"] +# -m32 needed for size_t and pthread sizes to match +cppflags = ["-m32", "-D__KERNEL__", "-DMODULE"] if driver_type == DriverType.CHAR: cppflags.append("-DDRIVER_TYPE_CHAR") elif driver_type == DriverType.BLOCK: diff --git a/ddverify/models/goblint/include/ddverify/pthread.h b/ddverify/models/goblint/include/ddverify/pthread.h deleted file mode 100644 index 64c351ee6..000000000 --- a/ddverify/models/goblint/include/ddverify/pthread.h +++ /dev/null @@ -1,253 +0,0 @@ -#ifndef __POSIX_PTHREAD_H -#define __POSIX_PTHREAD_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef NULL -#define NULL ((void *)0) -#endif - -/* Types */ -struct __pthread_t_struct -{ - int id; -}; - -struct __pthread_attr_t_struct -{ - int dummy; -}; - -struct __pthread_mutex_t_struct -{ - _Bool locked; -}; - -struct __pthread_mutexattr_t_struct -{ - int dummy; -}; - -struct __pthread_spinlock_t_struct -{ - int dummy; -}; - -struct __pthread_barrier_t_struct -{ - int dummy; -}; - -struct __pthread_barrierattr_t_struct -{ - int dummy; -}; - -typedef struct __pthread_t_struct pthread_t; -typedef struct __pthread_attr_t_struct pthread_attr_t; -typedef struct __pthread_mutex_t_struct pthread_mutex_t; -typedef struct __pthread_mutexattr_t_struct pthread_mutexattr_t; -typedef struct __pthread_spinlock_t_struct pthread_spinlock_t; -typedef struct __pthread_barrier_t_struct pthread_barrier_t; -typedef struct __pthread_barrierattr_t_struct pthread_barrierattr_t; - -/* Initializers */ - -#define PTHREAD_MUTEX_INITIALIZER {0} - -/* Attributes */ - -enum -{ - PTHREAD_CREATE_JOINABLE, -#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE - PTHREAD_CREATE_DETACHED -#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED -}; - -enum -{ - PTHREAD_INHERIT_SCHED, -#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED - PTHREAD_EXPLICIT_SCHED -#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED -}; - -enum -{ - PTHREAD_SCOPE_SYSTEM, -#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM - PTHREAD_SCOPE_PROCESS -#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS -}; - -enum -{ - PTHREAD_MUTEX_TIMED_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_ADAPTIVE_NP, - PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, - PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL -}; - -enum -{ - PTHREAD_PROCESS_PRIVATE, -#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE - PTHREAD_PROCESS_SHARED -#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED -}; - -enum -{ - PTHREAD_RWLOCK_PREFER_READER_NP, - PTHREAD_RWLOCK_PREFER_WRITER_NP, - PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, - PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP -}; - -#define PTHREAD_ONCE_INIT 0 - -/* -1 is distinct from 0 and all errno constants */ -#define PTHREAD_BARRIER_SERIAL_THREAD -1 - -enum -{ - PTHREAD_CANCEL_ENABLE, -#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE - PTHREAD_CANCEL_DISABLE -#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE -}; -enum -{ - PTHREAD_CANCEL_DEFERRED, -#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED - PTHREAD_CANCEL_ASYNCHRONOUS -#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS -}; -#define PTHREAD_CANCELED ((void *) -1) - -pthread_t nondet_pthread_t(); - -extern inline int pthread_create( - pthread_t *__threadp, - __const pthread_attr_t *__attr, - void *(*__start_routine) (void *), - void *__arg); - -extern pthread_t pthread_self(void); -extern int pthread_equal(pthread_t __thread1, pthread_t __thread2); -extern void pthread_exit(void *__retval); -extern int pthread_join(pthread_t __th, void **__thread_return); -extern int pthread_detach(pthread_t __th); -extern int pthread_attr_init(pthread_attr_t *__attr); -extern int pthread_attr_destroy(pthread_attr_t *__attr); -extern int pthread_attr_setdetachstate(pthread_attr_t *__attr, int __detachstate); -extern int pthread_attr_getdetachstate(__const pthread_attr_t *__attr, int *__detachstate); -extern int pthread_attr_setschedparam(pthread_attr_t *__attr, __const struct sched_param *__param); -extern int pthread_attr_getschedparam(__const pthread_attr_t *__attr, struct sched_param *__param); -extern int pthread_attr_setschedpolicy(pthread_attr_t *__attr, int __policy); -extern int pthread_attr_getschedpolicy(__const pthread_attr_t *__attr, int *__policy); -extern int pthread_attr_setinheritsched(pthread_attr_t *__attr, int __inherit); -extern int pthread_attr_getinheritsched(__const pthread_attr_t *__attr, int *__inherit); -extern int pthread_attr_setscope(pthread_attr_t *__attr, int __scope); -extern int pthread_attr_getscope(__const pthread_attr_t *__attr, int *__scope); -extern int pthread_attr_setguardsize(pthread_attr_t *__attr, size_t __guardsize); -extern int pthread_attr_getguardsize(__const pthread_attr_t *__attr, size_t *__guardsize); -extern int pthread_attr_setstackaddr(pthread_attr_t *__attr, void *__stackaddr); -extern int pthread_attr_getstackaddr(__const pthread_attr_t *__attr, void **__stackaddr); -extern int pthread_attr_setstack(pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize); -extern int pthread_attr_getstack(__const pthread_attr_t *__attr, - void **__stackaddr, - size_t *__stacksize); -extern int pthread_attr_setstacksize(pthread_attr_t *__attr, size_t __stacksize); -extern int pthread_attr_getstacksize(__const pthread_attr_t *, size_t *__stacksize); - -extern int pthread_getattr_np(pthread_t __th, pthread_attr_t *__attr); - -extern int pthread_setschedparam(pthread_t __target_thread, int __policy, - __const struct sched_param *__param); - -extern int pthread_getschedparam(pthread_t __target_thread, - int *__policy, - struct sched_param *__param); - -extern int pthread_getconcurrency(void); -extern int pthread_setconcurrency(int __level); -extern int pthread_yield(void); - -extern inline int pthread_mutex_init( - pthread_mutex_t *__mutex, - __const pthread_mutexattr_t *__mutex_attr) -{ - pthread_mutex_t i=PTHREAD_MUTEX_INITIALIZER; - *__mutex=i; -} - -extern inline int pthread_mutex_destroy(pthread_mutex_t *__mutex) -{ -} - -extern int pthread_mutex_trylock(pthread_mutex_t *__mutex); - -void __CPROVER_atomic_begin(); -void __CPROVER_atomic_end(); - -extern inline int pthread_mutex_lock(pthread_mutex_t *__mutex) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); - __CPROVER_assume(!__mutex->locked); - __mutex->locked=1; - __CPROVER_atomic_end(); - return 0; // we never fail -} - -extern inline int pthread_mutex_unlock(pthread_mutex_t *__mutex) -{ - __CPROVER_HIDE: - __CPROVER_assert(__mutex->locked, "pthread_mutex_unlock without lock"); - __mutex->locked=0; - return 0; // we never fail -} - -extern int pthread_spin_init(pthread_spinlock_t *__lock, int __pshared); -extern int pthread_spin_destroy(pthread_spinlock_t *__lock); -extern int pthread_spin_lock(pthread_spinlock_t *__lock); -extern int pthread_spin_trylock(pthread_spinlock_t *__lock); -extern int pthread_spin_unlock(pthread_spinlock_t *__lock); -extern int pthread_barrier_init(pthread_barrier_t *__barrier, - __const pthread_barrierattr_t *__attr, unsigned int __count); - -extern int pthread_barrier_destroy(pthread_barrier_t *__barrier); -extern int pthread_barrierattr_init(pthread_barrierattr_t *__attr); -extern int pthread_barrierattr_destroy(pthread_barrierattr_t *__attr); -extern int pthread_barrierattr_getpshared(__const pthread_barrierattr_t *__attr, - int *__pshared); - -extern int pthread_barrierattr_setpshared(pthread_barrierattr_t *__attr, int __pshared); -extern int pthread_barrier_wait(pthread_barrier_t *__barrier); - -extern int pthread_setcancelstate(int __state, int *__oldstate); -extern int pthread_setcanceltype(int __type, int *__oldtype); -extern int pthread_cancel(pthread_t __cancelthread); -extern void pthread_testcancel(void); - -extern int pthread_atfork(void (*__prepare)(void), - void (*__parent)(void), - void (*__child)(void)); - -extern void pthread_kill_other_threads_np(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ddverify/models/goblint/include/ddverify/satabs.h b/ddverify/models/goblint/include/ddverify/satabs.h index bb40b9867..854bade42 100644 --- a/ddverify/models/goblint/include/ddverify/satabs.h +++ b/ddverify/models/goblint/include/ddverify/satabs.h @@ -39,31 +39,4 @@ void noop(); void __CPROVER_atomic_begin(); void __CPROVER_atomic_end(); - -// pthread -struct __pthread_t_struct -{ - int id; -}; - -struct __pthread_attr_t_struct -{ - int dummy; -}; - -typedef struct __pthread_t_struct pthread_t; -typedef struct __pthread_attr_t_struct pthread_attr_t; - -pthread_t nondet_pthread_t(); - -extern inline int pthread_create(pthread_t *__threadp, - __const pthread_attr_t *__attr, - void *(*__start_routine) (void *), - void *__arg) -{ - __CPROVER_HIDE: - *__threadp = nondet_pthread_t(); - CPROVER_ASYNC_1: __start_routine(__arg); - return 0; -} #endif diff --git a/ddverify/models/goblint/src/ddverify/ddverify.c b/ddverify/models/goblint/src/ddverify/ddverify.c index 2e086bebb..bf69c0027 100644 --- a/ddverify/models/goblint/src/ddverify/ddverify.c +++ b/ddverify/models/goblint/src/ddverify/ddverify.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -12,6 +11,8 @@ #include #include +#include + void init_kernel() { int i; From ca9db859d9679f5c70d87f2b0c11c5b00d791426 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 11:10:18 +0300 Subject: [PATCH 10/24] Remove ddverify spinlock, semaphore, mutex stubs --- ddverify/goblint/conf/applicom.json | 3 - ddverify/goblint/conf/aztcd.json | 3 - ddverify/goblint/conf/cciss.json | 3 - ddverify/goblint/conf/cdu31a.json | 3 - ddverify/goblint/conf/cm206.json | 3 - ddverify/goblint/conf/cpqarray.json | 3 - ddverify/goblint/conf/cs5535_gpio.json | 3 - ddverify/goblint/conf/ds1286.json | 3 - ddverify/goblint/conf/efirtc.json | 3 - ddverify/goblint/conf/floppy.json | 3 - ddverify/goblint/conf/generic_nvram.json | 3 - ddverify/goblint/conf/genrtc.json | 3 - ddverify/goblint/conf/i8xx_tco.json | 3 - ddverify/goblint/conf/ib700wdt.json | 3 - ddverify/goblint/conf/machzwd.json | 3 - ddverify/goblint/conf/mixcomwd.json | 3 - ddverify/goblint/conf/nbd.json | 3 - ddverify/goblint/conf/nwbutton.json | 3 - ddverify/goblint/conf/pcwd.json | 3 - ddverify/goblint/conf/pcwd_pci.json | 3 - ddverify/goblint/conf/sbc60xxwdt.json | 3 - ddverify/goblint/conf/sc1200wdt.json | 3 - ddverify/goblint/conf/sc520_wdt.json | 3 - ddverify/goblint/conf/smsc37b787_wdt.json | 3 - ddverify/goblint/conf/toshiba.json | 3 - ddverify/goblint/conf/umem.json | 3 - ddverify/goblint/conf/w83877f_wdt.json | 3 - ddverify/goblint/conf/w83977f_wdt.json | 3 - ddverify/goblint/conf/wdt.json | 3 - ddverify/goblint/conf/wdt977.json | 3 - ddverify/goblint/conf/wdt_pci.json | 3 - .../models/goblint/src/linux/kernel/mutex.c | 37 ------- .../goblint/src/linux/kernel/semaphore.c | 86 ---------------- .../goblint/src/linux/kernel/spinlock.c | 99 ------------------- 34 files changed, 315 deletions(-) delete mode 100644 ddverify/models/goblint/src/linux/kernel/mutex.c delete mode 100644 ddverify/models/goblint/src/linux/kernel/semaphore.c delete mode 100644 ddverify/models/goblint/src/linux/kernel/spinlock.c diff --git a/ddverify/goblint/conf/applicom.json b/ddverify/goblint/conf/applicom.json index c95802f37..8d439ebbf 100644 --- a/ddverify/goblint/conf/applicom.json +++ b/ddverify/goblint/conf/applicom.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/aztcd.json b/ddverify/goblint/conf/aztcd.json index 3c648e044..405bbde8e 100644 --- a/ddverify/goblint/conf/aztcd.json +++ b/ddverify/goblint/conf/aztcd.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/cciss.json b/ddverify/goblint/conf/cciss.json index f0180839b..2da1c5c2f 100644 --- a/ddverify/goblint/conf/cciss.json +++ b/ddverify/goblint/conf/cciss.json @@ -21,12 +21,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/cdu31a.json b/ddverify/goblint/conf/cdu31a.json index dc8781315..75869f397 100644 --- a/ddverify/goblint/conf/cdu31a.json +++ b/ddverify/goblint/conf/cdu31a.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/cm206.json b/ddverify/goblint/conf/cm206.json index e2f7382dd..2783c4093 100644 --- a/ddverify/goblint/conf/cm206.json +++ b/ddverify/goblint/conf/cm206.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json index 01f1c2ce6..bd52daebd 100644 --- a/ddverify/goblint/conf/cpqarray.json +++ b/ddverify/goblint/conf/cpqarray.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/cs5535_gpio.json b/ddverify/goblint/conf/cs5535_gpio.json index f33d9807b..0f73cd3d6 100644 --- a/ddverify/goblint/conf/cs5535_gpio.json +++ b/ddverify/goblint/conf/cs5535_gpio.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/ds1286.json b/ddverify/goblint/conf/ds1286.json index 7b1f17906..61da28301 100644 --- a/ddverify/goblint/conf/ds1286.json +++ b/ddverify/goblint/conf/ds1286.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/efirtc.json b/ddverify/goblint/conf/efirtc.json index 000cb1e03..f26c030d4 100644 --- a/ddverify/goblint/conf/efirtc.json +++ b/ddverify/goblint/conf/efirtc.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/floppy.json b/ddverify/goblint/conf/floppy.json index e9e501675..dfb46aaf5 100644 --- a/ddverify/goblint/conf/floppy.json +++ b/ddverify/goblint/conf/floppy.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/generic_nvram.json b/ddverify/goblint/conf/generic_nvram.json index cef5ce0fb..d8d01d1ea 100644 --- a/ddverify/goblint/conf/generic_nvram.json +++ b/ddverify/goblint/conf/generic_nvram.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/genrtc.json b/ddverify/goblint/conf/genrtc.json index 2845ca565..cd9f1272d 100644 --- a/ddverify/goblint/conf/genrtc.json +++ b/ddverify/goblint/conf/genrtc.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/i8xx_tco.json b/ddverify/goblint/conf/i8xx_tco.json index 65f50df02..520a17739 100644 --- a/ddverify/goblint/conf/i8xx_tco.json +++ b/ddverify/goblint/conf/i8xx_tco.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/ib700wdt.json b/ddverify/goblint/conf/ib700wdt.json index 935bf7876..8a2bbb2a0 100644 --- a/ddverify/goblint/conf/ib700wdt.json +++ b/ddverify/goblint/conf/ib700wdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/machzwd.json b/ddverify/goblint/conf/machzwd.json index 0d7b0d37f..98a8b6a7b 100644 --- a/ddverify/goblint/conf/machzwd.json +++ b/ddverify/goblint/conf/machzwd.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/mixcomwd.json b/ddverify/goblint/conf/mixcomwd.json index 9e09513af..8f8f878c3 100644 --- a/ddverify/goblint/conf/mixcomwd.json +++ b/ddverify/goblint/conf/mixcomwd.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/nbd.json b/ddverify/goblint/conf/nbd.json index c2720a269..35a994c9b 100644 --- a/ddverify/goblint/conf/nbd.json +++ b/ddverify/goblint/conf/nbd.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/nwbutton.json b/ddverify/goblint/conf/nwbutton.json index ca2b8340e..7834ad3fc 100644 --- a/ddverify/goblint/conf/nwbutton.json +++ b/ddverify/goblint/conf/nwbutton.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/pcwd.json b/ddverify/goblint/conf/pcwd.json index 3bcd8d4a5..234f017f3 100644 --- a/ddverify/goblint/conf/pcwd.json +++ b/ddverify/goblint/conf/pcwd.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/pcwd_pci.json b/ddverify/goblint/conf/pcwd_pci.json index cb38f3df5..a647d5df0 100644 --- a/ddverify/goblint/conf/pcwd_pci.json +++ b/ddverify/goblint/conf/pcwd_pci.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/sbc60xxwdt.json b/ddverify/goblint/conf/sbc60xxwdt.json index 30f4b2032..3d9cbb8c8 100644 --- a/ddverify/goblint/conf/sbc60xxwdt.json +++ b/ddverify/goblint/conf/sbc60xxwdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/sc1200wdt.json b/ddverify/goblint/conf/sc1200wdt.json index 8ad9cf712..e4b336d97 100644 --- a/ddverify/goblint/conf/sc1200wdt.json +++ b/ddverify/goblint/conf/sc1200wdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/sc520_wdt.json b/ddverify/goblint/conf/sc520_wdt.json index 557661077..0ffd88a1e 100644 --- a/ddverify/goblint/conf/sc520_wdt.json +++ b/ddverify/goblint/conf/sc520_wdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/smsc37b787_wdt.json b/ddverify/goblint/conf/smsc37b787_wdt.json index 1f87237d6..dfe76a231 100644 --- a/ddverify/goblint/conf/smsc37b787_wdt.json +++ b/ddverify/goblint/conf/smsc37b787_wdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/toshiba.json b/ddverify/goblint/conf/toshiba.json index 3d86f0f0b..050f19042 100644 --- a/ddverify/goblint/conf/toshiba.json +++ b/ddverify/goblint/conf/toshiba.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/umem.json b/ddverify/goblint/conf/umem.json index cb11aee92..ac1fdbab0 100644 --- a/ddverify/goblint/conf/umem.json +++ b/ddverify/goblint/conf/umem.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/w83877f_wdt.json b/ddverify/goblint/conf/w83877f_wdt.json index 9afe60dc5..593b1100d 100644 --- a/ddverify/goblint/conf/w83877f_wdt.json +++ b/ddverify/goblint/conf/w83877f_wdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/w83977f_wdt.json b/ddverify/goblint/conf/w83977f_wdt.json index 7b25c8384..a40431dab 100644 --- a/ddverify/goblint/conf/w83977f_wdt.json +++ b/ddverify/goblint/conf/w83977f_wdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/wdt.json b/ddverify/goblint/conf/wdt.json index 333ed7ed1..0906c8350 100644 --- a/ddverify/goblint/conf/wdt.json +++ b/ddverify/goblint/conf/wdt.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/wdt977.json b/ddverify/goblint/conf/wdt977.json index af043365f..c0236edec 100644 --- a/ddverify/goblint/conf/wdt977.json +++ b/ddverify/goblint/conf/wdt977.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/goblint/conf/wdt_pci.json b/ddverify/goblint/conf/wdt_pci.json index 811856cea..d8cb3b81e 100644 --- a/ddverify/goblint/conf/wdt_pci.json +++ b/ddverify/goblint/conf/wdt_pci.json @@ -20,12 +20,9 @@ "models/goblint/src/linux/fs/proc/generic.c", "models/goblint/src/linux/fs/read_write.c", "models/goblint/src/linux/kernel/irq/manage.c", - "models/goblint/src/linux/kernel/mutex.c", "models/goblint/src/linux/kernel/resource.c", "models/goblint/src/linux/kernel/sched.c", - "models/goblint/src/linux/kernel/semaphore.c", "models/goblint/src/linux/kernel/softirq.c", - "models/goblint/src/linux/kernel/spinlock.c", "models/goblint/src/linux/kernel/timer.c", "models/goblint/src/linux/kernel/wait.c", "models/goblint/src/linux/kernel/workqueue.c", diff --git a/ddverify/models/goblint/src/linux/kernel/mutex.c b/ddverify/models/goblint/src/linux/kernel/mutex.c deleted file mode 100644 index 345196152..000000000 --- a/ddverify/models/goblint/src/linux/kernel/mutex.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -inline void mutex_init(struct mutex *lock) -{ - __CPROVER_HIDE: -#ifdef DDV_ASSERT_MUTEX - __CPROVER_assert(!lock->locked, "Locked mutex must not be reinitialized"); -#endif - lock->locked = 0; - lock->init = 1; -} - -inline void mutex_lock(struct mutex *lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); - assert_context_process(); -#ifdef DDV_ASSERT_MUTEX - __CPROVER_assert(lock->init, "Mutex is initialized"); - __CPROVER_assert(!lock->locked, "Lock a locked mutex"); -#endif - lock->locked = 1; - __CPROVER_atomic_end(); -} - -inline void mutex_unlock(struct mutex *lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); - assert_context_process(); -#ifdef DDV_ASSERT_MUTEX - __CPROVER_assert(lock->locked, "Unlock a not locked mutex"); -#endif - lock->locked = 0; - __CPROVER_atomic_end(); -} diff --git a/ddverify/models/goblint/src/linux/kernel/semaphore.c b/ddverify/models/goblint/src/linux/kernel/semaphore.c deleted file mode 100644 index d14ca0398..000000000 --- a/ddverify/models/goblint/src/linux/kernel/semaphore.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include - -// DDV: The count value is ignored because ddverify only supports binary semaphores! -inline void sema_init(struct semaphore *sem, int val) -{ - sem->init = 1; - sem->locked = 0; -} - -inline void init_MUTEX(struct semaphore * sem) -{ - sem->init = 1; - sem->locked = 0; -} - -inline void init_MUTEX_LOCKED(struct semaphore * sem) -{ - sem->init = 1; - sem->locked = 1; -} - -inline void down(struct semaphore * sem) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); - assert_context_process(); -#ifdef DDV_ASSERT_SEMAPHORE - __CPROVER_assert(sem->init, "Semaphore is initialized"); - __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); -#endif - sem->locked = 1; - __CPROVER_atomic_end(); -} - -inline int down_interruptible(struct semaphore * sem) -{ - if (nondet_int()) { - __CPROVER_HIDE: - __CPROVER_atomic_begin(); - assert_context_process(); -#ifdef DDV_ASSERT_SEMAPHORE - __CPROVER_assert(sem->init, "Semaphore is initialized"); - __CPROVER_assert(!sem->locked, "Lock a locked semaphore"); -#endif - sem->locked = 1; - __CPROVER_atomic_end(); - - return 0; - } else { - return -1; - } -} - -inline int down_trylock(struct semaphore * sem) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); - assert_context_process(); - -#ifdef DDV_ASSERT_SEMAPHORE - __CPROVER_assert(sem->init, "Semaphore is initialized"); -#endif - - if (sem->locked == 0) { - sem->locked = 1; - return 0; - } else { - return 1; - } - - __CPROVER_atomic_end(); - - return 0; -} - -inline void up(struct semaphore * sem) -{ - __CPROVER_HIDE: - assert_context_process(); -#ifdef DDV_ASSERT_SEMAPHORE - __CPROVER_assert(sem->locked, "Unlock a not locked semaphore"); -#endif - sem->locked = 0; -} diff --git a/ddverify/models/goblint/src/linux/kernel/spinlock.c b/ddverify/models/goblint/src/linux/kernel/spinlock.c deleted file mode 100644 index 44eaec19b..000000000 --- a/ddverify/models/goblint/src/linux/kernel/spinlock.c +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include - -inline void spin_lock_init(spinlock_t * lock) -{ - lock->init = 1; - lock->locked = 0; -} - -inline void spin_lock(spinlock_t * lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->init, "Spinlock is initialized"); - __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); -#endif - lock->locked = 1; - __CPROVER_atomic_end(); -} - -inline void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->init, "Spinlock is initialized"); - __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); -#endif - lock->locked = 1; - __CPROVER_atomic_end(); -} - -inline void spin_lock_irq(spinlock_t *lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->init, "Spinlock is initialized"); - __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); -#endif - lock->locked = 1; - __CPROVER_atomic_end(); -} - -inline void spin_lock_bh(spinlock_t *lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->init, "Spinlock is initialized"); - __CPROVER_assert(!lock->locked, "Lock a locked spinlock"); -#endif - lock->locked = 1; - __CPROVER_atomic_end(); -} - -inline void spin_unlock(spinlock_t *lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); -#endif - lock->locked = 0; -} - -inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); -#endif - lock->locked = 0; - __CPROVER_atomic_end(); -} - -inline void spin_unlock_irq(spinlock_t *lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); -#endif - lock->locked = 0; - __CPROVER_atomic_end(); -} - -inline void spin_unlock_bh(spinlock_t *lock) -{ - __CPROVER_HIDE: - __CPROVER_atomic_begin(); -#ifdef DDV_ASSERT_SPINLOCK - __CPROVER_assert(lock->locked, "Unlock a not locked spinlock"); -#endif - lock->locked = 0; - __CPROVER_atomic_end(); -} From d5f74f054a3e23ddd421d7716cd149b0666f27b5 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 11:28:59 +0300 Subject: [PATCH 11/24] Define satabs functions in ddverify --- ddverify/goblint/conf/applicom.json | 6 +++ ddverify/goblint/conf/aztcd.json | 6 +++ ddverify/goblint/conf/cciss.json | 6 +++ ddverify/goblint/conf/cdu31a.json | 6 +++ ddverify/goblint/conf/cm206.json | 6 +++ ddverify/goblint/conf/cpqarray.json | 6 +++ ddverify/goblint/conf/cs5535_gpio.json | 6 +++ ddverify/goblint/conf/ds1286.json | 6 +++ ddverify/goblint/conf/efirtc.json | 6 +++ ddverify/goblint/conf/floppy.json | 6 +++ ddverify/goblint/conf/generic_nvram.json | 6 +++ ddverify/goblint/conf/genrtc.json | 6 +++ ddverify/goblint/conf/i8xx_tco.json | 6 +++ ddverify/goblint/conf/ib700wdt.json | 6 +++ ddverify/goblint/conf/machzwd.json | 6 +++ ddverify/goblint/conf/mixcomwd.json | 6 +++ ddverify/goblint/conf/nbd.json | 6 +++ ddverify/goblint/conf/nwbutton.json | 6 +++ ddverify/goblint/conf/pcwd.json | 6 +++ ddverify/goblint/conf/pcwd_pci.json | 6 +++ ddverify/goblint/conf/sbc60xxwdt.json | 6 +++ ddverify/goblint/conf/sc1200wdt.json | 6 +++ ddverify/goblint/conf/sc520_wdt.json | 6 +++ ddverify/goblint/conf/smsc37b787_wdt.json | 6 +++ ddverify/goblint/conf/toshiba.json | 6 +++ ddverify/goblint/conf/umem.json | 6 +++ ddverify/goblint/conf/w83877f_wdt.json | 6 +++ ddverify/goblint/conf/w83977f_wdt.json | 6 +++ ddverify/goblint/conf/wdt.json | 6 +++ ddverify/goblint/conf/wdt977.json | 6 +++ ddverify/goblint/conf/wdt_pci.json | 6 +++ ddverify/goblint/ddverify.py | 5 +++ ddverify/models/goblint/src/ddverify/satabs.c | 37 +++++++++++++++++++ 33 files changed, 228 insertions(+) create mode 100644 ddverify/models/goblint/src/ddverify/satabs.c diff --git a/ddverify/goblint/conf/applicom.json b/ddverify/goblint/conf/applicom.json index 8d439ebbf..096c62756 100644 --- a/ddverify/goblint/conf/applicom.json +++ b/ddverify/goblint/conf/applicom.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_CHAR", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/aztcd.json b/ddverify/goblint/conf/aztcd.json index 405bbde8e..e31a98a89 100644 --- a/ddverify/goblint/conf/aztcd.json +++ b/ddverify/goblint/conf/aztcd.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_BLOCK" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cciss.json b/ddverify/goblint/conf/cciss.json index 2da1c5c2f..2ce88ae8d 100644 --- a/ddverify/goblint/conf/cciss.json +++ b/ddverify/goblint/conf/cciss.json @@ -9,6 +9,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -43,5 +44,10 @@ "-DDRIVER_TYPE_BLOCK", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cdu31a.json b/ddverify/goblint/conf/cdu31a.json index 75869f397..cb7da2fb4 100644 --- a/ddverify/goblint/conf/cdu31a.json +++ b/ddverify/goblint/conf/cdu31a.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_BLOCK" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cm206.json b/ddverify/goblint/conf/cm206.json index 2783c4093..ce616c58f 100644 --- a/ddverify/goblint/conf/cm206.json +++ b/ddverify/goblint/conf/cm206.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_BLOCK" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json index bd52daebd..f09624f1e 100644 --- a/ddverify/goblint/conf/cpqarray.json +++ b/ddverify/goblint/conf/cpqarray.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_BLOCK", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cs5535_gpio.json b/ddverify/goblint/conf/cs5535_gpio.json index 0f73cd3d6..24168db8a 100644 --- a/ddverify/goblint/conf/cs5535_gpio.json +++ b/ddverify/goblint/conf/cs5535_gpio.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_CHAR", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/ds1286.json b/ddverify/goblint/conf/ds1286.json index 61da28301..ca9fbf247 100644 --- a/ddverify/goblint/conf/ds1286.json +++ b/ddverify/goblint/conf/ds1286.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/efirtc.json b/ddverify/goblint/conf/efirtc.json index f26c030d4..4cba20342 100644 --- a/ddverify/goblint/conf/efirtc.json +++ b/ddverify/goblint/conf/efirtc.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/floppy.json b/ddverify/goblint/conf/floppy.json index dfb46aaf5..25e2e0c6b 100644 --- a/ddverify/goblint/conf/floppy.json +++ b/ddverify/goblint/conf/floppy.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_BLOCK" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/generic_nvram.json b/ddverify/goblint/conf/generic_nvram.json index d8d01d1ea..3c26b5f3c 100644 --- a/ddverify/goblint/conf/generic_nvram.json +++ b/ddverify/goblint/conf/generic_nvram.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/genrtc.json b/ddverify/goblint/conf/genrtc.json index cd9f1272d..e09d0f0d4 100644 --- a/ddverify/goblint/conf/genrtc.json +++ b/ddverify/goblint/conf/genrtc.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/i8xx_tco.json b/ddverify/goblint/conf/i8xx_tco.json index 520a17739..f1008586d 100644 --- a/ddverify/goblint/conf/i8xx_tco.json +++ b/ddverify/goblint/conf/i8xx_tco.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_CHAR", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/ib700wdt.json b/ddverify/goblint/conf/ib700wdt.json index 8a2bbb2a0..f5a304e62 100644 --- a/ddverify/goblint/conf/ib700wdt.json +++ b/ddverify/goblint/conf/ib700wdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/machzwd.json b/ddverify/goblint/conf/machzwd.json index 98a8b6a7b..3f77e602b 100644 --- a/ddverify/goblint/conf/machzwd.json +++ b/ddverify/goblint/conf/machzwd.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/mixcomwd.json b/ddverify/goblint/conf/mixcomwd.json index 8f8f878c3..323afe9bf 100644 --- a/ddverify/goblint/conf/mixcomwd.json +++ b/ddverify/goblint/conf/mixcomwd.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/nbd.json b/ddverify/goblint/conf/nbd.json index 35a994c9b..eab0ad12d 100644 --- a/ddverify/goblint/conf/nbd.json +++ b/ddverify/goblint/conf/nbd.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_BLOCK" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/nwbutton.json b/ddverify/goblint/conf/nwbutton.json index 7834ad3fc..810ae8d86 100644 --- a/ddverify/goblint/conf/nwbutton.json +++ b/ddverify/goblint/conf/nwbutton.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/pcwd.json b/ddverify/goblint/conf/pcwd.json index 234f017f3..82b103a96 100644 --- a/ddverify/goblint/conf/pcwd.json +++ b/ddverify/goblint/conf/pcwd.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/pcwd_pci.json b/ddverify/goblint/conf/pcwd_pci.json index a647d5df0..cb2961b89 100644 --- a/ddverify/goblint/conf/pcwd_pci.json +++ b/ddverify/goblint/conf/pcwd_pci.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_CHAR", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/sbc60xxwdt.json b/ddverify/goblint/conf/sbc60xxwdt.json index 3d9cbb8c8..f3b89085d 100644 --- a/ddverify/goblint/conf/sbc60xxwdt.json +++ b/ddverify/goblint/conf/sbc60xxwdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/sc1200wdt.json b/ddverify/goblint/conf/sc1200wdt.json index e4b336d97..7d6dbabae 100644 --- a/ddverify/goblint/conf/sc1200wdt.json +++ b/ddverify/goblint/conf/sc1200wdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_CHAR", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/sc520_wdt.json b/ddverify/goblint/conf/sc520_wdt.json index 0ffd88a1e..ff30f35d2 100644 --- a/ddverify/goblint/conf/sc520_wdt.json +++ b/ddverify/goblint/conf/sc520_wdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/smsc37b787_wdt.json b/ddverify/goblint/conf/smsc37b787_wdt.json index dfe76a231..209893906 100644 --- a/ddverify/goblint/conf/smsc37b787_wdt.json +++ b/ddverify/goblint/conf/smsc37b787_wdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/toshiba.json b/ddverify/goblint/conf/toshiba.json index 050f19042..72db33352 100644 --- a/ddverify/goblint/conf/toshiba.json +++ b/ddverify/goblint/conf/toshiba.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/umem.json b/ddverify/goblint/conf/umem.json index ac1fdbab0..c2ee881c4 100644 --- a/ddverify/goblint/conf/umem.json +++ b/ddverify/goblint/conf/umem.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_BLOCK", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/w83877f_wdt.json b/ddverify/goblint/conf/w83877f_wdt.json index 593b1100d..126ea6ddb 100644 --- a/ddverify/goblint/conf/w83877f_wdt.json +++ b/ddverify/goblint/conf/w83877f_wdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/w83977f_wdt.json b/ddverify/goblint/conf/w83977f_wdt.json index a40431dab..bacfa4674 100644 --- a/ddverify/goblint/conf/w83977f_wdt.json +++ b/ddverify/goblint/conf/w83977f_wdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt.json b/ddverify/goblint/conf/wdt.json index 0906c8350..f7e93f230 100644 --- a/ddverify/goblint/conf/wdt.json +++ b/ddverify/goblint/conf/wdt.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt977.json b/ddverify/goblint/conf/wdt977.json index c0236edec..7bc3b1b55 100644 --- a/ddverify/goblint/conf/wdt977.json +++ b/ddverify/goblint/conf/wdt977.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -41,5 +42,10 @@ "-DMODULE", "-DDRIVER_TYPE_CHAR" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt_pci.json b/ddverify/goblint/conf/wdt_pci.json index d8cb3b81e..d2636572c 100644 --- a/ddverify/goblint/conf/wdt_pci.json +++ b/ddverify/goblint/conf/wdt_pci.json @@ -8,6 +8,7 @@ "models/goblint/src/ddverify/interrupt.c", "models/goblint/src/ddverify/ioctl.c", "models/goblint/src/ddverify/pci.c", + "models/goblint/src/ddverify/satabs.c", "models/goblint/src/ddverify/tasklet.c", "models/goblint/src/ddverify/timer.c", "models/goblint/src/linux/arch/i386/lib/usercopy.c", @@ -42,5 +43,10 @@ "-DDRIVER_TYPE_CHAR", "-DDRIVER_TYPE_PCI" ] + }, + "ana": { + "sv-comp": { + "functions": true + } } } \ No newline at end of file diff --git a/ddverify/goblint/ddverify.py b/ddverify/goblint/ddverify.py index d80c6d0b6..3362a1dbb 100755 --- a/ddverify/goblint/ddverify.py +++ b/ddverify/goblint/ddverify.py @@ -76,6 +76,11 @@ class DriverType(Enum): "pre": { "includes": [str(model_path / "include")], "cppflags": cppflags + }, + "ana": { + "sv-comp": { + "functions": True + } } } diff --git a/ddverify/models/goblint/src/ddverify/satabs.c b/ddverify/models/goblint/src/ddverify/satabs.c new file mode 100644 index 000000000..04a934c63 --- /dev/null +++ b/ddverify/models/goblint/src/ddverify/satabs.c @@ -0,0 +1,37 @@ +#include + +#define nondet2(X, Y) X nondet_##Y() { X val; return val; } +#define nondet(X) nondet2(X, X) + +nondet(short) +nondet2(unsigned short, ushort) +nondet(int) +nondet2(unsigned int, uint) +nondet(long) +nondet2(unsigned long, ulong) +nondet(char) +nondet2(unsigned char, uchar) +nondet2(unsigned, unsigned) +nondet(loff_t) +nondet(size_t) +nondet(sector_t) +nondet(u32) +nondet2(char*, pchar) +nondet2(enum __bool, bool) + + +void noop() { + +} + + +void __CPROVER_atomic_begin() { + __VERIFIER_atomic_begin(); +} + +void __CPROVER_atomic_end() { + __VERIFIER_atomic_end(); +} + + +void __CPROVER_assume(int expression) { if (!expression) { LOOP: goto LOOP; }; return; } From 079888ea2ea149080b0f232a9675145a71e52c96 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 11:30:16 +0300 Subject: [PATCH 12/24] Disable unknown function invalidation and spawning in ddverify --- ddverify/goblint/conf/applicom.json | 8 ++++++++ ddverify/goblint/conf/aztcd.json | 8 ++++++++ ddverify/goblint/conf/cciss.json | 8 ++++++++ ddverify/goblint/conf/cdu31a.json | 8 ++++++++ ddverify/goblint/conf/cm206.json | 8 ++++++++ ddverify/goblint/conf/cpqarray.json | 8 ++++++++ ddverify/goblint/conf/cs5535_gpio.json | 8 ++++++++ ddverify/goblint/conf/ds1286.json | 8 ++++++++ ddverify/goblint/conf/efirtc.json | 8 ++++++++ ddverify/goblint/conf/floppy.json | 8 ++++++++ ddverify/goblint/conf/generic_nvram.json | 8 ++++++++ ddverify/goblint/conf/genrtc.json | 8 ++++++++ ddverify/goblint/conf/i8xx_tco.json | 8 ++++++++ ddverify/goblint/conf/ib700wdt.json | 8 ++++++++ ddverify/goblint/conf/machzwd.json | 8 ++++++++ ddverify/goblint/conf/mixcomwd.json | 8 ++++++++ ddverify/goblint/conf/nbd.json | 8 ++++++++ ddverify/goblint/conf/nwbutton.json | 8 ++++++++ ddverify/goblint/conf/pcwd.json | 8 ++++++++ ddverify/goblint/conf/pcwd_pci.json | 8 ++++++++ ddverify/goblint/conf/sbc60xxwdt.json | 8 ++++++++ ddverify/goblint/conf/sc1200wdt.json | 8 ++++++++ ddverify/goblint/conf/sc520_wdt.json | 8 ++++++++ ddverify/goblint/conf/smsc37b787_wdt.json | 8 ++++++++ ddverify/goblint/conf/toshiba.json | 8 ++++++++ ddverify/goblint/conf/umem.json | 8 ++++++++ ddverify/goblint/conf/w83877f_wdt.json | 8 ++++++++ ddverify/goblint/conf/w83977f_wdt.json | 8 ++++++++ ddverify/goblint/conf/wdt.json | 8 ++++++++ ddverify/goblint/conf/wdt977.json | 8 ++++++++ ddverify/goblint/conf/wdt_pci.json | 8 ++++++++ ddverify/goblint/ddverify.py | 8 ++++++++ 32 files changed, 256 insertions(+) diff --git a/ddverify/goblint/conf/applicom.json b/ddverify/goblint/conf/applicom.json index 096c62756..2d3678a78 100644 --- a/ddverify/goblint/conf/applicom.json +++ b/ddverify/goblint/conf/applicom.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/aztcd.json b/ddverify/goblint/conf/aztcd.json index e31a98a89..2afb9c8aa 100644 --- a/ddverify/goblint/conf/aztcd.json +++ b/ddverify/goblint/conf/aztcd.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cciss.json b/ddverify/goblint/conf/cciss.json index 2ce88ae8d..c116c3dfc 100644 --- a/ddverify/goblint/conf/cciss.json +++ b/ddverify/goblint/conf/cciss.json @@ -49,5 +49,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cdu31a.json b/ddverify/goblint/conf/cdu31a.json index cb7da2fb4..dbea85aa2 100644 --- a/ddverify/goblint/conf/cdu31a.json +++ b/ddverify/goblint/conf/cdu31a.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cm206.json b/ddverify/goblint/conf/cm206.json index ce616c58f..671fb096d 100644 --- a/ddverify/goblint/conf/cm206.json +++ b/ddverify/goblint/conf/cm206.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json index f09624f1e..1c0342102 100644 --- a/ddverify/goblint/conf/cpqarray.json +++ b/ddverify/goblint/conf/cpqarray.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/cs5535_gpio.json b/ddverify/goblint/conf/cs5535_gpio.json index 24168db8a..9a64db279 100644 --- a/ddverify/goblint/conf/cs5535_gpio.json +++ b/ddverify/goblint/conf/cs5535_gpio.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/ds1286.json b/ddverify/goblint/conf/ds1286.json index ca9fbf247..ecc5b6390 100644 --- a/ddverify/goblint/conf/ds1286.json +++ b/ddverify/goblint/conf/ds1286.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/efirtc.json b/ddverify/goblint/conf/efirtc.json index 4cba20342..36c8ed0e6 100644 --- a/ddverify/goblint/conf/efirtc.json +++ b/ddverify/goblint/conf/efirtc.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/floppy.json b/ddverify/goblint/conf/floppy.json index 25e2e0c6b..39effa398 100644 --- a/ddverify/goblint/conf/floppy.json +++ b/ddverify/goblint/conf/floppy.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/generic_nvram.json b/ddverify/goblint/conf/generic_nvram.json index 3c26b5f3c..1e0edfac6 100644 --- a/ddverify/goblint/conf/generic_nvram.json +++ b/ddverify/goblint/conf/generic_nvram.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/genrtc.json b/ddverify/goblint/conf/genrtc.json index e09d0f0d4..3d700b593 100644 --- a/ddverify/goblint/conf/genrtc.json +++ b/ddverify/goblint/conf/genrtc.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/i8xx_tco.json b/ddverify/goblint/conf/i8xx_tco.json index f1008586d..b659a24ec 100644 --- a/ddverify/goblint/conf/i8xx_tco.json +++ b/ddverify/goblint/conf/i8xx_tco.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/ib700wdt.json b/ddverify/goblint/conf/ib700wdt.json index f5a304e62..a481b915f 100644 --- a/ddverify/goblint/conf/ib700wdt.json +++ b/ddverify/goblint/conf/ib700wdt.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/machzwd.json b/ddverify/goblint/conf/machzwd.json index 3f77e602b..e21b540c2 100644 --- a/ddverify/goblint/conf/machzwd.json +++ b/ddverify/goblint/conf/machzwd.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/mixcomwd.json b/ddverify/goblint/conf/mixcomwd.json index 323afe9bf..53e52606a 100644 --- a/ddverify/goblint/conf/mixcomwd.json +++ b/ddverify/goblint/conf/mixcomwd.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/nbd.json b/ddverify/goblint/conf/nbd.json index eab0ad12d..b4cef5038 100644 --- a/ddverify/goblint/conf/nbd.json +++ b/ddverify/goblint/conf/nbd.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/nwbutton.json b/ddverify/goblint/conf/nwbutton.json index 810ae8d86..17265160f 100644 --- a/ddverify/goblint/conf/nwbutton.json +++ b/ddverify/goblint/conf/nwbutton.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/pcwd.json b/ddverify/goblint/conf/pcwd.json index 82b103a96..6be1dbb60 100644 --- a/ddverify/goblint/conf/pcwd.json +++ b/ddverify/goblint/conf/pcwd.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/pcwd_pci.json b/ddverify/goblint/conf/pcwd_pci.json index cb2961b89..34586f08e 100644 --- a/ddverify/goblint/conf/pcwd_pci.json +++ b/ddverify/goblint/conf/pcwd_pci.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/sbc60xxwdt.json b/ddverify/goblint/conf/sbc60xxwdt.json index f3b89085d..9465afbff 100644 --- a/ddverify/goblint/conf/sbc60xxwdt.json +++ b/ddverify/goblint/conf/sbc60xxwdt.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/sc1200wdt.json b/ddverify/goblint/conf/sc1200wdt.json index 7d6dbabae..527c7a655 100644 --- a/ddverify/goblint/conf/sc1200wdt.json +++ b/ddverify/goblint/conf/sc1200wdt.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/sc520_wdt.json b/ddverify/goblint/conf/sc520_wdt.json index ff30f35d2..ff961883c 100644 --- a/ddverify/goblint/conf/sc520_wdt.json +++ b/ddverify/goblint/conf/sc520_wdt.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/smsc37b787_wdt.json b/ddverify/goblint/conf/smsc37b787_wdt.json index 209893906..06f72799a 100644 --- a/ddverify/goblint/conf/smsc37b787_wdt.json +++ b/ddverify/goblint/conf/smsc37b787_wdt.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/toshiba.json b/ddverify/goblint/conf/toshiba.json index 72db33352..95ff2fe29 100644 --- a/ddverify/goblint/conf/toshiba.json +++ b/ddverify/goblint/conf/toshiba.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/umem.json b/ddverify/goblint/conf/umem.json index c2ee881c4..9d15336d6 100644 --- a/ddverify/goblint/conf/umem.json +++ b/ddverify/goblint/conf/umem.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/w83877f_wdt.json b/ddverify/goblint/conf/w83877f_wdt.json index 126ea6ddb..426cf9e4a 100644 --- a/ddverify/goblint/conf/w83877f_wdt.json +++ b/ddverify/goblint/conf/w83877f_wdt.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/w83977f_wdt.json b/ddverify/goblint/conf/w83977f_wdt.json index bacfa4674..5adacea3a 100644 --- a/ddverify/goblint/conf/w83977f_wdt.json +++ b/ddverify/goblint/conf/w83977f_wdt.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt.json b/ddverify/goblint/conf/wdt.json index f7e93f230..2ccb4f0a9 100644 --- a/ddverify/goblint/conf/wdt.json +++ b/ddverify/goblint/conf/wdt.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt977.json b/ddverify/goblint/conf/wdt977.json index 7bc3b1b55..1a40b609f 100644 --- a/ddverify/goblint/conf/wdt977.json +++ b/ddverify/goblint/conf/wdt977.json @@ -47,5 +47,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/conf/wdt_pci.json b/ddverify/goblint/conf/wdt_pci.json index d2636572c..c00b6453e 100644 --- a/ddverify/goblint/conf/wdt_pci.json +++ b/ddverify/goblint/conf/wdt_pci.json @@ -48,5 +48,13 @@ "sv-comp": { "functions": true } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": false + }, + "spawn": false + } } } \ No newline at end of file diff --git a/ddverify/goblint/ddverify.py b/ddverify/goblint/ddverify.py index 3362a1dbb..011505450 100755 --- a/ddverify/goblint/ddverify.py +++ b/ddverify/goblint/ddverify.py @@ -81,6 +81,14 @@ class DriverType(Enum): "sv-comp": { "functions": True } + }, + "sem": { + "unknown_function": { + "invalidate": { + "globals": False + }, + "spawn": False + } } } From 8885692c836fd86887d604e47d8c960452673b08 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 11:33:14 +0300 Subject: [PATCH 13/24] Fix switch_context race in ddverify model --- ddverify/models/goblint/include/ddverify/ddverify.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ddverify/models/goblint/include/ddverify/ddverify.h b/ddverify/models/goblint/include/ddverify/ddverify.h index f6d8a06fe..203a2fd71 100644 --- a/ddverify/models/goblint/include/ddverify/ddverify.h +++ b/ddverify/models/goblint/include/ddverify/ddverify.h @@ -13,7 +13,10 @@ int current_execution_context; #define CONTEXT_PROCESS 1 #define CONTEXT_INTERRUPT 2 -#define switch_context(x) current_execution_context = x +void __CPROVER_atomic_begin(); +void __CPROVER_atomic_end(); + +#define switch_context(x) do { __CPROVER_atomic_begin(); current_execution_context = x; __CPROVER_atomic_end(); } while (0) #ifdef DDV_ASSERT_CONTEXT From 67c037c8a6b4f6076a6530081ce47b5c88af6180 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 12:30:50 +0300 Subject: [PATCH 14/24] Fix ddverify cpqarray undeclared variable --- ddverify/goblint/conf/cpqarray.json | 3 ++- ddverify/goblint/ddverify.py | 14 ++++++++++++-- ddverify/goblint/ddverify.sh | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json index 1c0342102..113f3cc2e 100644 --- a/ddverify/goblint/conf/cpqarray.json +++ b/ddverify/goblint/conf/cpqarray.json @@ -41,7 +41,8 @@ "-D__KERNEL__", "-DMODULE", "-DDRIVER_TYPE_BLOCK", - "-DDRIVER_TYPE_PCI" + "-DDRIVER_TYPE_PCI", + "-DCONFIG_PROC_FS" ] }, "ana": { diff --git a/ddverify/goblint/ddverify.py b/ddverify/goblint/ddverify.py index 011505450..2c704ffef 100755 --- a/ddverify/goblint/ddverify.py +++ b/ddverify/goblint/ddverify.py @@ -7,9 +7,18 @@ import json -module_path = Path(sys.argv[1]) +arg_paths = [] +arg_defines = [] +for arg in sys.argv[1:]: + if arg.startswith("-D"): + arg_defines.append(arg) + else: + arg_paths.append(arg) + + +module_path = Path(arg_paths[0]) print(module_path) -other_paths = list(map(Path, sys.argv[2:])) +other_paths = list(map(Path, arg_paths[1:])) module_init = None module_exit = None @@ -70,6 +79,7 @@ class DriverType(Enum): cppflags.append("-DDRIVER_TYPE_BLOCK") if driver_type_pci: # no elif! cppflags.append("-DDRIVER_TYPE_PCI") +cppflags += arg_defines goblint_conf = { "files": list(map(str, files)), diff --git a/ddverify/goblint/ddverify.sh b/ddverify/goblint/ddverify.sh index d58588e40..4fe076ca8 100755 --- a/ddverify/goblint/ddverify.sh +++ b/ddverify/goblint/ddverify.sh @@ -2,7 +2,7 @@ # block ./goblint/ddverify.py case_studies/block/cciss/cciss.c case_studies/block/cciss/cciss_scsi.c -./goblint/ddverify.py case_studies/block/cpqarray/cpqarray.c +./goblint/ddverify.py case_studies/block/cpqarray/cpqarray.c -DCONFIG_PROC_FS ./goblint/ddverify.py case_studies/block/floppy/floppy.c ./goblint/ddverify.py case_studies/block/nbd/nbd.c ./goblint/ddverify.py case_studies/block/umem/umem.c From c26e3e09e13cff1e6192d2ea329dc0e1b7e18b0a Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 15:49:21 +0300 Subject: [PATCH 15/24] Fix duplicate module function in ddverify --- ddverify/goblint/conf/applicom.json | 1 - ddverify/goblint/conf/aztcd.json | 1 - ddverify/goblint/conf/cciss.json | 1 - ddverify/goblint/conf/cdu31a.json | 1 - ddverify/goblint/conf/cm206.json | 1 - ddverify/goblint/conf/cpqarray.json | 1 - ddverify/goblint/conf/cs5535_gpio.json | 1 - ddverify/goblint/conf/ds1286.json | 1 - ddverify/goblint/conf/efirtc.json | 1 - ddverify/goblint/conf/floppy.json | 1 - ddverify/goblint/conf/generic_nvram.json | 1 - ddverify/goblint/conf/genrtc.json | 1 - ddverify/goblint/conf/i8xx_tco.json | 1 - ddverify/goblint/conf/ib700wdt.json | 1 - ddverify/goblint/conf/machzwd.json | 1 - ddverify/goblint/conf/mixcomwd.json | 1 - ddverify/goblint/conf/nbd.json | 1 - ddverify/goblint/conf/nwbutton.json | 1 - ddverify/goblint/conf/pcwd.json | 1 - ddverify/goblint/conf/pcwd_pci.json | 1 - ddverify/goblint/conf/sbc60xxwdt.json | 1 - ddverify/goblint/conf/sc1200wdt.json | 1 - ddverify/goblint/conf/sc520_wdt.json | 1 - ddverify/goblint/conf/smsc37b787_wdt.json | 1 - ddverify/goblint/conf/toshiba.json | 1 - ddverify/goblint/conf/umem.json | 1 - ddverify/goblint/conf/w83877f_wdt.json | 1 - ddverify/goblint/conf/w83977f_wdt.json | 1 - ddverify/goblint/conf/wdt.json | 1 - ddverify/goblint/conf/wdt977.json | 1 - ddverify/goblint/conf/wdt_pci.json | 1 - ddverify/goblint/ddverify.py | 3 ++- 32 files changed, 2 insertions(+), 32 deletions(-) diff --git a/ddverify/goblint/conf/applicom.json b/ddverify/goblint/conf/applicom.json index 2d3678a78..c542bab3a 100644 --- a/ddverify/goblint/conf/applicom.json +++ b/ddverify/goblint/conf/applicom.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/applicom/applicom.main.c", - "case_studies/char/applicom/applicom.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/aztcd.json b/ddverify/goblint/conf/aztcd.json index 2afb9c8aa..360831dde 100644 --- a/ddverify/goblint/conf/aztcd.json +++ b/ddverify/goblint/conf/aztcd.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/cdrom/aztcd/aztcd.main.c", - "case_studies/cdrom/aztcd/aztcd.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/cciss.json b/ddverify/goblint/conf/cciss.json index c116c3dfc..8697db95e 100644 --- a/ddverify/goblint/conf/cciss.json +++ b/ddverify/goblint/conf/cciss.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/block/cciss/cciss.main.c", - "case_studies/block/cciss/cciss.c", "case_studies/block/cciss/cciss_scsi.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", diff --git a/ddverify/goblint/conf/cdu31a.json b/ddverify/goblint/conf/cdu31a.json index dbea85aa2..a0c043085 100644 --- a/ddverify/goblint/conf/cdu31a.json +++ b/ddverify/goblint/conf/cdu31a.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/cdrom/cdu31a/cdu31a.main.c", - "case_studies/cdrom/cdu31a/cdu31a.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/cm206.json b/ddverify/goblint/conf/cm206.json index 671fb096d..3222b4a57 100644 --- a/ddverify/goblint/conf/cm206.json +++ b/ddverify/goblint/conf/cm206.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/cdrom/cm206/cm206.main.c", - "case_studies/cdrom/cm206/cm206.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/cpqarray.json b/ddverify/goblint/conf/cpqarray.json index 113f3cc2e..b079fed7a 100644 --- a/ddverify/goblint/conf/cpqarray.json +++ b/ddverify/goblint/conf/cpqarray.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/block/cpqarray/cpqarray.main.c", - "case_studies/block/cpqarray/cpqarray.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/cs5535_gpio.json b/ddverify/goblint/conf/cs5535_gpio.json index 9a64db279..8d12a60a5 100644 --- a/ddverify/goblint/conf/cs5535_gpio.json +++ b/ddverify/goblint/conf/cs5535_gpio.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/cs5535_gpio/cs5535_gpio.main.c", - "case_studies/char/cs5535_gpio/cs5535_gpio.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/ds1286.json b/ddverify/goblint/conf/ds1286.json index ecc5b6390..ef2f6f1d8 100644 --- a/ddverify/goblint/conf/ds1286.json +++ b/ddverify/goblint/conf/ds1286.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/ds1286/ds1286.main.c", - "case_studies/char/ds1286/ds1286.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/efirtc.json b/ddverify/goblint/conf/efirtc.json index 36c8ed0e6..504484944 100644 --- a/ddverify/goblint/conf/efirtc.json +++ b/ddverify/goblint/conf/efirtc.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/efirtc/efirtc.main.c", - "case_studies/char/efirtc/efirtc.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/floppy.json b/ddverify/goblint/conf/floppy.json index 39effa398..3ffd5e4b0 100644 --- a/ddverify/goblint/conf/floppy.json +++ b/ddverify/goblint/conf/floppy.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/block/floppy/floppy.main.c", - "case_studies/block/floppy/floppy.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/generic_nvram.json b/ddverify/goblint/conf/generic_nvram.json index 1e0edfac6..ee255cab8 100644 --- a/ddverify/goblint/conf/generic_nvram.json +++ b/ddverify/goblint/conf/generic_nvram.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/generic_nvram/generic_nvram.main.c", - "case_studies/char/generic_nvram/generic_nvram.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/genrtc.json b/ddverify/goblint/conf/genrtc.json index 3d700b593..d7bafcd6f 100644 --- a/ddverify/goblint/conf/genrtc.json +++ b/ddverify/goblint/conf/genrtc.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/genrtc/genrtc.main.c", - "case_studies/char/genrtc/genrtc.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/i8xx_tco.json b/ddverify/goblint/conf/i8xx_tco.json index b659a24ec..432ab5d9f 100644 --- a/ddverify/goblint/conf/i8xx_tco.json +++ b/ddverify/goblint/conf/i8xx_tco.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/i8xx_tco/i8xx_tco.main.c", - "case_studies/char/watchdog/i8xx_tco/i8xx_tco.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/ib700wdt.json b/ddverify/goblint/conf/ib700wdt.json index a481b915f..5933a1cef 100644 --- a/ddverify/goblint/conf/ib700wdt.json +++ b/ddverify/goblint/conf/ib700wdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/ib700wdt/ib700wdt.main.c", - "case_studies/char/watchdog/ib700wdt/ib700wdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/machzwd.json b/ddverify/goblint/conf/machzwd.json index e21b540c2..7e47125c0 100644 --- a/ddverify/goblint/conf/machzwd.json +++ b/ddverify/goblint/conf/machzwd.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/machzwd/machzwd.main.c", - "case_studies/char/watchdog/machzwd/machzwd.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/mixcomwd.json b/ddverify/goblint/conf/mixcomwd.json index 53e52606a..022642ac6 100644 --- a/ddverify/goblint/conf/mixcomwd.json +++ b/ddverify/goblint/conf/mixcomwd.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/mixcomwd/mixcomwd.main.c", - "case_studies/char/watchdog/mixcomwd/mixcomwd.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/nbd.json b/ddverify/goblint/conf/nbd.json index b4cef5038..5b195657a 100644 --- a/ddverify/goblint/conf/nbd.json +++ b/ddverify/goblint/conf/nbd.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/block/nbd/nbd.main.c", - "case_studies/block/nbd/nbd.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/nwbutton.json b/ddverify/goblint/conf/nwbutton.json index 17265160f..af2a8ca25 100644 --- a/ddverify/goblint/conf/nwbutton.json +++ b/ddverify/goblint/conf/nwbutton.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/nwbutton/nwbutton.main.c", - "case_studies/char/nwbutton/nwbutton.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/pcwd.json b/ddverify/goblint/conf/pcwd.json index 6be1dbb60..ae8b7d3cb 100644 --- a/ddverify/goblint/conf/pcwd.json +++ b/ddverify/goblint/conf/pcwd.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/pcwd/pcwd.main.c", - "case_studies/char/watchdog/pcwd/pcwd.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/pcwd_pci.json b/ddverify/goblint/conf/pcwd_pci.json index 34586f08e..0aac5a98b 100644 --- a/ddverify/goblint/conf/pcwd_pci.json +++ b/ddverify/goblint/conf/pcwd_pci.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/pcwd_pci/pcwd_pci.main.c", - "case_studies/char/watchdog/pcwd_pci/pcwd_pci.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/sbc60xxwdt.json b/ddverify/goblint/conf/sbc60xxwdt.json index 9465afbff..829089455 100644 --- a/ddverify/goblint/conf/sbc60xxwdt.json +++ b/ddverify/goblint/conf/sbc60xxwdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.main.c", - "case_studies/char/watchdog/sbc60xxwdt/sbc60xxwdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/sc1200wdt.json b/ddverify/goblint/conf/sc1200wdt.json index 527c7a655..ca1a82609 100644 --- a/ddverify/goblint/conf/sc1200wdt.json +++ b/ddverify/goblint/conf/sc1200wdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/sc1200wdt/sc1200wdt.main.c", - "case_studies/char/watchdog/sc1200wdt/sc1200wdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/sc520_wdt.json b/ddverify/goblint/conf/sc520_wdt.json index ff961883c..e10e64d65 100644 --- a/ddverify/goblint/conf/sc520_wdt.json +++ b/ddverify/goblint/conf/sc520_wdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/sc520_wdt/sc520_wdt.main.c", - "case_studies/char/watchdog/sc520_wdt/sc520_wdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/smsc37b787_wdt.json b/ddverify/goblint/conf/smsc37b787_wdt.json index 06f72799a..f93299656 100644 --- a/ddverify/goblint/conf/smsc37b787_wdt.json +++ b/ddverify/goblint/conf/smsc37b787_wdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.main.c", - "case_studies/char/watchdog/smsc37b787_wdt/smsc37b787_wdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/toshiba.json b/ddverify/goblint/conf/toshiba.json index 95ff2fe29..3899b93ca 100644 --- a/ddverify/goblint/conf/toshiba.json +++ b/ddverify/goblint/conf/toshiba.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/toshiba/toshiba.main.c", - "case_studies/char/toshiba/toshiba.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/umem.json b/ddverify/goblint/conf/umem.json index 9d15336d6..0f62781eb 100644 --- a/ddverify/goblint/conf/umem.json +++ b/ddverify/goblint/conf/umem.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/block/umem/umem.main.c", - "case_studies/block/umem/umem.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/w83877f_wdt.json b/ddverify/goblint/conf/w83877f_wdt.json index 426cf9e4a..8654778f6 100644 --- a/ddverify/goblint/conf/w83877f_wdt.json +++ b/ddverify/goblint/conf/w83877f_wdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.main.c", - "case_studies/char/watchdog/w83877f_wdt/w83877f_wdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/w83977f_wdt.json b/ddverify/goblint/conf/w83977f_wdt.json index 5adacea3a..1a5728a64 100644 --- a/ddverify/goblint/conf/w83977f_wdt.json +++ b/ddverify/goblint/conf/w83977f_wdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.main.c", - "case_studies/char/watchdog/w83977f_wdt/w83977f_wdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/wdt.json b/ddverify/goblint/conf/wdt.json index 2ccb4f0a9..c7e21ed3a 100644 --- a/ddverify/goblint/conf/wdt.json +++ b/ddverify/goblint/conf/wdt.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/wdt/wdt.main.c", - "case_studies/char/watchdog/wdt/wdt.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/wdt977.json b/ddverify/goblint/conf/wdt977.json index 1a40b609f..31b3f8d57 100644 --- a/ddverify/goblint/conf/wdt977.json +++ b/ddverify/goblint/conf/wdt977.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/wdt977/wdt977.main.c", - "case_studies/char/watchdog/wdt977/wdt977.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/conf/wdt_pci.json b/ddverify/goblint/conf/wdt_pci.json index c00b6453e..b4369f94b 100644 --- a/ddverify/goblint/conf/wdt_pci.json +++ b/ddverify/goblint/conf/wdt_pci.json @@ -1,7 +1,6 @@ { "files": [ "case_studies/char/watchdog/wdt_pci/wdt_pci.main.c", - "case_studies/char/watchdog/wdt_pci/wdt_pci.c", "models/goblint/src/ddverify/cdev.c", "models/goblint/src/ddverify/ddverify.c", "models/goblint/src/ddverify/genhd.c", diff --git a/ddverify/goblint/ddverify.py b/ddverify/goblint/ddverify.py index 2c704ffef..ac24e8a1c 100755 --- a/ddverify/goblint/ddverify.py +++ b/ddverify/goblint/ddverify.py @@ -69,7 +69,8 @@ class DriverType(Enum): model_path = Path("models/goblint") -files = [main_path, module_path] + other_paths + sorted((model_path / "src").glob("**/*.c")) +# main program includes module itself +files = [main_path] + other_paths + sorted((model_path / "src").glob("**/*.c")) # -m32 needed for size_t and pthread sizes to match cppflags = ["-m32", "-D__KERNEL__", "-DMODULE"] From 6eee3fcf6edaeaf70c5c801e144940b47abacb29 Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Tue, 12 Apr 2022 15:49:54 +0300 Subject: [PATCH 16/24] Add script for running ddverify benchmarks --- index/defs/default.yaml | 5 + index/sets/ddverify.yaml | 123 ++++++++++++++++ update_bench_ddverify.rb | 300 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 428 insertions(+) create mode 100644 index/defs/default.yaml create mode 100644 index/sets/ddverify.yaml create mode 100755 update_bench_ddverify.rb diff --git a/index/defs/default.yaml b/index/defs/default.yaml new file mode 100644 index 000000000..3f9099585 --- /dev/null +++ b/index/defs/default.yaml @@ -0,0 +1,5 @@ +baseconf: index/conf/default.json +compare: false +incremental: false + +Default: diff --git a/index/sets/ddverify.yaml b/index/sets/ddverify.yaml new file mode 100644 index 000000000..17c4896f3 --- /dev/null +++ b/index/sets/ddverify.yaml @@ -0,0 +1,123 @@ +cciss: + info: cciss + param: --conf goblint/conf/cciss.json + +cpqarray: + info: cpqarray + param: --conf goblint/conf/cpqarray.json + +floppy: + info: floppy + param: --conf goblint/conf/floppy.json + +nbd: + info: nbd + param: --conf goblint/conf/nbd.json + +umem: + info: umem + param: --conf goblint/conf/umem.json + +aztcd: + info: aztcd + param: --conf goblint/conf/aztcd.json + +cdu31a: + info: cdu31a + param: --conf goblint/conf/cdu31a.json + +cm206: + info: cm206 + param: --conf goblint/conf/cm206.json + +applicom: + info: applicom + param: --conf goblint/conf/applicom.json + +cs5535_gpio: + info: cs5535_gpio + param: --conf goblint/conf/cs5535_gpio.json + +ds1286: + info: ds1286 + param: --conf goblint/conf/ds1286.json + +efirtc: + info: efirtc + param: --conf goblint/conf/efirtc.json + +generic_nvram: + info: generic_nvram + param: --conf goblint/conf/generic_nvram.json + +genrtc: + info: genrtc + param: --conf goblint/conf/genrtc.json + +nwbutton: + info: nwbutton + param: --conf goblint/conf/nwbutton.json + +toshiba: + info: toshiba + param: --conf goblint/conf/toshiba.json + +i8xx_tco: + info: i8xx_tco + param: --conf goblint/conf/i8xx_tco.json + +ib700wdt: + info: ib700wdt + param: --conf goblint/conf/ib700wdt.json + +machzwd: + info: machzwd + param: --conf goblint/conf/machzwd.json + +mixcomwd: + info: mixcomwd + param: --conf goblint/conf/mixcomwd.json + +pcwd: + info: pcwd + param: --conf goblint/conf/pcwd.json + +pcwd_pci: + info: pcwd_pci + param: --conf goblint/conf/pcwd_pci.json + +sbc60xxwdt: + info: sbc60xxwdt + param: --conf goblint/conf/sbc60xxwdt.json + +sc520_wdt: + info: sc520_wdt + param: --conf goblint/conf/sc520_wdt.json + +sc1200wdt: + info: sc1200wdt + param: --conf goblint/conf/sc1200wdt.json + +smsc37b787_wdt: + info: smsc37b787_wdt + param: --conf goblint/conf/smsc37b787_wdt.json + +w83877f_wdt: + info: w83877f_wdt + param: --conf goblint/conf/w83877f_wdt.json + +w83977f_wdt: + info: w83977f_wdt + param: --conf goblint/conf/w83977f_wdt.json + +wdt: + info: wdt + param: --conf goblint/conf/wdt.json + +wdt_pci: + info: wdt_pci + param: --conf goblint/conf/wdt_pci.json + +wdt977: + info: wdt977 + param: --conf goblint/conf/wdt977.json diff --git a/update_bench_ddverify.rb b/update_bench_ddverify.rb new file mode 100755 index 000000000..167f4fe88 --- /dev/null +++ b/update_bench_ddverify.rb @@ -0,0 +1,300 @@ +#!/usr/bin/ruby +require 'fileutils' +require 'yaml' +Dir.chdir(File.dirname(__FILE__)) +$goblint = File.expand_path('../analyzer/goblint') +$messagesCompare = File.expand_path('../analyzer/_build/default/src/messagesCompare.exe') +fail 'Please run script from goblint dir!' unless File.exist?($goblint) +$goblint_version = `#{$goblint} --version` +$bench_version = `git describe --all --long --dirty 2> /dev/null` +results = 'bench_result' +Dir.mkdir(results) unless Dir.exist?(results) +$testresults = File.expand_path('bench_result') + '/' +$bench_path = File.expand_path('.') + '/' +$repo_url = 'https://github.com/goblint/bench/blob/master/' + +class Project + attr_reader :id, :name, :group + attr_accessor :info, :params, :url + def initialize(id, name, info, group, params) + @id = id + @name = name + @info = info + @group = group + @params = params + end + def url + $repo_url + end + def to_html + name = "" + "#{@id}#{name}\n" + "\n" + end + def to_s + @name.to_s + end +end + + +$projects = [] + +$header = < + + + + Benchmarks on #{`uname -n`.chomp} + + +END +$theresultfile = File.join($testresults, 'index.html') + +def print_file_res (f, name) + first = true + $analyses.each do |a| + aname = a[0] + outfile = name + ".#{aname}.txt" + if File.exists?($testresults + outfile) + File.open($testresults + outfile, 'r') do |g| + lines = g.readlines + vars, evals = lines.grep(/vars = (\d*).*evals = (\d+)/) { |x| [$1.to_i, $2.to_i] } .first + res = lines.grep(/^TIMEOUT\s*(.*) s.*$/) { |x| $1 } + if res == [] + dur = lines.grep(/^Duration: (.*) s/) { |x| $1 } + cod = lines.grep(/^EXITCODE\s*(.*)$/) { |x| $1 } + if cod == [] and not dur == [] + if $compare + unless first + compfile = "#{outfile}.compare.txt" + complines = File.readlines($testresults + compfile) + verdict = complines.grep(/comparison summary: original (.*) increment/) { |x| $1 }.first + msg = case verdict + when 'equal to' then '=' + when 'more precise than' then '⊑' + when 'incomparable to' then '≸' + when 'less precise than' then '⊒' + end + thenumbers = "#{msg} " + thenumbers << " M" + end + else + safely = lines.grep(/[^n]safe:[ ]*([0-9]*)/) { |x| $1.to_i } .first + vulner = lines.grep(/vulnerable:[ ]*([0-9]*)/) { |x| $1.to_i } .first + unsafe = lines.grep(/unsafe:[ ]*([0-9]*)/) { |x| $1.to_i } .first + total = lines.grep(/total:[ ]*([0-9]*)/) { |x| $1.to_i } .first + uncalled = lines.grep(/will never be called/).reject {|x| x =~ /__check/}.size + deadlock = lines.grep(/\[Deadlock\]/).size + thenumbers = "#{safely}+" + thenumbers << "#{vulner}+" + thenumbers << "#{unsafe}=" + thenumbers << "#{total}" + thenumbers << "; #{deadlock}" + thenumbers << "; #{uncalled}" if uncalled > 0 + end + thenumbers = " (#{thenumbers})" unless thenumbers.nil? + f.puts "#{"%.2f" % dur} s / #{vars} vars / #{evals} evals#{thenumbers}" + else + f.puts "failed (code: #{cod.first.to_s})" + end + else + f.puts "#{res.first.to_s} s (limit)" + end + end + else + f.puts 'N/A' + end + first = false + end +end + +def print_res (i) + File.open($theresultfile, 'w') do |f| + f.puts $header + f.puts '' + f.puts "

Benchmarking in progress: #{i}/#{$projects.length}

" unless i.nil? + f.puts '' + gname = '' + $projects.each do |p| + if p.group != gname + gname = p.group + f.puts "" + f.puts '' + $analyses.each do |a| + aname = a[0] + f.puts "" + end + end + f.puts '' + f.puts p.to_html + print_file_res(f, p.name) + f.puts '' + end + f.puts '
#{gname}
#Name#{aname}
' + f.print '

' + f.puts "Last updated: #{Time.now.strftime("%Y-%m-%d %H:%M:%S %z")}" + f.puts "Bench version: #{$bench_version}" + f.puts "#{$goblint_version}" + f.puts "Goblint base configuration: #{$goblint_conf_name}." + f.puts "Analysis definitions: #{$conf_name}." + f.puts '

' + f.puts '' + f.puts '' + end +end + +#Command line parameters + +if ARGV[2].nil? + puts 'You must run command with timout, conf, and at least one benchmark set, e.g.:' + puts './update_bench_incremental.rb 60 index/defs/incremental.yaml index/sets/posix.yaml' + exit 1 +end + +$timeout = ARGV[0].to_i +conf_file = ARGV[1] +groups = ARGV[2..-1] + +#processing the input file + +$analyses = [] +conf = YAML.load_file(conf_file) +$conf_name = File.basename(conf_file) +$goblint_conf = File.expand_path(conf['baseconf']) +$goblint_conf_name = File.basename($goblint_conf) +abort("Configuration lacks base conf: #{$goblint_conf}") unless File.exist?($goblint_conf) + +$compare = conf['compare'] +$incremental = conf['incremental'] + +conf.delete('compare') +conf.delete('baseconf') +conf.delete('incremental') +conf.each { |(key, value)| $analyses << [key, value.nil? ? '' : value] } + +id = 0 +groups.each do |group| + benchmarks = YAML.load_file(group) + gname = File.basename(group, '.yaml').upcase + #TODO: name is ignored because it breaks patch hacks. + benchmarks.each do |name, spec| + info = spec['info'] + params = spec['param'] + params = '' if params.nil? + id += 1 + $projects << Project.new(id,name,info,gname,params) + end +end + +#Process linux results! + +$fileheader = < + + Benchmarks on #{`uname -n`.chomp} + + + +END + + +def proc_res(resultfile, url) + File.open(resultfile, 'r') do |f| + File.open(resultfile + '.html', 'w') do |o| + o.puts $fileheader + while (line = f.gets) + if line =~ /race with|\[Warning\]/ + o.puts '' + line.chop + '' + elsif line =~ /\[Success\]/ + o.puts '' + line.chop + '' + else + o.puts line + end + end + o.puts '' + o.puts '' + end + end +end + +$rootdirname = File.expand_path("./ddverify/") +$maxlen = $analyses.map { |x| x[0].length }.max + 1 +def analyze_project(p, save) + dirname = $rootdirname + resname = p.name + Dir.chdir(dirname) + puts "Analysing #{resname} (#{p.id}/#{$projects.length})" + first = true + $analyses.each do |a| + aname = a[0] + aparam = a[1] + if first + aparam += ' --enable incremental.save ' if save + aparam += ' --enable incremental.only-rename ' unless save + aparam += ' --set save_run original ' if $compare + aparam += ' --set outfile original.messages.json ' if $compare + else + aparam += ' --enable incremental.load ' if $incremental + aparam += ' --set save_run increment ' if $compare + aparam += ' --set outfile increment.messages.json ' if $compare + end + print " #{format("%*s", -$maxlen, aname)}" + STDOUT.flush + outfile = $testresults + resname + ".#{aname}.txt" + starttime = Time.now + #Add --sets cilout /dev/null to ignore CIL output. + cmd = "#{$goblint} --conf #{$goblint_conf} -v --set dbg.timeout #{$timeout} #{aparam} #{p.params} --enable dbg.uncalled --enable allglobs --enable printstats --set result json-messages 1>#{outfile} 2>&1" + system(cmd) + status = $?.exitstatus + endtime = Time.now + File.open(outfile, 'a') do |f| + f.puts "\n=== APPENDED BY BENCHMARKING SCRIPT ===" + f.puts "Analysis began: #{starttime}" + f.puts "Analysis ended: #{endtime}" + f.puts "Duration: #{format("%.02f", endtime-starttime)} s" + f.puts "Goblint params: #{cmd}" + f.puts $vrsn + end + if status != 0 + if status == 124 + puts '-- Timeout!' + `echo "TIMEOUT #{$timeout} s" >> #{outfile}` + else + puts '-- Failed!' + `echo "EXITCODE #{status}" >> #{outfile}` + end + else + system("#{$goblint} --conf #{$goblint_conf} -v --enable dbg.compare_runs.diff --compare_runs original increment #{p.params} 2>&1 | sed '2000,/comparison summary/{/comparison summary/!d;}' > #{outfile}.compare.txt") if $compare and not first + system("#{$messagesCompare} --no-colors original.messages.json increment.messages.json > #{outfile}.compare.messages.txt") if $compare and not first + puts '-- Done!' + end + first = false + print_res p.id + proc_res(outfile, p.url) + end + `rm -rf original increment` if $compare + `rm original.messages.json increment.messages.json` if $compare +end + +#analysing the files +gname = '' +system("rm -f #{$testresults}/*") +FileUtils.cp(conf_file, File.join($testresults, $conf_name)) +system("#{$goblint} --conf #{$goblint_conf} --writeconf #{$testresults}/#{$goblint_conf_name}") +$projects.each do |p| + if p.group != gname + gname = p.group + puts gname + end + analyze_project(p, true) + `rm -rf incremental_data` +end +print_res nil +puts ('Results: ' + $theresultfile) From 690ec4c1434cde0b505b1217c1a75fe2d5e5d64d Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Fri, 17 Jun 2022 12:31:41 +0300 Subject: [PATCH 17/24] Separate the DUET benchmark subset. --- index/sets/duet.yaml | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 index/sets/duet.yaml diff --git a/index/sets/duet.yaml b/index/sets/duet.yaml new file mode 100644 index 000000000..b5cd11834 --- /dev/null +++ b/index/sets/duet.yaml @@ -0,0 +1,59 @@ +i8xx_tco: + info: i8xx_tco + param: --conf goblint/conf/i8xx_tco.json + +ib700wdt: + info: ib700wdt + param: --conf goblint/conf/ib700wdt.json + +machzwd: + info: machzwd + param: --conf goblint/conf/machzwd.json + +mixcomwd: + info: mixcomwd + param: --conf goblint/conf/mixcomwd.json + +pcwd: + info: pcwd + param: --conf goblint/conf/pcwd.json + +pcwd_pci: + info: pcwd_pci + param: --conf goblint/conf/pcwd_pci.json + +sbc60xxwdt: + info: sbc60xxwdt + param: --conf goblint/conf/sbc60xxwdt.json + +sc520_wdt: + info: sc520_wdt + param: --conf goblint/conf/sc520_wdt.json + +sc1200wdt: + info: sc1200wdt + param: --conf goblint/conf/sc1200wdt.json + +smsc37b787_wdt: + info: smsc37b787_wdt + param: --conf goblint/conf/smsc37b787_wdt.json + +w83877f_wdt: + info: w83877f_wdt + param: --conf goblint/conf/w83877f_wdt.json + +w83977f_wdt: + info: w83977f_wdt + param: --conf goblint/conf/w83977f_wdt.json + +wdt: + info: wdt + param: --conf goblint/conf/wdt.json + +wdt_pci: + info: wdt_pci + param: --conf goblint/conf/wdt_pci.json + +wdt977: + info: wdt977 + param: --conf goblint/conf/wdt977.json From 5e159a0e7c8e038e9be8eb18684302c780df6184 Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Fri, 17 Jun 2022 11:50:47 +0000 Subject: [PATCH 18/24] Only save when incremental set. --- update_bench_ddverify.rb | 2 +- update_bench_incremental.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/update_bench_ddverify.rb b/update_bench_ddverify.rb index 167f4fe88..4df33fb44 100755 --- a/update_bench_ddverify.rb +++ b/update_bench_ddverify.rb @@ -293,7 +293,7 @@ def analyze_project(p, save) gname = p.group puts gname end - analyze_project(p, true) + analyze_project(p, $incremental) `rm -rf incremental_data` end print_res nil diff --git a/update_bench_incremental.rb b/update_bench_incremental.rb index f7a5c080f..924f87b74 100755 --- a/update_bench_incremental.rb +++ b/update_bench_incremental.rb @@ -312,7 +312,7 @@ def analyze_project(p, save) gname = p.group puts gname end - analyze_project(p, true) + analyze_project(p, $incremental) path = File.expand_path(p.path, $bench_path) p.patches.each do |pfile| `patch -b #{path} #{pfile}` From 280f5dde2c39addac64a44ada52dc84d253b426d Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Fri, 17 Jun 2022 11:51:15 +0000 Subject: [PATCH 19/24] Add the traces rel here. --- index/defs/reltraces.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 index/defs/reltraces.yaml diff --git a/index/defs/reltraces.yaml b/index/defs/reltraces.yaml new file mode 100644 index 000000000..061279a3c --- /dev/null +++ b/index/defs/reltraces.yaml @@ -0,0 +1,17 @@ +baseconf: index/conf/default.json +compare: false +incremental: false + +dummy: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization dummy +mutex-meet-box: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization mutex-meet --sets ana.apron.domain interval +mutex-meet: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet +mutex-meet-tid-nj: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid --disable ana.apron.priv.must-joined +mutex-meet-tid: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid +mutex-meet-tid-cluster12: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid-cluster12 +dummy-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization dummy --enable ana.apron.threshold_widening +mutex-meet-box-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization mutex-meet --sets ana.apron.domain interval --enable ana.apron.threshold_widening +mutex-meet-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet --enable ana.apron.threshold_widening +mutex-meet-tid-nj-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid --disable ana.apron.priv.must-joined --enable ana.apron.threshold_widening +mutex-meet-tid-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid --enable ana.apron.threshold_widening +mutex-meet-tid-cluster12-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid-cluster12 --enable ana.apron.threshold_widening + From 35dfa7f2112395cffda3165031883d9e9dbd4894 Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Fri, 17 Jun 2022 12:34:03 +0000 Subject: [PATCH 20/24] update reltraces.yaml --- index/defs/reltraces.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index/defs/reltraces.yaml b/index/defs/reltraces.yaml index 061279a3c..d26e6351a 100644 --- a/index/defs/reltraces.yaml +++ b/index/defs/reltraces.yaml @@ -2,14 +2,14 @@ baseconf: index/conf/default.json compare: false incremental: false -dummy: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization dummy -mutex-meet-box: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization mutex-meet --sets ana.apron.domain interval +dummy: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization top +mutex-meet-box: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet --set ana.apron.domain interval mutex-meet: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet mutex-meet-tid-nj: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid --disable ana.apron.priv.must-joined mutex-meet-tid: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid mutex-meet-tid-cluster12: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid-cluster12 -dummy-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization dummy --enable ana.apron.threshold_widening -mutex-meet-box-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --sets ana.apron.privatization mutex-meet --sets ana.apron.domain interval --enable ana.apron.threshold_widening +dummy-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization top --enable ana.apron.threshold_widening +mutex-meet-box-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet --set ana.apron.domain interval --enable ana.apron.threshold_widening mutex-meet-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet --enable ana.apron.threshold_widening mutex-meet-tid-nj-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid --disable ana.apron.priv.must-joined --enable ana.apron.threshold_widening mutex-meet-tid-th: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.apron.privatization mutex-meet-tid --enable ana.apron.threshold_widening From a0eb0426122631aa96b5ef0fc903d378a3f21209 Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Thu, 23 Jun 2022 09:33:39 +0000 Subject: [PATCH 21/24] Enable bounds checks. --- index/conf/checks.json | 5 +++++ index/defs/reltraces.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 index/conf/checks.json diff --git a/index/conf/checks.json b/index/conf/checks.json new file mode 100644 index 000000000..7cda5a586 --- /dev/null +++ b/index/conf/checks.json @@ -0,0 +1,5 @@ +{ + "ana": { + "arrayoob": true + } +} diff --git a/index/defs/reltraces.yaml b/index/defs/reltraces.yaml index d26e6351a..83aea2a7d 100644 --- a/index/defs/reltraces.yaml +++ b/index/defs/reltraces.yaml @@ -1,4 +1,4 @@ -baseconf: index/conf/default.json +baseconf: index/conf/checks.json compare: false incremental: false From cd48f97c8e966285cf2656262a82df035a9079bd Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Thu, 23 Jun 2022 09:34:31 +0000 Subject: [PATCH 22/24] Disable all incremental flags when supposed to be off. --- update_bench_ddverify.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_bench_ddverify.rb b/update_bench_ddverify.rb index 4df33fb44..639dde470 100755 --- a/update_bench_ddverify.rb +++ b/update_bench_ddverify.rb @@ -237,7 +237,7 @@ def analyze_project(p, save) aparam = a[1] if first aparam += ' --enable incremental.save ' if save - aparam += ' --enable incremental.only-rename ' unless save + aparam += ' --enable incremental.only-rename ' if $incremental and not save aparam += ' --set save_run original ' if $compare aparam += ' --set outfile original.messages.json ' if $compare else From f16dec4bdbe93e69ed05b3ca2a7c829c923c10a4 Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Thu, 23 Jun 2022 13:08:53 +0300 Subject: [PATCH 23/24] Crudely count warnings to see if this is worth doing. --- update_bench_ddverify.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/update_bench_ddverify.rb b/update_bench_ddverify.rb index 639dde470..83663c93a 100755 --- a/update_bench_ddverify.rb +++ b/update_bench_ddverify.rb @@ -83,10 +83,10 @@ def print_file_res (f, name) thenumbers << " M" end else - safely = lines.grep(/[^n]safe:[ ]*([0-9]*)/) { |x| $1.to_i } .first - vulner = lines.grep(/vulnerable:[ ]*([0-9]*)/) { |x| $1.to_i } .first - unsafe = lines.grep(/unsafe:[ ]*([0-9]*)/) { |x| $1.to_i } .first - total = lines.grep(/total:[ ]*([0-9]*)/) { |x| $1.to_i } .first + safely = lines.grep(/\[Success\]\[Behavior > Undefined > ArrayOutOfBound/).size + vulner = lines.grep(/\[Warning\]\[Behavior > Undefined > ArrayOutOfBound/).size + unsafe = lines.grep(/\[Error\]\[Behavior > Undefined > ArrayOutOfBound/).size + total = lines.grep(/\[Behavior > Undefined > ArrayOutOfBounds/).size uncalled = lines.grep(/will never be called/).reject {|x| x =~ /__check/}.size deadlock = lines.grep(/\[Deadlock\]/).size thenumbers = "#{safely}+" From 772ef8332e173f6b5dca76ea5c24375ea072f299 Mon Sep 17 00:00:00 2001 From: Vesal Vojdani Date: Thu, 23 Jun 2022 14:40:53 +0300 Subject: [PATCH 24/24] Update this script as well (will have to revert). --- update_bench_incremental.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/update_bench_incremental.rb b/update_bench_incremental.rb index 924f87b74..cb06d9df6 100755 --- a/update_bench_incremental.rb +++ b/update_bench_incremental.rb @@ -86,10 +86,10 @@ def print_file_res (f, path) thenumbers << " M" end else - safely = lines.grep(/[^n]safe:[ ]*([0-9]*)/) { |x| $1.to_i } .first - vulner = lines.grep(/vulnerable:[ ]*([0-9]*)/) { |x| $1.to_i } .first - unsafe = lines.grep(/unsafe:[ ]*([0-9]*)/) { |x| $1.to_i } .first - total = lines.grep(/total:[ ]*([0-9]*)/) { |x| $1.to_i } .first + safely = lines.grep(/\[Success\]\[Behavior > Undefined > ArrayOutOfBound/).size + vulner = lines.grep(/\[Warning\]\[Behavior > Undefined > ArrayOutOfBound/).size + unsafe = lines.grep(/\[Error\]\[Behavior > Undefined > ArrayOutOfBound/).size + total = lines.grep(/\[Behavior > Undefined > ArrayOutOfBounds/).size uncalled = lines.grep(/will never be called/).reject {|x| x =~ /__check/}.size deadlock = lines.grep(/\[Deadlock\]/).size thenumbers = "#{safely}+" @@ -256,7 +256,7 @@ def analyze_project(p, save) aparam = a[1] if first aparam += ' --enable incremental.save ' if save - aparam += ' --enable incremental.only-rename ' unless save + aparam += ' --enable incremental.only-rename ' if $incremental and not save aparam += ' --set save_run original ' if $compare aparam += ' --set outfile original.messages.json ' if $compare else