2 @file libvmod12e162dioaio.c
3 @brief Library file for the vmod12e16 driver
4 @author Samuel Iglesias Gonsalvez
12 #include "libvmod12e162dioaio.h"
13 #include <gm/moduletypes.h>
14 #include <ioconfiglib.h>
15 #include <dioaiolib.h>
17 #define VMOD12E16_MAX_MODULES 64
18 #define PURGE_CPUPIPELINE asm("eieio")
20 struct vmod12e16_registers
{
21 unsigned short control
; /**< control register (wo) */
22 unsigned short unused
;
23 unsigned short ready
; /**< ready status register (ro)
24 (bit 15 == 0 if ready, and then bits 11-0
25 in data register are valid) */
26 unsigned short interrupt
; /**< interrupt mode get/set (rw)
27 (bit 15 == 0 iff interrupt
28 mode is in force/desired) */
31 int vmod12e16_get_handle(unsigned int carrier_lun
)
33 if(carrier_lun
< 0 || carrier_lun
>= VMOD12E16_MAX_MODULES
){
34 fprintf(stderr
, "libvmod12e162dioaio : Invalid lun %d\n", carrier_lun
);
40 int vmod12e16_convert(int fd
, int channel
, enum vmod12e16_amplification factor
, int *datum
)
44 struct vmod12e16_registers
*reg
;
46 ret
= IocModulPointer(IocVMOD12E16
, fd
, IOC_DEFAULTP
, &address
);
48 fprintf(stderr
,"libvmod12e162dioaio: error getting the address: %d\n", ret
);
51 reg
= (struct vmod12e16_registers
*)address
;
53 reg
->interrupt
= 0x8000; /* No interrupts*/
56 reg
->control
= channel
;
59 while ((reg
->ready
& 0x8000) != 0) {};
61 *datum
= reg
->control
& 0x0fff;
67 int vmod12e16_close(int fd
)