From 838d63ab59134ce56a960f8eb25e4bde569cbf2b Mon Sep 17 00:00:00 2001 From: Pavel Cheblakov Date: Thu, 5 Aug 2010 16:27:02 +0700 Subject: [PATCH] Initial commit from http://www.inp.nsk.su/~tararysh/docs_and_soft/pci/IPS6/index.htm (2010-08-05) - newlines converted from win to unix - cleaned building garbage and binary files --- COPYING | 504 ++++++++++++++++++ Makefile | 23 + camt.c | 296 +++++++++++ doc/IPS(v_1).doc | Bin 0 -> 54784 bytes doc/ppi6camac.html | 1119 +++++++++++++++++++++++++++++++++++++++ doc/ppi6camac_foot.html | 25 + doc/ppi6camac_toc.html | 57 ++ doc/readme_pci.koi8 | 60 +++ k0607.h | 15 + lsi6.h | 43 ++ lsi6_lib.c | 233 ++++++++ lsi6_lib.h | 12 + lsi6_main.c | 527 ++++++++++++++++++ lsi6camac.h | 153 ++++++ makedevices | 24 + reload | 4 + tests/Makefile | 42 ++ tests/c0609.c | 72 +++ tests/c0612.c | 99 ++++ tests/catch_lam.c | 52 ++ tests/indicator.c | 58 ++ tests/naf.c | 43 ++ tests/read_block.c | 65 +++ tests/rw_count2.c | 80 +++ tests/rw_count3.c | 80 +++ tests/smi.c | 136 +++++ tests/start | 2 + tests/write_block.c | 60 +++ 28 files changed, 3884 insertions(+) create mode 100644 COPYING create mode 100644 Makefile create mode 100644 camt.c create mode 100644 doc/IPS(v_1).doc create mode 100644 doc/ppi6camac.html create mode 100644 doc/ppi6camac_foot.html create mode 100644 doc/ppi6camac_toc.html create mode 100644 doc/readme_pci.koi8 create mode 100644 k0607.h create mode 100644 lsi6.h create mode 100644 lsi6_lib.c create mode 100644 lsi6_lib.h create mode 100644 lsi6_main.c create mode 100644 lsi6camac.h create mode 100644 makedevices create mode 100644 reload create mode 100644 tests/Makefile create mode 100644 tests/c0609.c create mode 100644 tests/c0612.c create mode 100644 tests/catch_lam.c create mode 100644 tests/indicator.c create mode 100644 tests/naf.c create mode 100644 tests/read_block.c create mode 100644 tests/rw_count2.c create mode 100644 tests/rw_count3.c create mode 100644 tests/smi.c create mode 100644 tests/start create mode 100644 tests/write_block.c diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..223ede7 --- /dev/null +++ b/COPYING @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser 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. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..92e5296 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +KGCC=gcc + +ifneq ($(KERNELRELEASE),) +obj-m := lsi6.o +lsi6-objs += lsi6_lib.o lsi6_main.o +else +KERNELDIR ?=/lib/modules/$(shell uname -r)/build +PWD := $(shell pwd) +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) CC=$(KGCC) modules + +endif + +camt: camt.c + cc camt.c -o camt -lreadline -lncurses + +clean: + rm -f *.o *.ko camt + +install: + rm -f $(KERNELDIR)/misc/lsi6.ko + install -D -m 644 lsi6.ko $(KERNELDIR)/misc/lsi6.ko + @depmod diff --git a/camt.c b/camt.c new file mode 100644 index 0000000..b9868a2 --- /dev/null +++ b/camt.c @@ -0,0 +1,296 @@ +/* + * camt.c: the test program for ppi2camac driver + * + * Copyright (C) 1999 Alexei Nikiforov, BINP, Novosibirsk + * + * Email: A.A.Nikiforov@inp.nsk.su + * + * $Id: camt.c,v 1.1.1.1 2000/01/19 04:24:07 camac Exp $ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include"lsi6camac.h" + +int gethex(char **p, int * data) +{ + int i; + char * pp = *p; + + i = strtol( *p, &pp, 16); + if( *p == pp) return 0; + *p = pp; + *data = i; + return 1; +} + +int getint(char **p, int * data) +{ + int i; + char * pp = *p; + + i = strtol( *p, &pp, 0); + if( *p == pp) return 0; + *p = pp; + *data = i; + return 1; +} + +int getname(char ** p, char *s) +{ + int count=0; + char * in; + + for( in = *p; *in; in++ ) + if( ! isspace(*in)) break; + while( *in ){ + if( isspace(*in)) break; + *s++ = *in++; + count++; + } + *s = 0; + *p = in; + return count; +} + +void do_help(){ + printf("\no filename - open device file\n" + "s[n] - type/select opened device file descriptor \n" + "C - Clear, Z - Zero \n" + "n[i], a[i], f[i] - type/set n, a, f\n" + "d[i] - type/enter data value \n" + "D[val [val ...]] - type/enter buffer data values \n" + "F - fill buffer with 0,1,2,....\n" + "b[size] - type/enter buffer size in words\n" + "h[0|1] - disable/enable high byte\n" + "c[count] - carry out CAM ... \n" + "r[count] - ... CAM_READ to buffer bs words\n" + "w[count] - ... CAM_WRITE from buffer bs words\n" + "x - type xq or res on the last camac cycle\n" + "t - time report\n" + "g[i] - type/set group request number\n" + "G[i] - type/set LAM request number\n" + "T - timeout for lwait\n" + "L[count] - ... lwait(g,timeout) ... \n" + "l[count] - ... lseek(fd, NAF(n,a,f) count times\n" + "R[count] - ... read to buffer bs bytes\n" + "W[count] - ... write from buffer bs bytes\n" + "i[count] - ... ioctl ... \n" + "I1 - inhibit on, I0 - inhibit off\n" + "I - type state of the inhibit line\n" + ); +} + + +#define TEST( command ) \ +i=1;\ +getint(&p,&i);\ +num = i;\ +gettimeofday(&start,NULL);\ +while(i--) { command ;}\ +gettimeofday(&end,NULL);\ +dt=end.tv_sec-start.tv_sec+(end.tv_usec-start.tv_usec)/1000000.;\ + +char name[100]; + +unsigned * buf; + +void sigint(int sig){ + printf(" was pressed. Use q to exit\n"); + signal(SIGINT, sigint); + +} + +int i, num; +int crate=0, n=0, a=0, f=0, g=0, data=0, G=0; +int is24=0, cnt=2, bs=1024; +unsigned l24=0; +struct timeval start, end; +double dt; +int crate; +int T=-1; +int xq; + +int loop(char * line) +{ + char * p = line; + int i; + + while( *p ){ + switch(*p++){ + + case 'C': xq = CAM_C(crate); break; + case 'Z': xq = CAM_Z(crate); break; + case 'o': getname(&p,name); + printf("fd=%d\n",crate=open(name,O_RDWR)); + if( crate < 0) perror(""); + break; + case 'e': /* close crate */ + printf("close(%d)=%d\n", crate, close(crate)); + break; + case 's': /* set fd number */ + getint(&p,&crate)?:printf("fd=%d\n",crate); + break; + case 'd': /* data */ + getint(&p, &data)?:printf("data=%#x\n",data); + break; + case 'f': + getint(&p,&f)?:printf("f=%d\n",f); + break; + case 'n': + getint(&p,&n)?:printf("n=%d\n",n); + break; + case 'a': + getint(&p,&a)?:printf("a=%d\n",a); + break; + case 'g': getint(&p,&g)?:printf("g=%d\n",g); + break; + case 'G': getint(&p,&G);g=CAM_L2G(G);printf("G=%d, g=%d\n",G,g); + break; + case 'T': + getint(&p,&T)?:printf("timeout=%d\n",T); + break; + +/* lseek, ioctl, read, write, lwait, CAM*/ + case 'l': + TEST( xq=lseek(crate, l24 | NAF(n,a,f), 0)); + break; + case 'i': + TEST( xq=ioctl(crate, l24 | NAF(n,a,f), &data) ); + break; + case 'r': + TEST( xq=CAM_READ(crate, l24|NAF(n,a,f), buf, bs)); + break; + case 'w': + TEST( xq=CAM_WRITE(crate,l24|NAF(n,a,f), buf, bs)); + break; + case 'b': + if( !getint(&p,&i)){ + printf("bs=%d\n",bs); + break; + } + if( i > bs){ + unsigned * p = calloc(i, sizeof(unsigned)); + if( !p ){ + xq = -1; + errno = ENOMEM; + break; + } + memcpy( p, buf, bs*sizeof(unsigned)); + buf = p; + } + bs = i; + break; + case 'D': + for( i=0; i<1024; i++) + if( !getint(&p,buf+i) ) break; + if( i==0 ) { + for( ; i %d times in %f sec,\n %f op/sec, %f usec/loop\n", + num, dt, num/dt, 1000000.*dt/num); + break; + /* high byte using */ + case 'h': + if(getint(&p,&is24)) + if(is24) { + cnt=3; + l24=CAMAC_24; + } + else { + cnt=2; + l24=0; + } + else printf("h%d\n",is24); + break; + case 'I': + i=0; + if(getint(&p,&i)) i?CAM_ION(crate):CAM_IOFF(crate); + else printf("%d\n",CAM_I(crate)); + break; + /* help */ + case 'q': return 0; + case '?': do_help(); + } + if( xq < 0){ + fprintf(stderr,"errno=%d\n",errno); + perror(""); + xq = 0; + } + } + return 1; +} + +int +main(){ + char * line = NULL; + int i; + + printf(" camt from ppi2camac 0.3.1a\n"); + + buf = calloc( bs, sizeof(unsigned)); + if( !buf){ + fprintf(stderr, "no memory\n"); + exit(1); + } + for(i=0;i"); + if( ! line ) break; + if( *line ){ + HIST_ENTRY * he; + he = history_get( history_length); + if( !he || strcmp( line, he -> line)) + add_history(line); + } + if( ! loop( line)) break; + free( line); + } + return 0; +} diff --git a/doc/IPS(v_1).doc b/doc/IPS(v_1).doc new file mode 100644 index 0000000000000000000000000000000000000000..196584d52a2096124b450a18d9bef3b3dc78a981 GIT binary patch literal 54784 zcmeI53!Ifzx&POm*|TTlI)EY~;zo(^hQmz|0cQqK5CRgsn+l?#ArNxN%nS{c%sgb) z;dCgeQ=TFZ2Z>{5rDp0;|7v8VX5_(+iQy$gL@<^A_qU$C-pii7VYpf8?D_oOcdhq* z*X>!)dM<0N_npRVciXmYx_kj3 z*z)@aqQJ}F{ka?C4#?7V9q&;mI!Dj)FP?hw${()$p}(3s9FXnoy5H>F z>fdENzVYGI?Iw|J+uBFh%7w!NAM=45#a{e$PKLv^;`6?`Q22ejkam0Lo;>>?&)vp3 zJogOkzk~Sl3d?9m=Py*+bH(TL$wygSVDxO(S@l`e!MRP;X+bCF<`Dk^=|5^kq>h0e zq1@C>r7Kgf=z5`Er|e@XLw?~L+8y#${P#q{^^mUkto)ZJ`YSwNoUiCp>KFPUoI|>D z=g^*zpXzfXbqMwPzcxn44CPIxz~X#L)uB1pLV2NmbD+;q63)MU^@|t2eqSckKb!|u zIoF+0bqe)p*PH_0lV{qxF4opI&xLsc{kCGK+fdd0CJt+pBYRE zx;KUc&i)Dx=FQQ4l^LpiHOx^J}zdFYA3w09^eR4b(t z9n{_~*`rCTRw~y)KJUJS8na_5qmEM4u5r=*<4AiVISlt{hG+W{s?UyyXl-@2yod2j zLsqR9^@osh6!}>FhLZp2LK}t=)*aC_N&7mk_JO|L$zA!1+G>YUe6TNDR8Z~J>&H_M z^-w)eTaM`#TK>oJ^iZB2;GY&(j4g0Qy7av3nyt-t16{L6QVX@C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 + +

��������

+ +

+��������� ����� ������� ������ ��� Linux-� �������� � ������ ���������� +���-6 � ������������ ������ �0607, �������������� �����������, ���. + + +

+�� ������ ��� ���� �������, ���������� Ole Streicher ��� Aachen +DBCC Controller with PCCPI Card. + + +

+������� ������������� � ���������� ������ ����� �������� � ������������ +����������� ����. ��� ��������� �� ��������� ��� ����� ��������� � +���������� `/dev'. � ��������� ����� ���� ������������ +��� ����� ����������. ��� ���������� �������, ������������ � +������ ����� ������� �����, ������������ � `ppia', �� ������ - +� `ppib'. ������: + + +

+`/dev/ppia0' - ��� ������� ������, ������������� � ������ ����� +����������; + + +

+`/dev/ppib3' - ��� �������� ������, ������������� �� ������ ����� +����������. + + +

+������ ��� �����, ����� �������� � �������, ��������� ������� ������ +� �������: open, close, ioctl, lseek, +read, write � ������� �� ����� +`ppi6camac.h' + + +

+������� ����� ��������� �����: + + + +

    + +
  • + + ��������������� ��� ����������� ������; + +
  • + + �� ����� �������� ������ ����� ���������������: + + +
      +
    • ������� ����� ( �� ��������� 0x240 ), + +
    • ����� IRQ ( �� ��������� 15 ), + +
    • ������� ����� ������������ ����� ( -//- 120), + + ( ����������������� � �������� ��������� ������������ ��������� + ���� ���������� � ����� ����������); +
    + +
  • + + ����� ��������� 16-� ��� 24-� ��������� ��������� ����� ����� + ��� ����� ��� ������; +
  • + + ����� ��������� ������� ����� 16-� ��� 24-� ��������� �����; +
  • + + ����� ��������� ������� LAM ������� � + ������� LAM ������ � ������� ��������� �������; +
  • + + ��������� ������ Inhibit; +
  • + + ����� ��������� CZ ����� �����. +
+ + + +

��������� ��������

+ + + +

���������� ��������

+ + +
    +
  1. ����������� ����� � ���������� �����; + +
  2. ���������������. ��� ���� ���������� ������� + + + make + + � ����������, ��� ��������� �����. ��� ���� ����� ������ ����������� + ������ ppi6.o + + ������� + + make camt + + ��� ���������� ��������� ������ ������ � �������. + + ��� ���������� ����� �� ��������� ���������� ����� �����������������; + +
  3. ������� ����������� �����, ��������������� �������. ��� ����� ���� ������� + + + make devices + + ��� ���� ����� ������� ����� `/dev/ppia0' ... `/dev/ppia5' � +`/dev/ppib0' ... `/dev/ppib5'; + +
  4. ���������� �����, ��� ���� ������� + + + make install + + ���� `ppi6.o' ����� ���������� � `/lib/modules/$(VERSION)/misc'; + ���� `ppi6camac.h' ����� ���������� � `/usr/local/include'; + ���� `camt' ����� ���������� � `/usr/local/bin'; + info �������� �������� ����� ����������� � �������. + +
+ + + +

��������� ������

+ +

+ + +

+���� ��������� �������� ��������� ������������ ������ `ppi6.o' � �������. + + +

+����� ��������������� �������, ������� ������� �����������: + + + +

+    insmod ppi6 [irq=15] [major=120] [io=0x250]
+
+ +

+��� ������ ����� ���������� ������ ���� �������� ���� ��������� +������ �� ����� ���������� ������. �������� `ppia'`ppib'. + + +

+�������������� ��������� irq, major, io ������������� +��� ��������� �������� ��� ���������� ������������ ����� � ������������. + + +

+��� �������� ������ �� ������� ���� �������, ������� ������� +����������������� + + + +

+    rmmod ppi6
+
+ +

+������ ������ -- ������� ��������� � ����� `/etc/conf.modules': + + + +

+alias ppia ppi6
+options ppia -o ppia io=0x240 irq=10 major=120
+alias ppib ppi6
+options ppib -o ppib io=0x250 irq=12 major=121
+
+ +

+������ ��� ��������� �������� ��� ������ ����� ���������� ������� + +

+	modprobe ppia
+
+ +

+� ������� � ��� �� ����: + + + +

+alias char-major-120 ppi6
+options char-major-120 -o ppia io=0x240 irq=10 major=120
+alias char-major-121 ppi6
+options char-major-121 -o ppib io=0x250 irq=12 major=121
+
+ +

+������� ����� `���' ��������������� ��� �������� ���������������� +�����. + + + + +

������������� ��������.

+ +

+������� �������� ����� ����������� �����. ��� ��������� �� ��������� ��� +����� `/dev/ppia0'`/dev/ppia1'. ����� ������������� ������� � +������� �������, ������������ � ������ ����� ����������. + + +

+� ��������� �� "C" � "C++" ��� ������������� �������� ���������� ���������� +���� `ppi6camac.h': + +

+#include<ppi6camac.h>
+
+ +

+� ���� ����� ��������� ��������� � ������� ��� ����������� ���������� +��� ������ ��������� ������� � ������� �������, ����������� ������ +� �������. + + + + +

��������� ������

+ +

+������� ������������ ��������� ��������� ������: + + + + +

open()

+ +

+ + +

+int open(const char *pathname, int flafs);
+
+ +

+������� ����� �����. pathname ��� ������ `/dev/ppi0' ��� +`/dev/ppi1' +( � �.�. ���� ������������ ������ ����� ������������ �����). +flags ������ ���� O_RDWR. + + +

+������� ���������� ���������� ����� (fd), � ������� ����� �������� ��������� +�������, ��� -1 � ������ ������. + + + + +

close()

+ +

+ + +

+int close(int fd);
+
+ +

+������� '���������' ����� �����. + + +

+���������� 0 ��� �������� ����������. + + + + +

lseek()

+ + +
+off_t lseek(int fd, off_t offset, int whence)
+
+ +

+ +������� �������� � ������� ����� N, �������� A, +������� F �, ��������, ������� 24-� ������� ������ ����� +offset ��������. ��������� �� ���� ������� read +� write ����� ��������� CAMAC ������, ��������� ���������� +���������. + + +

+offset ����� ���������, +��������� ����� NAF(N,A,F) ��� NAF24(N,A,F) �� +`ppi6camac.h'. + + +

+whence �������� +����� ���� ������ SEEK_SET. ������� ���������� -1 ��� ������. +�.�. �������� ������������� ���� �������: + + + +

+ lseek(fd, NAF(n, a, f), SEEK_SET);
+
+ +

+lseek �� ��������� ������� �������� ������ � �������, +��� ������ ������������� � �������� '��������� ������� � �����', +�������� N, A � F ��� ������������ �������������. + + +

+��� ���������� ������ ������� ���������� �������� offset. + + + + +

read() � write()

+ +

+ + + +

+int read(int fd, char *buf, size_t count);
+int write(int fd, char *buf, size_t count);
+
+ +

+��� ������� ������������ ���������� ����� ����� � �������������� +�������������� �������� lseek �������, ���������� � ��������. + + +

+��� ����������� ����� ����� ������� �� �������� �������� count. + + +

+ +
count = 2 +
+ - ���������� 16-� ��������� ����� ���� +
count = 3 +
+- ���������� 24-� ��������� ����� ���� +
count = 4*n +
+- ���������� n 16-� ��� 24-� ��������� ����� ������ + ( ������ LONG NAF ) +
+ +

+������ ��������/������� ��/� buf. + + +

+��� �������� ���������� ������������ ���������� ���������� +������. ��� ������ ������������ -1. + + +

+����� XQ ����� ������ ����� +ioctl(fd ,CAMAC_STATUS, &status). + + +

+��� ������������� ���� ������� �������������� ������������ �������� +�������� ������ ������. ��� ���������� ��������� ����� ������� ����� +������������ ������� ioctl(). + + + + +

ioctl()

+ + +
+int ioctl(int fd, int cmd, unsigned long *argp);
+
+ +

+����� '�����������' �� ����������� ����� �������. ��������� ��������� +����� ����� � ������� � ��� ������, �������� ����� ����� � ������� �� +���������, ����������� �� ������������� fd, �����-����. + + +

+��������� ��������� ������� cmd, ������������ � ����� ppi6camac.h: + + +

+ +
NAF(n, a, f) +
+ - �������� 16-� ��������� ����� ����. + ��� ������ ������ ( F0 - F7), argp - ���� ������, + ��� ������ ������ ( F16 - F23), argp - ������ ������. + argp ����� ���� NULL. � ���� ������ ���������� ����� ����, + ������ �� ����������. + +���������� ����� X, Q � ������� ���� �����. ��� ������ ��� +�������� ���������� -1. ��� ������ ����� ���������� � errno. + +
CAMAC_24 | NAF(n, a, f) +
+- �� �� ��� � NAF, �� ���������� 24-� ��������� + ����� ����. + +
NAF24(n, a, f) +
+- ��. ����. + +
CAMAC_STATUS +
+ - ������ � *argp ������ timeout,X,Q + � ������� ��� ����. + ����� ������ �� ����������, ������������ ����� ������������ + ���������� fd, ����� �����. + ��� ����� �������� ��� ������ �� long naf, ������������ ����� + read ��� write. + +
CAMAC_NON_DATA +
+ - �������� ����� ���� ��� ������, � N, A, F + �������������� ������������� ����� lseek. + ����� timeout, X, Q ����� �������� + ����� ioctl �������� CAMAC_STATUS. + +
CAMAC_LWAIT(lgroup) +
+ - �������� ��������� LAM � ��������� ������� + lgroup. + + +timeout=argp + +���� timeout > 0 �� ����� LAM � ������� + ����� ��������; + +���� timeout < 0 - ����� �����; + +���� timeout == 0 �� �������� �������� ������� + LAM �������. + + timeout ����������� � "�����". + (��� x86 ��� ����� 10 �����������). + + ���������� ������� ��������, ���� LAM �������� � + ��������� ����, ����� -1 � + errno=ETIME. + ��� "�������" �������� ��� ��������� LAM + ������������ 0. + ��� ������� ������������ -1. + +
CAMAC_ION(1) +
+- �������� ����� INHIBIT + +
CAMAC_IOFF(2) +- ��������� ����� INHIBIT +
+ +

+������� ������� � ��������� ����������� ������: + + +

+ +
CAMAC_READ_LM +
+- ��������� � *argp ������� ����� � ��������; + +
CAMAC_WRITE_LM +
+- ������ �� *argp ������� ����� � ��������. + ������ ����� �������� ����� ����� � �������� �����-����������� + �0607; + +
CAMAC_READ_HB +
+- �������� � *argp ������� �������� �����; + +
CAMAC_WRITE_HB +
+- ������ �� *argp � ������� �������� �����; + +
CAMAC_READ_CONTROL +
+- ��������� ������� ������� � ���������� �����������; + +
CAMAC_WRITE_CONTROL +
+ - �������� ������� ������� � ���������� ����������� + ������ ����� �������� ����� ����� � �������� �����-����������� + �0607. +
+ +

+��� �������� ���������� ioctl ���������� 0 ��� ������������� +�����, � ������� ����������� ����������� �����. ��� ������ +������������ -1 � ����� ������ ������������ � errno. + + + + +

�������, ������������ � ppi6camac.h

+ +

+������� � ������� � ����� `ppi6camac.h' ������ ���� �����. + + +

+��-������ ��� �������� ���������, ����� ��� N, A, +F � ������, ��� �������� ����� ��������� ������ ��������. +(see section ioctl(), see section lseek()). + + +

+��-������ ��� ������������ ��� �������� ������� ���������� +� ���������� ������ � �������. � ���� ������� ������� ������ +���������. ��������� ������� ������������ ���������� ������ +����� ������������ ��� ������ � �������. + + + + +

�����������

+ +

+ +int NAF(n,a,f) - �������� n, a, f ��� ������� +lseek, ioctlCAM ��� +���������� 16-� �������� ����� �����. + + +

+ +int NAF24(n,a,f) - �������� n, a, f ��� ������� +lseek, ioctlCAM ��� +���������� 24-� �������� ����� �����. + + +

+int CAM_L2G(int l) - �������������� ������ ������� � ������ � +����� ���������� �������. + + + + +

���������� ����� �����

+ +

+ +int CAM(int fd, int naf, unsigned *pdata) - �������� 16-� +��������� ����� ����, +� ������� *pdata. pdata ����� ���� NULL. + + +

+ +int CAMW(int fd, int naf, unsigned data) - �������� 16-� +��������� ����� ���� ������, � ������� data. + + +

+ +int CAM24(int fd, int naf, unsigned *pdata) - �������� 24-� +��������� ����� ����, +� ������� *pdata. pdata ����� ���� NULL. + + +

+ +int CAM24W(int fd, int naf, unsigned data) - �������� 24-� +��������� ����� ���� ������, � ������� data. + + +

+��������� �������: +

+ +
fd +
+���������� ��������� ����� ����������, ���������������� +����� ������; + +
naf +
+NAF ���������� ��� ���������� ������. + +
+ +

+������� +���������� ����� X, Q � ������� ���� �����. ��� +������� ���������� -1. + + + + +

������� ��������

+ +

+ + +int CAM_READ( int fd, int naf, unsigned * buf, int num) + + +

+int CAM_WRITE( int fd, int naf, unsigned * buf, int num) + + +

+CAM_READ ������ ��� ������ ����� ������ �� ����� �����, +CAM_WRITE ��� ������ ����� ������ � ����� ����. + + +

+��������� �������: +

+ +
fd +
+���������� ��������� ����� ����������, ���������������� +����� ������; + +
naf +
+NAF ���������� ��� ���������� ������. ����� �������� ��� +16-� ��� � 24-� ������� �����.(See section �����������.); + +
buf +
+����� ������� ������. ������ ������ �������� �� ����������� +����� � ����� ����������� ������; + +
num +
+��������� ���������� �������. +
+ +

+��� �������� ���������� ������ CAM_READCAM_WRITE +���������� ����� XQ � ���� ������� �����. ��� +������ ������������ -1. + + + + +

����������� �������

+ +

+ +int CAM_C(int fd) - �������� Clear ����. + + +

+���������� 0 ��� �������� ����������, +-1 ��� ������. + + +

+ +int CAM_Z(int fd) - �������� Zero ����. + + +

+���������� 0 ��� �������� ����������, +-1 ��� ������. + + + +

�������� LAM �������

+ +

+ +int CAM_LWAITG(int fd, int g, int timeout ) - ������� +��������� LAM � ��������� ������� g. + + +

+ +int CAM_LWAIT(int fd, int l, int timeout) - ������� ��������� LAM �� +����� � ������� l. + + +

+ +
timeout > 0 +
+ - ������� ��������� LAM � ��������� ������� request � ������� +��������. ��� ������������� LAM ���������� ������� �� ��������. +( 0 ��� �� ��������. �������� LAM �������� � ��������� ������); + +
timeout = 0 +
+ - ��������� ������� ���������� LAM �������. ��� ��� ������� +���������� 0, ����� -1; + +
timeout < 0 +
+ - ������ �������� � �������� LAM + +
+ +

+��� ���������� LAM ������� � ������� ���������� �������� +������������ ������ ETIME. + + +

+�������� �������� ����� ���� ����� �������� ��������������� +��������. � ���� ������ ������������ ��������������� ������. + + +

+ +int CAM_L2G(int l) - �������������� ������ ������� � ������ � +����� ���������� �������. + + + + +

����� INHIBIT

+ +

+ +int CAM_ION(int fd) -- �������� ����� INHIBIT; + + +

+ +int CAM_IOFF(int fd) -- ��������� ����� INHIBIT; + + +

+ +int CAM_I(int fd) - �������� ��������� ����� INHIBIT. + ���������� 0 ���� ���������, 1 ���� ��������. + + +

+������� CAM_ION, CAM_IOFFCAM_I +���������� -1 ��� ������. + + + + +

��������� �� �������

+ +

+������� �������� � ��������� �������: + + +

+ +
EIO +
+������ �����/������. �������� �������� ��� �������� +�����(3); + +
EFAULT +
+� ������� ������� ������������ ����� ������ buf (��� +������� readwrite) ��� �������� argp (� +������� ioctl); + +
EINVAL +
+������������ �������� ��� ������ �������; + +
ENOMEM +
+�� ������� ������ ��� ���������� ��������; + +
ETIME +
+�� ��������� ���������� LAM ������� � ��������� ������� �������. +
+ + + +

����� �� �������

+ +

+�������� � ������� ��������, ���������� ����� ������������. + + +

+�������: + + +

+����� �� �������� LAM �� ����� ? + + +

+����� �� ������ ����� ������, �, ���� �����, �� ��� ��� +������ ��������� ? ������ �� ��� ���� ����� �������������� �������, +��� ���� ��������� ��� ������� ���������� �� ��� ������������ ����� ? + + +

+������ ��� ��������. ��� �������� ? + + +

+�������� �������, ��������� � ����������� + + +

+ ������� ��������� + + +

+ nikiforov@inp.nsk.su + + + + +

��������� camt ������ ����������

+ +

+������������� ��������� camt �������� ��� ������ � �������� ������� +����������� � ��� �������� � ������� ����� ��������. + + +

+��� ������, � ����� +���������� ��������� ������� ������ ����������� �� �����. +��������� ��������� ������������������ ������������� ������. +������� ����� �������������� �����������. + + + + +

�������

+ +

+������� ��������� ����������� �� ��� ������: + + + +

    +
  1. + +�������, ����������� �������� ��������, ����� ��� �������� ����� ��� +���������� ����� �����. �� ������������ ����� ������ +����� ��������� �������������� �������� - �-�� ���������� ���� �������. +��� ���������� ����� ��������� ������� ����������� ���� ���; + +
  2. + +�������, ���������� ��� ����������� ���������� ���������� ���������, +����� ��� n, a, f. ��� ������ ����� ������� +��� ���������� �������� �������� ���� ����������, ��� +������ � ���������� ���������� ������������� ��� ��������; + +
  3. + +�������������� �������, ������������ ��������� ���������� +������ ������. +
+ +

+���� ����������� �������� ������� ���������. + + + + +

������� ������

+ +
+ +
o ���_����� +
+��������� ���� ����������, ���������������� ����� ������. ���������� +s ������������� �������� ����������� �����������; + +
e +
+��������� ������� ����������; + +
C +
+�������� ���� Clear; + +
Z +
+�������� ���� Zero + +
c [count] +
+�������� ����� ���� � �������� n, a, f. ������ +��������/������� �/�� ���������� d (data). ��������� ���������� +����� ����� ����� ���������� �������� x; + +
r [count] +
+�������� ����� ���� ������ � ������ ������ (CAM_READ). +������ �������� � ������ D(Data), ������ ����� +������ ������������ ��������� b(block_size); + +
w [count] +
+�������� ����� ���� ������ � ������ ������ (CAM_WRITE). +������ ������������ � ������ D(Data), ������ ����� +������ ������������ ��������� b(block_size); + +
L [count] +
+���� ��������� LAM ������� �� ������� � ������, +��������� �������� G ��� ���������� �������, ���������� +�������� g � ������� �������� T; + +
I +
+��������� ��������� ����� Inhibit; + +
I<value> +
+��������/��������� Inhibit; + +
l[count] +
+��������� lseek � �������������� n, a, f � +��������� ������ �� ������� ������ h; + +
R [count] +
+��������� read � ����������� �������������� �������� lseek; + +
W [count] +
+��������� write � ����������� �������������� �������� lseek; + +
q +
+����� �� ���������. +
+ + + +

�������-����������

+ +
+ +
s[value] +
+���������� �����; + +
n,a,f +
+n,a,f; + +
h[value] +
+������� ������ �� ������� ������; + +
d[value] +
+������ ��� ������ (data); + +
D[val [val [val ...]]] +
+������ ������ (Data); + +
F +
+������� ������ ������ ������������������� 0, 1, 2, ... , bs-1; + +
b[val] +
+������ ������� ������ � ������ (bs); + +
g[val] +
+����� ���������� �������; + +
G[val] +
+����� �����, �� �������� ��������� LAM ������; + +
T[val] +
+�������; + +
+ +

+���� ��� ���������� ���� ������ ��������� ������, �� �� ���� +����� �������� ��������������� ���������. + + + + +

�������������� �������

+ +
+ +
x +
+����� �� ��������� ����������� ��������; + +
t +
+������� ������� ������ ��������� ��������; + +
? +
+�������� ����� ���������. +
+ + + +

������ ������

+ + +
+$ camt
+ camt from ppi6camac 0.3.1a
+>o /dev/ppi0
+fd=3
+>n6 f16 a0 d0xa c x
+res=3
+>f0 c d x
+data=0xa
+res=3
+>
+
+ + + +

������ �������

+

+Jump to: +c +- +l +- +n +- +o +- +r +- +w +

+

c

+ +
  • CAM +
  • CAM24 +
  • CAM24W +
  • CAM_C +
  • CAM_I +
  • CAM_IOFF +
  • CAM_ION +
  • CAM_L2G +
  • CAM_LWAIT +
  • CAM_LWAITG +
  • CAM_READ +
  • CAM_WRITE +
  • CAM_Z +
  • CAMW +
  • close +
  • +

    l

    + +
  • lseek +
  • +

    n

    + +
  • NAF +
  • NAF24 +
  • +

    o

    + +
  • open +
  • +

    r

    + +
  • read +
  • +

    w

    + +
  • write +
  • + + +


    +This document was generated on 24 February 2000 using +texi2html 1.56k. + + diff --git a/doc/ppi6camac_foot.html b/doc/ppi6camac_foot.html new file mode 100644 index 0000000..dabeb51 --- /dev/null +++ b/doc/ppi6camac_foot.html @@ -0,0 +1,25 @@ + + + + + +ppi6camac - Footnotes + + +

    ppi6camac

    +

    +


    +

    (1)

    +

    +

    (2)

    +

    ��� ����������� ������ Inhibit +

    +������� �������� ����� ���� � N=23, A=15, F=7 +

    (3)

    +

    ��� ������ ����� ����� ����������� � ������� +����������� ����� ����� ��������� ���������� ��� ��������� ������ +


    +This document was generated on 24 February 2000 using +texi2html 1.56k. + + diff --git a/doc/ppi6camac_toc.html b/doc/ppi6camac_toc.html new file mode 100644 index 0000000..ae02dd0 --- /dev/null +++ b/doc/ppi6camac_toc.html @@ -0,0 +1,57 @@ + + + + + +ppi6camac - Table of Contents + + +

    ppi6camac

    +

    +


    +

    +


    +This document was generated on 24 February 2000 using +texi2html 1.56k. + + diff --git a/doc/readme_pci.koi8 b/doc/readme_pci.koi8 new file mode 100644 index 0000000..9610465 --- /dev/null +++ b/doc/readme_pci.koi8 @@ -0,0 +1,60 @@ + +������ �������� LINUX ��� ���������� ���-6 � ��������� PCI. + +1. ����������� ��������� �������� �������� ����������� � +��������� ���������� ���������� ������ 1.4 �� 24.12.2001 +������������ � �������� ������� camt ������ ��. + +2. ��������� ������. + +2.1. ����� ���������� ������ ���������� ����������� ��������� ���� +Linux � ���������, ��� ���� ������������� �� ������ ������. +��� ���������� ������ ����� �������������� ������������ ����� ���� +� ������� modpost (��� ���� 2.6.x) + +2.2. ��� Linux 2.6.x � Makefile ���������� ���� �� +��������� ����, ��������, +LINUX_KERNEL_PATH = /usr/src/linux-2.6.9 + +2.2. +�������������� ������ � �������� �������: +make +make camt + +����������������: +make install + +������� ����� ���������: +make devices + +��������� ������: +insmod lsi6.o +��� ���������� - ����� ���������� � �������� �����-������ +����������� ������������� bios-��. +���� � ������� ��������� ����, ��� ������������� +����� �������. +(���������� - � ���� 2.6.x ������ ����� ���������� .ko) + +3. �������������. + ���� ���������� /dev/lsi6cardNchannelM + ��� N=1..4 ����� ����� + M=1..6 ����� ������ + + ��� ���������� �������� ������������ ��������� + lsi6camac.h + +4. �� ��������� � ISA ������� ����������, ��� ������� ���������� + X � Q � ��������������� ����, �.�. ���� � ������� ��� + X=1, ��� �������� ���������� ������� X. + +5. ������������ � ������ Linux +2.2.0, +2.2.25 +2.4.0 +2.4.13 +2.4.19 +2.6.0 +2.6.9 + +�.�.������, ���. 39-42-84 +V.R.Mamkin@inp.nsk.su diff --git a/k0607.h b/k0607.h new file mode 100644 index 0000000..87cfb38 --- /dev/null +++ b/k0607.h @@ -0,0 +1,15 @@ +#define K0607_LGROUPS 8 + +#define K0607_CSR_A 0 +#define K0607_LMR_A 1 +#define K0607_HB_A 2 + +#define K0607_CSR_IF 0x0020 +#define K0607_CSR_DE 0x0040 +#define K0607_CSR_D 0x0080 +#define K0607_CSR_C 0x0100 +#define K0607_CSR_Z 0x0200 +#define K0607_CSR_XE 0x0400 +#define K0607_CSR_IL 0x1000 +#define K0607_CSR_X 0x4000 +#define K0607_CSR_Q 0x8000 diff --git a/lsi6.h b/lsi6.h new file mode 100644 index 0000000..fae8bc2 --- /dev/null +++ b/lsi6.h @@ -0,0 +1,43 @@ +#define LSI6_WINDOW_SIZE 0x100000 +#define LSI6_VENDOR_ID 0x1172 +#define LSI6_DEVICE_ID 0x3333 +#define LSI6_MAJOR 122 +#define LSI6_NUMCHANNELS 6 +#define LSI6_NUMCARDS 4 + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18) +typedef struct wait_queue *wait_queue_head_t; +#endif + +typedef struct { + long pciaddr; + char *base; + int irq; + int card; + unsigned short CSR[LSI6_NUMCHANNELS]; + wait_queue_head_t LWQ[LSI6_NUMCHANNELS][K0607_LGROUPS]; + int LWQ_flags[LSI6_NUMCHANNELS][K0607_LGROUPS]; +} lsi6_dev_t; + +typedef struct { +#define LSI6_STATUS_AT 0x01 +#define LSI6_STATUS_AE 0x02 +#define LSI6_STATUS_AQ 0x04 +#define LSI6_STATUS_AX 0x08 +#define LSI6_STATUS_LT 0x10 +#define LSI6_STATUS_LE 0x20 +#define LSI6_STATUS_LQ 0x40 +#define LSI6_STATUS_LX 0x80 + unsigned int status; + unsigned int addr; + unsigned int data_wout_init; + unsigned int data_with_init; +} channel_regs_t; + +typedef struct { + unsigned int busy; + unsigned int intr; + unsigned int intr_enable; + unsigned int intr_global; + unsigned int exist; +} lsi6_regs_t; diff --git a/lsi6_lib.c b/lsi6_lib.c new file mode 100644 index 0000000..de8aa05 --- /dev/null +++ b/lsi6_lib.c @@ -0,0 +1,233 @@ +#include +#include +#include +#include +#include +#include +#ifndef LINUX_VERSION_CODE +#include +#endif + +#include +#include +#include +#include + +#include "k0607.h" +#include "lsi6.h" +#include "lsi6camac.h" + +int lsi6_wait_channel(lsi6_dev_t *lsi, int chnum) +{ + int chmask = 1 << chnum; + lsi6_regs_t *regs = (lsi6_regs_t *)lsi->base; + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int to = 0; + int status; + + while((readl(®s->busy) & chmask) == 0) { + to++; + if (to == 100000) { + printk("lsi6: unexpected timeout !\n"); + return -1; + } + } + status = readl(&chan->status); + if (status & LSI6_STATUS_LT) { +printk("lsi6: LT timeout !\n"); + return -1; +} + return ((status & (LSI6_STATUS_LX | LSI6_STATUS_LQ)) >> 6); +} + +int k0607_write_csr(lsi6_dev_t *lsi, int chnum, int CSR) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + + writel(K0607_CSR_A << 1, &chan->addr); + writel(CSR, &chan->data_with_init); + return lsi6_wait_channel(lsi, chnum); +} +int k0607_read_csr(lsi6_dev_t *lsi, int chnum, int *CSR) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status; + + writel(K0607_CSR_A << 1, &chan->addr); + readl(&chan->data_with_init); + status = lsi6_wait_channel(lsi, chnum); + if (status == -1) return -1; + *CSR = readl(&chan->data_wout_init); + return status; +} +int k0607_enable_lgroup(lsi6_dev_t *lsi, int chnum, int lgroup) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status, mask; + + writel(K0607_LMR_A << 1, &chan->addr); + readl(&chan->data_with_init); + status = lsi6_wait_channel(lsi, chnum); + if (status == -1) return -1; + mask = readl(&chan->data_wout_init); + mask |= 1 << lgroup; + writel(mask, &chan->data_with_init); + return lsi6_wait_channel(lsi, chnum); +} +int k0607_read_lmr(lsi6_dev_t *lsi, int chnum, int *lmr) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status; + + writel(K0607_LMR_A << 1, &chan->addr); + readl(&chan->data_with_init); + status = lsi6_wait_channel(lsi, chnum); + if (status == -1) return -1; + *lmr = readl(&chan->data_wout_init); + return status; +} +int k0607_write_lmr(lsi6_dev_t *lsi, int chnum, int lmr) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + + writel(K0607_LMR_A << 1, &chan->addr); + writel(lmr, &chan->data_with_init); + return lsi6_wait_channel(lsi, chnum); +} + +int k0607_write_hb(lsi6_dev_t *lsi, int chnum, int hb) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + + writel(K0607_HB_A << 1, &chan->addr); + writel(hb & 0xff, &chan->data_with_init); + return lsi6_wait_channel(lsi, chnum); +} +int k0607_read_hb(lsi6_dev_t *lsi, int chnum, int *hb) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status; + + writel(K0607_HB_A << 1, &chan->addr); + readl(&chan->data_with_init); + status = lsi6_wait_channel(lsi, chnum); + if (status == -1) return -1; + *hb = readl(&chan->data_wout_init) & 0xff; + return status; +} +int lsi6_do_naf(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status; + + if (k0607_write_csr(lsi, chnum, lsi->CSR[chnum] | f) == -1) return -1; + writel(((n << 5) | (a << 1)), &chan->addr); + + if (f < 8) readl(&chan->data_with_init); + else writel(*data, &chan->data_with_init); + + status = lsi6_wait_channel(lsi, chnum); + if (status == -1) return -1; + + if (f < 8) *data = readl(&chan->data_wout_init); + return status; +} +int lsi6_do_block(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data, int *count) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status = 0, i; + + if (k0607_write_csr(lsi, chnum, lsi->CSR[chnum] | f) == -1) return -1; + + writel(((n << 5) | (a << 1)), &chan->addr); + + for (i = 0; i < *count; i++) { + if (f < 8) readl(&chan->data_with_init); + else writel(data[i], &chan->data_with_init); + + status = lsi6_wait_channel(lsi, chnum); + if ((status < 0) || (status & 0x02)) break; + + if (f < 8) data[i] = readl(&chan->data_wout_init); + } + + *count -= i; + + return status; +} +int lsi6_do_naf24(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status, hb; + + if (f >= 8) { + hb = (*data >> 16) & 0xff; + if (k0607_write_hb(lsi, chnum, hb) == -1) return -1; + } + + if (k0607_write_csr(lsi, chnum, lsi->CSR[chnum] | f) == -1) return -1; + + writel(((n << 5) | (a << 1)), &chan->addr); + + if (f < 8) readl(&chan->data_with_init); + else writel(*data & 0xffff, &chan->data_with_init); + + status = lsi6_wait_channel(lsi, chnum); + if (status == -1) return -1; + + if (f < 8) { + unsigned long x; + + x = readl(&chan->data_wout_init) & 0xffff; + + if (k0607_read_hb(lsi, chnum, &hb) == -1) return -1; + + *data = x | (hb << 16); + } + return status; +} +int lsi6_do_block24(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data, int *count) +{ + channel_regs_t *chan = + (channel_regs_t *)(lsi->base + (0x2000 << chnum)); + int status = 0, hb, i; + + if (k0607_write_csr(lsi, chnum, lsi->CSR[chnum] | f) == -1) return -1; + + for (i = 0; i < *count; i++) { + if (f >= 8) { + hb = (data[i] >> 16) & 0xff; + if (k0607_write_hb(lsi, chnum, hb) == -1) break; + } + + writel(((n << 5) | (a << 1)), &chan->addr); + + if (f < 8) readl(&chan->data_with_init); + else writel(data[i] & 0xffff, &chan->data_with_init); + + status = lsi6_wait_channel(lsi, chnum); + if ((status < 0) || (status & 0x02)) break; + + if (f < 8) { + unsigned long x; + + x = readl(&chan->data_wout_init) & 0xffff; + + if (k0607_read_hb(lsi, chnum, &hb) == -1) return -1; + data[i] = x | (hb << 16); + } + } + *count -= i; + return status; +} diff --git a/lsi6_lib.h b/lsi6_lib.h new file mode 100644 index 0000000..e710cc1 --- /dev/null +++ b/lsi6_lib.h @@ -0,0 +1,12 @@ +int lsi6_wait_channel(lsi6_dev_t *lsi, int chnum); +int k0607_write_csr(lsi6_dev_t *lsi, int chnum, int CSR); +int k0607_read_csr(lsi6_dev_t *lsi, int chnum, int *CSR); +int k0607_enable_lgroup(lsi6_dev_t *lsi, int chnum, int lgroup); +int k0607_read_lmr(lsi6_dev_t *lsi, int chnum, int *lmr); +int k0607_write_lmr(lsi6_dev_t *lsi, int chnum, int lmr); +int k0607_write_hb(lsi6_dev_t *lsi, int chnum, int hb); +int k0607_read_hb(lsi6_dev_t *lsi, int chnum, int *hb); +int lsi6_do_naf(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data); +int lsi6_do_naf24(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data); +int lsi6_do_block(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data, int *count); +int lsi6_do_block24(lsi6_dev_t *lsi, int chnum, int n, int a, int f, unsigned long *data, int *count); diff --git a/lsi6_main.c b/lsi6_main.c new file mode 100644 index 0000000..7bae335 --- /dev/null +++ b/lsi6_main.c @@ -0,0 +1,527 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef LINUX_VERSION_CODE +#include +#endif + +#include +#include +#include +#include +#include + +#include "k0607.h" +#include "lsi6.h" +#include "lsi6camac.h" +#include "lsi6_lib.h" + +/* +extern void *kmalloc(size_t, int); +extern void kfree(const void *); +*/ + +#undef DEBUG + +#ifdef DEBUG +#define DP(x) x +#else +#define DP(x) +#endif + +#define DRV_NAME "lsi6" +#define DRV_VERSION "version 1.04" +#define DRV_RELDATE "May 2008" +#define DRV_AUTHOR "V.Mamkin" + +MODULE_AUTHOR(DRV_AUTHOR); +MODULE_DESCRIPTION("lsi6 - line serial interface for CAMAC"); +MODULE_LICENSE("GPL"); + +static const char version[] = +KERN_INFO DRV_NAME " camac interface module, " DRV_VERSION ", " DRV_RELDATE ", " DRV_AUTHOR "\n"; + +static lsi6_dev_t lsi6_dev[LSI6_NUMCARDS]; + +static int card_no = -1; + +static spinlock_t camlock = SPIN_LOCK_UNLOCKED; +#define CAM_LOCK(x) spin_lock_irqsave(&camlock, x) +#define CAM_UNLOCK(x) spin_unlock_irqrestore(&camlock, x) + +static struct pci_device_id lsi6_tbl[] = { + { LSI6_VENDOR_ID, LSI6_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, lsi6_tbl); + +static irqreturn_t lsi6_interrupt(int irq, void *dev_id) +{ + lsi6_dev_t *lsi = (lsi6_dev_t *)dev_id; + lsi6_regs_t *lsi6_regs = (lsi6_regs_t *)lsi->base; + int intr, lmr, mask, k, chnum; + unsigned long flags; + + CAM_LOCK(flags); + + intr = readl(&lsi6_regs->intr); + if (intr & 0x40) { + writel(0, &lsi6_regs->intr_global); + for (chnum = 0; chnum < LSI6_NUMCHANNELS; chnum++) { + if (intr & (1 << chnum)) { + k0607_read_lmr(lsi, chnum, &lmr); + for (k = 0, mask= 0x100; k < K0607_LGROUPS; k++, mask <<=1) { + if (lmr & mask) { + wake_up_interruptible(&lsi->LWQ[chnum][k]); + lsi->LWQ_flags[chnum][k] = 1; + } + } + k0607_write_lmr(lsi, chnum, (~(lmr >> 8)) & 0xff); + } + } + writel(1, &lsi6_regs->intr_global); + } + CAM_UNLOCK(flags); + + return (irqreturn_t)IRQ_HANDLED; +} +static int lsi6_open(struct inode * inode, struct file * file) +{ + unsigned int chnum = MINOR(inode->i_rdev); + unsigned int card = MAJOR(inode->i_rdev) - LSI6_MAJOR; + lsi6_dev_t *lsi = &lsi6_dev[card]; + lsi6_regs_t *regs = (lsi6_regs_t *)lsi->base; + unsigned long flags; + int csr; + + DP(printk(DRV_NAME ": open channel %d\n", chnum)); + + if (!(readl(®s->exist) & (1 << chnum))) return -1; + CAM_LOCK(flags); + if (k0607_read_csr(lsi, chnum, &csr) == -1) { + CAM_UNLOCK(flags); + return -1; + } + lsi->CSR[chnum] |= K0607_CSR_DE; + k0607_write_csr(lsi, chnum, lsi->CSR[chnum]); + CAM_UNLOCK(flags); + + file->private_data=kmalloc(sizeof(int),GFP_USER); + *(int*)(file->private_data)=0; + + return 0; +} +static int lsi6_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int chnum = MINOR(inode->i_rdev); + unsigned int card = MAJOR(inode->i_rdev) - LSI6_MAJOR; + lsi6_dev_t *lsi = &lsi6_dev[card]; + unsigned long * ptr = (unsigned long * ) arg; + unsigned long x; + int n,a,f, rc; + unsigned long flags; + unsigned long volatile jiffies_start, jiffies_end; + int jiffies_left; + + n = N_NAF(cmd); + a = A_NAF(cmd); + f = F_NAF(cmd); + + DP(printk(DRV_NAME ": ioctl channel = %d, n = %d, a=%d, f=%d\n", + chnum, n,a,f)); + + switch(cmd) { + case CAMAC_NON_DATA: + x = file->f_pos; + n = N_NAF(x); + a = A_NAF(x); + f = F_NAF(x); + if (n > 23) return -EINVAL; + CAM_LOCK(flags); + rc = lsi6_do_naf(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + return ( rc == -1 ) ? -EIO : rc; + + case CAMAC_STATUS: + if(ptr != NULL) { + x=*(int*)(file->private_data); + if( copy_to_user(ptr, &x, sizeof(long))) + return -EFAULT; + } + return 0; + + case CAMAC_ION: + CAM_LOCK(flags); + lsi->CSR[chnum] |= K0607_CSR_IF; + rc = k0607_write_csr(lsi, chnum, lsi->CSR[chnum]); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + return ( rc == -1 ) ? -EIO : rc; + + case CAMAC_IOFF: + CAM_LOCK(flags); + lsi->CSR[chnum] &= ~K0607_CSR_IF; + rc = k0607_write_csr(lsi, chnum, lsi->CSR[chnum]); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + + return ( rc == -1 ) ? -EIO : rc; + } + + if(n == CAMAC_NLAM) { + int lgroup = F_NAF(cmd); + int timeout = arg; + + if(lgroup >= K0607_LGROUPS ) return -EINVAL; + + if( timeout == 0 ) { + int req; + int mask = 0x100 << lgroup; + CAM_LOCK(flags); + k0607_read_lmr(lsi, chnum, &req); + CAM_UNLOCK(flags); + if (mask & req) return 0; + return -1; + } + + CAM_LOCK(flags); + lsi->LWQ_flags[chnum][lgroup] = 0; + if (k0607_enable_lgroup(lsi, chnum, lgroup) == -1) { + CAM_UNLOCK(flags); + return -EIO; + } + CAM_UNLOCK(flags); + if (timeout < 0) { + wait_event_interruptible(lsi->LWQ[chnum][lgroup], + lsi->LWQ_flags[chnum][lgroup]); + return 0; + } + jiffies_start = jiffies; + wait_event_interruptible_timeout(lsi->LWQ[chnum][lgroup], + lsi->LWQ_flags[chnum][lgroup], timeout); + + jiffies_end = jiffies; + + if (!lsi->LWQ_flags[chnum][lgroup]) { + return -ETIME; + } + + jiffies_left = timeout - (jiffies_end - jiffies_start); + if (jiffies_left < 0) jiffies_left = 0; + return jiffies_left; + } + + if (n > 23) return -EINVAL; + + if (f < 8) { /* read */ + CAM_LOCK(flags); + if (cmd & CAMAC_24) rc = lsi6_do_naf24(lsi, chnum, n,a,f, &x); + else rc = lsi6_do_naf(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + if(ptr) + if( copy_to_user(ptr, &x, sizeof(long))) + return -EFAULT; + return ( rc == -1 ) ? -EIO : rc; + } + else if ((f >= 16) && (f < 24)){ + /* write */ + if(ptr){ + if( cmd & CAMAC_24 ) { + if( copy_from_user(&x, ptr, 3)) + return -EFAULT; + x &= 0xffffff; + } + else { + if( copy_from_user(&x, ptr, 2)) + return -EFAULT; + x &= 0xffff; + } + } + else + return -EINVAL; + + CAM_LOCK(flags); + if (cmd & CAMAC_24) rc = lsi6_do_naf24(lsi, chnum, n,a,f, &x); + else rc = lsi6_do_naf(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + + *(int *)(file->private_data)=rc; + return ( rc == -1 ) ? -EIO : rc; + } + else { + x = 0; + CAM_LOCK(flags); + rc = lsi6_do_naf(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + return ( rc == -1 ) ? -EIO : rc; + } + return 0; +} +static ssize_t lsi6_read(struct file * file, char * buf, + size_t count, loff_t *ppos) +{ + unsigned int chnum=MINOR(file->f_dentry->d_inode->i_rdev); + unsigned int card = MAJOR(file->f_dentry->d_inode->i_rdev) - LSI6_MAJOR; + lsi6_dev_t *lsi = &lsi6_dev[card]; + int naf = *ppos; + int n,a,f, rc; + unsigned long x; + unsigned long flags; + + n = N_NAF(naf); + a = A_NAF(naf); + f = F_NAF(naf); + + DP(printk("camac: read(chnum=%d, n=%d, a=%d, f=%d)\n", chnum,n,a,f)); + + if ((n > 23)||( f >= 8)) return -EINVAL; + if (buf == NULL) return -EINVAL; + + if(count<3){ + CAM_LOCK(flags); + rc = lsi6_do_naf(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + if( copy_to_user(buf, &x, 2)) return -EFAULT; + return ( rc == -1 ) ? -EIO : count; + } + else if(count == 3){ + CAM_LOCK(flags); + rc = lsi6_do_naf24(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + if( copy_to_user(buf, &x, 3)) return -EFAULT; + return ( rc == -1 ) ? -EIO : count; + } + else { + int count_done = count /4; + unsigned long *tmpbuf; + + tmpbuf = kmalloc(count, GFP_USER); + if (!tmpbuf) return -ENOMEM; + + CAM_LOCK(flags); + if (naf & CAMAC_24) + rc = lsi6_do_block24(lsi, chnum, n,a,f, tmpbuf, &count_done); + else + rc = lsi6_do_block(lsi, chnum, n,a,f, tmpbuf, &count_done); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + if (copy_to_user(buf, tmpbuf, count)) { + kfree(tmpbuf); + return -EFAULT; + } + kfree(tmpbuf); + return ( rc == -1 ) ? -EIO : (count - count_done * 4); + } + + return 0; +} +static ssize_t lsi6_write(struct file * file, const char * buf, + size_t count, loff_t *ppos) +{ + unsigned int chnum=MINOR(file->f_dentry->d_inode->i_rdev); + unsigned int card = MAJOR(file->f_dentry->d_inode->i_rdev) - LSI6_MAJOR; + lsi6_dev_t *lsi = &lsi6_dev[card]; + int naf = *ppos; + int n,a,f, rc; + unsigned long x; + unsigned long flags; + + n = N_NAF(naf); + a = A_NAF(naf); + f = F_NAF(naf); + + DP(printk("camac: write(chnum=%d, n=%d, a=%d, f=%d)\n", chnum,n,a,f)); + + if ((n > 23)||(( f < 16)&&(f > 23))) return -EINVAL; + + if (buf == NULL) return -EINVAL; + + if(count<3){ + if( copy_from_user(&x, buf, 2)) + return -EFAULT; + x &= 0xffff; + + CAM_LOCK(flags); + rc = lsi6_do_naf(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + + *(int *)(file->private_data)=rc; + return ( rc == -1 ) ? -EIO : count; + } + else if(count==3){ + if( copy_from_user(&x, buf, 3)) + return -EFAULT; + x &= 0xffffff; + CAM_LOCK(flags); + rc = lsi6_do_naf24(lsi, chnum, n,a,f, &x); + CAM_UNLOCK(flags); + + *(int *)(file->private_data)=rc; + return ( rc == -1 ) ? -EIO : count; + } + else { + int count_done = count /4; + unsigned long *tmpbuf = kmalloc(count,GFP_USER); + if(!tmpbuf) return -ENOMEM; + if( copy_from_user(tmpbuf, buf,count)){ + kfree( tmpbuf ); + return -EFAULT; + } + CAM_LOCK(flags); + if (naf & CAMAC_24) + rc = lsi6_do_block24(lsi, chnum, n,a,f, tmpbuf, &count_done); + else + rc = lsi6_do_block(lsi, chnum, n,a,f, tmpbuf, &count_done); + CAM_UNLOCK(flags); + *(int *)(file->private_data)=rc; + kfree(tmpbuf); + return ( rc == -1 ) ? -EIO : (count - count_done * 4); + } + return 0; +} +static loff_t lsi6_lseek(struct file * file, loff_t offset, int orig) +{ + if(orig == 0) { + DP(printk(DRV_NAME ": llseek(n=%d, a=%d, f=%d)\n", + (int)N_NAF(offset), (int)A_NAF(offset),(int)F_NAF(offset))); + + file->f_pos = offset; + return file->f_pos; + } + else + return -EINVAL; +} +static int lsi6_release(struct inode * inode, struct file * file) +{ + DP(printk(DRV_NAME ": release\n")); + + kfree(file->private_data); + + return 0; +} +static struct file_operations lsi6_fops = { + owner: THIS_MODULE, + write: lsi6_write, + ioctl: lsi6_ioctl, + open: lsi6_open, + release: lsi6_release, + read: lsi6_read, + llseek: lsi6_lseek, +}; +static int lsi6_init_one (struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + int i; + lsi6_regs_t *regs; + lsi6_dev_t *lsi; + + card_no++; + if (card_no > (LSI6_NUMCARDS - 1)) + return -ENODEV; + + lsi = &lsi6_dev[card_no]; + memset(lsi, 0, sizeof(lsi6_dev_t)); + + i = pci_enable_device (pdev); + if (i) { + return i; + } + + lsi->pciaddr = pci_resource_start (pdev, 0); + lsi->irq = pdev->irq; + DP(printk(DRV_NAME ": pciaddr = %lx, irq = %d\n", + lsi->pciaddr, lsi->irq)); + + if (request_mem_region (lsi->pciaddr, LSI6_WINDOW_SIZE, DRV_NAME) == NULL) { + printk (KERN_ERR DRV_NAME ": I/O resource 0x%x @ 0x%lx busy\n", + LSI6_WINDOW_SIZE, lsi->pciaddr); + return -EBUSY; + } + + lsi->base = ioremap_nocache(lsi->pciaddr, LSI6_WINDOW_SIZE); + if (!lsi->base) { + printk(KERN_ERR DRV_NAME ": Can't map 0x%x @ 0x%lx\n", + LSI6_WINDOW_SIZE, lsi->pciaddr); + goto error_with_release; + } + if (register_chrdev (LSI6_MAJOR + card_no, "lsi6", &lsi6_fops)) { + printk(KERN_ERR DRV_NAME ": unable to get major %d\n", LSI6_MAJOR + card_no); + goto error_with_unmap; + } + + for (i = 0; i < LSI6_NUMCHANNELS; i++) { + int k; + for (k = 0; k < K0607_LGROUPS; k++) + init_waitqueue_head(&lsi->LWQ[i][k]); + } + + regs = (lsi6_regs_t *)lsi->base; + writel(0, ®s->intr_global); + + if (request_irq(lsi->irq, lsi6_interrupt, IRQF_SHARED, "lsi6", lsi)) { + printk (KERN_ERR DRV_NAME ": Can't request irq %d\n", lsi->irq); + goto error_with_unmap; + } + + writel(readl(®s->exist), ®s->intr_enable); + writel(1, ®s->intr_global); + + lsi->card = card_no; + pci_set_drvdata(pdev, lsi); + + return 0; + +error_with_unmap: + iounmap(lsi->base); +error_with_release: + release_mem_region (lsi->pciaddr, LSI6_WINDOW_SIZE); + return -ENODEV; +} +static void lsi6_remove_one (struct pci_dev *pdev) +{ + lsi6_dev_t *lsi = pci_get_drvdata(pdev); + lsi6_regs_t *regs = (lsi6_regs_t *)lsi->base; + + writel(0, ®s->intr_global); + unregister_chrdev(LSI6_MAJOR + lsi->card, "lsi6"); + + free_irq(lsi->irq, lsi); + + iounmap(lsi->base); + + release_mem_region (lsi->pciaddr, LSI6_WINDOW_SIZE); +} + +static struct pci_driver lsi6_driver = { + name: DRV_NAME, + probe: lsi6_init_one, + remove: lsi6_remove_one, + id_table: lsi6_tbl, +}; + +static int __init lsi6_init(void) +{ + printk(version); + return pci_register_driver(&lsi6_driver); +} + +static void __exit lsi6_cleanup(void) +{ + pci_unregister_driver (&lsi6_driver); +} + +module_init(lsi6_init); +module_exit(lsi6_cleanup); + diff --git a/lsi6camac.h b/lsi6camac.h new file mode 100644 index 0000000..cee1710 --- /dev/null +++ b/lsi6camac.h @@ -0,0 +1,153 @@ +/* + * ppi2camac.h: part of the ppi2camac driver + * + * Copyright (C) 1999 Alexei Nikiforov, BINP, Novosibirsk + * + * Email: A.A.Nikiforov@inp.nsk.su + * + * $Id: ppi2camac.h,v 1.4 2001/12/24 03:42:38 camac Exp $ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef _LINUX_CAMAC_LSI6_H +#define _LINUX_CAMAC_LSI6_H + +#ifndef __KERNEL__ +#include +#include +#include +#include +#include +#endif + +#define NAF(n,a,f) (((f&0x1f)<<16) | ((n&0x1f)<<4) | (a&0xf)) +#define NAF24(n,a,f) (((f&0x1f)<<16) | ((n&0x1f)<<4) | (a&0xf) | CAMAC_24) + +#define N_NAF(naf) (((naf) >> 4 ) & 0x1f) +#define A_NAF(naf) ((naf) & 0xf) +#define F_NAF(naf) (((naf) >> 16 ) & 0x1f) + +#ifdef __KERNEL__ +#define IS_N(naf) ((naf) & 0x1f0) +#endif + +#define CAMAC_TEST_CRATE 3 +#define CAMAC_STATUS 4 /* read X and Q flags */ +/* +#define CAMAC_C 5 +#define CAMAC_Z 6 +*/ +#define CAMAC_NON_DATA 7 +/* #define CAMAC_LWAIT 8 */ +#define CAMAC_ION 9 +#define CAMAC_IOFF 10 +#define CAMAC_24 0x8000 +#define CAMAC_READ_LM NAF(0,1,0) +#define CAMAC_WRITE_LM NAF(0,1,16) +#define CAMAC_READ_HB NAF(0,2,0) +#define CAMAC_WRITE_HB NAF(0,2,16) +#define CAMAC_READ_CONTROL NAF(0,0,0) +#define CAMAC_WRITE_CONTROL NAF(0,0,16) + + +#define CAMAC_NLAM 27 +#define CAMAC_LWAIT(lgroup) NAF(CAMAC_NLAM,0,lgroup) + + +#ifndef __KERNEL__ + +static __inline__ int CAM(int fd, int naf, unsigned * p){ + return ioctl(fd, naf, p); +} + +static __inline__ int CAMW(int fd, int naf, unsigned p){ + return ioctl(fd, naf, &p); +} + + +static __inline__ int CAM24(int fd, int naf, unsigned long * p){ + return ioctl(fd, naf | CAMAC_24, p); +} + +static __inline__ int CAM24W(int fd, int naf, unsigned long p){ + return ioctl(fd, naf | CAMAC_24, &p); +} + +static __inline__ int CAM_READ( int fd, int naf, unsigned * buf, int num){ + int txq, res; + lseek(fd, naf, SEEK_SET); + if( (res=read(fd, (char*)buf, 4*num)) < 0) return res; + if( (res=ioctl(fd, CAMAC_STATUS, &txq)) < 0) return res; + return txq; +} + +static __inline__ int CAM_WRITE( int fd, int naf, unsigned * buf, int num){ + int txq, res; + lseek(fd, naf, SEEK_SET); + if( (res=write(fd, (char*)buf, 4*num)) < 0) return res; + if( (res=ioctl(fd, CAMAC_STATUS, &txq)) < 0) return res; + return txq; +} + +static __inline__ int CAM_C(int fd){ + unsigned data=0x140; + return ioctl(fd, CAMAC_WRITE_CONTROL, &data); +} + +static __inline__ int CAM_Z(int fd){ + unsigned data=0x240; + return ioctl(fd, CAMAC_WRITE_CONTROL, &data); +} + +static char l2g[24]={ + 0,0,0,0, + 1,1,1,1, + 2,2,2, + 3,3,3, + 4,4,4, + 5,5,5, + 6,6,6, + 7 +}; + +static __inline__ int CAM_L2G(int l){ + return l2g[l-1]; +} + +static __inline__ int CAM_LWAIT(int fd, int l, int timeout){ + return ioctl(fd, CAMAC_LWAIT(CAM_L2G(l)), timeout); +} + +static __inline__ int CAM_LWAITG(int fd, int g, int timeout){ + return ioctl(fd, CAMAC_LWAIT(g), timeout); +} + +static __inline__ int CAM_ION(int fd){ + return ioctl(fd, CAMAC_ION,NULL); +} + +static __inline__ int CAM_IOFF(int fd){ + return ioctl(fd, CAMAC_IOFF,NULL); +} + +static __inline__ int CAM_I(int fd){ + int temp; + if( ioctl(fd, CAMAC_READ_CONTROL, &temp) < 0) + return -1; + return (temp & 0x1000)?1:0; +} +#endif /* __KERNEL__ */ +#endif /* _LINUX_CAMAC_LSI6_H */ diff --git a/makedevices b/makedevices new file mode 100644 index 0000000..183afcf --- /dev/null +++ b/makedevices @@ -0,0 +1,24 @@ + +number_cards=1 +number_channels=6 + +# ---------------------------------------------------------- + +cardnum=0 + +while true; do + chnum=0 + while true; do + + mknod -m 0666 /dev/lsi6card$(($cardnum+1))channel$(($chnum+1)) c $((122+$cardnum)) $chnum + + chnum=$(($chnum+1)) + if test "$chnum" == "$number_channels"; then + break; + fi + done + cardnum=$(($cardnum+1)) + if test "$cardnum" == "$number_cards"; then + break; + fi +done diff --git a/reload b/reload new file mode 100644 index 0000000..4f788a4 --- /dev/null +++ b/reload @@ -0,0 +1,4 @@ +make clean +make +rmmod lsi6 +insmod lsi6.o diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..8e8cd60 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,42 @@ + +all: naf indicator c0609 c0612 catch_lam rw_count2 rw_count3 write_block read_block + +CFLAGS= -I/usr/include -I../ -O2 -Wall +HEADERS = ../camac.h + +indicator: indicator.c + $(CC) $(CFLAGS) $< -o $@ + +smi: smi.c + $(CC) $(CFLAGS) $< -o $@ + +naf: naf.c + $(CC) $(CFLAGS) $< -o $@ + + +c0609: c0609.c + $(CC) $(CFLAGS) $< -o $@ + +c0612: c0612.c + $(CC) $(CFLAGS) $< -o $@ + +catch_lam: catch_lam.c + $(CC) $(CFLAGS) $< -o $@ + +test_intr: test_intr.c + $(CC) $(CFLAGS) $< -o $@ + +rw_count2: rw_count2.c + $(CC) $(CFLAGS) $< -o $@ + +rw_count3: rw_count3.c + $(CC) $(CFLAGS) $< -o $@ + +write_block: write_block.c + $(CC) $(CFLAGS) $< -o $@ + +read_block: read_block.c + $(CC) $(CFLAGS) $< -o $@ + +clean: + rm -f *.o diff --git a/tests/c0609.c b/tests/c0609.c new file mode 100644 index 0000000..304ccd9 --- /dev/null +++ b/tests/c0609.c @@ -0,0 +1,72 @@ +/* + CAMAC C0609 (ADC-20) test +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define BUS "/dev/lsi6card1channel2" + +int main(int argc, char **argv) +{ + int x,u; + int n,fd, data; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + + fd = open(BUS,O_RDWR | O_EXCL); + if(fd < 0){ + fprintf(stderr, "Can't open " BUS "\n"); + exit(-1); + } + + data = 0; + if (ioctl(fd, NAF(n, 0, 10), &data)) /* clear lam */ + goto xqerror; + + data = 6; /* T = 6 (320ms), 8V */ + if (ioctl(fd, NAF(n, 0, 16), &data)) + goto xqerror; + + while(1){ + data = 0; + if (ioctl(fd, NAF(n, 0, 26), &data)) /* start adc */ + break; + + data = -1; + if (ioctl(fd, CAMAC_LWAIT(CAM_L2G(n)), &data)) /* wait lam */ + break; + + if (ioctl(fd, NAF(n, 0, 0), &x)) + break; + + printf("ADC code: %x",x); + u = 0x2400 - (x >> 6); + printf(" u (mv) = %d\n",u); + } + close(fd); + exit(0); + + help:; + printf("%s N\n", argv[0]); + exit(-1); + + xqerror:; + fprintf(stderr,"xq error\n"); + exit(-2); +} + diff --git a/tests/c0612.c b/tests/c0612.c new file mode 100644 index 0000000..62b63e2 --- /dev/null +++ b/tests/c0612.c @@ -0,0 +1,99 @@ +/* + CAMAC C0612 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define BUS "/dev/lsi6card1channel2" + +#define ADC_N 9 +#define ADC_T 7 +#define ADC_D 1 /* 1 - 0.5V, 0 - 8V */ + +int main(int argc, char **argv) +{ + int n,fd, data; + float v, k; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + + fd = open(BUS,O_RDWR | O_EXCL); + if(fd < 0){ + fprintf(stderr, "Can't open " BUS "\n"); + exit(-1); + } + + data = 0; + if (ioctl(fd, NAF24(n, 0, 10), &data)) /* clear lam */ + goto xqerror; + + data = 0x20 | (ADC_D << 3) | ADC_T; + if (ioctl(fd, NAF24(n, 3, 16), &data)) + goto xqerror; + + data = 0; + if (ioctl(fd, NAF24(n, 2, 16), &data)) + goto xqerror; + + data = 0; + if (ioctl(fd, NAF24(n, 1, 16), &data)) + goto xqerror; + + + while(1){ + data = 0; + /* start adc */ + if (ioctl(fd, NAF24(n, 0, 25), &data)) + goto xqerror; + + /* wait */ + data =0; + while(1) { + if (!(ioctl(fd, NAF24(n, 0, 8), &data) & 0x1)) break; + } + + data = 0; + if (ioctl(fd, NAF24(n, 1, 16), &data)) + goto xqerror; + + if (ioctl(fd, NAF24(n, 0, 0), &data)) + goto xqerror; + + printf("ADC code: %05x",data); + + if (data & 0x80000) k = data - 0x100000; + else k = data; + v = 2 * k / (1 << (ADC_T + (ADC_D << 2))); + + if (ioctl(fd, NAF24(n, 0, 0), &data)) + break; + + printf(" u (mv) = %+.3f\n",v); + } + close(fd); + exit(0); + + help:; + printf("%s N\n", argv[0]); + exit(-1); + + xqerror:; + fprintf(stderr,"xq error\n"); + exit(-2); +} + diff --git a/tests/catch_lam.c b/tests/catch_lam.c new file mode 100644 index 0000000..5e068ca --- /dev/null +++ b/tests/catch_lam.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define BUS "/dev/lsi6card1channel2" + +int main(int argc, char **argv) +{ + int n,fd, data, i; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + + fd = open(BUS,O_RDWR | O_EXCL); + if(fd < 0){ + fprintf(stderr, "Can't open " BUS "\n"); + exit(-1); + } + + while(1){ + ioctl(fd, NAF(n, 0, 25), &data); /* LAM enable */ + data = 1000; +// data = -1; + i = ioctl(fd, CAMAC_LWAIT(CAM_L2G(n)), data); /* wait lam */ + if (i == -1) + printf("timeout\n"); + else + printf("LAM detected, time left %d\n", i); + + ioctl(fd, NAF(n, 0, 10), &data); /* LAM disable */ + } + + close(fd); + exit(0); + + help:; + printf("%s N\n", argv[0]); + exit(-1); +} + diff --git a/tests/indicator.c b/tests/indicator.c new file mode 100644 index 0000000..4ab600e --- /dev/null +++ b/tests/indicator.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include + + +#define CHANNEL "/dev/lsi6card1channel1" +#define A 0 +#define F_W 16 +#define F_R 0 + +int main(int argc, char **argv) +{ + int crate,xq, counter = 0xffffff; + int data; + int n; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + crate=open(CHANNEL,O_RDWR); + if (crate < 0) { + fprintf(stderr, "Can open %s\n", CHANNEL); + exit(-1); + } + + while(1) { + data = counter; + xq=CAM(crate, NAF24(n,A,F_W), &data); + if (xq & 2) { + fprintf(stderr, "Test failed1, xq = %d\n", xq); + break; + } + xq=CAM(crate, NAF24(n,A,F_R), &data); + if (xq & 2) { + fprintf(stderr, "Test failed2, xq = %d\n", xq); + break; + } + if (counter != data) { + fprintf(stderr, "Test failed, %x != %x\n", data, counter); + break; + } + counter++; + counter &= 0xffffff; + } + close(crate); + exit(-2); + + help:; + printf("%s N\n", argv[0]); + exit(-1); +} diff --git a/tests/naf.c b/tests/naf.c new file mode 100644 index 0000000..f822b61 --- /dev/null +++ b/tests/naf.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include + + +#define CHANNEL "/dev/lsi6card1channel1" +#define A 0 +#define F_W 16 +#define F_R 0 + +int main(int argc, char **argv) +{ + int crate,xq, counter = 0xffffff; + int data; + int n; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + crate=open(CHANNEL,O_RDWR); + if (crate < 0) { + fprintf(stderr, "Can open %s\n", CHANNEL); + exit(-1); + } + + while(1) { + xq=CAM(crate, NAF24(n,A,F_W), &data); + sleep(1); + } + close(crate); + exit(-2); + + help:; + printf("%s N\n", argv[0]); + exit(-1); +} diff --git a/tests/read_block.c b/tests/read_block.c new file mode 100644 index 0000000..06ef40b --- /dev/null +++ b/tests/read_block.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +#include + + +#define CHANNEL "/dev/lsi6card1channel2" +#define A 0 +#define F_W 16 +#define F_R 0 + +int buffer[1024]; + +int main(int argc, char **argv) +{ + int crate,xq; + int n,i; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + crate=open(CHANNEL,O_RDWR); + if (crate < 0) { + fprintf(stderr, "Can open %s\n", CHANNEL); + exit(-1); + } + + for(i = 0; i < 1024; i++) { + buffer[i] = 0; + } + + while(1) { + lseek(crate, NAF(n, A, F_R), SEEK_SET); + if ((i = read(crate, buffer, 1024*4)) != 1024*4) { + printf("read error %d\n", i); + break; + } + if (ioctl(crate, CAMAC_STATUS, &xq) != 0) { + printf("ioctl error\n"); + break; + } + if (xq & 2) { + printf("xq = %x\n", xq); + break; + } + for(i = 0; i < 1024; i++) { + if ((buffer[i] & 0xffff) != 0xaaaa) { + printf("Buffer error: i = %d, d = %x\n", i, buffer[i]); + break; + } + } + } + close(crate); + exit(-2); + + help:; + printf("%s N\n", argv[0]); + exit(-1); +} diff --git a/tests/rw_count2.c b/tests/rw_count2.c new file mode 100644 index 0000000..d9c99d0 --- /dev/null +++ b/tests/rw_count2.c @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include + + +#define CHANNEL "/dev/lsi6card1channel2" +#define A 0 +#define F_W 16 +#define F_R 0 + +int main(int argc, char **argv) +{ + int crate,xq, counter = 0xffff; + int data; + int n; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + crate=open(CHANNEL,O_RDWR); + if (crate < 0) { + fprintf(stderr, "Can open %s\n", CHANNEL); + exit(-1); + } + + while(1) { + data = counter; + + lseek(crate, NAF(n, A, F_W), SEEK_SET); + if (write(crate, &data, 2) != 2) { + printf("write error\n"); + break; + } + if (ioctl(crate, CAMAC_STATUS, &xq) != 0) { + printf("ioctl error\n"); + break; + } + if (xq & 2) { + printf("xq = %x\n", xq); + break; + } + + + lseek(crate, NAF(n, A, F_R), SEEK_SET); + data = 0; + if (read(crate, &data, 2) != 2) { + printf("read error\n"); + break; + } + if (data != counter) { + printf("read != write %x %x\n", data, counter); + break; + } + + if (ioctl(crate, CAMAC_STATUS, &xq) != 0) { + printf("ioctl error\n"); + break; + } + if (xq & 2) { + printf("xq = %x\n", xq); + break; + } + + counter++; + counter &= 0xffff; + } + close(crate); + exit(-2); + + help:; + printf("%s N\n", argv[0]); + exit(-1); +} diff --git a/tests/rw_count3.c b/tests/rw_count3.c new file mode 100644 index 0000000..74a02f4 --- /dev/null +++ b/tests/rw_count3.c @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include + + +#define CHANNEL "/dev/lsi6card1channel2" +#define A 0 +#define F_W 16 +#define F_R 0 + +int main(int argc, char **argv) +{ + int crate,xq, counter = 0xffffff; + int data; + int n; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + crate=open(CHANNEL,O_RDWR); + if (crate < 0) { + fprintf(stderr, "Can open %s\n", CHANNEL); + exit(-1); + } + + while(1) { + data = counter; + + lseek(crate, NAF(n, A, F_W), SEEK_SET); + if (write(crate, &data, 3) != 3) { + printf("write error\n"); + break; + } + if (ioctl(crate, CAMAC_STATUS, &xq) != 0) { + printf("ioctl error\n"); + break; + } + if (xq & 2) { + printf("xq = %x\n", xq); + break; + } + + + lseek(crate, NAF(n, A, F_R), SEEK_SET); + data = 0; + if (read(crate, &data, 3) != 3) { + printf("read error\n"); + break; + } + if (data != counter) { + printf("read != write %x %x\n", data, counter); + break; + } + + if (ioctl(crate, CAMAC_STATUS, &xq) != 0) { + printf("ioctl error\n"); + break; + } + if (xq & 2) { + printf("xq = %x\n", xq); + break; + } + + counter++; + counter &= 0xffffff; + } + close(crate); + exit(-2); + + help:; + printf("%s N\n", argv[0]); + exit(-1); +} diff --git a/tests/smi.c b/tests/smi.c new file mode 100644 index 0000000..cd25b21 --- /dev/null +++ b/tests/smi.c @@ -0,0 +1,136 @@ +#include +#include +#include +#include +#include +#include + +#define CHANNEL "/dev/lsi6card1channel2" + +#define MUX_N 7 +#define ADC_N 9 +#define ADC_T 7 +#define ADC_D 1 /* 1 - 0.5V, 0 - 8V */ + +#define DAC_N 11 + +int crate; + +void set_mux(int channel) +{ + int data; + int xq; + + data = channel; + xq = CAM(crate, NAF24(MUX_N, 0, 17), &data); +} +void mux_off(void) +{ + int data = 0x20; + int xq; + + xq = CAM(crate, NAF24(MUX_N, 0, 17), &data); +} + +void set_dac(float v) +{ + int data; + long k; + int xq; + + v = v * 1000000 / 15.625; + + if (v > 0) k = v; + else { k = -v; k |= 0x80000; }; + + data = k >> 4; + xq = CAM(crate, NAF24(DAC_N, 0, 18), &data); + + data = k & 0xf; + xq = CAM(crate, NAF24(DAC_N, 1, 18), &data); + + data = 0; + xq = CAM(crate, NAF24(DAC_N, 0, 26), &data); +} + +float read_adc(void) /* mv */ +{ + int xq; + int data; + float v, k; + + data = 0x20 | (ADC_D << 3) | ADC_T; + xq = CAM(crate, NAF24(ADC_N, 3, 16), &data); + + data = 0; + xq = CAM(crate, NAF24(ADC_N, 2, 16), &data); + + data = 0; + xq = CAM(crate, NAF24(ADC_N, 1, 16), &data); + + data = 0; + xq = CAM(crate, NAF24(ADC_N, 0, 25), &data); + + data =0; +#if 0 + usleep(1000000); +#else + while(1) { + xq = CAM(crate, NAF24(ADC_N, 0, 8), &data); + if (!(xq & 0x1)) break; + } + +#endif + data = 0; + xq = CAM(crate, NAF24(ADC_N, 1, 16), &data); + + xq = CAM(crate, NAF24(ADC_N, 0, 0), &data); + + printf("data = %08x, ", data); + + if (data & 0x80000) k = data - 0x100000; + else k = data; + v = 2 * k / (1 << (ADC_T + (ADC_D << 2))); + +printf("v=%9.4f\n",v); + + return v; +} + +int main(int arc, char **argv) +{ + int i; + + crate=open(CHANNEL,O_RDWR); + if (crate < 0) { + fprintf(stderr, "Can open %s\n", CHANNEL); + exit(-1); + } + + + set_dac(0.25); + +#if 0 + while(1) { + for(i = 0; i< 8; i++) { + set_mux(i + 8); + usleep(10000); + printf(" %9.4f",read_adc()); + fflush(stdout); + } + mux_off(); + printf("\n"); + usleep(1000000); + } + +#endif + while(1) { + usleep(10000); + read_adc(); + } + + + +} + + diff --git a/tests/start b/tests/start new file mode 100644 index 0000000..d632ad0 --- /dev/null +++ b/tests/start @@ -0,0 +1,2 @@ +./catch_lam 18 >/dev/null & +./indicator 12 diff --git a/tests/write_block.c b/tests/write_block.c new file mode 100644 index 0000000..8a73b89 --- /dev/null +++ b/tests/write_block.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include + + +#define CHANNEL "/dev/lsi6card1channel2" +#define A 0 +#define F_W 16 +#define F_R 0 + +int buffer[1024]; + +int main(int argc, char **argv) +{ + int crate,xq; + int n,i; + + if (argc != 2) + goto help; + + sscanf(argv[1], "%d", &n); + if ((n < 1) || (n > 23)) + goto help; + + crate=open(CHANNEL,O_RDWR); + if (crate < 0) { + fprintf(stderr, "Can open %s\n", CHANNEL); + exit(-1); + } + + for(i = 0; i < 1024; i++) { + buffer[i] = 0xaaaaaa; + } + + while(1) { + lseek(crate, NAF(n, A, F_W), SEEK_SET); + if ((i = write(crate, buffer, 1024*4)) != 1024*4) { + printf("write error %d\n", i); + break; + } + if (ioctl(crate, CAMAC_STATUS, &xq) != 0) { + printf("ioctl error\n"); + break; + } + if (xq & 2) { + printf("xq = %x\n", xq); + break; + } + + } + close(crate); + exit(-2); + + help:; + printf("%s N\n", argv[0]); + exit(-1); +}