2 #include <gm/moduletypes.h>
3 #include "libvmodttl2dioaio.h"
7 #define VMODTTL_MAX_BOARDS 64 /* max. # of boards supported */
9 static void print_error(int error
);
11 int vmodttl_open(int lun
)
13 if(lun
< 0 || lun
>= VMODTTL_MAX_BOARDS
){
14 fprintf(stderr
, "libvmodttl2dioaio : Invalid lun %d\n", lun
);
20 int vmodttl_close(int lun
)
25 int vmodttl_io_config(int lun
, struct vmodttl_config conf
)
29 ret
= DioGlobalReset(IocVMODTTL
, lun
);
35 ret
= DioChannelSet(IocVMODTTL
, lun
, 0, 1, conf
.dir_a
, conf
.inverting_logic
, conf
.inverting_logic
);
41 ret
= DioChannelSet(IocVMODTTL
, lun
, 1, 1, conf
.dir_b
, conf
.inverting_logic
, conf
.inverting_logic
);
50 int vmodttl_io_chan_config(int lun
, enum vmodttl_channel chan
, struct vmodttl_config conf
)
56 case VMOD_TTL_CHANNEL_A
:
57 ret
= DioChannelSet(IocVMODTTL
, lun
, 0, 1, conf
.dir_a
, conf
.inverting_logic
, conf
.inverting_logic
);
59 case VMOD_TTL_CHANNEL_B
:
60 ret
= DioChannelSet(IocVMODTTL
, lun
, 1, 1, conf
.dir_b
, conf
.inverting_logic
, conf
.inverting_logic
);
62 case VMOD_TTL_CHANNELS_AB
:
63 ret
= vmodttl_io_config(lun
, conf
);
66 fprintf(stderr
, "libvmodttl2dioaio : Invalid channel (%d) to configure\n", chan
);
76 int vmodttl_write(int lun
, enum vmodttl_channel chan
, int val
)
78 if (chan
!= VMOD_TTL_CHANNELS_AB
){
79 DioChannelWrite(IocVMODTTL
, lun
, chan
, 1, val
);
81 DioChannelWrite(IocVMODTTL
, lun
, 0, 1, val
& 0xff);
82 DioChannelWrite(IocVMODTTL
, lun
, 1, 1, (val
>> 8) & 0xff);
88 int vmodttl_read(int lun
, enum vmodttl_channel chan
, int *val
)
92 if (chan
!= VMOD_TTL_CHANNELS_AB
){
93 ret
= DioChannelRead(IocVMODTTL
, lun
, chan
, 1, (int *)val
);
98 ret
= DioChannelRead(IocVMODTTL
, lun
, 0, 1, (int *)&tmp
);
99 ret
= DioChannelRead(IocVMODTTL
, lun
, 1, 1, (int *)&tmp2
);
100 *val
= tmp
+ (tmp2
<< 8);
106 int vmodttl_pattern(int lun
, enum vmodttl_channel chan
, int pos
, enum vmodttl_conf_pattern bit_pattern
)
108 /* Not implemented */
112 int vmodttl_read_config(int lun
, struct vmodttl_config
*conf
)
114 /* Not implemented */
118 int vmodttl_read_device(int lun
, unsigned char buffer
[2])
120 /* Not implemented */
125 static void print_error(int error
)
128 case -dio_system_errno
:
129 fprintf(stderr
, dio_err1msg
);
132 fprintf(stderr
, dio_err8msg
);
134 case -dio_cannot_find_shared_table
:
135 fprintf(stderr
, dio_err7msg
);
137 case -dio_cannot_map_shared_table
:
138 fprintf(stderr
, dio_err6msg
);
140 case -dio_odd_group_no_and_even_size
:
141 fprintf(stderr
, dio_err5msg
);
144 fprintf(stderr
, dio_err4msg
);
147 fprintf(stderr
, dio_err3msg
);
149 case -dio_no_direct_access_allowed
:
150 fprintf(stderr
, dio_err2msg
);
152 case -dio_lun_out_of_range
:
153 fprintf(stderr
, dio_err9msg
);
155 case -dio_no_module_of_this_type
:
156 fprintf(stderr
, dio_err10msg
);