Go to the source code of this file.
Data Structures | |
struct | VME_TABLE |
Defines | |
#define | _GNU_SOURCE 1 |
#define | MAX_VME_SLOTS 7 |
Functions | |
static int | gefvme_openWindow (MVME_INTERFACE *mvme, int am, mvme_addr_t vme_addr, mvme_size_t n_bytes, int *pwindow, char **paddr) |
static int | gefvme_mapcheck (MVME_INTERFACE *mvme, mvme_addr_t vme_addr, mvme_size_t n_bytes, int *pfd, int *poffset, char **paddr) |
char * | gefvme_get_a16 (MVME_INTERFACE *mvme) |
char * | gefvme_get_a24 (MVME_INTERFACE *mvme) |
char * | gefvme_get_a32 (MVME_INTERFACE *mvme, uint32_t vmeaddr, int size) |
static int | makeDmaPacket (vmeDmaPacket_t *pkt, int blt_mode, int am, uint32_t vme_addr, char *dst_addr, int nbytes) |
static int | runDma (int channel, vmeDmaPacket_t *pkt) |
void | gefvme_set_dma_debug (int debug) |
void | gefvme_set_dma_channel (int channel) |
int | gefvme_read_dma_multiple (MVME_INTERFACE *mvme, int nseg, void *dstaddr[], const mvme_addr_t vmeaddr[], int nbytes[]) |
int | mvme_open (MVME_INTERFACE **mvme, int index) |
int | mvme_close (MVME_INTERFACE *mvme) |
int | mvme_sysreset (MVME_INTERFACE *mvme) |
int | gefvme_read_dma (MVME_INTERFACE *mvme, void *dst, mvme_addr_t vme_addr, int n_bytes) |
int | mvme_read (MVME_INTERFACE *mvme, void *dst, mvme_addr_t vme_addr, mvme_size_t n_bytes) |
DWORD | mvme_read_value (MVME_INTERFACE *mvme, mvme_addr_t vme_addr) |
int | mvme_write (MVME_INTERFACE *mvme, mvme_addr_t vme_addr, void *src, mvme_size_t n_bytes) |
int | mvme_write_value (MVME_INTERFACE *mvme, mvme_addr_t vme_addr, DWORD value) |
int | mvme_set_am (MVME_INTERFACE *mvme, int am) |
int EXPRT | mvme_get_am (MVME_INTERFACE *mvme, int *am) |
int | mvme_set_dmode (MVME_INTERFACE *mvme, int dmode) |
int | mvme_get_dmode (MVME_INTERFACE *mvme, int *dmode) |
int | mvme_set_blt (MVME_INTERFACE *mvme, int mode) |
int | mvme_get_blt (MVME_INTERFACE *mvme, int *mode) |
int | mvme_interrupt_generate (MVME_INTERFACE *mvme, int level, int vector, void *info) |
int | mvme_interrupt_attach (MVME_INTERFACE *mvme, int level, int vector, void(*isr)(int, void *, void *), void *info) |
int | mvme_interrupt_detach (MVME_INTERFACE *mvme, int level, int vector, void *info) |
int | mvme_interrupt_enable (MVME_INTERFACE *mvme, int level, int vector, void *info) |
int | mvme_interrupt_disable (MVME_INTERFACE *mvme, int level, int vector, void *info) |
Variables | |
int | gefvme_dma_debug = 0 |
int | gefvme_dma_channel = 0 |
#define MAX_VME_SLOTS 7 |
Definition at line 32 of file gefvme.c.
Referenced by gefvme_mapcheck(), gefvme_openWindow(), mvme_close(), mvme_open(), and vmic_mmap().
char* gefvme_get_a16 | ( | MVME_INTERFACE * | mvme | ) |
return pointer to memory-mapped VME A16 address space
Definition at line 266 of file gefvme.c.
00267 { 00268 char* addr; 00269 int status = gefvme_openWindow(mvme, MVME_AM_A16, 0, 0x10000, NULL, &addr); 00270 if (status != MVME_SUCCESS) 00271 return NULL; 00272 return addr; 00273 }
char* gefvme_get_a24 | ( | MVME_INTERFACE * | mvme | ) |
return pointer to memory-mapped VME A24 address space
Definition at line 275 of file gefvme.c.
00276 { 00277 char* addr; 00278 int status = gefvme_openWindow(mvme, MVME_AM_A24, 0, 0x1000000, NULL, &addr); 00279 if (status != MVME_SUCCESS) 00280 return NULL; 00281 return addr; 00282 }
char* gefvme_get_a32 | ( | MVME_INTERFACE * | mvme, | |
uint32_t | vmeaddr, | |||
int | size | |||
) |
Definition at line 284 of file gefvme.c.
00285 { 00286 char* addr; 00287 int status = gefvme_openWindow(mvme, MVME_AM_A32, vmeaddr, size, NULL, &addr); 00288 if (status != MVME_SUCCESS) 00289 return NULL; 00290 return addr; 00291 }
static int gefvme_mapcheck | ( | MVME_INTERFACE * | mvme, | |
mvme_addr_t | vme_addr, | |||
mvme_size_t | n_bytes, | |||
int * | pfd, | |||
int * | poffset, | |||
char ** | paddr | |||
) | [static] |
Retrieve mapped address from mapped table. Check if the given address belongs to an existing map. If not will create a new map based on the address, current address modifier and the given size in bytes.
*mvme | VME structure | |
nbytes | requested transfer size. |
Definition at line 226 of file gefvme.c.
Referenced by mvme_read(), mvme_read_value(), and mvme_write_value().
00227 { 00228 int status; 00229 int j; 00230 VME_TABLE *table; 00231 table = (VME_TABLE *) mvme->table; 00232 00233 /* Look for existing mapping */ 00234 00235 for (j=0; j<MAX_VME_SLOTS; j++) 00236 if (table[j].valid) { /* Check for the proper am */ 00237 if (mvme->am != table[j].am) 00238 continue; 00239 /* Check the vme address range */ 00240 if ((vme_addr >= table[j].low) && ((vme_addr+n_bytes) < table[j].high)) { 00241 /* valid range */ 00242 break; 00243 } 00244 } 00245 00246 /* Create a new mapping if needed */ 00247 00248 if (j>=MAX_VME_SLOTS) { 00249 status = gefvme_openWindow(mvme, mvme->am, vme_addr, n_bytes, &j, NULL); 00250 if (status != MVME_SUCCESS) 00251 return status; 00252 } 00253 00254 if (pfd) 00255 *pfd = table[j].handle; 00256 if (poffset) 00257 *poffset = vme_addr - table[j].low; 00258 if (paddr) 00259 *paddr = table[j].addr; 00260 00261 return MVME_SUCCESS; 00262 }
static int gefvme_openWindow | ( | MVME_INTERFACE * | mvme, | |
int | am, | |||
mvme_addr_t | vme_addr, | |||
mvme_size_t | n_bytes, | |||
int * | pwindow, | |||
char ** | paddr | |||
) | [static] |
VME Memory map, uses the driver MVME_INTERFACE for storing the map information.
*mvme | VME structure | |
vme_addr | source address (VME location). | |
n_bytes | data to write |
Definition at line 52 of file gefvme.c.
Referenced by gefvme_get_a16(), gefvme_get_a24(), gefvme_get_a32(), and gefvme_mapcheck().
00053 { 00054 int j; 00055 VME_TABLE *table; 00056 char devname[256]; 00057 int fd; 00058 struct vmeOutWindowCfg conf; 00059 int status; 00060 char* amode = "(unknown)"; 00061 00062 table = (VME_TABLE *) mvme->table; 00063 00064 if (1) 00065 { 00066 /* Find new slot */ 00067 for (j=0; j<MAX_VME_SLOTS; j++) 00068 if (!table[j].valid) 00069 { 00070 /* Create a new window */ 00071 00072 sprintf(devname, "/dev/vme_m%d", j); 00073 fd = open(devname, O_RDWR); 00074 if (fd < 0) { 00075 if (errno == ENXIO) { 00076 fprintf(stderr,"gefvme_openWindow: VME driver not present: Cannot open VME device \'%s\', errno %d (%s)\n", devname, errno, strerror(errno)); 00077 exit(1); 00078 } 00079 if (errno != EBUSY) 00080 fprintf(stderr,"gefvme_openWindow: Cannot open VME device \'%s\', errno %d (%s)\n", devname, errno, strerror(errno)); 00081 continue; 00082 } 00083 00084 break; 00085 } 00086 } 00087 else 00088 { 00089 // always use slot 0 00090 00091 j = 2; 00092 00093 fd = table[j].handle; 00094 00095 if (!table[j].valid) 00096 { 00097 /* Create a new window */ 00098 00099 sprintf(devname, "/dev/vme_m%d", j); 00100 fd = open(devname, O_RDWR); 00101 assert(fd >= 0); 00102 } 00103 } 00104 00105 printf("gefvme_openWindow: Slot %d, VME addr 0x%08x, am 0x%02x, size 0x%08x %d\n", j, vme_addr, table[j].am, n_bytes, n_bytes); 00106 00107 if (j >= MAX_VME_SLOTS) { 00108 /* No more slot available */ 00109 fprintf(stderr,"gefvme_openWindow: All VME slots are in use!\n"); 00110 assert(!"Cannot continue!\n"); 00111 return MVME_ACCESS_ERROR; 00112 } 00113 00114 table[j].am = ((am == 0) ? MVME_AM_DEFAULT : am); 00115 table[j].handle = fd; 00116 00117 memset(&conf, 0, sizeof(conf)); 00118 00119 switch (table[j].am) 00120 { 00121 default: 00122 fprintf(stderr,"gefvme_openWindow: Do not know how to handle VME AM 0x%x\n", table[j].am); 00123 abort(); 00124 return MVME_ACCESS_ERROR; 00125 case MVME_AM_A16_SD: 00126 case MVME_AM_A16_ND: 00127 vme_addr = 0; 00128 n_bytes = (1<<16); 00129 conf.addrSpace = VME_A16; /* Address Space */ 00130 conf.userAccessType = VME_USER; /* User/Supervisor Access Type */ 00131 conf.dataAccessType = VME_DATA; /* Data/Program Access Type */ 00132 amode = "A16"; 00133 break; 00134 case MVME_AM_A24: 00135 case MVME_AM_A24_ND: 00136 vme_addr = 0; 00137 n_bytes = (1<<24); 00138 conf.addrSpace = VME_A24; /* Address Space */ 00139 conf.userAccessType = VME_USER; /* User/Supervisor Access Type */ 00140 conf.dataAccessType = VME_DATA; /* Data/Program Access Type */ 00141 amode = "A24"; 00142 break; 00143 case MVME_AM_A32_ND: 00144 case MVME_AM_A32_SD: 00145 //n_bytes = 0x01000000; 00146 n_bytes = 0x00800000; 00147 { 00148 char* env = getenv("GEFVME_A32_SIZE"); 00149 if (env) 00150 { 00151 n_bytes = strtoul(env, NULL, 0); 00152 fprintf(stderr,"gefvme: A32 window size set to 0x%x\n", n_bytes); 00153 } 00154 } 00155 vme_addr = vme_addr - vme_addr%n_bytes; 00156 conf.addrSpace = VME_A32; /* Address Space */ 00157 conf.userAccessType = VME_USER; /* User/Supervisor Access Type */ 00158 conf.dataAccessType = VME_DATA; /* Data/Program Access Type */ 00159 amode = "A32"; 00160 break; 00161 } 00162 00163 table[j].low = vme_addr; 00164 table[j].nbytes = n_bytes; 00165 00166 table[j].addr = NULL; 00167 00168 conf.windowNbr = j; /* Window Number */ 00169 conf.windowEnable = 1; /* State of Window */ 00170 conf.pciBusAddrU = 0; /* Start Address on the PCI Bus */ 00171 conf.pciBusAddrL = 0; /* Start Address on the PCI Bus */ 00172 conf.windowSizeU = 0; /* Window Size */ 00173 conf.windowSizeL = n_bytes; /* Window Size */ 00174 conf.xlatedAddrU = 0; /* Starting Address on the VMEbus */ 00175 conf.xlatedAddrL = vme_addr; /* Starting Address on the VMEbus */ 00176 conf.bcastSelect2esst = 0; /* 2eSST Broadcast Select */ 00177 conf.wrPostEnable = 0; /* Write Post State */ 00178 conf.prefetchEnable = 0; /* Prefetch Read Enable State */ 00179 conf.prefetchSize = 0; /* Prefetch Read Size (in Cache Lines) */ 00180 conf.xferRate2esst = VME_SSTNONE; /* 2eSST Transfer Rate */ 00181 conf.maxDataWidth = VME_D32; /* Maximum Data Width */ 00182 conf.xferProtocol = 0; // VME_SCT; /* Transfer Protocol */ 00183 conf.reserved = 0; /* For future use */ 00184 00185 status = ioctl(fd, VME_IOCTL_SET_OUTBOUND, &conf); 00186 if (status != 0) { 00187 fprintf(stderr,"gefvme_openWindow: cannot VME_IOCTL_SET_OUTBOUND, errno %d (%s)\n", errno, strerror(errno)); 00188 abort(); 00189 return MVME_ACCESS_ERROR; 00190 } 00191 00192 void* addr = mmap(NULL, n_bytes, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 00193 00194 if (addr == (void*)(-1)) { 00195 fprintf(stderr,"gefvme_openWindow: cannot mmap() VME address space, errno %d (%s)\n", errno, strerror(errno)); 00196 abort(); 00197 return MVME_ACCESS_ERROR; 00198 } 00199 00200 table[j].addr = addr; 00201 00202 fprintf(stderr, "gefvme_openWindow: Configured window %d VME AM 0x%02x %s addr 0x%08x size 0x%08x fd %d\n", j, table[j].am, amode, (int)vme_addr, (int)n_bytes, table[j].handle); 00203 00204 table[j].valid = 1; 00205 table[j].high = (table[j].low + table[j].nbytes); 00206 00207 if (pwindow) 00208 *pwindow = j; 00209 00210 if (paddr) 00211 *paddr = addr; 00212 00213 return MVME_SUCCESS; 00214 }
int gefvme_read_dma | ( | MVME_INTERFACE * | mvme, | |
void * | dst, | |||
mvme_addr_t | vme_addr, | |||
int | n_bytes | |||
) |
run a single dma read operation. (note: data read through the tsi148 will have the wrong endianness and has to be byte-swapped by the user)
Definition at line 564 of file gefvme.c.
Referenced by mvme_read().
00565 { 00566 int i; 00567 vmeDmaPacket_t vmeDma; 00568 char* ptr; 00569 int xerrno; 00570 int bytesRead; 00571 00572 makeDmaPacket(&vmeDma, mvme->blt_mode, mvme->am, vme_addr, dst, n_bytes); 00573 xerrno = runDma(gefvme_dma_channel, &vmeDma); 00574 00575 if (0) 00576 { 00577 uint32_t *ptr = (uint32_t*)dst; 00578 int i; 00579 printf("dst %p\n", dst); 00580 for (i=0; i<10; i++) 00581 printf("dst[%d] = 0x%08x\n", i, ptr[i]); 00582 } 00583 00584 if (0) 00585 { 00586 printf("mvme_read_dma: DMA status:\n"); 00587 printf(" requested %d bytes\n", n_bytes); 00588 printf(" vmeDmaToken: %d\n", vmeDma.vmeDmaToken); 00589 printf(" vmeDmaWait: %d\n", vmeDma.vmeDmaWait); 00590 printf(" vmeDmaStartTick: %d\n", vmeDma.vmeDmaStartTick); 00591 printf(" vmeDmaStopTick: %d\n", vmeDma.vmeDmaStopTick); 00592 printf(" vmeDmaElapsedTime: %d\n", vmeDma.vmeDmaElapsedTime); 00593 printf(" vmeDmaStatus: %d\n", vmeDma.vmeDmaStatus); 00594 printf(" byte count: %d\n", vmeDma.byteCount); 00595 //assert(!"Crash here!"); 00596 } 00597 00598 bytesRead = vmeDma.srcAddr - vme_addr; 00599 00600 //printf("mvme_read_dma: DMA %6d of %6d bytes from 0x%08x, status 0x%08x, byteCount %d, srcAddr 0x%08x, dstAddr 0x%08x\n", n_bytes, bytesRead, vme_addr, vmeDma.vmeDmaStatus, vmeDma.byteCount, vmeDma.srcAddr, vmeDma.dstAddr); 00601 00602 if (xerrno < 0) { 00603 fprintf(stderr,"gefvme_read_dma: ioctl(VME_IOCTL_START_DMA) errno %d (%s)\n", -xerrno, strerror(-xerrno)); 00604 return MVME_ACCESS_ERROR; 00605 } 00606 00607 if (vmeDma.vmeDmaStatus != 0x02000000) { 00608 //*((uint32_t*)dst) = 0xdeadbeef; 00609 printf("mvme_read_dma: DMA error, read %6d out of %6d bytes from 0x%08x, status 0x%08x, srcAddr 0x%08x, dstAddr 0x%08x\n", bytesRead, n_bytes, vme_addr, vmeDma.vmeDmaStatus, vmeDma.srcAddr, vmeDma.dstAddr); 00610 fprintf(stderr,"mvme_read_dma: ioctl(VME_IOCTL_START_DMA) returned vmeDmaStatus 0x%08x\n", vmeDma.vmeDmaStatus); 00611 return MVME_ACCESS_ERROR; 00612 } 00613 00614 if (bytesRead!=0 && bytesRead!=n_bytes) { 00615 printf("mvme_read_dma: DMA %6d of %6d bytes from 0x%08x, status 0x%08x, srcAddr 0x%08x, dstAddr 0x%08x\n", n_bytes, bytesRead, vme_addr, vmeDma.vmeDmaStatus, vmeDma.srcAddr, vmeDma.dstAddr); 00616 fprintf(stderr,"mvme_read_dma: ioctl(VME_IOCTL_START_DMA) returned byteCount %d while requested read of %d bytes\n", bytesRead, n_bytes); 00617 return MVME_ACCESS_ERROR; 00618 } 00619 00620 if (0) 00621 { 00622 int i; 00623 uint32_t *p32 = (uint32_t*)dst; 00624 for (i=0; i<10; i++) 00625 printf("dma at %d is 0x%08x\n", i, p32[i]); 00626 } 00627 00628 ptr = (char*)dst; 00629 for (i=0; i<n_bytes; i+=4) { 00630 char tmp; 00631 tmp = ptr[i+0]; 00632 ptr[i+0] = ptr[i+3]; 00633 ptr[i+3] = tmp; 00634 tmp = ptr[i+1]; 00635 ptr[i+1] = ptr[i+2]; 00636 ptr[i+2] = tmp; 00637 } 00638 00639 return MVME_SUCCESS; 00640 }
int gefvme_read_dma_multiple | ( | MVME_INTERFACE * | mvme, | |
int | nseg, | |||
void * | dstaddr[], | |||
const mvme_addr_t | vmeaddr[], | |||
int | nbytes[] | |||
) |
run a chained dma read operation: each dma segment has it's own vme source address, length and memory destination address. (note: data read through the tsi148 will have the wrong endianness and has to be byte-swapped by the user)
Definition at line 418 of file gefvme.c.
00419 { 00420 int i; 00421 int xerrno; 00422 vmeDmaPacket_t pkt[nseg]; 00423 for (i=0; i<nseg; i++) 00424 { 00425 if (gefvme_dma_debug) 00426 printf("packet %p+%d, blt %d, am 0x%x, vmeaddr 0x%x, dstaddr %p, nbytes %d\n", pkt+i, sizeof(vmeDmaPacket_t), mvme->blt_mode, mvme->am, vmeaddr[i], dstaddr[i], nbytes[i]); 00427 makeDmaPacket(pkt+i, mvme->blt_mode, mvme->am, vmeaddr[i], dstaddr[i], nbytes[i]); 00428 pkt[i].pNextPacket = pkt+i+1; 00429 } 00430 pkt[nseg-1].pNextPacket = NULL; 00431 00432 xerrno = runDma(gefvme_dma_channel, pkt); 00433 00434 if (xerrno < 0) { 00435 fprintf(stderr,"gefvme_read_dma_multiple: ioctl(VME_IOCTL_START_DMA) errno %d (%s)\n", -xerrno, strerror(-xerrno)); 00436 return MVME_ACCESS_ERROR; 00437 } 00438 00439 if (pkt[0].vmeDmaStatus != 0x02000000) { 00440 fprintf(stderr,"mvme_read_dma_multiple: ioctl(VME_IOCTL_START_DMA) returned vmeDmaStatus 0x%08x\n", pkt[0].vmeDmaStatus); 00441 return MVME_ACCESS_ERROR; 00442 } 00443 00444 return MVME_SUCCESS; 00445 }
void gefvme_set_dma_channel | ( | int | channel | ) |
void gefvme_set_dma_debug | ( | int | debug | ) |
set gefvme DMA debug level: 0=off, >0=write more and more stuff into the system log
Definition at line 407 of file gefvme.c.
00408 { 00409 gefvme_dma_debug = debug; 00410 }
static int makeDmaPacket | ( | vmeDmaPacket_t * | pkt, | |
int | blt_mode, | |||
int | am, | |||
uint32_t | vme_addr, | |||
char * | dst_addr, | |||
int | nbytes | |||
) | [static] |
Definition at line 295 of file gefvme.c.
Referenced by gefvme_read_dma(), and gefvme_read_dma_multiple().
00296 { 00297 00298 memset(pkt, 0, sizeof(*pkt)); 00299 00300 pkt->maxPciBlockSize = 16*1024; 00301 pkt->maxVmeBlockSize = 16*1024; 00302 pkt->byteCount = nbytes; 00303 pkt->srcBus = VME_DMA_VME; 00304 pkt->srcAddr = vme_addr; 00305 pkt->srcAddrU = 0; // limited to A24 and A32. No A64, please! 00306 00307 switch (blt_mode) 00308 { 00309 case MVME_BLT_BLT32: 00310 assert(vme_addr%4 == 0); 00311 assert(nbytes%4 == 0); 00312 pkt->srcVmeAttr.maxDataWidth = VME_D32; 00313 pkt->srcVmeAttr.xferProtocol = VME_BLT; 00314 break; 00315 case MVME_BLT_MBLT64: 00316 case MVME_AM_A24_SMBLT: 00317 case MVME_AM_A24_NMBLT: 00318 case MVME_AM_A32_SMBLT: 00319 case MVME_AM_A32_NMBLT: 00320 assert(vme_addr%8 == 0); 00321 assert(nbytes%8 == 0); 00322 //pkt->srcVmeAttr.maxDataWidth = VME_D64; 00323 pkt->srcVmeAttr.maxDataWidth = VME_D32; 00324 pkt->srcVmeAttr.xferProtocol = VME_MBLT; 00325 break; 00326 default: 00327 fprintf(stderr,"makeDmaPacket: Unknown mvme->blt_mode DMA mode %d\n", blt_mode); 00328 assert(!"makeDmaPacket: Unknown DMA mode!"); 00329 } 00330 00331 switch (am) 00332 { 00333 default: 00334 fprintf(stderr,"makeDmaPacket: Unknown mvme->am VMA AM 0x%x\n", am); 00335 assert(!"makeDmaPacket: Unknown VME AM DMA mode!"); 00336 return MVME_ACCESS_ERROR; 00337 case MVME_AM_A24: 00338 case MVME_AM_A24_ND: 00339 case MVME_AM_A24_SMBLT: 00340 case MVME_AM_A24_NMBLT: 00341 pkt->srcVmeAttr.addrSpace = VME_A24; 00342 break; 00343 case MVME_AM_A32_ND: 00344 case MVME_AM_A32_SD: 00345 case MVME_AM_A32_SMBLT: 00346 case MVME_AM_A32_NMBLT: 00347 pkt->srcVmeAttr.addrSpace = VME_A32; 00348 break; 00349 } 00350 00351 //pkt->srcVmeAttr.userAccessType = VME_SUPER; 00352 pkt->srcVmeAttr.userAccessType = VME_USER; 00353 pkt->srcVmeAttr.dataAccessType = VME_DATA; 00354 pkt->dstBus = VME_DMA_USER; 00355 if (sizeof(dst_addr) == sizeof(uint32_t)) 00356 { 00357 /* 32-bit addresses */ 00358 pkt->dstAddr = (uint32_t)dst_addr; 00359 pkt->dstAddrU = 0; 00360 } 00361 else 00362 { 00363 /* 64-bit addresses */ 00364 pkt->dstAddr = 0xFFFFFFFF & ((uint64_t)dst_addr); 00365 pkt->dstAddrU = 0xFFFFFFFF & ((uint64_t)dst_addr)>>32; 00366 } 00367 00368 //printf("dst_addr: %p, addrL: 0x%08x, addrU: 0x%08x\n", dst_addr, pkt->dstAddr, pkt->dstAddrU); 00369 00370 pkt->dstVmeAttr.maxDataWidth = 0; 00371 pkt->dstVmeAttr.addrSpace = 0; 00372 pkt->dstVmeAttr.userAccessType = 0; 00373 pkt->dstVmeAttr.dataAccessType = 0; 00374 pkt->dstVmeAttr.xferProtocol = 0; 00375 00376 pkt->vmeDmaStatus = gefvme_dma_debug; 00377 00378 return MVME_SUCCESS; 00379 }
int mvme_write_value | ( | MVME_INTERFACE * | mvme, | |
mvme_addr_t | vme_addr, | |||
DWORD | value | |||
) |
Write single data to VME bus.
*mvme | VME structure | |
vme_addr | destination address (VME location). | |
value | data to write to the VME address. |
Definition at line 906 of file gefvme.c.
00907 { 00908 int status, fd, offset; 00909 char* addr; 00910 00911 status = gefvme_mapcheck(mvme, vme_addr, 4, &fd, &offset, &addr); 00912 if (status != MVME_SUCCESS) 00913 return status; 00914 00915 #if 1 00916 addr += offset; 00917 00918 /* Perform write */ 00919 if (mvme->dmode == MVME_DMODE_D8) 00920 *((char *)addr) = (char) (value & 0xFF); 00921 else if (mvme->dmode == MVME_DMODE_D16) { 00922 unsigned char buf[2]; 00923 buf[1] = value & 0xFF; 00924 buf[0] = value >> 8; 00925 *((WORD *)addr) = *(WORD*) buf; 00926 } 00927 else if (mvme->dmode == MVME_DMODE_D32) { 00928 unsigned char buf[4]; 00929 buf[3] = value; 00930 buf[2] = value >> 8; 00931 buf[1] = value >> 16; 00932 buf[0] = value >> 24; 00933 *((DWORD *)addr) = *(DWORD*) buf; 00934 } 00935 #else 00936 /* Perform read */ 00937 if (mvme->dmode == MVME_DMODE_D8) { 00938 status = pwrite(fd, &value, 1, offset); 00939 } else if (mvme->dmode == MVME_DMODE_D16) { 00940 char buf[2]; 00941 buf[0] = (value&0xff00) >> 8; 00942 buf[1] = (value&0xff); 00943 status = pwrite(fd, buf, 2, offset); 00944 } else if (mvme->dmode == MVME_DMODE_D32) { 00945 char buf[4]; 00946 buf[0] = (value&0xff000000) >> 24; 00947 buf[1] = (value&0xff0000) >> 16; 00948 buf[2] = (value&0xff00) >> 8; 00949 buf[3] = (value&0xff); 00950 status = pwrite(fd, buf, 4, offset); 00951 } 00952 #endif 00953 00954 return MVME_SUCCESS; 00955 }
static int runDma | ( | int | channel, | |
vmeDmaPacket_t * | pkt | |||
) | [static] |
Definition at line 381 of file gefvme.c.
Referenced by gefvme_read_dma(), and gefvme_read_dma_multiple().
00382 { 00383 char devnode[256]; 00384 int status, fd, xerrno; 00385 00386 sprintf(devnode, "/dev/vme_dma%d", channel); 00387 fd = open(devnode, 0); 00388 if (fd < 0) { 00389 fprintf(stderr,"gefvme::runDma: Cannot open VME device \'%s\', errno %d (%s)\n", devnode, errno, strerror(errno)); 00390 return -errno; 00391 } 00392 00393 errno = 0; 00394 status = ioctl(fd, VME_IOCTL_START_DMA, pkt); 00395 xerrno = errno; 00396 00397 close(fd); 00398 00399 if (status < 0) 00400 return -xerrno; 00401 00402 return 0; 00403 }
int gefvme_dma_channel = 0 |
Definition at line 405 of file gefvme.c.
Referenced by gefvme_read_dma(), gefvme_read_dma_multiple(), and gefvme_set_dma_channel().
int gefvme_dma_debug = 0 |
Definition at line 293 of file gefvme.c.
Referenced by gefvme_read_dma_multiple(), gefvme_set_dma_debug(), and makeDmaPacket().