00001 /* 00002 GNU GENERAL PUBLIC LICENSE 00003 Version 2, June 1991 00004 00005 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 00006 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00007 Everyone is permitted to copy and distribute verbatim copies 00008 of this license document, but changing it is not allowed. 00009 00010 Preamble 00011 00012 The licenses for most software are designed to take away your 00013 freedom to share and change it. By contrast, the GNU General Public 00014 License is intended to guarantee your freedom to share and change free 00015 software--to make sure the software is free for all its users. This 00016 General Public License applies to most of the Free Software 00017 Foundation's software and to any other program whose authors commit to 00018 using it. (Some other Free Software Foundation software is covered by 00019 the GNU Library General Public License instead.) You can apply it to 00020 your programs, too. 00021 00022 When we speak of free software, we are referring to freedom, not 00023 price. Our General Public Licenses are designed to make sure that you 00024 have the freedom to distribute copies of free software (and charge for 00025 this service if you wish), that you receive source code or can get it 00026 if you want it, that you can change the software or use pieces of it 00027 in new free programs; and that you know you can do these things. 00028 00029 To protect your rights, we need to make restrictions that forbid 00030 anyone to deny you these rights or to ask you to surrender the rights. 00031 These restrictions translate to certain responsibilities for you if you 00032 distribute copies of the software, or if you modify it. 00033 00034 For example, if you distribute copies of such a program, whether 00035 gratis or for a fee, you must give the recipients all the rights that 00036 you have. You must make sure that they, too, receive or can get the 00037 source code. And you must show them these terms so they know their 00038 rights. 00039 00040 We protect your rights with two steps: (1) copyright the software, and 00041 (2) offer you this license which gives you legal permission to copy, 00042 distribute and/or modify the software. 00043 00044 Also, for each author's protection and ours, we want to make certain 00045 that everyone understands that there is no warranty for this free 00046 software. If the software is modified by someone else and passed on, we 00047 want its recipients to know that what they have is not the original, so 00048 that any problems introduced by others will not reflect on the original 00049 authors' reputations. 00050 00051 Finally, any free program is threatened constantly by software 00052 patents. We wish to avoid the danger that redistributors of a free 00053 program will individually obtain patent licenses, in effect making the 00054 program proprietary. To prevent this, we have made it clear that any 00055 patent must be licensed for everyone's free use or not licensed at all. 00056 00057 The precise terms and conditions for copying, distribution and 00058 modification follow. 00059 00060 GNU GENERAL PUBLIC LICENSE 00061 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 00062 00063 0. This License applies to any program or other work which contains 00064 a notice placed by the copyright holder saying it may be distributed 00065 under the terms of this General Public License. The "Program", below, 00066 refers to any such program or work, and a "work based on the Program" 00067 means either the Program or any derivative work under copyright law: 00068 that is to say, a work containing the Program or a portion of it, 00069 either verbatim or with modifications and/or translated into another 00070 language. (Hereinafter, translation is included without limitation in 00071 the term "modification".) Each licensee is addressed as "you". 00072 00073 Activities other than copying, distribution and modification are not 00074 covered by this License; they are outside its scope. The act of 00075 running the Program is not restricted, and the output from the Program 00076 is covered only if its contents constitute a work based on the 00077 Program (independent of having been made by running the Program). 00078 Whether that is true depends on what the Program does. 00079 00080 1. You may copy and distribute verbatim copies of the Program's 00081 source code as you receive it, in any medium, provided that you 00082 conspicuously and appropriately publish on each copy an appropriate 00083 copyright notice and disclaimer of warranty; keep intact all the 00084 notices that refer to this License and to the absence of any warranty; 00085 and give any other recipients of the Program a copy of this License 00086 along with the Program. 00087 00088 You may charge a fee for the physical act of transferring a copy, and 00089 you may at your option offer warranty protection in exchange for a fee. 00090 00091 2. You may modify your copy or copies of the Program or any portion 00092 of it, thus forming a work based on the Program, and copy and 00093 distribute such modifications or work under the terms of Section 1 00094 above, provided that you also meet all of these conditions: 00095 00096 a) You must cause the modified files to carry prominent notices 00097 stating that you changed the files and the date of any change. 00098 00099 b) You must cause any work that you distribute or publish, that in 00100 whole or in part contains or is derived from the Program or any 00101 part thereof, to be licensed as a whole at no charge to all third 00102 parties under the terms of this License. 00103 00104 c) If the modified program normally reads commands interactively 00105 when run, you must cause it, when started running for such 00106 interactive use in the most ordinary way, to print or display an 00107 announcement including an appropriate copyright notice and a 00108 notice that there is no warranty (or else, saying that you provide 00109 a warranty) and that users may redistribute the program under 00110 these conditions, and telling the user how to view a copy of this 00111 License. (Exception: if the Program itself is interactive but 00112 does not normally print such an announcement, your work based on 00113 the Program is not required to print an announcement.) 00114 00115 These requirements apply to the modified work as a whole. If 00116 identifiable sections of that work are not derived from the Program, 00117 and can be reasonably considered independent and separate works in 00118 themselves, then this License, and its terms, do not apply to those 00119 sections when you distribute them as separate works. But when you 00120 distribute the same sections as part of a whole which is a work based 00121 on the Program, the distribution of the whole must be on the terms of 00122 this License, whose permissions for other licensees extend to the 00123 entire whole, and thus to each and every part regardless of who wrote it. 00124 00125 Thus, it is not the intent of this section to claim rights or contest 00126 your rights to work written entirely by you; rather, the intent is to 00127 exercise the right to control the distribution of derivative or 00128 collective works based on the Program. 00129 00130 In addition, mere aggregation of another work not based on the Program 00131 with the Program (or with a work based on the Program) on a volume of 00132 a storage or distribution medium does not bring the other work under 00133 the scope of this License. 00134 00135 3. You may copy and distribute the Program (or a work based on it, 00136 under Section 2) in object code or executable form under the terms of 00137 Sections 1 and 2 above provided that you also do one of the following: 00138 00139 a) Accompany it with the complete corresponding machine-readable 00140 source code, which must be distributed under the terms of Sections 00141 1 and 2 above on a medium customarily used for software interchange; or, 00142 00143 b) Accompany it with a written offer, valid for at least three 00144 years, to give any third party, for a charge no more than your 00145 cost of physically performing source distribution, a complete 00146 machine-readable copy of the corresponding source code, to be 00147 distributed under the terms of Sections 1 and 2 above on a medium 00148 customarily used for software interchange; or, 00149 00150 c) Accompany it with the information you received as to the offer 00151 to distribute corresponding source code. (This alternative is 00152 allowed only for noncommercial distribution and only if you 00153 received the program in object code or executable form with such 00154 an offer, in accord with Subsection b above.) 00155 00156 The source code for a work means the preferred form of the work for 00157 making modifications to it. For an executable work, complete source 00158 code means all the source code for all modules it contains, plus any 00159 associated interface definition files, plus the scripts used to 00160 control compilation and installation of the executable. However, as a 00161 special exception, the source code distributed need not include 00162 anything that is normally distributed (in either source or binary 00163 form) with the major components (compiler, kernel, and so on) of the 00164 operating system on which the executable runs, unless that component 00165 itself accompanies the executable. 00166 00167 If distribution of executable or object code is made by offering 00168 access to copy from a designated place, then offering equivalent 00169 access to copy the source code from the same place counts as 00170 distribution of the source code, even though third parties are not 00171 compelled to copy the source along with the object code. 00172 00173 4. You may not copy, modify, sublicense, or distribute the Program 00174 except as expressly provided under this License. Any attempt 00175 otherwise to copy, modify, sublicense or distribute the Program is 00176 void, and will automatically terminate your rights under this License. 00177 However, parties who have received copies, or rights, from you under 00178 this License will not have their licenses terminated so long as such 00179 parties remain in full compliance. 00180 00181 5. You are not required to accept this License, since you have not 00182 signed it. However, nothing else grants you permission to modify or 00183 distribute the Program or its derivative works. These actions are 00184 prohibited by law if you do not accept this License. Therefore, by 00185 modifying or distributing the Program (or any work based on the 00186 Program), you indicate your acceptance of this License to do so, and 00187 all its terms and conditions for copying, distributing or modifying 00188 the Program or works based on it. 00189 00190 6. Each time you redistribute the Program (or any work based on the 00191 Program), the recipient automatically receives a license from the 00192 original licensor to copy, distribute or modify the Program subject to 00193 these terms and conditions. You may not impose any further 00194 restrictions on the recipients' exercise of the rights granted herein. 00195 You are not responsible for enforcing compliance by third parties to 00196 this License. 00197 00198 7. If, as a consequence of a court judgment or allegation of patent 00199 infringement or for any other reason (not limited to patent issues), 00200 conditions are imposed on you (whether by court order, agreement or 00201 otherwise) that contradict the conditions of this License, they do not 00202 excuse you from the conditions of this License. If you cannot 00203 distribute so as to satisfy simultaneously your obligations under this 00204 License and any other pertinent obligations, then as a consequence you 00205 may not distribute the Program at all. For example, if a patent 00206 license would not permit royalty-free redistribution of the Program by 00207 all those who receive copies directly or indirectly through you, then 00208 the only way you could satisfy both it and this License would be to 00209 refrain entirely from distribution of the Program. 00210 00211 If any portion of this section is held invalid or unenforceable under 00212 any particular circumstance, the balance of the section is intended to 00213 apply and the section as a whole is intended to apply in other 00214 circumstances. 00215 00216 It is not the purpose of this section to induce you to infringe any 00217 patents or other property right claims or to contest validity of any 00218 such claims; this section has the sole purpose of protecting the 00219 integrity of the free software distribution system, which is 00220 implemented by public license practices. Many people have made 00221 generous contributions to the wide range of software distributed 00222 through that system in reliance on consistent application of that 00223 system; it is up to the author/donor to decide if he or she is willing 00224 to distribute software through any other system and a licensee cannot 00225 impose that choice. 00226 00227 This section is intended to make thoroughly clear what is believed to 00228 be a consequence of the rest of this License. 00229 00230 8. If the distribution and/or use of the Program is restricted in 00231 certain countries either by patents or by copyrighted interfaces, the 00232 original copyright holder who places the Program under this License 00233 may add an explicit geographical distribution limitation excluding 00234 those countries, so that distribution is permitted only in or among 00235 countries not thus excluded. In such case, this License incorporates 00236 the limitation as if written in the body of this License. 00237 00238 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 00239 00240 Each version is given a distinguishing version number. If the Program 00241 specifies a version number of this License which applies to it and "any 00242 later version", you have the option of following the terms and conditions 00243 either of that version or of any later version published by the Free Software 00244 Foundation. If the Program does not specify a version number of this License, 00245 you may choose any version ever published by the Free Software Foundation. 00246 00247 10. If you wish to incorporate parts of the Program into other free 00248 programs whose distribution conditions are different, write to the author to 00249 ask for permission. For software which is copyrighted by the Free Software 00250 Foundation, write to the Free Software Foundation; we sometimes make 00251 exceptions for this. Our decision will be guided by the two goals of 00252 preserving the free status of all derivatives of our free software and of 00253 promoting the sharing and reuse of software generally. 00254 00255 NO WARRANTY 00256 00257 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR 00258 THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 00259 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE 00260 THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 00261 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00262 FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND 00263 PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, 00264 YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 00265 00266 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 00267 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 00268 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 00269 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 00270 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO 00271 LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR 00272 THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 00273 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 00274 DAMAGES. 00275 00276 END OF TERMS AND CONDITIONS ' 00277 */ 00278 // #ifndef VMEMODULE_H 00279 // #define VMEMODULE_H 00280 00281 static const char* Copyright= "(C) Copyright Michigan State University 2002, All rights reserved";/* 00282 \class CVmeModule 00283 \file CVmeModule.cpp 00284 00285 Implements a Vme module object. CVmeModules have access to 00286 memory which is mapped via the mmap(3) system service using 00287 the CVME and CVMEptr objects. CVmeModules can write to and read 00288 from these registers using poke and peek operations, respectively. 00289 00290 Author: 00291 Jason Venema 00292 NSCL 00293 Michigan State University 00294 East Lansing, MI 48824-1321 00295 mailto: venemaja@msu.edu 00296 */ 00297 00298 #include <config.h> 00299 00300 #include "VmeModule.h" 00301 00302 #ifdef HAVE_WIENERVME_INTERFACE 00303 #include <CVMEInterface.h> 00304 #include <WienerAPI.h> 00305 #endif 00306 00307 #ifdef HAVE_WIENERUSBVME_INTERFACE 00308 #include <CVMEInterface.h> 00309 #include <WienerUSBVMEInterface.h> 00310 #endif 00311 00312 #include <string> 00313 00314 #ifdef HAVE_STD_NAMESPACE 00315 using namespace std; 00316 #endif 00317 00318 /* 00319 00320 The array below maps from address space selectors to CVME<UShort_t 00321 selectors or, in the caes of WienerVME controllers, the address modifier. 00322 00323 */ 00324 static const 00325 #if defined(HAVE_WIENERVME_INTERFACE) || defined (HAVE_WIENERUSBVME_INTERFACE) 00326 CVMEInterface::AddressMode AmodTable[] = { 00327 CVMEInterface::A16, 00328 CVMEInterface::A24, 00329 CVMEInterface::A24, 00330 CVMEInterface::A32, 00331 CVMEInterface::GEO 00332 }; 00333 #endif 00334 00335 #ifdef HAVE_SBSVME_INTERFACE 00336 CVME<UShort_t>::VmeSpace AmodTable[] = { 00337 CVME<UShort_t>::a16d16, 00338 CVME<UShort_t>::a24d16, 00339 CVME<UShort_t>::a24d32, 00340 CVME<UShort_t>::a32d32, 00341 CVME<UShort_t>::geo 00342 }; 00343 #endif 00344 /* 00345 \fn CVmeModule::CVmeModule(Space space, UInt_t base, UInt_t length) 00346 00347 Operation type: 00348 Basic constructor 00349 00350 Purpose: 00351 Contructs an object of type CVmeModule 00352 00353 \param Space space - the vme device to which we are mapping 00354 \param UInt_t base - the base address of the device 00355 \param UInt_t length - the length of the mapping (bytes) 00356 \param int nCrate - VME crate number. 00357 */ 00358 CVmeModule::CVmeModule(CVmeModule::Space space, UInt_t base, 00359 UInt_t length, int nCrate) 00360 #if defined(HAVE_WIENERVME_INTERFACE) || defined(HAVE_WIENERUSBVME_INTERFACE) 00361 : m_nSpace(space), 00362 m_nBase(base), 00363 m_nLength(length), 00364 m_nCrate(nCrate), 00365 m_pDriver(0) 00366 #endif 00367 { 00368 #if defined(HAVE_WIENERVME_INTERFACE) || defined(HAVE_WIENERUSBVME_INTERFACE) 00369 m_pDriver = CVMEInterface::Open(AmodTable[space], m_nCrate); 00370 #else 00371 try { 00372 switch(space) { 00373 case a16d16: 00374 m_CVME = CVME<UShort_t>(CVME<UShort_t>::a16d16, base, length, nCrate); 00375 break; 00376 case a24d16: 00377 m_CVME = CVME<UShort_t>(CVME<UShort_t>::a24d16, base, length, nCrate); 00378 break; 00379 case a24d32: 00380 m_CVME = CVME<UShort_t>(CVME<UShort_t>::a24d32, base, length, nCrate); 00381 break; 00382 case a32d32: 00383 m_CVME = CVME<UShort_t>(CVME<UShort_t>::a32d32, base, length, nCrate); 00384 break; 00385 case geo: 00386 m_CVME = CVME<UShort_t>(CVME<UShort_t>::geo, base, length); 00387 break; 00388 default: 00389 throw 1; // Force the catch below to complain. 00390 } 00391 } 00392 catch(int i) { 00393 throw string("Invalid address space in CVMEModule constructor"); 00394 } 00395 #endif 00396 } 00397 00398 00399 /* 00400 \fn CVmeModule::CVmeModule(const CVmeModule& aCVmeModule) 00401 00402 Operation Type: 00403 Copy contructor 00404 00405 Purpose: 00406 Constructs this by copying the attributes of its parameter 00407 00408 \param const CVmeModule& aCVmeModule - a CVmeModule from which 00409 to contrust this 00410 */ 00411 CVmeModule::CVmeModule(const CVmeModule& aCVmeModule) 00412 { 00413 00414 CopyToMe(aCVmeModule); 00415 } 00416 00417 /* 00418 \fn CVmeModule& CVmeModule::operator=(const CVmeModule& aCVmeModule) 00419 00420 Operation Type: 00421 operator= Assignment operator 00422 00423 Purpose: 00424 Assigns this object the same attributes as another CVmeModule object 00425 00426 \param const CVmeModule& aCVmeModule - the CVmeModule to copy from 00427 */ 00428 CVmeModule& 00429 CVmeModule::operator=(const CVmeModule& aCVmeModule) 00430 { 00431 if(this == &aCVmeModule) return *this; 00432 00433 CopyToMe(aCVmeModule); 00434 return *this; 00435 } 00436 00437 /* 00438 \fn int CVmeModule::operator== (const CVmeModule& aCVmeModule) 00439 00440 Operation Type: 00441 operator== Eqaulity operator 00442 00443 Purpose: 00444 Determine if this object is equal to its parameter 00445 00446 \param const CVmeModule& aCVmeModule - the CVmeModule with which to compare 00447 */ 00448 int 00449 CVmeModule::operator== (const CVmeModule& aCVmeModule) 00450 { 00451 #if defined(HAVE_WIENERVME_INTERFACE) || defined(HAVE_WIENERUSBVME_INTERFACE) 00452 return ((m_nSpace == aCVmeModule.m_nSpace) && 00453 (m_nBase == aCVmeModule.m_nBase) && 00454 (m_nLength== aCVmeModule.m_nLength) && 00455 (m_nCrate == aCVmeModule.m_nCrate)); 00456 #else 00457 return (m_CVME == aCVmeModule.m_CVME); 00458 #endif 00459 } 00460 00461 /* 00462 \fn UChar_t CVmeModule::peekb(UInt_t offset=0) 00463 00464 Operation Type: 00465 Accessor 00466 00467 Purpose: 00468 Reads byte from m_CVME at current offset + offset, which is 00469 defaulted to 0. Throws an exception if the read is out of bounds. 00470 00471 \param UInt_t offset - the offset from which to read (or the current offset 00472 if not specified. 00473 */ 00474 UChar_t 00475 CVmeModule::peekb(UInt_t offset) 00476 { 00477 #ifdef HAVE_WIENERVME_INTERFACE 00478 UChar_t byte; 00479 WienerVMEInterface::ReadBytes(m_pDriver, 00480 m_nBase + offset, 00481 &byte, 1); 00482 return byte; 00483 #endif 00484 #ifdef HAVE_WIENERUSBVME_INTERFACE 00485 UChar_t byte; 00486 WienerUSBVMEInterface::ReadBytes(m_pDriver, 00487 m_nBase + offset, 00488 &byte, 1); 00489 return byte; 00490 #endif 00491 #ifdef HAVE_VME_MAPPING 00492 return (UChar_t)((m_CVME.asChar())[offset]); 00493 #endif 00494 } 00495 00496 /* 00497 \fn UShort_t CVmeModule::peekw(UInt_t offset=0) 00498 00499 Operation Type: 00500 Accessor 00501 00502 Purpose: 00503 Reads word from m_CVME at current offset + offset, which is 00504 defaulted to 0. Throws an exception if the read is out of bounds. 00505 00506 \param UInt_t offset - the offset from which to read (or current offset 00507 if unspecified. 00508 */ 00509 UShort_t 00510 CVmeModule::peekw(UInt_t offset) 00511 { 00512 #ifdef HAVE_WIENERVME_INTERFACE 00513 UShort_t word; 00514 WienerVMEInterface::ReadWords(m_pDriver, 00515 m_nBase + offset * sizeof(UShort_t), 00516 &word, 1); 00517 return word; 00518 #endif 00519 00520 #ifdef HAVE_WIENERUSBVME_INTERFACE 00521 UShort_t word; 00522 WienerUSBVMEInterface::ReadWords(m_pDriver, 00523 m_nBase + offset * sizeof(UShort_t), 00524 &word, 1); 00525 return word; 00526 #endif 00527 00528 #ifdef HAVE_VME_MAPPING 00529 volatile UShort_t* c = (m_CVME.asShort()); 00530 return (UShort_t)(c[offset]); 00531 #endif 00532 } 00533 00534 /* 00535 \fn ULong_t CVmeModule::peekl(UInt_t offset=0) 00536 00537 Operation Type: 00538 Accessor 00539 00540 Purpose: 00541 Reads longword from m_CVME at current offset + offset, which is 00542 defaulted to 0. Throws an exception if the read is out of bounds. 00543 00544 \param UInt_t offset - the offset from which to read (reads from current 00545 offset if this is unspecified). 00546 */ 00547 ULong_t 00548 CVmeModule::peekl(UInt_t offset) 00549 { 00550 #ifdef HAVE_WIENERVME_INTERFACE 00551 ULong_t lword; 00552 WienerVMEInterface::ReadLongs(m_pDriver, 00553 m_nBase + offset * sizeof(UInt_t), 00554 &lword, 1); 00555 return lword; 00556 #endif 00557 00558 #ifdef HAVE_WIENERUSBVME_INTERFACE 00559 ULong_t lword; 00560 WienerUSBVMEInterface::ReadLongs(m_pDriver, 00561 m_nBase + offset * sizeof(UInt_t), 00562 &lword, 1); 00563 return lword; 00564 #endif 00565 00566 #ifdef HAVE_VME_MAPPING 00567 return (ULong_t)((m_CVME.asLong())[offset]); 00568 #endif 00569 } 00570 00571 /* 00572 \fn void CVmeModule::pokeb(UChar_t byte, UInt_t nOffset) 00573 00574 Operation Type: 00575 Mutator 00576 00577 Purpose: 00578 Writes the specified byte to the specified offset in the module. 00579 Throws an exception if the specified offset is out of range. 00580 00581 \param UChar_t byte - the byte to write into the memory map 00582 UInt_t offset - the offset at which to write the byte. 00583 */ 00584 void 00585 CVmeModule::pokeb(UChar_t byte, UInt_t nOffset) 00586 { 00587 #ifdef HAVE_WIENERVME_INTERFACE 00588 WienerVMEInterface::WriteBytes(m_pDriver, m_nBase + nOffset, 00589 &byte, 1); 00590 #endif 00591 00592 #ifdef HAVE_WIENERUSBVME_INTERFACE 00593 WienerUSBVMEInterface::WriteBytes(m_pDriver, m_nBase + nOffset, 00594 &byte, 1); 00595 #endif 00596 00597 #ifdef HAVE_VME_MAPPING 00598 (m_CVME.asChar())[nOffset] = byte; 00599 #endif 00600 } 00601 00602 /* 00603 \fn void CVmeModule::pokew(UShort_t word, UInt_t nOffset) 00604 00605 Operation Type: 00606 Mutator 00607 00608 Purpose: 00609 Writes the specified word to the specified offset in the module. 00610 Throws an exception if the specified offset is out of range. 00611 00612 \param UChar_t word - the word to write into the memory map 00613 UInt_t offset - the offset at which to write the word. 00614 */ 00615 void 00616 CVmeModule::pokew(UShort_t word, UInt_t nOffset) 00617 { 00618 #ifdef HAVE_WIENERVME_INTERFACE 00619 WienerVMEInterface::WriteWords(m_pDriver, 00620 m_nBase + nOffset*sizeof(UShort_t), 00621 &word, 1); 00622 #endif 00623 00624 #ifdef HAVE_WIENERUSBVME_INTERFACE 00625 WienerUSBVMEInterface::WriteWords(m_pDriver, 00626 m_nBase + nOffset*sizeof(UShort_t), 00627 &word, 1); 00628 #endif 00629 00630 #ifdef HAVE_VME_MAPPING 00631 (m_CVME.asShort())[nOffset] = word; 00632 #endif 00633 } 00634 00635 /* 00636 \fn void CVmeModule::pokel(UChar_t lword, UInt_t nOffset) 00637 00638 Operation Type: 00639 Mutator 00640 00641 Purpose: 00642 Writes the specified long word to the specified offset in the module. 00643 Throws an exception if the specified offset is out of range. 00644 00645 \param UChar_t long word - the long word to write into the memory map 00646 UInt_t offset - the offset at which to write the long word. 00647 */ 00648 void 00649 CVmeModule::pokel(ULong_t lword, UInt_t nOffset) 00650 { 00651 #ifdef HAVE_WIENERVME_INTERFACE 00652 WienerVMEInterface::WriteLongs(m_pDriver, 00653 m_nBase + nOffset * sizeof(ULong_t), 00654 &lword, 1); 00655 #endif 00656 00657 #ifdef HAVE_WIENERUSBVME_INTERFACE 00658 WienerUSBVMEInterface::WriteLongs(m_pDriver, 00659 m_nBase + nOffset * sizeof(ULong_t), 00660 &lword, 1); 00661 #endif 00662 00663 #ifdef HAVE_VME_MAPPING 00664 (m_CVME.asLong())[nOffset] = lword; 00665 #endif 00666 } 00670 void 00671 CVmeModule::CopyToMe(const CVmeModule& rModule) 00672 { 00673 #if defined(HAVE_WIENERVME_INTERFACE) || defined(HAVE_WIENERUSBVME_INTERFACE) 00674 m_nSpace = rModule.m_nSpace; 00675 m_nBase = rModule.m_nBase; 00676 m_nLength= rModule.m_nLength; 00677 m_nCrate = rModule.m_nCrate; 00678 m_pDriver= (rModule.m_pDriver); 00679 #endif 00680 #ifdef HAVE_VME_MAPPING 00681 m_CVME = rModule.m_CVME; 00682 #endif 00683 } 00684 00685 00707 UInt_t 00708 CVmeModule::readl(void* pBuffer, UInt_t nOffset, size_t longs) 00709 { 00710 #ifdef HAVE_VME_MAPPING 00711 ULong_t* pSource = (ULong_t*)m_CVME.asLong() + nOffset; 00712 ULong_t* pDest = (ULong_t*)pBuffer; 00713 for(UInt_t i =0; i < longs; i++) { // memcpy is not ensured to be long transfers. 00714 *pDest++ = *pSource++; 00715 } 00716 return longs; 00717 #endif 00718 00719 #ifdef HAVE_WIENERVME_INTERFACE 00720 return WienerVMEInterface::ReadLongs(m_pDriver, 00721 m_nBase + nOffset*sizeof(ULong_t), 00722 pBuffer, longs); 00723 #endif 00724 00725 #ifdef HAVE_WIENERUSBVME_INTERFACE 00726 return WienerUSBVMEInterface::ReadLongs(m_pDriver, 00727 m_nBase + nOffset*sizeof(ULong_t), 00728 pBuffer, longs); 00729 #endif 00730 00731 } 00732 00754 UInt_t 00755 CVmeModule::readw(void* pBuffer, UInt_t nOffset, size_t words) 00756 { 00757 #ifdef HAVE_VME_MAPPING 00758 UShort_t* pSource = (UShort_t*)m_CVME.asShort() + nOffset; 00759 UShort_t* pDest = (UShort_t*)pBuffer; 00760 for(UInt_t i =0; i < words; i++) { // memcpy is not ensured to be word transfers. 00761 *pDest++ = *pSource++; 00762 } 00763 return words; 00764 #endif 00765 #ifdef HAVE_WIENERVME_INTERFACE 00766 return WienerVMEInterface::ReadWords(m_pDriver, 00767 m_nBase + nOffset*sizeof(UShort_t), 00768 pBuffer, words); 00769 #endif 00770 #ifdef HAVE_WIENERUSBVME_INTERFACE 00771 return WienerUSBVMEInterface::ReadWords(m_pDriver, 00772 m_nBase + nOffset*sizeof(UShort_t), 00773 pBuffer, words); 00774 #endif 00775 } 00776 00798 UInt_t 00799 CVmeModule::readb(void* pBuffer, UInt_t nOffset, size_t bytes) 00800 { 00801 #ifdef HAVE_VME_MAPPING 00802 UChar_t* pSource = (UChar_t*)m_CVME.asChar() + nOffset; 00803 UChar_t* pDest = (UChar_t*)pBuffer; 00804 for(UInt_t i =0; i < bytes; i++) { // memcpy is not ensured to be long transfers. 00805 *pDest++ = *pSource++; 00806 } 00807 return bytes; 00808 #endif 00809 #ifdef HAVE_WIENERVME_INTERFACE 00810 return WienerVMEInterface::ReadBytes(m_pDriver, 00811 m_nBase + nOffset, 00812 pBuffer, bytes); 00813 #endif 00814 00815 #ifdef HAVE_WIENERUSBVME_INTERFACE 00816 return WienerUSBVMEInterface::ReadBytes(m_pDriver, 00817 m_nBase + nOffset, 00818 pBuffer, bytes); 00819 #endif 00820 00821 00822 } 00823 00824 00825 00826 // #endif