⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vme_api.c

📁 universeII驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
/*===============================================================================                            COPYRIGHT NOTICE    Copyright (C) 2002 VMIC    International Copyright Secured.  All Rights Reserved.-------------------------------------------------------------------------------Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:   o Redistributions of source code must retain the above copyright notice, this     list of conditions and the following disclaimer.   o Redistributions in binary form must reproduce the above copyright notice,     this list of conditions and the following disclaimer in the documentation     and/or other materials provided with the distribution.   o Neither the name of VMIC nor the names of its contributors may be used to     endorse or promote products derived from this software without specific     prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ONANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.===============================================================================*/ /* Notes on the implementation of the legacy VMEbus interface:    We create and map resources here, but since the Linux 2.x driver did not    dynamically allocate resources, the API provided no way to free the    resources.  The resource will continue to exist until the application exits.    The driver knows to free all resources granted to a process when vmeTerm()    is called, or when the process terminates.  */#include <fcntl.h>#include <errno.h>#include <stdlib.h>#include <unistd.h>#include <linux/stddef.h>#include <sys/mman.h>#include <vmic/vme_api.h>#define UNIVERSE_DEVICE  "/dev/bus/vme/ctl"static vme_interrupt_handle_t interrupt[UNIV_IRQS] = { 0 };static vme_bus_handle_t bus_handle;/*============================================================================ * Initialize the VMEbus driver interface */int                             /* Returns 0 on success or -1 on failure */vmeInit (){  return (vme_init (&bus_handle));}/*============================================================================ * Cleanup the VMEbus driver interface */int                             /* Returns a positive int on success or -1                                    on failure */vmeTerm (){  return (vme_term (bus_handle));}/***************************************************************************** * Set the number of retries before the PCI master interface signals an error */int                             /* 0 on success, -1 on failure */vmeSetMaxRetry (int maxrtry     /* Number of retry attempts. This value must                                   be a multiple of 64 between the                                   values of 0 and 960. The value 0                                   means retry forever */  ){  return (vme_set_max_retry (bus_handle, maxrtry));}/***************************************************************************** * Get the number of retries before the PCI master interface signals an error */int                             /* 0 on success, -1 on failure */vmeGetMaxRetry (int *maxrtry /* Number of retry attempts */ ){  return (vme_get_max_retry (bus_handle, maxrtry));}/***************************************************************************** * Set the transfer count at which the PCI slave channel posted write FIFO * gives up the VMEbus master interface */int                             /* 0 on success, -1 on failure */vmeSetPostedWriteCount (vme_posted_write_count_t pwon /* Transfer count */ ){  return (vme_set_posted_write_count (bus_handle, pwon));}/***************************************************************************** * Set the transfer count at which the PCI slave channel posted write FIFO * gives up the VMEbus master interface */int                             /* 0 on success, -1 on failure */vmeGetPostedWriteCount (vme_posted_write_count_t * pwon /* Transfer count */ ){  return (vme_get_posted_write_count (bus_handle, (int *) pwon));}/***************************************************************************** * Set the VMEbus request level */int                             /* 0 on success, -1 on failure */vmeSetBusRequestLevel (vme_bus_request_level_t br_level /* VMEbus request                                                           level */  ){  return (vme_set_bus_request_level (bus_handle, br_level));}/***************************************************************************** * Get the VMEbus request level */int                             /* 0 on success, -1 on failure */vmeGetBusRequestLevel (vme_bus_request_level_t * br_level       /* VMEbus                                                                   request                                                                   level */  ){  return (vme_get_bus_request_level (bus_handle, (int *) br_level));}/***************************************************************************** * Set the VMEbus request mode */int                             /* 0 on success, -1 on failure */vmeSetBusRequestMode (vme_bus_request_mode_t br_mode    /* VMEbus request                                                           mode */  ){  return (vme_set_bus_request_mode (bus_handle, br_mode));}/***************************************************************************** * Get the VMEbus request mode */int                             /* 0 on success, -1 on failure */vmeGetBusRequestMode (vme_bus_request_mode_t * br_mode  /* VMEbus request                                                           mode */  ){  return (vme_get_bus_request_mode (bus_handle, (int *) br_mode));}/***************************************************************************** * Set the VMEbus release mode */int                             /* 0 on success, -1 on failure */vmeSetBusReleaseMode (vme_bus_release_mode_t br_mode    /* VMEbus release                                                           mode */  ){  return (vme_set_bus_release_mode (bus_handle, br_mode));}/***************************************************************************** * Get the VMEbus release mode */int                             /* 0 on success, -1 on failure */vmeGetBusReleaseMode (vme_bus_release_mode_t * br_mode  /* VMEbus release                                                            mode */  ){  return (vme_get_bus_release_mode (bus_handle, (int *) br_mode));}/***************************************************************************** * Set the state of VMEbus ownership */int                             /* 0 on success, -1 on failure */vmeSetVown (vme_vown_t vown /* VMEbus ownership state */ ){  if (vown)    return (vme_acquire_bus_ownership (bus_handle));  else    return (vme_release_bus_ownership (bus_handle));}/***************************************************************************** * Get the state of VMEbus ownership */int                             /* 0 on success, -1 on failure */vmeGetVown (vme_vown_t * vown /* VMEbus ownership state */ ){  return (vme_get_bus_ownership (bus_handle, (int *) vown));}/***************************************************************************** * Set the VMEbus timeout value */int                             /* 0 on success, -1 on failure */vmeSetBusTimeout (vme_bus_timeout_t to /* VMEbus timeout value */ ){  return (vme_set_bus_timeout (bus_handle, to));}/***************************************************************************** * Get the VMEbus timeout value */int                             /* 0 on success, -1 on failure */vmeGetBusTimeout (vme_bus_timeout_t * to /* VMEbus timeout value */ ){  return (vme_get_bus_timeout (bus_handle, (int *) to));}/***************************************************************************** * Set the VMEbus arbitration mode */int                             /* 0 on success, -1 on failure */vmeSetBusArbitrationMode (vme_bus_arbitration_mode_t arb_mode   /* VMEbus                                                                   arbitration                                                                   mode */  ){  return (vme_set_arbitration_mode (bus_handle, arb_mode));}/***************************************************************************** * Get the VMEbus arbitration mode */int                             /* 0 on success, -1 on failure */vmeGetBusArbitrationMode (vme_bus_arbitration_mode_t * arb_mode /* VMEbus                                                                   arbitration                                                                   mode */  ){  return (vme_get_arbitration_mode (bus_handle, (int *) arb_mode));}/***************************************************************************** * Set the VMEbus arbitration timeout value */int                             /* 0 on success, -1 on failure */vmeSetBusArbitrationTimeout (vme_bus_arbitration_timeout_t to   /* VMEbus                                                                   arbitration                                                                   timeout */  ){  return (vme_set_arbitration_timeout (bus_handle, to));}/***************************************************************************** * Get the VMEbus arbitration timeout value */int                             /* 0 on success, -1 on failure */vmeGetBusArbitrationTimeout (vme_bus_arbitration_timeout_t * to /* VMEbus                                                                   arbitration                                                                   timeout */  ){  return (vme_get_arbitration_timeout (bus_handle, (int *) to));}/***************************************************************************** * Set the hardware master window endian control register */int                             /* 0 on success, -1 on failure */vmeSetMEC (vme_endian_conversion_t endian /* hardware endian control */ ){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -