Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 123 → Rev 124

/cvi/instr/WIENVME_DLL/wienvme_dll.c
9,7 → 9,9
#include <dlfcn.h>
#define LoadLibrary(x) dlopen( (x), RTLD_NOW );
#define GetProcAddress(x,y) dlsym((x),(y))
static int GetCurrentPlatform(void ){return 0;};
static int GetCurrentPlatform(void ) {
return 0;
};
#define __stdcall
#define UCHAR unsigned char
#define HINSTANCE void *
22,7 → 24,7
 
#include "wienvme_dll.h"
//----------- DEFINES -----------------------------------------------------
#define DEVICENAME_LINUX "/dev/pcivme_0" // a device name 'template' for WINNT
#define DEVICENAME_LINUX "/dev/pcivme_0" // a device name 'template' for LINUX
#define DEVICENAME_NT "\\\\.\\PCIVME:\\VMEMMxx" // a device name 'template' for WINNT
#define DEVICENAME_9X "\\\\.\\C:\\windows\\system\\VWIENVMED.vxd" // the same for WIN95/98
#define MODULE_NUMBER 1 // number of connected CC32 module
38,27 → 40,26
#define VMEclose (*vme_close)
static int VMEclose (int);
 
int hHandle24, hHandle32;
int hHandle24, hHandle32;
int VMEmodule;
 
