ia64/xen-unstable

changeset 10731:bd68ce5a3f0c

Remove qemu 0.6.1 based ioemu.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author chris@kneesaa.uk.xensource.com
date Wed Jul 12 19:16:07 2006 +0100 (2006-07-12)
parents b20580cf7fc1
children b450f21472a0
files tools/ioemu/COPYING tools/ioemu/COPYING.LIB tools/ioemu/Changelog tools/ioemu/Makefile tools/ioemu/README tools/ioemu/TODO tools/ioemu/VERSION tools/ioemu/aes.c tools/ioemu/aes.h tools/ioemu/audio/audio.c tools/ioemu/audio/audio.h tools/ioemu/audio/audio_int.h tools/ioemu/audio/mixeng.c tools/ioemu/audio/mixeng.h tools/ioemu/audio/mixeng_template.h tools/ioemu/audio/noaudio.c tools/ioemu/audio/ossaudio.c tools/ioemu/audio/sdlaudio.c tools/ioemu/audio/wavaudio.c tools/ioemu/block-cloop.c tools/ioemu/block-cow.c tools/ioemu/block-qcow.c tools/ioemu/block-vmdk.c tools/ioemu/block.c tools/ioemu/block_int.h tools/ioemu/bswap.h tools/ioemu/configure tools/ioemu/console.c tools/ioemu/cpu-all.h tools/ioemu/cpu-defs.h tools/ioemu/cpu.h tools/ioemu/create_keysym_header.sh tools/ioemu/exec-all.h tools/ioemu/exec.c tools/ioemu/hw/acpi.c tools/ioemu/hw/adb.c tools/ioemu/hw/adlib.c tools/ioemu/hw/cirrus_vga.c tools/ioemu/hw/cirrus_vga_rop.h tools/ioemu/hw/cirrus_vga_rop2.h tools/ioemu/hw/cuda.c tools/ioemu/hw/dma.c tools/ioemu/hw/fdc.c tools/ioemu/hw/fmopl.c tools/ioemu/hw/fmopl.h tools/ioemu/hw/i8254.c tools/ioemu/hw/i8259.c tools/ioemu/hw/i8259_stub.c tools/ioemu/hw/ide.c tools/ioemu/hw/iommu.c tools/ioemu/hw/lance.c tools/ioemu/hw/m48t08.c tools/ioemu/hw/m48t08.h tools/ioemu/hw/m48t59.c tools/ioemu/hw/m48t59.h tools/ioemu/hw/magic-load.c tools/ioemu/hw/mc146818rtc.c tools/ioemu/hw/ne2000.c tools/ioemu/hw/openpic.c tools/ioemu/hw/pc.c tools/ioemu/hw/pci.c tools/ioemu/hw/pckbd.c tools/ioemu/hw/pcnet.c tools/ioemu/hw/pcnet.h tools/ioemu/hw/piix4acpi.c tools/ioemu/hw/port-e9.c tools/ioemu/hw/ppc.c tools/ioemu/hw/ppc_chrp.c tools/ioemu/hw/ppc_prep.c tools/ioemu/hw/sb16.c tools/ioemu/hw/sched.c tools/ioemu/hw/serial.c tools/ioemu/hw/sun4m.c tools/ioemu/hw/tcx.c tools/ioemu/hw/timer.c tools/ioemu/hw/usb-hid.c tools/ioemu/hw/usb-hub.c tools/ioemu/hw/usb-uhci.c tools/ioemu/hw/usb.c tools/ioemu/hw/usb.h tools/ioemu/hw/vga.c tools/ioemu/hw/vga_int.h tools/ioemu/hw/vga_template.h tools/ioemu/ia64_intrinsic.h tools/ioemu/keyboard_rdesktop.c tools/ioemu/keymaps/ar tools/ioemu/keymaps/common tools/ioemu/keymaps/convert-map tools/ioemu/keymaps/da tools/ioemu/keymaps/de tools/ioemu/keymaps/de-ch tools/ioemu/keymaps/en-gb tools/ioemu/keymaps/en-us tools/ioemu/keymaps/es tools/ioemu/keymaps/et tools/ioemu/keymaps/fi tools/ioemu/keymaps/fo tools/ioemu/keymaps/fr tools/ioemu/keymaps/fr-be tools/ioemu/keymaps/fr-ca tools/ioemu/keymaps/fr-ch tools/ioemu/keymaps/hr tools/ioemu/keymaps/hu tools/ioemu/keymaps/is tools/ioemu/keymaps/it tools/ioemu/keymaps/ja tools/ioemu/keymaps/lt tools/ioemu/keymaps/lv tools/ioemu/keymaps/mk tools/ioemu/keymaps/modifiers tools/ioemu/keymaps/nl tools/ioemu/keymaps/nl-be tools/ioemu/keymaps/no tools/ioemu/keymaps/pl tools/ioemu/keymaps/pt tools/ioemu/keymaps/pt-br tools/ioemu/keymaps/ru tools/ioemu/keymaps/sl tools/ioemu/keymaps/sv tools/ioemu/keymaps/th tools/ioemu/keymaps/tr tools/ioemu/main.c tools/ioemu/monitor.c tools/ioemu/osdep.c tools/ioemu/osdep.h tools/ioemu/path.c tools/ioemu/qemu-binfmt-conf.sh tools/ioemu/qemu-img.c tools/ioemu/readline.c tools/ioemu/sdl.c tools/ioemu/target-i386-dm/Makefile tools/ioemu/target-i386-dm/helper2.c tools/ioemu/target-i386-dm/qemu-dm.debug tools/ioemu/target-i386-dm/qemu-ifup tools/ioemu/thunk.c tools/ioemu/thunk.h tools/ioemu/usb-linux.c tools/ioemu/vgafont.h tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c tools/ioemu/x86_32.ld tools/ioemu/x86_64.ld
line diff
     1.1 --- a/tools/ioemu/COPYING	Wed Jul 12 16:34:39 2006 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,339 +0,0 @@
     1.4 -		    GNU GENERAL PUBLIC LICENSE
     1.5 -		       Version 2, June 1991
     1.6 -
     1.7 - Copyright (C) 1989, 1991 Free Software Foundation, Inc.
     1.8 -                          675 Mass Ave, Cambridge, MA 02139, USA
     1.9 - Everyone is permitted to copy and distribute verbatim copies
    1.10 - of this license document, but changing it is not allowed.
    1.11 -
    1.12 -			    Preamble
    1.13 -
    1.14 -  The licenses for most software are designed to take away your
    1.15 -freedom to share and change it.  By contrast, the GNU General Public
    1.16 -License is intended to guarantee your freedom to share and change free
    1.17 -software--to make sure the software is free for all its users.  This
    1.18 -General Public License applies to most of the Free Software
    1.19 -Foundation's software and to any other program whose authors commit to
    1.20 -using it.  (Some other Free Software Foundation software is covered by
    1.21 -the GNU Library General Public License instead.)  You can apply it to
    1.22 -your programs, too.
    1.23 -
    1.24 -  When we speak of free software, we are referring to freedom, not
    1.25 -price.  Our General Public Licenses are designed to make sure that you
    1.26 -have the freedom to distribute copies of free software (and charge for
    1.27 -this service if you wish), that you receive source code or can get it
    1.28 -if you want it, that you can change the software or use pieces of it
    1.29 -in new free programs; and that you know you can do these things.
    1.30 -
    1.31 -  To protect your rights, we need to make restrictions that forbid
    1.32 -anyone to deny you these rights or to ask you to surrender the rights.
    1.33 -These restrictions translate to certain responsibilities for you if you
    1.34 -distribute copies of the software, or if you modify it.
    1.35 -
    1.36 -  For example, if you distribute copies of such a program, whether
    1.37 -gratis or for a fee, you must give the recipients all the rights that
    1.38 -you have.  You must make sure that they, too, receive or can get the
    1.39 -source code.  And you must show them these terms so they know their
    1.40 -rights.
    1.41 -
    1.42 -  We protect your rights with two steps: (1) copyright the software, and
    1.43 -(2) offer you this license which gives you legal permission to copy,
    1.44 -distribute and/or modify the software.
    1.45 -
    1.46 -  Also, for each author's protection and ours, we want to make certain
    1.47 -that everyone understands that there is no warranty for this free
    1.48 -software.  If the software is modified by someone else and passed on, we
    1.49 -want its recipients to know that what they have is not the original, so
    1.50 -that any problems introduced by others will not reflect on the original
    1.51 -authors' reputations.
    1.52 -
    1.53 -  Finally, any free program is threatened constantly by software
    1.54 -patents.  We wish to avoid the danger that redistributors of a free
    1.55 -program will individually obtain patent licenses, in effect making the
    1.56 -program proprietary.  To prevent this, we have made it clear that any
    1.57 -patent must be licensed for everyone's free use or not licensed at all.
    1.58 -
    1.59 -  The precise terms and conditions for copying, distribution and
    1.60 -modification follow.
    1.61 -
    1.62 -		    GNU GENERAL PUBLIC LICENSE
    1.63 -   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
    1.64 -
    1.65 -  0. This License applies to any program or other work which contains
    1.66 -a notice placed by the copyright holder saying it may be distributed
    1.67 -under the terms of this General Public License.  The "Program", below,
    1.68 -refers to any such program or work, and a "work based on the Program"
    1.69 -means either the Program or any derivative work under copyright law:
    1.70 -that is to say, a work containing the Program or a portion of it,
    1.71 -either verbatim or with modifications and/or translated into another
    1.72 -language.  (Hereinafter, translation is included without limitation in
    1.73 -the term "modification".)  Each licensee is addressed as "you".
    1.74 -
    1.75 -Activities other than copying, distribution and modification are not
    1.76 -covered by this License; they are outside its scope.  The act of
    1.77 -running the Program is not restricted, and the output from the Program
    1.78 -is covered only if its contents constitute a work based on the
    1.79 -Program (independent of having been made by running the Program).
    1.80 -Whether that is true depends on what the Program does.
    1.81 -
    1.82 -  1. You may copy and distribute verbatim copies of the Program's
    1.83 -source code as you receive it, in any medium, provided that you
    1.84 -conspicuously and appropriately publish on each copy an appropriate
    1.85 -copyright notice and disclaimer of warranty; keep intact all the
    1.86 -notices that refer to this License and to the absence of any warranty;
    1.87 -and give any other recipients of the Program a copy of this License
    1.88 -along with the Program.
    1.89 -
    1.90 -You may charge a fee for the physical act of transferring a copy, and
    1.91 -you may at your option offer warranty protection in exchange for a fee.
    1.92 -
    1.93 -  2. You may modify your copy or copies of the Program or any portion
    1.94 -of it, thus forming a work based on the Program, and copy and
    1.95 -distribute such modifications or work under the terms of Section 1
    1.96 -above, provided that you also meet all of these conditions:
    1.97 -
    1.98 -    a) You must cause the modified files to carry prominent notices
    1.99 -    stating that you changed the files and the date of any change.
   1.100 -
   1.101 -    b) You must cause any work that you distribute or publish, that in
   1.102 -    whole or in part contains or is derived from the Program or any
   1.103 -    part thereof, to be licensed as a whole at no charge to all third
   1.104 -    parties under the terms of this License.
   1.105 -
   1.106 -    c) If the modified program normally reads commands interactively
   1.107 -    when run, you must cause it, when started running for such
   1.108 -    interactive use in the most ordinary way, to print or display an
   1.109 -    announcement including an appropriate copyright notice and a
   1.110 -    notice that there is no warranty (or else, saying that you provide
   1.111 -    a warranty) and that users may redistribute the program under
   1.112 -    these conditions, and telling the user how to view a copy of this
   1.113 -    License.  (Exception: if the Program itself is interactive but
   1.114 -    does not normally print such an announcement, your work based on
   1.115 -    the Program is not required to print an announcement.)
   1.116 -
   1.117 -These requirements apply to the modified work as a whole.  If
   1.118 -identifiable sections of that work are not derived from the Program,
   1.119 -and can be reasonably considered independent and separate works in
   1.120 -themselves, then this License, and its terms, do not apply to those
   1.121 -sections when you distribute them as separate works.  But when you
   1.122 -distribute the same sections as part of a whole which is a work based
   1.123 -on the Program, the distribution of the whole must be on the terms of
   1.124 -this License, whose permissions for other licensees extend to the
   1.125 -entire whole, and thus to each and every part regardless of who wrote it.
   1.126 -
   1.127 -Thus, it is not the intent of this section to claim rights or contest
   1.128 -your rights to work written entirely by you; rather, the intent is to
   1.129 -exercise the right to control the distribution of derivative or
   1.130 -collective works based on the Program.
   1.131 -
   1.132 -In addition, mere aggregation of another work not based on the Program
   1.133 -with the Program (or with a work based on the Program) on a volume of
   1.134 -a storage or distribution medium does not bring the other work under
   1.135 -the scope of this License.
   1.136 -
   1.137 -  3. You may copy and distribute the Program (or a work based on it,
   1.138 -under Section 2) in object code or executable form under the terms of
   1.139 -Sections 1 and 2 above provided that you also do one of the following:
   1.140 -
   1.141 -    a) Accompany it with the complete corresponding machine-readable
   1.142 -    source code, which must be distributed under the terms of Sections
   1.143 -    1 and 2 above on a medium customarily used for software interchange; or,
   1.144 -
   1.145 -    b) Accompany it with a written offer, valid for at least three
   1.146 -    years, to give any third party, for a charge no more than your
   1.147 -    cost of physically performing source distribution, a complete
   1.148 -    machine-readable copy of the corresponding source code, to be
   1.149 -    distributed under the terms of Sections 1 and 2 above on a medium
   1.150 -    customarily used for software interchange; or,
   1.151 -
   1.152 -    c) Accompany it with the information you received as to the offer
   1.153 -    to distribute corresponding source code.  (This alternative is
   1.154 -    allowed only for noncommercial distribution and only if you
   1.155 -    received the program in object code or executable form with such
   1.156 -    an offer, in accord with Subsection b above.)
   1.157 -
   1.158 -The source code for a work means the preferred form of the work for
   1.159 -making modifications to it.  For an executable work, complete source
   1.160 -code means all the source code for all modules it contains, plus any
   1.161 -associated interface definition files, plus the scripts used to
   1.162 -control compilation and installation of the executable.  However, as a
   1.163 -special exception, the source code distributed need not include
   1.164 -anything that is normally distributed (in either source or binary
   1.165 -form) with the major components (compiler, kernel, and so on) of the
   1.166 -operating system on which the executable runs, unless that component
   1.167 -itself accompanies the executable.
   1.168 -
   1.169 -If distribution of executable or object code is made by offering
   1.170 -access to copy from a designated place, then offering equivalent
   1.171 -access to copy the source code from the same place counts as
   1.172 -distribution of the source code, even though third parties are not
   1.173 -compelled to copy the source along with the object code.
   1.174 -
   1.175 -  4. You may not copy, modify, sublicense, or distribute the Program
   1.176 -except as expressly provided under this License.  Any attempt
   1.177 -otherwise to copy, modify, sublicense or distribute the Program is
   1.178 -void, and will automatically terminate your rights under this License.
   1.179 -However, parties who have received copies, or rights, from you under
   1.180 -this License will not have their licenses terminated so long as such
   1.181 -parties remain in full compliance.
   1.182 -
   1.183 -  5. You are not required to accept this License, since you have not
   1.184 -signed it.  However, nothing else grants you permission to modify or
   1.185 -distribute the Program or its derivative works.  These actions are
   1.186 -prohibited by law if you do not accept this License.  Therefore, by
   1.187 -modifying or distributing the Program (or any work based on the
   1.188 -Program), you indicate your acceptance of this License to do so, and
   1.189 -all its terms and conditions for copying, distributing or modifying
   1.190 -the Program or works based on it.
   1.191 -
   1.192 -  6. Each time you redistribute the Program (or any work based on the
   1.193 -Program), the recipient automatically receives a license from the
   1.194 -original licensor to copy, distribute or modify the Program subject to
   1.195 -these terms and conditions.  You may not impose any further
   1.196 -restrictions on the recipients' exercise of the rights granted herein.
   1.197 -You are not responsible for enforcing compliance by third parties to
   1.198 -this License.
   1.199 -
   1.200 -  7. If, as a consequence of a court judgment or allegation of patent
   1.201 -infringement or for any other reason (not limited to patent issues),
   1.202 -conditions are imposed on you (whether by court order, agreement or
   1.203 -otherwise) that contradict the conditions of this License, they do not
   1.204 -excuse you from the conditions of this License.  If you cannot
   1.205 -distribute so as to satisfy simultaneously your obligations under this
   1.206 -License and any other pertinent obligations, then as a consequence you
   1.207 -may not distribute the Program at all.  For example, if a patent
   1.208 -license would not permit royalty-free redistribution of the Program by
   1.209 -all those who receive copies directly or indirectly through you, then
   1.210 -the only way you could satisfy both it and this License would be to
   1.211 -refrain entirely from distribution of the Program.
   1.212 -
   1.213 -If any portion of this section is held invalid or unenforceable under
   1.214 -any particular circumstance, the balance of the section is intended to
   1.215 -apply and the section as a whole is intended to apply in other
   1.216 -circumstances.
   1.217 -
   1.218 -It is not the purpose of this section to induce you to infringe any
   1.219 -patents or other property right claims or to contest validity of any
   1.220 -such claims; this section has the sole purpose of protecting the
   1.221 -integrity of the free software distribution system, which is
   1.222 -implemented by public license practices.  Many people have made
   1.223 -generous contributions to the wide range of software distributed
   1.224 -through that system in reliance on consistent application of that
   1.225 -system; it is up to the author/donor to decide if he or she is willing
   1.226 -to distribute software through any other system and a licensee cannot
   1.227 -impose that choice.
   1.228 -
   1.229 -This section is intended to make thoroughly clear what is believed to
   1.230 -be a consequence of the rest of this License.
   1.231 -
   1.232 -  8. If the distribution and/or use of the Program is restricted in
   1.233 -certain countries either by patents or by copyrighted interfaces, the
   1.234 -original copyright holder who places the Program under this License
   1.235 -may add an explicit geographical distribution limitation excluding
   1.236 -those countries, so that distribution is permitted only in or among
   1.237 -countries not thus excluded.  In such case, this License incorporates
   1.238 -the limitation as if written in the body of this License.
   1.239 -
   1.240 -  9. The Free Software Foundation may publish revised and/or new versions
   1.241 -of the General Public License from time to time.  Such new versions will
   1.242 -be similar in spirit to the present version, but may differ in detail to
   1.243 -address new problems or concerns.
   1.244 -
   1.245 -Each version is given a distinguishing version number.  If the Program
   1.246 -specifies a version number of this License which applies to it and "any
   1.247 -later version", you have the option of following the terms and conditions
   1.248 -either of that version or of any later version published by the Free
   1.249 -Software Foundation.  If the Program does not specify a version number of
   1.250 -this License, you may choose any version ever published by the Free Software
   1.251 -Foundation.
   1.252 -
   1.253 -  10. If you wish to incorporate parts of the Program into other free
   1.254 -programs whose distribution conditions are different, write to the author
   1.255 -to ask for permission.  For software which is copyrighted by the Free
   1.256 -Software Foundation, write to the Free Software Foundation; we sometimes
   1.257 -make exceptions for this.  Our decision will be guided by the two goals
   1.258 -of preserving the free status of all derivatives of our free software and
   1.259 -of promoting the sharing and reuse of software generally.
   1.260 -
   1.261 -			    NO WARRANTY
   1.262 -
   1.263 -  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
   1.264 -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
   1.265 -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
   1.266 -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
   1.267 -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   1.268 -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
   1.269 -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
   1.270 -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
   1.271 -REPAIR OR CORRECTION.
   1.272 -
   1.273 -  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
   1.274 -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
   1.275 -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
   1.276 -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
   1.277 -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
   1.278 -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
   1.279 -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
   1.280 -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
   1.281 -POSSIBILITY OF SUCH DAMAGES.
   1.282 -
   1.283 -		     END OF TERMS AND CONDITIONS
   1.284 -
   1.285 -	    How to Apply These Terms to Your New Programs
   1.286 -
   1.287 -  If you develop a new program, and you want it to be of the greatest
   1.288 -possible use to the public, the best way to achieve this is to make it
   1.289 -free software which everyone can redistribute and change under these terms.
   1.290 -
   1.291 -  To do so, attach the following notices to the program.  It is safest
   1.292 -to attach them to the start of each source file to most effectively
   1.293 -convey the exclusion of warranty; and each file should have at least
   1.294 -the "copyright" line and a pointer to where the full notice is found.
   1.295 -
   1.296 -    <one line to give the program's name and a brief idea of what it does.>
   1.297 -    Copyright (C) 19yy  <name of author>
   1.298 -
   1.299 -    This program is free software; you can redistribute it and/or modify
   1.300 -    it under the terms of the GNU General Public License as published by
   1.301 -    the Free Software Foundation; either version 2 of the License, or
   1.302 -    (at your option) any later version.
   1.303 -
   1.304 -    This program is distributed in the hope that it will be useful,
   1.305 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   1.306 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   1.307 -    GNU General Public License for more details.
   1.308 -
   1.309 -    You should have received a copy of the GNU General Public License
   1.310 -    along with this program; if not, write to the Free Software
   1.311 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   1.312 -
   1.313 -Also add information on how to contact you by electronic and paper mail.
   1.314 -
   1.315 -If the program is interactive, make it output a short notice like this
   1.316 -when it starts in an interactive mode:
   1.317 -
   1.318 -    Gnomovision version 69, Copyright (C) 19yy name of author
   1.319 -    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
   1.320 -    This is free software, and you are welcome to redistribute it
   1.321 -    under certain conditions; type `show c' for details.
   1.322 -
   1.323 -The hypothetical commands `show w' and `show c' should show the appropriate
   1.324 -parts of the General Public License.  Of course, the commands you use may
   1.325 -be called something other than `show w' and `show c'; they could even be
   1.326 -mouse-clicks or menu items--whatever suits your program.
   1.327 -
   1.328 -You should also get your employer (if you work as a programmer) or your
   1.329 -school, if any, to sign a "copyright disclaimer" for the program, if
   1.330 -necessary.  Here is a sample; alter the names:
   1.331 -
   1.332 -  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
   1.333 -  `Gnomovision' (which makes passes at compilers) written by James Hacker.
   1.334 -
   1.335 -  <signature of Ty Coon>, 1 April 1989
   1.336 -  Ty Coon, President of Vice
   1.337 -
   1.338 -This General Public License does not permit incorporating your program into
   1.339 -proprietary programs.  If your program is a subroutine library, you may
   1.340 -consider it more useful to permit linking proprietary applications with the
   1.341 -library.  If this is what you want to do, use the GNU Library General
   1.342 -Public License instead of this License.
     2.1 --- a/tools/ioemu/COPYING.LIB	Wed Jul 12 16:34:39 2006 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,504 +0,0 @@
     2.4 -		  GNU LESSER GENERAL PUBLIC LICENSE
     2.5 -		       Version 2.1, February 1999
     2.6 -
     2.7 - Copyright (C) 1991, 1999 Free Software Foundation, Inc.
     2.8 -     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     2.9 - Everyone is permitted to copy and distribute verbatim copies
    2.10 - of this license document, but changing it is not allowed.
    2.11 -
    2.12 -[This is the first released version of the Lesser GPL.  It also counts
    2.13 - as the successor of the GNU Library Public License, version 2, hence
    2.14 - the version number 2.1.]
    2.15 -
    2.16 -			    Preamble
    2.17 -
    2.18 -  The licenses for most software are designed to take away your
    2.19 -freedom to share and change it.  By contrast, the GNU General Public
    2.20 -Licenses are intended to guarantee your freedom to share and change
    2.21 -free software--to make sure the software is free for all its users.
    2.22 -
    2.23 -  This license, the Lesser General Public License, applies to some
    2.24 -specially designated software packages--typically libraries--of the
    2.25 -Free Software Foundation and other authors who decide to use it.  You
    2.26 -can use it too, but we suggest you first think carefully about whether
    2.27 -this license or the ordinary General Public License is the better
    2.28 -strategy to use in any particular case, based on the explanations below.
    2.29 -
    2.30 -  When we speak of free software, we are referring to freedom of use,
    2.31 -not price.  Our General Public Licenses are designed to make sure that
    2.32 -you have the freedom to distribute copies of free software (and charge
    2.33 -for this service if you wish); that you receive source code or can get
    2.34 -it if you want it; that you can change the software and use pieces of
    2.35 -it in new free programs; and that you are informed that you can do
    2.36 -these things.
    2.37 -
    2.38 -  To protect your rights, we need to make restrictions that forbid
    2.39 -distributors to deny you these rights or to ask you to surrender these
    2.40 -rights.  These restrictions translate to certain responsibilities for
    2.41 -you if you distribute copies of the library or if you modify it.
    2.42 -
    2.43 -  For example, if you distribute copies of the library, whether gratis
    2.44 -or for a fee, you must give the recipients all the rights that we gave
    2.45 -you.  You must make sure that they, too, receive or can get the source
    2.46 -code.  If you link other code with the library, you must provide
    2.47 -complete object files to the recipients, so that they can relink them
    2.48 -with the library after making changes to the library and recompiling
    2.49 -it.  And you must show them these terms so they know their rights.
    2.50 -
    2.51 -  We protect your rights with a two-step method: (1) we copyright the
    2.52 -library, and (2) we offer you this license, which gives you legal
    2.53 -permission to copy, distribute and/or modify the library.
    2.54 -
    2.55 -  To protect each distributor, we want to make it very clear that
    2.56 -there is no warranty for the free library.  Also, if the library is
    2.57 -modified by someone else and passed on, the recipients should know
    2.58 -that what they have is not the original version, so that the original
    2.59 -author's reputation will not be affected by problems that might be
    2.60 -introduced by others.
    2.61 -
    2.62 -  Finally, software patents pose a constant threat to the existence of
    2.63 -any free program.  We wish to make sure that a company cannot
    2.64 -effectively restrict the users of a free program by obtaining a
    2.65 -restrictive license from a patent holder.  Therefore, we insist that
    2.66 -any patent license obtained for a version of the library must be
    2.67 -consistent with the full freedom of use specified in this license.
    2.68 -
    2.69 -  Most GNU software, including some libraries, is covered by the
    2.70 -ordinary GNU General Public License.  This license, the GNU Lesser
    2.71 -General Public License, applies to certain designated libraries, and
    2.72 -is quite different from the ordinary General Public License.  We use
    2.73 -this license for certain libraries in order to permit linking those
    2.74 -libraries into non-free programs.
    2.75 -
    2.76 -  When a program is linked with a library, whether statically or using
    2.77 -a shared library, the combination of the two is legally speaking a
    2.78 -combined work, a derivative of the original library.  The ordinary
    2.79 -General Public License therefore permits such linking only if the
    2.80 -entire combination fits its criteria of freedom.  The Lesser General
    2.81 -Public License permits more lax criteria for linking other code with
    2.82 -the library.
    2.83 -
    2.84 -  We call this license the "Lesser" General Public License because it
    2.85 -does Less to protect the user's freedom than the ordinary General
    2.86 -Public License.  It also provides other free software developers Less
    2.87 -of an advantage over competing non-free programs.  These disadvantages
    2.88 -are the reason we use the ordinary General Public License for many
    2.89 -libraries.  However, the Lesser license provides advantages in certain
    2.90 -special circumstances.
    2.91 -
    2.92 -  For example, on rare occasions, there may be a special need to
    2.93 -encourage the widest possible use of a certain library, so that it becomes
    2.94 -a de-facto standard.  To achieve this, non-free programs must be
    2.95 -allowed to use the library.  A more frequent case is that a free
    2.96 -library does the same job as widely used non-free libraries.  In this
    2.97 -case, there is little to gain by limiting the free library to free
    2.98 -software only, so we use the Lesser General Public License.
    2.99 -
   2.100 -  In other cases, permission to use a particular library in non-free
   2.101 -programs enables a greater number of people to use a large body of
   2.102 -free software.  For example, permission to use the GNU C Library in
   2.103 -non-free programs enables many more people to use the whole GNU
   2.104 -operating system, as well as its variant, the GNU/Linux operating
   2.105 -system.
   2.106 -
   2.107 -  Although the Lesser General Public License is Less protective of the
   2.108 -users' freedom, it does ensure that the user of a program that is
   2.109 -linked with the Library has the freedom and the wherewithal to run
   2.110 -that program using a modified version of the Library.
   2.111 -
   2.112 -  The precise terms and conditions for copying, distribution and
   2.113 -modification follow.  Pay close attention to the difference between a
   2.114 -"work based on the library" and a "work that uses the library".  The
   2.115 -former contains code derived from the library, whereas the latter must
   2.116 -be combined with the library in order to run.
   2.117 -
   2.118 -		  GNU LESSER GENERAL PUBLIC LICENSE
   2.119 -   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
   2.120 -
   2.121 -  0. This License Agreement applies to any software library or other
   2.122 -program which contains a notice placed by the copyright holder or
   2.123 -other authorized party saying it may be distributed under the terms of
   2.124 -this Lesser General Public License (also called "this License").
   2.125 -Each licensee is addressed as "you".
   2.126 -
   2.127 -  A "library" means a collection of software functions and/or data
   2.128 -prepared so as to be conveniently linked with application programs
   2.129 -(which use some of those functions and data) to form executables.
   2.130 -
   2.131 -  The "Library", below, refers to any such software library or work
   2.132 -which has been distributed under these terms.  A "work based on the
   2.133 -Library" means either the Library or any derivative work under
   2.134 -copyright law: that is to say, a work containing the Library or a
   2.135 -portion of it, either verbatim or with modifications and/or translated
   2.136 -straightforwardly into another language.  (Hereinafter, translation is
   2.137 -included without limitation in the term "modification".)
   2.138 -
   2.139 -  "Source code" for a work means the preferred form of the work for
   2.140 -making modifications to it.  For a library, complete source code means
   2.141 -all the source code for all modules it contains, plus any associated
   2.142 -interface definition files, plus the scripts used to control compilation
   2.143 -and installation of the library.
   2.144 -
   2.145 -  Activities other than copying, distribution and modification are not
   2.146 -covered by this License; they are outside its scope.  The act of
   2.147 -running a program using the Library is not restricted, and output from
   2.148 -such a program is covered only if its contents constitute a work based
   2.149 -on the Library (independent of the use of the Library in a tool for
   2.150 -writing it).  Whether that is true depends on what the Library does
   2.151 -and what the program that uses the Library does.
   2.152 -  
   2.153 -  1. You may copy and distribute verbatim copies of the Library's
   2.154 -complete source code as you receive it, in any medium, provided that
   2.155 -you conspicuously and appropriately publish on each copy an
   2.156 -appropriate copyright notice and disclaimer of warranty; keep intact
   2.157 -all the notices that refer to this License and to the absence of any
   2.158 -warranty; and distribute a copy of this License along with the
   2.159 -Library.
   2.160 -
   2.161 -  You may charge a fee for the physical act of transferring a copy,
   2.162 -and you may at your option offer warranty protection in exchange for a
   2.163 -fee.
   2.164 -
   2.165 -  2. You may modify your copy or copies of the Library or any portion
   2.166 -of it, thus forming a work based on the Library, and copy and
   2.167 -distribute such modifications or work under the terms of Section 1
   2.168 -above, provided that you also meet all of these conditions:
   2.169 -
   2.170 -    a) The modified work must itself be a software library.
   2.171 -
   2.172 -    b) You must cause the files modified to carry prominent notices
   2.173 -    stating that you changed the files and the date of any change.
   2.174 -
   2.175 -    c) You must cause the whole of the work to be licensed at no
   2.176 -    charge to all third parties under the terms of this License.
   2.177 -
   2.178 -    d) If a facility in the modified Library refers to a function or a
   2.179 -    table of data to be supplied by an application program that uses
   2.180 -    the facility, other than as an argument passed when the facility
   2.181 -    is invoked, then you must make a good faith effort to ensure that,
   2.182 -    in the event an application does not supply such function or
   2.183 -    table, the facility still operates, and performs whatever part of
   2.184 -    its purpose remains meaningful.
   2.185 -
   2.186 -    (For example, a function in a library to compute square roots has
   2.187 -    a purpose that is entirely well-defined independent of the
   2.188 -    application.  Therefore, Subsection 2d requires that any
   2.189 -    application-supplied function or table used by this function must
   2.190 -    be optional: if the application does not supply it, the square
   2.191 -    root function must still compute square roots.)
   2.192 -
   2.193 -These requirements apply to the modified work as a whole.  If
   2.194 -identifiable sections of that work are not derived from the Library,
   2.195 -and can be reasonably considered independent and separate works in
   2.196 -themselves, then this License, and its terms, do not apply to those
   2.197 -sections when you distribute them as separate works.  But when you
   2.198 -distribute the same sections as part of a whole which is a work based
   2.199 -on the Library, the distribution of the whole must be on the terms of
   2.200 -this License, whose permissions for other licensees extend to the
   2.201 -entire whole, and thus to each and every part regardless of who wrote
   2.202 -it.
   2.203 -
   2.204 -Thus, it is not the intent of this section to claim rights or contest
   2.205 -your rights to work written entirely by you; rather, the intent is to
   2.206 -exercise the right to control the distribution of derivative or
   2.207 -collective works based on the Library.
   2.208 -
   2.209 -In addition, mere aggregation of another work not based on the Library
   2.210 -with the Library (or with a work based on the Library) on a volume of
   2.211 -a storage or distribution medium does not bring the other work under
   2.212 -the scope of this License.
   2.213 -
   2.214 -  3. You may opt to apply the terms of the ordinary GNU General Public
   2.215 -License instead of this License to a given copy of the Library.  To do
   2.216 -this, you must alter all the notices that refer to this License, so
   2.217 -that they refer to the ordinary GNU General Public License, version 2,
   2.218 -instead of to this License.  (If a newer version than version 2 of the
   2.219 -ordinary GNU General Public License has appeared, then you can specify
   2.220 -that version instead if you wish.)  Do not make any other change in
   2.221 -these notices.
   2.222 -
   2.223 -  Once this change is made in a given copy, it is irreversible for
   2.224 -that copy, so the ordinary GNU General Public License applies to all
   2.225 -subsequent copies and derivative works made from that copy.
   2.226 -
   2.227 -  This option is useful when you wish to copy part of the code of
   2.228 -the Library into a program that is not a library.
   2.229 -
   2.230 -  4. You may copy and distribute the Library (or a portion or
   2.231 -derivative of it, under Section 2) in object code or executable form
   2.232 -under the terms of Sections 1 and 2 above provided that you accompany
   2.233 -it with the complete corresponding machine-readable source code, which
   2.234 -must be distributed under the terms of Sections 1 and 2 above on a
   2.235 -medium customarily used for software interchange.
   2.236 -
   2.237 -  If distribution of object code is made by offering access to copy
   2.238 -from a designated place, then offering equivalent access to copy the
   2.239 -source code from the same place satisfies the requirement to
   2.240 -distribute the source code, even though third parties are not
   2.241 -compelled to copy the source along with the object code.
   2.242 -
   2.243 -  5. A program that contains no derivative of any portion of the
   2.244 -Library, but is designed to work with the Library by being compiled or
   2.245 -linked with it, is called a "work that uses the Library".  Such a
   2.246 -work, in isolation, is not a derivative work of the Library, and
   2.247 -therefore falls outside the scope of this License.
   2.248 -
   2.249 -  However, linking a "work that uses the Library" with the Library
   2.250 -creates an executable that is a derivative of the Library (because it
   2.251 -contains portions of the Library), rather than a "work that uses the
   2.252 -library".  The executable is therefore covered by this License.
   2.253 -Section 6 states terms for distribution of such executables.
   2.254 -
   2.255 -  When a "work that uses the Library" uses material from a header file
   2.256 -that is part of the Library, the object code for the work may be a
   2.257 -derivative work of the Library even though the source code is not.
   2.258 -Whether this is true is especially significant if the work can be
   2.259 -linked without the Library, or if the work is itself a library.  The
   2.260 -threshold for this to be true is not precisely defined by law.
   2.261 -
   2.262 -  If such an object file uses only numerical parameters, data
   2.263 -structure layouts and accessors, and small macros and small inline
   2.264 -functions (ten lines or less in length), then the use of the object
   2.265 -file is unrestricted, regardless of whether it is legally a derivative
   2.266 -work.  (Executables containing this object code plus portions of the
   2.267 -Library will still fall under Section 6.)
   2.268 -
   2.269 -  Otherwise, if the work is a derivative of the Library, you may
   2.270 -distribute the object code for the work under the terms of Section 6.
   2.271 -Any executables containing that work also fall under Section 6,
   2.272 -whether or not they are linked directly with the Library itself.
   2.273 -
   2.274 -  6. As an exception to the Sections above, you may also combine or
   2.275 -link a "work that uses the Library" with the Library to produce a
   2.276 -work containing portions of the Library, and distribute that work
   2.277 -under terms of your choice, provided that the terms permit
   2.278 -modification of the work for the customer's own use and reverse
   2.279 -engineering for debugging such modifications.
   2.280 -
   2.281 -  You must give prominent notice with each copy of the work that the
   2.282 -Library is used in it and that the Library and its use are covered by
   2.283 -this License.  You must supply a copy of this License.  If the work
   2.284 -during execution displays copyright notices, you must include the
   2.285 -copyright notice for the Library among them, as well as a reference
   2.286 -directing the user to the copy of this License.  Also, you must do one
   2.287 -of these things:
   2.288 -
   2.289 -    a) Accompany the work with the complete corresponding
   2.290 -    machine-readable source code for the Library including whatever
   2.291 -    changes were used in the work (which must be distributed under
   2.292 -    Sections 1 and 2 above); and, if the work is an executable linked
   2.293 -    with the Library, with the complete machine-readable "work that
   2.294 -    uses the Library", as object code and/or source code, so that the
   2.295 -    user can modify the Library and then relink to produce a modified
   2.296 -    executable containing the modified Library.  (It is understood
   2.297 -    that the user who changes the contents of definitions files in the
   2.298 -    Library will not necessarily be able to recompile the application
   2.299 -    to use the modified definitions.)
   2.300 -
   2.301 -    b) Use a suitable shared library mechanism for linking with the
   2.302 -    Library.  A suitable mechanism is one that (1) uses at run time a
   2.303 -    copy of the library already present on the user's computer system,
   2.304 -    rather than copying library functions into the executable, and (2)
   2.305 -    will operate properly with a modified version of the library, if
   2.306 -    the user installs one, as long as the modified version is
   2.307 -    interface-compatible with the version that the work was made with.
   2.308 -
   2.309 -    c) Accompany the work with a written offer, valid for at
   2.310 -    least three years, to give the same user the materials
   2.311 -    specified in Subsection 6a, above, for a charge no more
   2.312 -    than the cost of performing this distribution.
   2.313 -
   2.314 -    d) If distribution of the work is made by offering access to copy
   2.315 -    from a designated place, offer equivalent access to copy the above
   2.316 -    specified materials from the same place.
   2.317 -
   2.318 -    e) Verify that the user has already received a copy of these
   2.319 -    materials or that you have already sent this user a copy.
   2.320 -
   2.321 -  For an executable, the required form of the "work that uses the
   2.322 -Library" must include any data and utility programs needed for
   2.323 -reproducing the executable from it.  However, as a special exception,
   2.324 -the materials to be distributed need not include anything that is
   2.325 -normally distributed (in either source or binary form) with the major
   2.326 -components (compiler, kernel, and so on) of the operating system on
   2.327 -which the executable runs, unless that component itself accompanies
   2.328 -the executable.
   2.329 -
   2.330 -  It may happen that this requirement contradicts the license
   2.331 -restrictions of other proprietary libraries that do not normally
   2.332 -accompany the operating system.  Such a contradiction means you cannot
   2.333 -use both them and the Library together in an executable that you
   2.334 -distribute.
   2.335 -
   2.336 -  7. You may place library facilities that are a work based on the
   2.337 -Library side-by-side in a single library together with other library
   2.338 -facilities not covered by this License, and distribute such a combined
   2.339 -library, provided that the separate distribution of the work based on
   2.340 -the Library and of the other library facilities is otherwise
   2.341 -permitted, and provided that you do these two things:
   2.342 -
   2.343 -    a) Accompany the combined library with a copy of the same work
   2.344 -    based on the Library, uncombined with any other library
   2.345 -    facilities.  This must be distributed under the terms of the
   2.346 -    Sections above.
   2.347 -
   2.348 -    b) Give prominent notice with the combined library of the fact
   2.349 -    that part of it is a work based on the Library, and explaining
   2.350 -    where to find the accompanying uncombined form of the same work.
   2.351 -
   2.352 -  8. You may not copy, modify, sublicense, link with, or distribute
   2.353 -the Library except as expressly provided under this License.  Any
   2.354 -attempt otherwise to copy, modify, sublicense, link with, or
   2.355 -distribute the Library is void, and will automatically terminate your
   2.356 -rights under this License.  However, parties who have received copies,
   2.357 -or rights, from you under this License will not have their licenses
   2.358 -terminated so long as such parties remain in full compliance.
   2.359 -
   2.360 -  9. You are not required to accept this License, since you have not
   2.361 -signed it.  However, nothing else grants you permission to modify or
   2.362 -distribute the Library or its derivative works.  These actions are
   2.363 -prohibited by law if you do not accept this License.  Therefore, by
   2.364 -modifying or distributing the Library (or any work based on the
   2.365 -Library), you indicate your acceptance of this License to do so, and
   2.366 -all its terms and conditions for copying, distributing or modifying
   2.367 -the Library or works based on it.
   2.368 -
   2.369 -  10. Each time you redistribute the Library (or any work based on the
   2.370 -Library), the recipient automatically receives a license from the
   2.371 -original licensor to copy, distribute, link with or modify the Library
   2.372 -subject to these terms and conditions.  You may not impose any further
   2.373 -restrictions on the recipients' exercise of the rights granted herein.
   2.374 -You are not responsible for enforcing compliance by third parties with
   2.375 -this License.
   2.376 -
   2.377 -  11. If, as a consequence of a court judgment or allegation of patent
   2.378 -infringement or for any other reason (not limited to patent issues),
   2.379 -conditions are imposed on you (whether by court order, agreement or
   2.380 -otherwise) that contradict the conditions of this License, they do not
   2.381 -excuse you from the conditions of this License.  If you cannot
   2.382 -distribute so as to satisfy simultaneously your obligations under this
   2.383 -License and any other pertinent obligations, then as a consequence you
   2.384 -may not distribute the Library at all.  For example, if a patent
   2.385 -license would not permit royalty-free redistribution of the Library by
   2.386 -all those who receive copies directly or indirectly through you, then
   2.387 -the only way you could satisfy both it and this License would be to
   2.388 -refrain entirely from distribution of the Library.
   2.389 -
   2.390 -If any portion of this section is held invalid or unenforceable under any
   2.391 -particular circumstance, the balance of the section is intended to apply,
   2.392 -and the section as a whole is intended to apply in other circumstances.
   2.393 -
   2.394 -It is not the purpose of this section to induce you to infringe any
   2.395 -patents or other property right claims or to contest validity of any
   2.396 -such claims; this section has the sole purpose of protecting the
   2.397 -integrity of the free software distribution system which is
   2.398 -implemented by public license practices.  Many people have made
   2.399 -generous contributions to the wide range of software distributed
   2.400 -through that system in reliance on consistent application of that
   2.401 -system; it is up to the author/donor to decide if he or she is willing
   2.402 -to distribute software through any other system and a licensee cannot
   2.403 -impose that choice.
   2.404 -
   2.405 -This section is intended to make thoroughly clear what is believed to
   2.406 -be a consequence of the rest of this License.
   2.407 -
   2.408 -  12. If the distribution and/or use of the Library is restricted in
   2.409 -certain countries either by patents or by copyrighted interfaces, the
   2.410 -original copyright holder who places the Library under this License may add
   2.411 -an explicit geographical distribution limitation excluding those countries,
   2.412 -so that distribution is permitted only in or among countries not thus
   2.413 -excluded.  In such case, this License incorporates the limitation as if
   2.414 -written in the body of this License.
   2.415 -
   2.416 -  13. The Free Software Foundation may publish revised and/or new
   2.417 -versions of the Lesser General Public License from time to time.
   2.418 -Such new versions will be similar in spirit to the present version,
   2.419 -but may differ in detail to address new problems or concerns.
   2.420 -
   2.421 -Each version is given a distinguishing version number.  If the Library
   2.422 -specifies a version number of this License which applies to it and
   2.423 -"any later version", you have the option of following the terms and
   2.424 -conditions either of that version or of any later version published by
   2.425 -the Free Software Foundation.  If the Library does not specify a
   2.426 -license version number, you may choose any version ever published by
   2.427 -the Free Software Foundation.
   2.428 -
   2.429 -  14. If you wish to incorporate parts of the Library into other free
   2.430 -programs whose distribution conditions are incompatible with these,
   2.431 -write to the author to ask for permission.  For software which is
   2.432 -copyrighted by the Free Software Foundation, write to the Free
   2.433 -Software Foundation; we sometimes make exceptions for this.  Our
   2.434 -decision will be guided by the two goals of preserving the free status
   2.435 -of all derivatives of our free software and of promoting the sharing
   2.436 -and reuse of software generally.
   2.437 -
   2.438 -			    NO WARRANTY
   2.439 -
   2.440 -  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
   2.441 -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
   2.442 -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
   2.443 -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
   2.444 -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
   2.445 -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   2.446 -PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
   2.447 -LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
   2.448 -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
   2.449 -
   2.450 -  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
   2.451 -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
   2.452 -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
   2.453 -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
   2.454 -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
   2.455 -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
   2.456 -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
   2.457 -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
   2.458 -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
   2.459 -DAMAGES.
   2.460 -
   2.461 -		     END OF TERMS AND CONDITIONS
   2.462 -
   2.463 -           How to Apply These Terms to Your New Libraries
   2.464 -
   2.465 -  If you develop a new library, and you want it to be of the greatest
   2.466 -possible use to the public, we recommend making it free software that
   2.467 -everyone can redistribute and change.  You can do so by permitting
   2.468 -redistribution under these terms (or, alternatively, under the terms of the
   2.469 -ordinary General Public License).
   2.470 -
   2.471 -  To apply these terms, attach the following notices to the library.  It is
   2.472 -safest to attach them to the start of each source file to most effectively
   2.473 -convey the exclusion of warranty; and each file should have at least the
   2.474 -"copyright" line and a pointer to where the full notice is found.
   2.475 -
   2.476 -    <one line to give the library's name and a brief idea of what it does.>
   2.477 -    Copyright (C) <year>  <name of author>
   2.478 -
   2.479 -    This library is free software; you can redistribute it and/or
   2.480 -    modify it under the terms of the GNU Lesser General Public
   2.481 -    License as published by the Free Software Foundation; either
   2.482 -    version 2 of the License, or (at your option) any later version.
   2.483 -
   2.484 -    This library is distributed in the hope that it will be useful,
   2.485 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   2.486 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   2.487 -    Lesser General Public License for more details.
   2.488 -
   2.489 -    You should have received a copy of the GNU Lesser General Public
   2.490 -    License along with this library; if not, write to the Free Software
   2.491 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   2.492 -
   2.493 -Also add information on how to contact you by electronic and paper mail.
   2.494 -
   2.495 -You should also get your employer (if you work as a programmer) or your
   2.496 -school, if any, to sign a "copyright disclaimer" for the library, if
   2.497 -necessary.  Here is a sample; alter the names:
   2.498 -
   2.499 -  Yoyodyne, Inc., hereby disclaims all copyright interest in the
   2.500 -  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
   2.501 -
   2.502 -  <signature of Ty Coon>, 1 April 1990
   2.503 -  Ty Coon, President of Vice
   2.504 -
   2.505 -That's all there is to it!
   2.506 -
   2.507 -
     3.1 --- a/tools/ioemu/Changelog	Wed Jul 12 16:34:39 2006 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,295 +0,0 @@
     3.4 -version 0.6.1:
     3.5 -
     3.6 -  - Mac OS X port (Pierre d'Herbemont)
     3.7 -  - Virtual console support
     3.8 -  - Better monitor line edition
     3.9 -  - New block device layer 
    3.10 -  - New 'qcow' growable disk image support with AES encryption and
    3.11 -    transparent decompression
    3.12 -  - VMware 3 and 4 read-only disk image support (untested)
    3.13 -  - Support for up to 4 serial ports
    3.14 -  - TFTP server support (Magnus Damm)
    3.15 -  - Port redirection support in user mode networking
    3.16 -  - Support for not executable data sections
    3.17 -  - Compressed loop disk image support (Johannes Schindelin)
    3.18 -  - Level triggered IRQ fix (aka NE2000 PCI performance fix) (Steve
    3.19 -    Wormley)
    3.20 -  - Fixed Fedora Core 2 problems (now you can run qemu without any
    3.21 -    LD_ASSUME_KERNEL tricks on FC2)
    3.22 -  - DHCP fix for Windows (accept DHCPREQUEST alone)
    3.23 -  - SPARC system emulation (Blue Swirl)
    3.24 -  - Automatic Samba configuration for host file access from Windows.
    3.25 -  - '-loadvm' and '-full-screen' options
    3.26 -  - ne2000 savevm support (Johannes Schindelin)
    3.27 -  - Ctrl-Alt is now the default grab key. Ctrl-Alt-[0-9] switches to
    3.28 -    the virtual consoles.
    3.29 -  - BIOS floppy fix for NT4 (Mike Nordell, Derek Fawcus, Volker Ruppert)
    3.30 -  - Floppy fixes for NT4 and NT5 (Mike Nordell)
    3.31 -  - NT4 IDE fixes (Ben Pfaf, Mike Nordell)
    3.32 -  - SDL Audio support and SB16 fixes (malc)
    3.33 -  - ENTER instruction bug fix (initial patch by Stefan Kisdaroczi)
    3.34 -  - VGA font change fix
    3.35 -  - VGA read-only CRTC register fix
    3.36 -
    3.37 -version 0.6.0:
    3.38 -
    3.39 -  - minimalist FPU exception support (NetBSD FPU probe fix)
    3.40 -  - cr0.ET fix (Win95 boot)
    3.41 -  - *BSD port (Markus Niemisto)
    3.42 -  - I/O access fix (signaled by Mark Jonckheere)
    3.43 -  - IDE drives serial number fix (Mike Nordell)
    3.44 -  - int13 CDROM BIOS fix (aka Solaris x86 install CD fix)
    3.45 -  - int15, ah=86 BIOS fix (aka Solaris x86 hardware probe hang up fix)
    3.46 -  - BSR/BSF "undefined behaviour" fix
    3.47 -  - vmdk2raw: convert VMware disk images to raw images
    3.48 -  - PCI support
    3.49 -  - NE2K PCI support
    3.50 -  - dummy VGA PCI support
    3.51 -  - VGA font selection fix (Daniel Serpell)
    3.52 -  - PIC reset fix (Hidemi KAWAI)
    3.53 -  - PIC spurious irq support (aka Solaris install bug)
    3.54 -  - added '-localtime' option
    3.55 -  - Cirrus CL-GD54xx VGA support (initial patch by Makoto Suzuki (suzu))
    3.56 -  - APM and system shutdown support
    3.57 -  - Fixed system reset
    3.58 -  - Support for other PC BIOSes
    3.59 -  - Initial PowerMac hardware emulation
    3.60 -  - PowerMac/PREP OpenFirmware compatible BIOS (Jocelyn Mayer)
    3.61 -  - initial IDE BMDMA support (needed for Darwin x86)
    3.62 -  - Set the default memory size for PC emulation to 128 MB
    3.63 -
    3.64 -version 0.5.5:
    3.65 -
    3.66 -  - SDL full screen support (initial patch by malc)
    3.67 -  - VGA support on PowerPC PREP
    3.68 -  - VBE fixes (Matthew Mastracci)
    3.69 -  - PIT fixes (aka Win98 hardware probe and "VGA slowness" bug)
    3.70 -  - IDE master only fixes (aka Win98 CD-ROM probe bug)
    3.71 -  - ARM load/store half word fix (Ulrich Hecht)
    3.72 -  - FDC fixes for Win98
    3.73 -
    3.74 -version 0.5.4:
    3.75 -  
    3.76 -  - qemu-fast fixes
    3.77 -  - BIOS area protection fix (aka EMM386.EXE fix) (Mike Nordell)
    3.78 -  - keyboard/mouse fix (Mike Nordell)
    3.79 -  - IDE fixes (Linux did not recognized slave drivers)
    3.80 -  - VM86 EIP masking fix (aka NT5 install fix) (Mike Nordell)
    3.81 -  - QEMU can now boot a PowerPC Linux kernel (Jocelyn Mayer)
    3.82 -  - User mode network stack
    3.83 -  - imul imm8 fix + 0x82 opcode support (Hidemi KAWAI)
    3.84 -  - precise self modifying code (aka BeOS install bug)
    3.85 -
    3.86 -version 0.5.3:
    3.87 -
    3.88 -  - added Bochs VESA VBE support
    3.89 -  - VGA memory map mode 3 access fix (OS/2 install fix)
    3.90 -  - IDE fixes (Jens Axboe)
    3.91 -  - CPU interrupt fixes
    3.92 -  - fixed various TLB invalidation cases (NT install)
    3.93 -  - fixed cr0.WP semantics (XP install)
    3.94 -  - direct chaining support for SPARC and PowerPC (faster)
    3.95 -  - ARM NWFPE support (initial patch by Ulrich Hecht)
    3.96 -  - added specific x86 to x86 translator (close to native performance
    3.97 -    in qemu-i386 and qemu-fast)
    3.98 -  - shm syscalls support (Paul McKerras)
    3.99 -  - added accurate CR0.MP/ME/TS emulation
   3.100 -  - fixed DMA memory write access (Win95 boot floppy fix)
   3.101 -  - graphical x86 linux loader
   3.102 -  - command line monitor 
   3.103 -  - generic removable device support
   3.104 -  - support of CD-ROM change
   3.105 -  - multiple network interface support
   3.106 -  - initial x86-64 host support (Gwenole Beauchesne)
   3.107 -  - lret to outer priviledge fix (OS/2 install fix)
   3.108 -  - task switch fixes (SkyOS boot)
   3.109 -  - VM save/restore commands
   3.110 -  - new timer API
   3.111 -  - more precise RTC emulation (periodic timers + time updates)
   3.112 -  - Win32 port (initial patch by Kazu)
   3.113 -
   3.114 -version 0.5.2:
   3.115 -
   3.116 -  - improved soft MMU speed (assembly functions and specializing)
   3.117 -  - improved multitasking speed by avoiding flushing TBs when
   3.118 -    switching tasks
   3.119 -  - improved qemu-fast speed
   3.120 -  - improved self modifying code handling (big performance gain in
   3.121 -    softmmu mode).
   3.122 -  - fixed IO checking
   3.123 -  - fixed CD-ROM detection (win98 install CD)
   3.124 -  - fixed addseg real mode bug (GRUB boot fix)
   3.125 -  - added ROM memory support (win98 boot)
   3.126 -  - fixed 'call Ev' in case of paging exception
   3.127 -  - updated the script 'qemu-binfmt-conf.sh' to use QEMU automagically
   3.128 -    when launching executables for the supported target CPUs.
   3.129 -  - PowerPC system emulation update (Jocelyn Mayer)
   3.130 -  - PC floppy emulation and DMA fixes (Jocelyn Mayer)
   3.131 -  - polled mode for PIC (Jocelyn Mayer)
   3.132 -  - fixed PTE dirty bit handling
   3.133 -  - fixed xadd same reg bug
   3.134 -  - fixed cmpxchg exception safeness
   3.135 -  - access to virtual memory in gdb stub
   3.136 -  - task gate and NT flag fixes
   3.137 -  - eflags optimisation fix for string operations
   3.138 -
   3.139 -version 0.5.1:
   3.140 -  
   3.141 -  - float access fixes when using soft mmu
   3.142 -  - PC emulation support on PowerPC
   3.143 -  - A20 support
   3.144 -  - IDE CD-ROM emulation
   3.145 -  - ARM fixes (Ulrich Hecht)
   3.146 -  - SB16 emulation (malc)
   3.147 -  - IRET and INT fixes in VM86 mode with IOPL=3
   3.148 -  - Port I/Os use TSS io map
   3.149 -  - Full task switching/task gate support
   3.150 -  - added verr, verw, arpl, fcmovxx
   3.151 -  - PowerPC target support (Jocelyn Mayer)
   3.152 -  - Major SPARC target fixes (dynamically linked programs begin to work)
   3.153 -
   3.154 -version 0.5.0:
   3.155 -  
   3.156 -  - full hardware level VGA emulation
   3.157 -  - graphical display with SDL
   3.158 -  - added PS/2 mouse and keyboard emulation
   3.159 -  - popw (%esp) fix
   3.160 -  - mov to/from segment data width fix
   3.161 -  - added real mode support
   3.162 -  - added Bochs BIOS and LGPL'ed VGA BIOS loader in qemu
   3.163 -  - m68k host port (Richard Zidlicky)
   3.164 -  - partial soft MMU support for memory mapped I/Os
   3.165 -  - multi-target build
   3.166 -  - fixed: no error code in hardware interrupts
   3.167 -  - fixed: pop ss, mov ss, x and sti disable hardware irqs for the next insn
   3.168 -  - correct single stepping thru string operations
   3.169 -  - preliminary SPARC target support (Thomas M. Ogrisegg)
   3.170 -  - tun-fd option (Rusty Russell)
   3.171 -  - automatic IDE geometry detection
   3.172 -  - renamed 'vl' to qemu[-fast] and user qemu to qemu-{cpu}.
   3.173 -  - added man page
   3.174 -  - added full soft mmu mode to launch unpatched OSes.
   3.175 -
   3.176 -version 0.4.3:
   3.177 -
   3.178 -  - x86 exception fix in case of nop instruction.
   3.179 -  - gcc 3.2.2 bug workaround (RedHat 9 fix)
   3.180 -  - sparc and Alpha host fixes
   3.181 -  - many ARM target fixes: 'ls' and 'bash' can be launched.
   3.182 -
   3.183 -version 0.4.2:
   3.184 -
   3.185 - - many exception handling fixes (can compile a Linux kernel inside vl)
   3.186 - - IDE emulation support
   3.187 - - initial GDB stub support
   3.188 - - deferred update support for disk images (Rusty Russell)
   3.189 - - accept User Mode Linux Copy On Write disk images
   3.190 - - SMP kernels can at least be booted
   3.191 -
   3.192 -version 0.4.1:
   3.193 -  
   3.194 - - more accurate timer support in vl.
   3.195 - - more reliable NE2000 probe in vl.
   3.196 - - added 2.5.66 kernel in vl-test.
   3.197 - - added VLTMPDIR environment variable in vl.
   3.198 -
   3.199 -version 0.4:
   3.200 -
   3.201 - - initial support for ring 0 x86 processor emulation
   3.202 - - fixed signal handling for correct dosemu DPMI emulation
   3.203 - - fast x86 MMU emulation with mmap()
   3.204 - - fixed popl (%esp) case
   3.205 - - Linux kernel can be executed by QEMU with the 'vl' command.
   3.206 -
   3.207 -version 0.3:
   3.208 -
   3.209 - - initial support for ARM emulation
   3.210 - - added fnsave, frstor, fnstenv, fldenv FPU instructions
   3.211 - - added FPU register save in signal emulation
   3.212 - - initial ARM port
   3.213 - - Sparc and Alpha ports work on the regression test
   3.214 - - generic ioctl number conversion
   3.215 - - fixed ioctl type conversion
   3.216 -
   3.217 -version 0.2:
   3.218 -
   3.219 - - PowerPC disassembly and ELF symbols output (Rusty Russell)
   3.220 - - flock support (Rusty Russell)
   3.221 - - ugetrlimit support (Rusty Russell)
   3.222 - - fstat64 fix (Rusty Russell)
   3.223 - - initial Alpha port (Falk Hueffner)
   3.224 - - initial IA64 port (Matt Wilson)
   3.225 - - initial Sparc and Sparc64 port (David S. Miller)
   3.226 - - added HLT instruction
   3.227 - - LRET instruction fix.
   3.228 - - added GPF generation for I/Os.
   3.229 - - added INT3 and TF flag support.
   3.230 - - SHL instruction C flag fix.
   3.231 - - mmap emulation for host page size > 4KB
   3.232 - - self-modifying code support
   3.233 - - better VM86 support (dosemu works on non trivial programs)
   3.234 - - precise exception support (EIP is computed correctly in most cases)
   3.235 - - more precise LDT/GDT/IDT emulation
   3.236 - - faster segment load in vm86 mode
   3.237 - - direct chaining of basic blocks (faster emulation)
   3.238 -
   3.239 -version 0.1.6:
   3.240 -
   3.241 - - automatic library search system. QEMU can now work with unpatched
   3.242 -   ELF dynamic loader and libc (Rusty Russell).
   3.243 - - ISO C warning fixes (Alistair Strachan)
   3.244 - - first self-virtualizable version (works only as long as the
   3.245 -   translation cache is not flushed)
   3.246 - - RH9 fixes
   3.247 -
   3.248 -version 0.1.5:
   3.249 -
   3.250 - - ppc64 support + personality() patch (Rusty Russell)
   3.251 - - first Alpha CPU patches (Falk Hueffner)
   3.252 - - removed bfd.h dependancy
   3.253 - - fixed shrd, shld, idivl and divl on PowerPC.
   3.254 - - fixed buggy glibc PowerPC rint() function (test-i386 passes now on PowerPC).
   3.255 -
   3.256 -version 0.1.4:
   3.257 -
   3.258 - - more accurate VM86 emulation (can launch small DOS 16 bit
   3.259 -   executables in wine).
   3.260 - - fixed push/pop fs/gs
   3.261 - - added iret instruction.
   3.262 - - added times() syscall and SIOCATMARK ioctl.
   3.263 -
   3.264 -version 0.1.3:
   3.265 -
   3.266 - - S390 support (Ulrich Weigand)
   3.267 - - glibc 2.3.x compile fix (Ulrich Weigand)
   3.268 - - socketcall endian fix (Ulrich Weigand)
   3.269 - - struct sockaddr endian fix (Ulrich Weigand)
   3.270 - - sendmsg/recvmsg endian fix (Ulrich Weigand)
   3.271 - - execve endian fix (Ulrich Weigand)
   3.272 - - fdset endian fix (Ulrich Weigand)
   3.273 - - partial setsockopt syscall support (Ulrich Weigand)
   3.274 - - more accurate pushf/popf emulation
   3.275 - - first partial vm86() syscall support (can be used with runcom example).
   3.276 - - added bound, cmpxchg8b, cpuid instructions
   3.277 - - added 16 bit addressing support/override for string operations
   3.278 - - poll() fix
   3.279 - 
   3.280 -version 0.1.2:
   3.281 -
   3.282 - - compile fixes
   3.283 - - xlat instruction
   3.284 - - xchg instruction memory lock
   3.285 - - added simple vm86 example (not working with QEMU yet). The 54 byte
   3.286 -   DOS executable 'pi_10.com' program was released by Bertram
   3.287 -   Felgenhauer (more information at http://www.boo.net/~jasonp/pipage.html).
   3.288 -
   3.289 -version 0.1.1:
   3.290 -
   3.291 - - glibc 2.2 compilation fixes
   3.292 - - added -s and -L options
   3.293 - - binary distribution of x86 glibc and wine
   3.294 - - big endian fixes in ELF loader and getdents.
   3.295 -
   3.296 -version 0.1:
   3.297 -
   3.298 - - initial public release.
     4.1 --- a/tools/ioemu/Makefile	Wed Jul 12 16:34:39 2006 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,128 +0,0 @@
     4.4 -XEN_ROOT=../..
     4.5 -include $(XEN_ROOT)/tools/Rules.mk
     4.6 -
     4.7 --include config-host.mak
     4.8 -
     4.9 -CFLAGS+=-g -fno-strict-aliasing 
    4.10 -ifdef CONFIG_DARWIN
    4.11 -CFLAGS+= -mdynamic-no-pic
    4.12 -endif
    4.13 -ifdef CONFIG_WIN32
    4.14 -CFLAGS+=-fpack-struct 
    4.15 -endif
    4.16 -LDFLAGS=-g
    4.17 -LIBS=
    4.18 -DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
    4.19 -TOOLS=qemu-img
    4.20 -ifdef CONFIG_STATIC
    4.21 -LDFLAGS+=-static
    4.22 -endif
    4.23 -#DOCS=qemu-doc.html qemu-tech.html qemu.1
    4.24 -
    4.25 -.PHONY: all
    4.26 -all: $(DOCS) HEADERS
    4.27 -	for d in $(TARGET_DIRS); do \
    4.28 -	$(MAKE) -C $$d $@ || exit 1 ; \
    4.29 -        done
    4.30 -
    4.31 -qemu-img: qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c
    4.32 -	$(CC) -DQEMU_TOOL $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $@ $^ -lz $(LIBS)
    4.33 -
    4.34 -dyngen$(EXESUF): dyngen.c
    4.35 -	$(HOST_CC) $(CFLAGS) $(DEFINES) -o $@ $^
    4.36 -
    4.37 -.PHONY: clean
    4.38 -clean:
    4.39 -# avoid old build problems by removing potentially incorrect old files
    4.40 -	rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h 
    4.41 -	rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS qemu.pod *~ */*~
    4.42 -	#$(MAKE) -C tests clean
    4.43 -	for d in $(TARGET_DIRS); do \
    4.44 -	$(MAKE) -C $$d $@ || exit 1 ; \
    4.45 -        done
    4.46 -	rm -f config-host.mak config-host.h
    4.47 -	rm -f keysym_adapter_sdl.h keysym_adapter_vnc.h
    4.48 -
    4.49 -.PHONY: distclean
    4.50 -distclean: clean
    4.51 -	rm -f config-host.mak config-host.h
    4.52 -	rm -f keysym_adapter_sdl.h keysym_adapter_vnc.h
    4.53 -	for d in $(TARGET_DIRS); do \
    4.54 -	$(MAKE) -C $$d $@ || exit 1 ; \
    4.55 -        done
    4.56 -
    4.57 -KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
    4.58 -ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
    4.59 -common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr
    4.60 -
    4.61 -.PHONY: install
    4.62 -install: all 
    4.63 -	mkdir -p "$(bindir)"
    4.64 -	mkdir -p "$(DESTDIR)/$(datadir)"
    4.65 -	mkdir -p "$(DESTDIR)/$(datadir)/keymaps"
    4.66 -	install -m 644 $(addprefix keymaps/,$(KEYMAPS)) "$(DESTDIR)/$(datadir)/keymaps"
    4.67 -	for d in $(TARGET_DIRS); do \
    4.68 -	$(MAKE) -C $$d $@ || exit 1 ; \
    4.69 -        done
    4.70 -
    4.71 -# various test targets
    4.72 -.PHONY: test speed test2
    4.73 -test speed test2: all
    4.74 -	$(MAKE) -C tests $@
    4.75 -
    4.76 -.PHONY: TAGS
    4.77 -TAGS: 
    4.78 -	etags *.[ch] tests/*.[ch]
    4.79 -
    4.80 -# documentation
    4.81 -%.html: %.texi
    4.82 -	texi2html -monolithic -number $<
    4.83 -
    4.84 -qemu.1: qemu-doc.texi
    4.85 -	./texi2pod.pl $< qemu.pod
    4.86 -	pod2man --section=1 --center=" " --release=" " qemu.pod > $@
    4.87 -
    4.88 -FILE=qemu-$(shell cat VERSION)
    4.89 -
    4.90 -# tar release (use 'make -k tar' on a checkouted tree)
    4.91 -.PHONY: tar
    4.92 -tar:
    4.93 -	rm -rf /tmp/$(FILE)
    4.94 -	cp -r . /tmp/$(FILE)
    4.95 -	( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS )
    4.96 -	rm -rf /tmp/$(FILE)
    4.97 -
    4.98 -# generate a binary distribution
    4.99 -.PHONY: tarbin
   4.100 -tarbin:
   4.101 -	( cd $(DESTDIR) ; tar zcvf ~/qemu-$(VERSION)-i386.tar.gz \
   4.102 -	$(DESTDIR)/$(bindir)/qemu $(DESTDIR)/$(bindir)/qemu-fast \
   4.103 -	$(DESTDIR)/$(bindir)/qemu-system-ppc \
   4.104 -	$(DESTDIR)/$(bindir)/qemu-i386 \
   4.105 -        $(DESTDIR)/$(bindir)/qemu-arm \
   4.106 -        $(DESTDIR)/$(bindir)/qemu-sparc \
   4.107 -        $(DESTDIR)/$(bindir)/qemu-ppc \
   4.108 -	$(DESTDIR)/$(mandir)/man1/qemu.1 $(DESTDIR)/$(mandir)/man1/qemu-mkcow.1 )
   4.109 -
   4.110 -ifneq ($(wildcard .depend),)
   4.111 -include .depend
   4.112 -endif
   4.113 -
   4.114 -.PHONY: HEADERS
   4.115 -HEADERS:
   4.116 -
   4.117 -ifdef CONFIG_SDL
   4.118 -HEADERS: keysym_adapter_sdl.h
   4.119 -endif
   4.120 -
   4.121 -ifdef CONFIG_VNC
   4.122 -HEADERS: keysym_adapter_vnc.h
   4.123 -endif
   4.124 -
   4.125 -keysym_adapter_sdl.h: Makefile create_keysym_header.sh
   4.126 -	sh create_keysym_header.sh sdl "$(SDL_CFLAGS)"
   4.127 -
   4.128 -keysym_adapter_vnc.h: Makefile create_keysym_header.sh
   4.129 -	sh create_keysym_header.sh vnc "$(VNC_CFLAGS)"
   4.130 -
   4.131 -
     5.1 --- a/tools/ioemu/README	Wed Jul 12 16:34:39 2006 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,61 +0,0 @@
     5.4 -The QEMU x86 emulator
     5.5 ----------------------
     5.6 -
     5.7 -INSTALLATION
     5.8 -------------
     5.9 -
    5.10 -Type 
    5.11 -
    5.12 -    ./configure
    5.13 -    make
    5.14 -
    5.15 -to build qemu, qemu-CPU and libqemu.a (CPU is the name of the various
    5.16 -supported target CPUs).
    5.17 -
    5.18 -Type
    5.19 -
    5.20 -    make install
    5.21 -
    5.22 -to install QEMU in /usr/local
    5.23 -
    5.24 -Tested tool versions
    5.25 ---------------------
    5.26 -
    5.27 -In order to compile QEMU succesfully, it is very important that you
    5.28 -have the right tools. The most important one is gcc. I cannot guaranty
    5.29 -that QEMU works if you do not use a tested gcc version. Look at
    5.30 -'configure' and 'Makefile' if you want to make a different gcc
    5.31 -version work.
    5.32 -
    5.33 -host      gcc      binutils      glibc    linux       distribution
    5.34 -----------------------------------------------------------------------
    5.35 -x86       2.95.2   2.13.2        2.1.3    2.4.18           
    5.36 -          3.2      2.13.2        2.1.3    2.4.18
    5.37 -          2.96     2.11.93.0.2   2.2.5    2.4.18      Red Hat 7.3
    5.38 -          3.2.2    2.13.90.0.18  2.3.2    2.4.20      Red Hat 9
    5.39 -
    5.40 -PowerPC   3.3 [4]  2.13.90.0.18  2.3.1    2.4.20briq
    5.41 -          3.2
    5.42 -
    5.43 -Alpha     3.3 [1]  2.14.90.0.4   2.2.5    2.2.20 [2]  Debian 3.0
    5.44 -
    5.45 -Sparc32   2.95.4   2.12.90.0.1   2.2.5    2.4.18      Debian 3.0
    5.46 -
    5.47 -ARM       2.95.4   2.12.90.0.1   2.2.5    2.4.9 [3]   Debian 3.0
    5.48 -
    5.49 -[1] On Alpha, QEMU needs the gcc 'visibility' attribute only available
    5.50 -    for gcc version >= 3.3.
    5.51 -[2] Linux >= 2.4.20 is necessary for precise exception support
    5.52 -    (untested).
    5.53 -[3] 2.4.9-ac10-rmk2-np1-cerf2
    5.54 -
    5.55 -[4] gcc 2.95.x generates invalid code when using too many register
    5.56 -variables. You must use gcc 3.x on PowerPC.
    5.57 -
    5.58 -Documentation
    5.59 --------------
    5.60 -
    5.61 -Read the documentation in qemu-doc.html.
    5.62 -
    5.63 -
    5.64 -Fabrice Bellard.
    5.65 \ No newline at end of file
     6.1 --- a/tools/ioemu/TODO	Wed Jul 12 16:34:39 2006 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,66 +0,0 @@
     6.4 -short term:
     6.5 -----------
     6.6 -- debug option in 'configure' script + disable -fomit-frame-pointer
     6.7 -- Solaris display error with Cirrus VGA
     6.8 -  (http://lists.gnu.org/archive/html/qemu-devel/2004-10/msg00390.html).
     6.9 -- Precise VGA timings for old games/demos (malc patch)
    6.10 -- merge PIC spurious interrupt patch
    6.11 -- merge VNC keyboard patch
    6.12 -- merge Solaris patch
    6.13 -- merge ARM patches + self modifying code patch (Paul Brook)
    6.14 -- warning for OS/2: must not use 128 MB memory
    6.15 -- config file (at least for windows/Mac OS X)
    6.16 -- commit message if execution of code in IO memory
    6.17 -- update doc: PCI infos.
    6.18 -- VNC patch + Synaptic patch.
    6.19 -- basic VGA optimizations
    6.20 -- test sysenter/sysexit and fxsr for L4 pistachio 686
    6.21 -- physical memory cache (reduce qemu-fast address space size to about 32 MB)
    6.22 -- better code fetch (different exception handling + CS.limit support)
    6.23 -- do not resize vga if invalid size.
    6.24 -- avoid looping if only exceptions
    6.25 -- cycle counter for all archs
    6.26 -- TLB code protection support for PPC
    6.27 -- see openMosix Doc 
    6.28 -- disable SMC handling for ARM/SPARC/PPC (not finished)
    6.29 -- see undefined flags for BTx insn
    6.30 -- user/kernel PUSHL/POPL in helper.c
    6.31 -- keyboard output buffer filling timing emulation
    6.32 -- return UD exception if LOCK prefix incorrectly used
    6.33 -- test ldt limit < 7 ?
    6.34 -- tests for each target CPU
    6.35 -- fix CCOP optimisation
    6.36 -- fix all remaining thread lock issues (must put TBs in a specific invalid
    6.37 -  state, find a solution for tb_flush()).
    6.38 -- fix arm fpu rounding (at least for float->integer conversions)
    6.39 -- SMP support
    6.40 -
    6.41 -ppc specific:
    6.42 -------------
    6.43 -- TLB invalidate not needed if msr_pr changes
    6.44 -- endianness bugs in do_load_fpscr and do_store_fpscr
    6.45 -- SPR_ENCODE() not useful
    6.46 -- enable shift optimizations ?
    6.47 -
    6.48 -lower priority:
    6.49 ---------------
    6.50 -- more friendly BIOS (logo)
    6.51 -- int15 ah=86: use better timing
    6.52 -- HDD geometry in CMOS (not used except for very old DOS programs)
    6.53 -- suppress shift_mem ops
    6.54 -- fix some 16 bit sp push/pop overflow (pusha/popa, lcall lret)
    6.55 -- sysenter/sysexit emulation
    6.56 -- optimize FPU operations (evaluate x87 stack pointer statically)
    6.57 -- add IPC syscalls
    6.58 -- use -msoft-float on ARM
    6.59 -- use kernel traps for unaligned accesses on ARM ?
    6.60 -- handle rare page fault cases (in particular if page fault in helpers or
    6.61 -  in syscall emulation code).
    6.62 -- fix thread stack freeing (use kernel 2.5.x CLONE_CHILD_CLEARTID)
    6.63 -- more syscalls (in particular all 64 bit ones, IPCs, fix 64 bit
    6.64 -  issues, fix 16 bit uid issues)
    6.65 -- use page_unprotect_range in every suitable syscall to handle all
    6.66 -  cases of self modifying code.
    6.67 -- use gcc as a backend to generate better code (easy to do by using
    6.68 -  op-i386.c operations as local inline functions).
    6.69 -- add SSE2/MMX operations
     7.1 --- a/tools/ioemu/VERSION	Wed Jul 12 16:34:39 2006 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,1 +0,0 @@
     7.4 -0.6.1
     7.5 \ No newline at end of file
     8.1 --- a/tools/ioemu/aes.c	Wed Jul 12 16:34:39 2006 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,1317 +0,0 @@
     8.4 -/**
     8.5 - * 
     8.6 - * aes.c - integrated in QEMU by Fabrice Bellard from the OpenSSL project.
     8.7 - */
     8.8 -/*
     8.9 - * rijndael-alg-fst.c
    8.10 - *
    8.11 - * @version 3.0 (December 2000)
    8.12 - *
    8.13 - * Optimised ANSI C code for the Rijndael cipher (now AES)
    8.14 - *
    8.15 - * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
    8.16 - * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
    8.17 - * @author Paulo Barreto <paulo.barreto@terra.com.br>
    8.18 - *
    8.19 - * This code is hereby placed in the public domain.
    8.20 - *
    8.21 - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
    8.22 - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    8.23 - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    8.24 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
    8.25 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    8.26 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    8.27 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    8.28 - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    8.29 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    8.30 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    8.31 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    8.32 - */
    8.33 -#include "vl.h"
    8.34 -#include "aes.h"
    8.35 -
    8.36 -#define NDEBUG
    8.37 -#include <assert.h>
    8.38 -
    8.39 -typedef uint32_t u32;
    8.40 -typedef uint16_t u16;
    8.41 -typedef uint8_t u8;
    8.42 -
    8.43 -#define MAXKC   (256/32)
    8.44 -#define MAXKB   (256/8)
    8.45 -#define MAXNR   14
    8.46 -
    8.47 -/* This controls loop-unrolling in aes_core.c */
    8.48 -#undef FULL_UNROLL
    8.49 -# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] <<  8) ^ ((u32)(pt)[3]))
    8.50 -# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >>  8); (ct)[3] = (u8)(st); }
    8.51 -
    8.52 -/*
    8.53 -Te0[x] = S [x].[02, 01, 01, 03];
    8.54 -Te1[x] = S [x].[03, 02, 01, 01];
    8.55 -Te2[x] = S [x].[01, 03, 02, 01];
    8.56 -Te3[x] = S [x].[01, 01, 03, 02];
    8.57 -Te4[x] = S [x].[01, 01, 01, 01];
    8.58 -
    8.59 -Td0[x] = Si[x].[0e, 09, 0d, 0b];
    8.60 -Td1[x] = Si[x].[0b, 0e, 09, 0d];
    8.61 -Td2[x] = Si[x].[0d, 0b, 0e, 09];
    8.62 -Td3[x] = Si[x].[09, 0d, 0b, 0e];
    8.63 -Td4[x] = Si[x].[01, 01, 01, 01];
    8.64 -*/
    8.65 -
    8.66 -static const u32 Te0[256] = {
    8.67 -    0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
    8.68 -    0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
    8.69 -    0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
    8.70 -    0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
    8.71 -    0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
    8.72 -    0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
    8.73 -    0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
    8.74 -    0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
    8.75 -    0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
    8.76 -    0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
    8.77 -    0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
    8.78 -    0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
    8.79 -    0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
    8.80 -    0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
    8.81 -    0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
    8.82 -    0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
    8.83 -    0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
    8.84 -    0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
    8.85 -    0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
    8.86 -    0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
    8.87 -    0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
    8.88 -    0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
    8.89 -    0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
    8.90 -    0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
    8.91 -    0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
    8.92 -    0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
    8.93 -    0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
    8.94 -    0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
    8.95 -    0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
    8.96 -    0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
    8.97 -    0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
    8.98 -    0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
    8.99 -    0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
   8.100 -    0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
   8.101 -    0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
   8.102 -    0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
   8.103 -    0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
   8.104 -    0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
   8.105 -    0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
   8.106 -    0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
   8.107 -    0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
   8.108 -    0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
   8.109 -    0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
   8.110 -    0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
   8.111 -    0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
   8.112 -    0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
   8.113 -    0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
   8.114 -    0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
   8.115 -    0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
   8.116 -    0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
   8.117 -    0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
   8.118 -    0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
   8.119 -    0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
   8.120 -    0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
   8.121 -    0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
   8.122 -    0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
   8.123 -    0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
   8.124 -    0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
   8.125 -    0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
   8.126 -    0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
   8.127 -    0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
   8.128 -    0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
   8.129 -    0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
   8.130 -    0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
   8.131 -};
   8.132 -static const u32 Te1[256] = {
   8.133 -    0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
   8.134 -    0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
   8.135 -    0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
   8.136 -    0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
   8.137 -    0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
   8.138 -    0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
   8.139 -    0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
   8.140 -    0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
   8.141 -    0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
   8.142 -    0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
   8.143 -    0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
   8.144 -    0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
   8.145 -    0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
   8.146 -    0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
   8.147 -    0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
   8.148 -    0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
   8.149 -    0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
   8.150 -    0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
   8.151 -    0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
   8.152 -    0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
   8.153 -    0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
   8.154 -    0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
   8.155 -    0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
   8.156 -    0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
   8.157 -    0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
   8.158 -    0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
   8.159 -    0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
   8.160 -    0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
   8.161 -    0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
   8.162 -    0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
   8.163 -    0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
   8.164 -    0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
   8.165 -    0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
   8.166 -    0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
   8.167 -    0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
   8.168 -    0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
   8.169 -    0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
   8.170 -    0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
   8.171 -    0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
   8.172 -    0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
   8.173 -    0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
   8.174 -    0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
   8.175 -    0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
   8.176 -    0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
   8.177 -    0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
   8.178 -    0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
   8.179 -    0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
   8.180 -    0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
   8.181 -    0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
   8.182 -    0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
   8.183 -    0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
   8.184 -    0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
   8.185 -    0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
   8.186 -    0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
   8.187 -    0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
   8.188 -    0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
   8.189 -    0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
   8.190 -    0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
   8.191 -    0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
   8.192 -    0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
   8.193 -    0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
   8.194 -    0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
   8.195 -    0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
   8.196 -    0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
   8.197 -};
   8.198 -static const u32 Te2[256] = {
   8.199 -    0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
   8.200 -    0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
   8.201 -    0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
   8.202 -    0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
   8.203 -    0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
   8.204 -    0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
   8.205 -    0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
   8.206 -    0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
   8.207 -    0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
   8.208 -    0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
   8.209 -    0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
   8.210 -    0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
   8.211 -    0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
   8.212 -    0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
   8.213 -    0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
   8.214 -    0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
   8.215 -    0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
   8.216 -    0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
   8.217 -    0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
   8.218 -    0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
   8.219 -    0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
   8.220 -    0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
   8.221 -    0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
   8.222 -    0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
   8.223 -    0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
   8.224 -    0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
   8.225 -    0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
   8.226 -    0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
   8.227 -    0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
   8.228 -    0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
   8.229 -    0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
   8.230 -    0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
   8.231 -    0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
   8.232 -    0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
   8.233 -    0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
   8.234 -    0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
   8.235 -    0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
   8.236 -    0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
   8.237 -    0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
   8.238 -    0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
   8.239 -    0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
   8.240 -    0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
   8.241 -    0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
   8.242 -    0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
   8.243 -    0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
   8.244 -    0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
   8.245 -    0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
   8.246 -    0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
   8.247 -    0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
   8.248 -    0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
   8.249 -    0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
   8.250 -    0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
   8.251 -    0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
   8.252 -    0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
   8.253 -    0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
   8.254 -    0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
   8.255 -    0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
   8.256 -    0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
   8.257 -    0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
   8.258 -    0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
   8.259 -    0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
   8.260 -    0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
   8.261 -    0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
   8.262 -    0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
   8.263 -};
   8.264 -static const u32 Te3[256] = {
   8.265 -
   8.266 -    0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
   8.267 -    0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
   8.268 -    0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
   8.269 -    0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
   8.270 -    0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
   8.271 -    0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
   8.272 -    0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
   8.273 -    0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
   8.274 -    0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
   8.275 -    0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
   8.276 -    0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
   8.277 -    0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
   8.278 -    0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
   8.279 -    0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
   8.280 -    0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
   8.281 -    0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
   8.282 -    0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
   8.283 -    0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
   8.284 -    0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
   8.285 -    0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
   8.286 -    0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
   8.287 -    0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
   8.288 -    0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
   8.289 -    0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
   8.290 -    0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
   8.291 -    0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
   8.292 -    0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
   8.293 -    0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
   8.294 -    0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
   8.295 -    0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
   8.296 -    0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
   8.297 -    0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
   8.298 -    0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
   8.299 -    0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
   8.300 -    0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
   8.301 -    0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
   8.302 -    0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
   8.303 -    0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
   8.304 -    0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
   8.305 -    0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
   8.306 -    0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
   8.307 -    0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
   8.308 -    0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
   8.309 -    0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
   8.310 -    0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
   8.311 -    0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
   8.312 -    0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
   8.313 -    0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
   8.314 -    0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
   8.315 -    0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
   8.316 -    0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
   8.317 -    0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
   8.318 -    0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
   8.319 -    0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
   8.320 -    0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
   8.321 -    0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
   8.322 -    0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
   8.323 -    0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
   8.324 -    0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
   8.325 -    0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
   8.326 -    0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
   8.327 -    0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
   8.328 -    0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
   8.329 -    0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
   8.330 -};
   8.331 -static const u32 Te4[256] = {
   8.332 -    0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
   8.333 -    0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
   8.334 -    0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
   8.335 -    0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
   8.336 -    0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
   8.337 -    0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
   8.338 -    0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
   8.339 -    0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
   8.340 -    0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
   8.341 -    0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
   8.342 -    0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
   8.343 -    0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
   8.344 -    0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
   8.345 -    0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
   8.346 -    0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
   8.347 -    0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
   8.348 -    0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
   8.349 -    0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
   8.350 -    0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
   8.351 -    0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
   8.352 -    0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
   8.353 -    0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
   8.354 -    0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
   8.355 -    0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
   8.356 -    0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
   8.357 -    0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
   8.358 -    0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
   8.359 -    0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
   8.360 -    0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
   8.361 -    0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
   8.362 -    0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
   8.363 -    0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
   8.364 -    0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
   8.365 -    0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
   8.366 -    0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
   8.367 -    0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
   8.368 -    0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
   8.369 -    0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
   8.370 -    0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
   8.371 -    0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
   8.372 -    0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
   8.373 -    0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
   8.374 -    0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
   8.375 -    0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
   8.376 -    0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
   8.377 -    0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
   8.378 -    0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
   8.379 -    0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
   8.380 -    0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
   8.381 -    0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
   8.382 -    0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
   8.383 -    0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
   8.384 -    0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
   8.385 -    0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
   8.386 -    0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
   8.387 -    0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
   8.388 -    0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
   8.389 -    0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
   8.390 -    0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
   8.391 -    0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
   8.392 -    0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
   8.393 -    0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
   8.394 -    0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
   8.395 -    0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
   8.396 -};
   8.397 -static const u32 Td0[256] = {
   8.398 -    0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
   8.399 -    0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
   8.400 -    0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
   8.401 -    0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
   8.402 -    0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
   8.403 -    0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
   8.404 -    0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
   8.405 -    0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
   8.406 -    0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
   8.407 -    0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
   8.408 -    0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
   8.409 -    0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
   8.410 -    0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
   8.411 -    0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
   8.412 -    0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
   8.413 -    0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
   8.414 -    0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
   8.415 -    0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
   8.416 -    0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
   8.417 -    0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
   8.418 -    0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
   8.419 -    0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
   8.420 -    0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
   8.421 -    0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
   8.422 -    0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
   8.423 -    0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
   8.424 -    0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
   8.425 -    0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
   8.426 -    0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
   8.427 -    0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
   8.428 -    0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
   8.429 -    0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
   8.430 -    0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
   8.431 -    0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
   8.432 -    0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
   8.433 -    0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
   8.434 -    0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
   8.435 -    0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
   8.436 -    0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
   8.437 -    0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
   8.438 -    0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
   8.439 -    0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
   8.440 -    0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
   8.441 -    0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
   8.442 -    0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
   8.443 -    0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
   8.444 -    0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
   8.445 -    0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
   8.446 -    0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
   8.447 -    0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
   8.448 -    0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
   8.449 -    0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
   8.450 -    0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
   8.451 -    0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
   8.452 -    0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
   8.453 -    0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
   8.454 -    0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
   8.455 -    0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
   8.456 -    0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
   8.457 -    0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
   8.458 -    0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
   8.459 -    0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
   8.460 -    0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
   8.461 -    0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
   8.462 -};
   8.463 -static const u32 Td1[256] = {
   8.464 -    0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
   8.465 -    0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
   8.466 -    0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
   8.467 -    0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
   8.468 -    0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
   8.469 -    0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
   8.470 -    0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
   8.471 -    0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
   8.472 -    0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
   8.473 -    0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
   8.474 -    0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
   8.475 -    0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
   8.476 -    0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
   8.477 -    0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
   8.478 -    0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
   8.479 -    0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
   8.480 -    0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
   8.481 -    0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
   8.482 -    0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
   8.483 -    0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
   8.484 -    0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
   8.485 -    0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
   8.486 -    0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
   8.487 -    0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
   8.488 -    0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
   8.489 -    0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
   8.490 -    0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
   8.491 -    0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
   8.492 -    0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
   8.493 -    0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
   8.494 -    0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
   8.495 -    0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
   8.496 -    0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
   8.497 -    0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
   8.498 -    0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
   8.499 -    0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
   8.500 -    0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
   8.501 -    0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
   8.502 -    0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
   8.503 -    0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
   8.504 -    0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
   8.505 -    0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
   8.506 -    0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
   8.507 -    0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
   8.508 -    0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
   8.509 -    0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
   8.510 -    0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
   8.511 -    0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
   8.512 -    0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
   8.513 -    0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
   8.514 -    0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
   8.515 -    0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
   8.516 -    0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
   8.517 -    0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
   8.518 -    0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
   8.519 -    0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
   8.520 -    0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
   8.521 -    0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
   8.522 -    0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
   8.523 -    0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
   8.524 -    0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
   8.525 -    0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
   8.526 -    0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
   8.527 -    0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
   8.528 -};
   8.529 -static const u32 Td2[256] = {
   8.530 -    0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
   8.531 -    0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
   8.532 -    0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
   8.533 -    0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
   8.534 -    0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
   8.535 -    0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
   8.536 -    0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
   8.537 -    0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
   8.538 -    0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
   8.539 -    0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
   8.540 -    0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
   8.541 -    0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
   8.542 -    0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
   8.543 -    0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
   8.544 -    0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
   8.545 -    0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
   8.546 -    0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
   8.547 -    0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
   8.548 -    0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
   8.549 -    0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
   8.550 -
   8.551 -    0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
   8.552 -    0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
   8.553 -    0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
   8.554 -    0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
   8.555 -    0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
   8.556 -    0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
   8.557 -    0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
   8.558 -    0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
   8.559 -    0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
   8.560 -    0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
   8.561 -    0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
   8.562 -    0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
   8.563 -    0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
   8.564 -    0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
   8.565 -    0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
   8.566 -    0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
   8.567 -    0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
   8.568 -    0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
   8.569 -    0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
   8.570 -    0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
   8.571 -    0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
   8.572 -    0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
   8.573 -    0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
   8.574 -    0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
   8.575 -    0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
   8.576 -    0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
   8.577 -    0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
   8.578 -    0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
   8.579 -    0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
   8.580 -    0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
   8.581 -    0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
   8.582 -    0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
   8.583 -    0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
   8.584 -    0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
   8.585 -    0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
   8.586 -    0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
   8.587 -    0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
   8.588 -    0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
   8.589 -    0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
   8.590 -    0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
   8.591 -    0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
   8.592 -    0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
   8.593 -    0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
   8.594 -    0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
   8.595 -};
   8.596 -static const u32 Td3[256] = {
   8.597 -    0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
   8.598 -    0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
   8.599 -    0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
   8.600 -    0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
   8.601 -    0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
   8.602 -    0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
   8.603 -    0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
   8.604 -    0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
   8.605 -    0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
   8.606 -    0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
   8.607 -    0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
   8.608 -    0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
   8.609 -    0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
   8.610 -    0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
   8.611 -    0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
   8.612 -    0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
   8.613 -    0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
   8.614 -    0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
   8.615 -    0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
   8.616 -    0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
   8.617 -    0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
   8.618 -    0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
   8.619 -    0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
   8.620 -    0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
   8.621 -    0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
   8.622 -    0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
   8.623 -    0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
   8.624 -    0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
   8.625 -    0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
   8.626 -    0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
   8.627 -    0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
   8.628 -    0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
   8.629 -    0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
   8.630 -    0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
   8.631 -    0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
   8.632 -    0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
   8.633 -    0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
   8.634 -    0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
   8.635 -    0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
   8.636 -    0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
   8.637 -    0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
   8.638 -    0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
   8.639 -    0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
   8.640 -    0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
   8.641 -    0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
   8.642 -    0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
   8.643 -    0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
   8.644 -    0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
   8.645 -    0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
   8.646 -    0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
   8.647 -    0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
   8.648 -    0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
   8.649 -    0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
   8.650 -    0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
   8.651 -    0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
   8.652 -    0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
   8.653 -    0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
   8.654 -    0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
   8.655 -    0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
   8.656 -    0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
   8.657 -    0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
   8.658 -    0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
   8.659 -    0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
   8.660 -    0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
   8.661 -};
   8.662 -static const u32 Td4[256] = {
   8.663 -    0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
   8.664 -    0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
   8.665 -    0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
   8.666 -    0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
   8.667 -    0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
   8.668 -    0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
   8.669 -    0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
   8.670 -    0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
   8.671 -    0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
   8.672 -    0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
   8.673 -    0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
   8.674 -    0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
   8.675 -    0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
   8.676 -    0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
   8.677 -    0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
   8.678 -    0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
   8.679 -    0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
   8.680 -    0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
   8.681 -    0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
   8.682 -    0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
   8.683 -    0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
   8.684 -    0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
   8.685 -    0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
   8.686 -    0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
   8.687 -    0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
   8.688 -    0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
   8.689 -    0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
   8.690 -    0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
   8.691 -    0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
   8.692 -    0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
   8.693 -    0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
   8.694 -    0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
   8.695 -    0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
   8.696 -    0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
   8.697 -    0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
   8.698 -    0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
   8.699 -    0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
   8.700 -    0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
   8.701 -    0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
   8.702 -    0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
   8.703 -    0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
   8.704 -    0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
   8.705 -    0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
   8.706 -    0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
   8.707 -    0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
   8.708 -    0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
   8.709 -    0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
   8.710 -    0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
   8.711 -    0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
   8.712 -    0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
   8.713 -    0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
   8.714 -    0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
   8.715 -    0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
   8.716 -    0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
   8.717 -    0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
   8.718 -    0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
   8.719 -    0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
   8.720 -    0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
   8.721 -    0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
   8.722 -    0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
   8.723 -    0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
   8.724 -    0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
   8.725 -    0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
   8.726 -    0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
   8.727 -};
   8.728 -static const u32 rcon[] = {
   8.729 -	0x01000000, 0x02000000, 0x04000000, 0x08000000,
   8.730 -	0x10000000, 0x20000000, 0x40000000, 0x80000000,
   8.731 -	0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
   8.732 -};
   8.733 -
   8.734 -/**
   8.735 - * Expand the cipher key into the encryption key schedule.
   8.736 - */
   8.737 -int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
   8.738 -			AES_KEY *key) {
   8.739 -
   8.740 -	u32 *rk;
   8.741 -   	int i = 0;
   8.742 -	u32 temp;
   8.743 -
   8.744 -	if (!userKey || !key)
   8.745 -		return -1;
   8.746 -	if (bits != 128 && bits != 192 && bits != 256)
   8.747 -		return -2;
   8.748 -
   8.749 -	rk = key->rd_key;
   8.750 -
   8.751 -	if (bits==128)
   8.752 -		key->rounds = 10;
   8.753 -	else if (bits==192)
   8.754 -		key->rounds = 12;
   8.755 -	else
   8.756 -		key->rounds = 14;
   8.757 -
   8.758 -	rk[0] = GETU32(userKey     );
   8.759 -	rk[1] = GETU32(userKey +  4);
   8.760 -	rk[2] = GETU32(userKey +  8);
   8.761 -	rk[3] = GETU32(userKey + 12);
   8.762 -	if (bits == 128) {
   8.763 -		while (1) {
   8.764 -			temp  = rk[3];
   8.765 -			rk[4] = rk[0] ^
   8.766 -				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
   8.767 -				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
   8.768 -				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
   8.769 -				(Te4[(temp >> 24)       ] & 0x000000ff) ^
   8.770 -				rcon[i];
   8.771 -			rk[5] = rk[1] ^ rk[4];
   8.772 -			rk[6] = rk[2] ^ rk[5];
   8.773 -			rk[7] = rk[3] ^ rk[6];
   8.774 -			if (++i == 10) {
   8.775 -				return 0;
   8.776 -			}
   8.777 -			rk += 4;
   8.778 -		}
   8.779 -	}
   8.780 -	rk[4] = GETU32(userKey + 16);
   8.781 -	rk[5] = GETU32(userKey + 20);
   8.782 -	if (bits == 192) {
   8.783 -		while (1) {
   8.784 -			temp = rk[ 5];
   8.785 -			rk[ 6] = rk[ 0] ^
   8.786 -				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
   8.787 -				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
   8.788 -				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
   8.789 -				(Te4[(temp >> 24)       ] & 0x000000ff) ^
   8.790 -				rcon[i];
   8.791 -			rk[ 7] = rk[ 1] ^ rk[ 6];
   8.792 -			rk[ 8] = rk[ 2] ^ rk[ 7];
   8.793 -			rk[ 9] = rk[ 3] ^ rk[ 8];
   8.794 -			if (++i == 8) {
   8.795 -				return 0;
   8.796 -			}
   8.797 -			rk[10] = rk[ 4] ^ rk[ 9];
   8.798 -			rk[11] = rk[ 5] ^ rk[10];
   8.799 -			rk += 6;
   8.800 -		}
   8.801 -	}
   8.802 -	rk[6] = GETU32(userKey + 24);
   8.803 -	rk[7] = GETU32(userKey + 28);
   8.804 -	if (bits == 256) {
   8.805 -		while (1) {
   8.806 -			temp = rk[ 7];
   8.807 -			rk[ 8] = rk[ 0] ^
   8.808 -				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
   8.809 -				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
   8.810 -				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
   8.811 -				(Te4[(temp >> 24)       ] & 0x000000ff) ^
   8.812 -				rcon[i];
   8.813 -			rk[ 9] = rk[ 1] ^ rk[ 8];
   8.814 -			rk[10] = rk[ 2] ^ rk[ 9];
   8.815 -			rk[11] = rk[ 3] ^ rk[10];
   8.816 -			if (++i == 7) {
   8.817 -				return 0;
   8.818 -			}
   8.819 -			temp = rk[11];
   8.820 -			rk[12] = rk[ 4] ^
   8.821 -				(Te4[(temp >> 24)       ] & 0xff000000) ^
   8.822 -				(Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
   8.823 -				(Te4[(temp >>  8) & 0xff] & 0x0000ff00) ^
   8.824 -				(Te4[(temp      ) & 0xff] & 0x000000ff);
   8.825 -			rk[13] = rk[ 5] ^ rk[12];
   8.826 -			rk[14] = rk[ 6] ^ rk[13];
   8.827 -			rk[15] = rk[ 7] ^ rk[14];
   8.828 -
   8.829 -			rk += 8;
   8.830 -        	}
   8.831 -	}
   8.832 -	return 0;
   8.833 -}
   8.834 -
   8.835 -/**
   8.836 - * Expand the cipher key into the decryption key schedule.
   8.837 - */
   8.838 -int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
   8.839 -			 AES_KEY *key) {
   8.840 -
   8.841 -        u32 *rk;
   8.842 -	int i, j, status;
   8.843 -	u32 temp;
   8.844 -
   8.845 -	/* first, start with an encryption schedule */
   8.846 -	status = AES_set_encrypt_key(userKey, bits, key);
   8.847 -	if (status < 0)
   8.848 -		return status;
   8.849 -
   8.850 -	rk = key->rd_key;
   8.851 -
   8.852 -	/* invert the order of the round keys: */
   8.853 -	for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
   8.854 -		temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;
   8.855 -		temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
   8.856 -		temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
   8.857 -		temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
   8.858 -	}
   8.859 -	/* apply the inverse MixColumn transform to all round keys but the first and the last: */
   8.860 -	for (i = 1; i < (key->rounds); i++) {
   8.861 -		rk += 4;
   8.862 -		rk[0] =
   8.863 -			Td0[Te4[(rk[0] >> 24)       ] & 0xff] ^
   8.864 -			Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^
   8.865 -			Td2[Te4[(rk[0] >>  8) & 0xff] & 0xff] ^
   8.866 -			Td3[Te4[(rk[0]      ) & 0xff] & 0xff];
   8.867 -		rk[1] =
   8.868 -			Td0[Te4[(rk[1] >> 24)       ] & 0xff] ^
   8.869 -			Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^
   8.870 -			Td2[Te4[(rk[1] >>  8) & 0xff] & 0xff] ^
   8.871 -			Td3[Te4[(rk[1]      ) & 0xff] & 0xff];
   8.872 -		rk[2] =
   8.873 -			Td0[Te4[(rk[2] >> 24)       ] & 0xff] ^
   8.874 -			Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^
   8.875 -			Td2[Te4[(rk[2] >>  8) & 0xff] & 0xff] ^
   8.876 -			Td3[Te4[(rk[2]      ) & 0xff] & 0xff];
   8.877 -		rk[3] =
   8.878 -			Td0[Te4[(rk[3] >> 24)       ] & 0xff] ^
   8.879 -			Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^
   8.880 -			Td2[Te4[(rk[3] >>  8) & 0xff] & 0xff] ^
   8.881 -			Td3[Te4[(rk[3]      ) & 0xff] & 0xff];
   8.882 -	}
   8.883 -	return 0;
   8.884 -}
   8.885 -
   8.886 -#ifndef AES_ASM
   8.887 -/*
   8.888 - * Encrypt a single block
   8.889 - * in and out can overlap
   8.890 - */
   8.891 -void AES_encrypt(const unsigned char *in, unsigned char *out,
   8.892 -		 const AES_KEY *key) {
   8.893 -
   8.894 -	const u32 *rk;
   8.895 -	u32 s0, s1, s2, s3, t0, t1, t2, t3;
   8.896 -#ifndef FULL_UNROLL
   8.897 -	int r;
   8.898 -#endif /* ?FULL_UNROLL */
   8.899 -
   8.900 -	assert(in && out && key);
   8.901 -	rk = key->rd_key;
   8.902 -
   8.903 -	/*
   8.904 -	 * map byte array block to cipher state
   8.905 -	 * and add initial round key:
   8.906 -	 */
   8.907 -	s0 = GETU32(in     ) ^ rk[0];
   8.908 -	s1 = GETU32(in +  4) ^ rk[1];
   8.909 -	s2 = GETU32(in +  8) ^ rk[2];
   8.910 -	s3 = GETU32(in + 12) ^ rk[3];
   8.911 -#ifdef FULL_UNROLL
   8.912 -	/* round 1: */
   8.913 -   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4];
   8.914 -   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5];
   8.915 -   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6];
   8.916 -   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7];
   8.917 -   	/* round 2: */
   8.918 -   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8];
   8.919 -   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9];
   8.920 -   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10];
   8.921 -   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11];
   8.922 -	/* round 3: */
   8.923 -   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12];
   8.924 -   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13];
   8.925 -   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14];
   8.926 -   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15];
   8.927 -   	/* round 4: */
   8.928 -   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16];
   8.929 -   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17];
   8.930 -   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18];
   8.931 -   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19];
   8.932 -	/* round 5: */
   8.933 -   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20];
   8.934 -   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21];
   8.935 -   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22];
   8.936 -   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23];
   8.937 -   	/* round 6: */
   8.938 -   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24];
   8.939 -   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25];
   8.940 -   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26];
   8.941 -   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27];
   8.942 -	/* round 7: */
   8.943 -   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28];
   8.944 -   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29];
   8.945 -   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30];
   8.946 -   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31];
   8.947 -   	/* round 8: */
   8.948 -   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32];
   8.949 -   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33];
   8.950 -   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34];
   8.951 -   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35];
   8.952 -	/* round 9: */
   8.953 -   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36];
   8.954 -   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37];
   8.955 -   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38];
   8.956 -   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39];
   8.957 -    if (key->rounds > 10) {
   8.958 -        /* round 10: */
   8.959 -        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40];
   8.960 -        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41];
   8.961 -        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42];
   8.962 -        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43];
   8.963 -        /* round 11: */
   8.964 -        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44];
   8.965 -        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45];
   8.966 -        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46];
   8.967 -        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47];
   8.968 -        if (key->rounds > 12) {
   8.969 -            /* round 12: */
   8.970 -            s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48];
   8.971 -            s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49];
   8.972 -            s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50];
   8.973 -            s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51];
   8.974 -            /* round 13: */
   8.975 -            t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52];
   8.976 -            t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53];
   8.977 -            t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54];
   8.978 -            t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55];
   8.979 -        }
   8.980 -    }
   8.981 -    rk += key->rounds << 2;
   8.982 -#else  /* !FULL_UNROLL */
   8.983 -    /*
   8.984 -     * Nr - 1 full rounds:
   8.985 -     */
   8.986 -    r = key->rounds >> 1;
   8.987 -    for (;;) {
   8.988 -        t0 =
   8.989 -            Te0[(s0 >> 24)       ] ^
   8.990 -            Te1[(s1 >> 16) & 0xff] ^
   8.991 -            Te2[(s2 >>  8) & 0xff] ^
   8.992 -            Te3[(s3      ) & 0xff] ^
   8.993 -            rk[4];
   8.994 -        t1 =
   8.995 -            Te0[(s1 >> 24)       ] ^
   8.996 -            Te1[(s2 >> 16) & 0xff] ^
   8.997 -            Te2[(s3 >>  8) & 0xff] ^
   8.998 -            Te3[(s0      ) & 0xff] ^
   8.999 -            rk[5];
  8.1000 -        t2 =
  8.1001 -            Te0[(s2 >> 24)       ] ^
  8.1002 -            Te1[(s3 >> 16) & 0xff] ^
  8.1003 -            Te2[(s0 >>  8) & 0xff] ^
  8.1004 -            Te3[(s1      ) & 0xff] ^
  8.1005 -            rk[6];
  8.1006 -        t3 =
  8.1007 -            Te0[(s3 >> 24)       ] ^
  8.1008 -            Te1[(s0 >> 16) & 0xff] ^
  8.1009 -            Te2[(s1 >>  8) & 0xff] ^
  8.1010 -            Te3[(s2      ) & 0xff] ^
  8.1011 -            rk[7];
  8.1012 -
  8.1013 -        rk += 8;
  8.1014 -        if (--r == 0) {
  8.1015 -            break;
  8.1016 -        }
  8.1017 -
  8.1018 -        s0 =
  8.1019 -            Te0[(t0 >> 24)       ] ^
  8.1020 -            Te1[(t1 >> 16) & 0xff] ^
  8.1021 -            Te2[(t2 >>  8) & 0xff] ^
  8.1022 -            Te3[(t3      ) & 0xff] ^
  8.1023 -            rk[0];
  8.1024 -        s1 =
  8.1025 -            Te0[(t1 >> 24)       ] ^
  8.1026 -            Te1[(t2 >> 16) & 0xff] ^
  8.1027 -            Te2[(t3 >>  8) & 0xff] ^
  8.1028 -            Te3[(t0      ) & 0xff] ^
  8.1029 -            rk[1];
  8.1030 -        s2 =
  8.1031 -            Te0[(t2 >> 24)       ] ^
  8.1032 -            Te1[(t3 >> 16) & 0xff] ^
  8.1033 -            Te2[(t0 >>  8) & 0xff] ^
  8.1034 -            Te3[(t1      ) & 0xff] ^
  8.1035 -            rk[2];
  8.1036 -        s3 =
  8.1037 -            Te0[(t3 >> 24)       ] ^
  8.1038 -            Te1[(t0 >> 16) & 0xff] ^
  8.1039 -            Te2[(t1 >>  8) & 0xff] ^
  8.1040 -            Te3[(t2      ) & 0xff] ^
  8.1041 -            rk[3];
  8.1042 -    }
  8.1043 -#endif /* ?FULL_UNROLL */
  8.1044 -    /*
  8.1045 -	 * apply last round and
  8.1046 -	 * map cipher state to byte array block:
  8.1047 -	 */
  8.1048 -	s0 =
  8.1049 -		(Te4[(t0 >> 24)       ] & 0xff000000) ^
  8.1050 -		(Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
  8.1051 -		(Te4[(t2 >>  8) & 0xff] & 0x0000ff00) ^
  8.1052 -		(Te4[(t3      ) & 0xff] & 0x000000ff) ^
  8.1053 -		rk[0];
  8.1054 -	PUTU32(out     , s0);
  8.1055 -	s1 =
  8.1056 -		(Te4[(t1 >> 24)       ] & 0xff000000) ^
  8.1057 -		(Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
  8.1058 -		(Te4[(t3 >>  8) & 0xff] & 0x0000ff00) ^
  8.1059 -		(Te4[(t0      ) & 0xff] & 0x000000ff) ^
  8.1060 -		rk[1];
  8.1061 -	PUTU32(out +  4, s1);
  8.1062 -	s2 =
  8.1063 -		(Te4[(t2 >> 24)       ] & 0xff000000) ^
  8.1064 -		(Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
  8.1065 -		(Te4[(t0 >>  8) & 0xff] & 0x0000ff00) ^
  8.1066 -		(Te4[(t1      ) & 0xff] & 0x000000ff) ^
  8.1067 -		rk[2];
  8.1068 -	PUTU32(out +  8, s2);
  8.1069 -	s3 =
  8.1070 -		(Te4[(t3 >> 24)       ] & 0xff000000) ^
  8.1071 -		(Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
  8.1072 -		(Te4[(t1 >>  8) & 0xff] & 0x0000ff00) ^
  8.1073 -		(Te4[(t2      ) & 0xff] & 0x000000ff) ^
  8.1074 -		rk[3];
  8.1075 -	PUTU32(out + 12, s3);
  8.1076 -}
  8.1077 -
  8.1078 -/*
  8.1079 - * Decrypt a single block
  8.1080 - * in and out can overlap
  8.1081 - */
  8.1082 -void AES_decrypt(const unsigned char *in, unsigned char *out,
  8.1083 -		 const AES_KEY *key) {
  8.1084 -
  8.1085 -	const u32 *rk;
  8.1086 -	u32 s0, s1, s2, s3, t0, t1, t2, t3;
  8.1087 -#ifndef FULL_UNROLL
  8.1088 -	int r;
  8.1089 -#endif /* ?FULL_UNROLL */
  8.1090 -
  8.1091 -	assert(in && out && key);
  8.1092 -	rk = key->rd_key;
  8.1093 -
  8.1094 -	/*
  8.1095 -	 * map byte array block to cipher state
  8.1096 -	 * and add initial round key:
  8.1097 -	 */
  8.1098 -    s0 = GETU32(in     ) ^ rk[0];
  8.1099 -    s1 = GETU32(in +  4) ^ rk[1];
  8.1100 -    s2 = GETU32(in +  8) ^ rk[2];
  8.1101 -    s3 = GETU32(in + 12) ^ rk[3];
  8.1102 -#ifdef FULL_UNROLL
  8.1103 -    /* round 1: */
  8.1104 -    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4];
  8.1105 -    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5];
  8.1106 -    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6];
  8.1107 -    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7];
  8.1108 -    /* round 2: */
  8.1109 -    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8];
  8.1110 -    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9];
  8.1111 -    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10];
  8.1112 -    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11];
  8.1113 -    /* round 3: */
  8.1114 -    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12];
  8.1115 -    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13];
  8.1116 -    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14];
  8.1117 -    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15];
  8.1118 -    /* round 4: */
  8.1119 -    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16];
  8.1120 -    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17];
  8.1121 -    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18];
  8.1122 -    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19];
  8.1123 -    /* round 5: */
  8.1124 -    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20];
  8.1125 -    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21];
  8.1126 -    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22];
  8.1127 -    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23];
  8.1128 -    /* round 6: */
  8.1129 -    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24];
  8.1130 -    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25];
  8.1131 -    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26];
  8.1132 -    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27];
  8.1133 -    /* round 7: */
  8.1134 -    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28];
  8.1135 -    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29];
  8.1136 -    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30];
  8.1137 -    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31];
  8.1138 -    /* round 8: */
  8.1139 -    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32];
  8.1140 -    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33];
  8.1141 -    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34];
  8.1142 -    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35];
  8.1143 -    /* round 9: */
  8.1144 -    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36];
  8.1145 -    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37];
  8.1146 -    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38];
  8.1147 -    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39];
  8.1148 -    if (key->rounds > 10) {
  8.1149 -        /* round 10: */
  8.1150 -        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40];
  8.1151 -        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41];
  8.1152 -        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42];
  8.1153 -        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43];
  8.1154 -        /* round 11: */
  8.1155 -        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44];
  8.1156 -        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45];
  8.1157 -        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46];
  8.1158 -        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47];
  8.1159 -        if (key->rounds > 12) {
  8.1160 -            /* round 12: */
  8.1161 -            s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48];
  8.1162 -            s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49];
  8.1163 -            s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50];
  8.1164 -            s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51];
  8.1165 -            /* round 13: */
  8.1166 -            t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52];
  8.1167 -            t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53];
  8.1168 -            t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54];
  8.1169 -            t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55];
  8.1170 -        }
  8.1171 -    }
  8.1172 -	rk += key->rounds << 2;
  8.1173 -#else  /* !FULL_UNROLL */
  8.1174 -    /*
  8.1175 -     * Nr - 1 full rounds:
  8.1176 -     */
  8.1177 -    r = key->rounds >> 1;
  8.1178 -    for (;;) {
  8.1179 -        t0 =
  8.1180 -            Td0[(s0 >> 24)       ] ^
  8.1181 -            Td1[(s3 >> 16) & 0xff] ^
  8.1182 -            Td2[(s2 >>  8) & 0xff] ^
  8.1183 -            Td3[(s1      ) & 0xff] ^
  8.1184 -            rk[4];
  8.1185 -        t1 =
  8.1186 -            Td0[(s1 >> 24)       ] ^
  8.1187 -            Td1[(s0 >> 16) & 0xff] ^
  8.1188 -            Td2[(s3 >>  8) & 0xff] ^
  8.1189 -            Td3[(s2      ) & 0xff] ^
  8.1190 -            rk[5];
  8.1191 -        t2 =
  8.1192 -            Td0[(s2 >> 24)       ] ^
  8.1193 -            Td1[(s1 >> 16) & 0xff] ^
  8.1194 -            Td2[(s0 >>  8) & 0xff] ^
  8.1195 -            Td3[(s3      ) & 0xff] ^
  8.1196 -            rk[6];
  8.1197 -        t3 =
  8.1198 -            Td0[(s3 >> 24)       ] ^
  8.1199 -            Td1[(s2 >> 16) & 0xff] ^
  8.1200 -            Td2[(s1 >>  8) & 0xff] ^
  8.1201 -            Td3[(s0      ) & 0xff] ^
  8.1202 -            rk[7];
  8.1203 -
  8.1204 -        rk += 8;
  8.1205 -        if (--r == 0) {
  8.1206 -            break;
  8.1207 -        }
  8.1208 -
  8.1209 -        s0 =
  8.1210 -            Td0[(t0 >> 24)       ] ^
  8.1211 -            Td1[(t3 >> 16) & 0xff] ^
  8.1212 -            Td2[(t2 >>  8) & 0xff] ^
  8.1213 -            Td3[(t1      ) & 0xff] ^
  8.1214 -            rk[0];
  8.1215 -        s1 =
  8.1216 -            Td0[(t1 >> 24)       ] ^
  8.1217 -            Td1[(t0 >> 16) & 0xff] ^
  8.1218 -            Td2[(t3 >>  8) & 0xff] ^
  8.1219 -            Td3[(t2      ) & 0xff] ^
  8.1220 -            rk[1];
  8.1221 -        s2 =
  8.1222 -            Td0[(t2 >> 24)       ] ^
  8.1223 -            Td1[(t1 >> 16) & 0xff] ^
  8.1224 -            Td2[(t0 >>  8) & 0xff] ^
  8.1225 -            Td3[(t3      ) & 0xff] ^
  8.1226 -            rk[2];
  8.1227 -        s3 =
  8.1228 -            Td0[(t3 >> 24)       ] ^
  8.1229 -            Td1[(t2 >> 16) & 0xff] ^
  8.1230 -            Td2[(t1 >>  8) & 0xff] ^
  8.1231 -            Td3[(t0      ) & 0xff] ^
  8.1232 -            rk[3];
  8.1233 -    }
  8.1234 -#endif /* ?FULL_UNROLL */
  8.1235 -    /*
  8.1236 -	 * apply last round and
  8.1237 -	 * map cipher state to byte array block:
  8.1238 -	 */
  8.1239 -   	s0 =
  8.1240 -   		(Td4[(t0 >> 24)       ] & 0xff000000) ^
  8.1241 -   		(Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
  8.1242 -   		(Td4[(t2 >>  8) & 0xff] & 0x0000ff00) ^
  8.1243 -   		(Td4[(t1      ) & 0xff] & 0x000000ff) ^
  8.1244 -   		rk[0];
  8.1245 -	PUTU32(out     , s0);
  8.1246 -   	s1 =
  8.1247 -   		(Td4[(t1 >> 24)       ] & 0xff000000) ^
  8.1248 -   		(Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
  8.1249 -   		(Td4[(t3 >>  8) & 0xff] & 0x0000ff00) ^
  8.1250 -   		(Td4[(t2      ) & 0xff] & 0x000000ff) ^
  8.1251 -   		rk[1];
  8.1252 -	PUTU32(out +  4, s1);
  8.1253 -   	s2 =
  8.1254 -   		(Td4[(t2 >> 24)       ] & 0xff000000) ^
  8.1255 -   		(Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
  8.1256 -   		(Td4[(t0 >>  8) & 0xff] & 0x0000ff00) ^
  8.1257 -   		(Td4[(t3      ) & 0xff] & 0x000000ff) ^
  8.1258 -   		rk[2];
  8.1259 -	PUTU32(out +  8, s2);
  8.1260 -   	s3 =
  8.1261 -   		(Td4[(t3 >> 24)       ] & 0xff000000) ^
  8.1262 -   		(Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
  8.1263 -   		(Td4[(t1 >>  8) & 0xff] & 0x0000ff00) ^
  8.1264 -   		(Td4[(t0      ) & 0xff] & 0x000000ff) ^
  8.1265 -   		rk[3];
  8.1266 -	PUTU32(out + 12, s3);
  8.1267 -}
  8.1268 -
  8.1269 -#endif /* AES_ASM */
  8.1270 -
  8.1271 -void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
  8.1272 -		     const unsigned long length, const AES_KEY *key,
  8.1273 -		     unsigned char *ivec, const int enc) 
  8.1274 -{
  8.1275 -
  8.1276 -	unsigned long n;
  8.1277 -	unsigned long len = length;
  8.1278 -	unsigned char tmp[AES_BLOCK_SIZE];
  8.1279 -
  8.1280 -	assert(in && out && key && ivec);
  8.1281 -
  8.1282 -	if (enc) {
  8.1283 -		while (len >= AES_BLOCK_SIZE) {
  8.1284 -			for(n=0; n < AES_BLOCK_SIZE; ++n)
  8.1285 -				tmp[n] = in[n] ^ ivec[n];
  8.1286 -			AES_encrypt(tmp, out, key);
  8.1287 -			memcpy(ivec, out, AES_BLOCK_SIZE);
  8.1288 -			len -= AES_BLOCK_SIZE;
  8.1289 -			in += AES_BLOCK_SIZE;
  8.1290 -			out += AES_BLOCK_SIZE;
  8.1291 -		}
  8.1292 -		if (len) {
  8.1293 -			for(n=0; n < len; ++n)
  8.1294 -				tmp[n] = in[n] ^ ivec[n];
  8.1295 -			for(n=len; n < AES_BLOCK_SIZE; ++n)
  8.1296 -				tmp[n] = ivec[n];
  8.1297 -			AES_encrypt(tmp, tmp, key);
  8.1298 -			memcpy(out, tmp, AES_BLOCK_SIZE);
  8.1299 -			memcpy(ivec, tmp, AES_BLOCK_SIZE);
  8.1300 -		}			
  8.1301 -	} else {
  8.1302 -		while (len >= AES_BLOCK_SIZE) {
  8.1303 -			memcpy(tmp, in, AES_BLOCK_SIZE);
  8.1304 -			AES_decrypt(in, out, key);
  8.1305 -			for(n=0; n < AES_BLOCK_SIZE; ++n)
  8.1306 -				out[n] ^= ivec[n];
  8.1307 -			memcpy(ivec, tmp, AES_BLOCK_SIZE);
  8.1308 -			len -= AES_BLOCK_SIZE;
  8.1309 -			in += AES_BLOCK_SIZE;
  8.1310 -			out += AES_BLOCK_SIZE;
  8.1311 -		}
  8.1312 -		if (len) {
  8.1313 -			memcpy(tmp, in, AES_BLOCK_SIZE);
  8.1314 -			AES_decrypt(tmp, tmp, key);
  8.1315 -			for(n=0; n < len; ++n)
  8.1316 -				out[n] = tmp[n] ^ ivec[n];
  8.1317 -			memcpy(ivec, tmp, AES_BLOCK_SIZE);
  8.1318 -		}			
  8.1319 -	}
  8.1320 -}
     9.1 --- a/tools/ioemu/aes.h	Wed Jul 12 16:34:39 2006 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,26 +0,0 @@
     9.4 -#ifndef QEMU_AES_H
     9.5 -#define QEMU_AES_H
     9.6 -
     9.7 -#define AES_MAXNR 14
     9.8 -#define AES_BLOCK_SIZE 16
     9.9 -
    9.10 -struct aes_key_st {
    9.11 -    uint32_t rd_key[4 *(AES_MAXNR + 1)];
    9.12 -    int rounds;
    9.13 -};
    9.14 -typedef struct aes_key_st AES_KEY;
    9.15 -
    9.16 -int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
    9.17 -	AES_KEY *key);
    9.18 -int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
    9.19 -	AES_KEY *key);
    9.20 -
    9.21 -void AES_encrypt(const unsigned char *in, unsigned char *out,
    9.22 -	const AES_KEY *key);
    9.23 -void AES_decrypt(const unsigned char *in, unsigned char *out,
    9.24 -	const AES_KEY *key);
    9.25 -void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
    9.26 -		     const unsigned long length, const AES_KEY *key,
    9.27 -		     unsigned char *ivec, const int enc);
    9.28 -
    9.29 -#endif
    10.1 --- a/tools/ioemu/audio/audio.c	Wed Jul 12 16:34:39 2006 +0100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,910 +0,0 @@
    10.4 -/*
    10.5 - * QEMU Audio subsystem
    10.6 - * 
    10.7 - * Copyright (c) 2003-2004 Vassili Karpov (malc)
    10.8 - * 
    10.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   10.10 - * of this software and associated documentation files (the "Software"), to deal
   10.11 - * in the Software without restriction, including without limitation the rights
   10.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   10.13 - * copies of the Software, and to permit persons to whom the Software is
   10.14 - * furnished to do so, subject to the following conditions:
   10.15 - *
   10.16 - * The above copyright notice and this permission notice shall be included in
   10.17 - * all copies or substantial portions of the Software.
   10.18 - *
   10.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   10.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   10.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   10.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   10.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   10.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   10.25 - * THE SOFTWARE.
   10.26 - */
   10.27 -#include <assert.h>
   10.28 -#include "vl.h"
   10.29 -
   10.30 -#define USE_WAV_AUDIO
   10.31 -
   10.32 -#include "audio/audio_int.h"
   10.33 -
   10.34 -#define dolog(...) AUD_log ("audio", __VA_ARGS__)
   10.35 -#ifdef DEBUG
   10.36 -#define ldebug(...) dolog (__VA_ARGS__)
   10.37 -#else
   10.38 -#define ldebug(...)
   10.39 -#endif
   10.40 -
   10.41 -#define QC_AUDIO_DRV    "QEMU_AUDIO_DRV"
   10.42 -#define QC_VOICES       "QEMU_VOICES"
   10.43 -#define QC_FIXED_FORMAT "QEMU_FIXED_FORMAT"
   10.44 -#define QC_FIXED_FREQ   "QEMU_FIXED_FREQ"
   10.45 -
   10.46 -static HWVoice *hw_voices;
   10.47 -
   10.48 -AudioState audio_state = {
   10.49 -    1,                          /* use fixed settings */
   10.50 -    44100,                      /* fixed frequency */
   10.51 -    2,                          /* fixed channels */
   10.52 -    AUD_FMT_S16,                /* fixed format */
   10.53 -    1,                          /* number of hw voices */
   10.54 -    -1                          /* voice size */
   10.55 -};
   10.56 -
   10.57 -/* http://www.df.lth.se/~john_e/gems/gem002d.html */
   10.58 -/* http://www.multi-platforms.com/Tips/PopCount.htm */
   10.59 -uint32_t popcount (uint32_t u)
   10.60 -{
   10.61 -    u = ((u&0x55555555) + ((u>>1)&0x55555555));
   10.62 -    u = ((u&0x33333333) + ((u>>2)&0x33333333));
   10.63 -    u = ((u&0x0f0f0f0f) + ((u>>4)&0x0f0f0f0f));
   10.64 -    u = ((u&0x00ff00ff) + ((u>>8)&0x00ff00ff));
   10.65 -    u = ( u&0x0000ffff) + (u>>16);
   10.66 -    return u;
   10.67 -}
   10.68 -
   10.69 -inline uint32_t lsbindex (uint32_t u)
   10.70 -{
   10.71 -    return popcount ((u&-u)-1);
   10.72 -}
   10.73 -
   10.74 -int audio_get_conf_int (const char *key, int defval)
   10.75 -{
   10.76 -    int val = defval;
   10.77 -    char *strval;
   10.78 -
   10.79 -    strval = getenv (key);
   10.80 -    if (strval) {
   10.81 -        val = atoi (strval);
   10.82 -    }
   10.83 -
   10.84 -    return val;
   10.85 -}
   10.86 -
   10.87 -const char *audio_get_conf_str (const char *key, const char *defval)
   10.88 -{
   10.89 -    const char *val = getenv (key);
   10.90 -    if (!val)
   10.91 -        return defval;
   10.92 -    else
   10.93 -        return val;
   10.94 -}
   10.95 -
   10.96 -void AUD_log (const char *cap, const char *fmt, ...)
   10.97 -{
   10.98 -    va_list ap;
   10.99 -    fprintf (stderr, "%s: ", cap);
  10.100 -    va_start (ap, fmt);
  10.101 -    vfprintf (stderr, fmt, ap);
  10.102 -    va_end (ap);
  10.103 -}
  10.104 -
  10.105 -/*
  10.106 - * Soft Voice
  10.107 - */
  10.108 -void pcm_sw_free_resources (SWVoice *sw)
  10.109 -{
  10.110 -    if (sw->buf) qemu_free (sw->buf);
  10.111 -    if (sw->rate) st_rate_stop (sw->rate);
  10.112 -    sw->buf = NULL;
  10.113 -    sw->rate = NULL;
  10.114 -}
  10.115 -
  10.116 -int pcm_sw_alloc_resources (SWVoice *sw)
  10.117 -{
  10.118 -    sw->buf = qemu_mallocz (sw->hw->samples * sizeof (st_sample_t));
  10.119 -    if (!sw->buf)
  10.120 -        return -1;
  10.121 -
  10.122 -    sw->rate = st_rate_start (sw->freq, sw->hw->freq);
  10.123 -    if (!sw->rate) {
  10.124 -        qemu_free (sw->buf);
  10.125 -        sw->buf = NULL;
  10.126 -        return -1;
  10.127 -    }
  10.128 -    return 0;
  10.129 -}
  10.130 -
  10.131 -void pcm_sw_fini (SWVoice *sw)
  10.132 -{
  10.133 -    pcm_sw_free_resources (sw);
  10.134 -}
  10.135 -
  10.136 -int pcm_sw_init (SWVoice *sw, HWVoice *hw, int freq,
  10.137 -                 int nchannels, audfmt_e fmt)
  10.138 -{
  10.139 -    int bits = 8, sign = 0;
  10.140 -
  10.141 -    switch (fmt) {
  10.142 -    case AUD_FMT_S8:
  10.143 -        sign = 1;
  10.144 -    case AUD_FMT_U8:
  10.145 -        break;
  10.146 -
  10.147 -    case AUD_FMT_S16:
  10.148 -        sign = 1;
  10.149 -    case AUD_FMT_U16:
  10.150 -        bits = 16;
  10.151 -        break;
  10.152 -    }
  10.153 -
  10.154 -    sw->hw = hw;
  10.155 -    sw->freq = freq;
  10.156 -    sw->fmt = fmt;
  10.157 -    sw->nchannels = nchannels;
  10.158 -    sw->shift = (nchannels == 2) + (bits == 16);
  10.159 -    sw->align = (1 << sw->shift) - 1;
  10.160 -    sw->left = 0;
  10.161 -    sw->pos = 0;
  10.162 -    sw->wpos = 0;
  10.163 -    sw->live = 0;
  10.164 -    sw->ratio = (sw->hw->freq * ((int64_t) INT_MAX)) / sw->freq;
  10.165 -    sw->bytes_per_second = sw->freq << sw->shift;
  10.166 -    sw->conv = mixeng_conv[nchannels == 2][sign][bits == 16];
  10.167 -
  10.168 -    pcm_sw_free_resources (sw);
  10.169 -    return pcm_sw_alloc_resources (sw);
  10.170 -}
  10.171 -
  10.172 -/* Hard voice */
  10.173 -void pcm_hw_free_resources (HWVoice *hw)
  10.174 -{
  10.175 -    if (hw->mix_buf)
  10.176 -        qemu_free (hw->mix_buf);
  10.177 -    hw->mix_buf = NULL;
  10.178 -}
  10.179 -
  10.180 -int pcm_hw_alloc_resources (HWVoice *hw)
  10.181 -{
  10.182 -    hw->mix_buf = qemu_mallocz (hw->samples * sizeof (st_sample_t));
  10.183 -    if (!hw->mix_buf)
  10.184 -        return -1;
  10.185 -    return 0;
  10.186 -}
  10.187 -
  10.188 -void pcm_hw_fini (HWVoice *hw)
  10.189 -{
  10.190 -    if (hw->active) {
  10.191 -        ldebug ("pcm_hw_fini: %d %d %d\n", hw->freq, hw->nchannels, hw->fmt);
  10.192 -        pcm_hw_free_resources (hw);
  10.193 -        hw->pcm_ops->fini (hw);
  10.194 -        memset (hw, 0, audio_state.drv->voice_size);
  10.195 -    }
  10.196 -}
  10.197 -
  10.198 -void pcm_hw_gc (HWVoice *hw)
  10.199 -{
  10.200 -    if (hw->nb_voices)
  10.201 -        return;
  10.202 -
  10.203 -    pcm_hw_fini (hw);
  10.204 -}
  10.205 -
  10.206 -int pcm_hw_get_live (HWVoice *hw)
  10.207 -{
  10.208 -    int i, alive = 0, live = hw->samples;
  10.209 -
  10.210 -    for (i = 0; i < hw->nb_voices; i++) {
  10.211 -        if (hw->pvoice[i]->live) {
  10.212 -            live = audio_MIN (hw->pvoice[i]->live, live);
  10.213 -            alive += 1;
  10.214 -        }
  10.215 -    }
  10.216 -
  10.217 -    if (alive)
  10.218 -        return live;
  10.219 -    else
  10.220 -        return -1;
  10.221 -}
  10.222 -
  10.223 -int pcm_hw_get_live2 (HWVoice *hw, int *nb_active)
  10.224 -{
  10.225 -    int i, alive = 0, live = hw->samples;
  10.226 -
  10.227 -    *nb_active = 0;
  10.228 -    for (i = 0; i < hw->nb_voices; i++) {
  10.229 -        if (hw->pvoice[i]->live) {
  10.230 -            if (hw->pvoice[i]->live < live) {
  10.231 -                *nb_active = hw->pvoice[i]->active != 0;
  10.232 -                live = hw->pvoice[i]->live;
  10.233 -            }
  10.234 -            alive += 1;
  10.235 -        }
  10.236 -    }
  10.237 -
  10.238 -    if (alive)
  10.239 -        return live;
  10.240 -    else
  10.241 -        return -1;
  10.242 -}
  10.243 -
  10.244 -void pcm_hw_dec_live (HWVoice *hw, int decr)
  10.245 -{
  10.246 -    int i;
  10.247 -
  10.248 -    for (i = 0; i < hw->nb_voices; i++) {
  10.249 -        if (hw->pvoice[i]->live) {
  10.250 -            hw->pvoice[i]->live -= decr;
  10.251 -        }
  10.252 -    }
  10.253 -}
  10.254 -
  10.255 -void pcm_hw_clear (HWVoice *hw, void *buf, int len)
  10.256 -{
  10.257 -    if (!len)
  10.258 -        return;
  10.259 -
  10.260 -    switch (hw->fmt) {
  10.261 -    case AUD_FMT_S16:
  10.262 -    case AUD_FMT_S8:
  10.263 -        memset (buf, 0x00, len << hw->shift);
  10.264 -        break;
  10.265 -
  10.266 -    case AUD_FMT_U8:
  10.267 -        memset (buf, 0x80, len << hw->shift);
  10.268 -        break;
  10.269 -
  10.270 -    case AUD_FMT_U16:
  10.271 -        {
  10.272 -            unsigned int i;
  10.273 -            uint16_t *p = buf;
  10.274 -            int shift = hw->nchannels - 1;
  10.275 -
  10.276 -            for (i = 0; i < len << shift; i++) {
  10.277 -                p[i] = INT16_MAX;
  10.278 -            }
  10.279 -        }
  10.280 -        break;
  10.281 -    }
  10.282 -}
  10.283 -
  10.284 -int pcm_hw_write (SWVoice *sw, void *buf, int size)
  10.285 -{
  10.286 -    int hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim, blck;
  10.287 -    int ret = 0, pos = 0;
  10.288 -    if (!sw)
  10.289 -        return size;
  10.290 -
  10.291 -    hwsamples = sw->hw->samples;
  10.292 -    samples = size >> sw->shift;
  10.293 -
  10.294 -    if (!sw->live) {
  10.295 -        sw->wpos = sw->hw->rpos;
  10.296 -    }
  10.297 -    wpos = sw->wpos;
  10.298 -    live = sw->live;
  10.299 -    dead = hwsamples - live;
  10.300 -    swlim = (dead * ((int64_t) INT_MAX)) / sw->ratio;
  10.301 -    swlim = audio_MIN (swlim, samples);
  10.302 -
  10.303 -    ldebug ("size=%d live=%d dead=%d swlim=%d wpos=%d\n",
  10.304 -           size, live, dead, swlim, wpos);
  10.305 -    if (swlim)
  10.306 -        sw->conv (sw->buf, buf, swlim);
  10.307 -
  10.308 -    while (swlim) {
  10.309 -        dead = hwsamples - live;
  10.310 -        left = hwsamples - wpos;
  10.311 -        blck = audio_MIN (dead, left);
  10.312 -        if (!blck) {
  10.313 -            /* dolog ("swlim=%d\n", swlim); */
  10.314 -            break;
  10.315 -        }
  10.316 -        isamp = swlim;
  10.317 -        osamp = blck;
  10.318 -        st_rate_flow (sw->rate, sw->buf + pos, sw->hw->mix_buf + wpos, &isamp, &osamp);
  10.319 -        ret += isamp;
  10.320 -        swlim -= isamp;
  10.321 -        pos += isamp;
  10.322 -        live += osamp;
  10.323 -        wpos = (wpos + osamp) % hwsamples;
  10.324 -    }
  10.325 -
  10.326 -    sw->wpos = wpos;
  10.327 -    sw->live = live;
  10.328 -    return ret << sw->shift;
  10.329 -}
  10.330 -
  10.331 -int pcm_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
  10.332 -{
  10.333 -    int sign = 0, bits = 8;
  10.334 -
  10.335 -    pcm_hw_fini (hw);
  10.336 -    ldebug ("pcm_hw_init: %d %d %d\n", freq, nchannels, fmt);
  10.337 -    if (hw->pcm_ops->init (hw, freq, nchannels, fmt)) {
  10.338 -        memset (hw, 0, audio_state.drv->voice_size);
  10.339 -        return -1;
  10.340 -    }
  10.341 -
  10.342 -    switch (hw->fmt) {
  10.343 -    case AUD_FMT_S8:
  10.344 -        sign = 1;
  10.345 -    case AUD_FMT_U8:
  10.346 -        break;
  10.347 -
  10.348 -    case AUD_FMT_S16:
  10.349 -        sign = 1;
  10.350 -    case AUD_FMT_U16:
  10.351 -        bits = 16;
  10.352 -        break;
  10.353 -    }
  10.354 -
  10.355 -    hw->nb_voices = 0;
  10.356 -    hw->active = 1;
  10.357 -    hw->shift = (hw->nchannels == 2) + (bits == 16);
  10.358 -    hw->bytes_per_second = hw->freq << hw->shift;
  10.359 -    hw->align = (1 << hw->shift) - 1;
  10.360 -    hw->samples = hw->bufsize >> hw->shift;
  10.361 -    hw->clip = mixeng_clip[hw->nchannels == 2][sign][bits == 16];
  10.362 -    if (pcm_hw_alloc_resources (hw)) {
  10.363 -        pcm_hw_fini (hw);
  10.364 -        return -1;
  10.365 -    }
  10.366 -    return 0;
  10.367 -}
  10.368 -
  10.369 -static int dist (void *hw)
  10.370 -{
  10.371 -    if (hw) {
  10.372 -        return (((uint8_t *) hw - (uint8_t *) hw_voices)
  10.373 -                / audio_state.voice_size) + 1;
  10.374 -    }
  10.375 -    else {
  10.376 -        return 0;
  10.377 -    }
  10.378 -}
  10.379 -
  10.380 -#define ADVANCE(hw) hw ? advance (hw, audio_state.voice_size) : hw_voices
  10.381 -
  10.382 -HWVoice *pcm_hw_find_any (HWVoice *hw)
  10.383 -{
  10.384 -    int i = dist (hw);
  10.385 -    for (; i < audio_state.nb_hw_voices; i++) {
  10.386 -        hw = ADVANCE (hw);
  10.387 -        return hw;
  10.388 -    }
  10.389 -    return NULL;
  10.390 -}
  10.391 -
  10.392 -HWVoice *pcm_hw_find_any_active (HWVoice *hw)
  10.393 -{
  10.394 -    int i = dist (hw);
  10.395 -    for (; i < audio_state.nb_hw_voices; i++) {
  10.396 -        hw = ADVANCE (hw);
  10.397 -        if (hw->active)
  10.398 -            return hw;
  10.399 -    }
  10.400 -    return NULL;
  10.401 -}
  10.402 -
  10.403 -HWVoice *pcm_hw_find_any_active_enabled (HWVoice *hw)
  10.404 -{
  10.405 -    int i = dist (hw);
  10.406 -    for (; i < audio_state.nb_hw_voices; i++) {
  10.407 -        hw = ADVANCE (hw);
  10.408 -        if (hw->active && hw->enabled)
  10.409 -            return hw;
  10.410 -    }
  10.411 -    return NULL;
  10.412 -}
  10.413 -
  10.414 -HWVoice *pcm_hw_find_any_passive (HWVoice *hw)
  10.415 -{
  10.416 -    int i = dist (hw);
  10.417 -    for (; i < audio_state.nb_hw_voices; i++) {
  10.418 -        hw = ADVANCE (hw);
  10.419 -        if (!hw->active)
  10.420 -            return hw;
  10.421 -    }
  10.422 -    return NULL;
  10.423 -}
  10.424 -
  10.425 -HWVoice *pcm_hw_find_specific (HWVoice *hw, int freq,
  10.426 -                               int nchannels, audfmt_e fmt)
  10.427 -{
  10.428 -    while ((hw = pcm_hw_find_any_active (hw))) {
  10.429 -        if (hw->freq == freq &&
  10.430 -            hw->nchannels == nchannels &&
  10.431 -            hw->fmt == fmt)
  10.432 -            return hw;
  10.433 -    }
  10.434 -    return NULL;
  10.435 -}
  10.436 -
  10.437 -HWVoice *pcm_hw_add (int freq, int nchannels, audfmt_e fmt)
  10.438 -{
  10.439 -    HWVoice *hw;
  10.440 -
  10.441 -    if (audio_state.fixed_format) {
  10.442 -        freq = audio_state.fixed_freq;
  10.443 -        nchannels = audio_state.fixed_channels;
  10.444 -        fmt = audio_state.fixed_fmt;
  10.445 -    }
  10.446 -
  10.447 -    hw = pcm_hw_find_specific (NULL, freq, nchannels, fmt);
  10.448 -
  10.449 -    if (hw)
  10.450 -        return hw;
  10.451 -
  10.452 -    hw = pcm_hw_find_any_passive (NULL);
  10.453 -    if (hw) {
  10.454 -        hw->pcm_ops = audio_state.drv->pcm_ops;
  10.455 -        if (!hw->pcm_ops)
  10.456 -            return NULL;
  10.457 -
  10.458 -        if (pcm_hw_init (hw, freq, nchannels, fmt)) {
  10.459 -            pcm_hw_gc (hw);
  10.460 -            return NULL;
  10.461 -        }
  10.462 -        else
  10.463 -            return hw;
  10.464 -    }
  10.465 -
  10.466 -    return pcm_hw_find_any (NULL);
  10.467 -}
  10.468 -
  10.469 -int pcm_hw_add_sw (HWVoice *hw, SWVoice *sw)
  10.470 -{
  10.471 -    SWVoice **pvoice = qemu_mallocz ((hw->nb_voices + 1) * sizeof (sw));
  10.472 -    if (!pvoice)
  10.473 -        return -1;
  10.474 -
  10.475 -    memcpy (pvoice, hw->pvoice, hw->nb_voices * sizeof (sw));
  10.476 -    qemu_free (hw->pvoice);
  10.477 -    hw->pvoice = pvoice;
  10.478 -    hw->pvoice[hw->nb_voices++] = sw;
  10.479 -    return 0;
  10.480 -}
  10.481 -
  10.482 -int pcm_hw_del_sw (HWVoice *hw, SWVoice *sw)
  10.483 -{
  10.484 -    int i, j;
  10.485 -    if (hw->nb_voices > 1) {
  10.486 -        SWVoice **pvoice = qemu_mallocz ((hw->nb_voices - 1) * sizeof (sw));
  10.487 -
  10.488 -        if (!pvoice) {
  10.489 -            dolog ("Can not maintain consistent state (not enough memory)\n");
  10.490 -            return -1;
  10.491 -        }
  10.492 -
  10.493 -        for (i = 0, j = 0; i < hw->nb_voices; i++) {
  10.494 -            if (j >= hw->nb_voices - 1) {
  10.495 -                dolog ("Can not maintain consistent state "
  10.496 -                       "(invariant violated)\n");
  10.497 -                return -1;
  10.498 -            }
  10.499 -            if (hw->pvoice[i] != sw)
  10.500 -                pvoice[j++] = hw->pvoice[i];
  10.501 -        }
  10.502 -        qemu_free (hw->pvoice);
  10.503 -        hw->pvoice = pvoice;
  10.504 -        hw->nb_voices -= 1;
  10.505 -    }
  10.506 -    else {
  10.507 -        qemu_free (hw->pvoice);
  10.508 -        hw->pvoice = NULL;
  10.509 -        hw->nb_voices = 0;
  10.510 -    }
  10.511 -    return 0;
  10.512 -}
  10.513 -
  10.514 -SWVoice *pcm_create_voice_pair (int freq, int nchannels, audfmt_e fmt)
  10.515 -{
  10.516 -    SWVoice *sw;
  10.517 -    HWVoice *hw;
  10.518 -
  10.519 -    sw = qemu_mallocz (sizeof (*sw));
  10.520 -    if (!sw)
  10.521 -        goto err1;
  10.522 -
  10.523 -    hw = pcm_hw_add (freq, nchannels, fmt);
  10.524 -    if (!hw)
  10.525 -        goto err2;
  10.526 -
  10.527 -    if (pcm_hw_add_sw (hw, sw))
  10.528 -        goto err3;
  10.529 -
  10.530 -    if (pcm_sw_init (sw, hw, freq, nchannels, fmt))
  10.531 -        goto err4;
  10.532 -
  10.533 -    return sw;
  10.534 -
  10.535 -err4:
  10.536 -    pcm_hw_del_sw (hw, sw);
  10.537 -err3:
  10.538 -    pcm_hw_gc (hw);
  10.539 -err2:
  10.540 -    qemu_free (sw);
  10.541 -err1:
  10.542 -    return NULL;
  10.543 -}
  10.544 -
  10.545 -SWVoice *AUD_open (SWVoice *sw, const char *name,
  10.546 -                   int freq, int nchannels, audfmt_e fmt)
  10.547 -{
  10.548 -    if (!audio_state.drv) {
  10.549 -        return NULL;
  10.550 -    }
  10.551 -
  10.552 -    if (sw && freq == sw->freq && sw->nchannels == nchannels && sw->fmt == fmt) {
  10.553 -        return sw;
  10.554 -    }
  10.555 -
  10.556 -    if (sw) {
  10.557 -        ldebug ("Different format %s %d %d %d\n",
  10.558 -                name,
  10.559 -                sw->freq == freq,
  10.560 -                sw->nchannels == nchannels,
  10.561 -                sw->fmt == fmt);
  10.562 -    }
  10.563 -
  10.564 -    if (nchannels != 1 && nchannels != 2) {
  10.565 -        dolog ("Bogus channel count %d for voice %s\n", nchannels, name);
  10.566 -        return NULL;
  10.567 -    }
  10.568 -
  10.569 -    if (!audio_state.fixed_format && sw) {
  10.570 -        pcm_sw_fini (sw);
  10.571 -        pcm_hw_del_sw (sw->hw, sw);
  10.572 -        pcm_hw_gc (sw->hw);
  10.573 -        if (sw->name) {
  10.574 -            qemu_free (sw->name);
  10.575 -            sw->name = NULL;
  10.576 -        }
  10.577 -        qemu_free (sw);
  10.578 -        sw = NULL;
  10.579 -    }
  10.580 -
  10.581 -    if (sw) {
  10.582 -        HWVoice *hw = sw->hw;
  10.583 -        if (!hw) {
  10.584 -            dolog ("Internal logic error voice %s has no hardware store\n",
  10.585 -                   name);
  10.586 -            return sw;
  10.587 -        }
  10.588 -
  10.589 -        if (pcm_sw_init (sw, hw, freq, nchannels, fmt)) {
  10.590 -            pcm_sw_fini (sw);
  10.591 -            pcm_hw_del_sw (hw, sw);
  10.592 -            pcm_hw_gc (hw);
  10.593 -            if (sw->name) {
  10.594 -                qemu_free (sw->name);
  10.595 -                sw->name = NULL;
  10.596 -            }
  10.597 -            qemu_free (sw);
  10.598 -            return NULL;
  10.599 -        }
  10.600 -    }
  10.601 -    else {
  10.602 -        sw = pcm_create_voice_pair (freq, nchannels, fmt);
  10.603 -        if (!sw) {
  10.604 -            dolog ("Failed to create voice %s\n", name);
  10.605 -            return NULL;
  10.606 -        }
  10.607 -    }
  10.608 -
  10.609 -    if (sw->name) {
  10.610 -        qemu_free (sw->name);
  10.611 -        sw->name = NULL;
  10.612 -    }
  10.613 -    sw->name = qemu_strdup (name);
  10.614 -    return sw;
  10.615 -}
  10.616 -
  10.617 -void AUD_close (SWVoice *sw)
  10.618 -{
  10.619 -    if (!sw)
  10.620 -        return;
  10.621 -
  10.622 -    pcm_sw_fini (sw);
  10.623 -    pcm_hw_del_sw (sw->hw, sw);
  10.624 -    pcm_hw_gc (sw->hw);
  10.625 -    if (sw->name) {
  10.626 -        qemu_free (sw->name);
  10.627 -        sw->name = NULL;
  10.628 -    }
  10.629 -    qemu_free (sw);
  10.630 -}
  10.631 -
  10.632 -int AUD_write (SWVoice *sw, void *buf, int size)
  10.633 -{
  10.634 -    int bytes;
  10.635 -
  10.636 -    if (!sw->hw->enabled)
  10.637 -        dolog ("Writing to disabled voice %s\n", sw->name);
  10.638 -    bytes = sw->hw->pcm_ops->write (sw, buf, size);
  10.639 -    return bytes;
  10.640 -}
  10.641 -
  10.642 -void AUD_run (void)
  10.643 -{
  10.644 -    HWVoice *hw = NULL;
  10.645 -
  10.646 -    while ((hw = pcm_hw_find_any_active_enabled (hw))) {
  10.647 -        int i;
  10.648 -        if (hw->pending_disable && pcm_hw_get_live (hw) <= 0) {
  10.649 -            hw->enabled = 0;
  10.650 -            hw->pcm_ops->ctl (hw, VOICE_DISABLE);
  10.651 -            for (i = 0; i < hw->nb_voices; i++) {
  10.652 -                hw->pvoice[i]->live = 0;
  10.653 -                /* hw->pvoice[i]->old_ticks = 0; */
  10.654 -            }
  10.655 -            continue;
  10.656 -        }
  10.657 -
  10.658 -        hw->pcm_ops->run (hw);
  10.659 -        assert (hw->rpos < hw->samples);
  10.660 -        for (i = 0; i < hw->nb_voices; i++) {
  10.661 -            SWVoice *sw = hw->pvoice[i];
  10.662 -            if (!sw->active && !sw->live && sw->old_ticks) {
  10.663 -                int64_t delta = qemu_get_clock (vm_clock) - sw->old_ticks;
  10.664 -                if (delta > audio_state.ticks_threshold) {
  10.665 -                    ldebug ("resetting old_ticks for %s\n", sw->name);
  10.666 -                    sw->old_ticks = 0;
  10.667 -                }
  10.668 -            }
  10.669 -        }
  10.670 -    }
  10.671 -}
  10.672 -
  10.673 -int AUD_get_free (SWVoice *sw)
  10.674 -{
  10.675 -    int free;
  10.676 -
  10.677 -    if (!sw)
  10.678 -        return 4096;
  10.679 -
  10.680 -    free = ((sw->hw->samples - sw->live) << sw->hw->shift) * sw->ratio
  10.681 -        / INT_MAX;
  10.682 -
  10.683 -    free &= ~sw->hw->align;
  10.684 -    if (!free) return 0;
  10.685 -
  10.686 -    return free;
  10.687 -}
  10.688 -
  10.689 -int AUD_get_buffer_size (SWVoice *sw)
  10.690 -{
  10.691 -    return sw->hw->bufsize;
  10.692 -}
  10.693 -
  10.694 -void AUD_adjust (SWVoice *sw, int bytes)
  10.695 -{
  10.696 -    if (!sw)
  10.697 -        return;
  10.698 -    sw->old_ticks += (ticks_per_sec * (int64_t) bytes) / sw->bytes_per_second;
  10.699 -}
  10.700 -
  10.701 -void AUD_reset (SWVoice *sw)
  10.702 -{
  10.703 -    sw->active = 0;
  10.704 -    sw->old_ticks = 0;
  10.705 -}
  10.706 -
  10.707 -int AUD_calc_elapsed (SWVoice *sw)
  10.708 -{
  10.709 -    int64_t now, delta, bytes;
  10.710 -    int dead, swlim;
  10.711 -
  10.712 -    if (!sw)
  10.713 -        return 0;
  10.714 -
  10.715 -    now = qemu_get_clock (vm_clock);
  10.716 -    delta = now - sw->old_ticks;
  10.717 -    bytes = (delta * sw->bytes_per_second) / ticks_per_sec;
  10.718 -    if (delta < 0) {
  10.719 -        dolog ("whoops delta(<0)=%"PRId64"\n", delta);
  10.720 -        return 0;
  10.721 -    }
  10.722 -
  10.723 -    dead = sw->hw->samples - sw->live;
  10.724 -    swlim = ((dead * (int64_t) INT_MAX) / sw->ratio);
  10.725 -
  10.726 -    if (bytes > swlim) {
  10.727 -        return swlim;
  10.728 -    }
  10.729 -    else {
  10.730 -        return bytes;
  10.731 -    }
  10.732 -}
  10.733 -
  10.734 -void AUD_enable (SWVoice *sw, int on)
  10.735 -{
  10.736 -    int i;
  10.737 -    HWVoice *hw;
  10.738 -
  10.739 -    if (!sw)
  10.740 -        return;
  10.741 -
  10.742 -    hw = sw->hw;
  10.743 -    if (on) {
  10.744 -        if (!sw->live)
  10.745 -            sw->wpos = sw->hw->rpos;
  10.746 -        if (!sw->old_ticks) {
  10.747 -            sw->old_ticks = qemu_get_clock (vm_clock);
  10.748 -        }
  10.749 -    }
  10.750 -
  10.751 -    if (sw->active != on) {
  10.752 -        if (on) {
  10.753 -            hw->pending_disable = 0;
  10.754 -            if (!hw->enabled) {
  10.755 -                hw->enabled = 1;
  10.756 -                for (i = 0; i < hw->nb_voices; i++) {
  10.757 -                    ldebug ("resetting voice\n");
  10.758 -                    sw = hw->pvoice[i];
  10.759 -                    sw->old_ticks = qemu_get_clock (vm_clock);
  10.760 -                }
  10.761 -                hw->pcm_ops->ctl (hw, VOICE_ENABLE);
  10.762 -            }
  10.763 -        }
  10.764 -        else {
  10.765 -            if (hw->enabled && !hw->pending_disable) {
  10.766 -                int nb_active = 0;
  10.767 -                for (i = 0; i < hw->nb_voices; i++) {
  10.768 -                    nb_active += hw->pvoice[i]->active != 0;
  10.769 -                }
  10.770 -
  10.771 -                if (nb_active == 1) {
  10.772 -                    hw->pending_disable = 1;
  10.773 -                }
  10.774 -            }
  10.775 -        }
  10.776 -        sw->active = on;
  10.777 -    }
  10.778 -}
  10.779 -
  10.780 -static struct audio_output_driver *drvtab[] = {
  10.781 -#ifdef CONFIG_OSS
  10.782 -    &oss_output_driver,
  10.783 -#endif
  10.784 -#ifdef CONFIG_FMOD
  10.785 -    &fmod_output_driver,
  10.786 -#endif
  10.787 -#ifdef CONFIG_SDL
  10.788 -    &sdl_output_driver,
  10.789 -#endif
  10.790 -    &no_output_driver,
  10.791 -#ifdef USE_WAV_AUDIO
  10.792 -    &wav_output_driver,
  10.793 -#endif
  10.794 -};
  10.795 -
  10.796 -static int voice_init (struct audio_output_driver *drv)
  10.797 -{
  10.798 -    audio_state.opaque = drv->init ();
  10.799 -    if (audio_state.opaque) {
  10.800 -        if (audio_state.nb_hw_voices > drv->max_voices) {
  10.801 -            dolog ("`%s' does not support %d multiple hardware channels\n"
  10.802 -                   "Resetting to %d\n",
  10.803 -                   drv->name, audio_state.nb_hw_voices, drv->max_voices);
  10.804 -            audio_state.nb_hw_voices = drv->max_voices;
  10.805 -        }
  10.806 -        hw_voices = qemu_mallocz (audio_state.nb_hw_voices * drv->voice_size);
  10.807 -        if (hw_voices) {
  10.808 -            audio_state.drv = drv;
  10.809 -            return 1;
  10.810 -        }
  10.811 -        else {
  10.812 -            dolog ("Not enough memory for %d `%s' voices (each %d bytes)\n",
  10.813 -                   audio_state.nb_hw_voices, drv->name, drv->voice_size);
  10.814 -            drv->fini (audio_state.opaque);
  10.815 -            return 0;
  10.816 -        }
  10.817 -    }
  10.818 -    else {
  10.819 -        dolog ("Could not init `%s' audio\n", drv->name);
  10.820 -        return 0;
  10.821 -    }
  10.822 -}
  10.823 -
  10.824 -static void audio_vm_stop_handler (void *opaque, int reason)
  10.825 -{
  10.826 -    HWVoice *hw = NULL;
  10.827 -
  10.828 -    while ((hw = pcm_hw_find_any (hw))) {
  10.829 -        if (!hw->pcm_ops)
  10.830 -            continue;
  10.831 -
  10.832 -        hw->pcm_ops->ctl (hw, reason ? VOICE_ENABLE : VOICE_DISABLE);
  10.833 -    }
  10.834 -}
  10.835 -
  10.836 -static void audio_atexit (void)
  10.837 -{
  10.838 -    HWVoice *hw = NULL;
  10.839 -
  10.840 -    while ((hw = pcm_hw_find_any (hw))) {
  10.841 -        if (!hw->pcm_ops)
  10.842 -            continue;
  10.843 -
  10.844 -        hw->pcm_ops->ctl (hw, VOICE_DISABLE);
  10.845 -        hw->pcm_ops->fini (hw);
  10.846 -    }
  10.847 -    audio_state.drv->fini (audio_state.opaque);
  10.848 -}
  10.849 -
  10.850 -static void audio_save (QEMUFile *f, void *opaque)
  10.851 -{
  10.852 -}
  10.853 -
  10.854 -static int audio_load (QEMUFile *f, void *opaque, int version_id)
  10.855 -{
  10.856 -    if (version_id != 1)
  10.857 -        return -EINVAL;
  10.858 -
  10.859 -    return 0;
  10.860 -}
  10.861 -
  10.862 -void AUD_init (void)
  10.863 -{
  10.864 -    int i;
  10.865 -    int done = 0;
  10.866 -    const char *drvname;
  10.867 -
  10.868 -    audio_state.fixed_format =
  10.869 -        !!audio_get_conf_int (QC_FIXED_FORMAT, audio_state.fixed_format);
  10.870 -    audio_state.fixed_freq =
  10.871 -        audio_get_conf_int (QC_FIXED_FREQ, audio_state.fixed_freq);
  10.872 -    audio_state.nb_hw_voices =
  10.873 -        audio_get_conf_int (QC_VOICES, audio_state.nb_hw_voices);
  10.874 -
  10.875 -    if (audio_state.nb_hw_voices <= 0) {
  10.876 -        dolog ("Bogus number of voices %d, resetting to 1\n",
  10.877 -               audio_state.nb_hw_voices);
  10.878 -    }
  10.879 -
  10.880 -    drvname = audio_get_conf_str (QC_AUDIO_DRV, NULL);
  10.881 -    if (drvname) {
  10.882 -        int found = 0;
  10.883 -        for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
  10.884 -            if (!strcmp (drvname, drvtab[i]->name)) {
  10.885 -                done = voice_init (drvtab[i]);
  10.886 -                found = 1;
  10.887 -                break;
  10.888 -            }
  10.889 -        }
  10.890 -        if (!found) {
  10.891 -            dolog ("Unknown audio driver `%s'\n", drvname);
  10.892 -        }
  10.893 -    }
  10.894 -
  10.895 -    qemu_add_vm_stop_handler (audio_vm_stop_handler, NULL);
  10.896 -    atexit (audio_atexit);
  10.897 -
  10.898 -    if (!done) {
  10.899 -        for (i = 0; !done && i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
  10.900 -            if (drvtab[i]->can_be_default)
  10.901 -                done = voice_init (drvtab[i]);
  10.902 -        }
  10.903 -    }
  10.904 -
  10.905 -    audio_state.ticks_threshold = ticks_per_sec / 50;
  10.906 -    audio_state.freq_threshold = 100;
  10.907 -
  10.908 -    register_savevm ("audio", 0, 1, audio_save, audio_load, NULL);
  10.909 -    if (!done) {
  10.910 -        dolog ("Can not initialize audio subsystem\n");
  10.911 -        voice_init (&no_output_driver);
  10.912 -    }
  10.913 -}
    11.1 --- a/tools/ioemu/audio/audio.h	Wed Jul 12 16:34:39 2006 +0100
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,65 +0,0 @@
    11.4 -/*
    11.5 - * QEMU Audio subsystem header
    11.6 - * 
    11.7 - * Copyright (c) 2003-2004 Vassili Karpov (malc)
    11.8 - * 
    11.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   11.10 - * of this software and associated documentation files (the "Software"), to deal
   11.11 - * in the Software without restriction, including without limitation the rights
   11.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   11.13 - * copies of the Software, and to permit persons to whom the Software is
   11.14 - * furnished to do so, subject to the following conditions:
   11.15 - *
   11.16 - * The above copyright notice and this permission notice shall be included in
   11.17 - * all copies or substantial portions of the Software.
   11.18 - *
   11.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   11.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   11.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   11.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   11.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   11.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   11.25 - * THE SOFTWARE.
   11.26 - */
   11.27 -#ifndef QEMU_AUDIO_H
   11.28 -#define QEMU_AUDIO_H
   11.29 -
   11.30 -#include "mixeng.h"
   11.31 -
   11.32 -typedef enum {
   11.33 -  AUD_FMT_U8,
   11.34 -  AUD_FMT_S8,
   11.35 -  AUD_FMT_U16,
   11.36 -  AUD_FMT_S16
   11.37 -} audfmt_e;
   11.38 -
   11.39 -typedef struct SWVoice SWVoice;
   11.40 -
   11.41 -SWVoice * AUD_open (SWVoice *sw, const char *name, int freq,
   11.42 -                    int nchannels, audfmt_e fmt);
   11.43 -void   AUD_init (void);
   11.44 -void   AUD_log (const char *cap, const char *fmt, ...)
   11.45 -    __attribute__ ((__format__ (__printf__, 2, 3)));;
   11.46 -void   AUD_close (SWVoice *sw);
   11.47 -int    AUD_write (SWVoice *sw, void *pcm_buf, int size);
   11.48 -void   AUD_adjust (SWVoice *sw, int leftover);
   11.49 -void   AUD_reset (SWVoice *sw);
   11.50 -int    AUD_get_free (SWVoice *sw);
   11.51 -int    AUD_get_buffer_size (SWVoice *sw);
   11.52 -void   AUD_run (void);
   11.53 -void   AUD_enable (SWVoice *sw, int on);
   11.54 -int    AUD_calc_elapsed (SWVoice *sw);
   11.55 -
   11.56 -static inline void *advance (void *p, int incr)
   11.57 -{
   11.58 -    uint8_t *d = p;
   11.59 -    return (d + incr);
   11.60 -}
   11.61 -
   11.62 -uint32_t popcount (uint32_t u);
   11.63 -inline uint32_t lsbindex (uint32_t u);
   11.64 -
   11.65 -#define audio_MIN(a, b) ((a)>(b)?(b):(a))
   11.66 -#define audio_MAX(a, b) ((a)<(b)?(b):(a))
   11.67 -
   11.68 -#endif  /* audio.h */
    12.1 --- a/tools/ioemu/audio/audio_int.h	Wed Jul 12 16:34:39 2006 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,164 +0,0 @@
    12.4 -/*
    12.5 - * QEMU Audio subsystem header
    12.6 - * 
    12.7 - * Copyright (c) 2003-2004 Vassili Karpov (malc)
    12.8 - * 
    12.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   12.10 - * of this software and associated documentation files (the "Software"), to deal
   12.11 - * in the Software without restriction, including without limitation the rights
   12.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   12.13 - * copies of the Software, and to permit persons to whom the Software is
   12.14 - * furnished to do so, subject to the following conditions:
   12.15 - *
   12.16 - * The above copyright notice and this permission notice shall be included in
   12.17 - * all copies or substantial portions of the Software.
   12.18 - *
   12.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   12.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   12.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   12.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   12.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   12.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   12.25 - * THE SOFTWARE.
   12.26 - */
   12.27 -#ifndef QEMU_AUDIO_INT_H
   12.28 -#define QEMU_AUDIO_INT_H
   12.29 -
   12.30 -#include "vl.h"
   12.31 -
   12.32 -struct pcm_ops;
   12.33 -
   12.34 -typedef struct HWVoice {
   12.35 -    int active;
   12.36 -    int enabled;
   12.37 -    int pending_disable;
   12.38 -    int valid;
   12.39 -    int freq;
   12.40 -
   12.41 -    f_sample *clip;
   12.42 -    audfmt_e fmt;
   12.43 -    int nchannels;
   12.44 -
   12.45 -    int align;
   12.46 -    int shift;
   12.47 -
   12.48 -    int rpos;
   12.49 -    int bufsize;
   12.50 -
   12.51 -    int bytes_per_second;
   12.52 -    st_sample_t *mix_buf;
   12.53 -
   12.54 -    int samples;
   12.55 -    int64_t old_ticks;
   12.56 -    int nb_voices;
   12.57 -    struct SWVoice **pvoice;
   12.58 -    struct pcm_ops *pcm_ops;
   12.59 -} HWVoice;
   12.60 -
   12.61 -extern struct pcm_ops no_pcm_ops;
   12.62 -extern struct audio_output_driver no_output_driver;
   12.63 -
   12.64 -extern struct pcm_ops oss_pcm_ops;
   12.65 -extern struct audio_output_driver oss_output_driver;
   12.66 -
   12.67 -extern struct pcm_ops sdl_pcm_ops;
   12.68 -extern struct audio_output_driver sdl_output_driver;
   12.69 -
   12.70 -extern struct pcm_ops wav_pcm_ops;
   12.71 -extern struct audio_output_driver wav_output_driver;
   12.72 -
   12.73 -extern struct pcm_ops fmod_pcm_ops;
   12.74 -extern struct audio_output_driver fmod_output_driver;
   12.75 -
   12.76 -struct audio_output_driver {
   12.77 -    const char *name;
   12.78 -    void *(*init) (void);
   12.79 -    void (*fini) (void *);
   12.80 -    struct pcm_ops *pcm_ops;
   12.81 -    int can_be_default;
   12.82 -    int max_voices;
   12.83 -    int voice_size;
   12.84 -};
   12.85 -
   12.86 -typedef struct AudioState {
   12.87 -    int fixed_format;
   12.88 -    int fixed_freq;
   12.89 -    int fixed_channels;
   12.90 -    int fixed_fmt;
   12.91 -    int nb_hw_voices;
   12.92 -    int voice_size;
   12.93 -    int64_t ticks_threshold;
   12.94 -    int freq_threshold;
   12.95 -    void *opaque;
   12.96 -    struct audio_output_driver *drv;
   12.97 -} AudioState;
   12.98 -extern AudioState audio_state;
   12.99 -
  12.100 -struct SWVoice {
  12.101 -    int freq;
  12.102 -    audfmt_e fmt;
  12.103 -    int nchannels;
  12.104 -
  12.105 -    int shift;
  12.106 -    int align;
  12.107 -
  12.108 -    t_sample *conv;
  12.109 -
  12.110 -    int left;
  12.111 -    int pos;
  12.112 -    int bytes_per_second;
  12.113 -    int64_t ratio;
  12.114 -    st_sample_t *buf;
  12.115 -    void *rate;
  12.116 -
  12.117 -    int wpos;
  12.118 -    int live;
  12.119 -    int active;
  12.120 -    int64_t old_ticks;
  12.121 -    HWVoice *hw;
  12.122 -    char *name;
  12.123 -};
  12.124 -
  12.125 -struct pcm_ops {
  12.126 -    int  (*init)  (HWVoice *hw, int freq, int nchannels, audfmt_e fmt);
  12.127 -    void (*fini)  (HWVoice *hw);
  12.128 -    void (*run)   (HWVoice *hw);
  12.129 -    int  (*write) (SWVoice *sw, void *buf, int size);
  12.130 -    int  (*ctl)   (HWVoice *hw, int cmd, ...);
  12.131 -};
  12.132 -
  12.133 -void      pcm_sw_free_resources (SWVoice *sw);
  12.134 -int       pcm_sw_alloc_resources (SWVoice *sw);
  12.135 -void      pcm_sw_fini (SWVoice *sw);
  12.136 -int       pcm_sw_init (SWVoice *sw, HWVoice *hw, int freq,
  12.137 -                       int nchannels, audfmt_e fmt);
  12.138 -
  12.139 -void      pcm_hw_clear (HWVoice *hw, void *buf, int len);
  12.140 -HWVoice * pcm_hw_find_any (HWVoice *hw);
  12.141 -HWVoice * pcm_hw_find_any_active (HWVoice *hw);
  12.142 -HWVoice * pcm_hw_find_any_passive (HWVoice *hw);
  12.143 -HWVoice * pcm_hw_find_specific (HWVoice *hw, int freq,
  12.144 -                                int nchannels, audfmt_e fmt);
  12.145 -HWVoice * pcm_hw_add (int freq, int nchannels, audfmt_e fmt);
  12.146 -int       pcm_hw_add_sw (HWVoice *hw, SWVoice *sw);
  12.147 -int       pcm_hw_del_sw (HWVoice *hw, SWVoice *sw);
  12.148 -SWVoice * pcm_create_voice_pair (int freq, int nchannels, audfmt_e fmt);
  12.149 -
  12.150 -void      pcm_hw_free_resources (HWVoice *hw);
  12.151 -int       pcm_hw_alloc_resources (HWVoice *hw);
  12.152 -void      pcm_hw_fini (HWVoice *hw);
  12.153 -void      pcm_hw_gc (HWVoice *hw);
  12.154 -int       pcm_hw_get_live (HWVoice *hw);
  12.155 -int       pcm_hw_get_live2 (HWVoice *hw, int *nb_active);
  12.156 -void      pcm_hw_dec_live (HWVoice *hw, int decr);
  12.157 -int       pcm_hw_write (SWVoice *sw, void *buf, int len);
  12.158 -
  12.159 -int         audio_get_conf_int (const char *key, int defval);
  12.160 -const char *audio_get_conf_str (const char *key, const char *defval);
  12.161 -
  12.162 -struct audio_output_driver;
  12.163 -
  12.164 -#define VOICE_ENABLE 1
  12.165 -#define VOICE_DISABLE 2
  12.166 -
  12.167 -#endif /* audio_int.h */
    13.1 --- a/tools/ioemu/audio/mixeng.c	Wed Jul 12 16:34:39 2006 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,255 +0,0 @@
    13.4 -/*
    13.5 - * QEMU Mixing engine
    13.6 - *
    13.7 - * Copyright (c) 2004 Vassili Karpov (malc)
    13.8 - * Copyright (c) 1998 Fabrice Bellard
    13.9 - *
   13.10 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   13.11 - * of this software and associated documentation files (the "Software"), to deal
   13.12 - * in the Software without restriction, including without limitation the rights
   13.13 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   13.14 - * copies of the Software, and to permit persons to whom the Software is
   13.15 - * furnished to do so, subject to the following conditions:
   13.16 - *
   13.17 - * The above copyright notice and this permission notice shall be included in
   13.18 - * all copies or substantial portions of the Software.
   13.19 - *
   13.20 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   13.21 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   13.22 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   13.23 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   13.24 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   13.25 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   13.26 - * THE SOFTWARE.
   13.27 - */
   13.28 -#include "vl.h"
   13.29 -//#define DEBUG_FP
   13.30 -#include "audio/mixeng.h"
   13.31 -
   13.32 -#define IN_T int8_t
   13.33 -#define IN_MIN CHAR_MIN
   13.34 -#define IN_MAX CHAR_MAX
   13.35 -#define SIGNED
   13.36 -#include "mixeng_template.h"
   13.37 -#undef SIGNED
   13.38 -#undef IN_MAX
   13.39 -#undef IN_MIN
   13.40 -#undef IN_T
   13.41 -
   13.42 -#define IN_T uint8_t
   13.43 -#define IN_MIN 0
   13.44 -#define IN_MAX UCHAR_MAX
   13.45 -#include "mixeng_template.h"
   13.46 -#undef IN_MAX
   13.47 -#undef IN_MIN
   13.48 -#undef IN_T
   13.49 -
   13.50 -#define IN_T int16_t
   13.51 -#define IN_MIN SHRT_MIN
   13.52 -#define IN_MAX SHRT_MAX
   13.53 -#define SIGNED
   13.54 -#include "mixeng_template.h"
   13.55 -#undef SIGNED
   13.56 -#undef IN_MAX
   13.57 -#undef IN_MIN
   13.58 -#undef IN_T
   13.59 -
   13.60 -#define IN_T uint16_t
   13.61 -#define IN_MIN 0
   13.62 -#define IN_MAX USHRT_MAX
   13.63 -#include "mixeng_template.h"
   13.64 -#undef IN_MAX
   13.65 -#undef IN_MIN
   13.66 -#undef IN_T
   13.67 -
   13.68 -t_sample *mixeng_conv[2][2][2] = {
   13.69 -    {
   13.70 -        {
   13.71 -            conv_uint8_t_to_mono,
   13.72 -            conv_uint16_t_to_mono
   13.73 -        },
   13.74 -        {
   13.75 -            conv_int8_t_to_mono,
   13.76 -            conv_int16_t_to_mono
   13.77 -        }
   13.78 -    },
   13.79 -    {
   13.80 -        {
   13.81 -            conv_uint8_t_to_stereo,
   13.82 -            conv_uint16_t_to_stereo
   13.83 -        },
   13.84 -        {
   13.85 -            conv_int8_t_to_stereo,
   13.86 -            conv_int16_t_to_stereo
   13.87 -        }
   13.88 -    }
   13.89 -};
   13.90 -
   13.91 -f_sample *mixeng_clip[2][2][2] = {
   13.92 -    {
   13.93 -        {
   13.94 -            clip_uint8_t_from_mono,
   13.95 -            clip_uint16_t_from_mono
   13.96 -        },
   13.97 -        {
   13.98 -            clip_int8_t_from_mono,
   13.99 -            clip_int16_t_from_mono
  13.100 -        }
  13.101 -    },
  13.102 -    {
  13.103 -        {
  13.104 -            clip_uint8_t_from_stereo,
  13.105 -            clip_uint16_t_from_stereo
  13.106 -        },
  13.107 -        {
  13.108 -            clip_int8_t_from_stereo,
  13.109 -            clip_int16_t_from_stereo
  13.110 -        }
  13.111 -    }
  13.112 -};
  13.113 -
  13.114 -/*
  13.115 - * August 21, 1998
  13.116 - * Copyright 1998 Fabrice Bellard.
  13.117 - *
  13.118 - * [Rewrote completly the code of Lance Norskog And Sundry
  13.119 - * Contributors with a more efficient algorithm.]
  13.120 - *
  13.121 - * This source code is freely redistributable and may be used for
  13.122 - * any purpose.  This copyright notice must be maintained. 
  13.123 - * Lance Norskog And Sundry Contributors are not responsible for 
  13.124 - * the consequences of using this software.  
  13.125 - */
  13.126 -
  13.127 -/*
  13.128 - * Sound Tools rate change effect file.
  13.129 - */
  13.130 -/*
  13.131 - * Linear Interpolation.
  13.132 - *
  13.133 - * The use of fractional increment allows us to use no buffer. It
  13.134 - * avoid the problems at the end of the buffer we had with the old
  13.135 - * method which stored a possibly big buffer of size
  13.136 - * lcm(in_rate,out_rate).
  13.137 - *
  13.138 - * Limited to 16 bit samples and sampling frequency <= 65535 Hz. If
  13.139 - * the input & output frequencies are equal, a delay of one sample is
  13.140 - * introduced.  Limited to processing 32-bit count worth of samples.
  13.141 - *
  13.142 - * 1 << FRAC_BITS evaluating to zero in several places.  Changed with
  13.143 - * an (unsigned long) cast to make it safe.  MarkMLl 2/1/99
  13.144 - */
  13.145 -
  13.146 -/* Private data */
  13.147 -typedef struct ratestuff {
  13.148 -    uint64_t opos;
  13.149 -    uint64_t opos_inc;
  13.150 -    uint32_t ipos;              /* position in the input stream (integer) */
  13.151 -    st_sample_t ilast;          /* last sample in the input stream */
  13.152 -} *rate_t;
  13.153 -
  13.154 -/*
  13.155 - * Prepare processing.
  13.156 - */
  13.157 -void *st_rate_start (int inrate, int outrate)
  13.158 -{
  13.159 -    rate_t rate = (rate_t) qemu_mallocz (sizeof (struct ratestuff));
  13.160 -
  13.161 -    if (!rate) {
  13.162 -        exit (EXIT_FAILURE);
  13.163 -    }
  13.164 -
  13.165 -    if (inrate == outrate) {
  13.166 -        // exit (EXIT_FAILURE);
  13.167 -    }
  13.168 -
  13.169 -    if (inrate >= 65535 || outrate >= 65535) {
  13.170 -        // exit (EXIT_FAILURE);
  13.171 -    }
  13.172 -
  13.173 -    rate->opos = 0;
  13.174 -
  13.175 -    /* increment */
  13.176 -    rate->opos_inc = (inrate * ((int64_t) UINT_MAX)) / outrate;
  13.177 -
  13.178 -    rate->ipos = 0;
  13.179 -    rate->ilast.l = 0;
  13.180 -    rate->ilast.r = 0;
  13.181 -    return rate;
  13.182 -}
  13.183 -
  13.184 -/*
  13.185 - * Processed signed long samples from ibuf to obuf.
  13.186 - * Return number of samples processed.
  13.187 - */
  13.188 -void st_rate_flow (void *opaque, st_sample_t *ibuf, st_sample_t *obuf,
  13.189 -                   int *isamp, int *osamp)
  13.190 -{
  13.191 -    rate_t rate = (rate_t) opaque;
  13.192 -    st_sample_t *istart, *iend;
  13.193 -    st_sample_t *ostart, *oend;
  13.194 -    st_sample_t ilast, icur, out;
  13.195 -    int64_t t;
  13.196 -
  13.197 -    ilast = rate->ilast;
  13.198 -
  13.199 -    istart = ibuf;
  13.200 -    iend = ibuf + *isamp;
  13.201 -
  13.202 -    ostart = obuf;
  13.203 -    oend = obuf + *osamp;
  13.204 -
  13.205 -    if (rate->opos_inc == 1ULL << 32) {
  13.206 -        int i, n = *isamp > *osamp ? *osamp : *isamp;
  13.207 -        for (i = 0; i < n; i++) {
  13.208 -            obuf[i].l += ibuf[i].r;
  13.209 -            obuf[i].r += ibuf[i].r;
  13.210 -        }
  13.211 -        *isamp = n;
  13.212 -        *osamp = n;
  13.213 -        return;
  13.214 -    }
  13.215 -
  13.216 -    while (obuf < oend) {
  13.217 -
  13.218 -        /* Safety catch to make sure we have input samples.  */
  13.219 -        if (ibuf >= iend)
  13.220 -            break;
  13.221 -
  13.222 -        /* read as many input samples so that ipos > opos */
  13.223 -
  13.224 -        while (rate->ipos <= (rate->opos >> 32)) {
  13.225 -            ilast = *ibuf++;
  13.226 -            rate->ipos++;
  13.227 -            /* See if we finished the input buffer yet */
  13.228 -            if (ibuf >= iend) goto the_end;
  13.229 -        }
  13.230 -
  13.231 -        icur = *ibuf;
  13.232 -
  13.233 -        /* interpolate */
  13.234 -        t = rate->opos & 0xffffffff;
  13.235 -        out.l = (ilast.l * (INT_MAX - t) + icur.l * t) / INT_MAX;
  13.236 -        out.r = (ilast.r * (INT_MAX - t) + icur.r * t) / INT_MAX;
  13.237 -
  13.238 -        /* output sample & increment position */
  13.239 -#if 0
  13.240 -        *obuf++ = out;
  13.241 -#else
  13.242 -        obuf->l += out.l;
  13.243 -        obuf->r += out.r;
  13.244 -        obuf += 1;
  13.245 -#endif
  13.246 -        rate->opos += rate->opos_inc;
  13.247 -    }
  13.248 -
  13.249 -the_end:
  13.250 -    *isamp = ibuf - istart;
  13.251 -    *osamp = obuf - ostart;
  13.252 -    rate->ilast = ilast;
  13.253 -}
  13.254 -
  13.255 -void st_rate_stop (void *opaque)
  13.256 -{
  13.257 -    qemu_free (opaque);
  13.258 -}
    14.1 --- a/tools/ioemu/audio/mixeng.h	Wed Jul 12 16:34:39 2006 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,39 +0,0 @@
    14.4 -/*
    14.5 - * QEMU Mixing engine header
    14.6 - * 
    14.7 - * Copyright (c) 2004 Vassili Karpov (malc)
    14.8 - * 
    14.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   14.10 - * of this software and associated documentation files (the "Software"), to deal
   14.11 - * in the Software without restriction, including without limitation the rights
   14.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   14.13 - * copies of the Software, and to permit persons to whom the Software is
   14.14 - * furnished to do so, subject to the following conditions:
   14.15 - *
   14.16 - * The above copyright notice and this permission notice shall be included in
   14.17 - * all copies or substantial portions of the Software.
   14.18 - *
   14.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   14.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   14.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   14.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   14.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   14.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   14.25 - * THE SOFTWARE.
   14.26 - */
   14.27 -#ifndef QEMU_MIXENG_H
   14.28 -#define QEMU_MIXENG_H
   14.29 -
   14.30 -typedef void (t_sample) (void *dst, const void *src, int samples);
   14.31 -typedef void (f_sample) (void *dst, const void *src, int samples);
   14.32 -typedef struct { int64_t l; int64_t r; } st_sample_t;
   14.33 -
   14.34 -extern t_sample *mixeng_conv[2][2][2];
   14.35 -extern f_sample *mixeng_clip[2][2][2];
   14.36 -
   14.37 -void *st_rate_start (int inrate, int outrate);
   14.38 -void st_rate_flow (void *opaque, st_sample_t *ibuf, st_sample_t *obuf,
   14.39 -                   int *isamp, int *osamp);
   14.40 -void st_rate_stop (void *opaque);
   14.41 -
   14.42 -#endif  /* mixeng.h */
    15.1 --- a/tools/ioemu/audio/mixeng_template.h	Wed Jul 12 16:34:39 2006 +0100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,111 +0,0 @@
    15.4 -/*
    15.5 - * QEMU Mixing engine
    15.6 - * 
    15.7 - * Copyright (c) 2004 Vassili Karpov (malc)
    15.8 - * 
    15.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   15.10 - * of this software and associated documentation files (the "Software"), to deal
   15.11 - * in the Software without restriction, including without limitation the rights
   15.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   15.13 - * copies of the Software, and to permit persons to whom the Software is
   15.14 - * furnished to do so, subject to the following conditions:
   15.15 - *
   15.16 - * The above copyright notice and this permission notice shall be included in
   15.17 - * all copies or substantial portions of the Software.
   15.18 - *
   15.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   15.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   15.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   15.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   15.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   15.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   15.25 - * THE SOFTWARE.
   15.26 - */
   15.27 -
   15.28 -/*
   15.29 - * Tusen tack till Mike Nordell
   15.30 - * dec++'ified by Dscho
   15.31 - */
   15.32 -
   15.33 -#ifdef SIGNED
   15.34 -#define HALFT IN_MAX
   15.35 -#define HALF IN_MAX
   15.36 -#else
   15.37 -#define HALFT ((IN_MAX)>>1)
   15.38 -#define HALF HALFT
   15.39 -#endif
   15.40 -
   15.41 -static int64_t inline glue(conv_,IN_T) (IN_T v)
   15.42 -{
   15.43 -#ifdef SIGNED
   15.44 -    return (INT_MAX*(int64_t)v)/HALF;
   15.45 -#else
   15.46 -    return (INT_MAX*((int64_t)v-HALFT))/HALF;
   15.47 -#endif
   15.48 -}
   15.49 -
   15.50 -static IN_T inline glue(clip_,IN_T) (int64_t v)
   15.51 -{
   15.52 -    if (v >= INT_MAX)
   15.53 -        return IN_MAX;
   15.54 -    else if (v < -INT_MAX)
   15.55 -        return IN_MIN;
   15.56 -
   15.57 -#ifdef SIGNED
   15.58 -    return (IN_T) (v*HALF/INT_MAX);
   15.59 -#else
   15.60 -    return (IN_T) (v+INT_MAX/2)*HALF/INT_MAX;
   15.61 -#endif
   15.62 -}
   15.63 -
   15.64 -static void glue(glue(conv_,IN_T),_to_stereo) (void *dst, const void *src,
   15.65 -                                               int samples)
   15.66 -{
   15.67 -    st_sample_t *out = (st_sample_t *) dst;
   15.68 -    IN_T *in = (IN_T *) src;
   15.69 -    while (samples--) {
   15.70 -        out->l = glue(conv_,IN_T) (*in++);
   15.71 -        out->r = glue(conv_,IN_T) (*in++);
   15.72 -        out += 1;
   15.73 -    }
   15.74 -}
   15.75 -
   15.76 -static void glue(glue(conv_,IN_T),_to_mono) (void *dst, const void *src,
   15.77 -                                             int samples)
   15.78 -{
   15.79 -    st_sample_t *out = (st_sample_t *) dst;
   15.80 -    IN_T *in = (IN_T *) src;
   15.81 -    while (samples--) {
   15.82 -        out->l = glue(conv_,IN_T) (in[0]);
   15.83 -        out->r = out->l;
   15.84 -        out += 1;
   15.85 -        in += 1;
   15.86 -    }
   15.87 -}
   15.88 -
   15.89 -static void glue(glue(clip_,IN_T),_from_stereo) (void *dst, const void *src,
   15.90 -                                                 int samples)
   15.91 -{
   15.92 -    st_sample_t *in = (st_sample_t *) src;
   15.93 -    IN_T *out = (IN_T *) dst;
   15.94 -    while (samples--) {
   15.95 -        *out++ = glue(clip_,IN_T) (in->l);
   15.96 -        *out++ = glue(clip_,IN_T) (in->r);
   15.97 -        in += 1;
   15.98 -    }
   15.99 -}
  15.100 -
  15.101 -static void glue(glue(clip_,IN_T),_from_mono) (void *dst, const void *src,
  15.102 -                                               int samples)
  15.103 -{
  15.104 -    st_sample_t *in = (st_sample_t *) src;
  15.105 -    IN_T *out = (IN_T *) dst;
  15.106 -    while (samples--) {
  15.107 -        *out++ = glue(clip_,IN_T) (in->l + in->r);
  15.108 -        in += 1;
  15.109 -    }
  15.110 -}
  15.111 -
  15.112 -#undef HALF
  15.113 -#undef HALFT
  15.114 -
    16.1 --- a/tools/ioemu/audio/noaudio.c	Wed Jul 12 16:34:39 2006 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,128 +0,0 @@
    16.4 -/*
    16.5 - * QEMU NULL audio output driver
    16.6 - * 
    16.7 - * Copyright (c) 2004 Vassili Karpov (malc)
    16.8 - * 
    16.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   16.10 - * of this software and associated documentation files (the "Software"), to deal
   16.11 - * in the Software without restriction, including without limitation the rights
   16.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   16.13 - * copies of the Software, and to permit persons to whom the Software is
   16.14 - * furnished to do so, subject to the following conditions:
   16.15 - *
   16.16 - * The above copyright notice and this permission notice shall be included in
   16.17 - * all copies or substantial portions of the Software.
   16.18 - *
   16.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   16.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   16.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   16.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   16.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   16.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   16.25 - * THE SOFTWARE.
   16.26 - */
   16.27 -#include "vl.h"
   16.28 -
   16.29 -#include "audio/audio_int.h"
   16.30 -
   16.31 -typedef struct NoVoice {
   16.32 -    HWVoice hw;
   16.33 -    int64_t old_ticks;
   16.34 -} NoVoice;
   16.35 -
   16.36 -#define dolog(...) AUD_log ("noaudio", __VA_ARGS__)
   16.37 -#ifdef DEBUG
   16.38 -#define ldebug(...) dolog (__VA_ARGS__)
   16.39 -#else
   16.40 -#define ldebug(...)
   16.41 -#endif
   16.42 -
   16.43 -static void no_hw_run (HWVoice *hw)
   16.44 -{
   16.45 -    NoVoice *no = (NoVoice *) hw;
   16.46 -    int rpos, live, decr, samples;
   16.47 -    st_sample_t *src;
   16.48 -    int64_t now = qemu_get_clock (vm_clock);
   16.49 -    int64_t ticks = now - no->old_ticks;
   16.50 -    int64_t bytes = (ticks * hw->bytes_per_second) / ticks_per_sec;
   16.51 -
   16.52 -    if (bytes > INT_MAX)
   16.53 -        samples = INT_MAX >> hw->shift;
   16.54 -    else
   16.55 -        samples = bytes >> hw->shift;
   16.56 -
   16.57 -    live = pcm_hw_get_live (hw);
   16.58 -    if (live <= 0)
   16.59 -        return;
   16.60 -
   16.61 -    no->old_ticks = now;
   16.62 -    decr = audio_MIN (live, samples);
   16.63 -    samples = decr;
   16.64 -    rpos = hw->rpos;
   16.65 -    while (samples) {
   16.66 -        int left_till_end_samples = hw->samples - rpos;
   16.67 -        int convert_samples = audio_MIN (samples, left_till_end_samples);
   16.68 -
   16.69 -        src = advance (hw->mix_buf, rpos * sizeof (st_sample_t));
   16.70 -        memset (src, 0, convert_samples * sizeof (st_sample_t));
   16.71 -
   16.72 -        rpos = (rpos + convert_samples) % hw->samples;
   16.73 -        samples -= convert_samples;
   16.74 -    }
   16.75 -
   16.76 -    pcm_hw_dec_live (hw, decr);
   16.77 -    hw->rpos = rpos;
   16.78 -}
   16.79 -
   16.80 -static int no_hw_write (SWVoice *sw, void *buf, int len)
   16.81 -{
   16.82 -    return pcm_hw_write (sw, buf, len);
   16.83 -}
   16.84 -
   16.85 -static int no_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
   16.86 -{
   16.87 -    hw->freq = freq;
   16.88 -    hw->nchannels = nchannels;
   16.89 -    hw->fmt = fmt;
   16.90 -    hw->bufsize = 4096;
   16.91 -    return 0;
   16.92 -}
   16.93 -
   16.94 -static void no_hw_fini (HWVoice *hw)
   16.95 -{
   16.96 -    (void) hw;
   16.97 -}
   16.98 -
   16.99 -static int no_hw_ctl (HWVoice *hw, int cmd, ...)
  16.100 -{
  16.101 -    (void) hw;
  16.102 -    (void) cmd;
  16.103 -    return 0;
  16.104 -}
  16.105 -
  16.106 -static void *no_audio_init (void)
  16.107 -{
  16.108 -    return &no_audio_init;
  16.109 -}
  16.110 -
  16.111 -static void no_audio_fini (void *opaque)
  16.112 -{
  16.113 -}
  16.114 -
  16.115 -struct pcm_ops no_pcm_ops = {
  16.116 -    no_hw_init,
  16.117 -    no_hw_fini,
  16.118 -    no_hw_run,
  16.119 -    no_hw_write,
  16.120 -    no_hw_ctl
  16.121 -};
  16.122 -
  16.123 -struct audio_output_driver no_output_driver = {
  16.124 -    "none",
  16.125 -    no_audio_init,
  16.126 -    no_audio_fini,
  16.127 -    &no_pcm_ops,
  16.128 -    1,
  16.129 -    1,
  16.130 -    sizeof (NoVoice)
  16.131 -};
    17.1 --- a/tools/ioemu/audio/ossaudio.c	Wed Jul 12 16:34:39 2006 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,475 +0,0 @@
    17.4 -/*
    17.5 - * QEMU OSS audio output driver
    17.6 - * 
    17.7 - * Copyright (c) 2003-2004 Vassili Karpov (malc)
    17.8 - * 
    17.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   17.10 - * of this software and associated documentation files (the "Software"), to deal
   17.11 - * in the Software without restriction, including without limitation the rights
   17.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   17.13 - * copies of the Software, and to permit persons to whom the Software is
   17.14 - * furnished to do so, subject to the following conditions:
   17.15 - *
   17.16 - * The above copyright notice and this permission notice shall be included in
   17.17 - * all copies or substantial portions of the Software.
   17.18 - *
   17.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   17.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   17.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   17.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   17.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   17.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   17.25 - * THE SOFTWARE.
   17.26 - */
   17.27 -#include <sys/mman.h>
   17.28 -#include <sys/types.h>
   17.29 -#include <sys/ioctl.h>
   17.30 -#include <sys/soundcard.h>
   17.31 -#include <assert.h>
   17.32 -#include "vl.h"
   17.33 -
   17.34 -#include "audio/audio_int.h"
   17.35 -
   17.36 -typedef struct OSSVoice {
   17.37 -    HWVoice hw;
   17.38 -    void *pcm_buf;
   17.39 -    int fd;
   17.40 -    int nfrags;
   17.41 -    int fragsize;
   17.42 -    int mmapped;
   17.43 -    int old_optr;
   17.44 -} OSSVoice;
   17.45 -
   17.46 -#define dolog(...) AUD_log ("oss", __VA_ARGS__)
   17.47 -#ifdef DEBUG
   17.48 -#define ldebug(...) dolog (__VA_ARGS__)
   17.49 -#else
   17.50 -#define ldebug(...)
   17.51 -#endif
   17.52 -
   17.53 -#define QC_OSS_FRAGSIZE "QEMU_OSS_FRAGSIZE"
   17.54 -#define QC_OSS_NFRAGS   "QEMU_OSS_NFRAGS"
   17.55 -#define QC_OSS_MMAP     "QEMU_OSS_MMAP"
   17.56 -#define QC_OSS_DEV      "QEMU_OSS_DEV"
   17.57 -
   17.58 -#define errstr() strerror (errno)
   17.59 -
   17.60 -static struct {
   17.61 -    int try_mmap;
   17.62 -    int nfrags;
   17.63 -    int fragsize;
   17.64 -    const char *dspname;
   17.65 -} conf = {
   17.66 -    .try_mmap = 0,
   17.67 -    .nfrags = 4,
   17.68 -    .fragsize = 4096,
   17.69 -    .dspname = "/dev/dsp"
   17.70 -};
   17.71 -
   17.72 -struct oss_params {
   17.73 -    int freq;
   17.74 -    audfmt_e fmt;
   17.75 -    int nchannels;
   17.76 -    int nfrags;
   17.77 -    int fragsize;
   17.78 -};
   17.79 -
   17.80 -static int oss_hw_write (SWVoice *sw, void *buf, int len)
   17.81 -{
   17.82 -    return pcm_hw_write (sw, buf, len);
   17.83 -}
   17.84 -
   17.85 -static int AUD_to_ossfmt (audfmt_e fmt)
   17.86 -{
   17.87 -    switch (fmt) {
   17.88 -    case AUD_FMT_S8: return AFMT_S8;
   17.89 -    case AUD_FMT_U8: return AFMT_U8;
   17.90 -    case AUD_FMT_S16: return AFMT_S16_LE;
   17.91 -    case AUD_FMT_U16: return AFMT_U16_LE;
   17.92 -    default:
   17.93 -        dolog ("Internal logic error: Bad audio format %d\nAborting\n", fmt);
   17.94 -        exit (EXIT_FAILURE);
   17.95 -    }
   17.96 -}
   17.97 -
   17.98 -static int oss_to_audfmt (int fmt)
   17.99 -{
  17.100 -    switch (fmt) {
  17.101 -    case AFMT_S8: return AUD_FMT_S8;
  17.102 -    case AFMT_U8: return AUD_FMT_U8;
  17.103 -    case AFMT_S16_LE: return AUD_FMT_S16;
  17.104 -    case AFMT_U16_LE: return AUD_FMT_U16;
  17.105 -    default:
  17.106 -        dolog ("Internal logic error: Unrecognized OSS audio format %d\n"
  17.107 -               "Aborting\n",
  17.108 -               fmt);
  17.109 -        exit (EXIT_FAILURE);
  17.110 -    }
  17.111 -}
  17.112 -
  17.113 -#ifdef DEBUG_PCM
  17.114 -static void oss_dump_pcm_info (struct oss_params *req, struct oss_params *obt)
  17.115 -{
  17.116 -    dolog ("parameter | requested value | obtained value\n");
  17.117 -    dolog ("format    |      %10d |     %10d\n", req->fmt, obt->fmt);
  17.118 -    dolog ("channels  |      %10d |     %10d\n", req->nchannels, obt->nchannels);
  17.119 -    dolog ("frequency |      %10d |     %10d\n", req->freq, obt->freq);
  17.120 -    dolog ("nfrags    |      %10d |     %10d\n", req->nfrags, obt->nfrags);
  17.121 -    dolog ("fragsize  |      %10d |     %10d\n", req->fragsize, obt->fragsize);
  17.122 -}
  17.123 -#endif
  17.124 -
  17.125 -static int oss_open (struct oss_params *req, struct oss_params *obt, int *pfd)
  17.126 -{
  17.127 -    int fd;
  17.128 -    int mmmmssss;
  17.129 -    audio_buf_info abinfo;
  17.130 -    int fmt, freq, nchannels;
  17.131 -    const char *dspname = conf.dspname;
  17.132 -
  17.133 -    fd = open (dspname, O_RDWR | O_NONBLOCK);
  17.134 -    if (-1 == fd) {
  17.135 -        dolog ("Could not initialize audio hardware. Failed to open `%s':\n"
  17.136 -               "Reason:%s\n",
  17.137 -               dspname,
  17.138 -               errstr ());
  17.139 -        return -1;
  17.140 -    }
  17.141 -
  17.142 -    freq = req->freq;
  17.143 -    nchannels = req->nchannels;
  17.144 -    fmt = req->fmt;
  17.145 -
  17.146 -    if (ioctl (fd, SNDCTL_DSP_SAMPLESIZE, &fmt)) {
  17.147 -        dolog ("Could not initialize audio hardware\n"
  17.148 -               "Failed to set sample size\n"
  17.149 -               "Reason: %s\n",
  17.150 -               errstr ());
  17.151 -        goto err;
  17.152 -    }
  17.153 -
  17.154 -    if (ioctl (fd, SNDCTL_DSP_CHANNELS, &nchannels)) {
  17.155 -        dolog ("Could not initialize audio hardware\n"
  17.156 -               "Failed to set number of channels\n"
  17.157 -               "Reason: %s\n",
  17.158 -               errstr ());
  17.159 -        goto err;
  17.160 -    }
  17.161 -
  17.162 -    if (ioctl (fd, SNDCTL_DSP_SPEED, &freq)) {
  17.163 -        dolog ("Could not initialize audio hardware\n"
  17.164 -               "Failed to set frequency\n"
  17.165 -               "Reason: %s\n",
  17.166 -               errstr ());
  17.167 -        goto err;
  17.168 -    }
  17.169 -
  17.170 -    if (ioctl (fd, SNDCTL_DSP_NONBLOCK)) {
  17.171 -        dolog ("Could not initialize audio hardware\n"
  17.172 -               "Failed to set non-blocking mode\n"
  17.173 -               "Reason: %s\n",
  17.174 -               errstr ());
  17.175 -        goto err;
  17.176 -    }
  17.177 -
  17.178 -    mmmmssss = (req->nfrags << 16) | lsbindex (req->fragsize);
  17.179 -    if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) {
  17.180 -        dolog ("Could not initialize audio hardware\n"
  17.181 -               "Failed to set buffer length (%d, %d)\n"
  17.182 -               "Reason:%s\n",
  17.183 -               conf.nfrags, conf.fragsize,
  17.184 -               errstr ());
  17.185 -        goto err;
  17.186 -    }
  17.187 -
  17.188 -    if (ioctl (fd, SNDCTL_DSP_GETOSPACE, &abinfo)) {
  17.189 -        dolog ("Could not initialize audio hardware\n"
  17.190 -               "Failed to get buffer length\n"
  17.191 -               "Reason:%s\n",
  17.192 -               errstr ());
  17.193 -        goto err;
  17.194 -    }
  17.195 -
  17.196 -    obt->fmt = fmt;
  17.197 -    obt->nchannels = nchannels;
  17.198 -    obt->freq = freq;
  17.199 -    obt->nfrags = abinfo.fragstotal;
  17.200 -    obt->fragsize = abinfo.fragsize;
  17.201 -    *pfd = fd;
  17.202 -
  17.203 -    if ((req->fmt != obt->fmt) ||
  17.204 -        (req->nchannels != obt->nchannels) ||
  17.205 -        (req->freq != obt->freq) ||
  17.206 -        (req->fragsize != obt->fragsize) ||
  17.207 -        (req->nfrags != obt->nfrags)) {
  17.208 -#ifdef DEBUG_PCM
  17.209 -        dolog ("Audio parameters mismatch\n");
  17.210 -        oss_dump_pcm_info (req, obt);
  17.211 -#endif
  17.212 -    }
  17.213 -
  17.214 -#ifdef DEBUG_PCM
  17.215 -    oss_dump_pcm_info (req, obt);
  17.216 -#endif
  17.217 -    return 0;
  17.218 -
  17.219 -err:
  17.220 -    close (fd);
  17.221 -    return -1;
  17.222 -}
  17.223 -
  17.224 -static void oss_hw_run (HWVoice *hw)
  17.225 -{
  17.226 -    OSSVoice *oss = (OSSVoice *) hw;
  17.227 -    int err, rpos, live, decr;
  17.228 -    int samples;
  17.229 -    uint8_t *dst;
  17.230 -    st_sample_t *src;
  17.231 -    struct audio_buf_info abinfo;
  17.232 -    struct count_info cntinfo;
  17.233 -
  17.234 -    live = pcm_hw_get_live (hw);
  17.235 -    if (live <= 0)
  17.236 -        return;
  17.237 -
  17.238 -    if (oss->mmapped) {
  17.239 -        int bytes;
  17.240 -
  17.241 -        err = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo);
  17.242 -        if (err < 0) {
  17.243 -            dolog ("SNDCTL_DSP_GETOPTR failed\nReason: %s\n", errstr ());
  17.244 -            return;
  17.245 -        }
  17.246 -
  17.247 -        if (cntinfo.ptr == oss->old_optr) {
  17.248 -            if (abs (hw->samples - live) < 64)
  17.249 -                dolog ("overrun\n");
  17.250 -            return;
  17.251 -        }
  17.252 -
  17.253 -        if (cntinfo.ptr > oss->old_optr) {
  17.254 -            bytes = cntinfo.ptr - oss->old_optr;
  17.255 -        }
  17.256 -        else {
  17.257 -            bytes = hw->bufsize + cntinfo.ptr - oss->old_optr;
  17.258 -        }
  17.259 -
  17.260 -        decr = audio_MIN (bytes >> hw->shift, live);
  17.261 -    }
  17.262 -    else {
  17.263 -        err = ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &abinfo);
  17.264 -        if (err < 0) {
  17.265 -            dolog ("SNDCTL_DSP_GETOSPACE failed\nReason: %s\n", errstr ());
  17.266 -            return;
  17.267 -        }
  17.268 -
  17.269 -        decr = audio_MIN (abinfo.bytes >> hw->shift, live);
  17.270 -        if (decr <= 0)
  17.271 -            return;
  17.272 -    }
  17.273 -
  17.274 -    samples = decr;
  17.275 -    rpos = hw->rpos;
  17.276 -    while (samples) {
  17.277 -        int left_till_end_samples = hw->samples - rpos;
  17.278 -        int convert_samples = audio_MIN (samples, left_till_end_samples);
  17.279 -
  17.280 -        src = advance (hw->mix_buf, rpos * sizeof (st_sample_t));
  17.281 -        dst = advance (oss->pcm_buf, rpos << hw->shift);
  17.282 -
  17.283 -        hw->clip (dst, src, convert_samples);
  17.284 -        if (!oss->mmapped) {
  17.285 -            int written;
  17.286 -
  17.287 -            written = write (oss->fd, dst, convert_samples << hw->shift);
  17.288 -            /* XXX: follow errno recommendations ? */
  17.289 -            if (written == -1) {
  17.290 -                dolog ("Failed to write audio\nReason: %s\n", errstr ());
  17.291 -                continue;
  17.292 -            }
  17.293 -
  17.294 -            if (written != convert_samples << hw->shift) {
  17.295 -                int wsamples = written >> hw->shift;
  17.296 -                int wbytes = wsamples << hw->shift;
  17.297 -                if (wbytes != written) {
  17.298 -                    dolog ("Unaligned write %d, %d\n", wbytes, written);
  17.299 -                }
  17.300 -                memset (src, 0, wbytes);
  17.301 -                decr -= samples;
  17.302 -                rpos = (rpos + wsamples) % hw->samples;
  17.303 -                break;
  17.304 -            }
  17.305 -        }
  17.306 -        memset (src, 0, convert_samples * sizeof (st_sample_t));
  17.307 -
  17.308 -        rpos = (rpos + convert_samples) % hw->samples;
  17.309 -        samples -= convert_samples;
  17.310 -    }
  17.311 -    if (oss->mmapped) {
  17.312 -        oss->old_optr = cntinfo.ptr;
  17.313 -    }
  17.314 -
  17.315 -    pcm_hw_dec_live (hw, decr);
  17.316 -    hw->rpos = rpos;
  17.317 -}
  17.318 -
  17.319 -static void oss_hw_fini (HWVoice *hw)
  17.320 -{
  17.321 -    int err;
  17.322 -    OSSVoice *oss = (OSSVoice *) hw;
  17.323 -
  17.324 -    ldebug ("oss_hw_fini\n");
  17.325 -    err = close (oss->fd);
  17.326 -    if (err) {
  17.327 -        dolog ("Failed to close OSS descriptor\nReason: %s\n", errstr ());
  17.328 -    }
  17.329 -    oss->fd = -1;
  17.330 -
  17.331 -    if (oss->pcm_buf) {
  17.332 -        if (oss->mmapped) {
  17.333 -            err = munmap (oss->pcm_buf, hw->bufsize);
  17.334 -            if (err) {
  17.335 -                dolog ("Failed to unmap OSS buffer\nReason: %s\n",
  17.336 -                       errstr ());
  17.337 -            }
  17.338 -        }
  17.339 -        else {
  17.340 -            qemu_free (oss->pcm_buf);
  17.341 -        }
  17.342 -        oss->pcm_buf = NULL;
  17.343 -    }
  17.344 -}
  17.345 -
  17.346 -static int oss_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
  17.347 -{
  17.348 -    OSSVoice *oss = (OSSVoice *) hw;
  17.349 -    struct oss_params req, obt;
  17.350 -
  17.351 -    assert (!oss->fd);
  17.352 -    req.fmt = AUD_to_ossfmt (fmt);
  17.353 -    req.freq = freq;
  17.354 -    req.nchannels = nchannels;
  17.355 -    req.fragsize = conf.fragsize;
  17.356 -    req.nfrags = conf.nfrags;
  17.357 -
  17.358 -    if (oss_open (&req, &obt, &oss->fd))
  17.359 -        return -1;
  17.360 -
  17.361 -    hw->freq = obt.freq;
  17.362 -    hw->fmt = oss_to_audfmt (obt.fmt);
  17.363 -    hw->nchannels = obt.nchannels;
  17.364 -
  17.365 -    oss->nfrags = obt.nfrags;
  17.366 -    oss->fragsize = obt.fragsize;
  17.367 -    hw->bufsize = obt.nfrags * obt.fragsize;
  17.368 -
  17.369 -    oss->mmapped = 0;
  17.370 -    if (conf.try_mmap) {
  17.371 -        oss->pcm_buf = mmap (0, hw->bufsize, PROT_READ | PROT_WRITE,
  17.372 -                             MAP_SHARED, oss->fd, 0);
  17.373 -        if (oss->pcm_buf == MAP_FAILED) {
  17.374 -            dolog ("Failed to mmap OSS device\nReason: %s\n",
  17.375 -                   errstr ());
  17.376 -        } else {
  17.377 -            int err;
  17.378 -            int trig = 0;
  17.379 -            if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
  17.380 -                dolog ("SNDCTL_DSP_SETTRIGGER 0 failed\nReason: %s\n",
  17.381 -                       errstr ());
  17.382 -            }
  17.383 -            else {
  17.384 -                trig = PCM_ENABLE_OUTPUT;
  17.385 -                if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
  17.386 -                    dolog ("SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n"
  17.387 -                           "Reason: %s\n", errstr ());
  17.388 -                }
  17.389 -                else {
  17.390 -                    oss->mmapped = 1;
  17.391 -                }
  17.392 -            }
  17.393 -
  17.394 -            if (!oss->mmapped) {
  17.395 -                err = munmap (oss->pcm_buf, hw->bufsize);
  17.396 -                if (err) {
  17.397 -                    dolog ("Failed to unmap OSS device\nReason: %s\n",
  17.398 -                           errstr ());
  17.399 -                }
  17.400 -            }
  17.401 -        }
  17.402 -    }
  17.403 -
  17.404 -    if (!oss->mmapped) {
  17.405 -        oss->pcm_buf = qemu_mallocz (hw->bufsize);
  17.406 -        if (!oss->pcm_buf) {
  17.407 -            close (oss->fd);
  17.408 -            oss->fd = -1;
  17.409 -            return -1;
  17.410 -        }
  17.411 -    }
  17.412 -
  17.413 -    return 0;
  17.414 -}
  17.415 -
  17.416 -static int oss_hw_ctl (HWVoice *hw, int cmd, ...)
  17.417 -{
  17.418 -    int trig;
  17.419 -    OSSVoice *oss = (OSSVoice *) hw;
  17.420 -
  17.421 -    if (!oss->mmapped)
  17.422 -        return 0;
  17.423 -
  17.424 -    switch (cmd) {
  17.425 -    case VOICE_ENABLE:
  17.426 -        ldebug ("enabling voice\n");
  17.427 -        pcm_hw_clear (hw, oss->pcm_buf, hw->samples);
  17.428 -        trig = PCM_ENABLE_OUTPUT;
  17.429 -        if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
  17.430 -            dolog ("SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n"
  17.431 -                   "Reason: %s\n", errstr ());
  17.432 -            return -1;
  17.433 -        }
  17.434 -        break;
  17.435 -
  17.436 -    case VOICE_DISABLE:
  17.437 -        ldebug ("disabling voice\n");
  17.438 -        trig = 0;
  17.439 -        if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
  17.440 -            dolog ("SNDCTL_DSP_SETTRIGGER 0 failed\nReason: %s\n",
  17.441 -                   errstr ());
  17.442 -            return -1;
  17.443 -        }
  17.444 -        break;
  17.445 -    }
  17.446 -    return 0;
  17.447 -}
  17.448 -
  17.449 -static void *oss_audio_init (void)
  17.450 -{
  17.451 -    conf.fragsize = audio_get_conf_int (QC_OSS_FRAGSIZE, conf.fragsize);
  17.452 -    conf.nfrags = audio_get_conf_int (QC_OSS_NFRAGS, conf.nfrags);
  17.453 -    conf.try_mmap = audio_get_conf_int (QC_OSS_MMAP, conf.try_mmap);
  17.454 -    conf.dspname = audio_get_conf_str (QC_OSS_DEV, conf.dspname);
  17.455 -    return &conf;
  17.456 -}
  17.457 -
  17.458 -static void oss_audio_fini (void *opaque)
  17.459 -{
  17.460 -}
  17.461 -
  17.462 -struct pcm_ops oss_pcm_ops = {
  17.463 -    oss_hw_init,
  17.464 -    oss_hw_fini,
  17.465 -    oss_hw_run,
  17.466 -    oss_hw_write,
  17.467 -    oss_hw_ctl
  17.468 -};
  17.469 -
  17.470 -struct audio_output_driver oss_output_driver = {
  17.471 -    "oss",
  17.472 -    oss_audio_init,
  17.473 -    oss_audio_fini,
  17.474 -    &oss_pcm_ops,
  17.475 -    1,
  17.476 -    INT_MAX,
  17.477 -    sizeof (OSSVoice)
  17.478 -};
    18.1 --- a/tools/ioemu/audio/sdlaudio.c	Wed Jul 12 16:34:39 2006 +0100
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,332 +0,0 @@
    18.4 -/*
    18.5 - * QEMU SDL audio output driver
    18.6 - * 
    18.7 - * Copyright (c) 2004 Vassili Karpov (malc)
    18.8 - * 
    18.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   18.10 - * of this software and associated documentation files (the "Software"), to deal
   18.11 - * in the Software without restriction, including without limitation the rights
   18.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   18.13 - * copies of the Software, and to permit persons to whom the Software is
   18.14 - * furnished to do so, subject to the following conditions:
   18.15 - *
   18.16 - * The above copyright notice and this permission notice shall be included in
   18.17 - * all copies or substantial portions of the Software.
   18.18 - *
   18.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   18.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   18.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   18.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   18.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   18.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   18.25 - * THE SOFTWARE.
   18.26 - */
   18.27 -#include <SDL.h>
   18.28 -#include <SDL_thread.h>
   18.29 -#include "vl.h"
   18.30 -
   18.31 -#include "audio/audio_int.h"
   18.32 -
   18.33 -typedef struct SDLVoice {
   18.34 -    HWVoice hw;
   18.35 -} SDLVoice;
   18.36 -
   18.37 -#define dolog(...) AUD_log ("sdl", __VA_ARGS__)
   18.38 -#ifdef DEBUG
   18.39 -#define ldebug(...) dolog (__VA_ARGS__)
   18.40 -#else
   18.41 -#define ldebug(...)
   18.42 -#endif
   18.43 -
   18.44 -#define QC_SDL_SAMPLES "QEMU_SDL_SAMPLES"
   18.45 -
   18.46 -#define errstr() SDL_GetError ()
   18.47 -
   18.48 -static struct {
   18.49 -    int nb_samples;
   18.50 -} conf = {
   18.51 -    1024
   18.52 -};
   18.53 -
   18.54 -struct SDLAudioState {
   18.55 -    int exit;
   18.56 -    SDL_mutex *mutex;
   18.57 -    SDL_sem *sem;
   18.58 -    int initialized;
   18.59 -} glob_sdl;
   18.60 -typedef struct SDLAudioState SDLAudioState;
   18.61 -
   18.62 -static void sdl_hw_run (HWVoice *hw)
   18.63 -{
   18.64 -    (void) hw;
   18.65 -}
   18.66 -
   18.67 -static int sdl_lock (SDLAudioState *s)
   18.68 -{
   18.69 -    if (SDL_LockMutex (s->mutex)) {
   18.70 -        dolog ("SDL_LockMutex failed\nReason: %s\n", errstr ());
   18.71 -        return -1;
   18.72 -    }
   18.73 -    return 0;
   18.74 -}
   18.75 -
   18.76 -static int sdl_unlock (SDLAudioState *s)
   18.77 -{
   18.78 -    if (SDL_UnlockMutex (s->mutex)) {
   18.79 -        dolog ("SDL_UnlockMutex failed\nReason: %s\n", errstr ());
   18.80 -        return -1;
   18.81 -    }
   18.82 -    return 0;
   18.83 -}
   18.84 -
   18.85 -static int sdl_post (SDLAudioState *s)
   18.86 -{
   18.87 -    if (SDL_SemPost (s->sem)) {
   18.88 -        dolog ("SDL_SemPost failed\nReason: %s\n", errstr ());
   18.89 -        return -1;
   18.90 -    }
   18.91 -    return 0;
   18.92 -}
   18.93 -
   18.94 -static int sdl_wait (SDLAudioState *s)
   18.95 -{
   18.96 -    if (SDL_SemWait (s->sem)) {
   18.97 -        dolog ("SDL_SemWait failed\nReason: %s\n", errstr ());
   18.98 -        return -1;
   18.99 -    }
  18.100 -    return 0;
  18.101 -}
  18.102 -
  18.103 -static int sdl_unlock_and_post (SDLAudioState *s)
  18.104 -{
  18.105 -    if (sdl_unlock (s))
  18.106 -        return -1;
  18.107 -
  18.108 -    return sdl_post (s);
  18.109 -}
  18.110 -
  18.111 -static int sdl_hw_write (SWVoice *sw, void *buf, int len)
  18.112 -{
  18.113 -    int ret;
  18.114 -    SDLAudioState *s = &glob_sdl;
  18.115 -    sdl_lock (s);
  18.116 -    ret = pcm_hw_write (sw, buf, len);
  18.117 -    sdl_unlock_and_post (s);
  18.118 -    return ret;
  18.119 -}
  18.120 -
  18.121 -static int AUD_to_sdlfmt (audfmt_e fmt, int *shift)
  18.122 -{
  18.123 -    *shift = 0;
  18.124 -    switch (fmt) {
  18.125 -    case AUD_FMT_S8: return AUDIO_S8;
  18.126 -    case AUD_FMT_U8: return AUDIO_U8;
  18.127 -    case AUD_FMT_S16: *shift = 1; return AUDIO_S16LSB;
  18.128 -    case AUD_FMT_U16: *shift = 1; return AUDIO_U16LSB;
  18.129 -    default:
  18.130 -        dolog ("Internal logic error: Bad audio format %d\nAborting\n", fmt);
  18.131 -        exit (EXIT_FAILURE);
  18.132 -    }
  18.133 -}
  18.134 -
  18.135 -static int sdl_to_audfmt (int fmt)
  18.136 -{
  18.137 -    switch (fmt) {
  18.138 -    case AUDIO_S8: return AUD_FMT_S8;
  18.139 -    case AUDIO_U8: return AUD_FMT_U8;
  18.140 -    case AUDIO_S16LSB: return AUD_FMT_S16;
  18.141 -    case AUDIO_U16LSB: return AUD_FMT_U16;
  18.142 -    default:
  18.143 -        dolog ("Internal logic error: Unrecognized SDL audio format %d\n"
  18.144 -               "Aborting\n", fmt);
  18.145 -        exit (EXIT_FAILURE);
  18.146 -    }
  18.147 -}
  18.148 -
  18.149 -static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt)
  18.150 -{
  18.151 -    int status;
  18.152 -
  18.153 -    status = SDL_OpenAudio (req, obt);
  18.154 -    if (status) {
  18.155 -        dolog ("SDL_OpenAudio failed\nReason: %s\n", errstr ());
  18.156 -    }
  18.157 -    return status;
  18.158 -}
  18.159 -
  18.160 -static void sdl_close (SDLAudioState *s)
  18.161 -{
  18.162 -    if (s->initialized) {
  18.163 -        sdl_lock (s);
  18.164 -        s->exit = 1;
  18.165 -        sdl_unlock_and_post (s);
  18.166 -        SDL_PauseAudio (1);
  18.167 -        SDL_CloseAudio ();
  18.168 -        s->initialized = 0;
  18.169 -    }
  18.170 -}
  18.171 -
  18.172 -static void sdl_callback (void *opaque, Uint8 *buf, int len)
  18.173 -{
  18.174 -    SDLVoice *sdl = opaque;
  18.175 -    SDLAudioState *s = &glob_sdl;
  18.176 -    HWVoice *hw = &sdl->hw;
  18.177 -    int samples = len >> hw->shift;
  18.178 -
  18.179 -    if (s->exit) {
  18.180 -        return;
  18.181 -    }
  18.182 -
  18.183 -    while (samples) {
  18.184 -        int to_mix, live, decr;
  18.185 -
  18.186 -        /* dolog ("in callback samples=%d\n", samples); */
  18.187 -        sdl_wait (s);
  18.188 -        if (s->exit) {
  18.189 -            return;
  18.190 -        }
  18.191 -
  18.192 -        sdl_lock (s);
  18.193 -        live = pcm_hw_get_live (hw);
  18.194 -        if (live <= 0)
  18.195 -            goto again;
  18.196 -
  18.197 -        /* dolog ("in callback live=%d\n", live); */
  18.198 -        to_mix = audio_MIN (samples, live);
  18.199 -        decr = to_mix;
  18.200 -        while (to_mix) {
  18.201 -            int chunk = audio_MIN (to_mix, hw->samples - hw->rpos);
  18.202 -            st_sample_t *src = hw->mix_buf + hw->rpos;
  18.203 -
  18.204 -            /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */
  18.205 -            hw->clip (buf, src, chunk);
  18.206 -            memset (src, 0, chunk * sizeof (st_sample_t));
  18.207 -            hw->rpos = (hw->rpos + chunk) % hw->samples;
  18.208 -            to_mix -= chunk;
  18.209 -            buf += chunk << hw->shift;
  18.210 -        }
  18.211 -        samples -= decr;
  18.212 -        pcm_hw_dec_live (hw, decr);
  18.213 -
  18.214 -    again:
  18.215 -        sdl_unlock (s);
  18.216 -    }
  18.217 -    /* dolog ("done len=%d\n", len); */
  18.218 -}
  18.219 -
  18.220 -static void sdl_hw_fini (HWVoice *hw)
  18.221 -{
  18.222 -    ldebug ("sdl_hw_fini %d fixed=%d\n",
  18.223 -             glob_sdl.initialized, audio_conf.fixed_format);
  18.224 -    sdl_close (&glob_sdl);
  18.225 -}
  18.226 -
  18.227 -static int sdl_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
  18.228 -{
  18.229 -    SDLVoice *sdl = (SDLVoice *) hw;
  18.230 -    SDLAudioState *s = &glob_sdl;
  18.231 -    SDL_AudioSpec req, obt;
  18.232 -    int shift;
  18.233 -
  18.234 -    ldebug ("sdl_hw_init %d freq=%d fixed=%d\n",
  18.235 -            s->initialized, freq, audio_conf.fixed_format);
  18.236 -
  18.237 -    if (nchannels != 2) {
  18.238 -        dolog ("Bogus channel count %d\n", nchannels);
  18.239 -        return -1;
  18.240 -    }
  18.241 -
  18.242 -    req.freq = freq;
  18.243 -    req.format = AUD_to_sdlfmt (fmt, &shift);
  18.244 -    req.channels = nchannels;
  18.245 -    req.samples = conf.nb_samples;
  18.246 -    shift <<= nchannels == 2;
  18.247 -
  18.248 -    req.callback = sdl_callback;
  18.249 -    req.userdata = sdl;
  18.250 -
  18.251 -    if (sdl_open (&req, &obt))
  18.252 -        return -1;
  18.253 -
  18.254 -    hw->freq = obt.freq;
  18.255 -    hw->fmt = sdl_to_audfmt (obt.format);
  18.256 -    hw->nchannels = obt.channels;
  18.257 -    hw->bufsize = obt.samples << shift;
  18.258 -
  18.259 -    s->initialized = 1;
  18.260 -    s->exit = 0;
  18.261 -    SDL_PauseAudio (0);
  18.262 -    return 0;
  18.263 -}
  18.264 -
  18.265 -static int sdl_hw_ctl (HWVoice *hw, int cmd, ...)
  18.266 -{
  18.267 -    (void) hw;
  18.268 -
  18.269 -    switch (cmd) {
  18.270 -    case VOICE_ENABLE:
  18.271 -        SDL_PauseAudio (0);
  18.272 -        break;
  18.273 -
  18.274 -    case VOICE_DISABLE:
  18.275 -        SDL_PauseAudio (1);
  18.276 -        break;
  18.277 -    }
  18.278 -    return 0;
  18.279 -}
  18.280 -
  18.281 -static void *sdl_audio_init (void)
  18.282 -{
  18.283 -    SDLAudioState *s = &glob_sdl;
  18.284 -    conf.nb_samples = audio_get_conf_int (QC_SDL_SAMPLES, conf.nb_samples);
  18.285 -
  18.286 -    if (SDL_InitSubSystem (SDL_INIT_AUDIO)) {
  18.287 -        dolog ("SDL failed to initialize audio subsystem\nReason: %s\n",
  18.288 -               errstr ());
  18.289 -        return NULL;
  18.290 -    }
  18.291 -
  18.292 -    s->mutex = SDL_CreateMutex ();
  18.293 -    if (!s->mutex) {
  18.294 -        dolog ("Failed to create SDL mutex\nReason: %s\n", errstr ());
  18.295 -        SDL_QuitSubSystem (SDL_INIT_AUDIO);
  18.296 -        return NULL;
  18.297 -    }
  18.298 -
  18.299 -    s->sem = SDL_CreateSemaphore (0);
  18.300 -    if (!s->sem) {
  18.301 -        dolog ("Failed to create SDL semaphore\nReason: %s\n", errstr ());
  18.302 -        SDL_DestroyMutex (s->mutex);
  18.303 -        SDL_QuitSubSystem (SDL_INIT_AUDIO);
  18.304 -        return NULL;
  18.305 -    }
  18.306 -
  18.307 -    return s;
  18.308 -}
  18.309 -
  18.310 -static void sdl_audio_fini (void *opaque)
  18.311 -{
  18.312 -    SDLAudioState *s = opaque;
  18.313 -    sdl_close (s);
  18.314 -    SDL_DestroySemaphore (s->sem);
  18.315 -    SDL_DestroyMutex (s->mutex);
  18.316 -    SDL_QuitSubSystem (SDL_INIT_AUDIO);
  18.317 -}
  18.318 -
  18.319 -struct pcm_ops sdl_pcm_ops = {
  18.320 -    sdl_hw_init,
  18.321 -    sdl_hw_fini,
  18.322 -    sdl_hw_run,
  18.323 -    sdl_hw_write,
  18.324 -    sdl_hw_ctl
  18.325 -};
  18.326 -
  18.327 -struct audio_output_driver sdl_output_driver = {
  18.328 -    "sdl",
  18.329 -    sdl_audio_init,
  18.330 -    sdl_audio_fini,
  18.331 -    &sdl_pcm_ops,
  18.332 -    1,
  18.333 -    1,
  18.334 -    sizeof (SDLVoice)
  18.335 -};
    19.1 --- a/tools/ioemu/audio/wavaudio.c	Wed Jul 12 16:34:39 2006 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,217 +0,0 @@
    19.4 -/*
    19.5 - * QEMU WAV audio output driver
    19.6 - * 
    19.7 - * Copyright (c) 2004 Vassili Karpov (malc)
    19.8 - * 
    19.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   19.10 - * of this software and associated documentation files (the "Software"), to deal
   19.11 - * in the Software without restriction, including without limitation the rights
   19.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   19.13 - * copies of the Software, and to permit persons to whom the Software is
   19.14 - * furnished to do so, subject to the following conditions:
   19.15 - *
   19.16 - * The above copyright notice and this permission notice shall be included in
   19.17 - * all copies or substantial portions of the Software.
   19.18 - *
   19.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   19.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   19.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   19.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   19.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   19.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   19.25 - * THE SOFTWARE.
   19.26 - */
   19.27 -#include "vl.h"
   19.28 -
   19.29 -#include "audio/audio_int.h"
   19.30 -
   19.31 -typedef struct WAVVoice {
   19.32 -    HWVoice hw;
   19.33 -    QEMUFile *f;
   19.34 -    int64_t old_ticks;
   19.35 -    void *pcm_buf;
   19.36 -    int total_samples;
   19.37 -} WAVVoice;
   19.38 -
   19.39 -#define dolog(...) AUD_log ("wav", __VA_ARGS__)
   19.40 -#ifdef DEBUG
   19.41 -#define ldebug(...) dolog (__VA_ARGS__)
   19.42 -#else
   19.43 -#define ldebug(...)
   19.44 -#endif
   19.45 -
   19.46 -static struct {
   19.47 -    const char *wav_path;
   19.48 -} conf = {
   19.49 -    .wav_path = "qemu.wav"
   19.50 -};
   19.51 -
   19.52 -static void wav_hw_run (HWVoice *hw)
   19.53 -{
   19.54 -    WAVVoice *wav = (WAVVoice *) hw;
   19.55 -    int rpos, live, decr, samples;
   19.56 -    uint8_t *dst;
   19.57 -    st_sample_t *src;
   19.58 -    int64_t now = qemu_get_clock (vm_clock);
   19.59 -    int64_t ticks = now - wav->old_ticks;
   19.60 -    int64_t bytes = (ticks * hw->bytes_per_second) / ticks_per_sec;
   19.61 -
   19.62 -    if (bytes > INT_MAX)
   19.63 -        samples = INT_MAX >> hw->shift;
   19.64 -    else
   19.65 -        samples = bytes >> hw->shift;
   19.66 -
   19.67 -    live = pcm_hw_get_live (hw);
   19.68 -    if (live <= 0)
   19.69 -        return;
   19.70 -
   19.71 -    wav->old_ticks = now;
   19.72 -    decr = audio_MIN (live, samples);
   19.73 -    samples = decr;
   19.74 -    rpos = hw->rpos;
   19.75 -    while (samples) {
   19.76 -        int left_till_end_samples = hw->samples - rpos;
   19.77 -        int convert_samples = audio_MIN (samples, left_till_end_samples);
   19.78 -
   19.79 -        src = advance (hw->mix_buf, rpos * sizeof (st_sample_t));
   19.80 -        dst = advance (wav->pcm_buf, rpos << hw->shift);
   19.81 -
   19.82 -        hw->clip (dst, src, convert_samples);
   19.83 -        qemu_put_buffer (wav->f, dst, convert_samples << hw->shift);
   19.84 -        memset (src, 0, convert_samples * sizeof (st_sample_t));
   19.85 -
   19.86 -        rpos = (rpos + convert_samples) % hw->samples;
   19.87 -        samples -= convert_samples;
   19.88 -        wav->total_samples += convert_samples;
   19.89 -    }
   19.90 -
   19.91 -    pcm_hw_dec_live (hw, decr);
   19.92 -    hw->rpos = rpos;
   19.93 -}
   19.94 -
   19.95 -static int wav_hw_write (SWVoice *sw, void *buf, int len)
   19.96 -{
   19.97 -    return pcm_hw_write (sw, buf, len);
   19.98 -}
   19.99 -
  19.100 -/* VICE code: Store number as little endian. */
  19.101 -static void le_store (uint8_t *buf, uint32_t val, int len)
  19.102 -{
  19.103 -    int i;
  19.104 -    for (i = 0; i < len; i++) {
  19.105 -        buf[i] = (uint8_t) (val & 0xff);
  19.106 -        val >>= 8;
  19.107 -    }
  19.108 -}
  19.109 -
  19.110 -static int wav_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
  19.111 -{
  19.112 -    WAVVoice *wav = (WAVVoice *) hw;
  19.113 -    int bits16 = 0, stereo = audio_state.fixed_channels == 2;
  19.114 -    uint8_t hdr[] = {
  19.115 -        0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56,
  19.116 -        0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00,
  19.117 -        0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04,
  19.118 -        0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00
  19.119 -    };
  19.120 -
  19.121 -    switch (audio_state.fixed_fmt) {
  19.122 -    case AUD_FMT_S8:
  19.123 -    case AUD_FMT_U8:
  19.124 -        break;
  19.125 -
  19.126 -    case AUD_FMT_S16:
  19.127 -    case AUD_FMT_U16:
  19.128 -        bits16 = 1;
  19.129 -        break;
  19.130 -    }
  19.131 -
  19.132 -    hdr[34] = bits16 ? 0x10 : 0x08;
  19.133 -    hw->freq = 44100;
  19.134 -    hw->nchannels = stereo ? 2 : 1;
  19.135 -    hw->fmt = bits16 ? AUD_FMT_S16 : AUD_FMT_U8;
  19.136 -    hw->bufsize = 4096;
  19.137 -    wav->pcm_buf = qemu_mallocz (hw->bufsize);
  19.138 -    if (!wav->pcm_buf)
  19.139 -        return -1;
  19.140 -
  19.141 -    le_store (hdr + 22, hw->nchannels, 2);
  19.142 -    le_store (hdr + 24, hw->freq, 4);
  19.143 -    le_store (hdr + 28, hw->freq << (bits16 + stereo), 4);
  19.144 -    le_store (hdr + 32, 1 << (bits16 + stereo), 2);
  19.145 -
  19.146 -    wav->f = fopen (conf.wav_path, "wb");
  19.147 -    if (!wav->f) {
  19.148 -        dolog ("failed to open wave file `%s'\nReason: %s\n",
  19.149 -               conf.wav_path, strerror (errno));
  19.150 -        qemu_free (wav->pcm_buf);
  19.151 -        wav->pcm_buf = NULL;
  19.152 -        return -1;
  19.153 -    }
  19.154 -
  19.155 -    qemu_put_buffer (wav->f, hdr, sizeof (hdr));
  19.156 -    return 0;
  19.157 -}
  19.158 -
  19.159 -static void wav_hw_fini (HWVoice *hw)
  19.160 -{
  19.161 -    WAVVoice *wav = (WAVVoice *) hw;
  19.162 -    int stereo = hw->nchannels == 2;
  19.163 -    uint8_t rlen[4];
  19.164 -    uint8_t dlen[4];
  19.165 -    uint32_t rifflen = (wav->total_samples << stereo) + 36;
  19.166 -    uint32_t datalen = wav->total_samples << stereo;
  19.167 -
  19.168 -    if (!wav->f || !hw->active)
  19.169 -        return;
  19.170 -
  19.171 -    le_store (rlen, rifflen, 4);
  19.172 -    le_store (dlen, datalen, 4);
  19.173 -
  19.174 -    qemu_fseek (wav->f, 4, SEEK_SET);
  19.175 -    qemu_put_buffer (wav->f, rlen, 4);
  19.176 -
  19.177 -    qemu_fseek (wav->f, 32, SEEK_CUR);
  19.178 -    qemu_put_buffer (wav->f, dlen, 4);
  19.179 -
  19.180 -    fclose (wav->f);
  19.181 -    wav->f = NULL;
  19.182 -
  19.183 -    qemu_free (wav->pcm_buf);
  19.184 -    wav->pcm_buf = NULL;
  19.185 -}
  19.186 -
  19.187 -static int wav_hw_ctl (HWVoice *hw, int cmd, ...)
  19.188 -{
  19.189 -    (void) hw;
  19.190 -    (void) cmd;
  19.191 -    return 0;
  19.192 -}
  19.193 -
  19.194 -static void *wav_audio_init (void)
  19.195 -{
  19.196 -    return &conf;
  19.197 -}
  19.198 -
  19.199 -static void wav_audio_fini (void *opaque)
  19.200 -{
  19.201 -    ldebug ("wav_fini");
  19.202 -}
  19.203 -
  19.204 -struct pcm_ops wav_pcm_ops = {
  19.205 -    wav_hw_init,
  19.206 -    wav_hw_fini,
  19.207 -    wav_hw_run,
  19.208 -    wav_hw_write,
  19.209 -    wav_hw_ctl
  19.210 -};
  19.211 -
  19.212 -struct audio_output_driver wav_output_driver = {
  19.213 -    "wav",
  19.214 -    wav_audio_init,
  19.215 -    wav_audio_fini,
  19.216 -    &wav_pcm_ops,
  19.217 -    1,
  19.218 -    1,
  19.219 -    sizeof (WAVVoice)
  19.220 -};
    20.1 --- a/tools/ioemu/block-cloop.c	Wed Jul 12 16:34:39 2006 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,167 +0,0 @@
    20.4 -/*
    20.5 - * QEMU System Emulator block driver
    20.6 - * 
    20.7 - * Copyright (c) 2004 Johannes E. Schindelin
    20.8 - * 
    20.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   20.10 - * of this software and associated documentation files (the "Software"), to deal
   20.11 - * in the Software without restriction, including without limitation the rights
   20.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   20.13 - * copies of the Software, and to permit persons to whom the Software is
   20.14 - * furnished to do so, subject to the following conditions:
   20.15 - *
   20.16 - * The above copyright notice and this permission notice shall be included in
   20.17 - * all copies or substantial portions of the Software.
   20.18 - *
   20.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   20.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   20.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   20.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   20.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   20.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   20.25 - * THE SOFTWARE.
   20.26 - */
   20.27 -#include "vl.h"
   20.28 -#include "block_int.h"
   20.29 -#include <zlib.h>
   20.30 -
   20.31 -typedef struct BDRVCloopState {
   20.32 -    int fd;
   20.33 -    uint32_t block_size;
   20.34 -    uint32_t n_blocks;
   20.35 -    uint64_t* offsets;
   20.36 -    uint32_t sectors_per_block;
   20.37 -    uint32_t current_block;
   20.38 -    char* compressed_block;
   20.39 -    char* uncompressed_block;
   20.40 -    z_stream zstream;
   20.41 -} BDRVCloopState;
   20.42 -
   20.43 -static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
   20.44 -{
   20.45 -    const char* magic_version_2_0="#!/bin/sh\n"
   20.46 -	"#V2.0 Format\n"
   20.47 -	"modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n";
   20.48 -    int length=strlen(magic_version_2_0);
   20.49 -    if(length>buf_size)
   20.50 -	length=buf_size;
   20.51 -    if(!memcmp(magic_version_2_0,buf,length))
   20.52 -	return 2;
   20.53 -    return 0;
   20.54 -}
   20.55 -
   20.56 -static int cloop_open(BlockDriverState *bs, const char *filename)
   20.57 -{
   20.58 -    BDRVCloopState *s = bs->opaque;
   20.59 -    uint32_t offsets_size,max_compressed_block_size=1,i;
   20.60 -
   20.61 -    s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   20.62 -    if (s->fd < 0)
   20.63 -        return -1;
   20.64 -    bs->read_only = 1;
   20.65 -
   20.66 -    /* read header */
   20.67 -    if(lseek(s->fd,128,SEEK_SET)<0) {
   20.68 -cloop_close:
   20.69 -	close(s->fd);
   20.70 -	return -1;
   20.71 -    }
   20.72 -    if(read(s->fd,&s->block_size,4)<4)
   20.73 -	goto cloop_close;
   20.74 -    s->block_size=be32_to_cpu(s->block_size);
   20.75 -    if(read(s->fd,&s->n_blocks,4)<4)
   20.76 -	goto cloop_close;
   20.77 -    s->n_blocks=be32_to_cpu(s->n_blocks);
   20.78 -
   20.79 -    /* read offsets */
   20.80 -    offsets_size=s->n_blocks*sizeof(uint64_t);
   20.81 -    if(!(s->offsets=(uint64_t*)malloc(offsets_size)))
   20.82 -	goto cloop_close;
   20.83 -    if(read(s->fd,s->offsets,offsets_size)<offsets_size)
   20.84 -	goto cloop_close;
   20.85 -    for(i=0;i<s->n_blocks;i++) {
   20.86 -	s->offsets[i]=be64_to_cpu(s->offsets[i]);
   20.87 -	if(i>0) {
   20.88 -	    uint32_t size=s->offsets[i]-s->offsets[i-1];
   20.89 -	    if(size>max_compressed_block_size)
   20.90 -		max_compressed_block_size=size;
   20.91 -	}
   20.92 -    }
   20.93 -
   20.94 -    /* initialize zlib engine */
   20.95 -    if(!(s->compressed_block=(char*)malloc(max_compressed_block_size+1)))
   20.96 -	goto cloop_close;
   20.97 -    if(!(s->uncompressed_block=(char*)malloc(s->block_size)))
   20.98 -	goto cloop_close;
   20.99 -    if(inflateInit(&s->zstream) != Z_OK)
  20.100 -	goto cloop_close;
  20.101 -    s->current_block=s->n_blocks;
  20.102 -    
  20.103 -    s->sectors_per_block = s->block_size/512;
  20.104 -    bs->total_sectors = s->n_blocks*s->sectors_per_block;
  20.105 -    return 0;
  20.106 -}
  20.107 -
  20.108 -static inline int cloop_read_block(BDRVCloopState *s,int block_num)
  20.109 -{
  20.110 -    if(s->current_block != block_num) {
  20.111 -	int ret;
  20.112 -        uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];
  20.113 -	    
  20.114 -	lseek(s->fd, s->offsets[block_num], SEEK_SET);
  20.115 -        ret = read(s->fd, s->compressed_block, bytes);
  20.116 -        if (ret != bytes) 
  20.117 -            return -1;
  20.118 -	
  20.119 -	s->zstream.next_in = s->compressed_block;
  20.120 -	s->zstream.avail_in = bytes;
  20.121 -	s->zstream.next_out = s->uncompressed_block;
  20.122 -	s->zstream.avail_out = s->block_size;
  20.123 -	ret = inflateReset(&s->zstream);
  20.124 -	if(ret != Z_OK)
  20.125 -	    return -1;
  20.126 -	ret = inflate(&s->zstream, Z_FINISH);
  20.127 -	if(ret != Z_STREAM_END || s->zstream.total_out != s->block_size)
  20.128 -	    return -1;
  20.129 -	
  20.130 -	s->current_block = block_num;
  20.131 -    }
  20.132 -    return 0;
  20.133 -}
  20.134 -
  20.135 -static int cloop_read(BlockDriverState *bs, int64_t sector_num, 
  20.136 -                    uint8_t *buf, int nb_sectors)
  20.137 -{
  20.138 -    BDRVCloopState *s = bs->opaque;
  20.139 -    int i;
  20.140 -
  20.141 -    for(i=0;i<nb_sectors;i++) {
  20.142 -	uint32_t sector_offset_in_block=((sector_num+i)%s->sectors_per_block),
  20.143 -	    block_num=(sector_num+i)/s->sectors_per_block;
  20.144 -	if(cloop_read_block(s, block_num) != 0)
  20.145 -	    return -1;
  20.146 -	memcpy(buf+i*512,s->uncompressed_block+sector_offset_in_block*512,512);
  20.147 -    }
  20.148 -    return 0;
  20.149 -}
  20.150 -
  20.151 -static void cloop_close(BlockDriverState *bs)
  20.152 -{
  20.153 -    BDRVCloopState *s = bs->opaque;
  20.154 -    close(s->fd);
  20.155 -    free(s->compressed_block);
  20.156 -    free(s->uncompressed_block);
  20.157 -    inflateEnd(&s->zstream);
  20.158 -}
  20.159 -
  20.160 -BlockDriver bdrv_cloop = {
  20.161 -    "cloop",
  20.162 -    sizeof(BDRVCloopState),
  20.163 -    cloop_probe,
  20.164 -    cloop_open,
  20.165 -    cloop_read,
  20.166 -    NULL,
  20.167 -    cloop_close,
  20.168 -};
  20.169 -
  20.170 -
    21.1 --- a/tools/ioemu/block-cow.c	Wed Jul 12 16:34:39 2006 +0100
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,263 +0,0 @@
    21.4 -/*
    21.5 - * Block driver for the COW format
    21.6 - * 
    21.7 - * Copyright (c) 2004 Fabrice Bellard
    21.8 - * 
    21.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   21.10 - * of this software and associated documentation files (the "Software"), to deal
   21.11 - * in the Software without restriction, including without limitation the rights
   21.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   21.13 - * copies of the Software, and to permit persons to whom the Software is
   21.14 - * furnished to do so, subject to the following conditions:
   21.15 - *
   21.16 - * The above copyright notice and this permission notice shall be included in
   21.17 - * all copies or substantial portions of the Software.
   21.18 - *
   21.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   21.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   21.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   21.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   21.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   21.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   21.25 - * THE SOFTWARE.
   21.26 - */
   21.27 -#ifndef _WIN32
   21.28 -#include "vl.h"
   21.29 -#include "block_int.h"
   21.30 -#include <sys/mman.h>
   21.31 -
   21.32 -/**************************************************************/
   21.33 -/* COW block driver using file system holes */
   21.34 -
   21.35 -/* user mode linux compatible COW file */
   21.36 -#define COW_MAGIC 0x4f4f4f4d  /* MOOO */
   21.37 -#define COW_VERSION 2
   21.38 -
   21.39 -struct cow_header_v2 {
   21.40 -    uint32_t magic;
   21.41 -    uint32_t version;
   21.42 -    char backing_file[1024];
   21.43 -    int32_t mtime;
   21.44 -    uint64_t size;
   21.45 -    uint32_t sectorsize;
   21.46 -};
   21.47 -
   21.48 -typedef struct BDRVCowState {
   21.49 -    int fd;
   21.50 -    uint8_t *cow_bitmap; /* if non NULL, COW mappings are used first */
   21.51 -    uint8_t *cow_bitmap_addr; /* mmap address of cow_bitmap */
   21.52 -    int cow_bitmap_size;
   21.53 -    int64_t cow_sectors_offset;
   21.54 -} BDRVCowState;
   21.55 -
   21.56 -static int cow_probe(const uint8_t *buf, int buf_size, const char *filename)
   21.57 -{
   21.58 -    const struct cow_header_v2 *cow_header = (const void *)buf;
   21.59 -
   21.60 -    if (be32_to_cpu(cow_header->magic) == COW_MAGIC &&
   21.61 -        be32_to_cpu(cow_header->version) == COW_VERSION) 
   21.62 -        return 100;
   21.63 -    else
   21.64 -        return 0;
   21.65 -}
   21.66 -
   21.67 -static int cow_open(BlockDriverState *bs, const char *filename)
   21.68 -{
   21.69 -    BDRVCowState *s = bs->opaque;
   21.70 -    int fd;
   21.71 -    struct cow_header_v2 cow_header;
   21.72 -    int64_t size;
   21.73 -
   21.74 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
   21.75 -    if (fd < 0) {
   21.76 -        fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   21.77 -        if (fd < 0)
   21.78 -            return -1;
   21.79 -    }
   21.80 -    s->fd = fd;
   21.81 -    /* see if it is a cow image */
   21.82 -    if (read(fd, &cow_header, sizeof(cow_header)) != sizeof(cow_header)) {
   21.83 -        goto fail;
   21.84 -    }
   21.85 -
   21.86 -    if (be32_to_cpu(cow_header.magic) != COW_MAGIC ||
   21.87 -        be32_to_cpu(cow_header.version) != COW_VERSION) {
   21.88 -        goto fail;
   21.89 -    }
   21.90 -        
   21.91 -    /* cow image found */
   21.92 -    size = be64_to_cpu(cow_header.size);
   21.93 -    bs->total_sectors = size / 512;
   21.94 -
   21.95 -    pstrcpy(bs->backing_file, sizeof(bs->backing_file), 
   21.96 -            cow_header.backing_file);
   21.97 -    
   21.98 -#if 0
   21.99 -    if (cow_header.backing_file[0] != '\0') {
  21.100 -        if (stat(cow_header.backing_file, &st) != 0) {
  21.101 -            fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow_header.backing_file);
  21.102 -            goto fail;
  21.103 -        }
  21.104 -        if (st.st_mtime != be32_to_cpu(cow_header.mtime)) {
  21.105 -            fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow_header.backing_file);
  21.106 -            goto fail;
  21.107 -            }
  21.108 -        fd = open(cow_header.backing_file, O_RDONLY | O_LARGEFILE);
  21.109 -        if (fd < 0)
  21.110 -            goto fail;
  21.111 -        bs->fd = fd;
  21.112 -    }
  21.113 -#endif
  21.114 -    /* mmap the bitmap */
  21.115 -    s->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
  21.116 -    s->cow_bitmap_addr = mmap(get_mmap_addr(s->cow_bitmap_size), 
  21.117 -                              s->cow_bitmap_size, 
  21.118 -                              PROT_READ | PROT_WRITE,
  21.119 -                              MAP_SHARED, s->fd, 0);
  21.120 -    if (s->cow_bitmap_addr == MAP_FAILED)
  21.121 -        goto fail;
  21.122 -    s->cow_bitmap = s->cow_bitmap_addr + sizeof(cow_header);
  21.123 -    s->cow_sectors_offset = (s->cow_bitmap_size + 511) & ~511;
  21.124 -    return 0;
  21.125 - fail:
  21.126 -    close(fd);
  21.127 -    return -1;
  21.128 -}
  21.129 -
  21.130 -static inline void set_bit(uint8_t *bitmap, int64_t bitnum)
  21.131 -{
  21.132 -    bitmap[bitnum / 8] |= (1 << (bitnum%8));
  21.133 -}
  21.134 -
  21.135 -static inline int is_bit_set(const uint8_t *bitmap, int64_t bitnum)
  21.136 -{
  21.137 -    return !!(bitmap[bitnum / 8] & (1 << (bitnum%8)));
  21.138 -}
  21.139 -
  21.140 -
  21.141 -/* Return true if first block has been changed (ie. current version is
  21.142 - * in COW file).  Set the number of continuous blocks for which that
  21.143 - * is true. */
  21.144 -static inline int is_changed(uint8_t *bitmap,
  21.145 -                             int64_t sector_num, int nb_sectors,
  21.146 -                             int *num_same)
  21.147 -{
  21.148 -    int changed;
  21.149 -
  21.150 -    if (!bitmap || nb_sectors == 0) {
  21.151 -	*num_same = nb_sectors;
  21.152 -	return 0;
  21.153 -    }
  21.154 -
  21.155 -    changed = is_bit_set(bitmap, sector_num);
  21.156 -    for (*num_same = 1; *num_same < nb_sectors; (*num_same)++) {
  21.157 -	if (is_bit_set(bitmap, sector_num + *num_same) != changed)
  21.158 -	    break;
  21.159 -    }
  21.160 -
  21.161 -    return changed;
  21.162 -}
  21.163 -
  21.164 -static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num, 
  21.165 -                            int nb_sectors, int *pnum)
  21.166 -{
  21.167 -    BDRVCowState *s = bs->opaque;
  21.168 -    return is_changed(s->cow_bitmap, sector_num, nb_sectors, pnum);
  21.169 -}
  21.170 -
  21.171 -static int cow_read(BlockDriverState *bs, int64_t sector_num, 
  21.172 -                    uint8_t *buf, int nb_sectors)
  21.173 -{
  21.174 -    BDRVCowState *s = bs->opaque;
  21.175 -    int ret, n;
  21.176 -    
  21.177 -    while (nb_sectors > 0) {
  21.178 -        if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
  21.179 -            lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
  21.180 -            ret = read(s->fd, buf, n * 512);
  21.181 -            if (ret != n * 512) 
  21.182 -                return -1;
  21.183 -        } else {
  21.184 -            memset(buf, 0, n * 512);
  21.185 -        }
  21.186 -        nb_sectors -= n;
  21.187 -        sector_num += n;
  21.188 -        buf += n * 512;
  21.189 -    }
  21.190 -    return 0;
  21.191 -}
  21.192 -
  21.193 -static int cow_write(BlockDriverState *bs, int64_t sector_num, 
  21.194 -                     const uint8_t *buf, int nb_sectors)
  21.195 -{
  21.196 -    BDRVCowState *s = bs->opaque;
  21.197 -    int ret, i;
  21.198 -    
  21.199 -    lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
  21.200 -    ret = write(s->fd, buf, nb_sectors * 512);
  21.201 -    if (ret != nb_sectors * 512) 
  21.202 -        return -1;
  21.203 -    for (i = 0; i < nb_sectors; i++)
  21.204 -        set_bit(s->cow_bitmap, sector_num + i);
  21.205 -    return 0;
  21.206 -}
  21.207 -
  21.208 -static void cow_close(BlockDriverState *bs)
  21.209 -{
  21.210 -    BDRVCowState *s = bs->opaque;
  21.211 -    munmap(s->cow_bitmap_addr, s->cow_bitmap_size);
  21.212 -    close(s->fd);
  21.213 -}
  21.214 -
  21.215 -static int cow_create(const char *filename, int64_t image_sectors,
  21.216 -                      const char *image_filename, int flags)
  21.217 -{
  21.218 -    int fd, cow_fd;
  21.219 -    struct cow_header_v2 cow_header;
  21.220 -    struct stat st;
  21.221 -
  21.222 -    if (flags)
  21.223 -        return -ENOTSUP;
  21.224 -
  21.225 -    cow_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 
  21.226 -              0644);
  21.227 -    if (cow_fd < 0)
  21.228 -        return -1;
  21.229 -    memset(&cow_header, 0, sizeof(cow_header));
  21.230 -    cow_header.magic = cpu_to_be32(COW_MAGIC);
  21.231 -    cow_header.version = cpu_to_be32(COW_VERSION);
  21.232 -    if (image_filename) {
  21.233 -        fd = open(image_filename, O_RDONLY | O_BINARY);
  21.234 -        if (fd < 0) {
  21.235 -            close(cow_fd);
  21.236 -            return -1;
  21.237 -        }
  21.238 -        if (fstat(fd, &st) != 0) {
  21.239 -            close(fd);
  21.240 -            return -1;
  21.241 -        }
  21.242 -        close(fd);
  21.243 -        cow_header.mtime = cpu_to_be32(st.st_mtime);
  21.244 -        realpath(image_filename, cow_header.backing_file);
  21.245 -    }
  21.246 -    cow_header.sectorsize = cpu_to_be32(512);
  21.247 -    cow_header.size = cpu_to_be64(image_sectors * 512);
  21.248 -    write(cow_fd, &cow_header, sizeof(cow_header));
  21.249 -    /* resize to include at least all the bitmap */
  21.250 -    ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3));
  21.251 -    close(cow_fd);
  21.252 -    return 0;
  21.253 -}
  21.254 -
  21.255 -BlockDriver bdrv_cow = {
  21.256 -    "cow",
  21.257 -    sizeof(BDRVCowState),
  21.258 -    cow_probe,
  21.259 -    cow_open,
  21.260 -    cow_read,
  21.261 -    cow_write,
  21.262 -    cow_close,
  21.263 -    cow_create,
  21.264 -    cow_is_allocated,
  21.265 -};
  21.266 -#endif
    22.1 --- a/tools/ioemu/block-qcow.c	Wed Jul 12 16:34:39 2006 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,677 +0,0 @@
    22.4 -/*
    22.5 - * Block driver for the QCOW format
    22.6 - * 
    22.7 - * Copyright (c) 2004 Fabrice Bellard
    22.8 - * 
    22.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   22.10 - * of this software and associated documentation files (the "Software"), to deal
   22.11 - * in the Software without restriction, including without limitation the rights
   22.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   22.13 - * copies of the Software, and to permit persons to whom the Software is
   22.14 - * furnished to do so, subject to the following conditions:
   22.15 - *
   22.16 - * The above copyright notice and this permission notice shall be included in
   22.17 - * all copies or substantial portions of the Software.
   22.18 - *
   22.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   22.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   22.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   22.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   22.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   22.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   22.25 - * THE SOFTWARE.
   22.26 - */
   22.27 -#include "vl.h"
   22.28 -#include "block_int.h"
   22.29 -#include <zlib.h>
   22.30 -#include "aes.h"
   22.31 -
   22.32 -/**************************************************************/
   22.33 -/* QEMU COW block driver with compression and encryption support */
   22.34 -
   22.35 -#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
   22.36 -#define QCOW_VERSION 1
   22.37 -
   22.38 -#define QCOW_CRYPT_NONE 0
   22.39 -#define QCOW_CRYPT_AES  1
   22.40 -
   22.41 -#define QCOW_OFLAG_COMPRESSED (1LL << 63)
   22.42 -
   22.43 -typedef struct QCowHeader {
   22.44 -    uint32_t magic;
   22.45 -    uint32_t version;
   22.46 -    uint64_t backing_file_offset;
   22.47 -    uint32_t backing_file_size;
   22.48 -    uint32_t mtime;
   22.49 -    uint64_t size; /* in bytes */
   22.50 -    uint8_t cluster_bits;
   22.51 -    uint8_t l2_bits;
   22.52 -    uint32_t crypt_method;
   22.53 -    uint64_t l1_table_offset;
   22.54 -} QCowHeader;
   22.55 -
   22.56 -#define L2_CACHE_SIZE 16
   22.57 -
   22.58 -typedef struct BDRVQcowState {
   22.59 -    int fd;
   22.60 -    int cluster_bits;
   22.61 -    int cluster_size;
   22.62 -    int cluster_sectors;
   22.63 -    int l2_bits;
   22.64 -    int l2_size;
   22.65 -    int l1_size;
   22.66 -    uint64_t cluster_offset_mask;
   22.67 -    uint64_t l1_table_offset;
   22.68 -    uint64_t *l1_table;
   22.69 -    uint64_t *l2_cache;
   22.70 -    uint64_t l2_cache_offsets[L2_CACHE_SIZE];
   22.71 -    uint32_t l2_cache_counts[L2_CACHE_SIZE];
   22.72 -    uint8_t *cluster_cache;
   22.73 -    uint8_t *cluster_data;
   22.74 -    uint64_t cluster_cache_offset;
   22.75 -    uint32_t crypt_method; /* current crypt method, 0 if no key yet */
   22.76 -    uint32_t crypt_method_header;
   22.77 -    AES_KEY aes_encrypt_key;
   22.78 -    AES_KEY aes_decrypt_key;
   22.79 -} BDRVQcowState;
   22.80 -
   22.81 -static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset);
   22.82 -
   22.83 -static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
   22.84 -{
   22.85 -    const QCowHeader *cow_header = (const void *)buf;
   22.86 -
   22.87 -    if (be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
   22.88 -        be32_to_cpu(cow_header->version) == QCOW_VERSION) 
   22.89 -        return 100;
   22.90 -    else
   22.91 -        return 0;
   22.92 -}
   22.93 -
   22.94 -static int qcow_open(BlockDriverState *bs, const char *filename)
   22.95 -{
   22.96 -    BDRVQcowState *s = bs->opaque;
   22.97 -    int fd, len, i, shift;
   22.98 -    QCowHeader header;
   22.99 -    
  22.100 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
  22.101 -    if (fd < 0) {
  22.102 -        fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
  22.103 -        if (fd < 0)
  22.104 -            return -1;
  22.105 -    }
  22.106 -    s->fd = fd;
  22.107 -    if (read(fd, &header, sizeof(header)) != sizeof(header))
  22.108 -        goto fail;
  22.109 -    be32_to_cpus(&header.magic);
  22.110 -    be32_to_cpus(&header.version);
  22.111 -    be64_to_cpus(&header.backing_file_offset);
  22.112 -    be32_to_cpus(&header.backing_file_size);
  22.113 -    be32_to_cpus(&header.mtime);
  22.114 -    be64_to_cpus(&header.size);
  22.115 -    be32_to_cpus(&header.crypt_method);
  22.116 -    be64_to_cpus(&header.l1_table_offset);
  22.117 -    
  22.118 -    if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION)
  22.119 -        goto fail;
  22.120 -    if (header.size <= 1 || header.cluster_bits < 9)
  22.121 -        goto fail;
  22.122 -    if (header.crypt_method > QCOW_CRYPT_AES)
  22.123 -        goto fail;
  22.124 -    s->crypt_method_header = header.crypt_method;
  22.125 -    if (s->crypt_method_header)
  22.126 -        bs->encrypted = 1;
  22.127 -    s->cluster_bits = header.cluster_bits;
  22.128 -    s->cluster_size = 1 << s->cluster_bits;
  22.129 -    s->cluster_sectors = 1 << (s->cluster_bits - 9);
  22.130 -    s->l2_bits = header.l2_bits;
  22.131 -    s->l2_size = 1 << s->l2_bits;
  22.132 -    bs->total_sectors = header.size / 512;
  22.133 -    s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;
  22.134 -
  22.135 -    /* read the level 1 table */
  22.136 -    shift = s->cluster_bits + s->l2_bits;
  22.137 -    s->l1_size = (header.size + (1LL << shift) - 1) >> shift;
  22.138 -
  22.139 -    s->l1_table_offset = header.l1_table_offset;
  22.140 -    s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
  22.141 -    if (!s->l1_table)
  22.142 -        goto fail;
  22.143 -    lseek(fd, s->l1_table_offset, SEEK_SET);
  22.144 -    if (read(fd, s->l1_table, s->l1_size * sizeof(uint64_t)) != 
  22.145 -        s->l1_size * sizeof(uint64_t))
  22.146 -        goto fail;
  22.147 -    for(i = 0;i < s->l1_size; i++) {
  22.148 -        be64_to_cpus(&s->l1_table[i]);
  22.149 -    }
  22.150 -    /* alloc L2 cache */
  22.151 -    s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
  22.152 -    if (!s->l2_cache)
  22.153 -        goto fail;
  22.154 -    s->cluster_cache = qemu_malloc(s->cluster_size);
  22.155 -    if (!s->cluster_cache)
  22.156 -        goto fail;
  22.157 -    s->cluster_data = qemu_malloc(s->cluster_size);
  22.158 -    if (!s->cluster_data)
  22.159 -        goto fail;
  22.160 -    s->cluster_cache_offset = -1;
  22.161 -    
  22.162 -    /* read the backing file name */
  22.163 -    if (header.backing_file_offset != 0) {
  22.164 -        len = header.backing_file_size;
  22.165 -        if (len > 1023)
  22.166 -            len = 1023;
  22.167 -        lseek(fd, header.backing_file_offset, SEEK_SET);
  22.168 -        if (read(fd, bs->backing_file, len) != len)
  22.169 -            goto fail;
  22.170 -        bs->backing_file[len] = '\0';
  22.171 -    }
  22.172 -    return 0;
  22.173 -
  22.174 - fail:
  22.175 -    qemu_free(s->l1_table);
  22.176 -    qemu_free(s->l2_cache);
  22.177 -    qemu_free(s->cluster_cache);
  22.178 -    qemu_free(s->cluster_data);
  22.179 -    close(fd);
  22.180 -    return -1;
  22.181 -}
  22.182 -
  22.183 -static int qcow_set_key(BlockDriverState *bs, const char *key)
  22.184 -{
  22.185 -    BDRVQcowState *s = bs->opaque;
  22.186 -    uint8_t keybuf[16];
  22.187 -    int len, i;
  22.188 -    
  22.189 -    memset(keybuf, 0, 16);
  22.190 -    len = strlen(key);
  22.191 -    if (len > 16)
  22.192 -        len = 16;
  22.193 -    /* XXX: we could compress the chars to 7 bits to increase
  22.194 -       entropy */
  22.195 -    for(i = 0;i < len;i++) {
  22.196 -        keybuf[i] = key[i];
  22.197 -    }
  22.198 -    s->crypt_method = s->crypt_method_header;
  22.199 -
  22.200 -    if (AES_set_encrypt_key(keybuf, 128, &s->aes_encrypt_key) != 0)
  22.201 -        return -1;
  22.202 -    if (AES_set_decrypt_key(keybuf, 128, &s->aes_decrypt_key) != 0)
  22.203 -        return -1;
  22.204 -#if 0
  22.205 -    /* test */
  22.206 -    {
  22.207 -        uint8_t in[16];
  22.208 -        uint8_t out[16];
  22.209 -        uint8_t tmp[16];
  22.210 -        for(i=0;i<16;i++)
  22.211 -            in[i] = i;
  22.212 -        AES_encrypt(in, tmp, &s->aes_encrypt_key);
  22.213 -        AES_decrypt(tmp, out, &s->aes_decrypt_key);
  22.214 -        for(i = 0; i < 16; i++)
  22.215 -            printf(" %02x", tmp[i]);
  22.216 -        printf("\n");
  22.217 -        for(i = 0; i < 16; i++)
  22.218 -            printf(" %02x", out[i]);
  22.219 -        printf("\n");
  22.220 -    }
  22.221 -#endif
  22.222 -    return 0;
  22.223 -}
  22.224 -
  22.225 -/* The crypt function is compatible with the linux cryptoloop
  22.226 -   algorithm for < 4 GB images. NOTE: out_buf == in_buf is
  22.227 -   supported */
  22.228 -static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
  22.229 -                            uint8_t *out_buf, const uint8_t *in_buf,
  22.230 -                            int nb_sectors, int enc,
  22.231 -                            const AES_KEY *key)
  22.232 -{
  22.233 -    union {
  22.234 -        uint64_t ll[2];
  22.235 -        uint8_t b[16];
  22.236 -    } ivec;
  22.237 -    int i;
  22.238 -
  22.239 -    for(i = 0; i < nb_sectors; i++) {
  22.240 -        ivec.ll[0] = cpu_to_le64(sector_num);
  22.241 -        ivec.ll[1] = 0;
  22.242 -        AES_cbc_encrypt(in_buf, out_buf, 512, key, 
  22.243 -                        ivec.b, enc);
  22.244 -        sector_num++;
  22.245 -        in_buf += 512;
  22.246 -        out_buf += 512;
  22.247 -    }
  22.248 -}
  22.249 -
  22.250 -/* 'allocate' is:
  22.251 - *
  22.252 - * 0 to not allocate.
  22.253 - *
  22.254 - * 1 to allocate a normal cluster (for sector indexes 'n_start' to
  22.255 - * 'n_end')
  22.256 - *
  22.257 - * 2 to allocate a compressed cluster of size
  22.258 - * 'compressed_size'. 'compressed_size' must be > 0 and <
  22.259 - * cluster_size 
  22.260 - *
  22.261 - * return 0 if not allocated.
  22.262 - */
  22.263 -static uint64_t get_cluster_offset(BlockDriverState *bs,
  22.264 -                                   uint64_t offset, int allocate,
  22.265 -                                   int compressed_size,
  22.266 -                                   int n_start, int n_end)
  22.267 -{
  22.268 -    BDRVQcowState *s = bs->opaque;
  22.269 -    int min_index, i, j, l1_index, l2_index;
  22.270 -    uint64_t l2_offset, *l2_table, cluster_offset, tmp;
  22.271 -    uint32_t min_count;
  22.272 -    int new_l2_table;
  22.273 -    
  22.274 -    l1_index = offset >> (s->l2_bits + s->cluster_bits);
  22.275 -    l2_offset = s->l1_table[l1_index];
  22.276 -    new_l2_table = 0;
  22.277 -    if (!l2_offset) {
  22.278 -        if (!allocate)
  22.279 -            return 0;
  22.280 -        /* allocate a new l2 entry */
  22.281 -        l2_offset = lseek(s->fd, 0, SEEK_END);
  22.282 -        /* round to cluster size */
  22.283 -        l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
  22.284 -        /* update the L1 entry */
  22.285 -        s->l1_table[l1_index] = l2_offset;
  22.286 -        tmp = cpu_to_be64(l2_offset);
  22.287 -        lseek(s->fd, s->l1_table_offset + l1_index * sizeof(tmp), SEEK_SET);
  22.288 -        if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
  22.289 -            return 0;
  22.290 -        new_l2_table = 1;
  22.291 -    }
  22.292 -    for(i = 0; i < L2_CACHE_SIZE; i++) {
  22.293 -        if (l2_offset == s->l2_cache_offsets[i]) {
  22.294 -            /* increment the hit count */
  22.295 -            if (++s->l2_cache_counts[i] == 0xffffffff) {
  22.296 -                for(j = 0; j < L2_CACHE_SIZE; j++) {
  22.297 -                    s->l2_cache_counts[j] >>= 1;
  22.298 -                }
  22.299 -            }
  22.300 -            l2_table = s->l2_cache + (i << s->l2_bits);
  22.301 -            goto found;
  22.302 -        }
  22.303 -    }
  22.304 -    /* not found: load a new entry in the least used one */
  22.305 -    min_index = 0;
  22.306 -    min_count = 0xffffffff;
  22.307 -    for(i = 0; i < L2_CACHE_SIZE; i++) {
  22.308 -        if (s->l2_cache_counts[i] < min_count) {
  22.309 -            min_count = s->l2_cache_counts[i];
  22.310 -            min_index = i;
  22.311 -        }
  22.312 -    }
  22.313 -    l2_table = s->l2_cache + (min_index << s->l2_bits);
  22.314 -    lseek(s->fd, l2_offset, SEEK_SET);
  22.315 -    if (new_l2_table) {
  22.316 -        memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
  22.317 -        if (write(s->fd, l2_table, s->l2_size * sizeof(uint64_t)) !=
  22.318 -            s->l2_size * sizeof(uint64_t))
  22.319 -            return 0;
  22.320 -    } else {
  22.321 -        if (read(s->fd, l2_table, s->l2_size * sizeof(uint64_t)) != 
  22.322 -            s->l2_size * sizeof(uint64_t))
  22.323 -            return 0;
  22.324 -    }
  22.325 -    s->l2_cache_offsets[min_index] = l2_offset;
  22.326 -    s->l2_cache_counts[min_index] = 1;
  22.327 - found:
  22.328 -    l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
  22.329 -    cluster_offset = be64_to_cpu(l2_table[l2_index]);
  22.330 -    if (!cluster_offset || 
  22.331 -        ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
  22.332 -        if (!allocate)
  22.333 -            return 0;
  22.334 -        /* allocate a new cluster */
  22.335 -        if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
  22.336 -            (n_end - n_start) < s->cluster_sectors) {
  22.337 -            /* if the cluster is already compressed, we must
  22.338 -               decompress it in the case it is not completely
  22.339 -               overwritten */
  22.340 -            if (decompress_cluster(s, cluster_offset) < 0)
  22.341 -                return 0;
  22.342 -            cluster_offset = lseek(s->fd, 0, SEEK_END);
  22.343 -            cluster_offset = (cluster_offset + s->cluster_size - 1) & 
  22.344 -                ~(s->cluster_size - 1);
  22.345 -            /* write the cluster content */
  22.346 -            lseek(s->fd, cluster_offset, SEEK_SET);
  22.347 -            if (write(s->fd, s->cluster_cache, s->cluster_size) != 
  22.348 -                s->cluster_size)
  22.349 -                return -1;
  22.350 -        } else {
  22.351 -            cluster_offset = lseek(s->fd, 0, SEEK_END);
  22.352 -            if (allocate == 1) {
  22.353 -                /* round to cluster size */
  22.354 -                cluster_offset = (cluster_offset + s->cluster_size - 1) & 
  22.355 -                    ~(s->cluster_size - 1);
  22.356 -                ftruncate(s->fd, cluster_offset + s->cluster_size);
  22.357 -                /* if encrypted, we must initialize the cluster
  22.358 -                   content which won't be written */
  22.359 -                if (s->crypt_method && 
  22.360 -                    (n_end - n_start) < s->cluster_sectors) {
  22.361 -                    uint64_t start_sect;
  22.362 -                    start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
  22.363 -                    memset(s->cluster_data + 512, 0xaa, 512);
  22.364 -                    for(i = 0; i < s->cluster_sectors; i++) {
  22.365 -                        if (i < n_start || i >= n_end) {
  22.366 -                            encrypt_sectors(s, start_sect + i, 
  22.367 -                                            s->cluster_data, 
  22.368 -                                            s->cluster_data + 512, 1, 1,
  22.369 -                                            &s->aes_encrypt_key);
  22.370 -                            lseek(s->fd, cluster_offset + i * 512, SEEK_SET);
  22.371 -                            if (write(s->fd, s->cluster_data, 512) != 512)
  22.372 -                                return -1;
  22.373 -                        }
  22.374 -                    }
  22.375 -                }
  22.376 -            } else {
  22.377 -                cluster_offset |= QCOW_OFLAG_COMPRESSED | 
  22.378 -                    (uint64_t)compressed_size << (63 - s->cluster_bits);
  22.379 -            }
  22.380 -        }
  22.381 -        /* update L2 table */
  22.382 -        tmp = cpu_to_be64(cluster_offset);
  22.383 -        l2_table[l2_index] = tmp;
  22.384 -        lseek(s->fd, l2_offset + l2_index * sizeof(tmp), SEEK_SET);
  22.385 -        if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
  22.386 -            return 0;
  22.387 -    }
  22.388 -    return cluster_offset;
  22.389 -}
  22.390 -
  22.391 -static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num, 
  22.392 -                             int nb_sectors, int *pnum)
  22.393 -{
  22.394 -    BDRVQcowState *s = bs->opaque;
  22.395 -    int index_in_cluster, n;
  22.396 -    uint64_t cluster_offset;
  22.397 -
  22.398 -    cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
  22.399 -    index_in_cluster = sector_num & (s->cluster_sectors - 1);
  22.400 -    n = s->cluster_sectors - index_in_cluster;
  22.401 -    if (n > nb_sectors)
  22.402 -        n = nb_sectors;
  22.403 -    *pnum = n;
  22.404 -    return (cluster_offset != 0);
  22.405 -}
  22.406 -
  22.407 -static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
  22.408 -                             const uint8_t *buf, int buf_size)
  22.409 -{
  22.410 -    z_stream strm1, *strm = &strm1;
  22.411 -    int ret, out_len;
  22.412 -
  22.413 -    memset(strm, 0, sizeof(*strm));
  22.414 -
  22.415 -    strm->next_in = (uint8_t *)buf;
  22.416 -    strm->avail_in = buf_size;
  22.417 -    strm->next_out = out_buf;
  22.418 -    strm->avail_out = out_buf_size;
  22.419 -
  22.420 -    ret = inflateInit2(strm, -12);
  22.421 -    if (ret != Z_OK)
  22.422 -        return -1;
  22.423 -    ret = inflate(strm, Z_FINISH);
  22.424 -    out_len = strm->next_out - out_buf;
  22.425 -    if ((ret != Z_STREAM_END && ret != Z_BUF_ERROR) ||
  22.426 -        out_len != out_buf_size) {
  22.427 -        inflateEnd(strm);
  22.428 -        return -1;
  22.429 -    }
  22.430 -    inflateEnd(strm);
  22.431 -    return 0;
  22.432 -}
  22.433 -                              
  22.434 -static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
  22.435 -{
  22.436 -    int ret, csize;
  22.437 -    uint64_t coffset;
  22.438 -
  22.439 -    coffset = cluster_offset & s->cluster_offset_mask;
  22.440 -    if (s->cluster_cache_offset != coffset) {
  22.441 -        csize = cluster_offset >> (63 - s->cluster_bits);
  22.442 -        csize &= (s->cluster_size - 1);
  22.443 -        lseek(s->fd, coffset, SEEK_SET);
  22.444 -        ret = read(s->fd, s->cluster_data, csize);
  22.445 -        if (ret != csize) 
  22.446 -            return -1;
  22.447 -        if (decompress_buffer(s->cluster_cache, s->cluster_size,
  22.448 -                              s->cluster_data, csize) < 0) {
  22.449 -            return -1;
  22.450 -        }
  22.451 -        s->cluster_cache_offset = coffset;
  22.452 -    }
  22.453 -    return 0;
  22.454 -}
  22.455 -
  22.456 -static int qcow_read(BlockDriverState *bs, int64_t sector_num, 
  22.457 -                     uint8_t *buf, int nb_sectors)
  22.458 -{
  22.459 -    BDRVQcowState *s = bs->opaque;
  22.460 -    int ret, index_in_cluster, n;
  22.461 -    uint64_t cluster_offset;
  22.462 -    
  22.463 -    while (nb_sectors > 0) {
  22.464 -        cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
  22.465 -        index_in_cluster = sector_num & (s->cluster_sectors - 1);
  22.466 -        n = s->cluster_sectors - index_in_cluster;
  22.467 -        if (n > nb_sectors)
  22.468 -            n = nb_sectors;
  22.469 -        if (!cluster_offset) {
  22.470 -            memset(buf, 0, 512 * n);
  22.471 -        } else if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
  22.472 -            if (decompress_cluster(s, cluster_offset) < 0)
  22.473 -                return -1;
  22.474 -            memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
  22.475 -        } else {
  22.476 -            lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
  22.477 -            ret = read(s->fd, buf, n * 512);
  22.478 -            if (ret != n * 512) 
  22.479 -                return -1;
  22.480 -            if (s->crypt_method) {
  22.481 -                encrypt_sectors(s, sector_num, buf, buf, n, 0, 
  22.482 -                                &s->aes_decrypt_key);
  22.483 -            }
  22.484 -        }
  22.485 -        nb_sectors -= n;
  22.486 -        sector_num += n;
  22.487 -        buf += n * 512;
  22.488 -    }
  22.489 -    return 0;
  22.490 -}
  22.491 -
  22.492 -static int qcow_write(BlockDriverState *bs, int64_t sector_num, 
  22.493 -                     const uint8_t *buf, int nb_sectors)
  22.494 -{
  22.495 -    BDRVQcowState *s = bs->opaque;
  22.496 -    int ret, index_in_cluster, n;
  22.497 -    uint64_t cluster_offset;
  22.498 -    
  22.499 -    while (nb_sectors > 0) {
  22.500 -        index_in_cluster = sector_num & (s->cluster_sectors - 1);
  22.501 -        n = s->cluster_sectors - index_in_cluster;
  22.502 -        if (n > nb_sectors)
  22.503 -            n = nb_sectors;
  22.504 -        cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0, 
  22.505 -                                            index_in_cluster, 
  22.506 -                                            index_in_cluster + n);
  22.507 -        if (!cluster_offset)
  22.508 -            return -1;
  22.509 -        lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
  22.510 -        if (s->crypt_method) {
  22.511 -            encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
  22.512 -                            &s->aes_encrypt_key);
  22.513 -            ret = write(s->fd, s->cluster_data, n * 512);
  22.514 -        } else {
  22.515 -            ret = write(s->fd, buf, n * 512);
  22.516 -        }
  22.517 -        if (ret != n * 512) 
  22.518 -            return -1;
  22.519 -        nb_sectors -= n;
  22.520 -        sector_num += n;
  22.521 -        buf += n * 512;
  22.522 -    }
  22.523 -    s->cluster_cache_offset = -1; /* disable compressed cache */
  22.524 -    return 0;
  22.525 -}
  22.526 -
  22.527 -static void qcow_close(BlockDriverState *bs)
  22.528 -{
  22.529 -    BDRVQcowState *s = bs->opaque;
  22.530 -    qemu_free(s->l1_table);
  22.531 -    qemu_free(s->l2_cache);
  22.532 -    qemu_free(s->cluster_cache);
  22.533 -    qemu_free(s->cluster_data);
  22.534 -    close(s->fd);
  22.535 -}
  22.536 -
  22.537 -static int qcow_create(const char *filename, int64_t total_size,
  22.538 -                      const char *backing_file, int flags)
  22.539 -{
  22.540 -    int fd, header_size, backing_filename_len, l1_size, i, shift;
  22.541 -    QCowHeader header;
  22.542 -    char backing_filename[1024];
  22.543 -    uint64_t tmp;
  22.544 -    struct stat st;
  22.545 -
  22.546 -    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 
  22.547 -              0644);
  22.548 -    if (fd < 0)
  22.549 -        return -1;
  22.550 -    memset(&header, 0, sizeof(header));
  22.551 -    header.magic = cpu_to_be32(QCOW_MAGIC);
  22.552 -    header.version = cpu_to_be32(QCOW_VERSION);
  22.553 -    header.size = cpu_to_be64(total_size * 512);
  22.554 -    header_size = sizeof(header);
  22.555 -    backing_filename_len = 0;
  22.556 -    if (backing_file) {
  22.557 -        realpath(backing_file, backing_filename);
  22.558 -        if (stat(backing_filename, &st) != 0) {
  22.559 -            return -1;
  22.560 -        }
  22.561 -        header.mtime = cpu_to_be32(st.st_mtime);
  22.562 -        header.backing_file_offset = cpu_to_be64(header_size);
  22.563 -        backing_filename_len = strlen(backing_filename);
  22.564 -        header.backing_file_size = cpu_to_be32(backing_filename_len);
  22.565 -        header_size += backing_filename_len;
  22.566 -        header.cluster_bits = 9; /* 512 byte cluster to avoid copying
  22.567 -                                    unmodifyed sectors */
  22.568 -        header.l2_bits = 12; /* 32 KB L2 tables */
  22.569 -    } else {
  22.570 -        header.cluster_bits = 12; /* 4 KB clusters */
  22.571 -        header.l2_bits = 9; /* 4 KB L2 tables */
  22.572 -    }
  22.573 -    header_size = (header_size + 7) & ~7;
  22.574 -    shift = header.cluster_bits + header.l2_bits;
  22.575 -    l1_size = ((total_size * 512) + (1LL << shift) - 1) >> shift;
  22.576 -
  22.577 -    header.l1_table_offset = cpu_to_be64(header_size);
  22.578 -    if (flags) {
  22.579 -        header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
  22.580 -    } else {
  22.581 -        header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
  22.582 -    }
  22.583 -    
  22.584 -    /* write all the data */
  22.585 -    write(fd, &header, sizeof(header));
  22.586 -    if (backing_file) {
  22.587 -        write(fd, backing_filename, backing_filename_len);
  22.588 -    }
  22.589 -    lseek(fd, header_size, SEEK_SET);
  22.590 -    tmp = 0;
  22.591 -    for(i = 0;i < l1_size; i++) {
  22.592 -        write(fd, &tmp, sizeof(tmp));
  22.593 -    }
  22.594 -    close(fd);
  22.595 -    return 0;
  22.596 -}
  22.597 -
  22.598 -int qcow_get_cluster_size(BlockDriverState *bs)
  22.599 -{
  22.600 -    BDRVQcowState *s = bs->opaque;
  22.601 -    if (bs->drv != &bdrv_qcow)
  22.602 -        return -1;
  22.603 -    return s->cluster_size;
  22.604 -}
  22.605 -
  22.606 -/* XXX: put compressed sectors first, then all the cluster aligned
  22.607 -   tables to avoid losing bytes in alignment */
  22.608 -int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num, 
  22.609 -                          const uint8_t *buf)
  22.610 -{
  22.611 -    BDRVQcowState *s = bs->opaque;
  22.612 -    z_stream strm;
  22.613 -    int ret, out_len;
  22.614 -    uint8_t *out_buf;
  22.615 -    uint64_t cluster_offset;
  22.616 -
  22.617 -    if (bs->drv != &bdrv_qcow)
  22.618 -        return -1;
  22.619 -
  22.620 -    out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
  22.621 -    if (!out_buf)
  22.622 -        return -1;
  22.623 -
  22.624 -    /* best compression, small window, no zlib header */
  22.625 -    memset(&strm, 0, sizeof(strm));
  22.626 -    ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
  22.627 -                       Z_DEFLATED, -12, 
  22.628 -                       9, Z_DEFAULT_STRATEGY);
  22.629 -    if (ret != 0) {
  22.630 -        qemu_free(out_buf);
  22.631 -        return -1;
  22.632 -    }
  22.633 -
  22.634 -    strm.avail_in = s->cluster_size;
  22.635 -    strm.next_in = (uint8_t *)buf;
  22.636 -    strm.avail_out = s->cluster_size;
  22.637 -    strm.next_out = out_buf;
  22.638 -
  22.639 -    ret = deflate(&strm, Z_FINISH);
  22.640 -    if (ret != Z_STREAM_END && ret != Z_OK) {
  22.641 -        qemu_free(out_buf);
  22.642 -        deflateEnd(&strm);
  22.643 -        return -1;
  22.644 -    }
  22.645 -    out_len = strm.next_out - out_buf;
  22.646 -
  22.647 -    deflateEnd(&strm);
  22.648 -
  22.649 -    if (ret != Z_STREAM_END || out_len >= s->cluster_size) {
  22.650 -        /* could not compress: write normal cluster */
  22.651 -        qcow_write(bs, sector_num, buf, s->cluster_sectors);
  22.652 -    } else {
  22.653 -        cluster_offset = get_cluster_offset(bs, sector_num << 9, 2, 
  22.654 -                                            out_len, 0, 0);
  22.655 -        cluster_offset &= s->cluster_offset_mask;
  22.656 -        lseek(s->fd, cluster_offset, SEEK_SET);
  22.657 -        if (write(s->fd, out_buf, out_len) != out_len) {
  22.658 -            qemu_free(out_buf);
  22.659 -            return -1;
  22.660 -        }
  22.661 -    }
  22.662 -    
  22.663 -    qemu_free(out_buf);
  22.664 -    return 0;
  22.665 -}
  22.666 -
  22.667 -BlockDriver bdrv_qcow = {
  22.668 -    "qcow",
  22.669 -    sizeof(BDRVQcowState),
  22.670 -    qcow_probe,
  22.671 -    qcow_open,
  22.672 -    qcow_read,
  22.673 -    qcow_write,
  22.674 -    qcow_close,
  22.675 -    qcow_create,
  22.676 -    qcow_is_allocated,
  22.677 -    qcow_set_key,
  22.678 -};
  22.679 -
  22.680 -
    23.1 --- a/tools/ioemu/block-vmdk.c	Wed Jul 12 16:34:39 2006 +0100
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,279 +0,0 @@
    23.4 -/*
    23.5 - * Block driver for the VMDK format
    23.6 - * 
    23.7 - * Copyright (c) 2004 Fabrice Bellard
    23.8 - * 
    23.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   23.10 - * of this software and associated documentation files (the "Software"), to deal
   23.11 - * in the Software without restriction, including without limitation the rights
   23.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   23.13 - * copies of the Software, and to permit persons to whom the Software is
   23.14 - * furnished to do so, subject to the following conditions:
   23.15 - *
   23.16 - * The above copyright notice and this permission notice shall be included in
   23.17 - * all copies or substantial portions of the Software.
   23.18 - *
   23.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   23.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   23.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   23.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   23.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   23.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   23.25 - * THE SOFTWARE.
   23.26 - */
   23.27 -#include "vl.h"
   23.28 -#include "block_int.h"
   23.29 -
   23.30 -/* XXX: this code is untested */
   23.31 -/* XXX: add write support */
   23.32 -
   23.33 -#define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
   23.34 -#define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
   23.35 -
   23.36 -typedef struct {
   23.37 -    uint32_t version;
   23.38 -    uint32_t flags;
   23.39 -    uint32_t disk_sectors;
   23.40 -    uint32_t granularity;
   23.41 -    uint32_t l1dir_offset;
   23.42 -    uint32_t l1dir_size;
   23.43 -    uint32_t file_sectors;
   23.44 -    uint32_t cylinders;
   23.45 -    uint32_t heads;
   23.46 -    uint32_t sectors_per_track;
   23.47 -} VMDK3Header;
   23.48 -
   23.49 -typedef struct {
   23.50 -    uint32_t version;
   23.51 -    uint32_t flags;
   23.52 -    int64_t capacity;
   23.53 -    int64_t granularity;
   23.54 -    int64_t desc_offset;
   23.55 -    int64_t desc_size;
   23.56 -    int32_t num_gtes_per_gte;
   23.57 -    int64_t rgd_offset;
   23.58 -    int64_t gd_offset;
   23.59 -    int64_t grain_offset;
   23.60 -    char filler[1];
   23.61 -    char check_bytes[4];
   23.62 -} VMDK4Header;
   23.63 -
   23.64 -#define L2_CACHE_SIZE 16
   23.65 -
   23.66 -typedef struct BDRVVmdkState {
   23.67 -    int fd;
   23.68 -    int64_t l1_table_offset;
   23.69 -    uint32_t *l1_table;
   23.70 -    unsigned int l1_size;
   23.71 -    uint32_t l1_entry_sectors;
   23.72 -
   23.73 -    unsigned int l2_size;
   23.74 -    uint32_t *l2_cache;
   23.75 -    uint32_t l2_cache_offsets[L2_CACHE_SIZE];
   23.76 -    uint32_t l2_cache_counts[L2_CACHE_SIZE];
   23.77 -
   23.78 -    unsigned int cluster_sectors;
   23.79 -} BDRVVmdkState;
   23.80 -
   23.81 -static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
   23.82 -{
   23.83 -    uint32_t magic;
   23.84 -
   23.85 -    if (buf_size < 4)
   23.86 -        return 0;
   23.87 -    magic = be32_to_cpu(*(uint32_t *)buf);
   23.88 -    if (magic == VMDK3_MAGIC ||
   23.89 -        magic == VMDK4_MAGIC)
   23.90 -        return 100;
   23.91 -    else
   23.92 -        return 0;
   23.93 -}
   23.94 -
   23.95 -static int vmdk_open(BlockDriverState *bs, const char *filename)
   23.96 -{
   23.97 -    BDRVVmdkState *s = bs->opaque;
   23.98 -    int fd, i;
   23.99 -    uint32_t magic;
  23.100 -    int l1_size;
  23.101 -
  23.102 -    fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
  23.103 -    if (fd < 0)
  23.104 -        return -1;
  23.105 -    if (read(fd, &magic, sizeof(magic)) != sizeof(magic))
  23.106 -        goto fail;
  23.107 -    magic = be32_to_cpu(magic);
  23.108 -    if (magic == VMDK3_MAGIC) {
  23.109 -        VMDK3Header header;
  23.110 -        if (read(fd, &header, sizeof(header)) != 
  23.111 -            sizeof(header))
  23.112 -            goto fail;
  23.113 -        s->cluster_sectors = le32_to_cpu(header.granularity);
  23.114 -        s->l2_size = 1 << 9;
  23.115 -        s->l1_size = 1 << 6;
  23.116 -        bs->total_sectors = le32_to_cpu(header.disk_sectors);
  23.117 -        s->l1_table_offset = le32_to_cpu(header.l1dir_offset) * 512;
  23.118 -        s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
  23.119 -    } else if (magic == VMDK4_MAGIC) {
  23.120 -        VMDK4Header header;
  23.121 -        
  23.122 -        if (read(fd, &header, sizeof(header)) != sizeof(header))
  23.123 -            goto fail;
  23.124 -        bs->total_sectors = le32_to_cpu(header.capacity);
  23.125 -        s->cluster_sectors = le32_to_cpu(header.granularity);
  23.126 -        s->l2_size = le32_to_cpu(header.num_gtes_per_gte);
  23.127 -        s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
  23.128 -        if (s->l1_entry_sectors <= 0)
  23.129 -            goto fail;
  23.130 -        s->l1_size = (bs->total_sectors + s->l1_entry_sectors - 1) 
  23.131 -            / s->l1_entry_sectors;
  23.132 -        s->l1_table_offset = le64_to_cpu(header.rgd_offset) * 512;
  23.133 -    } else {
  23.134 -        goto fail;
  23.135 -    }
  23.136 -    /* read the L1 table */
  23.137 -    l1_size = s->l1_size * sizeof(uint32_t);
  23.138 -    s->l1_table = qemu_malloc(l1_size);
  23.139 -    if (!s->l1_table)
  23.140 -        goto fail;
  23.141 -    if (lseek(fd, s->l1_table_offset, SEEK_SET) == -1)
  23.142 -        goto fail;
  23.143 -    if (read(fd, s->l1_table, l1_size) != l1_size)
  23.144 -        goto fail;
  23.145 -    for(i = 0; i < s->l1_size; i++) {
  23.146 -        le32_to_cpus(&s->l1_table[i]);
  23.147 -    }
  23.148 -
  23.149 -    s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint32_t));
  23.150 -    if (!s->l2_cache)
  23.151 -        goto fail;
  23.152 -    s->fd = fd;
  23.153 -    /* XXX: currently only read only */
  23.154 -    bs->read_only = 1;
  23.155 -    return 0;
  23.156 - fail:
  23.157 -    qemu_free(s->l1_table);
  23.158 -    qemu_free(s->l2_cache);
  23.159 -    close(fd);
  23.160 -    return -1;
  23.161 -}
  23.162 -
  23.163 -static uint64_t get_cluster_offset(BlockDriverState *bs,
  23.164 -                                   uint64_t offset)
  23.165 -{
  23.166 -    BDRVVmdkState *s = bs->opaque;
  23.167 -    unsigned int l1_index, l2_offset, l2_index;
  23.168 -    int min_index, i, j;
  23.169 -    uint32_t min_count, *l2_table;
  23.170 -    uint64_t cluster_offset;
  23.171 -    
  23.172 -    l1_index = (offset >> 9) / s->l1_entry_sectors;
  23.173 -    if (l1_index >= s->l1_size)
  23.174 -        return 0;
  23.175 -    l2_offset = s->l1_table[l1_index];
  23.176 -    if (!l2_offset)
  23.177 -        return 0;
  23.178 -    
  23.179 -    for(i = 0; i < L2_CACHE_SIZE; i++) {
  23.180 -        if (l2_offset == s->l2_cache_offsets[i]) {
  23.181 -            /* increment the hit count */
  23.182 -            if (++s->l2_cache_counts[i] == 0xffffffff) {
  23.183 -                for(j = 0; j < L2_CACHE_SIZE; j++) {
  23.184 -                    s->l2_cache_counts[j] >>= 1;
  23.185 -                }
  23.186 -            }
  23.187 -            l2_table = s->l2_cache + (i * s->l2_size);
  23.188 -            goto found;
  23.189 -        }
  23.190 -    }
  23.191 -    /* not found: load a new entry in the least used one */
  23.192 -    min_index = 0;
  23.193 -    min_count = 0xffffffff;
  23.194 -    for(i = 0; i < L2_CACHE_SIZE; i++) {
  23.195 -        if (s->l2_cache_counts[i] < min_count) {
  23.196 -            min_count = s->l2_cache_counts[i];
  23.197 -            min_index = i;
  23.198 -        }
  23.199 -    }
  23.200 -    l2_table = s->l2_cache + (min_index * s->l2_size);
  23.201 -    lseek(s->fd, (int64_t)l2_offset * 512, SEEK_SET);
  23.202 -    if (read(s->fd, l2_table, s->l2_size * sizeof(uint32_t)) != 
  23.203 -        s->l2_size * sizeof(uint32_t))
  23.204 -        return 0;
  23.205 -    s->l2_cache_offsets[min_index] = l2_offset;
  23.206 -    s->l2_cache_counts[min_index] = 1;
  23.207 - found:
  23.208 -    l2_index = ((offset >> 9) / s->cluster_sectors) % s->l2_size;
  23.209 -    cluster_offset = le32_to_cpu(l2_table[l2_index]);
  23.210 -    cluster_offset <<= 9;
  23.211 -    return cluster_offset;
  23.212 -}
  23.213 -
  23.214 -static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num, 
  23.215 -                             int nb_sectors, int *pnum)
  23.216 -{
  23.217 -    BDRVVmdkState *s = bs->opaque;
  23.218 -    int index_in_cluster, n;
  23.219 -    uint64_t cluster_offset;
  23.220 -
  23.221 -    cluster_offset = get_cluster_offset(bs, sector_num << 9);
  23.222 -    index_in_cluster = sector_num % s->cluster_sectors;
  23.223 -    n = s->cluster_sectors - index_in_cluster;
  23.224 -    if (n > nb_sectors)
  23.225 -        n = nb_sectors;
  23.226 -    *pnum = n;
  23.227 -    return (cluster_offset != 0);
  23.228 -}
  23.229 -
  23.230 -static int vmdk_read(BlockDriverState *bs, int64_t sector_num, 
  23.231 -                    uint8_t *buf, int nb_sectors)
  23.232 -{
  23.233 -    BDRVVmdkState *s = bs->opaque;
  23.234 -    int ret, index_in_cluster, n;
  23.235 -    uint64_t cluster_offset;
  23.236 -    
  23.237 -    while (nb_sectors > 0) {
  23.238 -        cluster_offset = get_cluster_offset(bs, sector_num << 9);
  23.239 -        index_in_cluster = sector_num % s->cluster_sectors;
  23.240 -        n = s->cluster_sectors - index_in_cluster;
  23.241 -        if (n > nb_sectors)
  23.242 -            n = nb_sectors;
  23.243 -        if (!cluster_offset) {
  23.244 -            memset(buf, 0, 512 * n);
  23.245 -        } else {
  23.246 -            lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
  23.247 -            ret = read(s->fd, buf, n * 512);
  23.248 -            if (ret != n * 512) 
  23.249 -                return -1;
  23.250 -        }
  23.251 -        nb_sectors -= n;
  23.252 -        sector_num += n;
  23.253 -        buf += n * 512;
  23.254 -    }
  23.255 -    return 0;
  23.256 -}
  23.257 -
  23.258 -static int vmdk_write(BlockDriverState *bs, int64_t sector_num, 
  23.259 -                     const uint8_t *buf, int nb_sectors)
  23.260 -{
  23.261 -    return -1;
  23.262 -}
  23.263 -
  23.264 -static void vmdk_close(BlockDriverState *bs)
  23.265 -{
  23.266 -    BDRVVmdkState *s = bs->opaque;
  23.267 -    qemu_free(s->l1_table);
  23.268 -    qemu_free(s->l2_cache);
  23.269 -    close(s->fd);
  23.270 -}
  23.271 -
  23.272 -BlockDriver bdrv_vmdk = {
  23.273 -    "vmdk",
  23.274 -    sizeof(BDRVVmdkState),
  23.275 -    vmdk_probe,
  23.276 -    vmdk_open,
  23.277 -    vmdk_read,
  23.278 -    vmdk_write,
  23.279 -    vmdk_close,
  23.280 -    NULL, /* no create yet */
  23.281 -    vmdk_is_allocated,
  23.282 -};
    24.1 --- a/tools/ioemu/block.c	Wed Jul 12 16:34:39 2006 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,549 +0,0 @@
    24.4 -/*
    24.5 - * QEMU System Emulator block driver
    24.6 - * 
    24.7 - * Copyright (c) 2003 Fabrice Bellard
    24.8 - * 
    24.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   24.10 - * of this software and associated documentation files (the "Software"), to deal
   24.11 - * in the Software without restriction, including without limitation the rights
   24.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   24.13 - * copies of the Software, and to permit persons to whom the Software is
   24.14 - * furnished to do so, subject to the following conditions:
   24.15 - *
   24.16 - * The above copyright notice and this permission notice shall be included in
   24.17 - * all copies or substantial portions of the Software.
   24.18 - *
   24.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   24.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   24.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   24.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   24.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   24.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   24.25 - * THE SOFTWARE.
   24.26 - */
   24.27 -#include "vl.h"
   24.28 -#include "block_int.h"
   24.29 -
   24.30 -static BlockDriverState *bdrv_first;
   24.31 -static BlockDriver *first_drv;
   24.32 -
   24.33 -void bdrv_register(BlockDriver *bdrv)
   24.34 -{
   24.35 -    bdrv->next = first_drv;
   24.36 -    first_drv = bdrv;
   24.37 -}
   24.38 -
   24.39 -/* create a new block device (by default it is empty) */
   24.40 -BlockDriverState *bdrv_new(const char *device_name)
   24.41 -{
   24.42 -    BlockDriverState **pbs, *bs;
   24.43 -
   24.44 -    bs = qemu_mallocz(sizeof(BlockDriverState));
   24.45 -    if(!bs)
   24.46 -        return NULL;
   24.47 -    pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
   24.48 -    if (device_name[0] != '\0') {
   24.49 -        /* insert at the end */
   24.50 -        pbs = &bdrv_first;
   24.51 -        while (*pbs != NULL)
   24.52 -            pbs = &(*pbs)->next;
   24.53 -        *pbs = bs;
   24.54 -    }
   24.55 -    return bs;
   24.56 -}
   24.57 -
   24.58 -BlockDriver *bdrv_find_format(const char *format_name)
   24.59 -{
   24.60 -    BlockDriver *drv1;
   24.61 -    for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) {
   24.62 -        if (!strcmp(drv1->format_name, format_name))
   24.63 -            return drv1;
   24.64 -    }
   24.65 -    return NULL;
   24.66 -}
   24.67 -
   24.68 -int bdrv_create(BlockDriver *drv, 
   24.69 -                const char *filename, int64_t size_in_sectors,
   24.70 -                const char *backing_file, int flags)
   24.71 -{
   24.72 -    if (!drv->bdrv_create)
   24.73 -        return -ENOTSUP;
   24.74 -    return drv->bdrv_create(filename, size_in_sectors, backing_file, flags);
   24.75 -}
   24.76 -
   24.77 -static BlockDriver *find_image_format(const char *filename)
   24.78 -{
   24.79 -    int fd, ret, score, score_max;
   24.80 -    BlockDriver *drv1, *drv;
   24.81 -    uint8_t buf[1024];
   24.82 -
   24.83 -    fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   24.84 -    if (fd < 0)
   24.85 -        return NULL;
   24.86 -    ret = read(fd, buf, sizeof(buf));
   24.87 -    if (ret < 0) {
   24.88 -        close(fd);
   24.89 -        return NULL;
   24.90 -    }
   24.91 -    close(fd);
   24.92 -    
   24.93 -    drv = NULL;
   24.94 -    score_max = 0;
   24.95 -    for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) {
   24.96 -        score = drv1->bdrv_probe(buf, ret, filename);
   24.97 -        if (score > score_max) {
   24.98 -            score_max = score;
   24.99 -            drv = drv1;
  24.100 -        }
  24.101 -    }
  24.102 -    return drv;
  24.103 -}
  24.104 -
  24.105 -int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
  24.106 -{
  24.107 -    return bdrv_open2(bs, filename, snapshot, NULL);
  24.108 -}
  24.109 -
  24.110 -int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot,
  24.111 -               BlockDriver *drv)
  24.112 -{
  24.113 -    int ret;
  24.114 -    
  24.115 -    bs->read_only = 0;
  24.116 -    bs->is_temporary = 0;
  24.117 -    bs->encrypted = 0;
  24.118 -    
  24.119 -    pstrcpy(bs->filename, sizeof(bs->filename), filename);
  24.120 -    if (!drv) {
  24.121 -        drv = find_image_format(filename);
  24.122 -        if (!drv)
  24.123 -            return -1;
  24.124 -    }
  24.125 -    bs->drv = drv;
  24.126 -    bs->opaque = qemu_mallocz(drv->instance_size);
  24.127 -    if (bs->opaque == NULL && drv->instance_size > 0)
  24.128 -        return -1;
  24.129 -    
  24.130 -    ret = drv->bdrv_open(bs, filename);
  24.131 -    if (ret < 0) {
  24.132 -        qemu_free(bs->opaque);
  24.133 -        return -1;
  24.134 -    }
  24.135 -#ifndef _WIN32
  24.136 -    if (bs->is_temporary) {
  24.137 -        unlink(filename);
  24.138 -    }
  24.139 -#endif
  24.140 -    if (bs->backing_file[0] != '\0' && drv->bdrv_is_allocated) {
  24.141 -        /* if there is a backing file, use it */
  24.142 -        bs->backing_hd = bdrv_new("");
  24.143 -        if (!bs->backing_hd) {
  24.144 -        fail:
  24.145 -            bdrv_close(bs);
  24.146 -            return -1;
  24.147 -        }
  24.148 -        if (bdrv_open(bs->backing_hd, bs->backing_file, 0) < 0)
  24.149 -            goto fail;
  24.150 -    }
  24.151 -
  24.152 -    bs->inserted = 1;
  24.153 -
  24.154 -    /* call the change callback */
  24.155 -    if (bs->change_cb)
  24.156 -        bs->change_cb(bs->change_opaque);
  24.157 -
  24.158 -    return 0;
  24.159 -}
  24.160 -
  24.161 -void bdrv_close(BlockDriverState *bs)
  24.162 -{
  24.163 -    if (bs->inserted) {
  24.164 -        if (bs->backing_hd)
  24.165 -            bdrv_delete(bs->backing_hd);
  24.166 -        bs->drv->bdrv_close(bs);
  24.167 -        qemu_free(bs->opaque);
  24.168 -#ifdef _WIN32
  24.169 -        if (bs->is_temporary) {
  24.170 -            unlink(bs->filename);
  24.171 -        }
  24.172 -#endif
  24.173 -        bs->opaque = NULL;
  24.174 -        bs->drv = NULL;
  24.175 -        bs->inserted = 0;
  24.176 -
  24.177 -        /* call the change callback */
  24.178 -        if (bs->change_cb)
  24.179 -            bs->change_cb(bs->change_opaque);
  24.180 -    }
  24.181 -}
  24.182 -
  24.183 -void bdrv_delete(BlockDriverState *bs)
  24.184 -{
  24.185 -    /* XXX: remove the driver list */
  24.186 -    bdrv_close(bs);
  24.187 -    qemu_free(bs);
  24.188 -}
  24.189 -
  24.190 -/* commit COW file into the raw image */
  24.191 -int bdrv_commit(BlockDriverState *bs)
  24.192 -{
  24.193 -    int64_t i;
  24.194 -    int n, j;
  24.195 -    unsigned char sector[512];
  24.196 -
  24.197 -    if (!bs->inserted)
  24.198 -        return -ENOENT;
  24.199 -
  24.200 -    if (bs->read_only) {
  24.201 -	return -EACCES;
  24.202 -    }
  24.203 -
  24.204 -    if (!bs->backing_hd) {
  24.205 -	return -ENOTSUP;
  24.206 -    }
  24.207 -
  24.208 -    for (i = 0; i < bs->total_sectors;) {
  24.209 -        if (bs->drv->bdrv_is_allocated(bs, i, 65536, &n)) {
  24.210 -            for(j = 0; j < n; j++) {
  24.211 -                if (bdrv_read(bs, i, sector, 1) != 0) {
  24.212 -                    return -EIO;
  24.213 -                }
  24.214 -
  24.215 -                if (bdrv_write(bs->backing_hd, i, sector, 1) != 0) {
  24.216 -                    return -EIO;
  24.217 -                }
  24.218 -                i++;
  24.219 -	    }
  24.220 -	} else {
  24.221 -            i += n;
  24.222 -        }
  24.223 -    }
  24.224 -    return 0;
  24.225 -}
  24.226 -
  24.227 -/* return -1 if error */
  24.228 -int bdrv_read(BlockDriverState *bs, int64_t sector_num, 
  24.229 -              uint8_t *buf, int nb_sectors)
  24.230 -{
  24.231 -    int ret, n;
  24.232 -    BlockDriver *drv = bs->drv;
  24.233 -
  24.234 -    if (!bs->inserted)
  24.235 -        return -1;
  24.236 -
  24.237 -    while (nb_sectors > 0) {
  24.238 -        if (sector_num == 0 && bs->boot_sector_enabled) {
  24.239 -            memcpy(buf, bs->boot_sector_data, 512);
  24.240 -            n = 1;
  24.241 -        } else if (bs->backing_hd) {
  24.242 -            if (drv->bdrv_is_allocated(bs, sector_num, nb_sectors, &n)) {
  24.243 -                ret = drv->bdrv_read(bs, sector_num, buf, n);
  24.244 -                if (ret < 0)
  24.245 -                    return -1;
  24.246 -            } else {
  24.247 -                /* read from the base image */
  24.248 -                ret = bdrv_read(bs->backing_hd, sector_num, buf, n);
  24.249 -                if (ret < 0)
  24.250 -                    return -1;
  24.251 -            }
  24.252 -        } else {
  24.253 -            ret = drv->bdrv_read(bs, sector_num, buf, nb_sectors);
  24.254 -            if (ret < 0)
  24.255 -                return -1;
  24.256 -            /* no need to loop */
  24.257 -            break;
  24.258 -        }
  24.259 -        nb_sectors -= n;
  24.260 -        sector_num += n;
  24.261 -        buf += n * 512;
  24.262 -    }
  24.263 -    return 0;
  24.264 -}
  24.265 -
  24.266 -/* return -1 if error */
  24.267 -int bdrv_write(BlockDriverState *bs, int64_t sector_num, 
  24.268 -               const uint8_t *buf, int nb_sectors)
  24.269 -{
  24.270 -    if (!bs->inserted)
  24.271 -        return -1;
  24.272 -    if (bs->read_only)
  24.273 -        return -1;
  24.274 -    return bs->drv->bdrv_write(bs, sector_num, buf, nb_sectors);
  24.275 -}
  24.276 -
  24.277 -void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr)
  24.278 -{
  24.279 -    *nb_sectors_ptr = bs->total_sectors;
  24.280 -}
  24.281 -
  24.282 -/* force a given boot sector. */
  24.283 -void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size)
  24.284 -{
  24.285 -    bs->boot_sector_enabled = 1;
  24.286 -    if (size > 512)
  24.287 -        size = 512;
  24.288 -    memcpy(bs->boot_sector_data, data, size);
  24.289 -    memset(bs->boot_sector_data + size, 0, 512 - size);
  24.290 -}
  24.291 -
  24.292 -void bdrv_set_geometry_hint(BlockDriverState *bs, 
  24.293 -                            int cyls, int heads, int secs)
  24.294 -{
  24.295 -    bs->cyls = cyls;
  24.296 -    bs->heads = heads;
  24.297 -    bs->secs = secs;
  24.298 -}
  24.299 -
  24.300 -void bdrv_set_type_hint(BlockDriverState *bs, int type)
  24.301 -{
  24.302 -    bs->type = type;
  24.303 -    bs->removable = ((type == BDRV_TYPE_CDROM ||
  24.304 -                      type == BDRV_TYPE_FLOPPY));
  24.305 -}
  24.306 -
  24.307 -void bdrv_get_geometry_hint(BlockDriverState *bs, 
  24.308 -                            int *pcyls, int *pheads, int *psecs)
  24.309 -{
  24.310 -    *pcyls = bs->cyls;
  24.311 -    *pheads = bs->heads;
  24.312 -    *psecs = bs->secs;
  24.313 -}
  24.314 -
  24.315 -int bdrv_get_type_hint(BlockDriverState *bs)
  24.316 -{
  24.317 -    return bs->type;
  24.318 -}
  24.319 -
  24.320 -int bdrv_is_removable(BlockDriverState *bs)
  24.321 -{
  24.322 -    return bs->removable;
  24.323 -}
  24.324 -
  24.325 -int bdrv_is_read_only(BlockDriverState *bs)
  24.326 -{
  24.327 -    return bs->read_only;
  24.328 -}
  24.329 -
  24.330 -int bdrv_is_inserted(BlockDriverState *bs)
  24.331 -{
  24.332 -    return bs->inserted;
  24.333 -}
  24.334 -
  24.335 -int bdrv_is_locked(BlockDriverState *bs)
  24.336 -{
  24.337 -    return bs->locked;
  24.338 -}
  24.339 -
  24.340 -void bdrv_set_locked(BlockDriverState *bs, int locked)
  24.341 -{
  24.342 -    bs->locked = locked;
  24.343 -}
  24.344 -
  24.345 -void bdrv_set_change_cb(BlockDriverState *bs, 
  24.346 -                        void (*change_cb)(void *opaque), void *opaque)
  24.347 -{
  24.348 -    bs->change_cb = change_cb;
  24.349 -    bs->change_opaque = opaque;
  24.350 -}
  24.351 -
  24.352 -int bdrv_is_encrypted(BlockDriverState *bs)
  24.353 -{
  24.354 -    if (bs->backing_hd && bs->backing_hd->encrypted)
  24.355 -        return 1;
  24.356 -    return bs->encrypted;
  24.357 -}
  24.358 -
  24.359 -int bdrv_set_key(BlockDriverState *bs, const char *key)
  24.360 -{
  24.361 -    int ret;
  24.362 -    if (bs->backing_hd && bs->backing_hd->encrypted) {
  24.363 -        ret = bdrv_set_key(bs->backing_hd, key);
  24.364 -        if (ret < 0)
  24.365 -            return ret;
  24.366 -        if (!bs->encrypted)
  24.367 -            return 0;
  24.368 -    }
  24.369 -    if (!bs->encrypted || !bs->drv || !bs->drv->bdrv_set_key)
  24.370 -        return -1;
  24.371 -    return bs->drv->bdrv_set_key(bs, key);
  24.372 -}
  24.373 -
  24.374 -void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size)
  24.375 -{
  24.376 -    if (!bs->inserted || !bs->drv) {
  24.377 -        buf[0] = '\0';
  24.378 -    } else {
  24.379 -        pstrcpy(buf, buf_size, bs->drv->format_name);
  24.380 -    }
  24.381 -}
  24.382 -
  24.383 -void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 
  24.384 -                         void *opaque)
  24.385 -{
  24.386 -    BlockDriver *drv;
  24.387 -
  24.388 -    for (drv = first_drv; drv != NULL; drv = drv->next) {
  24.389 -        it(opaque, drv->format_name);
  24.390 -    }
  24.391 -}
  24.392 -
  24.393 -BlockDriverState *bdrv_find(const char *name)
  24.394 -{
  24.395 -    BlockDriverState *bs;
  24.396 -
  24.397 -    for (bs = bdrv_first; bs != NULL; bs = bs->next) {
  24.398 -        if (!strcmp(name, bs->device_name))
  24.399 -            return bs;
  24.400 -    }
  24.401 -    return NULL;
  24.402 -}
  24.403 -
  24.404 -void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque)
  24.405 -{
  24.406 -    BlockDriverState *bs;
  24.407 -
  24.408 -    for (bs = bdrv_first; bs != NULL; bs = bs->next) {
  24.409 -        it(opaque, bs->device_name);
  24.410 -    }
  24.411 -}
  24.412 -
  24.413 -const char *bdrv_get_device_name(BlockDriverState *bs)
  24.414 -{
  24.415 -    return bs->device_name;
  24.416 -}
  24.417 -
  24.418 -void bdrv_info(void)
  24.419 -{
  24.420 -    BlockDriverState *bs;
  24.421 -
  24.422 -    for (bs = bdrv_first; bs != NULL; bs = bs->next) {
  24.423 -        term_printf("%s:", bs->device_name);
  24.424 -        term_printf(" type=");
  24.425 -        switch(bs->type) {
  24.426 -        case BDRV_TYPE_HD:
  24.427 -            term_printf("hd");
  24.428 -            break;
  24.429 -        case BDRV_TYPE_CDROM:
  24.430 -            term_printf("cdrom");
  24.431 -            break;
  24.432 -        case BDRV_TYPE_FLOPPY:
  24.433 -            term_printf("floppy");
  24.434 -            break;
  24.435 -        }
  24.436 -        term_printf(" removable=%d", bs->removable);
  24.437 -        if (bs->removable) {
  24.438 -            term_printf(" locked=%d", bs->locked);
  24.439 -        }
  24.440 -        if (bs->inserted) {
  24.441 -            term_printf(" file=%s", bs->filename);
  24.442 -            if (bs->backing_file[0] != '\0')
  24.443 -                term_printf(" backing_file=%s", bs->backing_file);
  24.444 -            term_printf(" ro=%d", bs->read_only);
  24.445 -            term_printf(" drv=%s", bs->drv->format_name);
  24.446 -            if (bs->encrypted)
  24.447 -                term_printf(" encrypted");
  24.448 -        } else {
  24.449 -            term_printf(" [not inserted]");
  24.450 -        }
  24.451 -        term_printf("\n");
  24.452 -    }
  24.453 -}
  24.454 -
  24.455 -
  24.456 -/**************************************************************/
  24.457 -/* RAW block driver */
  24.458 -
  24.459 -typedef struct BDRVRawState {
  24.460 -    int fd;
  24.461 -} BDRVRawState;
  24.462 -
  24.463 -static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
  24.464 -{
  24.465 -    return 1; /* maybe */
  24.466 -}
  24.467 -
  24.468 -static int raw_open(BlockDriverState *bs, const char *filename)
  24.469 -{
  24.470 -    BDRVRawState *s = bs->opaque;
  24.471 -    int fd;
  24.472 -    int64_t size;
  24.473 -
  24.474 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
  24.475 -    if (fd < 0) {
  24.476 -        fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
  24.477 -        if (fd < 0)
  24.478 -            return -1;
  24.479 -        bs->read_only = 1;
  24.480 -    }
  24.481 -    size = lseek(fd, 0, SEEK_END);
  24.482 -    bs->total_sectors = size / 512;
  24.483 -    s->fd = fd;
  24.484 -    return 0;
  24.485 -}
  24.486 -
  24.487 -static int raw_read(BlockDriverState *bs, int64_t sector_num, 
  24.488 -                    uint8_t *buf, int nb_sectors)
  24.489 -{
  24.490 -    BDRVRawState *s = bs->opaque;
  24.491 -    int ret;
  24.492 -    
  24.493 -    lseek(s->fd, sector_num * 512, SEEK_SET);
  24.494 -    ret = read(s->fd, buf, nb_sectors * 512);
  24.495 -    if (ret != nb_sectors * 512) 
  24.496 -        return -1;
  24.497 -    return 0;
  24.498 -}
  24.499 -
  24.500 -static int raw_write(BlockDriverState *bs, int64_t sector_num, 
  24.501 -                     const uint8_t *buf, int nb_sectors)
  24.502 -{
  24.503 -    BDRVRawState *s = bs->opaque;
  24.504 -    int ret;
  24.505 -    
  24.506 -    lseek(s->fd, sector_num * 512, SEEK_SET);
  24.507 -    ret = write(s->fd, buf, nb_sectors * 512);
  24.508 -    if (ret != nb_sectors * 512) 
  24.509 -        return -1;
  24.510 -    return 0;
  24.511 -}
  24.512 -
  24.513 -static void raw_close(BlockDriverState *bs)
  24.514 -{
  24.515 -    BDRVRawState *s = bs->opaque;
  24.516 -    close(s->fd);
  24.517 -}
  24.518 -
  24.519 -static int raw_create(const char *filename, int64_t total_size,
  24.520 -                      const char *backing_file, int flags)
  24.521 -{
  24.522 -    int fd;
  24.523 -
  24.524 -    if (flags || backing_file)
  24.525 -        return -ENOTSUP;
  24.526 -
  24.527 -    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 
  24.528 -              0644);
  24.529 -    if (fd < 0)
  24.530 -        return -EIO;
  24.531 -    ftruncate(fd, total_size * 512);
  24.532 -    close(fd);
  24.533 -    return 0;
  24.534 -}
  24.535 -
  24.536 -BlockDriver bdrv_raw = {
  24.537 -    "raw",
  24.538 -    sizeof(BDRVRawState),
  24.539 -    raw_probe,
  24.540 -    raw_open,
  24.541 -    raw_read,
  24.542 -    raw_write,
  24.543 -    raw_close,
  24.544 -    raw_create,
  24.545 -};
  24.546 -
  24.547 -void bdrv_init(void)
  24.548 -{
  24.549 -    bdrv_register(&bdrv_raw);
  24.550 -    bdrv_register(&bdrv_qcow);
  24.551 -    bdrv_register(&bdrv_cloop);
  24.552 -}
    25.1 --- a/tools/ioemu/block_int.h	Wed Jul 12 16:34:39 2006 +0100
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,77 +0,0 @@
    25.4 -/*
    25.5 - * QEMU System Emulator block driver
    25.6 - * 
    25.7 - * Copyright (c) 2003 Fabrice Bellard
    25.8 - * 
    25.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   25.10 - * of this software and associated documentation files (the "Software"), to deal
   25.11 - * in the Software without restriction, including without limitation the rights
   25.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   25.13 - * copies of the Software, and to permit persons to whom the Software is
   25.14 - * furnished to do so, subject to the following conditions:
   25.15 - *
   25.16 - * The above copyright notice and this permission notice shall be included in
   25.17 - * all copies or substantial portions of the Software.
   25.18 - *
   25.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   25.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   25.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   25.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   25.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   25.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   25.25 - * THE SOFTWARE.
   25.26 - */
   25.27 -#ifndef BLOCK_INT_H
   25.28 -#define BLOCK_INT_H
   25.29 -
   25.30 -struct BlockDriver {
   25.31 -    const char *format_name;
   25.32 -    int instance_size;
   25.33 -    int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename);
   25.34 -    int (*bdrv_open)(BlockDriverState *bs, const char *filename);
   25.35 -    int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num, 
   25.36 -                     uint8_t *buf, int nb_sectors);
   25.37 -    int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num, 
   25.38 -                      const uint8_t *buf, int nb_sectors);
   25.39 -    void (*bdrv_close)(BlockDriverState *bs);
   25.40 -    int (*bdrv_create)(const char *filename, int64_t total_sectors, 
   25.41 -                       const char *backing_file, int flags);
   25.42 -    int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num,
   25.43 -                             int nb_sectors, int *pnum);
   25.44 -    int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
   25.45 -    struct BlockDriver *next;
   25.46 -};
   25.47 -
   25.48 -struct BlockDriverState {
   25.49 -    int64_t total_sectors;
   25.50 -    int read_only; /* if true, the media is read only */
   25.51 -    int inserted; /* if true, the media is present */
   25.52 -    int removable; /* if true, the media can be removed */
   25.53 -    int locked;    /* if true, the media cannot temporarily be ejected */
   25.54 -    int encrypted; /* if true, the media is encrypted */
   25.55 -    /* event callback when inserting/removing */
   25.56 -    void (*change_cb)(void *opaque);
   25.57 -    void *change_opaque;
   25.58 -
   25.59 -    BlockDriver *drv;
   25.60 -    void *opaque;
   25.61 -
   25.62 -    int boot_sector_enabled;
   25.63 -    uint8_t boot_sector_data[512];
   25.64 -
   25.65 -    char filename[1024];
   25.66 -    char backing_file[1024]; /* if non zero, the image is a diff of
   25.67 -                                this file image */
   25.68 -    int is_temporary;
   25.69 -    
   25.70 -    BlockDriverState *backing_hd;
   25.71 -    
   25.72 -    /* NOTE: the following infos are only hints for real hardware
   25.73 -       drivers. They are not used by the block driver */
   25.74 -    int cyls, heads, secs;
   25.75 -    int type;
   25.76 -    char device_name[32];
   25.77 -    BlockDriverState *next;
   25.78 -};
   25.79 -
   25.80 -#endif /* BLOCK_INT_H */
    26.1 --- a/tools/ioemu/bswap.h	Wed Jul 12 16:34:39 2006 +0100
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,202 +0,0 @@
    26.4 -#ifndef BSWAP_H
    26.5 -#define BSWAP_H
    26.6 -
    26.7 -#include "config-host.h"
    26.8 -
    26.9 -#include <inttypes.h>
   26.10 -
   26.11 -#ifdef HAVE_BYTESWAP_H
   26.12 -#include <byteswap.h>
   26.13 -#else
   26.14 -
   26.15 -#define bswap_16(x) \
   26.16 -({ \
   26.17 -	uint16_t __x = (x); \
   26.18 -	((uint16_t)( \
   26.19 -		(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
   26.20 -		(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
   26.21 -})
   26.22 -
   26.23 -#define bswap_32(x) \
   26.24 -({ \
   26.25 -	uint32_t __x = (x); \
   26.26 -	((uint32_t)( \
   26.27 -		(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
   26.28 -		(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
   26.29 -		(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
   26.30 -		(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
   26.31 -})
   26.32 -
   26.33 -#define bswap_64(x) \
   26.34 -({ \
   26.35 -	uint64_t __x = (x); \
   26.36 -	((uint64_t)( \
   26.37 -		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
   26.38 -		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
   26.39 -		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
   26.40 -		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
   26.41 -	        (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
   26.42 -		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
   26.43 -		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
   26.44 -		(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
   26.45 -})
   26.46 -
   26.47 -#endif /* !HAVE_BYTESWAP_H */
   26.48 -
   26.49 -static inline uint16_t bswap16(uint16_t x)
   26.50 -{
   26.51 -    return bswap_16(x);
   26.52 -}
   26.53 -
   26.54 -static inline uint32_t bswap32(uint32_t x) 
   26.55 -{
   26.56 -    return bswap_32(x);
   26.57 -}
   26.58 -
   26.59 -static inline uint64_t bswap64(uint64_t x) 
   26.60 -{
   26.61 -    return bswap_64(x);
   26.62 -}
   26.63 -
   26.64 -static inline void bswap16s(uint16_t *s)
   26.65 -{
   26.66 -    *s = bswap16(*s);
   26.67 -}
   26.68 -
   26.69 -static inline void bswap32s(uint32_t *s)
   26.70 -{
   26.71 -    *s = bswap32(*s);
   26.72 -}
   26.73 -
   26.74 -static inline void bswap64s(uint64_t *s)
   26.75 -{
   26.76 -    *s = bswap64(*s);
   26.77 -}
   26.78 -
   26.79 -#if defined(WORDS_BIGENDIAN)
   26.80 -#define be_bswap(v, size) (v)
   26.81 -#define le_bswap(v, size) bswap ## size(v)
   26.82 -#define be_bswaps(v, size)
   26.83 -#define le_bswaps(p, size) *p = bswap ## size(*p);
   26.84 -#else
   26.85 -#define le_bswap(v, size) (v)
   26.86 -#define be_bswap(v, size) bswap ## size(v)
   26.87 -#define le_bswaps(v, size)
   26.88 -#define be_bswaps(p, size) *p = bswap ## size(*p);
   26.89 -#endif
   26.90 -
   26.91 -#define CPU_CONVERT(endian, size, type)\
   26.92 -static inline type endian ## size ## _to_cpu(type v)\
   26.93 -{\
   26.94 -    return endian ## _bswap(v, size);\
   26.95 -}\
   26.96 -\
   26.97 -static inline type cpu_to_ ## endian ## size(type v)\
   26.98 -{\
   26.99 -    return endian ## _bswap(v, size);\
  26.100 -}\
  26.101 -\
  26.102 -static inline void endian ## size ## _to_cpus(type *p)\
  26.103 -{\
  26.104 -    endian ## _bswaps(p, size)\
  26.105 -}\
  26.106 -\
  26.107 -static inline void cpu_to_ ## endian ## size ## s(type *p)\
  26.108 -{\
  26.109 -    endian ## _bswaps(p, size)\
  26.110 -}\
  26.111 -\
  26.112 -static inline type endian ## size ## _to_cpup(const type *p)\
  26.113 -{\
  26.114 -    return endian ## size ## _to_cpu(*p);\
  26.115 -}\
  26.116 -\
  26.117 -static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\
  26.118 -{\
  26.119 -     *p = cpu_to_ ## endian ## size(v);\
  26.120 -}
  26.121 -
  26.122 -CPU_CONVERT(be, 16, uint16_t)
  26.123 -CPU_CONVERT(be, 32, uint32_t)
  26.124 -CPU_CONVERT(be, 64, uint64_t)
  26.125 -
  26.126 -CPU_CONVERT(le, 16, uint16_t)
  26.127 -CPU_CONVERT(le, 32, uint32_t)
  26.128 -CPU_CONVERT(le, 64, uint64_t)
  26.129 -
  26.130 -/* unaligned versions (optimized for frequent unaligned accesses)*/
  26.131 -
  26.132 -#if defined(__i386__) || defined(__powerpc__)
  26.133 -
  26.134 -#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v)
  26.135 -#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
  26.136 -#define le16_to_cpupu(p) le16_to_cpup(p)
  26.137 -#define le32_to_cpupu(p) le32_to_cpup(p)
  26.138 -
  26.139 -#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v)
  26.140 -#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v)
  26.141 -
  26.142 -#else
  26.143 -
  26.144 -static inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
  26.145 -{
  26.146 -    uint8_t *p1 = (uint8_t *)p;
  26.147 -
  26.148 -    p1[0] = v;
  26.149 -    p1[1] = v >> 8;
  26.150 -}
  26.151 -
  26.152 -static inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
  26.153 -{
  26.154 -    uint8_t *p1 = (uint8_t *)p;
  26.155 -
  26.156 -    p1[0] = v;
  26.157 -    p1[1] = v >> 8;
  26.158 -    p1[2] = v >> 16;
  26.159 -    p1[3] = v >> 24;
  26.160 -}
  26.161 -
  26.162 -static inline uint16_t le16_to_cpupu(const uint16_t *p)
  26.163 -{
  26.164 -    const uint8_t *p1 = (const uint8_t *)p;
  26.165 -    return p1[0] | (p1[1] << 8);
  26.166 -}
  26.167 -
  26.168 -static inline uint32_t le32_to_cpupu(const uint32_t *p)
  26.169 -{
  26.170 -    const uint8_t *p1 = (const uint8_t *)p;
  26.171 -    return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
  26.172 -}
  26.173 -
  26.174 -static inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
  26.175 -{
  26.176 -    uint8_t *p1 = (uint8_t *)p;
  26.177 -
  26.178 -    p1[0] = v >> 8;
  26.179 -    p1[1] = v;
  26.180 -}
  26.181 -
  26.182 -static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
  26.183 -{
  26.184 -    uint8_t *p1 = (uint8_t *)p;
  26.185 -
  26.186 -    p1[0] = v >> 24;
  26.187 -    p1[1] = v >> 16;
  26.188 -    p1[2] = v >> 8;
  26.189 -    p1[3] = v;
  26.190 -}
  26.191 -
  26.192 -#endif
  26.193 -
  26.194 -#ifdef WORDS_BIGENDIAN
  26.195 -#define cpu_to_32wu cpu_to_be32wu
  26.196 -#else
  26.197 -#define cpu_to_32wu cpu_to_le32wu
  26.198 -#endif
  26.199 -
  26.200 -#undef le_bswap
  26.201 -#undef be_bswap
  26.202 -#undef le_bswaps
  26.203 -#undef be_bswaps
  26.204 -
  26.205 -#endif /* BSWAP_H */
    27.1 --- a/tools/ioemu/configure	Wed Jul 12 16:34:39 2006 +0100
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,611 +0,0 @@
    27.4 -#!/bin/sh
    27.5 -#
    27.6 -# qemu configure script (c) 2003 Fabrice Bellard
    27.7 -#
    27.8 -# set temporary file name
    27.9 -if test ! -z "$TMPDIR" ; then
   27.10 -    TMPDIR1="${TMPDIR}"
   27.11 -elif test ! -z "$TEMPDIR" ; then
   27.12 -    TMPDIR1="${TEMPDIR}"
   27.13 -else
   27.14 -    TMPDIR1="/tmp"
   27.15 -fi
   27.16 -
   27.17 -TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
   27.18 -TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
   27.19 -TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}"
   27.20 -TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S"
   27.21 -
   27.22 -# default parameters
   27.23 -prefix=""
   27.24 -static="no"
   27.25 -libdir="lib"
   27.26 -cross_prefix=""
   27.27 -cc="gcc"
   27.28 -host_cc="gcc"
   27.29 -ar="ar"
   27.30 -make="make"
   27.31 -strip="strip"
   27.32 -cpu=`uname -m`
   27.33 -target_list="target-i386-dm"
   27.34 -case "$cpu" in
   27.35 -  i386|i486|i586|i686|i86pc|BePC)
   27.36 -    cpu="i386"
   27.37 -  ;;
   27.38 -  armv4l)
   27.39 -    cpu="armv4l"
   27.40 -  ;;
   27.41 -  alpha)
   27.42 -    cpu="alpha"
   27.43 -  ;;
   27.44 -  "Power Macintosh"|ppc|ppc64)
   27.45 -    cpu="powerpc"
   27.46 -  ;;
   27.47 -  mips)
   27.48 -    cpu="mips"
   27.49 -  ;;
   27.50 -  s390)
   27.51 -    cpu="s390"
   27.52 -  ;;
   27.53 -  sparc)
   27.54 -    cpu="sparc"
   27.55 -  ;;
   27.56 -  sparc64)
   27.57 -    cpu="sparc64"
   27.58 -  ;;
   27.59 -  ia64)
   27.60 -    cpu="ia64"
   27.61 -  ;;
   27.62 -  m68k)
   27.63 -    cpu="m68k"
   27.64 -  ;;
   27.65 -  x86_64|amd64)
   27.66 -    cpu="amd64"
   27.67 -    libdir="lib64"
   27.68 -  ;;
   27.69 -  *)
   27.70 -    cpu="unknown"
   27.71 -  ;;
   27.72 -esac
   27.73 -gprof="no"
   27.74 -bigendian="no"
   27.75 -mingw32="no"
   27.76 -EXESUF=""
   27.77 -gdbstub="no"
   27.78 -slirp="no"
   27.79 -adlib="no"
   27.80 -oss="no"
   27.81 -fmod="no"
   27.82 -fmod_lib=""
   27.83 -fmod_inc=""
   27.84 -
   27.85 -# OS specific
   27.86 -targetos=`uname -s`
   27.87 -case $targetos in
   27.88 -MINGW32*)
   27.89 -mingw32="yes"
   27.90 -;;
   27.91 -FreeBSD)
   27.92 -bsd="yes"
   27.93 -oss="yes"
   27.94 -;;
   27.95 -NetBSD)
   27.96 -bsd="yes"
   27.97 -oss="yes"
   27.98 -;;
   27.99 -OpenBSD)
  27.100 -bsd="yes"
  27.101 -oss="yes"
  27.102 -;;
  27.103 -Darwin)
  27.104 -bsd="yes"
  27.105 -darwin="yes"
  27.106 -;;
  27.107 -*) 
  27.108 -oss="yes"
  27.109 -;;
  27.110 -esac
  27.111 -
  27.112 -if [ "$bsd" = "yes" ] ; then
  27.113 -  if [ ! "$darwin" = "yes" ] ; then
  27.114 -    make="gmake"
  27.115 -  fi
  27.116 -  target_list="i386-softmmu ppc-softmmu sparc-softmmu"
  27.117 -fi
  27.118 -
  27.119 -# find source path
  27.120 -# XXX: we assume an absolute path is given when launching configure, 
  27.121 -# except in './configure' case.
  27.122 -source_path=${0%configure}
  27.123 -source_path=${source_path%/}
  27.124 -source_path_used="yes"
  27.125 -if test -z "$source_path" -o "$source_path" = "." ; then
  27.126 -    source_path=`pwd`
  27.127 -    source_path_used="no"
  27.128 -fi
  27.129 -
  27.130 -for opt do
  27.131 -  case "$opt" in
  27.132 -  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  27.133 -  ;;
  27.134 -  --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
  27.135 -  ;;
  27.136 -  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
  27.137 -  ;;
  27.138 -  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
  27.139 -  ;;
  27.140 -  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  27.141 -  ;;
  27.142 -  --make=*) make=`echo $opt | cut -d '=' -f 2`
  27.143 -  ;;
  27.144 -  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
  27.145 -  ;;
  27.146 -  --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
  27.147 -  ;;
  27.148 -  --extra-libs=*) extralibs=${opt#--extra-libs=}
  27.149 -  ;;
  27.150 -  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  27.151 -  ;;
  27.152 -  --target-list=*) target_list=${opt#--target-list=}
  27.153 -  ;;
  27.154 -  --enable-gprof) gprof="yes"
  27.155 -  ;;
  27.156 -  --static) static="yes"
  27.157 -  ;;
  27.158 -  --disable-sdl) sdl="no"
  27.159 -  ;;
  27.160 -  --enable-fmod) fmod="yes"
  27.161 -  ;;
  27.162 -  --fmod-lib=*) fmod_lib=${opt#--fmod-lib=}
  27.163 -  ;;
  27.164 -  --fmod-inc=*) fmod_inc=${opt#--fmod-inc=}
  27.165 -  ;;
  27.166 -  --disable-vnc) vnc="no"
  27.167 -  ;;
  27.168 -  --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
  27.169 -  ;; 
  27.170 -  --disable-slirp) slirp="no"
  27.171 -  ;; 
  27.172 -  --enable-adlib) adlib="yes"
  27.173 -  ;; 
  27.174 -  esac
  27.175 -done
  27.176 -
  27.177 -# Checking for CFLAGS
  27.178 -if test -z "$CFLAGS"; then
  27.179 -    CFLAGS="-O2"
  27.180 -fi
  27.181 -
  27.182 -cc="${cross_prefix}${cc}"
  27.183 -ar="${cross_prefix}${ar}"
  27.184 -strip="${cross_prefix}${strip}"
  27.185 -
  27.186 -if test "$mingw32" = "yes" ; then
  27.187 -    target_list="i386-softmmu ppc-softmmu sparc-softmmu"
  27.188 -    EXESUF=".exe"
  27.189 -    gdbstub="no"
  27.190 -    oss="no"
  27.191 -fi
  27.192 -
  27.193 -if test -z "$cross_prefix" ; then
  27.194 -
  27.195 -# ---
  27.196 -# big/little endian test
  27.197 -cat > $TMPC << EOF
  27.198 -#include <inttypes.h>
  27.199 -int main(int argc, char ** argv){
  27.200 -	volatile uint32_t i=0x01234567;
  27.201 -	return (*((uint8_t*)(&i))) == 0x67;
  27.202 -}
  27.203 -EOF
  27.204 -
  27.205 -if $cc -o $TMPE $TMPC 2>/dev/null ; then
  27.206 -$TMPE && bigendian="yes"
  27.207 -else
  27.208 -echo big/little test failed
  27.209 -fi
  27.210 -
  27.211 -else
  27.212 -
  27.213 -# if cross compiling, cannot launch a program, so make a static guess
  27.214 -if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k"; then
  27.215 -    bigendian="yes"
  27.216 -fi
  27.217 -
  27.218 -fi
  27.219 -
  27.220 -# check gcc options support
  27.221 -cat > $TMPC <<EOF
  27.222 -int main(void) {
  27.223 -}
  27.224 -EOF
  27.225 -
  27.226 -have_gcc3_options="no"
  27.227 -if $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
  27.228 -   have_gcc3_options="yes"
  27.229 -fi
  27.230 -
  27.231 -##########################################
  27.232 -# VNC probe
  27.233 -
  27.234 -if test -z "$vnc"; then
  27.235 -
  27.236 -if libvncserver-config --version > /dev/null 2>&1; then
  27.237 -    vnc=yes
  27.238 -else
  27.239 -    vnc=no
  27.240 -fi
  27.241 -
  27.242 -fi
  27.243 -
  27.244 -if test "$vnc" = "yes" ; then
  27.245 -
  27.246 -# check for eager event handling
  27.247 -cat > $TMPC <<EOF
  27.248 -#include "rfb/rfb.h"
  27.249 -int main(void) {
  27.250 -	rfbScreenInfoPtr screen;
  27.251 -
  27.252 -	screen->handleEventsEagerly = 1;
  27.253 -}
  27.254 -EOF
  27.255 -
  27.256 -if $cc `libvncserver-config --cflags` -o $TMPO $TMPC 2> /dev/null ; then
  27.257 -   have_eager_events="yes"
  27.258 -else
  27.259 -   echo "!!"
  27.260 -   echo "!! Slow VNC mouse, LibVNCServer doesn't support eager events"
  27.261 -   echo "!!"
  27.262 -   have_eager_events="no"
  27.263 -fi
  27.264 -
  27.265 -fi
  27.266 -
  27.267 -##########################################
  27.268 -# SDL probe
  27.269 -
  27.270 -sdl_too_old=no
  27.271 -
  27.272 -if test -z "$sdl" ; then
  27.273 -
  27.274 -sdl_config="sdl-config"
  27.275 -sdl=no
  27.276 -sdl_static=no
  27.277 -
  27.278 -if test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then
  27.279 -# win32 cross compilation case
  27.280 -    sdl_config="i386-mingw32msvc-sdl-config"
  27.281 -    sdl=yes
  27.282 -else
  27.283 -# normal SDL probe
  27.284 -cat > $TMPC << EOF
  27.285 -#include <SDL.h>
  27.286 -#undef main /* We don't want SDL to override our main() */
  27.287 -int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
  27.288 -EOF
  27.289 -
  27.290 -if $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then
  27.291 -_sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
  27.292 -if test "$_sdlversion" -lt 121 ; then
  27.293 -sdl_too_old=yes
  27.294 -else
  27.295 -sdl=yes
  27.296 -fi
  27.297 -
  27.298 -# static link with sdl ?
  27.299 -if test "$sdl" = "yes" ; then
  27.300 -aa="no"
  27.301 -`$sdl_config --static-libs | grep \\\-laa > /dev/null` && aa="yes"
  27.302 -sdl_static_libs=`$sdl_config --static-libs`
  27.303 -if [ "$aa" = "yes" ] ; then
  27.304 -  sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
  27.305 -fi
  27.306 -
  27.307 -if $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
  27.308 -  sdl_static=yes
  27.309 -fi
  27.310 -
  27.311 -fi # static link
  27.312 -
  27.313 -fi # sdl compile test
  27.314 -
  27.315 -fi # cross compilation
  27.316 -fi # -z $sdl
  27.317 -
  27.318 -if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  27.319 -cat << EOF
  27.320 -
  27.321 -Usage: configure [options]
  27.322 -Options: [defaults in brackets after descriptions]
  27.323 -
  27.324 -EOF
  27.325 -echo "Standard options:"
  27.326 -echo "  --help                   print this message"
  27.327 -echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
  27.328 -echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
  27.329 -echo "                           use %M for cpu name [$interp_prefix]"
  27.330 -echo "  --target-list=LIST       set target list [$target_list]"
  27.331 -echo "  --disable-vnc            disable vnc support (else configure checks"
  27.332 -echo "                           for libvncserver-config in your PATH)"
  27.333 -echo ""
  27.334 -echo "Advanced options (experts only):"
  27.335 -echo "  --source-path=PATH       path of source code [$source_path]"
  27.336 -echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
  27.337 -echo "  --cc=CC                  use C compiler CC [$cc]"
  27.338 -echo "  --make=MAKE              use specified make [$make]"
  27.339 -echo "  --static                 enable static build [$static]"
  27.340 -echo "  --enable-mingw32         enable Win32 cross compilation with mingw32"
  27.341 -echo "  --enable-fmod            enable FMOD audio output driver"
  27.342 -echo "  --fmod-lib               path to FMOD library"
  27.343 -echo "  --fmod-inc               path to FMOD includes"
  27.344 -echo ""
  27.345 -echo "NOTE: The object files are build at the place where configure is launched"
  27.346 -exit 1
  27.347 -fi
  27.348 -
  27.349 -#installroot=$source_path/../../dist/install
  27.350 -installroot=
  27.351 -
  27.352 -if test "$mingw32" = "yes" ; then
  27.353 -if test -z "$prefix" ; then
  27.354 -    prefix="/c/Program Files/Qemu"
  27.355 -fi
  27.356 -
  27.357 -mandir="$prefix"
  27.358 -datadir="$prefix"
  27.359 -docdir="$prefix"
  27.360 -bindir="$prefix"
  27.361 -configdir=""
  27.362 -else
  27.363 -if test -z "$prefix" ; then
  27.364 -    prefix="usr/local"
  27.365 -fi
  27.366 -mandir="$installroot/$prefix/share/man"
  27.367 -datadir="$installroot/$prefix/share/xen/qemu"
  27.368 -docdir="$installroot/$prefix/share/doc/qemu"
  27.369 -bindir="$installroot/$prefix/bin"
  27.370 -configdir="$installroot/etc/xen"
  27.371 -fi
  27.372 -
  27.373 -echo "Install prefix    $prefix"
  27.374 -echo "BIOS directory    $datadir"
  27.375 -echo "binary directory  $bindir"
  27.376 -if test "$mingw32" = "no" ; then
  27.377 -echo "Manual directory  $mandir"
  27.378 -fi
  27.379 -echo "Source path       $source_path"
  27.380 -echo "C compiler        $cc"
  27.381 -echo "make              $make"
  27.382 -echo "host CPU          $cpu"
  27.383 -echo "host big endian   $bigendian"
  27.384 -echo "target list       $target_list"
  27.385 -echo "gprof enabled     $gprof"
  27.386 -echo "static build      $static"
  27.387 -echo "VNC support       $vnc"
  27.388 -echo "SDL support       $sdl"
  27.389 -echo "SDL static link   $sdl_static"
  27.390 -echo "mingw32 support   $mingw32"
  27.391 -echo "Adlib support     $adlib"
  27.392 -echo -n "FMOD support      $fmod"
  27.393 -if test $fmod = "yes"; then
  27.394 -    echo -n " (lib='$fmod_lib' include='$fmod_inc')"
  27.395 -fi
  27.396 -echo ""
  27.397 -
  27.398 -if test $sdl_too_old = "yes"; then
  27.399 -echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
  27.400 -fi
  27.401 -if test "$sdl_static" = "no"; then
  27.402 -  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
  27.403 -fi
  27.404 -
  27.405 -config_mak="config-host.mak"
  27.406 -config_h="config-host.h"
  27.407 -
  27.408 -#echo "Creating $config_mak and $config_h"
  27.409 -
  27.410 -echo "# Automatically generated by configure - do not modify" > $config_mak
  27.411 -echo "/* Automatically generated by configure - do not modify */" > $config_h
  27.412 -
  27.413 -echo "prefix=$prefix" >> $config_mak
  27.414 -echo "bindir=$bindir" >> $config_mak
  27.415 -echo "mandir=$mandir" >> $config_mak
  27.416 -echo "datadir=$datadir" >> $config_mak
  27.417 -echo "docdir=$docdir" >> $config_mak
  27.418 -echo "configdir=$configdir" >> $config_mak
  27.419 -echo "LIBDIR=$libdir" >> $config_mak
  27.420 -echo "#define CONFIG_QEMU_SHAREDIR \"$datadir\"" >> $config_h
  27.421 -#echo "MAKE=$make" >> $config_mak
  27.422 -#echo "CC=$cc" >> $config_mak
  27.423 -#if test "$have_gcc3_options" = "yes" ; then
  27.424 -#  echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
  27.425 -#fi
  27.426 -#echo "HOST_CC=$host_cc" >> $config_mak
  27.427 -#echo "AR=$ar" >> $config_mak
  27.428 -#echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
  27.429 -#echo "CFLAGS=$CFLAGS" >> $config_mak
  27.430 -#echo "LDFLAGS=$LDFLAGS" >> $config_mak
  27.431 -#echo "EXESUF=$EXESUF" >> $config_mak
  27.432 -
  27.433 -if test "$bigendian" = "yes" ; then
  27.434 -  echo "WORDS_BIGENDIAN=yes" >> $config_mak
  27.435 -  echo "#define WORDS_BIGENDIAN 1" >> $config_h
  27.436 -fi
  27.437 -if test "$mingw32" = "yes" ; then
  27.438 -  echo "CONFIG_WIN32=yes" >> $config_mak
  27.439 -  echo "#define CONFIG_WIN32 1" >> $config_h
  27.440 -elif test -f "/usr/include/byteswap.h" ; then
  27.441 -  echo "#define HAVE_BYTESWAP_H 1" >> $config_h
  27.442 -fi
  27.443 -if test "$darwin" = "yes" ; then
  27.444 -  echo "CONFIG_DARWIN=yes" >> $config_mak
  27.445 -  echo "#define CONFIG_DARWIN 1" >> $config_h
  27.446 -fi
  27.447 -if test "$gdbstub" = "yes" ; then
  27.448 -  echo "CONFIG_GDBSTUB=yes" >> $config_mak
  27.449 -  echo "#define CONFIG_GDBSTUB 1" >> $config_h
  27.450 -fi
  27.451 -if test "$gprof" = "yes" ; then
  27.452 -  echo "TARGET_GPROF=yes" >> $config_mak
  27.453 -  echo "#define HAVE_GPROF 1" >> $config_h
  27.454 -fi
  27.455 -if test "$static" = "yes" ; then
  27.456 -  echo "CONFIG_STATIC=yes" >> $config_mak
  27.457 -  echo "#define CONFIG_STATIC 1" >> $config_h
  27.458 -fi
  27.459 -if test "$slirp" = "yes" ; then
  27.460 -  echo "CONFIG_SLIRP=yes" >> $config_mak
  27.461 -  echo "#define CONFIG_SLIRP 1" >> $config_h
  27.462 -fi
  27.463 -if test "$adlib" = "yes" ; then
  27.464 -  echo "CONFIG_ADLIB=yes" >> $config_mak
  27.465 -  echo "#define CONFIG_ADLIB 1" >> $config_h
  27.466 -fi
  27.467 -if test "$oss" = "yes" ; then
  27.468 -  echo "CONFIG_OSS=yes" >> $config_mak
  27.469 -  echo "#define CONFIG_OSS 1" >> $config_h
  27.470 -fi
  27.471 -if test "$fmod" = "yes" ; then
  27.472 -  echo "CONFIG_FMOD=yes" >> $config_mak
  27.473 -  echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
  27.474 -  echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
  27.475 -  echo "#define CONFIG_FMOD 1" >> $config_h
  27.476 -fi
  27.477 -echo -n "VERSION=" >>$config_mak
  27.478 -head $source_path/VERSION >>$config_mak
  27.479 -echo "" >>$config_mak
  27.480 -echo -n "#define QEMU_VERSION \"" >> $config_h
  27.481 -head $source_path/VERSION >> $config_h
  27.482 -echo "\"" >> $config_h
  27.483 -
  27.484 -echo "SRC_PATH=$source_path" >> $config_mak
  27.485 -echo "TARGET_DIRS=$target_list" >> $config_mak
  27.486 -
  27.487 -# XXX: suppress that
  27.488 -if [ "$bsd" = "yes" ] ; then
  27.489 -  echo "#define O_LARGEFILE 0" >> $config_h
  27.490 -  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
  27.491 -  echo "#define _BSD 1" >> $config_h
  27.492 -fi
  27.493 -
  27.494 -if test "$vnc" = "yes"; then
  27.495 -  echo "CONFIG_VNC=yes" >> $config_mak
  27.496 -  vnc_cflags=`libvncserver-config --cflags`
  27.497 -  if [ -z $vnc_cflags ]; then
  27.498 -    vnc_cflags="/usr/include"
  27.499 -  fi
  27.500 -  echo "VNC_CFLAGS=$vnc_cflags" >> $config_mak
  27.501 -  if test "$have_eager_events" = "yes" ; then
  27.502 -    echo "#define VNC_EAGER_EVENTS 1" >> $config_h
  27.503 -  fi
  27.504 -fi
  27.505 -
  27.506 -if test "$sdl" = "yes"; then
  27.507 -  echo "CONFIG_SDL=yes" >> $config_mak
  27.508 -  echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
  27.509 -fi
  27.510 -
  27.511 -for target in $target_list; do 
  27.512 -
  27.513 -target_dir="$target"
  27.514 -config_mak=$target_dir/config.mak
  27.515 -config_h=$target_dir/config.h
  27.516 -target_cpu=`echo $target | cut -d '-' -f 2`
  27.517 -[ "$target_cpu" = "ppc" ] && target_bigendian=yes
  27.518 -target_softmmu="no"
  27.519 -if expr $target : '.*-softmmu' > /dev/null ; then
  27.520 -  target_softmmu="yes"
  27.521 -fi
  27.522 -#for support 256M guest
  27.523 -target_softmmu="yes"
  27.524 -target_user_only="no"
  27.525 -if expr $target : '.*-user' > /dev/null ; then
  27.526 -  target_user_only="yes"
  27.527 -fi
  27.528 -#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
  27.529 -
  27.530 -mkdir -p $target_dir
  27.531 -if test "$target" = "arm-user" ; then
  27.532 -  mkdir -p $target_dir/nwfpe
  27.533 -fi
  27.534 -if test "$target_user_only" = "no" ; then
  27.535 -  mkdir -p $target_dir/slirp
  27.536 -fi
  27.537 -
  27.538 -#ln -sf $source_path/Makefile.target $target_dir/Makefile
  27.539 -
  27.540 -echo "# Automatically generated by configure - do not modify" > $config_mak
  27.541 -echo "/* Automatically generated by configure - do not modify */" > $config_h
  27.542 -
  27.543 -
  27.544 -echo "include ../config-host.mak" >> $config_mak
  27.545 -echo "#include \"../config-host.h\"" >> $config_h
  27.546 -
  27.547 -echo "TARGET_ARCH=i386" >> $config_mak
  27.548 -echo "#define TARGET_ARCH \"i386\"" >> $config_h
  27.549 -echo "#define TARGET_I386 1" >> $config_h
  27.550 -
  27.551 -interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
  27.552 -echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
  27.553 -
  27.554 -if test "$target_bigendian" = "yes" ; then
  27.555 -  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
  27.556 -  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
  27.557 -fi
  27.558 -if test "$target_softmmu" = "yes" ; then
  27.559 -  echo "CONFIG_SOFTMMU=yes" >> $config_mak
  27.560 -  echo "#define CONFIG_SOFTMMU 1" >> $config_h
  27.561 -fi
  27.562 -if test "$target_user_only" = "yes" ; then
  27.563 -  echo "CONFIG_USER_ONLY=yes" >> $config_mak
  27.564 -  echo "#define CONFIG_USER_ONLY 1" >> $config_h
  27.565 -fi
  27.566 -
  27.567 -if test "$target_user_only" = "no"; then
  27.568 -    if test "$vnc" = "yes"; then
  27.569 -	echo "#define CONFIG_VNC 1" >> $config_h
  27.570 -	echo "CONFIG_VNC=yes" >> $config_mak
  27.571 -	echo "VNC_CFLAGS=`libvncserver-config --cflags`" >> $config_mak
  27.572 -	echo "VNC_LIBS=`libvncserver-config --libs`" >> $config_mak
  27.573 -    fi
  27.574 -fi
  27.575 -
  27.576 -# sdl defines
  27.577 -
  27.578 -if test "$sdl" = "yes" -a "$target_user_only" = "no"; then
  27.579 -    if test "$target_softmmu" = "no" -o "$static" = "yes"; then
  27.580 -        sdl1=$sdl_static
  27.581 -    else
  27.582 -        sdl1=$sdl
  27.583 -    fi
  27.584 -    if test "$sdl1" = "yes" ; then
  27.585 -        echo "#define CONFIG_SDL 1" >> $config_h
  27.586 -        echo "CONFIG_SDL=yes" >> $config_mak
  27.587 -        if test "$target_softmmu" = "no" -o "$static" = "yes"; then
  27.588 -            echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
  27.589 -        else
  27.590 -            echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
  27.591 -        fi
  27.592 -        echo -n "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
  27.593 -        if [ "${aa}" = "yes" ] ; then
  27.594 -            echo -n " `aalib-config --cflags`" >> $config_mak ;
  27.595 -        fi
  27.596 -        echo "" >> $config_mak
  27.597 -    fi
  27.598 -fi
  27.599 -
  27.600 -done # for target in $targets
  27.601 -
  27.602 -# build tree in object directory if source path is different from current one
  27.603 -if test "$source_path_used" = "yes" ; then
  27.604 -    DIRS="tests"
  27.605 -    FILES="Makefile tests/Makefile"
  27.606 -    for dir in $DIRS ; do
  27.607 -            mkdir -p $dir
  27.608 -    done
  27.609 -    for f in $FILES ; do
  27.610 -        ln -sf $source_path/$f $f
  27.611 -    done
  27.612 -fi
  27.613 -
  27.614 -rm -f $TMPO $TMPC $TMPE $TMPS
    28.1 --- a/tools/ioemu/console.c	Wed Jul 12 16:34:39 2006 +0100
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,731 +0,0 @@
    28.4 -/*
    28.5 - * QEMU graphical console
    28.6 - * 
    28.7 - * Copyright (c) 2004 Fabrice Bellard
    28.8 - * 
    28.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   28.10 - * of this software and associated documentation files (the "Software"), to deal
   28.11 - * in the Software without restriction, including without limitation the rights
   28.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   28.13 - * copies of the Software, and to permit persons to whom the Software is
   28.14 - * furnished to do so, subject to the following conditions:
   28.15 - *
   28.16 - * The above copyright notice and this permission notice shall be included in
   28.17 - * all copies or substantial portions of the Software.
   28.18 - *
   28.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   28.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   28.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   28.22 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   28.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   28.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   28.25 - * THE SOFTWARE.
   28.26 - */
   28.27 -#include "vl.h"
   28.28 -
   28.29 -#define DEFAULT_BACKSCROLL 512
   28.30 -#define MAX_CONSOLES 12
   28.31 -
   28.32 -#define RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
   28.33 -#define RGB(r, g, b) RGBA(r, g, b, 0xff)
   28.34 -
   28.35 -typedef struct TextCell {
   28.36 -    uint8_t ch;
   28.37 -    uint8_t bgcol:4;
   28.38 -    uint8_t fgcol:4;
   28.39 -} TextCell;
   28.40 -
   28.41 -#define MAX_ESC_PARAMS 3
   28.42 -
   28.43 -enum TTYState {
   28.44 -    TTY_STATE_NORM,
   28.45 -    TTY_STATE_ESC,
   28.46 -    TTY_STATE_CSI,
   28.47 -};
   28.48 -
   28.49 -struct TextConsole {
   28.50 -    int text_console; /* true if text console */
   28.51 -    DisplayState *ds;
   28.52 -    int g_width, g_height;
   28.53 -    int width;
   28.54 -    int height;
   28.55 -    int total_height;
   28.56 -    int backscroll_height;
   28.57 -    int fgcol;
   28.58 -    int bgcol;
   28.59 -    int x, y;
   28.60 -    int y_displayed;
   28.61 -    int y_base;
   28.62 -    TextCell *cells;
   28.63 -
   28.64 -    enum TTYState state;
   28.65 -    int esc_params[MAX_ESC_PARAMS];
   28.66 -    int nb_esc_params;
   28.67 -
   28.68 -    /* kbd read handler */
   28.69 -    IOReadHandler *fd_read;
   28.70 -    void *fd_opaque;
   28.71 -};
   28.72 -
   28.73 -static TextConsole *active_console;
   28.74 -static TextConsole *consoles[MAX_CONSOLES];
   28.75 -static int nb_consoles = 0;
   28.76 -
   28.77 -/* convert a RGBA color to a color index usable in graphic primitives */
   28.78 -static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
   28.79 -{
   28.80 -    unsigned int r, g, b, color;
   28.81 -
   28.82 -    switch(ds->depth) {
   28.83 -#if 0
   28.84 -    case 8:
   28.85 -        r = (rgba >> 16) & 0xff;
   28.86 -        g = (rgba >> 8) & 0xff;
   28.87 -        b = (rgba) & 0xff;
   28.88 -        color = (rgb_to_index[r] * 6 * 6) + 
   28.89 -            (rgb_to_index[g] * 6) + 
   28.90 -            (rgb_to_index[b]);
   28.91 -        break;
   28.92 -#endif
   28.93 -    case 15:
   28.94 -        r = (rgba >> 16) & 0xff;
   28.95 -        g = (rgba >> 8) & 0xff;
   28.96 -        b = (rgba) & 0xff;
   28.97 -        color = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
   28.98 -        break;
   28.99 -    case 16:
  28.100 -        r = (rgba >> 16) & 0xff;
  28.101 -        g = (rgba >> 8) & 0xff;
  28.102 -        b = (rgba) & 0xff;
  28.103 -        color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
  28.104 -        break;
  28.105 -    case 32:
  28.106 -    default:
  28.107 -        color = rgba;
  28.108 -        break;
  28.109 -    }
  28.110 -    return color;
  28.111 -}
  28.112 -
  28.113 -static void vga_fill_rect (DisplayState *ds, 
  28.114 -                           int posx, int posy, int width, int height, uint32_t color)
  28.115 -{
  28.116 -    uint8_t *d, *d1;
  28.117 -    int x, y, bpp;
  28.118 -    
  28.119 -    bpp = (ds->depth + 7) >> 3;
  28.120 -    d1 = ds->data + 
  28.121 -        ds->linesize * posy + bpp * posx;
  28.122 -    for (y = 0; y < height; y++) {
  28.123 -        d = d1;
  28.124 -        switch(bpp) {
  28.125 -        case 1:
  28.126 -            for (x = 0; x < width; x++) {
  28.127 -                *((uint8_t *)d) = color;
  28.128 -                d++;
  28.129 -            }
  28.130 -            break;
  28.131 -        case 2:
  28.132 -            for (x = 0; x < width; x++) {
  28.133 -                *((uint16_t *)d) = color;
  28.134 -                d += 2;
  28.135 -            }
  28.136 -            break;
  28.137 -        case 4:
  28.138 -            for (x = 0; x < width; x++) {
  28.139 -                *((uint32_t *)d) = color;
  28.140 -                d += 4;
  28.141 -            }
  28.142 -            break;
  28.143 -        }
  28.144 -        d1 += ds->linesize;
  28.145 -    }
  28.146 -}
  28.147 -
  28.148 -/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */
  28.149 -static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w, int h)
  28.150 -{
  28.151 -    const uint8_t *s;
  28.152 -    uint8_t *d;
  28.153 -    int wb, y, bpp;
  28.154 -
  28.155 -    bpp = (ds->depth + 7) >> 3;
  28.156 -    wb = w * bpp;
  28.157 -    if (yd <= ys) {
  28.158 -        s = ds->data + 
  28.159 -            ds->linesize * ys + bpp * xs;
  28.160 -        d = ds->data + 
  28.161 -            ds->linesize * yd + bpp * xd;
  28.162 -        for (y = 0; y < h; y++) {
  28.163 -            memmove(d, s, wb);
  28.164 -            d += ds->linesize;
  28.165 -            s += ds->linesize;
  28.166 -        }
  28.167 -    } else {
  28.168 -        s = ds->data + 
  28.169 -            ds->linesize * (ys + h - 1) + bpp * xs;
  28.170 -        d = ds->data + 
  28.171 -            ds->linesize * (yd + h - 1) + bpp * xd;
  28.172 -       for (y = 0; y < h; y++) {
  28.173 -            memmove(d, s, wb);
  28.174 -            d -= ds->linesize;
  28.175 -            s -= ds->linesize;
  28.176 -        }
  28.177 -    }
  28.178 -}
  28.179 -
  28.180 -/***********************************************************/
  28.181 -/* basic char display */
  28.182 -
  28.183 -#define FONT_HEIGHT 16
  28.184 -#define FONT_WIDTH 8
  28.185 -
  28.186 -#include "vgafont.h"
  28.187 -
  28.188 -#define cbswap_32(__x) \
  28.189 -((uint32_t)( \
  28.190 -		(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
  28.191 -		(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
  28.192 -		(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
  28.193 -		(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) ))
  28.194 -
  28.195 -#ifdef WORDS_BIGENDIAN
  28.196 -#define PAT(x) x
  28.197 -#else
  28.198 -#define PAT(x) cbswap_32(x)
  28.199 -#endif
  28.200 -
  28.201 -static const uint32_t dmask16[16] = {
  28.202 -    PAT(0x00000000),
  28.203 -    PAT(0x000000ff),
  28.204 -    PAT(0x0000ff00),
  28.205 -    PAT(0x0000ffff),
  28.206 -    PAT(0x00ff0000),
  28.207 -    PAT(0x00ff00ff),
  28.208 -    PAT(0x00ffff00),
  28.209 -    PAT(0x00ffffff),
  28.210 -    PAT(0xff000000),
  28.211 -    PAT(0xff0000ff),
  28.212 -    PAT(0xff00ff00),
  28.213 -    PAT(0xff00ffff),
  28.214 -    PAT(0xffff0000),
  28.215 -    PAT(0xffff00ff),
  28.216 -    PAT(0xffffff00),
  28.217 -    PAT(0xffffffff),
  28.218 -};
  28.219 -
  28.220 -static const uint32_t dmask4[4] = {
  28.221 -    PAT(0x00000000),
  28.222 -    PAT(0x0000ffff),
  28.223 -    PAT(0xffff0000),
  28.224 -    PAT(0xffffffff),
  28.225 -};
  28.226 -
  28.227 -static uint32_t color_table[8];
  28.228 -
  28.229 -static const uint32_t color_table_rgb[8] = {
  28.230 -    RGB(0x00, 0x00, 0x00),
  28.231 -    RGB(0xff, 0x00, 0x00),
  28.232 -    RGB(0x00, 0xff, 0x00),
  28.233 -    RGB(0xff, 0xff, 0x00),
  28.234 -    RGB(0x00, 0x00, 0xff),
  28.235 -    RGB(0xff, 0x00, 0xff),
  28.236 -    RGB(0x00, 0xff, 0xff),
  28.237 -    RGB(0xff, 0xff, 0xff),
  28.238 -};
  28.239 -
  28.240 -static inline unsigned int col_expand(DisplayState *ds, unsigned int col)
  28.241 -{
  28.242 -    switch(ds->depth) {
  28.243 -    case 8:
  28.244 -        col |= col << 8;
  28.245 -        col |= col << 16;
  28.246 -        break;
  28.247 -    case 15:
  28.248 -    case 16:
  28.249 -        col |= col << 16;
  28.250 -        break;
  28.251 -    default:
  28.252 -        break;
  28.253 -    }
  28.254 -
  28.255 -    return col;
  28.256 -}
  28.257 -
  28.258 -static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, 
  28.259 -                          unsigned int fgcol, unsigned int bgcol)
  28.260 -{
  28.261 -    uint8_t *d;
  28.262 -    const uint8_t *font_ptr;
  28.263 -    unsigned int font_data, linesize, xorcol, bpp;
  28.264 -    int i;
  28.265 -
  28.266 -    bpp = (ds->depth + 7) >> 3;
  28.267 -    d = ds->data + 
  28.268 -        ds->linesize * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
  28.269 -    linesize = ds->linesize;
  28.270 -    font_ptr = vgafont16 + FONT_HEIGHT * ch;
  28.271 -    xorcol = bgcol ^ fgcol;
  28.272 -    switch(ds->depth) {
  28.273 -    case 8:
  28.274 -        for(i = 0; i < FONT_HEIGHT; i++) {
  28.275 -            font_data = *font_ptr++;
  28.276 -            ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol;
  28.277 -            ((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
  28.278 -            d += linesize;
  28.279 -        }
  28.280 -        break;
  28.281 -    case 16:
  28.282 -    case 15:
  28.283 -        for(i = 0; i < FONT_HEIGHT; i++) {
  28.284 -            font_data = *font_ptr++;
  28.285 -            ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol;
  28.286 -            ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol;
  28.287 -            ((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol;
  28.288 -            ((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
  28.289 -            d += linesize;
  28.290 -        }
  28.291 -        break;
  28.292 -    case 32:
  28.293 -        for(i = 0; i < FONT_HEIGHT; i++) {
  28.294 -            font_data = *font_ptr++;
  28.295 -            ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
  28.296 -            ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
  28.297 -            ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
  28.298 -            ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
  28.299 -            ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
  28.300 -            ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
  28.301 -            ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
  28.302 -            ((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
  28.303 -            d += linesize;
  28.304 -        }
  28.305 -        break;
  28.306 -    }
  28.307 -}
  28.308 -
  28.309 -static void text_console_resize(TextConsole *s)
  28.310 -{
  28.311 -    TextCell *cells, *c, *c1;
  28.312 -    int w1, x, y, last_width;
  28.313 -
  28.314 -    last_width = s->width;
  28.315 -    s->width = s->g_width / FONT_WIDTH;
  28.316 -    s->height = s->g_height / FONT_HEIGHT;
  28.317 -
  28.318 -    w1 = last_width;
  28.319 -    if (s->width < w1)
  28.320 -        w1 = s->width;
  28.321 -
  28.322 -    cells = qemu_malloc(s->width * s->total_height * sizeof(TextCell));
  28.323 -    for(y = 0; y < s->total_height; y++) {
  28.324 -        c = &cells[y * s->width];
  28.325 -        if (w1 > 0) {
  28.326 -            c1 = &s->cells[y * last_width];
  28.327 -            for(x = 0; x < w1; x++) {
  28.328 -                *c++ = *c1++;
  28.329 -            }
  28.330 -        }
  28.331 -        for(x = w1; x < s->width; x++) {
  28.332 -            c->ch = ' ';
  28.333 -            c->fgcol = 7;
  28.334 -            c->bgcol = 0;
  28.335 -            c++;
  28.336 -        }
  28.337 -    }
  28.338 -    qemu_free(s->cells);
  28.339 -    s->cells = cells;
  28.340 -}
  28.341 -
  28.342 -static void update_xy(TextConsole *s, int x, int y)
  28.343 -{
  28.344 -    TextCell *c;
  28.345 -    int y1, y2;
  28.346 -
  28.347 -    if (s == active_console) {
  28.348 -        y1 = (s->y_base + y) % s->total_height;
  28.349 -        y2 = y1 - s->y_displayed;
  28.350 -        if (y2 < 0)
  28.351 -            y2 += s->total_height;
  28.352 -        if (y2 < s->height) {
  28.353 -            c = &s->cells[y1 * s->width + x];
  28.354 -            vga_putcharxy(s->ds, x, y2, c->ch, 
  28.355 -                          color_table[c->fgcol], color_table[c->bgcol]);
  28.356 -            dpy_update(s->ds, x * FONT_WIDTH, y2 * FONT_HEIGHT, 
  28.357 -                       FONT_WIDTH, FONT_HEIGHT);
  28.358 -        }
  28.359 -    }
  28.360 -}
  28.361 -
  28.362 -static void console_show_cursor(TextConsole *s, int show)
  28.363 -{
  28.364 -    TextCell *c;
  28.365 -    int y, y1;
  28.366 -
  28.367 -    if (s == active_console) {
  28.368 -        y1 = (s->y_base + s->y) % s->total_height;
  28.369 -        y = y1 - s->y_displayed;
  28.370 -        if (y < 0)
  28.371 -            y += s->total_height;
  28.372 -        if (y < s->height) {
  28.373 -            c = &s->cells[y1 * s->width + s->x];
  28.374 -            if (show) {
  28.375 -                vga_putcharxy(s->ds, s->x, y, c->ch, 
  28.376 -                              color_table[0], color_table[7]);
  28.377 -            } else {
  28.378 -                vga_putcharxy(s->ds, s->x, y, c->ch, 
  28.379 -                              color_table[c->fgcol], color_table[c->bgcol]);
  28.380 -            }
  28.381 -            dpy_update(s->ds, s->x * FONT_WIDTH, y * FONT_HEIGHT, 
  28.382 -                       FONT_WIDTH, FONT_HEIGHT);
  28.383 -        }
  28.384 -    }
  28.385 -}
  28.386 -
  28.387 -static void console_refresh(TextConsole *s)
  28.388 -{
  28.389 -    TextCell *c;
  28.390 -    int x, y, y1;
  28.391 -
  28.392 -    if (s != active_console) 
  28.393 -        return;
  28.394 -
  28.395 -    vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height,
  28.396 -                  color_table[0]);
  28.397 -    y1 = s->y_displayed;
  28.398 -    for(y = 0; y < s->height; y++) {
  28.399 -        c = s->cells + y1 * s->width;
  28.400 -        for(x = 0; x < s->width; x++) {
  28.401 -            vga_putcharxy(s->ds, x, y, c->ch, 
  28.402 -                          color_table[c->fgcol], color_table[c->bgcol]);
  28.403 -            c++;
  28.404 -        }
  28.405 -        if (++y1 == s->total_height)
  28.406 -            y1 = 0;
  28.407 -    }
  28.408 -    dpy_update(s->ds, 0, 0, s->ds->width, s->ds->height);
  28.409 -    console_show_cursor(s, 1);
  28.410 -}
  28.411 -
  28.412 -static void console_scroll(int ydelta)
  28.413 -{
  28.414 -    TextConsole *s;
  28.415 -    int i, y1;
  28.416 -    
  28.417 -    s = active_console;
  28.418 -    if (!s || !s->text_console)
  28.419 -        return;
  28.420 -
  28.421 -    if (ydelta > 0) {
  28.422 -        for(i = 0; i < ydelta; i++) {
  28.423 -            if (s->y_displayed == s->y_base)
  28.424 -                break;
  28.425 -            if (++s->y_displayed == s->total_height)
  28.426 -                s->y_displayed = 0;
  28.427 -        }
  28.428 -    } else {
  28.429 -        ydelta = -ydelta;
  28.430 -        i = s->backscroll_height;
  28.431 -        if (i > s->total_height - s->height)
  28.432 -            i = s->total_height - s->height;
  28.433 -        y1 = s->y_base - i;
  28.434 -        if (y1 < 0)
  28.435 -            y1 += s->total_height;
  28.436 -        for(i = 0; i < ydelta; i++) {
  28.437 -            if (s->y_displayed == y1)
  28.438 -                break;
  28.439 -            if (--s->y_displayed < 0)
  28.440 -                s->y_displayed = s->total_height - 1;
  28.441 -        }
  28.442 -    }
  28.443 -    console_refresh(s);
  28.444 -}
  28.445 -
  28.446 -static void console_put_lf(TextConsole *s)
  28.447 -{
  28.448 -    TextCell *c;
  28.449 -    int x, y1;
  28.450 -
  28.451 -    s->x = 0;
  28.452 -    s->y++;
  28.453 -    if (s->y >= s->height) {
  28.454 -        s->y = s->height - 1;
  28.455 -        
  28.456 -        if (s->y_displayed == s->y_base) {
  28.457 -            if (++s->y_displayed == s->total_height)
  28.458 -                s->y_displayed = 0;
  28.459 -        }
  28.460 -        if (++s->y_base == s->total_height)
  28.461 -            s->y_base = 0;
  28.462 -        if (s->backscroll_height < s->total_height)
  28.463 -            s->backscroll_height++;
  28.464 -        y1 = (s->y_base + s->height - 1) % s->total_height;
  28.465 -        c = &s->cells[y1 * s->width];
  28.466 -        for(x = 0; x < s->width; x++) {
  28.467 -            c->ch = ' ';
  28.468 -            c->fgcol = s->fgcol;
  28.469 -            c->bgcol = s->bgcol;
  28.470 -            c++;
  28.471 -        }
  28.472 -        if (s == active_console && s->y_displayed == s->y_base) {
  28.473 -            vga_bitblt(s->ds, 0, FONT_HEIGHT, 0, 0, 
  28.474 -                       s->width * FONT_WIDTH, 
  28.475 -                       (s->height - 1) * FONT_HEIGHT);
  28.476 -            vga_fill_rect(s->ds, 0, (s->height - 1) * FONT_HEIGHT,
  28.477 -                          s->width * FONT_WIDTH, FONT_HEIGHT, 
  28.478 -                          color_table[s->bgcol]);
  28.479 -            dpy_update(s->ds, 0, 0, 
  28.480 -                       s->width * FONT_WIDTH, s->height * FONT_HEIGHT);
  28.481 -        }
  28.482 -    }
  28.483 -}
  28.484 -
  28.485 -static void console_putchar(TextConsole *s, int ch)
  28.486 -{
  28.487 -    TextCell *c;
  28.488 -    int y1, i, x;
  28.489 -
  28.490 -    switch(s->state) {
  28.491 -    case TTY_STATE_NORM:
  28.492 -        switch(ch) {
  28.493 -        case '\r':
  28.494 -            s->x = 0;
  28.495 -            break;
  28.496 -        case '\n':
  28.497 -            console_put_lf(s);
  28.498 -            break;
  28.499 -        case 27:
  28.500 -            s->state = TTY_STATE_ESC;
  28.501 -            break;
  28.502 -        default:
  28.503 -            y1 = (s->y_base + s->y) % s->total_height;
  28.504 -            c = &s->cells[y1 * s->width + s->x];
  28.505 -            c->ch = ch;
  28.506 -            c->fgcol = s->fgcol;
  28.507 -            c->bgcol = s->bgcol;
  28.508 -            update_xy(s, s->x, s->y);
  28.509 -            s->x++;
  28.510 -            if (s->x >= s->width)
  28.511 -                console_put_lf(s);
  28.512 -            break;
  28.513 -        }
  28.514 -        break;
  28.515 -    case TTY_STATE_ESC:
  28.516 -        if (ch == '[') {
  28.517 -            for(i=0;i<MAX_ESC_PARAMS;i++)
  28.518 -                s->esc_params[i] = 0;
  28.519 -            s->nb_esc_params = 0;
  28.520 -            s->state = TTY_STATE_CSI;
  28.521 -        } else {
  28.522 -            s->state = TTY_STATE_NORM;
  28.523 -        }
  28.524 -        break;
  28.525 -    case TTY_STATE_CSI:
  28.526 -        if (ch >= '0' && ch <= '9') {
  28.527 -            if (s->nb_esc_params < MAX_ESC_PARAMS) {
  28.528 -                s->esc_params[s->nb_esc_params] = 
  28.529 -                    s->esc_params[s->nb_esc_params] * 10 + ch - '0';
  28.530 -            }
  28.531 -        } else {
  28.532 -            s->nb_esc_params++;
  28.533 -            if (ch == ';')
  28.534 -                break;
  28.535 -            s->state = TTY_STATE_NORM;
  28.536 -            switch(ch) {
  28.537 -            case 'D':
  28.538 -                if (s->x > 0)
  28.539 -                    s->x--;
  28.540 -                break;
  28.541 -            case 'C':
  28.542 -                if (s->x < (s->width - 1))
  28.543 -                    s->x++;
  28.544 -                break;
  28.545 -            case 'K':
  28.546 -                /* clear to eol */
  28.547 -                y1 = (s->y_base + s->y) % s->total_height;
  28.548 -                for(x = s->x; x < s->width; x++) {
  28.549 -                    c = &s->cells[y1 * s->width + x];
  28.550 -                    c->ch = ' ';
  28.551 -                    c->fgcol = s->fgcol;
  28.552 -                    c->bgcol = s->bgcol;
  28.553 -                    c++;
  28.554 -                    update_xy(s, x, s->y);
  28.555 -                }
  28.556 -                break;
  28.557 -            default:
  28.558 -                break;
  28.559 -            }
  28.560 -            break;
  28.561 -        }
  28.562 -    }
  28.563 -}
  28.564 -
  28.565 -void console_select(unsigned int index)
  28.566 -{
  28.567 -    TextConsole *s;
  28.568 -    
  28.569 -    if (index >= MAX_CONSOLES)
  28.570 -        return;
  28.571 -    s = consoles[index];
  28.572 -    if (s) {
  28.573 -        active_console = s;
  28.574 -        if (s->text_console) {
  28.575 -            if (s->g_width != s->ds->width ||
  28.576 -                s->g_height != s->ds->height) {
  28.577 -		s->g_width = s->ds->width;
  28.578 -		s->g_height = s->ds->height;
  28.579 -                text_console_resize(s);
  28.580 -	    }
  28.581 -            console_refresh(s);
  28.582 -        }
  28.583 -    }
  28.584 -}
  28.585 -
  28.586 -static int console_puts(CharDriverState *chr, const uint8_t *buf, int len)
  28.587 -{
  28.588 -    TextConsole *s = chr->opaque;
  28.589 -    int i;
  28.590 -
  28.591 -    console_show_cursor(s, 0);
  28.592 -    for(i = 0; i < len; i++) {
  28.593 -        console_putchar(s, buf[i]);
  28.594 -    }
  28.595 -    console_show_cursor(s, 1);
  28.596 -    return len;
  28.597 -}
  28.598 -
  28.599 -static void console_chr_add_read_handler(CharDriverState *chr, 
  28.600 -                                         IOCanRWHandler *fd_can_read, 
  28.601 -                                         IOReadHandler *fd_read, void *opaque)
  28.602 -{
  28.603 -    TextConsole *s = chr->opaque;
  28.604 -    s->fd_read = fd_read;
  28.605 -    s->fd_opaque = opaque;
  28.606 -}
  28.607 -
  28.608 -static void console_send_event(CharDriverState *chr, int event)
  28.609 -{
  28.610 -    TextConsole *s = chr->opaque;
  28.611 -    int i;
  28.612 -
  28.613 -    if (event == CHR_EVENT_FOCUS) {
  28.614 -        for(i = 0; i < nb_consoles; i++) {
  28.615 -            if (consoles[i] == s) {
  28.616 -                console_select(i);
  28.617 -                break;
  28.618 -            }
  28.619 -        }
  28.620 -    }
  28.621 -}
  28.622 -
  28.623 -/* called when an ascii key is pressed */
  28.624 -void kbd_put_keysym(int keysym)
  28.625 -{
  28.626 -    TextConsole *s;
  28.627 -    uint8_t buf[16], *q;
  28.628 -    int c;
  28.629 -
  28.630 -    s = active_console;
  28.631 -    if (!s || !s->text_console)
  28.632 -        return;
  28.633 -
  28.634 -    switch(keysym) {
  28.635 -    case QEMU_KEY_CTRL_UP:
  28.636 -        console_scroll(-1);
  28.637 -        break;
  28.638 -    case QEMU_KEY_CTRL_DOWN:
  28.639 -        console_scroll(1);
  28.640 -        break;
  28.641 -    case QEMU_KEY_CTRL_PAGEUP:
  28.642 -        console_scroll(-10);
  28.643 -        break;
  28.644 -    case QEMU_KEY_CTRL_PAGEDOWN:
  28.645 -        console_scroll(10);
  28.646 -        break;
  28.647 -    default:
  28.648 -        if (s->fd_read) {
  28.649 -            /* convert the QEMU keysym to VT100 key string */
  28.650 -            q = buf;
  28.651 -            if (keysym >= 0xe100 && keysym <= 0xe11f) {
  28.652 -                *q++ = '\033';
  28.653 -                *q++ = '[';
  28.654 -                c = keysym - 0xe100;
  28.655 -                if (c >= 10)
  28.656 -                    *q++ = '0' + (c / 10);
  28.657 -                *q++ = '0' + (c % 10);
  28.658 -                *q++ = '~';
  28.659 -            } else if (keysym >= 0xe120 && keysym <= 0xe17f) {
  28.660 -                *q++ = '\033';
  28.661 -                *q++ = '[';
  28.662 -                *q++ = keysym & 0xff;
  28.663 -            } else {
  28.664 -                *q++ = keysym;
  28.665 -            }
  28.666 -            s->fd_read(s->fd_opaque, buf, q - buf);
  28.667 -        }
  28.668 -        break;
  28.669 -    }
  28.670 -}
  28.671 -
  28.672 -TextConsole *graphic_console_init(DisplayState *ds)
  28.673 -{
  28.674 -    TextConsole *s;
  28.675 -
  28.676 -    if (nb_consoles >= MAX_CONSOLES)
  28.677 -        return NULL;
  28.678 -    s = qemu_mallocz(sizeof(TextConsole));
  28.679 -    if (!s) {
  28.680 -        return NULL;
  28.681 -    }
  28.682 -    if (!active_console)
  28.683 -        active_console = s;
  28.684 -    s->ds = ds;
  28.685 -    consoles[nb_consoles++] = s;
  28.686 -    return s;
  28.687 -}
  28.688 -
  28.689 -int is_active_console(TextConsole *s)
  28.690 -{
  28.691 -    return s == active_console;
  28.692 -}
  28.693 -
  28.694 -CharDriverState *text_console_init(DisplayState *ds)
  28.695 -{
  28.696 -    CharDriverState *chr;
  28.697 -    TextConsole *s;
  28.698 -    int i;
  28.699 -    static int color_inited;
  28.700 -    
  28.701 -    chr = qemu_mallocz(sizeof(CharDriverState));
  28.702 -    if (!chr)
  28.703 -        return NULL;
  28.704 -    s = graphic_console_init(ds);
  28.705 -    if (!s) {
  28.706 -        free(chr);
  28.707 -        return NULL;
  28.708 -    }
  28.709 -    s->text_console = 1;
  28.710 -    chr->opaque = s;
  28.711 -    chr->chr_write = console_puts;
  28.712 -    chr->chr_add_read_handler = console_chr_add_read_handler;
  28.713 -    chr->chr_send_event = console_send_event;
  28.714 -
  28.715 -    if (!color_inited) {
  28.716 -        color_inited = 1;
  28.717 -        for(i = 0; i < 8; i++) {
  28.718 -            color_table[i] = col_expand(s->ds, 
  28.719 -                                        vga_get_color(s->ds, color_table_rgb[i]));
  28.720 -        }
  28.721 -    }
  28.722 -    s->y_displayed = 0;
  28.723 -    s->y_base = 0;
  28.724 -    s->total_height = DEFAULT_BACKSCROLL;
  28.725 -    s->x = 0;
  28.726 -    s->y = 0;
  28.727 -    s->fgcol = 7;
  28.728 -    s->bgcol = 0;
  28.729 -    s->g_width = s->ds->width;
  28.730 -    s->g_height = s->ds->height;
  28.731 -    text_console_resize(s);
  28.732 -
  28.733 -    return chr;
  28.734 -}
    29.1 --- a/tools/ioemu/cpu-all.h	Wed Jul 12 16:34:39 2006 +0100
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,731 +0,0 @@
    29.4 -/*
    29.5 - * defines common to all virtual CPUs
    29.6 - * 
    29.7 - *  Copyright (c) 2003 Fabrice Bellard
    29.8 - *
    29.9 - * This library is free software; you can redistribute it and/or
   29.10 - * modify it under the terms of the GNU Lesser General Public
   29.11 - * License as published by the Free Software Foundation; either
   29.12 - * version 2 of the License, or (at your option) any later version.
   29.13 - *
   29.14 - * This library is distributed in the hope that it will be useful,
   29.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   29.17 - * Lesser General Public License for more details.
   29.18 - *
   29.19 - * You should have received a copy of the GNU Lesser General Public
   29.20 - * License along with this library; if not, write to the Free Software
   29.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   29.22 - */
   29.23 -#ifndef CPU_ALL_H
   29.24 -#define CPU_ALL_H
   29.25 -
   29.26 -#if defined(__arm__) || defined(__sparc__)
   29.27 -#define WORDS_ALIGNED
   29.28 -#endif
   29.29 -
   29.30 -/* some important defines: 
   29.31 - * 
   29.32 - * WORDS_ALIGNED : if defined, the host cpu can only make word aligned
   29.33 - * memory accesses.
   29.34 - * 
   29.35 - * WORDS_BIGENDIAN : if defined, the host cpu is big endian and
   29.36 - * otherwise little endian.
   29.37 - * 
   29.38 - * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet))
   29.39 - * 
   29.40 - * TARGET_WORDS_BIGENDIAN : same for target cpu
   29.41 - */
   29.42 -
   29.43 -#include "bswap.h"
   29.44 -
   29.45 -#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
   29.46 -#define BSWAP_NEEDED
   29.47 -#endif
   29.48 -
   29.49 -#ifdef BSWAP_NEEDED
   29.50 -
   29.51 -static inline uint16_t tswap16(uint16_t s)
   29.52 -{
   29.53 -    return bswap16(s);
   29.54 -}
   29.55 -
   29.56 -static inline uint32_t tswap32(uint32_t s)
   29.57 -{
   29.58 -    return bswap32(s);
   29.59 -}
   29.60 -
   29.61 -static inline uint64_t tswap64(uint64_t s)
   29.62 -{
   29.63 -    return bswap64(s);
   29.64 -}
   29.65 -
   29.66 -static inline void tswap16s(uint16_t *s)
   29.67 -{
   29.68 -    *s = bswap16(*s);
   29.69 -}
   29.70 -
   29.71 -static inline void tswap32s(uint32_t *s)
   29.72 -{
   29.73 -    *s = bswap32(*s);
   29.74 -}
   29.75 -
   29.76 -static inline void tswap64s(uint64_t *s)
   29.77 -{
   29.78 -    *s = bswap64(*s);
   29.79 -}
   29.80 -
   29.81 -#else
   29.82 -
   29.83 -static inline uint16_t tswap16(uint16_t s)
   29.84 -{
   29.85 -    return s;
   29.86 -}
   29.87 -
   29.88 -static inline uint32_t tswap32(uint32_t s)
   29.89 -{
   29.90 -    return s;
   29.91 -}
   29.92 -
   29.93 -static inline uint64_t tswap64(uint64_t s)
   29.94 -{
   29.95 -    return s;
   29.96 -}
   29.97 -
   29.98 -static inline void tswap16s(uint16_t *s)
   29.99 -{
  29.100 -}
  29.101 -
  29.102 -static inline void tswap32s(uint32_t *s)
  29.103 -{
  29.104 -}
  29.105 -
  29.106 -static inline void tswap64s(uint64_t *s)
  29.107 -{
  29.108 -}
  29.109 -
  29.110 -#endif
  29.111 -
  29.112 -#if TARGET_LONG_SIZE == 4
  29.113 -#define tswapl(s) tswap32(s)
  29.114 -#define tswapls(s) tswap32s((uint32_t *)(s))
  29.115 -#else
  29.116 -#define tswapl(s) tswap64(s)
  29.117 -#define tswapls(s) tswap64s((uint64_t *)(s))
  29.118 -#endif
  29.119 -
  29.120 -/* NOTE: arm is horrible as double 32 bit words are stored in big endian ! */
  29.121 -typedef union {
  29.122 -    double d;
  29.123 -#if !defined(WORDS_BIGENDIAN) && !defined(__arm__)
  29.124 -    struct {
  29.125 -        uint32_t lower;
  29.126 -        uint32_t upper;
  29.127 -    } l;
  29.128 -#else
  29.129 -    struct {
  29.130 -        uint32_t upper;
  29.131 -        uint32_t lower;
  29.132 -    } l;
  29.133 -#endif
  29.134 -    uint64_t ll;
  29.135 -} CPU_DoubleU;
  29.136 -
  29.137 -/* CPU memory access without any memory or io remapping */
  29.138 -
  29.139 -/*
  29.140 - * the generic syntax for the memory accesses is:
  29.141 - *
  29.142 - * load: ld{type}{sign}{size}{endian}_{access_type}(ptr)
  29.143 - *
  29.144 - * store: st{type}{size}{endian}_{access_type}(ptr, val)
  29.145 - *
  29.146 - * type is:
  29.147 - * (empty): integer access
  29.148 - *   f    : float access
  29.149 - * 
  29.150 - * sign is:
  29.151 - * (empty): for floats or 32 bit size
  29.152 - *   u    : unsigned
  29.153 - *   s    : signed
  29.154 - *
  29.155 - * size is:
  29.156 - *   b: 8 bits
  29.157 - *   w: 16 bits
  29.158 - *   l: 32 bits
  29.159 - *   q: 64 bits
  29.160 - * 
  29.161 - * endian is:
  29.162 - * (empty): target cpu endianness or 8 bit access
  29.163 - *   r    : reversed target cpu endianness (not implemented yet)
  29.164 - *   be   : big endian (not implemented yet)
  29.165 - *   le   : little endian (not implemented yet)
  29.166 - *
  29.167 - * access_type is:
  29.168 - *   raw    : host memory access
  29.169 - *   user   : user mode access using soft MMU
  29.170 - *   kernel : kernel mode access using soft MMU
  29.171 - */
  29.172 -static inline int ldub_raw(void *ptr)
  29.173 -{
  29.174 -    return *(uint8_t *)ptr;
  29.175 -}
  29.176 -
  29.177 -static inline int ldsb_raw(void *ptr)
  29.178 -{
  29.179 -    return *(int8_t *)ptr;
  29.180 -}
  29.181 -
  29.182 -static inline void stb_raw(void *ptr, int v)
  29.183 -{
  29.184 -    *(uint8_t *)ptr = v;
  29.185 -}
  29.186 -
  29.187 -/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the
  29.188 -   kernel handles unaligned load/stores may give better results, but
  29.189 -   it is a system wide setting : bad */
  29.190 -#if !defined(TARGET_WORDS_BIGENDIAN) && (defined(WORDS_BIGENDIAN) || defined(WORDS_ALIGNED))
  29.191 -
  29.192 -/* conservative code for little endian unaligned accesses */
  29.193 -static inline int lduw_raw(void *ptr)
  29.194 -{
  29.195 -#ifdef __powerpc__
  29.196 -    int val;
  29.197 -    __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr));
  29.198 -    return val;
  29.199 -#else
  29.200 -    uint8_t *p = ptr;
  29.201 -    return p[0] | (p[1] << 8);
  29.202 -#endif
  29.203 -}
  29.204 -
  29.205 -static inline int ldsw_raw(void *ptr)
  29.206 -{
  29.207 -#ifdef __powerpc__
  29.208 -    int val;
  29.209 -    __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr));
  29.210 -    return (int16_t)val;
  29.211 -#else
  29.212 -    uint8_t *p = ptr;
  29.213 -    return (int16_t)(p[0] | (p[1] << 8));
  29.214 -#endif
  29.215 -}
  29.216 -
  29.217 -static inline int ldl_raw(void *ptr)
  29.218 -{
  29.219 -#ifdef __powerpc__
  29.220 -    int val;
  29.221 -    __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr));
  29.222 -    return val;
  29.223 -#else
  29.224 -    uint8_t *p = ptr;
  29.225 -    return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
  29.226 -#endif
  29.227 -}
  29.228 -
  29.229 -static inline uint64_t ldq_raw(void *ptr)
  29.230 -{
  29.231 -    uint8_t *p = ptr;
  29.232 -    uint32_t v1, v2;
  29.233 -    v1 = ldl_raw(p);
  29.234 -    v2 = ldl_raw(p + 4);
  29.235 -    return v1 | ((uint64_t)v2 << 32);
  29.236 -}
  29.237 -
  29.238 -static inline void stw_raw(void *ptr, int v)
  29.239 -{
  29.240 -#ifdef __powerpc__
  29.241 -    __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr));
  29.242 -#else
  29.243 -    uint8_t *p = ptr;
  29.244 -    p[0] = v;
  29.245 -    p[1] = v >> 8;
  29.246 -#endif
  29.247 -}
  29.248 -
  29.249 -static inline void stl_raw(void *ptr, int v)
  29.250 -{
  29.251 -#ifdef __powerpc__
  29.252 -    __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr));
  29.253 -#else
  29.254 -    uint8_t *p = ptr;
  29.255 -    p[0] = v;
  29.256 -    p[1] = v >> 8;
  29.257 -    p[2] = v >> 16;
  29.258 -    p[3] = v >> 24;
  29.259 -#endif
  29.260 -}
  29.261 -
  29.262 -static inline void stq_raw(void *ptr, uint64_t v)
  29.263 -{
  29.264 -    uint8_t *p = ptr;
  29.265 -    stl_raw(p, (uint32_t)v);
  29.266 -    stl_raw(p + 4, v >> 32);
  29.267 -}
  29.268 -
  29.269 -/* float access */
  29.270 -
  29.271 -static inline float ldfl_raw(void *ptr)
  29.272 -{
  29.273 -    union {
  29.274 -        float f;
  29.275 -        uint32_t i;
  29.276 -    } u;
  29.277 -    u.i = ldl_raw(ptr);
  29.278 -    return u.f;
  29.279 -}
  29.280 -
  29.281 -static inline void stfl_raw(void *ptr, float v)
  29.282 -{
  29.283 -    union {
  29.284 -        float f;
  29.285 -        uint32_t i;
  29.286 -    } u;
  29.287 -    u.f = v;
  29.288 -    stl_raw(ptr, u.i);
  29.289 -}
  29.290 -
  29.291 -static inline double ldfq_raw(void *ptr)
  29.292 -{
  29.293 -    CPU_DoubleU u;
  29.294 -    u.l.lower = ldl_raw(ptr);
  29.295 -    u.l.upper = ldl_raw(ptr + 4);
  29.296 -    return u.d;
  29.297 -}
  29.298 -
  29.299 -static inline void stfq_raw(void *ptr, double v)
  29.300 -{
  29.301 -    CPU_DoubleU u;
  29.302 -    u.d = v;
  29.303 -    stl_raw(ptr, u.l.lower);
  29.304 -    stl_raw(ptr + 4, u.l.upper);
  29.305 -}
  29.306 -
  29.307 -#elif defined(TARGET_WORDS_BIGENDIAN) && (!defined(WORDS_BIGENDIAN) || defined(WORDS_ALIGNED))
  29.308 -
  29.309 -static inline int lduw_raw(void *ptr)
  29.310 -{
  29.311 -#if defined(__i386__)
  29.312 -    int val;
  29.313 -    asm volatile ("movzwl %1, %0\n"
  29.314 -                  "xchgb %b0, %h0\n"
  29.315 -                  : "=q" (val)
  29.316 -                  : "m" (*(uint16_t *)ptr));
  29.317 -    return val;
  29.318 -#else
  29.319 -    uint8_t *b = (uint8_t *) ptr;
  29.320 -    return ((b[0] << 8) | b[1]);
  29.321 -#endif
  29.322 -}
  29.323 -
  29.324 -static inline int ldsw_raw(void *ptr)
  29.325 -{
  29.326 -#if defined(__i386__)
  29.327 -    int val;
  29.328 -    asm volatile ("movzwl %1, %0\n"
  29.329 -                  "xchgb %b0, %h0\n"
  29.330 -                  : "=q" (val)
  29.331 -                  : "m" (*(uint16_t *)ptr));
  29.332 -    return (int16_t)val;
  29.333 -#else
  29.334 -    uint8_t *b = (uint8_t *) ptr;
  29.335 -    return (int16_t)((b[0] << 8) | b[1]);
  29.336 -#endif
  29.337 -}
  29.338 -
  29.339 -static inline int ldl_raw(void *ptr)
  29.340 -{
  29.341 -#if defined(__i386__) || defined(__x86_64__)
  29.342 -    int val;
  29.343 -    asm volatile ("movl %1, %0\n"
  29.344 -                  "bswap %0\n"
  29.345 -                  : "=r" (val)
  29.346 -                  : "m" (*(uint32_t *)ptr));
  29.347 -    return val;
  29.348 -#else
  29.349 -    uint8_t *b = (uint8_t *) ptr;
  29.350 -    return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
  29.351 -#endif
  29.352 -}
  29.353 -
  29.354 -static inline uint64_t ldq_raw(void *ptr)
  29.355 -{
  29.356 -    uint32_t a,b;
  29.357 -    a = ldl_raw(ptr);
  29.358 -    b = ldl_raw(ptr+4);
  29.359 -    return (((uint64_t)a<<32)|b);
  29.360 -}
  29.361 -
  29.362 -static inline void stw_raw(void *ptr, int v)
  29.363 -{
  29.364 -#if defined(__i386__)
  29.365 -    asm volatile ("xchgb %b0, %h0\n"
  29.366 -                  "movw %w0, %1\n"
  29.367 -                  : "=q" (v)
  29.368 -                  : "m" (*(uint16_t *)ptr), "0" (v));
  29.369 -#else
  29.370 -    uint8_t *d = (uint8_t *) ptr;
  29.371 -    d[0] = v >> 8;
  29.372 -    d[1] = v;
  29.373 -#endif
  29.374 -}
  29.375 -
  29.376 -static inline void stl_raw(void *ptr, int v)
  29.377 -{
  29.378 -#if defined(__i386__) || defined(__x86_64__)
  29.379 -    asm volatile ("bswap %0\n"
  29.380 -                  "movl %0, %1\n"
  29.381 -                  : "=r" (v)
  29.382 -                  : "m" (*(uint32_t *)ptr), "0" (v));
  29.383 -#else
  29.384 -    uint8_t *d = (uint8_t *) ptr;
  29.385 -    d[0] = v >> 24;
  29.386 -    d[1] = v >> 16;
  29.387 -    d[2] = v >> 8;
  29.388 -    d[3] = v;
  29.389 -#endif
  29.390 -}
  29.391 -
  29.392 -static inline void stq_raw(void *ptr, uint64_t v)
  29.393 -{
  29.394 -    stl_raw(ptr, v >> 32);