Subversion Repositories f9daq

Rev

Rev 14 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 362
Line 153... Line 153...
153
    }
153
    }
154
 
154
 
155
    return 0;
155
    return 0;
156
}
156
}
157
 
157
 
158
int VMEopen(const char *cszDeviceName, unsigned char ubAddressModifier, int *pnHandle)
158
int VMEopen(const char *cszDeviceName, unsigned char ubAddressModifier, ptrdiff_t  *pnHandle)
159
{
159
{
160
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)NULL;
160
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)NULL;
161
    int error;
161
    int error;
162
 
162
 
163
    *pnHandle = 0;
163
    *pnHandle = 0;
Line 175... Line 175...
175
        free(dev);
175
        free(dev);
176
        return error;
176
        return error;
177
    }
177
    }
178
 
178
 
179
    dev->cAddressModifier = ubAddressModifier;
179
    dev->cAddressModifier = ubAddressModifier;
180
    *pnHandle             = (int)dev;
180
    *pnHandle             = (ptrdiff_t)dev;
181
 
181
 
182
    error = initHardware(dev);
182
    error = initHardware(dev);
183
    if (error)
183
    if (error)
184
        return error;
184
        return error;
185
 
185
 
186
    dev->nLastError = 0;
186
    dev->nLastError = 0;
187
 
187
 
188
    return setAccessProperties(*pnHandle, dev->cAddressModifier, BYTE_ACCESS); // set access properties to default
188
    return setAccessProperties(*pnHandle, dev->cAddressModifier, BYTE_ACCESS); // set access properties to default
189
}
189
}
190
 
190
 
191
int VMEinit(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle)
191
int VMEinit(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, ptrdiff_t *pnHandle)
192
{
192
{
193
    char *szLocalDeviceName = szDeviceName(cszDeviceName, nVMEMM);
193
    char *szLocalDeviceName = szDeviceName(cszDeviceName, nVMEMM);
194
 
194
 
195
    return VMEopen(szLocalDeviceName, ubAddressModifier, pnHandle);
195
    return VMEopen(szLocalDeviceName, ubAddressModifier, pnHandle);
196
}
196
}
197
 
197
 
198
int setAccessProperties(int nHandle, unsigned char bModifier, unsigned char bAccessType)
198
int setAccessProperties(ptrdiff_t nHandle, unsigned char bModifier, unsigned char bAccessType)
199
{
199
{
200
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
200
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
201
 
201
 
202
    PCIVME_ACCESS_COMMAND access_command;
202
    PCIVME_ACCESS_COMMAND access_command;
203
               
203
               
Line 216... Line 216...
216
    dev->cAccessWidth     = bAccessType;
216
    dev->cAccessWidth     = bAccessType;
217
 
217
 
218
    return 0;
218
    return 0;
219
}
219
}
220
 
220
 
221
int VMEread(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
221
int VMEread(ptrdiff_t nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
222
{
222
{
223
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
223
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
224
    size_t count      = (size_t)(ulElementCount * ubAccessWidth);
224
    size_t count      = (size_t)(ulElementCount * ubAccessWidth);
225
    ssize_t result;
225
    ssize_t result;
226
    int error;
226
    int error;
Line 261... Line 261...
261
    }
261
    }
262
 
262
 
263
    return 0;
263
    return 0;
264
}
264
}
265
 
265
 
266
int VMEwrite(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
266
int VMEwrite(ptrdiff_t nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
267
{
267
{
268
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
268
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
269
    size_t count      = (size_t)(ulElementCount * ubAccessWidth);
269
    size_t count      = (size_t)(ulElementCount * ubAccessWidth);
270
    ssize_t result;
270
    ssize_t result;
271
    int error;
271
    int error;
Line 305... Line 305...
305
    }
305
    }
306
 
306
 
307
    return 0;
307
    return 0;
308
}
308
}
309
 
309
 
310
int VMEaccessVIC(int nHandle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent)
310
int VMEaccessVIC(ptrdiff_t nHandle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent)
311
{
311
{
312
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
312
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
313
    PCIVME_VIC68A_ACTION vic68a_action;
313
    PCIVME_VIC68A_ACTION vic68a_action;
314
 
314
 
315
    vic68a_action.bAccessMode      = ubAccessMode;
315
    vic68a_action.bAccessMode      = ubAccessMode;
Line 325... Line 325...
325
    *ubContent = vic68a_action.bContent;
325
    *ubContent = vic68a_action.bContent;
326
 
326
 
327
    return 0;
327
    return 0;
328
}
328
}
329
 
329
 
330
int VMEreset(int nHandle)
330
int VMEreset(ptrdiff_t nHandle)
331
{
331
{
332
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
332
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
333
    PCIVME_RESET_COMMAND reset_command;
333
    PCIVME_RESET_COMMAND reset_command;
334
    int i = 10;
334
    int i = 10;
335
 
335
 
Line 361... Line 361...
361
    dev->nLastError = 0;
361
    dev->nLastError = 0;
362
 
362
 
363
    return 0;
363
    return 0;
364
}
364
}
365
 
365
 
