Compare commits
No commits in common. "master" and "pristine-tar" have entirely different histories.
master
...
pristine-t
3
AUTHOR
3
AUTHOR
@ -1,3 +0,0 @@
|
||||
|
||||
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
348
COPYING
@ -1,348 +0,0 @@
|
||||
|
||||
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
205
README
@ -1,205 +0,0 @@
|
||||
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.
|
||||
|
||||
|
85
debian/changelog
vendored
85
debian/changelog
vendored
@ -1,85 +0,0 @@
|
||||
megactl (0.4.1.1-1) UNRELEASED; urgency=medium
|
||||
|
||||
* Non-maintainer upload.
|
||||
* megatrace in own package
|
||||
|
||||
-- Mario Fetka <mario.fetka@gmail.com> Sat, 22 Apr 2017 16:52:02 +0200
|
||||
|
||||
megactl (0.4.1-6) unstable; urgency=medium
|
||||
|
||||
* Update 003-Fix_disk_enumeration_loop patch (fix issues with PERC6e).
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 25 Jan 2014 23:10:36 +0100
|
||||
|
||||
megactl (0.4.1+svn20090725.r6-5) unstable; urgency=medium
|
||||
|
||||
* Update 003-Fix_disk_enumeration_loop patch (fix issues with PERC6e).
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 25 Jan 2014 23:10:36 +0100
|
||||
|
||||
megactl (0.4.1+svn20090725.r6-4) unstable; urgency=medium
|
||||
|
||||
* Fix build on Jessie+.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Tue, 21 Jan 2014 22:54:42 +0100
|
||||
|
||||
megactl (0.4.1+svn20090725.r6-3) unstable; urgency=medium
|
||||
|
||||
* New patch by Pat Suwalski <pat@suwalski.net> to fix a bad disks
|
||||
enumeration loop.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Tue, 21 Jan 2014 20:24:22 +0100
|
||||
|
||||
megactl (0.4.1+svn20090725.r6-2) unstable; urgency=medium
|
||||
|
||||
* Integrate patch by Pat Suwalski <pat@suwalski.net> to handle devices
|
||||
without enclosure.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 14 Dec 2013 14:36:22 +0100
|
||||
|
||||
megactl (0.4.1+svn20090725.r6-1) unstable; urgency=low
|
||||
|
||||
* New upstream release (based on sv trunk snapshot):
|
||||
- Add RAID6 support,
|
||||
- Fixes for Dell PERC6 cards.
|
||||
* Bump Standards-Version to 3.8.2.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Sat, 25 Jul 2009 13:23:45 +0200
|
||||
|
||||
megactl (0.4.1-6) unstable; urgency=low
|
||||
|
||||
* Merge a Gentoo (thanks) patch that drops obsolete asm/user.h.
|
||||
* Add missing amd64 required gcc-multilib b-dep.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Mon, 27 Apr 2009 16:35:59 +0200
|
||||
|
||||
megactl (0.4.1-5) unstable; urgency=low
|
||||
|
||||
* Update create-devices-nodes to handle kernels 2.6.25rc2+.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Mon, 01 Sep 2008 12:03:07 +0200
|
||||
|
||||
megactl (0.4.1-4) unstable; urgency=low
|
||||
|
||||
* Add preinst script to clean obsolete initscripts used by previous
|
||||
releases.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Fri, 22 Aug 2008 14:02:08 +0200
|
||||
|
||||
megactl (0.4.1-3) unstable; urgency=low
|
||||
|
||||
* Fix packaging to allow build and run on amd64.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Thu, 21 Aug 2008 18:03:39 +0200
|
||||
|
||||
megactl (0.4.1-2) unstable; urgency=low
|
||||
|
||||
* Device node creation: remove initscript, replaced by binaries wrappers.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Thu, 21 Aug 2008 13:57:02 +0200
|
||||
|
||||
megactl (0.4.1-1) unstable; urgency=low
|
||||
|
||||
* Initial release.
|
||||
|
||||
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Wed, 26 Sep 2007 09:49:57 +0200
|
1
debian/compat
vendored
1
debian/compat
vendored
@ -1 +0,0 @@
|
||||
7
|
27
debian/control
vendored
27
debian/control
vendored
@ -1,27 +0,0 @@
|
||||
Source: megactl
|
||||
Section: admin
|
||||
Priority: optional
|
||||
Maintainer: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||
Build-Depends: debhelper (>= 4), dpatch, libc6-dev-i386 [amd64], gcc-multilib [amd64] | libc6-dev-i386 (<< 2.7) [amd64]
|
||||
Standards-Version: 3.8.2
|
||||
Homepage: http://sourceforge.net/projects/megactl
|
||||
|
||||
Package: megactl
|
||||
Architecture: i386 amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: LSI MegaRAID SCSI/SAS reporting tool
|
||||
This package contains both megactl and megasasctl tools that can be used
|
||||
to query LSI's MegaRAID adapters status.
|
||||
.
|
||||
It reports status and informations about the adapter itself, it's
|
||||
logical disks and the physical disks attached.
|
||||
|
||||
Package: megatrace
|
||||
Architecture: i386 amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, libc6-i386 [amd64], megactl
|
||||
Description: LSI MegaRAID SCSI/SAS reporting tool
|
||||
This package contains both megactl and megasasctl tools that can be used
|
||||
to query LSI's MegaRAID adapters status.
|
||||
.
|
||||
It reports status and informations about the adapter itself, it's
|
||||
logical disks and the physical disks attached.
|
45
debian/copyright
vendored
45
debian/copyright
vendored
@ -1,45 +0,0 @@
|
||||
This package was debianized by Adam Cécile (Le_Vert) <gandalf@le-vert.net> on
|
||||
Wed, 26 Sep 2007 09:49:57 +0200.
|
||||
|
||||
It was downloaded from http://sourceforge.net/projects/megactl
|
||||
|
||||
Upstream Author:
|
||||
|
||||
Jefferson Ogata <ogata@antibozo.net>
|
||||
|
||||
Copyright:
|
||||
|
||||
Copyright (C) 2007 Jefferson Ogata
|
||||
|
||||
License:
|
||||
|
||||
This package 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 package 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 package; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License can be found in `/usr/share/common-licenses/GPL'.
|
||||
|
||||
The Debian packaging is Copyright (C) 2007-2009 Adam Cécile (Le_Vert)
|
||||
<gandalf@le-vert.net> and is licensed under the GPL, see above.
|
||||
|
||||
Other files' copyright or license:
|
||||
|
||||
"src/schily/*" are (C) 1984-2003 J. Schilling except
|
||||
"src/schily/scg/srb_os2.h" which is (C) 1998 D. Dorau, C. Wohlgemuth.
|
||||
|
||||
"src/kernel-2.6.9-55.0.2.EL/*" and "src/megaraid/*" are
|
||||
(C) 2003-2004 LSI Logic Corporation.
|
||||
|
||||
All theses files are released under terms of GNU General Public License
|
||||
version 2 or later.
|
2
debian/dirs
vendored
2
debian/dirs
vendored
@ -1,2 +0,0 @@
|
||||
usr/lib/megactl
|
||||
usr/sbin
|
1
debian/docs
vendored
1
debian/docs
vendored
@ -1 +0,0 @@
|
||||
README
|
2
debian/examples
vendored
2
debian/examples
vendored
@ -1,2 +0,0 @@
|
||||
src/megarpt
|
||||
src/megasasrpt
|
102
debian/man/megactl/megactl.8
vendored
102
debian/man/megactl/megactl.8
vendored
@ -1,102 +0,0 @@
|
||||
.TH MEGACTL "8" "September 2007" "0.4.1" "User Commands"
|
||||
|
||||
.SH NAME
|
||||
megactl - a reporting tool for LSI MegaRAID adapters and its attached disks.
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B megactl
|
||||
can report diagnostics on megaraid adapters and attached disks.
|
||||
.br
|
||||
It 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.
|
||||
.br
|
||||
Target devices may be adapters, (e.g. a0), channels (e.g. a0c0), or individual disks (e.g. a0c0t0).
|
||||
.br
|
||||
If no target is specified, reports configuration and drive state on all
|
||||
adapters.
|
||||
.br
|
||||
If a target matches a collection of disks, operations are
|
||||
applied to all matching devices.
|
||||
|
||||
.SH REQUIREMENTS
|
||||
.B megactl
|
||||
requires the device file /dev/megadev0 to be present on
|
||||
the system.
|
||||
.br
|
||||
On Debian systems, this device node will be created at boot time by megactl-makedev init script.
|
||||
.br
|
||||
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 /dev/megadev0 as a character device with suitable permissions with a matching major device number and a minor number of 0.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B megactl
|
||||
[\-vest] [\-H] [\-l log-page-nr] [\-T long|short] [target ...]
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.I -v
|
||||
Increase program verbosity.
|
||||
.TP
|
||||
.I -e
|
||||
Dump read (0x03), write (0x02), and verify (0x05) error log pages.
|
||||
.TP
|
||||
.I -s
|
||||
Dump self-test (0x10) log page.
|
||||
.TP
|
||||
.I -t
|
||||
Dump temperature (0x0d) log page.
|
||||
.TP
|
||||
.I -l <page>
|
||||
Dump the specified log page.
|
||||
.br
|
||||
Log page 0 documents the log pages the device supports.
|
||||
.TP
|
||||
.I -p
|
||||
Do not report physical disks.
|
||||
.br
|
||||
Reports only adapters and logical drives.
|
||||
.br
|
||||
Useful for concisely documenting adapter configuration.
|
||||
.TP
|
||||
.I -T short|long
|
||||
Initiate the background short or long self-test procedure.
|
||||
.br
|
||||
The test may take up to an hour to complete, but does not inhibit access to the device.
|
||||
.br
|
||||
The test may be monitored using the \-s option.
|
||||
.br
|
||||
The background long self test is a useful tool for diagnosing problems with individual disks.
|
||||
.br
|
||||
But be cautious with program usage. "megactl \-T long" with no targets will initiate a background long self test on every drive on every adapter.
|
||||
.br
|
||||
This may not be what you want.
|
||||
.TP
|
||||
.I -H
|
||||
Perform an adapter health check.
|
||||
.br
|
||||
Inspects state of all logical and physical drives and battery backup unit and reports problem conditions.
|
||||
.br
|
||||
If all is well, generates no output. Useful in a cron job.
|
||||
.br
|
||||
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.
|
||||
.br
|
||||
If, however, any of the log page options is specified, only the designated log pages are inspected.
|
||||
.TP
|
||||
.I -B
|
||||
When performing health check, do not treat battery problems as failures.
|
||||
.TP
|
||||
.I -V
|
||||
Show version.
|
||||
|
||||
|
||||
.SH "SEE ALSO"
|
||||
Homepage: http://sourceforge.net/projects/megactl
|
||||
.br
|
||||
Some examples scripts (Debian systems): /usr/share/doc/megactl/examples/
|
||||
.br
|
||||
megasasctl(8): Same tool, for SAS adapters.
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Adam Cécile (Le_Vert) <gandalf@le-vert.net> for the Debian system (but may be used by others).
|
||||
.br
|
||||
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation
|
||||
.br
|
||||
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.
|
102
debian/man/megactl/megasasctl.8
vendored
102
debian/man/megactl/megasasctl.8
vendored
@ -1,102 +0,0 @@
|
||||
.TH MEGASASCTL "8" "September 2007" "0.4.1" "User Commands"
|
||||
|
||||
.SH NAME
|
||||
megasasctl - a reporting tool for LSI MegaRAID SAS (Serial-Attached-SCSI) adapters and its attached disks.
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B megasasctl
|
||||
can report diagnostics on megaraid adapters and attached disks.
|
||||
.br
|
||||
It 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.
|
||||
.br
|
||||
Target devices may be adapters, (e.g. a0), channels (e.g. a0c0), or individual disks (e.g. a0c0t0).
|
||||
.br
|
||||
If no target is specified, reports configuration and drive state on all
|
||||
adapters.
|
||||
.br
|
||||
If a target matches a collection of disks, operations are
|
||||
applied to all matching devices.
|
||||
|
||||
.SH REQUIREMENTS
|
||||
.B megasasctl
|
||||
requires the device file /dev/megaraid_sas_ioctl_node to be present on the system.
|
||||
the system.
|
||||
.br
|
||||
On Debian systems, this device node will be created at boot time by megactl-makedev init script.
|
||||
.br
|
||||
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 /dev/megaraid_sas_ioctl_node as a character device with suitable permissions with a matching major device number and a minor number of 0.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B megasasctl
|
||||
[\-vest] [\-H] [\-l log-page-nr] [\-T long|short] [target ...]
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.I -v
|
||||
Increase program verbosity.
|
||||
.TP
|
||||
.I -e
|
||||
Dump read (0x03), write (0x02), and verify (0x05) error log pages.
|
||||
.TP
|
||||
.I -s
|
||||
Dump self-test (0x10) log page.
|
||||
.TP
|
||||
.I -t
|
||||
Dump temperature (0x0d) log page.
|
||||
.TP
|
||||
.I -l <page>
|
||||
Dump the specified log page.
|
||||
.br
|
||||
Log page 0 documents the log pages the device supports.
|
||||
.TP
|
||||
.I -p
|
||||
Do not report physical disks.
|
||||
.br
|
||||
Reports only adapters and logical drives.
|
||||
.br
|
||||
Useful for concisely documenting adapter configuration.
|
||||
.TP
|
||||
.I -T short|long
|
||||
Initiate the background short or long self-test procedure.
|
||||
.br
|
||||
The test may take up to an hour to complete, but does not inhibit access to the device.
|
||||
.br
|
||||
The test may be monitored using the \-s option.
|
||||
.br
|
||||
The background long self test is a useful tool for diagnosing problems with individual disks.
|
||||
.br
|
||||
But be cautious with program usage. "megactl \-T long" with no targets will initiate a background long self test on every drive on every adapter.
|
||||
.br
|
||||
This may not be what you want.
|
||||
.TP
|
||||
.I -H
|
||||
Perform an adapter health check.
|
||||
.br
|
||||
Inspects state of all logical and physical drives and battery backup unit and reports problem conditions.
|
||||
.br
|
||||
If all is well, generates no output. Useful in a cron job.
|
||||
.br
|
||||
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.
|
||||
.br
|
||||
If, however, any of the log page options is specified, only the designated log pages are inspected.
|
||||
.TP
|
||||
.I -B
|
||||
When performing health check, do not treat battery problems as failures.
|
||||
.TP
|
||||
.I -V
|
||||
Show version.
|
||||
|
||||
|
||||
.SH "SEE ALSO"
|
||||
Homepage: http://sourceforge.net/projects/megactl
|
||||
.br
|
||||
Some examples scripts (Debian systems): /usr/share/doc/megactl/examples/
|
||||
.br
|
||||
megactl(8): Same tool, for SCSI adapters.
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Adam Cécile (Le_Vert) <gandalf@le-vert.net> for the Debian system (but may be used by others).
|
||||
.br
|
||||
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation
|
||||
.br
|
||||
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.
|
39
debian/man/megatrace/megatrace.8
vendored
39
debian/man/megatrace/megatrace.8
vendored
@ -1,39 +0,0 @@
|
||||
.TH MEGATRACE "8" "September 2007" "0.4.1" "User Commands"
|
||||
|
||||
.SH NAME
|
||||
megatrace - a debugging program which can be used to trace LSI MegaRAID-related ioctl() system calls.
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B megatrace
|
||||
is debugging program which can be used to trace LSI MegaRAID-related ioctl() system calls.
|
||||
.br
|
||||
You won't need that unless you're trying to add features to megactl, or are exceptionally curious.
|
||||
.br
|
||||
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.
|
||||
.PP
|
||||
If you're not developer, please check megactl(8) or megactlsas(8).
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B megatrace
|
||||
<command_to_trace>
|
||||
.PP
|
||||
You may really consider tracing a command that access MegaRAID card, like Dell's dellmgr or LSI's megacli.
|
||||
|
||||
.SH OPTIONS
|
||||
.B megatrace
|
||||
has no options.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
Homepage: http://sourceforge.net/projects/megactl
|
||||
.br
|
||||
Some examples scripts (Debian systems): /usr/share/doc/megactl/examples/
|
||||
.br
|
||||
megactl(8): Reporting tool for SCSI adapters.
|
||||
megasasctl(8): Reporting tool for SAS adapters.
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Adam Cécile (Le_Vert) <gandalf@le-vert.net> for the Debian system (but may be used by others).
|
||||
.br
|
||||
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation
|
||||
.br
|
||||
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.
|
5
debian/megactl.install
vendored
5
debian/megactl.install
vendored
@ -1,5 +0,0 @@
|
||||
src/megactl usr/lib/megactl
|
||||
src/megasasctl usr/lib/megactl
|
||||
debian/wrappers/create-devices-nodes usr/lib/megactl
|
||||
debian/wrappers/megactl usr/sbin
|
||||
debian/wrappers/megasasctl usr/sbin
|
1
debian/megactl.manpages
vendored
1
debian/megactl.manpages
vendored
@ -1 +0,0 @@
|
||||
debian/man/megactl/*
|
13
debian/megactl.preinst
vendored
13
debian/megactl.preinst
vendored
@ -1,13 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
# Skip if there's no previous version
|
||||
if [ ! -z $2 ]; then
|
||||
if dpkg --compare-versions $2 lt 0.4.1-4; then
|
||||
update-rc.d -f megactl-makedev remove || true
|
||||
rm -f /etc/init.d/megactl-makedev
|
||||
fi
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
2
debian/megatrace.install
vendored
2
debian/megatrace.install
vendored
@ -1,2 +0,0 @@
|
||||
src/megatrace usr/lib/megactl
|
||||
debian/wrappers/megatrace usr/sbin
|
1
debian/megatrace.manpages
vendored
1
debian/megatrace.manpages
vendored
@ -1 +0,0 @@
|
||||
debian/man/megatrace/*
|
@ -1,74 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 000-No_absolute_pathes_in_examples.dpatch
|
||||
## by Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||
##
|
||||
## DP: Drop all absolute pathes to binaries in megarpt and megasasrpt
|
||||
## DP: example scripts.
|
||||
|
||||
@DPATCH@
|
||||
|
||||
diff -u megactl-0.4.1/src/megarpt megactl-0.4.1/src.new/megarpt
|
||||
--- megactl-0.4.1/src/megarpt 2007-08-21 09:19:53.000000000 +0200
|
||||
+++ megactl-0.4.1/src.new/megarpt 2007-09-26 11:07:05.584181968 +0200
|
||||
@@ -9,7 +9,7 @@
|
||||
# Date: 2007/08/20
|
||||
|
||||
VERSION='0.3'
|
||||
-MEGACTL=/root/megactl
|
||||
+MEGACTL=/usr/sbin/megactl
|
||||
DEVICE=/dev/megadev0
|
||||
DEVICENAME=megadev
|
||||
DEVICEPERM=644
|
||||
@@ -32,8 +32,8 @@
|
||||
if [ -e "$DEVICE" ]; then
|
||||
|
||||
WARN=
|
||||
- HOST=`/bin/uname -n`
|
||||
- DATE=`/bin/date '+%Y/%m/%d %H:%M:%S %Z'`
|
||||
+ HOST=`uname -n`
|
||||
+ DATE=`date '+%Y/%m/%d %H:%M:%S %Z'`
|
||||
HC=/tmp/megactl.$$
|
||||
|
||||
$MEGACTL -vH > $HC 2>/dev/null
|
||||
@@ -59,7 +59,7 @@
|
||||
echo "$ME version: $VERSION"
|
||||
echo "megactl version: $MEGACTLVERSION"
|
||||
) 2>/dev/null |
|
||||
- /bin/mail -s "RAID report:$WARN $HOST $DATE" root
|
||||
+ mail -s "RAID report:$WARN $HOST $DATE" root
|
||||
|
||||
rm -f $HC
|
||||
fi
|
||||
|
||||
diff -u megactl-0.4.1/src/megasasrpt megactl-0.4.1/src.new/megasasrpt
|
||||
--- megactl-0.4.1/src/megasasrpt 2007-08-21 09:19:53.000000000 +0200
|
||||
+++ megactl-0.4.1/src.new/megasasrpt 2007-09-26 11:07:05.584181968 +0200
|
||||
@@ -9,7 +9,7 @@
|
||||
# Date: 2007/08/20
|
||||
|
||||
VERSION='0.3'
|
||||
-MEGACTL=/root/megasasctl
|
||||
+MEGACTL=/usr/sbin/megasasctl
|
||||
DEVICE=/dev/megaraid_sas_ioctl_node
|
||||
DEVICENAME=megaraid_sas_ioctl
|
||||
DEVICEPERM=400
|
||||
@@ -32,8 +32,8 @@
|
||||
if [ -e "$DEVICE" ]; then
|
||||
|
||||
WARN=
|
||||
- HOST=`/bin/uname -n`
|
||||
- DATE=`/bin/date '+%Y/%m/%d %H:%M:%S %Z'`
|
||||
+ HOST=`uname -n`
|
||||
+ DATE=`date '+%Y/%m/%d %H:%M:%S %Z'`
|
||||
HC=/tmp/megactl.$$
|
||||
|
||||
$MEGACTL -vH > $HC 2>/dev/null
|
||||
@@ -59,7 +59,7 @@
|
||||
echo "$ME version: $VERSION"
|
||||
echo "megactl version: $MEGACTLVERSION"
|
||||
) 2>/dev/null |
|
||||
- /bin/mail -s "RAID report:$WARN $HOST $DATE" root
|
||||
+ mail -s "RAID report:$WARN $HOST $DATE" root
|
||||
|
||||
rm -f $HC
|
||||
fi
|
@ -1,29 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 001-Drop_obsolete_asm_user.h.dpatch
|
||||
## by wschlich (Gentoo)
|
||||
##
|
||||
## DP: Stolen on Gentoo VCS, thanks a lot Gentoo guys :)
|
||||
## DP: http://sources.gentoo.org:80/viewcvs.py/gentoo-x86/sys-block/megactl/files/
|
||||
|
||||
@DPATCH@
|
||||
diff -urN megactl-0.4.1.orig/src/megatrace.c megactl-0.4.1/src/megatrace.c
|
||||
--- megactl-0.4.1.orig/src/megatrace.c 2007-08-21 09:19:53.000000000 +0200
|
||||
+++ megactl-0.4.1/src/megatrace.c 2008-02-10 21:27:24.416919438 +0100
|
||||
@@ -49,7 +49,7 @@
|
||||
#include <signal.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/wait.h>
|
||||
-#include <asm/user.h>
|
||||
+#include <sys/user.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
@@ -250,7 +250,7 @@
|
||||
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);
|
||||
+ fprintf (stderr, " ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx ebp=%08lx eax=%08lx xds=%08lx xes=%08lx xfs=%08lx xgs=%08lx orig_eax=%08lx eip=%08lx xcs=%08lx eflags=%08lx esp=%08lx xss=%08lx\n", r.ebx, r.ecx, r.edx, r.esi, r.edi, r.ebp, r.eax, r.xds, r.xes, r.xfs, r.xgs, r.orig_eax, r.eip, r.xcs, r.eflags, r.esp, r.xss);
|
||||
|
||||
copyout (buf, len, pid, r.edx);
|
||||
|
75
debian/patches/002-No_enclosure_support.dpatch
vendored
75
debian/patches/002-No_enclosure_support.dpatch
vendored
@ -1,75 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 002-No_enclosure_support by Pat Suwalski <pat@suwalski.net>
|
||||
##
|
||||
## DP: The root of the problem is that a lot of the logic behind building
|
||||
## DP: the enclosure map and printing the disk list compares directly the
|
||||
## DP: adapter channel list with the physical disk enclosure number, like so:
|
||||
## DP:
|
||||
## DP: if (device->device[k].enclosure == a->channel[j])
|
||||
## DP:
|
||||
## DP: The problem is that one is a uint16_t and the other is a uint8_t.
|
||||
## DP: When an enclosure is not present, the value comes back as all-ones.
|
||||
## DP: So, the code was trying in numerous places to compare 0xffff with
|
||||
## DP: 0xff. Adjusting the struct so both members are uint16_t fixes this.
|
||||
## DP:
|
||||
## DP: The patch also changes the output when no enclosure is present to
|
||||
## DP: put an asterisk as the enclosure ID in the output.
|
||||
## DP: The output on the same machine now looks like this:
|
||||
## DP:
|
||||
## DP: a0 PERC 5/i Integrated encl:1 ldrv:2 batt:good
|
||||
## DP: a0d0 19GiB RAID 5 1x4 DEGRADED
|
||||
## DP: a0d1 5567GiB RAID 5 1x4 DEGRADED
|
||||
## DP: a0e*s0 1863GiB a0d0+ online errs: media:0 other:28
|
||||
## DP: a0e*s1 1863GiB a0d0+ rebuild errs: media:0 other:26
|
||||
## DP: a0e*s2 1863GiB a0d0+ online errs: media:0 other:28
|
||||
## DP: a0e*s3 1863GiB a0d0+ online errs: media:0 other:28
|
||||
|
||||
@DPATCH@
|
||||
Index: adapter.c
|
||||
===================================================================
|
||||
--- a/src/adapter.c (revision 6)
|
||||
+++ b/src/adapter.c (working copy)
|
||||
@@ -192,7 +192,10 @@
|
||||
d->channel = info->enclosure;
|
||||
d->id = info->slot;
|
||||
|
||||
- snprintf (d->name, sizeof (d->name), "%se%us%u", a->name, d->channel, d->id);
|
||||
+ if (d->channel == DISK_NOENC)
|
||||
+ snprintf (d->name, sizeof (d->name), "%se*s%u", a->name, d->id);
|
||||
+ else
|
||||
+ 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);
|
||||
@@ -691,6 +694,7 @@
|
||||
for (j = 0; j < a->num_channels; ++j)
|
||||
if (device->device[k].enclosure == a->channel[j])
|
||||
break;
|
||||
+
|
||||
if (j < a->num_channels)
|
||||
continue;
|
||||
|
||||
Index: mega.h
|
||||
===================================================================
|
||||
--- a/src/mega.h (revision 6)
|
||||
+++ b/src/mega.h (working copy)
|
||||
@@ -114,7 +114,10 @@
|
||||
#define SCSI_SELFTEST_FOREGROUND_SHORT 0x05
|
||||
#define SCSI_SELFTEST_FOREGROUND_LONG 0x06
|
||||
|
||||
+/* Drives without enclosure report this as the enclosure ID */
|
||||
+#define DISK_NOENC 0xffff
|
||||
|
||||
+
|
||||
/* megaraid2 header file gets this wrong. */
|
||||
typedef struct {
|
||||
uint8_t max_commands;
|
||||
@@ -545,7 +548,7 @@
|
||||
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 *channel; /* channel/enclosure map */
|
||||
uint16_t num_physicals;
|
||||
struct physical_drive_info *physical;
|
||||
struct physical_drive_info **physical_list; /* ordered list of physical devices */
|
@ -1,64 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 003-Fix_disk_enumeration_loop.dpatch by Pat Suwalski <pat@suwalski.net>
|
||||
##
|
||||
## DP: When my controller has a failed disk, megasasctl fails.
|
||||
## DP:
|
||||
## DP: I have tracked the problem down to a bad assumption, that the various
|
||||
## DP: disk enumeration loops would use the number of currently online drives
|
||||
## DP: as the basis for the iterator.
|
||||
## DP:
|
||||
## DP: This number decreases when a disk fails. It is not noticeable in many
|
||||
## DP: cases, because on many some controllers pinfo->pd_present_count is
|
||||
## DP: one higher than the actual number of disks.
|
||||
## DP: However, the same situation would be encountered in a RAID1 system with
|
||||
## DP: two failed disks.
|
||||
## DP:
|
||||
## DP: The attached one-line patch uses the number of ports
|
||||
## DP: on the controller as the basis.
|
||||
|
||||
@DPATCH@
|
||||
|
||||
This patch fixes a segfault based on an incorrect assumption that the number
|
||||
of physical drives to loop over is the number of currently online drives
|
||||
connected to the controller. This change plays it safe and makes it use the
|
||||
number of ports on the controller, with a fallback for the worst case
|
||||
scenario.
|
||||
|
||||
Pat Suwalski <pat@suwalski.net>
|
||||
|
||||
diff -ur megactl-code/src/adapter.c megactl-code2/src/adapter.c
|
||||
--- a/src/adapter.c 2014-01-20 11:13:48.114598462 -0500
|
||||
+++ b/src/adapter.c 2014-01-20 14:33:32.950851825 -0500
|
||||
@@ -706,7 +706,31 @@
|
||||
}
|
||||
qsort (a->channel, a->num_channels, sizeof (*a->channel), cmpChannel);
|
||||
|
||||
- a->num_physicals = pinfo->pd_present_count;
|
||||
+ /* Some notes:
|
||||
+ Different meanings on different models.
|
||||
+ - FC_MAX_PHYSICAL_DEVICES used on older controllers, which is 256
|
||||
+ disks (overallocation)
|
||||
+ - pd_disk_present_count is number of working drives, not counting
|
||||
+ missing drives
|
||||
+ - pd_present_count is unclear. It is pd_disk_present_count + 1 on some
|
||||
+ controllers
|
||||
+ - device_interface.port_count contains number of physical ports on the
|
||||
+ controller
|
||||
+
|
||||
+ pd_present_count was used here, but in some controllers causes segfaults
|
||||
+ when there is a failed drive, and not enough space is allocated.
|
||||
+
|
||||
+ Since there cannot be more devices than there are ports, that is a safe
|
||||
+ number to set without going overboard.
|
||||
+ */
|
||||
+ a->num_physicals = pinfo->device_interface.port_count;
|
||||
+
|
||||
+ /* On some controllers, namely the PERC6e, the controller does not know
|
||||
+ how many ports there are in the enclosure. Fall back to the worst case
|
||||
+ scenario. */
|
||||
+ if (a->num_physicals < pinfo->pd_disk_present_count)
|
||||
+ 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));
|
@ -1,18 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 004-Fix_build_on_recent_distros.dpatch by Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||
##
|
||||
## DP: SYS_madvise1 has been renamed to SYS_madvise a long time ago (btw, it's
|
||||
## DP: not used anywhere)
|
||||
|
||||
@DPATCH@
|
||||
--- a/src/callinfo.c 2007-08-21 08:47:29.000000000 +0200
|
||||
+++ b/src/callinfo.c 2014-01-21 22:51:59.788201043 +0100
|
||||
@@ -255,7 +255,7 @@
|
||||
{ SYS_setfsgid32, 0, "setfsgid32" },
|
||||
{ SYS_pivot_root, 0, "pivot_root" },
|
||||
{ SYS_mincore, 0, "mincore" },
|
||||
- { SYS_madvise1, 0, "madvise1" },
|
||||
+ { SYS_madvise, 0, "madvise" },
|
||||
{ SYS_getdents64, 0, "getdents64" },
|
||||
{ SYS_fcntl64, 0, "fcntl64" },
|
||||
{ 222, 0, NULL },
|
33
debian/patches/005-Makefile.dpatch
vendored
33
debian/patches/005-Makefile.dpatch
vendored
@ -1,33 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 004-Makefile.dpatch by Mario Fetka (geos_one) <mario.fetka@gmail.com>
|
||||
##
|
||||
## DP: megatrace must be build with m32 on 64bit hosts
|
||||
## DP: thx. to gentoo devs
|
||||
|
||||
@DPATCH@
|
||||
diff -urN megactl-0.4.1.orig/src/Makefile megactl-0.4.1/src/Makefile
|
||||
--- megactl-0.4.1.orig/src/Makefile 2007-08-21 09:19:53.000000000 +0200
|
||||
+++ megactl-0.4.1/src/Makefile 2009-11-21 12:30:44.242501898 +0100
|
||||
@@ -1,11 +1,17 @@
|
||||
|
||||
-SRCS= megactl.c adapter.c megaioctl.c megatrace.c callinfo.c dumpbytes.c logpage.c ntrim.c
|
||||
+SRCS= megactl.c adapter.c megaioctl.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
|
||||
+ARCH?= -m32
|
||||
+CFLAGS?= -g -Wall
|
||||
+CFLAGS+= $(INC) $(ARCH)
|
||||
+LDFLAGS?= -g
|
||||
+LDFLAGS+= $(ARCH)
|
||||
+PROGRAMS= megactl megasasctl
|
||||
+ifeq ($(ARCH),-m32)
|
||||
+PROGRAMS+= megatrace
|
||||
+SRCS+= megatrace.c
|
||||
+endif
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
53
debian/patches/006-gcc-fixes.dpatch
vendored
53
debian/patches/006-gcc-fixes.dpatch
vendored
@ -1,53 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 004-gcc-fixes.dpatch by Mario Fetka (geos_one) <mario.fetka@gmail.com>
|
||||
##
|
||||
## DP: get it build on newer kernels
|
||||
## DP: thx. to gentoo devs
|
||||
|
||||
@DPATCH@
|
||||
diff -Nuar --exclude '*.swp' --exclude '*.o' megactl-0.4.1.orig/src/callinfo.c megactl-0.4.1/src/callinfo.c
|
||||
--- megactl-0.4.1.orig/src/callinfo.c 2007-08-21 00:19:53.000000000 -0700
|
||||
+++ megactl-0.4.1/src/callinfo.c 2014-07-13 22:05:06.585598812 -0700
|
||||
@@ -255,7 +255,12 @@
|
||||
{ SYS_setfsgid32, 0, "setfsgid32" },
|
||||
{ SYS_pivot_root, 0, "pivot_root" },
|
||||
{ SYS_mincore, 0, "mincore" },
|
||||
+#ifdef SYS_madvise
|
||||
+ { SYS_madvise, 0, "madvise" },
|
||||
+#endif
|
||||
+#ifdef SYS_madvise1
|
||||
{ SYS_madvise1, 0, "madvise1" },
|
||||
+#endif
|
||||
{ SYS_getdents64, 0, "getdents64" },
|
||||
{ SYS_fcntl64, 0, "fcntl64" },
|
||||
{ 222, 0, NULL },
|
||||
diff -Nuar --exclude '*.swp' --exclude '*.o' megactl-0.4.1.orig/src/logpage.c megactl-0.4.1/src/logpage.c
|
||||
--- megactl-0.4.1.orig/src/logpage.c 2007-08-21 00:19:53.000000000 -0700
|
||||
+++ megactl-0.4.1/src/logpage.c 2014-07-13 21:58:34.010848677 -0700
|
||||
@@ -20,6 +20,8 @@
|
||||
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
+#define __STDC_FORMAT_MACROS
|
||||
+#include <inttypes.h>
|
||||
|
||||
#include "megaioctl.h"
|
||||
#include "logpage.h"
|
||||
@@ -107,7 +109,7 @@
|
||||
|
||||
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);
|
||||
+ snprintf (bytes, sizeof bytes, "%3" PRIu64 "%s%s", b, suffix[k], unit);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@@ -378,7 +380,7 @@
|
||||
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);
|
||||
+ fprintf (f, " %2d: timestamp %4ud%02uh: %10s %-30s seg:%u lba:%-8"PRIu64" 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;
|
239
debian/patches/007-tracefix.dpatch
vendored
239
debian/patches/007-tracefix.dpatch
vendored
@ -1,239 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 004-tracefix.dpatch by Mario Fetka (geos_one) <mario.fetka@gmail.com>
|
||||
##
|
||||
## DP: megatrace fixup for 64bit systems
|
||||
## DP: thx. to gentoo devs
|
||||
|
||||
@DPATCH@
|
||||
diff -Nuar megactl-0.4.1.orig/src/megactl.c megactl-0.4.1/src/megactl.c
|
||||
--- megactl-0.4.1.orig/src/megactl.c 2007-08-21 00:19:53.000000000 -0700
|
||||
+++ megactl-0.4.1/src/megactl.c 2014-07-14 11:15:14.538745305 -0700
|
||||
@@ -45,6 +45,9 @@
|
||||
|
||||
********************************************************************/
|
||||
|
||||
+#define __STDC_FORMAT_MACROS
|
||||
+#include <inttypes.h>
|
||||
+
|
||||
#include "mega.h"
|
||||
#include "megaioctl.h"
|
||||
#include "adapter.h"
|
||||
@@ -207,7 +210,7 @@
|
||||
|
||||
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);
|
||||
+ snprintf (bytes, sizeof bytes, "%3"PRIu64"%s%s", b, suffix[k], unit);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@@ -604,6 +607,8 @@
|
||||
fprintf (stderr, "megaraid driver version %x too old.\n", driverVersion);
|
||||
return 1;
|
||||
}
|
||||
+#else
|
||||
+ driverVersion = 0;
|
||||
#endif
|
||||
|
||||
if (megaGetNumAdapters (fd, &numAdapters, sas) < 0)
|
||||
diff -Nuar megactl-0.4.1.orig/src/megaioctl.c megactl-0.4.1/src/megaioctl.c
|
||||
--- megactl-0.4.1.orig/src/megaioctl.c 2014-07-14 11:30:03.590781305 -0700
|
||||
+++ megactl-0.4.1/src/megaioctl.c 2014-07-14 11:31:36.410258930 -0700
|
||||
@@ -87,7 +87,11 @@
|
||||
m->cmd = cmd;
|
||||
m->opcode = opcode;
|
||||
m->subopcode = subopcode;
|
||||
+#ifdef __x86_64__
|
||||
+ m->xferaddr = (uint64_t) data;
|
||||
+#else
|
||||
m->xferaddr = (uint32_t) data;
|
||||
+#endif
|
||||
if (data)
|
||||
memset (data, 0, len);
|
||||
|
||||
@@ -115,7 +119,11 @@
|
||||
m->cmd = cmd;
|
||||
m->opcode = opcode;
|
||||
m->subopcode = subopcode;
|
||||
+#ifdef __x86_64__
|
||||
+ m->xferaddr = (uint64_t) data;
|
||||
+#else
|
||||
m->xferaddr = (uint32_t) data;
|
||||
+#endif
|
||||
if (data)
|
||||
memset (data, 0, len);
|
||||
|
||||
@@ -178,11 +186,19 @@
|
||||
u.ui.fcs.adapno = MKADAP(adapter->adapno);
|
||||
u.data = data;
|
||||
m->cmd = MBOXCMD_PASSTHRU;
|
||||
+#ifdef __x86_64__
|
||||
+ m->xferaddr = (uint64_t) p;
|
||||
+#else
|
||||
m->xferaddr = (uint32_t) p;
|
||||
+#endif
|
||||
p->timeout = 3;
|
||||
p->ars = 1;
|
||||
p->target = target;
|
||||
- p->dataxferaddr = (uint32_t) data;
|
||||
+#ifdef __x86_64__
|
||||
+ p->dataxferaddr = (uint64_t) data;
|
||||
+#else
|
||||
+ p->dataxferaddr = (uint32_t) data;
|
||||
+#endif
|
||||
p->dataxferlen = len;
|
||||
p->scsistatus = 239; /* HMMM */
|
||||
memcpy (p->cdb, cdb, cdblen);
|
||||
diff -Nuar megactl-0.4.1.orig/src/megatrace.c megactl-0.4.1/src/megatrace.c
|
||||
--- megactl-0.4.1.orig/src/megatrace.c 2014-07-14 01:31:47.704312799 -0700
|
||||
+++ megactl-0.4.1/src/megatrace.c 2014-07-14 11:37:20.570755832 -0700
|
||||
@@ -170,7 +170,11 @@
|
||||
fprintf (stderr, "ptrace:getregs: %s\n", strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
+#ifdef __x86_64__
|
||||
+ call = r.orig_rax;
|
||||
+#else
|
||||
call = r.orig_eax;
|
||||
+#endif
|
||||
/*printthis = call == SYS_ioctl;*/
|
||||
|
||||
if (state == INBOUND)
|
||||
@@ -188,18 +192,30 @@
|
||||
{
|
||||
if ((call < 0) || (call > callmax) || (callinfo[call].name == NULL))
|
||||
{
|
||||
+#ifdef __x86_64__
|
||||
+ fprintf (stderr, "= 0x%08llx\n", (unsigned long long) r.rax);
|
||||
+#else
|
||||
fprintf (stderr, "= 0x%08lx\n", (unsigned long) r.eax);
|
||||
+#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (callinfo[call].ptrval)
|
||||
{
|
||||
if (printcalls || printthis)
|
||||
+#ifdef __x86_64__
|
||||
+ fprintf (stderr, " = 0x%08llx\n", r.rax);
|
||||
+#else
|
||||
fprintf (stderr, " = 0x%08lx\n", r.eax);
|
||||
+#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
+#ifdef __x86_64__
|
||||
+ long rv = r.rax;
|
||||
+#else
|
||||
long rv = r.eax;
|
||||
+#endif
|
||||
if (rv < 0)
|
||||
{
|
||||
if (printcalls || printthis)
|
||||
@@ -219,16 +235,22 @@
|
||||
unsigned int len = 16;
|
||||
unsigned char buf[65536];
|
||||
|
||||
+#ifdef __x86_64__
|
||||
+ unsigned long long fd = r.rbx;
|
||||
+ unsigned long long ioc = r.rcx;
|
||||
+ unsigned long long arg = r.rdx;
|
||||
+#else
|
||||
unsigned long fd = r.ebx;
|
||||
-
|
||||
unsigned long ioc = r.ecx;
|
||||
+ unsigned long arg = r.edx;
|
||||
+#endif
|
||||
+
|
||||
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)
|
||||
{
|
||||
@@ -240,7 +262,11 @@
|
||||
|
||||
fprintf (stderr, "%s: ioctl(%ld, _IOC(\"%s\",'%c',0x%02x,0x%02x), 0x%08lx)", tbuf, fd, iocdirname, ioctype, iocnr, iocsize, arg);
|
||||
if (state == OUTBOUND)
|
||||
+#ifdef __x86_64__
|
||||
+ fprintf (stderr, " = %lld\n", r.rax);
|
||||
+#else
|
||||
fprintf (stderr, " = %ld\n", r.eax);
|
||||
+#endif
|
||||
if (getenv ("LOG_INBOUND"))
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
@@ -249,10 +275,18 @@
|
||||
if (len > sizeof buf)
|
||||
len = sizeof buf;
|
||||
|
||||
+#ifdef __x86_64__
|
||||
+ if (printregs)
|
||||
+ fprintf (stderr, " rbx=%08llx rcx=%08llx rdx=%08llx rsi=%08llx rdi=%08llx rbp=%08llx rax=%08llx ds=%08llx es=%08llx fs=%08llx gs=%08llx orig_rax=%08llx rip=%08llx cs=%08llx eflags=%08llx rsp=%08llx ss=%08llx\n", r.rbx, r.rcx, r.rdx, r.rsi, r.rdi, r.rbp, r.rax, r.ds, r.es, r.fs, r.gs, r.orig_rax, r.rip, r.cs, r.eflags, r.rsp, r.ss);
|
||||
+
|
||||
+ copyout (buf, len, pid, r.rdx);
|
||||
+#else
|
||||
if (printregs)
|
||||
fprintf (stderr, " ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx ebp=%08lx eax=%08lx xds=%08lx xes=%08lx xfs=%08lx xgs=%08lx orig_eax=%08lx eip=%08lx xcs=%08lx eflags=%08lx esp=%08lx xss=%08lx\n", r.ebx, r.ecx, r.edx, r.esi, r.edi, r.ebp, r.eax, r.xds, r.xes, r.xfs, r.xgs, r.orig_eax, r.eip, r.xcs, r.eflags, r.esp, r.xss);
|
||||
|
||||
copyout (buf, len, pid, r.edx);
|
||||
+#endif
|
||||
+
|
||||
|
||||
if ((ioctype == 'm') && (iocnr == 0) && (iocsize == sizeof (struct uioctl_t)))
|
||||
{
|
||||
@@ -405,7 +439,11 @@
|
||||
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);
|
||||
+#ifdef __x86_64__
|
||||
+ dumpbytes (stderr, buf, len, (void *) r.rdx, NULL);
|
||||
+#else
|
||||
dumpbytes (stderr, buf, len, (void *) r.edx, NULL);
|
||||
+#endif
|
||||
}
|
||||
if (log)
|
||||
{
|
||||
@@ -427,23 +465,38 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
+#ifdef __x86_64__
|
||||
+ dumpbytes (stderr, buf, len, (void *) r.rdx, NULL);
|
||||
+#else
|
||||
dumpbytes (stderr, buf, len, (void *) r.edx, NULL);
|
||||
+#endif
|
||||
}
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
+#ifdef __x86_64__
|
||||
+ static u64 lastrip = 0;
|
||||
+#else
|
||||
static u32 lasteip = 0;
|
||||
+#endif
|
||||
+
|
||||
|
||||
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. */
|
||||
+#ifdef __x86_64__
|
||||
+ if (lastrip == r.rip)
|
||||
+ state = INBOUND;
|
||||
+ lastrip = r.rip;
|
||||
+#else
|
||||
if (lasteip == r.eip)
|
||||
state = INBOUND;
|
||||
lasteip = r.eip;
|
||||
+#endif
|
||||
break;
|
||||
case INBOUND: state = OUTBOUND; break;
|
||||
case OUTBOUND: state = INBOUND; break;
|
21
debian/patches/008-device_id.dpatch
vendored
21
debian/patches/008-device_id.dpatch
vendored
@ -1,21 +0,0 @@
|
||||
#! /bin/sh /usr/share/dpatch/dpatch-run
|
||||
## 008-device_id.dpatch by Mario Fetka (geos_one) <mario.fetka@gmail.com>
|
||||
##
|
||||
## DP: add device_id to output
|
||||
## DP: thx. to gentoo devs
|
||||
|
||||
@DPATCH@
|
||||
--- megactl/src/adapter.c.orig 2017-04-22 17:15:55.068000000 +0200
|
||||
+++ megactl/src/adapter.c 2017-04-22 17:17:17.624000000 +0200
|
||||
@@ -193,9 +193,9 @@
|
||||
d->id = info->slot;
|
||||
|
||||
if (d->channel == DISK_NOENC)
|
||||
- snprintf (d->name, sizeof (d->name), "%se*s%u", a->name, d->id);
|
||||
+ snprintf (d->name, sizeof (d->name), "d%u%se*s%u", info->device_id, a->name, d->id);
|
||||
else
|
||||
- snprintf (d->name, sizeof (d->name), "%se%us%u", a->name, d->channel, d->id);
|
||||
+ snprintf (d->name, sizeof (d->name), "d%u%se%us%u", info->device_id, a->name, d->channel, d->id);
|
||||
|
||||
d->inquiry = info->inquiry.inq;
|
||||
strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1);
|
8
debian/patches/00list
vendored
8
debian/patches/00list
vendored
@ -1,8 +0,0 @@
|
||||
000-No_absolute_pathes_in_examples.dpatch
|
||||
001-Drop_obsolete_asm_user.h.dpatch
|
||||
002-No_enclosure_support.dpatch
|
||||
003-Fix_disk_enumeration_loop.dpatch
|
||||
005-Makefile.dpatch
|
||||
006-gcc-fixes.dpatch
|
||||
007-tracefix.dpatch
|
||||
008-device_id.dpatch
|
71
debian/rules
vendored
71
debian/rules
vendored
@ -1,71 +0,0 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
include /usr/share/dpatch/dpatch.make
|
||||
|
||||
ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
|
||||
|
||||
CFLAGS = -Wall -g
|
||||
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
||||
CFLAGS += -O0
|
||||
else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),i386)
|
||||
MY_MAKEOPTS="ARCH=-m32"
|
||||
MT_MAKEOPTS="ARCH=-m32"
|
||||
else
|
||||
MY_MAKEOPTS="ARCH=-m64"
|
||||
MT_MAKEOPTS="ARCH=-m32"
|
||||
endif
|
||||
# $(MAKE) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/
|
||||
|
||||
build: build-stamp
|
||||
build-stamp: patch-stamp
|
||||
dh_testdir
|
||||
$(MAKE) $(MT_MAKEOPTS) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/ megatrace
|
||||
mv src/megatrace src/megatrace.i386
|
||||
$(MAKE) clean -C src/
|
||||
$(MAKE) $(MY_MAKEOPTS) CFLAGS="$(CFLAGS) \$$(INC) \$$(ARCH)" -C src/
|
||||
mv src/megatrace.i386 src/megatrace
|
||||
touch $@
|
||||
|
||||
clean: unpatch
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -f build-stamp
|
||||
$(MAKE) clean -C src/
|
||||
dh_clean
|
||||
|
||||
install: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_installdirs
|
||||
|
||||
binary-indep: build install
|
||||
binary-arch: build install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs
|
||||
dh_installdocs
|
||||
dh_installexamples
|
||||
dh_install
|
||||
dh_installman
|
||||
dh_link
|
||||
dh_strip
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
dh_installdeb
|
||||
ifeq ($(ARCH),i386)
|
||||
dh_shlibdeps
|
||||
endif
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install
|
2
debian/watch
vendored
2
debian/watch
vendored
@ -1,2 +0,0 @@
|
||||
version=3
|
||||
http://sf.net/megactl/megactl-([0-9\.]+)\.tar\.gz
|
32
debian/wrappers/create-devices-nodes
vendored
32
debian/wrappers/create-devices-nodes
vendored
@ -1,32 +0,0 @@
|
||||
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||
# License: Public domain
|
||||
|
||||
create_node() {
|
||||
# Since 2.6.25rc2 linux kernel, megadev0 is created dynamically by udev
|
||||
# See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=90a95af85f22c82f87e5fb714bac7ee06673b0ff
|
||||
if [ ! -e /dev/megadev0 ]; then
|
||||
# Not available, try to create it by hand for kernel pre 2.6.25rc2
|
||||
grep -q 'megadev$' /proc/devices && MEGARAID="ok"
|
||||
if [ ! -z ${MEGARAID} ]; then
|
||||
MAJOR=`grep 'megadev$' /proc/devices | head -n 1 | awk '{ print $1 }'`
|
||||
mknod /dev/megadev0 c $MAJOR 0
|
||||
return $?
|
||||
fi
|
||||
fi
|
||||
if [ -e /dev/megadev0 ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
create_node_sas() {
|
||||
grep -q 'megaraid_sas_ioctl$' /proc/devices && MEGARAIDSAS="ok"
|
||||
if [ ! -z ${MEGARAIDSAS} ]; then
|
||||
MAJOR=`grep 'megaraid_sas_ioctl$' /proc/devices | head -n 1 | awk '{ print $1 }'`
|
||||
test -e /dev/megaraid_sas_ioctl_node || mknod /dev/megaraid_sas_ioctl_node c $MAJOR 0
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
15
debian/wrappers/megactl
vendored
15
debian/wrappers/megactl
vendored
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||
# License: Public domain
|
||||
|
||||
. /usr/lib/megactl/create-devices-nodes
|
||||
|
||||
create_node
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
/usr/lib/megactl/megactl $@
|
||||
else
|
||||
echo "No LSI MegaRAID cards found. You may try megasasctl instead."
|
||||
exit 1
|
||||
fi
|
15
debian/wrappers/megasasctl
vendored
15
debian/wrappers/megasasctl
vendored
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||
# License: Public domain
|
||||
|
||||
. /usr/lib/megactl/create-devices-nodes
|
||||
|
||||
create_node_sas
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
/usr/lib/megactl/megasasctl $@
|
||||
else
|
||||
echo "No LSI MegaRAID SAS cards found. You may try megactl instead."
|
||||
exit 1
|
||||
fi
|
11
debian/wrappers/megatrace
vendored
11
debian/wrappers/megatrace
vendored
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||
# License: Public domain
|
||||
|
||||
. /usr/lib/megactl/create-devices-nodes
|
||||
|
||||
create_node
|
||||
create_node_sas
|
||||
|
||||
/usr/lib/megactl/megatrace $@
|
BIN
megactl_0.4.1.1.orig.tar.gz.delta
Normal file
BIN
megactl_0.4.1.1.orig.tar.gz.delta
Normal file
Binary file not shown.
1
megactl_0.4.1.1.orig.tar.gz.id
Normal file
1
megactl_0.4.1.1.orig.tar.gz.id
Normal file
@ -0,0 +1 @@
|
||||
22c4d2002b38b54943b4003a31869b16acc919ae
|
BIN
megactl_0.4.1.orig.tar.gz.delta
Normal file
BIN
megactl_0.4.1.orig.tar.gz.delta
Normal file
Binary file not shown.
1
megactl_0.4.1.orig.tar.gz.id
Normal file
1
megactl_0.4.1.orig.tar.gz.id
Normal file
@ -0,0 +1 @@
|
||||
22c4d2002b38b54943b4003a31869b16acc919ae
|
42
src/Makefile
42
src/Makefile
@ -1,42 +0,0 @@
|
||||
|
||||
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
845
src/adapter.c
@ -1,845 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
#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
413
src/callinfo.c
@ -1,413 +0,0 @@
|
||||
/*
|
||||
* 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]);
|
||||
|
@ -1,35 +0,0 @@
|
||||
#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
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
#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
|
@ -1 +0,0 @@
|
||||
megaraid-2.20.4.6-rh2
|
@ -1,823 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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: */
|
@ -1,290 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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:
|
@ -1,300 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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_ */
|
File diff suppressed because it is too large
Load Diff
@ -1,237 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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:
|
File diff suppressed because it is too large
Load Diff
@ -1,105 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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:
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
420
src/logpage.c
420
src/logpage.c
@ -1,420 +0,0 @@
|
||||
/*
|
||||
* 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
148
src/logpage.h
@ -1,148 +0,0 @@
|
||||
#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
585
src/mega.h
@ -1,585 +0,0 @@
|
||||
#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
926
src/megactl.c
@ -1,926 +0,0 @@
|
||||
/*
|
||||
* 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
523
src/megaioctl.c
@ -1,523 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
#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 +0,0 @@
|
||||
kernel-2.6.9-55.0.2.EL/megaraid-2.20.4.6-rh2
|
66
src/megarpt
66
src/megarpt
@ -1,66 +0,0 @@
|
||||
#!/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
|
||||
|
@ -1,66 +0,0 @@
|
||||
#!/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
468
src/megatrace.c
@ -1,468 +0,0 @@
|
||||
/*
|
||||
* 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
412
src/modepage.c
@ -1,412 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,75 +0,0 @@
|
||||
#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
45
src/ntrim.c
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* 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
27
src/ntrim.h
@ -1,27 +0,0 @@
|
||||
#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
|
@ -1,69 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,120 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,119 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,67 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,76 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,145 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,177 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,82 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,49 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,43 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,113 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,38 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,111 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,64 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,75 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,483 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,63 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,103 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,105 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,95 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,156 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,155 +0,0 @@
|
||||
#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_
|
@ -1,196 +0,0 @@
|
||||
#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
|
@ -1,200 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,68 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,69 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,249 +0,0 @@
|
||||
/* @(#)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 */
|
@ -1,111 +0,0 @@
|
||||
/* @(#)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 */
|
File diff suppressed because it is too large
Load Diff
@ -1,191 +0,0 @@
|
||||
/* @(#)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 */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user