亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? galil_1800.c

?? galil1800 linux驅(qū)動(dòng)程序演示
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/* Copyright (C) 2002, 2003 Shell Technologies s.r.l.   Authors: Marco Cesati <cesati@uniroma2.it>      driver for the Galil 1800 PCI motion controllers (http://www.galilmc.com/)      loosely inspired by Galil's own Linux driver, as well as by a bunch of   PCI drivers in the kernel source code      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.      Programmers list:       		MC: Marco Cesati           Revision history:        8 November 2002 - ver. 0.1 (MC): first release (kernel 2.4.19)    12 December 2002 - ver. 0.2 (MC): support for secondary communication                                             channel (kernel 2.4.20)    13 December 2002 - ver. 0.3 (MC): ioctl() command to fetch interrupt                                             stack    30 January 2003  - ver. 0.4 (MC): fixed race condition in                                              galil_1800_send_signals()*/#include <linux/version.h>#include <linux/module.h>#include <linux/sched.h>#include <linux/interrupt.h>#include <linux/pci.h>#include <linux/spinlock.h>#include <asm/io.h>#include <asm/uaccess.h>#include <asm/hardirq.h>#include "galil_ioctl.h"#define GALIL_1800_MODULE_NAME "Galil 1800"#define PFX GALIL_1800_MODULE_NAME ": "#define GALIL_1800_READ_TIMEOUT      10 /* ticks (1 tick = ~10ms) */#define GALIL_1800_WRITE_TIMEOUT     10 /* ticks (1 tick = ~10ms) */#define PLX_PCI_VENDOR_ID            0x10B5#define PLX_PCI_DEVICE_ID            0x9050#define GALIL_SUB_VENDOR             0x1079#define GALIL_SUB_DEVICE_1800        0x1800#define GALIL_1800_READ_FIFO_SIZE    256#define GALIL_1800_WRITE_FIFO_SIZE   256#define GALIL_1800_READ_FIFO2_SIZE   256/* main device driver descriptor, one for every registered device */struct galil_1800_state {    struct list_head devs;       /* list of Galil 1800 devices */    struct pci_dev *dev;         /* the PCI main device descriptor */    unsigned long io;            /* base I/O address */    unsigned long ctrl_reg;      /* control register I/O address */    unsigned long irq_reg;       /* irq register I/O address */    unsigned long chan2_reg;     /* secondary channel register I/O address */    unsigned int irq;            /* IRQ line number */    int index;                   /* index (== minor number) of the device */    int opens;                   /* how many processes have opened the device                                    file; protected by open_sem */    struct semaphore open_sem;   /* semaphore for concurrent open requests */    mode_t open_mode;            /* the read/write mode of the device file */    wait_queue_head_t open_wait; /* waiting for an open to complete */    spinlock_t hwlock;           /* spin lock for low-level fiddling */    rwlock_t siglock;            /* r/w spin lock for the list of processes */    unsigned char irqstack[GALIL_1800_IRQ_STACK_SZ]; /* stack of IRQ values */    int irqstack_sz;             /* current number of values in the stack */    spinlock_t irqlock;          /* spin lock for the interrupt handler */    struct list_head siglist;    /* processes to be signaled on interrupts */    struct tasklet_struct tlet;  /* tasklet handling the siglist list of                                     processes to be signaled */    unsigned long serial;        /* the serial number read from the device */};/* element of the list of processes to be signaled on interrupt occurrences */struct galil_1800_siglist_t {    struct list_head list;    /* pointers for the next and previous elements */    struct task_struct * owner;  /* pointer to the process descriptor */    pid_t pid;               /* pid of the process descriptor (safety check) */    char *ubuf;                  /* buffer in the User Mode space for the interrupt values */};#define GALIL_1800_READ_REG(A)         ((A)->io)#define GALIL_1800_WRITE_REG(A)        GALIL_1800_READ_REG(A)#define GALIL_1800_CONTROL_REG(A)      ((A)->ctrl_reg)#define GALIL_1800_IRQ_REG(A)          ((A)->irq_reg)#define GALIL_1800_RESET_REG(A)        GALIL_1800_IRQ_REG(A)#define GALIL_1800_2CHAN_REG(A)        ((A)->chan2_reg)#define GALIL_1800_FIFO_FULL_FLAG      (0x01)#define GALIL_1800_FIFO_HALF_FLAG      (0x02)#define GALIL_1800_FIFO_EMPTY_FLAG     (0x04)#define GALIL_1800_FIFO2_BUSY_FLAG     (0x08)#define GALIL_1800_FIFO2_FREEZE_FLAG   (0x10)#define GALIL_1800_IRQ_STATUS_FLAG     (0x20)#define GALIL_1800_IRQ_ENABLE_FLAG     (0x40)#define GALIL_1800_FIFO2_EMPTY_FLAG    (0x80)/* the list of galil_1800_state descriptors */static LIST_HEAD(galil_1800_devs);/* a read/write spin lock that protects the above list in MP */static rwlock_t galil_1800_devs_lock = RW_LOCK_UNLOCKED;/* index (minor number) of the next device yet to be registered */static unsigned int devindex = 0;/* major number of associated device files */static int major = -1;/*    readwrite == 0: clear both read and write FIFO   readwrite == 1: clear read FIFO only   readwrite == 2: clear write FIFO only*/static inline void __galil_1800_clear_FIFO(struct galil_1800_state *dev,                                            int readwrite){    char mask = (!readwrite ? 6 : (readwrite == 1 ? 2 : 4));    outb(mask, GALIL_1800_RESET_REG(dev));    }static inline void galil_1800_clear_FIFO(struct galil_1800_state *dev,                                          int readwrite){    unsigned long flags;    spin_lock_irqsave(&dev->hwlock, flags);    __galil_1800_clear_FIFO(dev, readwrite);    spin_unlock_irqrestore(&dev->hwlock, flags);}static inline void galil_1800_enable_IRQ(struct galil_1800_state *dev){    char t;    unsigned long flags;        spin_lock_irqsave(&dev->hwlock, flags);     (void) inb(GALIL_1800_IRQ_REG(dev)); /* useless ?! */    t = inb(GALIL_1800_CONTROL_REG(dev));     outb(t|GALIL_1800_IRQ_ENABLE_FLAG, GALIL_1800_CONTROL_REG(dev));     (void) inb(GALIL_1800_IRQ_REG(dev)); /* useless ?! */    spin_unlock_irqrestore(&dev->hwlock, flags);}static inline void galil_1800_disable_IRQ(struct galil_1800_state *dev){    unsigned long flags;    char t;        spin_lock_irqsave(&dev->hwlock, flags);    t = inb(GALIL_1800_CONTROL_REG(dev)) & ~GALIL_1800_IRQ_ENABLE_FLAG;    outb(t, GALIL_1800_CONTROL_REG(dev));    spin_unlock_irqrestore(&dev->hwlock, flags);}/* Wait for a byte in the Read FIFO, or until a timeout occurs.   Return 1 if a byte is available in the FIFO, 0 otherwise.    Interrupts MUST be enabled, or the kernel will freeze */static inline int galil_1800_may_read(struct galil_1800_state *dev){    unsigned long timeout = jiffies + GALIL_1800_READ_TIMEOUT;        do {        char t = inb(GALIL_1800_CONTROL_REG(dev)) & GALIL_1800_FIFO_EMPTY_FLAG;        if (!t)            return 1;    } while (jiffies < timeout);    return 0;}/* Wait for a free slot in the Write FIFO, or until a timeout occurs.   Return 2 if FIFO is less than half full (at least 128 free slots),   1 if a slot is available in the FIFO, 0 otherwise.   Interrupts MUST be enabled, or the kernel will freeze */static inline int galil_1800_may_write(struct galil_1800_state *dev){    unsigned long timeout = jiffies + GALIL_1800_WRITE_TIMEOUT;        do {        char t = inb(GALIL_1800_CONTROL_REG(dev));        if (!(t & GALIL_1800_FIFO_HALF_FLAG))            return 2;        if (!(t & GALIL_1800_FIFO_FULL_FLAG))            return 1;    } while (jiffies < timeout);    return 0;    }/* Secondary Communication Channel:     - on DMC-1800, SCC can be used in polling FIFO mode only: data goes in      the secondary FIFO of the controller, and then transferred to the UM      address space by the driver    - SCC is not active by default, it must be enabled by using the DR command      with a negative argument -n (2^n samples between updates)    - DR0 command disables SCC    - SCC provide information at a fixed rate about position, position error,      auxiliary position, velocity, torque, axis status, input line status,      output line status, segment count for coordinate moves, and controller      status    - official docs are particularly obscure about SCC in 1800 devices, as       they fail in stating the differences between 1800 and 1802 devices;      some information has been gathered from the buggy Galil original driver    - our handshake procedure for accessing the secondary FIFO:        1. "wait for data": read GALIL_1800_FIFO2_EMPTY_FLAG bit in            GALIL_1800_CONTROL_REG until it is equal to 0        2. "freeze 2nd FIFO": set GALIL_1800_FIFO2_FREEZE_FLAG bit in           GALIL_1800_CONTROL_REG        3. "wait for complete": read GALIL_1800_FIFO2_BUSY_FLAG bit in            GALIL_1800_CONTROL_REG until it is equal to 0        4. "fetch data": read byte at GALIL_1800_2CHAN_REG        5. "check for data": read GALIL_1800_FIFO2_EMPTY_FLAG bit in            GALIL_1800_CONTROL_REG; if it is equal to 0, goto step 4.        6. "unfreeze 2nd FIFO": clear GALIL_1800_FIFO2_FREEZE_FLAG bit in           GALIL_1800_CONTROL_REG      that's different from the procedure in the Galil original driver, and it's      different from what's described in the official docs, but it has a slightly      better chance to work, IMHO*/    /* Wait for a byte in the secondary FIFO, or until a timeout occurs.   Return 1 if a byte is available in the 2nd FIFO, 0 otherwise.    Interrupts MUST be enabled, or the kernel will freeze */static inline int galil_1800_may_read_FIFO2(struct galil_1800_state *dev){    unsigned long timeout = jiffies + GALIL_1800_READ_TIMEOUT;        do {        char t = inb(GALIL_1800_CONTROL_REG(dev)) & GALIL_1800_FIFO2_EMPTY_FLAG;        if (!t)            return 1;    } while (jiffies < timeout);    return 0;}/* Freeze and unfreeze the secondary communication channel */static inline void galil_1800_freeze_FIFO2(struct galil_1800_state *dev){ 	char t = inb(GALIL_1800_CONTROL_REG(dev));    t |= GALIL_1800_FIFO2_FREEZE_FLAG;    outb(t, GALIL_1800_CONTROL_REG(dev));   }static inline void galil_1800_unfreeze_FIFO2(struct galil_1800_state *dev){ 	char t = inb(GALIL_1800_CONTROL_REG(dev));    t &= ~GALIL_1800_FIFO2_FREEZE_FLAG;    outb(t, GALIL_1800_CONTROL_REG(dev));}/* Wait until the controller ends transferring a data in the 2nd FIFO */static inline void galil_1800_wait_transfer_FIFO2(struct galil_1800_state *dev){	char t;        do {        t = inb(GALIL_1800_CONTROL_REG(dev)) & GALIL_1800_FIFO2_BUSY_FLAG;    } while (t);    }/* Read from the secondary communication channel (2nd FIFO)   - data are written in %buf%, a preallocated buffer of size %max%   - return the number of bytes read (even 0) */static inline int galil_1800_read_FIFO2(struct galil_1800_state *dev,                                         char *buf, int max){	char *p = buf;    char t;    int n = 0;	    if (!galil_1800_may_read_FIFO2(dev))        return n;	galil_1800_freeze_FIFO2(dev);	galil_1800_wait_transfer_FIFO2(dev);	do {        t = inb(GALIL_1800_2CHAN_REG(dev));        *p++ = t;        ++n;        t = inb(GALIL_1800_CONTROL_REG(dev)) & GALIL_1800_FIFO2_EMPTY_FLAG;    } while (!t && n<max);    galil_1800_unfreeze_FIFO2(dev);	return n;                }/* This feature is undocumented, info from the Galil's Linux driver.    It appears that they would use the S/N of their cards as a "private key"   known only to licensed user. Of course, this is yet another example of the   "security by hiding" approach, which is very weak and useless for any   practical purpose. Anyway, Galil has published the source code of its    Linux driver... *//* Return <0 in case of errors, 0 otherwise.   The serial number is written into %buf% */ static int galil_1800_get_serial_number(struct galil_1800_state *dev,                                         char *buf){    unsigned long flags;    int t, i;    unsigned long tot = 0;    char *p = buf;        if (!buf)        return -EINVAL;            galil_1800_clear_FIFO(dev, 0);        t = galil_1800_may_write(dev);        if (t == 0 || t == 1) {        printk(KERN_ERR PFX "cannot flush the Write FIFO (code=%d) \n", t);        return -ENOSPC;    }    spin_lock_irqsave(&dev->hwlock, flags);        outb( 'M',  GALIL_1800_WRITE_REG(dev) );    outb( 'G',  GALIL_1800_WRITE_REG(dev) );    outb( '_',  GALIL_1800_WRITE_REG(dev) );    outb( 'B',  GALIL_1800_WRITE_REG(dev) );    outb( 'N',  GALIL_1800_WRITE_REG(dev) );    outb( '\r', GALIL_1800_WRITE_REG(dev) );    spin_unlock_irqrestore(&dev->hwlock, flags);        for (i=60; i>0; --i) {        char c;                if (!galil_1800_may_read(dev)) {            printk(KERN_INFO PFX "waiting for serial number on Read FIFO\n");            ++i;            schedule();            continue;        }        c = inb(GALIL_1800_READ_REG(dev));        if (c == '.' || c == 0x0d)            break;        if (c >= '0' && c <= '9')            tot = tot * 10 + c - '0';        *p++ = c;    }        if (!i) {    	printk(KERN_INFO PFX "device #%d didn't return its serial number\n",                              dev->index);        return -1;       }    *p = '\0';        if (dev->serial != tot) {        printk(KERN_INFO PFX "device #%d has serial number %lu (\"%s\")\n",                 dev->index, tot, buf);        dev->serial = tot;    }    return 0;}/* This is the interrupt handler.   It sends a signal to any process in the siglist.   Actually, this is done later in a deferrable function     (galil_1800_send_signals()). */static void galil_1800_interrupt(int irq, void *dev_id, struct pt_regs *regs){    struct galil_1800_state *dev = dev_id;    unsigned long flags;    unsigned char status, t;    int i;        spin_lock_irqsave(&dev->hwlock, flags);#if 0    /* tech docs are not straightforward on how to get the interrupt status;     in particular, should we write 0x06 in GALIL_1800_IRQ_REG before      reading the status? */        outb(0x06, GALIL_1800_IRQ_REG(dev));#endif        status = inb(GALIL_1800_IRQ_REG(dev));    t = inb(GALIL_1800_CONTROL_REG(dev));    outb(t | GALIL_1800_IRQ_STATUS_FLAG, GALIL_1800_CONTROL_REG(dev));    spin_unlock_irqrestore(&dev->hwlock, flags);        if (!(t & GALIL_1800_IRQ_STATUS_FLAG))        return;    /* shared interrupt raised by someone else */            /* save the status value in the device descriptor's stack */    i = dev->irqstack_sz++;    if (i < GALIL_1800_IRQ_STACK_SZ)        dev->irqstack[i] = status;    else {         printk(KERN_INFO PFX               "IRQ stack is full, discarding value...\n");        dev->irqstack_sz = GALIL_1800_IRQ_STACK_SZ;    }    /* schedule execution of galil_1800_send_signals() */        tasklet_schedule(&dev->tlet);}static void galil_1800_send_signals(unsigned long device){    struct galil_1800_state * dev = (struct galil_1800_state *) device;    struct siginfo sinfo;    struct list_head *list;    struct list_head *head = &dev->siglist;    struct galil_1800_siglist_t *elem;    unsigned long flags;    int sz, i;        sinfo.si_signo = SIGUSR1;    sinfo.si_errno = 0;    sz = dev->irqstack_sz;    /* should irqstack_sz be atomic_t ? */    read_lock(&dev->siglock); /* it's safe to leave interrupts enabled,                                  because no asynchronous function                                 (interrupt handler or deferrable                                  function) gets the write siglock */    list_for_each(list, head) {         elem = list_entry(list, struct galil_1800_siglist_t, list);         if (copy_to_user(elem->ubuf, dev->irqstack, sz))             printk(KERN_ERR PFX "error while copying irq values, PID=%d buffer=%p\n",                elem->pid, elem->ubuf);         sinfo.si_code = sz;         send_sig_info(SIGUSR1, &sinfo, elem->owner);    }   

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲色图视频网| 国产91精品精华液一区二区三区 | 欧美国产成人精品| 日韩欧美国产一区二区在线播放 | 亚洲国产aⅴ成人精品无吗| 一区二区三区蜜桃网| 亚洲精品国产高清久久伦理二区| 国产精品久久久久久久久果冻传媒| 国产亚洲精品bt天堂精选| 久久老女人爱爱| 国产午夜精品久久久久久免费视 | 亚洲精品免费看| 亚洲精品第1页| 亚洲国产三级在线| 香蕉影视欧美成人| 美国毛片一区二区三区| 久久er精品视频| 国产麻豆日韩欧美久久| 丁香婷婷综合色啪| 色综合咪咪久久| 欧美色综合久久| 日韩欧美一级二级三级久久久| 欧美一区二区播放| 久久久国际精品| 中文字幕中文在线不卡住| 亚洲美女精品一区| 首页欧美精品中文字幕| 激情小说亚洲一区| 成人app软件下载大全免费| 一本久久精品一区二区| 欧美男同性恋视频网站| 精品国产亚洲在线| 国产精品久久久久永久免费观看| 亚洲人妖av一区二区| 五月激情六月综合| 国内精品国产成人国产三级粉色 | 欧洲精品一区二区| 日韩视频免费观看高清完整版在线观看 | 欧美成人女星排名| 国产精品电影一区二区| www.综合网.com| 日本二三区不卡| 日韩一区二区三区精品视频| 久久久久久亚洲综合影院红桃| 国产精品五月天| 亚洲小少妇裸体bbw| 狠狠色综合播放一区二区| 99久久久国产精品免费蜜臀| 精品视频1区2区| www国产精品av| 一区二区三区在线免费播放| 捆绑变态av一区二区三区| av在线一区二区三区| 欧美一区二区久久久| ...xxx性欧美| 麻豆91在线播放免费| 91在线视频网址| 欧美变态口味重另类| 一区二区三区在线高清| 国产自产v一区二区三区c| 欧美亚洲动漫另类| 日本一区二区三区久久久久久久久不| 夜夜爽夜夜爽精品视频| 国产精品夜夜爽| 欧美精品在线观看一区二区| 国产精品美女www爽爽爽| 另类小说色综合网站| 色婷婷综合久久久中文字幕| 久久久噜噜噜久噜久久综合| 亚洲成人精品一区二区| 成人黄色大片在线观看| 精品国产亚洲一区二区三区在线观看| 一个色综合网站| 成人黄色小视频| 欧美大片在线观看| 午夜影院在线观看欧美| 北条麻妃国产九九精品视频| 欧美精品一区二区三区蜜桃| 午夜精品一区在线观看| 91麻豆成人久久精品二区三区| 久久美女艺术照精彩视频福利播放| 日韩国产精品久久| 在线一区二区三区四区五区| 国产精品理伦片| 国产一区二区三区香蕉| 欧美一级欧美一级在线播放| 亚洲国产成人av网| 91日韩在线专区| 国产精品系列在线| 国产精品正在播放| 精品欧美黑人一区二区三区| 亚洲午夜私人影院| 日本精品免费观看高清观看| 中文字幕一区二区三区不卡 | av色综合久久天堂av综合| 久久精品无码一区二区三区| 激情文学综合网| 久久久亚洲综合| 国内精品视频一区二区三区八戒| 欧美大胆人体bbbb| 美女网站色91| 日韩亚洲欧美在线| 欧美96一区二区免费视频| 欧美精品在欧美一区二区少妇| 亚洲高清免费在线| 欧美色综合网站| 天天影视色香欲综合网老头| 欧美日韩高清在线| 香蕉av福利精品导航| 欧美高清一级片在线| 日韩电影免费在线观看网站| 91.com视频| 美女视频黄久久| 亚洲精品一区二区三区影院 | 制服丝袜亚洲精品中文字幕| 天天色天天操综合| 日韩免费成人网| 激情欧美日韩一区二区| 国产三级一区二区| 北条麻妃国产九九精品视频| 成人免费在线观看入口| 日本高清不卡一区| 日韩极品在线观看| 精品国产凹凸成av人导航| 国产精品白丝jk白祙喷水网站| 久久久99久久| 99re6这里只有精品视频在线观看| 亚洲欧美电影一区二区| 欧美三级三级三级| 人人超碰91尤物精品国产| 2014亚洲片线观看视频免费| 高清在线不卡av| 亚洲美女屁股眼交| 69av一区二区三区| 国产精品一区二区三区四区| 亚洲色欲色欲www在线观看| 欧美夫妻性生活| 国产精品一二一区| 亚洲国产美女搞黄色| 欧美电影免费观看高清完整版在| 国产成人在线免费观看| 尤物在线观看一区| 日韩欧美国产三级| 99久久国产免费看| 蜜桃一区二区三区在线观看| 国产精品亲子乱子伦xxxx裸| 欧美三级欧美一级| 国产精品自拍在线| 亚洲成人黄色影院| 久久精品水蜜桃av综合天堂| 欧美日免费三级在线| 国内精品久久久久影院薰衣草 | 午夜在线成人av| 久久久精品欧美丰满| 欧美在线观看一二区| 国内精品第一页| 亚洲自拍偷拍综合| 337p粉嫩大胆色噜噜噜噜亚洲| 97精品电影院| 婷婷亚洲久悠悠色悠在线播放 | 激情综合亚洲精品| 日韩一区欧美小说| 欧美tk—视频vk| 欧美aa在线视频| 一级精品视频在线观看宜春院 | 久久精品国产亚洲a| 中文字幕不卡在线| 欧美高清视频在线高清观看mv色露露十八| 国产成人免费视频网站| 亚洲电影视频在线| 中文字幕一区二区三区精华液| 欧美日韩免费高清一区色橹橹 | 99精品视频免费在线观看| 日韩不卡一区二区| 亚洲免费观看高清完整版在线观看| 欧美xxxxx裸体时装秀| 在线免费观看不卡av| 成人黄色网址在线观看| 免费看黄色91| 亚洲国产精品麻豆| 中文子幕无线码一区tr| 制服丝袜一区二区三区| 欧美午夜精品久久久久久超碰| 国产一区91精品张津瑜| 久久精品72免费观看| 亚洲美女电影在线| 国产精品久久久久久久久免费桃花| 久久综合久久综合亚洲| 欧美精选一区二区| 一本色道久久加勒比精品| 国产剧情av麻豆香蕉精品| 久久99精品久久久久久| 天天做天天摸天天爽国产一区 | 国产黄人亚洲片| 久久不见久久见免费视频1| 香蕉久久一区二区不卡无毒影院| 成人欧美一区二区三区小说| 国产精品网站在线| 精品国产成人系列| 精品国产乱码久久久久久夜甘婷婷|