366
int VMETAS(int nHandle, unsigned long ulAddress, unsigned char *ubResult)
366
int VMETAS(ptrdiff_t nHandle, unsigned long ulAddress, unsigned char *ubResult)
367
{
367
{
368
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
368
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
369
    PCIVME_TAS_STRUCT tas;
369
    PCIVME_TAS_STRUCT tas;
370
 
370
 
371
    tas.bContent  = *ubResult;
371
    tas.bContent  = *ubResult;
Line 381... Line 381...
381
    *ubResult = tas.bContent;
381
    *ubResult = tas.bContent;
382
 
382
 
383
    return 0;
383
    return 0;
384
}
384
}
385
 
385
 
386
int VMEinterrupt(int nHandle, unsigned char *ubVector)
386
int VMEinterrupt(ptrdiff_t nHandle, unsigned char *ubVector)
387
{
387
{
388
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
388
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
389
        PCIVME_VECTOR_LEVEL ubLocalVector;
389
        PCIVME_VECTOR_LEVEL ubLocalVector;
390
 
390
 
391
    if (ioctl(dev->nFileNo, PCIVME_READ_VECTOR_POLL, &ubLocalVector) < 0)
391
    if (ioctl(dev->nFileNo, PCIVME_READ_VECTOR_POLL, &ubLocalVector) < 0)
Line 397... Line 397...
397
    *ubVector = (__u8)ubLocalVector.dwStatusID;
397
    *ubVector = (__u8)ubLocalVector.dwStatusID;
398
 
398
 
399
    return 0;
399
    return 0;
400
}
400
}
401
 
401
 
402
int VMEsysfailGet(int nHandle, BOOLEAN *bResult)
402
int VMEsysfailGet(ptrdiff_t nHandle, BOOLEAN *bResult)
403
{
403
{
404
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
404
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
405
        PCIVME_VIC68A_ACTION sAction;    // structure to access vic chip
405
        PCIVME_VIC68A_ACTION sAction;    // structure to access vic chip
406
 
406
 
407
        sAction.wRegisterAddress = EGICR;
407
        sAction.wRegisterAddress = EGICR;
Line 417... Line 417...
417
        *bResult = (sAction.bContent & 0x08) ? FALSE : TRUE;
417
        *bResult = (sAction.bContent & 0x08) ? FALSE : TRUE;
418
 
418
 
419
    return 0;
419
    return 0;
420
}
420
}
421
 
421
 
422
int VMEsysfailSet(int nHandle, BOOLEAN bForce)
422
int VMEsysfailSet(ptrdiff_t nHandle, BOOLEAN bForce)
423
{
423
{
424
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
424
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
425
        PCIVME_VIC68A_ACTION sAction;    // structure to access vic chip
425
        PCIVME_VIC68A_ACTION sAction;    // structure to access vic chip
426
 
426
 
427
        sAction.wRegisterAddress = ICR7;
427
        sAction.wRegisterAddress = ICR7;
Line 435... Line 435...
435
    }
435
    }
436
 
436
 
437
    return 0;
437
    return 0;
438
}
438
}
439
 
439
 
440
int VMEerror(int nHandle)
440
int VMEerror(ptrdiff_t nHandle)
441
{
441
{
442
    __u8 ubVector;
442
    __u8 ubVector;
443
 
443
 
444
    VMEinterrupt(nHandle, &ubVector);
444
    VMEinterrupt(nHandle, &ubVector);
445
 
445
 
Line 447... Line 447...
447
        return EFAULT;  // it's a bus error
447
        return EFAULT;  // it's a bus error
448
    else
448
    else
449
        return 0;
449
        return 0;
450
}
450
}
451
 
451
 
452
int VMEclose(int nHandle)
452
int VMEclose(ptrdiff_t nHandle)
453
{
453
{
454
    int error = 0;
454
    int error = 0;
455
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
455
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
456
 
456
 
457
    if (dev != (VMEMM_DEVICE *)NULL)
457
    if (dev != (VMEMM_DEVICE *)NULL)
Line 467... Line 467...
467
    }
467
    }
468
 
468
 
469
    return error;
469
    return error;
470
}
470
}
471
 
471
 
472
int VMEcontrolInterrupt(int nHandle, BOOLEAN *bEnable)
472
int VMEcontrolInterrupt(ptrdiff_t nHandle, BOOLEAN *bEnable)
473
{
473
{
474
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
474
    VMEMM_DEVICE *dev = (VMEMM_DEVICE *)nHandle;
475
        PCIVME_IRQ_CONTROL  control;
475
        PCIVME_IRQ_CONTROL  control;
476
 
476
 
477
    control.bEnable = *bEnable;
477
    control.bEnable = *bEnable;
Line 486... Line 486...
486
    *bEnable = control.bEnable;
486
    *bEnable = control.bEnable;
487
 
487
 
488
    return 0;
488
    return 0;
489
}
489
}
490
 
490
 
491
int GetLastError(int nHandle)
491
int GetLastError(ptrdiff_t nHandle)
492
{
492
{
493
    VMEMM_DEVICE *dev  = (VMEMM_DEVICE *)nHandle;
493
    VMEMM_DEVICE *dev  = (VMEMM_DEVICE *)nHandle;
494
    int nLocalError;
494
    int nLocalError;
495
 
495
 
496
    nLocalError = dev->nLastError;
496
    nLocalError = dev->nLastError;