Imported Upstream version 0.4.1
This commit is contained in:
commit
7ea26e619b
3
AUTHOR
Normal file
3
AUTHOR
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
Other than the included megaraid2 driver code from LSI (GPLv2), and the SCSI header files from Joerg Schilling (GPLv2), this software was written entirely by Jefferson Ogata <ogata@antibozo.net>.
|
||||||
|
|
348
COPYING
Normal file
348
COPYING
Normal file
@ -0,0 +1,348 @@
|
|||||||
|
|
||||||
|
Note: This program includes megaraid2 driver source code, which was copied from
|
||||||
|
the kernel source of a Red Hat system, and header files from Joerg Schilling's
|
||||||
|
cdrecord, also as distributed on Red Hat, and also under GPL.
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------------------
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Library General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, 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 or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
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 give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
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 Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
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 Program, 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 Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) 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; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, 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 executable. However, as a
|
||||||
|
special exception, the source code 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.
|
||||||
|
|
||||||
|
If distribution of executable or 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 counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program 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.
|
||||||
|
|
||||||
|
5. 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 Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program 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 to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. 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 Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program 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 Program.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program 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.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
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 Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, 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
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), 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 Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. 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 program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Library General
|
||||||
|
Public License instead of this License.
|
205
README
Normal file
205
README
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
LSI Megaraid Control and Monitoring Tools by Jefferson Ogata
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Disclaimer
|
||||||
|
----------
|
||||||
|
|
||||||
|
WARNING: Use this software at your own risk. The author accepts no
|
||||||
|
responsibility for the consequences of your use of this software.
|
||||||
|
|
||||||
|
WARNING: Use this software at your own risk. The author accepts no
|
||||||
|
responsibility for the consequences of your use of this software.
|
||||||
|
|
||||||
|
WARNING: Use this software at your own risk. The author accepts no
|
||||||
|
responsibility for the consequences of your use of this software.
|
||||||
|
|
||||||
|
These programs directly query megaraid adapters via the ioctl(2) driver
|
||||||
|
interface and do a number of undocumented things. I and my colleagues use this
|
||||||
|
software regularly and have had no problems, but your mileage may vary. If
|
||||||
|
something goes terribly wrong and your RAID configs all get blown away, the
|
||||||
|
author accepts no responsibility for the consequences.
|
||||||
|
|
||||||
|
Please read this document carefully as it contains a warning or two. If you
|
||||||
|
have built the programs but are having any issues running them, please see the
|
||||||
|
Building, Device Nodes, and Limitations notes further down in this document.
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
------------
|
||||||
|
|
||||||
|
I've spent a fair amount of time working out the low-level interface to
|
||||||
|
megaraid adapters. This stems from the fact that I use a lot of these beasts
|
||||||
|
and have had failures at one time or another. The adapters are fast and
|
||||||
|
extremely useful, but they aren't bulletproof. For example, disks showing a
|
||||||
|
certain number of media errors are not failed immediately by the adapters; the
|
||||||
|
adapters seem to want to pass some threshold of failure before they decide that
|
||||||
|
a disk really needs to be dropped from a RAID, and by that time it's possible
|
||||||
|
there could be consistency problems. I wrote these tools so I could more
|
||||||
|
effectively monitor media errors (dellmgr makes this very tedious) and also
|
||||||
|
take advantage of the device self-test functions provided with drives.
|
||||||
|
Self-tests are in my opinion a suitable way to detect imminent drive failures
|
||||||
|
without tying up the adapter and SCSI bandwidth doing patrol reads. It is also
|
||||||
|
very useful to be able to conduct a self-test on a spare disk before using it
|
||||||
|
for a rebuild.
|
||||||
|
|
||||||
|
Another issue I've had with megaraids is keeping current documentation on RAID
|
||||||
|
configuration. You may choose a completely logical RAID layout when first
|
||||||
|
configuration a system, but that doesn't mean you'll remember it if you have to
|
||||||
|
reconstruct it in an emergency--did I leave out a disk for a hot spare? Which
|
||||||
|
one? Furthermore, as disks fail and hot spares are rotated in place, the
|
||||||
|
configuration changes over time. If you don't update your documentation every
|
||||||
|
time a disk fails, you lose track of it. While LSI's MegaCli program provides
|
||||||
|
methods for dumping the configuration (although verbosely) and saving and
|
||||||
|
restoring it from files, Dell's dellmgr doesn't give you any sensible way to
|
||||||
|
track down what spans comprise a logical disk. I wrote these programs in part
|
||||||
|
to solve this problem.
|
||||||
|
|
||||||
|
|
||||||
|
Programs
|
||||||
|
--------
|
||||||
|
|
||||||
|
This distribution contains three programs and a script:
|
||||||
|
|
||||||
|
|
||||||
|
*megactl*
|
||||||
|
|
||||||
|
megactl queries PERC2, PERC3, and PERC4 adapters and reports adapter
|
||||||
|
configuration, physical and logical drive condition, drive log sense pages, and
|
||||||
|
various other useful information. This allows you to document the actual
|
||||||
|
configuration of the adapter, since, for one thing, Dell's dellmgr does not
|
||||||
|
tell you which specific logical drive a given disk belongs to.
|
||||||
|
|
||||||
|
megactl has several features to query SCSI drive log pages, where each drive
|
||||||
|
controller saves accumulated error counts, drive temperature, self-test
|
||||||
|
results, et al. To get a list of supported log pages for a given drive, use
|
||||||
|
"megactl -vv -l 0 <target>" where target is the name of the drive, e.g. a0c1t2
|
||||||
|
for SCSI target 2 on channel 1 of adapter 0. In addition "-s" is shorthand for
|
||||||
|
"-l 0x10", "-t" is shorthand for "-l 0x0d", and "-e" is shorthand for "-l 0x02
|
||||||
|
-l 0x03 -l 0x05". megactl knows how to parse several useful log pages, but
|
||||||
|
there are others where you'll have to interpret the results yourself. Feel free
|
||||||
|
to write more parsing code.
|
||||||
|
|
||||||
|
megactl output is governed by a verbosity flag. At lower verbosity levels, the
|
||||||
|
program tends to minimize log page output unless it represents an actual
|
||||||
|
problem. So to see the full self-test log, you need to add "-vv". I usually run
|
||||||
|
the program with a single "-v".
|
||||||
|
|
||||||
|
Self-test and most status operations allow you to designate either an entire
|
||||||
|
adapter (a0), a specific channel (a0c1), or a specific drive (a0c1t2). When
|
||||||
|
performing drive self-test operations (q.v.), be sure to specify the actual
|
||||||
|
drive you wish to test, or you will end up starting a test on every drive on
|
||||||
|
the system. You may designate as many objects as you please, e.g.
|
||||||
|
"a0c0t{1,2,3,4,5,8} a0c1 a1".
|
||||||
|
|
||||||
|
megactl provides a health-check function, which inspects health check operation
|
||||||
|
allows only entire adapters to be designated. If no target is designated, the
|
||||||
|
program operates on all possible objects.
|
||||||
|
|
||||||
|
megactl with the -H option performs a health check of all (or specified)
|
||||||
|
adapters. By default, the health check checks the state of the adapter battery,
|
||||||
|
the state of all logical drives, and for each physical drive, the media error
|
||||||
|
count logged by the adapter, the read, write,and verify error log pages, and
|
||||||
|
the temperature log page. You can tune the log pages the health check will
|
||||||
|
inspect by specifying them with "-e", "-s", "-t", or "-l"; note that if you do
|
||||||
|
this, there is no default and you must specify every log page you wish to
|
||||||
|
inspect ("-et" for the default behaviour). If a problem is found, the program
|
||||||
|
prints the adapter and relevant drive info. If everything is okay, the program
|
||||||
|
is completely silent. So "megactl -vH" can be a useful cron job.
|
||||||
|
|
||||||
|
When using the health check you may specify which adapters you want to check,
|
||||||
|
but you may not designate specific channels or drives.
|
||||||
|
|
||||||
|
megactl also allows you to instruct the drive to perform a long ("-T long") or
|
||||||
|
short ("-T short") background self-test procedure, which does not take the
|
||||||
|
drive offline. I have performed self-tests on drives that are part of an
|
||||||
|
operational RAID many times with no problems. I recommend that you self-test
|
||||||
|
only one drive in a given span at a time; if the self-test causes the drive to
|
||||||
|
log errors, the adapter may fail the drive, and you don't want that to happen
|
||||||
|
to two drives in a span simultaneously or you may lose data.
|
||||||
|
|
||||||
|
You can get full usage info for megactl by executing it with the -? flag.
|
||||||
|
|
||||||
|
I use megactl on a number of PERC models, especially PERC3/QCs and PERC4/DCs.
|
||||||
|
In the past, megactl was known to work well with PERC2/DC adapters but I no
|
||||||
|
longer operate any systems with these adapters, so this may have broken. Please
|
||||||
|
let me know if you have success or problems.
|
||||||
|
|
||||||
|
megactl generally tries not to do anything harmful, so it's pretty safe.
|
||||||
|
Primarily it queries disks; the only instructions it issues in its current form
|
||||||
|
are to execute self-test operations.
|
||||||
|
|
||||||
|
|
||||||
|
*megasasctl*
|
||||||
|
|
||||||
|
The second program, megasasctl, is just like megactl, but intended for PERC5
|
||||||
|
adapters. The only syntactic difference is that instead of naming targets with
|
||||||
|
channels and ids, they are named with enclosures and slots, e.g. a0, a1e0,
|
||||||
|
a2e1s9.
|
||||||
|
|
||||||
|
The SAS support is brand new, and I'm sure I've got some things wrong. I
|
||||||
|
haven't been able to fully test SAS support yet because I don't have any bad
|
||||||
|
SAS disks.
|
||||||
|
|
||||||
|
|
||||||
|
*megatrace*
|
||||||
|
|
||||||
|
megatrace is a debugging program which can be used to trace PERC-related
|
||||||
|
ioctl() system calls that another program makes. You won't need that unless
|
||||||
|
you're trying to add features to megactl, or are exceptionally curious. This
|
||||||
|
program uses ptrace(2) and can inspect and modify data structures to help you
|
||||||
|
suss out what's going on in dellmgr and MegaCli.
|
||||||
|
|
||||||
|
|
||||||
|
*megarpt*
|
||||||
|
|
||||||
|
megarpt is a script I run in a cron job each night. It performs a health check
|
||||||
|
on all adapters, and emails any problems, along with the adapter configuration,
|
||||||
|
to root. It is handy to have the adapter configuration logged in case you need
|
||||||
|
to reconstruct adapter state in a catastrophic failure. There are various
|
||||||
|
scenarios involving hot spares and multiple drive failures where the adapter
|
||||||
|
configuration may not be quite what you thought it was. To use megarpt, copy
|
||||||
|
megarpt and megactl into /root/ and add a cron entry for /root/megarpt. Or
|
||||||
|
tweak as you see fit; there isn't much to it.
|
||||||
|
|
||||||
|
megarpt needs to be tweaked for megasasctl applications; it currently works
|
||||||
|
only with pre-SAS models.
|
||||||
|
|
||||||
|
|
||||||
|
*megasasrpt*
|
||||||
|
|
||||||
|
megasasrpt is just like megarpt, but for PERC5 adapters.
|
||||||
|
|
||||||
|
|
||||||
|
Building
|
||||||
|
--------
|
||||||
|
|
||||||
|
This software has been built successfully on RHEL 3, 4, and 5, and Debian Etch,
|
||||||
|
using the default gcc compiler, and Red Hat Linux 7.3 or RHEL 2.1 should work
|
||||||
|
as well. Simply run make in the src directory.
|
||||||
|
|
||||||
|
|
||||||
|
Device Nodes
|
||||||
|
------------
|
||||||
|
|
||||||
|
megactl and megasasctl require the existence of an appropriate device node in
|
||||||
|
order to communicate with adapters. For megactl, this device node should be
|
||||||
|
/dev/megadev0, and is created automatically by Dell's dellmgr program. You may
|
||||||
|
create it yourself by finding the major device number for megadev in
|
||||||
|
/proc/devices and creating a character device with that major number and minor
|
||||||
|
number 0. See the megarpt shell script if this is not clear. For megasasctl,
|
||||||
|
the device node is /dev/megaraid_sas_ioctl_node, and is created automatically
|
||||||
|
by LSI's MegaCli program. It should have the major number of megaraid_sas_ioctl
|
||||||
|
from /proc/devices and minor number 0. See the megasasrpt shell script for an
|
||||||
|
example of how to create this.
|
||||||
|
|
||||||
|
|
||||||
|
Limitations
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Currently these programs only operate if built as 32-bit targets. On 64-bit
|
||||||
|
architectures, you therefore will need 32-bit compatibility libraries. This
|
||||||
|
should not require any special action on Red Hat, but on Debian you may need to
|
||||||
|
install a few things.
|
||||||
|
|
||||||
|
|
42
src/Makefile
Normal file
42
src/Makefile
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
SRCS= megactl.c adapter.c megaioctl.c megatrace.c callinfo.c dumpbytes.c logpage.c ntrim.c
|
||||||
|
INC= -I./schily -Iincludes-hack
|
||||||
|
HDRS= mega.h adapter.h megaioctl.h callinfo.h logpage.h dumpbytes.h
|
||||||
|
ARCH= -m32
|
||||||
|
CFLAGS= -g -Wall $(INC) $(ARCH)
|
||||||
|
LDFLAGS= -g $(ARCH)
|
||||||
|
PROGRAMS= megactl megasasctl megatrace
|
||||||
|
|
||||||
|
all: $(PROGRAMS)
|
||||||
|
|
||||||
|
megatrace: megatrace.o callinfo.o dumpbytes.o
|
||||||
|
$(CC) $(LDFLAGS) -o $@ megatrace.o callinfo.o dumpbytes.o
|
||||||
|
|
||||||
|
megactl: megactl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||||
|
$(CC) $(LDFLAGS) -o $@ megactl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||||
|
|
||||||
|
megasasctl: megasasctl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||||
|
$(CC) $(LDFLAGS) -o $@ megasasctl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||||
|
|
||||||
|
megasasctl.o: megactl.c
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ -DMEGA_SAS_CTL megactl.c
|
||||||
|
|
||||||
|
%.o: Makefile.bak %.c
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $*.c
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(PROGRAMS) *.o
|
||||||
|
|
||||||
|
depend:
|
||||||
|
makedepend -- $(CFLAGS) -- $(SRCS)
|
||||||
|
|
||||||
|
megactl.o: mega.h adapter.h megaioctl.h logpage.h dumpbytes.h
|
||||||
|
megasasctl.o: mega.h adapter.h megaioctl.h logpage.h dumpbytes.h
|
||||||
|
adapter.o: mega.h megaioctl.h logpage.h ntrim.h
|
||||||
|
megaioctl.o: mega.h megaioctl.h logpage.h
|
||||||
|
megatrace.o: mega.h megaioctl.h logpage.h callinfo.h dumpbytes.h
|
||||||
|
callinfo.o: callinfo.h
|
||||||
|
logpage.o: mega.h megaioctl.h logpage.h ntrim.h dumpbytes.h
|
||||||
|
ntrim.o: ntrim.h
|
||||||
|
|
||||||
|
# DO NOT DELETE
|
845
src/adapter.c
Normal file
845
src/adapter.c
Normal file
@ -0,0 +1,845 @@
|
|||||||
|
/*
|
||||||
|
* High-level interface to adapter information.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "megaioctl.h"
|
||||||
|
#include "logpage.h"
|
||||||
|
#include "ntrim.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include <scg/scsireg.h>
|
||||||
|
|
||||||
|
|
||||||
|
static void batteryStatus (struct adapter_config *a, uint8_t status)
|
||||||
|
{
|
||||||
|
a->battery.module_missing = (status & BATTERY_MODULE_MISSING) != 0;
|
||||||
|
a->battery.pack_missing = (status & BATTERY_PACK_MISSING) != 0;
|
||||||
|
a->battery.low_voltage = (status & BATTERY_LOW_VOLTAGE) != 0;
|
||||||
|
a->battery.high_temperature = (status & BATTERY_TEMP_HIGH) != 0;
|
||||||
|
a->battery.cycles_exceeded = (status & BATTERY_CYCLES_EXCEEDED) != 0;
|
||||||
|
switch (status & BATTERY_CHARGE_MASK)
|
||||||
|
{
|
||||||
|
case BATTERY_CHARGE_FAIL: a->battery.charger_state = ChargerStateFailed; break;
|
||||||
|
case BATTERY_CHARGE_DONE: a->battery.charger_state = ChargerStateComplete; break;
|
||||||
|
case BATTERY_CHARGE_INPROG: a->battery.charger_state = ChargerStateInProgress; break;
|
||||||
|
default: a->battery.charger_state = ChargerStateUnknown; break;
|
||||||
|
}
|
||||||
|
a->battery.voltage = -1;
|
||||||
|
a->battery.temperature = -1;
|
||||||
|
a->battery.healthy = !(a->battery.module_missing || a->battery.pack_missing || a->battery.low_voltage || a->battery.high_temperature || a->battery.cycles_exceeded || (a->battery.charger_state != ChargerStateComplete));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void batteryStatus5 (struct adapter_config *a)
|
||||||
|
{
|
||||||
|
struct mega_battery_state_sas *b = &a->q.v5.battery.state;
|
||||||
|
|
||||||
|
a->battery.module_missing = !(a->q.v5.adapinfo.hw_present.bbu);
|
||||||
|
a->battery.pack_missing = b->type == MEGA_BATTERY_TYPE_NONE;
|
||||||
|
a->battery.low_voltage = b->remaining_capacity_alarm || b->remaining_time_alarm || b->fully_discharged;
|
||||||
|
a->battery.high_temperature = b->over_temperature != 0;
|
||||||
|
a->battery.over_charged = b->over_charged != 0;
|
||||||
|
switch (b->charger_status)
|
||||||
|
{
|
||||||
|
case 0: a->battery.charger_state = ChargerStateFailed; break;
|
||||||
|
case 1: a->battery.charger_state = ChargerStateComplete; break;
|
||||||
|
case 2: a->battery.charger_state = ChargerStateInProgress; break;
|
||||||
|
default: a->battery.charger_state = ChargerStateUnknown; break;
|
||||||
|
}
|
||||||
|
a->battery.voltage = b->voltage;
|
||||||
|
a->battery.temperature = b->temperature;
|
||||||
|
a->battery.healthy = !(a->battery.module_missing || a->battery.pack_missing || a->battery.low_voltage || a->battery.high_temperature || a->battery.cycles_exceeded || (a->battery.charger_state != ChargerStateComplete) || (!b->health));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct log_page_list *getPage (struct physical_drive_info *d, uint8_t page)
|
||||||
|
{
|
||||||
|
struct log_page_list *p;
|
||||||
|
|
||||||
|
if ((p = (struct log_page_list *) malloc (sizeof (*p))) == NULL)
|
||||||
|
return NULL;
|
||||||
|
memset (p, 0, sizeof (*p));
|
||||||
|
|
||||||
|
if (megaScsiLogSense (&d->adapter->target, d->target, &p->buf, sizeof (p->buf), 1, page, 0) < 0)
|
||||||
|
{
|
||||||
|
free (p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseLogPage (&p->buf, sizeof (p->buf), &p->log) < 0)
|
||||||
|
{
|
||||||
|
free (p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct log_page_list *getDriveLogPage (struct physical_drive_info *d, uint8_t page)
|
||||||
|
{
|
||||||
|
struct supportedLogsPage *supported = NULL;
|
||||||
|
struct log_page_list *p;
|
||||||
|
|
||||||
|
for (p = d->log; p; p = p->next)
|
||||||
|
{
|
||||||
|
if (p->log.h.page_code == page)
|
||||||
|
return p;
|
||||||
|
if (p->log.h.page_code == 0)
|
||||||
|
supported = &p->log.u.supported;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supported == NULL)
|
||||||
|
{
|
||||||
|
if ((p = getPage (d, 0)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
p->next = d->log;
|
||||||
|
d->log = p;
|
||||||
|
if (page == 0)
|
||||||
|
return p;
|
||||||
|
|
||||||
|
supported = &p->log.u.supported;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Is the requested page supported? */
|
||||||
|
if (supported->page[page] == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ((p = getPage (d, page)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
p->next = d->log;
|
||||||
|
d->log = p;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int cmpPhysical (const void *a, const void *b)
|
||||||
|
{
|
||||||
|
struct physical_drive_info *x = *((struct physical_drive_info **) a);
|
||||||
|
struct physical_drive_info *y = *((struct physical_drive_info **) b);
|
||||||
|
|
||||||
|
if (x->adapter->target.adapno != y->adapter->target.adapno)
|
||||||
|
return (int) (x->adapter->target.adapno) - (int) (y->adapter->target.adapno);
|
||||||
|
if (x->channel != y->channel)
|
||||||
|
return (int) (x->channel) - (int) (y->channel);
|
||||||
|
if (x->id != y->id)
|
||||||
|
return (int) (x->id) - (int) (y->id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct physical_drive_info *getPhysicalDriveInfo (struct adapter_config *a, uint16_t target, int fetch)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
struct physical_drive_info *d;
|
||||||
|
|
||||||
|
/* Look for it. */
|
||||||
|
for (k = 0, d = a->physical; k < a->num_physicals; ++k, ++d)
|
||||||
|
{
|
||||||
|
if (d->adapter == NULL)
|
||||||
|
break;
|
||||||
|
if (d->target == target)
|
||||||
|
return d->present ? d : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Not there and no place for it. That's just wrong. */
|
||||||
|
if (k >= a->num_physicals)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "me so crazy, me think adapter crazy too. sorry, mister.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we don't want to query it, we're done. */
|
||||||
|
if (!fetch)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
d->adapter = a;
|
||||||
|
d->target = target;
|
||||||
|
|
||||||
|
if (a->is_sas)
|
||||||
|
{
|
||||||
|
struct mega_physical_disk_info_sas *info = &d->q.v5.info;
|
||||||
|
|
||||||
|
if (megaSasGetDiskInfo (&a->target, target, info) < 0)
|
||||||
|
{
|
||||||
|
d->error_string = megaErrorString ();
|
||||||
|
d->present = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->channel = info->enclosure;
|
||||||
|
d->id = info->slot;
|
||||||
|
|
||||||
|
snprintf (d->name, sizeof (d->name), "%se%us%u", a->name, d->channel, d->id);
|
||||||
|
|
||||||
|
d->inquiry = info->inquiry.inq;
|
||||||
|
strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1);
|
||||||
|
d->vendor[sizeof (d->vendor) - 1] = '\0';
|
||||||
|
ntrim (d->vendor);
|
||||||
|
strncpy (d->model, d->inquiry.prod_ident, sizeof (d->model) - 1);
|
||||||
|
d->model[sizeof (d->model) - 1] = '\0';
|
||||||
|
ntrim (d->model);
|
||||||
|
strncpy (d->revision, d->inquiry.prod_revision, sizeof (d->revision) - 1);
|
||||||
|
d->revision[sizeof (d->revision) - 1] = '\0';
|
||||||
|
ntrim (d->revision);
|
||||||
|
|
||||||
|
if ((d->inquiry.qualifier == INQ_DEV_PRESENT) && (d->inquiry.type == INQ_DASD))
|
||||||
|
{
|
||||||
|
d->present = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d->present = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy (d->serial, (char *) info->inquiry.buf + sizeof (info->inquiry.inq), sizeof (d->serial));
|
||||||
|
d->serial[sizeof (d->serial) - 1] = '\0';
|
||||||
|
ntrim (d->serial);
|
||||||
|
|
||||||
|
if (info->configured)
|
||||||
|
{
|
||||||
|
if (info->online)
|
||||||
|
d->state = PdStateOnline;
|
||||||
|
else if (info->rebuild)
|
||||||
|
d->state = PdStateRebuild;
|
||||||
|
else if (info->failure)
|
||||||
|
d->state = PdStateFailed;
|
||||||
|
else
|
||||||
|
d->state = PdStateUnknown;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (info->hotspare)
|
||||||
|
d->state = PdStateHotspare;
|
||||||
|
else if (info->failure)
|
||||||
|
d->state = PdStateUnconfiguredBad;
|
||||||
|
else
|
||||||
|
d->state = PdStateUnconfiguredGood;
|
||||||
|
}
|
||||||
|
d->blocks = info->raw_size;
|
||||||
|
d->media_errors = info->media_errors;
|
||||||
|
d->other_errors = info->other_errors;
|
||||||
|
d->predictive_failures = info->predictive_failures;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
struct scsi_inquiry inq;
|
||||||
|
uint8_t evpd[128];
|
||||||
|
struct mega_physical_drive_error_info errors;
|
||||||
|
|
||||||
|
d->channel = (target >> 4) & 0xf;
|
||||||
|
d->id = target & 0xf;
|
||||||
|
|
||||||
|
snprintf (d->name, sizeof (d->name), "%sc%ut%u", a->name, d->channel, d->id);
|
||||||
|
|
||||||
|
if (megaScsiDriveInquiry (&a->target, target, &inq, sizeof (inq), 0, 0) == 0)
|
||||||
|
{
|
||||||
|
d->inquiry = inq;
|
||||||
|
strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1);
|
||||||
|
d->vendor[sizeof (d->vendor) - 1] = '\0';
|
||||||
|
ntrim (d->vendor);
|
||||||
|
strncpy (d->model, d->inquiry.prod_ident, sizeof (d->model) - 1);
|
||||||
|
d->model[sizeof (d->model) - 1] = '\0';
|
||||||
|
ntrim (d->model);
|
||||||
|
strncpy (d->revision, d->inquiry.prod_revision, sizeof (d->revision) - 1);
|
||||||
|
d->revision[sizeof (d->revision) - 1] = '\0';
|
||||||
|
ntrim (d->revision);
|
||||||
|
|
||||||
|
if ((d->inquiry.qualifier == INQ_DEV_PRESENT) && (d->inquiry.type == INQ_DASD))
|
||||||
|
{
|
||||||
|
d->present = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d->present = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d->error_string = megaErrorString ();
|
||||||
|
d->present = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (megaScsiDriveInquiry (&a->target, target, evpd, sizeof evpd, 0x80, 1) == 0)
|
||||||
|
{
|
||||||
|
uint8_t len = evpd[3];
|
||||||
|
|
||||||
|
if ((evpd[1] == 0x80) && (len + 4 <= sizeof evpd))
|
||||||
|
{
|
||||||
|
if (len > sizeof (d->serial) - 1)
|
||||||
|
len = sizeof (d->serial) - 1;
|
||||||
|
strncpy (d->serial, (char *) evpd + 4, len);
|
||||||
|
d->serial[len] = '\0';
|
||||||
|
ntrim (d->serial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((status = megaGetDriveErrorCount (&a->target, target, &errors)) == 0)
|
||||||
|
{
|
||||||
|
d->media_errors = errors.media;
|
||||||
|
d->other_errors = errors.other;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
d->error_string = megaErrorString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add it to the device list and sort it. */
|
||||||
|
for (k = 0; k < a->num_physicals; ++k)
|
||||||
|
if (a->physical_list[k] == NULL)
|
||||||
|
break;
|
||||||
|
if (k >= a->num_physicals)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "not ok at the ok corral. freak out, mama!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
a->physical_list[k++] = d;
|
||||||
|
qsort (a->physical_list, k, sizeof (*a->physical_list), cmpPhysical);
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Adapter handling for PERC2. */
|
||||||
|
static char *getAdapterConfig2 (struct adapter_config *a)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
logdrv_8ld_span8_t *ml;
|
||||||
|
int spanIndex;
|
||||||
|
mraid_adapinfo1_t *pinfo = &a->q.v2.inquiry.adapter_info;
|
||||||
|
mraid_inquiry1_t *inquiry = &a->q.v2.inquiry;
|
||||||
|
disk_array_8ld_span8_t *config = &a->q.v2.config;
|
||||||
|
|
||||||
|
a->target.type = MEGA_ADAPTER_V2;
|
||||||
|
|
||||||
|
if (megaGetAdapterInquiry (&a->target, inquiry) < 0)
|
||||||
|
return "cannot query adapter";
|
||||||
|
if (megaGetAdapterConfig8 (&a->target, config) < 0)
|
||||||
|
return "cannot read adapter config";
|
||||||
|
if (megaGetPredictiveMap (&a->target, &a->q.v2.map) < 0)
|
||||||
|
return "cannot read adapter predictive map";
|
||||||
|
|
||||||
|
a->rebuild_rate = pinfo->rebuild_rate;
|
||||||
|
a->dram_size = pinfo->dram_size;
|
||||||
|
|
||||||
|
snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno);
|
||||||
|
strcpy (a->product, "PERC2/");
|
||||||
|
switch (pinfo->nchannels)
|
||||||
|
{
|
||||||
|
case 1: strcat (a->product, "SC"); break;
|
||||||
|
case 2: strcat (a->product, "DC"); break;
|
||||||
|
case 4: strcat (a->product, "QC"); break;
|
||||||
|
default: return "invalid number of channels";
|
||||||
|
}
|
||||||
|
strncpy (a->bios, (char *) pinfo->bios_version, sizeof (a->bios));
|
||||||
|
a->bios[sizeof (a->bios) - 1] = '\0';
|
||||||
|
ntrim (a->bios);
|
||||||
|
strncpy (a->firmware, (char *) pinfo->fw_version, sizeof (a->firmware));
|
||||||
|
a->firmware[sizeof (a->firmware) - 1] = '\0';
|
||||||
|
ntrim (a->firmware);
|
||||||
|
|
||||||
|
batteryStatus (a, pinfo->battery_status);
|
||||||
|
|
||||||
|
if (config->numldrv > sizeof (config->ldrv) / sizeof (config->ldrv[0]))
|
||||||
|
return "invalid number of logical drives";
|
||||||
|
|
||||||
|
a->num_channels = pinfo->nchannels;
|
||||||
|
if ((a->channel = (uint8_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL)
|
||||||
|
return "out of memory (channels)";
|
||||||
|
for (k = 0; k < a->num_channels; ++k)
|
||||||
|
a->channel[k] = k;
|
||||||
|
|
||||||
|
a->num_physicals = FC_MAX_PHYSICAL_DEVICES;
|
||||||
|
if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
|
||||||
|
return "out of memory (physical drives)";
|
||||||
|
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));
|
||||||
|
if ((a->physical_list = (struct physical_drive_info **) malloc (a->num_physicals * sizeof (*a->physical_list))) == NULL)
|
||||||
|
return "out of memory (physical drives)";
|
||||||
|
memset (a->physical_list, 0, a->num_physicals * sizeof (*a->physical_list));
|
||||||
|
|
||||||
|
a->num_logicals = config->numldrv;
|
||||||
|
if ((a->logical = (struct logical_drive_info *) malloc (a->num_logicals * sizeof (*a->logical))) == NULL)
|
||||||
|
return "out of memory (logical drives)";
|
||||||
|
memset (a->logical, 0, a->num_logicals * sizeof (*a->logical));
|
||||||
|
|
||||||
|
/* Count how many spans there are. */
|
||||||
|
for (k = 0, ml = config->ldrv, a->num_spans = 0; k < config->numldrv; ++k, ++ml)
|
||||||
|
a->num_spans += ml->lparam.span_depth;
|
||||||
|
|
||||||
|
if ((a->span = (struct span_info *) malloc (a->num_spans * sizeof (*a->span))) == NULL)
|
||||||
|
return "out of memory (spans)";
|
||||||
|
memset (a->span, 0, a->num_spans * sizeof (*a->span));
|
||||||
|
|
||||||
|
/* Copy drive states. */
|
||||||
|
for (k = 0; k < sizeof (inquiry->pdrv_info.pdrv_state) / sizeof (inquiry->pdrv_info.pdrv_state[0]); ++k)
|
||||||
|
switch (inquiry->pdrv_info.pdrv_state[k] & 0xf)
|
||||||
|
{
|
||||||
|
case PDRV_UNCNF: a->physical[k].state = PdStateUnconfiguredGood; continue;
|
||||||
|
case PDRV_ONLINE: a->physical[k].state = PdStateOnline; continue;
|
||||||
|
case PDRV_FAILED: a->physical[k].state = PdStateFailed; continue;
|
||||||
|
case PDRV_RBLD: a->physical[k].state = PdStateRebuild; continue;
|
||||||
|
case PDRV_HOTSPARE: a->physical[k].state = PdStateHotspare; continue;
|
||||||
|
default: a->physical[k].state = PdStateUnknown; continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy drive sizes. */
|
||||||
|
for (k = 0; k < sizeof (config->pdrv) / sizeof (config->pdrv[0]); ++k)
|
||||||
|
a->physical[k].blocks = config->pdrv[k].size;
|
||||||
|
|
||||||
|
/* Copy drive predictive failures flag */
|
||||||
|
for (k = 0; k < 8 * sizeof (a->q.v2.map.map) / sizeof (a->q.v2.map.map[0]); ++k)
|
||||||
|
a->physical[k].predictive_failures = ((a->q.v2.map.map[k >> 3] & (1 << (k & 0x7))) != 0);
|
||||||
|
|
||||||
|
/* Examine all the logical drives. */
|
||||||
|
for (k = 0, ml = config->ldrv, spanIndex = 0; k < config->numldrv; ++k, ++ml)
|
||||||
|
{
|
||||||
|
struct span_info *span;
|
||||||
|
adap_span_8ld_t *mr;
|
||||||
|
int j;
|
||||||
|
struct logical_drive_info *l = &a->logical[k];
|
||||||
|
|
||||||
|
l->adapter = a;
|
||||||
|
snprintf (l->name, sizeof (l->name), "a%ud%u", a->target.adapno, k);
|
||||||
|
l->target = k;
|
||||||
|
switch (ml->lparam.status)
|
||||||
|
{
|
||||||
|
case RDRV_OFFLINE: l->state = LdStateOffline; break;
|
||||||
|
case RDRV_DEGRADED: l->state = LdStateDegraded; break;
|
||||||
|
case RDRV_OPTIMAL: l->state = LdStateOptimal; break;
|
||||||
|
case RDRV_DELETED: l->state = LdStateDeleted; break;
|
||||||
|
default: l->state = LdStateUnknown; break;
|
||||||
|
}
|
||||||
|
l->raid_level = ml->lparam.level;
|
||||||
|
l->span_size = ml->lparam.row_size;
|
||||||
|
|
||||||
|
l->num_spans = ml->lparam.span_depth;
|
||||||
|
if ((l->span = (struct span_reference *) malloc (l->num_spans * sizeof (*l->span))) == NULL)
|
||||||
|
return "out of memory (span references)";
|
||||||
|
|
||||||
|
for (j = 0, mr = ml->span; j < ml->lparam.span_depth; ++j, ++mr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
span = &a->span[spanIndex++];
|
||||||
|
span->adapter = a;
|
||||||
|
span->num_logical_drives = 1;
|
||||||
|
if ((span->logical_drive = (struct logical_drive_info **) malloc (span->num_logical_drives * sizeof (*span->logical_drive))) == NULL)
|
||||||
|
return "out of memory (span -> ldrv pointers)";
|
||||||
|
span->logical_drive[0] = l;
|
||||||
|
span->blocks_per_disk = mr->num_blks;
|
||||||
|
span->num_disks = ml->lparam.row_size;
|
||||||
|
if ((span->disk = (struct physical_drive_info **) malloc (span->num_disks * sizeof (*span->disk))) == NULL)
|
||||||
|
return "out of memory (span -> disk pointers)";
|
||||||
|
|
||||||
|
/* Logical drives use the whole span. */
|
||||||
|
l->span[j].offset = 0;
|
||||||
|
l->span[j].blocks_per_disk = span->blocks_per_disk;
|
||||||
|
l->span[j].span = span;
|
||||||
|
|
||||||
|
for (i = 0; i < span->num_disks; ++i)
|
||||||
|
{
|
||||||
|
span->disk[i] = &a->physical[mr->device[i].target];
|
||||||
|
span->disk[i]->span = span;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Adapter handling for PERC3 and PERC4 adapters. */
|
||||||
|
static char *getAdapterConfig3 (struct adapter_config *a)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
logdrv_40ld_t *ml;
|
||||||
|
int spanIndex;
|
||||||
|
mraid_pinfo_t *pinfo = &a->q.v3.adapinfo;
|
||||||
|
mraid_inquiry3_t *enquiry3 = &a->q.v3.enquiry3;
|
||||||
|
disk_array_40ld_t *config = &a->q.v3.config;
|
||||||
|
|
||||||
|
a->target.type = MEGA_ADAPTER_V34;
|
||||||
|
|
||||||
|
if (megaGetAdapterEnquiry3 (&a->target, &a->q.v3.enquiry3) < 0)
|
||||||
|
return "cannot query adapter";
|
||||||
|
if (megaGetAdapterConfig40 (&a->target, config) < 0)
|
||||||
|
return "cannot read adapter config";
|
||||||
|
if (megaGetPredictiveMap (&a->target, &a->q.v3.map) < 0)
|
||||||
|
return "cannot read adapter predictive map";
|
||||||
|
|
||||||
|
a->rebuild_rate = enquiry3->rebuild_rate;
|
||||||
|
a->dram_size = pinfo->dram_size;
|
||||||
|
|
||||||
|
snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno);
|
||||||
|
switch (pinfo->nchannels)
|
||||||
|
{
|
||||||
|
case 1: break;
|
||||||
|
case 2: break;
|
||||||
|
case 4: break;
|
||||||
|
default: return "invalid number of channels";
|
||||||
|
}
|
||||||
|
strncpy (a->product, (char *) pinfo->product_name, sizeof (pinfo->product_name));
|
||||||
|
a->product[sizeof (a->product) - 1] = '\0';
|
||||||
|
ntrim (a->product);
|
||||||
|
strncpy (a->bios, (char *) pinfo->bios_version, sizeof (a->bios));
|
||||||
|
a->bios[sizeof (a->bios) - 1] = '\0';
|
||||||
|
ntrim (a->bios);
|
||||||
|
strncpy (a->firmware, (char *) pinfo->fw_version, sizeof (a->firmware));
|
||||||
|
a->firmware[sizeof (a->firmware) - 1] = '\0';
|
||||||
|
ntrim (a->firmware);
|
||||||
|
|
||||||
|
batteryStatus (a, enquiry3->battery_status);
|
||||||
|
|
||||||
|
if (config->numldrv > sizeof (config->ldrv) / sizeof (config->ldrv[0]))
|
||||||
|
return "invalid number of logical drives";
|
||||||
|
|
||||||
|
a->num_channels = pinfo->nchannels;
|
||||||
|
if ((a->channel = (uint8_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL)
|
||||||
|
return "out of memory (channels)";
|
||||||
|
for (k = 0; k < a->num_channels; ++k)
|
||||||
|
a->channel[k] = k;
|
||||||
|
|
||||||
|
a->num_physicals = FC_MAX_PHYSICAL_DEVICES;
|
||||||
|
if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
|
||||||
|
return "out of memory (physical drives)";
|
||||||
|
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));
|
||||||
|
if ((a->physical_list = (struct physical_drive_info **) malloc (a->num_physicals * sizeof (*a->physical_list))) == NULL)
|
||||||
|
return "out of memory (physical drives)";
|
||||||
|
memset (a->physical_list, 0, a->num_physicals * sizeof (*a->physical_list));
|
||||||
|
|
||||||
|
a->num_logicals = config->numldrv;
|
||||||
|
if ((a->logical = (struct logical_drive_info *) malloc (a->num_logicals * sizeof (*a->logical))) == NULL)
|
||||||
|
return "out of memory (logical drives)";
|
||||||
|
memset (a->logical, 0, a->num_logicals * sizeof (*a->logical));
|
||||||
|
|
||||||
|
/* Count how many spans there are. */
|
||||||
|
for (k = 0, ml = config->ldrv, a->num_spans = 0; k < config->numldrv; ++k, ++ml)
|
||||||
|
a->num_spans += ml->lparam.span_depth;
|
||||||
|
|
||||||
|
if ((a->span = (struct span_info *) malloc (a->num_spans * sizeof (*a->span))) == NULL)
|
||||||
|
return "out of memory (spans)";
|
||||||
|
memset (a->span, 0, a->num_spans * sizeof (*a->span));
|
||||||
|
|
||||||
|
/* Copy drive states. */
|
||||||
|
for (k = 0; k < sizeof (enquiry3->pdrv_state) / sizeof (enquiry3->pdrv_state[0]); ++k)
|
||||||
|
switch (enquiry3->pdrv_state[k] & 0xf)
|
||||||
|
{
|
||||||
|
case PDRV_UNCNF: a->physical[k].state = PdStateUnconfiguredGood; continue;
|
||||||
|
case PDRV_ONLINE: a->physical[k].state = PdStateOnline; continue;
|
||||||
|
case PDRV_FAILED: a->physical[k].state = PdStateFailed; continue;
|
||||||
|
case PDRV_RBLD: a->physical[k].state = PdStateRebuild; continue;
|
||||||
|
case PDRV_HOTSPARE: a->physical[k].state = PdStateHotspare; continue;
|
||||||
|
default: a->physical[k].state = PdStateUnknown; continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy drive sizes. */
|
||||||
|
for (k = 0; k < sizeof (config->pdrv) / sizeof (config->pdrv[0]); ++k)
|
||||||
|
a->physical[k].blocks = config->pdrv[k].size;
|
||||||
|
|
||||||
|
/* Copy drive predictive failures flag */
|
||||||
|
for (k = 0; k < 8 * sizeof (a->q.v3.map.map) / sizeof (a->q.v3.map.map[0]); ++k)
|
||||||
|
a->physical[k].predictive_failures = ((a->q.v3.map.map[k >> 3] & (1 << (k & 0x7))) != 0);
|
||||||
|
|
||||||
|
/* Examine all the logical drives. */
|
||||||
|
for (k = 0, ml = config->ldrv, spanIndex = 0; k < config->numldrv; ++k, ++ml)
|
||||||
|
{
|
||||||
|
struct span_info *span;
|
||||||
|
adap_span_40ld_t *mr;
|
||||||
|
int j;
|
||||||
|
struct logical_drive_info *l = &a->logical[k];
|
||||||
|
|
||||||
|
l->adapter = a;
|
||||||
|
snprintf (l->name, sizeof (l->name), "a%ud%u", a->target.adapno, k);
|
||||||
|
l->target = k;
|
||||||
|
switch (ml->lparam.status)
|
||||||
|
{
|
||||||
|
case RDRV_OFFLINE: l->state = LdStateOffline; break;
|
||||||
|
case RDRV_DEGRADED: l->state = LdStateDegraded; break;
|
||||||
|
case RDRV_OPTIMAL: l->state = LdStateOptimal; break;
|
||||||
|
case RDRV_DELETED: l->state = LdStateDeleted; break;
|
||||||
|
default: l->state = LdStateUnknown; break;
|
||||||
|
}
|
||||||
|
l->raid_level = ml->lparam.level;
|
||||||
|
l->span_size = ml->lparam.row_size;
|
||||||
|
|
||||||
|
l->num_spans = ml->lparam.span_depth;
|
||||||
|
if ((l->span = (struct span_reference *) malloc (l->num_spans * sizeof (*l->span))) == NULL)
|
||||||
|
return "out of memory (span references)";
|
||||||
|
|
||||||
|
for (j = 0, mr = ml->span; j < ml->lparam.span_depth; ++j, ++mr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
span = &a->span[spanIndex++];
|
||||||
|
span->adapter = a;
|
||||||
|
span->num_logical_drives = 1;
|
||||||
|
if ((span->logical_drive = (struct logical_drive_info **) malloc (span->num_logical_drives * sizeof (*span->logical_drive))) == NULL)
|
||||||
|
return "out of memory (span -> ldrv pointers)";
|
||||||
|
span->logical_drive[0] = l;
|
||||||
|
span->blocks_per_disk = mr->num_blks;
|
||||||
|
span->num_disks = ml->lparam.row_size;
|
||||||
|
if ((span->disk = (struct physical_drive_info **) malloc (span->num_disks * sizeof (*span->disk))) == NULL)
|
||||||
|
return "out of memory (span -> disk pointers)";
|
||||||
|
|
||||||
|
/* Logical drives use the whole span. */
|
||||||
|
l->span[j].offset = 0;
|
||||||
|
l->span[j].blocks_per_disk = span->blocks_per_disk;
|
||||||
|
l->span[j].span = span;
|
||||||
|
|
||||||
|
for (i = 0; i < span->num_disks; ++i)
|
||||||
|
{
|
||||||
|
span->disk[i] = &a->physical[mr->device[i].target];
|
||||||
|
span->disk[i]->span = span;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Go ahead and hit all the other devices that have a non-zero scsi transfer rate. */
|
||||||
|
for (k = 0; k < sizeof (a->q.v3.enquiry3.targ_xfer) / sizeof (a->q.v3.enquiry3.targ_xfer[0]); ++k)
|
||||||
|
if (a->q.v3.enquiry3.targ_xfer[k])
|
||||||
|
(void) getPhysicalDriveInfo (a, (uint8_t) k, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int cmpChannel (const void *a, const void *b)
|
||||||
|
{
|
||||||
|
int x = (int) *((uint8_t *) a);
|
||||||
|
int y = (int) *((uint8_t *) b);
|
||||||
|
return x - y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adapter handling for PERC5 adapters. */
|
||||||
|
static char *getAdapterConfig5 (struct adapter_config *a)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
struct mega_array_span_def_sas *ms;
|
||||||
|
struct mega_array_disk_def_sas *ml;
|
||||||
|
struct megasas_ctrl_info *pinfo = &a->q.v5.adapinfo;
|
||||||
|
struct mega_device_list_sas *device;
|
||||||
|
struct mega_array_config_sas *config = &a->q.v5.config;
|
||||||
|
|
||||||
|
a->target.type = MEGA_ADAPTER_V5;
|
||||||
|
|
||||||
|
if (megaSasGetDeviceList (&a->target, &(a->q.v5.device)) < 0)
|
||||||
|
return "cannot retrieve device list";
|
||||||
|
device = a->q.v5.device;
|
||||||
|
if (megaSasGetArrayConfig (&a->target, &(a->q.v5.config)) < 0)
|
||||||
|
return "cannot retrieve array configuration";
|
||||||
|
if (megaSasGetBatteryInfo (&a->target, &(a->q.v5.battery)) < 0)
|
||||||
|
return "cannot retrieve battery info";
|
||||||
|
|
||||||
|
a->rebuild_rate = pinfo->properties.rebuild_rate;
|
||||||
|
a->dram_size = pinfo->memory_size;
|
||||||
|
|
||||||
|
snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno);
|
||||||
|
strncpy (a->product, (char *) pinfo->product_name, sizeof (pinfo->product_name));
|
||||||
|
a->product[sizeof (a->product) - 1] = '\0';
|
||||||
|
ntrim (a->product);
|
||||||
|
|
||||||
|
for (k = 0; k < pinfo->image_component_count; ++k)
|
||||||
|
{
|
||||||
|
if (!strcmp (pinfo->image_component[k].name, "BIOS"))
|
||||||
|
{
|
||||||
|
strncpy (a->bios, pinfo->image_component[k].version, sizeof (a->bios));
|
||||||
|
a->bios[sizeof (a->bios) - 1] = '\0';
|
||||||
|
ntrim (a->bios);
|
||||||
|
}
|
||||||
|
else if (!strcmp (pinfo->image_component[k].name, "APP "))
|
||||||
|
{
|
||||||
|
strncpy (a->firmware, pinfo->image_component[k].version, sizeof (a->firmware));
|
||||||
|
a->firmware[sizeof (a->firmware) - 1] = '\0';
|
||||||
|
ntrim (a->firmware);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
batteryStatus5 (a);
|
||||||
|
|
||||||
|
/* Build enclosure map. */
|
||||||
|
for (k = 0, a->num_channels = 0, a->channel = NULL; k < device->num_devices; ++k)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (j = 0; j < a->num_channels; ++j)
|
||||||
|
if (device->device[k].enclosure == a->channel[j])
|
||||||
|
break;
|
||||||
|
if (j < a->num_channels)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Didn't find this enclosure; extend the map */
|
||||||
|
++a->num_channels;
|
||||||
|
if ((a->channel = (uint8_t *) realloc (a->channel, a->num_channels * sizeof (*a->channel))) == NULL)
|
||||||
|
return "out of memory (channels)";
|
||||||
|
a->channel[a->num_channels - 1] = device->device[k].enclosure;
|
||||||
|
}
|
||||||
|
qsort (a->channel, a->num_channels, sizeof (*a->channel), cmpChannel);
|
||||||
|
|
||||||
|
a->num_physicals = pinfo->pd_present_count;
|
||||||
|
if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
|
||||||
|
return "out of memory (physical drives)";
|
||||||
|
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));
|
||||||
|
if ((a->physical_list = (struct physical_drive_info **) malloc (a->num_physicals * sizeof (*a->physical_list))) == NULL)
|
||||||
|
return "out of memory (physical drives)";
|
||||||
|
memset (a->physical_list, 0, a->num_physicals * sizeof (*a->physical_list));
|
||||||
|
|
||||||
|
a->num_logicals = config->header->num_disk_defs;
|
||||||
|
if ((a->logical = (struct logical_drive_info *) malloc (a->num_logicals * sizeof (*a->logical))) == NULL)
|
||||||
|
return "out of memory (logical drives)";
|
||||||
|
memset (a->logical, 0, a->num_logicals * sizeof (*a->logical));
|
||||||
|
|
||||||
|
a->num_spans = config->header->num_span_defs;
|
||||||
|
if ((a->span = (struct span_info *) malloc (a->num_spans * sizeof (*a->span))) == NULL)
|
||||||
|
return "out of memory (spans)";
|
||||||
|
memset (a->span, 0, a->num_spans * sizeof (*a->span));
|
||||||
|
|
||||||
|
/* Get drive info. (This is fast on a PERC5.) */
|
||||||
|
for (k = 0; k < device->num_devices; ++k)
|
||||||
|
if ((device->device[k].type == INQ_DASD) && (getPhysicalDriveInfo (a, device->device[k].device_id, 1) == NULL))
|
||||||
|
return "cannot get physical device info";
|
||||||
|
|
||||||
|
/* Examine all the spans. */
|
||||||
|
for (k = 0, ms = config->span; k < config->header->num_span_defs; ++k, ++ms)
|
||||||
|
{
|
||||||
|
struct span_info *span = &a->span[k];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
span->adapter = a;
|
||||||
|
span->num_logical_drives = 0;
|
||||||
|
span->logical_drive = NULL;
|
||||||
|
span->blocks_per_disk = ms->sectors_per_disk;
|
||||||
|
span->num_disks = ms->span_size;
|
||||||
|
if ((span->disk = (struct physical_drive_info **) malloc (span->num_disks * sizeof (*span->disk))) == NULL)
|
||||||
|
return "out of memory (span -> disk pointers)";
|
||||||
|
|
||||||
|
for (i = 0; i < span->num_disks; ++i)
|
||||||
|
{
|
||||||
|
span->disk[i] = getPhysicalDriveInfo (a, ms->disk[i].device_id, 1);
|
||||||
|
span->disk[i]->span = span;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Examine all the logical drives. */
|
||||||
|
for (k = 0, ml = config->disk; k < config->header->num_disk_defs; ++k, ++ml)
|
||||||
|
{
|
||||||
|
struct span_info *span;
|
||||||
|
struct mega_array_disk_entry_sas *mr;
|
||||||
|
int j;
|
||||||
|
struct logical_drive_info *l = &a->logical[k];
|
||||||
|
|
||||||
|
l->adapter = a;
|
||||||
|
snprintf (l->name, sizeof (l->name), "a%ud%u", a->target.adapno, k);
|
||||||
|
l->target = k;
|
||||||
|
switch (ml->state)
|
||||||
|
{
|
||||||
|
case MEGA_SAS_LD_OFFLINE: l->state = LdStateOffline; break;
|
||||||
|
case MEGA_SAS_LD_PARTIALLY_DEGRADED: l->state = LdStatePartiallyDegraded; break;
|
||||||
|
case MEGA_SAS_LD_DEGRADED: l->state = LdStateDegraded; break;
|
||||||
|
case MEGA_SAS_LD_OPTIMAL: l->state = LdStateOptimal; break;
|
||||||
|
default: l->state = LdStateUnknown; break;
|
||||||
|
}
|
||||||
|
l->raid_level = ml->raid_level;
|
||||||
|
l->span_size = ml->disks_per_span;
|
||||||
|
|
||||||
|
l->num_spans = ml->num_spans;
|
||||||
|
if ((l->span = (struct span_reference *) malloc (l->num_spans * sizeof (*l->span))) == NULL)
|
||||||
|
return "out of memory (span references)";
|
||||||
|
|
||||||
|
for (j = 0, mr = ml->span; j < ml->num_spans; ++j, ++mr)
|
||||||
|
{
|
||||||
|
span = &a->span[mr->span_index];
|
||||||
|
++(span->num_logical_drives);
|
||||||
|
if ((span->logical_drive = (struct logical_drive_info **) realloc (span->logical_drive, span->num_logical_drives * sizeof (*span->logical_drive))) == NULL)
|
||||||
|
return "out of memory (span -> ldrv pointers)";
|
||||||
|
span->logical_drive[span->num_logical_drives - 1] = l;
|
||||||
|
|
||||||
|
l->span[j].offset = mr->offset;
|
||||||
|
l->span[j].blocks_per_disk = mr->sectors_per_disk;
|
||||||
|
l->span[j].span = span;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct adapter_config *getAdapterConfig (int fd, uint8_t adapno, int sas)
|
||||||
|
{
|
||||||
|
static struct adapter_config *cf = NULL;
|
||||||
|
struct adapter_config *a;
|
||||||
|
char *status;
|
||||||
|
|
||||||
|
for (a = cf; a; a = a->next)
|
||||||
|
if ((a->target.adapno == adapno) && (a->is_sas == sas))
|
||||||
|
return a;
|
||||||
|
|
||||||
|
if ((a = (struct adapter_config *) malloc (sizeof (*a))) == NULL)
|
||||||
|
return NULL;
|
||||||
|
memset (a, 0, sizeof (*a));
|
||||||
|
|
||||||
|
a->target.fd = fd;
|
||||||
|
a->target.adapno = adapno;
|
||||||
|
a->is_sas = sas;
|
||||||
|
|
||||||
|
if (sas)
|
||||||
|
{
|
||||||
|
if (megaSasGetAdapterProductInfo (fd, adapno, &a->q.v5.adapinfo) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
status = getAdapterConfig5 (a);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mraid_pinfo_t pinfo;
|
||||||
|
|
||||||
|
if (megaGetAdapterProductInfo (fd, adapno, &pinfo) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (pinfo.data_size == 0)
|
||||||
|
status = getAdapterConfig2 (a);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a->q.v3.adapinfo = pinfo;
|
||||||
|
status = getAdapterConfig3 (a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
free (a);
|
||||||
|
fprintf (stderr, "adapter %d: %s\n", adapno, status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
a->next = cf;
|
||||||
|
cf = a;
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
34
src/adapter.h
Normal file
34
src/adapter.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef _ADAPTER_H
|
||||||
|
#define _ADAPTER_H
|
||||||
|
/*
|
||||||
|
* Definitions for high-level adapter interface.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "mega.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
struct log_page_list *getDriveLogPage (struct physical_drive_info *d, uint8_t page);
|
||||||
|
struct physical_drive_info *getPhysicalDriveInfo (struct adapter_config *cf, uint16_t target, int fetch);
|
||||||
|
struct adapter_config *getAdapterConfig (int fd, uint8_t adapno, int sas);
|
||||||
|
|
||||||
|
#endif
|
413
src/callinfo.c
Normal file
413
src/callinfo.c
Normal file
@ -0,0 +1,413 @@
|
|||||||
|
/*
|
||||||
|
* Sysctl call data for ptrace(2).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
|
#include "callinfo.h"
|
||||||
|
|
||||||
|
#ifndef SYS_pread
|
||||||
|
#define SYS_pread SYS_pread64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SYS_pwrite
|
||||||
|
#define SYS_pwrite SYS_pwrite64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct callinfo callinfo[] =
|
||||||
|
{
|
||||||
|
{ 0, 0, NULL },
|
||||||
|
{ SYS_exit, 0, "exit" },
|
||||||
|
{ SYS_fork, 0, "fork" },
|
||||||
|
{ SYS_read, 0, "read" },
|
||||||
|
{ SYS_write, 0, "write" },
|
||||||
|
{ SYS_open, 0, "open" },
|
||||||
|
{ SYS_close, 0, "close" },
|
||||||
|
{ SYS_waitpid, 0, "waitpid" },
|
||||||
|
{ SYS_creat, 0, "creat" },
|
||||||
|
{ SYS_link, 0, "link" },
|
||||||
|
{ SYS_unlink, 0, "unlink" },
|
||||||
|
{ SYS_execve, 0, "execve" },
|
||||||
|
{ SYS_chdir, 0, "chdir" },
|
||||||
|
{ SYS_time, 0, "time" },
|
||||||
|
{ SYS_mknod, 0, "mknod" },
|
||||||
|
{ SYS_chmod, 0, "chmod" },
|
||||||
|
{ SYS_lchown, 0, "lchown" },
|
||||||
|
{ SYS_break, 0, "break" },
|
||||||
|
{ SYS_oldstat, 0, "oldstat" },
|
||||||
|
{ SYS_lseek, 0, "lseek" },
|
||||||
|
{ SYS_getpid, 0, "getpid" },
|
||||||
|
{ SYS_mount, 0, "mount" },
|
||||||
|
{ SYS_umount, 0, "umount" },
|
||||||
|
{ SYS_setuid, 0, "setuid" },
|
||||||
|
{ SYS_getuid, 0, "getuid" },
|
||||||
|
{ SYS_stime, 0, "stime" },
|
||||||
|
{ SYS_ptrace, 1, "ptrace" },
|
||||||
|
{ SYS_alarm, 0, "alarm" },
|
||||||
|
{ SYS_oldfstat, 0, "oldfstat" },
|
||||||
|
{ SYS_pause, 0, "pause" },
|
||||||
|
{ SYS_utime, 0, "utime" },
|
||||||
|
{ SYS_stty, 0, "stty" },
|
||||||
|
{ SYS_gtty, 0, "gtty" },
|
||||||
|
{ SYS_access, 0, "access" },
|
||||||
|
{ SYS_nice, 0, "nice" },
|
||||||
|
{ SYS_ftime, 0, "ftime" },
|
||||||
|
{ SYS_sync, 0, "sync" },
|
||||||
|
{ SYS_kill, 0, "kill" },
|
||||||
|
{ SYS_rename, 0, "rename" },
|
||||||
|
{ SYS_mkdir, 0, "mkdir" },
|
||||||
|
{ SYS_rmdir, 0, "rmdir" },
|
||||||
|
{ SYS_dup, 0, "dup" },
|
||||||
|
{ SYS_pipe, 0, "pipe" },
|
||||||
|
{ SYS_times, 0, "times" },
|
||||||
|
{ SYS_prof, 0, "prof" },
|
||||||
|
{ SYS_brk, 1, "brk" },
|
||||||
|
{ SYS_setgid, 0, "setgid" },
|
||||||
|
{ SYS_getgid, 0, "getgid" },
|
||||||
|
{ SYS_signal, 0, "signal" },
|
||||||
|
{ SYS_geteuid, 0, "geteuid" },
|
||||||
|
{ SYS_getegid, 0, "getegid" },
|
||||||
|
{ SYS_acct, 0, "acct" },
|
||||||
|
{ SYS_umount2, 0, "umount2" },
|
||||||
|
{ SYS_lock, 0, "lock" },
|
||||||
|
{ SYS_ioctl, 0, "ioctl" },
|
||||||
|
{ SYS_fcntl, 0, "fcntl" },
|
||||||
|
{ SYS_mpx, 0, "mpx" },
|
||||||
|
{ SYS_setpgid, 0, "setpgid" },
|
||||||
|
{ SYS_ulimit, 0, "ulimit" },
|
||||||
|
{ SYS_oldolduname, 0, "oldolduname" },
|
||||||
|
{ SYS_umask, 0, "umask" },
|
||||||
|
{ SYS_chroot, 0, "chroot" },
|
||||||
|
{ SYS_ustat, 0, "ustat" },
|
||||||
|
{ SYS_dup2, 0, "dup2" },
|
||||||
|
{ SYS_getppid, 0, "getppid" },
|
||||||
|
{ SYS_getpgrp, 0, "getpgrp" },
|
||||||
|
{ SYS_setsid, 0, "setsid" },
|
||||||
|
{ SYS_sigaction, 0, "sigaction" },
|
||||||
|
{ SYS_sgetmask, 0, "sgetmask" },
|
||||||
|
{ SYS_ssetmask, 0, "ssetmask" },
|
||||||
|
{ SYS_setreuid, 0, "setreuid" },
|
||||||
|
{ SYS_setregid, 0, "setregid" },
|
||||||
|
{ SYS_sigsuspend, 0, "sigsuspend" },
|
||||||
|
{ SYS_sigpending, 0, "sigpending" },
|
||||||
|
{ SYS_sethostname, 0, "sethostname" },
|
||||||
|
{ SYS_setrlimit, 0, "setrlimit" },
|
||||||
|
{ SYS_getrlimit, 0, "getrlimit" },
|
||||||
|
{ SYS_getrusage, 0, "getrusage" },
|
||||||
|
{ SYS_gettimeofday, 0, "gettimeofday" },
|
||||||
|
{ SYS_settimeofday, 0, "settimeofday" },
|
||||||
|
{ SYS_getgroups, 0, "getgroups" },
|
||||||
|
{ SYS_setgroups, 0, "setgroups" },
|
||||||
|
{ SYS_select, 0, "select" },
|
||||||
|
{ SYS_symlink, 0, "symlink" },
|
||||||
|
{ SYS_oldlstat, 0, "oldlstat" },
|
||||||
|
{ SYS_readlink, 0, "readlink" },
|
||||||
|
{ SYS_uselib, 0, "uselib" },
|
||||||
|
{ SYS_swapon, 0, "swapon" },
|
||||||
|
{ SYS_reboot, 0, "reboot" },
|
||||||
|
{ SYS_readdir, 0, "readdir" },
|
||||||
|
{ SYS_mmap2, 1, "mmap2" },
|
||||||
|
{ SYS_munmap, 0, "munmap" },
|
||||||
|
{ SYS_truncate, 0, "truncate" },
|
||||||
|
{ SYS_ftruncate, 0, "ftruncate" },
|
||||||
|
{ SYS_fchmod, 0, "fchmod" },
|
||||||
|
{ SYS_fchown, 0, "fchown" },
|
||||||
|
{ SYS_getpriority, 0, "getpriority" },
|
||||||
|
{ SYS_setpriority, 0, "setpriority" },
|
||||||
|
{ SYS_profil, 0, "profil" },
|
||||||
|
{ SYS_statfs, 0, "statfs" },
|
||||||
|
{ SYS_fstatfs, 0, "fstatfs" },
|
||||||
|
{ SYS_ioperm, 0, "ioperm" },
|
||||||
|
{ SYS_socketcall, 0, "socketcall" },
|
||||||
|
{ SYS_syslog, 0, "syslog" },
|
||||||
|
{ SYS_setitimer, 0, "setitimer" },
|
||||||
|
{ SYS_getitimer, 0, "getitimer" },
|
||||||
|
{ SYS_stat, 0, "stat" },
|
||||||
|
{ SYS_lstat, 0, "lstat" },
|
||||||
|
{ SYS_fstat, 0, "fstat" },
|
||||||
|
{ SYS_olduname, 0, "olduname" },
|
||||||
|
{ SYS_iopl, 0, "iopl" },
|
||||||
|
{ SYS_vhangup, 0, "vhangup" },
|
||||||
|
{ SYS_idle, 0, "idle" },
|
||||||
|
{ SYS_vm86old, 0, "vm86old" },
|
||||||
|
{ SYS_wait4, 0, "wait4" },
|
||||||
|
{ SYS_swapoff, 0, "swapoff" },
|
||||||
|
{ SYS_sysinfo, 0, "sysinfo" },
|
||||||
|
{ SYS_ipc, 0, "ipc" },
|
||||||
|
{ SYS_fsync, 0, "fsync" },
|
||||||
|
{ SYS_sigreturn, 0, "sigreturn" },
|
||||||
|
{ SYS_clone, 0, "clone" },
|
||||||
|
{ SYS_setdomainname, 0, "setdomainname" },
|
||||||
|
{ SYS_uname, 0, "uname" },
|
||||||
|
{ SYS_modify_ldt, 0, "modify_ldt" },
|
||||||
|
{ SYS_adjtimex, 0, "adjtimex" },
|
||||||
|
{ SYS_mprotect, 0, "mprotect" },
|
||||||
|
{ SYS_sigprocmask, 0, "sigprocmask" },
|
||||||
|
{ SYS_create_module, 0, "create_module" },
|
||||||
|
{ SYS_init_module, 0, "init_module" },
|
||||||
|
{ SYS_delete_module, 0, "delete_module" },
|
||||||
|
{ SYS_get_kernel_syms, 0, "get_kernel_syms" },
|
||||||
|
{ SYS_quotactl, 0, "quotactl" },
|
||||||
|
{ SYS_getpgid, 0, "getpgid" },
|
||||||
|
{ SYS_fchdir, 0, "fchdir" },
|
||||||
|
{ SYS_bdflush, 0, "bdflush" },
|
||||||
|
{ SYS_sysfs, 0, "sysfs" },
|
||||||
|
{ SYS_personality, 0, "personality" },
|
||||||
|
{ SYS_afs_syscall, 0, "afs_syscall" },
|
||||||
|
{ SYS_setfsuid, 0, "setfsuid" },
|
||||||
|
{ SYS_setfsgid, 0, "setfsgid" },
|
||||||
|
{ SYS__llseek, 0, "_llseek" },
|
||||||
|
{ SYS_getdents, 0, "getdents" },
|
||||||
|
{ SYS__newselect, 0, "_newselect" },
|
||||||
|
{ SYS_flock, 0, "flock" },
|
||||||
|
{ SYS_msync, 0, "msync" },
|
||||||
|
{ SYS_readv, 0, "readv" },
|
||||||
|
{ SYS_writev, 0, "writev" },
|
||||||
|
{ SYS_getsid, 0, "getsid" },
|
||||||
|
{ SYS_fdatasync, 0, "fdatasync" },
|
||||||
|
{ SYS__sysctl, 0, "_sysctl" },
|
||||||
|
{ SYS_mlock, 0, "mlock" },
|
||||||
|
{ SYS_munlock, 0, "munlock" },
|
||||||
|
{ SYS_mlockall, 0, "mlockall" },
|
||||||
|
{ SYS_munlockall, 0, "munlockall" },
|
||||||
|
{ SYS_sched_setparam, 0, "sched_setparam" },
|
||||||
|
{ SYS_sched_getparam, 0, "sched_getparam" },
|
||||||
|
{ SYS_sched_setscheduler, 0, "sched_setscheduler" },
|
||||||
|
{ SYS_sched_getscheduler, 0, "sched_getscheduler" },
|
||||||
|
{ SYS_sched_yield, 0, "sched_yield" },
|
||||||
|
{ SYS_sched_get_priority_max, 0, "sched_get_priority_max" },
|
||||||
|
{ SYS_sched_get_priority_min, 0, "sched_get_priority_min" },
|
||||||
|
{ SYS_sched_rr_get_interval, 0, "sched_rr_get_interval" },
|
||||||
|
{ SYS_nanosleep, 0, "nanosleep" },
|
||||||
|
{ SYS_mremap, 0, "mremap" },
|
||||||
|
{ SYS_setresuid, 0, "setresuid" },
|
||||||
|
{ SYS_getresuid, 0, "getresuid" },
|
||||||
|
{ SYS_vm86, 0, "vm86" },
|
||||||
|
{ SYS_query_module, 0, "query_module" },
|
||||||
|
{ SYS_poll, 0, "poll" },
|
||||||
|
{ SYS_nfsservctl, 0, "nfsservctl" },
|
||||||
|
{ SYS_setresgid, 0, "setresgid" },
|
||||||
|
{ SYS_getresgid, 0, "getresgid" },
|
||||||
|
{ SYS_prctl, 0, "prctl" },
|
||||||
|
{ SYS_rt_sigreturn, 0, "rt_sigreturn" },
|
||||||
|
{ SYS_rt_sigaction, 0, "rt_sigaction" },
|
||||||
|
{ SYS_rt_sigprocmask, 0, "rt_sigprocmask" },
|
||||||
|
{ SYS_rt_sigpending, 0, "rt_sigpending" },
|
||||||
|
{ SYS_rt_sigtimedwait, 0, "rt_sigtimedwait" },
|
||||||
|
{ SYS_rt_sigqueueinfo, 0, "rt_sigqueueinfo" },
|
||||||
|
{ SYS_rt_sigsuspend, 0, "rt_sigsuspend" },
|
||||||
|
{ SYS_pread, 0, "pread" },
|
||||||
|
{ SYS_pwrite, 0, "pwrite" },
|
||||||
|
{ SYS_chown, 0, "chown" },
|
||||||
|
{ SYS_getcwd, 0, "getcwd" },
|
||||||
|
{ SYS_capget, 0, "capget" },
|
||||||
|
{ SYS_capset, 0, "capset" },
|
||||||
|
{ SYS_sigaltstack, 0, "sigaltstack" },
|
||||||
|
{ SYS_sendfile, 0, "sendfile" },
|
||||||
|
{ SYS_getpmsg, 0, "getpmsg" },
|
||||||
|
{ SYS_putpmsg, 0, "putpmsg" },
|
||||||
|
{ SYS_vfork, 0, "vfork" },
|
||||||
|
{ SYS_ugetrlimit, 0, "ugetrlimit" },
|
||||||
|
{ SYS_mmap2, 1, "mmap2" },
|
||||||
|
{ SYS_truncate64, 0, "truncate64" },
|
||||||
|
{ SYS_ftruncate64, 0, "ftruncate64" },
|
||||||
|
{ SYS_stat64, 0, "stat64" },
|
||||||
|
{ SYS_lstat64, 0, "lstat64" },
|
||||||
|
{ SYS_fstat64, 0, "fstat64" },
|
||||||
|
{ SYS_lchown32, 0, "lchown32" },
|
||||||
|
{ SYS_getuid32, 0, "getuid32" },
|
||||||
|
{ SYS_getgid32, 0, "getgid32" },
|
||||||
|
{ SYS_geteuid32, 0, "geteuid32" },
|
||||||
|
{ SYS_getegid32, 0, "getegid32" },
|
||||||
|
{ SYS_setreuid32, 0, "setreuid32" },
|
||||||
|
{ SYS_setregid32, 0, "setregid32" },
|
||||||
|
{ SYS_getgroups32, 0, "getgroups32" },
|
||||||
|
{ SYS_setgroups32, 0, "setgroups32" },
|
||||||
|
{ SYS_fchown32, 0, "fchown32" },
|
||||||
|
{ SYS_setresuid32, 0, "setresuid32" },
|
||||||
|
{ SYS_getresuid32, 0, "getresuid32" },
|
||||||
|
{ SYS_setresgid32, 0, "setresgid32" },
|
||||||
|
{ SYS_getresgid32, 0, "getresgid32" },
|
||||||
|
{ SYS_chown32, 0, "chown32" },
|
||||||
|
{ SYS_setuid32, 0, "setuid32" },
|
||||||
|
{ SYS_setgid32, 0, "setgid32" },
|
||||||
|
{ SYS_setfsuid32, 0, "setfsuid32" },
|
||||||
|
{ SYS_setfsgid32, 0, "setfsgid32" },
|
||||||
|
{ SYS_pivot_root, 0, "pivot_root" },
|
||||||
|
{ SYS_mincore, 0, "mincore" },
|
||||||
|
{ SYS_madvise1, 0, "madvise1" },
|
||||||
|
{ SYS_getdents64, 0, "getdents64" },
|
||||||
|
{ SYS_fcntl64, 0, "fcntl64" },
|
||||||
|
{ 222, 0, NULL },
|
||||||
|
{ 223 /* SYS_security */, 0, NULL /* "security" */ },
|
||||||
|
{ SYS_gettid, 0, "gettid" },
|
||||||
|
{ SYS_readahead, 0, "readahead" },
|
||||||
|
{ SYS_setxattr, 0, "setxattr" },
|
||||||
|
{ SYS_lsetxattr, 0, "lsetxattr" },
|
||||||
|
{ SYS_fsetxattr, 0, "fsetxattr" },
|
||||||
|
{ SYS_getxattr, 0, "getxattr" },
|
||||||
|
{ SYS_lgetxattr, 0, "lgetxattr" },
|
||||||
|
{ SYS_fgetxattr, 0, "fgetxattr" },
|
||||||
|
{ SYS_listxattr, 0, "listxattr" },
|
||||||
|
{ SYS_llistxattr, 0, "llistxattr" },
|
||||||
|
{ SYS_flistxattr, 0, "flistxattr" },
|
||||||
|
{ SYS_removexattr, 0, "removexattr" },
|
||||||
|
{ SYS_lremovexattr, 0, "lremovexattr" },
|
||||||
|
{ SYS_fremovexattr, 0, "fremovexattr" },
|
||||||
|
{ SYS_tkill, 0, "tkill" },
|
||||||
|
{ SYS_sendfile64, 0, "sendfile64" },
|
||||||
|
{ SYS_futex, 0, "futex" },
|
||||||
|
{ SYS_sched_setaffinity, 0, "sched_setaffinity" },
|
||||||
|
{ SYS_sched_getaffinity, 0, "sched_getaffinity" },
|
||||||
|
#ifdef SYS_set_thread_area
|
||||||
|
{ SYS_set_thread_area, 0, "set_thread_area " },
|
||||||
|
#else
|
||||||
|
{ 243, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_get_thread_area
|
||||||
|
{ SYS_get_thread_area, 0, "get_thread_area" },
|
||||||
|
#else
|
||||||
|
{ 244, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_io_setup
|
||||||
|
{ SYS_io_setup, 0, "io_setup" },
|
||||||
|
#else
|
||||||
|
{ 245, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_io_destroy
|
||||||
|
{ SYS_io_destroy, 0, "io_destroy" },
|
||||||
|
#else
|
||||||
|
{ 246, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_io_getevents
|
||||||
|
{ SYS_io_getevents, 0, "io_getevents" },
|
||||||
|
#else
|
||||||
|
{ 247, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_io_submit
|
||||||
|
{ SYS_io_submit, 0, "io_submit" },
|
||||||
|
#else
|
||||||
|
{ 248, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_io_cancel
|
||||||
|
{ SYS_io_cancel, 0, "io_cancel" },
|
||||||
|
#else
|
||||||
|
{ 249, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_fadvise64
|
||||||
|
{ SYS_fadvise64, 0, "fadvise64" },
|
||||||
|
#else
|
||||||
|
{ 250, 0, NULL },
|
||||||
|
#endif
|
||||||
|
{ 251, 0, NULL },
|
||||||
|
#ifdef SYS_exit_group
|
||||||
|
{ SYS_exit_group, 0, "exit_group" },
|
||||||
|
#else
|
||||||
|
{ 252, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_lookup_dcookie
|
||||||
|
{ SYS_lookup_dcookie, 0, "lookup_dcookie" },
|
||||||
|
#else
|
||||||
|
{ 253, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_epoll_create
|
||||||
|
{ SYS_epoll_create, 0, "epoll_create" },
|
||||||
|
#else
|
||||||
|
{ 254, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_epoll_ctl
|
||||||
|
{ SYS_epoll_ctl, 0, "epoll_ctl" },
|
||||||
|
#else
|
||||||
|
{ 255, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_epoll_wait
|
||||||
|
{ SYS_epoll_wait, 0, "epoll_wait" },
|
||||||
|
#else
|
||||||
|
{ 256, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_remap_file_pages
|
||||||
|
{ SYS_remap_file_pages, 0, "remap_file_pages" },
|
||||||
|
#else
|
||||||
|
{ 257, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_set_tid_address
|
||||||
|
{ SYS_set_tid_address, 0, "set_tid_address" },
|
||||||
|
#else
|
||||||
|
{ 258, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_timer_create
|
||||||
|
{ SYS_timer_create, 0, "timer_create" },
|
||||||
|
#else
|
||||||
|
{ 259, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_timer_settime
|
||||||
|
{ SYS_timer_settime, 0, "timer_settime" },
|
||||||
|
#else
|
||||||
|
{ 260, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_timer_gettime
|
||||||
|
{ SYS_timer_gettime, 0, "timer_gettime" },
|
||||||
|
#else
|
||||||
|
{ 261, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_timer_getoverrun
|
||||||
|
{ SYS_timer_getoverrun, 0, "timer_getoverrun" },
|
||||||
|
#else
|
||||||
|
{ 262, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_timer_delete
|
||||||
|
{ SYS_timer_delete, 0, "timer_delete" },
|
||||||
|
#else
|
||||||
|
{ 263, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_clock_settime
|
||||||
|
{ SYS_clock_settime, 0, "clock_settime" },
|
||||||
|
#else
|
||||||
|
{ 264, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_clock_gettime
|
||||||
|
{ SYS_clock_gettime, 0, "clock_gettime" },
|
||||||
|
#else
|
||||||
|
{ 265, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_clock_getres
|
||||||
|
{ SYS_clock_getres, 0, "clock_getres" },
|
||||||
|
#else
|
||||||
|
{ 266, 0, NULL },
|
||||||
|
#endif
|
||||||
|
#ifdef SYS_clock_nansleep
|
||||||
|
{ SYS_clock_nanosleep, 0, "clock_nanosleep" },
|
||||||
|
#else
|
||||||
|
{ 267, 0, NULL },
|
||||||
|
#endif
|
||||||
|
{ 268, 0, NULL },
|
||||||
|
{ 269, 0, NULL },
|
||||||
|
#ifdef SYS_tgkill
|
||||||
|
{ SYS_tgkill, 0, "tgkill" },
|
||||||
|
#else
|
||||||
|
{ 270, 0, NULL },
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
int callmax = sizeof (callinfo) / sizeof (callinfo[0]);
|
||||||
|
|
35
src/callinfo.h
Normal file
35
src/callinfo.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef _CALLINFO_H
|
||||||
|
#define _CALLINFO_H
|
||||||
|
/*
|
||||||
|
* Definitions for syscall constants.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct callinfo
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
int ptrval;
|
||||||
|
char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct callinfo callinfo[];
|
||||||
|
extern int callmax;
|
||||||
|
|
||||||
|
#endif
|
80
src/dumpbytes.c
Normal file
80
src/dumpbytes.c
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Hexadecimal dump for displaying ioctl data structures.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
|
void dumpbytes (FILE *f, void *z, size_t len, void *addr, char *prefix)
|
||||||
|
{
|
||||||
|
off_t k;
|
||||||
|
int j = 15;
|
||||||
|
char abuf[20];
|
||||||
|
unsigned char *buf = z;
|
||||||
|
|
||||||
|
for (k = 0; k < len; ++k)
|
||||||
|
{
|
||||||
|
unsigned char c = buf[k];
|
||||||
|
|
||||||
|
j = k % 16;
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
if (prefix)
|
||||||
|
fprintf (f, " %s+%04lx:\t", prefix, k);
|
||||||
|
else
|
||||||
|
fprintf (f, " %08lx:\t", ((unsigned long) addr) + k);
|
||||||
|
memset (abuf, ' ', sizeof abuf - 1);
|
||||||
|
abuf[sizeof abuf - 1] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (j % 4 == 0)
|
||||||
|
putc (' ', f);
|
||||||
|
if (j % 8 == 0)
|
||||||
|
putc (' ', f);
|
||||||
|
}
|
||||||
|
fprintf (f, "%02x", c);
|
||||||
|
abuf[j + j / 4] = isprint (c) ? c : '.';
|
||||||
|
if (j == 15)
|
||||||
|
{
|
||||||
|
fprintf (f, " %s\n", abuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j != 15)
|
||||||
|
{
|
||||||
|
for ( ; j < 15; ++j)
|
||||||
|
{
|
||||||
|
if (j % 4 == 0)
|
||||||
|
putc (' ', f);
|
||||||
|
if (j % 8 == 0)
|
||||||
|
putc (' ', f);
|
||||||
|
putc (' ', f);
|
||||||
|
putc (' ', f);
|
||||||
|
}
|
||||||
|
fprintf (f, " %s\n", abuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
29
src/dumpbytes.h
Normal file
29
src/dumpbytes.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef _DUMPBYTES_H
|
||||||
|
#define _DUMPBYTES_H
|
||||||
|
/*
|
||||||
|
* Definitions for hex dump routine.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern void dumpbytes (FILE *f, void *z, size_t len, void *addr, char *prefix);
|
||||||
|
|
||||||
|
#endif
|
0
src/includes-hack/asm/semaphore.h
Normal file
0
src/includes-hack/asm/semaphore.h
Normal file
1
src/kernel-2.6.9-55.0.2.EL/megaraid
Symbolic link
1
src/kernel-2.6.9-55.0.2.EL/megaraid
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
megaraid-2.20.4.6-rh2
|
823
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mbox_defs.h
Normal file
823
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mbox_defs.h
Normal file
@ -0,0 +1,823 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Linux MegaRAID Unified device driver
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2004 LSI Logic Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FILE : mbox_defs.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef _MRAID_MBOX_DEFS_H_
|
||||||
|
#define _MRAID_MBOX_DEFS_H_
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Commands and states for mailbox based controllers
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MBOXCMD_LREAD 0x01
|
||||||
|
#define MBOXCMD_LWRITE 0x02
|
||||||
|
#define MBOXCMD_PASSTHRU 0x03
|
||||||
|
#define MBOXCMD_ADPEXTINQ 0x04
|
||||||
|
#define MBOXCMD_ADAPTERINQ 0x05
|
||||||
|
#define MBOXCMD_LREAD64 0xA7
|
||||||
|
#define MBOXCMD_LWRITE64 0xA8
|
||||||
|
#define MBOXCMD_PASSTHRU64 0xC3
|
||||||
|
#define MBOXCMD_EXTPTHRU 0xE3
|
||||||
|
|
||||||
|
#define MAIN_MISC_OPCODE 0xA4
|
||||||
|
#define GET_MAX_SG_SUPPORT 0x01
|
||||||
|
#define SUPPORT_EXT_CDB 0x16
|
||||||
|
|
||||||
|
#define FC_NEW_CONFIG 0xA1
|
||||||
|
#define NC_SUBOP_PRODUCT_INFO 0x0E
|
||||||
|
#define NC_SUBOP_ENQUIRY3 0x0F
|
||||||
|
#define ENQ3_GET_SOLICITED_FULL 0x02
|
||||||
|
#define OP_DCMD_READ_CONFIG 0x04
|
||||||
|
#define NEW_READ_CONFIG_8LD 0x67
|
||||||
|
#define READ_CONFIG_8LD 0x07
|
||||||
|
#define FLUSH_ADAPTER 0x0A
|
||||||
|
#define FLUSH_SYSTEM 0xFE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Command for random deletion of logical drives
|
||||||
|
*/
|
||||||
|
#define FC_DEL_LOGDRV 0xA4
|
||||||
|
#define OP_SUP_DEL_LOGDRV 0x2A
|
||||||
|
#define OP_GET_LDID_MAP 0x18
|
||||||
|
#define OP_DEL_LOGDRV 0x1C
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BIOS commands
|
||||||
|
*/
|
||||||
|
#define IS_BIOS_ENABLED 0x62
|
||||||
|
#define GET_BIOS 0x01
|
||||||
|
#define CHNL_CLASS 0xA9
|
||||||
|
#define GET_CHNL_CLASS 0x00
|
||||||
|
#define SET_CHNL_CLASS 0x01
|
||||||
|
#define CH_RAID 0x01
|
||||||
|
#define CH_SCSI 0x00
|
||||||
|
#define BIOS_PVT_DATA 0x40
|
||||||
|
#define GET_BIOS_PVT_DATA 0x00
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Commands to support clustering
|
||||||
|
*/
|
||||||
|
#define GET_TARGET_ID 0x7D
|
||||||
|
#define CLUSTER_OP 0x70
|
||||||
|
#define GET_CLUSTER_MODE 0x02
|
||||||
|
#define CLUSTER_CMD 0x6E
|
||||||
|
#define RESERVE_LD 0x01
|
||||||
|
#define RELEASE_LD 0x02
|
||||||
|
#define RESET_RESERVATIONS 0x03
|
||||||
|
#define RESERVATION_STATUS 0x04
|
||||||
|
#define RESERVE_PD 0x05
|
||||||
|
#define RELEASE_PD 0x06
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Module battery status
|
||||||
|
*/
|
||||||
|
#define BATTERY_MODULE_MISSING 0x01
|
||||||
|
#define BATTERY_LOW_VOLTAGE 0x02
|
||||||
|
#define BATTERY_TEMP_HIGH 0x04
|
||||||
|
#define BATTERY_PACK_MISSING 0x08
|
||||||
|
#define BATTERY_CHARGE_MASK 0x30
|
||||||
|
#define BATTERY_CHARGE_DONE 0x00
|
||||||
|
#define BATTERY_CHARGE_INPROG 0x10
|
||||||
|
#define BATTERY_CHARGE_FAIL 0x20
|
||||||
|
#define BATTERY_CYCLES_EXCEEDED 0x40
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Physical drive states.
|
||||||
|
*/
|
||||||
|
#define PDRV_UNCNF 0
|
||||||
|
#define PDRV_ONLINE 3
|
||||||
|
#define PDRV_FAILED 4
|
||||||
|
#define PDRV_RBLD 5
|
||||||
|
#define PDRV_HOTSPARE 6
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Raid logical drive states.
|
||||||
|
*/
|
||||||
|
#define RDRV_OFFLINE 0
|
||||||
|
#define RDRV_DEGRADED 1
|
||||||
|
#define RDRV_OPTIMAL 2
|
||||||
|
#define RDRV_DELETED 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read, write and cache policies
|
||||||
|
*/
|
||||||
|
#define NO_READ_AHEAD 0
|
||||||
|
#define READ_AHEAD 1
|
||||||
|
#define ADAP_READ_AHEAD 2
|
||||||
|
#define WRMODE_WRITE_THRU 0
|
||||||
|
#define WRMODE_WRITE_BACK 1
|
||||||
|
#define CACHED_IO 0
|
||||||
|
#define DIRECT_IO 1
|
||||||
|
|
||||||
|
#define MAX_LOGICAL_DRIVES_8LD 8
|
||||||
|
#define MAX_LOGICAL_DRIVES_40LD 40
|
||||||
|
#define FC_MAX_PHYSICAL_DEVICES 256
|
||||||
|
#define MAX_MBOX_CHANNELS 5
|
||||||
|
#define MAX_MBOX_TARGET 15
|
||||||
|
#define MBOX_MAX_PHYSICAL_DRIVES MAX_MBOX_CHANNELS*MAX_MBOX_TARGET
|
||||||
|
#define MAX_ROW_SIZE_40LD 32
|
||||||
|
#define MAX_ROW_SIZE_8LD 8
|
||||||
|
#define SPAN_DEPTH_8_SPANS 8
|
||||||
|
#define SPAN_DEPTH_4_SPANS 4
|
||||||
|
#define MAX_REQ_SENSE_LEN 0x20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct mbox_t - Driver and f/w handshake structure.
|
||||||
|
* @cmd : firmware command
|
||||||
|
* @cmdid : command id
|
||||||
|
* @numsectors : number of sectors to be transferred
|
||||||
|
* @lba : Logical Block Address on LD
|
||||||
|
* @xferaddr : DMA address for data transfer
|
||||||
|
* @logdrv : logical drive number
|
||||||
|
* @numsge : number of scatter gather elements in sg list
|
||||||
|
* @resvd : reserved
|
||||||
|
* @busy : f/w busy, must wait to issue more commands.
|
||||||
|
* @numstatus : number of commands completed.
|
||||||
|
* @status : status of the commands completed
|
||||||
|
* @completed : array of completed command ids.
|
||||||
|
* @poll : poll and ack sequence
|
||||||
|
* @ack : poll and ack sequence
|
||||||
|
*
|
||||||
|
* The central handshake structure between the driver and the firmware. This
|
||||||
|
* structure must be allocated by the driver and aligned at 8-byte boundary.
|
||||||
|
*/
|
||||||
|
#define MBOX_MAX_FIRMWARE_STATUS 46
|
||||||
|
typedef struct {
|
||||||
|
uint8_t cmd;
|
||||||
|
uint8_t cmdid;
|
||||||
|
uint16_t numsectors;
|
||||||
|
uint32_t lba;
|
||||||
|
uint32_t xferaddr;
|
||||||
|
uint8_t logdrv;
|
||||||
|
uint8_t numsge;
|
||||||
|
uint8_t resvd;
|
||||||
|
uint8_t busy;
|
||||||
|
uint8_t numstatus;
|
||||||
|
uint8_t status;
|
||||||
|
uint8_t completed[MBOX_MAX_FIRMWARE_STATUS];
|
||||||
|
uint8_t poll;
|
||||||
|
uint8_t ack;
|
||||||
|
} __attribute__ ((packed)) mbox_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbox64_t - 64-bit extension for the mailbox
|
||||||
|
* @segment_lo : the low 32-bits of the address of the scatter-gather list
|
||||||
|
* @segment_hi : the upper 32-bits of the address of the scatter-gather list
|
||||||
|
* @mbox : 32-bit mailbox, whose xferadder field must be set to
|
||||||
|
* 0xFFFFFFFF
|
||||||
|
*
|
||||||
|
* This is the extension of the 32-bit mailbox to be able to perform DMA
|
||||||
|
* beyond 4GB address range.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint32_t xferaddr_lo;
|
||||||
|
uint32_t xferaddr_hi;
|
||||||
|
mbox_t mbox32;
|
||||||
|
} __attribute__ ((packed)) mbox64_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* mailbox structure used for internal commands
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
u8 cmd;
|
||||||
|
u8 cmdid;
|
||||||
|
u8 opcode;
|
||||||
|
u8 subopcode;
|
||||||
|
u32 lba;
|
||||||
|
u32 xferaddr;
|
||||||
|
u8 logdrv;
|
||||||
|
u8 rsvd[3];
|
||||||
|
u8 numstatus;
|
||||||
|
u8 status;
|
||||||
|
} __attribute__ ((packed)) int_mbox_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_passthru_t - passthru structure to issue commands to physical devices
|
||||||
|
* @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
|
||||||
|
* @ars : set if ARS required after check condition
|
||||||
|
* @islogical : set if command meant for logical devices
|
||||||
|
* @logdrv : logical drive number if command for LD
|
||||||
|
* @channel : Channel on which physical device is located
|
||||||
|
* @target : SCSI target of the device
|
||||||
|
* @queuetag : unused
|
||||||
|
* @queueaction : unused
|
||||||
|
* @cdb : SCSI CDB
|
||||||
|
* @cdblen : length of the CDB
|
||||||
|
* @reqsenselen : amount of request sense data to be returned
|
||||||
|
* @reqsensearea : Sense information buffer
|
||||||
|
* @numsge : number of scatter-gather elements in the sg list
|
||||||
|
* @scsistatus : SCSI status of the command completed.
|
||||||
|
* @dataxferaddr : DMA data transfer address
|
||||||
|
* @dataxferlen : amount of the data to be transferred.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t timeout :3;
|
||||||
|
uint8_t ars :1;
|
||||||
|
uint8_t reserved :3;
|
||||||
|
uint8_t islogical :1;
|
||||||
|
uint8_t logdrv;
|
||||||
|
uint8_t channel;
|
||||||
|
uint8_t target;
|
||||||
|
uint8_t queuetag;
|
||||||
|
uint8_t queueaction;
|
||||||
|
uint8_t cdb[10];
|
||||||
|
uint8_t cdblen;
|
||||||
|
uint8_t reqsenselen;
|
||||||
|
uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
|
||||||
|
uint8_t numsge;
|
||||||
|
uint8_t scsistatus;
|
||||||
|
uint32_t dataxferaddr;
|
||||||
|
uint32_t dataxferlen;
|
||||||
|
} __attribute__ ((packed)) mraid_passthru_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
uint32_t dataxferaddr_lo;
|
||||||
|
uint32_t dataxferaddr_hi;
|
||||||
|
mraid_passthru_t pthru32;
|
||||||
|
|
||||||
|
} __attribute__ ((packed)) mega_passthru64_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_epassthru_t - passthru structure to issue commands to physical devices
|
||||||
|
* @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
|
||||||
|
* @ars : set if ARS required after check condition
|
||||||
|
* @rsvd1 : reserved field
|
||||||
|
* @cd_rom : (?)
|
||||||
|
* @rsvd2 : reserved field
|
||||||
|
* @islogical : set if command meant for logical devices
|
||||||
|
* @logdrv : logical drive number if command for LD
|
||||||
|
* @channel : Channel on which physical device is located
|
||||||
|
* @target : SCSI target of the device
|
||||||
|
* @queuetag : unused
|
||||||
|
* @queueaction : unused
|
||||||
|
* @cdblen : length of the CDB
|
||||||
|
* @rsvd3 : reserved field
|
||||||
|
* @cdb : SCSI CDB
|
||||||
|
* @numsge : number of scatter-gather elements in the sg list
|
||||||
|
* @status : SCSI status of the command completed.
|
||||||
|
* @reqsenselen : amount of request sense data to be returned
|
||||||
|
* @reqsensearea : Sense information buffer
|
||||||
|
* @rsvd4 : reserved field
|
||||||
|
* @dataxferaddr : DMA data transfer address
|
||||||
|
* @dataxferlen : amount of the data to be transferred.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t timeout :3;
|
||||||
|
uint8_t ars :1;
|
||||||
|
uint8_t rsvd1 :1;
|
||||||
|
uint8_t cd_rom :1;
|
||||||
|
uint8_t rsvd2 :1;
|
||||||
|
uint8_t islogical :1;
|
||||||
|
uint8_t logdrv;
|
||||||
|
uint8_t channel;
|
||||||
|
uint8_t target;
|
||||||
|
uint8_t queuetag;
|
||||||
|
uint8_t queueaction;
|
||||||
|
uint8_t cdblen;
|
||||||
|
uint8_t rsvd3;
|
||||||
|
uint8_t cdb[16];
|
||||||
|
uint8_t numsge;
|
||||||
|
uint8_t status;
|
||||||
|
uint8_t reqsenselen;
|
||||||
|
uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
|
||||||
|
uint8_t rsvd4;
|
||||||
|
uint32_t dataxferaddr;
|
||||||
|
uint32_t dataxferlen;
|
||||||
|
} __attribute__ ((packed)) mraid_epassthru_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_pinfo_t - product info, static information about the controller
|
||||||
|
* @data_size : current size in bytes (not including resvd)
|
||||||
|
* @config_signature : Current value is 0x00282008
|
||||||
|
* @fw_version : Firmware version
|
||||||
|
* @bios_version : version of the BIOS
|
||||||
|
* @product_name : Name given to the controller
|
||||||
|
* @max_commands : Maximum concurrent commands supported
|
||||||
|
* @nchannels : Number of SCSI Channels detected
|
||||||
|
* @fc_loop_present : Number of Fibre Loops detected
|
||||||
|
* @mem_type : EDO, FPM, SDRAM etc
|
||||||
|
* @signature :
|
||||||
|
* @dram_size : In terms of MB
|
||||||
|
* @subsysid : device PCI subsystem ID
|
||||||
|
* @subsysvid : device PCI subsystem vendor ID
|
||||||
|
* @notify_counters :
|
||||||
|
* @pad1k : 135 + 889 resvd = 1024 total size
|
||||||
|
*
|
||||||
|
* This structures holds the information about the controller which is not
|
||||||
|
* expected to change dynamically.
|
||||||
|
*
|
||||||
|
* The current value of config signature is 0x00282008:
|
||||||
|
* 0x28 = MAX_LOGICAL_DRIVES,
|
||||||
|
* 0x20 = Number of stripes and
|
||||||
|
* 0x08 = Number of spans
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint32_t data_size;
|
||||||
|
uint32_t config_signature;
|
||||||
|
uint8_t fw_version[16];
|
||||||
|
uint8_t bios_version[16];
|
||||||
|
uint8_t product_name[80];
|
||||||
|
uint8_t max_commands;
|
||||||
|
uint8_t nchannels;
|
||||||
|
uint8_t fc_loop_present;
|
||||||
|
uint8_t mem_type;
|
||||||
|
uint32_t signature;
|
||||||
|
uint16_t dram_size;
|
||||||
|
uint16_t subsysid;
|
||||||
|
uint16_t subsysvid;
|
||||||
|
uint8_t notify_counters;
|
||||||
|
uint8_t pad1k[889];
|
||||||
|
} __attribute__ ((packed)) mraid_pinfo_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_notify_t - the notification structure
|
||||||
|
* @global_counter : Any change increments this counter
|
||||||
|
* @param_counter : Indicates any params changed
|
||||||
|
* @param_id : Param modified - defined below
|
||||||
|
* @param_val : New val of last param modified
|
||||||
|
* @write_config_counter : write config occurred
|
||||||
|
* @write_config_rsvd :
|
||||||
|
* @ldrv_op_counter : Indicates ldrv op started/completed
|
||||||
|
* @ldrv_opid : ldrv num
|
||||||
|
* @ldrv_opcmd : ldrv operation - defined below
|
||||||
|
* @ldrv_opstatus : status of the operation
|
||||||
|
* @ldrv_state_counter : Indicates change of ldrv state
|
||||||
|
* @ldrv_state_id : ldrv num
|
||||||
|
* @ldrv_state_new : New state
|
||||||
|
* @ldrv_state_old : old state
|
||||||
|
* @pdrv_state_counter : Indicates change of ldrv state
|
||||||
|
* @pdrv_state_id : pdrv id
|
||||||
|
* @pdrv_state_new : New state
|
||||||
|
* @pdrv_state_old : old state
|
||||||
|
* @pdrv_fmt_counter : Indicates pdrv format started/over
|
||||||
|
* @pdrv_fmt_id : pdrv id
|
||||||
|
* @pdrv_fmt_val : format started/over
|
||||||
|
* @pdrv_fmt_rsvd :
|
||||||
|
* @targ_xfer_counter : Indicates SCSI-2 Xfer rate change
|
||||||
|
* @targ_xfer_id : pdrv Id
|
||||||
|
* @targ_xfer_val : new Xfer params of last pdrv
|
||||||
|
* @targ_xfer_rsvd :
|
||||||
|
* @fcloop_id_chg_counter : Indicates loopid changed
|
||||||
|
* @fcloopid_pdrvid : pdrv id
|
||||||
|
* @fcloop_id0 : loopid on fc loop 0
|
||||||
|
* @fcloop_id1 : loopid on fc loop 1
|
||||||
|
* @fcloop_state_counter : Indicates loop state changed
|
||||||
|
* @fcloop_state0 : state of fc loop 0
|
||||||
|
* @fcloop_state1 : state of fc loop 1
|
||||||
|
* @fcloop_state_rsvd :
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint32_t global_counter;
|
||||||
|
uint8_t param_counter;
|
||||||
|
uint8_t param_id;
|
||||||
|
uint16_t param_val;
|
||||||
|
uint8_t write_config_counter;
|
||||||
|
uint8_t write_config_rsvd[3];
|
||||||
|
uint8_t ldrv_op_counter;
|
||||||
|
uint8_t ldrv_opid;
|
||||||
|
uint8_t ldrv_opcmd;
|
||||||
|
uint8_t ldrv_opstatus;
|
||||||
|
uint8_t ldrv_state_counter;
|
||||||
|
uint8_t ldrv_state_id;
|
||||||
|
uint8_t ldrv_state_new;
|
||||||
|
uint8_t ldrv_state_old;
|
||||||
|
uint8_t pdrv_state_counter;
|
||||||
|
uint8_t pdrv_state_id;
|
||||||
|
uint8_t pdrv_state_new;
|
||||||
|
uint8_t pdrv_state_old;
|
||||||
|
uint8_t pdrv_fmt_counter;
|
||||||
|
uint8_t pdrv_fmt_id;
|
||||||
|
uint8_t pdrv_fmt_val;
|
||||||
|
uint8_t pdrv_fmt_rsvd;
|
||||||
|
uint8_t targ_xfer_counter;
|
||||||
|
uint8_t targ_xfer_id;
|
||||||
|
uint8_t targ_xfer_val;
|
||||||
|
uint8_t targ_xfer_rsvd;
|
||||||
|
uint8_t fcloop_id_chg_counter;
|
||||||
|
uint8_t fcloopid_pdrvid;
|
||||||
|
uint8_t fcloop_id0;
|
||||||
|
uint8_t fcloop_id1;
|
||||||
|
uint8_t fcloop_state_counter;
|
||||||
|
uint8_t fcloop_state0;
|
||||||
|
uint8_t fcloop_state1;
|
||||||
|
uint8_t fcloop_state_rsvd;
|
||||||
|
} __attribute__ ((packed)) mraid_notify_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_inquiry3_t - enquiry for device information
|
||||||
|
*
|
||||||
|
* @data_size : current size in bytes (not including resvd)
|
||||||
|
* @notify :
|
||||||
|
* @notify_rsvd :
|
||||||
|
* @rebuild_rate : rebuild rate (0% - 100%)
|
||||||
|
* @cache_flush_int : cache flush interval in seconds
|
||||||
|
* @sense_alert :
|
||||||
|
* @drive_insert_count : drive insertion count
|
||||||
|
* @battery_status :
|
||||||
|
* @num_ldrv : no. of Log Drives configured
|
||||||
|
* @recon_state : state of reconstruct
|
||||||
|
* @ldrv_op_status : logdrv Status
|
||||||
|
* @ldrv_size : size of each log drv
|
||||||
|
* @ldrv_prop :
|
||||||
|
* @ldrv_state : state of log drives
|
||||||
|
* @pdrv_state : state of phys drvs.
|
||||||
|
* @pdrv_format :
|
||||||
|
* @targ_xfer : phys device transfer rate
|
||||||
|
* @pad1k : 761 + 263reserved = 1024 bytes total size
|
||||||
|
*/
|
||||||
|
#define MAX_NOTIFY_SIZE 0x80
|
||||||
|
#define CUR_NOTIFY_SIZE sizeof(mraid_notify_t)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t data_size;
|
||||||
|
|
||||||
|
mraid_notify_t notify;
|
||||||
|
|
||||||
|
uint8_t notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
|
||||||
|
|
||||||
|
uint8_t rebuild_rate;
|
||||||
|
uint8_t cache_flush_int;
|
||||||
|
uint8_t sense_alert;
|
||||||
|
uint8_t drive_insert_count;
|
||||||
|
|
||||||
|
uint8_t battery_status;
|
||||||
|
uint8_t num_ldrv;
|
||||||
|
uint8_t recon_state[MAX_LOGICAL_DRIVES_40LD / 8];
|
||||||
|
uint16_t ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8];
|
||||||
|
|
||||||
|
uint32_t ldrv_size[MAX_LOGICAL_DRIVES_40LD];
|
||||||
|
uint8_t ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
|
||||||
|
uint8_t ldrv_state[MAX_LOGICAL_DRIVES_40LD];
|
||||||
|
uint8_t pdrv_state[FC_MAX_PHYSICAL_DEVICES];
|
||||||
|
uint16_t pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
|
||||||
|
|
||||||
|
uint8_t targ_xfer[80];
|
||||||
|
uint8_t pad1k[263];
|
||||||
|
} __attribute__ ((packed)) mraid_inquiry3_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_adapinfo_t - information about the adapter
|
||||||
|
* @max_commands : max concurrent commands supported
|
||||||
|
* @rebuild_rate : rebuild rate - 0% thru 100%
|
||||||
|
* @max_targ_per_chan : max targ per channel
|
||||||
|
* @nchannels : number of channels on HBA
|
||||||
|
* @fw_version : firmware version
|
||||||
|
* @age_of_flash : number of times FW has been flashed
|
||||||
|
* @chip_set_value : contents of 0xC0000832
|
||||||
|
* @dram_size : in MB
|
||||||
|
* @cache_flush_interval : in seconds
|
||||||
|
* @bios_version :
|
||||||
|
* @board_type :
|
||||||
|
* @sense_alert :
|
||||||
|
* @write_config_count : increase with every configuration change
|
||||||
|
* @drive_inserted_count : increase with every drive inserted
|
||||||
|
* @inserted_drive : channel:Id of inserted drive
|
||||||
|
* @battery_status : bit 0: battery module missing
|
||||||
|
* bit 1: VBAD
|
||||||
|
* bit 2: temprature high
|
||||||
|
* bit 3: battery pack missing
|
||||||
|
* bit 4,5:
|
||||||
|
* 00 - charge complete
|
||||||
|
* 01 - fast charge in progress
|
||||||
|
* 10 - fast charge fail
|
||||||
|
* 11 - undefined
|
||||||
|
* bit 6: counter > 1000
|
||||||
|
* bit 7: Undefined
|
||||||
|
* @dec_fault_bus_info :
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t max_commands;
|
||||||
|
uint8_t rebuild_rate;
|
||||||
|
uint8_t max_targ_per_chan;
|
||||||
|
uint8_t nchannels;
|
||||||
|
uint8_t fw_version[4];
|
||||||
|
uint16_t age_of_flash;
|
||||||
|
uint8_t chip_set_value;
|
||||||
|
uint8_t dram_size;
|
||||||
|
uint8_t cache_flush_interval;
|
||||||
|
uint8_t bios_version[4];
|
||||||
|
uint8_t board_type;
|
||||||
|
uint8_t sense_alert;
|
||||||
|
uint8_t write_config_count;
|
||||||
|
uint8_t battery_status;
|
||||||
|
uint8_t dec_fault_bus_info;
|
||||||
|
} __attribute__ ((packed)) mraid_adapinfo_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_ldrv_info_t - information about the logical drives
|
||||||
|
* @nldrv : Number of logical drives configured
|
||||||
|
* @rsvd :
|
||||||
|
* @size : size of each logical drive
|
||||||
|
* @prop :
|
||||||
|
* @state : state of each logical drive
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t nldrv;
|
||||||
|
uint8_t rsvd[3];
|
||||||
|
uint32_t size[MAX_LOGICAL_DRIVES_8LD];
|
||||||
|
uint8_t prop[MAX_LOGICAL_DRIVES_8LD];
|
||||||
|
uint8_t state[MAX_LOGICAL_DRIVES_8LD];
|
||||||
|
} __attribute__ ((packed)) mraid_ldrv_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_pdrv_info_t - information about the physical drives
|
||||||
|
* @pdrv_state : state of each physical drive
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
|
||||||
|
uint8_t rsvd;
|
||||||
|
} __attribute__ ((packed)) mraid_pdrv_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_inquiry_t - RAID inquiry, mailbox command 0x05
|
||||||
|
* @mraid_adapinfo_t : adapter information
|
||||||
|
* @mraid_ldrv_info_t : logical drives information
|
||||||
|
* @mraid_pdrv_info_t : physical drives information
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
mraid_adapinfo_t adapter_info;
|
||||||
|
mraid_ldrv_info_t logdrv_info;
|
||||||
|
mraid_pdrv_info_t pdrv_info;
|
||||||
|
} __attribute__ ((packed)) mraid_inquiry_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_extinq_t - RAID extended inquiry, mailbox command 0x04
|
||||||
|
*
|
||||||
|
* @raid_inq : raid inquiry
|
||||||
|
* @phys_drv_format :
|
||||||
|
* @stack_attn :
|
||||||
|
* @modem_status :
|
||||||
|
* @rsvd :
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
mraid_inquiry_t raid_inq;
|
||||||
|
uint16_t phys_drv_format[MAX_MBOX_CHANNELS];
|
||||||
|
uint8_t stack_attn;
|
||||||
|
uint8_t modem_status;
|
||||||
|
uint8_t rsvd[2];
|
||||||
|
} __attribute__ ((packed)) mraid_extinq_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adap_device_t - device information
|
||||||
|
* @channel : channel fpor the device
|
||||||
|
* @target : target ID of the device
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t channel;
|
||||||
|
uint8_t target;
|
||||||
|
}__attribute__ ((packed)) adap_device_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adap_span_40ld_t - 40LD span
|
||||||
|
* @start_blk : starting block
|
||||||
|
* @num_blks : number of blocks
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint32_t start_blk;
|
||||||
|
uint32_t num_blks;
|
||||||
|
adap_device_t device[MAX_ROW_SIZE_40LD];
|
||||||
|
}__attribute__ ((packed)) adap_span_40ld_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adap_span_8ld_t - 8LD span
|
||||||
|
* @start_blk : starting block
|
||||||
|
* @num_blks : number of blocks
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint32_t start_blk;
|
||||||
|
uint32_t num_blks;
|
||||||
|
adap_device_t device[MAX_ROW_SIZE_8LD];
|
||||||
|
}__attribute__ ((packed)) adap_span_8ld_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logdrv_param_t - logical drives parameters
|
||||||
|
*
|
||||||
|
* @span_depth : total number of spans
|
||||||
|
* @level : RAID level
|
||||||
|
* @read_ahead : read ahead, no read ahead, adaptive read ahead
|
||||||
|
* @stripe_sz : encoded stripe size
|
||||||
|
* @status : status of the logical drive
|
||||||
|
* @write_mode : write mode, write_through/write_back
|
||||||
|
* @direct_io : direct io or through cache
|
||||||
|
* @row_size : number of stripes in a row
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t span_depth;
|
||||||
|
uint8_t level;
|
||||||
|
uint8_t read_ahead;
|
||||||
|
uint8_t stripe_sz;
|
||||||
|
uint8_t status;
|
||||||
|
uint8_t write_mode;
|
||||||
|
uint8_t direct_io;
|
||||||
|
uint8_t row_size;
|
||||||
|
} __attribute__ ((packed)) logdrv_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logdrv_40ld_t - logical drive definition for 40LD controllers
|
||||||
|
* @lparam : logical drives parameters
|
||||||
|
* @span : span
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
logdrv_param_t lparam;
|
||||||
|
adap_span_40ld_t span[SPAN_DEPTH_8_SPANS];
|
||||||
|
}__attribute__ ((packed)) logdrv_40ld_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logdrv_8ld_span8_t - logical drive definition for 8LD controllers
|
||||||
|
* @lparam : logical drives parameters
|
||||||
|
* @span : span
|
||||||
|
*
|
||||||
|
* 8-LD logical drive with upto 8 spans
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
logdrv_param_t lparam;
|
||||||
|
adap_span_8ld_t span[SPAN_DEPTH_8_SPANS];
|
||||||
|
}__attribute__ ((packed)) logdrv_8ld_span8_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logdrv_8ld_span4_t - logical drive definition for 8LD controllers
|
||||||
|
* @lparam : logical drives parameters
|
||||||
|
* @span : span
|
||||||
|
*
|
||||||
|
* 8-LD logical drive with upto 4 spans
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
logdrv_param_t lparam;
|
||||||
|
adap_span_8ld_t span[SPAN_DEPTH_4_SPANS];
|
||||||
|
}__attribute__ ((packed)) logdrv_8ld_span4_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phys_drive_t - physical device information
|
||||||
|
* @type : Type of the device
|
||||||
|
* @cur_status : current status of the device
|
||||||
|
* @tag_depth : Level of tagging
|
||||||
|
* @sync_neg : sync negotiation - ENABLE or DISBALE
|
||||||
|
* @size : configurable size in terms of 512 byte
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t cur_status;
|
||||||
|
uint8_t tag_depth;
|
||||||
|
uint8_t sync_neg;
|
||||||
|
uint32_t size;
|
||||||
|
}__attribute__ ((packed)) phys_drive_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* disk_array_40ld_t - disk array for 40LD controllers
|
||||||
|
* @numldrv : number of logical drives
|
||||||
|
* @resvd :
|
||||||
|
* @ldrv : logical drives information
|
||||||
|
* @pdrv : physical drives information
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t numldrv;
|
||||||
|
uint8_t resvd[3];
|
||||||
|
logdrv_40ld_t ldrv[MAX_LOGICAL_DRIVES_40LD];
|
||||||
|
phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
|
||||||
|
}__attribute__ ((packed)) disk_array_40ld_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* disk_array_8ld_span8_t - disk array for 8LD controllers
|
||||||
|
* @numldrv : number of logical drives
|
||||||
|
* @resvd :
|
||||||
|
* @ldrv : logical drives information
|
||||||
|
* @pdrv : physical drives information
|
||||||
|
*
|
||||||
|
* Disk array for 8LD logical drives with upto 8 spans
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t numldrv;
|
||||||
|
uint8_t resvd[3];
|
||||||
|
logdrv_8ld_span8_t ldrv[MAX_LOGICAL_DRIVES_8LD];
|
||||||
|
phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
|
||||||
|
}__attribute__ ((packed)) disk_array_8ld_span8_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* disk_array_8ld_span4_t - disk array for 8LD controllers
|
||||||
|
* @numldrv : number of logical drives
|
||||||
|
* @resvd :
|
||||||
|
* @ldrv : logical drives information
|
||||||
|
* @pdrv : physical drives information
|
||||||
|
*
|
||||||
|
* Disk array for 8LD logical drives with upto 4 spans
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t numldrv;
|
||||||
|
uint8_t resvd[3];
|
||||||
|
logdrv_8ld_span4_t ldrv[MAX_LOGICAL_DRIVES_8LD];
|
||||||
|
phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
|
||||||
|
}__attribute__ ((packed)) disk_array_8ld_span4_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* private_bios_data - bios private data for boot devices
|
||||||
|
* @geometry : bits 0-3 - BIOS geometry, 0x0001 - 1GB, 0x0010 - 2GB,
|
||||||
|
* 0x1000 - 8GB, Others values are invalid
|
||||||
|
* @unused : bits 4-7 are unused
|
||||||
|
* @boot_drv : logical drive set as boot drive, 0..7 - for 8LD cards,
|
||||||
|
* 0..39 - for 40LD cards
|
||||||
|
* @cksum : 0-(sum of first 13 bytes of this structure)
|
||||||
|
*/
|
||||||
|
struct private_bios_data {
|
||||||
|
uint8_t geometry :4;
|
||||||
|
uint8_t unused :4;
|
||||||
|
uint8_t boot_drv;
|
||||||
|
uint8_t rsvd[12];
|
||||||
|
uint16_t cksum;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbox_sgl64 - 64-bit scatter list for mailbox based controllers
|
||||||
|
* @address : address of the buffer
|
||||||
|
* @length : data transfer length
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint64_t address;
|
||||||
|
uint32_t length;
|
||||||
|
} __attribute__ ((packed)) mbox_sgl64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbox_sgl32 - 32-bit scatter list for mailbox based controllers
|
||||||
|
* @address : address of the buffer
|
||||||
|
* @length : data transfer length
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint32_t address;
|
||||||
|
uint32_t length;
|
||||||
|
} __attribute__ ((packed)) mbox_sgl32;
|
||||||
|
|
||||||
|
|
||||||
|
#undef wait_event
|
||||||
|
#define wait_event mraid_mm_diskdump_wait_event
|
||||||
|
#undef wake_up
|
||||||
|
#define wake_up mraid_mm_diskdump_wake_up
|
||||||
|
extern void mraid_mm_diskdump_schedule(void);
|
||||||
|
extern void mraid_mm_diskdump_wake_up(wait_queue_head_t *q);
|
||||||
|
|
||||||
|
|
||||||
|
#define __mraid_mm_diskdump_wait_event(wq, condition) \
|
||||||
|
do { \
|
||||||
|
wait_queue_t __wait; \
|
||||||
|
init_waitqueue_entry(&__wait, current); \
|
||||||
|
\
|
||||||
|
add_wait_queue(&wq, &__wait); \
|
||||||
|
for (;;) { \
|
||||||
|
set_current_state(TASK_UNINTERRUPTIBLE); \
|
||||||
|
if (condition) \
|
||||||
|
break; \
|
||||||
|
mraid_mm_diskdump_schedule(); \
|
||||||
|
} \
|
||||||
|
current->state = TASK_RUNNING; \
|
||||||
|
remove_wait_queue(&wq, &__wait); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define mraid_mm_diskdump_wait_event(wq, condition) \
|
||||||
|
do { \
|
||||||
|
if (condition) \
|
||||||
|
break; \
|
||||||
|
__mraid_mm_diskdump_wait_event(wq, condition); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _MRAID_MBOX_DEFS_H_
|
||||||
|
|
||||||
|
/* vim: set ts=8 sw=8 tw=78: */
|
290
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mega_common.h
Normal file
290
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/mega_common.h
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Linux MegaRAID device driver
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2004 LSI Logic Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FILE : mega_common.h
|
||||||
|
*
|
||||||
|
* Libaray of common routine used by all low-level megaraid drivers
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MEGA_COMMON_H_
|
||||||
|
#define _MEGA_COMMON_H_
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include <linux/pci.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
#include <linux/interrupt.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
#include <linux/list.h>
|
||||||
|
#include <linux/version.h>
|
||||||
|
#include <linux/moduleparam.h>
|
||||||
|
#include <linux/dma-mapping.h>
|
||||||
|
#include <linux/diskdump.h>
|
||||||
|
#include <asm/semaphore.h>
|
||||||
|
#include <scsi/scsi.h>
|
||||||
|
#include <scsi/scsi_cmnd.h>
|
||||||
|
#include <scsi/scsi_device.h>
|
||||||
|
#include <scsi/scsi_host.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define LSI_MAX_CHANNELS 16
|
||||||
|
#define LSI_MAX_LOGICAL_DRIVES_64LD (64+1)
|
||||||
|
|
||||||
|
#define HBA_SIGNATURE_64BIT 0x0299
|
||||||
|
#define PCI_CONF_AMISIG64 0xa4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scb_t - scsi command control block
|
||||||
|
* @param ccb : command control block for individual driver
|
||||||
|
* @param list : list of control blocks
|
||||||
|
* @param gp : general purpose field for LLDs
|
||||||
|
* @param sno : all SCBs have a serial number
|
||||||
|
* @param scp : associated scsi command
|
||||||
|
* @param state : current state of scb
|
||||||
|
* @param dma_dir : direction of data transfer
|
||||||
|
* @param dma_type : transfer with sg list, buffer, or no data transfer
|
||||||
|
* @param dev_channel : actual channel on the device
|
||||||
|
* @param dev_target : actual target on the device
|
||||||
|
* @param status : completion status
|
||||||
|
*
|
||||||
|
* This is our central data structure to issue commands the each driver.
|
||||||
|
* Driver specific data structures are maintained in the ccb field.
|
||||||
|
* scb provides a field 'gp', which can be used by LLD for its own purposes
|
||||||
|
*
|
||||||
|
* dev_channel and dev_target must be initialized with the actual channel and
|
||||||
|
* target on the controller.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
caddr_t ccb;
|
||||||
|
struct list_head list;
|
||||||
|
unsigned long gp;
|
||||||
|
unsigned int sno;
|
||||||
|
struct scsi_cmnd *scp;
|
||||||
|
uint32_t state;
|
||||||
|
uint32_t dma_direction;
|
||||||
|
uint32_t dma_type;
|
||||||
|
uint16_t dev_channel;
|
||||||
|
uint16_t dev_target;
|
||||||
|
uint32_t status;
|
||||||
|
} scb_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SCB states as it transitions from one state to another
|
||||||
|
*/
|
||||||
|
#define SCB_FREE 0x0000 /* on the free list */
|
||||||
|
#define SCB_ACTIVE 0x0001 /* off the free list */
|
||||||
|
#define SCB_PENDQ 0x0002 /* on the pending queue */
|
||||||
|
#define SCB_ISSUED 0x0004 /* issued - owner f/w */
|
||||||
|
#define SCB_ABORT 0x0008 /* Got an abort for this one */
|
||||||
|
#define SCB_RESET 0x0010 /* Got a reset for this one */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DMA types for scb
|
||||||
|
*/
|
||||||
|
#define MRAID_DMA_NONE 0x0000 /* no data transfer for this command */
|
||||||
|
#define MRAID_DMA_WSG 0x0001 /* data transfer using a sg list */
|
||||||
|
#define MRAID_DMA_WBUF 0x0002 /* data transfer using a contiguous buffer */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct adapter_t - driver's initialization structure
|
||||||
|
* @param dpc_h : tasklet handle
|
||||||
|
* @param pdev : pci configuration pointer for kernel
|
||||||
|
* @param host : pointer to host structure of mid-layer
|
||||||
|
* @param host_lock : pointer to appropriate lock
|
||||||
|
* @param lock : synchronization lock for mid-layer and driver
|
||||||
|
* @param quiescent : driver is quiescent for now.
|
||||||
|
* @param outstanding_cmds : number of commands pending in the driver
|
||||||
|
* @param kscb_list : pointer to the bulk of SCBs pointers for IO
|
||||||
|
* @param kscb_pool : pool of free scbs for IO
|
||||||
|
* @param kscb_pool_lock : lock for pool of free scbs
|
||||||
|
* @param pend_list : pending commands list
|
||||||
|
* @param pend_list_lock : exlusion lock for pending commands list
|
||||||
|
* @param completed_list : list of completed commands
|
||||||
|
* @param completed_list_lock : exclusion lock for list of completed commands
|
||||||
|
* @param sglen : max sg elements supported
|
||||||
|
* @param device_ids : to convert kernel device addr to our devices.
|
||||||
|
* @param raid_device : raid adapter specific pointer
|
||||||
|
* @param max_channel : maximum channel number supported - inclusive
|
||||||
|
* @param max_target : max target supported - inclusive
|
||||||
|
* @param max_lun : max lun supported - inclusive
|
||||||
|
* @param unique_id : unique identifier for each adapter
|
||||||
|
* @param irq : IRQ for this adapter
|
||||||
|
* @param ito : internal timeout value, (-1) means no timeout
|
||||||
|
* @param ibuf : buffer to issue internal commands
|
||||||
|
* @param ibuf_dma_h : dma handle for the above buffer
|
||||||
|
* @param uscb_list : SCB pointers for user cmds, common mgmt module
|
||||||
|
* @param uscb_pool : pool of SCBs for user commands
|
||||||
|
* @param uscb_pool_lock : exclusion lock for these SCBs
|
||||||
|
* @param max_cmds : max outstanding commands
|
||||||
|
* @param fw_version : firmware version
|
||||||
|
* @param bios_version : bios version
|
||||||
|
* @param max_cdb_sz : biggest CDB size supported.
|
||||||
|
* @param ha : is high availability present - clustering
|
||||||
|
* @param init_id : initiator ID, the default value should be 7
|
||||||
|
* @param max_sectors : max sectors per request
|
||||||
|
* @param cmd_per_lun : max outstanding commands per LUN
|
||||||
|
* @param being_detached : set when unloading, no more mgmt calls
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* mraid_setup_device_map() can be called anytime after the device map is
|
||||||
|
* available and MRAID_GET_DEVICE_MAP() can be called whenever the mapping is
|
||||||
|
* required, usually from LLD's queue entry point. The formar API sets up the
|
||||||
|
* MRAID_IS_LOGICAL(adapter_t *, struct scsi_cmnd *) to find out if the
|
||||||
|
* device in question is a logical drive.
|
||||||
|
*
|
||||||
|
* quiescent flag should be set by the driver if it is not accepting more
|
||||||
|
* commands
|
||||||
|
*
|
||||||
|
* NOTE: The fields of this structures are placed to minimize cache misses
|
||||||
|
*/
|
||||||
|
|
||||||
|
// amount of space required to store the bios and firmware version strings
|
||||||
|
#define VERSION_SIZE 16
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct tasklet_struct dpc_h;
|
||||||
|
struct pci_dev *pdev;
|
||||||
|
struct Scsi_Host *host;
|
||||||
|
spinlock_t *host_lock;
|
||||||
|
spinlock_t lock;
|
||||||
|
uint8_t quiescent;
|
||||||
|
int outstanding_cmds;
|
||||||
|
scb_t *kscb_list;
|
||||||
|
struct list_head kscb_pool;
|
||||||
|
spinlock_t kscb_pool_lock;
|
||||||
|
struct list_head pend_list;
|
||||||
|
spinlock_t pend_list_lock;
|
||||||
|
struct list_head completed_list;
|
||||||
|
spinlock_t completed_list_lock;
|
||||||
|
uint16_t sglen;
|
||||||
|
int device_ids[LSI_MAX_CHANNELS]
|
||||||
|
[LSI_MAX_LOGICAL_DRIVES_64LD];
|
||||||
|
caddr_t raid_device;
|
||||||
|
uint8_t max_channel;
|
||||||
|
uint16_t max_target;
|
||||||
|
uint8_t max_lun;
|
||||||
|
|
||||||
|
uint32_t unique_id;
|
||||||
|
uint8_t irq;
|
||||||
|
uint8_t ito;
|
||||||
|
caddr_t ibuf;
|
||||||
|
dma_addr_t ibuf_dma_h;
|
||||||
|
scb_t *uscb_list;
|
||||||
|
struct list_head uscb_pool;
|
||||||
|
spinlock_t uscb_pool_lock;
|
||||||
|
int max_cmds;
|
||||||
|
uint8_t fw_version[VERSION_SIZE];
|
||||||
|
uint8_t bios_version[VERSION_SIZE];
|
||||||
|
uint8_t max_cdb_sz;
|
||||||
|
uint8_t ha;
|
||||||
|
uint16_t init_id;
|
||||||
|
uint16_t max_sectors;
|
||||||
|
uint16_t cmd_per_lun;
|
||||||
|
atomic_t being_detached;
|
||||||
|
} adapter_t;
|
||||||
|
|
||||||
|
#define SCSI_FREE_LIST_LOCK(adapter) (&adapter->kscb_pool_lock)
|
||||||
|
#define USER_FREE_LIST_LOCK(adapter) (&adapter->uscb_pool_lock)
|
||||||
|
#define PENDING_LIST_LOCK(adapter) (&adapter->pend_list_lock)
|
||||||
|
#define COMPLETED_LIST_LOCK(adapter) (&adapter->completed_list_lock)
|
||||||
|
|
||||||
|
|
||||||
|
// conversion from scsi command
|
||||||
|
#define SCP2HOST(scp) (scp)->device->host // to host
|
||||||
|
#define SCP2HOSTDATA(scp) SCP2HOST(scp)->hostdata // to soft state
|
||||||
|
#define SCP2CHANNEL(scp) (scp)->device->channel // to channel
|
||||||
|
#define SCP2TARGET(scp) (scp)->device->id // to target
|
||||||
|
#define SCP2LUN(scp) (scp)->device->lun // to LUN
|
||||||
|
|
||||||
|
// generic macro to convert scsi command and host to controller's soft state
|
||||||
|
#define SCSIHOST2ADAP(host) (((caddr_t *)(host->hostdata))[0])
|
||||||
|
#define SCP2ADAPTER(scp) (adapter_t *)SCSIHOST2ADAP(SCP2HOST(scp))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MRAID_GET_DEVICE_MAP - device ids
|
||||||
|
* @param adp - Adapter's soft state
|
||||||
|
* @param scp - mid-layer scsi command pointer
|
||||||
|
* @param p_chan - physical channel on the controller
|
||||||
|
* @param target - target id of the device or logical drive number
|
||||||
|
* @param islogical - set if the command is for the logical drive
|
||||||
|
*
|
||||||
|
* Macro to retrieve information about device class, logical or physical and
|
||||||
|
* the corresponding physical channel and target or logical drive number
|
||||||
|
**/
|
||||||
|
#define MRAID_IS_LOGICAL(adp, scp) \
|
||||||
|
(SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0
|
||||||
|
|
||||||
|
#define MRAID_IS_LOGICAL_SDEV(adp, sdev) \
|
||||||
|
(sdev->channel == (adp)->max_channel) ? 1 : 0
|
||||||
|
|
||||||
|
#define MRAID_GET_DEVICE_MAP(adp, scp, p_chan, target, islogical) \
|
||||||
|
/* \
|
||||||
|
* Is the request coming for the virtual channel \
|
||||||
|
*/ \
|
||||||
|
islogical = MRAID_IS_LOGICAL(adp, scp); \
|
||||||
|
\
|
||||||
|
/* \
|
||||||
|
* Get an index into our table of drive ids mapping \
|
||||||
|
*/ \
|
||||||
|
if (islogical) { \
|
||||||
|
p_chan = 0xFF; \
|
||||||
|
target = \
|
||||||
|
(adp)->device_ids[(adp)->max_channel][SCP2TARGET(scp)]; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
p_chan = ((adp)->device_ids[SCP2CHANNEL(scp)] \
|
||||||
|
[SCP2TARGET(scp)] >> 8) & 0xFF; \
|
||||||
|
target = ((adp)->device_ids[SCP2CHANNEL(scp)] \
|
||||||
|
[SCP2TARGET(scp)] & 0xFF); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ### Helper routines ###
|
||||||
|
*/
|
||||||
|
#define LSI_DBGLVL mraid_debug_level // each LLD must define a global
|
||||||
|
// mraid_debug_level
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#if defined (_ASSERT_PANIC)
|
||||||
|
#define ASSERT_ACTION panic
|
||||||
|
#else
|
||||||
|
#define ASSERT_ACTION printk
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ASSERT(expression) \
|
||||||
|
if (!(expression)) { \
|
||||||
|
ASSERT_ACTION("assertion failed:(%s), file: %s, line: %d:%s\n", \
|
||||||
|
#expression, __FILE__, __LINE__, __FUNCTION__); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define ASSERT(expression)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* struct mraid_pci_blk - structure holds DMA memory block info
|
||||||
|
* @param vaddr : virtual address to a memory block
|
||||||
|
* @param dma_addr : DMA handle to a memory block
|
||||||
|
*
|
||||||
|
* This structure is filled up for the caller. It is the responsibilty of the
|
||||||
|
* caller to allocate this array big enough to store addresses for all
|
||||||
|
* requested elements
|
||||||
|
*/
|
||||||
|
struct mraid_pci_blk {
|
||||||
|
caddr_t vaddr;
|
||||||
|
dma_addr_t dma_addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _MEGA_COMMON_H_
|
||||||
|
|
||||||
|
// vim: set ts=8 sw=8 tw=78:
|
@ -0,0 +1,300 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Linux MegaRAID device driver
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2004 LSI Logic Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FILE : megaraid_ioctl.h
|
||||||
|
*
|
||||||
|
* Definitions to interface with user level applications
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MEGARAID_IOCTL_H_
|
||||||
|
#define _MEGARAID_IOCTL_H_
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include <asm/semaphore.h>
|
||||||
|
|
||||||
|
#include "mbox_defs.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* con_log() - console log routine
|
||||||
|
* @param level : indicates the severity of the message.
|
||||||
|
* @fparam mt : format string
|
||||||
|
*
|
||||||
|
* con_log displays the error messages on the console based on the current
|
||||||
|
* debug level. Also it attaches the appropriate kernel severity level with
|
||||||
|
* the message.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* consolge messages debug levels
|
||||||
|
*/
|
||||||
|
#define CL_ANN 0 /* print unconditionally, announcements */
|
||||||
|
#define CL_DLEVEL1 1 /* debug level 1, informative */
|
||||||
|
#define CL_DLEVEL2 2 /* debug level 2, verbose */
|
||||||
|
#define CL_DLEVEL3 3 /* debug level 3, very verbose */
|
||||||
|
|
||||||
|
#define con_log(level, fmt) if (LSI_DBGLVL >= level) printk fmt;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Definitions & Declarations needed to use common management module
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MEGAIOC_MAGIC 'm'
|
||||||
|
#define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, mimd_t)
|
||||||
|
|
||||||
|
#define MEGAIOC_QNADAP 'm' /* Query # of adapters */
|
||||||
|
#define MEGAIOC_QDRVRVER 'e' /* Query driver version */
|
||||||
|
#define MEGAIOC_QADAPINFO 'g' /* Query adapter information */
|
||||||
|
|
||||||
|
#define USCSICMD 0x80
|
||||||
|
#define UIOC_RD 0x00001
|
||||||
|
#define UIOC_WR 0x00002
|
||||||
|
|
||||||
|
#define MBOX_CMD 0x00000
|
||||||
|
#define GET_DRIVER_VER 0x10000
|
||||||
|
#define GET_N_ADAP 0x20000
|
||||||
|
#define GET_ADAP_INFO 0x30000
|
||||||
|
#define GET_CAP 0x40000
|
||||||
|
#define GET_STATS 0x50000
|
||||||
|
#define GET_IOCTL_VERSION 0x01
|
||||||
|
|
||||||
|
#define EXT_IOCTL_SIGN_SZ 16
|
||||||
|
#define EXT_IOCTL_SIGN "$$_EXTD_IOCTL_$$"
|
||||||
|
|
||||||
|
#define MBOX_LEGACY 0x00 /* ioctl has legacy mbox*/
|
||||||
|
#define MBOX_HPE 0x01 /* ioctl has hpe mbox */
|
||||||
|
|
||||||
|
#define APPTYPE_MIMD 0x00 /* old existing apps */
|
||||||
|
#define APPTYPE_UIOC 0x01 /* new apps using uioc */
|
||||||
|
|
||||||
|
#define IOCTL_ISSUE 0x00000001 /* Issue ioctl */
|
||||||
|
#define IOCTL_ABORT 0x00000002 /* Abort previous ioctl */
|
||||||
|
|
||||||
|
#define DRVRTYPE_MBOX 0x00000001 /* regular mbox driver */
|
||||||
|
#define DRVRTYPE_HPE 0x00000002 /* new hpe driver */
|
||||||
|
|
||||||
|
#define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) )
|
||||||
|
#define GETADAP(mkadap) ((mkadap) ^ MEGAIOC_MAGIC << 8)
|
||||||
|
|
||||||
|
#define MAX_DMA_POOLS 5 /* 4k, 8k, 16k, 32k, 64k*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct uioc_t - the common ioctl packet structure
|
||||||
|
*
|
||||||
|
* @signature : Must be "$$_EXTD_IOCTL_$$"
|
||||||
|
* @mb_type : Type of the mail box (MB_LEGACY or MB_HPE)
|
||||||
|
* @app_type : Type of the issuing application (existing or new)
|
||||||
|
* @opcode : Opcode of the command
|
||||||
|
* @adapno : Adapter number
|
||||||
|
* @cmdbuf : Pointer to buffer - can point to mbox or plain data buffer
|
||||||
|
* @xferlen : xferlen for DCMD and non mailbox commands
|
||||||
|
* @data_dir : Direction of the data transfer
|
||||||
|
* @status : Status from the driver
|
||||||
|
* @reserved : reserved bytes for future expansion
|
||||||
|
*
|
||||||
|
* @user_data : user data transfer address is saved in this
|
||||||
|
* @user_data_len: length of the data buffer sent by user app
|
||||||
|
* @user_pthru : user passthru address is saves in this (null if DCMD)
|
||||||
|
* @pthru32 : kernel address passthru (allocated per kioc)
|
||||||
|
* @pthru32_h : physicall address of @pthru32
|
||||||
|
* @list : for kioc free pool list maintenance
|
||||||
|
* @done : call back routine for llds to call when kioc is completed
|
||||||
|
* @buf_vaddr : dma pool buffer attached to kioc for data transfer
|
||||||
|
* @buf_paddr : physical address of the dma pool buffer
|
||||||
|
* @pool_index : index of the dma pool that @buf_vaddr is taken from
|
||||||
|
* @free_buf : indicates if buffer needs to be freed after kioc completes
|
||||||
|
*
|
||||||
|
* Note : All LSI drivers understand only this packet. Any other
|
||||||
|
* : format sent by applications would be converted to this.
|
||||||
|
*/
|
||||||
|
typedef struct uioc {
|
||||||
|
|
||||||
|
/* User Apps: */
|
||||||
|
|
||||||
|
uint8_t signature[EXT_IOCTL_SIGN_SZ];
|
||||||
|
uint16_t mb_type;
|
||||||
|
uint16_t app_type;
|
||||||
|
uint32_t opcode;
|
||||||
|
uint32_t adapno;
|
||||||
|
uint64_t cmdbuf;
|
||||||
|
uint32_t xferlen;
|
||||||
|
uint32_t data_dir;
|
||||||
|
int32_t status;
|
||||||
|
uint8_t reserved[128];
|
||||||
|
|
||||||
|
/* Driver Data: */
|
||||||
|
void __user * user_data;
|
||||||
|
uint32_t user_data_len;
|
||||||
|
|
||||||
|
/* 64bit alignment */
|
||||||
|
uint32_t pad_for_64bit_align;
|
||||||
|
|
||||||
|
mraid_passthru_t __user *user_pthru;
|
||||||
|
|
||||||
|
mraid_passthru_t *pthru32;
|
||||||
|
dma_addr_t pthru32_h;
|
||||||
|
|
||||||
|
struct list_head list;
|
||||||
|
void (*done)(struct uioc*);
|
||||||
|
|
||||||
|
caddr_t buf_vaddr;
|
||||||
|
dma_addr_t buf_paddr;
|
||||||
|
int8_t pool_index;
|
||||||
|
uint8_t free_buf;
|
||||||
|
|
||||||
|
uint8_t timedout;
|
||||||
|
|
||||||
|
} __attribute__ ((aligned(1024),packed)) uioc_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct mraid_hba_info - information about the controller
|
||||||
|
*
|
||||||
|
* @param pci_vendor_id : PCI vendor id
|
||||||
|
* @param pci_device_id : PCI device id
|
||||||
|
* @param subsystem_vendor_id : PCI subsystem vendor id
|
||||||
|
* @param subsystem_device_id : PCI subsystem device id
|
||||||
|
* @param baseport : base port of hba memory
|
||||||
|
* @param pci_bus : PCI bus
|
||||||
|
* @param pci_dev_fn : PCI device/function values
|
||||||
|
* @param irq : interrupt vector for the device
|
||||||
|
*
|
||||||
|
* Extended information of 256 bytes about the controller. Align on the single
|
||||||
|
* byte boundary so that 32-bit applications can be run on 64-bit platform
|
||||||
|
* drivers withoug re-compilation.
|
||||||
|
* NOTE: reduce the number of reserved bytes whenever new field are added, so
|
||||||
|
* that total size of the structure remains 256 bytes.
|
||||||
|
*/
|
||||||
|
typedef struct mraid_hba_info {
|
||||||
|
|
||||||
|
uint16_t pci_vendor_id;
|
||||||
|
uint16_t pci_device_id;
|
||||||
|
uint16_t subsys_vendor_id;
|
||||||
|
uint16_t subsys_device_id;
|
||||||
|
|
||||||
|
uint64_t baseport;
|
||||||
|
uint8_t pci_bus;
|
||||||
|
uint8_t pci_dev_fn;
|
||||||
|
uint8_t pci_slot;
|
||||||
|
uint8_t irq;
|
||||||
|
|
||||||
|
uint32_t unique_id;
|
||||||
|
uint32_t host_no;
|
||||||
|
|
||||||
|
uint8_t num_ldrv;
|
||||||
|
} __attribute__ ((aligned(256), packed)) mraid_hba_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mcontroller : adapter info structure for old mimd_t apps
|
||||||
|
*
|
||||||
|
* @base : base address
|
||||||
|
* @irq : irq number
|
||||||
|
* @numldrv : number of logical drives
|
||||||
|
* @pcibus : pci bus
|
||||||
|
* @pcidev : pci device
|
||||||
|
* @pcifun : pci function
|
||||||
|
* @pciid : pci id
|
||||||
|
* @pcivendor : vendor id
|
||||||
|
* @pcislot : slot number
|
||||||
|
* @uid : unique id
|
||||||
|
*/
|
||||||
|
typedef struct mcontroller {
|
||||||
|
|
||||||
|
uint64_t base;
|
||||||
|
uint8_t irq;
|
||||||
|
uint8_t numldrv;
|
||||||
|
uint8_t pcibus;
|
||||||
|
uint16_t pcidev;
|
||||||
|
uint8_t pcifun;
|
||||||
|
uint16_t pciid;
|
||||||
|
uint16_t pcivendor;
|
||||||
|
uint8_t pcislot;
|
||||||
|
uint32_t uid;
|
||||||
|
|
||||||
|
} __attribute__ ((packed)) mcontroller_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_dmapool_t : Represents one dma pool with just one buffer
|
||||||
|
*
|
||||||
|
* @vaddr : Virtual address
|
||||||
|
* @paddr : DMA physicall address
|
||||||
|
* @bufsize : In KB - 4 = 4k, 8 = 8k etc.
|
||||||
|
* @handle : Handle to the dma pool
|
||||||
|
* @lock : lock to synchronize access to the pool
|
||||||
|
* @in_use : If pool already in use, attach new block
|
||||||
|
*/
|
||||||
|
typedef struct mm_dmapool {
|
||||||
|
caddr_t vaddr;
|
||||||
|
dma_addr_t paddr;
|
||||||
|
uint32_t buf_size;
|
||||||
|
struct dma_pool *handle;
|
||||||
|
spinlock_t lock;
|
||||||
|
uint8_t in_use;
|
||||||
|
} mm_dmapool_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_mmadp_t: Structure that drivers pass during (un)registration
|
||||||
|
*
|
||||||
|
* @unique_id : Any unique id (usually PCI bus+dev+fn)
|
||||||
|
* @drvr_type : megaraid or hpe (DRVRTYPE_MBOX or DRVRTYPE_HPE)
|
||||||
|
* @drv_data : Driver specific; not touched by the common module
|
||||||
|
* @timeout : timeout for issued kiocs
|
||||||
|
* @max_kioc : Maximum ioctl packets acceptable by the lld
|
||||||
|
* @pdev : pci dev; used for allocating dma'ble memory
|
||||||
|
* @issue_uioc : Driver supplied routine to issue uioc_t commands
|
||||||
|
* : issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done)
|
||||||
|
* @quiescent : flag to indicate if ioctl can be issued to this adp
|
||||||
|
* @list : attach with the global list of adapters
|
||||||
|
* @kioc_list : block of mem for @max_kioc number of kiocs
|
||||||
|
* @kioc_pool : pool of free kiocs
|
||||||
|
* @kioc_pool_lock : protection for free pool
|
||||||
|
* @kioc_semaphore : so as not to exceed @max_kioc parallel ioctls
|
||||||
|
* @mbox_list : block of mem for @max_kioc number of mboxes
|
||||||
|
* @pthru_dma_pool : DMA pool to allocate passthru packets
|
||||||
|
* @dma_pool_list : array of dma pools
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct mraid_mmadp {
|
||||||
|
|
||||||
|
/* Filled by driver */
|
||||||
|
|
||||||
|
uint32_t unique_id;
|
||||||
|
uint32_t drvr_type;
|
||||||
|
unsigned long drvr_data;
|
||||||
|
uint16_t timeout;
|
||||||
|
uint8_t max_kioc;
|
||||||
|
|
||||||
|
struct pci_dev *pdev;
|
||||||
|
|
||||||
|
int(*issue_uioc)(unsigned long, uioc_t *, uint32_t);
|
||||||
|
|
||||||
|
/* Maintained by common module */
|
||||||
|
uint32_t quiescent;
|
||||||
|
|
||||||
|
struct list_head list;
|
||||||
|
uioc_t *kioc_list;
|
||||||
|
struct list_head kioc_pool;
|
||||||
|
spinlock_t kioc_pool_lock;
|
||||||
|
struct semaphore kioc_semaphore;
|
||||||
|
|
||||||
|
mbox64_t *mbox_list;
|
||||||
|
struct dma_pool *pthru_dma_pool;
|
||||||
|
mm_dmapool_t dma_pool_list[MAX_DMA_POOLS];
|
||||||
|
|
||||||
|
} mraid_mmadp_t;
|
||||||
|
|
||||||
|
int mraid_mm_register_adp(mraid_mmadp_t *);
|
||||||
|
int mraid_mm_unregister_adp(uint32_t);
|
||||||
|
uint32_t mraid_mm_adapter_app_handle(uint32_t);
|
||||||
|
|
||||||
|
#endif /* _MEGARAID_IOCTL_H_ */
|
4330
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.c
Normal file
4330
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.c
Normal file
File diff suppressed because it is too large
Load Diff
237
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.h
Normal file
237
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mbox.h
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Linux MegaRAID device driver
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2004 LSI Logic Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FILE : megaraid_mbox.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MEGARAID_H_
|
||||||
|
#define _MEGARAID_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "mega_common.h"
|
||||||
|
#include "mbox_defs.h"
|
||||||
|
#include "megaraid_ioctl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MEGARAID_VERSION "2.20.4.6-rh2"
|
||||||
|
#define MEGARAID_EXT_VERSION "(Release Date: Wed Jun 28 12:27:22 EST 2006)"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define some PCI values here until they are put in the kernel
|
||||||
|
*/
|
||||||
|
#define PCI_DEVICE_ID_PERC4_DI_DISCOVERY 0x000E
|
||||||
|
#define PCI_SUBSYS_ID_PERC4_DI_DISCOVERY 0x0123
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4_SC 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_PERC4_SC 0x0520
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4_DC 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_PERC4_DC 0x0518
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_VERDE 0x0407
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4_DI_EVERGLADES 0x000F
|
||||||
|
#define PCI_SUBSYS_ID_PERC4_DI_EVERGLADES 0x014A
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4E_SI_BIGBEND 0x0013
|
||||||
|
#define PCI_SUBSYS_ID_PERC4E_SI_BIGBEND 0x016c
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4E_DI_KOBUK 0x0013
|
||||||
|
#define PCI_SUBSYS_ID_PERC4E_DI_KOBUK 0x016d
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4E_DI_CORVETTE 0x0013
|
||||||
|
#define PCI_SUBSYS_ID_PERC4E_DI_CORVETTE 0x016e
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4E_DI_EXPEDITION 0x0013
|
||||||
|
#define PCI_SUBSYS_ID_PERC4E_DI_EXPEDITION 0x016f
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_PERC4E_DI_GUADALUPE 0x0013
|
||||||
|
#define PCI_SUBSYS_ID_PERC4E_DI_GUADALUPE 0x0170
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_DOBSON 0x0408
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_MEGARAID_SCSI_320_0 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_0 0xA520
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_MEGARAID_SCSI_320_1 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_1 0x0520
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_MEGARAID_SCSI_320_2 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_2 0x0518
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_MEGARAID_I4_133_RAID 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_MEGARAID_I4_133_RAID 0x0522
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_MEGARAID_SATA_150_4 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_MEGARAID_SATA_150_4 0x4523
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_MEGARAID_SATA_150_6 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_MEGARAID_SATA_150_6 0x0523
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_LINDSAY 0x0409
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_INTEL_RAID_SRCS16 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_INTEL_RAID_SRCS16 0x0523
|
||||||
|
|
||||||
|
#define PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x1960
|
||||||
|
#define PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x0520
|
||||||
|
|
||||||
|
#define PCI_SUBSYS_ID_PERC3_QC 0x0471
|
||||||
|
#define PCI_SUBSYS_ID_PERC3_DC 0x0493
|
||||||
|
#define PCI_SUBSYS_ID_PERC3_SC 0x0475
|
||||||
|
|
||||||
|
|
||||||
|
#define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel
|
||||||
|
#define MBOX_MAX_USER_CMDS 32 // number of cmds for applications
|
||||||
|
#define MBOX_DEF_CMD_PER_LUN 64 // default commands per lun
|
||||||
|
#define MBOX_DEFAULT_SG_SIZE 26 // default sg size supported by all fw
|
||||||
|
#define MBOX_MAX_SG_SIZE 32 // maximum scatter-gather list size
|
||||||
|
#define MBOX_MAX_SECTORS 128 // maximum sectors per IO
|
||||||
|
#define MBOX_TIMEOUT 30 // timeout value for internal cmds
|
||||||
|
#define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox
|
||||||
|
#define MBOX_RESET_WAIT 180 // wait these many seconds in reset
|
||||||
|
#define MBOX_RESET_EXT_WAIT 120 // extended wait reset
|
||||||
|
#define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode
|
||||||
|
|
||||||
|
#define MBOX_SYNC_DELAY_200 200 // 200 micro-secondes
|
||||||
|
|
||||||
|
/*
|
||||||
|
* maximum transfer that can happen through the firmware commands issued
|
||||||
|
* internnaly from the driver.
|
||||||
|
*/
|
||||||
|
#define MBOX_IBUF_SIZE 4096
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbox_ccb_t - command control block specific to mailbox based controllers
|
||||||
|
* @raw_mbox : raw mailbox pointer
|
||||||
|
* @mbox : mailbox
|
||||||
|
* @mbox64 : extended mailbox
|
||||||
|
* @mbox_dma_h : maibox dma address
|
||||||
|
* @sgl64 : 64-bit scatter-gather list
|
||||||
|
* @sgl32 : 32-bit scatter-gather list
|
||||||
|
* @sgl_dma_h : dma handle for the scatter-gather list
|
||||||
|
* @pthru : passthru structure
|
||||||
|
* @pthru_dma_h : dma handle for the passthru structure
|
||||||
|
* @epthru : extended passthru structure
|
||||||
|
* @epthru_dma_h : dma handle for extended passthru structure
|
||||||
|
* @buf_dma_h : dma handle for buffers w/o sg list
|
||||||
|
*
|
||||||
|
* command control block specific to the mailbox based controllers
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t *raw_mbox;
|
||||||
|
mbox_t *mbox;
|
||||||
|
mbox64_t *mbox64;
|
||||||
|
dma_addr_t mbox_dma_h;
|
||||||
|
mbox_sgl64 *sgl64;
|
||||||
|
mbox_sgl32 *sgl32;
|
||||||
|
dma_addr_t sgl_dma_h;
|
||||||
|
mraid_passthru_t *pthru;
|
||||||
|
dma_addr_t pthru_dma_h;
|
||||||
|
mraid_epassthru_t *epthru;
|
||||||
|
dma_addr_t epthru_dma_h;
|
||||||
|
dma_addr_t buf_dma_h;
|
||||||
|
} mbox_ccb_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mraid_device_t - adapter soft state structure for mailbox controllers
|
||||||
|
* @param una_mbox64 : 64-bit mbox - unaligned
|
||||||
|
* @param una_mbox64_dma : mbox dma addr - unaligned
|
||||||
|
* @param mbox : 32-bit mbox - aligned
|
||||||
|
* @param mbox64 : 64-bit mbox - aligned
|
||||||
|
* @param mbox_dma : mbox dma addr - aligned
|
||||||
|
* @param mailbox_lock : exclusion lock for the mailbox
|
||||||
|
* @param baseport : base port of hba memory
|
||||||
|
* @param baseaddr : mapped addr of hba memory
|
||||||
|
* @param mbox_pool : pool of mailboxes
|
||||||
|
* @param mbox_pool_handle : handle for the mailbox pool memory
|
||||||
|
* @param epthru_pool : a pool for extended passthru commands
|
||||||
|
* @param epthru_pool_handle : handle to the pool above
|
||||||
|
* @param sg_pool : pool of scatter-gather lists for this driver
|
||||||
|
* @param sg_pool_handle : handle to the pool above
|
||||||
|
* @param ccb_list : list of our command control blocks
|
||||||
|
* @param uccb_list : list of cmd control blocks for mgmt module
|
||||||
|
* @param umbox64 : array of mailbox for user commands (cmm)
|
||||||
|
* @param pdrv_state : array for state of each physical drive.
|
||||||
|
* @param last_disp : flag used to show device scanning
|
||||||
|
* @param hw_error : set if FW not responding
|
||||||
|
* @param fast_load : If set, skip physical device scanning
|
||||||
|
* @channel_class : channel class, RAID or SCSI
|
||||||
|
* @sysfs_sem : semaphore to serialize access to sysfs res.
|
||||||
|
* @sysfs_uioc : management packet to issue FW calls from sysfs
|
||||||
|
* @sysfs_mbox64 : mailbox packet to issue FW calls from sysfs
|
||||||
|
* @sysfs_buffer : data buffer for FW commands issued from sysfs
|
||||||
|
* @sysfs_buffer_dma : DMA buffer for FW commands issued from sysfs
|
||||||
|
* @sysfs_wait_q : wait queue for sysfs operations
|
||||||
|
* @random_del_supported : set if the random deletion is supported
|
||||||
|
* @curr_ldmap : current LDID map
|
||||||
|
*
|
||||||
|
* Initialization structure for mailbox controllers: memory based and IO based
|
||||||
|
* All the fields in this structure are LLD specific and may be discovered at
|
||||||
|
* init() or start() time.
|
||||||
|
*
|
||||||
|
* NOTE: The fields of this structures are placed to minimize cache misses
|
||||||
|
*/
|
||||||
|
#define MAX_LD_EXTENDED64 64
|
||||||
|
typedef struct {
|
||||||
|
mbox64_t *una_mbox64;
|
||||||
|
dma_addr_t una_mbox64_dma;
|
||||||
|
mbox_t *mbox;
|
||||||
|
mbox64_t *mbox64;
|
||||||
|
dma_addr_t mbox_dma;
|
||||||
|
spinlock_t mailbox_lock;
|
||||||
|
unsigned long baseport;
|
||||||
|
void __iomem * baseaddr;
|
||||||
|
struct mraid_pci_blk mbox_pool[MBOX_MAX_SCSI_CMDS];
|
||||||
|
struct dma_pool *mbox_pool_handle;
|
||||||
|
struct mraid_pci_blk epthru_pool[MBOX_MAX_SCSI_CMDS];
|
||||||
|
struct dma_pool *epthru_pool_handle;
|
||||||
|
struct mraid_pci_blk sg_pool[MBOX_MAX_SCSI_CMDS];
|
||||||
|
struct dma_pool *sg_pool_handle;
|
||||||
|
mbox_ccb_t ccb_list[MBOX_MAX_SCSI_CMDS];
|
||||||
|
mbox_ccb_t uccb_list[MBOX_MAX_USER_CMDS];
|
||||||
|
mbox64_t umbox64[MBOX_MAX_USER_CMDS];
|
||||||
|
|
||||||
|
uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
|
||||||
|
uint32_t last_disp;
|
||||||
|
int hw_error;
|
||||||
|
int fast_load;
|
||||||
|
uint8_t channel_class;
|
||||||
|
struct semaphore sysfs_sem;
|
||||||
|
uioc_t *sysfs_uioc;
|
||||||
|
mbox64_t *sysfs_mbox64;
|
||||||
|
caddr_t sysfs_buffer;
|
||||||
|
dma_addr_t sysfs_buffer_dma;
|
||||||
|
wait_queue_head_t sysfs_wait_q;
|
||||||
|
int random_del_supported;
|
||||||
|
uint16_t curr_ldmap[MAX_LD_EXTENDED64];
|
||||||
|
} mraid_device_t;
|
||||||
|
|
||||||
|
// route to raid device from adapter
|
||||||
|
#define ADAP2RAIDDEV(adp) ((mraid_device_t *)((adp)->raid_device))
|
||||||
|
|
||||||
|
#define MAILBOX_LOCK(rdev) (&(rdev)->mailbox_lock)
|
||||||
|
|
||||||
|
// Find out if this channel is a RAID or SCSI
|
||||||
|
#define IS_RAID_CH(rdev, ch) (((rdev)->channel_class >> (ch)) & 0x01)
|
||||||
|
|
||||||
|
|
||||||
|
#define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20)
|
||||||
|
#define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C)
|
||||||
|
#define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20)
|
||||||
|
#define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C)
|
||||||
|
|
||||||
|
#endif // _MEGARAID_H_
|
||||||
|
|
||||||
|
// vim: set ts=8 sw=8 tw=78:
|
1320
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.c
Normal file
1320
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.c
Normal file
File diff suppressed because it is too large
Load Diff
105
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.h
Normal file
105
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_mm.h
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Linux MegaRAID device driver
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2004 LSI Logic Corporation.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version
|
||||||
|
* 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FILE : megaraid_mm.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MEGARAID_MM_H
|
||||||
|
#define MEGARAID_MM_H
|
||||||
|
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
|
#include <asm/uaccess.h>
|
||||||
|
#include <linux/version.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <linux/moduleparam.h>
|
||||||
|
#include <linux/pci.h>
|
||||||
|
#include <linux/list.h>
|
||||||
|
#include <linux/ioctl32.h>
|
||||||
|
#include <linux/diskdump.h>
|
||||||
|
#include <scsi/scsi_device.h>
|
||||||
|
|
||||||
|
#include "mbox_defs.h"
|
||||||
|
#include "megaraid_ioctl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define LSI_COMMON_MOD_VERSION "2.20.2.6rh"
|
||||||
|
#define LSI_COMMON_MOD_EXT_VERSION \
|
||||||
|
"(Release Date: Tue Jan 16 12:35:06 PST 2007)"
|
||||||
|
|
||||||
|
|
||||||
|
#define LSI_DBGLVL dbglevel
|
||||||
|
|
||||||
|
// The smallest dma pool
|
||||||
|
#define MRAID_MM_INIT_BUFF_SIZE 4096
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mimd_t : Old style ioctl packet structure (deprecated)
|
||||||
|
*
|
||||||
|
* @inlen :
|
||||||
|
* @outlen :
|
||||||
|
* @fca :
|
||||||
|
* @opcode :
|
||||||
|
* @subopcode :
|
||||||
|
* @adapno :
|
||||||
|
* @buffer :
|
||||||
|
* @pad :
|
||||||
|
* @length :
|
||||||
|
* @mbox :
|
||||||
|
* @pthru :
|
||||||
|
* @data :
|
||||||
|
* @pad :
|
||||||
|
*
|
||||||
|
* Note : This structure is DEPRECATED. New applications must use
|
||||||
|
* : uioc_t structure instead. All new hba drivers use the new
|
||||||
|
* : format. If we get this mimd packet, we will convert it into
|
||||||
|
* : new uioc_t format and send it to the hba drivers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct mimd {
|
||||||
|
|
||||||
|
uint32_t inlen;
|
||||||
|
uint32_t outlen;
|
||||||
|
|
||||||
|
union {
|
||||||
|
uint8_t fca[16];
|
||||||
|
struct {
|
||||||
|
uint8_t opcode;
|
||||||
|
uint8_t subopcode;
|
||||||
|
uint16_t adapno;
|
||||||
|
#if BITS_PER_LONG == 32
|
||||||
|
uint8_t __user *buffer;
|
||||||
|
uint8_t pad[4];
|
||||||
|
#endif
|
||||||
|
#if BITS_PER_LONG == 64
|
||||||
|
uint8_t __user *buffer;
|
||||||
|
#endif
|
||||||
|
uint32_t length;
|
||||||
|
} __attribute__ ((packed)) fcs;
|
||||||
|
} __attribute__ ((packed)) ui;
|
||||||
|
|
||||||
|
uint8_t mbox[18]; /* 16 bytes + 2 status bytes */
|
||||||
|
mraid_passthru_t pthru;
|
||||||
|
|
||||||
|
#if BITS_PER_LONG == 32
|
||||||
|
char __user *data; /* buffer <= 4096 for 0x80 commands */
|
||||||
|
char pad[4];
|
||||||
|
#endif
|
||||||
|
#if BITS_PER_LONG == 64
|
||||||
|
char __user *data;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} __attribute__ ((packed))mimd_t;
|
||||||
|
|
||||||
|
#endif // MEGARAID_MM_H
|
||||||
|
|
||||||
|
// vi: set ts=8 sw=8 tw=78:
|
3159
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.c
Normal file
3159
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.c
Normal file
File diff suppressed because it is too large
Load Diff
1194
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.h
Normal file
1194
src/kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2/megaraid_sas.h
Normal file
File diff suppressed because it is too large
Load Diff
420
src/logpage.c
Normal file
420
src/logpage.c
Normal file
@ -0,0 +1,420 @@
|
|||||||
|
/*
|
||||||
|
* Parse and print SCSI log sense pages.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "megaioctl.h"
|
||||||
|
#include "logpage.h"
|
||||||
|
#include "ntrim.h"
|
||||||
|
#include "dumpbytes.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
|
||||||
|
static char *logPageType[] = {
|
||||||
|
/* 0 */ "supported log pages",
|
||||||
|
/* 1 */ "buffer over-run/under-run",
|
||||||
|
/* 2 */ "write error counter",
|
||||||
|
/* 3 */ "read error counter",
|
||||||
|
/* 4 */ "read reverse error counter",
|
||||||
|
/* 5 */ "verify error counter",
|
||||||
|
/* 6 */ "non-medium error",
|
||||||
|
/* 7 */ "last n error events",
|
||||||
|
/* 8 */ "format status",
|
||||||
|
/* 9 */ NULL,
|
||||||
|
/* a */ NULL,
|
||||||
|
/* b */ "last n deferred errors os asynchronous events",
|
||||||
|
/* c */ "sequential-access device",
|
||||||
|
/* d */ "temperature",
|
||||||
|
/* e */ "start-stop cycle counter",
|
||||||
|
/* f */ "application client",
|
||||||
|
/* 10 */ "self-test results",
|
||||||
|
/* 11 */ "DTD status",
|
||||||
|
/* 12 */ "TapeAlert response",
|
||||||
|
/* 13 */ "requested recover",
|
||||||
|
/* 14 */ "device statistics",
|
||||||
|
/* 15 */ NULL,
|
||||||
|
/* 16 */ NULL,
|
||||||
|
/* 17 */ "non-volatile cache",
|
||||||
|
/* 18 */ "protocol specific port",
|
||||||
|
/* 19 */ NULL,
|
||||||
|
/* 1a */ NULL,
|
||||||
|
/* 1b */ NULL,
|
||||||
|
/* 1c */ NULL,
|
||||||
|
/* 1d */ NULL,
|
||||||
|
/* 1e */ NULL,
|
||||||
|
/* 1f */ NULL,
|
||||||
|
/* 20 */ NULL,
|
||||||
|
/* 21 */ NULL,
|
||||||
|
/* 22 */ NULL,
|
||||||
|
/* 23 */ NULL,
|
||||||
|
/* 24 */ NULL,
|
||||||
|
/* 25 */ NULL,
|
||||||
|
/* 26 */ NULL,
|
||||||
|
/* 27 */ NULL,
|
||||||
|
/* 28 */ NULL,
|
||||||
|
/* 29 */ NULL,
|
||||||
|
/* 2a */ NULL,
|
||||||
|
/* 2b */ NULL,
|
||||||
|
/* 2c */ NULL,
|
||||||
|
/* 2d */ NULL,
|
||||||
|
/* 2e */ "TapeAlert",
|
||||||
|
/* 2f */ "informational exceptions",
|
||||||
|
/* 30 */ "vendor specific",
|
||||||
|
/* 31 */ "vendor specific",
|
||||||
|
/* 32 */ "vendor specific",
|
||||||
|
/* 33 */ "vendor specific",
|
||||||
|
/* 34 */ "vendor specific",
|
||||||
|
/* 35 */ "vendor specific",
|
||||||
|
/* 36 */ "vendor specific",
|
||||||
|
/* 37 */ "vendor specific",
|
||||||
|
/* 38 */ "vendor specific",
|
||||||
|
/* 39 */ "vendor specific",
|
||||||
|
/* 3a */ "vendor specific",
|
||||||
|
/* 3b */ "vendor specific",
|
||||||
|
/* 3c */ "vendor specific",
|
||||||
|
/* 3d */ "vendor specific",
|
||||||
|
/* 3e */ "vendor specific",
|
||||||
|
/* 3f */ NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static char *friendlySize (uint64_t b, char *unit)
|
||||||
|
{
|
||||||
|
static char *suffix[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi", };
|
||||||
|
int k;
|
||||||
|
static char bytes[128];
|
||||||
|
|
||||||
|
for (k = 0; (b >= 1024) && (k < sizeof (suffix) / sizeof (suffix[0]) - 1); ++k, b /= 1024)
|
||||||
|
;
|
||||||
|
snprintf (bytes, sizeof bytes, "%3llu%s%s", b, suffix[k], unit);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t blocksToGB (uint32_t blocks)
|
||||||
|
{
|
||||||
|
return (long) (((uint64_t) blocks) * 512 / 1000000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t blocksToGiB (uint32_t blocks)
|
||||||
|
{
|
||||||
|
return blocks / 2 / 1024 / 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint64_t extractInt64 (void *u, size_t len)
|
||||||
|
{
|
||||||
|
uint64_t x;
|
||||||
|
uint8_t *v;
|
||||||
|
|
||||||
|
for (x = 0, v = u; len > 0; --len, ++v)
|
||||||
|
x = (x << 8) + *v;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int parseLogPage (void *log, size_t len, struct logData *x)
|
||||||
|
{
|
||||||
|
struct logPageHeader *h = log;
|
||||||
|
void *u = log + sizeof (*h);
|
||||||
|
struct logParameterHeader *p;
|
||||||
|
size_t pageLen;
|
||||||
|
|
||||||
|
memset (x, 0, sizeof (*x));
|
||||||
|
|
||||||
|
if (len < sizeof (*h))
|
||||||
|
return -1;
|
||||||
|
pageLen = ntohs (h->length) + sizeof (*h);
|
||||||
|
if (len > pageLen)
|
||||||
|
len = pageLen;
|
||||||
|
len -= sizeof (*h);
|
||||||
|
|
||||||
|
x->h = *h;
|
||||||
|
x->h.length = pageLen;
|
||||||
|
|
||||||
|
if (h->page_code == 0)
|
||||||
|
{
|
||||||
|
for ( ; len > 0; --len, ++u)
|
||||||
|
{
|
||||||
|
uint8_t code = *((unsigned char *) u);
|
||||||
|
|
||||||
|
if (code < sizeof (x->u.supported.page) / sizeof (x->u.supported.page[0]))
|
||||||
|
x->u.supported.page[code] = 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (len >= sizeof (*p))
|
||||||
|
{
|
||||||
|
uint16_t code;
|
||||||
|
uint64_t e;
|
||||||
|
struct selfTestLogParameter *t;
|
||||||
|
|
||||||
|
p = u;
|
||||||
|
if (p->length + sizeof (*p) > len)
|
||||||
|
break;
|
||||||
|
len -= sizeof (*p);
|
||||||
|
u += sizeof (*p);
|
||||||
|
|
||||||
|
code = ntohs (p->parameter_code);
|
||||||
|
switch (h->page_code)
|
||||||
|
{
|
||||||
|
case 0x02:
|
||||||
|
case 0x03:
|
||||||
|
case 0x04:
|
||||||
|
case 0x05:
|
||||||
|
e = extractInt64 (u, p->length);
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case 0x0000: x->u.error.corrected = e; break;
|
||||||
|
case 0x0001: x->u.error.delayed = e; break;
|
||||||
|
case 0x0002: x->u.error.reread = e; break;
|
||||||
|
case 0x0003: x->u.error.total_corrected = e; break;
|
||||||
|
case 0x0004: x->u.error.total_algorithm = e; break;
|
||||||
|
case 0x0005: x->u.error.total_bytes = e; break;
|
||||||
|
case 0x0006: x->u.error.total_uncorrected = e; if (e) x->problem = 1; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0d:
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case 0x0000: x->u.temperature.current = ((uint8_t *) u)[1]; break;
|
||||||
|
case 0x0001: x->u.temperature.reference = ((uint8_t *) u)[1]; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0e:
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case 0x0001:
|
||||||
|
strncpy (x->u.startstop.manufacture_year, u, sizeof (x->u.startstop.manufacture_year) - 1);
|
||||||
|
x->u.startstop.manufacture_year[sizeof (x->u.startstop.manufacture_year) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.manufacture_year);
|
||||||
|
strncpy (x->u.startstop.manufacture_week, u + 4, sizeof (x->u.startstop.manufacture_week) - 1);
|
||||||
|
x->u.startstop.manufacture_week[sizeof (x->u.startstop.manufacture_week) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.manufacture_week);
|
||||||
|
break;
|
||||||
|
case 0x0002:
|
||||||
|
strncpy (x->u.startstop.accounting_year, u, sizeof (x->u.startstop.accounting_year) - 1);
|
||||||
|
x->u.startstop.accounting_year[sizeof (x->u.startstop.accounting_year) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.accounting_year);
|
||||||
|
strncpy (x->u.startstop.accounting_week, u + 4, sizeof (x->u.startstop.accounting_week) - 1);
|
||||||
|
x->u.startstop.accounting_week[sizeof (x->u.startstop.accounting_week) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.accounting_week);
|
||||||
|
break;
|
||||||
|
case 0x0003:
|
||||||
|
x->u.startstop.recommended_starts = ntohl (*((uint32_t *) u));
|
||||||
|
break;
|
||||||
|
case 0x0004:
|
||||||
|
x->u.startstop.accumulated_starts = ntohl (*((uint32_t *) u));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x10:
|
||||||
|
if ((code < 1) || (code > sizeof (x->u.selftest.entry) / sizeof (x->u.selftest.entry[0])))
|
||||||
|
break;
|
||||||
|
if (p->length != sizeof (x->u.selftest.entry[0]) - sizeof (*p))
|
||||||
|
break;
|
||||||
|
--code;
|
||||||
|
t = &x->u.selftest.entry[code];
|
||||||
|
*t = *((struct selfTestLogParameter *) p);
|
||||||
|
t->h.parameter_code = code;
|
||||||
|
t->timestamp = ntohs (t->timestamp);
|
||||||
|
t->lba = extractInt64 (&t->lba, sizeof (t->lba));
|
||||||
|
if (t->self_test_code || t->self_test_results || t->timestamp || t->number || t->lba)
|
||||||
|
if ((t->self_test_results >= 4) && (t->self_test_results <= 7))
|
||||||
|
x->problem = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
len -= p->length;
|
||||||
|
u += p->length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flag any other problems */
|
||||||
|
switch (h->page_code)
|
||||||
|
{
|
||||||
|
case 0x0d:
|
||||||
|
if (x->u.temperature.reference && (x->u.temperature.reference != 0xff) && (x->u.temperature.current >= x->u.temperature.reference))
|
||||||
|
x->problem = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dumpLogPage (FILE *f, struct logData *x, void *log, size_t len, int verbosity)
|
||||||
|
{
|
||||||
|
struct logPageHeader *h = log;
|
||||||
|
void *u = log + sizeof (*h);
|
||||||
|
struct logParameterHeader *p;
|
||||||
|
size_t pageLen;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
switch (x->h.page_code)
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
fprintf (f, " %s:", logPageType[h->page_code]);
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, "\n");
|
||||||
|
for (k = 0; k < sizeof (x->u.supported.page) / sizeof (x->u.supported.page[0]); ++k)
|
||||||
|
{
|
||||||
|
if (!(x->u.supported.page[k]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (verbosity > 1)
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
if (logPageType[k])
|
||||||
|
name = logPageType[k];
|
||||||
|
else
|
||||||
|
name = "unknown log page";
|
||||||
|
fprintf (f, " %02x %s\n", k, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf (f, " %02x", k);
|
||||||
|
}
|
||||||
|
if (!(verbosity > 1))
|
||||||
|
fprintf (f, "\n");
|
||||||
|
break;
|
||||||
|
case 0x02:
|
||||||
|
case 0x03:
|
||||||
|
case 0x04:
|
||||||
|
case 0x05:
|
||||||
|
switch (x->h.page_code)
|
||||||
|
{
|
||||||
|
case 0x02: fprintf (f, " write errors:"); break;
|
||||||
|
case 0x03: fprintf (f, " read errors:"); break;
|
||||||
|
case 0x04: fprintf (f, " read/rev errors:"); break;
|
||||||
|
case 0x05: fprintf (f, " verify errors:"); break;
|
||||||
|
}
|
||||||
|
fprintf (f, " corr:%-6s", friendlySize (x->u.error.corrected, ""));
|
||||||
|
fprintf (f, " delay:%-6s", friendlySize (x->u.error.delayed, ""));
|
||||||
|
switch (x->h.page_code)
|
||||||
|
{
|
||||||
|
case 0x02: fprintf (f, " rewrit:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
case 0x03: fprintf (f, " reread:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
case 0x04: fprintf (f, " reread:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
case 0x05: fprintf (f, " revrfy:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
}
|
||||||
|
fprintf (f, " tot/corr:%-6s", friendlySize (x->u.error.total_corrected, ""));
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, " tot/alg:%-6s", friendlySize (x->u.error.total_algorithm, ""));
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, " tot/bytes:%-6s", friendlySize (x->u.error.total_bytes, "B"));
|
||||||
|
fprintf (f, " tot/uncorr:%-6s", friendlySize (x->u.error.total_uncorrected, ""));
|
||||||
|
fprintf (f, "\n");
|
||||||
|
break;
|
||||||
|
case 0x0d:
|
||||||
|
fprintf (f, " temperature: current:%uC threshold:%uC%s\n", x->u.temperature.current, x->u.temperature.reference, x->problem ? " warning:temperature threshold exceeded" : "");
|
||||||
|
break;
|
||||||
|
case 0x0e:
|
||||||
|
fprintf (f, " ");
|
||||||
|
if (strlen (x->u.startstop.manufacture_year) && strlen (x->u.startstop.manufacture_week))
|
||||||
|
fprintf (f, " manufactured:%s/%s", x->u.startstop.manufacture_year, x->u.startstop.manufacture_week);
|
||||||
|
if (strlen (x->u.startstop.accounting_year) && strlen (x->u.startstop.accounting_week))
|
||||||
|
fprintf (f, " accounting:%s/%s", x->u.startstop.accounting_year, x->u.startstop.accounting_week);
|
||||||
|
fprintf (f, " starts:%d/%d", x->u.startstop.accumulated_starts, x->u.startstop.recommended_starts);
|
||||||
|
fprintf (f, "\n");
|
||||||
|
break;
|
||||||
|
case 0x10:
|
||||||
|
for (k = 0; k < sizeof (x->u.selftest.entry) / sizeof (x->u.selftest.entry[0]); ++k)
|
||||||
|
{
|
||||||
|
struct selfTestLogParameter *t = &x->u.selftest.entry[k];
|
||||||
|
|
||||||
|
if (t->self_test_code || t->self_test_results || t->timestamp || t->number || t->lba)
|
||||||
|
{
|
||||||
|
char *test;
|
||||||
|
char *result;
|
||||||
|
int notice = 0;
|
||||||
|
|
||||||
|
switch (t->self_test_code)
|
||||||
|
{
|
||||||
|
case SCSI_SELFTEST_DEFAULT: test = "default"; break;
|
||||||
|
case SCSI_SELFTEST_BACKGROUND_SHORT: test = "bg short"; break;
|
||||||
|
case SCSI_SELFTEST_BACKGROUND_LONG: test = "bg long"; break;
|
||||||
|
case SCSI_SELFTEST_BACKGROUND_ABORT: test = "bg aborted"; break;
|
||||||
|
case SCSI_SELFTEST_FOREGROUND_SHORT: test = "fg short"; break;
|
||||||
|
case SCSI_SELFTEST_FOREGROUND_LONG: test = "fg long"; break;
|
||||||
|
default: test = "unknown"; break;
|
||||||
|
}
|
||||||
|
switch (t->self_test_results)
|
||||||
|
{
|
||||||
|
case 0x0: result = "completed without error"; notice = 1; break;
|
||||||
|
case 0x1: result = "aborted via send diagnostic"; notice = 1; break;
|
||||||
|
case 0x2: result = "aborted via other method"; notice = 1; break;
|
||||||
|
case 0x3: result = "unable to complete"; notice = 1; break;
|
||||||
|
case 0x4: result = "failed in unknown segment"; notice = 0; break;
|
||||||
|
case 0x5: result = "failed in segment 1"; notice = 0; break;
|
||||||
|
case 0x6: result = "failed in segment 2"; notice = 0; break;
|
||||||
|
case 0x7: result = "failed in other segment"; notice = 0; break;
|
||||||
|
case 0xf: result = "in progress"; notice = 0; break;
|
||||||
|
default: result = "unknown result"; notice = 0; break;
|
||||||
|
}
|
||||||
|
if (verbosity > notice)
|
||||||
|
fprintf (f, " %2d: timestamp %4ud%02uh: %10s %-30s seg:%u lba:%-8lld sk:%u asc:%u ascq:%u vs:%u\n", k, t->timestamp / 24, t->timestamp % 24, test, result, t->number, t->lba, t->sense_key, t->additional_sense_code, t->additional_sense_code_qualifier, t->vendor_specific);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(verbosity > 2))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (len < sizeof (*h))
|
||||||
|
return;
|
||||||
|
pageLen = ntohs (h->length) + sizeof (*h);
|
||||||
|
if (len > pageLen)
|
||||||
|
len = pageLen;
|
||||||
|
len -= sizeof (*h);
|
||||||
|
|
||||||
|
fprintf (f, " log page %02x, length %u%s\n", h->page_code, ntohs (h->length), len < pageLen - sizeof (*h) ? " warning: truncated" : "");
|
||||||
|
|
||||||
|
while (len >= sizeof (*p))
|
||||||
|
{
|
||||||
|
uint16_t code;
|
||||||
|
|
||||||
|
p = u;
|
||||||
|
if (p->length + sizeof (*p) > len)
|
||||||
|
break;
|
||||||
|
len -= sizeof (*p);
|
||||||
|
u += sizeof (*p);
|
||||||
|
|
||||||
|
code = ntohs (p->parameter_code);
|
||||||
|
fprintf (f, " param %04x, du %u, ds %u, tsd %u, etc %u, tmc %u, lbin %u, lp %u, length %u\n", code, p->du, p->ds, p->tsd, p->etc, p->tmc, p->lbin, p->lp, p->length);
|
||||||
|
dumpbytes (f, u, p->length, u, "param");
|
||||||
|
|
||||||
|
len -= p->length;
|
||||||
|
u += p->length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
148
src/logpage.h
Normal file
148
src/logpage.h
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
#ifndef _LOGPAGE_H
|
||||||
|
#define _LOGPAGE_H
|
||||||
|
/*
|
||||||
|
* Definitions for SCSI log sense page parsing and printing.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <scg/scsireg.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct logPageHeader
|
||||||
|
{
|
||||||
|
uint8_t page_code;
|
||||||
|
uint8_t rsvd0;
|
||||||
|
uint16_t length;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct logParameterHeader
|
||||||
|
{
|
||||||
|
uint16_t parameter_code;
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder (thanks, Schily) */
|
||||||
|
uint8_t lp:1;
|
||||||
|
uint8_t lbin:1;
|
||||||
|
uint8_t tmc:2;
|
||||||
|
uint8_t etc:1;
|
||||||
|
uint8_t tsd:1;
|
||||||
|
uint8_t ds:1;
|
||||||
|
uint8_t du:1;
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
uint8_t du:1;
|
||||||
|
uint8_t ds:1;
|
||||||
|
uint8_t tsd:1;
|
||||||
|
uint8_t etc:1;
|
||||||
|
uint8_t tmc:2;
|
||||||
|
uint8_t lbin:1;
|
||||||
|
uint8_t lp:1;
|
||||||
|
#endif
|
||||||
|
uint8_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LOG_PAGE_MAX 0x40
|
||||||
|
|
||||||
|
struct supportedLogsPage
|
||||||
|
{
|
||||||
|
uint8_t page[LOG_PAGE_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct errorLogPage
|
||||||
|
{
|
||||||
|
uint64_t corrected;
|
||||||
|
uint64_t delayed;
|
||||||
|
uint64_t reread;
|
||||||
|
uint64_t total_corrected;
|
||||||
|
uint64_t total_algorithm;
|
||||||
|
uint64_t total_bytes;
|
||||||
|
uint64_t total_uncorrected;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct selfTestLogParameter
|
||||||
|
{
|
||||||
|
struct logParameterHeader h;
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder (thanks, Schily) */
|
||||||
|
uint8_t self_test_results:4;
|
||||||
|
uint8_t rsvd0:1;
|
||||||
|
uint8_t self_test_code:3;
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
uint8_t self_test_code:3;
|
||||||
|
uint8_t rsvd0:1;
|
||||||
|
uint8_t self_test_results:4;
|
||||||
|
#endif
|
||||||
|
uint8_t number;
|
||||||
|
uint16_t timestamp;
|
||||||
|
uint64_t lba;
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder (thanks, Schily) */
|
||||||
|
uint8_t sense_key:4;
|
||||||
|
uint8_t rsvd1:4;
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
uint8_t rsvd1:4;
|
||||||
|
uint8_t sense_key:4;
|
||||||
|
#endif
|
||||||
|
uint8_t additional_sense_code;
|
||||||
|
uint8_t additional_sense_code_qualifier;
|
||||||
|
uint8_t vendor_specific;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct selfTestLogPage
|
||||||
|
{
|
||||||
|
struct selfTestLogParameter entry[20];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct startStopCycleCounterLogPage
|
||||||
|
{
|
||||||
|
char manufacture_year[5];
|
||||||
|
char manufacture_week[3];
|
||||||
|
char accounting_year[5];
|
||||||
|
char accounting_week[3];
|
||||||
|
uint32_t recommended_starts;
|
||||||
|
uint32_t accumulated_starts;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct temperatureLogPage
|
||||||
|
{
|
||||||
|
uint8_t current;
|
||||||
|
uint8_t reference;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct logData
|
||||||
|
{
|
||||||
|
struct logPageHeader h;
|
||||||
|
uint8_t problem;
|
||||||
|
uint8_t pad[3];
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct supportedLogsPage supported;
|
||||||
|
struct errorLogPage error;
|
||||||
|
struct selfTestLogPage selftest;
|
||||||
|
struct startStopCycleCounterLogPage startstop;
|
||||||
|
struct temperatureLogPage temperature;
|
||||||
|
} u;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
extern int parseLogPage (void *log, size_t len, struct logData *x);
|
||||||
|
extern void dumpLogPage (FILE *f, struct logData *x, void *log, size_t len, int verbosity);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
585
src/mega.h
Normal file
585
src/mega.h
Normal file
@ -0,0 +1,585 @@
|
|||||||
|
#ifndef _MEGA_H
|
||||||
|
#define _MEGA_H
|
||||||
|
/*
|
||||||
|
* Definitions of data structures used by the adapter and by our
|
||||||
|
* high-level interface.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "logpage.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <scg/scsireg.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef signed char s8;
|
||||||
|
typedef unsigned char u8;
|
||||||
|
|
||||||
|
typedef signed short s16;
|
||||||
|
typedef unsigned short u16;
|
||||||
|
|
||||||
|
typedef signed int s32;
|
||||||
|
typedef unsigned int u32;
|
||||||
|
|
||||||
|
typedef signed long long s64;
|
||||||
|
typedef unsigned long long u64;
|
||||||
|
|
||||||
|
#define BITS_PER_LONG 32
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#ifdef NEED_UINT8_T
|
||||||
|
|
||||||
|
typedef __u8 uint8_t;
|
||||||
|
typedef __u16 uint16_t;
|
||||||
|
typedef __u32 uint32_t;
|
||||||
|
typedef __u64 uint64_t;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* DMA addresses come in generic and 64-bit flavours. */
|
||||||
|
|
||||||
|
#ifdef CONFIG_HIGHMEM
|
||||||
|
typedef u64 dma_addr_t;
|
||||||
|
#else
|
||||||
|
typedef u32 dma_addr_t;
|
||||||
|
#endif
|
||||||
|
typedef u64 dma64_addr_t;
|
||||||
|
|
||||||
|
/* Hacks to get kernel module headers to compile. We're not using any data structures where these matter. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
volatile unsigned int lock;
|
||||||
|
} spinlock_t;
|
||||||
|
struct semaphore
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct { volatile int counter; } atomic_t;
|
||||||
|
struct tasklet_struct
|
||||||
|
{
|
||||||
|
struct tasklet_struct *next;
|
||||||
|
unsigned long state;
|
||||||
|
atomic_t count;
|
||||||
|
void (*func)(unsigned long);
|
||||||
|
unsigned long data;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define __iomem
|
||||||
|
|
||||||
|
#define __user
|
||||||
|
#define wait_queue_head_t void *
|
||||||
|
/* typedef void wait_queue_head_t; */
|
||||||
|
|
||||||
|
struct list_head {
|
||||||
|
struct list_head *next, *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Okay, should be able to include module headers now, hopefully. */
|
||||||
|
#include "megaraid/mbox_defs.h"
|
||||||
|
#include "megaraid/megaraid_ioctl.h"
|
||||||
|
#include "megaraid/megaraid_sas.h"
|
||||||
|
|
||||||
|
#define MAX_CONTROLLERS 32
|
||||||
|
|
||||||
|
#define M_RD_IOCTL_CMD 0x80
|
||||||
|
#define M_RD_IOCTL_CMD_NEW 0x81
|
||||||
|
#define M_RD_DRIVER_IOCTL_INTERFACE 0x82
|
||||||
|
|
||||||
|
|
||||||
|
#define SCSI_SELFTEST_DEFAULT 0x00
|
||||||
|
#define SCSI_SELFTEST_BACKGROUND_SHORT 0x01
|
||||||
|
#define SCSI_SELFTEST_BACKGROUND_LONG 0x02
|
||||||
|
#define SCSI_SELFTEST_BACKGROUND_ABORT 0x04
|
||||||
|
#define SCSI_SELFTEST_FOREGROUND_SHORT 0x05
|
||||||
|
#define SCSI_SELFTEST_FOREGROUND_LONG 0x06
|
||||||
|
|
||||||
|
|
||||||
|
/* megaraid2 header file gets this wrong. */
|
||||||
|
typedef struct {
|
||||||
|
uint8_t max_commands;
|
||||||
|
uint8_t rebuild_rate;
|
||||||
|
uint8_t max_targ_per_chan;
|
||||||
|
uint8_t nchannels;
|
||||||
|
uint8_t fw_version[4];
|
||||||
|
uint16_t age_of_flash;
|
||||||
|
uint8_t chip_set_value;
|
||||||
|
uint8_t dram_size;
|
||||||
|
uint8_t cache_flush_interval;
|
||||||
|
uint8_t bios_version[4];
|
||||||
|
uint8_t board_type;
|
||||||
|
uint8_t sense_alert;
|
||||||
|
uint8_t write_config_count;
|
||||||
|
uint8_t drive_inserted_count;
|
||||||
|
uint8_t inserted_drive;
|
||||||
|
uint8_t battery_status;
|
||||||
|
uint8_t dec_fault_bus_info;
|
||||||
|
} __attribute__ ((packed)) mraid_adapinfo1_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
mraid_adapinfo1_t adapter_info;
|
||||||
|
mraid_ldrv_info_t logdrv_info;
|
||||||
|
mraid_pdrv_info_t pdrv_info;
|
||||||
|
} __attribute__ ((packed)) mraid_inquiry1_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
mraid_inquiry1_t raid_inq;
|
||||||
|
uint16_t phys_drv_format[MAX_MBOX_CHANNELS];
|
||||||
|
uint8_t stack_attn;
|
||||||
|
uint8_t modem_status;
|
||||||
|
uint8_t rsvd[2];
|
||||||
|
} __attribute__ ((packed)) mraid_extinq1_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* Structures we've figured out over many hours of staring at hex data. */
|
||||||
|
|
||||||
|
struct mega_physical_drive_error_info
|
||||||
|
{
|
||||||
|
uint8_t media;
|
||||||
|
uint8_t other;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
struct mega_predictive_map
|
||||||
|
{
|
||||||
|
uint8_t map[FC_MAX_PHYSICAL_DEVICES / 8];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
struct mega_device_entry_sas {
|
||||||
|
uint16_t device_id;
|
||||||
|
uint16_t enclosure;
|
||||||
|
uint8_t value_1; /* ? 1, 2 enclosure number + 1? backend port number? */
|
||||||
|
uint8_t slot;
|
||||||
|
uint8_t type; /* INQ_DASD, INQ_ENCL */
|
||||||
|
uint8_t port; /* 1 << connected port number */
|
||||||
|
uint64_t sas_address[2];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
/* opcode 0x02010000 */
|
||||||
|
struct mega_device_list_sas {
|
||||||
|
uint32_t length;
|
||||||
|
uint16_t num_devices;
|
||||||
|
uint16_t rsvd0;
|
||||||
|
struct mega_device_entry_sas device[32]; /* actually any number */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
struct mega_array_header_sas {
|
||||||
|
uint32_t length;
|
||||||
|
uint16_t num_span_defs;
|
||||||
|
uint16_t span_def_size; /* 0x0120 */
|
||||||
|
uint16_t num_disk_defs;
|
||||||
|
uint16_t disk_def_size; /* 0x0100 */
|
||||||
|
uint16_t num_hot_spares;
|
||||||
|
uint16_t value_0028; /* ? 0x0028 */
|
||||||
|
uint32_t pad0[4];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct mega_array_span_disk_sas
|
||||||
|
{
|
||||||
|
uint16_t device_id; /* 0xffff if device missing */
|
||||||
|
uint16_t sequence; /* ? 0x0002, 0x0004, 0x0006... as disks are created */
|
||||||
|
uint8_t flag_0:1;
|
||||||
|
uint8_t hotspare:1;
|
||||||
|
uint8_t rebuild:1;
|
||||||
|
uint8_t online:1;
|
||||||
|
uint8_t present:1;
|
||||||
|
uint8_t flag_1;
|
||||||
|
uint8_t enclosure;
|
||||||
|
uint8_t slot;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct mega_array_span_def_sas
|
||||||
|
{
|
||||||
|
uint64_t sectors_per_disk;
|
||||||
|
uint16_t span_size; /* number of disks in span */
|
||||||
|
uint16_t span_index; /* 0, 1, 2... */
|
||||||
|
uint32_t value_1; /* ? 0 */
|
||||||
|
uint32_t pad0[4];
|
||||||
|
struct mega_array_span_disk_sas disk[32]; /* real number is (config.span_def_size - offset .disks) / sizeof span_entry */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct mega_array_disk_entry_sas
|
||||||
|
{
|
||||||
|
uint64_t offset; /* offset in sectors of this vd */
|
||||||
|
uint64_t sectors_per_disk; /* sectors used for this vd on each disk */
|
||||||
|
uint16_t span_index; /* number of this span */
|
||||||
|
uint16_t pad2; /* ? 0 */
|
||||||
|
uint32_t pad3; /* ? 0 */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
#define MEGA_SAS_LD_OFFLINE 0
|
||||||
|
#define MEGA_SAS_LD_PARTIALLY_DEGRADED 1
|
||||||
|
#define MEGA_SAS_LD_DEGRADED 2
|
||||||
|
#define MEGA_SAS_LD_OPTIMAL 3
|
||||||
|
|
||||||
|
struct mega_array_disk_def_sas {
|
||||||
|
uint16_t disk_index; /* 0, 1, 2... */
|
||||||
|
uint16_t sequence; /* ? 0x0004, 0x0003 */
|
||||||
|
char name[16]; /* null-terminated, max 15 chars */
|
||||||
|
uint32_t flags; /* ? 0x01000001, 0x00000000 */
|
||||||
|
uint32_t pad0[2]; /* ? 0 */
|
||||||
|
uint8_t raid_level; /* 0, 1, 5 */
|
||||||
|
uint8_t raid_level_secondary; /* ? 3 for raid 5 with 4 spans, 0 for raid1 with 1 span */
|
||||||
|
uint8_t raid_level_qualifier; /* ? 3 for raid 5 with 4 spans, 0 for raid1 with 1 span */
|
||||||
|
uint8_t stripe_size; /* (2 << this) sectors per stripe; 4 == 8K, 5 == 16K, etc. */
|
||||||
|
uint8_t disks_per_span;
|
||||||
|
uint8_t num_spans;
|
||||||
|
uint16_t state; /* ? 0 == offline, 1 == partially degraded, 2 == degraded, 3 == optimal */
|
||||||
|
uint32_t value_4; /* ? 0x00000001, 0x00000000 */
|
||||||
|
uint32_t pad1[5]; /* ? 0 */
|
||||||
|
struct mega_array_disk_entry_sas span[8]; /* real number is (config.disk_def_size - offset .spans) / sizeof disk_entry */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct mega_array_hotspare_def_sas
|
||||||
|
{
|
||||||
|
uint16_t device_id;
|
||||||
|
uint16_t sequence; /* ? 0x001c, 0x001e, 0x0020 */
|
||||||
|
uint32_t flags; /* ? 0x00000000 for global, 0x01000001 for dedicated */
|
||||||
|
uint32_t array; /* dedicated array index */
|
||||||
|
uint32_t pad0[7]; /* ? 0 */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
/* opcode 0x04010000: array config is { header span_def* disk_def* hotspare_def* } */
|
||||||
|
struct mega_array_config_sas
|
||||||
|
{
|
||||||
|
struct mega_array_header_sas *header;
|
||||||
|
struct mega_array_span_def_sas *span;
|
||||||
|
struct mega_array_disk_def_sas *disk;
|
||||||
|
struct mega_array_hotspare_def_sas *hotspare;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* opcode 0x05010000 */
|
||||||
|
#define MEGA_BATTERY_TYPE_NONE 0
|
||||||
|
#define MEGA_BATTERY_TYPE_ITBBU 1
|
||||||
|
#define MEGA_BATTERY_TYPE_TBBU 2
|
||||||
|
|
||||||
|
struct mega_battery_state_sas
|
||||||
|
{
|
||||||
|
uint8_t type; /* see above */
|
||||||
|
uint8_t foo; /* ? */
|
||||||
|
uint16_t voltage; /* millivolts */
|
||||||
|
uint16_t current; /* milliamps */
|
||||||
|
uint16_t temperature; /* celsius */
|
||||||
|
uint32_t firmware_status;
|
||||||
|
uint32_t pad0[5]; /* ? 0 */
|
||||||
|
|
||||||
|
uint8_t pad1:4;
|
||||||
|
|
||||||
|
uint8_t fully_discharged:1;
|
||||||
|
uint8_t fully_charged:1;
|
||||||
|
uint8_t discharging:1;
|
||||||
|
uint8_t initialized:1;
|
||||||
|
|
||||||
|
uint8_t remaining_time_alarm:1;
|
||||||
|
uint8_t remaining_capacity_alarm:1;
|
||||||
|
uint8_t pad2:1;
|
||||||
|
uint8_t discharge_terminated:1;
|
||||||
|
|
||||||
|
uint8_t over_temperature:1;
|
||||||
|
uint8_t pad3:1;
|
||||||
|
uint8_t charging_terminated:1;
|
||||||
|
uint8_t over_charged:1;
|
||||||
|
|
||||||
|
uint16_t charge; /* percentage */
|
||||||
|
uint16_t charger_status; /* charger status 0 == off, 1 == complete, 2 == in progress */
|
||||||
|
uint16_t capacity_remaining; /* milliamp-hours */
|
||||||
|
uint16_t capacity_full; /* milliamp-hours */
|
||||||
|
uint16_t health; /* state of health 0 == no, * == good */
|
||||||
|
uint32_t pad9[5]; /* ? 0 */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
/* opcode 0x05020000 */
|
||||||
|
struct mega_battery_capacity_sas
|
||||||
|
{
|
||||||
|
uint16_t charge_relative; /* percentage */
|
||||||
|
uint16_t charge_absolute; /* percentage */
|
||||||
|
uint16_t capacity_remaining; /* milliamp-hours */
|
||||||
|
uint16_t capacity_full; /* milliamp-hours */
|
||||||
|
uint16_t time_empty_run; /* minutes */
|
||||||
|
uint16_t time_empty_average; /* minutes */
|
||||||
|
uint16_t time_full_average; /* minutes */
|
||||||
|
uint16_t cycles;
|
||||||
|
uint16_t error_max; /* percentage */
|
||||||
|
uint16_t alarm_capacity; /* milliamp-hours */
|
||||||
|
uint16_t alarm_time; /* minutes */
|
||||||
|
uint16_t pad0; /* ? 0 */
|
||||||
|
uint32_t pad1[6]; /* ? 0 */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
/* opcode 0x05030000 */
|
||||||
|
struct mega_battery_design_sas
|
||||||
|
{
|
||||||
|
uint32_t manufacture_date; /* weird encoding: 0xfae87 == 2007/04/07, 0xfaebf == 2007/05/31 */
|
||||||
|
uint16_t design_capacity; /* milliamp-hours */
|
||||||
|
uint16_t design_voltage; /* millivolts */
|
||||||
|
uint16_t specification_info;
|
||||||
|
uint16_t serial_number;
|
||||||
|
uint16_t pack_stat_configuration;
|
||||||
|
char manufacturer[12];
|
||||||
|
char device_name[8];
|
||||||
|
char device_chemistry[5];
|
||||||
|
char device_vendor[5];
|
||||||
|
uint32_t pad0[5]; /* ? 0 */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
/* opcode 0x05050100 */
|
||||||
|
struct mega_battery_properties_sas
|
||||||
|
{
|
||||||
|
uint32_t device_learn_period; /* seconds */
|
||||||
|
uint32_t next_learn_time; /* seconds */
|
||||||
|
uint32_t learn_delay_interval; /* ? hours */
|
||||||
|
uint32_t auto_learn_mode; /* ? */
|
||||||
|
uint32_t pad0[4]; /* ? 0 */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct mega_battery_info_sas
|
||||||
|
{
|
||||||
|
struct mega_battery_state_sas state;
|
||||||
|
struct mega_battery_capacity_sas capacity;
|
||||||
|
struct mega_battery_design_sas design;
|
||||||
|
struct mega_battery_properties_sas properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* opcode 0x02020000 */
|
||||||
|
struct mega_physical_disk_info_sas
|
||||||
|
{
|
||||||
|
uint16_t device_id;
|
||||||
|
uint16_t sequence;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct scsi_inquiry inq;
|
||||||
|
uint8_t buf[96];
|
||||||
|
} inquiry;
|
||||||
|
uint16_t value_x; /* ? 0x8300 */ /* 0x064 */
|
||||||
|
uint16_t value_y; /* ? 0x4800, 0x2000 */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t value[60];
|
||||||
|
} mystery_struct; /* 0x0a4 */
|
||||||
|
uint16_t value_0; /* ? 0x0000 */
|
||||||
|
uint8_t port; /* 1 << connected port number */
|
||||||
|
uint8_t value_1; /* ? 0 */
|
||||||
|
uint32_t media_errors;
|
||||||
|
uint32_t other_errors;
|
||||||
|
uint32_t predictive_failures;
|
||||||
|
uint32_t predictive_failure_event_sequence;
|
||||||
|
uint8_t failure:1;
|
||||||
|
uint8_t hotspare:1;
|
||||||
|
uint8_t rebuild:1;
|
||||||
|
uint8_t online:1;
|
||||||
|
uint8_t configured:1;
|
||||||
|
uint8_t flags_0:3;
|
||||||
|
uint8_t flags_1;
|
||||||
|
uint16_t value_4; /* ? 0x0000 */
|
||||||
|
uint32_t value_5; /* ? 0x00002002, 0x00003003, 0x00003009 */
|
||||||
|
uint32_t sas_address_count; /* number of sas addresses */
|
||||||
|
uint32_t pad_sas_addr; /* ? 0x00000000 */
|
||||||
|
uint64_t sas_address[4];
|
||||||
|
uint64_t raw_size; /* sectors; MegaCli only sees 32 bits */ /* 0x0e8 */
|
||||||
|
uint64_t noncoerced_size; /* sectors; MegaCli only sees 32 bits */ /* 0x0f0 */
|
||||||
|
uint64_t coerced_size; /* sectors; MegaCli only sees 32 bits */ /* 0x0f8 */
|
||||||
|
uint16_t enclosure; /* 0x100 */
|
||||||
|
uint8_t value_9; /* 1 or 2, not sure what it means, goes with enclosure */
|
||||||
|
uint8_t slot;
|
||||||
|
uint8_t value_10[0xfc];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
/* Unified config structures for generic high-level interface. */
|
||||||
|
|
||||||
|
enum mega_adapter_enum {
|
||||||
|
MEGA_ADAPTER_V2, /* PERC2 */
|
||||||
|
MEGA_ADAPTER_V34, /* PERC3 or PERC4 */
|
||||||
|
MEGA_ADAPTER_V5, /* PERC5 (SAS) */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Structure for io to adapters. */
|
||||||
|
struct mega_adapter_path
|
||||||
|
{
|
||||||
|
int fd; /* block device descriptor for adapter access */
|
||||||
|
uint8_t adapno; /* adapter number */
|
||||||
|
enum mega_adapter_enum type; /* adapter variant */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct log_page_list
|
||||||
|
{
|
||||||
|
struct logData log;
|
||||||
|
uint8_t buf[4095]; /* rhl 7.3 croaks on >= 4096 */
|
||||||
|
struct log_page_list *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum physical_drive_state
|
||||||
|
{
|
||||||
|
PdStateUnknown,
|
||||||
|
PdStateUnconfiguredGood,
|
||||||
|
PdStateUnconfiguredBad,
|
||||||
|
PdStateHotspare,
|
||||||
|
PdStateFailed,
|
||||||
|
PdStateRebuild,
|
||||||
|
PdStateOnline,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct physical_drive_info
|
||||||
|
{
|
||||||
|
uint8_t present; /* whether drive responds to inquiry */
|
||||||
|
struct adapter_config *adapter; /* adapter this drive belongs to */
|
||||||
|
struct span_info *span; /* span this disk is a member of */
|
||||||
|
char name[16]; /* drive name (AxCyTz) */
|
||||||
|
uint16_t target; /* scsi channel+id or device_id */
|
||||||
|
uint16_t channel; /* channel or enclosure */
|
||||||
|
uint8_t id; /* scsi id or enclosure slot */
|
||||||
|
enum physical_drive_state state; /* drive state */
|
||||||
|
char *error_string; /* status error string (NULL if okay) */
|
||||||
|
uint64_t blocks; /* number of blocks */
|
||||||
|
char vendor[9]; /* vendor name */
|
||||||
|
char model[17]; /* vendor model */
|
||||||
|
char revision[5]; /* firmware version */
|
||||||
|
char serial[32]; /* serial number */
|
||||||
|
uint32_t predictive_failures; /* predictive failure count */
|
||||||
|
uint32_t media_errors;
|
||||||
|
uint32_t other_errors;
|
||||||
|
struct scsi_inquiry inquiry; /* scsi inquiry result */
|
||||||
|
struct log_page_list *log;
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct mega_physical_disk_info_sas info;
|
||||||
|
} v5;
|
||||||
|
} q;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct span_info
|
||||||
|
{
|
||||||
|
struct adapter_config *adapter; /* adapter this span belongs to */
|
||||||
|
uint32_t blocks_per_disk; /* blocks used per disk for this span */
|
||||||
|
uint32_t num_disks; /* number of disks in this span */
|
||||||
|
struct physical_drive_info **disk; /* pointers to component disks */
|
||||||
|
uint32_t num_logical_drives; /* how many logical drives this span belongs to */
|
||||||
|
struct logical_drive_info **logical_drive; /* pointers to logical drives */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct span_reference
|
||||||
|
{
|
||||||
|
uint64_t offset; /* offset into each disk */
|
||||||
|
uint64_t blocks_per_disk; /* number of blocks used per disk */
|
||||||
|
struct span_info *span; /* the span */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum logical_drive_state
|
||||||
|
{
|
||||||
|
LdStateUnknown,
|
||||||
|
LdStateOffline,
|
||||||
|
LdStatePartiallyDegraded,
|
||||||
|
LdStateDegraded,
|
||||||
|
LdStateOptimal,
|
||||||
|
LdStateDeleted,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct logical_drive_info
|
||||||
|
{
|
||||||
|
struct adapter_config *adapter; /* adapter this drive belongs to */
|
||||||
|
char name[16]; /* logical drive name (AxLDy) */
|
||||||
|
uint16_t target; /* logical drive number */
|
||||||
|
enum logical_drive_state state; /* logical drive state */
|
||||||
|
uint8_t raid_level; /* raid level */
|
||||||
|
uint8_t num_spans; /* how many spans in this logical drive */
|
||||||
|
struct span_reference *span; /* pointers to component spans */
|
||||||
|
uint8_t span_size; /* number of disks per span */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum battery_charger_state
|
||||||
|
{
|
||||||
|
ChargerStateUnknown,
|
||||||
|
ChargerStateFailed,
|
||||||
|
ChargerStateInProgress,
|
||||||
|
ChargerStateComplete,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct adapter_config
|
||||||
|
{
|
||||||
|
struct mega_adapter_path target; /* adapter access path */
|
||||||
|
uint8_t is_sas; /* adapter is a sas adapter */
|
||||||
|
char name[16]; /* adapter name (Ax) */
|
||||||
|
char product[81]; /* adapter product name */
|
||||||
|
char bios[17]; /* adapter bios version */
|
||||||
|
char firmware[17]; /* adapter firmware version */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t healthy:1;
|
||||||
|
uint8_t module_missing:1;
|
||||||
|
uint8_t pack_missing:1;
|
||||||
|
uint8_t low_voltage:1;
|
||||||
|
uint8_t high_temperature:1;
|
||||||
|
uint8_t cycles_exceeded:1;
|
||||||
|
uint8_t over_charged:1;
|
||||||
|
enum battery_charger_state charger_state;
|
||||||
|
int16_t voltage;
|
||||||
|
int16_t temperature;
|
||||||
|
} battery;
|
||||||
|
uint16_t dram_size; /* size of DRAM in MB */
|
||||||
|
uint16_t rebuild_rate; /* rebuild rate as percentage */
|
||||||
|
uint16_t num_channels; /* number of channels or enclosures */
|
||||||
|
uint8_t *channel; /* channel/enclosure map */
|
||||||
|
uint16_t num_physicals;
|
||||||
|
struct physical_drive_info *physical;
|
||||||
|
struct physical_drive_info **physical_list; /* ordered list of physical devices */
|
||||||
|
uint16_t num_spans; /* number of spans */
|
||||||
|
struct span_info *span;
|
||||||
|
uint16_t num_logicals; /* number of logical drives */
|
||||||
|
struct logical_drive_info *logical; /* logical drives */
|
||||||
|
struct adapter_config *next;
|
||||||
|
|
||||||
|
/* adapter-specific data structures */
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
mraid_inquiry1_t inquiry;
|
||||||
|
struct mega_predictive_map map;
|
||||||
|
disk_array_8ld_span8_t config;
|
||||||
|
} v2;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
mraid_pinfo_t adapinfo;
|
||||||
|
mraid_inquiry3_t enquiry3;
|
||||||
|
struct mega_predictive_map map;
|
||||||
|
disk_array_40ld_t config;
|
||||||
|
} v3;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct megasas_ctrl_info adapinfo;
|
||||||
|
struct mega_device_list_sas *device;
|
||||||
|
struct mega_array_config_sas config;
|
||||||
|
struct mega_battery_info_sas battery;
|
||||||
|
} v5;
|
||||||
|
} q;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
926
src/megactl.c
Normal file
926
src/megactl.c
Normal file
@ -0,0 +1,926 @@
|
|||||||
|
/*
|
||||||
|
* Main program.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
|
||||||
|
megactl/megasasctl
|
||||||
|
|
||||||
|
Program to do the things you wish dellmgr or MegaCli could do, e.g.
|
||||||
|
report device log pages, run device self tests, report disk error
|
||||||
|
counts without having to pop in and out of countless dellmgr menus,
|
||||||
|
and actually document the adapter configuration concisely (dellmgr
|
||||||
|
gives you no way to do this).
|
||||||
|
|
||||||
|
Author: Jefferson Ogata (JO317) <ogata@antibozo.net>
|
||||||
|
Date: 2006/01/23
|
||||||
|
|
||||||
|
Version 0.4.0 major changes, including SAS support: 2007/08/20
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
|
||||||
|
Other log page parsers.
|
||||||
|
|
||||||
|
Cleaner log page output.
|
||||||
|
|
||||||
|
Fixes for 64-bit systems. Currently builds only with -m32.
|
||||||
|
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
#include "mega.h"
|
||||||
|
#include "megaioctl.h"
|
||||||
|
#include "adapter.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <scg/scsireg.h>
|
||||||
|
|
||||||
|
#include "dumpbytes.h"
|
||||||
|
|
||||||
|
#include "logpage.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MEGA_SAS_CTL
|
||||||
|
|
||||||
|
#define MEGA_DEVICE "/dev/megaraid_sas_ioctl_node"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define MEGA_DEVICE "/dev/megadev0"
|
||||||
|
|
||||||
|
#define MEGA_MIN_VERSION 0x118c
|
||||||
|
|
||||||
|
#endif /* defined(MEGA_SAS_CTL) */
|
||||||
|
|
||||||
|
|
||||||
|
static char *version = "0.4.1";
|
||||||
|
|
||||||
|
|
||||||
|
static int verbosity = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static char *me;
|
||||||
|
static char *usages[] = {
|
||||||
|
"usage: %p [-vest] [-H] [-l log-page-nr] [-T long|short] [target ...]",
|
||||||
|
"",
|
||||||
|
"Reports diagnostics on megaraid adapters and attached disks. Permits",
|
||||||
|
"dumping of controller log pages for inspection of error, temperature,",
|
||||||
|
"and self-test conditions, initiates self-test diagnostics, and documents",
|
||||||
|
"adapter and logical drive configuration. Target devices may be adapters,",
|
||||||
|
#ifdef MEGA_SAS_CTL
|
||||||
|
"(e.g. a0), enclosures (e.g. a0e0), or individual disks (e.g. a0e0s0). If",
|
||||||
|
#else
|
||||||
|
"(e.g. a0), channels (e.g. a0c0), or individual disks (e.g. a0c0t0). If",
|
||||||
|
#endif
|
||||||
|
"no target is specified, reports configuration and drive state on all",
|
||||||
|
"adapters. If a target matches a collection of disks, operations are",
|
||||||
|
"applied to all matching devices. Options are:",
|
||||||
|
"-v Increase program verbosity.",
|
||||||
|
"-e Dump read (0x03), write (0x02), and verify (0x05) error log",
|
||||||
|
" pages.",
|
||||||
|
"-s Dump self-test (0x10) log page.",
|
||||||
|
"-t Dump temperature (0x0d) log page.",
|
||||||
|
"-l page Dump the specified log page. Log page 0 documents the log pages",
|
||||||
|
" the device supports.",
|
||||||
|
"-p Do not report physical disks. Reports only adapters and logical",
|
||||||
|
" drives. Useful for concisely documenting adapter configuration.",
|
||||||
|
"-T test Initiate the background short or long self-test procedure. The",
|
||||||
|
" test may take up to an hour to complete, but does not inhibit",
|
||||||
|
" access to the device. The test may be monitored using the -s",
|
||||||
|
" option.",
|
||||||
|
"-H Perform an adapter health check. Inspects state of all logical",
|
||||||
|
" and physical drives and battery backup unit and reports problem",
|
||||||
|
" conditions. If all is well, generates no output. Useful in a",
|
||||||
|
" cron job.",
|
||||||
|
"-B When performing health check, do not treat battery problems as",
|
||||||
|
" failures.",
|
||||||
|
"-V Show version.",
|
||||||
|
"",
|
||||||
|
"N.B. The background long self test is a useful tool for diagnosing",
|
||||||
|
"problems with individual disks. But be cautious with program usage.",
|
||||||
|
"\"%p -T long\" with no targets will initiate a background long self",
|
||||||
|
"test on every drive on every adapter. This may not be what you want.",
|
||||||
|
"",
|
||||||
|
"By default, the health check option inspects log pages 0x02, 0x03, and",
|
||||||
|
"0x05 for uncorrected read, write, and verify errors, 0x0d for excess",
|
||||||
|
"temperature conditions, and 0x10 for failed self tests. If, however, any",
|
||||||
|
"of the log page options is specified, only the designated log pages are",
|
||||||
|
"inspected.",
|
||||||
|
"",
|
||||||
|
#ifdef MEGA_SAS_CTL
|
||||||
|
"This program requires the device file " MEGA_DEVICE " to be",
|
||||||
|
"present on the system. If your system does not have this device file,",
|
||||||
|
"you may create it either by executing LSI\'s \"MegaCli\" program once,",
|
||||||
|
"or by locating the megadev_sas_ioctl entry in /proc/devices and creating",
|
||||||
|
MEGA_DEVICE " as a character device with suitable",
|
||||||
|
"permissions with a matching major device number and a minor number of 0.",
|
||||||
|
#else
|
||||||
|
"This program requires the device file " MEGA_DEVICE " to be present on",
|
||||||
|
"the system. If your system does not have this device file, you may",
|
||||||
|
"create it either by executing Dell\'s \"dellmgr\" program once, or by",
|
||||||
|
"locating the megadev entry in /proc/devices and creating " MEGA_DEVICE,
|
||||||
|
"as a character device with suitable permissions with a matching major",
|
||||||
|
"device number and a minor number of 0.",
|
||||||
|
#endif
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void usage (const int ec, const char *format, ...)
|
||||||
|
{
|
||||||
|
char **u;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start (ap, format);
|
||||||
|
if (format)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: ", me);
|
||||||
|
vfprintf (stderr, format, ap);
|
||||||
|
fprintf (stderr, "\n\n");
|
||||||
|
}
|
||||||
|
for (u = usages; *u; ++u)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
int esc;
|
||||||
|
for (s = *u, esc = 0; *s; ++s)
|
||||||
|
{
|
||||||
|
if (esc)
|
||||||
|
{
|
||||||
|
switch (*s)
|
||||||
|
{
|
||||||
|
case 'p': fputs (me, stderr); break;
|
||||||
|
case '%': fputc ('%', stderr); break;
|
||||||
|
default: fputc ('%', stderr); fputc (*s, stderr); break;
|
||||||
|
}
|
||||||
|
esc = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (*s)
|
||||||
|
{
|
||||||
|
case '%': esc = 1; break;
|
||||||
|
default: fputc (*s, stderr); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fputc ('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit (ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *friendlySize (uint64_t b, char *unit)
|
||||||
|
{
|
||||||
|
static char *suffix[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi", };
|
||||||
|
int k;
|
||||||
|
static char bytes[128];
|
||||||
|
|
||||||
|
for (k = 0; (b >= 1024) && (k < sizeof (suffix) / sizeof (suffix[0]) - 1); ++k, b /= 1024)
|
||||||
|
;
|
||||||
|
snprintf (bytes, sizeof bytes, "%3llu%s%s", b, suffix[k], unit);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void describePhysicalDrive (FILE *f, struct physical_drive_info *d, int verbosity)
|
||||||
|
{
|
||||||
|
char *state;
|
||||||
|
|
||||||
|
if (d->present)
|
||||||
|
switch (d->state)
|
||||||
|
{
|
||||||
|
case PdStateUnconfiguredGood: state = "ready"; break;
|
||||||
|
case PdStateUnconfiguredBad: state = "BAD"; break;
|
||||||
|
case PdStateOnline: state = "online"; break;
|
||||||
|
case PdStateFailed: state = d->span ? "FAILED" : "rdy/fail"; break;
|
||||||
|
case PdStateRebuild: state = "rebuild"; break;
|
||||||
|
case PdStateHotspare: state = "hotspare"; break;
|
||||||
|
default: state = "???"; break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
state = "absent";
|
||||||
|
|
||||||
|
fprintf (f, "%-8s", d->name);
|
||||||
|
if (verbosity > 0)
|
||||||
|
fprintf (f, " %8s %-16s", d->vendor, d->model);
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, " rev:%-4s s/n:%-20s", d->revision, d->serial);
|
||||||
|
fprintf (f, " %7s", friendlySize (d->blocks << 9, "B"));
|
||||||
|
fprintf (f, " %5s%c", d->span && d->span->num_logical_drives ? d->span->logical_drive[0]->name : "", d->span && (d->span->num_logical_drives > 1) ? '+' : ' ');
|
||||||
|
fprintf (f, " %-8s", state);
|
||||||
|
if (d->media_errors || d->other_errors)
|
||||||
|
fprintf (f, " errs: media:%-2u other:%u", d->media_errors, d->other_errors);
|
||||||
|
if (d->predictive_failures)
|
||||||
|
fprintf (f, " predictive-failure");
|
||||||
|
fprintf (f, "\n");
|
||||||
|
if (d->present && d->error_string)
|
||||||
|
fprintf (f, "\t%s\n", d->error_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void describeLogicalDrive (FILE *f, struct logical_drive_info *l, int verbosity)
|
||||||
|
{
|
||||||
|
char *state;
|
||||||
|
uint64_t blocks;
|
||||||
|
int k;
|
||||||
|
struct span_reference *r;
|
||||||
|
|
||||||
|
switch (l->state)
|
||||||
|
{
|
||||||
|
case LdStateOffline: state = "OFFLINE"; break;
|
||||||
|
case LdStatePartiallyDegraded:
|
||||||
|
case LdStateDegraded: state = "DEGRADED"; break;
|
||||||
|
case LdStateOptimal: state = "optimal"; break;
|
||||||
|
case LdStateDeleted: state = "deleted"; break;
|
||||||
|
default: state = "???"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0, blocks = 0; k < l->num_spans; ++k)
|
||||||
|
{
|
||||||
|
r = &l->span[k];
|
||||||
|
switch (l->raid_level)
|
||||||
|
{
|
||||||
|
case 0: blocks += r->blocks_per_disk * r->span->num_disks; break;
|
||||||
|
case 1: blocks += r->blocks_per_disk * r->span->num_disks / 2; break;
|
||||||
|
case 5: blocks += r->blocks_per_disk * (r->span->num_disks - 1); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (f, "%-8s", l->name);
|
||||||
|
fprintf (f, " %s", friendlySize (blocks << 9, "B"));
|
||||||
|
fprintf (f, " RAID %u%s", l->raid_level, l->num_spans > 1 ? "0" : " ");
|
||||||
|
fprintf (f, " %2ux%-2u", l->num_spans, l->span_size);
|
||||||
|
fprintf (f, " %s", state);
|
||||||
|
fprintf (f, "\n");
|
||||||
|
if (verbosity > 0)
|
||||||
|
{
|
||||||
|
for (k = 0; k < l->num_spans; ++k)
|
||||||
|
{
|
||||||
|
struct physical_drive_info **p;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
r = &l->span[k];
|
||||||
|
fprintf (f, " row %2d:", k);
|
||||||
|
for (j = 0, p = r->span->disk; j < r->span->num_disks; ++j, ++p)
|
||||||
|
{
|
||||||
|
char *flag = (*p)->state != PdStateOnline ? "*" : " ";
|
||||||
|
fprintf (f, " %s%-8s", flag, (*p)->name);
|
||||||
|
}
|
||||||
|
fprintf (f, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void describeBattery (FILE *f, struct adapter_config *a, int verbosity)
|
||||||
|
{
|
||||||
|
if (a->battery.healthy)
|
||||||
|
fprintf (f, "good");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (f, "FAULT");
|
||||||
|
if (a->battery.module_missing)
|
||||||
|
fprintf (f, ", module missing");
|
||||||
|
if (a->battery.pack_missing)
|
||||||
|
fprintf (f, ", pack missing");
|
||||||
|
if (a->battery.low_voltage)
|
||||||
|
fprintf (f, ", low voltage");
|
||||||
|
if (a->battery.high_temperature)
|
||||||
|
fprintf (f, ", high temperature");
|
||||||
|
if (a->battery.cycles_exceeded)
|
||||||
|
fprintf (f, ", cycles exceeded");
|
||||||
|
if (a->battery.over_charged)
|
||||||
|
fprintf (f, ", over charged");
|
||||||
|
switch (a->battery.charger_state)
|
||||||
|
{
|
||||||
|
case ChargerStateComplete: break;
|
||||||
|
case ChargerStateFailed: fprintf (f, ", charge failed"); break;
|
||||||
|
case ChargerStateInProgress: fprintf (f, ", charging"); break;
|
||||||
|
default: fprintf (f, ", unknown charge state"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (verbosity)
|
||||||
|
{
|
||||||
|
if (a->battery.voltage >= 0)
|
||||||
|
fprintf (f, "/%dmV", a->battery.voltage);
|
||||||
|
if (a->battery.temperature >= 0)
|
||||||
|
fprintf (f, "/%dC", a->battery.temperature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void describeAdapter (FILE *f, struct adapter_config *a, int verbosity)
|
||||||
|
{
|
||||||
|
fprintf (f, "%-8s %-24s", a->name, a->product);
|
||||||
|
if (verbosity > 0)
|
||||||
|
fprintf (f, " bios:%s fw:%s", a->bios, a->firmware);
|
||||||
|
fprintf (f, " %s:%u ldrv:%-2u", a->is_sas ? "encl" : "chan", a->num_channels, a->num_logicals);
|
||||||
|
if (verbosity > 0)
|
||||||
|
fprintf (f, " rbld:%u%%", a->rebuild_rate);
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, " mem:%uMiB", a->dram_size);
|
||||||
|
fprintf (f, " batt:");
|
||||||
|
describeBattery (f, a, verbosity);
|
||||||
|
fprintf (f, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
int fd;
|
||||||
|
uint32_t numAdapters;
|
||||||
|
uint32_t driverVersion;
|
||||||
|
int startSelfTest = -1;
|
||||||
|
int healthCheck = 0;
|
||||||
|
int checkBattery = 1;
|
||||||
|
char *device = MEGA_DEVICE;
|
||||||
|
struct query_object {
|
||||||
|
int adapter;
|
||||||
|
int channel;
|
||||||
|
int id;
|
||||||
|
} *object = NULL;
|
||||||
|
int numObjects = 0;
|
||||||
|
uint8_t readLog[LOG_PAGE_MAX] = { 0, };
|
||||||
|
int reportPhysical = 1;
|
||||||
|
int showVersion = 0;
|
||||||
|
#ifdef MEGA_SAS_CTL
|
||||||
|
int sas = 1;
|
||||||
|
#else
|
||||||
|
int sas = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((me = strrchr (argv[0], '/')))
|
||||||
|
++me;
|
||||||
|
else
|
||||||
|
me = argv[0];
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
if ((object = (struct query_object *) malloc ((argc - 1) * sizeof (*object))) == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 1; k < argc; ++k)
|
||||||
|
{
|
||||||
|
if (argv[k][0] == '-')
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
for (s = argv[k] + 1; *s; ++s)
|
||||||
|
{
|
||||||
|
if (*s == 'v')
|
||||||
|
{
|
||||||
|
++verbosity;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 'e')
|
||||||
|
{
|
||||||
|
/* read error log pages */
|
||||||
|
readLog[0x02] = 1; /* write errors */
|
||||||
|
readLog[0x03] = 1; /* read errors */
|
||||||
|
readLog[0x05] = 1; /* read errors */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 's')
|
||||||
|
{
|
||||||
|
/* read self test log page */
|
||||||
|
readLog[0x10] = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 't')
|
||||||
|
{
|
||||||
|
/* read temperature log page */
|
||||||
|
readLog[0x0d] = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 'l')
|
||||||
|
{
|
||||||
|
/* read specific log page */
|
||||||
|
char *t;
|
||||||
|
unsigned long u;
|
||||||
|
|
||||||
|
if ((++k) >= argc)
|
||||||
|
usage (2, "no log page specified");
|
||||||
|
u = strtoul (argv[k], &t, 0);
|
||||||
|
if (*t)
|
||||||
|
usage (2, "invalid log page \"%s\"", argv[k]);
|
||||||
|
if (u >= sizeof (readLog) / sizeof (readLog[0]))
|
||||||
|
usage (2, "log page out of range: \"%s\"", argv[k]);
|
||||||
|
readLog[u] = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 'D')
|
||||||
|
{
|
||||||
|
/* specify device file */
|
||||||
|
if ((++k) >= argc)
|
||||||
|
usage (2, "no device specified");
|
||||||
|
device = argv[k];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 'p')
|
||||||
|
{
|
||||||
|
reportPhysical = 0;;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 'B')
|
||||||
|
{
|
||||||
|
/* skip battery check */
|
||||||
|
checkBattery = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 'H')
|
||||||
|
{
|
||||||
|
/* perform adapter health check */
|
||||||
|
++healthCheck;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*s == 'T')
|
||||||
|
{
|
||||||
|
/* start self test */
|
||||||
|
if ((++k) >= argc)
|
||||||
|
usage (2, "must specify short or long self-test");
|
||||||
|
if (!strcmp (argv[k], "short"))
|
||||||
|
startSelfTest = SCSI_SELFTEST_BACKGROUND_SHORT;
|
||||||
|
else if (!strcmp (argv[k], "long"))
|
||||||
|
startSelfTest = SCSI_SELFTEST_BACKGROUND_LONG;
|
||||||
|
else
|
||||||
|
usage (2, "invalid self test: \"%s\"; must specify short or long", argv[k]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if ((*s == '?') || (*s == 'h'))
|
||||||
|
usage (0, NULL);
|
||||||
|
else if (*s == 'V')
|
||||||
|
{
|
||||||
|
++showVersion;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
usage (2, "invalid flag \"%s\"", s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
char *t;
|
||||||
|
unsigned long l;
|
||||||
|
|
||||||
|
s = argv[k];
|
||||||
|
object[numObjects].adapter = -1;
|
||||||
|
object[numObjects].channel = -1;
|
||||||
|
object[numObjects].id = -1;
|
||||||
|
|
||||||
|
if (*s)
|
||||||
|
{
|
||||||
|
if (tolower (*s) != 'a')
|
||||||
|
usage (2, "invalid specifier \"%s\"", argv[k]);
|
||||||
|
++s;
|
||||||
|
l = strtoul (s, &t, 10);
|
||||||
|
if (s == t)
|
||||||
|
usage (2, "invalid specifier \"%s\"", argv[k]);
|
||||||
|
#ifndef MEGA_SAS_CTL
|
||||||
|
if (l >= MAX_CONTROLLERS)
|
||||||
|
usage (2, "adapter out of range: \"%s\"", argv[k]);
|
||||||
|
#endif
|
||||||
|
object[numObjects].adapter = l;
|
||||||
|
s = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*s)
|
||||||
|
{
|
||||||
|
if (tolower (*s) != (sas ? 'e' : 'c'))
|
||||||
|
usage (2, "invalid specifier \"%s\"", argv[k]);
|
||||||
|
++s;
|
||||||
|
l = strtoul (s, &t, 10);
|
||||||
|
if (s == t)
|
||||||
|
usage (2, "invalid specifier \"%s\"", argv[k]);
|
||||||
|
#ifndef MEGA_SAS_CTL
|
||||||
|
if (l >= MAX_MBOX_CHANNELS)
|
||||||
|
usage (2, "channel out of range: \"%s\"", argv[k]);
|
||||||
|
#endif
|
||||||
|
object[numObjects].channel = l;
|
||||||
|
s = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*s)
|
||||||
|
{
|
||||||
|
if (tolower (*s) != (sas ? 's' : 't'))
|
||||||
|
usage (2, "invalid specifier \"%s\"", argv[k]);
|
||||||
|
++s;
|
||||||
|
l = strtoul (s, &t, 10);
|
||||||
|
if (s == t)
|
||||||
|
usage (2, "invalid specifier \"%s\"", argv[k]);
|
||||||
|
#ifndef MEGA_SAS_CTL
|
||||||
|
if (l > MAX_MBOX_TARGET)
|
||||||
|
usage (2, "target out of range: \"%s\"", argv[k]);
|
||||||
|
#endif
|
||||||
|
object[numObjects].id = l;
|
||||||
|
s = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
++numObjects;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showVersion)
|
||||||
|
{
|
||||||
|
if (verbosity)
|
||||||
|
fprintf (stdout, "%s: version %s by Jefferson Ogata\n", me, version);
|
||||||
|
else
|
||||||
|
fprintf (stdout, "%s\n", version);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (healthCheck)
|
||||||
|
{
|
||||||
|
int set = 0;
|
||||||
|
|
||||||
|
for (k = 0; k < numObjects; ++k)
|
||||||
|
if ((object[k].channel >= 0) || (object[k].id >= 0))
|
||||||
|
usage (2, "for health check, must specify adapter only");
|
||||||
|
for (k = 0; k < sizeof readLog / sizeof (readLog[0]); ++k)
|
||||||
|
if (readLog[k])
|
||||||
|
{
|
||||||
|
set = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (set == 0)
|
||||||
|
{
|
||||||
|
/* No specific log pages requested; check read/write/verify errors and temperature. */
|
||||||
|
readLog[0x02] = 1;
|
||||||
|
readLog[0x03] = 1;
|
||||||
|
readLog[0x05] = 1;
|
||||||
|
readLog[0x0d] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fd = open (device, O_RDONLY)) < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "unable to open device %s: %s\n", device, strerror (errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef MEGA_SAS_CTL
|
||||||
|
if (megaGetDriverVersion (fd, &driverVersion) < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "unable to determine megaraid driver version: %s\n", megaErrorString ());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (driverVersion < MEGA_MIN_VERSION)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "megaraid driver version %x too old.\n", driverVersion);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (megaGetNumAdapters (fd, &numAdapters, sas) < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "unable to determine number of adapters: %s\n", megaErrorString ());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 2)
|
||||||
|
fprintf (stderr, "%u adapters, driver version %08x\n\n", numAdapters, driverVersion);
|
||||||
|
|
||||||
|
/* Default to enumerating all adapters. */
|
||||||
|
if (numObjects == 0)
|
||||||
|
{
|
||||||
|
if (object)
|
||||||
|
free (object);
|
||||||
|
if ((object = (struct query_object *) malloc (numAdapters * sizeof (*object))) == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for (k = 0; k < numAdapters; ++k)
|
||||||
|
{
|
||||||
|
object[k].adapter = k;
|
||||||
|
object[k].channel = -1;
|
||||||
|
object[k].id = -1;
|
||||||
|
}
|
||||||
|
numObjects = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < numObjects; ++k)
|
||||||
|
{
|
||||||
|
int adapter = object[k].adapter;
|
||||||
|
int channel = object[k].channel;
|
||||||
|
int id = object[k].id;
|
||||||
|
char name[32];
|
||||||
|
struct adapter_config *a;
|
||||||
|
uint32_t c;
|
||||||
|
uint32_t i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
if (id >= 0)
|
||||||
|
snprintf (name, sizeof name, "a%u%c%u%c%u", adapter, sas ? 'e' : 'c', channel, sas ? 's' : 't', id);
|
||||||
|
else if (channel >= 0)
|
||||||
|
snprintf (name, sizeof name, "a%u%c%u", adapter, sas ? 'e' : 'c', channel);
|
||||||
|
else
|
||||||
|
snprintf (name, sizeof name, "a%u", adapter);
|
||||||
|
|
||||||
|
if (adapter >= numAdapters)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: no such adapter\n", name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((a = getAdapterConfig (fd, adapter, sas)) == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: cannot read adapter configuration: %s\n", name, megaErrorString ());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (healthCheck)
|
||||||
|
{
|
||||||
|
int adapterReported = 0;
|
||||||
|
struct logical_drive_info *l;
|
||||||
|
|
||||||
|
if (checkBattery && (!a->battery.healthy))
|
||||||
|
{
|
||||||
|
if (!(adapterReported++))
|
||||||
|
describeAdapter (stdout, a, verbosity);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef MEGA_SAS_CTL
|
||||||
|
/* Scan all physical devices. */
|
||||||
|
for (c = 0; c < a->num_channels; ++c)
|
||||||
|
{
|
||||||
|
for (i = 0; i <= MAX_MBOX_TARGET; ++i)
|
||||||
|
{
|
||||||
|
uint8_t target = (a->channel[c] << 4) | i;
|
||||||
|
|
||||||
|
(void) getPhysicalDriveInfo (a, target, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0, l = a->logical; i < a->num_logicals; ++i, ++l)
|
||||||
|
{
|
||||||
|
int reportDrive = 0;
|
||||||
|
|
||||||
|
if ((l->state != LdStateOptimal) && (l->state != LdStateDeleted))
|
||||||
|
++reportDrive;
|
||||||
|
|
||||||
|
if (reportDrive)
|
||||||
|
{
|
||||||
|
if (!(adapterReported++))
|
||||||
|
describeAdapter (stdout, a, verbosity);
|
||||||
|
describeLogicalDrive (stdout, l, verbosity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < a->num_physicals; ++i)
|
||||||
|
{
|
||||||
|
struct physical_drive_info *d = a->physical_list[i];
|
||||||
|
int reportDrive = 0;
|
||||||
|
struct log_page_list *log;
|
||||||
|
|
||||||
|
if (d == NULL)
|
||||||
|
break;
|
||||||
|
if (!(d->present))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//describePhysicalDrive (stdout, d, verbosity);
|
||||||
|
|
||||||
|
/* check for drive problems */
|
||||||
|
if ((d->state == PdStateRebuild) || (d->span && (d->state == PdStateFailed)))
|
||||||
|
++reportDrive;
|
||||||
|
if (d->media_errors)
|
||||||
|
++reportDrive;
|
||||||
|
if (d->predictive_failures)
|
||||||
|
++reportDrive;
|
||||||
|
|
||||||
|
/* check interesting log pages */
|
||||||
|
for (j = 0; j < sizeof (readLog) / sizeof (readLog[0]); ++j)
|
||||||
|
{
|
||||||
|
if (readLog[j] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((log = getDriveLogPage (d, j)) == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (log->log.problem)
|
||||||
|
++reportDrive;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportDrive)
|
||||||
|
{
|
||||||
|
if (!(adapterReported++))
|
||||||
|
describeAdapter (stdout, a, verbosity);
|
||||||
|
describePhysicalDrive (stdout, d, verbosity);
|
||||||
|
for (j = 0; j < sizeof (readLog) / sizeof (readLog[0]); ++j)
|
||||||
|
{
|
||||||
|
if (readLog[j] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((log = getDriveLogPage (d, j)) == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dumpLogPage (stdout, &log->log, NULL, 0, verbosity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel >= 0)
|
||||||
|
{
|
||||||
|
for (c = 0; c < a->num_channels; ++c)
|
||||||
|
if (channel == a->channel[c])
|
||||||
|
break;
|
||||||
|
if (c >= a->num_channels)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: no such channel\n", name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((channel < 0) && (id < 0))
|
||||||
|
{
|
||||||
|
struct logical_drive_info *l;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
describeAdapter (stdout, a, verbosity);
|
||||||
|
|
||||||
|
#ifndef MEGA_SAS_CTL
|
||||||
|
/* Scan all physical devices. */
|
||||||
|
for (c = 0; c < a->num_channels; ++c)
|
||||||
|
{
|
||||||
|
for (i = 0; i <= MAX_MBOX_TARGET; ++i)
|
||||||
|
{
|
||||||
|
uint8_t target = (a->channel[c] << 4) | i;
|
||||||
|
|
||||||
|
(void) getPhysicalDriveInfo (a, target, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0, l = a->logical; i < a->num_logicals; ++i, ++l)
|
||||||
|
describeLogicalDrive (stdout, l, verbosity);
|
||||||
|
|
||||||
|
x = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < a->num_physicals; ++i)
|
||||||
|
{
|
||||||
|
struct physical_drive_info *d = a->physical_list[i];
|
||||||
|
|
||||||
|
if (d == NULL)
|
||||||
|
break;
|
||||||
|
if (!(d->present))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (d->state == PdStateHotspare)
|
||||||
|
{
|
||||||
|
if (x == 0)
|
||||||
|
fprintf (stdout, "hot spares :");
|
||||||
|
else if ((x % 8) == 0)
|
||||||
|
fprintf (stdout, " :");
|
||||||
|
fprintf (stdout, " %-8s", d->name);
|
||||||
|
if (((++x) % 8) == 0)
|
||||||
|
fprintf (stdout, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (x % 8)
|
||||||
|
fprintf (stdout, "\n");
|
||||||
|
|
||||||
|
x = 0;
|
||||||
|
for (i = 0; i < a->num_physicals; ++i)
|
||||||
|
{
|
||||||
|
struct physical_drive_info *d = a->physical_list[i];
|
||||||
|
|
||||||
|
if (d == NULL)
|
||||||
|
break;
|
||||||
|
if (!(d->present))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((!(d->span)) && (d->state != PdStateHotspare))
|
||||||
|
{
|
||||||
|
if (x == 0)
|
||||||
|
fprintf (stdout, "unconfigured :");
|
||||||
|
else if ((x % 8) == 0)
|
||||||
|
fprintf (stdout, " :");
|
||||||
|
fprintf (stdout, " %-8s", d->name);
|
||||||
|
if (((++x) % 8) == 0)
|
||||||
|
fprintf (stdout, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (x % 8)
|
||||||
|
fprintf (stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = 0; c < a->num_channels; ++c)
|
||||||
|
{
|
||||||
|
if ((channel >= 0) && (channel != a->channel[c]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
#ifndef MEGA_SAS_CTL
|
||||||
|
if (id >= 0)
|
||||||
|
{
|
||||||
|
uint8_t target = (a->channel[c] << 4) | id;
|
||||||
|
(void) getPhysicalDriveInfo (a, target, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Scan all devices on this channel. */
|
||||||
|
for (i = 0; i <= MAX_MBOX_TARGET; ++i)
|
||||||
|
{
|
||||||
|
uint8_t target = (a->channel[c] << 4) | i;
|
||||||
|
|
||||||
|
(void) getPhysicalDriveInfo (a, target, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < a->num_physicals; ++i)
|
||||||
|
{
|
||||||
|
struct physical_drive_info *d = a->physical_list[i];
|
||||||
|
|
||||||
|
if (d == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (d->channel != a->channel[c])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((id >= 0) && (id != d->id))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (startSelfTest >= 0)
|
||||||
|
{
|
||||||
|
uint8_t diag[256];
|
||||||
|
|
||||||
|
memset (diag, 0, sizeof diag);
|
||||||
|
if (megaScsiSendDiagnostic (&a->target, d->target, diag, sizeof diag, startSelfTest, 0, 0) < 0)
|
||||||
|
fprintf (stderr, "self test: %s\n", megaErrorString ());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportPhysical)
|
||||||
|
{
|
||||||
|
describePhysicalDrive (stdout, d, verbosity);
|
||||||
|
for (j = 0; j < sizeof (readLog) / sizeof (readLog[0]); ++j)
|
||||||
|
{
|
||||||
|
struct log_page_list *log;
|
||||||
|
|
||||||
|
if (readLog[j] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((log = getDriveLogPage (d, j)) == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dumpLogPage (stdout, &log->log, &log->buf, sizeof (log->buf), verbosity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (0)
|
||||||
|
{
|
||||||
|
uint8_t modes[1024];
|
||||||
|
|
||||||
|
memset (modes, 0, sizeof modes);
|
||||||
|
megaScsiModeSense (fd, adapter, target, modes, sizeof modes, 0, 0x3f, 0xff);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
523
src/megaioctl.c
Normal file
523
src/megaioctl.c
Normal file
@ -0,0 +1,523 @@
|
|||||||
|
/*
|
||||||
|
* Low-level interface to adapter information.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "megaioctl.h"
|
||||||
|
|
||||||
|
/* Don't include <sys/types.h> */
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <scsi/scsi.h>
|
||||||
|
|
||||||
|
|
||||||
|
int megaErrno = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static int doIoctl (struct mega_adapter_path *adapter, void *u)
|
||||||
|
{
|
||||||
|
switch (adapter->type)
|
||||||
|
{
|
||||||
|
case MEGA_ADAPTER_V2:
|
||||||
|
case MEGA_ADAPTER_V34:
|
||||||
|
return ioctl (adapter->fd, _IOWR(MEGAIOC_MAGIC, 0, struct uioctl_t), u);
|
||||||
|
case MEGA_ADAPTER_V5:
|
||||||
|
return ioctl (adapter->fd, MEGASAS_IOC_FIRMWARE, u);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int driverQuery (int fd, uint16_t adap, void *data, uint32_t len, uint8_t subop)
|
||||||
|
{
|
||||||
|
struct uioctl_t u;
|
||||||
|
struct mega_adapter_path adapter;
|
||||||
|
|
||||||
|
memset (&u, 0, sizeof u);
|
||||||
|
u.outlen = len;
|
||||||
|
u.ui.fcs.opcode = M_RD_DRIVER_IOCTL_INTERFACE;
|
||||||
|
u.ui.fcs.subopcode = subop;
|
||||||
|
u.ui.fcs.length = len;
|
||||||
|
u.data = data;
|
||||||
|
if (data)
|
||||||
|
memset (data, 0, len);
|
||||||
|
|
||||||
|
adapter.fd = fd;
|
||||||
|
adapter.type = MEGA_ADAPTER_V34;
|
||||||
|
if (doIoctl (&adapter, &u) < 0)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int oldCommand (struct mega_adapter_path *adapter, void *data, uint32_t len, uint8_t cmd, uint8_t opcode, uint8_t subopcode)
|
||||||
|
{
|
||||||
|
struct uioctl_t u;
|
||||||
|
int_mbox_t *m = (int_mbox_t *) &u.mbox;
|
||||||
|
|
||||||
|
memset (&u, 0, sizeof u);
|
||||||
|
u.outlen = len;
|
||||||
|
u.ui.fcs.opcode = M_RD_IOCTL_CMD;
|
||||||
|
u.ui.fcs.adapno = MKADAP(adapter->adapno);
|
||||||
|
u.data = data;
|
||||||
|
m->cmd = cmd;
|
||||||
|
m->opcode = opcode;
|
||||||
|
m->subopcode = subopcode;
|
||||||
|
m->xferaddr = (uint32_t) data;
|
||||||
|
if (data)
|
||||||
|
memset (data, 0, len);
|
||||||
|
|
||||||
|
if (doIoctl (adapter, &u) < 0)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int newCommand (struct mega_adapter_path *adapter, void *data, uint32_t len, uint8_t cmd, uint8_t opcode, uint8_t subopcode)
|
||||||
|
{
|
||||||
|
struct uioctl_t u;
|
||||||
|
int_mbox_t *m = (int_mbox_t *) &u.mbox;
|
||||||
|
|
||||||
|
memset (&u, 0, sizeof u);
|
||||||
|
u.outlen = len;
|
||||||
|
u.ui.fcs.opcode = M_RD_IOCTL_CMD_NEW;
|
||||||
|
u.ui.fcs.adapno = MKADAP(adapter->adapno);
|
||||||
|
u.ui.fcs.buffer = data;
|
||||||
|
u.ui.fcs.length = len;
|
||||||
|
u.data = data;
|
||||||
|
m->cmd = cmd;
|
||||||
|
m->opcode = opcode;
|
||||||
|
m->subopcode = subopcode;
|
||||||
|
m->xferaddr = (uint32_t) data;
|
||||||
|
if (data)
|
||||||
|
memset (data, 0, len);
|
||||||
|
|
||||||
|
if (doIoctl (adapter, &u) < 0)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int sasCommand (struct mega_adapter_path *adapter, void *data, uint32_t len, uint32_t opcode, uint16_t flags, void *mbox, uint32_t mboxlen)
|
||||||
|
{
|
||||||
|
struct megasas_iocpacket u;
|
||||||
|
struct megasas_dcmd_frame *f = (struct megasas_dcmd_frame *) &u.frame;
|
||||||
|
|
||||||
|
memset (&u, 0, sizeof u);
|
||||||
|
u.host_no = (u16) adapter->adapno;
|
||||||
|
|
||||||
|
f->cmd = MFI_CMD_DCMD;
|
||||||
|
f->flags = (u16) flags;
|
||||||
|
f->opcode = (u32) opcode;
|
||||||
|
|
||||||
|
if ((data != NULL) && (len > 0))
|
||||||
|
{
|
||||||
|
u.sgl_off = ((void *) &f->sgl) - ((void *) f);
|
||||||
|
u.sge_count = 1;
|
||||||
|
u.sgl[0].iov_base = data;
|
||||||
|
u.sgl[0].iov_len = len;
|
||||||
|
f->sge_count = 1;
|
||||||
|
f->data_xfer_len = (u32) len;
|
||||||
|
f->sgl.sge32[0].phys_addr = (u32) data;
|
||||||
|
f->sgl.sge32[0].length = (u32) len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mbox != NULL)
|
||||||
|
memcpy (&f->mbox, mbox, mboxlen);
|
||||||
|
|
||||||
|
if (doIoctl (adapter, &u) < 0)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return f->cmd_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int passthruCommand (struct mega_adapter_path *adapter, void *data, uint32_t len, uint8_t target, uint8_t *cdb, uint8_t cdblen)
|
||||||
|
{
|
||||||
|
if ((adapter->type == MEGA_ADAPTER_V2) || (adapter->type == MEGA_ADAPTER_V34))
|
||||||
|
{
|
||||||
|
struct uioctl_t u;
|
||||||
|
int_mbox_t *m = (int_mbox_t *) &u.mbox;
|
||||||
|
mraid_passthru_t *p = &u.pthru;
|
||||||
|
|
||||||
|
memset (&u, 0, sizeof u);
|
||||||
|
u.outlen = len;
|
||||||
|
u.ui.fcs.opcode = M_RD_IOCTL_CMD;
|
||||||
|
u.ui.fcs.adapno = MKADAP(adapter->adapno);
|
||||||
|
u.data = data;
|
||||||
|
m->cmd = MBOXCMD_PASSTHRU;
|
||||||
|
m->xferaddr = (uint32_t) p;
|
||||||
|
p->timeout = 3;
|
||||||
|
p->ars = 1;
|
||||||
|
p->target = target;
|
||||||
|
p->dataxferaddr = (uint32_t) data;
|
||||||
|
p->dataxferlen = len;
|
||||||
|
p->scsistatus = 239; /* HMMM */
|
||||||
|
memcpy (p->cdb, cdb, cdblen);
|
||||||
|
p->cdblen = cdblen;
|
||||||
|
if (data)
|
||||||
|
memset (data, 0, len);
|
||||||
|
|
||||||
|
if (doIoctl (adapter, &u) < 0)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m->status)
|
||||||
|
{
|
||||||
|
megaErrno = - (m->status);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->scsistatus & CHECK_CONDITION)
|
||||||
|
{
|
||||||
|
megaErrno = - CHECK_CONDITION;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ((p->scsistatus & STATUS_MASK) != GOOD)
|
||||||
|
{
|
||||||
|
megaErrno = - (p->scsistatus & STATUS_MASK);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct megasas_iocpacket u;
|
||||||
|
struct megasas_pthru_frame *f = (struct megasas_pthru_frame *) &u.frame;
|
||||||
|
|
||||||
|
memset (&u, 0, sizeof u);
|
||||||
|
u.host_no = (u16) adapter->adapno;
|
||||||
|
|
||||||
|
f->cmd = MFI_CMD_PD_SCSI_IO;
|
||||||
|
f->target_id = target;
|
||||||
|
f->cdb_len = cdblen;
|
||||||
|
f->flags = MFI_FRAME_DIR_READ;
|
||||||
|
memcpy (f->cdb, cdb, cdblen);
|
||||||
|
|
||||||
|
if ((data != NULL) && (len > 0))
|
||||||
|
{
|
||||||
|
u.sgl_off = ((void *) &f->sgl) - ((void *) f);
|
||||||
|
u.sge_count = 1;
|
||||||
|
u.sgl[0].iov_base = data;
|
||||||
|
u.sgl[0].iov_len = len;
|
||||||
|
|
||||||
|
f->sge_count = 1;
|
||||||
|
f->data_xfer_len = (u32) len;
|
||||||
|
f->sgl.sge32[0].phys_addr = (u32) data;
|
||||||
|
f->sgl.sge32[0].length = (u32) len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doIoctl (adapter, &u) < 0)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f->cmd_status)
|
||||||
|
{
|
||||||
|
megaErrno = - (f->cmd_status);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((f->scsi_status & STATUS_MASK) != GOOD)
|
||||||
|
{
|
||||||
|
megaErrno = - (f->scsi_status & STATUS_MASK);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaScsiDriveInquiry (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageCode, uint8_t evpd)
|
||||||
|
{
|
||||||
|
uint8_t cdb[6];
|
||||||
|
|
||||||
|
cdb[0] = INQUIRY;
|
||||||
|
cdb[1] = (evpd != 0);
|
||||||
|
cdb[2] = pageCode;
|
||||||
|
cdb[3] = (len >> 8) & 0xff;
|
||||||
|
cdb[4] = len & 0xff;
|
||||||
|
cdb[5] = 0;
|
||||||
|
|
||||||
|
return passthruCommand (adapter, data, len, target, cdb, sizeof cdb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaScsiModeSense (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageControl, uint8_t page, uint8_t subpage)
|
||||||
|
{
|
||||||
|
#ifdef USE_MODE_SENSE_6
|
||||||
|
uint8_t cdb[6];
|
||||||
|
|
||||||
|
cdb[0] = MODE_SENSE;
|
||||||
|
cdb[1] = 0; /* dbd in bit 3 */
|
||||||
|
cdb[2] = ((pageControl & 0x3) << 6) | (page & 0x3f);
|
||||||
|
cdb[3] = subpage;
|
||||||
|
cdb[4] = len & 0xff;
|
||||||
|
cdb[5] = 0;
|
||||||
|
#else
|
||||||
|
uint8_t cdb[10];
|
||||||
|
|
||||||
|
cdb[0] = MODE_SENSE_10;
|
||||||
|
cdb[1] = 0; /* llbaa in bit 4, dbd in bit 3 */
|
||||||
|
cdb[2] = ((pageControl & 0x3) << 6) | (page & 0x3f);
|
||||||
|
cdb[3] = subpage;
|
||||||
|
cdb[4] = 0;
|
||||||
|
cdb[5] = 0;
|
||||||
|
cdb[6] = 0;
|
||||||
|
cdb[7] = (len >> 8) & 0xff;
|
||||||
|
cdb[8] = len & 0xff;
|
||||||
|
cdb[9] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return passthruCommand (adapter, data, len, target, cdb, sizeof cdb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaScsiLogSense (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageControl, uint8_t page, uint16_t parameterPointer)
|
||||||
|
{
|
||||||
|
uint8_t cdb[10];
|
||||||
|
|
||||||
|
cdb[0] = LOG_SENSE;
|
||||||
|
cdb[1] = 0; /* ppc in bit 1, sp in bit 1 */
|
||||||
|
cdb[2] = ((pageControl & 0x3) << 6) | (page & 0x3f);
|
||||||
|
cdb[3] = 0;
|
||||||
|
cdb[4] = 0;
|
||||||
|
cdb[5] = (parameterPointer >> 8) & 0xff;
|
||||||
|
cdb[6] = parameterPointer & 0xff;
|
||||||
|
cdb[7] = (len >> 8) & 0xff;
|
||||||
|
cdb[8] = len & 0xff;
|
||||||
|
cdb[9] = 0;
|
||||||
|
|
||||||
|
return passthruCommand (adapter, data, len, target, cdb, sizeof cdb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaScsiSendDiagnostic (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t testCode, uint8_t unitOffline, uint8_t deviceOffline)
|
||||||
|
{
|
||||||
|
uint8_t cdb[6];
|
||||||
|
|
||||||
|
cdb[0] = SEND_DIAGNOSTIC;
|
||||||
|
cdb[1] = ((testCode & 0x7) << 5) | ((deviceOffline != 0) << 1) | (unitOffline != 0);
|
||||||
|
cdb[2] = 0;
|
||||||
|
cdb[3] = 0;
|
||||||
|
cdb[4] = 0;
|
||||||
|
cdb[5] = 0;
|
||||||
|
|
||||||
|
return passthruCommand (adapter, data, len, target, cdb, sizeof cdb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetAdapterConfig8 (struct mega_adapter_path *adapter, disk_array_8ld_span8_t *config)
|
||||||
|
{
|
||||||
|
return oldCommand (adapter, config, sizeof (*config), NEW_READ_CONFIG_8LD, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetAdapterConfig40 (struct mega_adapter_path *adapter, disk_array_40ld_t *config)
|
||||||
|
{
|
||||||
|
return newCommand (adapter, config, sizeof (*config), FC_NEW_CONFIG, OP_DCMD_READ_CONFIG, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetAdapterInquiry (struct mega_adapter_path *adapter, mraid_inquiry1_t *data)
|
||||||
|
{
|
||||||
|
return oldCommand (adapter, data, sizeof (*data), MBOXCMD_ADAPTERINQ, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetAdapterExtendedInquiry (struct mega_adapter_path *adapter, mraid_extinq1_t *data)
|
||||||
|
{
|
||||||
|
return oldCommand (adapter, data, sizeof (*data), MBOXCMD_ADPEXTINQ, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetAdapterEnquiry3 (struct mega_adapter_path *adapter, mraid_inquiry3_t *data)
|
||||||
|
{
|
||||||
|
return newCommand (adapter, data, sizeof (*data), FC_NEW_CONFIG, NC_SUBOP_ENQUIRY3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetPredictiveMap (struct mega_adapter_path *adapter, struct mega_predictive_map *data)
|
||||||
|
{
|
||||||
|
return oldCommand (adapter, data, sizeof (*data), MAIN_MISC_OPCODE, 0x0f, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetDriveErrorCount (struct mega_adapter_path *adapter, uint8_t target, struct mega_physical_drive_error_info *data)
|
||||||
|
{
|
||||||
|
return oldCommand (adapter, data, sizeof (*data), 0x77, 0, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaSasGetDeviceList (struct mega_adapter_path *adapter, struct mega_device_list_sas **data)
|
||||||
|
{
|
||||||
|
unsigned char buf[0x20];
|
||||||
|
uint32_t len;
|
||||||
|
|
||||||
|
if (sasCommand (adapter, buf, sizeof buf, 0x02010000, MFI_FRAME_DIR_READ, NULL, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
len = ((struct mega_device_list_sas *) buf)->length;
|
||||||
|
if ((*data = (struct mega_device_list_sas *) malloc (len)) == NULL)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return sasCommand (adapter, *data, len, 0x02010000, MFI_FRAME_DIR_READ, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaSasGetDiskInfo (struct mega_adapter_path *adapter, uint8_t target, struct mega_physical_disk_info_sas *data)
|
||||||
|
{
|
||||||
|
uint8_t mbox[0xc];
|
||||||
|
|
||||||
|
memset (&mbox, 0, sizeof mbox);
|
||||||
|
mbox[0] = target;
|
||||||
|
return sasCommand (adapter, data, sizeof (*data), 0x02020000, MFI_FRAME_DIR_READ, mbox, sizeof mbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaSasGetArrayConfig (struct mega_adapter_path *adapter, struct mega_array_config_sas *data)
|
||||||
|
{
|
||||||
|
unsigned char buf[0x20];
|
||||||
|
uint32_t len;
|
||||||
|
|
||||||
|
if (sasCommand (adapter, buf, sizeof buf, 0x04010000, MFI_FRAME_DIR_READ, NULL, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
len = ((struct mega_array_header_sas *) buf)->length;
|
||||||
|
if ((data->header = (struct mega_array_header_sas *) malloc (len)) == NULL)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (sasCommand (adapter, data->header, len, 0x04010000, MFI_FRAME_DIR_READ, NULL, 0) < 0)
|
||||||
|
{
|
||||||
|
megaErrno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->span = (struct mega_array_span_def_sas *) (data->header + 1);
|
||||||
|
data->disk = (struct mega_array_disk_def_sas *) (data->span + data->header->num_span_defs);
|
||||||
|
data->hotspare = (struct mega_array_hotspare_def_sas *) (data->disk + data->header->num_disk_defs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int megaSasGetBatteryInfo (struct mega_adapter_path *adapter, struct mega_battery_info_sas *data)
|
||||||
|
{
|
||||||
|
if (sasCommand (adapter, &(data->state), sizeof (data->state), 0x05010000, MFI_FRAME_DIR_READ, NULL, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
if (sasCommand (adapter, &(data->capacity), sizeof (data->capacity), 0x05020000, MFI_FRAME_DIR_READ, NULL, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
if (sasCommand (adapter, &(data->design), sizeof (data->design), 0x05030000, MFI_FRAME_DIR_READ, NULL, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
return sasCommand (adapter, &(data->properties), sizeof (data->properties), 0x05050100, MFI_FRAME_DIR_READ, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetDriverVersion (int fd, uint32_t *version)
|
||||||
|
{
|
||||||
|
return driverQuery (fd, 0, version, sizeof (*version), 'e');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetNumAdapters (int fd, uint32_t *numAdapters, int sas)
|
||||||
|
{
|
||||||
|
if (sas)
|
||||||
|
{
|
||||||
|
uint8_t k;
|
||||||
|
for (k = 0; k < 16; ++k)
|
||||||
|
if (megaSasAdapterPing (fd, k) < 0)
|
||||||
|
break;
|
||||||
|
*numAdapters = k;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return driverQuery (fd, 0, numAdapters, sizeof (*numAdapters), 'm');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaGetAdapterProductInfo (int fd, uint8_t adapno, mraid_pinfo_t *data)
|
||||||
|
{
|
||||||
|
struct mega_adapter_path adapter;
|
||||||
|
adapter.fd = fd;
|
||||||
|
adapter.adapno = adapno;
|
||||||
|
adapter.type = MEGA_ADAPTER_V34;
|
||||||
|
return newCommand (&adapter, data, sizeof (*data), FC_NEW_CONFIG, NC_SUBOP_PRODUCT_INFO, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaSasGetAdapterProductInfo (int fd, uint8_t adapno, struct megasas_ctrl_info *data)
|
||||||
|
{
|
||||||
|
struct mega_adapter_path adapter;
|
||||||
|
adapter.fd = fd;
|
||||||
|
adapter.adapno = adapno;
|
||||||
|
adapter.type = MEGA_ADAPTER_V5;
|
||||||
|
return sasCommand (&adapter, data, sizeof (*data), MR_DCMD_CTRL_GET_INFO, MFI_FRAME_DIR_READ, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int megaSasAdapterPing (int fd, uint8_t adapno)
|
||||||
|
{
|
||||||
|
struct mega_adapter_path adapter;
|
||||||
|
unsigned char data[0xc4];
|
||||||
|
adapter.fd = fd;
|
||||||
|
adapter.adapno = adapno;
|
||||||
|
adapter.type = MEGA_ADAPTER_V5;
|
||||||
|
return sasCommand (&adapter, data, sizeof data, 0x04060100, MFI_FRAME_DIR_READ, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *megaErrorString (void)
|
||||||
|
{
|
||||||
|
if (megaErrno >= 0)
|
||||||
|
return strerror (megaErrno);
|
||||||
|
switch (-megaErrno)
|
||||||
|
{
|
||||||
|
case CHECK_CONDITION: return "scsi command status CHECK_CONDITION"; break;
|
||||||
|
case CONDITION_GOOD: return "scsi command status CONDITION_GOOD"; break;
|
||||||
|
case BUSY: return "scsi command status BUSY"; break;
|
||||||
|
case INTERMEDIATE_GOOD: return "scsi command status INTERMEDIATE_GOOD"; break;
|
||||||
|
case INTERMEDIATE_C_GOOD: return "scsi command status INTERMEDIATE_C_GOOD"; break;
|
||||||
|
case RESERVATION_CONFLICT: return "scsi command status RESERVATION_CONFLICT"; break;
|
||||||
|
case COMMAND_TERMINATED: return "scsi command status COMMAND_TERMINATED"; break;
|
||||||
|
case QUEUE_FULL: return "scsi command status QUEUE_FULL"; break;
|
||||||
|
default: return "scsi command status unknown"; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
90
src/megaioctl.h
Normal file
90
src/megaioctl.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#ifndef _MEGAIOCTL_H
|
||||||
|
#define _MEGAIOCTL_H
|
||||||
|
/*
|
||||||
|
* Definitions for low-level adapter interface.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "mega.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Old-style ioctl structure for megaraid 1 & 2 drivers. Cribbed from version 1 megaraid.h. */
|
||||||
|
#pragma pack(1)
|
||||||
|
struct uioctl_t {
|
||||||
|
uint32_t inlen;
|
||||||
|
uint32_t outlen;
|
||||||
|
union {
|
||||||
|
uint8_t fca[16];
|
||||||
|
struct {
|
||||||
|
uint8_t opcode;
|
||||||
|
uint8_t subopcode;
|
||||||
|
uint16_t adapno;
|
||||||
|
#if BITS_PER_LONG == 32
|
||||||
|
uint8_t *buffer;
|
||||||
|
uint8_t pad[4];
|
||||||
|
#endif
|
||||||
|
#if BITS_PER_LONG == 64
|
||||||
|
uint8_t *buffer;
|
||||||
|
#endif
|
||||||
|
uint32_t length;
|
||||||
|
} fcs;
|
||||||
|
} ui;
|
||||||
|
uint8_t mbox[18]; /* 16 bytes + 2 status bytes */
|
||||||
|
mraid_passthru_t pthru;
|
||||||
|
#if BITS_PER_LONG == 32
|
||||||
|
char *data; /* buffer <= 4096 for 0x80 commands */
|
||||||
|
char pad[4];
|
||||||
|
#endif
|
||||||
|
#if BITS_PER_LONG == 64
|
||||||
|
char *data;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
extern int megaErrno;
|
||||||
|
|
||||||
|
extern int megaScsiDriveInquiry (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageCode, uint8_t evpd);
|
||||||
|
extern int megaScsiModeSense (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageControl, uint8_t page, uint8_t subpage);
|
||||||
|
extern int megaScsiLogSense (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t pageControl, uint8_t page, uint16_t parameterPointer);
|
||||||
|
extern int megaScsiSendDiagnostic (struct mega_adapter_path *adapter, uint8_t target, void *data, uint32_t len, uint8_t testCode, uint8_t unitOffline, uint8_t deviceOffline);
|
||||||
|
extern int megaGetAdapterConfig8 (struct mega_adapter_path *adapter, disk_array_8ld_span8_t *data);
|
||||||
|
extern int megaGetAdapterConfig40 (struct mega_adapter_path *adapter, disk_array_40ld_t *data);
|
||||||
|
extern int megaGetAdapterInquiry (struct mega_adapter_path *adapter, mraid_inquiry1_t *data);
|
||||||
|
extern int megaGetAdapterExtendedInquiry (struct mega_adapter_path *adapter, mraid_extinq1_t *data);
|
||||||
|
extern int megaGetAdapterEnquiry3 (struct mega_adapter_path *adapter, mraid_inquiry3_t *data);
|
||||||
|
extern int megaGetPredictiveMap (struct mega_adapter_path *adapter, struct mega_predictive_map *data);
|
||||||
|
extern int megaGetDriveErrorCount (struct mega_adapter_path *adapter, uint8_t target, struct mega_physical_drive_error_info *data);
|
||||||
|
|
||||||
|
extern int megaSasGetDeviceList (struct mega_adapter_path *adapter, struct mega_device_list_sas **data);
|
||||||
|
extern int megaSasGetDiskInfo (struct mega_adapter_path *adapter, uint8_t target, struct mega_physical_disk_info_sas *data);
|
||||||
|
extern int megaSasGetArrayConfig (struct mega_adapter_path *adapter, struct mega_array_config_sas *data);
|
||||||
|
extern int megaSasGetBatteryInfo (struct mega_adapter_path *adapter, struct mega_battery_info_sas *data);
|
||||||
|
|
||||||
|
extern int megaGetDriverVersion (int fd, uint32_t *version);
|
||||||
|
extern int megaGetNumAdapters (int fd, uint32_t *numAdapters, int sas);
|
||||||
|
extern int megaGetAdapterProductInfo (int fd, uint8_t adapno, mraid_pinfo_t *info);
|
||||||
|
extern int megaSasGetAdapterProductInfo (int fd, uint8_t adapno, struct megasas_ctrl_info *info);
|
||||||
|
extern int megaSasAdapterPing (int fd, uint8_t adapno);
|
||||||
|
|
||||||
|
extern char *megaErrorString (void);
|
||||||
|
|
||||||
|
#endif
|
1
src/megaraid
Symbolic link
1
src/megaraid
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2
|
66
src/megarpt
Executable file
66
src/megarpt
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# megarpt
|
||||||
|
#
|
||||||
|
# Emails a message to root with megaraid configuration and any
|
||||||
|
# output from a health check. Useful as a nightly cron job.
|
||||||
|
#
|
||||||
|
# Author: Jefferson Ogata (JO317) <ogata@antibozo.net>
|
||||||
|
# Date: 2007/08/20
|
||||||
|
|
||||||
|
VERSION='0.3'
|
||||||
|
MEGACTL=/root/megactl
|
||||||
|
DEVICE=/dev/megadev0
|
||||||
|
DEVICENAME=megadev
|
||||||
|
DEVICEPERM=644
|
||||||
|
ME=`basename $0`
|
||||||
|
|
||||||
|
if [ -x $MEGACTL ]; then
|
||||||
|
MEGACTLVERSION=`$MEGACTL -V`
|
||||||
|
else
|
||||||
|
echo "No megactl program in $MEGACTL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MAJOR=`grep "$DEVICENAME" /proc/devices | awk '{print $1}'`
|
||||||
|
|
||||||
|
if [ -n "$MAJOR" -a ! -e "$DEVICE" ]; then
|
||||||
|
mknod "$DEVICE" c "$MAJOR" 0
|
||||||
|
chmod "$DEVICEPERM" "$DEVICE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "$DEVICE" ]; then
|
||||||
|
|
||||||
|
WARN=
|
||||||
|
HOST=`/bin/uname -n`
|
||||||
|
DATE=`/bin/date '+%Y/%m/%d %H:%M:%S %Z'`
|
||||||
|
HC=/tmp/megactl.$$
|
||||||
|
|
||||||
|
$MEGACTL -vH > $HC 2>/dev/null
|
||||||
|
if [ -s $HC ]; then
|
||||||
|
WARN=' **WARNING**'
|
||||||
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
if [ -s $HC ]; then
|
||||||
|
echo "megaraid health check"
|
||||||
|
echo "---------------------"
|
||||||
|
cat $HC
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "megaraid configuration"
|
||||||
|
echo "----------------------"
|
||||||
|
$MEGACTL -vp
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "--------------"
|
||||||
|
echo "$ME version: $VERSION"
|
||||||
|
echo "megactl version: $MEGACTLVERSION"
|
||||||
|
) 2>/dev/null |
|
||||||
|
/bin/mail -s "RAID report:$WARN $HOST $DATE" root
|
||||||
|
|
||||||
|
rm -f $HC
|
||||||
|
fi
|
||||||
|
|
66
src/megasasrpt
Executable file
66
src/megasasrpt
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# megarpt
|
||||||
|
#
|
||||||
|
# Emails a message to root with megaraid configuration and any
|
||||||
|
# output from a health check. Useful as a nightly cron job.
|
||||||
|
#
|
||||||
|
# Author: Jefferson Ogata (JO317) <ogata@antibozo.net>
|
||||||
|
# Date: 2007/08/20
|
||||||
|
|
||||||
|
VERSION='0.3'
|
||||||
|
MEGACTL=/root/megasasctl
|
||||||
|
DEVICE=/dev/megaraid_sas_ioctl_node
|
||||||
|
DEVICENAME=megaraid_sas_ioctl
|
||||||
|
DEVICEPERM=400
|
||||||
|
ME=`basename $0`
|
||||||
|
|
||||||
|
if [ -x $MEGACTL ]; then
|
||||||
|
MEGACTLVERSION=`$MEGACTL -V`
|
||||||
|
else
|
||||||
|
echo "No megactl program in $MEGACTL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MAJOR=`grep "$DEVICENAME" /proc/devices | awk '{print $1}'`
|
||||||
|
|
||||||
|
if [ -n "$MAJOR" -a ! -e "$DEVICE" ]; then
|
||||||
|
mknod "$DEVICE" c "$MAJOR" 0
|
||||||
|
chmod "$DEVICEPERM" "$DEVICE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "$DEVICE" ]; then
|
||||||
|
|
||||||
|
WARN=
|
||||||
|
HOST=`/bin/uname -n`
|
||||||
|
DATE=`/bin/date '+%Y/%m/%d %H:%M:%S %Z'`
|
||||||
|
HC=/tmp/megactl.$$
|
||||||
|
|
||||||
|
$MEGACTL -vH > $HC 2>/dev/null
|
||||||
|
if [ -s $HC ]; then
|
||||||
|
WARN=' **WARNING**'
|
||||||
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
if [ -s $HC ]; then
|
||||||
|
echo "megaraid health check"
|
||||||
|
echo "---------------------"
|
||||||
|
cat $HC
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "megaraid configuration"
|
||||||
|
echo "----------------------"
|
||||||
|
$MEGACTL -vp
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "--------------"
|
||||||
|
echo "$ME version: $VERSION"
|
||||||
|
echo "megactl version: $MEGACTLVERSION"
|
||||||
|
) 2>/dev/null |
|
||||||
|
/bin/mail -s "RAID report:$WARN $HOST $DATE" root
|
||||||
|
|
||||||
|
rm -f $HC
|
||||||
|
fi
|
||||||
|
|
468
src/megatrace.c
Normal file
468
src/megatrace.c
Normal file
@ -0,0 +1,468 @@
|
|||||||
|
/*
|
||||||
|
* Main program for ioctl tracer.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
/********************************************************************
|
||||||
|
|
||||||
|
megatrace
|
||||||
|
|
||||||
|
Program to ptrace another program and inspect megaraid-related ioctl
|
||||||
|
syscalls it makes.
|
||||||
|
|
||||||
|
Author: Jefferson Ogata (JO317) <ogata@antibozo.net>
|
||||||
|
Date: 2006/01/23
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
|
||||||
|
Fixes for 64-bit systems.
|
||||||
|
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "mega.h"
|
||||||
|
#include "megaioctl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <asm/user.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <scsi/scsi.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "callinfo.h"
|
||||||
|
#include "dumpbytes.h"
|
||||||
|
|
||||||
|
enum state { UNTRACED, INBOUND, OUTBOUND };
|
||||||
|
|
||||||
|
|
||||||
|
void copyout (void *buf, size_t len, pid_t pid, uint32_t addr)
|
||||||
|
{
|
||||||
|
off_t k;
|
||||||
|
uint32_t *z = (uint32_t *) buf;
|
||||||
|
uint32_t sd;
|
||||||
|
|
||||||
|
for (k = 0; k < (len + 3) / 4; ++k)
|
||||||
|
{
|
||||||
|
sd = ptrace (PTRACE_PEEKDATA, pid, (void *) (addr + 4 * k), 0);
|
||||||
|
z[k] = sd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void copyin (void *buf, size_t len, pid_t pid, uint32_t addr)
|
||||||
|
{
|
||||||
|
off_t k;
|
||||||
|
uint32_t *z = (uint32_t *) buf;
|
||||||
|
|
||||||
|
for (k = 0; k < (len + 3) / 4; ++k)
|
||||||
|
ptrace (PTRACE_POKEDATA, pid, (void *) (addr + 4 * k), z[k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main (int argc, char **argv, char **environ)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
int state = UNTRACED;
|
||||||
|
struct timeval starttv;
|
||||||
|
int printproc = 0;
|
||||||
|
|
||||||
|
if ((pid = fork ()) == 0)
|
||||||
|
{
|
||||||
|
ptrace (PTRACE_TRACEME);
|
||||||
|
++argv;
|
||||||
|
execvp (argv[0], argv);
|
||||||
|
fprintf (stderr, "execve: %s: %s\n", argv[0], strerror (errno));
|
||||||
|
_exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "fork: %s\n", strerror (errno));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday (&starttv, NULL);
|
||||||
|
|
||||||
|
/*fprintf (stderr, "%d\n", sizeof (mega_host_config));*/
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
pid_t w;
|
||||||
|
int st;
|
||||||
|
|
||||||
|
w = waitpid (pid, &st, /*WNOHANG*/ 0);
|
||||||
|
|
||||||
|
if (w == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "wait: no child\n");
|
||||||
|
usleep (10);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "wait: %s\n", strerror (errno));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WIFEXITED (st))
|
||||||
|
{
|
||||||
|
if (printproc)
|
||||||
|
fprintf (stderr, "child exited with status %d\n", WEXITSTATUS (st));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WIFSTOPPED (st))
|
||||||
|
{
|
||||||
|
if (WSTOPSIG (st) == SIGTRAP)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
long secs;
|
||||||
|
long usecs;
|
||||||
|
char tbuf[1024];
|
||||||
|
int printcalls = (getenv ("LOG_CALLS") != NULL);
|
||||||
|
int printthis = 0;
|
||||||
|
int printregs = (getenv ("LOG_REGS") != NULL);
|
||||||
|
|
||||||
|
struct user_regs_struct r;
|
||||||
|
u32 call;
|
||||||
|
|
||||||
|
gettimeofday (&tv, NULL);
|
||||||
|
secs = tv.tv_sec - starttv.tv_sec;
|
||||||
|
usecs = tv.tv_usec - starttv.tv_usec;
|
||||||
|
if (usecs < 0)
|
||||||
|
{
|
||||||
|
usecs += 1000000;
|
||||||
|
secs -= 1;
|
||||||
|
}
|
||||||
|
snprintf (tbuf, sizeof tbuf, "%ld.%06ld", secs, usecs);
|
||||||
|
|
||||||
|
if (ptrace (PTRACE_GETREGS, pid, 0, &r) < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "ptrace:getregs: %s\n", strerror (errno));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
call = r.orig_eax;
|
||||||
|
/*printthis = call == SYS_ioctl;*/
|
||||||
|
|
||||||
|
if (state == INBOUND)
|
||||||
|
{
|
||||||
|
if (printcalls || printthis)
|
||||||
|
{
|
||||||
|
if ((call >= 0) && (call < callmax) && (callinfo[call].name != NULL))
|
||||||
|
fprintf (stderr, "%s()", callinfo[call].name);
|
||||||
|
else
|
||||||
|
fprintf (stderr, "syscall(%u)", call);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == OUTBOUND)
|
||||||
|
{
|
||||||
|
if ((call < 0) || (call > callmax) || (callinfo[call].name == NULL))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "= 0x%08lx\n", (unsigned long) r.eax);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (callinfo[call].ptrval)
|
||||||
|
{
|
||||||
|
if (printcalls || printthis)
|
||||||
|
fprintf (stderr, " = 0x%08lx\n", r.eax);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long rv = r.eax;
|
||||||
|
if (rv < 0)
|
||||||
|
{
|
||||||
|
if (printcalls || printthis)
|
||||||
|
fprintf (stderr, " = -1 (%s)\n", strerror (-rv));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (printcalls || printthis)
|
||||||
|
fprintf (stderr, " = %lu\n", rv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((call == SYS_ioctl) && ((state == OUTBOUND) || getenv ("LOG_INBOUND")))
|
||||||
|
{
|
||||||
|
unsigned int len = 16;
|
||||||
|
unsigned char buf[65536];
|
||||||
|
|
||||||
|
unsigned long fd = r.ebx;
|
||||||
|
|
||||||
|
unsigned long ioc = r.ecx;
|
||||||
|
unsigned int iocdir = _IOC_DIR(ioc);
|
||||||
|
unsigned char ioctype = _IOC_TYPE(ioc);
|
||||||
|
unsigned int iocnr = _IOC_NR(ioc);
|
||||||
|
unsigned int iocsize = _IOC_SIZE(ioc);
|
||||||
|
char *iocdirname;
|
||||||
|
|
||||||
|
unsigned long arg = r.edx;
|
||||||
|
|
||||||
|
switch (iocdir)
|
||||||
|
{
|
||||||
|
case _IOC_READ: iocdirname = "r"; break;
|
||||||
|
case _IOC_WRITE: iocdirname = "w"; break;
|
||||||
|
case _IOC_READ|_IOC_WRITE: iocdirname = "rw"; break;
|
||||||
|
default: iocdirname = "none"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "%s: ioctl(%ld, _IOC(\"%s\",'%c',0x%02x,0x%02x), 0x%08lx)", tbuf, fd, iocdirname, ioctype, iocnr, iocsize, arg);
|
||||||
|
if (state == OUTBOUND)
|
||||||
|
fprintf (stderr, " = %ld\n", r.eax);
|
||||||
|
if (getenv ("LOG_INBOUND"))
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
|
if (_IOC_SIZE(ioc) > len)
|
||||||
|
len = _IOC_SIZE(ioc);
|
||||||
|
if (len > sizeof buf)
|
||||||
|
len = sizeof buf;
|
||||||
|
|
||||||
|
if (printregs)
|
||||||
|
fprintf (stderr, " ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx ebp=%08lx eax=%08lx ds=%04x __ds=%04x es=%04x __es=%04x fs=%04x __fs=%04x gs=%04x __gs=%04x orig_eax=%08lx eip=%08lx cs=%04x __cs=%04x eflags=%08lx esp=%08lx ss=%04x __ss=%04x\n", r.ebx, r.ecx, r.edx, r.esi, r.edi, r.ebp, r.eax, r.ds, r.__ds, r.es, r.__es, r.fs, r.__fs, r.gs, r.__gs, r.orig_eax, r.eip, r.cs, r.__cs, r.eflags, r.esp, r.ss, r.__ss);
|
||||||
|
|
||||||
|
copyout (buf, len, pid, r.edx);
|
||||||
|
|
||||||
|
if ((ioctype == 'm') && (iocnr == 0) && (iocsize == sizeof (struct uioctl_t)))
|
||||||
|
{
|
||||||
|
/* megaraid_mbox-style ioctl */
|
||||||
|
struct uioctl_t *uio = (struct uioctl_t *) buf;
|
||||||
|
mraid_passthru_t p = uio->pthru;
|
||||||
|
unsigned long datalen;
|
||||||
|
int_mbox_t *m = (int_mbox_t *) uio->mbox;
|
||||||
|
|
||||||
|
fprintf (stderr, " uio:\tinlen %u, outlen %u, { op %02x, subop %02x, adap %04x, buf %08lx, len %u }, data %08lx\n", uio->inlen, uio->outlen, uio->ui.fcs.opcode, uio->ui.fcs.subopcode, uio->ui.fcs.adapno, (unsigned long) uio->ui.fcs.buffer, uio->ui.fcs.length, (unsigned long) uio->data);
|
||||||
|
dumpbytes (stderr, uio, sizeof (*uio), uio, "uioc");
|
||||||
|
fprintf (stderr, " mbox:\tcmd %02x, cmdid %02x, op %02x, subop %02x, lba %08x, xfer %08x, ldrv %02x, numsge %u, busy %u, nstatus %u, status %u\n", m->cmd, m->cmdid, m->opcode, m->subopcode, m->lba, m->xferaddr, m->logdrv, m->rsvd[0], m->rsvd[2], m->numstatus, m->status);
|
||||||
|
dumpbytes (stderr, uio->mbox, sizeof (uio->mbox), uio->mbox, "mbox");
|
||||||
|
fprintf (stderr, " pass:\ttimeout %u, ars %u, isldrv %u, ldrv %u, chan %u, targ %02x, qtag %u, qact %u, numsge %u, scsistat %u\n", p.timeout, p.ars, p.islogical, p.logdrv, p.channel, p.target, p.queuetag, p.queueaction, p.numsge, p.scsistatus);
|
||||||
|
dumpbytes (stderr, &p.cdb, p.cdblen, &p.cdb, "cdb");
|
||||||
|
dumpbytes (stderr, &p.reqsensearea, p.reqsenselen, &p.reqsensearea, "rqsense");
|
||||||
|
dumpbytes (stderr, &uio->pthru, sizeof (uio->pthru), &uio->pthru, "pass");
|
||||||
|
if (p.dataxferaddr && p.dataxferlen)
|
||||||
|
{
|
||||||
|
unsigned char data[4096];
|
||||||
|
unsigned long len = p.dataxferlen;
|
||||||
|
if (len > sizeof data)
|
||||||
|
len = sizeof data;
|
||||||
|
copyout (data, len, pid, p.dataxferaddr);
|
||||||
|
dumpbytes (stderr, data, len, (void *) p.dataxferaddr, "parm");
|
||||||
|
}
|
||||||
|
|
||||||
|
datalen = uio->ui.fcs.length;
|
||||||
|
if (datalen < uio->outlen)
|
||||||
|
datalen = uio->outlen;
|
||||||
|
if (datalen > sizeof buf)
|
||||||
|
datalen = sizeof buf;
|
||||||
|
if (datalen < 16)
|
||||||
|
datalen = 16;
|
||||||
|
if (datalen && uio->data)
|
||||||
|
{
|
||||||
|
// if ((state == INBOUND) && (datalen > uio->inlen))
|
||||||
|
// datalen = uio->inlen;
|
||||||
|
// else if ((state == OUTBOUND) && (datalen > uio->outlen))
|
||||||
|
// datalen = uio->outlen;
|
||||||
|
// if (datalen)
|
||||||
|
// {
|
||||||
|
copyout (buf, datalen, pid, (unsigned long) uio->data);
|
||||||
|
dumpbytes (stderr, buf, datalen, uio->data, "data");
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((ioctype == 'M') && (iocnr == 1) && (iocsize == sizeof (struct megasas_iocpacket)))
|
||||||
|
{
|
||||||
|
/* megaraid_sas-style ioctl */
|
||||||
|
struct megasas_iocpacket *iocp = (struct megasas_iocpacket *) buf;
|
||||||
|
struct megasas_header *mh = &(iocp->frame.hdr);
|
||||||
|
int k;
|
||||||
|
u8 cmd;
|
||||||
|
struct megasas_sge32 *sge = (struct megasas_sge32 *) ((u32) (&iocp->frame) + iocp->sgl_off);
|
||||||
|
int log = 1;
|
||||||
|
|
||||||
|
cmd = mh->cmd;
|
||||||
|
if (cmd == MFI_CMD_DCMD)
|
||||||
|
{
|
||||||
|
struct megasas_dcmd_frame *f = (struct megasas_dcmd_frame *) mh;
|
||||||
|
|
||||||
|
if ((getenv ("LOG_OPCODE") != 0) && (strtoul (getenv ("LOG_OPCODE"), NULL, 0) != f->opcode))
|
||||||
|
{
|
||||||
|
log = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lie like a rug. */
|
||||||
|
if ((f->opcode == 0x02020000) && (state == OUTBOUND))
|
||||||
|
{
|
||||||
|
u32 sgbase = sge[0].phys_addr;
|
||||||
|
size_t sglen = sge[0].length;
|
||||||
|
struct mega_physical_disk_info_sas disk;
|
||||||
|
|
||||||
|
if (sglen > sizeof disk)
|
||||||
|
sglen = sizeof disk;
|
||||||
|
|
||||||
|
copyout (&disk, sglen, pid, sgbase);
|
||||||
|
|
||||||
|
//if (!((disk.device_id == 16) || (disk.device_id == 15)))
|
||||||
|
// log = 0;
|
||||||
|
|
||||||
|
copyin (&disk, sglen, pid, sgbase);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((f->opcode == 0x04010000) && (state == OUTBOUND))
|
||||||
|
{
|
||||||
|
u32 sgbase = sge[0].phys_addr;
|
||||||
|
size_t sglen = sge[0].length;
|
||||||
|
u8 config[4096];
|
||||||
|
|
||||||
|
if (sglen > sizeof config)
|
||||||
|
sglen = sizeof config;
|
||||||
|
|
||||||
|
copyout (&config, sglen, pid, sgbase);
|
||||||
|
|
||||||
|
{
|
||||||
|
struct mega_array_header_sas *header = (struct mega_array_header_sas *) config;
|
||||||
|
struct mega_array_span_def_sas *span = (struct mega_array_span_def_sas *) (header + 1);
|
||||||
|
struct mega_array_disk_def_sas *disk = (struct mega_array_disk_def_sas *) (span + header->num_span_defs);
|
||||||
|
struct mega_array_hotspare_def_sas *hotspare = (struct mega_array_hotspare_def_sas *) (disk + header->num_disk_defs);
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for (k = 0; k < header->num_disk_defs; ++k)
|
||||||
|
{
|
||||||
|
// disk[k].state = 0xffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
copyin (&config, sglen, pid, sgbase);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((f->opcode == 0x05010000) && (state == OUTBOUND))
|
||||||
|
{
|
||||||
|
u32 sgbase = sge[0].phys_addr;
|
||||||
|
size_t sglen = sge[0].length;
|
||||||
|
struct mega_battery_state_sas bs;
|
||||||
|
|
||||||
|
if (sglen > sizeof bs)
|
||||||
|
sglen = sizeof bs;
|
||||||
|
|
||||||
|
copyout (&bs, sglen, pid, sgbase);
|
||||||
|
|
||||||
|
if (getenv ("BATTERY_X"))
|
||||||
|
bs.type = strtoul (getenv ("BATTERY_X"), NULL, 0);
|
||||||
|
if (getenv ("BATTERY_Y"))
|
||||||
|
bs.foo = strtoul (getenv ("BATTERY_Y"), NULL, 0);
|
||||||
|
bs.over_charged = 1;
|
||||||
|
|
||||||
|
copyin (&bs, sglen, pid, sgbase);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log)
|
||||||
|
{
|
||||||
|
fprintf (stderr, " host %d, off 0x%04x, count %d, sense_off 0x%08x, sense_len 0x%08x\n", iocp->host_no, iocp->sgl_off, iocp->sge_count, iocp->sense_off, iocp->sense_len);
|
||||||
|
fprintf (stderr, " DCMD: cmd_status %d, sge_count %d, context 0x%08x, flags 0x%04x, timeout %d, data_xfer_len 0x%x, opcode 0x%08x\n", f->cmd_status, f->sge_count, f->context, f->flags, f->timeout, f->data_xfer_len, f->opcode);
|
||||||
|
dumpbytes (stderr, &f->mbox, sizeof (f->mbox), &f->mbox, "mbox");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd == MFI_CMD_PD_SCSI_IO)
|
||||||
|
{
|
||||||
|
struct megasas_pthru_frame *f = (struct megasas_pthru_frame *) mh;
|
||||||
|
|
||||||
|
fprintf (stderr, " host %d, off 0x%04x, count %d, sense_off 0x%08x, sense_len 0x%08x\n", iocp->host_no, iocp->sgl_off, iocp->sge_count, iocp->sense_off, iocp->sense_len);
|
||||||
|
fprintf (stderr, " SCSI: cmd_status %d, sge_count %d, context 0x%08x, flags 0x%04x, timeout %d, data_xfer_len 0x%x\n", f->cmd_status, f->sge_count, f->context, f->flags, f->timeout, f->data_xfer_len);
|
||||||
|
fprintf (stderr, " : scsi_status %d, target_id 0x%02x, lun %d, sense_len %d, sense_lo 0x%08x, sense_hi 0x%08x\n", f->scsi_status, f->target_id, f->lun, f->sense_len, f->sense_buf_phys_addr_lo, f->sense_buf_phys_addr_hi);
|
||||||
|
|
||||||
|
dumpbytes (stderr, &f->cdb, f->cdb_len, &f->cdb, "cdb");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, " host %d, off 0x%04x, count %d, sense_off 0x%08x, sense_len 0x%08x\n", iocp->host_no, iocp->sgl_off, iocp->sge_count, iocp->sense_off, iocp->sense_len);
|
||||||
|
dumpbytes (stderr, buf, len, (void *) r.edx, NULL);
|
||||||
|
}
|
||||||
|
if (log)
|
||||||
|
{
|
||||||
|
for (k = 0; k < iocp->sge_count; ++k)
|
||||||
|
{
|
||||||
|
u32 sgbase = sge[k].phys_addr;
|
||||||
|
size_t sglen = sge[k].length;
|
||||||
|
char sgname[16];
|
||||||
|
char sgdata[4096];
|
||||||
|
|
||||||
|
snprintf (sgname, sizeof sgname, "sg%d", k);
|
||||||
|
fprintf (stderr, " %s at 0x%08x [0x%x]:\n", sgname, sgbase, sglen);
|
||||||
|
if (sglen > sizeof sgdata)
|
||||||
|
sglen = sizeof sgdata;
|
||||||
|
copyout (sgdata, sglen, pid, sgbase);
|
||||||
|
dumpbytes (stderr, sgdata, sglen, (void *) sgbase, sgname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dumpbytes (stderr, buf, len, (void *) r.edx, NULL);
|
||||||
|
}
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
static u32 lasteip = 0;
|
||||||
|
|
||||||
|
case UNTRACED:
|
||||||
|
/* We don't know whether we were inbound or outbound on the first signal; this
|
||||||
|
appears to differ between kernels. So we defer until we see the same eip in
|
||||||
|
two successive traps, at which point we know we were outbound, so the next
|
||||||
|
trap is inbound. */
|
||||||
|
if (lasteip == r.eip)
|
||||||
|
state = INBOUND;
|
||||||
|
lasteip = r.eip;
|
||||||
|
break;
|
||||||
|
case INBOUND: state = OUTBOUND; break;
|
||||||
|
case OUTBOUND: state = INBOUND; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptrace (PTRACE_SYSCALL, pid, 0, 0) < 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "ptrace:syscall: %s\n", strerror (errno));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "running\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
412
src/modepage.c
Normal file
412
src/modepage.c
Normal file
@ -0,0 +1,412 @@
|
|||||||
|
/*
|
||||||
|
* Incomplete code for handling mode sense data. Not used.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "megactl.h"
|
||||||
|
#include "megaioctl.h"
|
||||||
|
#include "modepage.h"
|
||||||
|
#include "dumpbytes.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static char *logPageType[] = {
|
||||||
|
/* 0 */ "supported log pages",
|
||||||
|
/* 1 */ "buffer over-run/under-run",
|
||||||
|
/* 2 */ "write error counter",
|
||||||
|
/* 3 */ "read error counter",
|
||||||
|
/* 4 */ "read reverse error counter",
|
||||||
|
/* 5 */ "verify error counter",
|
||||||
|
/* 6 */ "non-medium error",
|
||||||
|
/* 7 */ "last n error events",
|
||||||
|
/* 8 */ "format status",
|
||||||
|
/* 9 */ NULL,
|
||||||
|
/* a */ NULL,
|
||||||
|
/* b */ "last n deferred errors os asynchronous events",
|
||||||
|
/* c */ "sequential-access device",
|
||||||
|
/* d */ "temperature",
|
||||||
|
/* e */ "start-stop cycle counter",
|
||||||
|
/* f */ "application client",
|
||||||
|
/* 10 */ "self-test results",
|
||||||
|
/* 11 */ "DTD status",
|
||||||
|
/* 12 */ "TapeAlert response",
|
||||||
|
/* 13 */ "requested recover",
|
||||||
|
/* 14 */ "device statistics",
|
||||||
|
/* 15 */ NULL,
|
||||||
|
/* 16 */ NULL,
|
||||||
|
/* 17 */ "non-volatile cache",
|
||||||
|
/* 18 */ "protocol specific port",
|
||||||
|
/* 19 */ NULL,
|
||||||
|
/* 1a */ NULL,
|
||||||
|
/* 1b */ NULL,
|
||||||
|
/* 1c */ NULL,
|
||||||
|
/* 1d */ NULL,
|
||||||
|
/* 1e */ NULL,
|
||||||
|
/* 1f */ NULL,
|
||||||
|
/* 20 */ NULL,
|
||||||
|
/* 21 */ NULL,
|
||||||
|
/* 22 */ NULL,
|
||||||
|
/* 23 */ NULL,
|
||||||
|
/* 24 */ NULL,
|
||||||
|
/* 25 */ NULL,
|
||||||
|
/* 26 */ NULL,
|
||||||
|
/* 27 */ NULL,
|
||||||
|
/* 28 */ NULL,
|
||||||
|
/* 29 */ NULL,
|
||||||
|
/* 2a */ NULL,
|
||||||
|
/* 2b */ NULL,
|
||||||
|
/* 2c */ NULL,
|
||||||
|
/* 2d */ NULL,
|
||||||
|
/* 2e */ "TapeAlert",
|
||||||
|
/* 2f */ "informational exceptions",
|
||||||
|
/* 30 */ "vendor specific",
|
||||||
|
/* 31 */ "vendor specific",
|
||||||
|
/* 32 */ "vendor specific",
|
||||||
|
/* 33 */ "vendor specific",
|
||||||
|
/* 34 */ "vendor specific",
|
||||||
|
/* 35 */ "vendor specific",
|
||||||
|
/* 36 */ "vendor specific",
|
||||||
|
/* 37 */ "vendor specific",
|
||||||
|
/* 38 */ "vendor specific",
|
||||||
|
/* 39 */ "vendor specific",
|
||||||
|
/* 3a */ "vendor specific",
|
||||||
|
/* 3b */ "vendor specific",
|
||||||
|
/* 3c */ "vendor specific",
|
||||||
|
/* 3d */ "vendor specific",
|
||||||
|
/* 3e */ "vendor specific",
|
||||||
|
/* 3f */ NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
char *friendlySize (uint64_t b, char *unit)
|
||||||
|
{
|
||||||
|
static char *suffix[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi", };
|
||||||
|
int k;
|
||||||
|
static char bytes[128];
|
||||||
|
|
||||||
|
for (k = 0; (b >= 1024) && (k < sizeof (suffix) / sizeof (suffix[0]) - 1); ++k, b /= 1024)
|
||||||
|
;
|
||||||
|
snprintf (bytes, sizeof bytes, "%3llu%s%s", b, suffix[k], unit);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t blocksToGB (uint32_t blocks)
|
||||||
|
{
|
||||||
|
return (long) (((uint64_t) blocks) * 512 / 1000000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t blocksToGiB (uint32_t blocks)
|
||||||
|
{
|
||||||
|
return blocks / 2 / 1024 / 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint64_t extractInt64 (void *u, size_t len)
|
||||||
|
{
|
||||||
|
uint64_t x;
|
||||||
|
uint8_t *v;
|
||||||
|
|
||||||
|
for (x = 0, v = u; len > 0; --len, ++v)
|
||||||
|
x = (x << 8) + *v;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int parseLogPage (void *log, size_t len, struct logData *x)
|
||||||
|
{
|
||||||
|
struct logPageHeader *h = log;
|
||||||
|
void *u = log + sizeof (*h);
|
||||||
|
struct logParameterHeader *p;
|
||||||
|
size_t pageLen;
|
||||||
|
|
||||||
|
memset (x, 0, sizeof (*x));
|
||||||
|
|
||||||
|
if (len < sizeof (*h))
|
||||||
|
return -1;
|
||||||
|
pageLen = ntohs (h->length) + sizeof (*h);
|
||||||
|
if (len > pageLen)
|
||||||
|
len = pageLen;
|
||||||
|
len -= sizeof (*h);
|
||||||
|
|
||||||
|
x->h = *h;
|
||||||
|
x->h.length = pageLen;
|
||||||
|
|
||||||
|
while (len >= sizeof (*p))
|
||||||
|
{
|
||||||
|
uint16_t code;
|
||||||
|
uint64_t e;
|
||||||
|
|
||||||
|
p = u;
|
||||||
|
if (p->length + sizeof (*p) > len)
|
||||||
|
break;
|
||||||
|
len -= sizeof (*p);
|
||||||
|
u += sizeof (*p);
|
||||||
|
|
||||||
|
code = ntohs (p->parameter_code);
|
||||||
|
switch (h->page_code)
|
||||||
|
{
|
||||||
|
case 0x02:
|
||||||
|
case 0x03:
|
||||||
|
case 0x04:
|
||||||
|
case 0x05:
|
||||||
|
e = extractInt64 (u, p->length);
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case 0x0000: x->u.error.corrected = e; break;
|
||||||
|
case 0x0001: x->u.error.delayed = e; break;
|
||||||
|
case 0x0002: x->u.error.reread = e; break;
|
||||||
|
case 0x0003: x->u.error.total_corrected = e; break;
|
||||||
|
case 0x0004: x->u.error.total_algorithm = e; break;
|
||||||
|
case 0x0005: x->u.error.total_bytes = e; break;
|
||||||
|
case 0x0006: x->u.error.total_uncorrected = e; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0d:
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case 0x0000: x->u.temperature.current = ((uint8_t *) u)[1]; break;
|
||||||
|
case 0x0001: x->u.temperature.reference = ((uint8_t *) u)[1]; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0e:
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case 0x0001:
|
||||||
|
strncpy (x->u.startstop.manufacture_year, u, sizeof (x->u.startstop.manufacture_year) - 1);
|
||||||
|
x->u.startstop.manufacture_year[sizeof (x->u.startstop.manufacture_year) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.manufacture_year);
|
||||||
|
strncpy (x->u.startstop.manufacture_week, u + 4, sizeof (x->u.startstop.manufacture_week) - 1);
|
||||||
|
x->u.startstop.manufacture_week[sizeof (x->u.startstop.manufacture_week) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.manufacture_week);
|
||||||
|
break;
|
||||||
|
case 0x0002:
|
||||||
|
strncpy (x->u.startstop.accounting_year, u, sizeof (x->u.startstop.accounting_year) - 1);
|
||||||
|
x->u.startstop.accounting_year[sizeof (x->u.startstop.accounting_year) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.accounting_year);
|
||||||
|
strncpy (x->u.startstop.accounting_week, u + 4, sizeof (x->u.startstop.accounting_week) - 1);
|
||||||
|
x->u.startstop.accounting_week[sizeof (x->u.startstop.accounting_week) - 1] = '\0';
|
||||||
|
ntrim (x->u.startstop.accounting_week);
|
||||||
|
break;
|
||||||
|
case 0x0003:
|
||||||
|
x->u.startstop.recommended_starts = ntohl (*((uint32_t *) u));
|
||||||
|
break;
|
||||||
|
case 0x0004:
|
||||||
|
x->u.startstop.accumulated_starts = ntohl (*((uint32_t *) u));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x10:
|
||||||
|
if ((code < 1) || (code > sizeof (x->u.selftest.entry) / sizeof (x->u.selftest.entry[0])))
|
||||||
|
break;
|
||||||
|
if (p->length != sizeof (x->u.selftest.entry[0]) - sizeof (*p))
|
||||||
|
break;
|
||||||
|
--code;
|
||||||
|
x->u.selftest.entry[code] = *((struct selfTestLogParameter *) p);
|
||||||
|
x->u.selftest.entry[code].h.parameter_code = code;
|
||||||
|
x->u.selftest.entry[code].timestamp = ntohs (x->u.selftest.entry[code].timestamp);
|
||||||
|
x->u.selftest.entry[code].lba = extractInt64 (&x->u.selftest.entry[code].lba, sizeof (x->u.selftest.entry[code].lba));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
len -= p->length;
|
||||||
|
u += p->length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flag any problems */
|
||||||
|
switch (h->page_code)
|
||||||
|
{
|
||||||
|
case 0x02:
|
||||||
|
case 0x03:
|
||||||
|
case 0x04:
|
||||||
|
case 0x05:
|
||||||
|
if (x->u.error.total_uncorrected)
|
||||||
|
x->problem = 1;
|
||||||
|
break;
|
||||||
|
case 0x0d:
|
||||||
|
if (x->u.temperature.reference && (x->u.temperature.reference != 0xff) && (x->u.temperature.current >= x->u.temperature.reference))
|
||||||
|
x->problem = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void dumpModePage (FILE *f, struct modeData *x, void *mode, size_t len, int verbosity)
|
||||||
|
{
|
||||||
|
struct logPageHeader *h = log;
|
||||||
|
void *u = log + sizeof (*h);
|
||||||
|
struct logParameterHeader *p;
|
||||||
|
size_t pageLen;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
switch (x->h.page_code)
|
||||||
|
{
|
||||||
|
case 0x02:
|
||||||
|
case 0x03:
|
||||||
|
case 0x04:
|
||||||
|
case 0x05:
|
||||||
|
switch (x->h.page_code)
|
||||||
|
{
|
||||||
|
case 0x02: fprintf (f, " write errors:"); break;
|
||||||
|
case 0x03: fprintf (f, " read errors:"); break;
|
||||||
|
case 0x04: fprintf (f, " read/rev errors:"); break;
|
||||||
|
case 0x05: fprintf (f, " verify errors:"); break;
|
||||||
|
}
|
||||||
|
fprintf (f, " corr:%-6s", friendlySize (x->u.error.corrected, ""));
|
||||||
|
fprintf (f, " delay:%-6s", friendlySize (x->u.error.delayed, ""));
|
||||||
|
switch (x->h.page_code)
|
||||||
|
{
|
||||||
|
case 0x02: fprintf (f, " rewrit:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
case 0x03: fprintf (f, " reread:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
case 0x04: fprintf (f, " reread:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
case 0x05: fprintf (f, " revrfy:%-6s", friendlySize (x->u.error.reread, "")); break;
|
||||||
|
}
|
||||||
|
fprintf (f, " tot/corr:%-6s", friendlySize (x->u.error.total_corrected, ""));
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, " tot/alg:%-6s", friendlySize (x->u.error.total_algorithm, ""));
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, " tot/bytes:%-6s", friendlySize (x->u.error.total_bytes, "B"));
|
||||||
|
fprintf (f, " tot/uncorr:%-6s", friendlySize (x->u.error.total_uncorrected, ""));
|
||||||
|
fprintf (f, "\n");
|
||||||
|
break;
|
||||||
|
case 0x0d:
|
||||||
|
fprintf (f, " temperature: current:%uC threshold:%uC%s\n", x->u.temperature.current, x->u.temperature.reference, x->problem ? " warning:temperature threshold exceeded" : "");
|
||||||
|
break;
|
||||||
|
case 0x0e:
|
||||||
|
fprintf (f, " ");
|
||||||
|
if (strlen (x->u.startstop.manufacture_year) && strlen (x->u.startstop.manufacture_week))
|
||||||
|
fprintf (f, " manufactured:%s/%s", x->u.startstop.manufacture_year, x->u.startstop.manufacture_week);
|
||||||
|
if (strlen (x->u.startstop.accounting_year) && strlen (x->u.startstop.accounting_week))
|
||||||
|
fprintf (f, " accounting:%s/%s", x->u.startstop.accounting_year, x->u.startstop.accounting_week);
|
||||||
|
fprintf (f, " starts:%d/%d", x->u.startstop.accumulated_starts, x->u.startstop.recommended_starts);
|
||||||
|
fprintf (f, "\n");
|
||||||
|
break;
|
||||||
|
case 0x10:
|
||||||
|
for (k = 0; k < sizeof (x->u.selftest.entry) / sizeof (x->u.selftest.entry[0]); ++k)
|
||||||
|
{
|
||||||
|
struct selfTestLogParameter *t = &x->u.selftest.entry[k];
|
||||||
|
if (t->self_test_code || t->self_test_results || t->timestamp || t->number || t->lba)
|
||||||
|
{
|
||||||
|
char *test;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
switch (t->self_test_code)
|
||||||
|
{
|
||||||
|
case SCSI_SELFTEST_DEFAULT: test = "default"; break;
|
||||||
|
case SCSI_SELFTEST_BACKGROUND_SHORT: test = "bg short"; break;
|
||||||
|
case SCSI_SELFTEST_BACKGROUND_LONG: test = "bg long"; break;
|
||||||
|
case SCSI_SELFTEST_BACKGROUND_ABORT: test = "bg aborted"; break;
|
||||||
|
case SCSI_SELFTEST_FOREGROUND_SHORT: test = "fg short"; break;
|
||||||
|
case SCSI_SELFTEST_FOREGROUND_LONG: test = "fg long"; break;
|
||||||
|
default: test = "unknown"; break;
|
||||||
|
}
|
||||||
|
switch (t->self_test_results)
|
||||||
|
{
|
||||||
|
case 0x0: result = "completed without error"; break;
|
||||||
|
case 0x1: result = "aborted via send diagnostic"; break;
|
||||||
|
case 0x2: result = "aborted via other method"; break;
|
||||||
|
case 0x3: result = "unable to complete"; break;
|
||||||
|
case 0x4: result = "failed in unknown segment"; break;
|
||||||
|
case 0x5: result = "failed in segment 1"; break;
|
||||||
|
case 0x6: result = "failed in segment 2"; break;
|
||||||
|
case 0x7: result = "failed in other segment"; break;
|
||||||
|
case 0xf: result = "in progress"; break;
|
||||||
|
default: result = "unknown result"; break;
|
||||||
|
}
|
||||||
|
fprintf (f, " %2d: timestamp %4ud%02uh: %10s %-30s seg:%u lba:%-8lld sk:%u asc:%u ascq:%u vs:%u\n", k, t->timestamp / 24, t->timestamp % 24, test, result, t->number, t->lba, t->sense_key, t->additional_sense_code, t->additional_sense_code_qualifier, t->vendor_specific);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(verbosity > 2))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (len < sizeof (*h))
|
||||||
|
return;
|
||||||
|
pageLen = ntohs (h->length) + sizeof (*h);
|
||||||
|
if (len > pageLen)
|
||||||
|
len = pageLen;
|
||||||
|
len -= sizeof (*h);
|
||||||
|
|
||||||
|
switch (h->page_code)
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
fprintf (f, " %s:", logPageType[h->page_code]);
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf (f, "\n");
|
||||||
|
for (k = len; k > 0; --k, ++u)
|
||||||
|
{
|
||||||
|
uint8_t code = *((unsigned char *) u);
|
||||||
|
|
||||||
|
if (verbosity > 1)
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
if ((code < sizeof logPageType / sizeof (logPageType[0])) && logPageType[code])
|
||||||
|
name = logPageType[code];
|
||||||
|
else
|
||||||
|
name = "unknown log page";
|
||||||
|
fprintf (f, " %02x %s\n", code, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf (f, " %02x", code);
|
||||||
|
}
|
||||||
|
if (verbosity <= 1)
|
||||||
|
fprintf (f, "\n");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
fprintf (f, " log page %02x, length %u%s\n", h->page_code, ntohs (h->length), len < pageLen - sizeof (*h) ? " warning: truncated" : "");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (len >= sizeof (*p))
|
||||||
|
{
|
||||||
|
uint16_t code;
|
||||||
|
|
||||||
|
p = u;
|
||||||
|
if (p->length + sizeof (*p) > len)
|
||||||
|
break;
|
||||||
|
len -= sizeof (*p);
|
||||||
|
u += sizeof (*p);
|
||||||
|
|
||||||
|
code = ntohs (p->parameter_code);
|
||||||
|
fprintf (f, " param %04x, du %u, ds %u, tsd %u, etc %u, tmc %u, lbin %u, lp %u, length %u\n", code, p->du, p->ds, p->tsd, p->etc, p->tmc, p->lbin, p->lp, p->length);
|
||||||
|
dumpbytes (f, u, p->length, u, "param");
|
||||||
|
|
||||||
|
len -= p->length;
|
||||||
|
u += p->length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
75
src/modepage.h
Normal file
75
src/modepage.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#ifndef _MODEPAGE_H
|
||||||
|
#define _MODEPAGE_H
|
||||||
|
/*
|
||||||
|
* Definitions for unused mode page code.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <scg/scsireg.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct modePage0Header
|
||||||
|
{
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder (thanks, Schily) */
|
||||||
|
uint8_t page_code:6;
|
||||||
|
uint8_t spf:1;
|
||||||
|
uint8_t ps:1;
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
uint8_t ps:1;
|
||||||
|
uint8_t spf:1;
|
||||||
|
uint8_t page_code:6;
|
||||||
|
#endif
|
||||||
|
uint8_t length;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct modeSubPageHeader
|
||||||
|
{
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder (thanks, Schily) */
|
||||||
|
uint8_t page_code:6;
|
||||||
|
uint8_t spf:1;
|
||||||
|
uint8_t ps:1;
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
uint8_t ps:1;
|
||||||
|
uint8_t spf:1;
|
||||||
|
uint8_t page_code:6;
|
||||||
|
#endif
|
||||||
|
uint8_t subpage_code;
|
||||||
|
uint16_t length;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct modeData
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct modePage0Header error;
|
||||||
|
struct modeSubPageHeader selftest;
|
||||||
|
} u;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
extern int parseLogPage (void *log, size_t len, struct logData *x);
|
||||||
|
#endif
|
||||||
|
extern void dumpModePage (FILE *f, struct modeData *x, void *mode, size_t len, int verbosity);
|
||||||
|
|
||||||
|
#endif
|
45
src/ntrim.c
Normal file
45
src/ntrim.c
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Little string-trimming function.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "ntrim.h"
|
||||||
|
|
||||||
|
void ntrim (char *s)
|
||||||
|
{
|
||||||
|
char *t;
|
||||||
|
size_t len = strlen (s);
|
||||||
|
|
||||||
|
for (t = s + len - 1; (t >= s) && isspace (*t); --t)
|
||||||
|
*t = '\0';
|
||||||
|
for (t = s; isspace (*t); ++t)
|
||||||
|
;
|
||||||
|
if (t > s)
|
||||||
|
{
|
||||||
|
for ( ; *t; ++t, ++s)
|
||||||
|
*s = *t;
|
||||||
|
*s = *t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
27
src/ntrim.h
Normal file
27
src/ntrim.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef _NTRIM_H
|
||||||
|
#define _NTRIM_H
|
||||||
|
/*
|
||||||
|
* Definitions for little string trimmer function.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 by Jefferson Ogata
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void ntrim (char *s);
|
||||||
|
|
||||||
|
#endif
|
69
src/schily/allocax.h
Normal file
69
src/schily/allocax.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* @(#)allocax.h 1.3 03/07/15 Copyright 2002 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for users of alloca()
|
||||||
|
*
|
||||||
|
* Important: #include this directly after <mconfig.h>
|
||||||
|
* and before any other include file.
|
||||||
|
* See comment in _AIX part below.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _ALLOCAX_H
|
||||||
|
#define _ALLOCAX_H
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# ifndef alloca
|
||||||
|
# define alloca(s) __builtin_alloca(s)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# include <malloc.h>
|
||||||
|
# define alloca _alloca
|
||||||
|
# else
|
||||||
|
# if HAVE_ALLOCA_H
|
||||||
|
# include <alloca.h>
|
||||||
|
# else
|
||||||
|
# ifdef _AIX
|
||||||
|
/*
|
||||||
|
* Indent so pre-ANSI compilers will ignore it
|
||||||
|
*
|
||||||
|
* Some versions of AIX may require this to be
|
||||||
|
* first in the file and only preceded by
|
||||||
|
* comments and preprocessor directives/
|
||||||
|
*/
|
||||||
|
#pragma alloca
|
||||||
|
# else
|
||||||
|
# ifndef alloca
|
||||||
|
/*
|
||||||
|
* predefined by HP cc +Olibcalls
|
||||||
|
*/
|
||||||
|
# ifdef PROTOTYPES
|
||||||
|
extern void *alloca();
|
||||||
|
# else
|
||||||
|
extern char *alloca();
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _ALLOCAX_H */
|
120
src/schily/btorder.h
Normal file
120
src/schily/btorder.h
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/* @(#)btorder.h 1.16 03/06/15 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for Bit and Byte ordering
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _BTORDER_H
|
||||||
|
#define _BTORDER_H
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h> /* try to load isa_defs.h on Solaris */
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h> /* load bit/byte-oder from xmconfig.h*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert bit-order definitions from xconfig.h into our values
|
||||||
|
* and verify them.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_C_BITFIELDS) && \
|
||||||
|
defined(BITFIELDS_LTOH)
|
||||||
|
#define _BIT_FIELDS_LTOH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_C_BITFIELDS) && \
|
||||||
|
defined(BITFIELDS_HTOL)
|
||||||
|
#define _BIT_FIELDS_HTOL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_C_BITFIELDS) && \
|
||||||
|
!defined(BITFIELDS_HTOL)
|
||||||
|
#define BITFIELDS_LTOH
|
||||||
|
#define _BIT_FIELDS_LTOH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) && defined(_BIT_FIELDS_HTOL)
|
||||||
|
/*
|
||||||
|
* #error will not work for all compilers (e.g. sunos4)
|
||||||
|
* The following line will abort compilation on all compilers
|
||||||
|
* if none of the above is defines. And that's what we want.
|
||||||
|
*/
|
||||||
|
error Only one of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL may be defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert byte-order definitions from xconfig.h into our values
|
||||||
|
* and verify them.
|
||||||
|
* Note that we cannot use the definitions _LITTLE_ENDIAN and _BIG_ENDIAN
|
||||||
|
* because they are used on IRIX-6.5 with different meaning.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_C_BIGENDIAN) && \
|
||||||
|
!defined(WORDS_BIGENDIAN)
|
||||||
|
#define WORDS_LITTLEENDIAN
|
||||||
|
/*#define _LITTLE_ENDIAN*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_C_BIGENDIAN) && \
|
||||||
|
defined(WORDS_BIGENDIAN)
|
||||||
|
#undef WORDS_LITTLEENDIAN
|
||||||
|
/*#define _BIG_ENDIAN*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) || defined(_BIT_FIELDS_HTOL)
|
||||||
|
/*
|
||||||
|
* Bitorder is already known.
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* Bitorder not yet known.
|
||||||
|
*/
|
||||||
|
# if defined(sun3) || defined(mc68000) || \
|
||||||
|
defined(sun4) || defined(__sparc) || defined(sparc) || \
|
||||||
|
defined(__hppa) || defined(_ARCH_PPC) || defined(_IBMR2)
|
||||||
|
# define _BIT_FIELDS_HTOL
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__sgi) && defined(__mips)
|
||||||
|
# define _BIT_FIELDS_HTOL
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__i386__) || defined(__i386) || defined(i386) || \
|
||||||
|
defined(__ia64__) || defined(__ia64) || defined(ia64) || \
|
||||||
|
defined(__alpha__) || defined(__alpha) || defined(alpha) || \
|
||||||
|
defined(__arm__) || defined(__arm) || defined(arm)
|
||||||
|
# define _BIT_FIELDS_LTOH
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__ppc__) || defined(ppc) || defined(__ppc) || \
|
||||||
|
defined(__PPC) || defined(powerpc) || defined(__powerpc__)
|
||||||
|
|
||||||
|
# if defined(__BIG_ENDIAN__)
|
||||||
|
# define _BIT_FIELDS_HTOL
|
||||||
|
# else
|
||||||
|
# define _BIT_FIELDS_LTOH
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _BTORDER_H */
|
119
src/schily/btorder.h.endian
Normal file
119
src/schily/btorder.h.endian
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/* @(#)btorder.h 1.16 03/06/15 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for Bit and Byte ordering
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _BTORDER_H
|
||||||
|
#define _BTORDER_H
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h> /* try to load isa_defs.h on Solaris */
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h> /* load bit/byte-oder from xmconfig.h*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert bit-order definitions from xconfig.h into our values
|
||||||
|
* and verify them.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_C_BITFIELDS) && \
|
||||||
|
defined(BITFIELDS_LTOH)
|
||||||
|
#define _BIT_FIELDS_LTOH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_C_BITFIELDS) && \
|
||||||
|
defined(BITFIELDS_HTOL)
|
||||||
|
#define _BIT_FIELDS_HTOL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_C_BITFIELDS) && \
|
||||||
|
!defined(BITFIELDS_HTOL)
|
||||||
|
#define BITFIELDS_LTOH
|
||||||
|
#define _BIT_FIELDS_LTOH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) && defined(_BIT_FIELDS_HTOL)
|
||||||
|
/*
|
||||||
|
* #error will not work for all compilers (e.g. sunos4)
|
||||||
|
* The following line will abort compilation on all compilers
|
||||||
|
* if none of the above is defines. And that's what we want.
|
||||||
|
*/
|
||||||
|
error Only one of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL may be defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert byte-order definitions from xconfig.h into our values
|
||||||
|
* and verify them.
|
||||||
|
* Note that we cannot use the definitions _LITTLE_ENDIAN and _BIG_ENDIAN
|
||||||
|
* because they are used on IRIX-6.5 with different meaning.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_C_BIGENDIAN) && \
|
||||||
|
!defined(WORDS_BIGENDIAN)
|
||||||
|
#define WORDS_LITTLEENDIAN
|
||||||
|
/*#define _LITTLE_ENDIAN*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_C_BIGENDIAN) && \
|
||||||
|
defined(WORDS_BIGENDIAN)
|
||||||
|
#undef WORDS_LITTLEENDIAN
|
||||||
|
/*#define _BIG_ENDIAN*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) || defined(_BIT_FIELDS_HTOL)
|
||||||
|
/*
|
||||||
|
* Bitorder is already known.
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* Bitorder not yet known.
|
||||||
|
*/
|
||||||
|
# if defined(sun3) || defined(mc68000) || \
|
||||||
|
defined(sun4) || defined(__sparc) || defined(sparc) || \
|
||||||
|
defined(__hppa) || defined(_ARCH_PPC) || defined(_IBMR2)
|
||||||
|
# define _BIT_FIELDS_HTOL
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__sgi) && defined(__mips)
|
||||||
|
# define _BIT_FIELDS_HTOL
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__i386__) || defined(__i386) || defined(i386) || \
|
||||||
|
defined(__alpha__) || defined(__alpha) || defined(alpha) || \
|
||||||
|
defined(__arm__) || defined(__arm) || defined(arm)
|
||||||
|
# define _BIT_FIELDS_LTOH
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__ppc__) || defined(ppc) || defined(__ppc) || \
|
||||||
|
defined(__PPC) || defined(powerpc) || defined(__powerpc__)
|
||||||
|
|
||||||
|
# if defined(__BIG_ENDIAN__)
|
||||||
|
# define _BIT_FIELDS_HTOL
|
||||||
|
# else
|
||||||
|
# define _BIT_FIELDS_LTOH
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _BTORDER_H */
|
67
src/schily/ccomdefs.h
Normal file
67
src/schily/ccomdefs.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* @(#)ccomdefs.h 1.3 03/06/15 Copyright 2000 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Various compiler dependant macros.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2000 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CCOMDEFS_H
|
||||||
|
#define _CCOMDEFS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compiler-dependent macros to declare that functions take printf-like
|
||||||
|
* or scanf-like arguments. They are defined to nothing for versions of gcc
|
||||||
|
* that are not known to support the features properly (old versions of gcc-2
|
||||||
|
* didn't permit keeping the keywords out of the application namespace).
|
||||||
|
*/
|
||||||
|
#if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
|
||||||
|
|
||||||
|
#define __printflike__(fmtarg, firstvararg)
|
||||||
|
#define __printf0like__(fmtarg, firstvararg)
|
||||||
|
#define __scanflike__(fmtarg, firstvararg)
|
||||||
|
|
||||||
|
#else /* We found GCC that supports __attribute__ */
|
||||||
|
|
||||||
|
#define __printflike__(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__(__printf__, fmtarg, firstvararg)))
|
||||||
|
#define __printf0like__(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__(__printf0__, fmtarg, firstvararg)))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FreeBSD GCC implements printf0 that allows the format string to
|
||||||
|
* be a NULL pointer.
|
||||||
|
*/
|
||||||
|
#if __FreeBSD_cc_version < 300001
|
||||||
|
#undef __printf0like__
|
||||||
|
#define __printf0like__ __printflike__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __scanflike__(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__(__scanf__, fmtarg, firstvararg)))
|
||||||
|
|
||||||
|
#endif /* GNUC */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _CCOMDEFS_H */
|
76
src/schily/deflts.h
Normal file
76
src/schily/deflts.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/* @(#)deflts.h 1.6 02/08/26 Copyright 1997 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for reading program defaults.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _DEFLTS_H
|
||||||
|
#define _DEFLTS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEFLT "/etc/default"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cmd's to defltcntl()
|
||||||
|
*/
|
||||||
|
#define DC_GETFLAGS 0 /* Get actual flags */
|
||||||
|
#define DC_SETFLAGS 1 /* Set new flags */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* flags to defltcntl()
|
||||||
|
*
|
||||||
|
* Make sure that when adding features, the default behaviour
|
||||||
|
* is the same as old behaviour.
|
||||||
|
*/
|
||||||
|
#define DC_CASE 0x0001 /* Don't ignore case */
|
||||||
|
|
||||||
|
#define DC_STD DC_CASE /* Default flags */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros to handle flags
|
||||||
|
*/
|
||||||
|
#ifndef TURNON
|
||||||
|
#define TURNON(flags, mask) flags |= mask
|
||||||
|
#define TURNOFF(flags, mask) flags &= ~(mask)
|
||||||
|
#define ISON(flags, mask) (((flags) & (mask)) == (mask))
|
||||||
|
#define ISOFF(flags, mask) (((flags) & (mask)) != (mask))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int defltopen __PR((const char *name));
|
||||||
|
extern int defltclose __PR((void));
|
||||||
|
extern void defltfirst __PR((void));
|
||||||
|
extern char *defltread __PR((const char *name));
|
||||||
|
extern char *defltnext __PR((const char *name));
|
||||||
|
extern int defltcntl __PR((int cmd, int flags));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _DEFLTS_H */
|
145
src/schily/device.h
Normal file
145
src/schily/device.h
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/* @(#)device.h 1.12 03/06/15 Copyright 1995 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Generic header for users of major(), minor() and makedev()
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _DEVICE_H
|
||||||
|
#define _DEVICE_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On generic SVR4, major is a function (defined in sys/mkdev.h).
|
||||||
|
* On Solaris it is defined ...
|
||||||
|
* As we cannot just test if major is #define'd, we have to
|
||||||
|
* define _FOUND_MAJOR_ instead.
|
||||||
|
*
|
||||||
|
* WARNING: Do never include <sys/sysmacros.h> in SVR4, it contains
|
||||||
|
* an old definition for major()/minor() defining 8 minorbits.
|
||||||
|
* Use <sys/mkdev.h> instead.
|
||||||
|
*/
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Some systems define major in <sys/types.h>.
|
||||||
|
* We are ready...
|
||||||
|
*/
|
||||||
|
#ifdef major
|
||||||
|
# define _FOUND_MAJOR_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAJOR_IN_MKDEV
|
||||||
|
# ifndef _INCL_SYS_MKDEV_H
|
||||||
|
# include <sys/mkdev.h>
|
||||||
|
# define _INCL_SYS_MKDEV_H
|
||||||
|
# endif
|
||||||
|
# define _FOUND_MAJOR_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _FOUND_MAJOR_
|
||||||
|
# ifdef MAJOR_IN_SYSMACROS
|
||||||
|
# ifndef _INCL_SYS_SYSMACROS_H
|
||||||
|
# include <sys/sysmacros.h>
|
||||||
|
# define _INCL_SYS_SYSMACROS_H
|
||||||
|
# endif
|
||||||
|
# define _FOUND_MAJOR_
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are on HP/UX before HP/UX 8,
|
||||||
|
* major/minor are not in <sys/sysmacros.h>.
|
||||||
|
*/
|
||||||
|
#ifndef _FOUND_MAJOR_
|
||||||
|
# if defined(hpux) || defined(__hpux__) || defined(__hpux)
|
||||||
|
# ifndef _INCL_SYS_MKOD_H
|
||||||
|
# include <sys/mknod.h>
|
||||||
|
# define _INCL_SYS_MKOD_H
|
||||||
|
# endif
|
||||||
|
# define _FOUND_MAJOR_
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For all other systems define major()/minor() here.
|
||||||
|
* XXX Check if this definition will be usefull for ms dos too.
|
||||||
|
*/
|
||||||
|
#ifndef _FOUND_MAJOR_
|
||||||
|
# define major(dev) (((dev) >> 8) & 0xFF)
|
||||||
|
# define minor(dev) ((dev) & 0xFF)
|
||||||
|
# define makedev(majo, mino) (((majo) << 8) | (mino))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't pollute namespace...
|
||||||
|
*/
|
||||||
|
#undef _FOUND_MAJOR_
|
||||||
|
|
||||||
|
#ifdef __XDEV__
|
||||||
|
/*
|
||||||
|
* The following defines are currently only needed for 'star'.
|
||||||
|
* We make it conditional code to avoid to pollute the namespace.
|
||||||
|
*/
|
||||||
|
#define XDEV_T unsigned long
|
||||||
|
|
||||||
|
extern int minorbits;
|
||||||
|
extern XDEV_T minormask;
|
||||||
|
extern XDEV_T _dev_mask[];
|
||||||
|
|
||||||
|
#define dev_major(dev) (((XDEV_T)(dev)) >> minorbits)
|
||||||
|
#define _dev_major(mbits, dev) (((XDEV_T)(dev)) >> (mbits))
|
||||||
|
|
||||||
|
#define dev_minor(dev) (((XDEV_T)(dev)) & minormask)
|
||||||
|
#define _dev_minor(mbits, dev) (((XDEV_T)(dev)) & _dev_mask[(mbits)])
|
||||||
|
|
||||||
|
|
||||||
|
#define dev_make(majo, mino) ((((XDEV_T)(majo)) << minorbits) | \
|
||||||
|
((XDEV_T)(mino)))
|
||||||
|
#define _dev_make(mbits, majo, mino) ((((XDEV_T)(majo)) << (mbits) | \
|
||||||
|
((XDEV_T)(mino)))
|
||||||
|
|
||||||
|
extern void dev_init __PR((BOOL debug));
|
||||||
|
#ifndef dev_major
|
||||||
|
extern XDEV_T dev_major __PR((XDEV_T dev));
|
||||||
|
extern XDEV_T _dev_major __PR((int mbits, XDEV_T dev));
|
||||||
|
extern XDEV_T dev_minor __PR((XDEV_T dev));
|
||||||
|
extern XDEV_T _dev_minor __PR((int mbits, XDEV_T dev));
|
||||||
|
extern XDEV_T dev_make __PR((XDEV_T majo, XDEV_T mino));
|
||||||
|
extern XDEV_T _dev_make __PR((int mbits, XDEV_T majo, XDEV_T mino));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __XDEV__ */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _DEVICE_H */
|
177
src/schily/dirdefs.h
Normal file
177
src/schily/dirdefs.h
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
/* @(#)dirdefs.h 1.15 04/06/16 Copyright 1987, 1998 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1987, 1998 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _DIRDEFS_H
|
||||||
|
#define _DIRDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JOS
|
||||||
|
# ifndef _INCL_SYS_STYPES_H
|
||||||
|
# include <sys/stypes.h>
|
||||||
|
# define _INCL_SYS_STYPES_H
|
||||||
|
# endif
|
||||||
|
# ifndef _INCL_SYS_FILEDESC_H
|
||||||
|
# include <sys/filedesc.h>
|
||||||
|
# define _INCL_SYS_FILEDESC_H
|
||||||
|
# endif
|
||||||
|
# define NEED_READDIR
|
||||||
|
# define dirent _direct
|
||||||
|
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
|
||||||
|
# define DIRSIZE 30
|
||||||
|
# define FOUND_DIRSIZE
|
||||||
|
typedef struct _dirent {
|
||||||
|
char name[DIRSIZE];
|
||||||
|
short ino;
|
||||||
|
} dirent;
|
||||||
|
|
||||||
|
#else /* !JOS */
|
||||||
|
|
||||||
|
# ifndef _INCL_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
# define _INCL_SYS_TYPES_H
|
||||||
|
# endif
|
||||||
|
# ifndef _INCL_SYS_STAT_H
|
||||||
|
# include <sys/stat.h>
|
||||||
|
# define _INCL_SYS_STAT_H
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_LIMITS_H
|
||||||
|
# ifndef _INCL_LIMITS_H
|
||||||
|
# include <limits.h>
|
||||||
|
# define _INCL_LIMITS_H
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_SYS_PARAM_H
|
||||||
|
# ifndef _INCL_SYS_PARAM_H
|
||||||
|
# include <sys/param.h>
|
||||||
|
# define _INCL_SYS_PARAM_H
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef HAVE_DIRENT_H /* This a POSIX compliant system */
|
||||||
|
# ifndef _INCL_DIRENT_H
|
||||||
|
# include <dirent.h>
|
||||||
|
# define _INCL_DIRENT_H
|
||||||
|
# endif
|
||||||
|
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
|
||||||
|
# define _FOUND_DIR_
|
||||||
|
# else /* This is a Pre POSIX system */
|
||||||
|
|
||||||
|
# define dirent direct
|
||||||
|
# define DIR_NAMELEN(dirent) (dirent)->d_namlen
|
||||||
|
|
||||||
|
# if defined(HAVE_SYS_DIR_H)
|
||||||
|
# ifndef _INCL_SYS_DIR_H
|
||||||
|
# include <sys/dir.h>
|
||||||
|
# define _INCL_SYS_DIR_H
|
||||||
|
# endif
|
||||||
|
# define _FOUND_DIR_
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(HAVE_NDIR_H) && !defined(_FOUND_DIR_)
|
||||||
|
# ifndef _INCL_NDIR_H
|
||||||
|
# include <ndir.h>
|
||||||
|
# define _INCL_NDIR_H
|
||||||
|
# endif
|
||||||
|
# define _FOUND_DIR_
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(HAVE_SYS_NDIR_H) && !defined(_FOUND_DIR_)
|
||||||
|
# ifndef _INCL_SYS_NDIR_H
|
||||||
|
# include <sys/ndir.h>
|
||||||
|
# define _INCL_SYS_NDIR_H
|
||||||
|
# endif
|
||||||
|
# define _FOUND_DIR_
|
||||||
|
# endif
|
||||||
|
# endif /* HAVE_DIRENT_H */
|
||||||
|
|
||||||
|
# if defined(_FOUND_DIR_)
|
||||||
|
/*
|
||||||
|
* Don't use defaults here to allow recognition of problems.
|
||||||
|
*/
|
||||||
|
# ifdef MAXNAMELEN
|
||||||
|
# define DIRSIZE MAXNAMELEN /* From sys/param.h */
|
||||||
|
# define FOUND_DIRSIZE
|
||||||
|
# else
|
||||||
|
# ifdef MAXNAMLEN
|
||||||
|
# define DIRSIZE MAXNAMLEN /* From dirent.h */
|
||||||
|
# define FOUND_DIRSIZE
|
||||||
|
# else
|
||||||
|
# ifdef DIRSIZ
|
||||||
|
# define DIRSIZE DIRSIZ /* From sys/dir.h */
|
||||||
|
# define FOUND_DIRSIZE
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# else /* !_FOUND_DIR_ */
|
||||||
|
|
||||||
|
# define NEED_DIRENT
|
||||||
|
# define NEED_READDIR
|
||||||
|
# define dirent _direct
|
||||||
|
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
|
||||||
|
|
||||||
|
# endif /* _FOUND_DIR_ */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEED_DIRENT
|
||||||
|
|
||||||
|
#ifndef FOUND_DIRSIZE
|
||||||
|
#define DIRSIZE 14 /* The old UNIX standard value */
|
||||||
|
#define FOUND_DIRSIZE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct _dirent {
|
||||||
|
short ino;
|
||||||
|
char name[DIRSIZE];
|
||||||
|
} dirent;
|
||||||
|
|
||||||
|
#endif /* NEED_DIRENT */
|
||||||
|
|
||||||
|
#endif /* !JOS */
|
||||||
|
|
||||||
|
#ifdef NEED_READDIR
|
||||||
|
typedef struct __dirdesc {
|
||||||
|
FILE *dd_fd;
|
||||||
|
} DIR;
|
||||||
|
|
||||||
|
struct _direct {
|
||||||
|
unsigned long d_ino;
|
||||||
|
unsigned short d_reclen;
|
||||||
|
unsigned short d_namlen;
|
||||||
|
char d_name[DIRSIZE +1];
|
||||||
|
};
|
||||||
|
|
||||||
|
extern DIR *opendir();
|
||||||
|
extern closedir();
|
||||||
|
extern struct dirent *readdir();
|
||||||
|
|
||||||
|
#endif /* NEED_READDIR */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _DIRDEFS_H */
|
82
src/schily/fctldefs.h
Normal file
82
src/schily/fctldefs.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/* @(#)fctldefs.h 1.13 03/02/23 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Generic header for users of open(), creat() and chmod()
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FCTLDEFS_H
|
||||||
|
#define _FCTLDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _STATDEFS_H
|
||||||
|
#include <statdefs.h> /* For 3rd arg of open() and chmod() */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h> /* Needed for fcntl.h */
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_FILE_H
|
||||||
|
/*
|
||||||
|
* Historical systems with flock() only need sys/file.h
|
||||||
|
*/
|
||||||
|
# ifndef _INCL_SYS_FILE_H
|
||||||
|
# include <sys/file.h>
|
||||||
|
# define _INCL_SYS_FILE_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_FCNTL_H
|
||||||
|
# ifndef _INCL_FCNTL_H
|
||||||
|
# include <fcntl.h>
|
||||||
|
# define _INCL_FCNTL_H
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do not define more than O_RDONLY / O_WRONLY / O_RDWR / O_BINARY
|
||||||
|
* The values may differ.
|
||||||
|
*
|
||||||
|
* O_BINARY is defined here to allow all applications to compile on a non DOS
|
||||||
|
* environment without repeating this definition.
|
||||||
|
*/
|
||||||
|
#ifndef O_RDONLY
|
||||||
|
# define O_RDONLY 0
|
||||||
|
#endif
|
||||||
|
#ifndef O_WRONLY
|
||||||
|
# define O_WRONLY 1
|
||||||
|
#endif
|
||||||
|
#ifndef O_RDWR
|
||||||
|
# define O_RDWR 2
|
||||||
|
#endif
|
||||||
|
#ifndef O_BINARY /* Only present on DOS or similar */
|
||||||
|
# define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
#ifndef O_NDELAY /* This is undefined on BeOS :-( */
|
||||||
|
# define O_NDELAY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_ACCMODE
|
||||||
|
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _FCTLDEFS_H */
|
49
src/schily/getargs.h
Normal file
49
src/schily/getargs.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* @(#)getargs.h 1.9 03/06/15 Copyright 1985 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for getargs()/getallargs()/getfiles()
|
||||||
|
*
|
||||||
|
* Copyright (c) 1985 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GETARGS_H
|
||||||
|
#define _GETARGS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NOARGS 0 /* No more args */
|
||||||
|
#define NOTAFLAG 1 /* Not a flag type argument */
|
||||||
|
#define BADFLAG (-1) /* Not a valid flag argument */
|
||||||
|
#define BADFMT (-2) /* Error in format string */
|
||||||
|
#define NOTAFILE (-3) /* Seems to be a flag type */
|
||||||
|
|
||||||
|
typedef int (*getargfun) __PR((const void *, void *));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _GETARGS_H */
|
43
src/schily/getcwd.h
Normal file
43
src/schily/getcwd.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* @(#)getcwd.h 1.3 01/07/15 Copyright 1998 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for getcwd()
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GETCWD_H
|
||||||
|
#define _GETCWD_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JOS
|
||||||
|
# ifndef _INCL_SYS_STYPES_H
|
||||||
|
# include <sys/stypes.h>
|
||||||
|
# define _INCL_SYS_STYPES_H
|
||||||
|
# endif
|
||||||
|
extern char *gwd();
|
||||||
|
# define getcwd(b, len) gwd(b)
|
||||||
|
#else
|
||||||
|
# ifndef HAVE_GETCWD
|
||||||
|
# define getcwd(b, len) getwd(b)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _GETCWD_H */
|
113
src/schily/intcvt.h
Normal file
113
src/schily/intcvt.h
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/* @(#)intcvt.h 1.4 03/12/29 Copyright 1986-2003 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for conversion to/from integer data types of various size.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1986-2003 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INTCVT_H
|
||||||
|
#define _INTCVT_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define i_to_2_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define i_to_3_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 16)& 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[2] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define i_to_4_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 24)& 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = ((i) >> 16)& 0xFF,\
|
||||||
|
((Uchar *)(a))[2] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[3] = (i) & 0xFF)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define a_to_byte(a) (((Int8_t *) a)[0])
|
||||||
|
|
||||||
|
#define a_to_u_byte(a) ((UInt8_t) \
|
||||||
|
(((Uchar *) a)[0] & 0xFF))
|
||||||
|
|
||||||
|
#define a_to_u_2_byte(a) ((UInt16_t) \
|
||||||
|
((((Uchar *) a)[1] & 0xFF) | \
|
||||||
|
(((Uchar *) a)[0] << 8 & 0xFF00)))
|
||||||
|
|
||||||
|
#define a_to_2_byte(a) (int)(Int16_t)a_to_u_2_byte(a)
|
||||||
|
|
||||||
|
#define a_to_u_3_byte(a) ((Ulong) \
|
||||||
|
((((Uchar *) a)[2] & 0xFF) | \
|
||||||
|
(((Uchar *) a)[1] << 8 & 0xFF00) | \
|
||||||
|
(((Uchar *) a)[0] << 16 & 0xFF0000)))
|
||||||
|
|
||||||
|
#define a_to_3_byte(a) a_to_u_3_byte(a) /* XXX Is there a signed version ? */
|
||||||
|
|
||||||
|
#ifdef __STDC__
|
||||||
|
# define __TOP_4BYTE 0xFF000000UL
|
||||||
|
#else
|
||||||
|
# define __TOP_4BYTE 0xFF000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define a_to_u_4_byte(a) ((Ulong) \
|
||||||
|
((((Uchar*) a)[3] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[2] << 8 & 0xFF00) | \
|
||||||
|
(((Uchar*) a)[1] << 16 & 0xFF0000) | \
|
||||||
|
(((Uchar*) a)[0] << 24 & __TOP_4BYTE)))
|
||||||
|
|
||||||
|
#define a_to_4_byte(a) (long)(Int32_t)a_to_u_4_byte(a)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Little Endian versions of above macros
|
||||||
|
*/
|
||||||
|
#define li_to_2_byte(a, i) (((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[0] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define li_to_3_byte(a, i) (((Uchar *)(a))[2] = ((i) >> 16)& 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[0] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define li_to_4_byte(a, i) (((Uchar *)(a))[3] = ((i) >> 24)& 0xFF,\
|
||||||
|
((Uchar *)(a))[2] = ((i) >> 16)& 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[0] = (i) & 0xFF)
|
||||||
|
|
||||||
|
|
||||||
|
#define la_to_u_2_byte(a) ((UInt16_t) \
|
||||||
|
((((Uchar*) a)[0] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[1] << 8 & 0xFF00)))
|
||||||
|
|
||||||
|
#define la_to_2_byte(a) (int)(Int16_t)la_to_u_2_byte(a)
|
||||||
|
|
||||||
|
#define la_to_u_3_byte(a) ((Ulong) \
|
||||||
|
((((Uchar*) a)[0] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[1] << 8 & 0xFF00) | \
|
||||||
|
(((Uchar*) a)[2] << 16 & 0xFF0000)))
|
||||||
|
|
||||||
|
#define la_to_3_byte(a) la_to_u_3_byte(a) /* XXX Is there a signed version ? */
|
||||||
|
|
||||||
|
#define la_to_u_4_byte(a) ((Ulong) \
|
||||||
|
((((Uchar*) a)[0] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[1] << 8 & 0xFF00) | \
|
||||||
|
(((Uchar*) a)[2] << 16 & 0xFF0000) | \
|
||||||
|
(((Uchar*) a)[3] << 24 & __TOP_4BYTE)))
|
||||||
|
|
||||||
|
#define la_to_4_byte(a) (long)(Int32_t)la_to_u_4_byte(a)
|
||||||
|
|
||||||
|
#endif /* _INTCVT_H */
|
38
src/schily/jmpdefs.h
Normal file
38
src/schily/jmpdefs.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* @(#)jmpdefs.h 1.2 00/11/08 Copyright 1999 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions that help to handle a jmp_buf
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _JMPDEFS_H
|
||||||
|
#define _JMPDEFS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
jmp_buf jb;
|
||||||
|
} jmps_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _JMPDEFS_H */
|
111
src/schily/libport.h
Normal file
111
src/schily/libport.h
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/* @(#)libport.h 1.9 03/06/15 Copyright 1995 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1995 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _LIBPORT_H
|
||||||
|
#define _LIBPORT_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _STANDARD_H
|
||||||
|
#include <standard.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to get HOST_NAME_MAX for gethostname()
|
||||||
|
*/
|
||||||
|
#ifndef _UNIXSTD_H
|
||||||
|
#include <unixstd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HOST_NAME_MAX
|
||||||
|
#if defined(HAVE_NETDB_H) && !defined(HOST_NOT_FOUND) && \
|
||||||
|
!defined(_INCL_NETDB_H)
|
||||||
|
#include <netdb.h>
|
||||||
|
#define _INCL_NETDB_H
|
||||||
|
#endif
|
||||||
|
#ifdef MAXHOSTNAMELEN
|
||||||
|
#define HOST_NAME_MAX MAXHOSTNAMELEN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HOST_NAME_MAX
|
||||||
|
#ifdef HAVE_SYS_PARAM_H
|
||||||
|
#include <sys/param.h> /* Include various defs needed with some OS */
|
||||||
|
/* Linux MAXHOSTNAMELEN */
|
||||||
|
#endif
|
||||||
|
#ifdef MAXHOSTNAMELEN
|
||||||
|
#define HOST_NAME_MAX MAXHOSTNAMELEN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HOST_NAME_MAX
|
||||||
|
#define HOST_NAME_MAX 255
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPENSERVER
|
||||||
|
/*
|
||||||
|
* Don't use the usleep() from libc on SCO's OPENSERVER.
|
||||||
|
* It will kill our processes with SIGALRM.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Don't #undef HAVE_USLEEP in this file, SCO has a
|
||||||
|
* usleep() prototype in unistd.h
|
||||||
|
*/
|
||||||
|
/*#undef HAVE_USLEEP*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETHOSTID
|
||||||
|
extern long gethostid __PR((void));
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_GETHOSTNAME
|
||||||
|
extern int gethostname __PR((char *name, int namelen));
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_GETDOMAINNAME
|
||||||
|
extern int getdomainname __PR((char *name, int namelen));
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_GETPAGESIZE
|
||||||
|
EXPORT int getpagesize __PR((void));
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_USLEEP
|
||||||
|
extern int usleep __PR((int usec));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_STRDUP) || defined(__SVR4)
|
||||||
|
extern char *strdup __PR((const char *s));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_RENAME
|
||||||
|
extern int rename __PR((const char *old, const char *new));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _LIBPORT_H */
|
64
src/schily/librmt.h
Normal file
64
src/schily/librmt.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* @(#)librmt.h 1.16 03/06/15 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Prototypes for rmt client subroutines
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995,1996,2000-2002 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBRMT_H
|
||||||
|
#define _LIBRMT_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rmtio.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* remote.c
|
||||||
|
*/
|
||||||
|
extern void rmtinit __PR((int (*errmsgn)(int, const char *, ...),
|
||||||
|
void (*eexit)(int)));
|
||||||
|
extern int rmtdebug __PR((int dlevel));
|
||||||
|
extern char *rmtfilename __PR((char *name));
|
||||||
|
extern char *rmthostname __PR((char *hostname, int hnsize, char *rmtspec));
|
||||||
|
extern int rmtgetconn __PR((char *host, int trsize, int excode));
|
||||||
|
extern int rmtopen __PR((int fd, char *fname, int fmode));
|
||||||
|
extern int rmtclose __PR((int fd));
|
||||||
|
extern int rmtread __PR((int fd, char *buf, int count));
|
||||||
|
extern int rmtwrite __PR((int fd, char *buf, int count));
|
||||||
|
extern off_t rmtseek __PR((int fd, off_t offset, int whence));
|
||||||
|
extern int rmtioctl __PR((int fd, int cmd, int count));
|
||||||
|
#ifdef MTWEOF
|
||||||
|
extern int rmtstatus __PR((int fd, struct mtget *mtp));
|
||||||
|
#endif
|
||||||
|
extern int rmtxstatus __PR((int fd, struct rmtget *mtp));
|
||||||
|
#ifdef MTWEOF
|
||||||
|
extern void _rmtg2mtg __PR((struct mtget *mtp, struct rmtget *rmtp));
|
||||||
|
extern int _mtg2rmtg __PR((struct rmtget *rmtp, struct mtget *mtp));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _LIBRMT_H */
|
75
src/schily/maxpath.h
Normal file
75
src/schily/maxpath.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/* @(#)maxpath.h 1.6 03/08/23 Copyright 1985, 1995, 1998 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for dealing with statically limitations on pathnames
|
||||||
|
*
|
||||||
|
* Copyright (c) 1985, 1995, 1998 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MAXPATH_H
|
||||||
|
#define _MAXPATH_H
|
||||||
|
|
||||||
|
#ifndef _DIRDEFS_H
|
||||||
|
#include <dirdefs.h> /* Includes mconfig.h if needed */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JOS
|
||||||
|
#ifndef _JOS_MAXP_H
|
||||||
|
# include <jos_maxp.h>
|
||||||
|
#endif
|
||||||
|
# define FOUND_MAXPATHNAME
|
||||||
|
# define FOUND_MAXFILENAME
|
||||||
|
#else
|
||||||
|
|
||||||
|
# ifdef MAXPATHLEN
|
||||||
|
# define MAXPATHNAME MAXPATHLEN /* From sys/param.h */
|
||||||
|
# define FOUND_MAXPATHNAME
|
||||||
|
# else
|
||||||
|
# ifdef PATH_MAX
|
||||||
|
# define MAXPATHNAME PATH_MAX /* From limits.h */
|
||||||
|
# define FOUND_MAXPATHNAME
|
||||||
|
# else
|
||||||
|
# define MAXPATHNAME 256 /* Is there a limit? */
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't use defaults here to allow recognition of problems.
|
||||||
|
*/
|
||||||
|
# ifdef MAXNAMELEN
|
||||||
|
# define MAXFILENAME MAXNAMELEN /* From sys/param.h */
|
||||||
|
# define FOUND_MAXFILENAME
|
||||||
|
# else
|
||||||
|
# ifdef MAXNAMLEN
|
||||||
|
# define MAXFILENAME MAXNAMLEN /* From dirent.h */
|
||||||
|
# define FOUND_MAXFILENAME
|
||||||
|
# else
|
||||||
|
# ifdef DIRSIZ
|
||||||
|
# define MAXFILENAME DIRSIZ /* From sys/dir.h */
|
||||||
|
# define FOUND_MAXFILENAME
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#if !defined(FOUND_MAXFILENAME) && defined(FOUND_DIRSIZE)
|
||||||
|
# define MAXFILENAME DIRSIZE /* From dirdefs.h */
|
||||||
|
# define FOUND_MAXFILENAME
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* JOS */
|
||||||
|
|
||||||
|
#endif /* _MAXPATH_H */
|
483
src/schily/mconfig.h
Normal file
483
src/schily/mconfig.h
Normal file
@ -0,0 +1,483 @@
|
|||||||
|
/* @(#)mconfig.h 1.50 04/07/11 Copyright 1995 J. Schilling */
|
||||||
|
/*
|
||||||
|
* definitions for machine configuration
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995 J. Schilling
|
||||||
|
*
|
||||||
|
* This file must be included before any other file.
|
||||||
|
* If this file is not included before stdio.h you will not be
|
||||||
|
* able to get LARGEFILE support
|
||||||
|
*
|
||||||
|
* Use only cpp instructions.
|
||||||
|
*
|
||||||
|
* NOTE: SING: (Schily Is Not Gnu)
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#define _MCONFIG_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tell our users that this is a Schily SING compile environment.
|
||||||
|
*/
|
||||||
|
#define IS_SCHILY
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This hack that is needed as long as VMS has no POSIX shell.
|
||||||
|
*/
|
||||||
|
#ifdef VMS
|
||||||
|
# define USE_STATIC_CONF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_STATIC_CONF
|
||||||
|
#include <xmconfig.h> /* This is the current static autoconf stuff */
|
||||||
|
#else
|
||||||
|
#include <xconfig.h> /* This is the current dynamic autoconf stuff */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The NetBSD people want to bother us.
|
||||||
|
* They removed the definition for 'unix' and are bleating for every test
|
||||||
|
* for #if defined(unix). So we need to check for NetBSD early.
|
||||||
|
*/
|
||||||
|
#ifndef IS_UNIX
|
||||||
|
# if defined(__NetBSD__)
|
||||||
|
# define IS_UNIX
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IS_UNIX
|
||||||
|
# if (defined(unix) || defined(__unix) || defined(__unix__)) && !defined(__DJGPP__)
|
||||||
|
# define IS_UNIX
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __MSDOS__
|
||||||
|
# define IS_MSDOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(tos) || defined(__tos)
|
||||||
|
# define IS_TOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef THINK_C
|
||||||
|
# define IS_MAC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(sun) || defined(__sun) || defined(__sun__)
|
||||||
|
# define IS_SUN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__CYGWIN32__) || defined(__CYGWIN__)
|
||||||
|
# define IS_GCC_WIN32
|
||||||
|
# define IS_CYGWIN
|
||||||
|
|
||||||
|
#if defined(unix) || defined(_X86)
|
||||||
|
# define IS_CYGWIN_1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
/*
|
||||||
|
* Some magic that cannot (yet) be figured out with autoconf.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(sun3) || defined(mc68000) || defined(mc68020)
|
||||||
|
# ifndef HAVE_SCANSTACK
|
||||||
|
# define HAVE_SCANSTACK
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifdef sparc
|
||||||
|
# ifndef HAVE_LDSTUB
|
||||||
|
# define HAVE_LDSTUB
|
||||||
|
# endif
|
||||||
|
# ifndef HAVE_SCANSTACK
|
||||||
|
# define HAVE_SCANSTACK
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(__i386_) || defined(i386)
|
||||||
|
# ifndef HAVE_XCHG
|
||||||
|
# define HAVE_XCHG
|
||||||
|
# endif
|
||||||
|
# ifndef HAVE_SCANSTACK
|
||||||
|
# define HAVE_SCANSTACK
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use of SCANSTACK is disabled by default
|
||||||
|
*/
|
||||||
|
#ifndef USE_SCANSTACK
|
||||||
|
# undef HAVE_SCANSTACK
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* But ....
|
||||||
|
* The tests are much better now, so always give it a chance.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_SCANSTACK
|
||||||
|
# define HAVE_SCANSTACK
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allow to overwrite the defines in the makefiles by calling
|
||||||
|
*
|
||||||
|
* make COPTX=-DFORCE_SCANSTACK
|
||||||
|
*/
|
||||||
|
#ifdef FORCE_SCANSTACK
|
||||||
|
# undef NO_SCANSTACK
|
||||||
|
#ifndef HAVE_SCANSTACK
|
||||||
|
# define HAVE_SCANSTACK
|
||||||
|
#endif
|
||||||
|
#ifndef USE_SCANSTACK
|
||||||
|
# define USE_SCANSTACK
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the global switch to deactivate stack scanning
|
||||||
|
*/
|
||||||
|
#ifdef NO_SCANSTACK
|
||||||
|
# ifdef HAVE_SCANSTACK
|
||||||
|
# undef HAVE_SCANSTACK
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_FORK
|
||||||
|
# ifdef HAVE_FORK
|
||||||
|
# undef HAVE_FORK
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_VFORK
|
||||||
|
# undef HAVE_VFORK
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifdef NO_VFORK
|
||||||
|
# ifdef HAVE_VFORK
|
||||||
|
# undef HAVE_VFORK
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SOL2) || defined(SOL2) || \
|
||||||
|
defined(S5R4) || defined(__S5R4) || defined(SVR4)
|
||||||
|
# ifndef __SVR4
|
||||||
|
# define __SVR4
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __SVR4
|
||||||
|
# ifndef SVR4
|
||||||
|
# define SVR4
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SunOS 4.x / SunOS 5.x
|
||||||
|
*/
|
||||||
|
#if defined(IS_SUN)
|
||||||
|
# define HAVE_GETAV0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* AIX
|
||||||
|
*/
|
||||||
|
#if defined(_IBMR2) || defined(_AIX)
|
||||||
|
# ifndef IS_UNIX
|
||||||
|
# define IS_UNIX /* ??? really ??? */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* QNX
|
||||||
|
*/
|
||||||
|
#if defined(__QNX__)
|
||||||
|
# ifndef IS_UNIX
|
||||||
|
# define IS_UNIX
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Silicon Graphics (must be before SVR4)
|
||||||
|
*/
|
||||||
|
#if defined(sgi) || defined(__sgi)
|
||||||
|
# define __NOT_SVR4__ /* Not a real SVR4 implementation */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data General
|
||||||
|
*/
|
||||||
|
#if defined(__DGUX__)
|
||||||
|
#ifdef XXXXXXX
|
||||||
|
# undef HAVE_MTGET_DSREG
|
||||||
|
# undef HAVE_MTGET_RESID
|
||||||
|
# undef HAVE_MTGET_FILENO
|
||||||
|
# undef HAVE_MTGET_BLKNO
|
||||||
|
#endif
|
||||||
|
# define mt_type mt_model
|
||||||
|
# define mt_dsreg mt_status1
|
||||||
|
# define mt_erreg mt_status2
|
||||||
|
/*
|
||||||
|
* DGUX hides its flock as dg_flock.
|
||||||
|
*/
|
||||||
|
# define HAVE_FLOCK
|
||||||
|
# define flock dg_flock
|
||||||
|
/*
|
||||||
|
* Use the BSD style wait on DGUX to get the resource usages of child
|
||||||
|
* processes.
|
||||||
|
*/
|
||||||
|
# define _BSD_WAIT_FLAVOR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Apple Rhapsody (This is the name for Mac OS X beta)
|
||||||
|
*/
|
||||||
|
#if defined(__NeXT__) && defined(__TARGET_OSNAME) && __TARGET_OSNAME == rhapsody
|
||||||
|
# define HAVE_OSDEF /* prevent later definitions to overwrite current */
|
||||||
|
# ifndef IS_UNIX
|
||||||
|
# define IS_UNIX
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NextStep
|
||||||
|
*/
|
||||||
|
#if defined(__NeXT__) && !defined(HAVE_OSDEF)
|
||||||
|
#define NO_PRINT_OVR
|
||||||
|
#undef HAVE_USG_STDIO /*
|
||||||
|
* NeXT Step 3.x uses __flsbuf(unsigned char, FILE *)
|
||||||
|
* instead of __flsbuf(int, FILE *)
|
||||||
|
*/
|
||||||
|
# ifndef IS_UNIX
|
||||||
|
# define IS_UNIX
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mac OS X
|
||||||
|
*/
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
# ifndef IS_UNIX
|
||||||
|
# define IS_UNIX
|
||||||
|
# endif
|
||||||
|
# define IS_MACOS_X
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NextStep 3.x has a broken linker that does not allow us to override
|
||||||
|
* these functions.
|
||||||
|
*/
|
||||||
|
#ifndef __OPRINTF__
|
||||||
|
|
||||||
|
#ifdef NO_PRINT_OVR
|
||||||
|
# define printf Xprintf
|
||||||
|
# define fprintf Xfprintf
|
||||||
|
# define sprintf Xsprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __OPRINTF__ */
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
/*
|
||||||
|
* If there is no flock defined by the system, use emulation
|
||||||
|
* through fcntl record locking.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_FLOCK
|
||||||
|
#define LOCK_SH 1 /* shared lock */
|
||||||
|
#define LOCK_EX 2 /* exclusive lock */
|
||||||
|
#define LOCK_NB 4 /* don't block when locking */
|
||||||
|
#define LOCK_UN 8 /* unlock */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gcc 2.x generally implements the long long type.
|
||||||
|
*/
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# if __GNUC__ > 1
|
||||||
|
# ifndef HAVE_LONGLONG
|
||||||
|
# define HAVE_LONGLONG
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __CHAR_UNSIGNED__ /* GNU GCC define (dynamic) */
|
||||||
|
#ifndef CHAR_IS_UNSIGNED
|
||||||
|
#define CHAR_IS_UNSIGNED /* Sing Schily define (static) */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert to GNU name
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_STDC_HEADERS
|
||||||
|
# ifndef STDC_HEADERS
|
||||||
|
# define STDC_HEADERS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Convert to SCHILY name
|
||||||
|
*/
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# ifndef HAVE_STDC_HEADERS
|
||||||
|
# define HAVE_STDC_HEADERS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef IS_UNIX
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '/'
|
||||||
|
# define PATH_DELIM_STR "/"
|
||||||
|
# define PATH_ENV_DELIM ':'
|
||||||
|
# define PATH_ENV_DELIM_STR ":"
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Win32 with Gygwin
|
||||||
|
*/
|
||||||
|
#ifdef IS_GCC_WIN32
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '/'
|
||||||
|
# define PATH_DELIM_STR "/"
|
||||||
|
# define PATH_ENV_DELIM ':'
|
||||||
|
# define PATH_ENV_DELIM_STR ":"
|
||||||
|
# define HAVE_DOS_DRIVELETTER
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
# define NEED_O_BINARY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Win32 with Mingw32
|
||||||
|
*/
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '/'
|
||||||
|
# define PATH_DELIM_STR "/"
|
||||||
|
# define PATH_ENV_DELIM ';'
|
||||||
|
# define PATH_ENV_DELIM_STR ";"
|
||||||
|
# define HAVE_DOS_DRIVELETTER
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
# define NEED_O_BINARY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OS/2 EMX
|
||||||
|
*/
|
||||||
|
#ifdef __EMX__ /* We don't want to call it UNIX */
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '/'
|
||||||
|
# define PATH_DELIM_STR "/"
|
||||||
|
# define PATH_ENV_DELIM ';'
|
||||||
|
# define PATH_ENV_DELIM_STR ";"
|
||||||
|
# define HAVE_DOS_DRIVELETTER
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
# define NEED_O_BINARY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __BEOS__ /* We don't want to call it UNIX */
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '/'
|
||||||
|
# define PATH_DELIM_STR "/"
|
||||||
|
# define PATH_ENV_DELIM ':'
|
||||||
|
# define PATH_ENV_DELIM_STR ":"
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DOS with DJGPP
|
||||||
|
*/
|
||||||
|
#ifdef __DJGPP__ /* We don't want to call it UNIX */
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '/'
|
||||||
|
# define PATH_DELIM_STR "/"
|
||||||
|
# define PATH_ENV_DELIM ';'
|
||||||
|
# define PATH_ENV_DELIM_STR ";"
|
||||||
|
# define HAVE_DOS_DRIVELETTER
|
||||||
|
|
||||||
|
# define NEED_O_BINARY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Vanilla DOS
|
||||||
|
*/
|
||||||
|
#if defined(IS_MSDOS) && !defined(__DJGPP__)
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '\\'
|
||||||
|
# define PATH_DELIM_STR "\\"
|
||||||
|
# define PATH_ENV_DELIM ';'
|
||||||
|
# define PATH_ENV_DELIM_STR ";"
|
||||||
|
# define HAVE_DOS_DRIVELETTER
|
||||||
|
|
||||||
|
# define NEED_O_BINARY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ATARI TOS
|
||||||
|
*/
|
||||||
|
#ifdef IS_TOS
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '\\'
|
||||||
|
# define PATH_DELIM_STR "\\"
|
||||||
|
# define PATH_ENV_DELIM ','
|
||||||
|
# define PATH_ENV_DELIM_STR ","
|
||||||
|
# define HAVE_DOS_DRIVELETTER
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mac OS 9
|
||||||
|
*/
|
||||||
|
#ifdef IS_MAC
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM ':'
|
||||||
|
# define PATH_DELIM_STR ":"
|
||||||
|
# define PATH_ENV_DELIM ';' /* ??? */
|
||||||
|
# define PATH_ENV_DELIM_STR ";" /* ??? */
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I hope this will make compilation on unknown OS easier.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_PATH_DELIM /* Default to POSIX rules */
|
||||||
|
# define HAVE_PATH_DELIM
|
||||||
|
# define PATH_DELIM '/'
|
||||||
|
# define PATH_DELIM_STR "/"
|
||||||
|
# define PATH_ENV_DELIM ':'
|
||||||
|
# define PATH_ENV_DELIM_STR ":"
|
||||||
|
# define far
|
||||||
|
# define near
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _MCONFIG_H */
|
63
src/schily/mmapdefs.h
Normal file
63
src/schily/mmapdefs.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/* @(#)mmapdefs.h 1.1 01/02/25 Copyright 2001 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions to be used for mmap()
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MMAPDEFS_H
|
||||||
|
#define _MMAPDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_SMMAP)
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_MMAN_H
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#define _INCL_SYS_MMAN_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAP_ANONYMOUS
|
||||||
|
# ifdef MAP_ANON
|
||||||
|
# define MAP_ANONYMOUS MAP_ANON
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAP_FILE
|
||||||
|
# define MAP_FILE 0 /* Needed on Apollo Domain/OS */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Needed for Apollo Domain/OS and may be for others?
|
||||||
|
*/
|
||||||
|
#ifdef _MMAP_WITH_SIZEP
|
||||||
|
# define mmap_sizeparm(s) (&(s))
|
||||||
|
#else
|
||||||
|
# define mmap_sizeparm(s) (s)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* defined(HAVE_SMMAP) */
|
||||||
|
|
||||||
|
#endif /* _MMAPDEFS_H */
|
103
src/schily/mtiodefs.h
Normal file
103
src/schily/mtiodefs.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/* @(#)mtiodefs.h 1.4 02/08/26 Copyright 1995,2000-2002 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Generic header for users of magnetic tape ioctl interface.
|
||||||
|
*
|
||||||
|
* If there is no local mtio.h or equivalent, define
|
||||||
|
* simplified mtio definitions here in order
|
||||||
|
* to be able to do at least remote mtio on systems
|
||||||
|
* that have no local mtio
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995,2000-2002 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MTIODEFS_H
|
||||||
|
#define _MTIODEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_MTIO_H
|
||||||
|
|
||||||
|
#include <sys/mtio.h>
|
||||||
|
|
||||||
|
#else /* ! HAVE_SYS_MTIO_H */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Definitions for magnetic tape io control commands
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* structure for MTIOCTOP - magnetic tape operation command
|
||||||
|
*/
|
||||||
|
struct mtop {
|
||||||
|
short mt_op; /* op code (see below) */
|
||||||
|
daddr_t mt_count; /* repeat count or param */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* op code values for mt_op
|
||||||
|
*/
|
||||||
|
#define MTWEOF 0 /* write EOF record(s) */
|
||||||
|
#define MTFSF 1 /* fwd space over file mark(s) */
|
||||||
|
#define MTBSF 2 /* back space over file mark(s) (1/2" only ) */
|
||||||
|
#define MTFSR 3 /* fwd space record(s) (to inter-record gap) */
|
||||||
|
#define MTBSR 4 /* back space record(s) (to inter-record gap)*/
|
||||||
|
#define MTREW 5 /* rewind tape */
|
||||||
|
#define MTOFFL 6 /* rewind and put the drive offline */
|
||||||
|
#define MTNOP 7 /* no operation (sets status ?) */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* structure for MTIOCGET - magnetic tape get status command
|
||||||
|
*/
|
||||||
|
struct mtget {
|
||||||
|
short mt_type; /* type of magnetic tape device */
|
||||||
|
/* the next two regs are device dependent */
|
||||||
|
short mt_dsreg; /* drive status 'register' */
|
||||||
|
short mt_erreg; /* error 'register' */
|
||||||
|
daddr_t mt_resid; /* transfer residual count */
|
||||||
|
daddr_t mt_fileno; /* file # for current position */
|
||||||
|
daddr_t mt_blkno; /* block # for current position */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define HAVE_MTGET_TYPE
|
||||||
|
#define HAVE_MTGET_DSREG
|
||||||
|
#define HAVE_MTGET_ERREG
|
||||||
|
#define HAVE_MTGET_RESID
|
||||||
|
#define HAVE_MTGET_FILENO
|
||||||
|
#define HAVE_MTGET_BLKNO
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define some junk here as software may assume that these two definitions
|
||||||
|
* are always present.
|
||||||
|
*/
|
||||||
|
#define MTIOCGET 0x12340001
|
||||||
|
#define MTIOCTOP 0x12340002
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* HAVE_SYS_MTIO_H */
|
||||||
|
|
||||||
|
#endif /* _MTIODEFS_H */
|
105
src/schily/patmatch.h
Normal file
105
src/schily/patmatch.h
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/* @(#)patmatch.h 1.10 03/08/24 Copyright 1985 J. Schilling */
|
||||||
|
|
||||||
|
#ifndef _PATMATCH_H
|
||||||
|
#define _PATMATCH_H
|
||||||
|
/*
|
||||||
|
* Definitions for the pattern matching functions.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1985,1995 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* The pattern matching functions are based on the algorithm
|
||||||
|
* presented by Martin Richards in:
|
||||||
|
*
|
||||||
|
* "A Compact Function for Regular Expression Pattern Matching",
|
||||||
|
* Software-Practice and Experience, Vol. 9, 527-534 (1979)
|
||||||
|
*
|
||||||
|
* Several changes have been made to the original source which has been
|
||||||
|
* written in BCPL:
|
||||||
|
*
|
||||||
|
* '/' is replaced by '!' (to allow UNIX filenames)
|
||||||
|
* '(',')' are replaced by '{', '}'
|
||||||
|
* '\'' is replaced by '\\' (UNIX compatible quote)
|
||||||
|
*
|
||||||
|
* Character classes have been added to allow "[<character list>]"
|
||||||
|
* to be used.
|
||||||
|
* Start of line '^' and end of line '$' have been added.
|
||||||
|
*
|
||||||
|
* Any number in the following comment is zero or more occurrencies
|
||||||
|
*/
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ALT '!' /* Alternation in match i.e. this!that!the_other */
|
||||||
|
#define REP '#' /* Any number of occurrences of the following expr */
|
||||||
|
#define NIL '%' /* Empty string (exactly nothing) */
|
||||||
|
#define STAR '*' /* Any number of any character (equivalent of #?) */
|
||||||
|
#define ANY '?' /* Any one character */
|
||||||
|
#define QUOTE '\\' /* Quotes the next character */
|
||||||
|
#define LBRACK '{' /* Begin of precedence grouping */
|
||||||
|
#define RBRACK '}' /* End of precedence grouping */
|
||||||
|
#define LCLASS '[' /* Begin of character set */
|
||||||
|
#define RCLASS ']' /* End of character set */
|
||||||
|
#define NOT '^' /* If first in set: invert set content */
|
||||||
|
#define RANGE '-' /* Range notation in sets */
|
||||||
|
#define START '^' /* Begin of a line */
|
||||||
|
#define END '$' /* End of a line */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A list of case statements that may be used for a issimple() or ispattern()
|
||||||
|
* funtion that checks whether a string conrtains characters that need the
|
||||||
|
* pattern matcher.
|
||||||
|
*
|
||||||
|
* Note that this list does not contain NOT or RANGE because you need
|
||||||
|
* LCLASS and RCLASS in addition.
|
||||||
|
*/
|
||||||
|
#define casePAT case ALT: case REP: case NIL: case STAR: case ANY: \
|
||||||
|
case QUOTE: case LBRACK: case RBRACK: \
|
||||||
|
case LCLASS: case RCLASS: case START: case END:
|
||||||
|
|
||||||
|
|
||||||
|
#define MAXPAT 128 /* Maximum length of pattern */
|
||||||
|
|
||||||
|
extern int patcompile __PR((const unsigned char * __pat, int __patlen, int * __aux));
|
||||||
|
|
||||||
|
extern unsigned char *opatmatch __PR((const unsigned char * __pat, const int * __aux,
|
||||||
|
const unsigned char * __str, int __soff, int __slen,
|
||||||
|
int __alt));
|
||||||
|
extern unsigned char *opatlmatch __PR((const unsigned char * __pat, const int * __aux,
|
||||||
|
const unsigned char * __str, int __soff, int __slen,
|
||||||
|
int __alt));
|
||||||
|
extern unsigned char *patmatch __PR((const unsigned char * __pat, const int * __aux,
|
||||||
|
const unsigned char * __str, int __soff, int __slen,
|
||||||
|
int __alt, int __state[]));
|
||||||
|
extern unsigned char *patlmatch __PR((const unsigned char * __pat, const int * __aux,
|
||||||
|
const unsigned char * __str, int __soff, int __slen,
|
||||||
|
int __alt, int __state[]));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _PATMATCH_H */
|
95
src/schily/prototyp.h
Normal file
95
src/schily/prototyp.h
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/* @(#)prototyp.h 1.11 03/08/23 Copyright 1995 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for dealing with ANSI / KR C-Compilers
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* mconfig.h includes prototype.h so we must do this include before we test
|
||||||
|
* for _PROTOTYP_H
|
||||||
|
*/
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#define _PROTOTYP_H
|
||||||
|
|
||||||
|
#ifndef PROTOTYPES
|
||||||
|
/*
|
||||||
|
* If this has already been defined,
|
||||||
|
* someone else knows better than us...
|
||||||
|
*/
|
||||||
|
# ifdef __STDC__
|
||||||
|
# if __STDC__ /* ANSI C */
|
||||||
|
# define PROTOTYPES
|
||||||
|
# endif
|
||||||
|
# if defined(sun) && __STDC__ - 0 == 0 /* Sun C */
|
||||||
|
# define PROTOTYPES
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif /* PROTOTYPES */
|
||||||
|
|
||||||
|
#if !defined(PROTOTYPES) && (defined(__cplusplus) || defined(_MSC_VER))
|
||||||
|
/*
|
||||||
|
* C++ always supports prototypes.
|
||||||
|
* Define PROTOTYPES so we are not forced to make
|
||||||
|
* a separtate autoconf run for C++
|
||||||
|
*
|
||||||
|
* Microsoft C has prototypes but does not define __STDC__
|
||||||
|
*/
|
||||||
|
# define PROTOTYPES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we have prototypes, we should have stdlib.h string.h stdarg.h
|
||||||
|
*/
|
||||||
|
#ifdef PROTOTYPES
|
||||||
|
#if !(defined(SABER) && defined(sun))
|
||||||
|
# ifndef HAVE_STDARG_H
|
||||||
|
# define HAVE_STDARG_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef JOS
|
||||||
|
# ifndef HAVE_STDLIB_H
|
||||||
|
# define HAVE_STDLIB_H
|
||||||
|
# endif
|
||||||
|
# ifndef HAVE_STRING_H
|
||||||
|
# define HAVE_STRING_H
|
||||||
|
# endif
|
||||||
|
# ifndef HAVE_STDC_HEADERS
|
||||||
|
# define HAVE_STDC_HEADERS
|
||||||
|
# endif
|
||||||
|
# ifndef STDC_HEADERS
|
||||||
|
# define STDC_HEADERS /* GNU name */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_PROTOTYPES /* Force not to use prototypes */
|
||||||
|
# undef PROTOTYPES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PROTOTYPES
|
||||||
|
# define __PR(a) a
|
||||||
|
#else
|
||||||
|
# define __PR(a) ()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _PROTOTYP_H */
|
156
src/schily/rmtio.h
Normal file
156
src/schily/rmtio.h
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/* @(#)rmtio.h 1.5 03/06/15 Copyright 1995,2000 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definition for enhanced remote tape IO
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995,2000-2002 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RMTIO_H
|
||||||
|
#define _RMTIO_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _UTYPES_H
|
||||||
|
#include <utypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* values for mt_op
|
||||||
|
*/
|
||||||
|
#define RMTWEOF 0 /* write an end-of-file record */
|
||||||
|
#define RMTFSF 1 /* forward space over file mark */
|
||||||
|
#define RMTBSF 2 /* backward space over file mark (1/2" only ) */
|
||||||
|
#define RMTFSR 3 /* forward space to inter-record gap */
|
||||||
|
#define RMTBSR 4 /* backward space to inter-record gap */
|
||||||
|
#define RMTREW 5 /* rewind */
|
||||||
|
#define RMTOFFL 6 /* rewind and put the drive offline */
|
||||||
|
#define RMTNOP 7 /* no operation, sets status only */
|
||||||
|
|
||||||
|
#ifdef __needed__
|
||||||
|
#define MTRETEN 8 /* retension the tape (cartridge tape only) */
|
||||||
|
#define MTERASE 9 /* erase the entire tape */
|
||||||
|
#define MTEOM 10 /* position to end of media */
|
||||||
|
#define MTNBSF 11 /* backward space file to BOF */
|
||||||
|
|
||||||
|
#define MTSRSZ 12 /* set record size */
|
||||||
|
#define MTGRSZ 13 /* get record size */
|
||||||
|
#define MTLOAD 14 /* for loading a tape (use o_delay to open */
|
||||||
|
/* the tape device) */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Definitions for the new RMT Protocol version 1
|
||||||
|
*
|
||||||
|
* The new Protocol version tries to make the use
|
||||||
|
* of rmtioctl() more portable between different platforms.
|
||||||
|
*/
|
||||||
|
#define RMTIVERSION -1 /* Opcode to request version */
|
||||||
|
#define RMT_NOVERSION -1 /* Old version code */
|
||||||
|
#define RMT_VERSION 1 /* New (current) version code */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Support for commands bejond MTWEOF..MTNOP (0..7)
|
||||||
|
*/
|
||||||
|
#define RMTICACHE 0 /* enable controller cache */
|
||||||
|
#define RMTINOCACHE 1 /* disable controller cache */
|
||||||
|
#define RMTIRETEN 2 /* retension the tape (cartridge tape only) */
|
||||||
|
#define RMTIERASE 3 /* erase the entire tape */
|
||||||
|
#define RMTIEOM 4 /* position to end of media */
|
||||||
|
#define RMTINBSF 5 /* backward space file to BOF */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Old MTIOCGET copies a binary version of struct mtget back
|
||||||
|
* over the wire. This is highly non portable.
|
||||||
|
* MTS_* retrieves ascii versions (%d format) of a single
|
||||||
|
* field in the struct mtget.
|
||||||
|
* NOTE: MTS_ERREG may only be valid on the first call and
|
||||||
|
* must be retrived first.
|
||||||
|
*/
|
||||||
|
#define MTS_TYPE 'T' /* mtget.mt_type */
|
||||||
|
#define MTS_DSREG 'D' /* mtget.mt_dsreg */
|
||||||
|
#define MTS_ERREG 'E' /* mtget.mt_erreg */
|
||||||
|
#define MTS_RESID 'R' /* mtget.mt_resid */
|
||||||
|
#define MTS_FILENO 'F' /* mtget.mt_fileno */
|
||||||
|
#define MTS_BLKNO 'B' /* mtget.mt_blkno */
|
||||||
|
#define MTS_FLAGS 'f' /* mtget.mt_flags */
|
||||||
|
#define MTS_BF 'b' /* mtget.mt_bf */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* structure for remote MTIOCGET - mag tape get status command
|
||||||
|
*/
|
||||||
|
struct rmtget {
|
||||||
|
Llong mt_type; /* type of magtape device */
|
||||||
|
/* the following two registers are grossly device dependent */
|
||||||
|
Llong mt_dsreg; /* ``drive status'' register */
|
||||||
|
Int32_t mt_dsreg1; /* ``drive status'' register */
|
||||||
|
Int32_t mt_dsreg2; /* ``drive status'' register */
|
||||||
|
Llong mt_gstat; /* ``generic status'' register */
|
||||||
|
Llong mt_erreg; /* ``error'' register */
|
||||||
|
/* optional error info. */
|
||||||
|
Llong mt_resid; /* residual count */
|
||||||
|
Llong mt_fileno; /* file number of current position */
|
||||||
|
Llong mt_blkno; /* block number of current position */
|
||||||
|
Llong mt_flags;
|
||||||
|
Llong mt_gflags; /* generic flags */
|
||||||
|
long mt_bf; /* optimum blocking factor */
|
||||||
|
int mt_xflags; /* eXistence flags for struct members */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Values for mt_xflags
|
||||||
|
*/
|
||||||
|
#define RMT_TYPE 0x0001 /* mt_type/mt_model present */
|
||||||
|
#define RMT_DSREG 0x0002 /* mt_dsreg present */
|
||||||
|
#define RMT_DSREG1 0x0004 /* mt_dsreg1 present */
|
||||||
|
#define RMT_DSREG2 0x0008 /* mt_dsreg2 present */
|
||||||
|
#define RMT_GSTAT 0x0010 /* mt_gstat present */
|
||||||
|
#define RMT_ERREG 0x0020 /* mt_erreg present */
|
||||||
|
#define RMT_RESID 0x0040 /* mt_resid present */
|
||||||
|
#define RMT_FILENO 0x0080 /* mt_fileno present */
|
||||||
|
#define RMT_BLKNO 0x0100 /* mt_blkno present */
|
||||||
|
#define RMT_FLAGS 0x0200 /* mt_flags present */
|
||||||
|
#define RMT_BF 0x0400 /* mt_bf present */
|
||||||
|
#define RMT_COMPAT 0x0800 /* Created from old compat data */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* values for mt_flags
|
||||||
|
*/
|
||||||
|
#define RMTF_SCSI 0x01
|
||||||
|
#define RMTF_REEL 0x02
|
||||||
|
#define RMTF_ASF 0x04
|
||||||
|
#define RMTF_TAPE_HEAD_DIRTY 0x08
|
||||||
|
#define RMTF_TAPE_CLN_SUPPORTED 0x10
|
||||||
|
|
||||||
|
/*
|
||||||
|
* these are recommended
|
||||||
|
*/
|
||||||
|
#ifdef __needed__
|
||||||
|
#define MT_ISQIC 0x32 /* generic QIC tape drive */
|
||||||
|
#define MT_ISREEL 0x33 /* generic reel tape drive */
|
||||||
|
#define MT_ISDAT 0x34 /* generic DAT tape drive */
|
||||||
|
#define MT_IS8MM 0x35 /* generic 8mm tape drive */
|
||||||
|
#define MT_ISOTHER 0x36 /* generic other type of tape drive */
|
||||||
|
|
||||||
|
/* more Sun devices */
|
||||||
|
#define MT_ISTAND25G 0x37 /* sun: SCSI Tandberg 2.5 Gig QIC */
|
||||||
|
#define MT_ISDLT 0x38 /* sun: SCSI DLT tape drive */
|
||||||
|
#define MT_ISSTK9840 0x39 /* sun: STK 9840 (Ironsides) */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _RMTIO_H */
|
155
src/schily/scg/aspi-dos.h
Normal file
155
src/schily/scg/aspi-dos.h
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
#ifndef __ASPI16_H_
|
||||||
|
#define __ASPI16_H_
|
||||||
|
|
||||||
|
#define PACKED __attribute__((packed))
|
||||||
|
#define FAR
|
||||||
|
typedef unsigned char BYTE;
|
||||||
|
typedef unsigned short WORD;
|
||||||
|
typedef unsigned long DWORD;
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// %%% SCSI MISCELLANEOUS EQUATES %%%
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#define SENSE_LEN 14 // Default sense buffer length
|
||||||
|
#define SRB_DIR_SCSI 0x00 // Direction determined by SCSI
|
||||||
|
#define SRB_POSTING 0x01 // Enable ASPI posting
|
||||||
|
#define SRB_ENABLE_RESIDUAL_COUNT 0x04 // Enable residual byte count reporting
|
||||||
|
#define SRB_DIR_IN 0x08 // Transfer from SCSI target to host
|
||||||
|
#define SRB_DIR_OUT 0x10 // Transfer from host to SCSI target
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// %%% ASPI Command Definitions %%%
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#define SC_HA_INQUIRY 0x00 // Host adapter inquiry
|
||||||
|
#define SC_GET_DEV_TYPE 0x01 // Get device type
|
||||||
|
#define SC_EXEC_SCSI_CMD 0x02 // Execute SCSI command
|
||||||
|
#define SC_ABORT_SRB 0x03 // Abort an SRB
|
||||||
|
#define SC_RESET_DEV 0x04 // SCSI bus device reset
|
||||||
|
#define SC_SET_HA_PARMS 0x05 // Set HA parameters
|
||||||
|
#define SC_GET_DISK_INFO 0x06 // Get Disk information
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// %%% SRB Status %%%
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#define SS_PENDING 0x00 // SRB being processed
|
||||||
|
#define SS_COMP 0x01 // SRB completed without error
|
||||||
|
#define SS_ABORTED 0x02 // SRB aborted
|
||||||
|
#define SS_ABORT_FAIL 0x03 // Unable to abort SRB
|
||||||
|
#define SS_ERR 0x04 // SRB completed with error
|
||||||
|
|
||||||
|
#define SS_INVALID_CMD 0x80 // Invalid ASPI command
|
||||||
|
#define SS_INVALID_HA 0x81 // Invalid host adapter number
|
||||||
|
#define SS_NO_DEVICE 0x82 // SCSI device not installed
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// %%% Host Adapter Status %%%
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#define HASTAT_OK 0x00 // Host adapter did not detect an // error
|
||||||
|
#define HASTAT_SEL_TO 0x11 // Selection Timeout
|
||||||
|
#define HASTAT_DO_DU 0x12 // Data overrun data underrun
|
||||||
|
#define HASTAT_BUS_FREE 0x13 // Unexpected bus free
|
||||||
|
#define HASTAT_PHASE_ERR 0x14 // Target bus phase sequence // failure
|
||||||
|
#define HASTAT_TIMEOUT 0x09 // Timed out while SRB was waiting to beprocessed.
|
||||||
|
#define HASTAT_COMMAND_TIMEOUT 0x0B // Adapter timed out processing SRB.
|
||||||
|
#define HASTAT_MESSAGE_REJECT 0x0D // While processing SRB, the // adapter received a MESSAGE
|
||||||
|
#define HASTAT_BUS_RESET 0x0E // A bus reset was detected.
|
||||||
|
#define HASTAT_PARITY_ERROR 0x0F // A parity error was detected.
|
||||||
|
#define HASTAT_REQUEST_SENSE_FAILED 0x10 // The adapter failed in issuing
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
BYTE Cmd; // 00/000 ASPI command code = SC_EXEC_SCSI_CMD
|
||||||
|
BYTE Status; // 01/001 ASPI command status byte
|
||||||
|
BYTE HaId; // 02/002 ASPI host adapter number
|
||||||
|
BYTE Flags; // 03/003 ASPI request flags
|
||||||
|
DWORD Hdr_Rsvd; // 04/004 Reserved, MUST = 0
|
||||||
|
|
||||||
|
union {
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
BYTE Count; // 08/008 Number of host adapters present
|
||||||
|
BYTE SCSI_ID; // 09/009 SCSI ID of host adapter
|
||||||
|
BYTE ManagerId[16]; // 0A/010 String describing the manager
|
||||||
|
BYTE Identifier[16]; // 1A/026 String describing the host adapter
|
||||||
|
BYTE Unique[16]; // 2A/042 Host Adapter Unique parameters
|
||||||
|
BYTE ExtBuffer[8]; // 3A/058 Extended inquiry data
|
||||||
|
|
||||||
|
} PACKED HAInquiry;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
BYTE Target; // 08/008 Target's SCSI ID
|
||||||
|
BYTE Lun; // 09/009 Target's LUN number
|
||||||
|
BYTE DeviceType; // 0A/010 Target's peripheral device type
|
||||||
|
|
||||||
|
} PACKED GetDeviceType;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
BYTE Target; // 08/008 Target's SCSI ID
|
||||||
|
BYTE Lun; // 09/009 Target's LUN number
|
||||||
|
DWORD BufLen; // 0A/010 Data Allocation Length
|
||||||
|
BYTE SenseLen; // 0E/014 Sense Allocation Length
|
||||||
|
BYTE FAR *BufPointer; // 0F/015 Data Buffer Pointer
|
||||||
|
DWORD Rsvd1; // 13/019 Reserved, MUST = 0
|
||||||
|
BYTE CDBLen; // 17/023 CDB Length = 6/10/12
|
||||||
|
BYTE HaStat; // 18/024 Host Adapter Status
|
||||||
|
BYTE TargStat; // 19/025 Target Status
|
||||||
|
VOID FAR *PostProc; // 1A/026 Post routine
|
||||||
|
BYTE Rsvd2[34]; // 1E/030 Reserved, MUST = 0
|
||||||
|
|
||||||
|
union {
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
BYTE CDBByte[6]; // 40/064 SCSI CDB
|
||||||
|
BYTE SenseArea[SENSE_LEN+2]; // 46/070 Request Sense buffer
|
||||||
|
|
||||||
|
} PACKED _6;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
BYTE CDBByte[10]; // 40/064 SCSI CDB
|
||||||
|
BYTE SenseArea[SENSE_LEN+2]; // 4A/074 Request Sense buffer
|
||||||
|
|
||||||
|
} PACKED _10;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
BYTE CDBByte[12]; // 40/064 SCSI CDB
|
||||||
|
BYTE SenseArea[SENSE_LEN+2]; // 4C/076 Request Sense buffer
|
||||||
|
|
||||||
|
} PACKED _12;
|
||||||
|
|
||||||
|
} PACKED CmdLen;
|
||||||
|
|
||||||
|
} PACKED ExecSCSICmd;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
VOID FAR *SRBToAbort; // 08/008 Pointer to SRB to abort
|
||||||
|
|
||||||
|
} PACKED Abort;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
BYTE Target; // 08/008 Target's SCSI ID
|
||||||
|
BYTE Lun; // 09/009 Target's LUN number
|
||||||
|
BYTE ResetRsvd1[14]; // 0A/010 Reserved, MUST = 0
|
||||||
|
BYTE HaStat; // 18/024 Host Adapter Status
|
||||||
|
BYTE TargStat; // 19/025 Target Status
|
||||||
|
VOID FAR *PostProc; // 1A/026 Post routine
|
||||||
|
BYTE ResetRsvd2[34]; // 1E/030 Reserved, MUST = 0
|
||||||
|
|
||||||
|
} Reset;
|
||||||
|
|
||||||
|
} PACKED Type;
|
||||||
|
|
||||||
|
} PACKED SRB;
|
||||||
|
|
||||||
|
#endif //__ASPI16_H_
|
196
src/schily/scg/aspi-win32.h
Normal file
196
src/schily/scg/aspi-win32.h
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
#ifndef __ASPI_WIN32_H_
|
||||||
|
#define __ASPI_WIN32_H_
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** SCSI MISCELLANEOUS EQUATES
|
||||||
|
***************************************************************************/
|
||||||
|
#define SENSE_LEN 14 /* Default sense buffer length */
|
||||||
|
#define SRB_DIR_SCSI 0x00 /* Direction determined by SCSI */
|
||||||
|
#define SRB_POSTING 0x01 /* Enable ASPI posting */
|
||||||
|
#define SRB_ENABLE_RESIDUAL_COUNT 0x04 /* Enable residual byte count */
|
||||||
|
/* reporting */
|
||||||
|
#define SRB_DIR_IN 0x08 /* Transfer from SCSI target to */
|
||||||
|
/* host */
|
||||||
|
#define SRB_DIR_OUT 0x10 /* Transfer from host to SCSI */
|
||||||
|
/* target */
|
||||||
|
#define SRB_EVENT_NOTIFY 0x40 /* Enable ASPI event notification */
|
||||||
|
#define RESIDUAL_COUNT_SUPPORTED 0x02 /* Extended buffer flag */
|
||||||
|
#define MAX_SRB_TIMEOUT 1080001u /* 30 hour maximum timeout in sec */
|
||||||
|
#define DEFAULT_SRB_TIMEOUT 1080001u /* use max.timeout by default */
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** ASPI command definitions
|
||||||
|
***************************************************************************/
|
||||||
|
#define SC_HA_INQUIRY 0x00 /* Host adapter inquiry */
|
||||||
|
#define SC_GET_DEV_TYPE 0x01 /* Get device type */
|
||||||
|
#define SC_EXEC_SCSI_CMD 0x02 /* Execute SCSI command */
|
||||||
|
#define SC_ABORT_SRB 0x03 /* Abort an SRB */
|
||||||
|
#define SC_RESET_DEV 0x04 /* SCSI bus device reset */
|
||||||
|
#define SC_SET_HA_PARMS 0x05 /* Set HA parameters */
|
||||||
|
#define SC_GET_DISK_INFO 0x06 /* Get Disk */
|
||||||
|
#define SC_RESCAN_SCSI_BUS 0x07 /* Rebuild SCSI device map */
|
||||||
|
#define SC_GETSET_TIMEOUTS 0x08 /* Get/Set target timeouts */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** SRB Status
|
||||||
|
***************************************************************************/
|
||||||
|
#define SS_PENDING 0x00 /* SRB being processed */
|
||||||
|
#define SS_COMP 0x01 /* SRB completed without error */
|
||||||
|
#define SS_ABORTED 0x02 /* SRB aborted */
|
||||||
|
#define SS_ABORT_FAIL 0x03 /* Unable to abort SRB */
|
||||||
|
#define SS_ERR 0x04 /* SRB completed with error */
|
||||||
|
#define SS_INVALID_CMD 0x80 /* Invalid ASPI command */
|
||||||
|
#define SS_INVALID_HA 0x81 /* Invalid host adapter number */
|
||||||
|
#define SS_NO_DEVICE 0x82 /* SCSI device not installed */
|
||||||
|
#define SS_INVALID_SRB 0xE0 /* Invalid parameter set in SRB */
|
||||||
|
#define SS_OLD_MANAGER 0xE1 /* ASPI manager doesn't support */
|
||||||
|
/* windows */
|
||||||
|
#define SS_BUFFER_ALIGN 0xE1 /* Buffer not aligned (replaces */
|
||||||
|
/* SS_OLD_MANAGER in Win32) */
|
||||||
|
#define SS_ILLEGAL_MODE 0xE2 /* Unsupported Windows mode */
|
||||||
|
#define SS_NO_ASPI 0xE3 /* No ASPI managers */
|
||||||
|
#define SS_FAILED_INIT 0xE4 /* ASPI for windows failed init */
|
||||||
|
#define SS_ASPI_IS_BUSY 0xE5 /* No resources available to */
|
||||||
|
/* execute command */
|
||||||
|
#define SS_BUFFER_TO_BIG 0xE6 /* Buffer size too big to handle */
|
||||||
|
#define SS_BUFFER_TOO_BIG 0xE6 /* Correct spelling of 'too' */
|
||||||
|
#define SS_MISMATCHED_COMPONENTS 0xE7 /* The DLLs/EXEs of ASPI don't */
|
||||||
|
/* version check */
|
||||||
|
#define SS_NO_ADAPTERS 0xE8 /* No host adapters to manager */
|
||||||
|
#define SS_INSUFFICIENT_RESOURCES 0xE9 /* Couldn't allocate resources */
|
||||||
|
/* needed to init */
|
||||||
|
#define SS_ASPI_IS_SHUTDOWN 0xEA /* Call came to ASPI after */
|
||||||
|
/* PROCESS_DETACH */
|
||||||
|
#define SS_BAD_INSTALL 0xEB /* The DLL or other components */
|
||||||
|
/* are installed wrong */
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** Host Adapter Status
|
||||||
|
***************************************************************************/
|
||||||
|
#define HASTAT_OK 0x00 /* No error detected by HA */
|
||||||
|
#define HASTAT_SEL_TO 0x11 /* Selection Timeout */
|
||||||
|
#define HASTAT_DO_DU 0x12 /* Data overrun/data underrun */
|
||||||
|
#define HASTAT_BUS_FREE 0x13 /* Unexpected bus free */
|
||||||
|
#define HASTAT_PHASE_ERR 0x14 /* Target bus phase sequence */
|
||||||
|
#define HASTAT_TIMEOUT 0x09 /* Timed out while SRB was */
|
||||||
|
/* waiting to be processed */
|
||||||
|
#define HASTAT_COMMAND_TIMEOUT 0x0B /* Adapter timed out while */
|
||||||
|
/* processing SRB */
|
||||||
|
#define HASTAT_MESSAGE_REJECT 0x0D /* While processing the SRB, the */
|
||||||
|
/* adapter received a MESSAGE */
|
||||||
|
#define HASTAT_BUS_RESET 0x0E /* A bus reset was detected */
|
||||||
|
#define HASTAT_PARITY_ERROR 0x0F /* A parity error was detected */
|
||||||
|
#define HASTAT_REQUEST_SENSE_FAILED 0x10 /* The adapter failed in issuing */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** SRB - HOST ADAPTER INQUIRIY - SC_HA_INQUIRY (0)
|
||||||
|
***************************************************************************/
|
||||||
|
typedef struct {
|
||||||
|
BYTE SRB_Cmd; /* 00/000 ASPI command code == SC_HA_INQUIRY */
|
||||||
|
BYTE SRB_Status; /* 01/001 ASPI command status byte */
|
||||||
|
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
|
||||||
|
BYTE SRB_Flags; /* 03/003 ASPI request flags */
|
||||||
|
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
|
||||||
|
BYTE HA_Count; /* 08/008 Number of host adapters present */
|
||||||
|
BYTE HA_SCSI_ID; /* 09/009 SCSI ID of host adapter */
|
||||||
|
BYTE HA_ManagerId[16]; /* 0a/010 String describing the manager */
|
||||||
|
BYTE HA_Identifier[16]; /* 1a/026 String describing the host adapter */
|
||||||
|
BYTE HA_Unique[16]; /* 2a/042 Host Adapter Unique parameters */
|
||||||
|
WORD HA_Rsvd1; /* 3a/058 Reserved, must = 0 */
|
||||||
|
} PACKED SRB_HAInquiry, *PSRB_HAInquiry, FAR *LPSRB_HAInquiry;
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE (1)
|
||||||
|
***************************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_GET_DEV_TYPE */
|
||||||
|
BYTE SRB_Status; /* 01/001 ASPI command status byte */
|
||||||
|
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
|
||||||
|
BYTE SRB_Flags; /* 03/003 Reserved, must = 0 */
|
||||||
|
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
|
||||||
|
BYTE SRB_Target; /* 08/008 Target's SCSI ID */
|
||||||
|
BYTE SRB_Lun; /* 09/009 Target's LUN number */
|
||||||
|
BYTE SRB_DeviceType; /* 0a/010 Target's peripheral device type */
|
||||||
|
BYTE SRB_Rsvd1; /* 0b/011 Reserved, must = 0 */
|
||||||
|
} PACKED SRB_GDEVBlock, *PSRB_GDEVBlock, FAR *LPSRB_GDEVBlock;
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD (2)
|
||||||
|
***************************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_EXEC_SCSI_CMD */
|
||||||
|
BYTE SRB_Status; /* 01/001 ASPI command status byte */
|
||||||
|
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
|
||||||
|
BYTE SRB_Flags; /* 03/003 Reserved, must = 0 */
|
||||||
|
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
|
||||||
|
BYTE SRB_Target; /* 08/008 Target's SCSI ID */
|
||||||
|
BYTE SRB_Lun; /* 09/009 Target's LUN */
|
||||||
|
WORD SRB_Rsvd1; /* 0a/010 Reserved for alignment */
|
||||||
|
DWORD SRB_BufLen; /* 0c/012 Data Allocation Length */
|
||||||
|
BYTE FAR *SRB_BufPointer; /* 10/016 Data Buffer Pointer */
|
||||||
|
BYTE SRB_SenseLen; /* 14/020 Sense Allocation Length */
|
||||||
|
BYTE SRB_CDBLen; /* 15/021 CDB Length */
|
||||||
|
BYTE SRB_HaStat; /* 16/022 Host Adapter Status */
|
||||||
|
BYTE SRB_TargStat; /* 17/023 Target Status */
|
||||||
|
VOID FAR *SRB_PostProc; /* 18/024 Post routine */
|
||||||
|
BYTE SRB_Rsvd2[20]; /* 1c/028 Reserved, must = 0 */
|
||||||
|
BYTE CDBByte[16]; /* 30/048 SCSI CDB */
|
||||||
|
BYTE SenseArea[SENSE_LEN+2]; /* 40/064 Request Sense buffer */
|
||||||
|
} PACKED SRB_ExecSCSICmd, *PSRB_ExecSCSICmd, FAR *LPSRB_ExecSCSICmd;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_ABORT_SRB */
|
||||||
|
BYTE SRB_Status; /* 01/001 ASPI command status byte */
|
||||||
|
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
|
||||||
|
BYTE SRB_Flags; /* 03/003 Reserved, must = 0 */
|
||||||
|
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
|
||||||
|
void *SRB_ToAbort; /* 08/008 Pointer to SRB to abort */
|
||||||
|
} PACKED SRB_Abort, *PSRB_Abort, FAR *LPSRB_Abort;
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** SRB - BUS DEVICE RESET - SC_RESET_DEV (4)
|
||||||
|
***************************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_RESET_DEV */
|
||||||
|
BYTE SRB_Status; /* 01/001 ASPI command status byte */
|
||||||
|
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
|
||||||
|
DWORD SRB_Flags; /* 04/004 Reserved */
|
||||||
|
BYTE SRB_Target; /* 08/008 Target's SCSI ID */
|
||||||
|
BYTE SRB_Lun; /* 09/009 Target's LUN number */
|
||||||
|
BYTE SRB_Rsvd1[12]; /* 0A/010 Reserved for alignment */
|
||||||
|
BYTE SRB_HaStat; /* 16/022 Host Adapter Status */
|
||||||
|
BYTE SRB_TargStat; /* 17/023 Target Status */
|
||||||
|
VOID FAR *SRB_PostProc; /* 18/024 Post routine */
|
||||||
|
BYTE SRB_Rsvd2[36]; /* 1C/028 Reserved, must = 0 */
|
||||||
|
} SRB_BusDeviceReset, *PSRB_BusDeviceReset, FAR *LPSRB_BusDeviceReset;
|
||||||
|
|
||||||
|
typedef struct tag_ASPI32BUFF
|
||||||
|
{
|
||||||
|
PBYTE AB_BufPointer;
|
||||||
|
DWORD AB_BufLen;
|
||||||
|
DWORD AB_ZeroFill;
|
||||||
|
DWORD AB_Reserved;
|
||||||
|
} PACKED ASPI32BUFF, *PASPI32BUFF, FAR *LPASPI32BUFF;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BYTE SRB_Cmd;
|
||||||
|
BYTE SRB_Status;
|
||||||
|
BYTE SRB_HaId;
|
||||||
|
BYTE SRB_Flags;
|
||||||
|
DWORD SRB_Hdr_Rsvd;
|
||||||
|
} SRB, *PSRB, FAR *LPSRB;
|
||||||
|
|
||||||
|
#endif
|
200
src/schily/scg/scgcmd.h
Normal file
200
src/schily/scg/scgcmd.h
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
/* @(#)scgcmd.h 2.22 04/09/04 Copyright 1986 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for the SCSI 'scg_cmd' structure that has been created
|
||||||
|
* for the SCSI general driver 'scg' for SunOS and Solaris but
|
||||||
|
* now is used for wrapping general libscg SCSI transport requests.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1986 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SCG_SCGCMD_H
|
||||||
|
#define _SCG_SCGCMD_H
|
||||||
|
|
||||||
|
#include <utypes.h>
|
||||||
|
#include <btorder.h>
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
|
||||||
|
#else
|
||||||
|
# if defined(_BIT_FIELDS_HTOL) /* Motorola byteorder */
|
||||||
|
# else
|
||||||
|
/*
|
||||||
|
* #error will not work for all compilers (e.g. sunos4)
|
||||||
|
* The following line will abort compilation on all compilers
|
||||||
|
* if none of the above is defines. And that's what we want.
|
||||||
|
*/
|
||||||
|
error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <scg/scsisense.h>
|
||||||
|
#include <scg/scsicdb.h>
|
||||||
|
#include <intcvt.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Leave these definitions here if possible to avoid the need to
|
||||||
|
* include scsireg.h which makes problems on some OS because these
|
||||||
|
* OS define the same types as in scsireg.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SCSI status bits.
|
||||||
|
*/
|
||||||
|
#define ST_VU_00 0x01 /* Vendor unique */
|
||||||
|
#define ST_CHK_COND 0x02 /* Check condition */
|
||||||
|
#define ST_COND_MET 0x04 /* Condition met */
|
||||||
|
#define ST_BUSY 0x08 /* Busy */
|
||||||
|
#define ST_IS_SEND 0x10 /* Intermediate status send */
|
||||||
|
#define ST_VU_05 0x20 /* Vendor unique */
|
||||||
|
#define ST_VU_06 0x40 /* Vendor unique */
|
||||||
|
#define ST_RSVD_07 0x80 /* Reserved */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sense key values for extended sense.
|
||||||
|
*/
|
||||||
|
#define SC_NO_SENSE 0x00
|
||||||
|
#define SC_RECOVERABLE_ERROR 0x01
|
||||||
|
#define SC_NOT_READY 0x02
|
||||||
|
#define SC_MEDIUM_ERROR 0x03
|
||||||
|
#define SC_HARDWARE_ERROR 0x04
|
||||||
|
#define SC_ILLEGAL_REQUEST 0x05
|
||||||
|
#define SC_UNIT_ATTENTION 0x06
|
||||||
|
#define SC_WRITE_PROTECT 0x07
|
||||||
|
#define SC_BLANK_CHECK 0x08
|
||||||
|
#define SC_VENDOR_UNIQUE 0x09
|
||||||
|
#define SC_COPY_ABORTED 0x0A
|
||||||
|
#define SC_ABORTED_COMMAND 0x0B
|
||||||
|
#define SC_EQUAL 0x0C
|
||||||
|
#define SC_VOLUME_OVERFLOW 0x0D
|
||||||
|
#define SC_MISCOMPARE 0x0E
|
||||||
|
#define SC_RESERVED 0x0F
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Messages that SCSI can send.
|
||||||
|
*/
|
||||||
|
#define SC_COMMAND_COMPLETE 0x00
|
||||||
|
#define SC_SYNCHRONOUS 0x01
|
||||||
|
#define SC_SAVE_DATA_PTR 0x02
|
||||||
|
#define SC_RESTORE_PTRS 0x03
|
||||||
|
#define SC_DISCONNECT 0x04
|
||||||
|
#define SC_ABORT 0x06
|
||||||
|
#define SC_MSG_REJECT 0x07
|
||||||
|
#define SC_NO_OP 0x08
|
||||||
|
#define SC_PARITY 0x09
|
||||||
|
#define SC_IDENTIFY 0x80
|
||||||
|
#define SC_DR_IDENTIFY 0xc0
|
||||||
|
#define SC_DEVICE_RESET 0x0c
|
||||||
|
|
||||||
|
#define SC_G0_CDBLEN 6 /* Len of Group 0 commands */
|
||||||
|
#define SC_G1_CDBLEN 10 /* Len of Group 1 commands */
|
||||||
|
#define SC_G5_CDBLEN 12 /* Len of Group 5 commands */
|
||||||
|
|
||||||
|
#define SCG_MAX_CMD 24 /* 24 bytes max. size is supported */
|
||||||
|
#define SCG_MAX_STATUS 3 /* XXX (sollte 4 allign.) Mamimum Status Len */
|
||||||
|
#define SCG_MAX_SENSE 32 /* Mamimum Sense Len for auto Req. Sense */
|
||||||
|
|
||||||
|
#define DEF_SENSE_LEN 16 /* Default Sense Len */
|
||||||
|
#define CCS_SENSE_LEN 18 /* Sense Len for CCS compatible devices */
|
||||||
|
|
||||||
|
struct scg_cmd {
|
||||||
|
caddr_t addr; /* Address of data in user space */
|
||||||
|
int size; /* DMA count for data transfer */
|
||||||
|
int flags; /* see below for definition */
|
||||||
|
int cdb_len; /* Size of SCSI command in bytes */
|
||||||
|
/* NOTE: rel 4 uses this field only */
|
||||||
|
/* with commands not in group 1 or 2*/
|
||||||
|
int sense_len; /* for intr() if -1 don't get sense */
|
||||||
|
int timeout; /* timeout in seconds */
|
||||||
|
/* NOTE: actual resolution depends */
|
||||||
|
/* on driver implementation */
|
||||||
|
int kdebug; /* driver kernel debug level */
|
||||||
|
int resid; /* Bytes not transfered */
|
||||||
|
int error; /* Error code from scgintr() */
|
||||||
|
int ux_errno; /* UNIX error code */
|
||||||
|
#ifdef comment
|
||||||
|
XXX struct scsi_status scb; ??? /* Status returnd by command */
|
||||||
|
#endif
|
||||||
|
union {
|
||||||
|
struct scsi_status Scb; /* Status returnd by command */
|
||||||
|
Uchar cmd_scb[SCG_MAX_STATUS];
|
||||||
|
} u_scb;
|
||||||
|
#define scb u_scb.Scb
|
||||||
|
#ifdef comment
|
||||||
|
XXX struct scsi_sense sense; ??? /* Sense bytes from command */
|
||||||
|
#endif
|
||||||
|
union {
|
||||||
|
struct scsi_sense Sense; /* Sense bytes from command */
|
||||||
|
Uchar cmd_sense[SCG_MAX_SENSE];
|
||||||
|
} u_sense;
|
||||||
|
#define sense u_sense.Sense
|
||||||
|
int sense_count; /* Number of bytes valid in sense */
|
||||||
|
int target; /* SCSI target id */
|
||||||
|
/* NOTE: The SCSI target id field */
|
||||||
|
/* does not need to be filled unless */
|
||||||
|
/* the low level transport is a real */
|
||||||
|
/* scg driver. In this case the low */
|
||||||
|
/* level transport routine of libscg */
|
||||||
|
/* will fill in the needed value */
|
||||||
|
union { /* SCSI command descriptor block */
|
||||||
|
struct scsi_g0cdb g0_cdb;
|
||||||
|
struct scsi_g1cdb g1_cdb;
|
||||||
|
struct scsi_g5cdb g5_cdb;
|
||||||
|
Uchar cmd_cdb[SCG_MAX_CMD];
|
||||||
|
} cdb; /* 24 bytes max. size is supported */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define dma_read flags /* 1 if DMA to Sun, 0 otherwise */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* definition for flags field in scg_cmd struct
|
||||||
|
*/
|
||||||
|
#define SCG_RECV_DATA 0x0001 /* DMA direction to Sun */
|
||||||
|
#define SCG_DISRE_ENA 0x0002 /* enable disconnect/reconnect */
|
||||||
|
#define SCG_SILENT 0x0004 /* be silent on errors */
|
||||||
|
#define SCG_CMD_RETRY 0x0008 /* enable retries */
|
||||||
|
#define SCG_NOPARITY 0x0010 /* disable parity for this command */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* definition for error field in scg_cmd struct
|
||||||
|
*
|
||||||
|
* The codes refer to SCSI general errors, not to device
|
||||||
|
* specific errors. Device specific errors are discovered
|
||||||
|
* by checking the sense data.
|
||||||
|
* The distinction between retryable and fatal is somewhat ad hoc.
|
||||||
|
*/
|
||||||
|
#define SCG_NO_ERROR 0 /* cdb transported without error */
|
||||||
|
/* SCG_NO_ERROR incudes all commands */
|
||||||
|
/* where the SCSI status is valid */
|
||||||
|
|
||||||
|
#define SCG_RETRYABLE 1 /* any other case e.g. SCSI bus busy */
|
||||||
|
/* SCSI cdb could not be send, */
|
||||||
|
/* includes DMA errors other than */
|
||||||
|
/* DMA underrun */
|
||||||
|
|
||||||
|
#define SCG_FATAL 2 /* could not select target */
|
||||||
|
#define SCG_TIMEOUT 3 /* driver timed out */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCG_SCGCMD_H */
|
68
src/schily/scg/scgio.h
Normal file
68
src/schily/scg/scgio.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/* @(#)scgio.h 2.16 00/11/07 Copyright 1986 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for the SCSI general driver 'scg'
|
||||||
|
*
|
||||||
|
* Copyright (c) 1986 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SCG_SCGIO_H
|
||||||
|
#define _SCG_SCGIO_H
|
||||||
|
|
||||||
|
#ifndef _SCG_SCGCMD_H
|
||||||
|
#include <scg/scgcmd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SVR4)
|
||||||
|
#include <sys/ioccom.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__STDC__) || defined(SVR4)
|
||||||
|
#define SCGIOCMD _IOWR('G', 1, struct scg_cmd) /* do a SCSI cmd */
|
||||||
|
#define SCGIORESET _IO('G', 2) /* reset SCSI bus */
|
||||||
|
#define SCGIOGDISRE _IOR('G', 4, int) /* get sc disre Val*/
|
||||||
|
#define SCGIOSDISRE _IOW('G', 5, int) /* set sc disre Val*/
|
||||||
|
#define SCGIOIDBG _IO('G', 100) /* Inc Debug Val */
|
||||||
|
#define SCGIODDBG _IO('G', 101) /* Dec Debug Val */
|
||||||
|
#define SCGIOGDBG _IOR('G', 102, int) /* get Debug Val */
|
||||||
|
#define SCGIOSDBG _IOW('G', 103, int) /* set Debug Val */
|
||||||
|
#define SCIOGDBG _IOR('G', 104, int) /* get sc Debug Val*/
|
||||||
|
#define SCIOSDBG _IOW('G', 105, int) /* set sc Debug Val*/
|
||||||
|
#else
|
||||||
|
#define SCGIOCMD _IOWR(G, 1, struct scg_cmd) /* do a SCSI cmd */
|
||||||
|
#define SCGIORESET _IO(G, 2) /* reset SCSI bus */
|
||||||
|
#define SCGIOGDISRE _IOR(G, 4, int) /* get sc disre Val*/
|
||||||
|
#define SCGIOSDISRE _IOW(G, 5, int) /* set sc disre Val*/
|
||||||
|
#define SCGIOIDBG _IO(G, 100) /* Inc Debug Val */
|
||||||
|
#define SCGIODDBG _IO(G, 101) /* Dec Debug Val */
|
||||||
|
#define SCGIOGDBG _IOR(G, 102, int) /* get Debug Val */
|
||||||
|
#define SCGIOSDBG _IOW(G, 103, int) /* set Debug Val */
|
||||||
|
#define SCIOGDBG _IOR(G, 104, int) /* get sc Debug Val*/
|
||||||
|
#define SCIOSDBG _IOW(G, 105, int) /* set sc Debug Val*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SCGIO_CMD SCGIOCMD /* backward ccompatibility */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCG_SCGIO_H */
|
69
src/schily/scg/scgops.h
Normal file
69
src/schily/scg/scgops.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* @(#)scgops.h 1.5 02/10/19 Copyright 2000 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2000 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SCG_SCGOPS_H
|
||||||
|
#define _SCG_SCGOPS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct scg_ops {
|
||||||
|
int (*scgo_send) __PR((SCSI *scgp));
|
||||||
|
|
||||||
|
char * (*scgo_version) __PR((SCSI *scgp, int what));
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
int (*scgo_help) __PR((SCSI *scgp, FILE *f));
|
||||||
|
#else
|
||||||
|
int (*scgo_help) __PR((SCSI *scgp, void *f));
|
||||||
|
#endif
|
||||||
|
int (*scgo_open) __PR((SCSI *scgp, char *device));
|
||||||
|
int (*scgo_close) __PR((SCSI *scgp));
|
||||||
|
long (*scgo_maxdma) __PR((SCSI *scgp, long amt));
|
||||||
|
void * (*scgo_getbuf) __PR((SCSI *scgp, long amt));
|
||||||
|
void (*scgo_freebuf) __PR((SCSI *scgp));
|
||||||
|
|
||||||
|
|
||||||
|
BOOL (*scgo_havebus) __PR((SCSI *scgp, int busno));
|
||||||
|
int (*scgo_fileno) __PR((SCSI *scgp, int busno, int tgt, int tlun));
|
||||||
|
int (*scgo_initiator_id) __PR((SCSI *scgp));
|
||||||
|
int (*scgo_isatapi) __PR((SCSI *scgp));
|
||||||
|
int (*scgo_reset) __PR((SCSI *scgp, int what));
|
||||||
|
} scg_ops_t;
|
||||||
|
|
||||||
|
#define SCGO_SEND(scgp) (*(scgp)->ops->scgo_send)(scgp)
|
||||||
|
#define SCGO_VERSION(scgp, what) (*(scgp)->ops->scgo_version)(scgp, what)
|
||||||
|
#define SCGO_HELP(scgp, f) (*(scgp)->ops->scgo_help)(scgp, f)
|
||||||
|
#define SCGO_OPEN(scgp, device) (*(scgp)->ops->scgo_open)(scgp, device)
|
||||||
|
#define SCGO_CLOSE(scgp) (*(scgp)->ops->scgo_close)(scgp)
|
||||||
|
#define SCGO_MAXDMA(scgp, amt) (*(scgp)->ops->scgo_maxdma)(scgp, amt)
|
||||||
|
#define SCGO_GETBUF(scgp, amt) (*(scgp)->ops->scgo_getbuf)(scgp, amt)
|
||||||
|
#define SCGO_FREEBUF(scgp) (*(scgp)->ops->scgo_freebuf)(scgp)
|
||||||
|
#define SCGO_HAVEBUS(scgp, busno) (*(scgp)->ops->scgo_havebus)(scgp, busno)
|
||||||
|
#define SCGO_FILENO(scgp, busno, tgt, tlun) (*(scgp)->ops->scgo_fileno)(scgp, busno, tgt, tlun)
|
||||||
|
#define SCGO_INITIATOR_ID(scgp) (*(scgp)->ops->scgo_initiator_id)(scgp)
|
||||||
|
#define SCGO_ISATAPI(scgp) (*(scgp)->ops->scgo_isatapi)(scgp)
|
||||||
|
#define SCGO_RESET(scgp, what) (*(scgp)->ops->scgo_reset)(scgp, what)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCG_SCGOPS_H */
|
249
src/schily/scg/scsicdb.h
Normal file
249
src/schily/scg/scsicdb.h
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
/* @(#)scsicdb.h 2.19 04/09/04 Copyright 1986 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for the SCSI Command Descriptor Block
|
||||||
|
*
|
||||||
|
* Copyright (c) 1986 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SCG_SCSICDB_H
|
||||||
|
#define _SCG_SCSICDB_H
|
||||||
|
|
||||||
|
#ifndef _UTYPES_H
|
||||||
|
#include <utypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* SCSI Operation codes.
|
||||||
|
*/
|
||||||
|
#define SC_TEST_UNIT_READY 0x00
|
||||||
|
#define SC_REZERO_UNIT 0x01
|
||||||
|
#define SC_REQUEST_SENSE 0x03
|
||||||
|
#define SC_FORMAT 0x04
|
||||||
|
#define SC_FORMAT_TRACK 0x06
|
||||||
|
#define SC_REASSIGN_BLOCK 0x07 /* CCS only */
|
||||||
|
#define SC_SEEK 0x0b
|
||||||
|
#define SC_TRANSLATE 0x0f /* ACB4000 only */
|
||||||
|
#define SC_INQUIRY 0x12 /* CCS only */
|
||||||
|
#define SC_MODE_SELECT 0x15
|
||||||
|
#define SC_RESERVE 0x16
|
||||||
|
#define SC_RELEASE 0x17
|
||||||
|
#define SC_MODE_SENSE 0x1a
|
||||||
|
#define SC_START 0x1b
|
||||||
|
#define SC_READ_DEFECT_LIST 0x37 /* CCS only, group 1 */
|
||||||
|
#define SC_READ_BUFFER 0x3c /* CCS only, group 1 */
|
||||||
|
/*
|
||||||
|
* Note, these two commands use identical command blocks for all
|
||||||
|
* controllers except the Adaptec ACB 4000 which sets bit 1 of byte 1.
|
||||||
|
*/
|
||||||
|
#define SC_READ 0x08
|
||||||
|
#define SC_WRITE 0x0a
|
||||||
|
#define SC_EREAD 0x28 /* 10 byte read */
|
||||||
|
#define SC_EWRITE 0x2a /* 10 byte write */
|
||||||
|
#define SC_WRITE_VERIFY 0x2e /* 10 byte write+verify */
|
||||||
|
#define SC_WRITE_FILE_MARK 0x10
|
||||||
|
#define SC_UNKNOWN 0xff /* cmd list terminator */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Standard SCSI control blocks.
|
||||||
|
* These go in or out over the SCSI bus.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
|
||||||
|
|
||||||
|
struct scsi_g0cdb { /* scsi group 0 command description block */
|
||||||
|
Uchar cmd; /* command code */
|
||||||
|
Ucbit high_addr : 5; /* high part of block address */
|
||||||
|
Ucbit lun : 3; /* logical unit number */
|
||||||
|
Uchar mid_addr; /* middle part of block address */
|
||||||
|
Uchar low_addr; /* low part of block address */
|
||||||
|
Uchar count; /* transfer length */
|
||||||
|
Ucbit link : 1; /* link (another command follows) */
|
||||||
|
Ucbit fr : 1; /* flag request (interrupt at completion) */
|
||||||
|
Ucbit naca : 1; /* Normal ACA (Auto Contingent Allegiance) */
|
||||||
|
Ucbit rsvd : 3; /* reserved */
|
||||||
|
Ucbit vu_56 : 1; /* vendor unique (byte 5 bit 6) */
|
||||||
|
Ucbit vu_57 : 1; /* vendor unique (byte 5 bit 7) */
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
|
||||||
|
struct scsi_g0cdb { /* scsi group 0 command description block */
|
||||||
|
Uchar cmd; /* command code */
|
||||||
|
Ucbit lun : 3; /* logical unit number */
|
||||||
|
Ucbit high_addr : 5; /* high part of block address */
|
||||||
|
Uchar mid_addr; /* middle part of block address */
|
||||||
|
Uchar low_addr; /* low part of block address */
|
||||||
|
Uchar count; /* transfer length */
|
||||||
|
Ucbit vu_57 : 1; /* vendor unique (byte 5 bit 7) */
|
||||||
|
Ucbit vu_56 : 1; /* vendor unique (byte 5 bit 6) */
|
||||||
|
Ucbit rsvd : 3; /* reserved */
|
||||||
|
Ucbit naca : 1; /* Normal ACA (Auto Contingent Allegiance) */
|
||||||
|
Ucbit fr : 1; /* flag request (interrupt at completion) */
|
||||||
|
Ucbit link : 1; /* link (another command follows) */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
|
||||||
|
|
||||||
|
struct scsi_g1cdb { /* scsi group 1 command description block */
|
||||||
|
Uchar cmd; /* command code */
|
||||||
|
Ucbit reladr : 1; /* address is relative */
|
||||||
|
Ucbit res : 4; /* reserved bits 1-4 of byte 1 */
|
||||||
|
Ucbit lun : 3; /* logical unit number */
|
||||||
|
Uchar addr[4]; /* logical block address */
|
||||||
|
Uchar res6; /* reserved byte 6 */
|
||||||
|
Uchar count[2]; /* transfer length */
|
||||||
|
Ucbit link : 1; /* link (another command follows) */
|
||||||
|
Ucbit fr : 1; /* flag request (interrupt at completion) */
|
||||||
|
Ucbit naca : 1; /* Normal ACA (Auto Contingent Allegiance) */
|
||||||
|
Ucbit rsvd : 3; /* reserved */
|
||||||
|
Ucbit vu_96 : 1; /* vendor unique (byte 5 bit 6) */
|
||||||
|
Ucbit vu_97 : 1; /* vendor unique (byte 5 bit 7) */
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
|
||||||
|
struct scsi_g1cdb { /* scsi group 1 command description block */
|
||||||
|
Uchar cmd; /* command code */
|
||||||
|
Ucbit lun : 3; /* logical unit number */
|
||||||
|
Ucbit res : 4; /* reserved bits 1-4 of byte 1 */
|
||||||
|
Ucbit reladr : 1; /* address is relative */
|
||||||
|
Uchar addr[4]; /* logical block address */
|
||||||
|
Uchar res6; /* reserved byte 6 */
|
||||||
|
Uchar count[2]; /* transfer length */
|
||||||
|
Ucbit vu_97 : 1; /* vendor unique (byte 5 bit 7) */
|
||||||
|
Ucbit vu_96 : 1; /* vendor unique (byte 5 bit 6) */
|
||||||
|
Ucbit rsvd : 3; /* reserved */
|
||||||
|
Ucbit naca : 1; /* Normal ACA (Auto Contingent Allegiance) */
|
||||||
|
Ucbit fr : 1; /* flag request (interrupt at completion) */
|
||||||
|
Ucbit link : 1; /* link (another command follows) */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
|
||||||
|
|
||||||
|
struct scsi_g5cdb { /* scsi group 5 command description block */
|
||||||
|
Uchar cmd; /* command code */
|
||||||
|
Ucbit reladr : 1; /* address is relative */
|
||||||
|
Ucbit res : 4; /* reserved bits 1-4 of byte 1 */
|
||||||
|
Ucbit lun : 3; /* logical unit number */
|
||||||
|
Uchar addr[4]; /* logical block address */
|
||||||
|
Uchar count[4]; /* transfer length */
|
||||||
|
Uchar res10; /* reserved byte 10 */
|
||||||
|
Ucbit link : 1; /* link (another command follows) */
|
||||||
|
Ucbit fr : 1; /* flag request (interrupt at completion) */
|
||||||
|
Ucbit naca : 1; /* Normal ACA (Auto Contingent Allegiance) */
|
||||||
|
Ucbit rsvd : 3; /* reserved */
|
||||||
|
Ucbit vu_B6 : 1; /* vendor unique (byte B bit 6) */
|
||||||
|
Ucbit vu_B7 : 1; /* vendor unique (byte B bit 7) */
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
|
||||||
|
struct scsi_g5cdb { /* scsi group 5 command description block */
|
||||||
|
Uchar cmd; /* command code */
|
||||||
|
Ucbit lun : 3; /* logical unit number */
|
||||||
|
Ucbit res : 4; /* reserved bits 1-4 of byte 1 */
|
||||||
|
Ucbit reladr : 1; /* address is relative */
|
||||||
|
Uchar addr[4]; /* logical block address */
|
||||||
|
Uchar count[4]; /* transfer length */
|
||||||
|
Uchar res10; /* reserved byte 10 */
|
||||||
|
Ucbit vu_B7 : 1; /* vendor unique (byte B bit 7) */
|
||||||
|
Ucbit vu_B6 : 1; /* vendor unique (byte B bit 6) */
|
||||||
|
Ucbit rsvd : 3; /* reserved */
|
||||||
|
Ucbit naca : 1; /* Normal ACA (Auto Contingent Allegiance) */
|
||||||
|
Ucbit fr : 1; /* flag request (interrupt at completion) */
|
||||||
|
Ucbit link : 1; /* link (another command follows) */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define g0_cdbaddr(cdb, a) ((cdb)->high_addr = (a) >> 16,\
|
||||||
|
(cdb)->mid_addr = ((a) >> 8) & 0xFF,\
|
||||||
|
(cdb)->low_addr = (a) & 0xFF)
|
||||||
|
|
||||||
|
#define g1_cdbaddr(cdb, a) ((cdb)->addr[0] = (a) >> 24,\
|
||||||
|
(cdb)->addr[1] = ((a) >> 16)& 0xFF,\
|
||||||
|
(cdb)->addr[2] = ((a) >> 8) & 0xFF,\
|
||||||
|
(cdb)->addr[3] = (a) & 0xFF)
|
||||||
|
|
||||||
|
#define g5_cdbaddr(cdb, a) g1_cdbaddr(cdb, a)
|
||||||
|
|
||||||
|
|
||||||
|
#define g0_cdblen(cdb, len) ((cdb)->count = (len))
|
||||||
|
|
||||||
|
#define g1_cdblen(cdb, len) ((cdb)->count[0] = ((len) >> 8) & 0xFF,\
|
||||||
|
(cdb)->count[1] = (len) & 0xFF)
|
||||||
|
|
||||||
|
#define g5_cdblen(cdb, len) ((cdb)->count[0] = (len) >> 24L,\
|
||||||
|
(cdb)->count[1] = ((len) >> 16L)& 0xFF,\
|
||||||
|
(cdb)->count[2] = ((len) >> 8L) & 0xFF,\
|
||||||
|
(cdb)->count[3] = (len) & 0xFF)
|
||||||
|
|
||||||
|
/*#define XXXXX*/
|
||||||
|
#ifdef XXXXX
|
||||||
|
#define i_to_long(a, i) (((Uchar *)(a))[0] = ((i) >> 24)& 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = ((i) >> 16)& 0xFF,\
|
||||||
|
((Uchar *)(a))[2] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[3] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define i_to_3_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 16)& 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[2] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define i_to_4_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 24)& 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = ((i) >> 16)& 0xFF,\
|
||||||
|
((Uchar *)(a))[2] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[3] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define i_to_short(a, i) (((Uchar *)(a))[0] = ((i) >> 8) & 0xFF,\
|
||||||
|
((Uchar *)(a))[1] = (i) & 0xFF)
|
||||||
|
|
||||||
|
#define a_to_u_short(a) ((unsigned short) \
|
||||||
|
((((Uchar*) a)[1] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[0] << 8 & 0xFF00)))
|
||||||
|
|
||||||
|
#define a_to_3_byte(a) ((Ulong) \
|
||||||
|
((((Uchar*) a)[2] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[1] << 8 & 0xFF00) | \
|
||||||
|
(((Uchar*) a)[0] << 16 & 0xFF0000)))
|
||||||
|
|
||||||
|
#ifdef __STDC__
|
||||||
|
#define a_to_u_long(a) ((Ulong) \
|
||||||
|
((((Uchar*) a)[3] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[2] << 8 & 0xFF00) | \
|
||||||
|
(((Uchar*) a)[1] << 16 & 0xFF0000) | \
|
||||||
|
(((Uchar*) a)[0] << 24 & 0xFF000000UL)))
|
||||||
|
#else
|
||||||
|
#define a_to_u_long(a) ((Ulong) \
|
||||||
|
((((Uchar*) a)[3] & 0xFF) | \
|
||||||
|
(((Uchar*) a)[2] << 8 & 0xFF00) | \
|
||||||
|
(((Uchar*) a)[1] << 16 & 0xFF0000) | \
|
||||||
|
(((Uchar*) a)[0] << 24 & 0xFF000000)))
|
||||||
|
#endif
|
||||||
|
#endif /* XXXX */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCG_SCSICDB_H */
|
111
src/schily/scg/scsidefs.h
Normal file
111
src/schily/scg/scsidefs.h
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/* @(#)scsidefs.h 1.28 04/09/04 Copyright 1988 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for SCSI devices i.e. for error strings in scsierrs.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 1988 J. Schilling
|
||||||
|
*/
|
||||||
|
/*@@C@@*/
|
||||||
|
|
||||||
|
#ifndef _SCG_SCSIDEFS_H
|
||||||
|
#define _SCG_SCSIDEFS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Disks
|
||||||
|
*/
|
||||||
|
#ifdef DEV_UNKNOWN
|
||||||
|
/*
|
||||||
|
* True64 defines DEV_UNKNOWN in /usr/include/sys/devio.h as "UNKNOWN"
|
||||||
|
*/
|
||||||
|
#undef DEV_UNKNOWN
|
||||||
|
#endif
|
||||||
|
#define DEV_UNKNOWN 0
|
||||||
|
#define DEV_ACB40X0 1
|
||||||
|
#define DEV_ACB4000 2
|
||||||
|
#define DEV_ACB4010 3
|
||||||
|
#define DEV_ACB4070 4
|
||||||
|
#define DEV_ACB5500 5
|
||||||
|
#define DEV_ACB4520A 6
|
||||||
|
#define DEV_ACB4525 7
|
||||||
|
#define DEV_MD21 8
|
||||||
|
#define DEV_MD23 9
|
||||||
|
#define DEV_NON_CCS_DSK 10
|
||||||
|
#define DEV_CCS_GENDISK 11
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tapes
|
||||||
|
*/
|
||||||
|
#define DEV_MT02 100
|
||||||
|
#define DEV_SC4000 101
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Printer
|
||||||
|
*/
|
||||||
|
#define DEV_PRT 200
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Processors
|
||||||
|
*/
|
||||||
|
#define DEV_PROC 300
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Worm
|
||||||
|
*/
|
||||||
|
#define DEV_WORM 400
|
||||||
|
#define DEV_RXT800S 401
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CD-ROM
|
||||||
|
*/
|
||||||
|
#define DEV_CDROM 500
|
||||||
|
#define DEV_MMC_CDROM 501
|
||||||
|
#define DEV_MMC_CDR 502
|
||||||
|
#define DEV_MMC_CDRW 503
|
||||||
|
#define DEV_MMC_DVD 504
|
||||||
|
#define DEV_MMC_DVD_WR 505
|
||||||
|
|
||||||
|
#define DEV_CDD_521_OLD 510
|
||||||
|
#define DEV_CDD_521 511
|
||||||
|
#define DEV_CDD_522 512
|
||||||
|
#define DEV_PCD_600 513
|
||||||
|
#define DEV_CDD_2000 514
|
||||||
|
#define DEV_CDD_2600 515
|
||||||
|
#define DEV_TYUDEN_EW50 516
|
||||||
|
#define DEV_YAMAHA_CDR_100 520
|
||||||
|
#define DEV_YAMAHA_CDR_400 521
|
||||||
|
#define DEV_PLASMON_RF_4100 530
|
||||||
|
#define DEV_SONY_CDU_924 540
|
||||||
|
#define DEV_RICOH_RO_1420C 550
|
||||||
|
#define DEV_RICOH_RO_1060C 551
|
||||||
|
#define DEV_TEAC_CD_R50S 560
|
||||||
|
#define DEV_MATSUSHITA_7501 570
|
||||||
|
#define DEV_MATSUSHITA_7502 571
|
||||||
|
#define DEV_PIONEER_DW_S114X 580
|
||||||
|
#define DEV_PIONEER_DVDR_S101 581
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scanners
|
||||||
|
*/
|
||||||
|
#define DEV_HRSCAN 600
|
||||||
|
#define DEV_MS300A 601
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Optical memory
|
||||||
|
*/
|
||||||
|
#define DEV_SONY_SMO 700
|
||||||
|
|
||||||
|
|
||||||
|
#define old_acb(d) (((d) == DEV_ACB40X0) || \
|
||||||
|
((d) == DEV_ACB4000) || ((d) == DEV_ACB4010) || \
|
||||||
|
((d) == DEV_ACB4070) || ((d) == DEV_ACB5500))
|
||||||
|
|
||||||
|
#define is_ccs(d) (!old_acb(d))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCG_SCSIDEFS_H */
|
1229
src/schily/scg/scsireg.h
Normal file
1229
src/schily/scg/scsireg.h
Normal file
File diff suppressed because it is too large
Load Diff
191
src/schily/scg/scsisense.h
Normal file
191
src/schily/scg/scsisense.h
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
/* @(#)scsisense.h 2.18 04/09/04 Copyright 1986 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for the SCSI status code and sense structure
|
||||||
|
*
|
||||||
|
* Copyright (c) 1986 J. Schilling
|
||||||
|
*/
|
||||||
|
/*@@C@@*/
|
||||||
|
|
||||||
|
#ifndef _SCG_SCSISENSE_H
|
||||||
|
#define _SCG_SCSISENSE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SCSI status completion block.
|
||||||
|
*/
|
||||||
|
#define SCSI_EXTENDED_STATUS
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
|
||||||
|
|
||||||
|
struct scsi_status {
|
||||||
|
Ucbit vu_00 : 1; /* vendor unique */
|
||||||
|
Ucbit chk : 1; /* check condition: sense data available */
|
||||||
|
Ucbit cm : 1; /* condition met */
|
||||||
|
Ucbit busy : 1; /* device busy or reserved */
|
||||||
|
Ucbit is : 1; /* intermediate status sent */
|
||||||
|
Ucbit vu_05 : 1; /* vendor unique */
|
||||||
|
#define st_scsi2 vu_05 /* SCSI-2 modifier bit */
|
||||||
|
Ucbit vu_06 : 1; /* vendor unique */
|
||||||
|
Ucbit st_rsvd : 1; /* reserved */
|
||||||
|
|
||||||
|
#ifdef SCSI_EXTENDED_STATUS
|
||||||
|
#define ext_st1 st_rsvd /* extended status (next byte valid) */
|
||||||
|
/* byte 1 */
|
||||||
|
Ucbit ha_er : 1; /* host adapter detected error */
|
||||||
|
Ucbit reserved: 6; /* reserved */
|
||||||
|
Ucbit ext_st2 : 1; /* extended status (next byte valid) */
|
||||||
|
/* byte 2 */
|
||||||
|
Uchar byte2; /* third byte */
|
||||||
|
#endif /* SCSI_EXTENDED_STATUS */
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
|
||||||
|
struct scsi_status {
|
||||||
|
Ucbit st_rsvd : 1; /* reserved */
|
||||||
|
Ucbit vu_06 : 1; /* vendor unique */
|
||||||
|
Ucbit vu_05 : 1; /* vendor unique */
|
||||||
|
#define st_scsi2 vu_05 /* SCSI-2 modifier bit */
|
||||||
|
Ucbit is : 1; /* intermediate status sent */
|
||||||
|
Ucbit busy : 1; /* device busy or reserved */
|
||||||
|
Ucbit cm : 1; /* condition met */
|
||||||
|
Ucbit chk : 1; /* check condition: sense data available */
|
||||||
|
Ucbit vu_00 : 1; /* vendor unique */
|
||||||
|
#ifdef SCSI_EXTENDED_STATUS
|
||||||
|
#define ext_st1 st_rsvd /* extended status (next byte valid) */
|
||||||
|
/* byte 1 */
|
||||||
|
Ucbit ext_st2 : 1; /* extended status (next byte valid) */
|
||||||
|
Ucbit reserved: 6; /* reserved */
|
||||||
|
Ucbit ha_er : 1; /* host adapter detected error */
|
||||||
|
/* byte 2 */
|
||||||
|
Uchar byte2; /* third byte */
|
||||||
|
#endif /* SCSI_EXTENDED_STATUS */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OLD Standard (Non Extended) SCSI Sense. Used mainly by the
|
||||||
|
* Adaptec ACB 4000 which is the only controller that
|
||||||
|
* does not support the Extended sense format.
|
||||||
|
*/
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
|
||||||
|
|
||||||
|
struct scsi_sense { /* scsi sense for error classes 0-6 */
|
||||||
|
Ucbit code : 7; /* error class/code */
|
||||||
|
Ucbit adr_val : 1; /* sense data is valid */
|
||||||
|
#ifdef comment
|
||||||
|
Ucbit high_addr:5; /* high byte of block addr */
|
||||||
|
Ucbit rsvd : 3;
|
||||||
|
#else
|
||||||
|
Uchar high_addr; /* high byte of block addr */
|
||||||
|
#endif
|
||||||
|
Uchar mid_addr; /* middle byte of block addr */
|
||||||
|
Uchar low_addr; /* low byte of block addr */
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
|
||||||
|
struct scsi_sense { /* scsi sense for error classes 0-6 */
|
||||||
|
Ucbit adr_val : 1; /* sense data is valid */
|
||||||
|
Ucbit code : 7; /* error class/code */
|
||||||
|
#ifdef comment
|
||||||
|
Ucbit rsvd : 3;
|
||||||
|
Ucbit high_addr:5; /* high byte of block addr */
|
||||||
|
#else
|
||||||
|
Uchar high_addr; /* high byte of block addr */
|
||||||
|
#endif
|
||||||
|
Uchar mid_addr; /* middle byte of block addr */
|
||||||
|
Uchar low_addr; /* low byte of block addr */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SCSI extended sense parameter block.
|
||||||
|
*/
|
||||||
|
#ifdef comment
|
||||||
|
#define SC_CLASS_EXTENDED_SENSE 0x7 /* indicates extended sense */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_BIT_FIELDS_LTOH) /* Intel byteorder */
|
||||||
|
|
||||||
|
struct scsi_ext_sense { /* scsi extended sense for error class 7 */
|
||||||
|
/* byte 0 */
|
||||||
|
Ucbit type : 7; /* fixed at 0x70 */
|
||||||
|
Ucbit adr_val : 1; /* sense data is valid */
|
||||||
|
/* byte 1 */
|
||||||
|
Uchar seg_num; /* segment number, applies to copy cmd only */
|
||||||
|
/* byte 2 */
|
||||||
|
Ucbit key : 4; /* sense key, see below */
|
||||||
|
Ucbit : 1; /* reserved */
|
||||||
|
Ucbit ili : 1; /* incorrect length indicator */
|
||||||
|
Ucbit eom : 1; /* end of media */
|
||||||
|
Ucbit fil_mk : 1; /* file mark on device */
|
||||||
|
/* bytes 3 through 7 */
|
||||||
|
Uchar info_1; /* information byte 1 */
|
||||||
|
Uchar info_2; /* information byte 2 */
|
||||||
|
Uchar info_3; /* information byte 3 */
|
||||||
|
Uchar info_4; /* information byte 4 */
|
||||||
|
Uchar add_len; /* number of additional bytes */
|
||||||
|
/* bytes 8 through 13, CCS additions */
|
||||||
|
Uchar optional_8; /* CCS search and copy only */
|
||||||
|
Uchar optional_9; /* CCS search and copy only */
|
||||||
|
Uchar optional_10; /* CCS search and copy only */
|
||||||
|
Uchar optional_11; /* CCS search and copy only */
|
||||||
|
Uchar sense_code; /* sense code */
|
||||||
|
Uchar qual_code; /* sense code qualifier */
|
||||||
|
Uchar fru_code; /* Field replacable unit code */
|
||||||
|
Ucbit bptr : 3; /* bit pointer for failure (if bpv) */
|
||||||
|
Ucbit bpv : 1; /* bit pointer is valid */
|
||||||
|
Ucbit : 2;
|
||||||
|
Ucbit cd : 1; /* pointers refer to command not data */
|
||||||
|
Ucbit sksv : 1; /* sense key specific valid */
|
||||||
|
Uchar field_ptr[2]; /* field pointer for failure */
|
||||||
|
Uchar add_info[2]; /* round up to 20 bytes */
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* Motorola byteorder */
|
||||||
|
|
||||||
|
struct scsi_ext_sense { /* scsi extended sense for error class 7 */
|
||||||
|
/* byte 0 */
|
||||||
|
Ucbit adr_val : 1; /* sense data is valid */
|
||||||
|
Ucbit type : 7; /* fixed at 0x70 */
|
||||||
|
/* byte 1 */
|
||||||
|
Uchar seg_num; /* segment number, applies to copy cmd only */
|
||||||
|
/* byte 2 */
|
||||||
|
Ucbit fil_mk : 1; /* file mark on device */
|
||||||
|
Ucbit eom : 1; /* end of media */
|
||||||
|
Ucbit ili : 1; /* incorrect length indicator */
|
||||||
|
Ucbit : 1; /* reserved */
|
||||||
|
Ucbit key : 4; /* sense key, see below */
|
||||||
|
/* bytes 3 through 7 */
|
||||||
|
Uchar info_1; /* information byte 1 */
|
||||||
|
Uchar info_2; /* information byte 2 */
|
||||||
|
Uchar info_3; /* information byte 3 */
|
||||||
|
Uchar info_4; /* information byte 4 */
|
||||||
|
Uchar add_len; /* number of additional bytes */
|
||||||
|
/* bytes 8 through 13, CCS additions */
|
||||||
|
Uchar optional_8; /* CCS search and copy only */
|
||||||
|
Uchar optional_9; /* CCS search and copy only */
|
||||||
|
Uchar optional_10; /* CCS search and copy only */
|
||||||
|
Uchar optional_11; /* CCS search and copy only */
|
||||||
|
Uchar sense_code; /* sense code */
|
||||||
|
Uchar qual_code; /* sense code qualifier */
|
||||||
|
Uchar fru_code; /* Field replacable unit code */
|
||||||
|
Ucbit sksv : 1; /* sense key specific valid */
|
||||||
|
Ucbit cd : 1; /* pointers refer to command not data */
|
||||||
|
Ucbit : 2;
|
||||||
|
Ucbit bpv : 1; /* bit pointer is valid */
|
||||||
|
Ucbit bptr : 3; /* bit pointer for failure (if bpv) */
|
||||||
|
Uchar field_ptr[2]; /* field pointer for failure */
|
||||||
|
Uchar add_info[2]; /* round up to 20 bytes */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCG_SCSISENSE_H */
|
257
src/schily/scg/scsitransp.h
Normal file
257
src/schily/scg/scsitransp.h
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
/* @(#)scsitransp.h 1.54 03/05/03 Copyright 1995 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for commands that use functions from scsitransp.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SCG_SCSITRANSP_H
|
||||||
|
#define _SCG_SCSITRANSP_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct scg_scsi SCSI;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int scsibus; /* SCSI bus # for next I/O */
|
||||||
|
int target; /* SCSI target # for next I/O */
|
||||||
|
int lun; /* SCSI lun # for next I/O */
|
||||||
|
} scg_addr_t;
|
||||||
|
|
||||||
|
#ifndef _SCG_SCGOPS_H
|
||||||
|
#include <scg/scgops.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int (*scg_cb_t) __PR((void *));
|
||||||
|
|
||||||
|
struct scg_scsi {
|
||||||
|
scg_ops_t *ops; /* Ptr to low level SCSI transport ops */
|
||||||
|
int fd; /* File descriptor for next I/O */
|
||||||
|
scg_addr_t addr; /* SCSI address for next I/O */
|
||||||
|
int flags; /* Libscg flags (see below) */
|
||||||
|
int dflags; /* Drive specific flags (see below) */
|
||||||
|
int kdebug; /* Kernel debug value for next I/O */
|
||||||
|
int debug; /* Debug value for SCSI library */
|
||||||
|
int silent; /* Be silent if value > 0 */
|
||||||
|
int verbose; /* Be verbose if value > 0 */
|
||||||
|
int overbose; /* Be verbose in open() if value > 0 */
|
||||||
|
int disre_disable;
|
||||||
|
int deftimeout;
|
||||||
|
int noparity; /* Do not use SCSI parity fo next I/O */
|
||||||
|
int dev; /* from scsi_cdr.c */
|
||||||
|
struct scg_cmd *scmd;
|
||||||
|
char *cmdname;
|
||||||
|
char *curcmdname;
|
||||||
|
BOOL running;
|
||||||
|
int error; /* libscg error number */
|
||||||
|
|
||||||
|
long maxdma; /* Max DMA limit for this open instance */
|
||||||
|
long maxbuf; /* Cur DMA buffer limit for this inst. */
|
||||||
|
/* This is the size behind bufptr */
|
||||||
|
struct timeval *cmdstart;
|
||||||
|
struct timeval *cmdstop;
|
||||||
|
const char **nonstderrs;
|
||||||
|
void *local; /* Local data from the low level code */
|
||||||
|
void *bufbase; /* needed for scsi_freebuf() */
|
||||||
|
void *bufptr; /* DMA buffer pointer for appl. use */
|
||||||
|
char *errstr; /* Error string for scsi_open/sendmcd */
|
||||||
|
char *errbeg; /* Pointer to begin of not flushed data */
|
||||||
|
char *errptr; /* Actual write pointer into errstr */
|
||||||
|
void *errfile; /* FILE to write errors to. NULL for not*/
|
||||||
|
/* writing and leaving errs in errstr */
|
||||||
|
scg_cb_t cb_fun;
|
||||||
|
void *cb_arg;
|
||||||
|
|
||||||
|
struct scsi_inquiry *inq;
|
||||||
|
struct scsi_capacity *cap;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros for accessing members of the scg address structure.
|
||||||
|
* scg_settarget() is the only function that is allowed to modify
|
||||||
|
* the values of the SCSI address.
|
||||||
|
*/
|
||||||
|
#define scg_scsibus(scgp) (scgp)->addr.scsibus
|
||||||
|
#define scg_target(scgp) (scgp)->addr.target
|
||||||
|
#define scg_lun(scgp) (scgp)->addr.lun
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flags for struct SCSI:
|
||||||
|
*/
|
||||||
|
/* NONE yet */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Drive specific flags for struct SCSI:
|
||||||
|
*/
|
||||||
|
#define DRF_MODE_DMA_OVR 0x0001 /* Drive gives DMA overrun */
|
||||||
|
/* on mode sense */
|
||||||
|
|
||||||
|
#define SCSI_ERRSTR_SIZE 4096
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Libscg error codes:
|
||||||
|
*/
|
||||||
|
#define SCG_ERRBASE 1000000
|
||||||
|
#define SCG_NOMEM 1000001
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function codes for scg_version():
|
||||||
|
*/
|
||||||
|
#define SCG_VERSION 0 /* libscg or transport version */
|
||||||
|
#define SCG_AUTHOR 1 /* Author of above */
|
||||||
|
#define SCG_SCCS_ID 2 /* SCCS id of above */
|
||||||
|
#define SCG_RVERSION 10 /* Remote transport version */
|
||||||
|
#define SCG_RAUTHOR 11 /* Remote transport author */
|
||||||
|
#define SCG_RSCCS_ID 12 /* Remote transport SCCS ID */
|
||||||
|
#define SCG_KVERSION 20 /* Kernel transport version */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function codes for scg_reset():
|
||||||
|
*/
|
||||||
|
#define SCG_RESET_NOP 0 /* Test if reset is supported */
|
||||||
|
#define SCG_RESET_TGT 1 /* Reset Target only */
|
||||||
|
#define SCG_RESET_BUS 2 /* Reset complete SCSI Bus */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helpers for the error buffer in SCSI*
|
||||||
|
*/
|
||||||
|
#define scg_errsize(scgp) ((scgp)->errptr - (scgp)->errstr)
|
||||||
|
#define scg_errrsize(scgp) (SCSI_ERRSTR_SIZE - scg_errsize(scgp))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From scsitransp.c:
|
||||||
|
*/
|
||||||
|
extern char *scg_version __PR((SCSI *scgp, int what));
|
||||||
|
extern int scg__open __PR((SCSI *scgp, char *device));
|
||||||
|
extern int scg__close __PR((SCSI *scgp));
|
||||||
|
extern BOOL scg_havebus __PR((SCSI *scgp, int));
|
||||||
|
extern int scg_initiator_id __PR((SCSI *scgp));
|
||||||
|
extern int scg_isatapi __PR((SCSI *scgp));
|
||||||
|
extern int scg_reset __PR((SCSI *scgp, int what));
|
||||||
|
extern void *scg_getbuf __PR((SCSI *scgp, long));
|
||||||
|
extern void scg_freebuf __PR((SCSI *scgp));
|
||||||
|
extern long scg_bufsize __PR((SCSI *scgp, long));
|
||||||
|
extern void scg_setnonstderrs __PR((SCSI *scgp, const char **));
|
||||||
|
extern BOOL scg_yes __PR((char *));
|
||||||
|
extern int scg_cmd __PR((SCSI *scgp));
|
||||||
|
extern void scg_vhead __PR((SCSI *scgp));
|
||||||
|
extern int scg_svhead __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
extern int scg_vtail __PR((SCSI *scgp));
|
||||||
|
extern int scg_svtail __PR((SCSI *scgp, int *retp, char *buf, int maxcnt));
|
||||||
|
extern void scg_vsetup __PR((SCSI *scgp));
|
||||||
|
extern int scg_getresid __PR((SCSI *scgp));
|
||||||
|
extern int scg_getdmacnt __PR((SCSI *scgp));
|
||||||
|
extern BOOL scg_cmd_err __PR((SCSI *scgp));
|
||||||
|
extern void scg_printerr __PR((SCSI *scgp));
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern void scg_fprinterr __PR((SCSI *scgp, FILE *f));
|
||||||
|
#endif
|
||||||
|
extern int scg_sprinterr __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
extern int scg__sprinterr __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
extern void scg_printcdb __PR((SCSI *scgp));
|
||||||
|
extern int scg_sprintcdb __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
extern void scg_printwdata __PR((SCSI *scgp));
|
||||||
|
extern int scg_sprintwdata __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
extern void scg_printrdata __PR((SCSI *scgp));
|
||||||
|
extern int scg_sprintrdata __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
extern void scg_printresult __PR((SCSI *scgp));
|
||||||
|
extern int scg_sprintresult __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
extern void scg_printstatus __PR((SCSI *scgp));
|
||||||
|
extern int scg_sprintstatus __PR((SCSI *scgp, char *buf, int maxcnt));
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern void scg_fprbytes __PR((FILE *, char *, unsigned char *, int));
|
||||||
|
extern void scg_fprascii __PR((FILE *, char *, unsigned char *, int));
|
||||||
|
#endif
|
||||||
|
extern void scg_prbytes __PR((char *, unsigned char *, int));
|
||||||
|
extern void scg_prascii __PR((char *, unsigned char *, int));
|
||||||
|
extern int scg_sprbytes __PR((char *buf, int maxcnt, char *, unsigned char *, int));
|
||||||
|
extern int scg_sprascii __PR((char *buf, int maxcnt, char *, unsigned char *, int));
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern void scg_fprsense __PR((FILE *f, unsigned char *, int));
|
||||||
|
#endif
|
||||||
|
extern void scg_prsense __PR((unsigned char *, int));
|
||||||
|
extern int scg_sprsense __PR((char *buf, int maxcnt, unsigned char *, int));
|
||||||
|
extern int scg_cmd_status __PR((SCSI *scgp));
|
||||||
|
extern int scg_sense_key __PR((SCSI *scgp));
|
||||||
|
extern int scg_sense_code __PR((SCSI *scgp));
|
||||||
|
extern int scg_sense_qual __PR((SCSI *scgp));
|
||||||
|
#ifdef _SCG_SCSIREG_H
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern void scg_fprintdev __PR((FILE *, struct scsi_inquiry *));
|
||||||
|
#endif
|
||||||
|
extern void scg_printdev __PR((struct scsi_inquiry *));
|
||||||
|
#endif
|
||||||
|
extern int scg_printf __PR((SCSI *scgp, const char *form, ...));
|
||||||
|
extern int scg_errflush __PR((SCSI *scgp));
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern int scg_errfflush __PR((SCSI *scgp, FILE *f));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From scsierrmsg.c:
|
||||||
|
*/
|
||||||
|
extern const char *scg_sensemsg __PR((int, int, int,
|
||||||
|
const char **, char *, int maxcnt));
|
||||||
|
#ifdef _SCG_SCSISENSE_H
|
||||||
|
extern int scg__errmsg __PR((SCSI *scgp, char *obuf, int maxcnt,
|
||||||
|
struct scsi_sense *,
|
||||||
|
struct scsi_status *,
|
||||||
|
int));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From scsiopen.c:
|
||||||
|
*/
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern int scg_help __PR((FILE *f));
|
||||||
|
#endif
|
||||||
|
extern SCSI *scg_open __PR((char *scsidev, char *errs, int slen, int odebug, int be_verbose));
|
||||||
|
extern int scg_close __PR((SCSI * scgp));
|
||||||
|
extern void scg_settimeout __PR((SCSI * scgp, int timeout));
|
||||||
|
extern SCSI *scg_smalloc __PR((void));
|
||||||
|
extern void scg_sfree __PR((SCSI *scgp));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From scgsettarget.c:
|
||||||
|
*/
|
||||||
|
extern int scg_settarget __PR((SCSI *scgp, int scsibus, int target, int lun));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From scsi-remote.c:
|
||||||
|
*/
|
||||||
|
extern scg_ops_t *scg_remote __PR((void));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From scsihelp.c:
|
||||||
|
*/
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern void __scg_help __PR((FILE *f, char *name, char *tcomment,
|
||||||
|
char *tind,
|
||||||
|
char *tspec,
|
||||||
|
char *texample,
|
||||||
|
BOOL mayscan,
|
||||||
|
BOOL bydev));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCG_SCSITRANSP_H */
|
131
src/schily/scg/spti-wnt.h
Normal file
131
src/schily/scg/spti-wnt.h
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* distilled information from various header files from Microsoft's
|
||||||
|
* DDK for Windows NT 4.0
|
||||||
|
*/
|
||||||
|
#ifndef _SCSIPT_H_INC
|
||||||
|
#define _SCSIPT_H_INC
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
USHORT Length;
|
||||||
|
UCHAR ScsiStatus;
|
||||||
|
UCHAR PathId;
|
||||||
|
UCHAR TargetId;
|
||||||
|
UCHAR Lun;
|
||||||
|
UCHAR CdbLength;
|
||||||
|
UCHAR SenseInfoLength;
|
||||||
|
UCHAR DataIn;
|
||||||
|
ULONG DataTransferLength;
|
||||||
|
ULONG TimeOutValue;
|
||||||
|
ULONG DataBufferOffset;
|
||||||
|
ULONG SenseInfoOffset;
|
||||||
|
UCHAR Cdb[16];
|
||||||
|
} SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
USHORT Length;
|
||||||
|
UCHAR ScsiStatus;
|
||||||
|
UCHAR PathId;
|
||||||
|
UCHAR TargetId;
|
||||||
|
UCHAR Lun;
|
||||||
|
UCHAR CdbLength;
|
||||||
|
UCHAR SenseInfoLength;
|
||||||
|
UCHAR DataIn;
|
||||||
|
ULONG DataTransferLength;
|
||||||
|
ULONG TimeOutValue;
|
||||||
|
PVOID DataBuffer;
|
||||||
|
ULONG SenseInfoOffset;
|
||||||
|
UCHAR Cdb[16];
|
||||||
|
} SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SCSI_PASS_THROUGH spt;
|
||||||
|
ULONG Filler;
|
||||||
|
UCHAR ucSenseBuf[32];
|
||||||
|
UCHAR ucDataBuf[512];
|
||||||
|
} SCSI_PASS_THROUGH_WITH_BUFFERS, *PSCSI_PASS_THROUGH_WITH_BUFFERS;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SCSI_PASS_THROUGH_DIRECT spt;
|
||||||
|
ULONG Filler;
|
||||||
|
UCHAR ucSenseBuf[32];
|
||||||
|
} SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UCHAR NumberOfLogicalUnits;
|
||||||
|
UCHAR InitiatorBusId;
|
||||||
|
ULONG InquiryDataOffset;
|
||||||
|
} SCSI_BUS_DATA, *PSCSI_BUS_DATA;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UCHAR NumberOfBusses;
|
||||||
|
SCSI_BUS_DATA BusData[1];
|
||||||
|
} SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UCHAR PathId;
|
||||||
|
UCHAR TargetId;
|
||||||
|
UCHAR Lun;
|
||||||
|
BOOLEAN DeviceClaimed;
|
||||||
|
ULONG InquiryDataLength;
|
||||||
|
ULONG NextInquiryDataOffset;
|
||||||
|
UCHAR InquiryData[1];
|
||||||
|
} SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ULONG Length;
|
||||||
|
UCHAR PortNumber;
|
||||||
|
UCHAR PathId;
|
||||||
|
UCHAR TargetId;
|
||||||
|
UCHAR Lun;
|
||||||
|
} SCSI_ADDRESS, *PSCSI_ADDRESS;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* method codes
|
||||||
|
*/
|
||||||
|
#define METHOD_BUFFERED 0
|
||||||
|
#define METHOD_IN_DIRECT 1
|
||||||
|
#define METHOD_OUT_DIRECT 2
|
||||||
|
#define METHOD_NEITHER 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* file access values
|
||||||
|
*/
|
||||||
|
#define FILE_ANY_ACCESS 0
|
||||||
|
#define FILE_READ_ACCESS 0x0001
|
||||||
|
#define FILE_WRITE_ACCESS 0x0002
|
||||||
|
|
||||||
|
|
||||||
|
#define IOCTL_SCSI_BASE 0x00000004
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constants for DataIn member of SCSI_PASS_THROUGH* structures
|
||||||
|
*/
|
||||||
|
#define SCSI_IOCTL_DATA_OUT 0
|
||||||
|
#define SCSI_IOCTL_DATA_IN 1
|
||||||
|
#define SCSI_IOCTL_DATA_UNSPECIFIED 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Standard IOCTL define
|
||||||
|
*/
|
||||||
|
#define CTL_CODE(DevType, Function, Method, Access) \
|
||||||
|
(((DevType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
|
||||||
|
|
||||||
|
#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||||
|
#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||||
|
#define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||||
|
#define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||||
|
#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||||
|
#define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||||
|
|
||||||
|
#endif
|
169
src/schily/scg/srb_os2.h
Normal file
169
src/schily/scg/srb_os2.h
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
/* @(#)srb_os2.h 1.0 98/10/28 Copyright 1998 D. Dorau, C. Wohlgemuth */
|
||||||
|
/*
|
||||||
|
* Definitions for ASPI-Router (ASPIROUT.SYS).
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 D. Dorau, C. Wohlgemuth
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
/* SRB command */
|
||||||
|
#define SRB_Inquiry 0x00
|
||||||
|
#define SRB_Device 0x01
|
||||||
|
#define SRB_Command 0x02
|
||||||
|
#define SRB_Abort 0x03
|
||||||
|
#define SRB_Reset 0x04
|
||||||
|
#define SRB_Param 0x05
|
||||||
|
|
||||||
|
/* SRB status */
|
||||||
|
#define SRB_Busy 0x00 /* SCSI request in progress */
|
||||||
|
#define SRB_Done 0x01 /* SCSI request completed without error */
|
||||||
|
#define SRB_Aborted 0x02 /* SCSI aborted by host */
|
||||||
|
#define SRB_BadAbort 0x03 /* Unable to abort SCSI request */
|
||||||
|
#define SRB_Error 0x04 /* SCSI request completed with error */
|
||||||
|
#define SRB_BusyPost 0x10 /* SCSI request in progress with POST - Nokia */
|
||||||
|
#define SRB_InvalidCmd 0x80 /* Invalid SCSI request */
|
||||||
|
#define SRB_InvalidHA 0x81 /* Invalid Hhost adapter number */
|
||||||
|
#define SRB_BadDevice 0x82 /* SCSI device not installed */
|
||||||
|
|
||||||
|
/* SRB flags */
|
||||||
|
#define SRB_Post 0x01 /* Post vector valid */
|
||||||
|
#define SRB_Link 0x02 /* Link vector valid */
|
||||||
|
#define SRB_SG 0x04 /* Nokia: scatter/gather */
|
||||||
|
/* S/G: n * (4 bytes length, 4 bytes addr) */
|
||||||
|
/* No of s/g items not limited by HA spec. */
|
||||||
|
#define SRB_NoCheck 0x00 /* determined by command, not checked */
|
||||||
|
#define SRB_Read 0x08 /* target to host, length checked */
|
||||||
|
#define SRB_Write 0x10 /* host to target, length checked */
|
||||||
|
#define SRB_NoTransfer 0x18 /* no data transfer */
|
||||||
|
#define SRB_DirMask 0x18 /* bit mask */
|
||||||
|
|
||||||
|
/* SRB host adapter status */
|
||||||
|
#define SRB_NoError 0x00 /* No host adapter detected error */
|
||||||
|
#define SRB_Timeout 0x11 /* Selection timeout */
|
||||||
|
#define SRB_DataLength 0x12 /* Data over/underrun */
|
||||||
|
#define SRB_BusFree 0x13 /* Unexpected bus free */
|
||||||
|
#define SRB_BusSequence 0x14 /* Target bus sequence failure */
|
||||||
|
|
||||||
|
/* SRB target status field */
|
||||||
|
#define SRB_NoStatus 0x00 /* No target status */
|
||||||
|
#define SRB_CheckStatus 0x02 /* Check status (sense data valid) */
|
||||||
|
#define SRB_LUN_Busy 0x08 /* Specified LUN is busy */
|
||||||
|
#define SRB_Reserved 0x18 /* Reservation conflict */
|
||||||
|
|
||||||
|
#define MaxCDBStatus 64 /* max size of CDB + status */
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct SRb {
|
||||||
|
unsigned char cmd, /* 00 */
|
||||||
|
status, /* 01 */
|
||||||
|
ha_num, /* 02 */
|
||||||
|
flags; /* 03 */
|
||||||
|
unsigned long res_04_07; /* 04..07 */
|
||||||
|
union { /* 08 */
|
||||||
|
|
||||||
|
/* SRB_Inquiry */
|
||||||
|
struct {
|
||||||
|
unsigned char num_ha, /* 08 */
|
||||||
|
ha_target, /* 09 */
|
||||||
|
aspimgr_id[16], /* 0A..19 */
|
||||||
|
host_id[16], /* 1A..29 */
|
||||||
|
unique_id[16]; /* 2A..39 */
|
||||||
|
} inq;
|
||||||
|
|
||||||
|
/* SRB_Device */
|
||||||
|
struct {
|
||||||
|
unsigned char target, /* 08 */
|
||||||
|
lun, /* 09 */
|
||||||
|
devtype; /* 0A */
|
||||||
|
} dev;
|
||||||
|
|
||||||
|
/* SRB_Command */
|
||||||
|
struct {
|
||||||
|
unsigned char target, /* 08 */
|
||||||
|
lun; /* 09 */
|
||||||
|
unsigned long data_len; /* 0A..0D */
|
||||||
|
unsigned char sense_len; /* 0E */
|
||||||
|
unsigned long data_ptr; /* 0F..12 */
|
||||||
|
unsigned long link_ptr; /* 13..16 */
|
||||||
|
// void * _Seg16 data_ptr; /* 0F..12 */
|
||||||
|
// void * _Seg16 link_ptr; /* 13..16 */
|
||||||
|
unsigned char cdb_len, /* 17 */
|
||||||
|
ha_status, /* 18 */
|
||||||
|
target_status; /* 19 */
|
||||||
|
unsigned char _Seg16postSRB[4];
|
||||||
|
// void (* _Seg16 post) (SRB *); /* 1A..1D */
|
||||||
|
unsigned char res_1E_29[12]; /* 1E..29 */
|
||||||
|
unsigned char res_2A_3F[22]; /* 2A..3F */
|
||||||
|
unsigned char cdb_st[64]; /* 40..7F CDB+status */
|
||||||
|
unsigned char res_80_BF[64]; /* 80..BF */
|
||||||
|
} cmd;
|
||||||
|
|
||||||
|
/* SRB_Abort */
|
||||||
|
struct {
|
||||||
|
unsigned char _Seg16srb[4];
|
||||||
|
// void * _Seg16 srb; /* 08..0B */
|
||||||
|
} abt;
|
||||||
|
|
||||||
|
/* SRB_Reset */
|
||||||
|
struct {
|
||||||
|
unsigned char target, /* 08 */
|
||||||
|
lun, /* 09 */
|
||||||
|
res_0A_17[14], /* 0A..17 */
|
||||||
|
ha_status, /* 18 */
|
||||||
|
target_status; /* 19 */
|
||||||
|
} res;
|
||||||
|
|
||||||
|
/* SRB_Param - unused by ASPI4OS2 */
|
||||||
|
struct {
|
||||||
|
unsigned char unique[16]; /* 08..17 */
|
||||||
|
} par;
|
||||||
|
|
||||||
|
} u;
|
||||||
|
} SRB;
|
||||||
|
|
||||||
|
|
||||||
|
// SCSI sense codes
|
||||||
|
// Note! This list may not be complete. I did this compilation for use with tape drives.
|
||||||
|
|
||||||
|
#define Sense_Current 0x70; // Current Error
|
||||||
|
#define Sense_Deferred 0x71; // Deferred Error
|
||||||
|
#define Sense_Filemark 0x80; // Filemark detected
|
||||||
|
#define Sense_EOM 0x40; // End of medium detected
|
||||||
|
#define Sense_ILI 0x20; // Incorrect length indicator
|
||||||
|
|
||||||
|
// Sense Keys
|
||||||
|
|
||||||
|
#define SK_NoSense 0x00; // No Sense
|
||||||
|
#define SK_RcvrdErr 0x01; // Recovered Error
|
||||||
|
#define SK_NotReady 0x02; // Not ready
|
||||||
|
#define SK_MedErr 0x03; // Medium Error
|
||||||
|
#define SK_HWErr 0x04; // Hardware Error
|
||||||
|
#define SK_IllReq 0x05; // Illegal Request
|
||||||
|
#define SK_UnitAtt 0x06; // Unit attention
|
||||||
|
#define SK_DataProt 0x07: // Data Protect
|
||||||
|
#define SK_BlankChk 0x08: // Blank Check
|
||||||
|
#define SK_VndSpec 0x09; // Vendor Specific
|
||||||
|
#define SK_CopyAbort 0x0A; // Copy Aborted
|
||||||
|
#define SK_AbtdCmd 0x0B; // Aborted Command
|
||||||
|
#define SK_Equal 0x0C; // Equal
|
||||||
|
#define SK_VolOvfl 0x0D; // Volume Overflow
|
||||||
|
#define SK_MisComp 0x0E; // Miscompare
|
||||||
|
#define SK_Reserved 0x0F; // Reserved
|
308
src/schily/schily.h
Normal file
308
src/schily/schily.h
Normal file
@ -0,0 +1,308 @@
|
|||||||
|
/* @(#)schily.h 1.52 04/03/05 Copyright 1985-2002 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for libschily
|
||||||
|
*
|
||||||
|
* This file should be included past:
|
||||||
|
*
|
||||||
|
* mconfig.h / config.h
|
||||||
|
* standard.h
|
||||||
|
* stdio.h
|
||||||
|
* stdlib.h (better use stdxlib.h)
|
||||||
|
* unistd.h (better use unixstd.h) needed LARGEFILE support
|
||||||
|
* string.h
|
||||||
|
* sys/types.h
|
||||||
|
*
|
||||||
|
* If you need stdio.h, you must include it before schily.h
|
||||||
|
*
|
||||||
|
* NOTE: If you need ctype.h and did not include stdio.h you need to
|
||||||
|
* include ctype.h past schily.h as OpenBSD does not follow POSIX and
|
||||||
|
* defines EOF in ctype.h
|
||||||
|
*
|
||||||
|
* Copyright (c) 1985-2002 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SCHILY_H
|
||||||
|
#define _SCHILY_H
|
||||||
|
|
||||||
|
#ifndef _STANDARD_H
|
||||||
|
#include <standard.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _CCOMDEFS_H
|
||||||
|
#include <ccomdefs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_INCL_SYS_TYPES_H) || defined(off_t)
|
||||||
|
# ifndef FOUND_OFF_T
|
||||||
|
# define FOUND_OFF_T
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(_INCL_SYS_TYPES_H) || defined(size_t)
|
||||||
|
# ifndef FOUND_SIZE_T
|
||||||
|
# define FOUND_SIZE_T
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __never_def__
|
||||||
|
/*
|
||||||
|
* It turns out that we cannot use the folloginw definition because there are
|
||||||
|
* some platforms that do not behave application friendly. These are mainly
|
||||||
|
* BSD-4.4 based systems (which #undef a definition when size_t is available.
|
||||||
|
* We actually removed this code because of a problem with QNX Neutrino.
|
||||||
|
* For this reason, it is important not to include <sys/types.h> directly but
|
||||||
|
* via the Schily SING include files so we know whether it has been included
|
||||||
|
* before we come here.
|
||||||
|
*/
|
||||||
|
#if defined(_SIZE_T) || defined(_T_SIZE_) || defined(_T_SIZE) || \
|
||||||
|
defined(__SIZE_T) || defined(_SIZE_T_) || \
|
||||||
|
defined(_GCC_SIZE_T) || defined(_SIZET_) || \
|
||||||
|
defined(__sys_stdtypes_h) || defined(___int_size_t_h) || defined(size_t)
|
||||||
|
|
||||||
|
#ifndef FOUND_SIZE_T
|
||||||
|
# define FOUND_SIZE_T /* We already included a size_t definition */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif /* __never_def__ */
|
||||||
|
|
||||||
|
#if defined(HAVE_LARGEFILES)
|
||||||
|
# define _fcons _fcons64
|
||||||
|
# define fdup fdup64
|
||||||
|
# define fileluopen fileluopen64
|
||||||
|
# define fileopen fileopen64
|
||||||
|
# define filemopen filemopen64
|
||||||
|
# define filepos filepos64
|
||||||
|
# define filereopen filereopen64
|
||||||
|
# define fileseek fileseek64
|
||||||
|
# define filesize filesize64
|
||||||
|
# define filestat filestat64
|
||||||
|
# define _openfd _openfd64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
extern int _cvmod __PR((const char *, int *, int *));
|
||||||
|
extern FILE *_fcons __PR((FILE *, int, int));
|
||||||
|
extern FILE *fdup __PR((FILE *));
|
||||||
|
extern int fdown __PR((FILE *));
|
||||||
|
extern int fexecl __PR((const char *, FILE *, FILE *, FILE *,
|
||||||
|
const char *, ...));
|
||||||
|
extern int fexecle __PR((const char *, FILE *, FILE *, FILE *,
|
||||||
|
const char *, ...));
|
||||||
|
/* 6th arg not const, fexecv forces av[ac] = NULL */
|
||||||
|
extern int fexecv __PR((const char *, FILE *, FILE *, FILE *, int,
|
||||||
|
char **));
|
||||||
|
extern int fexecve __PR((const char *, FILE *, FILE *, FILE *,
|
||||||
|
char * const *, char * const *));
|
||||||
|
extern int fspawnv __PR((FILE *, FILE *, FILE *, int, char * const *));
|
||||||
|
extern int fspawnl __PR((FILE *, FILE *, FILE *,
|
||||||
|
const char *, const char *, ...));
|
||||||
|
extern int fspawnv_nowait __PR((FILE *, FILE *, FILE *,
|
||||||
|
const char *, int, char *const*));
|
||||||
|
extern int fgetline __PR((FILE *, char *, int));
|
||||||
|
extern int fgetstr __PR((FILE *, char *, int));
|
||||||
|
extern void file_raise __PR((FILE *, int));
|
||||||
|
extern int fileclose __PR((FILE *));
|
||||||
|
extern FILE *fileluopen __PR((int, const char *));
|
||||||
|
extern FILE *fileopen __PR((const char *, const char *));
|
||||||
|
#ifdef _INCL_SYS_TYPES_H
|
||||||
|
extern FILE *filemopen __PR((const char *, const char *, mode_t));
|
||||||
|
#endif
|
||||||
|
#ifdef FOUND_OFF_T
|
||||||
|
extern off_t filepos __PR((FILE *));
|
||||||
|
#endif
|
||||||
|
extern int fileread __PR((FILE *, void *, int));
|
||||||
|
extern int ffileread __PR((FILE *, void *, int));
|
||||||
|
extern FILE *filereopen __PR((const char *, const char *, FILE *));
|
||||||
|
#ifdef FOUND_OFF_T
|
||||||
|
extern int fileseek __PR((FILE *, off_t));
|
||||||
|
extern off_t filesize __PR((FILE *));
|
||||||
|
#endif
|
||||||
|
#ifdef S_IFMT
|
||||||
|
extern int filestat __PR((FILE *, struct stat *));
|
||||||
|
#endif
|
||||||
|
extern int filewrite __PR((FILE *, void *, int));
|
||||||
|
extern int ffilewrite __PR((FILE *, void *, int));
|
||||||
|
extern int flush __PR((void));
|
||||||
|
extern int fpipe __PR((FILE **));
|
||||||
|
/*extern int fprintf __PR((FILE *, const char *, ...)) __printflike__(2, 3);*/
|
||||||
|
extern int getbroken __PR((FILE *, char *, char, char **, int));
|
||||||
|
extern int ofindline __PR((FILE *, char, const char *, int,
|
||||||
|
char **, int));
|
||||||
|
extern int peekc __PR((FILE *));
|
||||||
|
|
||||||
|
#ifdef __never_def__
|
||||||
|
/*
|
||||||
|
* We cannot define this or we may get into problems with DOS based systems.
|
||||||
|
*/
|
||||||
|
extern int spawnv __PR((FILE *, FILE *, FILE *, int, char * const *));
|
||||||
|
extern int spawnl __PR((FILE *, FILE *, FILE *,
|
||||||
|
const char *, const char *, ...));
|
||||||
|
extern int spawnv_nowait __PR((FILE *, FILE *, FILE *,
|
||||||
|
const char *, int, char *const*));
|
||||||
|
#endif /* __never_def__m */
|
||||||
|
#endif /* EOF */
|
||||||
|
|
||||||
|
extern int _niread __PR((int, void *, int));
|
||||||
|
extern int _niwrite __PR((int, void *, int));
|
||||||
|
extern int _nixread __PR((int, void *, int));
|
||||||
|
extern int _nixwrite __PR((int, void *, int));
|
||||||
|
extern int _openfd __PR((const char *, int));
|
||||||
|
extern int on_comerr __PR((void (*fun)(int, void *), void *arg));
|
||||||
|
/*PRINTFLIKE1*/
|
||||||
|
extern void comerr __PR((const char *, ...)) __printflike__(1, 2);
|
||||||
|
/*PRINTFLIKE2*/
|
||||||
|
extern void comerrno __PR((int, const char *, ...)) __printflike__(2, 3);
|
||||||
|
/*PRINTFLIKE1*/
|
||||||
|
extern int errmsg __PR((const char *, ...)) __printflike__(1, 2);
|
||||||
|
/*PRINTFLIKE2*/
|
||||||
|
extern int errmsgno __PR((int, const char *, ...)) __printflike__(2, 3);
|
||||||
|
#ifdef FOUND_SIZE_T
|
||||||
|
/*PRINTFLIKE3*/
|
||||||
|
extern int serrmsg __PR((char *, size_t, const char *, ...)) __printflike__(3, 4);
|
||||||
|
/*PRINTFLIKE4*/
|
||||||
|
extern int serrmsgno __PR((int, char *, size_t, const char *, ...)) __printflike__(4, 5);
|
||||||
|
#endif
|
||||||
|
extern void comexit __PR((int));
|
||||||
|
extern char *errmsgstr __PR((int));
|
||||||
|
/*PRINTFLIKE1*/
|
||||||
|
extern int error __PR((const char *, ...)) __printflike__(1, 2);
|
||||||
|
extern char *fillbytes __PR((void *, int, char));
|
||||||
|
extern char *findbytes __PR((const void *, int, char));
|
||||||
|
extern int findline __PR((const char *, char, const char *,
|
||||||
|
int, char **, int));
|
||||||
|
extern int getline __PR((char *, int));
|
||||||
|
extern int getstr __PR((char *, int));
|
||||||
|
extern int breakline __PR((char *, char, char **, int));
|
||||||
|
extern int getallargs __PR((int *, char * const**, const char *, ...));
|
||||||
|
extern int getargs __PR((int *, char * const**, const char *, ...));
|
||||||
|
extern int getfiles __PR((int *, char * const**, const char *));
|
||||||
|
extern char *astoi __PR((const char *, int *));
|
||||||
|
extern char *astol __PR((const char *, long *));
|
||||||
|
extern char *astolb __PR((const char *, long *, int base));
|
||||||
|
#ifdef _UTYPES_H
|
||||||
|
extern char *astoll __PR((const char *, Llong *));
|
||||||
|
extern char *astollb __PR((const char *, Llong *, int base));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*extern void handlecond __PR((const char *, SIGBLK *, int(*)(const char *, long, long), long));*/
|
||||||
|
/*extern void unhandlecond __PR((SIGBLK *));*/
|
||||||
|
|
||||||
|
extern int patcompile __PR((const unsigned char *, int, int *));
|
||||||
|
extern unsigned char *patmatch __PR((const unsigned char *, const int *,
|
||||||
|
const unsigned char *, int, int, int, int[]));
|
||||||
|
extern unsigned char *patlmatch __PR((const unsigned char *, const int *,
|
||||||
|
const unsigned char *, int, int, int, int[]));
|
||||||
|
|
||||||
|
/*extern int printf __PR((const char *, ...)) __printflike__(1, 2);*/
|
||||||
|
extern char *movebytes __PR((const void *, void *, int));
|
||||||
|
|
||||||
|
extern void save_args __PR((int, char **));
|
||||||
|
extern int saved_ac __PR((void));
|
||||||
|
extern char **saved_av __PR((void));
|
||||||
|
extern char *saved_av0 __PR((void));
|
||||||
|
#ifndef seterrno
|
||||||
|
extern int seterrno __PR((int));
|
||||||
|
#endif
|
||||||
|
extern void set_progname __PR((const char *));
|
||||||
|
extern char *get_progname __PR((void));
|
||||||
|
|
||||||
|
extern void setfp __PR((void * const *));
|
||||||
|
extern int wait_chld __PR((int)); /* for fspawnv_nowait() */
|
||||||
|
extern int geterrno __PR((void));
|
||||||
|
extern void raisecond __PR((const char *, long));
|
||||||
|
#ifdef FOUND_SIZE_T
|
||||||
|
/*
|
||||||
|
* We currently cannot define this here because there IXIX has a definition
|
||||||
|
* than violates the standard.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
/*PRINTFLIKE3*/
|
||||||
|
extern int snprintf __PR((char *, size_t, const char *, ...)) __printflike__(3, 4);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
/*extern int sprintf __PR((char *, const char *, ...)); ist woanders falsch deklariert !!!*/
|
||||||
|
extern char *strcatl __PR((char *, ...));
|
||||||
|
extern int streql __PR((const char *, const char *));
|
||||||
|
#ifdef va_arg
|
||||||
|
extern int format __PR((void (*)(char, long), long, const char *, va_list));
|
||||||
|
#else
|
||||||
|
extern int format __PR((void (*)(char, long), long, const char *, void *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int ftoes __PR((char *, double, int, int));
|
||||||
|
extern int ftofs __PR((char *, double, int, int));
|
||||||
|
|
||||||
|
#ifdef EOF /* stdio.h has been included */
|
||||||
|
/*PRINTFLIKE2*/
|
||||||
|
extern int js_fprintf __PR((FILE *, const char *, ...)) __printflike__(2, 3);
|
||||||
|
/*PRINTFLIKE1*/
|
||||||
|
extern int js_printf __PR((const char *, ...)) __printflike__(1, 2);
|
||||||
|
#ifdef FOUND_SIZE_T
|
||||||
|
/*PRINTFLIKE3*/
|
||||||
|
extern int js_snprintf __PR((char *, size_t, const char *, ...)) __printflike__(3, 4);
|
||||||
|
#endif
|
||||||
|
/*PRINTFLIKE2*/
|
||||||
|
extern int js_sprintf __PR((char *, const char *, ...)) __printflike__(2, 3);
|
||||||
|
#endif /* EOF */
|
||||||
|
|
||||||
|
extern void swabbytes __PR((void *, int));
|
||||||
|
extern char **getmainfp __PR((void));
|
||||||
|
extern char **getavp __PR((void));
|
||||||
|
extern char *getav0 __PR((void));
|
||||||
|
extern void **getfp __PR((void));
|
||||||
|
extern int flush_reg_windows __PR((int));
|
||||||
|
extern int cmpbytes __PR((const void *, const void *, int));
|
||||||
|
extern int cmpnullbytes __PR((const void *, int));
|
||||||
|
|
||||||
|
#ifdef nonono
|
||||||
|
#if defined(HAVE_LARGEFILES)
|
||||||
|
/*
|
||||||
|
* To allow this, we need to figure out how to do autoconfiguration for off64_t
|
||||||
|
*/
|
||||||
|
extern FILE *_fcons64 __PR((FILE *, int, int));
|
||||||
|
extern FILE *fdup64 __PR((FILE *));
|
||||||
|
extern FILE *fileluopen64 __PR((int, const char *));
|
||||||
|
extern FILE *fileopen64 __PR((const char *, const char *));
|
||||||
|
#ifdef FOUND_OFF_T
|
||||||
|
extern off64_t filepos64 __PR((FILE *));
|
||||||
|
#endif
|
||||||
|
extern FILE *filereopen64 __PR((const char *, const char *, FILE *));
|
||||||
|
#ifdef FOUND_OFF_T
|
||||||
|
extern int fileseek64 __PR((FILE *, off64_t));
|
||||||
|
extern off64_t filesize64 __PR((FILE *));
|
||||||
|
#endif
|
||||||
|
#ifdef S_IFMT
|
||||||
|
extern int filestat64 __PR((FILE *, struct stat *));
|
||||||
|
#endif
|
||||||
|
extern int _openfd64 __PR((const char *, int));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_JOS) || defined(JOS)
|
||||||
|
# ifndef _JOS_IO_H
|
||||||
|
# include <jos_io.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SCHILY_H */
|
69
src/schily/sigblk.h
Normal file
69
src/schily/sigblk.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* @(#)sigblk.h 1.10 03/07/10 Copyright 1985, 1995-2003 J. Schilling */
|
||||||
|
/*
|
||||||
|
* software signal block definition
|
||||||
|
*
|
||||||
|
* Copyright (c) 1985, 1995-2003 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SIGBLK_H
|
||||||
|
#define _SIGBLK_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _STANDARD_H
|
||||||
|
#include <standard.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct sigblk {
|
||||||
|
long **sb_savfp; /* Real saved framepointer */
|
||||||
|
struct sigblk *sb_signext; /* Next sw signal blk for this func */
|
||||||
|
short sb_siglen; /* Strlen for sb_signame */
|
||||||
|
const char *sb_signame; /* Name of software signal */
|
||||||
|
|
||||||
|
/* sb_sigfun: function to call */
|
||||||
|
int (*sb_sigfun) __PR((const char *, long, long));
|
||||||
|
|
||||||
|
long sb_sigarg; /* Second arg for sb_sigfun */
|
||||||
|
} SIGBLK;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The handler function is called with three arguments:
|
||||||
|
*
|
||||||
|
* 1) The name of the software signal
|
||||||
|
* 2) The argument from the handlecond() call
|
||||||
|
* 3) The argument from the raisecond() call
|
||||||
|
*/
|
||||||
|
typedef int (*handlefunc_t) __PR((const char *, long, long));
|
||||||
|
|
||||||
|
extern void handlecond __PR((const char *, SIGBLK *,
|
||||||
|
int(*)(const char *, long, long),
|
||||||
|
long));
|
||||||
|
extern void raisecond __PR((const char *, long));
|
||||||
|
extern void starthandlecond __PR((SIGBLK *));
|
||||||
|
extern void unhandlecond __PR((SIGBLK *));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SIGBLK_H */
|
70
src/schily/sigdefs.h
Normal file
70
src/schily/sigdefs.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* @(#)sigdefs.h 1.5 02/01/19 Copyright 1997 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Signal abstraction for BSD/SVR4 signals
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SIGDEFS_H
|
||||||
|
#define _SIGDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SIGSET
|
||||||
|
/*
|
||||||
|
* Try to by default use the function that sets up signal handlers in a way
|
||||||
|
* that does not reset the handler after it has been called.
|
||||||
|
*/
|
||||||
|
#define signal sigset
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SIGPROCMASK
|
||||||
|
#define block_sigs(a) { \
|
||||||
|
sigset_t __new; \
|
||||||
|
\
|
||||||
|
sigfillset(&__new); \
|
||||||
|
sigprocmask(SIG_BLOCK, &__new, &a);\
|
||||||
|
}
|
||||||
|
#define unblock_sig(s) { \
|
||||||
|
sigset_t __new; \
|
||||||
|
\
|
||||||
|
sigemptyset(&__new); \
|
||||||
|
sigaddset(&__new, (s)); \
|
||||||
|
sigprocmask(SIG_UNBLOCK, &__new, NULL);\
|
||||||
|
}
|
||||||
|
#define restore_sigs(a) sigprocmask(SIG_SETMASK, &a, 0);
|
||||||
|
|
||||||
|
#else /* !HAVE_SIGPROCMASK */
|
||||||
|
|
||||||
|
#define sigset_t int
|
||||||
|
#define block_sigs(a) a = sigblock(0xFFFFFFFF)
|
||||||
|
#define restore_sigs(a) sigsetmask(a);
|
||||||
|
#define unblock_sig(s) { \
|
||||||
|
int __old, __new; \
|
||||||
|
\
|
||||||
|
block_sigs(__old); \
|
||||||
|
__new = sigmask(s); \
|
||||||
|
__new = __old & ~__new; \
|
||||||
|
sigsetmask(__new); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_SIGPROCMASK */
|
||||||
|
|
||||||
|
#endif /* _SIGDEFS_H */
|
154
src/schily/standard.h
Normal file
154
src/schily/standard.h
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
/* @(#)standard.h 1.31 03/08/23 Copyright 1985 J. Schilling */
|
||||||
|
/*
|
||||||
|
* standard definitions
|
||||||
|
*
|
||||||
|
* This file should be included past:
|
||||||
|
*
|
||||||
|
* mconfig.h / config.h
|
||||||
|
* stdio.h
|
||||||
|
* stdlib.h (better use stdxlib.h)
|
||||||
|
* unistd.h (better use unixstd.h) needed LARGEFILE support
|
||||||
|
*
|
||||||
|
* If you need stdio.h, you must include it before standard.h
|
||||||
|
*
|
||||||
|
* Copyright (c) 1985 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STANDARD_H
|
||||||
|
#define _STANDARD_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef M68000
|
||||||
|
# ifndef tos
|
||||||
|
# define JOS 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* fundamental constants
|
||||||
|
*/
|
||||||
|
#ifndef NULL
|
||||||
|
# define NULL 0
|
||||||
|
#endif
|
||||||
|
#ifndef TRUE
|
||||||
|
# define TRUE 1
|
||||||
|
# define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Program exit codes
|
||||||
|
*/
|
||||||
|
#define EX_BAD (-1)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* standard storage class definitions
|
||||||
|
*/
|
||||||
|
#define GLOBAL extern
|
||||||
|
#define IMPORT extern
|
||||||
|
#define EXPORT
|
||||||
|
#define INTERN static
|
||||||
|
#define LOCAL static
|
||||||
|
#define FAST register
|
||||||
|
|
||||||
|
#ifndef PROTOTYPES
|
||||||
|
# ifndef const
|
||||||
|
# define const
|
||||||
|
# endif
|
||||||
|
# ifndef signed
|
||||||
|
# define signed
|
||||||
|
# endif
|
||||||
|
# ifndef volatile
|
||||||
|
# define volatile
|
||||||
|
# endif
|
||||||
|
#endif /* PROTOTYPES */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* standard type definitions
|
||||||
|
*
|
||||||
|
* The hidden Schily BOOL definition is used in case we need to deal
|
||||||
|
* with other BOOL defines on systems we like to port to.
|
||||||
|
*/
|
||||||
|
typedef int __SBOOL;
|
||||||
|
typedef int BOOL;
|
||||||
|
#ifdef JOS
|
||||||
|
# ifndef __GNUC__
|
||||||
|
# define NO_VOID
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifdef NO_VOID
|
||||||
|
typedef int VOID;
|
||||||
|
# ifndef lint
|
||||||
|
typedef int void;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
typedef void VOID;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_INCL_SYS_TYPES_H) || defined(off_t)
|
||||||
|
# ifndef FOUND_OFF_T
|
||||||
|
# define FOUND_OFF_T
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(_INCL_SYS_TYPES_H) || defined(size_t)
|
||||||
|
# ifndef FOUND_SIZE_T
|
||||||
|
# define FOUND_SIZE_T
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __never_def__
|
||||||
|
/*
|
||||||
|
* It turns out that we cannot use the folloginw definition because there are
|
||||||
|
* some platforms that do not behave application friendly. These are mainly
|
||||||
|
* BSD-4.4 based systems (which #undef a definition when size_t is available.
|
||||||
|
* We actually removed this code because of a problem with QNX Neutrino.
|
||||||
|
* For this reason, it is important not to include <sys/types.h> directly but
|
||||||
|
* via the Schily SING include files so we know whether it has been included
|
||||||
|
* before we come here.
|
||||||
|
*/
|
||||||
|
#if defined(_SIZE_T) || defined(_T_SIZE_) || defined(_T_SIZE) || \
|
||||||
|
defined(__SIZE_T) || defined(_SIZE_T_) || \
|
||||||
|
defined(_GCC_SIZE_T) || defined(_SIZET_) || \
|
||||||
|
defined(__sys_stdtypes_h) || defined(___int_size_t_h) || defined(size_t)
|
||||||
|
|
||||||
|
#ifndef FOUND_SIZE_T
|
||||||
|
# define FOUND_SIZE_T /* We already included a size_t definition */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif /* __never_def__ */
|
||||||
|
|
||||||
|
#if defined(_JOS) || defined(JOS)
|
||||||
|
# ifndef _SCHILY_H
|
||||||
|
# include <schily.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef _JOS_DEFS_H
|
||||||
|
# include <jos_defs.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef _JOS_IO_H
|
||||||
|
# include <jos_io.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _STANDARD_H */
|
339
src/schily/statdefs.h
Normal file
339
src/schily/statdefs.h
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
/* @(#)statdefs.h 1.9 03/06/15 Copyright 1998 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for stat() file mode
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STATDEFS_H
|
||||||
|
#define _STATDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h> /* Needed for sys/stat.h */
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
#ifndef _INCL_SYS_STAT_H
|
||||||
|
#include <sys/stat.h> /* For S_IS* and S_IF* */
|
||||||
|
#define _INCL_SYS_STAT_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Apollo Domain/OS has a broken sys/stat.h that defines
|
||||||
|
* S_IFIFO == S_IFSOCK and creates trouble if the constants
|
||||||
|
* are used as case labels.
|
||||||
|
*/
|
||||||
|
#if S_IFIFO == S_IFSOCK
|
||||||
|
# undef S_IFSOCK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STAT_MACROS_BROKEN
|
||||||
|
#undef S_ISFIFO /* Named pipe */
|
||||||
|
#undef S_ISCHR /* Character special */
|
||||||
|
#undef S_ISMPC /* UNUSED multiplexed c */
|
||||||
|
#undef S_ISDIR /* Directory */
|
||||||
|
#undef S_ISNAM /* Named file (XENIX) */
|
||||||
|
#undef S_ISBLK /* Block special */
|
||||||
|
#undef S_ISMPB /* UNUSED multiplexed b */
|
||||||
|
#undef S_ISREG /* Regular file */
|
||||||
|
#undef S_ISCNT /* Contiguous file */
|
||||||
|
#undef S_ISLNK /* Symbolic link */
|
||||||
|
#undef S_ISSHAD /* Solaris shadow inode */
|
||||||
|
#undef S_ISSOCK /* UNIX domain socket */
|
||||||
|
#undef S_ISDOOR /* Solaris DOOR */
|
||||||
|
#undef S_ISWHT /* BSD whiteout */
|
||||||
|
#undef S_ISEVC /* UNOS eventcount */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_ISFIFO /* 1 Named pipe */
|
||||||
|
# ifdef S_IFIFO
|
||||||
|
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||||
|
# else
|
||||||
|
# define S_ISFIFO(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISCHR /* 2 Character special */
|
||||||
|
# ifdef S_IFCHR
|
||||||
|
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||||
|
# else
|
||||||
|
# define S_ISCHR(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISMPC /* 3 UNUSED multiplexed char */
|
||||||
|
# ifdef S_IFMPC
|
||||||
|
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||||
|
# else
|
||||||
|
# define S_ISMPC(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISDIR /* 4 Directory */
|
||||||
|
# ifdef S_IFDIR
|
||||||
|
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||||
|
# else
|
||||||
|
# define S_ISDIR(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISNAM /* 5 Named file (XENIX) */
|
||||||
|
# ifdef S_IFNAM
|
||||||
|
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
|
||||||
|
# else
|
||||||
|
# define S_ISNAM(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISBLK /* 6 Block special */
|
||||||
|
# ifdef S_IFBLK
|
||||||
|
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||||
|
# else
|
||||||
|
# define S_ISBLK(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISMPB /* 7 UNUSED multiplexed block */
|
||||||
|
# ifdef S_IFMPB
|
||||||
|
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||||
|
# else
|
||||||
|
# define S_ISMPB(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISREG /* 8 Regular file */
|
||||||
|
# ifdef S_IFREG
|
||||||
|
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||||
|
# else
|
||||||
|
# define S_ISREG(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISCNT /* 9 Contiguous file */
|
||||||
|
# ifdef S_IFCNT
|
||||||
|
# define S_ISCNT(m) (((m) & S_IFMT) == S_IFCNT)
|
||||||
|
# else
|
||||||
|
# define S_ISCNT(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISLNK /* 10 Symbolic link */
|
||||||
|
# ifdef S_IFLNK
|
||||||
|
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||||
|
# else
|
||||||
|
# define S_ISLNK(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISSHAD /* 11 Solaris shadow inode */
|
||||||
|
# ifdef S_IFSHAD
|
||||||
|
# define S_ISSHAD(m) (((m) & S_IFMT) == S_IFSHAD)
|
||||||
|
# else
|
||||||
|
# define S_ISSHAD(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISSOCK /* 12 UNIX domain socket */
|
||||||
|
# ifdef S_IFSOCK
|
||||||
|
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||||
|
# else
|
||||||
|
# define S_ISSOCK(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISDOOR /* 13 Solaris DOOR */
|
||||||
|
# ifdef S_IFDOOR
|
||||||
|
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
|
||||||
|
# else
|
||||||
|
# define S_ISDOOR(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISWHT /* 14 BSD whiteout */
|
||||||
|
# ifdef S_IFWHT
|
||||||
|
# define S_ISWHT(m) (((m) & S_IFMT) == S_ISWHT)
|
||||||
|
# else
|
||||||
|
# define S_ISWHT(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IFEVC /* 15 UNOS eventcount */
|
||||||
|
# ifdef S_IFEVC
|
||||||
|
# define S_ISEVC(m) (((m) & S_IFMT) == S_IFEVC)
|
||||||
|
# else
|
||||||
|
# define S_ISEVC(m) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_TYPEISMQ
|
||||||
|
/*
|
||||||
|
* XXX ??? where is a definition of a message queue ???
|
||||||
|
*/
|
||||||
|
# define S_TYPEISMQ(_stbuf) (0)
|
||||||
|
#endif
|
||||||
|
#ifndef S_TYPEISSEM
|
||||||
|
# ifdef S_INSEM
|
||||||
|
# define S_TYPEISSEM(_stbuf) (S_ISNAM((_stbuf)->st_mode) && (_stbuf)->st_rdev == S_INSEM)
|
||||||
|
# else
|
||||||
|
# define S_TYPEISSEM(_stbuf) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_TYPEISSHM
|
||||||
|
# ifdef S_INSHD
|
||||||
|
# define S_TYPEISSHM(_stbuf) (S_ISNAM((_stbuf)->st_mode) && (_stbuf)->st_rdev == S_INSHD)
|
||||||
|
# else
|
||||||
|
# define S_TYPEISSHM(_stbuf) (0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mode permission bits.
|
||||||
|
* UNIX V.7 has only S_ISUID/S_ISGID/S_ISVTX and S_IREAD/S_IWRITE/S_IEXEC
|
||||||
|
*/
|
||||||
|
#ifndef S_ISUID /* Set-user-ID on execution */
|
||||||
|
#define S_ISUID 0 /* If it is not defined, it is not supported */
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISGID /* Set-group-ID on execution */
|
||||||
|
#define S_ISGID 0 /* If it is not defined, it is not supported */
|
||||||
|
#endif
|
||||||
|
#ifndef S_ISVTX /* On directories, restricted deletion flag */
|
||||||
|
#define S_ISVTX 0 /* If it is not defined, it is not supported */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_IRUSR /* Read permission, owner */
|
||||||
|
#ifdef S_IREAD
|
||||||
|
#define S_IRUSR S_IREAD /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IRUSR 0400
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IWUSR /* Write permission, owner */
|
||||||
|
#ifdef S_IWRITE
|
||||||
|
#define S_IWUSR S_IWRITE /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IWUSR 0200
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IXUSR /* Execute/search permission, owner */
|
||||||
|
#ifdef S_IEXEC
|
||||||
|
#define S_IXUSR S_IEXEC /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IXUSR 0100
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IRGRP /* Read permission, group */
|
||||||
|
#ifdef S_IREAD
|
||||||
|
#define S_IRGRP (S_IREAD >> 3) /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IRGRP 040
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IWGRP /* Write permission, group */
|
||||||
|
#ifdef S_IWRITE
|
||||||
|
#define S_IWGRP (S_IWRITE >> 3) /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IWGRP 020
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IXGRP /* Execute/search permission, group */
|
||||||
|
#ifdef S_IEXEC
|
||||||
|
#define S_IXGRP (S_IEXEC >> 3) /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IXGRP 010
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IROTH /* Read permission, others */
|
||||||
|
#ifdef S_IREAD
|
||||||
|
#define S_IROTH (S_IREAD >> 6) /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IROTH 004
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IWOTH /* Write permission, others */
|
||||||
|
#ifdef S_IWRITE
|
||||||
|
#define S_IWOTH (S_IWRITE >> 6) /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IWOTH 002
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef S_IXOTH /* Execute/search permission, others */
|
||||||
|
#ifdef S_IEXEC
|
||||||
|
#define S_IXOTH (S_IEXEC >> 6) /* Needed on old UNIX systems */
|
||||||
|
#else
|
||||||
|
#define S_IXOTH 001
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_IRWXU /* Read, write, execute/search by owner */
|
||||||
|
#define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
|
||||||
|
#endif
|
||||||
|
#ifndef S_IRWXG /* Read, write, execute/search by group */
|
||||||
|
#define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
|
||||||
|
#endif
|
||||||
|
#ifndef S_IRWXO /* Read, write, execute/search by others */
|
||||||
|
#define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SCO UnixWare has st_atim.st__tim.tv_nsec but the st_atim.tv_nsec tests also
|
||||||
|
* succeeds. If we use st_atim.tv_nsec on UnixWare, we get a warning about
|
||||||
|
* illegal structure usage. For this reason, our code needs to have
|
||||||
|
* #ifdef HAVE_ST__TIM before #ifdef HAVE_ST_NSEC.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_ST_ATIMENSEC)
|
||||||
|
|
||||||
|
#define stat_ansecs(s) ((s)->st_atimensec)
|
||||||
|
#define stat_mnsecs(s) ((s)->st_mtimensec)
|
||||||
|
#define stat_cnsecs(s) ((s)->st_ctimensec)
|
||||||
|
|
||||||
|
#define _FOUND_STAT_NSECS_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_ST_SPARE1) && !defined(_FOUND_STAT_NSECS_)
|
||||||
|
|
||||||
|
#define stat_ansecs(s) ((s)->st_spare1 * 1000)
|
||||||
|
#define stat_mnsecs(s) ((s)->st_spare2 * 1000)
|
||||||
|
#define stat_cnsecs(s) ((s)->st_spare3 * 1000)
|
||||||
|
|
||||||
|
#define _FOUND_STAT_USECS_
|
||||||
|
#define _FOUND_STAT_NSECS_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_ST__TIM) && !defined(_FOUND_STAT_NSECS_)
|
||||||
|
|
||||||
|
#define stat_ansecs(s) ((s)->st_atim.st__tim.tv_nsec)
|
||||||
|
#define stat_mnsecs(s) ((s)->st_mtim.st__tim.tv_nsec)
|
||||||
|
#define stat_cnsecs(s) ((s)->st_ctim.st__tim.tv_nsec)
|
||||||
|
|
||||||
|
#define _FOUND_STAT_NSECS_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_ST_NSEC) && !defined(_FOUND_STAT_NSECS_)
|
||||||
|
|
||||||
|
#define stat_ansecs(s) ((s)->st_atim.tv_nsec)
|
||||||
|
#define stat_mnsecs(s) ((s)->st_mtim.tv_nsec)
|
||||||
|
#define stat_cnsecs(s) ((s)->st_ctim.tv_nsec)
|
||||||
|
|
||||||
|
#define _FOUND_STAT_NSECS_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_ST_ATIMESPEC) && !defined(_FOUND_STAT_NSECS_)
|
||||||
|
|
||||||
|
#define stat_ansecs(s) ((s)->st_atimespec.tv_nsec)
|
||||||
|
#define stat_mnsecs(s) ((s)->st_mtimespec.tv_nsec)
|
||||||
|
#define stat_cnsecs(s) ((s)->st_ctimespec.tv_nsec)
|
||||||
|
|
||||||
|
#define _FOUND_STAT_NSECS_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_FOUND_STAT_NSECS_)
|
||||||
|
#define stat_ansecs(s) (0)
|
||||||
|
#define stat_mnsecs(s) (0)
|
||||||
|
#define stat_cnsecs(s) (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _STATDEFS_H */
|
54
src/schily/stdxlib.h
Normal file
54
src/schily/stdxlib.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* @(#)stdxlib.h 1.6 01/07/15 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for stdlib
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STDXLIB_H
|
||||||
|
#define _STDXLIB_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#ifndef _INCL_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define _INCL_STDLIB_H
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
|
||||||
|
extern char *malloc();
|
||||||
|
extern char *realloc();
|
||||||
|
|
||||||
|
extern double atof();
|
||||||
|
|
||||||
|
#endif /* HAVE_STDLIB_H */
|
||||||
|
|
||||||
|
#ifndef EXIT_FAILURE
|
||||||
|
#define EXIT_FAILURE 1
|
||||||
|
#endif
|
||||||
|
#ifndef EXIT_SUCCESS
|
||||||
|
#define EXIT_SUCCESS 0
|
||||||
|
#endif
|
||||||
|
#ifndef RAND_MAX
|
||||||
|
#define RAND_MAX 32767
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _STDXLIB_H */
|
90
src/schily/stkframe.h
Normal file
90
src/schily/stkframe.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/* @(#)stkframe.h 1.10 03/06/15 Copyright 1995 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Common definitions for routines that parse the stack frame.
|
||||||
|
*
|
||||||
|
* This file has to be fixed if you want to port routines which use getfp().
|
||||||
|
* Have a look at struct frame below and use it as a sample,
|
||||||
|
* the new struct frame must at least contain a member 'fr_savfp'.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STKFRAME_H
|
||||||
|
#define _STKFRAME_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(sun) && (defined(SVR4) || defined(__SVR4) || defined(__SVR4__))
|
||||||
|
/*
|
||||||
|
* Solaris 2.x aka SunOS 5.x
|
||||||
|
*/
|
||||||
|
# ifdef i386
|
||||||
|
/*
|
||||||
|
* On Solaris 2.1 x86 sys/frame.h is not useful at all
|
||||||
|
* On Solaris 2.4 x86 sys/frame.h is buggy (fr_savfp is int!!)
|
||||||
|
*/
|
||||||
|
# ifndef _INCL_SYS_REG_H
|
||||||
|
# include <sys/reg.h>
|
||||||
|
# define _INCL_SYS_REG_H
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifndef _INCL_SYS_FRAME_H
|
||||||
|
# include <sys/frame.h>
|
||||||
|
# define _INCL_SYS_FRAME_H
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
# if defined(sun)
|
||||||
|
/*
|
||||||
|
* SunOS 4.x
|
||||||
|
*/
|
||||||
|
# ifndef _INCL_MACHINE_FRAME_H
|
||||||
|
# include <machine/frame.h>
|
||||||
|
# define _INCL_MACHINE_FRAME_H
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
/*
|
||||||
|
* Anything that is not SunOS
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: I hope this will be useful on other machines (no guarantee)
|
||||||
|
* XXX: It is taken from a sun Motorola system, but should also be useful
|
||||||
|
* XXX: on a i386.
|
||||||
|
* XXX: In general you have to write a sample program, set a breakpoint
|
||||||
|
* XXX: on a small function and inspect the stackframe with adb.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct frame {
|
||||||
|
struct frame *fr_savfp; /* saved frame pointer */
|
||||||
|
int fr_savpc; /* saved program counter */
|
||||||
|
int fr_arg[1]; /* array of arguments */
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# endif /* ! defined (sun) */
|
||||||
|
#endif /* ! defined (sun) && (defined(SVR4) || defined(__SVR4) || defined(__SVR4__)) */
|
||||||
|
|
||||||
|
#endif /* _STKFRAME_H */
|
114
src/schily/strdefs.h
Normal file
114
src/schily/strdefs.h
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/* @(#)strdefs.h 1.8 03/03/09 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for strings
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STRDEFS_H
|
||||||
|
#define _STRDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It may be that IBM's AIX has problems when doing
|
||||||
|
* #include <string.h>
|
||||||
|
* #include <strings.h>
|
||||||
|
* So I moved the #include <strings.h> to the top. As the file strings.h
|
||||||
|
* defines strcasecmp() we may need it...
|
||||||
|
*
|
||||||
|
* Note that the only real problem appears if we use rubbish FSF based code that
|
||||||
|
* #defines _NO_PROTO
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#ifndef _INCL_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#define _INCL_STRINGS_H
|
||||||
|
#endif
|
||||||
|
#endif /* HAVE_STRINGS_H */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
#ifndef _INCL_STRING_H
|
||||||
|
#include <string.h>
|
||||||
|
#define _INCL_STRING_H
|
||||||
|
#endif
|
||||||
|
#else /* HAVE_STRING_H */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void *memcpy __PR((void *, const void *, int));
|
||||||
|
extern void *memmove __PR((void *, const void *, int));
|
||||||
|
extern char *strcpy __PR((char *, const char *));
|
||||||
|
extern char *strncpy __PR((char *, const char *, int));
|
||||||
|
|
||||||
|
extern char *strcat __PR((char *, const char *));
|
||||||
|
extern char *strncat __PR((char *, const char *, int));
|
||||||
|
|
||||||
|
extern int memcmp __PR((const void *, const void *, int));
|
||||||
|
extern int strcmp __PR((const char *, const char *));
|
||||||
|
extern int strcoll __PR((const char *, const char *));
|
||||||
|
extern int strncmp __PR((const char *, const char *, int));
|
||||||
|
extern int strxfrm __PR((char *, const char *, int));
|
||||||
|
|
||||||
|
extern void *memchr __PR((const void *, int, int));
|
||||||
|
extern char *strchr __PR((const char *, int));
|
||||||
|
|
||||||
|
extern int strcspn __PR((const char *, const char *));
|
||||||
|
/*#pragma int_to_unsigned strcspn*/
|
||||||
|
|
||||||
|
extern char *strpbrk __PR((const char *, const char *));
|
||||||
|
extern char *strrchr __PR((const char *, int));
|
||||||
|
|
||||||
|
extern int strspn __PR((const char *, const char *));
|
||||||
|
/*#pragma int_to_unsigned strspn*/
|
||||||
|
|
||||||
|
extern char *strstr __PR((const char *, const char *));
|
||||||
|
extern char *strtok __PR((char *, const char *));
|
||||||
|
extern void *memset __PR((void *, int, int));
|
||||||
|
extern char *strerror __PR((int));
|
||||||
|
|
||||||
|
extern int strlen __PR((const char *));
|
||||||
|
/*#pragma int_to_unsigned strlen*/
|
||||||
|
|
||||||
|
extern void *memccpy __PR((void *, const void *, int, int));
|
||||||
|
|
||||||
|
extern int strcasecmp __PR((const char *, const char *));
|
||||||
|
extern int strncasecmp __PR((const char *, const char *, int));
|
||||||
|
|
||||||
|
/*#define index strchr*/
|
||||||
|
/*#define rindex strrchr*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* HAVE_STRING_H */
|
||||||
|
|
||||||
|
#endif /* _STRDEFS_H */
|
62
src/schily/termcap.h
Normal file
62
src/schily/termcap.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* @(#)termcap.h 1.6 03/06/15 Copyright 1995 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1995 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TERMCAP_H
|
||||||
|
#define _TERMCAP_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flags for tcsetflags()
|
||||||
|
*/
|
||||||
|
#define TCF_NO_TC 0x0001 /* Don't follow tc= entries */
|
||||||
|
#define TCF_NO_SIZE 0x0002 /* Don't get actual ttysize (li#/co#)*/
|
||||||
|
#define TCF_NO_STRIP 0x0004 /* Don't strip down termcap buffer */
|
||||||
|
|
||||||
|
extern char PC; /* Pad character */
|
||||||
|
extern char *BC; /* Backspace if not "\b" from "bc" capability*/
|
||||||
|
extern char *UP; /* Cursor up string from "up" capability */
|
||||||
|
extern short ospeed; /* output speed coded as in ioctl */
|
||||||
|
|
||||||
|
extern int tgetent __PR((char *bp, char *name));
|
||||||
|
extern int tcsetflags __PR((int flags));
|
||||||
|
extern char *tcgetbuf __PR((void));
|
||||||
|
extern int tgetnum __PR((char *ent));
|
||||||
|
extern BOOL tgetflag __PR((char *ent));
|
||||||
|
extern char *tgetstr __PR((char *ent, char **array));
|
||||||
|
extern char *tdecode __PR((char *ep, char **array));
|
||||||
|
|
||||||
|
extern int tputs __PR((char *cp, int affcnt, int (*outc)(int c)));
|
||||||
|
extern char *tgoto __PR((char *cm, int destcol, int destline));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TERMCAP_H */
|
101
src/schily/timedefs.h
Normal file
101
src/schily/timedefs.h
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/* @(#)timedefs.h 1.11 03/11/24 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Generic header for users of time(), gettimeofday() ...
|
||||||
|
*
|
||||||
|
* It includes definitions for time_t, struct timeval, ...
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TIMEDEFS_H
|
||||||
|
#define _TIMEDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h> /* Needed for time_t */
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TIME_WITH_SYS_TIME
|
||||||
|
# ifndef _INCL_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
# define _INCL_SYS_TIME_H
|
||||||
|
# endif
|
||||||
|
# ifndef _INCL_TIME_H
|
||||||
|
# include <time.h>
|
||||||
|
# define _INCL_TIME_H
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# ifndef _INCL_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
# define _INCL_SYS_TIME_H
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifndef _INCL_TIME_H
|
||||||
|
# include <time.h>
|
||||||
|
# define _INCL_TIME_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__CYGWIN32__) || defined(__EMX__) || defined(__linux__) || defined(__DJGPP__)
|
||||||
|
/*
|
||||||
|
* Cygnus defines struct timeval in sys/time.h but not timerclear
|
||||||
|
* timerclear is defined in windows32/Sockets.h ???
|
||||||
|
*
|
||||||
|
* EMX for OS/2 defines struct timeval in sys/time.h but not timerclear
|
||||||
|
*
|
||||||
|
* Linux defines struct timeval in sys/time.h but if __USE_BSD is not
|
||||||
|
* defined, timerclear is missing.
|
||||||
|
*/
|
||||||
|
#ifndef timerclear
|
||||||
|
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef timerclear
|
||||||
|
|
||||||
|
#ifndef VMS
|
||||||
|
struct timeval {
|
||||||
|
long tv_sec;
|
||||||
|
long tv_usec;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct timezone {
|
||||||
|
int tz_minuteswest;
|
||||||
|
int tz_dsttime;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TIMEDEFS_H */
|
120
src/schily/ttydefs.h
Normal file
120
src/schily/ttydefs.h
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/* @(#)ttydefs.h 1.26 03/02/28 Copyright 1984-2003 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Terminal driver tty mode handling
|
||||||
|
*
|
||||||
|
* Copyright (c) 1984-2003 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _TTYDEFS_H
|
||||||
|
#define _TTYDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JOS
|
||||||
|
# include <ttymodes.h>
|
||||||
|
# include <spfcode.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_TERMIOS_H
|
||||||
|
# include <termios.h>
|
||||||
|
# define _INCL_TERMIOS_H
|
||||||
|
# ifdef TIOCGETA /* FreeBSD */
|
||||||
|
# define TCGETS TIOCGETA
|
||||||
|
# define TCSETSW TIOCSETAW
|
||||||
|
# endif
|
||||||
|
# ifdef TCGETATTR
|
||||||
|
# define TCGETS TCGETATTR
|
||||||
|
# define TCSETSW TCSETATTRD
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_TERMIO_H
|
||||||
|
# include <termio.h>
|
||||||
|
# define _INCL_TERMIO_H
|
||||||
|
# ifndef TCGETS
|
||||||
|
# define termios termio
|
||||||
|
# define TCGETS TCGETA
|
||||||
|
# define TCSETSW TCSETAW
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define USE_V7_TTY
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_TCGETATTR) || !defined(HAVE_TCSETATTR)
|
||||||
|
# undef TCSANOW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TCSANOW
|
||||||
|
# if !defined(TCGETS) || !defined(TCSETSW)
|
||||||
|
# define USE_V7_TTY
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_INCL_TERMIOS_H) && !defined(_INCL_TERMIO_H)
|
||||||
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
|
# ifndef _INCL_SYS_IOCTl_H
|
||||||
|
# include <sys/ioctl.h>
|
||||||
|
# define _INCL_SYS_IOCTL_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_BSDTTY_H
|
||||||
|
#include <sys/bsdtty.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(TIOCGWINSZ) && ! defined(TIOCGSIZE)
|
||||||
|
# ifndef _INCL_SYS_IOCTl_H
|
||||||
|
# include <sys/ioctl.h>
|
||||||
|
# define _INCL_SYS_IOCTL_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef OXTABS /* OS/2 EMX */
|
||||||
|
#define OXTABS 0
|
||||||
|
#endif
|
||||||
|
#ifndef XTABS
|
||||||
|
# ifndef TAB3 /* FreeBSD */
|
||||||
|
# define TABDLY OXTABS
|
||||||
|
# define XTABS OXTABS
|
||||||
|
# else
|
||||||
|
# define XTABS TAB3
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef ONLCR /* OS/2 EMX */
|
||||||
|
#define ONLCR 0
|
||||||
|
#endif
|
||||||
|
#ifndef OCRNL /* FreeBSD */
|
||||||
|
# define OCRNL 0
|
||||||
|
#endif
|
||||||
|
#ifndef ONLRET /* FreeBSD */
|
||||||
|
# define ONLRET 0
|
||||||
|
#endif
|
||||||
|
#ifndef _POSIX_VDISABLE
|
||||||
|
# define _POSIX_VDISABLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TTYDEFS_H */
|
121
src/schily/unixstd.h
Normal file
121
src/schily/unixstd.h
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/* @(#)unixstd.h 1.12 04/06/17 Copyright 1996 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for unix system interface
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UNIXSTD_H
|
||||||
|
#define _UNIXSTD_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
#ifndef _INCL_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#define _INCL_UNISTD_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _SC_PAGESIZE
|
||||||
|
#ifdef _SC_PAGE_SIZE /* HP/UX & OSF */
|
||||||
|
#define _SC_PAGESIZE _SC_PAGE_SIZE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* HAVE_UNISTD_H */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* unistd.h grants things like off_t to be typedef'd.
|
||||||
|
*/
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* HAVE_UNISTD_H */
|
||||||
|
|
||||||
|
#ifndef STDIN_FILENO
|
||||||
|
# ifdef JOS
|
||||||
|
# ifndef _JOS_IO_H
|
||||||
|
# include <jos_io.h>
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define STDIN_FILENO 0
|
||||||
|
# define STDOUT_FILENO 1
|
||||||
|
# define STDERR_FILENO 2
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef R_OK
|
||||||
|
/* Symbolic constants for the "access" routine: */
|
||||||
|
#define R_OK 4 /* Test for Read permission */
|
||||||
|
#define W_OK 2 /* Test for Write permission */
|
||||||
|
#define X_OK 1 /* Test for eXecute permission */
|
||||||
|
#define F_OK 0 /* Test for existence of File */
|
||||||
|
#endif
|
||||||
|
#ifndef E_OK
|
||||||
|
#ifdef HAVE_ACCESS_E_OK
|
||||||
|
#ifdef EFF_ONLY_OK
|
||||||
|
#define E_OK EFF_ONLY_OK /* Irix */
|
||||||
|
#else
|
||||||
|
#ifdef EUID_OK
|
||||||
|
#define E_OK EUID_OK /* UNICOS (0400) */
|
||||||
|
#else
|
||||||
|
#define E_OK 010 /* Test effective uids */
|
||||||
|
#endif /* EUID_OK */
|
||||||
|
#endif /* EFF_ONLY_OK */
|
||||||
|
#else
|
||||||
|
#define E_OK 0
|
||||||
|
#endif /* HAVE_ACCESS_E_OK */
|
||||||
|
#endif /* !E_OK */
|
||||||
|
|
||||||
|
/* Symbolic constants for the "lseek" routine: */
|
||||||
|
#ifndef SEEK_SET
|
||||||
|
#define SEEK_SET 0 /* Set file pointer to "offset" */
|
||||||
|
#endif
|
||||||
|
#ifndef SEEK_CUR
|
||||||
|
#define SEEK_CUR 1 /* Set file pointer to current plus "offset" */
|
||||||
|
#endif
|
||||||
|
#ifndef SEEK_END
|
||||||
|
#define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_UNISTD_H) || !defined(_POSIX_VERSION)
|
||||||
|
/*
|
||||||
|
* Maybe we need a lot more definitions here...
|
||||||
|
* It is not clear whether we should have prototyped definitions.
|
||||||
|
*/
|
||||||
|
extern int access __PR((const char *, int));
|
||||||
|
extern int close __PR((int));
|
||||||
|
extern int dup __PR((int));
|
||||||
|
extern int dup2 __PR((int, int));
|
||||||
|
extern void _exit __PR((int));
|
||||||
|
extern int link __PR((const char *, const char *));
|
||||||
|
extern int read __PR((int, void *, size_t));
|
||||||
|
extern int unlink __PR((const char *));
|
||||||
|
extern int write __PR((int, void *, size_t));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _UNIXSTD_H */
|
76
src/schily/unls.h
Normal file
76
src/schily/unls.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/* @(#)unls.h 1.5 03/06/15 2000 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Modifications to make the code portable Copyright (c) 2000 J. Schilling
|
||||||
|
*
|
||||||
|
* Code taken from the Linux kernel.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UNLS_H
|
||||||
|
#define _UNLS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ICONV
|
||||||
|
#include <iconv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct nls_unicode {
|
||||||
|
unsigned char uni1;
|
||||||
|
unsigned char uni2;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nls_table {
|
||||||
|
char *charset;
|
||||||
|
unsigned char **page_uni2charset;
|
||||||
|
struct nls_unicode *charset2uni;
|
||||||
|
#ifdef USE_ICONV
|
||||||
|
iconv_t iconv_d;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void (*inc_use_count) __PR((void));
|
||||||
|
void (*dec_use_count) __PR((void));
|
||||||
|
struct nls_table *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int init_nls __PR((void));
|
||||||
|
extern int register_nls __PR((struct nls_table *));
|
||||||
|
extern int unregister_nls __PR((struct nls_table *));
|
||||||
|
extern struct nls_table *find_nls __PR((char *));
|
||||||
|
extern void list_nls __PR((void));
|
||||||
|
extern struct nls_table *load_nls __PR((char *));
|
||||||
|
extern void unload_nls __PR((struct nls_table *));
|
||||||
|
extern struct nls_table *load_nls_default __PR((void));
|
||||||
|
extern int init_nls_file __PR((char * name));
|
||||||
|
#ifdef USE_ICONV
|
||||||
|
extern int init_nls_iconv __PR((char * name));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _UNLS_H */
|
66
src/schily/unls.h.utf8
Normal file
66
src/schily/unls.h.utf8
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* @(#)unls.h 1.5 03/06/15 2000 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Modifications to make the code portable Copyright (c) 2000 J. Schilling
|
||||||
|
*
|
||||||
|
* Code taken from the Linux kernel.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UNLS_H
|
||||||
|
#define _UNLS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PROTOTYP_H
|
||||||
|
#include <prototyp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct nls_unicode {
|
||||||
|
unsigned char uni1;
|
||||||
|
unsigned char uni2;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nls_table {
|
||||||
|
char *charset;
|
||||||
|
unsigned char **page_uni2charset;
|
||||||
|
struct nls_unicode *charset2uni;
|
||||||
|
|
||||||
|
void (*inc_use_count) __PR((void));
|
||||||
|
void (*dec_use_count) __PR((void));
|
||||||
|
struct nls_table *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int init_nls __PR((void));
|
||||||
|
extern int register_nls __PR((struct nls_table *));
|
||||||
|
extern int unregister_nls __PR((struct nls_table *));
|
||||||
|
extern struct nls_table *find_nls __PR((char *));
|
||||||
|
extern void list_nls __PR((void));
|
||||||
|
extern struct nls_table *load_nls __PR((char *));
|
||||||
|
extern void unload_nls __PR((struct nls_table *));
|
||||||
|
extern struct nls_table *load_nls_default __PR((void));
|
||||||
|
extern int init_nls_file __PR((char * name));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _UNLS_H */
|
76
src/schily/utimdefs.h
Normal file
76
src/schily/utimdefs.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/* @(#)utimdefs.h 1.5 03/06/15 Copyright 2001 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Defines for utimes() / utime()
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UTIMDEFS_H
|
||||||
|
#define _UTIMDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UTIMES
|
||||||
|
#ifndef _TIMEDEFS_H
|
||||||
|
#include <timedefs.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UTIME_H
|
||||||
|
#ifndef _INCL_UTIME_H
|
||||||
|
#include <utime.h>
|
||||||
|
#define _INCL_UTIME_H
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_SYS_UTIME_H
|
||||||
|
#ifndef _INCL_SYS_UTIME_H
|
||||||
|
#include <sys/utime.h>
|
||||||
|
#define _INCL_SYS_UTIME_H
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
struct utimbuf {
|
||||||
|
time_t actime;
|
||||||
|
time_t modtime;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __comment__
|
||||||
|
/*
|
||||||
|
* file.c contains this
|
||||||
|
* I am not sure if it is really needed.
|
||||||
|
* It may be a good idea to add a test for HAVE_STRUCT_UTIMBUF
|
||||||
|
* as in gnutar.
|
||||||
|
*/
|
||||||
|
#if (__COHERENT__ >= 0x420)
|
||||||
|
# include <sys/utime.h>
|
||||||
|
#else
|
||||||
|
# include <utime.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __comment__ */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _UTIMDEFS_H */
|
339
src/schily/utypes.h
Normal file
339
src/schily/utypes.h
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
/* @(#)utypes.h 1.11 03/06/15 Copyright 1997 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions for some user defined types
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UTYPES_H
|
||||||
|
#define _UTYPES_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include limits.h for CHAR_BIT
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_LIMITS_H
|
||||||
|
#ifndef _INCL_LIMITS_H
|
||||||
|
#include <limits.h>
|
||||||
|
#define _INCL_LIMITS_H
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CHAR_BIT
|
||||||
|
#define CHAR_BIT 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These macros may not work on all platforms but as we depend
|
||||||
|
* on two's complement in many places, they do not reduce portability.
|
||||||
|
*/
|
||||||
|
#define TYPE_ISSIGNED(t) (((t)-1) < ((t)0))
|
||||||
|
#define TYPE_MSBVAL(t) ((t)(~((t)0) << (sizeof (t)*CHAR_BIT - 1)))
|
||||||
|
#define TYPE_MINVAL(t) (TYPE_ISSIGNED(t) \
|
||||||
|
? TYPE_MSBVAL(t) \
|
||||||
|
: ((t)0))
|
||||||
|
#define TYPE_MAXVAL(t) ((t)(~((t)0) - TYPE_MINVAL(t)))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Let us include system defined types too.
|
||||||
|
*/
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __CHAR_UNSIGNED__ /* GNU GCC define (dynamic) */
|
||||||
|
#ifndef CHAR_IS_UNSIGNED
|
||||||
|
#define CHAR_IS_UNSIGNED /* Sing Schily define (static) */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Several unsigned cardinal types
|
||||||
|
*/
|
||||||
|
typedef unsigned long Ulong;
|
||||||
|
typedef unsigned int Uint;
|
||||||
|
typedef unsigned short Ushort;
|
||||||
|
typedef unsigned char Uchar;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a definition for a compiler dependant 64 bit type.
|
||||||
|
* It currently is silently a long if the compiler does not
|
||||||
|
* support it. Check if this is the right way.
|
||||||
|
*/
|
||||||
|
#ifndef NO_LONGLONG
|
||||||
|
# if defined(HAVE_LONGLONG)
|
||||||
|
# define USE_LONGLONG
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_LONGLONG
|
||||||
|
|
||||||
|
typedef long long Llong;
|
||||||
|
typedef unsigned long long Ullong;
|
||||||
|
|
||||||
|
#define SIZEOF_LLONG SIZEOF_LONG_LONG
|
||||||
|
#define SIZEOF_ULLONG SIZEOF_UNSIGNED_LONG_LONG
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef long Llong;
|
||||||
|
typedef unsigned long Ullong;
|
||||||
|
|
||||||
|
#define SIZEOF_LLONG SIZEOF_LONG
|
||||||
|
#define SIZEOF_ULLONG SIZEOF_UNSIGNED_LONG
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The IBM AIX C-compiler seems to be the only compiler on the world
|
||||||
|
* which does not allow to use unsigned char bit fields as a hint
|
||||||
|
* for packed bit fields. Define a pesical type to avoid warnings.
|
||||||
|
* The packed attribute is honored wit unsigned int in this case too.
|
||||||
|
*/
|
||||||
|
#if defined(_AIX) && !defined(__GNUC__)
|
||||||
|
|
||||||
|
typedef unsigned int Ucbit;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef unsigned char Ucbit;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start inttypes.h emulation.
|
||||||
|
*
|
||||||
|
* Thanks to Solaris 2.4 and even recent 1999 Linux versions, we
|
||||||
|
* cannot use the official UNIX-98 names here. Old Solaris versions
|
||||||
|
* define parts of the types in some exotic include files.
|
||||||
|
* Linux even defines incompatible types in <sys/types.h>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_INTTYPES_H
|
||||||
|
# ifndef _INCL_INTTYPES_H
|
||||||
|
# include <inttypes.h>
|
||||||
|
# define _INCL_INTTYPES_H
|
||||||
|
# endif
|
||||||
|
# define HAVE_INT64_T
|
||||||
|
# define HAVE_UINT64_T
|
||||||
|
|
||||||
|
#define Int8_t int8_t
|
||||||
|
#define Int16_t int16_t
|
||||||
|
#define Int32_t int32_t
|
||||||
|
#define Int64_t int64_t
|
||||||
|
#define Intmax_t intmax_t
|
||||||
|
#define UInt8_t uint8_t
|
||||||
|
#define UInt16_t uint16_t
|
||||||
|
#define UInt32_t uint32_t
|
||||||
|
#define UInt64_t uint64_t
|
||||||
|
#define UIntmax_t uintmax_t
|
||||||
|
|
||||||
|
#define Intptr_t intptr_t
|
||||||
|
#define UIntptr_t uintptr_t
|
||||||
|
|
||||||
|
#else /* !HAVE_INTTYPES_H */
|
||||||
|
|
||||||
|
#if SIZEOF_CHAR != 1 || SIZEOF_UNSIGNED_CHAR != 1
|
||||||
|
/*
|
||||||
|
* #error will not work for all compilers (e.g. sunos4)
|
||||||
|
* The following line will abort compilation on all compilers
|
||||||
|
* if the above is true. And that's what we want.
|
||||||
|
*/
|
||||||
|
error Sizeof char is not equal 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__STDC__) || defined(CHAR_IS_UNSIGNED)
|
||||||
|
typedef signed char Int8_t;
|
||||||
|
#else
|
||||||
|
typedef char Int8_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_SHORT_INT == 2
|
||||||
|
typedef short Int16_t;
|
||||||
|
#else
|
||||||
|
error No int16_t found
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_INT == 4
|
||||||
|
typedef int Int32_t;
|
||||||
|
#else
|
||||||
|
error No int32_t found
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_LONG_INT == 8
|
||||||
|
typedef long Int64_t;
|
||||||
|
# define HAVE_INT64_T
|
||||||
|
#else
|
||||||
|
#if SIZEOF_LONG_LONG == 8
|
||||||
|
typedef long long Int64_t;
|
||||||
|
# define HAVE_INT64_T
|
||||||
|
#else
|
||||||
|
/* error No int64_t found*/
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_CHAR_P == SIZEOF_INT
|
||||||
|
typedef int Intptr_t;
|
||||||
|
#else
|
||||||
|
#if SIZEOF_CHAR_P == SIZEOF_LONG_INT
|
||||||
|
typedef long Intptr_t;
|
||||||
|
#else
|
||||||
|
error No intptr_t found
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned char UInt8_t;
|
||||||
|
|
||||||
|
#if SIZEOF_UNSIGNED_SHORT_INT == 2
|
||||||
|
typedef unsigned short UInt16_t;
|
||||||
|
#else
|
||||||
|
error No uint16_t found
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_UNSIGNED_INT == 4
|
||||||
|
typedef unsigned int UInt32_t;
|
||||||
|
#else
|
||||||
|
error No int32_t found
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_UNSIGNED_LONG_INT == 8
|
||||||
|
typedef unsigned long UInt64_t;
|
||||||
|
# define HAVE_UINT64_T
|
||||||
|
#else
|
||||||
|
#if SIZEOF_UNSIGNED_LONG_LONG == 8
|
||||||
|
typedef unsigned long long UInt64_t;
|
||||||
|
# define HAVE_UINT64_T
|
||||||
|
#else
|
||||||
|
/* error No uint64_t found*/
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Intmax_t Llong
|
||||||
|
#define UIntmax_t Ullong
|
||||||
|
|
||||||
|
#if SIZEOF_CHAR_P == SIZEOF_UNSIGNED_INT
|
||||||
|
typedef unsigned int UIntptr_t;
|
||||||
|
#else
|
||||||
|
#if SIZEOF_CHAR_P == SIZEOF_UNSIGNED_LONG_INT
|
||||||
|
typedef unsigned long UIntptr_t;
|
||||||
|
#else
|
||||||
|
error No uintptr_t found
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* HAVE_INTTYPES_H */
|
||||||
|
|
||||||
|
#ifndef CHAR_MIN
|
||||||
|
#define CHAR_MIN TYPE_MINVAL(char)
|
||||||
|
#endif
|
||||||
|
#ifndef CHAR_MAX
|
||||||
|
#define CHAR_MAX TYPE_MAXVAL(char)
|
||||||
|
#endif
|
||||||
|
#ifndef UCHAR_MAX
|
||||||
|
#define UCHAR_MAX TYPE_MAXVAL(unsigned char)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SHRT_MIN
|
||||||
|
#define SHRT_MIN TYPE_MINVAL(short)
|
||||||
|
#endif
|
||||||
|
#ifndef SHRT_MAX
|
||||||
|
#define SHRT_MAX TYPE_MAXVAL(short)
|
||||||
|
#endif
|
||||||
|
#ifndef USHRT_MAX
|
||||||
|
#define USHRT_MAX TYPE_MAXVAL(unsigned short)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT_MIN
|
||||||
|
#define INT_MIN TYPE_MINVAL(int)
|
||||||
|
#endif
|
||||||
|
#ifndef INT_MAX
|
||||||
|
#define INT_MAX TYPE_MAXVAL(int)
|
||||||
|
#endif
|
||||||
|
#ifndef UINT_MAX
|
||||||
|
#define UINT_MAX TYPE_MAXVAL(unsigned int)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LONG_MIN
|
||||||
|
#define LONG_MIN TYPE_MINVAL(long)
|
||||||
|
#endif
|
||||||
|
#ifndef LONG_MAX
|
||||||
|
#define LONG_MAX TYPE_MAXVAL(long)
|
||||||
|
#endif
|
||||||
|
#ifndef ULONG_MAX
|
||||||
|
#define ULONG_MAX TYPE_MAXVAL(unsigned long)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT8_MIN
|
||||||
|
#define INT8_MIN TYPE_MINVAL(Int8_t)
|
||||||
|
#endif
|
||||||
|
#ifndef INT8_MAX
|
||||||
|
#define INT8_MAX TYPE_MAXVAL(Int8_t)
|
||||||
|
#endif
|
||||||
|
#ifndef UINT8_MAX
|
||||||
|
#define UINT8_MAX TYPE_MAXVAL(UInt8_t)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT16_MIN
|
||||||
|
#define INT16_MIN TYPE_MINVAL(Int16_t)
|
||||||
|
#endif
|
||||||
|
#ifndef INT16_MAX
|
||||||
|
#define INT16_MAX TYPE_MAXVAL(Int16_t)
|
||||||
|
#endif
|
||||||
|
#ifndef UINT16_MAX
|
||||||
|
#define UINT16_MAX TYPE_MAXVAL(UInt16_t)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT32_MIN
|
||||||
|
#define INT32_MIN TYPE_MINVAL(Int32_t)
|
||||||
|
#endif
|
||||||
|
#ifndef INT32_MAX
|
||||||
|
#define INT32_MAX TYPE_MAXVAL(Int32_t)
|
||||||
|
#endif
|
||||||
|
#ifndef UINT32_MAX
|
||||||
|
#define UINT32_MAX TYPE_MAXVAL(UInt32_t)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_INT64_T
|
||||||
|
#ifndef INT64_MIN
|
||||||
|
#define INT64_MIN TYPE_MINVAL(Int64_t)
|
||||||
|
#endif
|
||||||
|
#ifndef INT64_MAX
|
||||||
|
#define INT64_MAX TYPE_MAXVAL(Int64_t)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UINT64_T
|
||||||
|
#ifndef UINT64_MAX
|
||||||
|
#define UINT64_MAX TYPE_MAXVAL(UInt64_t)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INTMAX_MIN
|
||||||
|
#define INTMAX_MIN TYPE_MINVAL(Intmax_t)
|
||||||
|
#endif
|
||||||
|
#ifndef INTMAX_MAX
|
||||||
|
#define INTMAX_MAX TYPE_MAXVAL(Intmax_t)
|
||||||
|
#endif
|
||||||
|
#ifndef UINTMAX_MAX
|
||||||
|
#define UINTMAX_MAX TYPE_MAXVAL(UIntmax_t)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _UTYPES_H */
|
120
src/schily/vadefs.h
Normal file
120
src/schily/vadefs.h
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/* @(#)vadefs.h 1.5 01/07/15 Copyright 1998 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Generic header for users of var args ...
|
||||||
|
*
|
||||||
|
* Includes a default definition for va_copy()
|
||||||
|
* and some magic know how about the SVr4 Power PC var args ABI
|
||||||
|
* to create a __va_arg_list() macro.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _VADEFS_H
|
||||||
|
#define _VADEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PROTOTYPES
|
||||||
|
/*
|
||||||
|
* For ANSI C-compilers prefer stdarg.h
|
||||||
|
*/
|
||||||
|
# ifdef HAVE_STDARG_H
|
||||||
|
# ifndef _INCL_STDARG_H
|
||||||
|
# include <stdarg.h>
|
||||||
|
# define _INCL_STDARG_H
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifndef _INCL_VARARGS_H
|
||||||
|
# include <varargs.h>
|
||||||
|
# define _INCL_VARARGS_H
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* For K&R C-compilers prefer varargs.h
|
||||||
|
*/
|
||||||
|
# ifdef HAVE_VARARGS_H
|
||||||
|
# ifndef _INCL_VARARGS_H
|
||||||
|
# include <varargs.h>
|
||||||
|
# define _INCL_VARARGS_H
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifndef _INCL_STDARG_H
|
||||||
|
# include <stdarg.h>
|
||||||
|
# define _INCL_STDARG_H
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__linux__) || defined(__linux) || defined(sun)) && \
|
||||||
|
(defined(__ppc) || defined(__PPC) || defined(powerpc) || defined(__powerpc__))
|
||||||
|
|
||||||
|
# ifndef VA_LIST_IS_ARRAY
|
||||||
|
# define VA_LIST_IS_ARRAY
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* __va_copy() is used by GCC 2.8 or newer until va_copy() becomes
|
||||||
|
* a final ISO standard.
|
||||||
|
*/
|
||||||
|
#if !defined(va_copy) && !defined(HAVE_VA_COPY)
|
||||||
|
# if defined(__va_copy)
|
||||||
|
# define va_copy(to, from) __va_copy(to, from)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* va_copy() is a Solaris extension to provide a portable way to perform a
|
||||||
|
* variable argument list "bookmarking" function.
|
||||||
|
* If it is not available via stdarg.h, use a simple assignement for backward
|
||||||
|
* compatibility.
|
||||||
|
*/
|
||||||
|
#if !defined(va_copy) && !defined(HAVE_VA_COPY)
|
||||||
|
#ifdef VA_LIST_IS_ARRAY
|
||||||
|
# define va_copy(to, from) ((to)[0] = (from)[0])
|
||||||
|
#else
|
||||||
|
# define va_copy(to, from) ((to) = (from))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I don't know any portable way to get an arbitrary
|
||||||
|
* C object from a var arg list so I use a
|
||||||
|
* system-specific routine __va_arg_list() that knows
|
||||||
|
* if 'va_list' is an array. You will not be able to
|
||||||
|
* assign the value of __va_arg_list() but it works
|
||||||
|
* to be used as an argument of a function.
|
||||||
|
* It is a requirement for recursive printf to be able
|
||||||
|
* to use this function argument. If your system
|
||||||
|
* defines va_list to be an array you need to know this
|
||||||
|
* via autoconf or another mechanism.
|
||||||
|
* It would be nice to have something like
|
||||||
|
* __va_arg_list() in stdarg.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef VA_LIST_IS_ARRAY
|
||||||
|
# define __va_arg_list(list) va_arg(list, void *)
|
||||||
|
#else
|
||||||
|
# define __va_arg_list(list) va_arg(list, va_list)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _VADEFS_H */
|
141
src/schily/waitdefs.h
Normal file
141
src/schily/waitdefs.h
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/* @(#)waitdefs.h 1.10 03/02/25 Copyright 1995-2003 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Definitions to deal with various kinds of wait flavour
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995-2003 J. Schilling
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; see the file COPYING. If not, write to the Free Software
|
||||||
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _WAITDEFS_H
|
||||||
|
#define _WAITDEFS_H
|
||||||
|
|
||||||
|
#ifndef _MCONFIG_H
|
||||||
|
#include <mconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Needed for SysVr4
|
||||||
|
*/
|
||||||
|
#ifndef _INCL_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define _INCL_SYS_TYPES_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_WAIT_H)
|
||||||
|
# ifndef _INCL_WAIT_H
|
||||||
|
# include <wait.h>
|
||||||
|
# define _INCL_WAIT_H
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* K&R Compiler doesn't like #elif
|
||||||
|
*/
|
||||||
|
# if defined(HAVE_SYS_WAIT_H) /* POSIX.1 compl. sys/wait.h */
|
||||||
|
# undef HAVE_UNION_WAIT /* POSIX.1 doesn't use U_W */
|
||||||
|
# ifndef _INCL_SYS_WAIT_H
|
||||||
|
# include <sys/wait.h>
|
||||||
|
# define _INCL_SYS_WAIT_H
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# if defined(HAVE_UNION_WAIT) /* Pure BSD U_W / sys/wait.h */
|
||||||
|
# ifndef _INCL_SYS_WAIT_H
|
||||||
|
# include <sys/wait.h>
|
||||||
|
# define _INCL_SYS_WAIT_H
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNION_WAIT
|
||||||
|
# define WAIT_T union wait
|
||||||
|
# ifndef WSTOPPED
|
||||||
|
# define WSTOPPED 0x7F
|
||||||
|
# endif
|
||||||
|
# ifndef WTERMSIG
|
||||||
|
# define WTERMSIG(status) ((status).w_termsig)
|
||||||
|
# endif
|
||||||
|
# ifndef WCOREDUMP
|
||||||
|
# define WCOREDUMP(status) ((status).w_coredump)
|
||||||
|
# endif
|
||||||
|
# ifndef WEXITSTATUS
|
||||||
|
# define WEXITSTATUS(status) ((status).w_retcode)
|
||||||
|
# endif
|
||||||
|
# ifndef WSTOPSIG
|
||||||
|
# define WSTOPSIG(status) ((status).w_stopsig)
|
||||||
|
# endif
|
||||||
|
# ifndef WIFSTOPPED
|
||||||
|
# define WIFSTOPPED(status) ((status).w_stopval == \
|
||||||
|
WSTOPPED)
|
||||||
|
# endif
|
||||||
|
# ifndef WIFSIGNALED
|
||||||
|
# define WIFSIGNALED(status) ((status).w_stopval != \
|
||||||
|
WSTOPPED && \
|
||||||
|
(status).w_termsig != 0)
|
||||||
|
# endif
|
||||||
|
# ifndef WIFEXITED
|
||||||
|
# define WIFEXITED(status) ((status).w_stopval != \
|
||||||
|
WSTOPPED && \
|
||||||
|
(status).w_termsig == 0)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define WAIT_T int
|
||||||
|
# ifndef WTERMSIG
|
||||||
|
# define WTERMSIG(status) ((status) & 0x7F)
|
||||||
|
# endif
|
||||||
|
# ifndef WCOREDUMP
|
||||||
|
# define WCOREDUMP(status) ((status) & 0x80)
|
||||||
|
# endif
|
||||||
|
# ifndef WEXITSTATUS
|
||||||
|
# define WEXITSTATUS(status) (((status) >> 8) & 0xFF)
|
||||||
|
# endif
|
||||||
|
# ifndef WSTOPSIG
|
||||||
|
# define WSTOPSIG(status) (((status) >> 8) & 0xFF)
|
||||||
|
# endif
|
||||||
|
# ifndef WIFSTOPPED
|
||||||
|
# define WIFSTOPPED(status) (((status) & 0xFF) == 0x7F)
|
||||||
|
# endif
|
||||||
|
# ifndef WIFSIGNALED
|
||||||
|
# define WIFSIGNALED(status) (((status) & 0xFF) != 0x7F && \
|
||||||
|
WTERMSIG(status) != 0)
|
||||||
|
# endif
|
||||||
|
# ifndef WIFEXITED
|
||||||
|
# define WIFEXITED(status) (((status) & 0xFF) == 0)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WCOREFLG
|
||||||
|
#define WCOREFLG 0x80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WSTOPFLG
|
||||||
|
#define WSTOPFLG 0x7F
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WCONTFLG
|
||||||
|
#define WCONTFLG 0xFFFF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _WAITDEFS_H */
|
550
src/schily/xconfig.h
Normal file
550
src/schily/xconfig.h
Normal file
@ -0,0 +1,550 @@
|
|||||||
|
/* xconfig.h. Generated automatically by configure. */
|
||||||
|
/* @(#)xconfig.h.in 1.76 04/07/26 Copyright 1998-2003 J. Schilling */
|
||||||
|
/*
|
||||||
|
* Dynamic autoconf C-include code.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998-2003 J. Schilling
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Header Files
|
||||||
|
*/
|
||||||
|
#define PROTOTYPES 1 /* if Compiler supports ANSI C prototypes */
|
||||||
|
#define HAVE_STDARG_H 1 /* to use stdarg.h, else use varargs.h NOTE: SaberC on a Sun has prototypes but no stdarg.h */
|
||||||
|
/* #undef HAVE_VARARGS_H */ /* to use use varargs.h NOTE: The free HP-UX C-compiler has stdarg.h but no PROTOTYPES */
|
||||||
|
#define HAVE_STDLIB_H 1 /* to use general utility defines (malloc(), size_t ...) and general C library prototypes */
|
||||||
|
#define HAVE_STDDEF_H 1 /* to use offsetof(), ptrdiff_t, wchar>t, size_t */
|
||||||
|
#define HAVE_STRING_H 1 /* to get NULL and ANSI C string function prototypes */
|
||||||
|
#define HAVE_STRINGS_H 1 /* to get BSD string function prototypes */
|
||||||
|
#define STDC_HEADERS 1 /* if ANSI compliant stdlib.h, stdarg.h, string.h, float.h are present */
|
||||||
|
#define HAVE_UNISTD_H 1 /* to get POSIX syscall prototypes XXX sys/file.h fcntl.h (unixstd/fctl)XXX*/
|
||||||
|
#define HAVE_GETOPT_H 1 /* to get getopt() prototype from getopt.h instead of unistd.h */
|
||||||
|
#define HAVE_LIMITS_H 1 /* to get POSIX numeric limits constants */
|
||||||
|
#define HAVE_A_OUT_H 1 /* if a.out.h is present (may be a system using a.out format) */
|
||||||
|
/* #undef HAVE_AOUTHDR_H */ /* if aouthdr.h is present. This is a COFF system */
|
||||||
|
#define HAVE_ELF_H 1 /* if elf.h is present. This is an ELF system */
|
||||||
|
#define HAVE_FCNTL_H 1 /* to access, O_XXX constants for open(), otherwise use sys/file.h */
|
||||||
|
#define HAVE_SYS_FILE_H 1 /* to use O_XXX constants for open() and flock() defs */
|
||||||
|
#define HAVE_INTTYPES_H 1 /* to use UNIX-98 inttypes.h */
|
||||||
|
#define HAVE_DIRENT_H 1 /* to use POSIX dirent.h */
|
||||||
|
/* #undef HAVE_SYS_DIR_H */ /* to use BSD sys/dir.h */
|
||||||
|
/* #undef HAVE_NDIR_H */ /* to use ndir.h */
|
||||||
|
/* #undef HAVE_SYS_NDIR_H */ /* to use sys/ndir.h */
|
||||||
|
#define HAVE_ALLOCA_H 1 /* if alloca.h exists */
|
||||||
|
#define HAVE_MALLOC_H 1 /* if malloc.h exists */
|
||||||
|
#define HAVE_TERMIOS_H 1 /* to use POSIX termios.h */
|
||||||
|
#define HAVE_TERMIO_H 1 /* to use SVR4 termio.h */
|
||||||
|
#define HAVE_PWD_H 1 /* if pwd.h exists */
|
||||||
|
#define HAVE_GRP_H 1 /* if grp.h exists */
|
||||||
|
#define HAVE_SYS_ACL_H 1 /* to use <sys/acl.h> for ACL definitions */
|
||||||
|
/* #undef HAVE_ACLLIB_H */ /* if HP-UX <acllib.h> is present */
|
||||||
|
#define HAVE_SHADOW_H 1 /* if shadow.h exists */
|
||||||
|
#define HAVE_SYSLOG_H 1 /* if syslog.h exists */
|
||||||
|
#define HAVE_SYS_TIME_H 1 /* may include sys/time.h for struct timeval */
|
||||||
|
#define TIME_WITH_SYS_TIME 1 /* may include both time.h and sys/time.h */
|
||||||
|
#define HAVE_TIMES 1 /* to use times() and sys/times.h */
|
||||||
|
#define HAVE_SYS_TIMES_H 1 /* may include sys/times.h for struct tms */
|
||||||
|
#define HAVE_UTIME 1 /* to use AT&T utime() and utimbuf */
|
||||||
|
#define HAVE_UTIMES 1 /* to use BSD utimes() and sys/time.h */
|
||||||
|
#define HAVE_UTIME_H 1 /* to use utime.h for the utimbuf structure declaration, else declare struct utimbuf yourself */
|
||||||
|
/* #undef HAVE_SYS_UTIME_H */ /* to use sys/utime.h if utime.h does not exist */
|
||||||
|
#define HAVE_SYS_IOCTL_H 1 /* if sys/ioctl.h is present */
|
||||||
|
/* #undef HAVE_SYS_FILIO_H */ /* if sys/ioctl.h is present */
|
||||||
|
#define HAVE_SYS_PARAM_H 1 /* if sys/param.h is present */
|
||||||
|
#define HAVE_MNTENT_H 1 /* if mntent.h is present */
|
||||||
|
/* #undef HAVE_SYS_MNTENT_H */ /* if sys/mntent.h is present */
|
||||||
|
/* #undef HAVE_SYS_MNTTAB_H */ /* if sys/mnttab.h is present */
|
||||||
|
#define HAVE_SYS_MOUNT_H 1 /* if sys/mount.h is present */
|
||||||
|
#define HAVE_WAIT_H 1 /* to use wait.h for prototypes and union wait */
|
||||||
|
#define HAVE_SYS_WAIT_H 1 /* else use sys/wait.h */
|
||||||
|
#define HAVE_SYS_RESOURCE_H 1 /* to use sys/resource.h for rlimit() and wait3() */
|
||||||
|
#define HAVE_SYS_PROCFS_H 1 /* to use sys/procfs.h for wait3() emulation */
|
||||||
|
/* #undef HAVE_SYS_SYSTEMINFO_H */ /* to use SVr4 sysinfo() */
|
||||||
|
#define HAVE_SYS_UTSNAME_H 1 /* to use uname() */
|
||||||
|
/* #undef HAVE_SYS_PRIOCNTL_H */ /* to use SVr4 priocntl() instead of nice()/setpriority() */
|
||||||
|
/* #undef HAVE_SYS_RTPRIOCNTL_H */ /* if the system supports SVr4 real time classes */
|
||||||
|
#define HAVE_SYS_SYSCALL_H 1 /* to use syscall() */
|
||||||
|
#define HAVE_SYS_MTIO_H 1 /* to use mtio definitions from sys/mtio.h */
|
||||||
|
/* #undef HAVE_SYS_TAPE_H */ /* to use mtio definitions from AIX sys/tape.h */
|
||||||
|
#define HAVE_SYS_MMAN_H 1 /* to use definitions for mmap()/madvise()... from sys/mman.h */
|
||||||
|
#define HAVE_SYS_SHM_H 1 /* to use definitions for shmget() ... from sys/shm.h */
|
||||||
|
#define HAVE_SYS_IPC_H 1 /* to use definitions for shmget() ... from sys/ipc.h */
|
||||||
|
/* #undef MAJOR_IN_MKDEV */ /* if we should include sys/mkdev.h to get major()/minor()/makedev() */
|
||||||
|
#define MAJOR_IN_SYSMACROS 1 /* if we should include sys/sysmacros.h to get major()/minor()/makedev() */
|
||||||
|
/* #undef HAVE_SYS_DKIO_H */ /* if we may include sys/dkio.h for disk ioctls */
|
||||||
|
/* #undef HAVE_SYS_DKLABEL_H */ /* if we may include sys/dklabel.h for disk label */
|
||||||
|
/* #undef HAVE_SUN_DKIO_H */ /* if we may include sun/dkio.h for disk ioctls */
|
||||||
|
/* #undef HAVE_SUN_DKLABEL_H */ /* if we may include sun/dklabel.h for disk label */
|
||||||
|
#define HAVE_SYS_TYPES_H 1 /* if we may include sys/types.h (the standard) */
|
||||||
|
#define HAVE_SYS_STAT_H 1 /* if we may include sys/stat.h (the standard) */
|
||||||
|
/* #undef HAVE_TYPES_H */ /* if we may include types.h (rare cases e.g. ATARI TOS) */
|
||||||
|
/* #undef HAVE_STAT_H */ /* if we may include stat.h (rare cases e.g. ATARI TOS) */
|
||||||
|
#define HAVE_POLL_H 1 /* if we may include poll.h to use poll() */
|
||||||
|
#define HAVE_SYS_POLL_H 1 /* if we may include sys/poll.h to use poll() */
|
||||||
|
#define HAVE_SYS_SELECT_H 1 /* if we may have sys/select.h nonstandard use for select() on some systems*/
|
||||||
|
/* #undef NEED_SYS_SELECT_H */ /* if we need sys/select.h to use select() (this is nonstandard) */
|
||||||
|
#define HAVE_NETDB_H 1 /* if we have netdb.h for get*by*() and rcmd() */
|
||||||
|
#define HAVE_SYS_SOCKET_H 1 /* if we have sys/socket.h for socket() */
|
||||||
|
/* #undef NEED_SYS_SOCKET_H */ /* if we need sys/socket.h to use select() (this is nonstandard) */
|
||||||
|
#define HAVE_LINUX_PG_H 1 /* if we may include linux/pg.h for PP ATAPI sypport */
|
||||||
|
/* #undef HAVE_CAMLIB_H */ /* if we may include camlib.h for CAM SCSI transport definitions */
|
||||||
|
/* #undef HAVE_IEEEFP_H */ /* if we may include ieeefp.h for finite()/isnand() */
|
||||||
|
/* #undef HAVE_FP_H */ /* if we may include fp.h for FINITE()/IS_INF()/IS_NAN() */
|
||||||
|
#define HAVE_VALUES_H 1 /* if we may include values.h for MAXFLOAT */
|
||||||
|
#define HAVE_FLOAT_H 1 /* if we may include float.h for FLT_MAX */
|
||||||
|
/* #undef HAVE__FILBUF */ /* if we have _filbuf() for USG derived STDIO */
|
||||||
|
/* #undef HAVE___FILBUF */ /* if we have __filbuf() for USG derived STDIO */
|
||||||
|
/* #undef HAVE_USG_STDIO */ /* if we have USG derived STDIO */
|
||||||
|
#define HAVE_ERRNO_DEF 1 /* if we have errno definition in <errno.h> */
|
||||||
|
/* #undef HAVE_VFORK_H */ /* if we should include vfork.h for vfork() definitions */
|
||||||
|
#define HAVE_ARPA_INET_H 1 /* if we have arpa/inet.h (missing on BeOS) */
|
||||||
|
/* BeOS has inet_ntoa() in <netdb.h> */
|
||||||
|
/* #undef HAVE_BSD_DEV_SCSIREG_H */ /* if we have a NeXT Step compatible sg driver */
|
||||||
|
/* #undef HAVE_SYS_BSDTTY_H */ /* if we have sys/bsdtty.h on HP-UX for TIOCGPGRP */
|
||||||
|
/* #undef HAVE_OS_H */ /* if we have the BeOS kernel definitions in OS.h */
|
||||||
|
#define HAVE_ATTR_XATTR_H 1 /* if we have the Linux Extended File Attr definitions in attr/xattr.h */
|
||||||
|
#define HAVE_FNMATCH_H 1 /* if we may include fnmatch.h */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert to SCHILY name
|
||||||
|
*/
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# ifndef HAVE_STDC_HEADERS
|
||||||
|
# define HAVE_STDC_HEADERS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ELF_H
|
||||||
|
#define HAVE_ELF /* This system uses ELF */
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_AOUTHDR_H
|
||||||
|
# define HAVE_COFF /* This system uses COFF */
|
||||||
|
# else
|
||||||
|
# ifdef HAVE_A_OUT_H
|
||||||
|
# define HAVE_AOUT /* This system uses AOUT */
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Library Functions
|
||||||
|
*/
|
||||||
|
#define HAVE_ACCESS 1 /* access() is present in libc */
|
||||||
|
/* #undef HAVE_EACCESS */ /* eaccess() is present in libc */
|
||||||
|
#define HAVE_EUIDACCESS 1 /* euidaccess() is present in libc */
|
||||||
|
/* #undef HAVE_ACCESS_E_OK */ /* access() implements E_OK (010) for effective UIDs */
|
||||||
|
#define HAVE_CRYPT 1 /* crypt() is present in libc or libcrypt */
|
||||||
|
#define HAVE_STRERROR 1 /* strerror() is present in libc */
|
||||||
|
#define HAVE_MEMMOVE 1 /* memmove() is present in libc */
|
||||||
|
#define HAVE_MADVISE 1 /* madvise() is present in libc */
|
||||||
|
#define HAVE_MLOCK 1 /* mlock() is present in libc */
|
||||||
|
#define HAVE_MLOCKALL 1 /* working mlockall() is present in libc */
|
||||||
|
#define HAVE_MMAP 1 /* working mmap() is present in libc */
|
||||||
|
/* #undef _MMAP_WITH_SIZEP */ /* mmap() needs address of size parameter */
|
||||||
|
#define HAVE_FLOCK 1 /* *BSD flock() is present in libc */
|
||||||
|
#define HAVE_LOCKF 1 /* lockf() is present in libc (XOPEN) */
|
||||||
|
#define HAVE_FCNTL_LOCKF 1 /* file locking via fcntl() is present in libc */
|
||||||
|
#define HAVE_FCHDIR 1 /* fchdir() is present in libc */
|
||||||
|
#define HAVE_STATVFS 1 /* statvfs() is present in libc */
|
||||||
|
#define HAVE_QUOTACTL 1 /* quotactl() is present in libc */
|
||||||
|
/* #undef HAVE_QUOTAIOCTL */ /* use ioctl(f, Q_QUOTACTL, &q) instead of quotactl() */
|
||||||
|
#define HAVE_SETREUID 1 /* setreuid() is present in libc */
|
||||||
|
#define HAVE_SETRESUID 1 /* setresuid() is present in libc */
|
||||||
|
#define HAVE_SETEUID 1 /* seteuid() is present in libc */
|
||||||
|
#define HAVE_SETUID 1 /* setuid() is present in libc */
|
||||||
|
#define HAVE_SETREGID 1 /* setregid() is present in libc */
|
||||||
|
#define HAVE_SETRESGID 1 /* setresgid() is present in libc */
|
||||||
|
#define HAVE_SETEGID 1 /* setegid() is present in libc */
|
||||||
|
#define HAVE_SETGID 1 /* setgid() is present in libc */
|
||||||
|
#define HAVE_GETPGID 1 /* getpgid() is present in libc (POSIX) */
|
||||||
|
#define HAVE_SETPGID 1 /* setpgid() is present in libc (POSIX) */
|
||||||
|
#define HAVE_GETPGRP 1 /* getpgrp() is present in libc (ANY) */
|
||||||
|
#define HAVE_SETPGRP 1 /* setpgrp() is present in libc (ANY) */
|
||||||
|
/* #undef HAVE_BSD_GETPGRP */ /* getpgrp() in libc is BSD-4.2 compliant */
|
||||||
|
/* #undef HAVE_BSD_SETPGRP */ /* setpgrp() in libc is BSD-4.2 compliant */
|
||||||
|
#define HAVE_GETSPNAM 1 /* getspnam() in libc (SVR4 compliant) */
|
||||||
|
/* #undef HAVE_GETSPWNAM */ /* getspwnam() in libsec.a (HP-UX) */
|
||||||
|
#define HAVE_SYNC 1 /* sync() is present in libc */
|
||||||
|
#define HAVE_FSYNC 1 /* fsync() is present in libc */
|
||||||
|
#define HAVE_TCGETATTR 1 /* tcgetattr() is present in libc */
|
||||||
|
#define HAVE_TCSETATTR 1 /* tcsetattr() is present in libc */
|
||||||
|
#define HAVE_WAIT3 1 /* working wait3() is present in libc */
|
||||||
|
#define HAVE_WAIT4 1 /* wait4() is present in libc */
|
||||||
|
#define HAVE_WAITID 1 /* waitid() is present in libc */
|
||||||
|
#define HAVE_WAITPID 1 /* waitpid() is present in libc */
|
||||||
|
#define HAVE_GETHOSTID 1 /* gethostid() is present in libc */
|
||||||
|
#define HAVE_GETHOSTNAME 1 /* gethostname() is present in libc */
|
||||||
|
#define HAVE_GETDOMAINNAME 1 /* getdomainname() is present in libc */
|
||||||
|
#define HAVE_GETPAGESIZE 1 /* getpagesize() is present in libc */
|
||||||
|
#define HAVE_GETDTABLESIZE 1 /* getdtablesize() is present in libc */
|
||||||
|
#define HAVE_GETRUSAGE 1 /* getrusage() is present in libc */
|
||||||
|
#define HAVE_GETRLIMIT 1 /* getrlimit() is present in libc */
|
||||||
|
#define HAVE_SETRLIMIT 1 /* setrlimit() is present in libc */
|
||||||
|
#define HAVE_ULIMIT 1 /* ulimit() is present in libc */
|
||||||
|
#define HAVE_GETTIMEOFDAY 1 /* gettimeofday() is present in libc */
|
||||||
|
#define HAVE_SETTIMEOFDAY 1 /* settimeofday() is present in libc */
|
||||||
|
#define HAVE_TIME 1 /* time() is present in libc */
|
||||||
|
#define HAVE_STIME 1 /* stime() is present in libc */
|
||||||
|
#define HAVE_POLL 1 /* poll() is present in libc */
|
||||||
|
#define HAVE_SELECT 1 /* select() is present in libc */
|
||||||
|
#define HAVE_CHOWN 1 /* chown() is present in libc */
|
||||||
|
#define HAVE_LCHOWN 1 /* lchown() is present in libc */
|
||||||
|
#define HAVE_BRK 1 /* brk() is present in libc */
|
||||||
|
#define HAVE_SBRK 1 /* sbrk() is present in libc */
|
||||||
|
#define HAVE_VA_COPY 1 /* va_copy() is present in varargs.h/stdarg.h */
|
||||||
|
#define HAVE__VA_COPY 1 /* __va_copy() is present in varargs.h/stdarg.h */
|
||||||
|
/* #undef HAVE_DTOA */ /* BSD-4.4 __dtoa() is present in libc */
|
||||||
|
/* #undef HAVE_DTOA_R */ /* BSD-4.4 __dtoa() with result ptr (reentrant) */
|
||||||
|
#define HAVE_DUP2 1 /* dup2() is present in libc */
|
||||||
|
#define HAVE_GETCWD 1 /* POSIX getcwd() is present in libc */
|
||||||
|
#define HAVE_SMMAP 1 /* may map anonymous memory to get shared mem */
|
||||||
|
#define HAVE_SHMAT 1 /* shmat() is present in libc */
|
||||||
|
#define HAVE_SEMGET 1 /* semget() is present in libc */
|
||||||
|
#define HAVE_LSTAT 1 /* lstat() is present in libc */
|
||||||
|
#define HAVE_READLINK 1 /* readlink() is present in libc */
|
||||||
|
#define HAVE_SYMLINK 1 /* symlink() is present in libc */
|
||||||
|
#define HAVE_LINK 1 /* link() is present in libc */
|
||||||
|
#define HAVE_HARD_SYMLINKS 1 /* link() allows hard links on symlinks */
|
||||||
|
#define HAVE_LINK_NOFOLLOW 1 /* link() does not follow symlinks when hard linking symlinks */
|
||||||
|
#define HAVE_RENAME 1 /* rename() is present in libc */
|
||||||
|
#define HAVE_MKFIFO 1 /* mkfifo() is present in libc */
|
||||||
|
#define HAVE_MKNOD 1 /* mknod() is present in libc */
|
||||||
|
#define HAVE_ECVT 1 /* ecvt() is present in libc */
|
||||||
|
#define HAVE_FCVT 1 /* fcvt() is present in libc */
|
||||||
|
#define HAVE_GCVT 1 /* gcvt() is present in libc */
|
||||||
|
#define HAVE_ECVT_R 1 /* ecvt_r() is present in libc */
|
||||||
|
#define HAVE_FCVT_R 1 /* fcvt_r() is present in libc */
|
||||||
|
/* #undef HAVE_GCVT_R */ /* gcvt_r() is present in libc */
|
||||||
|
/* #undef HAVE_ECONVERT */ /* econvert() is present in libc */
|
||||||
|
/* #undef HAVE_FCONVERT */ /* fconvert() is present in libc */
|
||||||
|
/* #undef HAVE_GCONVERT */ /* gconvert() is present in libc */
|
||||||
|
#define HAVE_ISINF 1 /* isinf() is present in libc */
|
||||||
|
#define HAVE_ISNAN 1 /* isnan() is present in libc */
|
||||||
|
#define HAVE_RAND 1 /* rand() is present in libc */
|
||||||
|
#define HAVE_DRAND48 1 /* drand48() is present in libc */
|
||||||
|
#define HAVE_SETPRIORITY 1 /* setpriority() is present in libc */
|
||||||
|
#define HAVE_NICE 1 /* nice() is present in libc */
|
||||||
|
/* #undef HAVE_DOSSETPRIORITY */ /* DosSetPriority() is present in libc */
|
||||||
|
/* #undef HAVE_DOSALLOCSHAREDMEM */ /* DosAllocSharedMem() is present in libc */
|
||||||
|
#define HAVE_SEEKDIR 1 /* seekdir() is present in libc */
|
||||||
|
#define HAVE_PUTENV 1 /* putenv() is present in libc (preferred function) */
|
||||||
|
#define HAVE_SETENV 1 /* setenv() is present in libc (use instead of putenv()) */
|
||||||
|
#define HAVE_UNAME 1 /* uname() is present in libc */
|
||||||
|
#define HAVE_SNPRINTF 1 /* snprintf() is present in libc */
|
||||||
|
#define HAVE_STRCASECMP 1 /* strcasecmp() is present in libc */
|
||||||
|
#define HAVE_STRDUP 1 /* strdup() is present in libc */
|
||||||
|
#define HAVE_STRSIGNAL 1 /* strsignal() is present in libc */
|
||||||
|
/* #undef HAVE_STR2SIG */ /* str2sig() is present in libc */
|
||||||
|
/* #undef HAVE_SIG2STR */ /* sig2str() is present in libc */
|
||||||
|
#define HAVE_KILLPG 1 /* killpg() is present in libc */
|
||||||
|
#define HAVE_SIGRELSE 1 /* sigrelse() is present in libc */
|
||||||
|
#define HAVE_SIGPROCMASK 1 /* sigprocmask() is present in libc (POSIX) */
|
||||||
|
#define HAVE_SIGSETMASK 1 /* sigsetmask() is present in libc (BSD) */
|
||||||
|
#define HAVE_SIGSET 1 /* sigset() is present in libc (POSIX) */
|
||||||
|
#define HAVE_SYS_SIGLIST 1 /* char *sys_siglist[] is present in libc */
|
||||||
|
#define HAVE_NANOSLEEP 1 /* nanosleep() is present in libc */
|
||||||
|
#define HAVE_USLEEP 1 /* usleep() is present in libc */
|
||||||
|
#define HAVE_FORK 1 /* fork() is present in libc */
|
||||||
|
#define HAVE_EXECL 1 /* execl() is present in libc */
|
||||||
|
#define HAVE_EXECLE 1 /* execle() is present in libc */
|
||||||
|
#define HAVE_EXECLP 1 /* execlp() is present in libc */
|
||||||
|
#define HAVE_EXECV 1 /* execv() is present in libc */
|
||||||
|
#define HAVE_EXECVE 1 /* execve() is present in libc */
|
||||||
|
#define HAVE_EXECVP 1 /* execvp() is present in libc */
|
||||||
|
#define HAVE_ALLOCA 1 /* alloca() is present (else use malloc())*/
|
||||||
|
#define HAVE_VALLOC 1 /* valloc() is present in libc (else use malloc())*/
|
||||||
|
/* #undef vfork */
|
||||||
|
|
||||||
|
/* #undef HAVE_CHFLAGS */ /* chflags() is present in libc */
|
||||||
|
/* #undef HAVE_FCHFLAGS */ /* fchflags() is present in libc */
|
||||||
|
/* #undef HAVE_FFLAGSTOSTR */ /* fflagstostr() is present in libc */
|
||||||
|
/* #undef HAVE_STRTOFFLAGS */ /* strtofflags() is present in libc */
|
||||||
|
|
||||||
|
#define HAVE_FNMATCH 1 /* fnmatch() is present in libc */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Linux Extended File Attributes
|
||||||
|
*/
|
||||||
|
#define HAVE_GETXATTR 1 /* getxattr() */
|
||||||
|
#define HAVE_SETXATTR 1 /* setxattr() */
|
||||||
|
#define HAVE_LISTXATTR 1 /* listxattr() */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Important: This must be a result from a check _before_ the Large File test
|
||||||
|
* has been run. It then tells us whether these functions are
|
||||||
|
* available even when not in Large File mode.
|
||||||
|
*
|
||||||
|
* Do not run the AC_FUNC_FSEEKO test from the GNU tar Large File test
|
||||||
|
* siute. It will use the same cache names and interfere with our test.
|
||||||
|
* Instead use the tests AC_SMALL_FSEEKO/AC_SMALL/STELLO and make sure
|
||||||
|
* they are placed before the large file tests.
|
||||||
|
*/
|
||||||
|
/* #undef HAVE_FSEEKO */ /* fseeko() is present in default compile mode */
|
||||||
|
/* #undef HAVE_FTELLO */ /* ftello() is present in default compile mode */
|
||||||
|
|
||||||
|
#define HAVE_RCMD 1 /* rcmd() is present in libc/libsocket */
|
||||||
|
#define HAVE_SOCKET 1 /* socket() is present in libc/libsocket */
|
||||||
|
#define HAVE_SOCKETPAIR 1 /* socketpair() is present in libc/libsocket */
|
||||||
|
#define HAVE_GETSERVBYNAME 1 /* getservbyname() is present in libc/libsocket */
|
||||||
|
#define HAVE_INET_NTOA 1 /* inet_ntoa() is present in libc/libsocket */
|
||||||
|
#define HAVE_GETADDRINFO 1 /* getaddrinfo() is present in libc/libsocket */
|
||||||
|
#define HAVE_GETNAMEINFO 1 /* getnameinfo() is present in libc/libsocket */
|
||||||
|
|
||||||
|
#if defined(HAVE_QUOTACTL) || defined(HAVE_QUOTAIOCTL)
|
||||||
|
# define HAVE_QUOTA /* The system inludes quota */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need to test for the include files too because Apollo Domain/OS has a
|
||||||
|
* libc that includes the functions but the includes files are not visible
|
||||||
|
* from the BSD compile environment.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_SHMAT) && defined(HAVE_SYS_SHM_H) && defined(HAVE_SYS_IPC_H)
|
||||||
|
# define HAVE_USGSHM /* USG shared memory is present */
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_SEMGET) && defined(HAVE_SYS_SHM_H) && defined(HAVE_SYS_IPC_H)
|
||||||
|
# define HAVE_USGSEM /* USG semaphores are present */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_GETPGRP) && !defined(HAVE_BSD_GETPGRP)
|
||||||
|
#define HAVE_POSIX_GETPGRP 1 /* getpgrp() in libc is POSIX compliant */
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_SETPGRP) && !defined(HAVE_BSD_SETPGRP)
|
||||||
|
#define HAVE_POSIX_SETPGRP 1 /* setpgrp() in libc is POSIX compliant */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structures
|
||||||
|
*/
|
||||||
|
#define HAVE_MTGET_TYPE 1 /* if struct mtget contains mt_type (drive type) */
|
||||||
|
/* #undef HAVE_MTGET_MODEL */ /* if struct mtget contains mt_model (drive type) */
|
||||||
|
#define HAVE_MTGET_DSREG 1 /* if struct mtget contains mt_dsreg (drive status) */
|
||||||
|
/* #undef HAVE_MTGET_DSREG1 */ /* if struct mtget contains mt_dsreg1 (drive status msb) */
|
||||||
|
/* #undef HAVE_MTGET_DSREG2 */ /* if struct mtget contains mt_dsreg2 (drive status lsb) */
|
||||||
|
#define HAVE_MTGET_GSTAT 1 /* if struct mtget contains mt_gstat (generic status) */
|
||||||
|
#define HAVE_MTGET_ERREG 1 /* if struct mtget contains mt_erreg (error register) */
|
||||||
|
#define HAVE_MTGET_RESID 1 /* if struct mtget contains mt_resid (residual count) */
|
||||||
|
#define HAVE_MTGET_FILENO 1 /* if struct mtget contains mt_fileno (file #) */
|
||||||
|
#define HAVE_MTGET_BLKNO 1 /* if struct mtget contains mt_blkno (block #) */
|
||||||
|
/* #undef HAVE_MTGET_FLAGS */ /* if struct mtget contains mt_flags (flags) */
|
||||||
|
/* #undef HAVE_MTGET_BF */ /* if struct mtget contains mt_bf (optimum blocking factor) */
|
||||||
|
#define HAVE_STRUCT_RUSAGE 1 /* have struct rusage in sys/resource.h */
|
||||||
|
/* #undef HAVE_SI_UTIME */ /* if struct siginfo contains si_utime */
|
||||||
|
/* #undef HAVE_UNION_SEMUN */ /* have an illegal definition for union semun in sys/sem.h */
|
||||||
|
#define HAVE_UNION_WAIT 1 /* have union wait in wait.h */
|
||||||
|
/*
|
||||||
|
* SCO UnixWare has st_atim.st__tim.tv_nsec but the st_atim.tv_nsec tests also
|
||||||
|
* succeeds. If you use st_atim.tv_nsec on UnixWare, you get a warning about
|
||||||
|
* illegal structure usage. For this reason, your code needs to have
|
||||||
|
* #ifdef HAVE_ST__TIM before #ifdef HAVE_ST_NSEC.
|
||||||
|
*/
|
||||||
|
/* #undef HAVE_ST_SPARE1 */ /* if struct stat contains st_spare1 (usecs) */
|
||||||
|
/* #undef HAVE_ST_ATIMENSEC */ /* if struct stat contains st_atimensec (nanosecs) */
|
||||||
|
#define HAVE_ST_NSEC 1 /* if struct stat contains st_atim.tv_nsec (nanosecs) */
|
||||||
|
/* #undef HAVE_ST__TIM */ /* if struct stat contains st_atim.st__tim.tv_nsec (nanosecs) */
|
||||||
|
/* #undef HAVE_ST_ATIMESPEC */ /* if struct stat contains st_atimespec.tv_nsec (nanosecs) */
|
||||||
|
#define HAVE_ST_BLKSIZE 1 /* if struct stat contains st_blksize */
|
||||||
|
#define HAVE_ST_BLOCKS 1 /* if struct stat contains st_blocks */
|
||||||
|
/* #undef HAVE_ST_FSTYPE */ /* if struct stat contains st_fstype */
|
||||||
|
#define HAVE_ST_RDEV 1 /* if struct stat contains st_rdev */
|
||||||
|
/* #undef HAVE_ST_FLAGS */ /* if struct stat contains st_flags */
|
||||||
|
/* #undef STAT_MACROS_BROKEN */ /* if the macros S_ISDIR, S_ISREG .. don't work */
|
||||||
|
|
||||||
|
#define DEV_MINOR_BITS 32 /* # if bits needed to hold minor device number */
|
||||||
|
#define DEV_MINOR_NONCONTIG 1 /* if bits in minor device number are noncontiguous */
|
||||||
|
|
||||||
|
#define HAVE_SOCKADDR_STORAGE 1 /* if socket.h defines struct sockaddr_storage */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Byteorder/Bitorder
|
||||||
|
*/
|
||||||
|
#define HAVE_C_BIGENDIAN /* Flag that WORDS_BIGENDIAN test was done */
|
||||||
|
/* #undef WORDS_BIGENDIAN */ /* If using network byte order */
|
||||||
|
#define HAVE_C_BITFIELDS /* Flag that BITFIELDS_HTOL test was done */
|
||||||
|
/* #undef BITFIELDS_HTOL */ /* If high bits come first in structures */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types/Keywords
|
||||||
|
*/
|
||||||
|
#define SIZEOF_CHAR 1
|
||||||
|
#define SIZEOF_SHORT_INT 2
|
||||||
|
#define SIZEOF_INT 4
|
||||||
|
#define SIZEOF_LONG_INT 4
|
||||||
|
#define SIZEOF_LONG_LONG 8
|
||||||
|
#define SIZEOF_CHAR_P 4
|
||||||
|
#define SIZEOF_UNSIGNED_CHAR 1
|
||||||
|
#define SIZEOF_UNSIGNED_SHORT_INT 2
|
||||||
|
#define SIZEOF_UNSIGNED_INT 4
|
||||||
|
#define SIZEOF_UNSIGNED_LONG_INT 4
|
||||||
|
#define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||||
|
#define SIZEOF_UNSIGNED_CHAR_P 4
|
||||||
|
|
||||||
|
#define HAVE_LONGLONG 1 /* Compiler defines long long type */
|
||||||
|
/* #undef CHAR_IS_UNSIGNED */ /* Compiler defines char to be unsigned */
|
||||||
|
|
||||||
|
/* #undef const */ /* Define to empty if const doesn't work */
|
||||||
|
/* #undef uid_t */ /* To be used if uid_t is not present */
|
||||||
|
/* #undef gid_t */ /* To be used if gid_t is not present */
|
||||||
|
/* #undef size_t */ /* To be used if size_t is not present */
|
||||||
|
/* #undef ssize_t */ /* To be used if ssize_t is not present */
|
||||||
|
/* #undef pid_t */ /* To be used if pid_t is not present */
|
||||||
|
/* #undef off_t */ /* To be used if off_t is not present */
|
||||||
|
/* #undef mode_t */ /* To be used if mode_t is not present */
|
||||||
|
/* #undef time_t */ /* To be used if time_t is not present */
|
||||||
|
/* #undef caddr_t */ /* To be used if caddr_t is not present */
|
||||||
|
/* #undef daddr_t */ /* To be used if daddr_t is not present */
|
||||||
|
/* #undef dev_t */ /* To be used if dev_t is not present */
|
||||||
|
/* #undef ino_t */ /* To be used if ino_t is not present */
|
||||||
|
/* #undef nlink_t */ /* To be used if nlink_t is not present */
|
||||||
|
#define blksize_t long /* To be used if blksize_t is not present */
|
||||||
|
/* #undef blkcnt_t */ /* To be used if blkcnt_t is not present */
|
||||||
|
/*
|
||||||
|
* Important: Next Step needs time.h for clock_t (because of a bug)
|
||||||
|
*/
|
||||||
|
/* #undef clock_t */ /* To be used if clock_t is not present */
|
||||||
|
/* #undef socklen_t */ /* To be used if socklen_t is not present */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These types are present on all UNIX systems but should be avoided
|
||||||
|
* for portability.
|
||||||
|
* On Apollo/Domain OS we don't have them....
|
||||||
|
*
|
||||||
|
* Better include <utypes.h> and use Uchar, Uint & Ulong
|
||||||
|
*/
|
||||||
|
/* #undef u_char */ /* To be used if u_char is not present */
|
||||||
|
/* #undef u_short */ /* To be used if u_short is not present */
|
||||||
|
/* #undef u_int */ /* To be used if u_int is not present */
|
||||||
|
/* #undef u_long */ /* To be used if u_long is not present */
|
||||||
|
|
||||||
|
/*#undef HAVE_SIZE_T*/
|
||||||
|
/*#undef NO_SIZE_T*/
|
||||||
|
/* #undef VA_LIST_IS_ARRAY */ /* va_list is an array */
|
||||||
|
#define GETGROUPS_T gid_t
|
||||||
|
#define GID_T GETGROUPS_T
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define as the return type of signal handlers (int or void).
|
||||||
|
*/
|
||||||
|
#define RETSIGTYPE void
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defines needed to get large file support.
|
||||||
|
*/
|
||||||
|
#ifdef USE_LARGEFILES
|
||||||
|
|
||||||
|
#define HAVE_LARGEFILES 1
|
||||||
|
|
||||||
|
#ifdef HAVE_LARGEFILES /* If we have working largefiles at all */
|
||||||
|
/* This is not defined with glibc-2.1.3 */
|
||||||
|
|
||||||
|
#define _FILE_OFFSET_BITS 64 /* # of bits in off_t if settable */
|
||||||
|
#define _LARGEFILE_SOURCE 1 /* To make ftello() visible (HP-UX 10.20). */
|
||||||
|
/* #undef _LARGE_FILES */ /* Large file defined on AIX-style hosts. */
|
||||||
|
/* #undef _XOPEN_SOURCE */ /* To make ftello() visible (glibc 2.1.3). */
|
||||||
|
/* XXX We don't use this because glibc2.1.3*/
|
||||||
|
/* XXX is bad anyway. If we define */
|
||||||
|
/* XXX _XOPEN_SOURCE we will loose caddr_t */
|
||||||
|
|
||||||
|
/* #undef HAVE_FSEEKO */ /* Do we need this? If HAVE_LARGEFILES is */
|
||||||
|
/* defined, we have fseeko() */
|
||||||
|
|
||||||
|
#endif /* HAVE_LARGEFILES */
|
||||||
|
#endif /* USE_LARGEFILES */
|
||||||
|
|
||||||
|
#ifdef USE_ACL /* Enable/disable ACL support */
|
||||||
|
/*
|
||||||
|
* POSIX ACL support
|
||||||
|
*/
|
||||||
|
#define HAVE_ACL_GET_FILE 1 /* acl_get_file() function */
|
||||||
|
#define HAVE_ACL_SET_FILE 1 /* acl_set_file() function */
|
||||||
|
#define HAVE_ACL_FROM_TEXT 1 /* acl_from_text() function */
|
||||||
|
#define HAVE_ACL_TO_TEXT 1 /* acl_to_text() function */
|
||||||
|
#define HAVE_ACL_FREE 1 /* acl_free() function */
|
||||||
|
#define HAVE_ACL_DELETE_DEF_FILE 1 /* acl_delete_def_file() function */
|
||||||
|
|
||||||
|
#if defined(HAVE_ACL_GET_FILE) && defined(HAVE_ACL_SET_FILE) && \
|
||||||
|
defined(HAVE_ACL_FROM_TEXT) && defined(HAVE_ACL_TO_TEXT) && \
|
||||||
|
defined(HAVE_ACL_FREE)
|
||||||
|
# define HAVE_POSIX_ACL 1 /* POSIX ACL's present */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sun ACL support.
|
||||||
|
* Note: unfortunately, HP-UX has an (undocumented) acl() function in libc.
|
||||||
|
*/
|
||||||
|
/* #undef HAVE_ACL */ /* acl() function */
|
||||||
|
/* #undef HAVE_FACL */ /* facl() function */
|
||||||
|
/* #undef HAVE_ACLFROMTEXT */ /* aclfromtext() function */
|
||||||
|
/* #undef HAVE_ACLTOTEXT */ /* acltotext() function */
|
||||||
|
|
||||||
|
#if defined(HAVE_ACL) && defined(HAVE_FACL) && \
|
||||||
|
defined(HAVE_ACLFROMTEXT) && defined(HAVE_ACLTOTEXT)
|
||||||
|
# define HAVE_SUN_ACL 1 /* Sun ACL's present */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HP-UX ACL support.
|
||||||
|
* Note: unfortunately, HP-UX has an (undocumented) acl() function in libc.
|
||||||
|
*/
|
||||||
|
/* #undef HAVE_GETACL */ /* getacl() function */
|
||||||
|
/* #undef HAVE_FGETACL */ /* fgetacl() function */
|
||||||
|
/* #undef HAVE_SETACL */ /* setacl() function */
|
||||||
|
/* #undef HAVE_FSETACL */ /* fsetacl() function */
|
||||||
|
/* #undef HAVE_STRTOACL */ /* strtoacl() function */
|
||||||
|
/* #undef HAVE_ACLTOSTR */ /* acltostr() function */
|
||||||
|
/* #undef HAVE_CPACL */ /* cpacl() function */
|
||||||
|
/* #undef HAVE_FCPACL */ /* fcpacl() function */
|
||||||
|
/* #undef HAVE_CHOWNACL */ /* chownacl() function */
|
||||||
|
/* #undef HAVE_SETACLENTRY */ /* setaclentry() function */
|
||||||
|
/* #undef HAVE_FSETACLENTRY */ /* fsetaclentry() function */
|
||||||
|
|
||||||
|
#if defined(HAVE_GETACL) && defined(HAVE_FGETACL) && \
|
||||||
|
defined(HAVE_SETACL) && defined(HAVE_FSETACL) && \
|
||||||
|
defined(HAVE_STRTOACL) && defined(HAVE_ACLTOTEXT)
|
||||||
|
# define HAVE_HP_ACL 1 /* HP-UX ACL's present */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Global definition whether ACL support is present.
|
||||||
|
* As HP-UX differs too much from other implementations, HAVE_HP_ACL is not
|
||||||
|
* included in HAVE_ANY_ACL.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_POSIX_ACL) || defined(HAVE_SUN_ACL)
|
||||||
|
# define HAVE_ANY_ACL 1 /* Any ACL implementation present */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* USE_ACL */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Misc CC / LD related stuff
|
||||||
|
*/
|
||||||
|
/* #undef NO_USER_MALLOC */ /* If we cannot define our own malloc() */
|
||||||
|
#define HAVE_DYN_ARRAYS 1 /* If the compiler allows dynamic sized arrays */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Strings that help to maintain OS/platform id's in C-programs
|
||||||
|
*/
|
||||||
|
#define HOST_ALIAS "i686-pc-linux-gnu" /* Output from config.guess (orig) */
|
||||||
|
#define HOST_SUB "i686-pc-linux-gnu" /* Output from config.sub (modified) */
|
||||||
|
#define HOST_CPU "i686" /* CPU part from HOST_SUB */
|
||||||
|
#define HOST_VENDOR "pc" /* VENDOR part from HOST_SUB */
|
||||||
|
#define HOST_OS "linux-gnu" /* CPU part from HOST_SUB */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Begin restricted code for quality assurance.
|
||||||
|
*
|
||||||
|
* Warning: you are not allowed to include the #define below if you are not
|
||||||
|
* using the Schily makefile system or if you modified the autoconfiguration
|
||||||
|
* tests.
|
||||||
|
*
|
||||||
|
* If you only added other tests you are allowed to keep this #define.
|
||||||
|
*
|
||||||
|
* This restiction is introduced because this way, I hope that people
|
||||||
|
* contribute to the project instead of creating branches.
|
||||||
|
*/
|
||||||
|
#define IS_SCHILY_XCONFIG
|
||||||
|
/*
|
||||||
|
* End restricted code for quality assurance.
|
||||||
|
*/
|
1356
src/schily/xmconfig.h
Normal file
1356
src/schily/xmconfig.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user