00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef MOST_SYNC_H
00022 #define MOST_SYNC_H
00023 
00034 #ifdef __KERNEL__
00035 #   include <linux/cdev.h>
00036 #   include <asm/semaphore.h>
00037 #   include <asm/ioctl.h>
00038 #   include <linux/rwsem.h>
00039 #   include "most-rxbuf.h"
00040 #   include "most-txbuf.h"
00041 #endif
00042 
00043 #include "most-common.h"
00044 
00045 
00046 
00047 
00048 
00053 #define MOST_SYNC_IOCTL_MAGIC                           'h'
00054 
00075 #define MOST_SYNC_SETUP_RX  \
00076     _IOW(MOST_SYNC_IOCTL_MAGIC, 0, struct frame_part)
00077 
00098 #define MOST_SYNC_SETUP_TX \
00099     _IOW(MOST_SYNC_IOCTL_MAGIC, 1, struct frame_part)
00100 
00104 #define MOST_SYNC_MAXIOCTL                  1
00105 
00106 
00107 #ifdef __KERNEL__
00108 
00109 
00110 
00111 
00112 
00116 #define MOST_SYNC_MINOR_OFFSET              8
00117 
00118 
00119 
00120 
00121 
00122 
00128 struct most_sync_dev {
00129     struct cdev             cdev;                
00131     struct most_dev         *most_dev;           
00133     struct dma_buffer       hw_receive_buf;      
00134     struct dma_buffer       hw_transmit_buf;     
00135     struct rx_buffer        *sw_receive_buf;     
00136     struct tx_buffer        *sw_transmit_buf;    
00137     struct list_head        file_list;           
00139     atomic_t                open_count;          
00140     atomic_t                receiver_count;      
00141     atomic_t                transmitter_count;   
00142     wait_queue_head_t       rx_queue;            
00145     wait_queue_head_t       tx_queue;            
00148     struct rw_semaphore     config_lock_rx;      
00151     struct rw_semaphore     config_lock_tx;      
00154     unsigned char           rx_current_page;     
00157     unsigned char           tx_current_page;     
00160 };
00161 
00165 struct most_sync_file {
00166     struct list_head       list;                
00168     struct most_sync_dev   *sync_dev;           
00170     struct frame_part      part_rx;             
00171     struct frame_part      part_tx;             
00172     bool                   rx_running;          
00173     bool                   tx_running;          
00174     int                    reader_index;        
00177     int                    writer_index;        
00180 };
00181 
00182 
00193 ssize_t most_sync_read(struct file                  *filp, 
00194                        void                         *buff,
00195                        size_t                       count,
00196                        struct rtnrt_memcopy_desc    *copy);
00197 
00208 ssize_t most_sync_write(struct file                 *filp, 
00209                         void                        *buff,
00210                         size_t                      count,
00211                         struct rtnrt_memcopy_desc   *copy);
00212 
00221 int most_sync_setup_rx(struct file *filp, struct frame_part *frame_part);
00222 
00230 int most_sync_setup_tx(struct file *filp, struct frame_part *frame_part);
00231 
00232 #endif 
00233 
00234 #endif 
00235 
00236 
00237 
00238