2 #include <gm/moduletypes.h>
4 #include "libvmoddor2dioaio.h"
6 #define VMODDOR_MAX_BOARDS 64
9 static short int offset_to_group
[MAX_OFFSET
][MAX_SIZE
] = /* Translate from offset to groups */
10 {{-1, -1, 2, -1, 0}, /* that are used in dioaiolib */
17 static void print_error(int error
);
19 int vmoddor_open(int lun
)
21 if(lun
< 0 || lun
>= VMODDOR_MAX_BOARDS
){
22 fprintf(stderr
, "libvmoddor2dioaio : Invalid lun %d\n", lun
);
29 int vmoddor_close(int lun
)
34 int vmoddor_write(int lun
, struct vmoddor_warg val
)
38 int size
= val
.size
/ 4;
40 group_no
= offset_to_group
[val
.offset
][size
];
42 /* The size in dioaiolib means 4 bits in VMODDOR case. */
43 ret
= DioStrobeWrite(IocVMODDOR
, group_no
, size
, 0, 20, 80, val
.data
);
51 static void print_error(int error
)
54 case -dio_system_errno
:
55 fprintf(stderr
, dio_err1msg
);
58 fprintf(stderr
, dio_err8msg
);
60 case -dio_cannot_find_shared_table
:
61 fprintf(stderr
, dio_err7msg
);
63 case -dio_cannot_map_shared_table
:
64 fprintf(stderr
, dio_err6msg
);
66 case -dio_odd_group_no_and_even_size
:
67 fprintf(stderr
, dio_err5msg
);
70 fprintf(stderr
, dio_err4msg
);
73 fprintf(stderr
, dio_err3msg
);
75 case -dio_no_direct_access_allowed
:
76 fprintf(stderr
, dio_err2msg
);
78 case -dio_lun_out_of_range
:
79 fprintf(stderr
, dio_err9msg
);
81 case -dio_no_module_of_this_type
:
82 fprintf(stderr
, dio_err10msg
);