static HINSTANCE DLLHandle;
void WIENVME_load (char* module_path)
{
/*
int stat;
if (module_path == NULL)
VMEmodule = LoadExternalModule
("c:\\home\\CVI\\instr\\WIENVME_DLL\\pcivme_ni.lib");
else
VMEmodule = LoadExternalModule (module_path);
vme_init = GetExternalModuleAddr (VMEmodule, "VMEinit", &stat);
vme_read = GetExternalModuleAddr (VMEmodule, "VMEread", &stat);
vme_write = GetExternalModuleAddr (VMEmodule, "VMEwrite", &stat);
vme_reset = GetExternalModuleAddr (VMEmodule, "VMEreset", &stat);
vme_close = GetExternalModuleAddr (VMEmodule, "VMEclose", &stat);
*/
void WIENVME_load (char* module_path) {
/*
int stat;
 
if (module_path == NULL)
VMEmodule = LoadExternalModule
("c:\\home\\CVI\\instr\\WIENVME_DLL\\pcivme_ni.lib");
else
VMEmodule = LoadExternalModule (module_path);
 
vme_init = GetExternalModuleAddr (VMEmodule, "VMEinit", &stat);
vme_read = GetExternalModuleAddr (VMEmodule, "VMEread", &stat);
vme_write = GetExternalModuleAddr (VMEmodule, "VMEwrite", &stat);
vme_reset = GetExternalModuleAddr (VMEmodule, "VMEreset", &stat);
vme_close = GetExternalModuleAddr (VMEmodule, "VMEclose", &stat);
*/
if (module_path == NULL) {
DLLHandle = LoadLibrary("c:\\home\\CVI\\instr\\WIENVME_DLL\\pcivme_ni.lib");
} else {
65,10 → 66,10
DLLHandle = LoadLibrary(module_path);
}
if (!DLLHandle) {
printf ("\n\nFailed to Open libxxusb.dll \n");
return;
printf ("\n\nFailed to Open libxxusb.dll \n");
return;
}
 
vme_init = (void *) GetProcAddress (DLLHandle , "VMEinit");
vme_read = (void *) GetProcAddress (DLLHandle , "VMEread");
vme_write =(void *) GetProcAddress (DLLHandle , "VMEwrite");
79,26 → 80,24
}
 
int WIENVME_open (int* hHandle, unsigned char AddMod, char* device_name,
unsigned short module_number)
{
int result;
unsigned short module_number) {
int result;
 
/* open a path to a device. */
/* open a path to a device. */
if (device_name == NULL)
switch (GetCurrentPlatform ())
{
case 0:
switch (GetCurrentPlatform ()) {
case 0:
device_name = DEVICENAME_LINUX;
case 2:
break;
case 2:
device_name = DEVICENAME_9X;
break;
case 3:
break;
case 3:
device_name = DEVICENAME_NT;
break;
default:
break;
}
break;
default:
break;
}
result = VMEinit(device_name, module_number, AddMod, hHandle);
if (result) {
printf("Can't open interface \"%s\" to VMEMM-module \"%d\"!\n", DEVICENAME_NT, MODULE_NUMBER);
106,39 → 105,34
return(result);
}
 
int WIENVME_open24 (void)
{
int WIENVME_open24 (void) {
return (WIENVME_open (&hHandle24, Std_NoPriv_Data, NULL, 1));
}
 
int WIENVME_open32 (void)
{
int WIENVME_open32 (void) {
return (WIENVME_open (&hHandle32, Ext_NoPriv_Data, NULL, 1));
}
 
int WIENVME_start (char* module_path)
{
int WIENVME_start (char* module_path) {
WIENVME_load(module_path);
WIENVME_open24();
WIENVME_open32();
 
return 0;
}
 
void WIENVME_unload ()
{
void WIENVME_unload () {
//UnloadExternalModule (VMEmodule);
return;
}
 
int WIENVME_close (int hHandle)
{
int WIENVME_close (int hHandle) {
int result;
 
/* close the opened path */
/* close the opened path */
printf("hHandle %d\n",hHandle);
result = VMEclose(hHandle);
 
result = VMEclose(hHandle);
if (result) {
printf("Can't close interface!\n");
}
145,31 → 139,27
return (result);
}
 
int WIENVME_close24 ()
{
int WIENVME_close24 () {
return (WIENVME_close (hHandle24));
}
 
int WIENVME_close32 ()
{
int WIENVME_close32 () {
return (WIENVME_close (hHandle32));
}
 
int WIENVME_stop ()
{
int WIENVME_stop () {
WIENVME_close24();
WIENVME_close32();
WIENVME_unload();
 
return 0;
}
 
int WIENVME_reset ()
{
int WIENVME_reset () {
int result;
 
/* close the opened path */
result = VMEreset(hHandle24);
/* close the opened path */
result = VMEreset(hHandle24);
if (result) {
printf("Can't reset interface!\n");
}
176,11 → 166,10
return (result);
}
 
int WIENVME_read8 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int WIENVME_read8 (int hHandle, unsigned long n, unsigned long at, void* buff) {
int result;
 
/* D8 read */
/* D8 read */
result = VMEread(hHandle, at, 1, n, buff);
if (result) {
printf("D8 read at 0x%lX failed!\n", at);
189,11 → 178,10
return (result);
}
 
int WIENVME_read16 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int WIENVME_read16 (int hHandle, unsigned long n, unsigned long at, void* buff) {
int result;
 
/* D16 read */
/* D16 read */
result = VMEread(hHandle, at, 2, n, buff);
if (result) {
printf("D16 read at 0x%lX failed!\n", at);
202,11 → 190,10
return (result);
}
 
int WIENVME_read32 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int WIENVME_read32 (int hHandle, unsigned long n, unsigned long at, void* buff) {
int result;
 
/* D32 read */
/* D32 read */
result = VMEread(hHandle, at, 4, n, buff);
if (result) {
printf("D32 read at 0x%lX failed!\n", at);
215,11 → 202,10
return (result);
}
 
int WIENVME_write8 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int WIENVME_write8 (int hHandle, unsigned long n, unsigned long at, void* buff) {
int result;
 
/* D8 write */
/* D8 write */
result = VMEwrite(hHandle, at, 1, n, buff);
if (result) {
printf("D8 write at 0x%lX failed!\n", at);
227,11 → 213,10
return (result);
}
 
int WIENVME_write16 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int WIENVME_write16 (int hHandle, unsigned long n, unsigned long at, void* buff) {
int result;
 
/* D16 write */
/* D16 write */
result = VMEwrite(hHandle, at, 2, n, buff);
if (result) {
printf("D16 write at 0x%lX failed!\n", at);
239,11 → 224,10
return (result);
}
 
int WIENVME_write32 (int hHandle, unsigned long n, unsigned long at, void* buff)
{
int WIENVME_write32 (int hHandle, unsigned long n, unsigned long at, void* buff) {
int result;
 
/* D32 write */
/* D32 write */
result = VMEwrite(hHandle, at, 4, n, buff);
if (result) {
printf("D32 write at 0x%lX failed!\n", at);
260,69 → 244,89
#define VME_D32 0x4
#endif
 
short __stdcall WIENVME_VME_R( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data){
int hHandle=0, nb=0;
switch (AM){
case Ext_NoPriv_Data: hHandle = hHandle32; break;
case Std_NoPriv_Data: hHandle = hHandle24; break;
default : return 0;
}
short __stdcall WIENVME_VME_R( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data) {
int hHandle=0, nb=0;
switch (AM) {
case Ext_NoPriv_Data:
hHandle = hHandle32;
break;
case Std_NoPriv_Data:
hHandle = hHandle24;
break;
default :
return 0;
}
 
switch (DW){
case VME_D16: nb= WIENVME_read16 (hHandle, 1, (unsigned long) VME_Address, (void*) Data) ; break;
case VME_D32: nb= WIENVME_read32 (hHandle, 1, (unsigned long) VME_Address, (void*) Data) ; break;
default: return 0;
}
return nb;
}
 
short __stdcall WIENVME_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){
int hHandle=0, nb=0;
switch (AM){
case Ext_NoPriv_Data: hHandle = hHandle32; break;
case Std_NoPriv_Data: hHandle = hHandle24; break;
default : return 0;
}
switch (DW) {
case VME_D16:
nb= WIENVME_read16 (hHandle, 1, (unsigned long) VME_Address, (void*) Data) ;
break;
case VME_D32:
nb= WIENVME_read32 (hHandle, 1, (unsigned long) VME_Address, (void*) Data) ;
break;
 
switch (DW){
case VME_D16: nb= WIENVME_write16 (hHandle, 1, (unsigned long) VME_Address, (void*) &Data) ; break;
case VME_D32: nb= WIENVME_write32 (hHandle, 1, (unsigned long) VME_Address, (void*) &Data) ; break;
default: return 0;
}
return nb;
}
default:
return 0;
}
return nb;
}
 
short __stdcall WIENVME_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data){
short __stdcall WIENVME_VME_W( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data) {
int hHandle=0, nb=0;
switch (AM) {
case Ext_NoPriv_Data:
hHandle = hHandle32;
break;
case Std_NoPriv_Data:
hHandle = hHandle24;
break;
default :
return 0;
}
 
return WIENVME_VME_W( AM, DW, VME_Address, Data);
}
short __stdcall WIENVME_VME_MWRST( void ){
 
return 0;
}
short __stdcall WIENVME_VME_MWEXEC( void ){
switch (DW) {
case VME_D16:
nb= WIENVME_write16 (hHandle, 1, (unsigned long) VME_Address, (void*) &Data) ;
break;
case VME_D32:
nb= WIENVME_write32 (hHandle, 1, (unsigned long) VME_Address, (void*) &Data) ;
break;
 
return 0;
}
default:
return 0;
}
return nb;
}
 
short __stdcall WIENVME_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data){
short __stdcall WIENVME_VME_MW( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t Data) {
 
return WIENVME_VME_R( AM, DW, VME_Address, Data);
}
short __stdcall WIENVME_VME_MRRST( void ){
return WIENVME_VME_W( AM, DW, VME_Address, Data);
}
short __stdcall WIENVME_VME_MWRST( void ) {
 
return 0;
}
short __stdcall WIENVME_VME_MREXEC( uint32_t *Data ){
 
return 0;
}
return 0;
}
short __stdcall WIENVME_VME_MWEXEC( void ) {
 
 
return 0;
}
 
short __stdcall WIENVME_VME_MR( uint16_t AM, uint16_t DW, uint32_t VME_Address, uint32_t *Data) {
 
 
return WIENVME_VME_R( AM, DW, VME_Address, Data);
}
short __stdcall WIENVME_VME_MRRST( void ) {
 
 
return 0;
}
short __stdcall WIENVME_VME_MREXEC( uint32_t *Data ) {
 
 
return 0;
}