📄 vme_api.c
字号:
return (vme_set_master_endian_conversion (bus_handle, endian));}/***************************************************************************** * Get the state of hardware master window endian control register */int /* 0 on success, -1 on failure */vmeGetMEC (vme_endian_conversion_t * endian /* hardware endian control */ ){ return (vme_get_master_endian_conversion (bus_handle, (int *) endian));}/***************************************************************************** * Set the hardware slave window endian control register */int /* 0 on success, -1 on failure */vmeSetSEC (vme_endian_conversion_t endian /* hardware endian control */ ){ return (vme_set_slave_endian_conversion (bus_handle, endian));}/***************************************************************************** * Get the state of hardware slave window endian control register */int /* 0 on success, -1 on failure */vmeGetSEC (vme_endian_conversion_t * endian /* hardware endian control */ ){ return (vme_get_slave_endian_conversion (bus_handle, (int *) endian));}/***************************************************************************** * Assert a VMEbus sysreset */int /* 0 on success, -1 on failure */vmeSysreset (){ return (vme_sysreset (bus_handle));}/*============================================================================ * Get a pointer into a VMEbus master window conforming to the input parameters */void * /* Pointer to VMEbus master window, or NULL on error */vmeMapAddr (uint64_t addr, /* Address on the VMEbus */ unsigned long size, /* Minimum size of the window from addr */ vme_addr_mod_t am, /* VMEbus address modifier */ vme_dwidth_t dw /* Maximum data width supported by the window. All accesses to the bus will be made at this data width or smaller */ ){ vme_master_handle_t handle; int flags = VME_CTL_PWEN; void *ptr; /* The new Tundra Universe driver does not tolerate address modifiers with inconsistant data widths. i.e. The Universe chip generates MBLT cycles if the data width is 64-bit, whether you specified BLT's or not. For that reason, this function must fix the call parameters so old code does not fail this new check. */ switch (am) { case VME_A24UMB: case VME_A24SMB: case VME_A32UMB: case VME_A32SMB: dw = VME_D64; break; default: if (VME_D64 == dw) dw = VME_D32; } switch (dw) { case VME_D8: flags |= VME_CTL_MAX_DW_8; break; case VME_D16: flags |= VME_CTL_MAX_DW_16; break; case VME_D32: flags |= VME_CTL_MAX_DW_32; break; case VME_D64: flags |= VME_CTL_MAX_DW_64; break; } if (0 > vme_master_window_create (bus_handle, &handle, addr, am, size, flags, NULL)) return (NULL); ptr = vme_master_window_map (bus_handle, handle, 0); free (handle); return (ptr);}/*============================================================================ * Get a pointer to the base address of a VMEbus master window */void * /* Pointer to VMEbus master window, or NULL on error */vmeMapWindow (int winnum, /* Window number to map */ unsigned long size /* Size of the region to map */ ){ vme_master_handle_t handle; void *ptr; /* The window number is passed as the VMEbus address. We supply a dummy address modifier. The flag VME_CTL_LEGACY_WINNUM lets the driver know our intentions. */ if (0 > vme_master_window_create (bus_handle, &handle, winnum, VME_A32SD, size, VME_CTL_PWEN | VME_CTL_LEGACY_WINNUM, NULL)) return (NULL); ptr = vme_master_window_map (bus_handle, handle, 0); free (handle); return (ptr);}/*============================================================================ * Get a pointer to a VMEbus slave window conforming to the input parameters */void * /* Pointer to VMEbus slave memory, or NULL on error */vmeMapSlaveAddr (uint64_t addr, /* Address on the VMEbus */ unsigned long size, /* Minimum size of the window from addr */ vme_addr_mod_t am /* VMEbus address modifier */ ){ vme_slave_handle_t handle; int as; void *ptr; /* Convert the address modifier to an address space */ switch (0xF0 & am) { case 0x00: as = VME_A32; break; case 0x20: as = VME_A16; break; case 0x30: as = VME_A24; break; default: errno = EINVAL; return (NULL); } if (0 > vme_slave_window_create (bus_handle, &handle, addr, as, size, VME_CTL_PWEN | VME_CTL_PREN, NULL)) return (NULL); ptr = vme_slave_window_map (bus_handle, handle, 0); free (handle); return (ptr);}/*============================================================================ * Get a pointer to the base address of the VMEbus slave window */void * /* Pointer to VMEbus slave memory, or NULL on error */vmeMapSlaveWindow (int winnum, /* Window number to map */ unsigned long size /* Size of the region to map */ ){ vme_slave_handle_t handle; void *ptr; /* The window number is passed as the VMEbus address. We supply a dummy address modifier. The flag VME_CTL_LEGACY_WINNUM lets the driver know our intentions. */ if (0 > vme_slave_window_create (bus_handle, &handle, winnum, VME_A32SD, size, VME_CTL_PWEN | VME_CTL_PREN | VME_CTL_LEGACY_WINNUM, NULL)) return (NULL); ptr = vme_slave_window_map (bus_handle, handle, 0); free (handle); return (ptr);}/*============================================================================ * Allocate memory for DMA transfer. */void * /* Pointer the specified region, or NULL on failure */vmeAllocDmaBuff (vme_dma_handle_t * handle, /* Pointer to a handle for the allocated DMA memory */ unsigned long nbytes, /* Number of bytes to allocate and map */ int flags /* There are currently no flags defined, use 0 */ ){ if (0 > vme_dma_buffer_create (bus_handle, handle, nbytes, 0, NULL)) return (NULL); return (vme_dma_buffer_map (bus_handle, *handle, 0));}/*============================================================================ * Free allocated DMA memory. */int /* 0 on success -1 on failure */vmeFreeDmaBuff (vme_dma_handle_t * handle /* Pointer to a handle for the allocated DMA memory */ ){ int rval = 0; rval += vme_dma_buffer_unmap (bus_handle, *handle); rval += vme_dma_buffer_release (bus_handle, *handle); return ((rval) ? -1 : 0);}/*============================================================================ * Map in allocated DMA memory. */void * /* Pointer the specified region, or NULL on failure */vmeMapDmaBuff (vme_dma_handle_t handle, /* Handle to a DMA buffer allocated by vmeAllocDmaBuff */ uint32_t size, /* Size of the region to map. */ uint32_t offset /* Offset from the base of the DMA buffer to begin mapping. */ ){ return (vme_dma_buffer_map (bus_handle, handle, offset));}/*============================================================================ * Read data from the specified VMEbus address into the DMA buffer at offset */int /* Returns 0 on success or -1 on failure */vmeReadDma (vme_dma_handle_t handle, /* Handle to allocated DMA memory */ uint64_t addr, /* Address on the VMEbus to read from */ unsigned long nelem, /* Number of elements of data width sized elements to read. */ vme_addr_mod_t am, /* VMEbus address modifier */ vme_dwidth_t dw, /* Transfer data width */ unsigned long offset, /* Offset into the DMA buffer */ unsigned int flags, /* The following constants may be OR'ed together to control the DMA operation: - DMA_LD64EN - enable 64-bit PCI transactions One of the following settings of the VON counter: - DMA_VON_UNITL_DONE - DMA_VON_256BYTE - DMA_VON_512BYTE - DMA_VON_1024BYTE - DMA_VON_2048BYTE - DMA_VON_4096BYTES - DMA_VON_8192BYTES - DMA_VON_16384BYTES One of the following settings of the VOFF counter: - DMA_VOFF_0US - DMA_VOFF_16US - DMA_VOFF_32US - DMA_VOFF_64US - DMA_VOFF_128US - DMA_VOFF_256US
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -