Creation
This commit is contained in:
5
CMakeLists.txt
Normal file
5
CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(BoundaryScan)
|
||||
|
||||
add_subdirectory(lib_jtag_core)
|
||||
add_subdirectory(app)
|
||||
502
LICENSE
Normal file
502
LICENSE
Normal file
@@ -0,0 +1,502 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
11
app/CMakeLists.txt
Normal file
11
app/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
# Application configuration
|
||||
add_executable(
|
||||
bs
|
||||
main.c
|
||||
)
|
||||
|
||||
# linking configuration
|
||||
target_link_libraries(
|
||||
bs PRIVATE jtag_core
|
||||
)
|
||||
21
app/main.c
Normal file
21
app/main.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jtag_core.h"
|
||||
|
||||
|
||||
void jtcprint(jtag_core *jc, const char *msg) {
|
||||
printf(msg);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
jtag_core *jc;
|
||||
|
||||
jc = jtagcore_init();
|
||||
if (jtagcore_set_logs_callback(jc, jtcprint) < 0) goto end;
|
||||
|
||||
end:
|
||||
jtagcore_deinit(jc);
|
||||
printf("Finished.");
|
||||
return 0;
|
||||
}
|
||||
22
lib_jtag_core/CMakeLists.txt
Normal file
22
lib_jtag_core/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
|
||||
file(GLOB_RECURSE ALL_SOURCES "src/*.c")
|
||||
|
||||
# Custom command to be executed before the build
|
||||
add_custom_command(
|
||||
OUTPUT prebuild_command_done
|
||||
COMMAND cd "${SOURCE_DIR}" && xxd -i config.script > config_script.h
|
||||
COMMENT "Generating the config script"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Custom target that depends on the custom command
|
||||
add_custom_target(
|
||||
prebuild ALL
|
||||
DEPENDS prebuild_command_done
|
||||
)
|
||||
|
||||
add_library(jtag_core ${ALL_SOURCES})
|
||||
add_dependencies(jtag_core prebuild)
|
||||
|
||||
target_include_directories(jtag_core PUBLIC ${SOURCE_DIR})
|
||||
502
lib_jtag_core/src/COPYING.LESSER
Normal file
502
lib_jtag_core/src/COPYING.LESSER
Normal file
@@ -0,0 +1,502 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
1524
lib_jtag_core/src/bsdl_parser/bsdl_loader.c
Normal file
1524
lib_jtag_core/src/bsdl_parser/bsdl_loader.c
Normal file
File diff suppressed because it is too large
Load Diff
81
lib_jtag_core/src/bsdl_parser/bsdl_loader.h
Normal file
81
lib_jtag_core/src/bsdl_parser/bsdl_loader.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file bsdl_loader.h
|
||||
* @brief bsdl file parser header
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#define MAX_ELEMENT_SIZE (64+1)
|
||||
|
||||
typedef struct _pin_ctrl
|
||||
{
|
||||
char pinname[MAX_ELEMENT_SIZE];
|
||||
int pintype;
|
||||
|
||||
char physical_pin[MAX_ELEMENT_SIZE];
|
||||
|
||||
int ctrl_bit_number;
|
||||
int out_bit_number;
|
||||
int in_bit_number;
|
||||
}pin_ctrl;
|
||||
|
||||
typedef struct _jtag_chain
|
||||
{
|
||||
int bit_index;
|
||||
|
||||
int bit_cell_type; // BC_1,BC_2,...
|
||||
|
||||
char pinname[MAX_ELEMENT_SIZE]; // Pin name.
|
||||
|
||||
int bit_type; // None , ctrl , in, out.
|
||||
|
||||
int safe_state; // Default - Safe state. (0,1,-1)
|
||||
|
||||
int control_bit_index; // Indicate the associated control bit. -1 if no control bit.
|
||||
int control_disable_state;
|
||||
int control_disable_result;
|
||||
|
||||
}jtag_chain;
|
||||
|
||||
typedef struct _jtag_bsdl
|
||||
{
|
||||
unsigned long chip_id;
|
||||
unsigned long chip_id_mask;
|
||||
|
||||
char src_filename[512];
|
||||
char entity_name[512];
|
||||
|
||||
int number_of_chainbits;
|
||||
jtag_chain * chain_list;
|
||||
|
||||
int number_of_pins;
|
||||
pin_ctrl * pins_list;
|
||||
|
||||
int number_of_bits_per_instruction;
|
||||
char IDCODE_Instruction[MAX_ELEMENT_SIZE];
|
||||
char EXTEST_Instruction[MAX_ELEMENT_SIZE];
|
||||
char BYPASS_Instruction[MAX_ELEMENT_SIZE];
|
||||
char SAMPLE_Instruction[MAX_ELEMENT_SIZE];
|
||||
|
||||
}jtag_bsdl;
|
||||
|
||||
jtag_bsdl * load_bsdlfile(jtag_core * jc,char *filename);
|
||||
void unload_bsdlfile(jtag_core * jc, jtag_bsdl * bsdl);
|
||||
95
lib_jtag_core/src/bsdl_parser/bsdl_strings.c
Normal file
95
lib_jtag_core/src/bsdl_parser/bsdl_strings.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file bsdl_strings.c
|
||||
* @brief bsdl file string keywords
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../drivers/drv_loader.h"
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "bsdl_loader.h"
|
||||
#include "bsdl_strings.h"
|
||||
|
||||
type_strings celltype_str[]=
|
||||
{
|
||||
{"BC_1",CELLTYPE_BC1},
|
||||
{"BC_2",CELLTYPE_BC2},
|
||||
{"BC_3",CELLTYPE_BC3},
|
||||
{"BC_4",CELLTYPE_BC4},
|
||||
{"BC_5",CELLTYPE_BC5},
|
||||
{"BC_6",CELLTYPE_BC6},
|
||||
{"BC_7",CELLTYPE_BC7},
|
||||
|
||||
{0,CELLTYPE_UNKNOWN}
|
||||
};
|
||||
|
||||
type_strings bittype_str[]=
|
||||
{
|
||||
{"INPUT",BITTYPE_INPUT},
|
||||
{"OBSERVE_ONLY",BITTYPE_INPUT},
|
||||
{"OUTPUT",BITTYPE_OUTPUT},
|
||||
{"OUTPUT2", BITTYPE_OUTPUT },
|
||||
{"OUTPUT3",BITTYPE_TRISTATE_OUTPUT},
|
||||
{"BIDIR",BITTYPE_INOUT},
|
||||
{"CONTROL",BITTYPE_CONTROL},
|
||||
{"CONTROLR",BITTYPE_CONTROL},
|
||||
{"INTERNAL",BITTYPE_INTERNAL},
|
||||
{0,BITTYPE_UNKNOWN}
|
||||
};
|
||||
|
||||
type_strings statetype_str[]=
|
||||
{
|
||||
{"X",STATE_UNDEF},
|
||||
{"1",STATE_HIGH},
|
||||
{"0",STATE_LOW},
|
||||
{"Z",STATE_HIGHZ},
|
||||
{0,STATE_UNKNOWN}
|
||||
};
|
||||
|
||||
type_strings pintype_str[]=
|
||||
{
|
||||
{"IN",IO_IN},
|
||||
{"OUT",IO_OUT},
|
||||
{"INOUT",IO_INOUT},
|
||||
{"BUFFER", IO_OUT },
|
||||
{0,IO_UNDEF}
|
||||
};
|
||||
|
||||
int get_typecode(type_strings * typelist,char * name)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while( typelist[i].type_name )
|
||||
{
|
||||
if(!strcmp( typelist[i].type_name, name ) )
|
||||
{
|
||||
return typelist[i].type_code;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return typelist[i].type_code;
|
||||
}
|
||||
77
lib_jtag_core/src/bsdl_parser/bsdl_strings.h
Normal file
77
lib_jtag_core/src/bsdl_parser/bsdl_strings.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file bsdl_strings.h
|
||||
* @brief bsdl file string keywords header
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
typedef struct type_strings_
|
||||
{
|
||||
char * type_name;
|
||||
int type_code;
|
||||
}type_strings;
|
||||
|
||||
enum CELLTYPE
|
||||
{
|
||||
CELLTYPE_UNKNOWN = 0x00,
|
||||
CELLTYPE_BC1,
|
||||
CELLTYPE_BC2,
|
||||
CELLTYPE_BC3,
|
||||
CELLTYPE_BC4,
|
||||
CELLTYPE_BC5,
|
||||
CELLTYPE_BC6,
|
||||
CELLTYPE_BC7
|
||||
};
|
||||
|
||||
enum BITTYPE
|
||||
{
|
||||
BITTYPE_UNKNOWN = 0x00,
|
||||
BITTYPE_INPUT,
|
||||
BITTYPE_OUTPUT,
|
||||
BITTYPE_TRISTATE_OUTPUT,
|
||||
BITTYPE_INOUT,
|
||||
BITTYPE_CONTROL,
|
||||
BITTYPE_INTERNAL
|
||||
};
|
||||
|
||||
enum STATETYPE
|
||||
{
|
||||
STATE_UNKNOWN = 0x00,
|
||||
STATE_UNDEF,
|
||||
STATE_HIGH,
|
||||
STATE_LOW,
|
||||
STATE_HIGHZ
|
||||
};
|
||||
|
||||
enum PINIOTYPE
|
||||
{
|
||||
IO_UNDEF = 0x00,
|
||||
IO_IN,
|
||||
IO_OUT,
|
||||
IO_INOUT
|
||||
};
|
||||
|
||||
extern type_strings celltype_str[];
|
||||
extern type_strings bittype_str[];
|
||||
extern type_strings statetype_str[];
|
||||
extern type_strings pintype_str[];
|
||||
|
||||
int get_typecode(type_strings * typelist,char * name);
|
||||
359
lib_jtag_core/src/bus_over_jtag/i2c_over_jtag.c
Normal file
359
lib_jtag_core/src/bus_over_jtag/i2c_over_jtag.c
Normal file
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file i2c_over_jtag.c
|
||||
* @brief I2C over jtag API
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../drivers/drv_loader.h"
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../drivers/drivers_list.h"
|
||||
|
||||
#include "../dbg_logs.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// I2C Over JTAG API
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int jtagcore_i2c_set_scl_pin(jtag_core * jc, int device, int pin)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->i2c_scl_pin = pin;
|
||||
jc->i2c_scl_device = device;
|
||||
|
||||
jtagcore_logs_printf(jc,MSG_DEBUG,"jtagcore_i2c_set_scl_pin : device %d, pin %d\r\n",device,pin);
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
else
|
||||
jtagcore_logs_printf(jc,MSG_DEBUG,"jtagcore_i2c_set_scl_pin : ERROR invalid pin %d\r\n",pin);
|
||||
}
|
||||
else
|
||||
jtagcore_logs_printf(jc,MSG_DEBUG,"jtagcore_i2c_set_scl_pin : ERROR bsdl not loaded\r\n");
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_i2c_set_sda_pin(jtag_core * jc, int device, int pin)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->i2c_sda_pin = pin;
|
||||
jc->i2c_sda_device = device;
|
||||
|
||||
jtagcore_logs_printf(jc,MSG_DEBUG,"jtagcore_i2c_set_sda_pin : device %d, pin %d\r\n",device,pin);
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
else
|
||||
jtagcore_logs_printf(jc,MSG_DEBUG,"jtagcore_i2c_set_sda_pin : ERROR invalid pin %d\r\n",pin);
|
||||
}
|
||||
else
|
||||
jtagcore_logs_printf(jc,MSG_DEBUG,"jtagcore_i2c_set_sda_pin : ERROR bsdl not loaded\r\n");
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
static void jtagcore_i2c_set_scl_state_high(jtag_core * jc)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->i2c_scl_device, jc->i2c_scl_pin, JTAG_CORE_OE, 0);
|
||||
jtagcore_set_pin_state(jc, jc->i2c_scl_device, jc->i2c_scl_pin, JTAG_CORE_OUTPUT, 1);
|
||||
}
|
||||
|
||||
static void jtagcore_i2c_set_scl_state_low(jtag_core * jc)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->i2c_scl_device, jc->i2c_scl_pin, JTAG_CORE_OE, 1);
|
||||
jtagcore_set_pin_state(jc, jc->i2c_scl_device, jc->i2c_scl_pin, JTAG_CORE_OUTPUT, 0);
|
||||
}
|
||||
|
||||
static void jtagcore_i2c_set_sda_state_high(jtag_core * jc)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->i2c_sda_device, jc->i2c_sda_pin, JTAG_CORE_OE, 0);
|
||||
jtagcore_set_pin_state(jc, jc->i2c_sda_device, jc->i2c_sda_pin, JTAG_CORE_OUTPUT, 1);
|
||||
}
|
||||
|
||||
static void jtagcore_i2c_set_sda_state_low(jtag_core * jc)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->i2c_sda_device, jc->i2c_sda_pin, JTAG_CORE_OE, 1);
|
||||
jtagcore_set_pin_state(jc, jc->i2c_sda_device, jc->i2c_sda_pin, JTAG_CORE_OUTPUT, 0);
|
||||
}
|
||||
|
||||
static void i2c_start_bit(jtag_core * jc)
|
||||
{
|
||||
// Start bit.
|
||||
|
||||
jtagcore_i2c_set_sda_state_low(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_i2c_set_scl_state_low(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
}
|
||||
|
||||
static void i2c_push_bit(jtag_core * jc, int sda_state)
|
||||
{
|
||||
if (sda_state)
|
||||
{
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_i2c_set_sda_state_low(jc);
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_i2c_set_scl_state_low(jc);
|
||||
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
if (!sda_state)
|
||||
{
|
||||
// jtagcore_i2c_set_sda_state_high(jc);
|
||||
// jtagcore_push_and_pop_chain(jc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void i2c_stop_bit(jtag_core * jc)
|
||||
{
|
||||
// Stop bit.
|
||||
|
||||
jtagcore_i2c_set_sda_state_low(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
}
|
||||
|
||||
|
||||
static int i2c_wait_ack(jtag_core * jc)
|
||||
{
|
||||
int i, acknowledged;
|
||||
|
||||
acknowledged = 0;
|
||||
|
||||
// ACK
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
return JTAG_CORE_IO_ERROR;
|
||||
}
|
||||
|
||||
i++;
|
||||
} while (jtagcore_get_pin_state(jc, jc->i2c_sda_device, jc->i2c_sda_pin, JTAG_CORE_INPUT) && i < 10);
|
||||
|
||||
if (i < 10)
|
||||
acknowledged = 1;
|
||||
|
||||
jtagcore_i2c_set_scl_state_low(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
return acknowledged;
|
||||
}
|
||||
|
||||
int jtagcore_i2c_write_read(jtag_core * jc, int address, int address10bits,int wr_size,unsigned char * wr_buffer,int rd_size,unsigned char * rd_buffer)
|
||||
{
|
||||
int i,j,acknowledged;
|
||||
|
||||
acknowledged = 0;
|
||||
|
||||
if( jc )
|
||||
{
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
// Is the bus Free / High state?
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
return JTAG_CORE_IO_ERROR;
|
||||
}
|
||||
|
||||
if (!jtagcore_get_pin_state(jc, jc->i2c_sda_device, jc->i2c_sda_pin, JTAG_CORE_INPUT) || !jtagcore_get_pin_state(jc, jc->i2c_scl_device, jc->i2c_scl_pin, JTAG_CORE_INPUT))
|
||||
{
|
||||
return JTAG_CORE_I2C_BUS_NOTFREE;
|
||||
}
|
||||
|
||||
// Start bit.
|
||||
i2c_start_bit(jc);
|
||||
|
||||
for(i=0;i<7;i++)
|
||||
{
|
||||
i2c_push_bit(jc, address & (0x80 >> i));
|
||||
}
|
||||
|
||||
// WR/RD
|
||||
if(wr_size)
|
||||
{
|
||||
i2c_push_bit(jc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
i2c_push_bit(jc, 1);
|
||||
}
|
||||
|
||||
// ACK
|
||||
acknowledged = i2c_wait_ack(jc);
|
||||
|
||||
if( acknowledged < 0 ) // Error ?
|
||||
{
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
return acknowledged;
|
||||
}
|
||||
|
||||
if(wr_size)
|
||||
{
|
||||
for(i=0;i<wr_size;i++)
|
||||
{
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
i2c_push_bit(jc, wr_buffer[i] & (0x80 >> j));
|
||||
}
|
||||
|
||||
// ACK
|
||||
i2c_push_bit(jc, 1);
|
||||
}
|
||||
|
||||
// Stop bit.
|
||||
i2c_stop_bit(jc);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<rd_size;i++)
|
||||
{
|
||||
rd_buffer[i] = 0x00;
|
||||
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
do
|
||||
{
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
return JTAG_CORE_IO_ERROR;
|
||||
}
|
||||
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
jtagcore_i2c_set_scl_state_high(jc);
|
||||
jtagcore_i2c_set_sda_state_high(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
return JTAG_CORE_IO_ERROR;
|
||||
}
|
||||
}while(!jtagcore_get_pin_state(jc,jc->i2c_scl_device,jc->i2c_scl_pin,JTAG_CORE_INPUT));
|
||||
|
||||
|
||||
if(jtagcore_get_pin_state(jc,jc->i2c_sda_device,jc->i2c_sda_pin,JTAG_CORE_INPUT))
|
||||
{
|
||||
rd_buffer[i] |= 0x80>>j;
|
||||
}
|
||||
|
||||
jtagcore_i2c_set_scl_state_low(jc);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if(i!=rd_size-1)
|
||||
{
|
||||
// ACK
|
||||
i2c_push_bit(jc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// NACK
|
||||
i2c_push_bit(jc, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Stop bit.
|
||||
i2c_stop_bit(jc);
|
||||
}
|
||||
|
||||
return acknowledged;
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
292
lib_jtag_core/src/bus_over_jtag/mdio_over_jtag.c
Normal file
292
lib_jtag_core/src/bus_over_jtag/mdio_over_jtag.c
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file mdio_over_jtag.c
|
||||
* @brief MDC/MDIO over jtag API
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../drivers/drv_loader.h"
|
||||
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../drivers/drivers_list.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MDIO Over JTAG API
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int jtagcore_mdio_set_mdc_pin(jtag_core * jc, int device, int pin)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->mdio_mdc_pin = pin;
|
||||
jc->mdio_mdc_device = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_mdio_set_mdio_pin(jtag_core * jc, int device, int pin)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >=0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->mdio_mdio_pin = pin;
|
||||
jc->mdio_mdio_device = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
static void mdio_push_bit(jtag_core * jc, int bit_state)
|
||||
{
|
||||
if (bit_state)
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdio_device, jc->mdio_mdio_pin, JTAG_CORE_OE, 0); // MDIO High
|
||||
else
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdio_device, jc->mdio_mdio_pin, JTAG_CORE_OE, 1); // MDIO Low
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OUTPUT, 0); // MDC Low
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OUTPUT, 1); // MDC High
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
}
|
||||
|
||||
|
||||
static int mdio_get_bit(jtag_core * jc)
|
||||
{
|
||||
int state;
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OUTPUT, 1); // MDC High
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OUTPUT, 0); // MDC Low
|
||||
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
return JTAG_CORE_IO_ERROR;
|
||||
}
|
||||
|
||||
state = jtagcore_get_pin_state(jc, jc->mdio_mdio_device, jc->mdio_mdio_pin, JTAG_CORE_INPUT);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
int jtagcore_mdio_write(jtag_core * jc, int phy_adr, int reg_adr, int data)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( jc )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OE, 1);
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdio_device, jc->mdio_mdio_pin, JTAG_CORE_OE, 0);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OUTPUT, 0);
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdio_device, jc->mdio_mdio_pin, JTAG_CORE_OUTPUT, 0);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
}
|
||||
|
||||
// Start.
|
||||
mdio_push_bit(jc, 0);
|
||||
mdio_push_bit(jc, 1);
|
||||
|
||||
//Write
|
||||
mdio_push_bit(jc, 0);
|
||||
mdio_push_bit(jc, 1);
|
||||
|
||||
// dev address
|
||||
for (i=0;i<5;i++)
|
||||
{
|
||||
if(phy_adr & (0x10>>i))
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mdio_push_bit(jc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// reg address
|
||||
for (i=0;i<5;i++)
|
||||
{
|
||||
if(reg_adr & (0x10>>i))
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mdio_push_bit(jc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//TA
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 0);
|
||||
|
||||
// data
|
||||
for (i=0;i<16;i++)
|
||||
{
|
||||
if(data & (0x8000>>i))
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mdio_push_bit(jc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_mdio_read(jtag_core * jc, int phy_adr, int reg_adr)
|
||||
{
|
||||
int i,data;
|
||||
int bit_state;
|
||||
|
||||
if( jc )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OE, 1);
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdio_device, jc->mdio_mdio_pin, JTAG_CORE_OE, 0);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OUTPUT, 0);
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdio_device, jc->mdio_mdio_pin, JTAG_CORE_OUTPUT, 0);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
}
|
||||
|
||||
// Start.
|
||||
mdio_push_bit(jc, 0);
|
||||
mdio_push_bit(jc, 1);
|
||||
|
||||
//Read
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 0);
|
||||
|
||||
// dev address
|
||||
for (i=0;i<5;i++)
|
||||
{
|
||||
if(phy_adr & (0x10>>i))
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mdio_push_bit(jc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// reg address
|
||||
for (i=0;i<5;i++)
|
||||
{
|
||||
if(reg_adr & (0x10>>i))
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mdio_push_bit(jc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// TA
|
||||
mdio_push_bit(jc, 1);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->mdio_mdc_device, jc->mdio_mdc_pin, JTAG_CORE_OUTPUT, 0); // MDC Low
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
data = 0;
|
||||
// data
|
||||
for (i=0;i<16;i++)
|
||||
{
|
||||
bit_state = mdio_get_bit(jc);
|
||||
if(bit_state < 0 )
|
||||
{
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 1);
|
||||
|
||||
return bit_state;
|
||||
}
|
||||
|
||||
if(bit_state)
|
||||
{
|
||||
data |= (0x8000>>i);
|
||||
}
|
||||
}
|
||||
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 1);
|
||||
mdio_push_bit(jc, 1);
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
325
lib_jtag_core/src/bus_over_jtag/memory_over_jtag.c
Normal file
325
lib_jtag_core/src/bus_over_jtag/memory_over_jtag.c
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file memory_over_jtag.c
|
||||
* @brief parallel memory over jtag API
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../drivers/drv_loader.h"
|
||||
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../drivers/drivers_list.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Memory Over JTAG API
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int jtagcore_memory_clear_pins(jtag_core * jc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<MAX_BUS_WIDTH;i++)
|
||||
{
|
||||
jc->ram_address_pin[i] = -1;
|
||||
jc->ram_address_device[i] = -1;
|
||||
jc->ram_data_pin[i] = -1;
|
||||
jc->ram_data_device[i] = -1;
|
||||
}
|
||||
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
jc->ram_ctrl_pin[i] = -1;
|
||||
jc->ram_ctrl_pin_pol[i] = -1;
|
||||
jc->ram_ctrl_device[i] = -1;
|
||||
}
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
|
||||
int jtagcore_memory_set_address_pin(jtag_core * jc, int address_bit, int device, int pin)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && address_bit < MAX_BUS_WIDTH)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if ( pin < bsdl_file->number_of_pins && pin >= 0 )
|
||||
{
|
||||
jc->ram_address_pin[address_bit] = pin;
|
||||
jc->ram_address_device[address_bit] = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_memory_set_data_pin(jtag_core * jc, int data_bit, int device, int pin)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && data_bit < MAX_BUS_WIDTH)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if ( pin < bsdl_file->number_of_pins && pin >= 0 )
|
||||
{
|
||||
jc->ram_data_pin[data_bit] = pin;
|
||||
jc->ram_data_device[data_bit] = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_memory_set_ctrl_pin(jtag_core * jc, int ctrl, int polarity, int device, int pin)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && ctrl < 16)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if ( pin < bsdl_file->number_of_pins && pin >= 0 )
|
||||
{
|
||||
jc->ram_ctrl_pin[ctrl] = pin;
|
||||
jc->ram_ctrl_pin_pol[ctrl] = polarity;
|
||||
jc->ram_ctrl_device[ctrl] = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
unsigned long jtagcore_memory_read(jtag_core * jc, int mem_adr)
|
||||
{
|
||||
int i;
|
||||
unsigned long value;
|
||||
|
||||
// Set address bus
|
||||
for(i=0;i<MAX_BUS_WIDTH;i++)
|
||||
{
|
||||
if(jc->ram_address_pin[i]>=0 && jc->ram_address_device[i]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_address_device[i], jc->ram_address_pin[i], JTAG_CORE_OE, 1);
|
||||
|
||||
if( mem_adr & (0x00000001<<i) )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_address_device[i], jc->ram_address_pin[i], JTAG_CORE_OUTPUT, 1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_address_device[i], jc->ram_address_pin[i], JTAG_CORE_OUTPUT, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set data bus tristate.
|
||||
for(i=0;i<MAX_BUS_WIDTH;i++)
|
||||
{
|
||||
if(jc->ram_data_pin[i]>=0 && jc->ram_data_device[i]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_data_device[i], jc->ram_data_pin[i], JTAG_CORE_OE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// deassert control pins.
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
if(jc->ram_ctrl_pin[i]>=0 && jc->ram_ctrl_device[i]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[i], jc->ram_ctrl_pin[i], JTAG_CORE_OE, 1);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[i], jc->ram_ctrl_pin[i], JTAG_CORE_OUTPUT, (jc->ram_ctrl_pin_pol[i]&1)^1 );
|
||||
}
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
// Assert CS
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL], JTAG_CORE_OUTPUT, jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_CS_CTRL] & 1 );
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
// Assert RD
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_RD_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_RD_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_RD_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_RD_CTRL], JTAG_CORE_OUTPUT, jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_RD_CTRL] & 1 );
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
return (unsigned long)-1;
|
||||
}
|
||||
|
||||
// read the data bus.
|
||||
value = 0x00000000;
|
||||
for(i=0;i<MAX_BUS_WIDTH;i++)
|
||||
{
|
||||
if(jc->ram_data_pin[i]>=0 && jc->ram_data_device[i]>=0)
|
||||
{
|
||||
if(jtagcore_get_pin_state(jc, jc->ram_data_device[i], jc->ram_data_pin[i], JTAG_CORE_INPUT))
|
||||
{
|
||||
value |= (0x00000001<<i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dessert RD
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_RD_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_RD_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_RD_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_RD_CTRL], JTAG_CORE_OUTPUT, ( jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_RD_CTRL] & 1 ) ^ 1 );
|
||||
}
|
||||
|
||||
// deassert CS
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL], JTAG_CORE_OUTPUT, ( jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_CS_CTRL] & 1 ) ^ 1 );
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int jtagcore_memory_write(jtag_core * jc, int mem_adr, unsigned long data)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
// Set address bus
|
||||
for(i=0;i<MAX_BUS_WIDTH;i++)
|
||||
{
|
||||
if(jc->ram_address_pin[i]>=0 && jc->ram_address_device[i]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_address_device[i], jc->ram_address_pin[i], JTAG_CORE_OE, 1);
|
||||
|
||||
if( mem_adr & (0x00000001<<i) )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_address_device[i], jc->ram_address_pin[i], JTAG_CORE_OUTPUT, 1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_address_device[i], jc->ram_address_pin[i], JTAG_CORE_OUTPUT, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set data bus
|
||||
for(i=0;i<MAX_BUS_WIDTH;i++)
|
||||
{
|
||||
if(jc->ram_data_pin[i]>=0 && jc->ram_data_device[i]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_data_device[i], jc->ram_data_pin[i], JTAG_CORE_OE, 1);
|
||||
|
||||
if( data & (0x00000001<<i) )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_data_device[i], jc->ram_data_pin[i], JTAG_CORE_OUTPUT, 1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_data_device[i], jc->ram_data_pin[i], JTAG_CORE_OUTPUT, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// deassert control pins.
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
if(jc->ram_ctrl_pin[i]>=0 && jc->ram_ctrl_device[i]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[i], jc->ram_ctrl_pin[i], JTAG_CORE_OE, 1);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[i], jc->ram_ctrl_pin[i], JTAG_CORE_OUTPUT, (jc->ram_ctrl_pin_pol[i]&1)^1 );
|
||||
}
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
// Assert CS
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL], JTAG_CORE_OUTPUT, jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_CS_CTRL] & 1 );
|
||||
}
|
||||
|
||||
// Assert WR
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_WR_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_WR_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_WR_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_WR_CTRL], JTAG_CORE_OUTPUT, jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_WR_CTRL] & 1 );
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
// dessert WR
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_WR_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_WR_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_WR_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_WR_CTRL], JTAG_CORE_OUTPUT, (jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_WR_CTRL] & 1) ^ 1 );
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
// deassert CS
|
||||
if(jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL]>=0 && jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_ctrl_device[JTAG_CORE_RAM_CS_CTRL], jc->ram_ctrl_pin[JTAG_CORE_RAM_CS_CTRL], JTAG_CORE_OUTPUT, ( jc->ram_ctrl_pin_pol[JTAG_CORE_RAM_CS_CTRL] & 1 ) ^ 1 );
|
||||
}
|
||||
|
||||
// Set data bus tristate.
|
||||
for(i=0;i<MAX_BUS_WIDTH;i++)
|
||||
{
|
||||
if(jc->ram_data_pin[i]>=0 && jc->ram_data_device[i]>=0)
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->ram_data_device[i], jc->ram_data_pin[i], JTAG_CORE_OE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
290
lib_jtag_core/src/bus_over_jtag/spi_over_jtag.c
Normal file
290
lib_jtag_core/src/bus_over_jtag/spi_over_jtag.c
Normal file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file spi_over_jtag.c
|
||||
* @brief spi over jtag API
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../drivers/drv_loader.h"
|
||||
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../drivers/drivers_list.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SPI Over JTAG API
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int jtagcore_spi_set_mosi_pin(jtag_core * jc, int device, int pin, int sample_clk_phase)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->spi_mosi_pin = pin;
|
||||
if(sample_clk_phase)
|
||||
jc->spi_mosi_pol = 1;
|
||||
else
|
||||
jc->spi_mosi_pol = 0;
|
||||
jc->spi_mosi_device = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_spi_set_miso_pin(jtag_core * jc, int device, int pin, int sample_clk_phase)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->spi_miso_pin = pin;
|
||||
if(sample_clk_phase)
|
||||
jc->spi_miso_pol = 1;
|
||||
else
|
||||
jc->spi_miso_pol = 0;
|
||||
jc->spi_miso_device = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_spi_set_clk_pin(jtag_core * jc, int device, int pin, int polarity)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->spi_clk_pin = pin;
|
||||
if(polarity)
|
||||
jc->spi_clk_pol = 1;
|
||||
else
|
||||
jc->spi_clk_pol = 0;
|
||||
jc->spi_clk_device = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_spi_set_cs_pin(jtag_core * jc, int device, int pin, int polarity)
|
||||
{
|
||||
jtag_bsdl * bsdl_file;
|
||||
|
||||
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
|
||||
{
|
||||
if (jc->devices_list[device].bsdl)
|
||||
{
|
||||
bsdl_file = jc->devices_list[device].bsdl;
|
||||
|
||||
if (pin < bsdl_file->number_of_pins && pin >= 0)
|
||||
{
|
||||
jc->spi_cs_pin = pin;
|
||||
if(polarity)
|
||||
jc->spi_cs_pol = 1;
|
||||
else
|
||||
jc->spi_cs_pol = 0;
|
||||
jc->spi_cs_device = device;
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_spi_set_bitorder(jtag_core * jc, int lsb_first)
|
||||
{
|
||||
if(lsb_first)
|
||||
jc->spi_lsb_first = 1;
|
||||
else
|
||||
jc->spi_lsb_first = 0;
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
int jtagcore_spi_write_read(jtag_core * jc, int wr_size,unsigned char * wr_buffer,unsigned char * rd_buffer, int flags)
|
||||
{
|
||||
int i,j;
|
||||
unsigned char byte_mask;
|
||||
|
||||
if( jc )
|
||||
{
|
||||
if(jc->spi_lsb_first)
|
||||
byte_mask = (0x01);
|
||||
else
|
||||
byte_mask = (0x80);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->spi_mosi_device, jc->spi_mosi_pin, JTAG_CORE_OUTPUT, 0);
|
||||
if(wr_size)
|
||||
{
|
||||
if( wr_buffer[0] & byte_mask )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->spi_mosi_device, jc->spi_mosi_pin, JTAG_CORE_OUTPUT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->spi_miso_device, jc->spi_miso_pin, JTAG_CORE_OUTPUT, 1);
|
||||
jtagcore_set_pin_state(jc, jc->spi_cs_device, jc->spi_cs_pin, JTAG_CORE_OUTPUT, 1 ^ jc->spi_cs_pol);
|
||||
jtagcore_set_pin_state(jc, jc->spi_clk_device, jc->spi_clk_pin, JTAG_CORE_OUTPUT, 0 ^ jc->spi_clk_pol);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->spi_miso_device, jc->spi_miso_pin, JTAG_CORE_OE, 0);
|
||||
jtagcore_set_pin_state(jc, jc->spi_mosi_device, jc->spi_mosi_pin, JTAG_CORE_OE, 1);
|
||||
jtagcore_set_pin_state(jc, jc->spi_cs_device, jc->spi_cs_pin, JTAG_CORE_OE, 1);
|
||||
jtagcore_set_pin_state(jc, jc->spi_clk_device, jc->spi_clk_pin, JTAG_CORE_OE, 1);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->spi_cs_device, jc->spi_cs_pin, JTAG_CORE_OUTPUT, 0 ^ jc->spi_cs_pol);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
for(i=0;i<wr_size;i++)
|
||||
{
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
if(jc->spi_lsb_first)
|
||||
byte_mask = (0x01<<j);
|
||||
else
|
||||
byte_mask = (0x80>>j);
|
||||
|
||||
if(!jc->spi_mosi_pol) // CPHA = 0
|
||||
{ // MOSI OUT on clock phase 0
|
||||
if( wr_buffer[i] & byte_mask )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->spi_mosi_device, jc->spi_mosi_pin, JTAG_CORE_OUTPUT, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->spi_mosi_device, jc->spi_mosi_pin, JTAG_CORE_OUTPUT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(!jc->spi_miso_pol) // CPHA = 0
|
||||
{ // MISO IN on clock phase 0
|
||||
|
||||
// clock phase 0
|
||||
jtagcore_set_pin_state(jc, jc->spi_clk_device, jc->spi_clk_pin, JTAG_CORE_OUTPUT, 1 ^ jc->spi_clk_pol);
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
return JTAG_CORE_IO_ERROR;
|
||||
}
|
||||
|
||||
if(jtagcore_get_pin_state(jc,jc->spi_miso_device,jc->spi_miso_pin,JTAG_CORE_INPUT))
|
||||
{
|
||||
rd_buffer[i] |= byte_mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
rd_buffer[i] &= ~(byte_mask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// clock phase 0
|
||||
jtagcore_set_pin_state(jc, jc->spi_clk_device, jc->spi_clk_pin, JTAG_CORE_OUTPUT, 1 ^ jc->spi_clk_pol);
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if(jc->spi_mosi_pol) // CPHA = 1
|
||||
{ // MOSI OUT on clock phase 1
|
||||
if( wr_buffer[i] & byte_mask )
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->spi_mosi_device, jc->spi_mosi_pin, JTAG_CORE_OUTPUT, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_set_pin_state(jc, jc->spi_mosi_device, jc->spi_mosi_pin, JTAG_CORE_OUTPUT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(jc->spi_miso_pol) // CPHA = 1
|
||||
{
|
||||
// clock phase 1
|
||||
jtagcore_set_pin_state(jc, jc->spi_clk_device, jc->spi_clk_pin, JTAG_CORE_OUTPUT, 0 ^ jc->spi_clk_pol);
|
||||
|
||||
if ( jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_READ) != JTAG_CORE_NO_ERROR )
|
||||
{
|
||||
return JTAG_CORE_IO_ERROR;
|
||||
}
|
||||
|
||||
// MISO IN on clock phase 1
|
||||
if(jtagcore_get_pin_state(jc,jc->spi_miso_device,jc->spi_miso_pin,JTAG_CORE_INPUT))
|
||||
{
|
||||
rd_buffer[i] |= byte_mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
rd_buffer[i] &= ~(byte_mask);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// clock phase 1
|
||||
jtagcore_set_pin_state(jc, jc->spi_clk_device, jc->spi_clk_pin, JTAG_CORE_OUTPUT, 0 ^ jc->spi_clk_pol);
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jtagcore_set_pin_state(jc, jc->spi_cs_device, jc->spi_cs_pin, JTAG_CORE_OUTPUT, 1 ^ jc->spi_cs_pol);
|
||||
|
||||
jtagcore_push_and_pop_chain(jc, JTAG_CORE_WRITE_ONLY);
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
182
lib_jtag_core/src/config.script
Normal file
182
lib_jtag_core/src/config.script
Normal file
@@ -0,0 +1,182 @@
|
||||
#
|
||||
# lib jtag core init config script
|
||||
#
|
||||
# This script is built-in the jtag library and is executed at startup to apply
|
||||
# the default variables values.
|
||||
#
|
||||
# You can put a "config.script" file in the JTAG boundaryscanner software's
|
||||
# folder to change one or more of these variables if needed.
|
||||
# Your "config.script" will be executed right after this script at startup.
|
||||
# The syntax to use in your script is exactly the same.
|
||||
#
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# Log messages filter level
|
||||
#
|
||||
# 0 : Debug messages
|
||||
# 1 : Info level 0 messages
|
||||
# 2 : Info level 1 messages
|
||||
# 3 : Warning level messages
|
||||
# 4 : Error level messages
|
||||
# 5 : No log / no message
|
||||
|
||||
set LOG_MESSAGES_FILTER_LEVEL 1
|
||||
|
||||
# Log file
|
||||
|
||||
#set LOG_MESSAGES_FILE_OUTPUT "logs_file.txt"
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Pins name sorter
|
||||
#
|
||||
# 0 To keep the bsdl pins order.
|
||||
# 1 To sort the bsdl pins name.
|
||||
#
|
||||
|
||||
set BSDL_LOADER_SORT_PINS_NAME 1
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# This section expose the FTDI probes parameters
|
||||
#
|
||||
|
||||
#
|
||||
# Parameters to compute the FDTI FT2232D/H clock divisor.
|
||||
# ( TCK clock = (12Mhz or 60Mhz)/ ((1 + ([ValueH << 8 | ValueL]))*2) )
|
||||
#
|
||||
|
||||
# Internal clock : FT2232H -> 60 MHz, FT2232D -> 12MHz
|
||||
|
||||
set PROBE_FTDI_INTERNAL_FREQ_KHZ 60000
|
||||
|
||||
# Max TCK Clock
|
||||
|
||||
set PROBE_FTDI_TCK_FREQ_KHZ 1000
|
||||
|
||||
#
|
||||
# To enable the RTCK / adaptative clock mode set the following
|
||||
# variable to 1.
|
||||
# Warning : Need a FDTI chip supporting this mode (FT2232H,...)
|
||||
#
|
||||
|
||||
set PROBE_FTDI_JTAG_ENABLE_RTCK 0
|
||||
|
||||
#
|
||||
# Probe internal mapping
|
||||
#
|
||||
# Olimex ARM-USB-OCD-H JTAG signals example
|
||||
#
|
||||
# VREF – voltage follower input for the output buffers adjust
|
||||
# JTAG signals as per your target board voltage levels
|
||||
#
|
||||
# The TCK/TDI/TDO/TMS signals are fixed to these pins
|
||||
# ADBUS0 -> TCK; (out)
|
||||
# ADBUS1 -> TDI; (out)
|
||||
# ADBUS2 -> TDO; (in)
|
||||
# ADBUS3 -> TMS; (out)
|
||||
|
||||
# ADBUS4 -> 0 to enable JTAG buffers; (GPIOL0) (out)
|
||||
# ADBUS5 -> 0 if target present; (GPIOL1) (in)
|
||||
# ADBUS6 -> TSRST in; (GPIOL2) (in)
|
||||
# ADBUS7 -> RTCK; (in) (GPIOL3) (in)
|
||||
# ACBUS0 -> TRST; (GPIOH0)
|
||||
# ACBUS1 -> SRST; (GPIOH1)
|
||||
# ACBUS2 -> TRST buffer enable (GPIOH2)
|
||||
# ACBUS3 -> RED LED; (GPIOH3)
|
||||
|
||||
#
|
||||
# Set the internal GPIO direction (0 -> input, 1 -> output)
|
||||
#
|
||||
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS0 1 # TCK -> out
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS1 1 # TDI -> out
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS2 0 # TDO -> in
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS3 1 # TMS -> out
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS4 1 # Buffers enable -> out
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS5 0 # Target presence : 0 if target present -> in
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS6 0 # TSRST -> in
|
||||
set PROBE_FTDI_SET_PIN_DIR_ADBUS7 0 # RTCK -> in
|
||||
|
||||
set PROBE_FTDI_SET_PIN_DIR_ACBUS0 1 # TRST -> out
|
||||
set PROBE_FTDI_SET_PIN_DIR_ACBUS1 1 # SRST -> out
|
||||
set PROBE_FTDI_SET_PIN_DIR_ACBUS2 1 # TRST buffer enable -> out
|
||||
set PROBE_FTDI_SET_PIN_DIR_ACBUS3 1 # RED LED -> out
|
||||
|
||||
#
|
||||
# Set the internal GPIOs output state
|
||||
#
|
||||
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS0 0
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS1 0
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS2 0
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS3 1
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS4 0 # JTAG buffer enable (active low)
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS5 0
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS6 0
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS7 0
|
||||
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ACBUS0 0 # TRST
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ACBUS1 0 # SRST
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ACBUS2 0 # TRST buffer enable
|
||||
set PROBE_FTDI_SET_PIN_DEFAULT_STATE_ACBUS3 0 # RED LED
|
||||
|
||||
#
|
||||
# Set the internal GPIOs polarity
|
||||
# 0 : Active High.
|
||||
# 1 : Active Low.
|
||||
#
|
||||
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS0 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS1 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS2 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS3 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS4 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS5 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS6 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ADBUS7 0
|
||||
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ACBUS0 1 # TRST is active-low
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ACBUS1 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ACBUS2 0
|
||||
set PROBE_FTDI_SET_PIN_POLARITY_ACBUS3 0
|
||||
|
||||
#
|
||||
# Assign the TRST / SRST control pins
|
||||
# 0<>7 : ADBUS
|
||||
# 8<>11 : ACBUS
|
||||
# Set to -1 when not available/used.
|
||||
#
|
||||
|
||||
set PROBE_FTDI_SET_TRST_OE_PINNUM 10
|
||||
set PROBE_FTDI_SET_TRST_STATE_PINNUM 8
|
||||
|
||||
set PROBE_FTDI_SET_SRST_OE_PINNUM -1
|
||||
set PROBE_FTDI_SET_SRST_STATE_PINNUM -1
|
||||
|
||||
set PROBE_FTDI_SET_CONNECTION_LED_PINNUM 11
|
||||
|
||||
set PROBE_FTDI_JTAG_TRST_DELAY_MS 200
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set PROBE_LINUXGPIO_ENABLE 0
|
||||
|
||||
set PROBE_LINUXGPIO_BASE_FOLDER "/sys/class/gpio"
|
||||
|
||||
set PROBE_LINUXGPIO_TMS_PIN 24
|
||||
set PROBE_LINUXGPIO_TDI_PIN 25
|
||||
set PROBE_LINUXGPIO_TDO_PIN 26
|
||||
set PROBE_LINUXGPIO_TCK_PIN 27
|
||||
|
||||
set PROBE_LINUXGPIO_TMS_PIN_INVERT_POLARITY 0
|
||||
set PROBE_LINUXGPIO_TDI_PIN_INVERT_POLARITY 0
|
||||
set PROBE_LINUXGPIO_TDO_PIN_INVERT_POLARITY 0
|
||||
set PROBE_LINUXGPIO_TCK_PIN_INVERT_POLARITY 0
|
||||
500
lib_jtag_core/src/config_script.h
Normal file
500
lib_jtag_core/src/config_script.h
Normal file
@@ -0,0 +1,500 @@
|
||||
unsigned char config_script[] = {
|
||||
0x23, 0x0d, 0x0a, 0x23, 0x20, 0x6c, 0x69, 0x62, 0x20, 0x6a, 0x74, 0x61,
|
||||
0x67, 0x20, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x20,
|
||||
0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x73, 0x63, 0x72, 0x69, 0x70,
|
||||
0x74, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x54, 0x68, 0x69, 0x73,
|
||||
0x20, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x69, 0x73, 0x20, 0x62,
|
||||
0x75, 0x69, 0x6c, 0x74, 0x2d, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20,
|
||||
0x6a, 0x74, 0x61, 0x67, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
|
||||
0x20, 0x61, 0x6e, 0x64, 0x20, 0x69, 0x73, 0x20, 0x65, 0x78, 0x65, 0x63,
|
||||
0x75, 0x74, 0x65, 0x64, 0x20, 0x61, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72,
|
||||
0x74, 0x75, 0x70, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x79,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x74, 0x68, 0x65, 0x20, 0x64, 0x65, 0x66, 0x61,
|
||||
0x75, 0x6c, 0x74, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65,
|
||||
0x73, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2e, 0x0d, 0x0a, 0x23,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x59, 0x6f, 0x75, 0x20, 0x63, 0x61, 0x6e, 0x20,
|
||||
0x70, 0x75, 0x74, 0x20, 0x61, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x66, 0x69,
|
||||
0x67, 0x2e, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x22, 0x20, 0x66, 0x69,
|
||||
0x6c, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4a, 0x54,
|
||||
0x41, 0x47, 0x20, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x73,
|
||||
0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x20, 0x73, 0x6f, 0x66, 0x74, 0x77,
|
||||
0x61, 0x72, 0x65, 0x27, 0x73, 0x0d, 0x0a, 0x23, 0x20, 0x66, 0x6f, 0x6c,
|
||||
0x64, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67,
|
||||
0x65, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x6f, 0x72, 0x20, 0x6d, 0x6f, 0x72,
|
||||
0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x73, 0x65, 0x20, 0x76,
|
||||
0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x20, 0x69, 0x66, 0x20,
|
||||
0x6e, 0x65, 0x65, 0x64, 0x65, 0x64, 0x2e, 0x0d, 0x0a, 0x23, 0x20, 0x59,
|
||||
0x6f, 0x75, 0x72, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x22, 0x20, 0x77, 0x69, 0x6c, 0x6c,
|
||||
0x20, 0x62, 0x65, 0x20, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64,
|
||||
0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x61, 0x66, 0x74, 0x65, 0x72,
|
||||
0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x20, 0x61, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x75, 0x70, 0x2e,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x54, 0x68, 0x65, 0x20, 0x73, 0x79, 0x6e, 0x74,
|
||||
0x61, 0x78, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x73, 0x65, 0x20, 0x69, 0x6e,
|
||||
0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x20, 0x69, 0x73, 0x20, 0x65, 0x78, 0x61, 0x63, 0x74, 0x6c, 0x79, 0x20,
|
||||
0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x65, 0x2e, 0x0d, 0x0a, 0x23,
|
||||
0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a,
|
||||
0x23, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x20,
|
||||
0x4c, 0x6f, 0x67, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73,
|
||||
0x20, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x20, 0x6c, 0x65, 0x76, 0x65,
|
||||
0x6c, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x30, 0x20, 0x3a, 0x20,
|
||||
0x44, 0x65, 0x62, 0x75, 0x67, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x73, 0x0d, 0x0a, 0x23, 0x20, 0x31, 0x20, 0x3a, 0x20, 0x49, 0x6e,
|
||||
0x66, 0x6f, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x20, 0x30, 0x20, 0x6d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x0d, 0x0a, 0x23, 0x20, 0x32,
|
||||
0x20, 0x3a, 0x20, 0x49, 0x6e, 0x66, 0x6f, 0x20, 0x6c, 0x65, 0x76, 0x65,
|
||||
0x6c, 0x20, 0x31, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x33, 0x20, 0x3a, 0x20, 0x57, 0x61, 0x72, 0x6e,
|
||||
0x69, 0x6e, 0x67, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x20, 0x6d, 0x65,
|
||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x0d, 0x0a, 0x23, 0x20, 0x34, 0x20,
|
||||
0x3a, 0x20, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x6c, 0x65, 0x76, 0x65,
|
||||
0x6c, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x0d, 0x0a,
|
||||
0x23, 0x20, 0x35, 0x20, 0x3a, 0x20, 0x4e, 0x6f, 0x20, 0x6c, 0x6f, 0x67,
|
||||
0x20, 0x2f, 0x20, 0x6e, 0x6f, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x4c, 0x4f, 0x47,
|
||||
0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x53, 0x5f, 0x46, 0x49,
|
||||
0x4c, 0x54, 0x45, 0x52, 0x5f, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x20, 0x31,
|
||||
0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x20, 0x4c, 0x6f, 0x67, 0x20, 0x66, 0x69,
|
||||
0x6c, 0x65, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x73, 0x65, 0x74, 0x20, 0x4c,
|
||||
0x4f, 0x47, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x53, 0x5f,
|
||||
0x46, 0x49, 0x4c, 0x45, 0x5f, 0x4f, 0x55, 0x54, 0x50, 0x55, 0x54, 0x20,
|
||||
0x22, 0x6c, 0x6f, 0x67, 0x73, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x74,
|
||||
0x78, 0x74, 0x22, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x20, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x0d, 0x0a, 0x23, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x50, 0x69, 0x6e, 0x73, 0x20, 0x6e,
|
||||
0x61, 0x6d, 0x65, 0x20, 0x73, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x0d, 0x0a,
|
||||
0x23, 0x0d, 0x0a, 0x23, 0x20, 0x30, 0x20, 0x54, 0x6f, 0x20, 0x6b, 0x65,
|
||||
0x65, 0x70, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x73, 0x64, 0x6c, 0x20,
|
||||
0x70, 0x69, 0x6e, 0x73, 0x20, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x0d,
|
||||
0x0a, 0x23, 0x20, 0x31, 0x20, 0x54, 0x6f, 0x20, 0x73, 0x6f, 0x72, 0x74,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x73, 0x64, 0x6c, 0x20, 0x70, 0x69,
|
||||
0x6e, 0x73, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x2e, 0x0d, 0x0a, 0x23, 0x0d,
|
||||
0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x42, 0x53, 0x44, 0x4c, 0x5f,
|
||||
0x4c, 0x4f, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x53, 0x4f, 0x52, 0x54, 0x5f,
|
||||
0x50, 0x49, 0x4e, 0x53, 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x20, 0x31, 0x0d,
|
||||
0x0a, 0x0d, 0x0a, 0x23, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a, 0x23,
|
||||
0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d, 0x0a,
|
||||
0x23, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x73, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x20, 0x65, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x46, 0x54, 0x44, 0x49, 0x20, 0x70, 0x72, 0x6f, 0x62, 0x65,
|
||||
0x73, 0x20, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73,
|
||||
0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20,
|
||||
0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x20, 0x74,
|
||||
0x6f, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x46, 0x44, 0x54, 0x49, 0x20, 0x46, 0x54, 0x32, 0x32, 0x33,
|
||||
0x32, 0x44, 0x2f, 0x48, 0x20, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x64,
|
||||
0x69, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x0d, 0x0a, 0x23, 0x20, 0x28,
|
||||
0x20, 0x54, 0x43, 0x4b, 0x20, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x3d,
|
||||
0x20, 0x28, 0x31, 0x32, 0x4d, 0x68, 0x7a, 0x20, 0x6f, 0x72, 0x20, 0x36,
|
||||
0x30, 0x4d, 0x68, 0x7a, 0x29, 0x2f, 0x20, 0x28, 0x28, 0x31, 0x20, 0x2b,
|
||||
0x20, 0x28, 0x5b, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x20, 0x3c, 0x3c,
|
||||
0x20, 0x38, 0x20, 0x7c, 0x20, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4c, 0x5d,
|
||||
0x29, 0x29, 0x2a, 0x32, 0x29, 0x20, 0x29, 0x0d, 0x0a, 0x23, 0x0d, 0x0a,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
|
||||
0x20, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x3a, 0x20, 0x46, 0x54, 0x32,
|
||||
0x32, 0x33, 0x32, 0x48, 0x20, 0x2d, 0x3e, 0x20, 0x36, 0x30, 0x20, 0x4d,
|
||||
0x48, 0x7a, 0x2c, 0x20, 0x46, 0x54, 0x32, 0x32, 0x33, 0x32, 0x44, 0x20,
|
||||
0x2d, 0x3e, 0x20, 0x31, 0x32, 0x4d, 0x48, 0x7a, 0x0d, 0x0a, 0x0d, 0x0a,
|
||||
0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54,
|
||||
0x44, 0x49, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x5f,
|
||||
0x46, 0x52, 0x45, 0x51, 0x5f, 0x4b, 0x48, 0x5a, 0x20, 0x36, 0x30, 0x30,
|
||||
0x30, 0x30, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x20, 0x4d, 0x61, 0x78, 0x20,
|
||||
0x54, 0x43, 0x4b, 0x20, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46,
|
||||
0x54, 0x44, 0x49, 0x5f, 0x54, 0x43, 0x4b, 0x5f, 0x46, 0x52, 0x45, 0x51,
|
||||
0x5f, 0x4b, 0x48, 0x5a, 0x20, 0x31, 0x30, 0x30, 0x30, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x54, 0x6f, 0x20, 0x65, 0x6e, 0x61,
|
||||
0x62, 0x6c, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x52, 0x54, 0x43, 0x4b,
|
||||
0x20, 0x2f, 0x20, 0x61, 0x64, 0x61, 0x70, 0x74, 0x61, 0x74, 0x69, 0x76,
|
||||
0x65, 0x20, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x6d, 0x6f, 0x64, 0x65,
|
||||
0x20, 0x73, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x6c,
|
||||
0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x0d, 0x0a, 0x23, 0x20, 0x76, 0x61,
|
||||
0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x31, 0x2e,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x20,
|
||||
0x3a, 0x20, 0x4e, 0x65, 0x65, 0x64, 0x20, 0x61, 0x20, 0x46, 0x44, 0x54,
|
||||
0x49, 0x20, 0x63, 0x68, 0x69, 0x70, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6f,
|
||||
0x72, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6d,
|
||||
0x6f, 0x64, 0x65, 0x20, 0x28, 0x46, 0x54, 0x32, 0x32, 0x33, 0x32, 0x48,
|
||||
0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x0d, 0x0a,
|
||||
0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54,
|
||||
0x44, 0x49, 0x5f, 0x4a, 0x54, 0x41, 0x47, 0x5f, 0x45, 0x4e, 0x41, 0x42,
|
||||
0x4c, 0x45, 0x5f, 0x52, 0x54, 0x43, 0x4b, 0x20, 0x30, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x20,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x70,
|
||||
0x70, 0x69, 0x6e, 0x67, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x4f,
|
||||
0x6c, 0x69, 0x6d, 0x65, 0x78, 0x20, 0x41, 0x52, 0x4d, 0x2d, 0x55, 0x53,
|
||||
0x42, 0x2d, 0x4f, 0x43, 0x44, 0x2d, 0x48, 0x20, 0x4a, 0x54, 0x41, 0x47,
|
||||
0x20, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x20, 0x65, 0x78, 0x61,
|
||||
0x6d, 0x70, 0x6c, 0x65, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x56,
|
||||
0x52, 0x45, 0x46, 0x20, 0xe2, 0x80, 0x93, 0x20, 0x76, 0x6f, 0x6c, 0x74,
|
||||
0x61, 0x67, 0x65, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72,
|
||||
0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x62, 0x75,
|
||||
0x66, 0x66, 0x65, 0x72, 0x73, 0x20, 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x4a, 0x54, 0x41, 0x47, 0x20, 0x73, 0x69, 0x67,
|
||||
0x6e, 0x61, 0x6c, 0x73, 0x20, 0x61, 0x73, 0x20, 0x70, 0x65, 0x72, 0x20,
|
||||
0x79, 0x6f, 0x75, 0x72, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20,
|
||||
0x62, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x76, 0x6f, 0x6c, 0x74, 0x61, 0x67,
|
||||
0x65, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x73, 0x0d, 0x0a, 0x23, 0x0d,
|
||||
0x0a, 0x23, 0x20, 0x54, 0x68, 0x65, 0x20, 0x54, 0x43, 0x4b, 0x2f, 0x54,
|
||||
0x44, 0x49, 0x2f, 0x54, 0x44, 0x4f, 0x2f, 0x54, 0x4d, 0x53, 0x20, 0x73,
|
||||
0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x66,
|
||||
0x69, 0x78, 0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x73,
|
||||
0x65, 0x20, 0x70, 0x69, 0x6e, 0x73, 0x0d, 0x0a, 0x23, 0x20, 0x41, 0x44,
|
||||
0x42, 0x55, 0x53, 0x30, 0x20, 0x2d, 0x3e, 0x20, 0x54, 0x43, 0x4b, 0x3b,
|
||||
0x20, 0x28, 0x6f, 0x75, 0x74, 0x29, 0x0d, 0x0a, 0x23, 0x20, 0x41, 0x44,
|
||||
0x42, 0x55, 0x53, 0x31, 0x20, 0x2d, 0x3e, 0x20, 0x54, 0x44, 0x49, 0x3b,
|
||||
0x20, 0x28, 0x6f, 0x75, 0x74, 0x29, 0x0d, 0x0a, 0x23, 0x20, 0x41, 0x44,
|
||||
0x42, 0x55, 0x53, 0x32, 0x20, 0x2d, 0x3e, 0x20, 0x54, 0x44, 0x4f, 0x3b,
|
||||
0x20, 0x28, 0x69, 0x6e, 0x29, 0x0d, 0x0a, 0x23, 0x20, 0x41, 0x44, 0x42,
|
||||
0x55, 0x53, 0x33, 0x20, 0x2d, 0x3e, 0x20, 0x54, 0x4d, 0x53, 0x3b, 0x20,
|
||||
0x28, 0x6f, 0x75, 0x74, 0x29, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x20, 0x41,
|
||||
0x44, 0x42, 0x55, 0x53, 0x34, 0x20, 0x2d, 0x3e, 0x20, 0x30, 0x20, 0x74,
|
||||
0x6f, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x4a, 0x54, 0x41,
|
||||
0x47, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x73, 0x3b, 0x20, 0x20,
|
||||
0x28, 0x47, 0x50, 0x49, 0x4f, 0x4c, 0x30, 0x29, 0x20, 0x28, 0x6f, 0x75,
|
||||
0x74, 0x29, 0x0d, 0x0a, 0x23, 0x20, 0x41, 0x44, 0x42, 0x55, 0x53, 0x35,
|
||||
0x20, 0x2d, 0x3e, 0x20, 0x30, 0x20, 0x69, 0x66, 0x20, 0x74, 0x61, 0x72,
|
||||
0x67, 0x65, 0x74, 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x3b,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x47, 0x50, 0x49, 0x4f,
|
||||
0x4c, 0x31, 0x29, 0x20, 0x28, 0x69, 0x6e, 0x29, 0x0d, 0x0a, 0x23, 0x20,
|
||||
0x41, 0x44, 0x42, 0x55, 0x53, 0x36, 0x20, 0x2d, 0x3e, 0x20, 0x54, 0x53,
|
||||
0x52, 0x53, 0x54, 0x20, 0x69, 0x6e, 0x3b, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x28, 0x47, 0x50, 0x49, 0x4f, 0x4c, 0x32, 0x29, 0x20, 0x28, 0x69,
|
||||
0x6e, 0x29, 0x0d, 0x0a, 0x23, 0x20, 0x41, 0x44, 0x42, 0x55, 0x53, 0x37,
|
||||
0x20, 0x2d, 0x3e, 0x20, 0x52, 0x54, 0x43, 0x4b, 0x3b, 0x20, 0x28, 0x69,
|
||||
0x6e, 0x29, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x47, 0x50, 0x49, 0x4f,
|
||||
0x4c, 0x33, 0x29, 0x20, 0x28, 0x69, 0x6e, 0x29, 0x0d, 0x0a, 0x23, 0x20,
|
||||
0x41, 0x43, 0x42, 0x55, 0x53, 0x30, 0x20, 0x2d, 0x3e, 0x20, 0x54, 0x52,
|
||||
0x53, 0x54, 0x3b, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x28, 0x47, 0x50, 0x49, 0x4f, 0x48, 0x30, 0x29, 0x0d, 0x0a, 0x23,
|
||||
0x20, 0x41, 0x43, 0x42, 0x55, 0x53, 0x31, 0x20, 0x2d, 0x3e, 0x20, 0x53,
|
||||
0x52, 0x53, 0x54, 0x3b, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x28, 0x47, 0x50, 0x49, 0x4f, 0x48, 0x31, 0x29, 0x0d, 0x0a,
|
||||
0x23, 0x20, 0x41, 0x43, 0x42, 0x55, 0x53, 0x32, 0x20, 0x2d, 0x3e, 0x20,
|
||||
0x54, 0x52, 0x53, 0x54, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x20,
|
||||
0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x28, 0x47, 0x50, 0x49, 0x4f, 0x48, 0x32, 0x29, 0x0d,
|
||||
0x0a, 0x23, 0x20, 0x41, 0x43, 0x42, 0x55, 0x53, 0x33, 0x20, 0x2d, 0x3e,
|
||||
0x20, 0x52, 0x45, 0x44, 0x20, 0x4c, 0x45, 0x44, 0x3b, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x28, 0x47, 0x50, 0x49, 0x4f, 0x48, 0x33, 0x29,
|
||||
0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20, 0x53, 0x65, 0x74,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61,
|
||||
0x6c, 0x20, 0x47, 0x50, 0x49, 0x4f, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x30, 0x20, 0x2d, 0x3e, 0x20, 0x69,
|
||||
0x6e, 0x70, 0x75, 0x74, 0x2c, 0x20, 0x31, 0x20, 0x2d, 0x3e, 0x20, 0x6f,
|
||||
0x75, 0x74, 0x70, 0x75, 0x74, 0x29, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46,
|
||||
0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f,
|
||||
0x44, 0x49, 0x52, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x30, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x31,
|
||||
0x20, 0x23, 0x20, 0x54, 0x43, 0x4b, 0x20, 0x2d, 0x3e, 0x20, 0x6f, 0x75,
|
||||
0x74, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45,
|
||||
0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49,
|
||||
0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x31,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x31, 0x20, 0x23, 0x20, 0x54, 0x44, 0x49, 0x20, 0x2d, 0x3e, 0x20,
|
||||
0x6f, 0x75, 0x74, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f,
|
||||
0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f,
|
||||
0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41, 0x44, 0x42, 0x55,
|
||||
0x53, 0x32, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x30, 0x20, 0x23, 0x20, 0x54, 0x44, 0x4f, 0x20, 0x2d,
|
||||
0x3e, 0x20, 0x69, 0x6e, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52,
|
||||
0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54,
|
||||
0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41, 0x44, 0x42,
|
||||
0x55, 0x53, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x31, 0x20, 0x23, 0x20, 0x54, 0x4d, 0x53, 0x20,
|
||||
0x2d, 0x3e, 0x20, 0x6f, 0x75, 0x74, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20,
|
||||
0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53,
|
||||
0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41,
|
||||
0x44, 0x42, 0x55, 0x53, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x31, 0x20, 0x23, 0x20, 0x42, 0x75,
|
||||
0x66, 0x66, 0x65, 0x72, 0x73, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65,
|
||||
0x20, 0x2d, 0x3e, 0x20, 0x6f, 0x75, 0x74, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f,
|
||||
0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f,
|
||||
0x41, 0x44, 0x42, 0x55, 0x53, 0x35, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x20, 0x23, 0x20, 0x54,
|
||||
0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e,
|
||||
0x63, 0x65, 0x20, 0x3a, 0x20, 0x30, 0x20, 0x69, 0x66, 0x20, 0x74, 0x61,
|
||||
0x72, 0x67, 0x65, 0x74, 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74,
|
||||
0x20, 0x2d, 0x3e, 0x20, 0x69, 0x6e, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20,
|
||||
0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53,
|
||||
0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41,
|
||||
0x44, 0x42, 0x55, 0x53, 0x36, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x20, 0x23, 0x20, 0x54, 0x53,
|
||||
0x52, 0x53, 0x54, 0x20, 0x2d, 0x3e, 0x20, 0x69, 0x6e, 0x0d, 0x0a, 0x73,
|
||||
0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44,
|
||||
0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49,
|
||||
0x52, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x37, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x20, 0x23,
|
||||
0x20, 0x52, 0x54, 0x43, 0x4b, 0x20, 0x2d, 0x3e, 0x20, 0x69, 0x6e, 0x0d,
|
||||
0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45,
|
||||
0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49,
|
||||
0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41, 0x43, 0x42, 0x55, 0x53, 0x30,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x31, 0x20, 0x23, 0x20, 0x54, 0x52, 0x53, 0x54, 0x20, 0x2d, 0x3e,
|
||||
0x20, 0x6f, 0x75, 0x74, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52,
|
||||
0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54,
|
||||
0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41, 0x43, 0x42,
|
||||
0x55, 0x53, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x31, 0x20, 0x23, 0x20, 0x53, 0x52, 0x53, 0x54,
|
||||
0x20, 0x2d, 0x3e, 0x20, 0x6f, 0x75, 0x74, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f,
|
||||
0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x49, 0x52, 0x5f,
|
||||
0x41, 0x43, 0x42, 0x55, 0x53, 0x32, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x31, 0x20, 0x23, 0x20, 0x54,
|
||||
0x52, 0x53, 0x54, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x20, 0x65,
|
||||
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x2d, 0x3e, 0x20, 0x6f, 0x75, 0x74,
|
||||
0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f,
|
||||
0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e,
|
||||
0x5f, 0x44, 0x49, 0x52, 0x5f, 0x41, 0x43, 0x42, 0x55, 0x53, 0x33, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x31, 0x20, 0x23, 0x20, 0x52, 0x45, 0x44, 0x20, 0x4c, 0x45, 0x44, 0x20,
|
||||
0x2d, 0x3e, 0x20, 0x6f, 0x75, 0x74, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d,
|
||||
0x0a, 0x23, 0x20, 0x53, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x47, 0x50, 0x49, 0x4f,
|
||||
0x73, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x73, 0x74, 0x61,
|
||||
0x74, 0x65, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f,
|
||||
0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x45, 0x46, 0x41,
|
||||
0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x41, 0x44,
|
||||
0x42, 0x55, 0x53, 0x30, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65,
|
||||
0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49,
|
||||
0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x45, 0x46,
|
||||
0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x41,
|
||||
0x44, 0x42, 0x55, 0x53, 0x31, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a, 0x73,
|
||||
0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44,
|
||||
0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x45,
|
||||
0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f,
|
||||
0x41, 0x44, 0x42, 0x55, 0x53, 0x32, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a,
|
||||
0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54,
|
||||
0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44,
|
||||
0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45,
|
||||
0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x33, 0x20, 0x20, 0x20, 0x31, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46,
|
||||
0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f,
|
||||
0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54,
|
||||
0x45, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x34, 0x20, 0x20, 0x20, 0x30,
|
||||
0x20, 0x23, 0x20, 0x4a, 0x54, 0x41, 0x47, 0x20, 0x62, 0x75, 0x66, 0x66,
|
||||
0x65, 0x72, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x28, 0x61,
|
||||
0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x6c, 0x6f, 0x77, 0x29, 0x0d, 0x0a,
|
||||
0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54,
|
||||
0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44,
|
||||
0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45,
|
||||
0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x35, 0x20, 0x20, 0x20, 0x30, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46,
|
||||
0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f,
|
||||
0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54,
|
||||
0x45, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x36, 0x20, 0x20, 0x20, 0x30,
|
||||
0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f,
|
||||
0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e,
|
||||
0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41,
|
||||
0x54, 0x45, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x37, 0x20, 0x20, 0x20,
|
||||
0x30, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f,
|
||||
0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f,
|
||||
0x50, 0x49, 0x4e, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f,
|
||||
0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x41, 0x43, 0x42, 0x55, 0x53, 0x30,
|
||||
0x20, 0x20, 0x20, 0x30, 0x20, 0x23, 0x20, 0x54, 0x52, 0x53, 0x54, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46,
|
||||
0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f,
|
||||
0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54,
|
||||
0x45, 0x5f, 0x41, 0x43, 0x42, 0x55, 0x53, 0x31, 0x20, 0x20, 0x20, 0x30,
|
||||
0x20, 0x23, 0x20, 0x53, 0x52, 0x53, 0x54, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f,
|
||||
0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x45, 0x46, 0x41,
|
||||
0x55, 0x4c, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x41, 0x43,
|
||||
0x42, 0x55, 0x53, 0x32, 0x20, 0x20, 0x20, 0x30, 0x20, 0x23, 0x20, 0x54,
|
||||
0x52, 0x53, 0x54, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x20, 0x65,
|
||||
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50,
|
||||
0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45,
|
||||
0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c,
|
||||
0x54, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x41, 0x43, 0x42, 0x55,
|
||||
0x53, 0x33, 0x20, 0x20, 0x20, 0x30, 0x20, 0x23, 0x20, 0x52, 0x45, 0x44,
|
||||
0x20, 0x4c, 0x45, 0x44, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23,
|
||||
0x20, 0x53, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x47, 0x50, 0x49, 0x4f, 0x73, 0x20,
|
||||
0x70, 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x74, 0x79, 0x0d, 0x0a, 0x23, 0x20,
|
||||
0x30, 0x20, 0x3a, 0x20, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x48,
|
||||
0x69, 0x67, 0x68, 0x2e, 0x0d, 0x0a, 0x23, 0x20, 0x31, 0x20, 0x3a, 0x20,
|
||||
0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x4c, 0x6f, 0x77, 0x2e, 0x0d,
|
||||
0x0a, 0x23, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52,
|
||||
0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54,
|
||||
0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54,
|
||||
0x59, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x30, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50,
|
||||
0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45,
|
||||
0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49,
|
||||
0x54, 0x59, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x31, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20,
|
||||
0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53,
|
||||
0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52,
|
||||
0x49, 0x54, 0x59, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x32, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f,
|
||||
0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x50, 0x4f, 0x4c, 0x41,
|
||||
0x52, 0x49, 0x54, 0x59, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x33, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65,
|
||||
0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49,
|
||||
0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x50, 0x4f, 0x4c,
|
||||
0x41, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53, 0x34,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a, 0x73,
|
||||
0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44,
|
||||
0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x50, 0x4f,
|
||||
0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x41, 0x44, 0x42, 0x55, 0x53,
|
||||
0x35, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x0d, 0x0a,
|
||||
0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54,
|
||||
0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x50,
|
||||
0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x41, 0x44, 0x42, 0x55,
|
||||
0x53, 0x36, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46,
|
||||
0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e, 0x5f,
|
||||
0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x41, 0x44, 0x42,
|
||||
0x55, 0x53, 0x37, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30,
|
||||
0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42,
|
||||
0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50,
|
||||
0x49, 0x4e, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x5f,
|
||||
0x41, 0x43, 0x42, 0x55, 0x53, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x31, 0x20, 0x23, 0x20, 0x54, 0x52, 0x53, 0x54, 0x20, 0x69,
|
||||
0x73, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2d, 0x6c, 0x6f, 0x77,
|
||||
0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f,
|
||||
0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49, 0x4e,
|
||||
0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x41, 0x43,
|
||||
0x42, 0x55, 0x53, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45,
|
||||
0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50, 0x49,
|
||||
0x4e, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x41,
|
||||
0x43, 0x42, 0x55, 0x53, 0x32, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42,
|
||||
0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x50,
|
||||
0x49, 0x4e, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x5f,
|
||||
0x41, 0x43, 0x42, 0x55, 0x53, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x30, 0x0d, 0x0a, 0x0d, 0x0a, 0x23, 0x0d, 0x0a, 0x23, 0x20,
|
||||
0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x54,
|
||||
0x52, 0x53, 0x54, 0x20, 0x2f, 0x20, 0x53, 0x52, 0x53, 0x54, 0x20, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x20, 0x70, 0x69, 0x6e, 0x73, 0x0d,
|
||||
0x0a, 0x23, 0x20, 0x30, 0x3c, 0x3e, 0x37, 0x20, 0x20, 0x3a, 0x20, 0x41,
|
||||
0x44, 0x42, 0x55, 0x53, 0x0d, 0x0a, 0x23, 0x20, 0x38, 0x3c, 0x3e, 0x31,
|
||||
0x31, 0x20, 0x3a, 0x20, 0x41, 0x43, 0x42, 0x55, 0x53, 0x0d, 0x0a, 0x23,
|
||||
0x20, 0x53, 0x65, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x2d, 0x31, 0x20, 0x77,
|
||||
0x68, 0x65, 0x6e, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x61, 0x76, 0x61, 0x69,
|
||||
0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2f, 0x75, 0x73, 0x65, 0x64, 0x2e, 0x0d,
|
||||
0x0a, 0x23, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52,
|
||||
0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54,
|
||||
0x5f, 0x54, 0x52, 0x53, 0x54, 0x5f, 0x4f, 0x45, 0x5f, 0x50, 0x49, 0x4e,
|
||||
0x4e, 0x55, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x31, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20,
|
||||
0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53,
|
||||
0x45, 0x54, 0x5f, 0x54, 0x52, 0x53, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x54,
|
||||
0x45, 0x5f, 0x50, 0x49, 0x4e, 0x4e, 0x55, 0x4d, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x0d, 0x0a, 0x0d, 0x0a, 0x73,
|
||||
0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44,
|
||||
0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x53, 0x52, 0x53, 0x54, 0x5f, 0x4f,
|
||||
0x45, 0x5f, 0x50, 0x49, 0x4e, 0x4e, 0x55, 0x4d, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x31, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46,
|
||||
0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f, 0x53, 0x52, 0x53, 0x54,
|
||||
0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x49, 0x4e, 0x4e, 0x55,
|
||||
0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d,
|
||||
0x31, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f,
|
||||
0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f, 0x53, 0x45, 0x54, 0x5f,
|
||||
0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c,
|
||||
0x45, 0x44, 0x5f, 0x50, 0x49, 0x4e, 0x4e, 0x55, 0x4d, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x31, 0x31, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x46, 0x54, 0x44, 0x49, 0x5f,
|
||||
0x4a, 0x54, 0x41, 0x47, 0x5f, 0x54, 0x52, 0x53, 0x54, 0x5f, 0x44, 0x45,
|
||||
0x4c, 0x41, 0x59, 0x5f, 0x4d, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x30, 0x30, 0x0d, 0x0a,
|
||||
0x0d, 0x0a, 0x23, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a, 0x23, 0x20,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20,
|
||||
0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x47,
|
||||
0x50, 0x49, 0x4f, 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x20, 0x30,
|
||||
0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42,
|
||||
0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x47, 0x50, 0x49, 0x4f, 0x5f,
|
||||
0x42, 0x41, 0x53, 0x45, 0x5f, 0x46, 0x4f, 0x4c, 0x44, 0x45, 0x52, 0x20,
|
||||
0x22, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x2f,
|
||||
0x67, 0x70, 0x69, 0x6f, 0x22, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58,
|
||||
0x47, 0x50, 0x49, 0x4f, 0x5f, 0x54, 0x4d, 0x53, 0x5f, 0x50, 0x49, 0x4e,
|
||||
0x20, 0x32, 0x34, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f,
|
||||
0x42, 0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x47, 0x50, 0x49, 0x4f,
|
||||
0x5f, 0x54, 0x44, 0x49, 0x5f, 0x50, 0x49, 0x4e, 0x20, 0x32, 0x35, 0x0d,
|
||||
0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x4c,
|
||||
0x49, 0x4e, 0x55, 0x58, 0x47, 0x50, 0x49, 0x4f, 0x5f, 0x54, 0x44, 0x4f,
|
||||
0x5f, 0x50, 0x49, 0x4e, 0x20, 0x32, 0x36, 0x0d, 0x0a, 0x73, 0x65, 0x74,
|
||||
0x20, 0x50, 0x52, 0x4f, 0x42, 0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58,
|
||||
0x47, 0x50, 0x49, 0x4f, 0x5f, 0x54, 0x43, 0x4b, 0x5f, 0x50, 0x49, 0x4e,
|
||||
0x20, 0x32, 0x37, 0x0d, 0x0a, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50,
|
||||
0x52, 0x4f, 0x42, 0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x47, 0x50,
|
||||
0x49, 0x4f, 0x5f, 0x54, 0x4d, 0x53, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x49,
|
||||
0x4e, 0x56, 0x45, 0x52, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49,
|
||||
0x54, 0x59, 0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52,
|
||||
0x4f, 0x42, 0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x47, 0x50, 0x49,
|
||||
0x4f, 0x5f, 0x54, 0x44, 0x49, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x49, 0x4e,
|
||||
0x56, 0x45, 0x52, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54,
|
||||
0x59, 0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f,
|
||||
0x42, 0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x47, 0x50, 0x49, 0x4f,
|
||||
0x5f, 0x54, 0x44, 0x4f, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x49, 0x4e, 0x56,
|
||||
0x45, 0x52, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59,
|
||||
0x20, 0x30, 0x0d, 0x0a, 0x73, 0x65, 0x74, 0x20, 0x50, 0x52, 0x4f, 0x42,
|
||||
0x45, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x47, 0x50, 0x49, 0x4f, 0x5f,
|
||||
0x54, 0x43, 0x4b, 0x5f, 0x50, 0x49, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x45,
|
||||
0x52, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x20,
|
||||
0x30, 0x0d, 0x0a
|
||||
};
|
||||
unsigned int config_script_len = 5955;
|
||||
139
lib_jtag_core/src/dbg_logs.c
Normal file
139
lib_jtag_core/src/dbg_logs.c
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file dbg_logs.c
|
||||
* @brief logs/debug output
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "./drivers/drv_loader.h"
|
||||
#include "jtag_core_internal.h"
|
||||
#include "jtag_core.h"
|
||||
|
||||
#include "./os_interface/os_interface.h"
|
||||
|
||||
#include "dbg_logs.h"
|
||||
|
||||
int jtagcore_logs_printf(jtag_core * jc,int MSGTYPE,char * chaine, ...)
|
||||
{
|
||||
char tmp_msg[1024+1];
|
||||
char tmp_msg2[1024];
|
||||
JTAGCORE_PRINT_FUNC print_callback;
|
||||
|
||||
if( jc->logs_level <= MSGTYPE )
|
||||
{
|
||||
if( jc->jtagcore_print_callback )
|
||||
{
|
||||
va_list marker;
|
||||
va_start( marker, chaine );
|
||||
|
||||
print_callback = jc->jtagcore_print_callback;
|
||||
|
||||
switch(MSGTYPE)
|
||||
{
|
||||
case MSG_INFO_0:
|
||||
strcpy(tmp_msg,"Info : ");
|
||||
break;
|
||||
case MSG_INFO_1:
|
||||
strcpy(tmp_msg,"Info : ");
|
||||
break;
|
||||
case MSG_WARNING:
|
||||
strcpy(tmp_msg,"Warning : ");
|
||||
break;
|
||||
case MSG_ERROR:
|
||||
strcpy(tmp_msg,"Error : ");
|
||||
break;
|
||||
case MSG_DEBUG:
|
||||
strcpy(tmp_msg,"Debug : ");
|
||||
break;
|
||||
default:
|
||||
strcpy(tmp_msg,"Unknown : ");
|
||||
break;
|
||||
}
|
||||
|
||||
vsprintf(tmp_msg2,chaine,marker);
|
||||
genos_strndstcat(tmp_msg, tmp_msg2, sizeof(tmp_msg) );
|
||||
tmp_msg[sizeof(tmp_msg) - 1] = '\0';
|
||||
|
||||
print_callback( jc, tmp_msg);
|
||||
|
||||
va_end( marker );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int jtagcore_set_logs_callback(jtag_core * jc, JTAGCORE_PRINT_FUNC jtag_core_print)
|
||||
{
|
||||
if(jc)
|
||||
{
|
||||
jc->jtagcore_print_callback = jtag_core_print;
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_set_logs_level(jtag_core * jc,int level)
|
||||
{
|
||||
if(jc)
|
||||
{
|
||||
jc->logs_level = level;
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_get_logs_level(jtag_core * jc)
|
||||
{
|
||||
if(jc)
|
||||
{
|
||||
return jc->logs_level;
|
||||
}
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int jtagcore_set_logs_file(jtag_core * jc,char * path)
|
||||
{
|
||||
if(jc)
|
||||
{
|
||||
strncpy(jc->log_file_path, path, DEFAULT_BUFLEN - 1);
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
char * jtagcore_get_logs_file(jtag_core * jc)
|
||||
{
|
||||
if(jc)
|
||||
{
|
||||
return jc->log_file_path;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
26
lib_jtag_core/src/dbg_logs.h
Normal file
26
lib_jtag_core/src/dbg_logs.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file dbg_logs.c
|
||||
* @brief logs/debug output
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
int jtagcore_logs_printf(jtag_core * jc, int MSGTYPE, char * chaine, ...);
|
||||
65
lib_jtag_core/src/drivers/drivers_list.c
Normal file
65
lib_jtag_core/src/drivers/drivers_list.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drivers_list.h
|
||||
* @brief drivers list
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include "drv_loader.h"
|
||||
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "./ftdi_jtag/ftdi_jtag_drv.h"
|
||||
#include "./lpt_jtag/lpt_jtag_drv.h"
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#include "./linux_gpio_jtag/linux_gpio_jtag_drv.h"
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(WIN32)
|
||||
#include "./jlink_jtag/jlink_jtag_drv.h"
|
||||
#endif
|
||||
|
||||
#include "drivers_list.h"
|
||||
|
||||
const drv_entry staticdrvs[] =
|
||||
{
|
||||
#ifdef WIN32
|
||||
{(DRV_GETMODULEINFOS)drv_FTDI_libGetDrv,0},
|
||||
#if !defined(_WIN64)
|
||||
{(DRV_GETMODULEINFOS)drv_LPT_libGetDrv,0},
|
||||
{(DRV_GETMODULEINFOS)drv_LPT_libGetDrv,1},
|
||||
{(DRV_GETMODULEINFOS)drv_LPT_libGetDrv,2},
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__linux__) || defined(WIN32)
|
||||
{(DRV_GETMODULEINFOS)drv_JLINK_libGetDrv,0},
|
||||
#endif
|
||||
#if defined(__linux__)
|
||||
{(DRV_GETMODULEINFOS)drv_LinuxGPIO_libGetDrv,0},
|
||||
#endif
|
||||
{(DRV_GETMODULEINFOS)-1,0}
|
||||
};
|
||||
33
lib_jtag_core/src/drivers/drivers_list.h
Normal file
33
lib_jtag_core/src/drivers/drivers_list.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drivers_list.h
|
||||
* @brief drivers list struct
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
typedef struct _drv_entry
|
||||
{
|
||||
DRV_GETMODULEINFOS getinfosfunc;
|
||||
int sub_drv_id;
|
||||
}drv_entry;
|
||||
|
||||
extern const drv_entry staticdrvs[];
|
||||
|
||||
|
||||
120
lib_jtag_core/src/drivers/drv_loader.c
Normal file
120
lib_jtag_core/src/drivers/drv_loader.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drv_loader.c
|
||||
* @brief driver loader
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "drv_loader.h"
|
||||
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "drivers_list.h"
|
||||
|
||||
#include "../dbg_logs.h"
|
||||
|
||||
int GetDrvInfo(void * jc_ctx,unsigned long infotype,void * returnvalue,const char * drv_id,const char * drv_desc,drv_ptr * drv_func)
|
||||
{
|
||||
if(jc_ctx)
|
||||
{
|
||||
if(returnvalue)
|
||||
{
|
||||
switch(infotype)
|
||||
{
|
||||
case GET_DRV_ID:
|
||||
*(char**)(returnvalue)=(char*)drv_id;
|
||||
break;
|
||||
|
||||
case GET_DRV_DESCRIPTION:
|
||||
strcpy(returnvalue, (char*)drv_desc);
|
||||
break;
|
||||
|
||||
case GET_DRV_FUNCPTR:
|
||||
memcpy(returnvalue,drv_func,sizeof(drv_ptr));
|
||||
break;
|
||||
|
||||
case GET_DRV_DETECT:
|
||||
*((int*)(returnvalue)) = drv_func->drv_Detect(jc_ctx);
|
||||
break;
|
||||
|
||||
default:
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
}
|
||||
return JTAG_CORE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
int jtagcore_loaddriver(jtag_core * jc, int id, char * parameters)
|
||||
{
|
||||
int i,ret;
|
||||
i = 0;
|
||||
|
||||
while (staticdrvs[i].getinfosfunc != (DRV_GETMODULEINFOS)-1 )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( (id >> 8) < i)
|
||||
{
|
||||
if (jc->io_functions.drv_DeInit)
|
||||
{
|
||||
jc->io_functions.drv_DeInit(jc);
|
||||
memset(&jc->io_functions, 0, sizeof(drv_ptr));
|
||||
}
|
||||
|
||||
staticdrvs[id>>8].getinfosfunc(jc, id & 0xFF, GET_DRV_FUNCPTR, &jc->io_functions);
|
||||
|
||||
if( jc->io_functions.drv_Init )
|
||||
{
|
||||
ret = jc->io_functions.drv_Init(jc, id & 0xFF,0);
|
||||
if (ret < 0)
|
||||
{
|
||||
jtagcore_logs_printf(jc, MSG_ERROR, "jtagcore_loaddriver : Can't load the driver !\r\n");
|
||||
memset(&jc->io_functions, 0, sizeof(drv_ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf(jc, MSG_INFO_0, "jtagcore_loaddriver : Probe Driver 0x%.8X loaded...\r\n", id);
|
||||
}
|
||||
}
|
||||
else
|
||||
goto fail;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
fail:
|
||||
jtagcore_logs_printf(jc, MSG_ERROR, "jtagcore_loaddriver : Driver ID not found !\r\n");
|
||||
|
||||
return JTAG_CORE_NOT_FOUND;
|
||||
};
|
||||
|
||||
50
lib_jtag_core/src/drivers/drv_loader.h
Normal file
50
lib_jtag_core/src/drivers/drv_loader.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drv_loader.h
|
||||
* @brief driver functions definitions
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
enum {
|
||||
GET_DRV_ID = 1,
|
||||
GET_DRV_DESCRIPTION,
|
||||
GET_DRV_FUNCPTR,
|
||||
GET_DRV_DETECT
|
||||
};
|
||||
|
||||
typedef int (*DRV_DETECT) (void* jtag_core);
|
||||
typedef int (*DRV_INIT) (void* jtag_core,int sub_drv,char * params);
|
||||
typedef int (*DRV_TXRXDATA) (void* jtag_core, unsigned char * str_out, unsigned char * str_in, int size);
|
||||
typedef int (*DRV_TXTMS) (void* jtag_core, unsigned char * str_out, int size);
|
||||
typedef int (*DRV_GETMODULEINFOS) (void* jtag_core,int sub_drv,unsigned int infotype, void * returnvalue);
|
||||
typedef int (*DRV_DEINIT) (void* jtag_core);
|
||||
|
||||
typedef struct drv_ptr_
|
||||
{
|
||||
DRV_DETECT drv_Detect;
|
||||
DRV_INIT drv_Init;
|
||||
DRV_DEINIT drv_DeInit;
|
||||
DRV_TXTMS drv_TX_TMS;
|
||||
DRV_TXRXDATA drv_TXRX_DATA;
|
||||
DRV_GETMODULEINFOS drv_Get_ModInfos;
|
||||
} drv_ptr;
|
||||
|
||||
int GetDrvInfo(void * jc_ctx, unsigned long infotype, void * returnvalue, const char * drv_id, const char * drv_desc, drv_ptr * drv_func);
|
||||
136
lib_jtag_core/src/drivers/ftdi_jtag/ftdi/WinTypes.h
Normal file
136
lib_jtag_core/src/drivers/ftdi_jtag/ftdi/WinTypes.h
Normal file
@@ -0,0 +1,136 @@
|
||||
#ifndef __WINDOWS_TYPES__
|
||||
#define __WINDOWS_TYPES__
|
||||
|
||||
#define WINAPI
|
||||
|
||||
typedef unsigned int DWORD;
|
||||
typedef unsigned int ULONG;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned short SHORT;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned char BYTE;
|
||||
typedef BYTE *LPBYTE;
|
||||
typedef unsigned int BOOL;
|
||||
typedef unsigned char BOOLEAN;
|
||||
typedef unsigned char CHAR;
|
||||
typedef BOOL *LPBOOL;
|
||||
typedef UCHAR *PUCHAR;
|
||||
typedef const char *LPCSTR;
|
||||
typedef char *PCHAR;
|
||||
typedef void *PVOID;
|
||||
typedef void *HANDLE;
|
||||
typedef unsigned int LONG;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef char *LPSTR;
|
||||
typedef char *LPTSTR;
|
||||
typedef const char *LPCTSTR;
|
||||
typedef DWORD *LPDWORD;
|
||||
typedef WORD *LPWORD;
|
||||
typedef ULONG *PULONG;
|
||||
typedef LONG *LPLONG;
|
||||
typedef PVOID LPVOID;
|
||||
typedef void VOID;
|
||||
typedef unsigned long long int ULONGLONG;
|
||||
|
||||
typedef struct _OVERLAPPED {
|
||||
DWORD Internal;
|
||||
DWORD InternalHigh;
|
||||
DWORD Offset;
|
||||
DWORD OffsetHigh;
|
||||
HANDLE hEvent;
|
||||
} OVERLAPPED, *LPOVERLAPPED;
|
||||
|
||||
typedef struct _SECURITY_ATTRIBUTES {
|
||||
DWORD nLength;
|
||||
LPVOID lpSecurityDescriptor;
|
||||
BOOL bInheritHandle;
|
||||
} SECURITY_ATTRIBUTES , *LPSECURITY_ATTRIBUTES;
|
||||
|
||||
#include <pthread.h>
|
||||
// Substitute for HANDLE returned by Windows CreateEvent API.
|
||||
// FT_SetEventNotification expects parameter 3 to be the address
|
||||
// of one of these structures.
|
||||
typedef struct _EVENT_HANDLE
|
||||
{
|
||||
pthread_cond_t eCondVar;
|
||||
pthread_mutex_t eMutex;
|
||||
int iVar;
|
||||
} EVENT_HANDLE;
|
||||
|
||||
typedef struct timeval SYSTEMTIME;
|
||||
typedef struct timeval FILETIME;
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
//
|
||||
// Modem Status Flags
|
||||
//
|
||||
#define MS_CTS_ON ((DWORD)0x0010)
|
||||
#define MS_DSR_ON ((DWORD)0x0020)
|
||||
#define MS_RING_ON ((DWORD)0x0040)
|
||||
#define MS_RLSD_ON ((DWORD)0x0080)
|
||||
|
||||
//
|
||||
// Error Flags
|
||||
//
|
||||
#define CE_RXOVER 0x0001 // Receive Queue overflow
|
||||
#define CE_OVERRUN 0x0002 // Receive Overrun Error
|
||||
#define CE_RXPARITY 0x0004 // Receive Parity Error
|
||||
#define CE_FRAME 0x0008 // Receive Framing error
|
||||
#define CE_BREAK 0x0010 // Break Detected
|
||||
#define CE_TXFULL 0x0100 // TX Queue is full
|
||||
#define CE_PTO 0x0200 // LPTx Timeout
|
||||
#define CE_IOE 0x0400 // LPTx I/O Error
|
||||
#define CE_DNS 0x0800 // LPTx Device not selected
|
||||
#define CE_OOP 0x1000 // LPTx Out-Of-Paper
|
||||
#define CE_MODE 0x8000 // Requested mode unsupported
|
||||
|
||||
//
|
||||
// Events
|
||||
//
|
||||
#define EV_RXCHAR 0x0001 // Any Character received
|
||||
#define EV_RXFLAG 0x0002 // Received certain character
|
||||
#define EV_TXEMPTY 0x0004 // Transmit Queue Empty
|
||||
#define EV_CTS 0x0008 // CTS changed state
|
||||
#define EV_DSR 0x0010 // DSR changed state
|
||||
#define EV_RLSD 0x0020 // RLSD changed state
|
||||
#define EV_BREAK 0x0040 // BREAK received
|
||||
#define EV_ERR 0x0080 // Line status error occurred
|
||||
#define EV_RING 0x0100 // Ring signal detected
|
||||
#define EV_PERR 0x0200 // Printer error occured
|
||||
#define EV_RX80FULL 0x0400 // Receive buffer is 80 percent full
|
||||
#define EV_EVENT1 0x0800 // Provider specific event 1
|
||||
#define EV_EVENT2 0x1000 // Provider specific event 2
|
||||
|
||||
//
|
||||
// Escape Functions
|
||||
//
|
||||
#define SETXOFF 1 // Simulate XOFF received
|
||||
#define SETXON 2 // Simulate XON received
|
||||
#define SETRTS 3 // Set RTS high
|
||||
#define CLRRTS 4 // Set RTS low
|
||||
#define SETDTR 5 // Set DTR high
|
||||
#define CLRDTR 6 // Set DTR low
|
||||
#define RESETDEV 7 // Reset device if possible
|
||||
#define SETBREAK 8 // Set the device break line.
|
||||
#define CLRBREAK 9 // Clear the device break line.
|
||||
|
||||
//
|
||||
// PURGE function flags.
|
||||
//
|
||||
#define PURGE_TXABORT 0x0001 // Kill the pending/current writes to the comm port.
|
||||
#define PURGE_RXABORT 0x0002 // Kill the pending/current reads to the comm port.
|
||||
#define PURGE_TXCLEAR 0x0004 // Kill the transmit queue if there.
|
||||
#define PURGE_RXCLEAR 0x0008 // Kill the typeahead buffer if there.
|
||||
|
||||
#ifndef INVALID_HANDLE_VALUE
|
||||
#define INVALID_HANDLE_VALUE 0xFFFFFFFF
|
||||
#endif
|
||||
|
||||
#endif /* __WINDOWS_TYPES__ */
|
||||
1443
lib_jtag_core/src/drivers/ftdi_jtag/ftdi/ftd2xx.h
Normal file
1443
lib_jtag_core/src/drivers/ftdi_jtag/ftdi/ftd2xx.h
Normal file
File diff suppressed because it is too large
Load Diff
967
lib_jtag_core/src/drivers/ftdi_jtag/ftdi_jtag_drv.c
Normal file
967
lib_jtag_core/src/drivers/ftdi_jtag/ftdi_jtag_drv.c
Normal file
@@ -0,0 +1,967 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ftdi_jtag_drv.c
|
||||
* @brief FTDI based probes driver
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(WIN32)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "../drv_loader.h"
|
||||
#include "../../jtag_core_internal.h"
|
||||
#include "../../jtag_core.h"
|
||||
|
||||
#include "../../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../../dbg_logs.h"
|
||||
|
||||
#include "../../os_interface/os_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ftdi/ftd2xx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
#define MACH_WORD long long
|
||||
#else
|
||||
#define MACH_WORD int
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
typedef struct _drv_desc
|
||||
{
|
||||
char drv_id[128];
|
||||
char drv_desc[128];
|
||||
int id;
|
||||
int ftdi_index;
|
||||
}drv_desc;
|
||||
|
||||
#define PROBE_GENERIC_FTDI 0
|
||||
|
||||
#define MAX_PROBES_FTDI 8
|
||||
|
||||
static drv_desc subdrv_list[MAX_PROBES_FTDI]=
|
||||
{
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0},
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0},
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0},
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0},
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0},
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0},
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0},
|
||||
{"USB_GENERIC_FTDI_PROBE","GENERIC USB FTDI PROBE",PROBE_GENERIC_FTDI,0}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Command Processor for MPSSE and MCU Host Bus Emulation Modes
|
||||
//
|
||||
// The data shifting commands are made up of the following definitions:
|
||||
// Bit 7 : 0
|
||||
// Bit 6 : Do write TMS
|
||||
// Bit 5 : Do read TDO
|
||||
// Bit 4 : Do write TDI
|
||||
// Bit 3 : LSB first = 1 else MSB first = 0
|
||||
// Bit 2 : -ve CLK on read
|
||||
// Bit 1 : bit mode = 1 else byte mode = 0
|
||||
// Bit 0 : -ve CLK on write
|
||||
|
||||
// The write commands to TDI take effect when bits 7 and 6 are '0'. Read TDO will operate with TMS output or TDI output or on its own.
|
||||
|
||||
// Clock Data Bytes Out on +ve clock edge MSB first (no read)
|
||||
// 0x10, LengthL, LengthH, [Byte1..Byte65536 (max)]
|
||||
|
||||
#define OP_WR_TMS (0x1 << 6)
|
||||
#define OP_RD_TDO (0x1 << 5)
|
||||
#define OP_WR_TDI (0x1 << 4)
|
||||
#define OP_LSB_FIRST (0x1 << 3)
|
||||
#define OP_FEDGE_RD (0x1 << 2)
|
||||
#define OP_BIT_MODE (0x1 << 1)
|
||||
#define OP_FEDGE_WR (0x1 << 0)
|
||||
|
||||
#define CMD_ENABLE_LOOPBACK 0x84
|
||||
#define CMD_DISABLE_LOOPBACK 0x85
|
||||
#define CMD_SET_DIVISOR 0x86 // +0xValueL, 0xValueH
|
||||
#define CMD_WAIT_IO_HIGH 0x88
|
||||
#define CMD_WAIT_IO_LOW 0x89
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static HMODULE lib_handle = 0;
|
||||
|
||||
static FT_HANDLE ftdih = NULL;
|
||||
static FT_DEVICE ftdi_device;
|
||||
|
||||
static int trst_oe_pin, trst_state_pin;
|
||||
static int srst_oe_pin, srst_state_pin;
|
||||
static int led_pin;
|
||||
|
||||
static unsigned char low_direction;
|
||||
static unsigned char low_polarity;
|
||||
static unsigned char low_output;
|
||||
|
||||
static unsigned char high_output;
|
||||
static unsigned char high_polarity;
|
||||
static unsigned char high_direction;
|
||||
|
||||
unsigned char ftdi_out_buf[64 * 1024];
|
||||
unsigned char ftdi_in_buf[64 * 1024];
|
||||
|
||||
#if !defined(WIN32)
|
||||
|
||||
int Sleep( unsigned int timeout_ms )
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = timeout_ms/1000;
|
||||
tv.tv_usec = (timeout_ms%1000) * 1000;
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if !defined(FTDILIB)
|
||||
|
||||
typedef FT_STATUS(WINAPI * FT_OPEN)(DWORD deviceNumber, FT_HANDLE *pHandle);
|
||||
typedef FT_STATUS(WINAPI * FT_OPENEX)(PVOID pArg1, DWORD Flags, FT_HANDLE *pHandle);
|
||||
typedef FT_STATUS(WINAPI * FT_READ)(FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD nBufferSize, LPDWORD lpBytesReturned);
|
||||
typedef FT_STATUS(WINAPI * FT_WRITE)(FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD nBufferSize, LPDWORD lpBytesWritten);
|
||||
typedef FT_STATUS(WINAPI * FT_GETSTATUS)(FT_HANDLE ftHandle, DWORD *dwRxBytes, DWORD *dwTxBytes, DWORD *dwEventDWord);
|
||||
typedef FT_STATUS(WINAPI * FT_PURGE)(FT_HANDLE ftHandle, ULONG Mask);
|
||||
typedef FT_STATUS(WINAPI * FT_SETUSBPARAMETERS)(FT_HANDLE ftHandle, ULONG ulInTransferSize, ULONG ulOutTransferSize);
|
||||
typedef FT_STATUS(WINAPI * FT_SETLATENCYTIMER)(FT_HANDLE ftHandle, UCHAR ucLatency);
|
||||
typedef FT_STATUS(WINAPI * FT_SETEVENTNOTIFICATION)(FT_HANDLE ftHandle, DWORD dwEventMask, PVOID pvArg);
|
||||
typedef FT_STATUS(WINAPI * FT_CLOSE)(FT_HANDLE ftHandle);
|
||||
typedef FT_STATUS(WINAPI * FT_LISTDEVICES)(LPVOID pArg1, LPVOID pArg2, DWORD Flags);
|
||||
typedef FT_STATUS(WINAPI * FT_SETBITMODE)(FT_HANDLE ftHandle, UCHAR ucMask, UCHAR ucEnable);
|
||||
typedef FT_STATUS(WINAPI * FT_SETTIMEOUTS)(FT_HANDLE ftHandle, ULONG ReadTimeout, ULONG WriteTimeout);
|
||||
typedef FT_STATUS(WINAPI * FT_GETQUEUESTATUS)(FT_HANDLE ftHandle, DWORD *dwRxBytes);
|
||||
typedef FT_STATUS(WINAPI * FT_GETDEVICEINFO)(FT_HANDLE ftHandle, FT_DEVICE *lpftDevice, LPDWORD lpdwID, PCHAR SerialNumber, PCHAR Description, LPVOID Dummy);
|
||||
typedef FT_STATUS(WINAPI * FT_RESETDEVICE)(FT_HANDLE ftHandle);
|
||||
typedef FT_STATUS(WINAPI * FT_SETCHARS)(FT_HANDLE ftHandle, UCHAR EventChar, UCHAR EventCharEnabled, UCHAR ErrorChar, UCHAR ErrorCharEnabled);
|
||||
|
||||
FT_OPEN pFT_Open;
|
||||
FT_OPENEX pFT_OpenEx;
|
||||
FT_READ pFT_Read;
|
||||
FT_WRITE pFT_Write;
|
||||
FT_GETSTATUS pFT_GetStatus;
|
||||
FT_PURGE pFT_Purge;
|
||||
FT_SETUSBPARAMETERS pFT_SetUSBParameters;
|
||||
FT_SETLATENCYTIMER pFT_SetLatencyTimer;
|
||||
FT_SETEVENTNOTIFICATION pFT_SetEventNotification;
|
||||
FT_CLOSE pFT_Close;
|
||||
FT_LISTDEVICES pFT_ListDevices;
|
||||
FT_SETBITMODE pFT_SetBitMode;
|
||||
FT_SETTIMEOUTS pFT_SetTimeouts;
|
||||
FT_GETQUEUESTATUS pFT_GetQueueStatus;
|
||||
FT_GETDEVICEINFO pFT_GetDeviceInfo;
|
||||
FT_RESETDEVICE pFT_ResetDevice;
|
||||
FT_SETCHARS pFT_SetChars;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static int ft2232_set_data_bits_low_byte(unsigned char value, unsigned char direction)
|
||||
{
|
||||
FT_STATUS status;
|
||||
DWORD dw_bytes_written = 0;
|
||||
unsigned char buf[3];
|
||||
|
||||
buf[0] = 0x80; // command "set data bits low byte"
|
||||
buf[1] = value; // value
|
||||
buf[2] = direction; // direction
|
||||
|
||||
status = pFT_Write(ftdih, buf, sizeof(buf), &dw_bytes_written);
|
||||
if ( (status != FT_OK) || (dw_bytes_written != sizeof(buf) ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ft2232_set_data_bits_high_byte(unsigned char value, unsigned char direction)
|
||||
{
|
||||
FT_STATUS status;
|
||||
DWORD dw_bytes_written = 0;
|
||||
unsigned char buf[3];
|
||||
|
||||
buf[0] = 0x82; // command "set data bits high byte"
|
||||
buf[1] = value; // value
|
||||
buf[2] = direction; // direction
|
||||
|
||||
status = pFT_Write(ftdih, buf, sizeof(buf), &dw_bytes_written);
|
||||
if ( (status != FT_OK) || ( dw_bytes_written != sizeof(buf) ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ft2232h_enable_rtck(int enable)
|
||||
{
|
||||
FT_STATUS status;
|
||||
DWORD dw_bytes_written = 0;
|
||||
unsigned char buf;
|
||||
|
||||
buf = enable ? 0x96 : 0x97;
|
||||
|
||||
status = pFT_Write(ftdih, &buf, sizeof(buf), &dw_bytes_written);
|
||||
if ( (status != FT_OK) || ( dw_bytes_written != sizeof(buf) ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_FTDI_Detect(jtag_core * jc)
|
||||
{
|
||||
int numDevs,i;
|
||||
FT_STATUS status;
|
||||
char SerialNumber[512];
|
||||
|
||||
if(lib_handle == NULL)
|
||||
lib_handle = LoadLibrary("ftd2xx.dll");
|
||||
|
||||
if (lib_handle)
|
||||
{
|
||||
pFT_ListDevices = (FT_LISTDEVICES)GetProcAddress(lib_handle, "FT_ListDevices");
|
||||
if (!pFT_ListDevices)
|
||||
return 0;
|
||||
|
||||
status = pFT_ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY);
|
||||
if (status != FT_OK && !numDevs)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_ListDevices : Error %x !\r\n",status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while( i<numDevs && i<MAX_PROBES_FTDI )
|
||||
{
|
||||
status = pFT_ListDevices((LPVOID)(MACH_WORD)i, SerialNumber, FT_LIST_BY_INDEX | FT_OPEN_BY_DESCRIPTION);
|
||||
if (status != FT_OK)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_ListDevices : Error %x !\r\n",status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(subdrv_list[i].drv_id,SerialNumber);
|
||||
strcpy(subdrv_list[i].drv_desc,SerialNumber);
|
||||
strcat(subdrv_list[i].drv_desc," ");
|
||||
|
||||
status = pFT_ListDevices((LPVOID)(MACH_WORD)i, SerialNumber, FT_LIST_BY_INDEX | FT_OPEN_BY_SERIAL_NUMBER);
|
||||
if (status != FT_OK)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_ListDevices : Error %x !\r\n",status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcat(subdrv_list[i].drv_desc,SerialNumber);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
jtagcore_logs_printf( jc, MSG_INFO_1, "drv_FTDI_Detect : %d interface(s) found !\r\n", numDevs );
|
||||
|
||||
return numDevs;
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf( jc, MSG_INFO_1, "drv_FTDI_Detect : ftd2xx.dll not found !\r\n" );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void update_gpio_state(int index,int state)
|
||||
{
|
||||
if( index >=0 )
|
||||
{
|
||||
if(index < 8)
|
||||
{
|
||||
if(state)
|
||||
low_output |= (0x01<<index);
|
||||
else
|
||||
low_output &= ~(0x01<<index);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(state)
|
||||
high_output |= (0x01<<(index - 8));
|
||||
else
|
||||
high_output &= ~(0x01<<(index - 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int drv_FTDI_Init(jtag_core * jc, int sub_drv, char * params)
|
||||
{
|
||||
FT_STATUS status;
|
||||
DWORD deviceID;
|
||||
char SerialNumber[16];
|
||||
char Description[64];
|
||||
char tmp_str[64];
|
||||
int numDevs;
|
||||
int baseclock, divisor, tckfreq;
|
||||
DWORD devIndex;
|
||||
DWORD nbRead,nbtosend;
|
||||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
if(lib_handle == NULL)
|
||||
lib_handle = LoadLibrary("ftd2xx.dll");
|
||||
|
||||
if (lib_handle)
|
||||
{
|
||||
pFT_Write = (FT_WRITE)GetProcAddress(lib_handle, "FT_Write");
|
||||
if (!pFT_Write)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_Read = (FT_READ)GetProcAddress(lib_handle, "FT_Read");
|
||||
if (!pFT_Read)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_GetStatus = (FT_GETSTATUS)GetProcAddress(lib_handle, "FT_GetStatus");
|
||||
if (!pFT_GetStatus)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_Open = (FT_OPEN)GetProcAddress(lib_handle, "FT_Open");
|
||||
if (!pFT_Open)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_Close = (FT_CLOSE)GetProcAddress(lib_handle, "FT_Close");
|
||||
if (!pFT_Close)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_Purge = (FT_PURGE)GetProcAddress(lib_handle, "FT_Purge");
|
||||
if (!pFT_Purge)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_SetUSBParameters = (FT_SETUSBPARAMETERS)GetProcAddress(lib_handle, "FT_SetUSBParameters");
|
||||
if (!pFT_SetUSBParameters)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_SetLatencyTimer = (FT_SETLATENCYTIMER)GetProcAddress(lib_handle, "FT_SetLatencyTimer");
|
||||
if (!pFT_SetLatencyTimer)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_SetEventNotification = (FT_SETEVENTNOTIFICATION)GetProcAddress(lib_handle, "FT_SetEventNotification");
|
||||
if (!pFT_SetEventNotification)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_OpenEx = (FT_OPENEX)GetProcAddress(lib_handle, "FT_OpenEx");
|
||||
if (!pFT_OpenEx)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_ListDevices = (FT_LISTDEVICES)GetProcAddress(lib_handle, "FT_ListDevices");
|
||||
if (!pFT_ListDevices)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_SetBitMode = (FT_SETBITMODE)GetProcAddress(lib_handle, "FT_SetBitMode");
|
||||
if (!pFT_SetBitMode)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_SetTimeouts = (FT_SETTIMEOUTS)GetProcAddress(lib_handle, "FT_SetTimeouts");
|
||||
if (!pFT_SetTimeouts)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_GetQueueStatus = (FT_GETQUEUESTATUS)GetProcAddress(lib_handle, "FT_GetQueueStatus");
|
||||
if (!pFT_GetQueueStatus)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_GetDeviceInfo = (FT_GETDEVICEINFO)GetProcAddress(lib_handle, "FT_GetDeviceInfo");
|
||||
if (!pFT_GetDeviceInfo)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_ResetDevice = (FT_RESETDEVICE)GetProcAddress(lib_handle, "FT_ResetDevice");
|
||||
if (!pFT_ResetDevice)
|
||||
goto loadliberror;
|
||||
|
||||
pFT_SetChars = (FT_SETCHARS)GetProcAddress(lib_handle, "FT_SetChars");
|
||||
if (!pFT_SetChars)
|
||||
goto loadliberror;
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_FTDI_Init : Can't open ftd2xx.dll !\r\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
// TODO : Linux lib loader.
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
status = pFT_ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY);
|
||||
if (status != FT_OK && !numDevs)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_ListDevices : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
devIndex = sub_drv;
|
||||
status = pFT_ListDevices((LPVOID)(MACH_WORD)devIndex, SerialNumber, FT_LIST_BY_INDEX | FT_OPEN_BY_SERIAL_NUMBER);
|
||||
if (status != FT_OK)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_ListDevices : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
status = pFT_OpenEx(SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &ftdih);
|
||||
if (status != FT_OK)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_OpenEx : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
status = pFT_ResetDevice(ftdih);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_ResetDevice : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
status = pFT_GetQueueStatus(ftdih, &nbRead);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_GetQueueStatus : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
if ( nbRead > 0)
|
||||
pFT_Read(ftdih, &ftdi_in_buf, nbRead, &nbRead);
|
||||
|
||||
//Set USB request transfer sizes to 64K
|
||||
status = pFT_SetUSBParameters(ftdih, 65536, 65535);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_SetUSBParameters : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
//Disable event and error characters
|
||||
status = pFT_SetChars(ftdih, 0, 0, 0, 0);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_SetChars : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
//Sets the read and write timeouts in milliseconds
|
||||
status = pFT_SetTimeouts(ftdih, 5000, 5000);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_SetTimeouts : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
//Set the latency timer (default is 16mS)
|
||||
status = pFT_SetLatencyTimer(ftdih, 2);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_SetLatencyTimer : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
//Reset controller
|
||||
status = pFT_SetBitMode(ftdih, 0x0, 0x00);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_SetBitMode : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
//Enable MPSSE mode
|
||||
status = pFT_SetBitMode(ftdih, 0x0, 0x02);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_SetBitMode : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
status = pFT_SetBitMode(ftdih, 0x0b, 2);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_SetBitMode : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
status = pFT_GetDeviceInfo(ftdih, &ftdi_device, &deviceID,
|
||||
SerialNumber, Description, NULL);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_GetDeviceInfo : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
/*
|
||||
Olimex ARM-USB-OCD-H JTAG signals
|
||||
|
||||
VREF – voltage follower input for the output buffers adjust JTAG signals as per your target board voltage levels
|
||||
ADBUS0 -> TCK; (out)
|
||||
ADBUS1 -> TDI; (out)
|
||||
ADBUS2 -> TDO; (in)
|
||||
ADBUS3 -> TMS; (out)
|
||||
ADBUS4 -> 0 to enable JTAG buffers; (GPIOL0) (out)
|
||||
ADBUS5 -> 0 if target present; (GPIOL1) (in)
|
||||
ADBUS6 -> TSRST in; (GPIOL2) (in)
|
||||
ADBUS7 -> RTCK; (in) (GPIOL3) (in)
|
||||
|
||||
ACBUS0 -> TRST; (GPIOH0)
|
||||
ACBUS1 -> SRST; (GPIOH1)
|
||||
ACBUS2 -> TRST buffer enable (GPIOH2)
|
||||
ACBUS3 -> RED LED; (GPIOH3)
|
||||
*/
|
||||
|
||||
low_direction = 0x00;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
sprintf(tmp_str,"PROBE_FTDI_SET_PIN_DIR_ADBUS%d",i);
|
||||
if( jtagcore_getEnvVarValue( jc, tmp_str) > 0 )
|
||||
{
|
||||
low_direction |= (0x01<<i);
|
||||
}
|
||||
}
|
||||
|
||||
low_output = 0x00;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
sprintf(tmp_str,"PROBE_FTDI_SET_PIN_DEFAULT_STATE_ADBUS%d",i);
|
||||
if( jtagcore_getEnvVarValue( jc, tmp_str) > 0 )
|
||||
{
|
||||
low_output |= (0x01<<i);
|
||||
}
|
||||
}
|
||||
|
||||
low_polarity = 0;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
sprintf(tmp_str,"PROBE_FTDI_SET_PIN_POLARITY_ADBUS%d",i);
|
||||
if( jtagcore_getEnvVarValue( jc, tmp_str) > 0 )
|
||||
{
|
||||
low_polarity |= (0x01<<i);
|
||||
}
|
||||
}
|
||||
|
||||
high_direction = 0x00;
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
sprintf(tmp_str,"PROBE_FTDI_SET_PIN_DIR_ACBUS%d",i);
|
||||
if( jtagcore_getEnvVarValue( jc, tmp_str) > 0 )
|
||||
{
|
||||
high_direction |= (0x01<<i);
|
||||
}
|
||||
}
|
||||
|
||||
high_output = 0x00;
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
sprintf(tmp_str,"PROBE_FTDI_SET_PIN_DEFAULT_STATE_ACBUS%d",i);
|
||||
if( jtagcore_getEnvVarValue( jc, tmp_str) > 0 )
|
||||
{
|
||||
high_output |= (0x01<<i);
|
||||
}
|
||||
}
|
||||
|
||||
high_polarity = 0x00;
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
sprintf(tmp_str,"PROBE_FTDI_SET_PIN_POLARITY_ACBUS%d",i);
|
||||
if( jtagcore_getEnvVarValue( jc, tmp_str) > 0 )
|
||||
{
|
||||
high_polarity |= (0x01<<i);
|
||||
}
|
||||
}
|
||||
|
||||
trst_oe_pin = jtagcore_getEnvVarValue( jc, "PROBE_FTDI_SET_TRST_OE_PINNUM" );
|
||||
trst_state_pin = jtagcore_getEnvVarValue( jc, "PROBE_FTDI_SET_TRST_STATE_PINNUM" );
|
||||
|
||||
srst_oe_pin = jtagcore_getEnvVarValue( jc, "PROBE_FTDI_SET_SRST_OE_PINNUM" );
|
||||
srst_state_pin = jtagcore_getEnvVarValue( jc, "PROBE_FTDI_SET_SRST_STATE_PINNUM" );
|
||||
|
||||
led_pin = jtagcore_getEnvVarValue( jc, "PROBE_FTDI_SET_CONNECTION_LED_PINNUM" );
|
||||
|
||||
/* jtag reset */
|
||||
update_gpio_state(trst_oe_pin,1);
|
||||
update_gpio_state(trst_state_pin,1);
|
||||
|
||||
update_gpio_state(srst_oe_pin,1);
|
||||
update_gpio_state(srst_state_pin,0);
|
||||
|
||||
/* turn red LED off */
|
||||
update_gpio_state(led_pin,0);
|
||||
|
||||
ft2232_set_data_bits_low_byte( (unsigned char)(low_output ^ low_polarity), low_direction);
|
||||
ft2232_set_data_bits_high_byte( (unsigned char)(high_output ^ high_polarity), high_direction);
|
||||
|
||||
// Clock divisor
|
||||
// 0x86 ValueL ValueH
|
||||
// FT2232D/H
|
||||
// TCK clock = (12Mhz or 60Mhz)/ ((1 + ([ValueH << 8 | ValueL]))*2)
|
||||
|
||||
baseclock = jtagcore_getEnvVarValue( jc, "PROBE_FTDI_INTERNAL_FREQ_KHZ");
|
||||
tckfreq = jtagcore_getEnvVarValue( jc, "PROBE_FTDI_TCK_FREQ_KHZ");
|
||||
if( baseclock <= 0 || tckfreq <= 0){
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_FTDI_Init : Invalid probe clock settings !\r\n");
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
divisor = ( ( baseclock / tckfreq ) - 2 ) / 2;
|
||||
|
||||
nbtosend = 0;
|
||||
ftdi_out_buf[nbtosend++] = CMD_SET_DIVISOR;
|
||||
ftdi_out_buf[nbtosend++] = divisor & 0xFF;
|
||||
ftdi_out_buf[nbtosend++] = (divisor>>8) & 0xFF;
|
||||
|
||||
status = pFT_Write(ftdih, ftdi_out_buf, nbtosend, &nbtosend);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_Write : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
|
||||
#if 0 // Loopback
|
||||
nbtosend = 0;
|
||||
ftdi_out_buf[nbtosend++] = CMD_ENABLE_LOOPBACK;
|
||||
|
||||
status = pFT_Write(ftdih, ftdi_out_buf, nbtosend, &nbtosend);
|
||||
if (status != FT_OK) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pFT_Write : Error %x !\r\n",status);
|
||||
goto loadliberror;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(jtagcore_getEnvVarValue( jc, "PROBE_FTDI_JTAG_ENABLE_RTCK") > 0)
|
||||
{
|
||||
ft2232h_enable_rtck(1);
|
||||
}
|
||||
|
||||
/* Delay... */
|
||||
genos_pause(jtagcore_getEnvVarValue( jc, "PROBE_FTDI_JTAG_TRST_DELAY_MS"));
|
||||
|
||||
/* turn red LED on */
|
||||
update_gpio_state(led_pin,1);
|
||||
|
||||
/* Release system & jtag reset */
|
||||
update_gpio_state(trst_state_pin,0);
|
||||
update_gpio_state(srst_state_pin,0);
|
||||
|
||||
ft2232_set_data_bits_low_byte( (unsigned char)(low_output ^ low_polarity), low_direction);
|
||||
ft2232_set_data_bits_high_byte( (unsigned char)(high_output ^ high_polarity), high_direction);
|
||||
|
||||
jtagcore_logs_printf(jc,MSG_INFO_0,"drv_FTDI_Init : Probe Driver loaded successfully...\r\n");
|
||||
|
||||
return 0;
|
||||
|
||||
loadliberror:
|
||||
FreeLibrary(lib_handle);
|
||||
lib_handle = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int drv_FTDI_DeInit(jtag_core * jc)
|
||||
{
|
||||
pFT_Close(ftdih);
|
||||
FreeLibrary(lib_handle);
|
||||
lib_handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_FTDI_TDOTDI_xfer(jtag_core * jc, unsigned char * str_out, unsigned char * str_in, int size)
|
||||
{
|
||||
int wr_bit_index,rd_bit_index;
|
||||
int i,payloadsize;
|
||||
unsigned char bitscnt;
|
||||
int rounded_size;
|
||||
DWORD nbRead,nbtosend;
|
||||
FT_STATUS status;
|
||||
unsigned char opcode,data;
|
||||
|
||||
rd_bit_index = 0;
|
||||
wr_bit_index = 0;
|
||||
|
||||
memset(ftdi_out_buf, 0, sizeof(ftdi_out_buf));
|
||||
memset(ftdi_in_buf, 0, sizeof(ftdi_in_buf));
|
||||
|
||||
if (size)
|
||||
{
|
||||
// Set the first TMS/DOUT bit
|
||||
if ( str_out[wr_bit_index] & JTAG_STR_TMS )
|
||||
{
|
||||
if( str_in )
|
||||
opcode = ( OP_WR_TMS | OP_LSB_FIRST | OP_BIT_MODE | OP_FEDGE_WR | OP_RD_TDO ); // with TDO read back
|
||||
else
|
||||
opcode = ( OP_WR_TMS | OP_LSB_FIRST | OP_BIT_MODE | OP_FEDGE_WR );
|
||||
|
||||
nbtosend = 0;
|
||||
|
||||
ftdi_out_buf[nbtosend++] = opcode;
|
||||
ftdi_out_buf[nbtosend++] = 0x00; // Size field : 1 Bit
|
||||
|
||||
data = 0x7F; // TMS state set
|
||||
|
||||
if (str_out[wr_bit_index] & JTAG_STR_DOUT)
|
||||
data |= 0x80; // Bit 7: TDI/DO pin state
|
||||
|
||||
wr_bit_index++;
|
||||
|
||||
ftdi_out_buf[nbtosend++] = data; // Data field
|
||||
|
||||
status = pFT_Write(ftdih, ftdi_out_buf, nbtosend, &nbtosend);
|
||||
|
||||
if ( opcode & OP_RD_TDO )
|
||||
{
|
||||
status = pFT_GetQueueStatus(ftdih, &nbRead);
|
||||
while (nbRead < 1 && (status == FT_OK))
|
||||
{
|
||||
Sleep(3);
|
||||
status = pFT_GetQueueStatus(ftdih, &nbRead);
|
||||
}
|
||||
|
||||
status = pFT_Read(ftdih, &ftdi_in_buf, nbRead, &nbRead);
|
||||
|
||||
// bits are shifted in from MSB to LSB ...
|
||||
if ( ftdi_in_buf[0] & 0x80 )
|
||||
{
|
||||
str_in[rd_bit_index++] = JTAG_STR_DOUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
str_in[rd_bit_index++] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( wr_bit_index >= size )
|
||||
return 0;
|
||||
|
||||
rounded_size = (size - wr_bit_index) & ~(0x7);
|
||||
if( rounded_size )
|
||||
{
|
||||
// byte(s) buffer transmission/reception
|
||||
|
||||
if( str_in )
|
||||
opcode = ( OP_WR_TDI | OP_LSB_FIRST | OP_FEDGE_WR | OP_RD_TDO );
|
||||
else
|
||||
opcode = ( OP_WR_TDI | OP_LSB_FIRST | OP_FEDGE_WR );
|
||||
|
||||
nbtosend = 0;
|
||||
|
||||
ftdi_out_buf[nbtosend++] = opcode;
|
||||
ftdi_out_buf[nbtosend++] = ( ( (rounded_size>>3)-1 ) & 0xff ); // (Size-1) Low byte
|
||||
ftdi_out_buf[nbtosend++] = ( ( (rounded_size>>3)-1 ) >> 8 ); // (Size-1) High byte
|
||||
|
||||
ftdi_out_buf[nbtosend] = 0x00;
|
||||
|
||||
i = 0;
|
||||
payloadsize = 0;
|
||||
while (payloadsize < rounded_size)
|
||||
{
|
||||
if (str_out[wr_bit_index] & JTAG_STR_DOUT)
|
||||
{
|
||||
ftdi_out_buf[nbtosend] |= (0x01 << (i & 0x7));
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
if (!(i & 0x7))
|
||||
{
|
||||
nbtosend++;
|
||||
ftdi_out_buf[nbtosend] = 0x00;
|
||||
}
|
||||
|
||||
payloadsize++;
|
||||
wr_bit_index++;
|
||||
}
|
||||
|
||||
status = pFT_Write(ftdih, ftdi_out_buf, nbtosend, &nbtosend);
|
||||
|
||||
if (str_in)
|
||||
{
|
||||
do
|
||||
{
|
||||
Sleep(3);
|
||||
status = pFT_GetQueueStatus(ftdih, &nbRead);
|
||||
} while (nbRead < (unsigned long)(rounded_size >> 3) && (status == FT_OK ));
|
||||
|
||||
status = pFT_Read(ftdih, &ftdi_in_buf, nbRead, &nbRead);
|
||||
|
||||
for (i = 0; i < rounded_size; i++)
|
||||
{
|
||||
if (ftdi_in_buf[i >> 3] & (0x01 << (i & 7)))
|
||||
{
|
||||
str_in[rd_bit_index++] = JTAG_STR_DOUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
str_in[rd_bit_index++] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send the remaining bits...
|
||||
while( wr_bit_index < size )
|
||||
{
|
||||
if( str_in )
|
||||
opcode = ( OP_WR_TDI | OP_LSB_FIRST | OP_BIT_MODE | OP_FEDGE_WR | OP_RD_TDO ); //bit mode with TDO read back
|
||||
else
|
||||
opcode = ( OP_WR_TDI | OP_LSB_FIRST | OP_BIT_MODE | OP_FEDGE_WR ); //bit mode
|
||||
|
||||
nbtosend = 0;
|
||||
|
||||
bitscnt = (size - wr_bit_index);
|
||||
if( bitscnt > 8 )
|
||||
{
|
||||
bitscnt = 8;
|
||||
}
|
||||
|
||||
ftdi_out_buf[nbtosend++] = opcode;
|
||||
ftdi_out_buf[nbtosend++] = (bitscnt - 1) & 7; // Size field
|
||||
ftdi_out_buf[nbtosend] = 0x00;
|
||||
|
||||
i = 0;
|
||||
while( i < bitscnt )
|
||||
{
|
||||
if (str_out[wr_bit_index++] & JTAG_STR_DOUT)
|
||||
ftdi_out_buf[nbtosend] |= 0x01 << i; // Data field
|
||||
|
||||
i++;
|
||||
}
|
||||
nbtosend++;
|
||||
|
||||
status = pFT_Write(ftdih, ftdi_out_buf, nbtosend, &nbtosend);
|
||||
|
||||
if ( opcode & OP_RD_TDO )
|
||||
{
|
||||
do
|
||||
{
|
||||
Sleep(3);
|
||||
status = pFT_GetQueueStatus(ftdih, &nbRead);
|
||||
} while ( ( nbRead < 1 ) && ( status == FT_OK ) );
|
||||
|
||||
status = pFT_Read(ftdih, &ftdi_in_buf, nbRead, &nbRead);
|
||||
|
||||
// bits are shifted in from MSB to LSB ...
|
||||
i = 0;
|
||||
while( i < bitscnt )
|
||||
{
|
||||
if ( ftdi_in_buf[0] & (0x01 << ( (8 - bitscnt) + i ) ) )
|
||||
{
|
||||
str_in[rd_bit_index++] = JTAG_STR_DOUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
str_in[rd_bit_index++] = 0x00;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_FTDI_TMS_xfer(jtag_core * jc, unsigned char * str_out, int size)
|
||||
{
|
||||
int i;
|
||||
int wr_bit_index;
|
||||
DWORD nbtosend;
|
||||
FT_STATUS status;
|
||||
unsigned char bitscnt;
|
||||
unsigned char opcode;
|
||||
|
||||
status = FT_OK;
|
||||
|
||||
memset(ftdi_out_buf, 0, sizeof(ftdi_out_buf));
|
||||
memset(ftdi_in_buf, 0, sizeof(ftdi_in_buf));
|
||||
|
||||
wr_bit_index = 0;
|
||||
while( wr_bit_index < size )
|
||||
{
|
||||
opcode = ( OP_WR_TMS | OP_LSB_FIRST | OP_BIT_MODE | OP_FEDGE_WR );
|
||||
|
||||
nbtosend = 0;
|
||||
|
||||
bitscnt = (size - wr_bit_index);
|
||||
if( bitscnt > 7 )
|
||||
{
|
||||
bitscnt = 7;
|
||||
}
|
||||
|
||||
ftdi_out_buf[nbtosend++] = opcode;
|
||||
ftdi_out_buf[nbtosend++] = (bitscnt - 1); // Size field
|
||||
ftdi_out_buf[nbtosend] = 0x00;
|
||||
|
||||
i = 0;
|
||||
while( i < bitscnt )
|
||||
{
|
||||
if (str_out[wr_bit_index++] & JTAG_STR_TMS)
|
||||
ftdi_out_buf[nbtosend] |= 0x01 << i; // Data field
|
||||
|
||||
i++;
|
||||
}
|
||||
nbtosend++;
|
||||
|
||||
status = pFT_Write(ftdih, ftdi_out_buf, nbtosend, &nbtosend);
|
||||
}
|
||||
|
||||
if (status != FT_OK)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drv_FTDI_libGetDrv(jtag_core * jc,int sub_drv,unsigned int infotype,void * returnvalue)
|
||||
{
|
||||
|
||||
drv_ptr drv_funcs =
|
||||
{
|
||||
(DRV_DETECT) drv_FTDI_Detect,
|
||||
(DRV_INIT) drv_FTDI_Init,
|
||||
(DRV_DEINIT) drv_FTDI_DeInit,
|
||||
(DRV_TXTMS) drv_FTDI_TMS_xfer,
|
||||
(DRV_TXRXDATA) drv_FTDI_TDOTDI_xfer,
|
||||
(DRV_GETMODULEINFOS) drv_FTDI_libGetDrv
|
||||
};
|
||||
|
||||
return GetDrvInfo(
|
||||
jc,
|
||||
infotype,
|
||||
returnvalue,
|
||||
subdrv_list[sub_drv].drv_id,
|
||||
subdrv_list[sub_drv].drv_desc,
|
||||
&drv_funcs
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
26
lib_jtag_core/src/drivers/ftdi_jtag/ftdi_jtag_drv.h
Normal file
26
lib_jtag_core/src/drivers/ftdi_jtag/ftdi_jtag_drv.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ftdi_jtag_drv.h
|
||||
* @brief FTDI based probes driver entry point definition
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
int drv_FTDI_libGetDrv(jtag_core * jc,int sub_drv, unsigned int infotype,void * returnvalue);
|
||||
389
lib_jtag_core/src/drivers/jlink_jtag/jlink_jtag_drv.c
Normal file
389
lib_jtag_core/src/drivers/jlink_jtag/jlink_jtag_drv.c
Normal file
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file jlink_jtag_drv.c
|
||||
* @brief JLINK based probes driver
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../drv_loader.h"
|
||||
#include "../../jtag_core_internal.h"
|
||||
#include "../../jtag_core.h"
|
||||
|
||||
#include "../../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../../dbg_logs.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
// Compiling on Windows
|
||||
#include <windows.h>
|
||||
#elif defined(__linux__)
|
||||
#include <dlfcn.h>
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#error "Unsupported OS (only available on Windows or Linux)"
|
||||
#endif
|
||||
|
||||
typedef struct _drv_desc
|
||||
{
|
||||
char *drv_id;
|
||||
char *drv_desc;
|
||||
int id;
|
||||
}drv_desc;
|
||||
|
||||
#define PROBE_JLINK_ARM 0
|
||||
|
||||
const static drv_desc subdrv_list[]=
|
||||
{
|
||||
{"JLINK_ARM","USB JLINK ARM",PROBE_JLINK_ARM}
|
||||
};
|
||||
|
||||
unsigned char jlink_out_tms_buf[64 * 1024];
|
||||
unsigned char jlink_out_tdi_buf[64 * 1024];
|
||||
unsigned char jlink_in_buf[64 * 1024];
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
#if defined(_WIN64)
|
||||
#define MODULE_NAME "JLink_x64.dll"
|
||||
#else
|
||||
#define MODULE_NAME "JLinkARM.dll"
|
||||
#endif
|
||||
|
||||
typedef const char* (WINAPIV * JL_OPENEX)(const char* pfLog, void*);
|
||||
typedef int (WINAPIV * JL_JTAG_STORERAW)(const unsigned char* pTDI, const unsigned char* pTMS, unsigned int NumBits);
|
||||
typedef int (WINAPIV * JL_JTAG_STOREGETRAW)(const unsigned char* pTDI, unsigned char* pTDO, const unsigned char* pTMS, unsigned int NumBits);
|
||||
typedef void (WINAPIV * JL_JTAG_SYNCBITS)(void);
|
||||
typedef void (WINAPIV * JL_SETSPEED)(unsigned int Speed);
|
||||
typedef void (WINAPIV * JL_SETRESETDELAY)(int ms);
|
||||
typedef void (WINAPIV * JL_RESETPULLSRESET)(unsigned char OnOff);
|
||||
typedef void (WINAPIV * JL_RESET)(void);
|
||||
typedef int (WINAPIV * JL_HASERROR)(void);
|
||||
typedef void (WINAPIV * JL_CLOSE)(void);
|
||||
|
||||
#else
|
||||
|
||||
#define MODULE_NAME "./libjlinkarm.so"
|
||||
|
||||
#if defined(__i386__)
|
||||
#define __cdecl __attribut__((cdecl))
|
||||
#else // __x86_64__ and others...
|
||||
#define __cdecl
|
||||
#endif
|
||||
|
||||
typedef void* HMODULE;
|
||||
|
||||
typedef const char* (__cdecl * JL_OPENEX)(const char* pfLog, void*);
|
||||
typedef int (__cdecl * JL_JTAG_STORERAW)(const unsigned char* pTDI, const unsigned char* pTMS, unsigned int NumBits);
|
||||
typedef int (__cdecl * JL_JTAG_STOREGETRAW)(const unsigned char* pTDI, unsigned char* pTDO, const unsigned char* pTMS, unsigned int NumBits);
|
||||
typedef void (__cdecl * JL_JTAG_SYNCBITS)(void);
|
||||
typedef void (__cdecl * JL_SETSPEED)(unsigned int Speed);
|
||||
typedef void (__cdecl * JL_SETRESETDELAY)(int ms);
|
||||
typedef void (__cdecl * JL_RESETPULLSRESET)(unsigned char OnOff);
|
||||
typedef void (__cdecl * JL_RESET)(void);
|
||||
typedef int (__cdecl * JL_HASERROR)(void);
|
||||
typedef void (__cdecl * JL_CLOSE)(void);
|
||||
|
||||
void* GetProcAddress(HMODULE handle, const char* name)
|
||||
{
|
||||
if(!handle || !name)
|
||||
return NULL;
|
||||
|
||||
dlerror();
|
||||
|
||||
return dlsym(handle, name);
|
||||
}
|
||||
|
||||
bool FreeLibrary(HMODULE handle)
|
||||
{
|
||||
dlerror();
|
||||
if(0 != dlclose(handle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
HMODULE LoadLibrary(const char* path)
|
||||
{
|
||||
dlerror();
|
||||
return dlopen(path, RTLD_NOW);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static HMODULE lib_handle = 0;
|
||||
|
||||
JL_OPENEX pJLINKARM_OpenEx;
|
||||
JL_JTAG_STORERAW pJLINKARM_JTAG_StoreRaw;
|
||||
JL_JTAG_STOREGETRAW pJLINKARM_JTAG_StoreGetRaw;
|
||||
JL_JTAG_SYNCBITS pJLINKARM_JTAG_SyncBits;
|
||||
JL_SETSPEED pJLINKARM_SetSpeed;
|
||||
JL_SETRESETDELAY pJLINKARM_SetResetDelay;
|
||||
JL_RESETPULLSRESET pJLINKARM_ResetPullsRESET;
|
||||
JL_RESET pJLINKARM_Reset;
|
||||
JL_HASERROR pJLINKARM_HasError;
|
||||
JL_CLOSE pJLINKARM_Close;
|
||||
|
||||
int drv_JLINK_Detect(jtag_core * jc)
|
||||
{
|
||||
if(lib_handle == NULL) {
|
||||
lib_handle = LoadLibrary(MODULE_NAME);
|
||||
}
|
||||
|
||||
if (lib_handle)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_INFO_1,"drv_JLINK_Detect : %s JLink library found !\r\n",MODULE_NAME);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_INFO_1,"drv_JLINK_Detect : %s JLink library not found !\r\n",MODULE_NAME);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void * drv_JLINK_GetDrvFunc(jtag_core * jc, HMODULE libh, char * function_name)
|
||||
{
|
||||
void * function_ptr;
|
||||
|
||||
function_ptr = (void *)GetProcAddress(libh, function_name);
|
||||
if (!function_ptr)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_JLINK_GetDrvFunc : Can't get %s function !\r\n",function_name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return function_ptr;
|
||||
}
|
||||
|
||||
int drv_JLINK_Init(jtag_core * jc, int sub_drv, char * params)
|
||||
{
|
||||
const char* sError;
|
||||
|
||||
if(lib_handle == NULL) {
|
||||
lib_handle = LoadLibrary(MODULE_NAME);
|
||||
}
|
||||
|
||||
if (lib_handle)
|
||||
{
|
||||
pJLINKARM_OpenEx = (JL_OPENEX)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_OpenEx");
|
||||
if (!pJLINKARM_OpenEx)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_JTAG_StoreRaw = (JL_JTAG_STORERAW)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_JTAG_StoreRaw");
|
||||
if (!pJLINKARM_JTAG_StoreRaw)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_JTAG_StoreGetRaw = (JL_JTAG_STOREGETRAW)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_JTAG_StoreGetRaw");
|
||||
if (!pJLINKARM_JTAG_StoreGetRaw)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_JTAG_SyncBits = (JL_JTAG_SYNCBITS)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_JTAG_SyncBits");
|
||||
if (!pJLINKARM_JTAG_SyncBits)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_SetSpeed = (JL_SETSPEED)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_SetSpeed");
|
||||
if (!pJLINKARM_SetSpeed)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_SetResetDelay = (JL_SETRESETDELAY)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_SetResetDelay");
|
||||
if (!pJLINKARM_SetResetDelay)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_ResetPullsRESET = (JL_RESETPULLSRESET)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_ResetPullsRESET");
|
||||
if (!pJLINKARM_ResetPullsRESET)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_Reset = (JL_RESET)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_Reset");
|
||||
if (!pJLINKARM_Reset)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_HasError = (JL_HASERROR)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_HasError");
|
||||
if (!pJLINKARM_HasError)
|
||||
goto loadliberror;
|
||||
|
||||
pJLINKARM_Close = (JL_CLOSE)drv_JLINK_GetDrvFunc(jc, lib_handle, "JLINKARM_Close");
|
||||
if (!pJLINKARM_Close)
|
||||
goto loadliberror;
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_JLINK_Init : Can't load JLinkARM.dll !\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sError = pJLINKARM_OpenEx(NULL, 0);
|
||||
if (sError) {
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"pJLINKARM_OpenEx : Error 0x%x !\r\n",sError);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pJLINKARM_SetSpeed(1000); // 1 Mhz
|
||||
|
||||
jtagcore_logs_printf(jc,MSG_INFO_0,"drv_JLINK_Init : Probe Driver loaded successfully...\r\n");
|
||||
|
||||
return 0;
|
||||
|
||||
loadliberror:
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_JLINK_Init : Something wrong happened ! JLink probe support not enabled.\r\n");
|
||||
|
||||
FreeLibrary(lib_handle);
|
||||
|
||||
lib_handle = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int drv_JLINK_DeInit(jtag_core * jc)
|
||||
{
|
||||
pJLINKARM_Close();
|
||||
FreeLibrary(lib_handle);
|
||||
lib_handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_JLINK_TDOTDI_xfer(jtag_core * jc, unsigned char * str_out, unsigned char * str_in, int size)
|
||||
{
|
||||
int i;
|
||||
int bitoffset;
|
||||
|
||||
memset(jlink_out_tms_buf, 0, sizeof(jlink_out_tms_buf));
|
||||
memset(jlink_out_tdi_buf, 0, sizeof(jlink_out_tdi_buf));
|
||||
|
||||
if (!str_in)
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
i = 0;
|
||||
bitoffset = 0;
|
||||
while (i < size)
|
||||
{
|
||||
if (str_out[i] & JTAG_STR_TMS)
|
||||
jlink_out_tms_buf[bitoffset >> 3] |= (0x01 << (bitoffset & 7));
|
||||
|
||||
if (str_out[i] & JTAG_STR_DOUT)
|
||||
jlink_out_tdi_buf[bitoffset >> 3] |= (0x01 << (bitoffset & 7));
|
||||
|
||||
bitoffset++;
|
||||
i++;
|
||||
}
|
||||
|
||||
pJLINKARM_JTAG_StoreRaw(jlink_out_tdi_buf, jlink_out_tms_buf, bitoffset);
|
||||
pJLINKARM_JTAG_SyncBits();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
memset(jlink_in_buf, 0, sizeof(jlink_in_buf));
|
||||
|
||||
i = 0;
|
||||
bitoffset = 0;
|
||||
while (i < size)
|
||||
{
|
||||
if (str_out[i] & JTAG_STR_TMS)
|
||||
jlink_out_tms_buf[bitoffset >> 3] |= (0x01 << (bitoffset & 7));
|
||||
|
||||
if (str_out[i] & JTAG_STR_DOUT)
|
||||
jlink_out_tdi_buf[bitoffset >> 3] |= (0x01 << (bitoffset & 7));
|
||||
|
||||
bitoffset++;
|
||||
i++;
|
||||
}
|
||||
|
||||
pJLINKARM_JTAG_StoreGetRaw(jlink_out_tdi_buf, jlink_in_buf, jlink_out_tms_buf, bitoffset);
|
||||
pJLINKARM_JTAG_SyncBits();
|
||||
|
||||
i = 0;
|
||||
while (i < size)
|
||||
{
|
||||
if (jlink_in_buf[i >> 3] & (0x01 << (i & 7)))
|
||||
{
|
||||
str_in[i] = JTAG_STR_DOUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
str_in[i] = 0x00;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_JLINK_TMS_xfer(jtag_core * jc, unsigned char * str_out, int size)
|
||||
{
|
||||
int bitoffset,i;
|
||||
|
||||
memset(jlink_out_tms_buf, 0, sizeof(jlink_out_tms_buf));
|
||||
memset(jlink_out_tdi_buf, 0, sizeof(jlink_out_tdi_buf));
|
||||
|
||||
if (size)
|
||||
{
|
||||
i = 0;
|
||||
bitoffset = 0;
|
||||
while (i < size)
|
||||
{
|
||||
if (str_out[i] & JTAG_STR_TMS)
|
||||
jlink_out_tms_buf[bitoffset >> 3] |= (0x01 << (bitoffset & 7));
|
||||
|
||||
bitoffset++;
|
||||
i++;
|
||||
}
|
||||
|
||||
pJLINKARM_JTAG_StoreRaw(jlink_out_tdi_buf, jlink_out_tms_buf, bitoffset);
|
||||
pJLINKARM_JTAG_SyncBits();
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_JLINK_libGetDrv(jtag_core * jc,int sub_drv,unsigned int infotype,void * returnvalue)
|
||||
{
|
||||
drv_ptr drv_funcs =
|
||||
{
|
||||
(DRV_DETECT) drv_JLINK_Detect,
|
||||
(DRV_INIT) drv_JLINK_Init,
|
||||
(DRV_DEINIT) drv_JLINK_DeInit,
|
||||
(DRV_TXTMS) drv_JLINK_TMS_xfer,
|
||||
(DRV_TXRXDATA) drv_JLINK_TDOTDI_xfer,
|
||||
(DRV_GETMODULEINFOS) drv_JLINK_libGetDrv
|
||||
};
|
||||
|
||||
return GetDrvInfo(
|
||||
jc,
|
||||
infotype,
|
||||
returnvalue,
|
||||
subdrv_list[sub_drv].drv_id,
|
||||
subdrv_list[sub_drv].drv_desc,
|
||||
&drv_funcs
|
||||
);
|
||||
}
|
||||
|
||||
26
lib_jtag_core/src/drivers/jlink_jtag/jlink_jtag_drv.h
Normal file
26
lib_jtag_core/src/drivers/jlink_jtag/jlink_jtag_drv.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file jlink_jtag_drv.h
|
||||
* @brief JLINK based probes driver entry point definition
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
int drv_JLINK_libGetDrv(jtag_core * jc,int sub_drv, unsigned int infotype,void * returnvalue);
|
||||
452
lib_jtag_core/src/drivers/linux_gpio_jtag/linux_gpio_jtag_drv.c
Normal file
452
lib_jtag_core/src/drivers/linux_gpio_jtag/linux_gpio_jtag_drv.c
Normal file
@@ -0,0 +1,452 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file linux_gpio_jtag_drv.c
|
||||
* @brief jtag linux gpio probes driver
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../drv_loader.h"
|
||||
#include "../../jtag_core_internal.h"
|
||||
#include "../../jtag_core.h"
|
||||
|
||||
#include "../../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../../os_interface/os_interface.h"
|
||||
|
||||
#include "../../dbg_logs.h"
|
||||
|
||||
char linux_gpio_base[512];
|
||||
|
||||
#define IGNORE_PORT 0
|
||||
#define READ_PORT 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
int gpio_num;
|
||||
int dir;
|
||||
int state;
|
||||
int old_state;
|
||||
int negate_polarity;
|
||||
int handle;
|
||||
}io_defs;
|
||||
|
||||
#define TMS_INDEX 0
|
||||
#define TDO_INDEX 1
|
||||
#define TDI_INDEX 2
|
||||
#define TCK_INDEX 3
|
||||
|
||||
io_defs gpio_var_names[]=
|
||||
{
|
||||
{(const char*)"PROBE_LINUXGPIO_TMS_PIN",-1,1,0,-1,0,-1},
|
||||
{(const char*)"PROBE_LINUXGPIO_TDO_PIN",-1,0,0,-1,0,-1},
|
||||
{(const char*)"PROBE_LINUXGPIO_TDI_PIN",-1,1,0,-1,0,-1},
|
||||
{(const char*)"PROBE_LINUXGPIO_TCK_PIN",-1,1,0,-1,0,-1},
|
||||
{(const char*)NULL,-1,-1,0,-1,-1}
|
||||
};
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
static int putp(int tdi, int tms, int rp)
|
||||
{
|
||||
int tdo = -1;
|
||||
int ret;
|
||||
char tmp_str[512];
|
||||
char rd_value;
|
||||
|
||||
tmp_str[0] = '0';
|
||||
tmp_str[1] = '\n';
|
||||
tmp_str[2] = 0;
|
||||
|
||||
rd_value = 0;
|
||||
|
||||
if (rp == READ_PORT)
|
||||
{
|
||||
|
||||
rd_value = 0;
|
||||
lseek(gpio_var_names[TDO_INDEX].handle, 0, SEEK_SET);
|
||||
ret = read(gpio_var_names[TDO_INDEX].handle,&rd_value,1);
|
||||
if(ret < 1)
|
||||
goto wr_error;
|
||||
|
||||
if(rd_value >= '0' && rd_value <='1')
|
||||
{
|
||||
gpio_var_names[TDO_INDEX].old_state = gpio_var_names[TDO_INDEX].state;
|
||||
tdo = (rd_value - '0') ^ (gpio_var_names[TDO_INDEX].negate_polarity&1);
|
||||
gpio_var_names[TDO_INDEX].state = tdo;
|
||||
}
|
||||
}
|
||||
|
||||
if( gpio_var_names[TMS_INDEX].old_state != (tms&1))
|
||||
{
|
||||
tmp_str[0] = '0' + ((tms&1) ^ (gpio_var_names[TMS_INDEX].negate_polarity&1));
|
||||
|
||||
ret = write(gpio_var_names[TMS_INDEX].handle,tmp_str,2);
|
||||
if(ret < 2)
|
||||
goto wr_error;
|
||||
|
||||
gpio_var_names[TMS_INDEX].old_state = (tms&1);
|
||||
}
|
||||
|
||||
if( gpio_var_names[TDI_INDEX].old_state != (tdi&1))
|
||||
{
|
||||
tmp_str[0] = '0' + ((tdi&1) ^ (gpio_var_names[TDI_INDEX].negate_polarity&1));
|
||||
ret = write(gpio_var_names[TDI_INDEX].handle,tmp_str,2);
|
||||
if(ret < 2)
|
||||
goto wr_error;
|
||||
|
||||
gpio_var_names[TDI_INDEX].old_state = (tdi&1);
|
||||
}
|
||||
|
||||
tmp_str[0] = '0' + (gpio_var_names[TCK_INDEX].negate_polarity&1);
|
||||
ret = write(gpio_var_names[TCK_INDEX].handle,tmp_str,2);
|
||||
if(ret < 2)
|
||||
goto wr_error;
|
||||
|
||||
gpio_var_names[TCK_INDEX].old_state = 0;
|
||||
|
||||
tmp_str[0] = '0' + (1 ^ (gpio_var_names[TCK_INDEX].negate_polarity&1));
|
||||
ret = write(gpio_var_names[TCK_INDEX].handle,tmp_str,2);
|
||||
if(ret < 2)
|
||||
goto wr_error;
|
||||
|
||||
gpio_var_names[TCK_INDEX].old_state = 1;
|
||||
|
||||
tmp_str[0] = '0' + (gpio_var_names[TCK_INDEX].negate_polarity&1);
|
||||
ret = write(gpio_var_names[TCK_INDEX].handle,tmp_str,2);
|
||||
if(ret < 2)
|
||||
goto wr_error;
|
||||
|
||||
gpio_var_names[TCK_INDEX].old_state = 0;
|
||||
|
||||
return tdo;
|
||||
|
||||
wr_error:
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
int drv_LinuxGPIO_Detect(jtag_core * jc)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
char tmp_str[1024];
|
||||
FILE * f;
|
||||
|
||||
if( jtagcore_getEnvVarValue( jc, "PROBE_GPIO_LINUX_ENABLE") > 0)
|
||||
{
|
||||
jtagcore_getEnvVar( jc, "PROBE_GPIO_LINUX_BASE_FOLDER", (char*)&linux_gpio_base);
|
||||
|
||||
strncpy(tmp_str, linux_gpio_base, sizeof(tmp_str) - 1);
|
||||
genos_strndstcat(tmp_str,"/export",sizeof(tmp_str));
|
||||
tmp_str[sizeof(tmp_str) - 1] = '\0';
|
||||
|
||||
f = fopen(tmp_str,"rb");
|
||||
if(f)
|
||||
{
|
||||
fclose(f);
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LinuxGPIO_Detect : JTAG GPIO interface enabled\r\n",tmp_str);
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LinuxGPIO_Detect : Can't open %s !\r\n",tmp_str);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
static int exportGPIO(char * path_base,int pin)
|
||||
{
|
||||
char tmp_str[512];
|
||||
FILE * f;
|
||||
|
||||
strcpy(tmp_str,path_base);
|
||||
strcat(tmp_str,"/export");
|
||||
|
||||
f = fopen(tmp_str,"w");
|
||||
if(!f)
|
||||
{
|
||||
return JTAG_CORE_ACCESS_ERROR;
|
||||
}
|
||||
|
||||
fprintf(f,"%d\n", pin);
|
||||
fclose(f);
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
|
||||
static int setdirGPIO(char * path_base,int pin,int dir)
|
||||
{
|
||||
char tmp_str[1024];
|
||||
char tmp_str2[64];
|
||||
FILE * f;
|
||||
|
||||
strncpy(tmp_str,path_base,sizeof(tmp_str)-1);
|
||||
snprintf(tmp_str2,sizeof(tmp_str2)-1,"/gpio%d/direction",pin);
|
||||
genos_strndstcat(tmp_str,tmp_str2,sizeof(tmp_str));
|
||||
tmp_str[sizeof(tmp_str) - 1] = '\0';
|
||||
|
||||
f = fopen(tmp_str,"w");
|
||||
if(!f)
|
||||
{
|
||||
return JTAG_CORE_ACCESS_ERROR;
|
||||
}
|
||||
|
||||
if(dir)
|
||||
fprintf(f,"out\n");
|
||||
else
|
||||
fprintf(f,"in\n");
|
||||
|
||||
fclose(f);
|
||||
|
||||
return JTAG_CORE_NO_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int drv_LinuxGPIO_Init(jtag_core * jc, int sub_drv,char * params)
|
||||
{
|
||||
int probe_detected;
|
||||
|
||||
probe_detected = 0;
|
||||
|
||||
if( jtagcore_getEnvVarValue( jc, "PROBE_LINUXGPIO_ENABLE") <= 0)
|
||||
{
|
||||
return JTAG_CORE_NO_PROBE;
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
int i;
|
||||
char tmp_str[1024];
|
||||
|
||||
jtagcore_getEnvVar( jc, "PROBE_LINUXGPIO_BASE_FOLDER", (char*)&linux_gpio_base);
|
||||
|
||||
i = 0;
|
||||
while(gpio_var_names[i].name)
|
||||
{
|
||||
gpio_var_names[i].gpio_num = jtagcore_getEnvVarValue( jc, (char*)gpio_var_names[i].name);
|
||||
|
||||
strncpy(tmp_str,(char*)gpio_var_names[i].name,sizeof(tmp_str) - 1);
|
||||
tmp_str[sizeof(tmp_str) - 1] = '\0';
|
||||
|
||||
genos_strndstcat(tmp_str,"_INVERT_POLARITY",sizeof(tmp_str));
|
||||
tmp_str[sizeof(tmp_str) - 1] = '\0';
|
||||
|
||||
gpio_var_names[i].negate_polarity = jtagcore_getEnvVarValue( jc, (char*)tmp_str);
|
||||
|
||||
if( exportGPIO(linux_gpio_base, gpio_var_names[i].gpio_num) != JTAG_CORE_NO_ERROR )
|
||||
break;
|
||||
|
||||
if( setdirGPIO(linux_gpio_base, gpio_var_names[i].gpio_num, gpio_var_names[i].dir) != JTAG_CORE_NO_ERROR )
|
||||
break;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if(!gpio_var_names[i].name)
|
||||
{
|
||||
probe_detected = 1;
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
snprintf(tmp_str,sizeof(tmp_str),"%s/gpio%d/value",linux_gpio_base,gpio_var_names[i].gpio_num);
|
||||
|
||||
if(gpio_var_names[i].handle != -1)
|
||||
close(gpio_var_names[i].handle);
|
||||
|
||||
if(gpio_var_names[i].dir)
|
||||
gpio_var_names[i].handle = open(tmp_str, O_WRONLY);
|
||||
else
|
||||
gpio_var_names[i].handle = open(tmp_str, O_RDONLY);
|
||||
|
||||
if(gpio_var_names[i].handle < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == 4 )
|
||||
{
|
||||
// init gpio
|
||||
putp(0, 0, IGNORE_PORT);
|
||||
putp(0, 0, IGNORE_PORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
probe_detected = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(probe_detected)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_INFO_0,"drv_LinuxGPIO_Init : Probe Driver loaded successfully...\r\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LinuxGPIO_Init : No probe found !\r\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int drv_LinuxGPIO_DeInit(jtag_core * jc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_LinuxGPIO_TDOTDI_xfer(jtag_core * jc, unsigned char * str_out, unsigned char * str_in, int size)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
|
||||
if (!str_in)
|
||||
{
|
||||
while (i < size)
|
||||
{
|
||||
|
||||
if (str_out[i] & JTAG_STR_TMS)
|
||||
{
|
||||
gpio_var_names[TMS_INDEX].state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_var_names[TMS_INDEX].state = 0;
|
||||
}
|
||||
|
||||
if (str_out[i] & JTAG_STR_DOUT)
|
||||
{
|
||||
gpio_var_names[TDI_INDEX].state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_var_names[TDI_INDEX].state = 0;
|
||||
}
|
||||
|
||||
putp(gpio_var_names[TDI_INDEX].state, gpio_var_names[TMS_INDEX].state, IGNORE_PORT);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (i < size)
|
||||
{
|
||||
if (str_out[i] & JTAG_STR_DOUT)
|
||||
{
|
||||
gpio_var_names[TDI_INDEX].state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_var_names[TDI_INDEX].state = 0;
|
||||
}
|
||||
|
||||
if (str_out[i] & JTAG_STR_TMS)
|
||||
{
|
||||
gpio_var_names[TMS_INDEX].state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_var_names[TMS_INDEX].state = 0;
|
||||
}
|
||||
|
||||
str_in[i] = putp(gpio_var_names[TDI_INDEX].state, gpio_var_names[TMS_INDEX].state, READ_PORT);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
int drv_LinuxGPIO_TMS_xfer(jtag_core * jc, unsigned char * str_out, int size)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
int i;
|
||||
|
||||
gpio_var_names[TDI_INDEX].state = 0;
|
||||
|
||||
i = 0;
|
||||
while (i < size)
|
||||
{
|
||||
if (str_out[i] & JTAG_STR_TMS)
|
||||
{
|
||||
gpio_var_names[TMS_INDEX].state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_var_names[TMS_INDEX].state = 0;
|
||||
}
|
||||
|
||||
putp(gpio_var_names[TDI_INDEX].state, gpio_var_names[TMS_INDEX].state, IGNORE_PORT);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
int drv_LinuxGPIO_libGetDrv(jtag_core * jc, int sub_drv, unsigned int infotype,void * returnvalue)
|
||||
{
|
||||
|
||||
drv_ptr drv_funcs =
|
||||
{
|
||||
(DRV_DETECT) drv_LinuxGPIO_Detect,
|
||||
(DRV_INIT) drv_LinuxGPIO_Init,
|
||||
(DRV_DEINIT) drv_LinuxGPIO_DeInit,
|
||||
(DRV_TXTMS) drv_LinuxGPIO_TMS_xfer,
|
||||
(DRV_TXRXDATA) drv_LinuxGPIO_TDOTDI_xfer,
|
||||
(DRV_GETMODULEINFOS) drv_LinuxGPIO_libGetDrv
|
||||
};
|
||||
|
||||
return GetDrvInfo(
|
||||
jc,
|
||||
infotype,
|
||||
returnvalue,
|
||||
"LINUX_GPIO",
|
||||
"GENERIC LINUX GPIO JTAG",
|
||||
&drv_funcs
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file linux_gpio_jtag_drv.h
|
||||
* @brief jtag linux gpio probes driver
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
int drv_LinuxGPIO_libGetDrv(jtag_core * jc,int sub_drv,unsigned int infotype,void * returnvalue);
|
||||
426
lib_jtag_core/src/drivers/lpt_jtag/lpt_jtag_drv.c
Normal file
426
lib_jtag_core/src/drivers/lpt_jtag/lpt_jtag_drv.c
Normal file
@@ -0,0 +1,426 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file lpt_jtag_drv.c
|
||||
* @brief parallel port probes driver
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#ifndef _WIN64
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <conio.h>
|
||||
#endif
|
||||
|
||||
#include "../drv_loader.h"
|
||||
#include "../../jtag_core_internal.h"
|
||||
#include "../../jtag_core.h"
|
||||
|
||||
#include "../../bsdl_parser/bsdl_loader.h"
|
||||
|
||||
#include "../../dbg_logs.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
HANDLE h;
|
||||
|
||||
#endif
|
||||
|
||||
#define LPT1 0x3bc
|
||||
#define LPT2 0x378
|
||||
#define LPT3 0x278
|
||||
|
||||
#define IGNORE_PORT 0
|
||||
#define READ_PORT 1
|
||||
|
||||
unsigned short lpt_address;
|
||||
|
||||
|
||||
int sub_probe_id;
|
||||
|
||||
typedef struct _drv_desc
|
||||
{
|
||||
char *drv_id;
|
||||
char *drv_desc;
|
||||
int id;
|
||||
}drv_desc;
|
||||
|
||||
#define PROBE_INSIGHT_IJC 0
|
||||
#define PROBE_ALTERA_BYTEBLASTER 1
|
||||
#define PROBE_MACRAIGOR_WIGGLER 2
|
||||
|
||||
const static drv_desc subdrv_list[]=
|
||||
{
|
||||
{"LPT_INSIGHT_JTAG","LPT Memec IJC-4",PROBE_INSIGHT_IJC},
|
||||
{"LPT_ALTERA_BYTEBLASTER_JTAG","LPT Altera ByteBlaster",PROBE_ALTERA_BYTEBLASTER},
|
||||
{"LPT_MACRAIGOR_WIGGLERJTAG","LPT Macgraigor Wiggler",PROBE_MACRAIGOR_WIGGLER}
|
||||
};
|
||||
|
||||
void out_io_port( unsigned short port, unsigned char data )
|
||||
{
|
||||
#if defined(WIN32)
|
||||
_outp( port, data );
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char in_io_port( unsigned short port )
|
||||
{
|
||||
#if defined(WIN32)
|
||||
return _inp( port );
|
||||
#else
|
||||
return 0x00;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int test_port(void)
|
||||
{
|
||||
// search for valid parallel port
|
||||
out_io_port(LPT1, 0x55);
|
||||
if ((int)in_io_port(LPT1) == 0x55)
|
||||
{
|
||||
return LPT1;
|
||||
}
|
||||
|
||||
out_io_port(LPT2, 0x55);
|
||||
if ((int)in_io_port(LPT2) == 0x55)
|
||||
{
|
||||
return LPT2;
|
||||
}
|
||||
|
||||
out_io_port(LPT3, 0x55);
|
||||
if ((int)in_io_port(LPT3) == 0x55)
|
||||
{
|
||||
return LPT3;
|
||||
}
|
||||
|
||||
return(0); // return zero if none found
|
||||
}
|
||||
|
||||
int putp(int tdi, int tms, int rp)
|
||||
{
|
||||
int tdo = -1;
|
||||
int lpt_data;
|
||||
|
||||
switch (sub_probe_id)
|
||||
{
|
||||
case PROBE_INSIGHT_IJC:
|
||||
// Insight/Xilinx :
|
||||
// D4 : TDO DRV LOW (AL)
|
||||
// D3 : OE (AL)
|
||||
// D1 : TCK (AH)
|
||||
// D2 : TMS (AH)
|
||||
// D0 : TDI (AH) (To device)
|
||||
// OnLine :TDO (AH) (From device)
|
||||
|
||||
lpt_data = 0x10; //Output to TDO off / Outputs enabled
|
||||
if (tms == 1) lpt_data |= 0x04;
|
||||
if (tdi == 1) lpt_data |= 0x01;
|
||||
|
||||
out_io_port(lpt_address, (unsigned char)lpt_data); // TCK low
|
||||
|
||||
lpt_data |= 0x02;
|
||||
out_io_port(lpt_address, (unsigned char)lpt_data); // TCK high
|
||||
|
||||
if (rp == READ_PORT)
|
||||
{
|
||||
tdo = ((int)in_io_port((unsigned short)(lpt_address + 1)) & 0x10) >> 4; // get TDO data
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PROBE_ALTERA_BYTEBLASTER:
|
||||
// Byteblaster :
|
||||
// AutoF : OE (AH)
|
||||
// D0 : TCK (AH)
|
||||
// D1 : TMS (AH)
|
||||
// D6 : TDI (AH) (To device)
|
||||
// BUSY : TDO (AL) (From device)
|
||||
// D4 : Loopback test out (AH)
|
||||
// Ack : Loopback test in (AH)
|
||||
|
||||
lpt_data = 0x00;
|
||||
|
||||
if (tms == 1) lpt_data |= 0x02;
|
||||
if (tdi == 1) lpt_data |= 0x40;
|
||||
|
||||
out_io_port(lpt_address, (unsigned char)lpt_data); // TCK low
|
||||
|
||||
lpt_data |= 0x01;
|
||||
out_io_port(lpt_address, (unsigned char)lpt_data); // TCK high
|
||||
|
||||
if (rp == READ_PORT)
|
||||
{
|
||||
tdo = (((int)in_io_port((unsigned short)(lpt_address + 1)) & 0x80) >> 7) ^ 1; // get TDO data
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PROBE_MACRAIGOR_WIGGLER:
|
||||
// Macraigor Wiggler :
|
||||
// AutoF : OE (AH)
|
||||
// D0 : RST (AH)
|
||||
// D1 : TMS (AH)
|
||||
// D2 : TCK (AH)
|
||||
// D3 : TDI (AH) (To device)
|
||||
// D4 : TRST (AH)
|
||||
// D7 : "PC VCC"
|
||||
// BUSY : TDO (AL) (From device)
|
||||
// D6 : Loopback test out (AH)
|
||||
// Error : Loopback test in (AH)
|
||||
|
||||
lpt_data = 0x10 | 0x80; //Set PC VCC & TRST to 1
|
||||
|
||||
if (tms == 1) lpt_data |= 0x02;
|
||||
if (tdi == 1) lpt_data |= 0x08;
|
||||
|
||||
out_io_port(lpt_address, (unsigned char)lpt_data); // TCK low
|
||||
|
||||
lpt_data |= 0x04;
|
||||
out_io_port(lpt_address, (unsigned char)lpt_data); // TCK high
|
||||
|
||||
if (rp == READ_PORT)
|
||||
{
|
||||
tdo = (((int)in_io_port((unsigned short)(lpt_address + 1)) & 0x80) >> 7) ^ 1; // get TDO data
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return tdo;
|
||||
}
|
||||
|
||||
int drv_LPT_Detect(jtag_core * jc)
|
||||
{
|
||||
|
||||
#if defined(WIN32)
|
||||
h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LPT_Init : Can't load giveio !\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LPT_Detect : giveio enabled !\r\n");
|
||||
#endif
|
||||
|
||||
lpt_address = test_port(); // find a valid parallel port address
|
||||
if (!lpt_address)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LPT_Init : No LPT port found !\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
int drv_LPT_Init(jtag_core * jc, int sub_drv,char * params)
|
||||
{
|
||||
int probe_detected;
|
||||
|
||||
#if defined(WIN32)
|
||||
h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LPT_Init : Can't load giveio !\r\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
lpt_address = test_port(); // find a valid parallel port address
|
||||
if (!lpt_address)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LPT_Init : No LPT port found !\r\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
sub_probe_id = subdrv_list[sub_drv].id;
|
||||
|
||||
switch(sub_probe_id)
|
||||
{
|
||||
case PROBE_ALTERA_BYTEBLASTER:
|
||||
probe_detected = 1;
|
||||
|
||||
/*
|
||||
// Loop back test
|
||||
out_io_port(lpt_address, 0x00);
|
||||
if( in_io_port(lpt_address + 1) & 0x40)
|
||||
{
|
||||
probe_detected = 0;
|
||||
}
|
||||
|
||||
out_io_port(lpt_address, 0x10);
|
||||
if( !(in_io_port(lpt_address + 1) & 0x40))
|
||||
{
|
||||
probe_detected = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
// Enable outputs.
|
||||
if(probe_detected)
|
||||
out_io_port((unsigned short)(lpt_address + 0x02), 0x02);
|
||||
break;
|
||||
|
||||
default:
|
||||
probe_detected = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(probe_detected)
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_INFO_0,"drv_LPT_Init : Probe Driver loaded successfully...\r\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
jtagcore_logs_printf(jc,MSG_ERROR,"drv_LPT_Init : No probe found !\r\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int drv_LPT_DeInit(jtag_core * jc)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
CloseHandle(h);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_LPT_TDOTDI_xfer(jtag_core * jc, unsigned char * str_out, unsigned char * str_in, int size)
|
||||
{
|
||||
int i;
|
||||
int tms, tdi;
|
||||
|
||||
|
||||
if (size)
|
||||
{
|
||||
if (str_out[0] & JTAG_STR_TMS)
|
||||
{
|
||||
tms = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tms = 0;
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
if (!str_in)
|
||||
{
|
||||
while (i < size)
|
||||
{
|
||||
|
||||
if (str_out[i] & JTAG_STR_DOUT)
|
||||
{
|
||||
tdi = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tdi = 0;
|
||||
}
|
||||
|
||||
putp(tdi, tms, IGNORE_PORT);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (i < size)
|
||||
{
|
||||
|
||||
if (str_out[i] & JTAG_STR_DOUT)
|
||||
{
|
||||
tdi = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tdi = 0;
|
||||
}
|
||||
|
||||
str_in[i] = putp(tdi, tms, READ_PORT);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_LPT_TMS_xfer(jtag_core * jc, unsigned char * str_out, int size)
|
||||
{
|
||||
int i;
|
||||
int tms, tdi;
|
||||
|
||||
tdi = 0;
|
||||
i = 0;
|
||||
|
||||
while (i < size)
|
||||
{
|
||||
if (str_out[i] & JTAG_STR_TMS)
|
||||
{
|
||||
tms = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tms = 0;
|
||||
}
|
||||
|
||||
putp(tdi, tms, IGNORE_PORT);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_LPT_libGetDrv(jtag_core * jc, int sub_drv, unsigned int infotype,void * returnvalue)
|
||||
{
|
||||
|
||||
drv_ptr drv_funcs =
|
||||
{
|
||||
(DRV_DETECT) drv_LPT_Detect,
|
||||
(DRV_INIT) drv_LPT_Init,
|
||||
(DRV_DEINIT) drv_LPT_DeInit,
|
||||
(DRV_TXTMS) drv_LPT_TMS_xfer,
|
||||
(DRV_TXRXDATA) drv_LPT_TDOTDI_xfer,
|
||||
(DRV_GETMODULEINFOS) drv_LPT_libGetDrv
|
||||
};
|
||||
|
||||
return GetDrvInfo(
|
||||
jc,
|
||||
infotype,
|
||||
returnvalue,
|
||||
subdrv_list[sub_drv].drv_id,
|
||||
subdrv_list[sub_drv].drv_desc,
|
||||
&drv_funcs
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
26
lib_jtag_core/src/drivers/lpt_jtag/lpt_jtag_drv.h
Normal file
26
lib_jtag_core/src/drivers/lpt_jtag/lpt_jtag_drv.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file lpt_jtag_drv.h
|
||||
* @brief parallel port probes driver entry point definition
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
int drv_LPT_libGetDrv(jtag_core * jc,int sub_drv,unsigned int infotype,void * returnvalue);
|
||||
1112
lib_jtag_core/src/jtag_core.c
Normal file
1112
lib_jtag_core/src/jtag_core.c
Normal file
File diff suppressed because it is too large
Load Diff
342
lib_jtag_core/src/jtag_core.h
Normal file
342
lib_jtag_core/src/jtag_core.h
Normal file
@@ -0,0 +1,342 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file jtag_core.h
|
||||
* @brief Main jtag core library header
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#ifndef _jtag_core_
|
||||
typedef void jtag_core;
|
||||
#define _jtag_core_
|
||||
#endif
|
||||
|
||||
#ifndef _script_ctx_
|
||||
typedef void script_ctx;
|
||||
#define _script_ctx_
|
||||
#endif
|
||||
|
||||
#ifndef _jtag_emu_
|
||||
typedef void jtag_emu;
|
||||
#define _jtag_emu_
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Functions Error / return codes
|
||||
|
||||
#define JTAG_CORE_NO_ERROR 0
|
||||
#define JTAG_CORE_BAD_PARAMETER -1
|
||||
#define JTAG_CORE_ACCESS_ERROR -2
|
||||
#define JTAG_CORE_IO_ERROR -3
|
||||
#define JTAG_CORE_MEM_ERROR -4
|
||||
#define JTAG_CORE_NO_PROBE -5
|
||||
#define JTAG_CORE_NOT_FOUND -6
|
||||
#define JTAG_CORE_CMD_NOT_FOUND -7
|
||||
#define JTAG_CORE_INTERNAL_ERROR -8
|
||||
#define JTAG_CORE_BAD_CMD -9
|
||||
|
||||
#define JTAG_CORE_I2C_BUS_NOTFREE -10
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Lib init functions
|
||||
|
||||
// jtagcore_init : Library alloc and init
|
||||
jtag_core * jtagcore_init();
|
||||
|
||||
// jtagcore_init : Library dealloc and deinit
|
||||
void jtagcore_deinit(jtag_core * jc);
|
||||
|
||||
#ifndef _JTAGCORE_PRINT_FUNC_
|
||||
typedef void (*JTAGCORE_PRINT_FUNC)(jtag_core * jc, const char * string);
|
||||
#define _JTAGCORE_PRINT_FUNC_
|
||||
#endif
|
||||
|
||||
int jtagcore_set_logs_callback(jtag_core * jc, JTAGCORE_PRINT_FUNC jtag_core_print);
|
||||
int jtagcore_set_logs_level(jtag_core * jc,int level);
|
||||
int jtagcore_get_logs_level(jtag_core * jc);
|
||||
int jtagcore_set_logs_file(jtag_core * jc,char * path);
|
||||
char * jtagcore_get_logs_file(jtag_core * jc);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Probe driver selection/initialisation functions
|
||||
|
||||
// jtagcore_get_number_of_probes_drv : Return the "number of supported probes"
|
||||
|
||||
int jtagcore_get_number_of_probes_drv(jtag_core * jc);
|
||||
int jtagcore_get_number_of_probes(jtag_core * jc, int probe_driver_id);
|
||||
|
||||
#define PROBE_ID(drv_id,probe_index) ( (drv_id<<8) | probe_index )
|
||||
|
||||
// jtagcore_get_probe_name : Return the probe name (probe_id should be between 0 and "number of supported probes" - 1)
|
||||
|
||||
int jtagcore_get_probe_name(jtag_core * jc, int probe_id,char * name);
|
||||
|
||||
// jtagcore_select_and_open_probe : Try to init the probe (probe_id should be between 0 and "number of supported probes" - 1)
|
||||
|
||||
int jtagcore_select_and_open_probe(jtag_core * jc, int probe_id);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// JTAG Chain init functions
|
||||
|
||||
// jtagcore_scan_and_init_chain : Scan and init the chain (devices detection)
|
||||
|
||||
int jtagcore_scan_and_init_chain(jtag_core * jc);
|
||||
|
||||
// jtagcore_get_number_of_devices : return "the number of devices into the chain" found by jtagcore_scan_and_init_chain
|
||||
|
||||
int jtagcore_get_number_of_devices(jtag_core * jc);
|
||||
|
||||
// jtagcore_get_dev_id : Return the device chip ID
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
|
||||
unsigned long jtagcore_get_dev_id(jtag_core * jc, int device);
|
||||
|
||||
// jtagcore_loadbsdlfile : Load/attach a bsdl file to a device into the chain
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
|
||||
int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device);
|
||||
|
||||
// jtagcore_get_dev_name : Get the currently loaded bsdl name & path
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
int jtagcore_get_dev_name(jtag_core * jc, int device, char * devname, char * bsdlpath);
|
||||
|
||||
// jtagcore_get_bsdl_id : Return the chip id present into a bsdl file
|
||||
|
||||
unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path, unsigned long * mask);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Pins/IO access functions
|
||||
|
||||
// jtagcore_get_number_of_pins : Return the number of pins of a device.
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// and a bsdl must be attached to this device
|
||||
|
||||
int jtagcore_get_number_of_pins(jtag_core * jc,int device);
|
||||
|
||||
// jtagcore_get_pin_properties : Return the pin properties
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// and a bsdl must be attached to this device
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
// "type" return is a mask between JTAG_CORE_PIN_IS_INPUT / JTAG_CORE_PIN_IS_OUTPUT / JTAG_CORE_PIN_IS_TRISTATES states
|
||||
|
||||
int jtagcore_get_pin_properties(jtag_core * jc, int device, int pin, char * pinname, int maxsize, int * type);
|
||||
|
||||
#define JTAG_CORE_PIN_IS_INPUT 0x01
|
||||
#define JTAG_CORE_PIN_IS_OUTPUT 0x02
|
||||
#define JTAG_CORE_PIN_IS_TRISTATES 0x04
|
||||
|
||||
// jtagcore_get_pin_id : Find and return a pin id (if exist) from the pin name
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
|
||||
int jtagcore_get_pin_id(jtag_core * jc, int device, char * pinname);
|
||||
|
||||
// jtagcore_get_pin_state : Return the current pin state
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
// "type" should be set to JTAG_CORE_INPUT or JTAG_CORE_OUTPUT or JTAG_CORE_OE
|
||||
|
||||
int jtagcore_get_pin_state(jtag_core * jc, int device, int pin, int type);
|
||||
|
||||
// jtagcore_set_pin_state : Set the pin state
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
// "type" should be set to JTAG_CORE_INPUT or JTAG_CORE_OUTPUT or JTAG_CORE_OE
|
||||
|
||||
int jtagcore_set_pin_state(jtag_core * jc, int device, int pin, int type, int state);
|
||||
|
||||
#define JTAG_CORE_INPUT 0x01
|
||||
#define JTAG_CORE_OUTPUT 0x02
|
||||
#define JTAG_CORE_OE 0x04
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Scan chain functions
|
||||
|
||||
// jtagcore_set_scan_mode : Set the scan mode for a particular device
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "scan_mode" should be set to JTAG_CORE_SAMPLE_SCANMODE (observation only) or JTAG_CORE_EXTEST_SCANMODE (full pin control)
|
||||
int jtagcore_set_scan_mode(jtag_core * jc, int device, int scan_mode);
|
||||
|
||||
// JTAG Scan mode
|
||||
#define JTAG_CORE_SAMPLE_SCANMODE 0x00
|
||||
#define JTAG_CORE_EXTEST_SCANMODE 0x01
|
||||
|
||||
// jtagcore_push_and_pop_chain : Do a JTAG chain transaction.
|
||||
// "mode" should be set to JTAG_CORE_WRITE_READ (Push/write and pop/read the chain) or JTAG_CORE_WRITE_ONLY (only Push/write the chain)
|
||||
int jtagcore_push_and_pop_chain(jtag_core * jc, int mode);
|
||||
|
||||
#define JTAG_CORE_WRITE_READ 0x00
|
||||
#define JTAG_CORE_WRITE_ONLY 0x01
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// I2C over JTAG API functions
|
||||
|
||||
// jtagcore_i2c_set_scl_pin : Select the SCL pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_i2c_set_scl_pin(jtag_core * jc, int device, int pin);
|
||||
|
||||
// jtagcore_i2c_set_sda_pin : Select the SDA pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_i2c_set_sda_pin(jtag_core * jc, int device, int pin);
|
||||
|
||||
// jtagcore_i2c_write_read : Do an I2C transfert
|
||||
// "address" : I2C address (8 bits aligned)
|
||||
// "address10bits" != 0 if this is an 10bits address
|
||||
// "wr_size" write size
|
||||
// "rd_size" read size
|
||||
int jtagcore_i2c_write_read(jtag_core * jc, int address, int address10bits,int wr_size,unsigned char * wr_buffer,int rd_size,unsigned char * rd_buffer);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SPI over JTAG API functions
|
||||
|
||||
// jtagcore_spi_set_cs_pin : Select the CS pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_spi_set_cs_pin(jtag_core * jc, int device, int pin, int polarity);
|
||||
|
||||
// jtagcore_spi_set_clk_pin : Select the CLK pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_spi_set_clk_pin(jtag_core * jc, int device, int pin, int polarity);
|
||||
|
||||
// jtagcore_spi_set_miso_pin : Select the MISO pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_spi_set_miso_pin(jtag_core * jc, int device, int pin, int sample_clk_phase);
|
||||
|
||||
// jtagcore_spi_set_mosi_pin : Select the MOSI pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_spi_set_mosi_pin(jtag_core * jc, int device, int pin, int sample_clk_phase);
|
||||
|
||||
// jtagcore_spi_write_read : Do a SPI transfert
|
||||
// "wr_size" is the transaction size
|
||||
|
||||
int jtagcore_spi_write_read(jtag_core * jc, int wr_size,unsigned char * wr_buffer,unsigned char * rd_buffer, int flags);
|
||||
|
||||
// jtagcore_spi_set_bitorder : Select MSB/LSB first mode
|
||||
|
||||
int jtagcore_spi_set_bitorder(jtag_core * jc, int lsb_first);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MDIO over JTAG API functions
|
||||
|
||||
// jtagcore_mdio_set_mdio_pin : Select the MDIO pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_mdio_set_mdio_pin(jtag_core * jc, int device, int pin);
|
||||
|
||||
// jtagcore_mdio_set_mdc_pin : Select the MDC pin
|
||||
// "device" should be between 0 and "the number of devices into the chain" - 1
|
||||
// "pin" should be between 0 and "number of pins of a device" - 1
|
||||
|
||||
int jtagcore_mdio_set_mdc_pin(jtag_core * jc, int device, int pin);
|
||||
|
||||
// jtagcore_mdio_read : Read to an MDIO register
|
||||
// phy_adr : Phylayer address
|
||||
// reg_adr : Register address
|
||||
|
||||
int jtagcore_mdio_read(jtag_core * jc, int phy_adr, int reg_adr);
|
||||
|
||||
// jtagcore_mdio_write : Write to an MDIO register
|
||||
// phy_adr : Phylayer address
|
||||
// reg_adr : Register address
|
||||
// data : data value to write
|
||||
|
||||
int jtagcore_mdio_write(jtag_core * jc, int phy_adr, int reg_adr, int data);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Parallel Memory over JTAG API functions
|
||||
|
||||
#define JTAG_CORE_RAM_CS_CTRL 0x00
|
||||
#define JTAG_CORE_RAM_WR_CTRL 0x01
|
||||
#define JTAG_CORE_RAM_RD_CTRL 0x02
|
||||
#define JTAG_CORE_RAM_RW_CTRL 0x03
|
||||
|
||||
int jtagcore_memory_clear_pins(jtag_core * jc);
|
||||
int jtagcore_memory_set_address_pin(jtag_core * jc, int address_bit, int device, int pin);
|
||||
int jtagcore_memory_set_data_pin(jtag_core * jc, int data_bit, int device, int pin);
|
||||
int jtagcore_memory_set_ctrl_pin(jtag_core * jc, int ctrl, int polarity, int device, int pin);
|
||||
unsigned long jtagcore_memory_read(jtag_core * jc, int mem_adr);
|
||||
int jtagcore_memory_write(jtag_core * jc, int mem_adr, unsigned long data);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal variables functions
|
||||
|
||||
int jtagcore_setEnvVar( jtag_core * jc, char * varname, char * varvalue );
|
||||
char * jtagcore_getEnvVar( jtag_core * jc, char * varname, char * varvalue);
|
||||
int jtagcore_getEnvVarValue( jtag_core * jc, char * varname);
|
||||
char * jtagcore_getEnvVarIndex( jtag_core * jc, int index, char * varvalue);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Script execution functions
|
||||
|
||||
#define DEFAULT_BUFLEN 1024
|
||||
|
||||
// Output message types/levels
|
||||
enum MSGTYPE
|
||||
{
|
||||
MSG_DEBUG = 0,
|
||||
MSG_INFO_0,
|
||||
MSG_INFO_1,
|
||||
MSG_WARNING,
|
||||
MSG_ERROR,
|
||||
MSG_NONE
|
||||
};
|
||||
|
||||
#ifndef _jtag_script_printf_func_
|
||||
typedef int (* SCRIPT_PRINTF_FUNC)(void * ctx, int MSGTYPE, char * string, ... );
|
||||
#define _jtag_script_printf_func_
|
||||
#endif
|
||||
|
||||
script_ctx * jtagcore_initScript(jtag_core * jc);
|
||||
|
||||
void jtagcore_setScriptOutputFunc( script_ctx * ctx, SCRIPT_PRINTF_FUNC ext_printf );
|
||||
int jtagcore_execScriptLine( script_ctx * ctx, char * line );
|
||||
int jtagcore_execScriptFile( script_ctx * ctx, char * script_path );
|
||||
int jtagcore_execScriptRam( script_ctx * ctx, unsigned char * script_buffer, int buffersize );
|
||||
|
||||
script_ctx * jtagcore_deinitScript( script_ctx * ctx );
|
||||
|
||||
int jtagcore_savePinsStateScript( jtag_core * jc, int device, char * script_path );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// JTAG Emulation layer (WIP)
|
||||
|
||||
jtag_emu * jtagemu_init(jtag_core * jc);
|
||||
|
||||
int jtagemu_reset(jtag_emu * je);
|
||||
|
||||
int jtagemu_tick(jtag_emu * je, unsigned char io_state);
|
||||
|
||||
int jtagemu_get_regbit_state(jtag_emu * je, int regid, int bit);
|
||||
|
||||
int jtagemu_loadbsdlfile(jtag_emu * je, char * path, int device);
|
||||
|
||||
void jtagemu_deinit(jtag_emu * je);
|
||||
155
lib_jtag_core/src/jtag_core_internal.h
Normal file
155
lib_jtag_core/src/jtag_core_internal.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file jtag_core_internal.h
|
||||
* @brief jtag core library internal structures and defines types
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#define _jtag_core_
|
||||
|
||||
#define MAX_NB_JTAG_DEVICE 64
|
||||
#define MAX_NUMBER_BITS_IN_CHAIN ( 256 * 1024 )
|
||||
#define MAX_NUMBER_PINS_PER_DEV ( 64 * 1024 )
|
||||
#define MAX_BSDL_FILE_SIZE ( 1024 * 1024 )
|
||||
#define MAX_NUMBER_OF_BSDL_LINES ( 64 * 1024 )
|
||||
|
||||
#define MAX_PATH_LEN 4096
|
||||
|
||||
typedef struct _jtag_device
|
||||
{
|
||||
void * bsdl;
|
||||
unsigned long devices_id;
|
||||
unsigned char * out_boundary_scan;
|
||||
unsigned char * in_boundary_scan;
|
||||
int boundary_scan_size;
|
||||
int scan_mode;
|
||||
}jtag_device;
|
||||
|
||||
#define MAX_BUS_WIDTH 32
|
||||
|
||||
typedef struct _jtag_core
|
||||
{
|
||||
drv_ptr io_functions;
|
||||
|
||||
void * jtagcore_print_callback;
|
||||
int logs_level;
|
||||
|
||||
void * envvar;
|
||||
|
||||
int t;
|
||||
|
||||
int nb_of_devices_in_chain;
|
||||
|
||||
int total_IR_lenght;
|
||||
jtag_device devices_list[MAX_NB_JTAG_DEVICE];
|
||||
int IR_filled;
|
||||
|
||||
// I2C over JTAG
|
||||
int i2c_sda_device;
|
||||
int i2c_scl_device;
|
||||
|
||||
int i2c_sda_pin;
|
||||
int i2c_scl_pin;
|
||||
|
||||
// SPI over JTAG
|
||||
int spi_mosi_device;
|
||||
int spi_miso_device;
|
||||
int spi_cs_device;
|
||||
int spi_clk_device;
|
||||
|
||||
int spi_mosi_pin;
|
||||
int spi_miso_pin;
|
||||
int spi_cs_pin;
|
||||
int spi_clk_pin;
|
||||
|
||||
int spi_cs_pol;
|
||||
int spi_clk_pol;
|
||||
int spi_mosi_pol;
|
||||
int spi_miso_pol;
|
||||
|
||||
int spi_lsb_first;
|
||||
|
||||
// MDIO over JTAG
|
||||
int mdio_mdc_pin;
|
||||
int mdio_mdc_device;
|
||||
int mdio_mdio_pin;
|
||||
int mdio_mdio_device;
|
||||
|
||||
// Memory over JTAG
|
||||
int ram_address_pin[MAX_BUS_WIDTH];
|
||||
int ram_address_device[MAX_BUS_WIDTH];
|
||||
int ram_data_pin[MAX_BUS_WIDTH];
|
||||
int ram_data_device[MAX_BUS_WIDTH];
|
||||
int ram_ctrl_pin[16];
|
||||
int ram_ctrl_pin_pol[16];
|
||||
int ram_ctrl_device[16];
|
||||
|
||||
char log_file_path[MAX_PATH_LEN];
|
||||
}jtag_core;
|
||||
|
||||
#define JTAG_STR_DOUT 0x01
|
||||
#define JTAG_STR_TMS 0x02
|
||||
#define JTAG_STR_CLKDIS 0x04
|
||||
#define JTAG_STR_JTAGRST 0x08
|
||||
#define JTAG_STR_DIN 0x10
|
||||
#define JTAG_STR_DINREQ 0x20
|
||||
|
||||
int jtagcore_loaddriver(jtag_core * jc,int id, char * parameters);
|
||||
|
||||
// jtag device emulator
|
||||
|
||||
#define _jtag_emu_
|
||||
|
||||
typedef struct _jtag_emu
|
||||
{
|
||||
jtag_core * jc;
|
||||
|
||||
void * bsdl_file;
|
||||
|
||||
unsigned char * out_boundary_scan;
|
||||
unsigned char * in_boundary_scan;
|
||||
unsigned char * data_register;
|
||||
unsigned char * inst_register;
|
||||
|
||||
int jtag_state_machine;
|
||||
}jtag_emu;
|
||||
|
||||
enum
|
||||
{
|
||||
JTAG_EMU_STATE_RESET = 0,
|
||||
JTAG_EMU_STATE_IDLE,
|
||||
|
||||
JTAG_EMU_STATE_SEL_DR_SCAN,
|
||||
JTAG_EMU_STATE_CAPTURE_DR,
|
||||
JTAG_EMU_STATE_SHIFT_DR,
|
||||
JTAG_EMU_STATE_EXIT1_DR,
|
||||
JTAG_EMU_STATE_PAUSE_DR,
|
||||
JTAG_EMU_STATE_EXIT2_DR,
|
||||
JTAG_EMU_STATE_UPDATE_DR,
|
||||
|
||||
JTAG_EMU_STATE_SEL_IR_SCAN,
|
||||
JTAG_EMU_STATE_CAPTURE_IR,
|
||||
JTAG_EMU_STATE_SHIFT_IR,
|
||||
JTAG_EMU_STATE_EXIT1_IR,
|
||||
JTAG_EMU_STATE_PAUSE_IR,
|
||||
JTAG_EMU_STATE_EXIT2_IR,
|
||||
JTAG_EMU_STATE_UPDATE_IR
|
||||
};
|
||||
178
lib_jtag_core/src/natsort/strnatcmp.c
Normal file
178
lib_jtag_core/src/natsort/strnatcmp.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* -*- mode: c; c-file-style: "k&r" -*-
|
||||
|
||||
strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
|
||||
Copyright (C) 2000, 2004 by Martin Pool <mbp sourcefrog net>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
/* partial change history:
|
||||
*
|
||||
* 2004-10-10 mbp: Lift out character type dependencies into macros.
|
||||
*
|
||||
* Eric Sosman pointed out that ctype functions take a parameter whose
|
||||
* value must be that of an unsigned int, even on platforms that have
|
||||
* negative chars in their default char type.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "strnatcmp.h"
|
||||
|
||||
|
||||
/* These are defined as macros to make it easier to adapt this code to
|
||||
* different characters types or comparison functions. */
|
||||
static /*inline*/ int
|
||||
nat_isdigit(nat_char a)
|
||||
{
|
||||
return isdigit((unsigned char) a);
|
||||
}
|
||||
|
||||
|
||||
static /*inline*/ int
|
||||
nat_isspace(nat_char a)
|
||||
{
|
||||
return isspace((unsigned char) a);
|
||||
}
|
||||
|
||||
|
||||
static /*inline*/ nat_char
|
||||
nat_toupper(nat_char a)
|
||||
{
|
||||
return toupper((unsigned char) a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
compare_right(nat_char const *a, nat_char const *b)
|
||||
{
|
||||
int bias = 0;
|
||||
|
||||
/* The longest run of digits wins. That aside, the greatest
|
||||
value wins, but we can't know that it will until we've scanned
|
||||
both numbers to know that they have the same magnitude, so we
|
||||
remember it in BIAS. */
|
||||
for (;; a++, b++) {
|
||||
if (!nat_isdigit(*a) && !nat_isdigit(*b))
|
||||
return bias;
|
||||
else if (!nat_isdigit(*a))
|
||||
return -1;
|
||||
else if (!nat_isdigit(*b))
|
||||
return +1;
|
||||
else if (*a < *b) {
|
||||
if (!bias)
|
||||
bias = -1;
|
||||
} else if (*a > *b) {
|
||||
if (!bias)
|
||||
bias = +1;
|
||||
} else if (!*a && !*b)
|
||||
return bias;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
compare_left(nat_char const *a, nat_char const *b)
|
||||
{
|
||||
/* Compare two left-aligned numbers: the first to have a
|
||||
different value wins. */
|
||||
for (;; a++, b++) {
|
||||
if (!nat_isdigit(*a) && !nat_isdigit(*b))
|
||||
return 0;
|
||||
else if (!nat_isdigit(*a))
|
||||
return -1;
|
||||
else if (!nat_isdigit(*b))
|
||||
return +1;
|
||||
else if (*a < *b)
|
||||
return -1;
|
||||
else if (*a > *b)
|
||||
return +1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int strnatcmp0(nat_char const *a, nat_char const *b, int fold_case)
|
||||
{
|
||||
int ai, bi;
|
||||
nat_char ca, cb;
|
||||
int fractional, result;
|
||||
|
||||
assert(a && b);
|
||||
ai = bi = 0;
|
||||
while (1) {
|
||||
ca = a[ai]; cb = b[bi];
|
||||
|
||||
/* skip over leading spaces or zeros */
|
||||
while (nat_isspace(ca))
|
||||
ca = a[++ai];
|
||||
|
||||
while (nat_isspace(cb))
|
||||
cb = b[++bi];
|
||||
|
||||
/* process run of digits */
|
||||
if (nat_isdigit(ca) && nat_isdigit(cb)) {
|
||||
fractional = (ca == '0' || cb == '0');
|
||||
|
||||
if (fractional) {
|
||||
if ((result = compare_left(a+ai, b+bi)) != 0)
|
||||
return result;
|
||||
} else {
|
||||
if ((result = compare_right(a+ai, b+bi)) != 0)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ca && !cb) {
|
||||
/* The strings compare the same. Perhaps the caller
|
||||
will want to call strcmp to break the tie. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fold_case) {
|
||||
ca = nat_toupper(ca);
|
||||
cb = nat_toupper(cb);
|
||||
}
|
||||
|
||||
if (ca < cb)
|
||||
return -1;
|
||||
else if (ca > cb)
|
||||
return +1;
|
||||
|
||||
++ai; ++bi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int strnatcmp(nat_char const *a, nat_char const *b) {
|
||||
return strnatcmp0(a, b, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Compare, recognizing numeric string and ignoring case. */
|
||||
int strnatcasecmp(nat_char const *a, nat_char const *b) {
|
||||
return strnatcmp0(a, b, 1);
|
||||
}
|
||||
31
lib_jtag_core/src/natsort/strnatcmp.h
Normal file
31
lib_jtag_core/src/natsort/strnatcmp.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* -*- mode: c; c-file-style: "k&r" -*-
|
||||
|
||||
strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
|
||||
Copyright (C) 2000, 2004 by Martin Pool <mbp sourcefrog net>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
/* CUSTOMIZATION SECTION
|
||||
*
|
||||
* You can change this typedef, but must then also change the inline
|
||||
* functions in strnatcmp.c */
|
||||
typedef char nat_char;
|
||||
|
||||
int strnatcmp(nat_char const *a, nat_char const *b);
|
||||
int strnatcasecmp(nat_char const *a, nat_char const *b);
|
||||
597
lib_jtag_core/src/os_interface/fs.c
Normal file
597
lib_jtag_core/src/os_interface/fs.c
Normal file
@@ -0,0 +1,597 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file fs.c
|
||||
* @brief Basic/generic OS file system functions wrapper.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
# include <direct.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <dirent.h>
|
||||
|
||||
#ifdef OSX
|
||||
# include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "os_interface.h"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
||||
int convertpath (const char * path, wchar_t * wpath)
|
||||
{
|
||||
if (!MultiByteToWideChar (CP_UTF8, 0, path, -1, wpath, MAX_PATH))
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
wpath[MAX_PATH] = L'\0';
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int genos_open (const char *filename, int flags, ...)
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
wchar_t wpath[MAX_PATH+1];
|
||||
#else
|
||||
const char *local_name;
|
||||
#endif
|
||||
|
||||
unsigned int mode = 0;
|
||||
va_list ap;
|
||||
|
||||
#if defined (DEBUG)
|
||||
printf("genos_open : filename=%s flags=%x\n",filename,flags);
|
||||
#endif
|
||||
|
||||
va_start (ap, flags);
|
||||
if (flags & O_CREAT)
|
||||
mode = va_arg (ap, unsigned int);
|
||||
va_end (ap);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
memset(wpath,0,(MAX_PATH+1)*sizeof(wchar_t));
|
||||
if(convertpath(filename, wpath)<0)
|
||||
return -1;
|
||||
|
||||
return _wopen (wpath, flags, mode);
|
||||
|
||||
#else
|
||||
|
||||
local_name = filename;
|
||||
//local_name = (const char *)ToLocale (filename);
|
||||
|
||||
if (local_name == NULL)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd = open (local_name, flags, mode);
|
||||
|
||||
//LocaleFree (local_name);
|
||||
return fd;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
FILE *genos_fopen (const char *filename, const char *mode)
|
||||
{
|
||||
int rwflags, oflags;
|
||||
int append;
|
||||
int fd;
|
||||
const char *ptr;
|
||||
FILE *stream;
|
||||
|
||||
#if defined (DEBUG)
|
||||
printf("genos_fopen : filename=%s mode=%s\n",filename,mode);
|
||||
#endif
|
||||
|
||||
// Try the classic way (ascii path)
|
||||
stream = fopen(filename,mode);
|
||||
|
||||
if( ( stream == NULL ) && (errno == ENOENT) )
|
||||
{
|
||||
// Try the utf8 way
|
||||
rwflags = 0;
|
||||
oflags = 0;
|
||||
append = 0;
|
||||
|
||||
for(ptr = mode;*ptr;ptr++)
|
||||
{
|
||||
switch (*ptr)
|
||||
{
|
||||
case 'r':
|
||||
rwflags = O_RDONLY;
|
||||
break;
|
||||
#ifdef O_BINARY
|
||||
case 'b':
|
||||
oflags |= O_BINARY;
|
||||
break;
|
||||
#endif
|
||||
case 'a':
|
||||
rwflags = O_WRONLY;
|
||||
oflags |= O_CREAT;
|
||||
append = 1;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
rwflags = O_WRONLY;
|
||||
oflags |= O_CREAT | O_TRUNC;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
rwflags = O_RDWR;
|
||||
break;
|
||||
|
||||
#ifdef O_TEXT
|
||||
case 't':
|
||||
oflags |= O_TEXT;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
fd = genos_open (filename, rwflags|oflags, (unsigned int)(0666));
|
||||
if(fd==-1)
|
||||
return NULL;
|
||||
|
||||
if(append)
|
||||
{
|
||||
#if defined (WIN32)
|
||||
if(_lseek(fd,0,SEEK_END) == -1)
|
||||
{
|
||||
_close (fd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if(lseek(fd,0,SEEK_END) == -1)
|
||||
{
|
||||
close (fd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (WIN32)
|
||||
_lseek(fd,0,SEEK_SET);
|
||||
#else
|
||||
lseek(fd,0,SEEK_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (WIN32)
|
||||
stream = _fdopen(fd,mode);
|
||||
if(stream == NULL)
|
||||
{
|
||||
_close (fd);
|
||||
}
|
||||
#else
|
||||
stream = fdopen(fd,mode);
|
||||
if(stream == NULL)
|
||||
{
|
||||
close (fd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
int genos_fread(void * ptr, size_t size, FILE *f)
|
||||
{
|
||||
|
||||
#if defined (DEBUG)
|
||||
printf("genos_fread : ptr=%p size=%zu file:%p\n",ptr,size,f);
|
||||
#endif
|
||||
|
||||
if( fread(ptr,size,1,f) != 1 )
|
||||
{
|
||||
return 1; // Error
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0; // No Error
|
||||
}
|
||||
}
|
||||
|
||||
char * genos_fgets(char * str, int num, FILE *f)
|
||||
{
|
||||
return fgets( str, num, f );
|
||||
}
|
||||
|
||||
int genos_fclose(FILE * f)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
printf("genos_fclose : file:%p\n",f);
|
||||
#endif
|
||||
|
||||
return fclose(f);
|
||||
}
|
||||
|
||||
int genos_statex( const char *filename, struct stat *buf)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
printf("genos_statex : filename=%s\n",filename);
|
||||
#endif
|
||||
#if defined (WIN32)
|
||||
wchar_t wpath[MAX_PATH+1];
|
||||
|
||||
if( convertpath(filename, wpath) < 0 )
|
||||
return -1;
|
||||
|
||||
return _wstat (wpath,(struct _stat *)buf);
|
||||
#else
|
||||
int res;
|
||||
const char *local_name;
|
||||
|
||||
local_name = filename;//ToLocale( filename );
|
||||
|
||||
if( local_name != NULL )
|
||||
{
|
||||
res = lstat( local_name, buf );
|
||||
// LocaleFree( local_name );
|
||||
return res;
|
||||
}
|
||||
|
||||
errno = ENOENT;
|
||||
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
int genos_stat( const char *filename, struct stat *buf)
|
||||
{
|
||||
return genos_statex(filename,buf);
|
||||
}
|
||||
|
||||
void * genos_find_first_file(char *folder, char *file, filefoundinfo* fileinfo)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
printf("genos_find_first_file : folder=%s file=%s\n",folder,file);
|
||||
#endif
|
||||
|
||||
#if defined (WIN32)
|
||||
|
||||
HANDLE hfindfile;
|
||||
char *folderstr;
|
||||
WIN32_FIND_DATAW FindFileData;
|
||||
wchar_t wpath[MAX_PATH+1];
|
||||
|
||||
if(file)
|
||||
{
|
||||
folderstr=(char *) malloc(strlen(folder)+strlen(file)+2);
|
||||
sprintf((char *)folderstr,"%s\\%s",folder,file);
|
||||
}
|
||||
else
|
||||
{
|
||||
folderstr = (char *) malloc(strlen(folder)+1);
|
||||
sprintf((char *)folderstr,"%s",folder);
|
||||
}
|
||||
|
||||
convertpath (folderstr, wpath);
|
||||
hfindfile = FindFirstFileW(wpath, &FindFileData);
|
||||
if(hfindfile!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
WideCharToMultiByte(CP_UTF8,0,FindFileData.cFileName,-1,fileinfo->filename,sizeof(fileinfo->filename),NULL,NULL);
|
||||
//sprintf(fileinfo->filename,"%s",FindFileData.cFileName);
|
||||
|
||||
fileinfo->isdirectory = 0;
|
||||
|
||||
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
fileinfo->isdirectory = 1;
|
||||
}
|
||||
|
||||
fileinfo->size = FindFileData.nFileSizeLow;
|
||||
free(folderstr);
|
||||
return (void*)hfindfile;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(folderstr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
struct dirent *d;
|
||||
DIR * dir;
|
||||
struct stat fileStat;
|
||||
char * tmpstr;
|
||||
|
||||
if(!file)
|
||||
{
|
||||
// File mode
|
||||
memset(&fileStat,0,sizeof(struct stat));
|
||||
if(!lstat (folder, &fileStat))
|
||||
{
|
||||
if ( !S_ISDIR ( fileStat.st_mode ) )
|
||||
{
|
||||
fileinfo->isdirectory = 0;
|
||||
fileinfo->size = fileStat.st_size;
|
||||
strncpy(fileinfo->filename,genos_getfilenamebase(folder,NULL,SYS_PATH_TYPE),FILEFOUND_NAMESIZE - 1);
|
||||
fileinfo->filename[FILEFOUND_NAMESIZE - 1] = 0;
|
||||
|
||||
return (void*)-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dir = opendir (folder);
|
||||
if(dir)
|
||||
{
|
||||
d = readdir (dir);
|
||||
if(d)
|
||||
{
|
||||
tmpstr = malloc (strlen(folder) + strlen(d->d_name) + 4 );
|
||||
if(tmpstr)
|
||||
{
|
||||
strcpy(tmpstr,folder);
|
||||
strcat(tmpstr,"/");
|
||||
strcat(tmpstr,d->d_name);
|
||||
|
||||
memset(&fileStat,0,sizeof(struct stat));
|
||||
if(!lstat (tmpstr, &fileStat))
|
||||
{
|
||||
|
||||
if ( S_ISDIR ( fileStat.st_mode ) )
|
||||
fileinfo->isdirectory=1;
|
||||
else
|
||||
fileinfo->isdirectory=0;
|
||||
|
||||
fileinfo->size=fileStat.st_size;
|
||||
|
||||
strncpy(fileinfo->filename,d->d_name,FILEFOUND_NAMESIZE - 1);
|
||||
fileinfo->filename[FILEFOUND_NAMESIZE - 1] = '\0';
|
||||
|
||||
free(tmpstr);
|
||||
return (void*)dir;
|
||||
}
|
||||
|
||||
free(tmpstr);
|
||||
}
|
||||
|
||||
closedir (dir);
|
||||
dir=0;
|
||||
|
||||
return (void*)dir;
|
||||
}
|
||||
|
||||
closedir (dir);
|
||||
dir=0;
|
||||
}
|
||||
|
||||
return (void*)dir;
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int genos_find_next_file(void* handleff, char *folder, char *file, filefoundinfo* fileinfo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#if defined (DEBUG)
|
||||
printf("genos_find_next_file : handleff:%p folder=%s file=%s\n",handleff,folder,file);
|
||||
#endif
|
||||
|
||||
#if defined (WIN32)
|
||||
WIN32_FIND_DATAW FindFileData;
|
||||
|
||||
|
||||
ret=FindNextFileW((HANDLE)handleff,&FindFileData);
|
||||
if(ret)
|
||||
{
|
||||
WideCharToMultiByte(CP_UTF8,0,FindFileData.cFileName,-1,fileinfo->filename,sizeof(fileinfo->filename),NULL,NULL);
|
||||
//sprintf(fileinfo->filename,"%s",FindFileData.cFileName);
|
||||
|
||||
fileinfo->isdirectory=0;
|
||||
|
||||
if( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
|
||||
{
|
||||
fileinfo->isdirectory = 1;
|
||||
}
|
||||
|
||||
fileinfo->size = FindFileData.nFileSizeLow;
|
||||
}
|
||||
#else
|
||||
struct dirent *d;
|
||||
DIR * dir;
|
||||
struct stat fileStat;
|
||||
char * tmpstr;
|
||||
|
||||
if((long)(handleff) == -1) // File mode
|
||||
return 0;
|
||||
|
||||
dir = (DIR*) handleff;
|
||||
d = readdir (dir);
|
||||
|
||||
ret = 0;
|
||||
if(d)
|
||||
{
|
||||
tmpstr = malloc (strlen(folder) + strlen(d->d_name) + 4 );
|
||||
if(tmpstr)
|
||||
{
|
||||
strcpy(tmpstr,folder);
|
||||
strcat(tmpstr,"/");
|
||||
strcat(tmpstr,d->d_name);
|
||||
|
||||
if(!lstat (tmpstr, &fileStat))
|
||||
{
|
||||
if ( S_ISDIR ( fileStat.st_mode ) )
|
||||
fileinfo->isdirectory=1;
|
||||
else
|
||||
fileinfo->isdirectory=0;
|
||||
|
||||
fileinfo->size=fileStat.st_size;
|
||||
strncpy(fileinfo->filename,d->d_name,FILEFOUND_NAMESIZE - 1);
|
||||
fileinfo->filename[FILEFOUND_NAMESIZE - 1] = '\0';
|
||||
|
||||
ret = 1;
|
||||
free(tmpstr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
free(tmpstr);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int genos_find_close(void* handle)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
printf("genos_find_close : handle:%p\n",handle);
|
||||
#endif
|
||||
|
||||
#if defined (WIN32)
|
||||
if(handle)
|
||||
FindClose((void*)handle);
|
||||
#else
|
||||
if((long)(handle) == -1) // File mode
|
||||
return 0;
|
||||
|
||||
if(handle)
|
||||
closedir((DIR*) handle);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * genos_getcurrentdirectory(char *currentdirectory,int buffersize)
|
||||
{
|
||||
memset(currentdirectory,0,buffersize);
|
||||
#if defined (WIN32)
|
||||
if(GetModuleFileName(GetModuleHandle(NULL),currentdirectory,buffersize))
|
||||
{
|
||||
if(strrchr(currentdirectory,'\\'))
|
||||
{
|
||||
*((char*)strrchr(currentdirectory,'\\')) = 0;
|
||||
return currentdirectory;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#if defined (OSX)
|
||||
|
||||
if (_NSGetExecutablePath(currentdirectory, &buffersize) == 0)
|
||||
{
|
||||
if(strrchr(currentdirectory,'/'))
|
||||
{
|
||||
*((char*)strrchr(currentdirectory,'/')) = 0;
|
||||
return currentdirectory;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
strncpy(currentdirectory,"./",buffersize - 1);
|
||||
currentdirectory[buffersize-1] = '\0';
|
||||
|
||||
return currentdirectory;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int genos_mkdir(char * folder)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
printf("genos_mkdir : folder:%s\n",folder);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
_mkdir(folder);
|
||||
#else
|
||||
mkdir(folder,0777);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int genos_fgetsize( FILE * f )
|
||||
{
|
||||
int cur_pos,filesize;
|
||||
|
||||
filesize = 0;
|
||||
|
||||
if( f )
|
||||
{
|
||||
cur_pos = ftell(f);
|
||||
if( cur_pos >= 0 )
|
||||
{
|
||||
if(fseek (f , 0 , SEEK_END))
|
||||
return 0;
|
||||
|
||||
filesize = ftell(f);
|
||||
|
||||
if( filesize < 0 )
|
||||
filesize = 0;
|
||||
|
||||
fseek (f , cur_pos , SEEK_SET);
|
||||
}
|
||||
|
||||
return filesize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
203
lib_jtag_core/src/os_interface/network.c
Normal file
203
lib_jtag_core/src/os_interface/network.c
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file network.c
|
||||
* @brief Basic/generic network functions wrapper.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
#define closesocket(s) close (s)
|
||||
typedef int SOCKET;
|
||||
typedef struct sockaddr_in SOCKADDR_IN;
|
||||
typedef struct sockaddr SOCKADDR;
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#ifdef OSX
|
||||
# include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "../jtag_core.h"
|
||||
#include "network.h"
|
||||
#include "os_interface.h"
|
||||
|
||||
void * network_connect(char * address,unsigned short port)
|
||||
{
|
||||
genos_tcp_stat * tcp_stat;
|
||||
#ifdef WIN32
|
||||
int iResult;
|
||||
#endif
|
||||
|
||||
tcp_stat = malloc(sizeof(genos_tcp_stat));
|
||||
if(tcp_stat)
|
||||
{
|
||||
memset(tcp_stat,0,sizeof(genos_tcp_stat));
|
||||
|
||||
#ifdef WIN32
|
||||
iResult = WSAStartup(MAKEWORD(2,2), &tcp_stat->wsaData);
|
||||
if (iResult != NO_ERROR)
|
||||
{
|
||||
free(tcp_stat);
|
||||
return (void*)NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
tcp_stat->m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (tcp_stat->m_socket == INVALID_SOCKET)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
free(tcp_stat);
|
||||
return (void*)NULL;
|
||||
}
|
||||
|
||||
tcp_stat->clientService.sin_family = AF_INET;
|
||||
tcp_stat->clientService.sin_addr.s_addr = inet_addr(address);
|
||||
tcp_stat->clientService.sin_port = htons(port);
|
||||
|
||||
if (connect(tcp_stat->m_socket, (SOCKADDR*)&tcp_stat->clientService, sizeof(tcp_stat->clientService)) == SOCKET_ERROR)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#else
|
||||
close(tcp_stat->m_socket);
|
||||
#endif
|
||||
|
||||
free(tcp_stat);
|
||||
return (void*)NULL;
|
||||
}
|
||||
|
||||
return (void*)tcp_stat;
|
||||
}
|
||||
|
||||
return (void*)NULL;
|
||||
}
|
||||
|
||||
int network_read(void * network_connection, unsigned char * buffer, int size,int timeout)
|
||||
{
|
||||
int bytesRecv;
|
||||
int offset;
|
||||
genos_tcp_stat * tcp_stat;
|
||||
|
||||
tcp_stat = (genos_tcp_stat *)network_connection;
|
||||
|
||||
offset=0;
|
||||
|
||||
while(offset < size)
|
||||
{
|
||||
bytesRecv = recv(tcp_stat->m_socket, (char*)&buffer[offset], size - offset, 0);
|
||||
if(bytesRecv == SOCKET_ERROR)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset += bytesRecv;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int network_read2(void * network_connection, unsigned char * buffer, int size,int timeout)
|
||||
{
|
||||
int bytesRecv;
|
||||
int offset;
|
||||
genos_tcp_stat * tcp_stat;
|
||||
|
||||
tcp_stat = (genos_tcp_stat *)network_connection;
|
||||
|
||||
offset=0;
|
||||
|
||||
bytesRecv = recv(tcp_stat->m_socket, (char*)&buffer[offset], size - offset, 0);
|
||||
|
||||
return bytesRecv;
|
||||
}
|
||||
|
||||
int network_write(void * network_connection, unsigned char * buffer, int size,int timeout)
|
||||
{
|
||||
int bytesSent;
|
||||
int offset;
|
||||
genos_tcp_stat * tcp_stat;
|
||||
|
||||
tcp_stat = (genos_tcp_stat *)network_connection;
|
||||
|
||||
offset = 0;
|
||||
while(offset < size)
|
||||
{
|
||||
bytesSent = send(tcp_stat->m_socket, (char*)&buffer[offset], size - offset, 0);
|
||||
if(bytesSent == SOCKET_ERROR)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset += bytesSent;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int network_close(void * network_connection)
|
||||
{
|
||||
genos_tcp_stat * tcp_stat;
|
||||
|
||||
tcp_stat = (genos_tcp_stat *)network_connection;
|
||||
|
||||
closesocket (tcp_stat->m_socket);
|
||||
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
free(tcp_stat);
|
||||
|
||||
return 0;
|
||||
}
|
||||
33
lib_jtag_core/src/os_interface/network.h
Normal file
33
lib_jtag_core/src/os_interface/network.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* JTAG Boundary Scanner
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Boundary Scanner 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 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Boundary Scanner 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 version 3 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JTAG Boundary Scanners; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file network.h
|
||||
* @brief Basic/generic network functions wrapper header.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
typedef struct genos_tcp_stat_
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSADATA wsaData;
|
||||
#endif
|
||||
struct sockaddr_in clientService;
|
||||
SOCKET m_socket;
|
||||
}genos_tcp_stat;
|
||||
672
lib_jtag_core/src/os_interface/os_interface.c
Normal file
672
lib_jtag_core/src/os_interface/os_interface.c
Normal file
@@ -0,0 +1,672 @@
|
||||
/*
|
||||
* JTAG Core library
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Core 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.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Core 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 JTAG Core library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file os_interface.c
|
||||
* @brief Basic/generic OS functions wrapper.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../drivers/drv_loader.h"
|
||||
#include "../jtag_core_internal.h"
|
||||
#include "../script/script.h"
|
||||
#include "../jtag_core.h"
|
||||
|
||||
#include "os_interface.h"
|
||||
|
||||
#ifdef WIN32
|
||||
HANDLE eventtab[256];
|
||||
CRITICAL_SECTION criticalsectiontab[256];
|
||||
#else
|
||||
typedef struct _EVENT_HANDLE{
|
||||
pthread_cond_t eCondVar;
|
||||
pthread_mutex_t eMutex;
|
||||
int iVar;
|
||||
} EVENT_HANDLE;
|
||||
|
||||
EVENT_HANDLE * eventtab[256];
|
||||
|
||||
pthread_mutex_t criticalsectiontab[256];
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
DWORD WINAPI ThreadProc( LPVOID lpParameter)
|
||||
{
|
||||
threadinit *threadinitptr;
|
||||
THREADFUNCTION thread;
|
||||
jtag_core* jtag_ctx;
|
||||
void * hw_context;
|
||||
|
||||
if( lpParameter )
|
||||
{
|
||||
//SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
||||
|
||||
threadinitptr=(threadinit*)lpParameter;
|
||||
thread=threadinitptr->thread;
|
||||
jtag_ctx = threadinitptr->jtag_ctx;
|
||||
hw_context=threadinitptr->hwcontext;
|
||||
thread(jtag_ctx,hw_context);
|
||||
|
||||
free(threadinitptr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
void * ThreadProc( void *lpParameter)
|
||||
{
|
||||
threadinit *threadinitptr;
|
||||
THREADFUNCTION thread;
|
||||
jtag_core* jtag_ctx;
|
||||
void * hw_context;
|
||||
|
||||
threadinitptr=(threadinit*)lpParameter;
|
||||
if( threadinitptr )
|
||||
{
|
||||
|
||||
thread=threadinitptr->thread;
|
||||
jtag_ctx = threadinitptr->jtag_ctx;
|
||||
hw_context=threadinitptr->hwcontext;
|
||||
thread(jtag_ctx,hw_context);
|
||||
|
||||
free(threadinitptr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int genos_setevent(jtag_core* jtag_ctx,unsigned char id)
|
||||
{
|
||||
#ifdef WIN32
|
||||
SetEvent(eventtab[id]);
|
||||
#else
|
||||
pthread_mutex_lock(&eventtab[id]->eMutex);
|
||||
pthread_cond_signal(&eventtab[id]->eCondVar);
|
||||
pthread_mutex_unlock(&eventtab[id]->eMutex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
uintptr_t genos_createevent(jtag_core* jtag_ctx,unsigned char id)
|
||||
{
|
||||
#ifdef WIN32
|
||||
|
||||
eventtab[id] = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
return (uintptr_t)eventtab[id];
|
||||
|
||||
#else
|
||||
|
||||
eventtab[id]=(EVENT_HANDLE*)malloc(sizeof(EVENT_HANDLE));
|
||||
pthread_mutex_init(&eventtab[id]->eMutex, NULL);
|
||||
pthread_cond_init(&eventtab[id]->eCondVar, NULL);
|
||||
return (uintptr_t)eventtab[id];
|
||||
#endif
|
||||
}
|
||||
|
||||
int genos_waitevent(jtag_core* jtag_ctx,int id,int timeout)
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
int ret;
|
||||
|
||||
if(timeout==0) timeout=INFINITE;
|
||||
ret=WaitForSingleObject(eventtab[id],timeout);
|
||||
|
||||
if(ret==0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
struct timeval now;
|
||||
struct timespec timeoutstr;
|
||||
int retcode;
|
||||
|
||||
pthread_mutex_lock(&eventtab[id]->eMutex);
|
||||
gettimeofday(&now,0);
|
||||
timeoutstr.tv_sec = now.tv_sec + (timeout/1000);
|
||||
timeoutstr.tv_nsec = (now.tv_usec * 1000) ;//+(timeout*1000000);
|
||||
retcode = 0;
|
||||
|
||||
retcode = pthread_cond_timedwait(&eventtab[id]->eCondVar, &eventtab[id]->eMutex, &timeoutstr);
|
||||
if (retcode == ETIMEDOUT)
|
||||
{
|
||||
pthread_mutex_unlock(&eventtab[id]->eMutex);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_mutex_unlock(&eventtab[id]->eMutex);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uintptr_t genos_createcriticalsection(jtag_core* jtag_ctx,unsigned char id)
|
||||
{
|
||||
#ifdef WIN32
|
||||
|
||||
InitializeCriticalSection(&criticalsectiontab[id]);
|
||||
return (uintptr_t)&criticalsectiontab[id];
|
||||
|
||||
#else
|
||||
//create mutex attribute variable
|
||||
pthread_mutexattr_t mAttr;
|
||||
|
||||
pthread_mutexattr_init(&mAttr);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// setup recursive mutex for mutex attribute
|
||||
pthread_mutexattr_settype(&mAttr, PTHREAD_MUTEX_RECURSIVE);
|
||||
#else
|
||||
pthread_mutexattr_settype(&mAttr, PTHREAD_MUTEX_RECURSIVE_NP);
|
||||
#endif
|
||||
// Use the mutex attribute to create the mutex
|
||||
pthread_mutex_init(&criticalsectiontab[id], &mAttr);
|
||||
|
||||
// Mutex attribute can be destroy after initializing the mutex variable
|
||||
pthread_mutexattr_destroy(&mAttr);
|
||||
|
||||
return (uintptr_t)&criticalsectiontab[id];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void genos_entercriticalsection(jtag_core* jtag_ctx,unsigned char id)
|
||||
{
|
||||
#ifdef WIN32
|
||||
EnterCriticalSection( &criticalsectiontab[id] );
|
||||
#else
|
||||
pthread_mutex_lock( &criticalsectiontab[id] );
|
||||
#endif
|
||||
}
|
||||
|
||||
void genos_leavecriticalsection(jtag_core* jtag_ctx,unsigned char id)
|
||||
{
|
||||
#ifdef WIN32
|
||||
LeaveCriticalSection( &criticalsectiontab[id] );
|
||||
#else
|
||||
pthread_mutex_unlock( &criticalsectiontab[id] );
|
||||
#endif
|
||||
}
|
||||
|
||||
void genos_destroycriticalsection(jtag_core* jtag_ctx,unsigned char id)
|
||||
{
|
||||
#ifdef WIN32
|
||||
DeleteCriticalSection(&criticalsectiontab[id]);
|
||||
#else
|
||||
pthread_mutex_destroy (&criticalsectiontab[id]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
void genos_msleep (unsigned int ms) {
|
||||
int microsecs;
|
||||
struct timeval tv;
|
||||
microsecs = ms * 1000;
|
||||
tv.tv_sec = microsecs / 1000000;
|
||||
tv.tv_usec = microsecs % 1000000;
|
||||
select (0, NULL, NULL, NULL, &tv);
|
||||
}
|
||||
#endif
|
||||
|
||||
void genos_pause(int ms)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Sleep(ms);
|
||||
#else
|
||||
genos_msleep(ms);
|
||||
#endif
|
||||
}
|
||||
|
||||
int genos_createthread(jtag_core* jtag_ctx,void* hwcontext,THREADFUNCTION thread,int priority)
|
||||
{
|
||||
#ifdef WIN32
|
||||
DWORD sit;
|
||||
HANDLE thread_handle;
|
||||
threadinit *threadinitptr;
|
||||
|
||||
sit = 0;
|
||||
|
||||
threadinitptr=(threadinit*)malloc(sizeof(threadinit));
|
||||
if( threadinitptr )
|
||||
{
|
||||
threadinitptr->thread = thread;
|
||||
threadinitptr->jtag_ctx = jtag_ctx;
|
||||
threadinitptr->hwcontext = hwcontext;
|
||||
|
||||
thread_handle = CreateThread(NULL,8*1024,&ThreadProc,threadinitptr,0,&sit);
|
||||
|
||||
if(!thread_handle)
|
||||
{
|
||||
free(threadinitptr);
|
||||
// jtag_ctx->jtagcore_print_callback(MSG_ERROR,"genos_createthread : CreateThread failed -> 0x.8X", GetLastError());
|
||||
}
|
||||
}
|
||||
return sit;
|
||||
#else
|
||||
unsigned long sit;
|
||||
int ret;
|
||||
pthread_t threadid;
|
||||
pthread_attr_t threadattrib;
|
||||
threadinit *threadinitptr;
|
||||
struct sched_param param;
|
||||
JTAGCORE_PRINT_FUNC print_callback;
|
||||
|
||||
sit = 0;
|
||||
|
||||
pthread_attr_init(&threadattrib);
|
||||
|
||||
pthread_attr_setinheritsched(&threadattrib, PTHREAD_EXPLICIT_SCHED);
|
||||
|
||||
if(priority)
|
||||
{
|
||||
pthread_attr_setschedpolicy(&threadattrib,SCHED_FIFO);
|
||||
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_attr_setschedpolicy(&threadattrib,SCHED_OTHER);
|
||||
param.sched_priority = sched_get_priority_max(SCHED_OTHER);
|
||||
}
|
||||
/* set the new scheduling param */
|
||||
pthread_attr_setschedparam (&threadattrib, ¶m);
|
||||
|
||||
print_callback = jtag_ctx->jtagcore_print_callback;
|
||||
|
||||
threadinitptr = (threadinit *)malloc(sizeof(threadinit));
|
||||
if( threadinitptr )
|
||||
{
|
||||
threadinitptr->thread = thread;
|
||||
threadinitptr->jtag_ctx = jtag_ctx;
|
||||
//threadinitptr->hwcontext=hwcontext;
|
||||
|
||||
ret = pthread_create(&threadid, &threadattrib,ThreadProc, threadinitptr);
|
||||
if(ret)
|
||||
{
|
||||
print_callback(jtag_ctx,"genos_createthread : pthread_create failed !");
|
||||
free( threadinitptr );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print_callback(jtag_ctx,"genos_createthread : memory allocation failed !");
|
||||
}
|
||||
|
||||
return sit;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
/*void strlwr(char *string)
|
||||
{
|
||||
int i;
|
||||
|
||||
i=0;
|
||||
while (string[i])
|
||||
{
|
||||
string[i] = tolower(string[i]);
|
||||
i++;
|
||||
}
|
||||
}*/
|
||||
#endif
|
||||
|
||||
char * genos_strupper(char * str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i=0;
|
||||
while(str[i])
|
||||
{
|
||||
|
||||
if(str[i]>='a' && str[i]<='z')
|
||||
{
|
||||
str[i]=str[i]+('A'-'a');
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char * genos_strlower(char * str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i=0;
|
||||
while(str[i])
|
||||
{
|
||||
|
||||
if(str[i]>='A' && str[i]<='Z')
|
||||
{
|
||||
str[i]=str[i]+('a'-'A');
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char * genos_getfilenamebase(char * fullpath,char * filenamebase, int type)
|
||||
{
|
||||
int len,i;
|
||||
char separator;
|
||||
|
||||
if(fullpath)
|
||||
{
|
||||
len=strlen(fullpath);
|
||||
|
||||
separator = DIR_SEPARATOR_CHAR; // system type by default
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case SYS_PATH_TYPE: // System based
|
||||
separator = DIR_SEPARATOR_CHAR;
|
||||
break;
|
||||
|
||||
case UNIX_PATH_TYPE: // Unix style
|
||||
separator = '/';
|
||||
break;
|
||||
|
||||
case WINDOWS_PATH_TYPE: // Windows style
|
||||
separator = '\\';
|
||||
break;
|
||||
}
|
||||
|
||||
i=0;
|
||||
if(len)
|
||||
{
|
||||
i=len-1;
|
||||
while(i && ( fullpath[i] != separator && fullpath[i]!=':') )
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
||||
if( fullpath[i] == separator || fullpath[i]==':' )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i>len)
|
||||
{
|
||||
i=len;
|
||||
}
|
||||
}
|
||||
|
||||
if(filenamebase)
|
||||
{
|
||||
strcpy(filenamebase,&fullpath[i]);
|
||||
}
|
||||
|
||||
return &fullpath[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * genos_getfilenameext(char * fullpath,char * filenameext, int type )
|
||||
{
|
||||
char * filename;
|
||||
int len,i;
|
||||
|
||||
filename = genos_getfilenamebase(fullpath,0,type);
|
||||
|
||||
if(filename)
|
||||
{
|
||||
len=strlen(filename);
|
||||
|
||||
i=0;
|
||||
if(len)
|
||||
{
|
||||
i=len-1;
|
||||
|
||||
while(i && ( filename[i] != '.' ) )
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
||||
if( filename[i] == '.' )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
i=len;
|
||||
}
|
||||
|
||||
if(i>len)
|
||||
{
|
||||
i=len;
|
||||
}
|
||||
}
|
||||
|
||||
if(filenameext)
|
||||
{
|
||||
strcpy(filenameext,&filename[i]);
|
||||
}
|
||||
|
||||
return &filename[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int genos_getfilenamewext(char * fullpath,char * filenamewext, int type)
|
||||
{
|
||||
char * filename;
|
||||
char * ext;
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
if(fullpath)
|
||||
{
|
||||
filename = genos_getfilenamebase(fullpath,0,type);
|
||||
ext = genos_getfilenameext(fullpath,0,type);
|
||||
|
||||
len = ext-filename;
|
||||
|
||||
if(len && filename[len-1]=='.')
|
||||
{
|
||||
len--;
|
||||
}
|
||||
|
||||
if(filenamewext)
|
||||
{
|
||||
memcpy(filenamewext,filename,len);
|
||||
filenamewext[len]=0;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int genos_getpathfolder(char * fullpath,char * folder,int type)
|
||||
{
|
||||
int len;
|
||||
char * filenameptr;
|
||||
|
||||
len = 0;
|
||||
if(fullpath)
|
||||
{
|
||||
filenameptr = genos_getfilenamebase(fullpath,0,type);
|
||||
|
||||
len = filenameptr-fullpath;
|
||||
|
||||
if(folder)
|
||||
{
|
||||
memcpy(folder,fullpath,len);
|
||||
folder[len]=0;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int genos_checkfileext(char * path,char *ext,int type)
|
||||
{
|
||||
char pathext[16];
|
||||
char srcext[16];
|
||||
char * ptr;
|
||||
|
||||
if(path && ext)
|
||||
{
|
||||
pathext[0] = '\0';
|
||||
srcext[0] = ' ';
|
||||
srcext[1] = '\0';
|
||||
|
||||
ptr = genos_getfilenameext(path,0,type);
|
||||
if(!ptr)
|
||||
return 0;
|
||||
|
||||
if( ( strlen(ptr) < 16 ) && ( strlen(ext) < 16 ))
|
||||
{
|
||||
genos_getfilenameext(path,(char*)&pathext,type);
|
||||
genos_strlower(pathext);
|
||||
|
||||
strcpy((char*)srcext,ext);
|
||||
genos_strlower(srcext);
|
||||
|
||||
if(!strcmp(pathext,srcext))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int genos_getfilesize(char * path)
|
||||
{
|
||||
int filesize;
|
||||
FILE * f;
|
||||
|
||||
filesize=-1;
|
||||
|
||||
if(path)
|
||||
{
|
||||
f=genos_fopen(path,"rb");
|
||||
if(f)
|
||||
{
|
||||
fseek (f , 0 , SEEK_END);
|
||||
filesize=ftell(f);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
return filesize;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
#define va_copy(dest, src) (dest = src)
|
||||
|
||||
int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
|
||||
{
|
||||
int ret;
|
||||
va_list ap_copy;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
else if (n > INT_MAX)
|
||||
return 0;
|
||||
memset(s, 0, n);
|
||||
va_copy(ap_copy, ap);
|
||||
ret = _vsnprintf(s, n - 1, fmt, ap_copy);
|
||||
va_end(ap_copy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int snprintf(char *s, size_t n, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = vsnprintf(s, n, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
char * genos_strndstcat( char *dest, const char *src, size_t maxdestsize )
|
||||
{
|
||||
int i,j;
|
||||
|
||||
i = 0;
|
||||
while( ( i < maxdestsize ) && dest[i] )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if( !dest[i] )
|
||||
{
|
||||
j = 0;
|
||||
while( ( i < maxdestsize ) && src[j] )
|
||||
{
|
||||
dest[i] = src[j];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
if( i < maxdestsize )
|
||||
{
|
||||
dest[i] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
126
lib_jtag_core/src/os_interface/os_interface.h
Normal file
126
lib_jtag_core/src/os_interface/os_interface.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* JTAG Boundary Scanner
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Boundary Scanner 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 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Boundary Scanner 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 version 3 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JTAG Boundary Scanners; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file os_interface.h
|
||||
* @brief Basic/generic OS functions wrapper header.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define DIR_SEPARATOR "\\"
|
||||
#define DIR_SEPARATOR_CHAR '\\'
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
int snprintf(char *outBuf, size_t size, const char *format, ...);
|
||||
#endif
|
||||
#else
|
||||
#define DIR_SEPARATOR "/"
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#endif
|
||||
|
||||
#define FILEFOUND_NAMESIZE 256
|
||||
|
||||
/////////////// Thread functions ////////////////
|
||||
|
||||
typedef int (*THREADFUNCTION) (void* jtag_ctx,void* hw_ctx);
|
||||
|
||||
typedef struct threadinit_
|
||||
{
|
||||
THREADFUNCTION thread;
|
||||
jtag_core * jtag_ctx;
|
||||
void * hwcontext;
|
||||
}threadinit;
|
||||
|
||||
typedef struct filefoundinfo_
|
||||
{
|
||||
int isdirectory;
|
||||
char filename[FILEFOUND_NAMESIZE];
|
||||
int size;
|
||||
}filefoundinfo;
|
||||
|
||||
int genos_setevent( jtag_core* jtag_ctx, unsigned char id );
|
||||
uintptr_t genos_createevent( jtag_core* jtag_ctx, unsigned char id );
|
||||
int genos_waitevent( jtag_core* jtag_ctx, int id, int timeout );
|
||||
void genos_pause( int ms );
|
||||
int genos_createthread( jtag_core* jtag_ctx, void* hwcontext, THREADFUNCTION thread, int priority );
|
||||
|
||||
uintptr_t genos_createcriticalsection( jtag_core* jtag_ctx, unsigned char id );
|
||||
void genos_entercriticalsection( jtag_core* jtag_ctx, unsigned char id );
|
||||
void genos_leavecriticalsection( jtag_core* jtag_ctx, unsigned char id );
|
||||
void genos_destroycriticalsection( jtag_core* jtag_ctx, unsigned char id );
|
||||
|
||||
/////////////// String functions ///////////////
|
||||
|
||||
#ifndef WIN32
|
||||
//void strlwr(char *string)
|
||||
#endif
|
||||
char * genos_strupper( char * str );
|
||||
char * genos_strlower( char * str );
|
||||
char * genos_strndstcat( char *dest, const char *src, size_t maxdestsize );
|
||||
|
||||
/////////////// File functions ////////////////
|
||||
|
||||
int genos_open ( const char *filename, int flags, ... );
|
||||
|
||||
FILE *genos_fopen ( const char *filename, const char *mode );
|
||||
int genos_fread( void * ptr, size_t size, FILE *f );
|
||||
char * genos_fgets( char * str, int num, FILE *f );
|
||||
int genos_fclose( FILE * f );
|
||||
int genos_fgetsize( FILE * f );
|
||||
#ifndef stat
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
int genos_stat( const char *filename, struct stat *buf );
|
||||
|
||||
void* genos_find_first_file( char *folder, char *file, filefoundinfo* fileinfo );
|
||||
int genos_find_next_file( void* handleff, char *folder, char *file, filefoundinfo* fileinfo );
|
||||
int genos_find_close( void* handle );
|
||||
|
||||
int genos_mkdir( char * folder );
|
||||
|
||||
char * genos_getcurrentdirectory( char *currentdirectory, int buffersize );
|
||||
|
||||
enum
|
||||
{
|
||||
SYS_PATH_TYPE = 0,
|
||||
UNIX_PATH_TYPE,
|
||||
WINDOWS_PATH_TYPE,
|
||||
};
|
||||
|
||||
char * genos_getfilenamebase( char * fullpath, char * filenamebase, int type );
|
||||
char * genos_getfilenameext( char * fullpath, char * filenameext, int type );
|
||||
int genos_getfilenamewext( char * fullpath, char * filenamewext, int type );
|
||||
int genos_getpathfolder( char * fullpath, char * folder, int type );
|
||||
int genos_checkfileext( char * path, char *ext, int type );
|
||||
int genos_getfilesize( char * path );
|
||||
|
||||
/////////////// Network functions ////////////////
|
||||
|
||||
void * network_connect(char * address,unsigned short port);
|
||||
int network_read(void * network_connection, unsigned char * buffer, int size,int timeout);
|
||||
int network_read2(void * network_connection, unsigned char * buffer, int size,int timeout);
|
||||
int network_write(void * network_connection, unsigned char * buffer, int size,int timeout);
|
||||
int network_close(void * network_connection);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
66
lib_jtag_core/src/os_interface/win32/libjtagcore.def
Normal file
66
lib_jtag_core/src/os_interface/win32/libjtagcore.def
Normal file
@@ -0,0 +1,66 @@
|
||||
LIBRARY LIBJTAGCORE
|
||||
|
||||
EXPORTS
|
||||
jtagcore_init @1
|
||||
jtagcore_set_logs_callback @2
|
||||
jtagcore_set_logs_level @3
|
||||
setOutputFunc_script @4
|
||||
jtagcore_get_logs_level @5
|
||||
jtagcore_set_logs_file @6
|
||||
jtagcore_get_logs_file @7
|
||||
jtagcore_deinit @9
|
||||
|
||||
jtagcore_scan_and_init_chain @10
|
||||
jtagcore_get_number_of_devices @11
|
||||
jtagcore_get_dev_id @12
|
||||
jtagcore_loadbsdlfile @13
|
||||
jtagcore_get_dev_name @14
|
||||
jtagcore_get_number_of_pins @15
|
||||
jtagcore_get_pin_properties @16
|
||||
jtagcore_get_bsdl_id @17
|
||||
jtagcore_set_scan_mode @18
|
||||
jtagcore_get_pin_state @19
|
||||
jtagcore_set_pin_state @20
|
||||
jtagcore_push_and_pop_chain @21
|
||||
|
||||
jtagcore_get_number_of_probes @30
|
||||
jtagcore_get_number_of_probes_drv @31
|
||||
jtagcore_get_probe_name @32
|
||||
jtagcore_select_and_open_probe @33
|
||||
jtagcore_get_pin_id @34
|
||||
|
||||
jtagcore_i2c_set_scl_pin @100
|
||||
jtagcore_i2c_set_sda_pin @101
|
||||
jtagcore_i2c_write_read @102
|
||||
|
||||
jtagcore_spi_set_cs_pin @200
|
||||
jtagcore_spi_set_clk_pin @201
|
||||
jtagcore_spi_set_miso_pin @202
|
||||
jtagcore_spi_set_mosi_pin @203
|
||||
jtagcore_spi_write_read @204
|
||||
jtagcore_spi_set_bitorder @205
|
||||
|
||||
jtagcore_mdio_set_mdio_pin @300
|
||||
jtagcore_mdio_set_mdc_pin @301
|
||||
jtagcore_mdio_read @302
|
||||
jtagcore_mdio_write @303
|
||||
|
||||
jtagcore_memory_clear_pins @400
|
||||
jtagcore_memory_set_address_pin @401
|
||||
jtagcore_memory_set_data_pin @402
|
||||
jtagcore_memory_set_ctrl_pin @403
|
||||
jtagcore_memory_read @404
|
||||
jtagcore_memory_write @405
|
||||
|
||||
jtagcore_setEnvVar @500
|
||||
jtagcore_getEnvVar @501
|
||||
jtagcore_getEnvVarValue @502
|
||||
jtagcore_getEnvVarIndex @503
|
||||
|
||||
jtagcore_execScriptLine @600
|
||||
jtagcore_execScriptFile @601
|
||||
jtagcore_execScriptRam @602
|
||||
jtagcore_savePinsStateScript @603
|
||||
jtagcore_initScript @604
|
||||
jtagcore_setScriptOutputFunc @605
|
||||
jtagcore_deinitScript @606
|
||||
107
lib_jtag_core/src/os_interface/win32/libjtagcore.rc
Normal file
107
lib_jtag_core/src/os_interface/win32/libjtagcore.rc
Normal file
@@ -0,0 +1,107 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "../../version.h"
|
||||
|
||||
#define FILE_VERSION VDIG1,VDIG2,VDIG3,VDIG4
|
||||
#define STR_FILE_VERSION vxstr(VDIG1) "." vxstr(VDIG2) "." vxstr(VDIG3) "." vxstr(VDIG4)
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "windows.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Language resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION FILE_VERSION
|
||||
PRODUCTVERSION FILE_VERSION
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040c04b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "lib jtag core " STR_FILE_VERSION " Release : " STR_DATE " Build : " __DATE__ " " __TIME__ "\0"
|
||||
VALUE "CompanyName", "(c) Viveris\0"
|
||||
VALUE "FileDescription", "jtag boundary scanner core\0"
|
||||
VALUE "FileVersion", STR_FILE_VERSION "\0"
|
||||
VALUE "InternalName", "libjtagcore.dll\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2023\0"
|
||||
VALUE "LegalTrademarks", "(c) Viveris\0"
|
||||
VALUE "OriginalFilename", "libjtagcore.dll\0"
|
||||
VALUE "ProductName", "jtag-boundary-scanner\0"
|
||||
VALUE "ProductVersion", STR_FILE_VERSION "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x40c, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
247
lib_jtag_core/src/os_interface/win32/stdint.h
Normal file
247
lib_jtag_core/src/os_interface/win32/stdint.h
Normal file
@@ -0,0 +1,247 @@
|
||||
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||
//
|
||||
// Copyright (c) 2006-2008 Alexander Chemeris
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The name of the author may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSC_VER // [
|
||||
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||
#endif // _MSC_VER ]
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
/*#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif*/
|
||||
|
||||
// Define _W64 macros to mark types changing their size, like intptr_t.
|
||||
#ifndef _W64
|
||||
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||
# define _W64 __w64
|
||||
# else
|
||||
# define _W64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// 7.18.1 Integer types
|
||||
|
||||
// 7.18.1.1 Exact-width integer types
|
||||
|
||||
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||
// realize that, e.g. char has the same size as __int8
|
||||
// so we give up on __intX for them.
|
||||
#if (_MSC_VER < 1300)
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#else
|
||||
typedef signed __int8 int8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#endif
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
|
||||
// 7.18.1.2 Minimum-width integer types
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int16_t int_fast16_t;
|
||||
typedef int32_t int_fast32_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
typedef uint16_t uint_fast16_t;
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
// 7.18.1.4 Integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
typedef signed __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else // _WIN64 ][
|
||||
typedef _W64 signed int intptr_t;
|
||||
typedef _W64 unsigned int uintptr_t;
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.1.5 Greatest-width integer types
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
|
||||
// 7.18.2 Limits of specified-width integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||
|
||||
// 7.18.2.1 Limits of exact-width integer types
|
||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||
#define INT8_MAX _I8_MAX
|
||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||
#define INT16_MAX _I16_MAX
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
#define INT32_MAX _I32_MAX
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
#define INT64_MAX _I64_MAX
|
||||
#define UINT8_MAX _UI8_MAX
|
||||
#define UINT16_MAX _UI16_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
|
||||
// 7.18.2.2 Limits of minimum-width integer types
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define INTPTR_MIN INT32_MIN
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.2.5 Limits of greatest-width integer types
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
// 7.18.3 Limits of other integer types
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define PTRDIFF_MIN _I64_MIN
|
||||
# define PTRDIFF_MAX _I64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define PTRDIFF_MIN _I32_MIN
|
||||
# define PTRDIFF_MAX _I32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
#define SIG_ATOMIC_MIN INT_MIN
|
||||
#define SIG_ATOMIC_MAX INT_MAX
|
||||
|
||||
#ifndef SIZE_MAX // [
|
||||
# ifdef _WIN64 // [
|
||||
# define SIZE_MAX _UI64_MAX
|
||||
# else // _WIN64 ][
|
||||
# define SIZE_MAX _UI32_MAX
|
||||
# endif // _WIN64 ]
|
||||
#endif // SIZE_MAX ]
|
||||
|
||||
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||
#ifndef WCHAR_MIN // [
|
||||
# define WCHAR_MIN 0
|
||||
#endif // WCHAR_MIN ]
|
||||
#ifndef WCHAR_MAX // [
|
||||
# define WCHAR_MAX _UI16_MAX
|
||||
#endif // WCHAR_MAX ]
|
||||
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX _UI16_MAX
|
||||
|
||||
#endif // __STDC_LIMIT_MACROS ]
|
||||
|
||||
|
||||
// 7.18.4 Limits of other integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||
|
||||
// 7.18.4.1 Macros for minimum-width integer constants
|
||||
|
||||
#define INT8_C(val) val##i8
|
||||
#define INT16_C(val) val##i16
|
||||
#define INT32_C(val) val##i32
|
||||
#define INT64_C(val) val##i64
|
||||
|
||||
#define UINT8_C(val) val##ui8
|
||||
#define UINT16_C(val) val##ui16
|
||||
#define UINT32_C(val) val##ui32
|
||||
#define UINT64_C(val) val##ui64
|
||||
|
||||
// 7.18.4.2 Macros for greatest-width integer constants
|
||||
#define INTMAX_C INT64_C
|
||||
#define UINTMAX_C UINT64_C
|
||||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
|
||||
|
||||
#endif // _MSC_STDINT_H_ ]
|
||||
563
lib_jtag_core/src/script/env.c
Normal file
563
lib_jtag_core/src/script/env.c
Normal file
@@ -0,0 +1,563 @@
|
||||
/*
|
||||
* JTAG Boundary Scanner
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Boundary Scanner 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 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Boundary Scanner 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 version 3 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JTAG Boundary Scanners; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file env.c
|
||||
* @brief Internal variables support.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "env.h"
|
||||
|
||||
/*
|
||||
|L|H|str varname\0|L|H|str vardata\0|L|H|str varname\0|L|H|str vardata\0|0|0|
|
||||
|
||||
(H*256)+L = str size (\0 included)
|
||||
if L & H == 0 -> end of buffer
|
||||
*/
|
||||
|
||||
static int stringcopy(char * dst, char * src, unsigned int maxsize)
|
||||
{
|
||||
int s;
|
||||
|
||||
if( !dst || (maxsize <= 0))
|
||||
return 0;
|
||||
|
||||
if( !src )
|
||||
{
|
||||
*dst = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
s = 0;
|
||||
while( *src && s < (maxsize - 1))
|
||||
{
|
||||
*dst++ = *src++;
|
||||
s++;
|
||||
}
|
||||
|
||||
*dst = '\0';
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static uint16_t getEnvStrSize(unsigned char * buf)
|
||||
{
|
||||
uint16_t size;
|
||||
|
||||
size = *buf++;
|
||||
size += (((uint16_t)*buf)<<8);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static void setEnvStrSize(unsigned char * buf, uint16_t size)
|
||||
{
|
||||
*buf++ = size & 0xFF;
|
||||
*buf = (size >> 8) & 0xFF;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int getEnvEmptyOffset(envvar_entry * env)
|
||||
{
|
||||
int off;
|
||||
unsigned short varname_size, vardata_size;
|
||||
|
||||
off = 0;
|
||||
|
||||
varname_size = getEnvStrSize(&env->buf[off]); // var name string size
|
||||
vardata_size = getEnvStrSize(&env->buf[off + 2 + varname_size]); // var data string size
|
||||
|
||||
while( varname_size )
|
||||
{
|
||||
off += (2 + varname_size + 2 + vardata_size);
|
||||
|
||||
varname_size = getEnvStrSize(&env->buf[off]); // var name string size
|
||||
vardata_size = getEnvStrSize(&env->buf[off + 2 + varname_size]); // var data string size
|
||||
}
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
static int getEnvBufOff(envvar_entry * env, char * varname)
|
||||
{
|
||||
unsigned short curstr_size;
|
||||
int str_index,i;
|
||||
|
||||
i = 0;
|
||||
|
||||
str_index = 0;
|
||||
curstr_size = getEnvStrSize(&env->buf[i]);
|
||||
i += 2;
|
||||
|
||||
while( curstr_size )
|
||||
{
|
||||
if( !(str_index & 1) ) // variable name ?
|
||||
{
|
||||
if( !strcmp((char*)&env->buf[i],varname ) )
|
||||
{
|
||||
// this is the variable we are looking for.
|
||||
return (i - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not the right variable - skip this string.
|
||||
i += curstr_size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//variable data - skip this string.
|
||||
i += curstr_size;
|
||||
}
|
||||
|
||||
if( i < env->bufsize - 2 )
|
||||
{
|
||||
curstr_size = getEnvStrSize(&env->buf[i]);
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
curstr_size = 0;
|
||||
}
|
||||
|
||||
str_index++;
|
||||
}
|
||||
|
||||
return -1; // Not found.
|
||||
}
|
||||
|
||||
static int pushStr(envvar_entry * env, int offset, char * str)
|
||||
{
|
||||
int size;
|
||||
|
||||
if(!str || offset < 0)
|
||||
return -1;
|
||||
|
||||
size = strlen(str) + 1;
|
||||
if(size > 0xFFFF)
|
||||
return -1;
|
||||
|
||||
if( ( offset + 2 + size ) < env->bufsize )
|
||||
{
|
||||
setEnvStrSize(&env->buf[offset], size);
|
||||
offset += 2;
|
||||
stringcopy((char*)&env->buf[offset], str, size);
|
||||
offset += size;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef STATIC_ENV_BUFFER
|
||||
static envvar_entry * realloc_env_buffer(envvar_entry * env, unsigned int size)
|
||||
{
|
||||
unsigned int tmp_bufsize;
|
||||
unsigned char * tmpbuf;
|
||||
|
||||
if( !env )
|
||||
{
|
||||
env = malloc( sizeof(envvar_entry) );
|
||||
if(!env)
|
||||
return NULL;
|
||||
|
||||
memset( env,0,sizeof(envvar_entry));
|
||||
}
|
||||
|
||||
tmp_bufsize = size;
|
||||
|
||||
if( tmp_bufsize & (ENV_PAGE_SIZE - 1) )
|
||||
{
|
||||
tmp_bufsize = (tmp_bufsize & (~(ENV_PAGE_SIZE - 1))) + ENV_PAGE_SIZE;
|
||||
}
|
||||
|
||||
if( tmp_bufsize > ENV_MAX_TOTAL_BUFFER_SIZE )
|
||||
{
|
||||
return env;
|
||||
}
|
||||
|
||||
if( env->bufsize != tmp_bufsize )
|
||||
{
|
||||
tmpbuf = realloc(env->buf, tmp_bufsize);
|
||||
if(tmpbuf)
|
||||
{
|
||||
if( env->bufsize < tmp_bufsize )
|
||||
memset(&tmpbuf[env->bufsize], 0, tmp_bufsize - env->bufsize );
|
||||
|
||||
env->bufsize = tmp_bufsize;
|
||||
env->buf = tmpbuf;
|
||||
}
|
||||
}
|
||||
|
||||
return env;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int pushEnvEntry(envvar_entry * env, char * varname, char * vardata)
|
||||
{
|
||||
unsigned int total_size;
|
||||
int varname_len,vardata_len;
|
||||
int offset;
|
||||
|
||||
if(!varname || !vardata)
|
||||
return -1;
|
||||
|
||||
varname_len = strlen(varname) + 1;
|
||||
vardata_len = strlen(vardata) + 1;
|
||||
|
||||
if( varname_len > ENV_MAX_STRING_SIZE || vardata_len > ENV_MAX_STRING_SIZE)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
total_size = 2 + varname_len + 2 + vardata_len;
|
||||
|
||||
offset = getEnvEmptyOffset(env);
|
||||
if( offset < 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef STATIC_ENV_BUFFER
|
||||
realloc_env_buffer(env, offset + total_size + 4);
|
||||
#endif
|
||||
|
||||
if( (total_size + offset) < env->bufsize )
|
||||
{
|
||||
offset = pushStr(env, offset, varname);
|
||||
offset = pushStr(env, offset, vardata);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int setEnvVarDat( envvar_entry * env, char * varname, char * vardata )
|
||||
{
|
||||
int i,off,ret;
|
||||
unsigned short varname_size, vardata_size;
|
||||
int varname_len, vardata_len;
|
||||
int oldentrysize;
|
||||
|
||||
ret = 0;
|
||||
|
||||
if(!env)
|
||||
return -1;
|
||||
|
||||
i = 0;
|
||||
|
||||
varname_len = 0;
|
||||
vardata_len = 0;
|
||||
|
||||
if( !varname )
|
||||
return -1;
|
||||
|
||||
varname_len = strlen(varname);
|
||||
|
||||
if( vardata )
|
||||
vardata_len = strlen(vardata);
|
||||
|
||||
if( varname_len > ENV_MAX_STRING_SIZE || vardata_len > ENV_MAX_STRING_SIZE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
off = getEnvBufOff( env, varname );
|
||||
if( off >= 0 )
|
||||
{
|
||||
varname_size = getEnvStrSize(&env->buf[off]); // var name string size
|
||||
vardata_size = getEnvStrSize(&env->buf[off + 2 + varname_size]); // var data string size
|
||||
|
||||
oldentrysize = 2 + varname_size + 2 + vardata_size;
|
||||
|
||||
if(vardata)
|
||||
{
|
||||
vardata_len = strlen(vardata);
|
||||
if( vardata_len + 1 > 0xFFFF )
|
||||
return -1;
|
||||
|
||||
if( vardata_len + 1 > vardata_size )
|
||||
{
|
||||
// add new entry, and pack the strings
|
||||
ret = pushEnvEntry(env, varname, vardata);
|
||||
if( ret > 0 )
|
||||
{
|
||||
unsigned char byte;
|
||||
for(i=0;i<env->bufsize - (off + oldentrysize);i++)
|
||||
{
|
||||
byte = env->buf[off + i + oldentrysize];
|
||||
env->buf[off + i + oldentrysize] = '\0';
|
||||
env->buf[off + i] = byte;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vardata_size = getEnvStrSize(&env->buf[off + 2 + varname_size]); // var data string size
|
||||
if(vardata_size)
|
||||
{
|
||||
memset((char*)&env->buf[off + 2 + varname_size + 2], 0, vardata_size );
|
||||
stringcopy( (char*)&env->buf[off + 2 + varname_size + 2], vardata, vardata_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// unset variable
|
||||
unsigned char byte;
|
||||
for(i=0;i<env->bufsize - (off + oldentrysize);i++)
|
||||
{
|
||||
byte = env->buf[off + i + oldentrysize];
|
||||
env->buf[off + i + oldentrysize] = '\0';
|
||||
env->buf[off + i] = byte;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vardata)
|
||||
{
|
||||
// New variable
|
||||
ret = pushEnvEntry(env, varname, vardata);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char * getEnvVarDat( envvar_entry * env, char * varname, char * vardata, int maxsize)
|
||||
{
|
||||
int off;
|
||||
unsigned short varname_size, vardata_size;
|
||||
|
||||
envvar_entry * tmp_envvars;
|
||||
|
||||
tmp_envvars = (envvar_entry *)env;
|
||||
if(!tmp_envvars)
|
||||
return NULL;
|
||||
|
||||
off = getEnvBufOff( env, varname );
|
||||
if( off >= 0 )
|
||||
{
|
||||
varname_size = getEnvStrSize(&env->buf[off]); // var name string size
|
||||
vardata_size = getEnvStrSize(&env->buf[off + 2 + varname_size]); // var data string size
|
||||
|
||||
if( varname_size>0 && vardata_size>0)
|
||||
{
|
||||
if(vardata)
|
||||
{
|
||||
stringcopy(vardata, (char*)&env->buf[off + 2 + varname_size + 2], maxsize);
|
||||
}
|
||||
|
||||
return (char*)&env->buf[off + 2 + varname_size + 2];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env_var_value getEnvVarValue( envvar_entry * env, char * varname)
|
||||
{
|
||||
env_var_value value;
|
||||
char * str_return;
|
||||
|
||||
value = 0;
|
||||
|
||||
if(!varname)
|
||||
return 0;
|
||||
|
||||
str_return = getEnvVarDat( env, varname, NULL, 0);
|
||||
|
||||
if(str_return)
|
||||
{
|
||||
if( strlen(str_return) > 2 )
|
||||
{
|
||||
if( str_return[0]=='0' && ( str_return[1]=='x' || str_return[1]=='X'))
|
||||
{
|
||||
value = (env_var_value)STRTOVALUE(str_return, NULL, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = atoi(str_return);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = atoi(str_return);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int setEnvVarValue( envvar_entry * env, char * varname, env_var_value value)
|
||||
{
|
||||
char tmp_str[128];
|
||||
|
||||
tmp_str[128 - 1] = 0;
|
||||
|
||||
snprintf(tmp_str,sizeof(tmp_str) - 1, "%d",value);
|
||||
|
||||
return setEnvVarDat( env, varname, tmp_str );
|
||||
}
|
||||
|
||||
char * getEnvVarDatIndex( envvar_entry * env, int index, char * vardata, int maxsize)
|
||||
{
|
||||
int str_index, off;
|
||||
unsigned short varname_size, vardata_size;
|
||||
|
||||
off = 0;
|
||||
|
||||
str_index = 0;
|
||||
|
||||
varname_size = getEnvStrSize(&env->buf[off]); // var name string size
|
||||
vardata_size = getEnvStrSize(&env->buf[off + 2 + varname_size]); // var data string size
|
||||
|
||||
while( varname_size )
|
||||
{
|
||||
if( str_index == index )
|
||||
{
|
||||
if( varname_size>0 && vardata_size>0)
|
||||
{
|
||||
if(vardata)
|
||||
{
|
||||
stringcopy(vardata,(char*)&env->buf[off + 2 + varname_size + 2], maxsize);
|
||||
}
|
||||
|
||||
return (char*)&env->buf[off + 2];
|
||||
}
|
||||
}
|
||||
|
||||
off += (2 + varname_size + 2 + vardata_size);
|
||||
|
||||
varname_size = getEnvStrSize(&env->buf[off]); // var name string size
|
||||
vardata_size = getEnvStrSize(&env->buf[off + 2 + varname_size]); // var data string size
|
||||
|
||||
str_index++;
|
||||
}
|
||||
|
||||
return NULL; // Not found.
|
||||
}
|
||||
|
||||
envvar_entry * initEnv(envvar_entry * src, envvar_entry * dst)
|
||||
{
|
||||
if( !dst )
|
||||
{
|
||||
#ifdef STATIC_ENV_BUFFER
|
||||
return NULL;
|
||||
#else
|
||||
dst = malloc( sizeof(envvar_entry) );
|
||||
if(!dst)
|
||||
return NULL;
|
||||
|
||||
memset( dst, 0, sizeof(envvar_entry) );
|
||||
|
||||
if( src )
|
||||
dst->bufsize = src->bufsize;
|
||||
else
|
||||
dst->bufsize = ENV_PAGE_SIZE;
|
||||
|
||||
dst->buf = malloc(dst->bufsize);
|
||||
if(!dst->buf)
|
||||
{
|
||||
free(dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( src )
|
||||
memcpy( dst->buf, src->buf, src->bufsize );
|
||||
else
|
||||
memset( dst->buf, 0, dst->bufsize );
|
||||
|
||||
return dst;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef STATIC_ENV_BUFFER
|
||||
|
||||
memset( dst, 0, sizeof(envvar_entry) );
|
||||
dst->bufsize = ENV_PAGE_SIZE;
|
||||
if(src)
|
||||
{
|
||||
memcpy( dst->buf, src->buf, dst->bufsize );
|
||||
}
|
||||
else
|
||||
{
|
||||
memset( dst->buf, 0, dst->bufsize );
|
||||
}
|
||||
|
||||
return dst;
|
||||
#else
|
||||
free(dst->buf);
|
||||
|
||||
dst->buf = NULL;
|
||||
|
||||
if( src )
|
||||
dst->bufsize = src->bufsize;
|
||||
else
|
||||
dst->bufsize = ENV_PAGE_SIZE;
|
||||
|
||||
dst->buf = malloc(dst->bufsize);
|
||||
if(!dst->buf)
|
||||
{
|
||||
dst->bufsize = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(src)
|
||||
{
|
||||
memcpy( dst->buf, src->buf, dst->bufsize );
|
||||
}
|
||||
else
|
||||
{
|
||||
memset( dst->buf, 0, dst->bufsize );
|
||||
}
|
||||
|
||||
return dst;
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void deinitEnv(envvar_entry * env)
|
||||
{
|
||||
#ifndef STATIC_ENV_BUFFER
|
||||
if(!env)
|
||||
return;
|
||||
|
||||
free(env->buf);
|
||||
|
||||
free(env);
|
||||
#else
|
||||
memset(env,0,sizeof(envvar_entry));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
60
lib_jtag_core/src/script/env.h
Normal file
60
lib_jtag_core/src/script/env.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* JTAG Boundary Scanner
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Boundary Scanner 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 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Boundary Scanner 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 version 3 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JTAG Boundary Scanners; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file env.h
|
||||
* @brief Internal variables support header file.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
#ifdef SCRIPT_64BITS_SUPPORT
|
||||
#define env_var_value uint64_t
|
||||
#define signed_env_var_value int64_t
|
||||
#define STRTOVALUE strtoull
|
||||
#else
|
||||
#define env_var_value uint32_t
|
||||
#define signed_env_var_value int32_t
|
||||
#define STRTOVALUE strtoul
|
||||
#endif
|
||||
|
||||
//#define STATIC_ENV_BUFFER 1
|
||||
#define ENV_PAGE_SIZE (16*1024)
|
||||
#define ENV_MAX_TOTAL_BUFFER_SIZE (1024 * 1024) // 1MB
|
||||
#define ENV_MAX_STRING_SIZE 512
|
||||
|
||||
typedef struct envvar_entry_
|
||||
{
|
||||
#ifdef STATIC_ENV_BUFFER
|
||||
unsigned char buf[ENV_PAGE_SIZE];
|
||||
#else
|
||||
unsigned char * buf;
|
||||
#endif
|
||||
unsigned int bufsize;
|
||||
}envvar_entry;
|
||||
|
||||
envvar_entry * initEnv( envvar_entry * src, envvar_entry * dst );
|
||||
|
||||
int setEnvVarDat( envvar_entry * env, char * varname, char * vardata );
|
||||
int setEnvVarValue( envvar_entry * env, char * varname, env_var_value value );
|
||||
|
||||
char * getEnvVarDat( envvar_entry * env, char * varname, char * vardata, int maxsize );
|
||||
env_var_value getEnvVarValue( envvar_entry * env, char * varname );
|
||||
|
||||
char * getEnvVarDatIndex( envvar_entry * env, int index, char * vardata, int maxsize );
|
||||
|
||||
void deinitEnv( envvar_entry * env );
|
||||
2658
lib_jtag_core/src/script/script.c
Normal file
2658
lib_jtag_core/src/script/script.c
Normal file
File diff suppressed because it is too large
Load Diff
86
lib_jtag_core/src/script/script.h
Normal file
86
lib_jtag_core/src/script/script.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* JTAG Boundary Scanner
|
||||
* Copyright (c) 2008 - 2024 Viveris Technologies
|
||||
*
|
||||
* JTAG Boundary Scanner 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 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* JTAG Boundary Scanner 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 version 3 for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with JTAG Boundary Scanners; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file script.h
|
||||
* @brief JTAG Boundary Scanner scripts support header file.
|
||||
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
|
||||
*/
|
||||
|
||||
#define _script_ctx_
|
||||
|
||||
#ifndef _script_printf_func_
|
||||
typedef int (* SCRIPT_PRINTF_FUNC)(void * ctx, int MSGTYPE, char * string, ... );
|
||||
#define _script_printf_func_
|
||||
#endif
|
||||
|
||||
#ifdef SCRIPT_64BITS_SUPPORT
|
||||
#define env_var_value uint64_t
|
||||
#define STRTOVALUE strtoull
|
||||
#define LONGHEXSTR "%llX"
|
||||
#else
|
||||
#define env_var_value uint32_t
|
||||
#define STRTOVALUE strtoul
|
||||
#define LONGHEXSTR "%.8X"
|
||||
#endif
|
||||
|
||||
#define MAX_LABEL_SIZE 64
|
||||
#define MAX_LABEL 256
|
||||
|
||||
typedef struct _script_label
|
||||
{
|
||||
char label_name[MAX_LABEL_SIZE];
|
||||
unsigned int offset;
|
||||
} script_label;
|
||||
|
||||
typedef struct _script_ctx
|
||||
{
|
||||
SCRIPT_PRINTF_FUNC script_printf;
|
||||
void * app_ctx;
|
||||
|
||||
void * env;
|
||||
|
||||
void * cmdlist;
|
||||
|
||||
FILE * script_file;
|
||||
char script_file_path[1024];
|
||||
|
||||
int cur_label_index;
|
||||
script_label labels[MAX_LABEL];
|
||||
|
||||
int cur_script_offset;
|
||||
|
||||
int dry_run;
|
||||
|
||||
int last_error_code;
|
||||
env_var_value last_data_value;
|
||||
int last_flags;
|
||||
|
||||
char pre_command[1024 + 32];
|
||||
|
||||
uint32_t rand_seed;
|
||||
|
||||
} script_ctx;
|
||||
|
||||
script_ctx * init_script(void * app_ctx, unsigned int flags, void * env);
|
||||
int execute_file_script( script_ctx * ctx, char * filename );
|
||||
int execute_line_script( script_ctx * ctx, char * line );
|
||||
int execute_ram_script( script_ctx * ctx, unsigned char * script_buffer, int buffersize );
|
||||
void setOutputFunc_script( script_ctx * ctx, SCRIPT_PRINTF_FUNC ext_printf );
|
||||
script_ctx * deinit_script(script_ctx * ctx);
|
||||
16
lib_jtag_core/src/version.h
Normal file
16
lib_jtag_core/src/version.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#define VDIG1 2
|
||||
#define VDIG2 6
|
||||
#define VDIG3 7
|
||||
#define VDIG4 1
|
||||
|
||||
#define STR_DATE "28 Oct 2024"
|
||||
|
||||
#define vxstr(s) vstr(s)
|
||||
#define vstr(s) #s
|
||||
|
||||
#define LIB_JTAG_CORE_VERSION vxstr(VDIG1) "." vxstr(VDIG2) "." vxstr(VDIG3) "." vxstr(VDIG4)
|
||||
#define LIB_JTAG_CORE_VERSION_COMMA vxstr(VDIG1) "," vxstr(VDIG2) "," vxstr(VDIG3) "," vxstr(VDIG4)
|
||||
|
||||
#define APP_VER VDIG1.VDIG2.VDIG3.VDIG4
|
||||
#define APP_VER_TXT( N ) JTAG Boundary Scanner v##N
|
||||
#define APP_VER_STR( N ) vxstr( APP_VER_TXT( N ) )
|
||||
Reference in New Issue
Block a user