00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035
00036
00037 #ifndef __EC_DATAGRAM_H__
00038 #define __EC_DATAGRAM_H__
00039
00040 #include <linux/list.h>
00041 #include <linux/time.h>
00042 #include <linux/timex.h>
00043
00044 #include "globals.h"
00045
00046
00047
00050 typedef enum {
00051 EC_DATAGRAM_NONE = 0x00,
00052 EC_DATAGRAM_APRD = 0x01,
00053 EC_DATAGRAM_APWR = 0x02,
00054 EC_DATAGRAM_APRW = 0x03,
00055 EC_DATAGRAM_FPRD = 0x04,
00056 EC_DATAGRAM_FPWR = 0x05,
00057 EC_DATAGRAM_FPRW = 0x06,
00058 EC_DATAGRAM_BRD = 0x07,
00059 EC_DATAGRAM_BWR = 0x08,
00060 EC_DATAGRAM_BRW = 0x09,
00061 EC_DATAGRAM_LRD = 0x0A,
00062 EC_DATAGRAM_LWR = 0x0B,
00063 EC_DATAGRAM_LRW = 0x0C,
00064 EC_DATAGRAM_ARMW = 0x0D,
00066 EC_DATAGRAM_FRMW = 0x0E,
00068 } ec_datagram_type_t;
00069
00070
00071
00074 typedef enum {
00075 EC_DATAGRAM_INIT,
00076 EC_DATAGRAM_QUEUED,
00077 EC_DATAGRAM_SENT,
00078 EC_DATAGRAM_RECEIVED,
00079 EC_DATAGRAM_TIMED_OUT,
00080 EC_DATAGRAM_ERROR
00081 } ec_datagram_state_t;
00082
00083
00084
00087 typedef struct {
00088 struct list_head queue;
00089 struct list_head sent;
00090 ec_device_index_t device_index;
00092 ec_datagram_type_t type;
00093 uint8_t address[EC_ADDR_LEN];
00094 uint8_t *data;
00095 ec_origin_t data_origin;
00096 size_t mem_size;
00097 size_t data_size;
00098 uint8_t index;
00099 uint16_t working_counter;
00100 ec_datagram_state_t state;
00101 #ifdef EC_HAVE_CYCLES
00102 cycles_t cycles_sent;
00103 #endif
00104 unsigned long jiffies_sent;
00105 #ifdef EC_HAVE_CYCLES
00106 cycles_t cycles_received;
00107 #endif
00108 unsigned long jiffies_received;
00110 unsigned int skip_count;
00111 unsigned long stats_output_jiffies;
00112 char name[EC_DATAGRAM_NAME_SIZE];
00113 } ec_datagram_t;
00114
00115
00116
00117 void ec_datagram_init(ec_datagram_t *);
00118 void ec_datagram_clear(ec_datagram_t *);
00119 void ec_datagram_unqueue(ec_datagram_t *);
00120 int ec_datagram_prealloc(ec_datagram_t *, size_t);
00121 void ec_datagram_zero(ec_datagram_t *);
00122
00123 int ec_datagram_aprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
00124 int ec_datagram_apwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
00125 int ec_datagram_aprw(ec_datagram_t *, uint16_t, uint16_t, size_t);
00126 int ec_datagram_armw(ec_datagram_t *, uint16_t, uint16_t, size_t);
00127 int ec_datagram_fprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
00128 int ec_datagram_fpwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
00129 int ec_datagram_fprw(ec_datagram_t *, uint16_t, uint16_t, size_t);
00130 int ec_datagram_frmw(ec_datagram_t *, uint16_t, uint16_t, size_t);
00131 int ec_datagram_brd(ec_datagram_t *, uint16_t, size_t);
00132 int ec_datagram_bwr(ec_datagram_t *, uint16_t, size_t);
00133 int ec_datagram_brw(ec_datagram_t *, uint16_t, size_t);
00134 int ec_datagram_lrd(ec_datagram_t *, uint32_t, size_t);
00135 int ec_datagram_lwr(ec_datagram_t *, uint32_t, size_t);
00136 int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t);
00137 int ec_datagram_lrd_ext(ec_datagram_t *, uint32_t, size_t, uint8_t *);
00138 int ec_datagram_lwr_ext(ec_datagram_t *, uint32_t, size_t, uint8_t *);
00139 int ec_datagram_lrw_ext(ec_datagram_t *, uint32_t, size_t, uint8_t *);
00140
00141 void ec_datagram_print_state(const ec_datagram_t *);
00142 void ec_datagram_print_wc_error(const ec_datagram_t *);
00143 void ec_datagram_output_stats(ec_datagram_t *);
00144 const char *ec_datagram_type_string(const ec_datagram_t *);
00145
00146
00147
00148 #endif