X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/91dfab84182937b62ef64cb12d8e4f89e6d5c3ec..328a0f0a261a7349b3731dbfdfc6591188003c48:/lincan/include/main.h diff --git a/lincan/include/main.h b/lincan/include/main.h index 4bb0e0e..2fa81ce 100644 --- a/lincan/include/main.h +++ b/lincan/include/main.h @@ -13,15 +13,17 @@ #include "./can_queue.h" #ifdef CAN_DEBUG - #define DEBUGMSG(fmt,args...) printk(KERN_ERR "can.o (debug): " fmt,\ + #define DEBUGMSG(fmt,args...) can_printk(KERN_ERR "can.o (debug): " fmt,\ ##args) #else #define DEBUGMSG(fmt,args...) #endif -#define CANMSG(fmt,args...) printk(KERN_ERR "can.o: " fmt,##args) +#define CANMSG(fmt,args...) can_printk(KERN_ERR "can.o: " fmt,##args) +extern can_spinlock_t canuser_manipulation_lock; + /** * struct canhardware_t - structure representing pointers to all CAN boards * @nr_boards: number of present boards @@ -51,6 +53,8 @@ struct canhardware_t { * @chip: array of pointers to the chip structures * @hwspecops: pointer to board specific operations * @hosthardware_p: pointer to the root hardware structure + * @sysdevptr: union reserved for pointer to bus specific + * device structure (case @pcidev is used for PCI devices) * * The structure represent configuration and state of associated board. * The driver infrastructure prepares this structure and calls @@ -81,6 +85,13 @@ struct candevice_t { struct hwspecops_t *hwspecops; struct canhardware_t *hosthardware_p; + + union { + #ifdef CAN_ENABLE_PCI_SUPPORT + struct pci_dev *pcidev; + #endif /*CAN_ENABLE_PCI_SUPPORT*/ + } sysdevptr; + }; /** @@ -120,6 +131,15 @@ struct candevice_t { * @chipspecops: pointer to the set of chip specific object filled by init_chip_data() function * @hostdevice: pointer to chip hosting board * @max_objects: maximal number of communication objects connected to this chip + * @chip_lock: reserved for synchronization of the chip supporting routines + * (not used in the current driver version) + * @worker_thread: chip worker thread ID (RT-Linux specific field) + * @pend_flags: holds information about pending interrupt and tx_wake() operations + * (RT-Linux specific field). Masks values: + * %MSGOBJ_TX_REQUEST .. some of the message objects requires tx_wake() call, + * %MSGOBJ_IRQ_REQUEST .. chip interrupt processing required + * %MSGOBJ_WORKER_WAKE .. marks, that worker thread should be waked + * for some of above reasons * * The fields @write_register and @read_register are copied from * corresponding fields from @hwspecops structure @@ -152,6 +172,13 @@ struct chip_t { struct candevice_t *hostdevice; int max_objects; /* 1 for sja1000, 15 for i82527 */ + + can_spinlock_t chip_lock; + + #ifdef CAN_WITH_RTL + pthread_t worker_thread; + unsigned long pend_flags; + #endif /*CAN_WITH_RTL*/ }; /** @@ -174,12 +201,16 @@ struct chip_t { * @obj_used: counter of users (associated file structures for Linux * userspace clients) of this object * @obj_users: list of user structures of type &canuser_t. + * @obj_flags: message object specific flags. Masks values: + * %MSGOBJ_TX_REQUEST .. the message object requests TX activation + * %MSGOBJ_TX_LOCK .. some IRQ routine or callback on some CPU + * is running inside TX activation processing code */ struct msgobj_t { unsigned long obj_base_addr; unsigned int minor; /* associated device minor number */ unsigned int object; /* object number in chip_t +1 for debug printk */ - unsigned long flags; + unsigned long obj_flags; int ret; struct canque_ends_t *qends; @@ -201,20 +232,33 @@ struct msgobj_t { /** * struct canuser_t - structure holding CAN user/client state + * @flags: used to distinguish Linux/RT-Linux type * @peers: for connection into list of object users * @qends: pointer to the ends structure corresponding for this user - * @file: pointer to open device file state structure * @msgobj: communication object the user is connected to * @rx_edge0: default receive queue for filter IOCTL + * @userinfo: stores user context specific information. + * The field @fileinfo.file holds pointer to open device file state structure + * for the Linux user-space client applications * @magic: magic number to check consistency when pointer is retrieved * from file private field */ struct canuser_t { + unsigned long flags; struct list_head peers; struct canque_ends_t *qends; - struct file *file; /* back ptr to file */ struct msgobj_t *msgobj; struct canque_edge_t *rx_edge0; /* simplifies IOCTL */ + union { + struct { + struct file *file; /* back ptr to file */ + } fileinfo; + #ifdef CAN_WITH_RTL + struct { + struct rtl_file *file; + } rtlinfo; + #endif /*CAN_WITH_RTL*/ + } userinfo; int magic; }; @@ -297,7 +341,7 @@ struct chipspecops_t { unsigned short btr1); int (*start_chip)(struct chip_t *chip); int (*stop_chip)(struct chip_t *chip); - irqreturn_t (*irq_handler)(int irq, void *dev_id, struct pt_regs *regs); + can_irqreturn_t (*irq_handler)(int irq, void *dev_id, struct pt_regs *regs); }; struct mem_addr { @@ -375,3 +419,7 @@ struct boardtype_t { }; const struct boardtype_t* boardtype_find(const char *str); + +#ifdef CAN_WITH_RTL +extern int can_rtl_priority; +#endif /*CAN_WITH_RTL*/