Greatly simplified the SDL CPU info code
authorSam Lantinga <slouken@libsdl.org>
Mon, 24 Nov 2003 09:16:52 +0000
changeset 74571ee03909f42
parent 744 f601f5c05045
child 746 72ef7ce609ef
Greatly simplified the SDL CPU info code
include/SDL_cpuinfo.h
src/cpuinfo/COPYING.LIB
src/cpuinfo/Makefile.am
src/cpuinfo/README
src/cpuinfo/SDL_cpuinfo.c
src/cpuinfo/_cpuinfo.asm
src/cpuinfo/_pcihelp.asm
src/cpuinfo/cpuinfo.h
src/cpuinfo/gcpuinfo.c
src/cpuinfo/scitech.mac
     1.1 --- a/include/SDL_cpuinfo.h	Mon Nov 24 00:21:24 2003 +0000
     1.2 +++ b/include/SDL_cpuinfo.h	Mon Nov 24 09:16:52 2003 +0000
     1.3 @@ -37,6 +37,10 @@
     1.4  extern "C" {
     1.5  #endif
     1.6  
     1.7 +/* This function returns true if the CPU has the RDTSC instruction
     1.8 + */
     1.9 +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC();
    1.10 +
    1.11  /* This function returns true if the CPU has MMX features
    1.12   */
    1.13  extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX();
     2.1 --- a/src/cpuinfo/COPYING.LIB	Mon Nov 24 00:21:24 2003 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,438 +0,0 @@
     2.4 -		  GNU LIBRARY GENERAL PUBLIC LICENSE
     2.5 -		       Version 2, June 1991
     2.6 -
     2.7 - Copyright (C) 1991 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 library GPL.  It is
    2.13 - numbered 2 because it goes with version 2 of the ordinary GPL.]
    2.14 -
    2.15 -			    Preamble
    2.16 -
    2.17 -  The licenses for most software are designed to take away your
    2.18 -freedom to share and change it.  By contrast, the GNU General Public
    2.19 -Licenses are intended to guarantee your freedom to share and change
    2.20 -free software--to make sure the software is free for all its users.
    2.21 -
    2.22 -  This license, the Library General Public License, applies to some
    2.23 -specially designated Free Software Foundation software, and to any
    2.24 -other libraries whose authors decide to use it.  You can use it for
    2.25 -your libraries, too.
    2.26 -
    2.27 -  When we speak of free software, we are referring to freedom, not
    2.28 -price.  Our General Public Licenses are designed to make sure that you
    2.29 -have the freedom to distribute copies of free software (and charge for
    2.30 -this service if you wish), that you receive source code or can get it
    2.31 -if you want it, that you can change the software or use pieces of it
    2.32 -in new free programs; and that you know you can do these things.
    2.33 -
    2.34 -  To protect your rights, we need to make restrictions that forbid
    2.35 -anyone to deny you these rights or to ask you to surrender the rights.
    2.36 -These restrictions translate to certain responsibilities for you if
    2.37 -you distribute copies of the library, or if you modify it.
    2.38 -
    2.39 -  For example, if you distribute copies of the library, whether gratis
    2.40 -or for a fee, you must give the recipients all the rights that we gave
    2.41 -you.  You must make sure that they, too, receive or can get the source
    2.42 -code.  If you link a program with the library, you must provide
    2.43 -complete object files to the recipients so that they can relink them
    2.44 -with the library, after making changes to the library and recompiling
    2.45 -it.  And you must show them these terms so they know their rights.
    2.46 -
    2.47 -  Our method of protecting your rights has two steps: (1) copyright
    2.48 -the library, and (2) offer you this license which gives you legal
    2.49 -permission to copy, distribute and/or modify the library.
    2.50 -
    2.51 -  Also, for each distributor's protection, we want to make certain
    2.52 -that everyone understands that there is no warranty for this free
    2.53 -library.  If the library is modified by someone else and passed on, we
    2.54 -want its recipients to know that what they have is not the original
    2.55 -version, so that any problems introduced by others will not reflect on
    2.56 -the original authors' reputations.
    2.57 -
    2.58 -  Finally, any free program is threatened constantly by software
    2.59 -patents.  We wish to avoid the danger that companies distributing free
    2.60 -software will individually obtain patent licenses, thus in effect
    2.61 -transforming the program into proprietary software.  To prevent this,
    2.62 -we have made it clear that any patent must be licensed for everyone's
    2.63 -free use or not licensed at all.
    2.64 -
    2.65 -  Most GNU software, including some libraries, is covered by the ordinary
    2.66 -GNU General Public License, which was designed for utility programs.  This
    2.67 -license, the GNU Library General Public License, applies to certain
    2.68 -designated libraries.  This license is quite different from the ordinary
    2.69 -one; be sure to read it in full, and don't assume that anything in it is
    2.70 -the same as in the ordinary license.
    2.71 -
    2.72 -  The reason we have a separate public license for some libraries is that
    2.73 -they blur the distinction we usually make between modifying or adding to a
    2.74 -program and simply using it.  Linking a program with a library, without
    2.75 -changing the library, is in some sense simply using the library, and is
    2.76 -analogous to running a utility program or application program.  However, in
    2.77 -a textual and legal sense, the linked executable is a combined work, a
    2.78 -derivative of the original library, and the ordinary General Public License
    2.79 -treats it as such.
    2.80 -
    2.81 -  Because of this blurred distinction, using the ordinary General
    2.82 -Public License for libraries did not effectively promote software
    2.83 -sharing, because most developers did not use the libraries.  We
    2.84 -concluded that weaker conditions might promote sharing better.
    2.85 -
    2.86 -  However, unrestricted linking of non-free programs would deprive the
    2.87 -users of those programs of all benefit from the free status of the
    2.88 -libraries themselves.  This Library General Public License is intended to
    2.89 -permit developers of non-free programs to use free libraries, while
    2.90 -preserving your freedom as a user of such programs to change the free
    2.91 -libraries that are incorporated in them.  (We have not seen how to achieve
    2.92 -this as regards changes in header files, but we have achieved it as regards
    2.93 -changes in the actual functions of the Library.)  The hope is that this
    2.94 -will lead to faster development of free libraries.
    2.95 -
    2.96 -  The precise terms and conditions for copying, distribution and
    2.97 -modification follow.  Pay close attention to the difference between a
    2.98 -"work based on the library" and a "work that uses the library".  The
    2.99 -former contains code derived from the library, while the latter only
   2.100 -works together with the library.
   2.101 -
   2.102 -  Note that it is possible for a library to be covered by the ordinary
   2.103 -General Public License rather than by this special one.
   2.104 -
   2.105 -		  GNU LIBRARY GENERAL PUBLIC LICENSE
   2.106 -   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
   2.107 -
   2.108 -  0. This License Agreement applies to any software library which
   2.109 -contains a notice placed by the copyright holder or other authorized
   2.110 -party saying it may be distributed under the terms of this Library
   2.111 -General Public License (also called "this License").  Each licensee is
   2.112 -addressed as "you".
   2.113 -
   2.114 -  A "library" means a collection of software functions and/or data
   2.115 -prepared so as to be conveniently linked with application programs
   2.116 -(which use some of those functions and data) to form executables.
   2.117 -
   2.118 -  The "Library", below, refers to any such software library or work
   2.119 -which has been distributed under these terms.  A "work based on the
   2.120 -Library" means either the Library or any derivative work under
   2.121 -copyright law: that is to say, a work containing the Library or a
   2.122 -portion of it, either verbatim or with modifications and/or translated
   2.123 -straightforwardly into another language.  (Hereinafter, translation is
   2.124 -included without limitation in the term "modification".)
   2.125 -
   2.126 -  "Source code" for a work means the preferred form of the work for
   2.127 -making modifications to it.  For a library, complete source code means
   2.128 -all the source code for all modules it contains, plus any associated
   2.129 -interface definition files, plus the scripts used to control compilation
   2.130 -and installation of the library.
   2.131 -
   2.132 -  Activities other than copying, distribution and modification are not
   2.133 -covered by this License; they are outside its scope.  The act of
   2.134 -running a program using the Library is not restricted, and output from
   2.135 -such a program is covered only if its contents constitute a work based
   2.136 -on the Library (independent of the use of the Library in a tool for
   2.137 -writing it).  Whether that is true depends on what the Library does
   2.138 -and what the program that uses the Library does.
   2.139 -  
   2.140 -  1. You may copy and distribute verbatim copies of the Library's
   2.141 -complete source code as you receive it, in any medium, provided that
   2.142 -you conspicuously and appropriately publish on each copy an
   2.143 -appropriate copyright notice and disclaimer of warranty; keep intact
   2.144 -all the notices that refer to this License and to the absence of any
   2.145 -warranty; and distribute a copy of this License along with the
   2.146 -Library.
   2.147 -
   2.148 -  You may charge a fee for the physical act of transferring a copy,
   2.149 -and you may at your option offer warranty protection in exchange for a
   2.150 -fee.
   2.151 -
   2.152 -  2. You may modify your copy or copies of the Library or any portion
   2.153 -of it, thus forming a work based on the Library, and copy and
   2.154 -distribute such modifications or work under the terms of Section 1
   2.155 -above, provided that you also meet all of these conditions:
   2.156 -
   2.157 -    a) The modified work must itself be a software library.
   2.158 -
   2.159 -    b) You must cause the files modified to carry prominent notices
   2.160 -    stating that you changed the files and the date of any change.
   2.161 -
   2.162 -    c) You must cause the whole of the work to be licensed at no
   2.163 -    charge to all third parties under the terms of this License.
   2.164 -
   2.165 -    d) If a facility in the modified Library refers to a function or a
   2.166 -    table of data to be supplied by an application program that uses
   2.167 -    the facility, other than as an argument passed when the facility
   2.168 -    is invoked, then you must make a good faith effort to ensure that,
   2.169 -    in the event an application does not supply such function or
   2.170 -    table, the facility still operates, and performs whatever part of
   2.171 -    its purpose remains meaningful.
   2.172 -
   2.173 -    (For example, a function in a library to compute square roots has
   2.174 -    a purpose that is entirely well-defined independent of the
   2.175 -    application.  Therefore, Subsection 2d requires that any
   2.176 -    application-supplied function or table used by this function must
   2.177 -    be optional: if the application does not supply it, the square
   2.178 -    root function must still compute square roots.)
   2.179 -
   2.180 -These requirements apply to the modified work as a whole.  If
   2.181 -identifiable sections of that work are not derived from the Library,
   2.182 -and can be reasonably considered independent and separate works in
   2.183 -themselves, then this License, and its terms, do not apply to those
   2.184 -sections when you distribute them as separate works.  But when you
   2.185 -distribute the same sections as part of a whole which is a work based
   2.186 -on the Library, the distribution of the whole must be on the terms of
   2.187 -this License, whose permissions for other licensees extend to the
   2.188 -entire whole, and thus to each and every part regardless of who wrote
   2.189 -it.
   2.190 -
   2.191 -Thus, it is not the intent of this section to claim rights or contest
   2.192 -your rights to work written entirely by you; rather, the intent is to
   2.193 -exercise the right to control the distribution of derivative or
   2.194 -collective works based on the Library.
   2.195 -
   2.196 -In addition, mere aggregation of another work not based on the Library
   2.197 -with the Library (or with a work based on the Library) on a volume of
   2.198 -a storage or distribution medium does not bring the other work under
   2.199 -the scope of this License.
   2.200 -
   2.201 -  3. You may opt to apply the terms of the ordinary GNU General Public
   2.202 -License instead of this License to a given copy of the Library.  To do
   2.203 -this, you must alter all the notices that refer to this License, so
   2.204 -that they refer to the ordinary GNU General Public License, version 2,
   2.205 -instead of to this License.  (If a newer version than version 2 of the
   2.206 -ordinary GNU General Public License has appeared, then you can specify
   2.207 -that version instead if you wish.)  Do not make any other change in
   2.208 -these notices.
   2.209 -
   2.210 -  Once this change is made in a given copy, it is irreversible for
   2.211 -that copy, so the ordinary GNU General Public License applies to all
   2.212 -subsequent copies and derivative works made from that copy.
   2.213 -
   2.214 -  This option is useful when you wish to copy part of the code of
   2.215 -the Library into a program that is not a library.
   2.216 -
   2.217 -  4. You may copy and distribute the Library (or a portion or
   2.218 -derivative of it, under Section 2) in object code or executable form
   2.219 -under the terms of Sections 1 and 2 above provided that you accompany
   2.220 -it with the complete corresponding machine-readable source code, which
   2.221 -must be distributed under the terms of Sections 1 and 2 above on a
   2.222 -medium customarily used for software interchange.
   2.223 -
   2.224 -  If distribution of object code is made by offering access to copy
   2.225 -from a designated place, then offering equivalent access to copy the
   2.226 -source code from the same place satisfies the requirement to
   2.227 -distribute the source code, even though third parties are not
   2.228 -compelled to copy the source along with the object code.
   2.229 -
   2.230 -  5. A program that contains no derivative of any portion of the
   2.231 -Library, but is designed to work with the Library by being compiled or
   2.232 -linked with it, is called a "work that uses the Library".  Such a
   2.233 -work, in isolation, is not a derivative work of the Library, and
   2.234 -therefore falls outside the scope of this License.
   2.235 -
   2.236 -  However, linking a "work that uses the Library" with the Library
   2.237 -creates an executable that is a derivative of the Library (because it
   2.238 -contains portions of the Library), rather than a "work that uses the
   2.239 -library".  The executable is therefore covered by this License.
   2.240 -Section 6 states terms for distribution of such executables.
   2.241 -
   2.242 -  When a "work that uses the Library" uses material from a header file
   2.243 -that is part of the Library, the object code for the work may be a
   2.244 -derivative work of the Library even though the source code is not.
   2.245 -Whether this is true is especially significant if the work can be
   2.246 -linked without the Library, or if the work is itself a library.  The
   2.247 -threshold for this to be true is not precisely defined by law.
   2.248 -
   2.249 -  If such an object file uses only numerical parameters, data
   2.250 -structure layouts and accessors, and small macros and small inline
   2.251 -functions (ten lines or less in length), then the use of the object
   2.252 -file is unrestricted, regardless of whether it is legally a derivative
   2.253 -work.  (Executables containing this object code plus portions of the
   2.254 -Library will still fall under Section 6.)
   2.255 -
   2.256 -  Otherwise, if the work is a derivative of the Library, you may
   2.257 -distribute the object code for the work under the terms of Section 6.
   2.258 -Any executables containing that work also fall under Section 6,
   2.259 -whether or not they are linked directly with the Library itself.
   2.260 -
   2.261 -  6. As an exception to the Sections above, you may also compile or
   2.262 -link a "work that uses the Library" with the Library to produce a
   2.263 -work containing portions of the Library, and distribute that work
   2.264 -under terms of your choice, provided that the terms permit
   2.265 -modification of the work for the customer's own use and reverse
   2.266 -engineering for debugging such modifications.
   2.267 -
   2.268 -  You must give prominent notice with each copy of the work that the
   2.269 -Library is used in it and that the Library and its use are covered by
   2.270 -this License.  You must supply a copy of this License.  If the work
   2.271 -during execution displays copyright notices, you must include the
   2.272 -copyright notice for the Library among them, as well as a reference
   2.273 -directing the user to the copy of this License.  Also, you must do one
   2.274 -of these things:
   2.275 -
   2.276 -    a) Accompany the work with the complete corresponding
   2.277 -    machine-readable source code for the Library including whatever
   2.278 -    changes were used in the work (which must be distributed under
   2.279 -    Sections 1 and 2 above); and, if the work is an executable linked
   2.280 -    with the Library, with the complete machine-readable "work that
   2.281 -    uses the Library", as object code and/or source code, so that the
   2.282 -    user can modify the Library and then relink to produce a modified
   2.283 -    executable containing the modified Library.  (It is understood
   2.284 -    that the user who changes the contents of definitions files in the
   2.285 -    Library will not necessarily be able to recompile the application
   2.286 -    to use the modified definitions.)
   2.287 -
   2.288 -    b) Accompany the work with a written offer, valid for at
   2.289 -    least three years, to give the same user the materials
   2.290 -    specified in Subsection 6a, above, for a charge no more
   2.291 -    than the cost of performing this distribution.
   2.292 -
   2.293 -    c) If distribution of the work is made by offering access to copy
   2.294 -    from a designated place, offer equivalent access to copy the above
   2.295 -    specified materials from the same place.
   2.296 -
   2.297 -    d) Verify that the user has already received a copy of these
   2.298 -    materials or that you have already sent this user a copy.
   2.299 -
   2.300 -  For an executable, the required form of the "work that uses the
   2.301 -Library" must include any data and utility programs needed for
   2.302 -reproducing the executable from it.  However, as a special exception,
   2.303 -the source code distributed need not include anything that is normally
   2.304 -distributed (in either source or binary form) with the major
   2.305 -components (compiler, kernel, and so on) of the operating system on
   2.306 -which the executable runs, unless that component itself accompanies
   2.307 -the executable.
   2.308 -
   2.309 -  It may happen that this requirement contradicts the license
   2.310 -restrictions of other proprietary libraries that do not normally
   2.311 -accompany the operating system.  Such a contradiction means you cannot
   2.312 -use both them and the Library together in an executable that you
   2.313 -distribute.
   2.314 -
   2.315 -  7. You may place library facilities that are a work based on the
   2.316 -Library side-by-side in a single library together with other library
   2.317 -facilities not covered by this License, and distribute such a combined
   2.318 -library, provided that the separate distribution of the work based on
   2.319 -the Library and of the other library facilities is otherwise
   2.320 -permitted, and provided that you do these two things:
   2.321 -
   2.322 -    a) Accompany the combined library with a copy of the same work
   2.323 -    based on the Library, uncombined with any other library
   2.324 -    facilities.  This must be distributed under the terms of the
   2.325 -    Sections above.
   2.326 -
   2.327 -    b) Give prominent notice with the combined library of the fact
   2.328 -    that part of it is a work based on the Library, and explaining
   2.329 -    where to find the accompanying uncombined form of the same work.
   2.330 -
   2.331 -  8. You may not copy, modify, sublicense, link with, or distribute
   2.332 -the Library except as expressly provided under this License.  Any
   2.333 -attempt otherwise to copy, modify, sublicense, link with, or
   2.334 -distribute the Library is void, and will automatically terminate your
   2.335 -rights under this License.  However, parties who have received copies,
   2.336 -or rights, from you under this License will not have their licenses
   2.337 -terminated so long as such parties remain in full compliance.
   2.338 -
   2.339 -  9. You are not required to accept this License, since you have not
   2.340 -signed it.  However, nothing else grants you permission to modify or
   2.341 -distribute the Library or its derivative works.  These actions are
   2.342 -prohibited by law if you do not accept this License.  Therefore, by
   2.343 -modifying or distributing the Library (or any work based on the
   2.344 -Library), you indicate your acceptance of this License to do so, and
   2.345 -all its terms and conditions for copying, distributing or modifying
   2.346 -the Library or works based on it.
   2.347 -
   2.348 -  10. Each time you redistribute the Library (or any work based on the
   2.349 -Library), the recipient automatically receives a license from the
   2.350 -original licensor to copy, distribute, link with or modify the Library
   2.351 -subject to these terms and conditions.  You may not impose any further
   2.352 -restrictions on the recipients' exercise of the rights granted herein.
   2.353 -You are not responsible for enforcing compliance by third parties to
   2.354 -this License.
   2.355 -
   2.356 -  11. If, as a consequence of a court judgment or allegation of patent
   2.357 -infringement or for any other reason (not limited to patent issues),
   2.358 -conditions are imposed on you (whether by court order, agreement or
   2.359 -otherwise) that contradict the conditions of this License, they do not
   2.360 -excuse you from the conditions of this License.  If you cannot
   2.361 -distribute so as to satisfy simultaneously your obligations under this
   2.362 -License and any other pertinent obligations, then as a consequence you
   2.363 -may not distribute the Library at all.  For example, if a patent
   2.364 -license would not permit royalty-free redistribution of the Library by
   2.365 -all those who receive copies directly or indirectly through you, then
   2.366 -the only way you could satisfy both it and this License would be to
   2.367 -refrain entirely from distribution of the Library.
   2.368 -
   2.369 -If any portion of this section is held invalid or unenforceable under any
   2.370 -particular circumstance, the balance of the section is intended to apply,
   2.371 -and the section as a whole is intended to apply in other circumstances.
   2.372 -
   2.373 -It is not the purpose of this section to induce you to infringe any
   2.374 -patents or other property right claims or to contest validity of any
   2.375 -such claims; this section has the sole purpose of protecting the
   2.376 -integrity of the free software distribution system which is
   2.377 -implemented by public license practices.  Many people have made
   2.378 -generous contributions to the wide range of software distributed
   2.379 -through that system in reliance on consistent application of that
   2.380 -system; it is up to the author/donor to decide if he or she is willing
   2.381 -to distribute software through any other system and a licensee cannot
   2.382 -impose that choice.
   2.383 -
   2.384 -This section is intended to make thoroughly clear what is believed to
   2.385 -be a consequence of the rest of this License.
   2.386 -
   2.387 -  12. If the distribution and/or use of the Library is restricted in
   2.388 -certain countries either by patents or by copyrighted interfaces, the
   2.389 -original copyright holder who places the Library under this License may add
   2.390 -an explicit geographical distribution limitation excluding those countries,
   2.391 -so that distribution is permitted only in or among countries not thus
   2.392 -excluded.  In such case, this License incorporates the limitation as if
   2.393 -written in the body of this License.
   2.394 -
   2.395 -  13. The Free Software Foundation may publish revised and/or new
   2.396 -versions of the Library General Public License from time to time.
   2.397 -Such new versions will be similar in spirit to the present version,
   2.398 -but may differ in detail to address new problems or concerns.
   2.399 -
   2.400 -Each version is given a distinguishing version number.  If the Library
   2.401 -specifies a version number of this License which applies to it and
   2.402 -"any later version", you have the option of following the terms and
   2.403 -conditions either of that version or of any later version published by
   2.404 -the Free Software Foundation.  If the Library does not specify a
   2.405 -license version number, you may choose any version ever published by
   2.406 -the Free Software Foundation.
   2.407 -
   2.408 -  14. If you wish to incorporate parts of the Library into other free
   2.409 -programs whose distribution conditions are incompatible with these,
   2.410 -write to the author to ask for permission.  For software which is
   2.411 -copyrighted by the Free Software Foundation, write to the Free
   2.412 -Software Foundation; we sometimes make exceptions for this.  Our
   2.413 -decision will be guided by the two goals of preserving the free status
   2.414 -of all derivatives of our free software and of promoting the sharing
   2.415 -and reuse of software generally.
   2.416 -
   2.417 -			    NO WARRANTY
   2.418 -
   2.419 -  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
   2.420 -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
   2.421 -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
   2.422 -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
   2.423 -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
   2.424 -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   2.425 -PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
   2.426 -LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
   2.427 -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
   2.428 -
   2.429 -  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
   2.430 -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
   2.431 -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
   2.432 -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
   2.433 -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
   2.434 -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
   2.435 -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
   2.436 -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
   2.437 -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
   2.438 -DAMAGES.
   2.439 -
   2.440 -		     END OF TERMS AND CONDITIONS
   2.441 -
     3.1 --- a/src/cpuinfo/Makefile.am	Mon Nov 24 00:21:24 2003 +0000
     3.2 +++ b/src/cpuinfo/Makefile.am	Mon Nov 24 09:16:52 2003 +0000
     3.3 @@ -1,35 +1,8 @@
     3.4 -###########################################################################
     3.5 -#
     3.6 -# Some consistent rules for building asm files:
     3.7 -
     3.8 -STRIP_FPIC = sh $(top_srcdir)/strip_fPIC.sh
     3.9 -
    3.10 -SUFFIXES = .asm
    3.11 -
    3.12 -.asm.lo:
    3.13 -	$(LIBTOOL) --tag=CC --mode=compile $(STRIP_FPIC) $(NASM) -t -D __FLAT__ @NASMFLAGS@ $< -o $*.o
    3.14 -
    3.15 -###########################################################################
    3.16  
    3.17  # The cpuinfo library target
    3.18  noinst_LTLIBRARIES = libcpuinfo.la
    3.19  
    3.20 -if HAVE_NASM
    3.21 -ARCH_SRCS =			\
    3.22 -	_cpuinfo.asm		\
    3.23 -	_pcihelp.asm
    3.24 -else
    3.25 -ARCH_SRCS =
    3.26 -endif
    3.27 -
    3.28  COMMON_SRCS = 			\
    3.29 -	cpuinfo.h		\
    3.30 -	gcpuinfo.c		\
    3.31  	SDL_cpuinfo.c
    3.32  
    3.33 -libcpuinfo_la_SOURCES = $(ARCH_SRCS) $(COMMON_SRCS)
    3.34 -
    3.35 -EXTRA_DIST =			\
    3.36 -	COPYING.LIB		\
    3.37 -	README
    3.38 -
    3.39 +libcpuinfo_la_SOURCES = $(COMMON_SRCS)
     4.1 --- a/src/cpuinfo/README	Mon Nov 24 00:21:24 2003 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,5 +0,0 @@
     4.4 -This is a stripped down version of the portable CPU detection code included
     4.5 -in the SciTech SNAP Graphics SDK.  It is redistributed under the LGPL license,
     4.6 -which can be found in COPYING.LIB.
     4.7 -
     4.8 -You can visit SciTech Software Inc. at: http://www.scitechsoft.com/
     5.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Mon Nov 24 00:21:24 2003 +0000
     5.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Mon Nov 24 09:16:52 2003 +0000
     5.3 @@ -28,16 +28,160 @@
     5.4  /* CPU feature detection for SDL */
     5.5  
     5.6  #include "SDL.h"
     5.7 -//#include "SDL_cpuinfo.h"
     5.8 +#include "SDL_cpuinfo.h"
     5.9  
    5.10 -#define CPU_HAS_MMX	0x00000001
    5.11 -#define CPU_HAS_3DNOW	0x00000002
    5.12 -#define CPU_HAS_SSE	0x00000004
    5.13 +#define CPU_HAS_RDTSC	0x00000001
    5.14 +#define CPU_HAS_MMX	0x00000002
    5.15 +#define CPU_HAS_3DNOW	0x00000004
    5.16 +#define CPU_HAS_SSE	0x00000008
    5.17  
    5.18 -/* These functions come from SciTech's PM library */
    5.19 -extern int CPU_haveMMX();
    5.20 -extern int CPU_have3DNow();
    5.21 -extern int CPU_haveSSE();
    5.22 +static __inline__ int CPU_haveCPUID()
    5.23 +{
    5.24 +	int has_CPUID = 0;
    5.25 +#if defined(__GNUC__) && defined(i386)
    5.26 +	__asm__ (
    5.27 +"push %%ecx\n"
    5.28 +"        pushfl                      # Get original EFLAGS             \n"
    5.29 +"        popl    %%eax                                                 \n"
    5.30 +"        movl    %%eax,%%ecx                                           \n"
    5.31 +"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
    5.32 +"        pushl   %%eax               # Save new EFLAGS value on stack  \n"
    5.33 +"        popfl                       # Replace current EFLAGS value    \n"
    5.34 +"        pushfl                      # Get new EFLAGS                  \n"
    5.35 +"        popl    %%eax               # Store new EFLAGS in EAX         \n"
    5.36 +"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
    5.37 +"        jz      1f                  # Processor=80486                 \n"
    5.38 +"        movl    $1,%0               # We have CPUID support           \n"
    5.39 +"1:                                                                    \n"
    5.40 +"pop %%ecx\n"
    5.41 +	: "=r" (has_CPUID)
    5.42 +	:
    5.43 +	: "%eax", "%ecx"
    5.44 +	);
    5.45 +#elif defined(_MSC_VER)
    5.46 +	__asm__ {
    5.47 +        pushfd                      ; Get original EFLAGS
    5.48 +        pop     eax
    5.49 +        mov     ecx, eax
    5.50 +        xor     eax, 200000h        ; Flip ID bit in EFLAGS
    5.51 +        push    eax                 ; Save new EFLAGS value on stack
    5.52 +        popfd                       ; Replace current EFLAGS value
    5.53 +        pushfd                      ; Get new EFLAGS
    5.54 +        pop     eax                 ; Store new EFLAGS in EAX
    5.55 +        xor     eax, ecx            ; Can not toggle ID bit,
    5.56 +        jz      done                ; Processor=80486
    5.57 +        mov     has_CPUID,1         ; We have CPUID support
    5.58 +done:
    5.59 +	}
    5.60 +#endif
    5.61 +	return has_CPUID;
    5.62 +}
    5.63 +
    5.64 +static __inline__ int CPU_getCPUIDFeatures()
    5.65 +{
    5.66 +	int features = 0;
    5.67 +#if defined(__GNUC__) && defined(i386)
    5.68 +	__asm__ (
    5.69 +"push %%ebx\n"
    5.70 +"push %%ecx\n"
    5.71 +"push %%edx\n"
    5.72 +"        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
    5.73 +"        cpuid                       # Get and save vendor ID          \n"
    5.74 +"        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n"
    5.75 +"        jl      1f                  # We dont have the CPUID instruction\n"
    5.76 +"        xorl    %%eax,%%eax                                           \n"
    5.77 +"        incl    %%eax                                                 \n"
    5.78 +"        cpuid                       # Get family/model/stepping/features\n"
    5.79 +"        movl    %%edx,%0                                              \n"
    5.80 +"1:                                                                    \n"
    5.81 +"pop %%edx\n"
    5.82 +"pop %%ecx\n"
    5.83 +"pop %%ebx\n"
    5.84 +	: "=r" (features)
    5.85 +	:
    5.86 +	: "%eax", "%ebx", "%ecx", "%edx"
    5.87 +	);
    5.88 +#elif defined(_MSC_VER)
    5.89 +	__asm__ {
    5.90 +        xor     eax, eax            ; Set up for CPUID instruction
    5.91 +        cpuid                       ; Get and save vendor ID
    5.92 +        cmp     eax, 1              ; Make sure 1 is valid input for CPUID
    5.93 +        jl      done                ; We dont have the CPUID instruction
    5.94 +        xor     eax, eax
    5.95 +        inc     eax
    5.96 +        cpuid                       ; Get family/model/stepping/features
    5.97 +        mov     features, edx
    5.98 +done:
    5.99 +	}
   5.100 +#endif
   5.101 +	return features;
   5.102 +}
   5.103 +
   5.104 +static __inline__ int CPU_haveRDTSC()
   5.105 +{
   5.106 +	if ( CPU_haveCPUID() ) {
   5.107 +		return (CPU_getCPUIDFeatures() & 0x00000010);
   5.108 +	}
   5.109 +	return 0;
   5.110 +}
   5.111 +
   5.112 +static __inline__ int CPU_haveMMX()
   5.113 +{
   5.114 +	if ( CPU_haveCPUID() ) {
   5.115 +		return (CPU_getCPUIDFeatures() & 0x00800000);
   5.116 +	}
   5.117 +	return 0;
   5.118 +}
   5.119 +
   5.120 +static __inline__ int CPU_have3DNow()
   5.121 +{
   5.122 +	int has_3DNow = 0;
   5.123 +#if defined(__GNUC__) && defined(i386)
   5.124 +	__asm__ (
   5.125 +"push %%ebx\n"
   5.126 +"push %%ecx\n"
   5.127 +"push %%edx\n"
   5.128 +"        movl    $0x80000000,%%eax   # Query for extended functions    \n"
   5.129 +"        cpuid                       # Get extended function limit     \n"
   5.130 +"        cmpl    $0x80000001,%%eax                                     \n"
   5.131 +"        jbe     1f                  # Nope, we dont have function 800000001h\n"
   5.132 +"        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n"
   5.133 +"        cpuid                       # and get the information         \n"
   5.134 +"        testl   $0x80000000,%%edx   # Bit 31 is set if 3DNow! present \n"
   5.135 +"        jz      1f                  # Nope, we dont have 3DNow support\n"
   5.136 +"        movl    $1,%0               # Yep, we have 3DNow! support!    \n"
   5.137 +"1:                                                                    \n"
   5.138 +"pop %%edx\n"
   5.139 +"pop %%ecx\n"
   5.140 +"pop %%ebx\n"
   5.141 +	: "=r" (has_3DNow)
   5.142 +	:
   5.143 +	: "%eax", "%ebx", "%ecx", "%edx"
   5.144 +	);
   5.145 +#elif defined(_MSC_VER)
   5.146 +	__asm__ {
   5.147 +        mov     eax,80000000h       ; Query for extended functions
   5.148 +        cpuid                       ; Get extended function limit
   5.149 +        cmp     eax,80000001h
   5.150 +        jbe     done                ; Nope, we dont have function 800000001h
   5.151 +        mov     eax,80000001h       ; Setup extended function 800000001h
   5.152 +        cpuid                       ; and get the information
   5.153 +        test    edx,80000000h       ; Bit 31 is set if 3DNow! present
   5.154 +        jz      done                ; Nope, we dont have 3DNow support
   5.155 +        mov     has_3DNow,1         ; Yep, we have 3DNow! support!
   5.156 +done:
   5.157 +	}
   5.158 +#endif
   5.159 +	return has_3DNow;
   5.160 +}
   5.161 +
   5.162 +static __inline__ int CPU_haveSSE()
   5.163 +{
   5.164 +	if ( CPU_haveCPUID() ) {
   5.165 +		return (CPU_getCPUIDFeatures() & 0x02000000);
   5.166 +	}
   5.167 +	return 0;
   5.168 +}
   5.169  
   5.170  static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
   5.171  
   5.172 @@ -45,6 +189,9 @@
   5.173  {
   5.174  	if ( SDL_CPUFeatures == 0xFFFFFFFF ) {
   5.175  		SDL_CPUFeatures = 0;
   5.176 +		if ( CPU_haveRDTSC() ) {
   5.177 +			SDL_CPUFeatures |= CPU_HAS_RDTSC;
   5.178 +		}
   5.179  		if ( CPU_haveMMX() ) {
   5.180  			SDL_CPUFeatures |= CPU_HAS_MMX;
   5.181  		}
   5.182 @@ -58,6 +205,14 @@
   5.183  	return SDL_CPUFeatures;
   5.184  }
   5.185  
   5.186 +SDL_bool SDL_HasRDTSC()
   5.187 +{
   5.188 +	if ( SDL_GetCPUFeatures() & CPU_HAS_RDTSC ) {
   5.189 +		return SDL_TRUE;
   5.190 +	}
   5.191 +	return SDL_FALSE;
   5.192 +}
   5.193 +
   5.194  SDL_bool SDL_HasMMX()
   5.195  {
   5.196  	if ( SDL_GetCPUFeatures() & CPU_HAS_MMX ) {
   5.197 @@ -91,6 +246,7 @@
   5.198  	printf("MMX: %d\n", SDL_HasMMX());
   5.199  	printf("3DNow: %d\n", SDL_Has3DNow());
   5.200  	printf("SSE: %d\n", SDL_HasSSE());
   5.201 +	return 0;
   5.202  }
   5.203  
   5.204  #endif /* TEST_MAIN */
     6.1 --- a/src/cpuinfo/_cpuinfo.asm	Mon Nov 24 00:21:24 2003 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,611 +0,0 @@
     6.4 -;****************************************************************************
     6.5 -;*
     6.6 -;*                  SciTech OS Portability Manager Library
     6.7 -;*
     6.8 -;*  ========================================================================
     6.9 -;*
    6.10 -;*   Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
    6.11 -;*
    6.12 -;*   This file may be distributed and/or modified under the terms of the
    6.13 -;*   GNU Lesser General Public License version 2.1 as published by the Free
    6.14 -;*   Software Foundation and appearing in the file LICENSE.LGPL included
    6.15 -;*   in the packaging of this file.
    6.16 -;*
    6.17 -;*   Licensees holding a valid Commercial License for this product from
    6.18 -;*   SciTech Software, Inc. may use this file in accordance with the
    6.19 -;*   Commercial License Agreement provided with the Software.
    6.20 -;*
    6.21 -;*   This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
    6.22 -;*   THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    6.23 -;*   PURPOSE.
    6.24 -;*
    6.25 -;*   See http://www.scitechsoft.com/license/ for information about
    6.26 -;*   the licensing options available and how to purchase a Commercial
    6.27 -;*   License Agreement.
    6.28 -;*
    6.29 -;*   Contact license@scitechsoft.com if any conditions of this licensing
    6.30 -;*   are not clear to you, or you have questions about licensing options.
    6.31 -;*
    6.32 -;*  ========================================================================
    6.33 -;*
    6.34 -;* Language:    NASM
    6.35 -;* Environment: Intel 32 bit Protected Mode.
    6.36 -;*
    6.37 -;* Description: Code to determine the Intel processor type.
    6.38 -;*
    6.39 -;****************************************************************************
    6.40 -
    6.41 -include "scitech.mac"
    6.42 -
    6.43 -header      _cpuinfo
    6.44 -
    6.45 -begdataseg  _cpuinfo                ; Start of data segment
    6.46 -
    6.47 -cache_id    db  "01234567890123456"
    6.48 -intel_id    db  "GenuineIntel"      ; Intel vendor ID
    6.49 -cyrix_id    db  "CyrixInstead"      ; Cyrix vendor ID
    6.50 -amd_id      db  "AuthenticAMD"      ; AMD vendor ID
    6.51 -idt_id      db  "CentaurHauls"      ; IDT vendor ID
    6.52 -
    6.53 -CPU_IDT     EQU 01000h              ; Flag for IDT processors
    6.54 -CPU_Cyrix   EQU 02000h              ; Flag for Cyrix processors
    6.55 -CPU_AMD     EQU 04000h              ; Flag for AMD processors
    6.56 -CPU_Intel   EQU 08000h              ; Flag for Intel processors
    6.57 -
    6.58 -enddataseg  _cpuinfo
    6.59 -
    6.60 -begcodeseg  _cpuinfo                ; Start of code segment
    6.61 -
    6.62 -%macro mCPU_ID 0
    6.63 -db  00Fh,0A2h
    6.64 -%endmacro
    6.65 -
    6.66 -%macro mRDTSC 0
    6.67 -db  00Fh,031h
    6.68 -%endmacro
    6.69 -
    6.70 -;----------------------------------------------------------------------------
    6.71 -; bool _CPU_check80386(void)
    6.72 -;----------------------------------------------------------------------------
    6.73 -; Determines if we have an i386 processor.
    6.74 -;----------------------------------------------------------------------------
    6.75 -cprocstart  _CPU_check80386
    6.76 -
    6.77 -        enter_c
    6.78 -
    6.79 -        xor     edx,edx             ; EDX = 0, not an 80386
    6.80 -        mov     bx, sp
    6.81 -        and     sp, ~3
    6.82 -        pushfd                      ; Push original EFLAGS
    6.83 -        pop     eax                 ; Get original EFLAGS
    6.84 -        mov     ecx, eax            ; Save original EFLAGS
    6.85 -        xor     eax, 40000h         ; Flip AC bit in EFLAGS
    6.86 -        push    eax                 ; Save new EFLAGS value on
    6.87 -                                    ;   stack
    6.88 -        popfd                       ; Replace current EFLAGS value
    6.89 -        pushfd                      ; Get new EFLAGS
    6.90 -        pop     eax                 ; Store new EFLAGS in EAX
    6.91 -        xor     eax, ecx            ; Can't toggle AC bit,
    6.92 -                                    ;   processor=80386
    6.93 -        jnz     @@Done              ; Jump if not an 80386 processor
    6.94 -        inc     edx                 ; We have an 80386
    6.95 -
    6.96 -@@Done: push    ecx
    6.97 -        popfd
    6.98 -        mov     sp, bx
    6.99 -        mov     eax, edx
   6.100 -        leave_c
   6.101 -        ret
   6.102 -
   6.103 -cprocend
   6.104 -
   6.105 -;----------------------------------------------------------------------------
   6.106 -; bool _CPU_check80486(void)
   6.107 -;----------------------------------------------------------------------------
   6.108 -; Determines if we have an i486 processor.
   6.109 -;----------------------------------------------------------------------------
   6.110 -cprocstart  _CPU_check80486
   6.111 -
   6.112 -        enter_c
   6.113 -
   6.114 -; Distinguish between the i486 and Pentium by the ability to set the ID flag
   6.115 -; in the EFLAGS register. If the ID flag is set, then we can use the CPUID
   6.116 -; instruction to determine the final version of the chip. Otherwise we
   6.117 -; simply have an 80486.
   6.118 -
   6.119 -; Distinguish between the i486 and Pentium by the ability to set the ID flag
   6.120 -; in the EFLAGS register. If the ID flag is set, then we can use the CPUID
   6.121 -; instruction to determine the final version of the chip. Otherwise we
   6.122 -; simply have an 80486.
   6.123 -
   6.124 -        pushfd                      ; Get original EFLAGS
   6.125 -        pop     eax
   6.126 -        mov     ecx, eax
   6.127 -        xor     eax, 200000h        ; Flip ID bit in EFLAGS
   6.128 -        push    eax                 ; Save new EFLAGS value on stack
   6.129 -        popfd                       ; Replace current EFLAGS value
   6.130 -        pushfd                      ; Get new EFLAGS
   6.131 -        pop     eax                 ; Store new EFLAGS in EAX
   6.132 -        xor     eax, ecx            ; Can not toggle ID bit,
   6.133 -        jnz     @@1                 ; Processor=80486
   6.134 -        mov     eax,1               ; We dont have a Pentium
   6.135 -        jmp     @@Done
   6.136 -@@1:    mov     eax,0               ; We have Pentium or later
   6.137 -@@Done: leave_c
   6.138 -        ret
   6.139 -
   6.140 -cprocend
   6.141 -
   6.142 -;----------------------------------------------------------------------------
   6.143 -; bool _CPU_checkClone(void)
   6.144 -;----------------------------------------------------------------------------
   6.145 -; Checks if the i386 or i486 processor is a clone or genuine Intel.
   6.146 -;----------------------------------------------------------------------------
   6.147 -cprocstart  _CPU_checkClone
   6.148 -
   6.149 -        enter_c
   6.150 -
   6.151 -        mov     ax,5555h            ; Check to make sure this is a 32-bit processor
   6.152 -        xor     dx,dx
   6.153 -        mov     cx,2h
   6.154 -        div     cx                  ; Perform Division
   6.155 -        clc
   6.156 -        jnz     @@NoClone
   6.157 -        jmp     @@Clone
   6.158 -@@NoClone:
   6.159 -        stc
   6.160 -@@Clone:
   6.161 -        pushfd
   6.162 -        pop     eax                 ; Get the flags
   6.163 -        and     eax,1
   6.164 -        xor     eax,1               ; EAX=0 is probably Intel, EAX=1 is a Clone
   6.165 -
   6.166 -        leave_c
   6.167 -        ret
   6.168 -
   6.169 -cprocend
   6.170 -
   6.171 -;----------------------------------------------------------------------------
   6.172 -; bool _CPU_haveCPUID(void)
   6.173 -;----------------------------------------------------------------------------
   6.174 -; Determines if we have support for the CPUID instruction.
   6.175 -;----------------------------------------------------------------------------
   6.176 -cprocstart  _CPU_haveCPUID
   6.177 -
   6.178 -        enter_c
   6.179 -
   6.180 -ifdef flatmodel
   6.181 -        pushfd                      ; Get original EFLAGS
   6.182 -        pop     eax
   6.183 -        mov     ecx, eax
   6.184 -        xor     eax, 200000h        ; Flip ID bit in EFLAGS
   6.185 -        push    eax                 ; Save new EFLAGS value on stack
   6.186 -        popfd                       ; Replace current EFLAGS value
   6.187 -        pushfd                      ; Get new EFLAGS
   6.188 -        pop     eax                 ; Store new EFLAGS in EAX
   6.189 -        xor     eax, ecx            ; Can not toggle ID bit,
   6.190 -        jnz     @@1                 ; Processor=80486
   6.191 -        mov     eax,0               ; We dont have CPUID support
   6.192 -        jmp     @@Done
   6.193 -@@1:    mov     eax,1               ; We have CPUID support
   6.194 -else
   6.195 -        mov     eax,0               ; CPUID requires 32-bit pmode
   6.196 -endif
   6.197 -@@Done: leave_c
   6.198 -        ret
   6.199 -
   6.200 -cprocend
   6.201 -
   6.202 -;----------------------------------------------------------------------------
   6.203 -; uint _CPU_checkCPUID(void)
   6.204 -;----------------------------------------------------------------------------
   6.205 -; Determines the CPU type using the CPUID instruction.
   6.206 -;----------------------------------------------------------------------------
   6.207 -cprocstart  _CPU_checkCPUID
   6.208 -
   6.209 -        enter_c
   6.210 -
   6.211 -        xor     eax, eax            ; Set up for CPUID instruction
   6.212 -        mCPU_ID                     ; Get and save vendor ID
   6.213 -        cmp     eax, 1              ; Make sure 1 is valid input for CPUID
   6.214 -        jl      @@Fail              ; We dont have the CPUID instruction
   6.215 -        xor     eax,eax             ; Assume vendor is unknown
   6.216 -
   6.217 -; Check for GenuineIntel processors
   6.218 -
   6.219 -        LEA_L   esi,intel_id
   6.220 -        cmp     [DWORD esi], ebx
   6.221 -        jne     @@NotIntel
   6.222 -        cmp     [DWORD esi+4], edx
   6.223 -        jne     @@NotIntel
   6.224 -        cmp     [DWORD esi+8], ecx
   6.225 -        jne     @@NotIntel
   6.226 -        mov     eax,CPU_Intel       ; Flag that we have GenuineIntel
   6.227 -        jmp     @@FoundVendor
   6.228 -
   6.229 -; Check for CyrixInstead processors
   6.230 -
   6.231 -@@NotIntel:
   6.232 -        LEA_L   esi,cyrix_id
   6.233 -        cmp     [DWORD esi], ebx
   6.234 -        jne     @@NotCyrix
   6.235 -        cmp     [DWORD esi+4], edx
   6.236 -        jne     @@NotCyrix
   6.237 -        cmp     [DWORD esi+8], ecx
   6.238 -        jne     @@NotCyrix
   6.239 -        mov     eax,CPU_Cyrix       ; Flag that we have CyrixInstead
   6.240 -        jmp     @@FoundVendor
   6.241 -
   6.242 -; Check for AuthenticAMD processors
   6.243 -
   6.244 -@@NotCyrix:
   6.245 -        LEA_L   esi,amd_id
   6.246 -        cmp     [DWORD esi], ebx
   6.247 -        jne     @@NotAMD
   6.248 -        cmp     [DWORD esi+4], edx
   6.249 -        jne     @@NotAMD
   6.250 -        cmp     [DWORD esi+8], ecx
   6.251 -        jne     @@NotAMD
   6.252 -        mov     eax,CPU_AMD         ; Flag that we have AuthenticAMD
   6.253 -        jmp     @@FoundVendor
   6.254 -
   6.255 -; Check for CentaurHauls processors
   6.256 -
   6.257 -@@NotAMD:
   6.258 -        LEA_L   esi,idt_id
   6.259 -        cmp     [DWORD esi], ebx
   6.260 -        jne     @@NotIDT
   6.261 -        cmp     [DWORD esi+4], edx
   6.262 -        jne     @@NotIDT
   6.263 -        cmp     [DWORD esi+8], ecx
   6.264 -        jne     @@NotIDT
   6.265 -        mov     eax,CPU_IDT         ; Flag that we have AuthenticIDT
   6.266 -        jmp     @@FoundVendor
   6.267 -
   6.268 -@@NotIDT:
   6.269 -
   6.270 -@@FoundVendor:
   6.271 -        push    eax
   6.272 -        xor     eax, eax
   6.273 -        inc     eax
   6.274 -        mCPU_ID                     ; Get family/model/stepping/features
   6.275 -        and     eax, 0F00h
   6.276 -        shr     eax, 8              ; Isolate CPU family
   6.277 -        and     eax, 0Fh
   6.278 -        cmp     eax, 0Fh            ; Check for Pentium 4 which is an 0Fh!
   6.279 -        jne     @@NotP4
   6.280 -        mov     eax, 07h            ; Change P4 ID to 7 for consistency
   6.281 -@@NotP4:
   6.282 -        pop     ecx
   6.283 -        or      eax,ecx             ; Combine in the CPU vendor flag
   6.284 -@@Done: leave_c
   6.285 -        ret
   6.286 -
   6.287 -@@Fail: xor     eax,eax
   6.288 -        jmp     @@Done
   6.289 -
   6.290 -cprocend
   6.291 -
   6.292 -;----------------------------------------------------------------------------
   6.293 -; uint _CPU_getCPUIDModel(void)
   6.294 -;----------------------------------------------------------------------------
   6.295 -; Determines the CPU type using the CPUID instruction.
   6.296 -;----------------------------------------------------------------------------
   6.297 -cprocstart  _CPU_getCPUIDModel
   6.298 -
   6.299 -        enter_c
   6.300 -
   6.301 -        xor     eax, eax            ; Set up for CPUID instruction
   6.302 -        mCPU_ID                     ; Get and save vendor ID
   6.303 -        cmp     eax, 1              ; Make sure 1 is valid input for CPUID
   6.304 -        jl      @@Fail              ; We dont have the CPUID instruction
   6.305 -        xor     eax, eax
   6.306 -        inc     eax
   6.307 -        mCPU_ID                     ; Get family/model/stepping/features
   6.308 -        and     eax, 0F0h
   6.309 -        shr     eax, 4              ; Isolate model
   6.310 -@@Done: leave_c
   6.311 -        ret
   6.312 -
   6.313 -@@Fail: xor     eax,eax
   6.314 -        jmp     @@Done
   6.315 -
   6.316 -cprocend
   6.317 -
   6.318 -;----------------------------------------------------------------------------
   6.319 -; uint _CPU_getCPUIDStepping(void)
   6.320 -;----------------------------------------------------------------------------
   6.321 -; Determines the CPU type using the CPUID instruction.
   6.322 -;----------------------------------------------------------------------------
   6.323 -cprocstart  _CPU_getCPUIDStepping
   6.324 -
   6.325 -        enter_c
   6.326 -
   6.327 -        xor     eax, eax            ; Set up for CPUID instruction
   6.328 -        mCPU_ID                     ; Get and save vendor ID
   6.329 -        cmp     eax, 1              ; Make sure 1 is valid input for CPUID
   6.330 -        jl      @@Fail              ; We dont have the CPUID instruction
   6.331 -        xor     eax, eax
   6.332 -        inc     eax
   6.333 -        mCPU_ID                     ; Get family/model/stepping/features
   6.334 -        and     eax, 00Fh           ; Isolate stepping
   6.335 -@@Done: leave_c
   6.336 -        ret
   6.337 -
   6.338 -@@Fail: xor     eax,eax
   6.339 -        jmp     @@Done
   6.340 -
   6.341 -cprocend
   6.342 -
   6.343 -;----------------------------------------------------------------------------
   6.344 -; uint _CPU_getCPUIDFeatures(void)
   6.345 -;----------------------------------------------------------------------------
   6.346 -; Determines the CPU type using the CPUID instruction.
   6.347 -;----------------------------------------------------------------------------
   6.348 -cprocstart  _CPU_getCPUIDFeatures
   6.349 -
   6.350 -        enter_c
   6.351 -
   6.352 -        xor     eax, eax            ; Set up for CPUID instruction
   6.353 -        mCPU_ID                     ; Get and save vendor ID
   6.354 -        cmp     eax, 1              ; Make sure 1 is valid input for CPUID
   6.355 -        jl      @@Fail              ; We dont have the CPUID instruction
   6.356 -        xor     eax, eax
   6.357 -        inc     eax
   6.358 -        mCPU_ID                     ; Get family/model/stepping/features
   6.359 -        mov     eax, edx
   6.360 -@@Done: leave_c
   6.361 -        ret
   6.362 -
   6.363 -@@Fail: xor     eax,eax
   6.364 -        jmp     @@Done
   6.365 -
   6.366 -cprocend
   6.367 -
   6.368 -;----------------------------------------------------------------------------
   6.369 -; uint _CPU_getCacheSize(void)
   6.370 -;----------------------------------------------------------------------------
   6.371 -; Determines the CPU cache size for Intel processors
   6.372 -;----------------------------------------------------------------------------
   6.373 -cprocstart  _CPU_getCacheSize
   6.374 -
   6.375 -        enter_c
   6.376 -        xor     eax, eax            ; Set up for CPUID instruction
   6.377 -        mCPU_ID                     ; Get and save vendor ID
   6.378 -        cmp     eax,2               ; Make sure 2 is valid input for CPUID
   6.379 -        jl      @@Fail              ; We dont have the CPUID instruction
   6.380 -        mov     eax,2
   6.381 -        mCPU_ID                     ; Get cache descriptors
   6.382 -        LEA_L   esi,cache_id        ; Get address of cache ID (-fPIC aware)
   6.383 -        shr     eax,8
   6.384 -        mov     [esi+0],eax
   6.385 -        mov     [esi+3],ebx
   6.386 -        mov     [esi+7],ecx
   6.387 -        mov     [esi+11],edx
   6.388 -        xor     eax,eax
   6.389 -        LEA_L   esi,cache_id        ; Get address of cache ID (-fPIC aware)
   6.390 -        mov     edi,15
   6.391 -@@ScanLoop:
   6.392 -        cmp     [BYTE esi],41h
   6.393 -        mov     eax,128
   6.394 -        je      @@Done
   6.395 -        cmp     [BYTE esi],42h
   6.396 -        mov     eax,256
   6.397 -        je      @@Done
   6.398 -        cmp     [BYTE esi],43h
   6.399 -        mov     eax,512
   6.400 -        je      @@Done
   6.401 -        cmp     [BYTE esi],44h
   6.402 -        mov     eax,1024
   6.403 -        je      @@Done
   6.404 -        cmp     [BYTE esi],45h
   6.405 -        mov     eax,2048
   6.406 -        je      @@Done
   6.407 -        inc     esi
   6.408 -        dec     edi
   6.409 -        jnz     @@ScanLoop
   6.410 -
   6.411 -@@Done: leave_c
   6.412 -        ret
   6.413 -
   6.414 -@@Fail: xor     eax,eax
   6.415 -        jmp     @@Done
   6.416 -
   6.417 -cprocend
   6.418 -
   6.419 -;----------------------------------------------------------------------------
   6.420 -; uint _CPU_have3DNow(void)
   6.421 -;----------------------------------------------------------------------------
   6.422 -; Determines the CPU type using the CPUID instruction.
   6.423 -;----------------------------------------------------------------------------
   6.424 -cprocstart  _CPU_have3DNow
   6.425 -
   6.426 -        enter_c
   6.427 -
   6.428 -        mov     eax,80000000h       ; Query for extended functions
   6.429 -        mCPU_ID                     ; Get extended function limit
   6.430 -        cmp     eax,80000001h
   6.431 -        jbe     @@Fail              ; Nope, we dont have function 800000001h
   6.432 -        mov     eax,80000001h       ; Setup extended function 800000001h
   6.433 -        mCPU_ID                     ; and get the information
   6.434 -        test    edx,80000000h       ; Bit 31 is set if 3DNow! present
   6.435 -        jz      @@Fail              ; Nope, we dont have 3DNow support
   6.436 -        mov     eax,1               ; Yep, we have 3DNow! support!
   6.437 -@@Done: leave_c
   6.438 -        ret
   6.439 -
   6.440 -@@Fail: xor     eax,eax
   6.441 -        jmp     @@Done
   6.442 -
   6.443 -cprocend
   6.444 -
   6.445 -;----------------------------------------------------------------------------
   6.446 -; ulong _CPU_quickRDTSC(void)
   6.447 -;----------------------------------------------------------------------------
   6.448 -; Reads the time stamp counter and returns the low order 32-bits
   6.449 -;----------------------------------------------------------------------------
   6.450 -cprocstart  _CPU_quickRDTSC
   6.451 -
   6.452 -        mRDTSC
   6.453 -        ret
   6.454 -
   6.455 -cprocend
   6.456 -
   6.457 -;----------------------------------------------------------------------------
   6.458 -; void _CPU_runBSFLoop(ulong interations)
   6.459 -;----------------------------------------------------------------------------
   6.460 -; Runs a loop of BSF instructions for the specified number of iterations
   6.461 -;----------------------------------------------------------------------------
   6.462 -cprocstart  _CPU_runBSFLoop
   6.463 -
   6.464 -        ARG     iterations:ULONG
   6.465 -
   6.466 -        push    _bp
   6.467 -        mov     _bp,_sp
   6.468 -        push    _bx
   6.469 -
   6.470 -        mov     edx,[iterations]
   6.471 -        mov     eax,80000000h
   6.472 -        mov     ebx,edx
   6.473 -
   6.474 -        ALIGN   4
   6.475 -
   6.476 -@@loop: bsf     ecx,eax
   6.477 -        dec     ebx
   6.478 -        jnz     @@loop
   6.479 -
   6.480 -        pop     _bx
   6.481 -        pop     _bp
   6.482 -        ret
   6.483 -
   6.484 -cprocend
   6.485 -
   6.486 -;----------------------------------------------------------------------------
   6.487 -; void  _CPU_readTimeStamp(CPU_largeInteger *time);
   6.488 -;----------------------------------------------------------------------------
   6.489 -; Reads the time stamp counter and returns the 64-bit result.
   6.490 -;----------------------------------------------------------------------------
   6.491 -cprocstart  _CPU_readTimeStamp
   6.492 -
   6.493 -        mRDTSC
   6.494 -        mov     ecx,[esp+4]     ; Access directly without stack frame
   6.495 -        mov     [ecx],eax
   6.496 -        mov     [ecx+4],edx
   6.497 -        ret
   6.498 -
   6.499 -cprocend
   6.500 -
   6.501 -;----------------------------------------------------------------------------
   6.502 -; ulong _CPU_diffTime64(CPU_largeInteger *t1,CPU_largeInteger *t2,CPU_largeInteger *t)
   6.503 -;----------------------------------------------------------------------------
   6.504 -; Computes the difference between two 64-bit numbers.
   6.505 -;----------------------------------------------------------------------------
   6.506 -cprocstart  _CPU_diffTime64
   6.507 -
   6.508 -        ARG     t1:DPTR, t2:DPTR, t:DPTR
   6.509 -
   6.510 -        enter_c
   6.511 -
   6.512 -        mov     ecx,[t2]
   6.513 -        mov     eax,[ecx]       ; EAX := t2.low
   6.514 -        mov     ecx,[t1]
   6.515 -        sub     eax,[ecx]
   6.516 -        mov     edx,eax         ; EDX := low difference
   6.517 -        mov     ecx,[t2]
   6.518 -        mov     eax,[ecx+4]     ; ECX := t2.high
   6.519 -        mov     ecx,[t1]
   6.520 -        sbb     eax,[ecx+4]     ; EAX := high difference
   6.521 -
   6.522 -        mov     ebx,[t]         ; Store the result
   6.523 -        mov     [ebx],edx       ; Store low part
   6.524 -        mov     [ebx+4],eax     ; Store high part
   6.525 -        mov     eax,edx         ; Return low part
   6.526 -ifndef flatmodel
   6.527 -        shld    edx,eax,16      ; Return in DX:AX
   6.528 -endif
   6.529 -        leave_c
   6.530 -        ret
   6.531 -
   6.532 -cprocend
   6.533 -
   6.534 -;----------------------------------------------------------------------------
   6.535 -; ulong _CPU_calcMicroSec(CPU_largeInteger *count,ulong freq);
   6.536 -;----------------------------------------------------------------------------
   6.537 -; Computes the value in microseconds for the elapsed time with maximum
   6.538 -; precision. The formula we use is:
   6.539 -;
   6.540 -;   us = (((diff * 0x100000) / freq) * 1000000) / 0x100000)
   6.541 -;
   6.542 -; The power of two multiple before the first divide allows us to scale the
   6.543 -; 64-bit difference using simple shifts, and then the divide brings the
   6.544 -; final result into the range to fit into a 32-bit integer.
   6.545 -;----------------------------------------------------------------------------
   6.546 -cprocstart  _CPU_calcMicroSec
   6.547 -
   6.548 -        ARG     count:DPTR, freq:ULONG
   6.549 -
   6.550 -        enter_c
   6.551 -
   6.552 -        mov     ecx,[count]
   6.553 -        mov     eax,[ecx]       ; EAX := low part
   6.554 -        mov     edx,[ecx+4]     ; EDX := high part
   6.555 -        shld    edx,eax,20
   6.556 -        shl     eax,20          ; diff * 0x100000
   6.557 -        div     [DWORD freq]    ; (diff * 0x100000) / freq
   6.558 -        mov     ecx,1000000
   6.559 -        xor     edx,edx
   6.560 -        mul     ecx             ; ((diff * 0x100000) / freq) * 1000000)
   6.561 -        shrd    eax,edx,20      ; ((diff * 0x100000) / freq) * 1000000) / 0x100000
   6.562 -ifndef flatmodel
   6.563 -        shld    edx,eax,16      ; Return in DX:AX
   6.564 -endif
   6.565 -        leave_c
   6.566 -        ret
   6.567 -
   6.568 -cprocend
   6.569 -
   6.570 -;----------------------------------------------------------------------------
   6.571 -; ulong _CPU_mulDiv(ulong a,ulong b,ulong c);
   6.572 -;----------------------------------------------------------------------------
   6.573 -; Computes the following with 64-bit integer precision:
   6.574 -;
   6.575 -;   result = (a * b) / c
   6.576 -;
   6.577 -;----------------------------------------------------------------------------
   6.578 -cprocstart  _CPU_mulDiv
   6.579 -
   6.580 -        ARG     a:ULONG, b:ULONG, c:ULONG
   6.581 -
   6.582 -        enter_c
   6.583 -        mov     eax,[a]
   6.584 -        imul    [ULONG b]
   6.585 -        idiv    [ULONG c]
   6.586 -ifndef flatmodel
   6.587 -        shld    edx,eax,16      ; Return in DX:AX
   6.588 -endif
   6.589 -        leave_c
   6.590 -        ret
   6.591 -
   6.592 -cprocend
   6.593 -
   6.594 -;----------------------------------------------------------------------------
   6.595 -; int PM_getIOPL(void)
   6.596 -;----------------------------------------------------------------------------
   6.597 -; Returns current IOPL, callable from any ring, any OS, any day of the week
   6.598 -; (as long as it's 386 compatible). Sort of CPU information too.
   6.599 -;----------------------------------------------------------------------------
   6.600 -cprocstart  PM_getIOPL
   6.601 -
   6.602 -        pushfd
   6.603 -        pop     eax
   6.604 -        and     eax,0011000000000000b
   6.605 -        shr     eax,12
   6.606 -        ret
   6.607 -
   6.608 -cprocend
   6.609 -
   6.610 -
   6.611 -endcodeseg  _cpuinfo
   6.612 -
   6.613 -        END
   6.614 -
     7.1 --- a/src/cpuinfo/_pcihelp.asm	Mon Nov 24 00:21:24 2003 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,339 +0,0 @@
     7.4 -;****************************************************************************
     7.5 -;*
     7.6 -;*                  SciTech OS Portability Manager Library
     7.7 -;*
     7.8 -;*  ========================================================================
     7.9 -;*
    7.10 -;*   Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
    7.11 -;*
    7.12 -;*   This file may be distributed and/or modified under the terms of the
    7.13 -;*   GNU Lesser General Public License version 2.1 as published by the Free
    7.14 -;*   Software Foundation and appearing in the file LICENSE.LGPL included
    7.15 -;*   in the packaging of this file.
    7.16 -;*
    7.17 -;*   Licensees holding a valid Commercial License for this product from
    7.18 -;*   SciTech Software, Inc. may use this file in accordance with the
    7.19 -;*   Commercial License Agreement provided with the Software.
    7.20 -;*
    7.21 -;*   This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
    7.22 -;*   THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    7.23 -;*   PURPOSE.
    7.24 -;*
    7.25 -;*   See http://www.scitechsoft.com/license/ for information about
    7.26 -;*   the licensing options available and how to purchase a Commercial
    7.27 -;*   License Agreement.
    7.28 -;*
    7.29 -;*   Contact license@scitechsoft.com if any conditions of this licensing
    7.30 -;*   are not clear to you, or you have questions about licensing options.
    7.31 -;*
    7.32 -;*  ========================================================================
    7.33 -;*
    7.34 -;* Language:    NASM
    7.35 -;* Environment: Any
    7.36 -;*
    7.37 -;* Description: Helper assembler functions for PCI access module.
    7.38 -;*
    7.39 -;****************************************************************************
    7.40 -
    7.41 -include "scitech.mac"           ; Memory model macros
    7.42 -
    7.43 -header  _pcilib
    7.44 -
    7.45 -begcodeseg  _pcilib
    7.46 -
    7.47 -ifdef flatmodel
    7.48 -
    7.49 -;----------------------------------------------------------------------------
    7.50 -; uchar _ASMAPI _BIOS32_service(
    7.51 -;   ulong service,
    7.52 -;   ulong func,
    7.53 -;   ulong *physBase,
    7.54 -;   ulong *length,
    7.55 -;   ulong *serviceOffset,
    7.56 -;   PCIBIOS_entry entry);
    7.57 -;----------------------------------------------------------------------------
    7.58 -; Call the BIOS32 services directory
    7.59 -;----------------------------------------------------------------------------
    7.60 -cprocstart   _BIOS32_service
    7.61 -
    7.62 -        ARG     service:ULONG, func:ULONG, physBase:DPTR, len:DPTR, off:DPTR, entry:QWORD
    7.63 -
    7.64 -        enter_c
    7.65 -        mov     eax,[service]
    7.66 -        mov     ebx,[func]
    7.67 -        call    far dword [entry]
    7.68 -        mov     esi,[physBase]
    7.69 -        mov     [esi],ebx
    7.70 -        mov     esi,[len]
    7.71 -        mov     [esi],ecx
    7.72 -        mov     esi,[off]
    7.73 -        mov     [esi],edx
    7.74 -        leave_c
    7.75 -        ret
    7.76 -
    7.77 -cprocend
    7.78 -
    7.79 -endif
    7.80 -
    7.81 -;----------------------------------------------------------------------------
    7.82 -; ushort _ASMAPI _PCIBIOS_isPresent(ulong i_eax,ulong *o_edx,ushort *oeax,
    7.83 -;   uchar *o_cl,PCIBIOS_entry entry)
    7.84 -;----------------------------------------------------------------------------
    7.85 -; Call the PCI BIOS to determine if it is present.
    7.86 -;----------------------------------------------------------------------------
    7.87 -cprocstart   _PCIBIOS_isPresent
    7.88 -
    7.89 -        ARG     i_eax:ULONG, o_edx:DPTR, oeax:DPTR, o_cl:DPTR, entry:QWORD
    7.90 -
    7.91 -        enter_c
    7.92 -        mov     eax,[i_eax]
    7.93 -ifdef   flatmodel
    7.94 -        call    far dword [entry]
    7.95 -else
    7.96 -        int     1Ah
    7.97 -endif
    7.98 -        _les    _si,[o_edx]
    7.99 -        mov     [_ES _si],edx
   7.100 -        _les    _si,[oeax]
   7.101 -        mov     [_ES _si],ax
   7.102 -        _les    _si,[o_cl]
   7.103 -        mov     [_ES _si],cl
   7.104 -        mov     ax,bx
   7.105 -        leave_c
   7.106 -        ret
   7.107 -
   7.108 -cprocend
   7.109 -
   7.110 -;----------------------------------------------------------------------------
   7.111 -; ulong _PCIBIOS_service(ulong r_eax,ulong r_ebx,ulong r_edi,ulong r_ecx,
   7.112 -;   PCIBIOS_entry entry)
   7.113 -;----------------------------------------------------------------------------
   7.114 -; Call the PCI BIOS services, either via the 32-bit protected mode entry
   7.115 -; point or via the Int 1Ah 16-bit interrupt.
   7.116 -;----------------------------------------------------------------------------
   7.117 -cprocstart   _PCIBIOS_service
   7.118 -
   7.119 -        ARG     r_eax:ULONG, r_ebx:ULONG, r_edi:ULONG, r_ecx:ULONG, entry:QWORD
   7.120 -
   7.121 -        enter_c
   7.122 -        mov     eax,[r_eax]
   7.123 -        mov     ebx,[r_ebx]
   7.124 -        mov     edi,[r_edi]
   7.125 -        mov     ecx,[r_ecx]
   7.126 -ifdef   flatmodel
   7.127 -        call    far dword [entry]
   7.128 -else
   7.129 -        int     1Ah
   7.130 -endif
   7.131 -        mov     eax,ecx
   7.132 -ifndef  flatmodel
   7.133 -        shld    edx,eax,16      ; Return result in DX:AX
   7.134 -endif
   7.135 -        leave_c
   7.136 -        ret
   7.137 -
   7.138 -cprocend
   7.139 -
   7.140 -;----------------------------------------------------------------------------
   7.141 -; int _PCIBIOS_getRouting(PCIRoutingOptionsBuffer *buf,PCIBIOS_entry entry);
   7.142 -;----------------------------------------------------------------------------
   7.143 -; Get the routing options for PCI devices
   7.144 -;----------------------------------------------------------------------------
   7.145 -cprocstart   _PCIBIOS_getRouting
   7.146 -
   7.147 -        ARG     buf:DPTR, entry:QWORD
   7.148 -
   7.149 -        enter_c
   7.150 -        mov     eax,0B10Eh
   7.151 -        mov     bx,0
   7.152 -        _les    _di,[buf]
   7.153 -ifdef   flatmodel
   7.154 -        call    far dword [entry]
   7.155 -else
   7.156 -        int     1Ah
   7.157 -endif
   7.158 -        movzx   eax,ah
   7.159 -        leave_c
   7.160 -        ret
   7.161 -
   7.162 -cprocend
   7.163 -
   7.164 -;----------------------------------------------------------------------------
   7.165 -; ibool _PCIBIOS_setIRQ(int busDev,int intPin,int IRQ,PCIBIOS_entry entry);
   7.166 -;----------------------------------------------------------------------------
   7.167 -; Change the IRQ routing for the PCI device
   7.168 -;----------------------------------------------------------------------------
   7.169 -cprocstart   _PCIBIOS_setIRQ
   7.170 -
   7.171 -        ARG     busDev:UINT, intPin:UINT, IRQ:UINT, entry:QWORD
   7.172 -
   7.173 -        enter_c
   7.174 -        mov     eax,0B10Fh
   7.175 -        mov     bx,[USHORT busDev]
   7.176 -        mov     cl,[BYTE intPin]
   7.177 -        mov     ch,[BYTE IRQ]
   7.178 -ifdef   flatmodel
   7.179 -        call    far dword [entry]
   7.180 -else
   7.181 -        int     1Ah
   7.182 -endif
   7.183 -        mov     eax,1
   7.184 -        jnc     @@1
   7.185 -        xor     eax,eax         ; Function failed!
   7.186 -@@1:    leave_c
   7.187 -        ret
   7.188 -
   7.189 -cprocend
   7.190 -
   7.191 -;----------------------------------------------------------------------------
   7.192 -; ulong _PCIBIOS_specialCycle(int bus,ulong data,PCIBIOS_entry entry);
   7.193 -;----------------------------------------------------------------------------
   7.194 -; Generate a special cycle via the PCI BIOS.
   7.195 -;----------------------------------------------------------------------------
   7.196 -cprocstart   _PCIBIOS_specialCycle
   7.197 -
   7.198 -        ARG     bus:UINT, data:ULONG, entry:QWORD
   7.199 -
   7.200 -        enter_c
   7.201 -        mov     eax,0B106h
   7.202 -        mov     bh,[BYTE bus]
   7.203 -        mov     ecx,[data]
   7.204 -ifdef   flatmodel
   7.205 -        call    far dword [entry]
   7.206 -else
   7.207 -        int     1Ah
   7.208 -endif
   7.209 -        leave_c
   7.210 -        ret
   7.211 -
   7.212 -cprocend
   7.213 -
   7.214 -;----------------------------------------------------------------------------
   7.215 -; ushort _PCI_getCS(void)
   7.216 -;----------------------------------------------------------------------------
   7.217 -cprocstart   _PCI_getCS
   7.218 -
   7.219 -        mov     ax,cs
   7.220 -        ret
   7.221 -
   7.222 -cprocend
   7.223 -
   7.224 -;----------------------------------------------------------------------------
   7.225 -; int PM_inpb(int port)
   7.226 -;----------------------------------------------------------------------------
   7.227 -; Reads a byte from the specified port
   7.228 -;----------------------------------------------------------------------------
   7.229 -cprocstart  PM_inpb
   7.230 -
   7.231 -        ARG     port:UINT
   7.232 -
   7.233 -        push    _bp
   7.234 -        mov     _bp,_sp
   7.235 -        xor     _ax,_ax
   7.236 -        mov     _dx,[port]
   7.237 -        in      al,dx
   7.238 -        pop     _bp
   7.239 -        ret
   7.240 -
   7.241 -cprocend
   7.242 -
   7.243 -;----------------------------------------------------------------------------
   7.244 -; int PM_inpw(int port)
   7.245 -;----------------------------------------------------------------------------
   7.246 -; Reads a word from the specified port
   7.247 -;----------------------------------------------------------------------------
   7.248 -cprocstart  PM_inpw
   7.249 -
   7.250 -        ARG     port:UINT
   7.251 -
   7.252 -        push    _bp
   7.253 -        mov     _bp,_sp
   7.254 -        xor     _ax,_ax
   7.255 -        mov     _dx,[port]
   7.256 -        in      ax,dx
   7.257 -        pop     _bp
   7.258 -        ret
   7.259 -
   7.260 -cprocend
   7.261 -
   7.262 -;----------------------------------------------------------------------------
   7.263 -; ulong PM_inpd(int port)
   7.264 -;----------------------------------------------------------------------------
   7.265 -; Reads a word from the specified port
   7.266 -;----------------------------------------------------------------------------
   7.267 -cprocstart  PM_inpd
   7.268 -
   7.269 -        ARG     port:UINT
   7.270 -
   7.271 -        push    _bp
   7.272 -        mov     _bp,_sp
   7.273 -        mov     _dx,[port]
   7.274 -        in      eax,dx
   7.275 -ifndef flatmodel
   7.276 -        shld    edx,eax,16      ; DX:AX = result
   7.277 -endif
   7.278 -        pop     _bp
   7.279 -        ret
   7.280 -
   7.281 -cprocend
   7.282 -
   7.283 -;----------------------------------------------------------------------------
   7.284 -; void PM_outpb(int port,int value)
   7.285 -;----------------------------------------------------------------------------
   7.286 -; Write a byte to the specified port.
   7.287 -;----------------------------------------------------------------------------
   7.288 -cprocstart  PM_outpb
   7.289 -
   7.290 -        ARG     port:UINT, value:UINT
   7.291 -
   7.292 -        push    _bp
   7.293 -        mov     _bp,_sp
   7.294 -        mov     _dx,[port]
   7.295 -        mov     _ax,[value]
   7.296 -        out     dx,al
   7.297 -        pop     _bp
   7.298 -        ret
   7.299 -
   7.300 -cprocend
   7.301 -
   7.302 -;----------------------------------------------------------------------------
   7.303 -; void PM_outpw(int port,int value)
   7.304 -;----------------------------------------------------------------------------
   7.305 -; Write a word to the specified port.
   7.306 -;----------------------------------------------------------------------------
   7.307 -cprocstart  PM_outpw
   7.308 -
   7.309 -        ARG     port:UINT, value:UINT
   7.310 -
   7.311 -        push    _bp
   7.312 -        mov     _bp,_sp
   7.313 -        mov     _dx,[port]
   7.314 -        mov     _ax,[value]
   7.315 -        out     dx,ax
   7.316 -        pop     _bp
   7.317 -        ret
   7.318 -
   7.319 -cprocend
   7.320 -
   7.321 -;----------------------------------------------------------------------------
   7.322 -; void PM_outpd(int port,ulong value)
   7.323 -;----------------------------------------------------------------------------
   7.324 -; Write a word to the specified port.
   7.325 -;----------------------------------------------------------------------------
   7.326 -cprocstart  PM_outpd
   7.327 -
   7.328 -        ARG     port:UINT, value:ULONG
   7.329 -
   7.330 -        push    _bp
   7.331 -        mov     _bp,_sp
   7.332 -        mov     _dx,[port]
   7.333 -        mov     eax,[value]
   7.334 -        out     dx,eax
   7.335 -        pop     _bp
   7.336 -        ret
   7.337 -
   7.338 -cprocend
   7.339 -
   7.340 -endcodeseg  _pcilib
   7.341 -
   7.342 -        END
     8.1 --- a/src/cpuinfo/cpuinfo.h	Mon Nov 24 00:21:24 2003 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,203 +0,0 @@
     8.4 -/****************************************************************************
     8.5 -*
     8.6 -*                   SciTech OS Portability Manager Library
     8.7 -*
     8.8 -*  ========================================================================
     8.9 -*
    8.10 -*   Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
    8.11 -*
    8.12 -*   This file may be distributed and/or modified under the terms of the
    8.13 -*   GNU Lesser General Public License version 2.1 as published by the Free
    8.14 -*   Software Foundation and appearing in the file LICENSE.LGPL included
    8.15 -*   in the packaging of this file.
    8.16 -*
    8.17 -*   Licensees holding a valid Commercial License for this product from
    8.18 -*   SciTech Software, Inc. may use this file in accordance with the
    8.19 -*   Commercial License Agreement provided with the Software.
    8.20 -*
    8.21 -*   This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
    8.22 -*   THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    8.23 -*   PURPOSE.
    8.24 -*
    8.25 -*   See http://www.scitechsoft.com/license/ for information about
    8.26 -*   the licensing options available and how to purchase a Commercial
    8.27 -*   License Agreement.
    8.28 -*
    8.29 -*   Contact license@scitechsoft.com if any conditions of this licensing
    8.30 -*   are not clear to you, or you have questions about licensing options.
    8.31 -*
    8.32 -*  ========================================================================
    8.33 -*
    8.34 -* Language:     ANSI C
    8.35 -* Environment:  Any
    8.36 -*
    8.37 -* Description:  Header file for PM library functions for querying the CPU
    8.38 -*               type, CPU speed and CPU features. Includes support for
    8.39 -*               high precision timing on Pentium based systems using the
    8.40 -*               Read Time Stamp Counter.
    8.41 -*
    8.42 -****************************************************************************/
    8.43 -
    8.44 -#ifndef __CPUINFO_H
    8.45 -#define __CPUINFO_H
    8.46 -
    8.47 -//#include "scitech.h"
    8.48 -#include "SDL.h"
    8.49 -#ifdef USE_ASMBLIT
    8.50 -#define __INTEL__
    8.51 -#endif
    8.52 -typedef enum {
    8.53 -	false,
    8.54 -	true
    8.55 -} ibool;
    8.56 -typedef Uint8 uchar;
    8.57 -typedef Uint16 ushort;
    8.58 -typedef Uint32 uint;
    8.59 -typedef Uint32 ulong;
    8.60 -typedef Uint64 u64;
    8.61 -#define _ASMAPI SDLCALL
    8.62 -
    8.63 -/*--------------------- Macros and type definitions -----------------------*/
    8.64 -
    8.65 -/* Define the calling conventions - C always */
    8.66 -
    8.67 -#define ZAPI    _ASMAPI
    8.68 -
    8.69 -/****************************************************************************
    8.70 -REMARKS:
    8.71 -Defines the types of processors returned by CPU_getProcessorType.
    8.72 -
    8.73 -HEADER:
    8.74 -cpuinfo.h
    8.75 -
    8.76 -MEMBERS:
    8.77 -CPU_i386            - Intel 80386 processor
    8.78 -CPU_i486            - Intel 80486 processor
    8.79 -CPU_Pentium         - Intel Pentium(R) processor
    8.80 -CPU_PentiumPro      - Intel PentiumPro(R) processor
    8.81 -CPU_PentiumII       - Intel PentiumII(R) processor
    8.82 -CPU_Celeron         - Intel Celeron(R) processor
    8.83 -CPU_PentiumIII      - Intel PentiumIII(R) processor
    8.84 -CPU_Pentium4        - Intel Pentium4(R) processor
    8.85 -CPU_UnkIntel        - Unknown Intel processor
    8.86 -CPU_Cyrix6x86       - Cyrix 6x86 processor
    8.87 -CPU_Cyrix6x86MX     - Cyrix 6x86MX processor
    8.88 -CPU_CyrixMediaGX    - Cyrix MediaGX processor
    8.89 -CPU_CyrixMediaGXm   - Cyrix MediaGXm processor
    8.90 -CPU_UnkCyrix        - Unknown Cyrix processor
    8.91 -CPU_AMDAm486        - AMD Am486 processor
    8.92 -CPU_AMDAm5x86       - AMD Am5x86 processor
    8.93 -CPU_AMDK5           - AMD K5 processor
    8.94 -CPU_AMDK6           - AMD K6 processor
    8.95 -CPU_AMDK6_2         - AMD K6-2 processor
    8.96 -CPU_AMDK6_2plus     - AMD K6-2+ processor
    8.97 -CPU_AMDK6_III       - AMD K6-III processor
    8.98 -CPU_AMDK6_IIIplus   - AMD K6-III+ processor
    8.99 -CPU_AMDAthlon       - AMD Athlon processor
   8.100 -CPU_AMDDuron        - AMD Duron processor
   8.101 -CPU_UnkAMD          - Unknown AMD processor
   8.102 -CPU_WinChipC6       - IDT WinChip C6 processor
   8.103 -CPU_WinChip2        - IDT WinChip 2 processor
   8.104 -CPU_UnkIDT          - Unknown IDT processor
   8.105 -CPU_ViaCyrixIII     - Via Cyrix III
   8.106 -CPU_UnkVIA          - Unknown Via processor
   8.107 -CPU_Alpha           - DEC Alpha processor
   8.108 -CPU_Mips            - MIPS processor
   8.109 -CPU_PowerPC         - PowerPC processor
   8.110 -CPU_mask            - Mask to remove flags and get CPU type
   8.111 -CPU_IDT             - This bit is set if the processor vendor is IDT
   8.112 -CPU_Cyrix           - This bit is set if the processor vendor is Cyrix
   8.113 -CPU_AMD             - This bit is set if the processor vendor is AMD
   8.114 -CPU_Intel           - This bit is set if the processor vendor is Intel
   8.115 -CPU_VIA             - This bit is set if the processor vendor is Via
   8.116 -CPU_familyMask      - Mask to isolate CPU family
   8.117 -CPU_steppingMask    - Mask to isolate CPU stepping
   8.118 -CPU_steppingShift   - Shift factor for CPU stepping
   8.119 -****************************************************************************/
   8.120 -typedef enum {
   8.121 -    CPU_i386            = 0,
   8.122 -    CPU_i486            = 1,
   8.123 -    CPU_Pentium         = 2,
   8.124 -    CPU_PentiumPro      = 3,
   8.125 -    CPU_PentiumII       = 4,
   8.126 -    CPU_Celeron         = 5,
   8.127 -    CPU_PentiumIII      = 6,
   8.128 -    CPU_Pentium4        = 7,
   8.129 -    CPU_UnkIntel        = 8,
   8.130 -    CPU_Cyrix6x86       = 100,
   8.131 -    CPU_Cyrix6x86MX     = 101,
   8.132 -    CPU_CyrixMediaGX    = 102,
   8.133 -    CPU_CyrixMediaGXm   = 104,
   8.134 -    CPU_UnkCyrix        = 105,
   8.135 -    CPU_AMDAm486        = 200,
   8.136 -    CPU_AMDAm5x86       = 201,
   8.137 -    CPU_AMDK5           = 202,
   8.138 -    CPU_AMDK6           = 203,
   8.139 -    CPU_AMDK6_2         = 204,
   8.140 -    CPU_AMDK6_2plus     = 205,
   8.141 -    CPU_AMDK6_III       = 206,
   8.142 -    CPU_AMDK6_IIIplus   = 207,
   8.143 -    CPU_UnkAMD          = 208,
   8.144 -    CPU_AMDAthlon       = 250,
   8.145 -    CPU_AMDDuron        = 251,
   8.146 -    CPU_WinChipC6       = 300,
   8.147 -    CPU_WinChip2        = 301,
   8.148 -    CPU_UnkIDT          = 302,
   8.149 -    CPU_ViaCyrixIII     = 400,
   8.150 -    CPU_UnkVIA          = 401,
   8.151 -    CPU_Alpha           = 500,
   8.152 -    CPU_Mips            = 600,
   8.153 -    CPU_PowerPC         = 700,
   8.154 -    CPU_mask            = 0x00000FFF,
   8.155 -    CPU_IDT             = 0x00001000,
   8.156 -    CPU_Cyrix           = 0x00002000,
   8.157 -    CPU_AMD             = 0x00004000,
   8.158 -    CPU_Intel           = 0x00008000,
   8.159 -    CPU_VIA             = 0x00010000,
   8.160 -    CPU_familyMask      = 0x00FFF000,
   8.161 -    CPU_steppingMask    = 0x0F000000,
   8.162 -    CPU_steppingShift   = 24
   8.163 -    } CPU_processorType;
   8.164 -
   8.165 -#pragma pack(1)
   8.166 -/****************************************************************************
   8.167 -REMARKS:
   8.168 -Defines the structure for holding 64-bit integers used for storing the values
   8.169 -returned by the Intel RDTSC instruction.
   8.170 -
   8.171 -HEADER:
   8.172 -cpuinfo.h
   8.173 -
   8.174 -MEMBERS:
   8.175 -low     - Low 32-bits of the 64-bit integer
   8.176 -high    - High 32-bits of the 64-bit integer
   8.177 -****************************************************************************/
   8.178 -typedef struct {
   8.179 -    ulong   low;
   8.180 -    ulong   high;
   8.181 -    } CPU_largeInteger;
   8.182 -#pragma pack()
   8.183 -
   8.184 -/*-------------------------- Function Prototypes --------------------------*/
   8.185 -
   8.186 -#ifdef  __cplusplus
   8.187 -extern "C" {            /* Use "C" linkage when in C++ mode */
   8.188 -#endif
   8.189 -
   8.190 -/* Routines to obtain CPU information */
   8.191 -
   8.192 -uint    ZAPI CPU_getProcessorType(void);
   8.193 -ibool   ZAPI CPU_haveMMX(void);
   8.194 -ibool   ZAPI CPU_have3DNow(void);
   8.195 -ibool   ZAPI CPU_haveSSE(void);
   8.196 -ibool   ZAPI CPU_haveRDTSC(void);
   8.197 -ulong   ZAPI CPU_getProcessorSpeed(ibool accurate);
   8.198 -void    ZAPI CPU_getProcessorSpeedInHZ(ibool accurate,CPU_largeInteger *speed);
   8.199 -char *  ZAPI CPU_getProcessorName(void);
   8.200 -
   8.201 -#ifdef  __cplusplus
   8.202 -}                       /* End of "C" linkage for C++   */
   8.203 -#endif
   8.204 -
   8.205 -#endif  /* __CPUINFO_H */
   8.206 -
     9.1 --- a/src/cpuinfo/gcpuinfo.c	Mon Nov 24 00:21:24 2003 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,436 +0,0 @@
     9.4 -/****************************************************************************
     9.5 -*
     9.6 -*                   SciTech OS Portability Manager Library
     9.7 -*
     9.8 -*  ========================================================================
     9.9 -*
    9.10 -*   Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
    9.11 -*
    9.12 -*   This file may be distributed and/or modified under the terms of the
    9.13 -*   GNU Lesser General Public License version 2.1 as published by the Free
    9.14 -*   Software Foundation and appearing in the file LICENSE.LGPL included
    9.15 -*   in the packaging of this file.
    9.16 -*
    9.17 -*   Licensees holding a valid Commercial License for this product from
    9.18 -*   SciTech Software, Inc. may use this file in accordance with the
    9.19 -*   Commercial License Agreement provided with the Software.
    9.20 -*
    9.21 -*   This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
    9.22 -*   THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    9.23 -*   PURPOSE.
    9.24 -*
    9.25 -*   See http://www.scitechsoft.com/license/ for information about
    9.26 -*   the licensing options available and how to purchase a Commercial
    9.27 -*   License Agreement.
    9.28 -*
    9.29 -*   Contact license@scitechsoft.com if any conditions of this licensing
    9.30 -*   are not clear to you, or you have questions about licensing options.
    9.31 -*
    9.32 -*  ========================================================================
    9.33 -*
    9.34 -* Language:     ANSI C
    9.35 -* Environment:  Any
    9.36 -*
    9.37 -* Description:  Main module to implement the Zen Timer support functions.
    9.38 -*
    9.39 -****************************************************************************/
    9.40 -
    9.41 -#include "cpuinfo.h"
    9.42 -//#include "pmapi.h"
    9.43 -//#include "oshdr.h"
    9.44 -
    9.45 -/*----------------------------- Implementation ----------------------------*/
    9.46 -
    9.47 -/* External Intel assembler functions */
    9.48 -#ifdef  __INTEL__
    9.49 -/* {secret} */
    9.50 -ibool   _ASMAPI _CPU_haveCPUID(void);
    9.51 -/* {secret} */
    9.52 -ibool   _ASMAPI _CPU_check80386(void);
    9.53 -/* {secret} */
    9.54 -ibool   _ASMAPI _CPU_check80486(void);
    9.55 -/* {secret} */
    9.56 -uint    _ASMAPI _CPU_checkCPUID(void);
    9.57 -/* {secret} */
    9.58 -uint    _ASMAPI _CPU_getCPUIDModel(void);
    9.59 -/* {secret} */
    9.60 -uint    _ASMAPI _CPU_getCPUIDStepping(void);
    9.61 -/* {secret} */
    9.62 -uint    _ASMAPI _CPU_getCPUIDFeatures(void);
    9.63 -/* {secret} */
    9.64 -uint    _ASMAPI _CPU_getCacheSize(void);
    9.65 -/* {secret} */
    9.66 -uint    _ASMAPI _CPU_have3DNow(void);
    9.67 -/* {secret} */
    9.68 -ibool   _ASMAPI _CPU_checkClone(void);
    9.69 -/* {secret} */
    9.70 -void    _ASMAPI _CPU_readTimeStamp(CPU_largeInteger *time);
    9.71 -/* {secret} */
    9.72 -void    _ASMAPI _CPU_runBSFLoop(ulong iterations);
    9.73 -/* {secret} */
    9.74 -ulong   _ASMAPI _CPU_mulDiv(ulong a,ulong b,ulong c);
    9.75 -/* {secret} */
    9.76 -#define CPU_HaveMMX     0x00800000
    9.77 -#define CPU_HaveRDTSC   0x00000010
    9.78 -#define CPU_HaveSSE     0x02000000
    9.79 -#endif
    9.80 -
    9.81 -/*------------------------ Public interface routines ----------------------*/
    9.82 -
    9.83 -#ifdef __INTEL__
    9.84 -extern Uint8 PM_inpb(int port);
    9.85 -extern void PM_outpb(int port,Uint8 val);
    9.86 -
    9.87 -/****************************************************************************
    9.88 -REMARKS:
    9.89 -Read an I/O port location.
    9.90 -****************************************************************************/
    9.91 -static uchar rdinx(
    9.92 -    int port,
    9.93 -    int index)
    9.94 -{
    9.95 -    PM_outpb(port,(uchar)index);
    9.96 -    return PM_inpb(port+1);
    9.97 -}
    9.98 -
    9.99 -/****************************************************************************
   9.100 -REMARKS:
   9.101 -Write an I/O port location.
   9.102 -****************************************************************************/
   9.103 -static void wrinx(
   9.104 -    ushort port,
   9.105 -    ushort index,
   9.106 -    ushort value)
   9.107 -{
   9.108 -    PM_outpb(port,(uchar)index);
   9.109 -    PM_outpb(port+1,(uchar)value);
   9.110 -}
   9.111 -
   9.112 -/****************************************************************************
   9.113 -REMARKS:
   9.114 -Enables the Cyrix CPUID instruction to properly detect MediaGX and 6x86
   9.115 -processors.
   9.116 -****************************************************************************/
   9.117 -static void _CPU_enableCyrixCPUID(void)
   9.118 -{
   9.119 -    uchar   ccr3;
   9.120 -
   9.121 -    //PM_init();
   9.122 -    ccr3 = rdinx(0x22,0xC3);
   9.123 -    wrinx(0x22,0xC3,(uchar)(ccr3 | 0x10));
   9.124 -    wrinx(0x22,0xE8,(uchar)(rdinx(0x22,0xE8) | 0x80));
   9.125 -    wrinx(0x22,0xC3,ccr3);
   9.126 -}
   9.127 -#endif
   9.128 -
   9.129 -/****************************************************************************
   9.130 -DESCRIPTION:
   9.131 -Returns the type of processor in the system.
   9.132 -
   9.133 -HEADER:
   9.134 -cpuinfo.h
   9.135 -
   9.136 -RETURNS:
   9.137 -Numerical identifier for the installed processor
   9.138 -
   9.139 -REMARKS:
   9.140 -Returns the type of processor in the system. Note that if the CPU is an
   9.141 -unknown Pentium family processor that we don't have an enumeration for,
   9.142 -the return value will be greater than or equal to the value of CPU_UnkPentium
   9.143 -(depending on the value returned by the CPUID instruction).
   9.144 -
   9.145 -SEE ALSO:
   9.146 -CPU_getProcessorSpeed, CPU_haveMMX, CPU_getProcessorName
   9.147 -****************************************************************************/
   9.148 -uint ZAPI CPU_getProcessorType(void)
   9.149 -{
   9.150 -#if     defined(__INTEL__)
   9.151 -    uint            cpu,vendor,model,cacheSize;
   9.152 -    static ibool    firstTime = true;
   9.153 -
   9.154 -    if (_CPU_haveCPUID()) {
   9.155 -        cpu = _CPU_checkCPUID();
   9.156 -        vendor = cpu & ~CPU_mask;
   9.157 -        if (vendor == CPU_Intel) {
   9.158 -            /* Check for Intel processors */
   9.159 -            switch (cpu & CPU_mask) {
   9.160 -                case 4: cpu = CPU_i486;         break;
   9.161 -                case 5: cpu = CPU_Pentium;      break;
   9.162 -                case 6:
   9.163 -                    if ((model = _CPU_getCPUIDModel()) == 1)
   9.164 -                        cpu = CPU_PentiumPro;
   9.165 -                    else if (model <= 6) {
   9.166 -                        cacheSize = _CPU_getCacheSize();
   9.167 -                        if ((model == 5 && cacheSize == 0) ||
   9.168 -                            (model == 5 && cacheSize == 256) ||
   9.169 -                            (model == 6 && cacheSize == 128))
   9.170 -                            cpu = CPU_Celeron;
   9.171 -                        else
   9.172 -                            cpu = CPU_PentiumII;
   9.173 -                        }
   9.174 -                    else if (model >= 7) {
   9.175 -                        /* Model 7 == Pentium III */
   9.176 -                        /* Model 8 == Celeron/Pentium III Coppermine */
   9.177 -                        cacheSize = _CPU_getCacheSize();
   9.178 -                        if ((model == 8 && cacheSize == 128))
   9.179 -                            cpu = CPU_Celeron;
   9.180 -                        else
   9.181 -                            cpu = CPU_PentiumIII;
   9.182 -                        }
   9.183 -                    break;
   9.184 -                case 7:
   9.185 -                    cpu = CPU_Pentium4;
   9.186 -                    break;
   9.187 -                default:
   9.188 -                    cpu = CPU_UnkIntel;
   9.189 -                    break;
   9.190 -                }
   9.191 -            }
   9.192 -        else if (vendor == CPU_Cyrix) {
   9.193 -            /* Check for Cyrix processors */
   9.194 -            switch (cpu & CPU_mask) {
   9.195 -                case 4:
   9.196 -                    if ((model = _CPU_getCPUIDModel()) == 4)
   9.197 -                        cpu = CPU_CyrixMediaGX;
   9.198 -                    else
   9.199 -                        cpu = CPU_UnkCyrix;
   9.200 -                    break;
   9.201 -                case 5:
   9.202 -                    if ((model = _CPU_getCPUIDModel()) == 2)
   9.203 -                        cpu = CPU_Cyrix6x86;
   9.204 -                    else if (model == 4)
   9.205 -                        cpu = CPU_CyrixMediaGXm;
   9.206 -                    else
   9.207 -                        cpu = CPU_UnkCyrix;
   9.208 -                    break;
   9.209 -                case 6:
   9.210 -                    if ((model = _CPU_getCPUIDModel()) <= 1)
   9.211 -                        cpu = CPU_Cyrix6x86MX;
   9.212 -                    else
   9.213 -                        cpu = CPU_UnkCyrix;
   9.214 -                    break;
   9.215 -                default:
   9.216 -                    cpu = CPU_UnkCyrix;
   9.217 -                    break;
   9.218 -                }
   9.219 -            }
   9.220 -        else if (vendor == CPU_AMD) {
   9.221 -            /* Check for AMD processors */
   9.222 -            switch (cpu & CPU_mask) {
   9.223 -                case 4:
   9.224 -                    if ((model = _CPU_getCPUIDModel()) == 0)
   9.225 -                        cpu = CPU_AMDAm5x86;
   9.226 -                    else
   9.227 -                        cpu = CPU_AMDAm486;
   9.228 -                    break;
   9.229 -                case 5:
   9.230 -                    if ((model = _CPU_getCPUIDModel()) <= 3)
   9.231 -                        cpu = CPU_AMDK5;
   9.232 -                    else if (model <= 7)
   9.233 -                        cpu = CPU_AMDK6;
   9.234 -                    else if (model == 8)
   9.235 -                        cpu = CPU_AMDK6_2;
   9.236 -                    else if (model == 9)
   9.237 -                        cpu = CPU_AMDK6_III;
   9.238 -                    else if (model == 13) {
   9.239 -                        if (_CPU_getCPUIDStepping() <= 3)
   9.240 -                            cpu = CPU_AMDK6_IIIplus;
   9.241 -                        else
   9.242 -                            cpu = CPU_AMDK6_2plus;
   9.243 -                        }
   9.244 -                    else
   9.245 -                        cpu = CPU_UnkAMD;
   9.246 -                    break;
   9.247 -                case 6:
   9.248 -                    if ((model = _CPU_getCPUIDModel()) == 3)
   9.249 -                        cpu = CPU_AMDDuron;
   9.250 -                    else
   9.251 -                        cpu = CPU_AMDAthlon;
   9.252 -                    break;
   9.253 -                default:
   9.254 -                    cpu = CPU_UnkAMD;
   9.255 -                    break;
   9.256 -                }
   9.257 -            }
   9.258 -        else if (vendor == CPU_IDT) {
   9.259 -            /* Check for IDT WinChip processors */
   9.260 -            switch (cpu & CPU_mask) {
   9.261 -                case 5:
   9.262 -                    if ((model = _CPU_getCPUIDModel()) <= 4)
   9.263 -                        cpu = CPU_WinChipC6;
   9.264 -                    else if (model == 8)
   9.265 -                        cpu = CPU_WinChip2;
   9.266 -                    else
   9.267 -                        cpu = CPU_UnkIDT;
   9.268 -                    break;
   9.269 -                case 6:
   9.270 -                    vendor = CPU_VIA;
   9.271 -                    if ((model = _CPU_getCPUIDModel()) <= 6)
   9.272 -                        cpu = CPU_ViaCyrixIII;
   9.273 -                    else
   9.274 -                        cpu = CPU_UnkVIA;
   9.275 -                    break;
   9.276 -                default:
   9.277 -                    vendor = CPU_VIA;
   9.278 -                    cpu = CPU_UnkVIA;
   9.279 -                    break;
   9.280 -                }
   9.281 -            }
   9.282 -        else {
   9.283 -            /* Assume a Pentium compatible Intel clone */
   9.284 -            cpu = CPU_Pentium;
   9.285 -            }
   9.286 -        return cpu | vendor | (_CPU_getCPUIDStepping() << CPU_steppingShift);
   9.287 -        }
   9.288 -    else {
   9.289 -        if (_CPU_check80386())
   9.290 -            cpu = CPU_i386;
   9.291 -        else  if (_CPU_check80486()) {
   9.292 -            /* If we get here we may have a Cyrix processor so we can try
   9.293 -             * enabling the CPUID instruction and trying again.
   9.294 -             */
   9.295 -            if (firstTime) {
   9.296 -                firstTime = false;
   9.297 -                _CPU_enableCyrixCPUID();
   9.298 -                return CPU_getProcessorType();
   9.299 -                }
   9.300 -            cpu = CPU_i486;
   9.301 -            }
   9.302 -        else
   9.303 -            cpu = CPU_Pentium;
   9.304 -        if (!_CPU_checkClone())
   9.305 -            return cpu | CPU_Intel;
   9.306 -        return cpu;
   9.307 -        }
   9.308 -#elif   defined(__ALPHA__)
   9.309 -    return CPU_Alpha;
   9.310 -#elif   defined(__MIPS__)
   9.311 -    return CPU_Mips;
   9.312 -#elif   defined(__PPC__)
   9.313 -    return CPU_PowerPC;
   9.314 -#endif
   9.315 -}
   9.316 -
   9.317 -/****************************************************************************
   9.318 -DESCRIPTION:
   9.319 -Returns true if the processor supports Intel MMX extensions.
   9.320 -
   9.321 -HEADER:
   9.322 -cpuinfo.h
   9.323 -
   9.324 -RETURNS:
   9.325 -True if MMX is available, false if not.
   9.326 -
   9.327 -REMARKS:
   9.328 -This function determines if the processor supports the Intel MMX extended
   9.329 -instruction set.
   9.330 -
   9.331 -SEE ALSO:
   9.332 -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_have3DNow, CPU_haveSSE,
   9.333 -CPU_getProcessorName
   9.334 -****************************************************************************/
   9.335 -ibool ZAPI CPU_haveMMX(void)
   9.336 -{
   9.337 -#ifdef  __INTEL__
   9.338 -    if (_CPU_haveCPUID())
   9.339 -        return (_CPU_getCPUIDFeatures() & CPU_HaveMMX) != 0;
   9.340 -    return false;
   9.341 -#else
   9.342 -    return false;
   9.343 -#endif
   9.344 -}
   9.345 -
   9.346 -/****************************************************************************
   9.347 -DESCRIPTION:
   9.348 -Returns true if the processor supports AMD 3DNow! extensions.
   9.349 -
   9.350 -HEADER:
   9.351 -cpuinfo.h
   9.352 -
   9.353 -RETURNS:
   9.354 -True if 3DNow! is available, false if not.
   9.355 -
   9.356 -REMARKS:
   9.357 -This function determines if the processor supports the AMD 3DNow! extended
   9.358 -instruction set.
   9.359 -
   9.360 -SEE ALSO:
   9.361 -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_haveMMX, CPU_haveSSE,
   9.362 -CPU_getProcessorName
   9.363 -****************************************************************************/
   9.364 -ibool ZAPI CPU_have3DNow(void)
   9.365 -{
   9.366 -#ifdef  __INTEL__
   9.367 -    if (_CPU_haveCPUID())
   9.368 -        return _CPU_have3DNow();
   9.369 -    return false;
   9.370 -#else
   9.371 -    return false;
   9.372 -#endif
   9.373 -}
   9.374 -
   9.375 -/****************************************************************************
   9.376 -DESCRIPTION:
   9.377 -Returns true if the processor supports Intel SSE extensions.
   9.378 -
   9.379 -HEADER:
   9.380 -cpuinfo.h
   9.381 -
   9.382 -RETURNS:
   9.383 -True if Intel SSE is available, false if not.
   9.384 -
   9.385 -REMARKS:
   9.386 -This function determines if the processor supports the Intel SSE extended
   9.387 -instruction set.
   9.388 -
   9.389 -SEE ALSO:
   9.390 -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_haveMMX, CPU_have3DNow,
   9.391 -CPU_getProcessorName
   9.392 -****************************************************************************/
   9.393 -ibool ZAPI CPU_haveSSE(void)
   9.394 -{
   9.395 -#ifdef  __INTEL__
   9.396 -    if (_CPU_haveCPUID())
   9.397 -        return (_CPU_getCPUIDFeatures() & CPU_HaveSSE) != 0;
   9.398 -    return false;
   9.399 -#else
   9.400 -    return false;
   9.401 -#endif
   9.402 -}
   9.403 -
   9.404 -/****************************************************************************
   9.405 -RETURNS:
   9.406 -True if the RTSC instruction is available, false if not.
   9.407 -
   9.408 -REMARKS:
   9.409 -This function determines if the processor supports the Intel RDTSC
   9.410 -instruction, for high precision timing. If the processor is not an Intel or
   9.411 -Intel clone CPU, this function will always return false.
   9.412 -
   9.413 -DESCRIPTION:
   9.414 -Returns true if the processor supports RDTSC extensions.
   9.415 -
   9.416 -HEADER:
   9.417 -cpuinfo.h
   9.418 -
   9.419 -RETURNS:
   9.420 -True if RTSC is available, false if not.
   9.421 -
   9.422 -REMARKS:
   9.423 -This function determines if the processor supports the RDTSC instruction
   9.424 -for reading the processor time stamp counter.
   9.425 -
   9.426 -SEE ALSO:
   9.427 -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_haveMMX, CPU_have3DNow,
   9.428 -CPU_getProcessorName
   9.429 -****************************************************************************/
   9.430 -ibool ZAPI CPU_haveRDTSC(void)
   9.431 -{
   9.432 -#ifdef  __INTEL__
   9.433 -    if (_CPU_haveCPUID())
   9.434 -        return (_CPU_getCPUIDFeatures() & CPU_HaveRDTSC) != 0;
   9.435 -    return false;
   9.436 -#else
   9.437 -    return false;
   9.438 -#endif
   9.439 -}
    10.1 --- a/src/cpuinfo/scitech.mac	Mon Nov 24 00:21:24 2003 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,714 +0,0 @@
    10.4 -;****************************************************************************
    10.5 -;*
    10.6 -;*  ========================================================================
    10.7 -;*
    10.8 -;*   Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
    10.9 -;*
   10.10 -;*   This file may be distributed and/or modified under the terms of the
   10.11 -;*   GNU Lesser General Public License version 2.1 as published by the Free
   10.12 -;*   Software Foundation and appearing in the file LICENSE.LGPL included
   10.13 -;*   in the packaging of this file.
   10.14 -;*
   10.15 -;*   Licensees holding a valid Commercial License for this product from
   10.16 -;*   SciTech Software, Inc. may use this file in accordance with the
   10.17 -;*   Commercial License Agreement provided with the Software.
   10.18 -;*
   10.19 -;*   This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
   10.20 -;*   THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   10.21 -;*   PURPOSE.
   10.22 -;*
   10.23 -;*   See http://www.scitechsoft.com/license/ for information about
   10.24 -;*   the licensing options available and how to purchase a Commercial
   10.25 -;*   License Agreement.
   10.26 -;*
   10.27 -;*   Contact license@scitechsoft.com if any conditions of this licensing
   10.28 -;*   are not clear to you, or you have questions about licensing options.
   10.29 -;*
   10.30 -;*  ========================================================================
   10.31 -;*
   10.32 -;* Language:    NetWide Assembler (NASM)
   10.33 -;* Environment: Any Intel IA32 Environment
   10.34 -;*
   10.35 -;* Description: Macros to provide memory model independant assembly language
   10.36 -;*              module for C programming. Supports the large and flat memory
   10.37 -;*              models.
   10.38 -;*
   10.39 -;*              The defines that you should use when assembling modules that
   10.40 -;*              use this macro package are:
   10.41 -;*
   10.42 -;*                  __FLAT__    Assemble for 32-bit FLAT memory model
   10.43 -;*                  __NOU__     No underscore for all external C labels
   10.44 -;*                  __NOU_VAR__ No underscore for global variables only
   10.45 -;*
   10.46 -;*              The default settings are for 16-bit large memory model with
   10.47 -;*              leading underscores for symbol names.
   10.48 -;*
   10.49 -;****************************************************************************
   10.50 -
   10.51 -%ifndef SCITECH_MAC
   10.52 -%define SCITECH_MAC
   10.53 -
   10.54 -; Turn off underscores for globals if disabled for all externals
   10.55 -
   10.56 -%ifdef  __NOU__
   10.57 -%define __NOU_VAR__
   10.58 -%endif
   10.59 -
   10.60 -; Determine if we should use COFF style segment naming
   10.61 -
   10.62 -%ifdef __MSC__
   10.63 -%define __COFF__
   10.64 -%endif
   10.65 -%ifdef __GNUC__
   10.66 -%define __COFF__
   10.67 -%endif
   10.68 -
   10.69 -; Define the __WINDOWS__ symbol if we are compiling for any Windows
   10.70 -; environment
   10.71 -
   10.72 -%ifdef  __WINDOWS16__
   10.73 -%define __WINDOWS__         1
   10.74 -%endif
   10.75 -%ifdef  __WINDOWS32__
   10.76 -%define __WINDOWS__         1
   10.77 -%define __WINDOWS32_386__   1
   10.78 -%endif
   10.79 -
   10.80 -; Macros for accessing 'generic' registers
   10.81 -
   10.82 -%ifdef  __FLAT__
   10.83 -%idefine _ax    eax
   10.84 -%idefine _bx    ebx
   10.85 -%idefine _cx    ecx
   10.86 -%idefine _dx    edx
   10.87 -%idefine _si    esi
   10.88 -%idefine _di    edi
   10.89 -%idefine _bp    ebp
   10.90 -%idefine _sp    esp
   10.91 -%idefine _es
   10.92 -%idefine UCHAR  BYTE        ; Size of a character
   10.93 -%idefine USHORT WORD        ; Size of a short
   10.94 -%idefine UINT   DWORD       ; Size of an integer
   10.95 -%idefine ULONG  DWORD       ; Size of a long
   10.96 -%idefine BOOL   DWORD       ; Size of a boolean
   10.97 -%idefine DPTR   DWORD       ; Size of a data pointer
   10.98 -%idefine FDPTR  FWORD       ; Size of a far data pointer
   10.99 -%idefine NDPTR  DWORD       ; Size of a near data pointer
  10.100 -%idefine CPTR   DWORD       ; Size of a code pointer
  10.101 -%idefine FCPTR  FWORD       ; Size of a far code pointer
  10.102 -%idefine NCPTR  DWORD       ; Size of a near code pointer
  10.103 -%idefine FPTR   NEAR        ; Distance for function pointers
  10.104 -%idefine DUINT  dd          ; Declare a integer variable
  10.105 -%idefine intsize 4
  10.106 -%idefine flatmodel 1
  10.107 -%else
  10.108 -%idefine _ax    ax
  10.109 -%idefine _bx    bx
  10.110 -%idefine _cx    cx
  10.111 -%idefine _dx    dx
  10.112 -%idefine _si    si
  10.113 -%idefine _di    di
  10.114 -%idefine _bp    bp
  10.115 -%idefine _sp    sp
  10.116 -%idefine _es    es:
  10.117 -%idefine UCHAR  BYTE        ; Size of a character
  10.118 -%idefine USHORT WORD        ; Size of a short
  10.119 -%idefine UINT   WORD        ; Size of an integer
  10.120 -%idefine ULONG  DWORD       ; Size of a long
  10.121 -%idefine BOOL   WORD        ; Size of a boolean
  10.122 -%idefine DPTR   DWORD       ; Size of a data pointer
  10.123 -%idefine FDPTR  DWORD       ; Size of a far data pointer
  10.124 -%idefine NDPTR  WORD        ; Size of a near data pointer
  10.125 -%idefine CPTR   DWORD       ; Size of a code pointer
  10.126 -%idefine FCPTR  DWORD       ; Size of a far code pointer
  10.127 -%idefine NCPTR  WORD        ; Size of a near code pointer
  10.128 -%idefine FPTR   FAR         ; Distance for function pointers
  10.129 -%idefine DUINT  dw          ; Declare a integer variable
  10.130 -%idefine intsize 2
  10.131 -%endif
  10.132 -%idefine invert ~
  10.133 -%idefine offset
  10.134 -%idefine use_nasm
  10.135 -
  10.136 -; Convert all jumps to near jumps, since NASM does not so this automatically
  10.137 -
  10.138 -%idefine jo     jo near
  10.139 -%idefine jno    jno near
  10.140 -%idefine jz     jz near
  10.141 -%idefine jnz    jnz near
  10.142 -%idefine je     je near
  10.143 -%idefine jne    jne near
  10.144 -%idefine jb     jb  near
  10.145 -%idefine jbe    jbe near
  10.146 -%idefine ja     ja  near
  10.147 -%idefine jae    jae near
  10.148 -%idefine jl     jl  near
  10.149 -%idefine jle    jle near
  10.150 -%idefine jg     jg  near
  10.151 -%idefine jge    jge near
  10.152 -%idefine jc     jc  near
  10.153 -%idefine jnc    jnc near
  10.154 -%idefine js     js  near
  10.155 -%idefine jns    jns near
  10.156 -
  10.157 -%ifdef  DOUBLE
  10.158 -%idefine    REAL    QWORD
  10.159 -%idefine    DREAL   dq
  10.160 -%else
  10.161 -%idefine    REAL    DWORD
  10.162 -%idefine    DREAL   dd
  10.163 -%endif
  10.164 -
  10.165 -; Boolean truth values (same as those in debug.h)
  10.166 -
  10.167 -%idefine False      0
  10.168 -%idefine True       1
  10.169 -%idefine No         0
  10.170 -%idefine Yes        1
  10.171 -%idefine Yes        1
  10.172 -
  10.173 -; TODO: If we wish to port VxD code to NASM, we will potentially
  10.174 -;       need special macros in here to handle this!
  10.175 -
  10.176 -; Setup all correct segment definitions and attributes once at the
  10.177 -; beginning of the assembler module. This allows us to open/close
  10.178 -; code and data segments at will throughout the code as necessary.
  10.179 -
  10.180 -%ifdef __PIC__
  10.181 -%ifdef __LINUX__
  10.182 -        extern _GLOBAL_OFFSET_TABLE_
  10.183 -%else
  10.184 -        extern __GLOBAL_OFFSET_TABLE_
  10.185 -%endif
  10.186 -%endif
  10.187 -%ifdef __COFF__
  10.188 -segment .text public class=CODE use32 flat
  10.189 -segment .data public class=DATA use32 flat
  10.190 -%else
  10.191 -%ifdef flatmodel
  10.192 -segment _TEXT public align=16 class=CODE use32 flat
  10.193 -segment _DATA public align=4 class=DATA use32 flat
  10.194 -%else
  10.195 -segment _TEXT public align=16 class=CODE use16
  10.196 -segment _DATA public align=4 class=DATA use16
  10.197 -%endif
  10.198 -%endif
  10.199 -
  10.200 -; Macro to be invoked at the start of all modules to set up segments for
  10.201 -; later use. This does nothing for 32-bit code, but for 16-bit code
  10.202 -; will set up a far model code segment as well for later use.
  10.203 -
  10.204 -%imacro header 1
  10.205 -%ifndef flatmodel
  10.206 -segment %1_TEXT public align=16 class=CODE use16
  10.207 -%endif
  10.208 -%endmacro
  10.209 -
  10.210 -; Macro to begin a data segment. Segment attributes were specified in
  10.211 -; the header macro that is always required.
  10.212 -
  10.213 -%imacro begdataseg 1
  10.214 -%ifdef __COFF__
  10.215 -segment .data
  10.216 -%else
  10.217 -segment _DATA
  10.218 -%endif
  10.219 -%endmacro
  10.220 -
  10.221 -; Macro to end a data segment
  10.222 -
  10.223 -%imacro enddataseg 1
  10.224 -%endmacro
  10.225 -
  10.226 -; Macro to begin a code segment
  10.227 -
  10.228 -%imacro begcodeseg 1
  10.229 -%ifdef __COFF__
  10.230 -segment .text
  10.231 -%else
  10.232 -%ifdef flatmodel
  10.233 -segment _TEXT
  10.234 -%else
  10.235 -segment %1_TEXT
  10.236 -%endif
  10.237 -%endif
  10.238 -%endmacro
  10.239 -
  10.240 -; Macro to end a code segment
  10.241 -
  10.242 -%imacro endcodeseg 1
  10.243 -%endmacro
  10.244 -
  10.245 -; Macro to begin a near code segment
  10.246 -
  10.247 -%imacro begcodeseg_near 0
  10.248 -%ifdef __COFF__
  10.249 -segment .text
  10.250 -%else
  10.251 -segment _TEXT
  10.252 -%endif
  10.253 -%endmacro
  10.254 -
  10.255 -; Macro to end a near code segment
  10.256 -
  10.257 -%imacro endcodeseg_near 0
  10.258 -%endmacro
  10.259 -
  10.260 -; Macro for an extern C symbol. If the C compiler requires leading
  10.261 -; underscores, then the underscores are added to the symbol names, otherwise
  10.262 -; they are left off. The symbol name is referenced in the assembler code
  10.263 -; using the non-underscored symbol name.
  10.264 -
  10.265 -%imacro cextern 2
  10.266 -%ifdef  __NOU_VAR__
  10.267 -extern %1
  10.268 -%else
  10.269 -extern _%1
  10.270 -%define %1 _%1
  10.271 -%endif
  10.272 -%endmacro
  10.273 -
  10.274 -%imacro cexternfunc 2
  10.275 -%ifdef  __NOU__
  10.276 -extern %1
  10.277 -%else
  10.278 -extern _%1
  10.279 -%define %1 _%1
  10.280 -%endif
  10.281 -%endmacro
  10.282 -
  10.283 -; Macro for a public C symbol. If the C compiler requires leading
  10.284 -; underscores, then the underscores are added to the symbol names, otherwise
  10.285 -; they are left off. The symbol name is referenced in the assembler code
  10.286 -; using the non-underscored symbol name.
  10.287 -
  10.288 -%imacro cpublic 1
  10.289 -%ifdef  __NOU_VAR__
  10.290 -global %1
  10.291 -%1:
  10.292 -%else
  10.293 -global _%1
  10.294 -_%1:
  10.295 -%define %1 _%1
  10.296 -%endif
  10.297 -%endmacro
  10.298 -
  10.299 -; Macro for an global C symbol. If the C compiler requires leading
  10.300 -; underscores, then the underscores are added to the symbol names, otherwise
  10.301 -; they are left off. The symbol name is referenced in the assembler code
  10.302 -; using the non-underscored symbol name.
  10.303 -
  10.304 -%imacro cglobal 1
  10.305 -%ifdef  __NOU_VAR__
  10.306 -global %1
  10.307 -%else
  10.308 -global _%1
  10.309 -%define %1 _%1
  10.310 -%endif
  10.311 -%endmacro
  10.312 -
  10.313 -; Macro for an global C function symbol. If the C compiler requires leading
  10.314 -; underscores, then the underscores are added to the symbol names, otherwise
  10.315 -; they are left off. The symbol name is referenced in the assembler code
  10.316 -; using the non-underscored symbol name.
  10.317 -
  10.318 -%imacro cglobalfunc 1
  10.319 -%ifdef __PIC__
  10.320 -global %1:function
  10.321 -%else
  10.322 -%ifdef  __NOU__
  10.323 -global %1
  10.324 -%else
  10.325 -global _%1
  10.326 -%define %1 _%1
  10.327 -%endif
  10.328 -%endif
  10.329 -%endmacro
  10.330 -
  10.331 -; Macro to start a C callable function. This will be a far function for
  10.332 -; 16-bit code, and a near function for 32-bit code.
  10.333 -
  10.334 -%imacro cprocstatic 1
  10.335 -%push cproc
  10.336 -%1:
  10.337 -%ifdef flatmodel
  10.338 -%stacksize flat
  10.339 -%define ret retn
  10.340 -%else
  10.341 -%stacksize large
  10.342 -%define ret retf
  10.343 -%endif
  10.344 -%assign %$localsize 0
  10.345 -%endmacro
  10.346 -
  10.347 -%imacro cprocstart 1
  10.348 -%push cproc
  10.349 -    cglobalfunc %1
  10.350 -%1:
  10.351 -%ifdef flatmodel
  10.352 -%stacksize flat
  10.353 -%define ret retn
  10.354 -%else
  10.355 -%stacksize large
  10.356 -%define ret retf
  10.357 -%endif
  10.358 -%assign %$localsize 0
  10.359 -%endmacro
  10.360 -
  10.361 -; This macro sets up a procedure to be exported from a 16 bit DLL. Since the
  10.362 -; calling conventions are always _far _pascal for 16 bit DLL's, we actually
  10.363 -; rename this routine with an extra underscore with 'C' calling conventions
  10.364 -; and a small DLL stub will be provided by the high level code to call the
  10.365 -; assembler routine.
  10.366 -
  10.367 -%imacro cprocstartdll16 1
  10.368 -%ifdef  __WINDOWS16__
  10.369 -cprocstart  _%1
  10.370 -%else
  10.371 -cprocstart  %1
  10.372 -%endif
  10.373 -%endmacro
  10.374 -
  10.375 -; Macro to start a C callable near function.
  10.376 -
  10.377 -%imacro cprocnear 1
  10.378 -%push cproc
  10.379 -    cglobalfunc %1
  10.380 -%1:
  10.381 -%define ret retn
  10.382 -%ifdef flatmodel
  10.383 -%stacksize flat
  10.384 -%else
  10.385 -%stacksize small
  10.386 -%endif
  10.387 -%assign %$localsize 0
  10.388 -%endmacro
  10.389 -
  10.390 -; Macro to start a C callable far function.
  10.391 -
  10.392 -%imacro cprocfar 1
  10.393 -%push cproc
  10.394 -    cglobalfunc %1
  10.395 -%1:
  10.396 -%define ret retf
  10.397 -%ifdef flatmodel
  10.398 -%stacksize flat
  10.399 -%else
  10.400 -%stacksize large
  10.401 -%endif
  10.402 -%assign %$localsize 0
  10.403 -%endmacro
  10.404 -
  10.405 -; Macro to end a C function
  10.406 -
  10.407 -%imacro cprocend 0
  10.408 -%pop
  10.409 -%endmacro
  10.410 -
  10.411 -; Macros for entering and exiting C callable functions. Note that we must
  10.412 -; always save and restore the SI and DI registers for C functions, and for
  10.413 -; 32 bit C functions we also need to save and restore EBX and clear the
  10.414 -; direction flag.
  10.415 -
  10.416 -%imacro enter_c 0
  10.417 -        push    _bp
  10.418 -        mov     _bp,_sp
  10.419 -%ifnidn %$localsize,0
  10.420 -        sub     _sp,%$localsize
  10.421 -%endif
  10.422 -%ifdef  flatmodel
  10.423 -        push    ebx
  10.424 -%endif
  10.425 -        push    _si
  10.426 -        push    _di
  10.427 -%endmacro
  10.428 -
  10.429 -%imacro leave_c 0
  10.430 -        pop     _di
  10.431 -        pop     _si
  10.432 -%ifdef  flatmodel
  10.433 -        pop     ebx
  10.434 -        cld
  10.435 -%endif
  10.436 -%ifnidn %$localsize,0
  10.437 -        mov     _sp,_bp
  10.438 -%endif
  10.439 -        pop     _bp
  10.440 -%endmacro
  10.441 -
  10.442 -%imacro   use_ebx 0
  10.443 -%ifdef flatmodel
  10.444 -        push    ebx
  10.445 -%endif
  10.446 -%endmacro
  10.447 -
  10.448 -%imacro   unuse_ebx 0
  10.449 -%ifdef flatmodel
  10.450 -        pop     ebx
  10.451 -%endif
  10.452 -%endmacro
  10.453 -
  10.454 -; Macros for saving and restoring the value of DS,ES,FS,GS when it is to
  10.455 -; be used in assembly routines. This evaluates to nothing in the flat memory
  10.456 -; model, but is saves and restores DS in the large memory model.
  10.457 -
  10.458 -%imacro use_ds 0
  10.459 -%ifndef flatmodel
  10.460 -        push    ds
  10.461 -%endif
  10.462 -%endmacro
  10.463 -
  10.464 -%imacro unuse_ds 0
  10.465 -%ifndef flatmodel
  10.466 -        pop     ds
  10.467 -%endif
  10.468 -%endmacro
  10.469 -
  10.470 -%imacro use_es 0
  10.471 -%ifndef flatmodel
  10.472 -        push    es
  10.473 -%endif
  10.474 -%endmacro
  10.475 -
  10.476 -%imacro unuse_es 0
  10.477 -%ifndef flatmodel
  10.478 -        pop     es
  10.479 -%endif
  10.480 -%endmacro
  10.481 -
  10.482 -; Macros for loading the address of a data pointer into a segment and
  10.483 -; index register pair. The %imacro explicitly loads DS or ES in the 16 bit
  10.484 -; memory model, or it simply loads the offset into the register in the flat
  10.485 -; memory model since DS and ES always point to all addressable memory. You
  10.486 -; must use the correct _REG (ie: _BX) %imacros for documentation purposes.
  10.487 -
  10.488 -%imacro _lds    2
  10.489 -%ifdef flatmodel
  10.490 -        mov     %1,%2
  10.491 -%else
  10.492 -        lds     %1,%2
  10.493 -%endif
  10.494 -%endmacro
  10.495 -
  10.496 -%imacro   _les  2
  10.497 -%ifdef flatmodel
  10.498 -        mov     %1,%2
  10.499 -%else
  10.500 -        les     %1,%2
  10.501 -%endif
  10.502 -%endmacro
  10.503 -
  10.504 -; Macros for adding and subtracting a value from registers. Two value are
  10.505 -; provided, one for 16 bit modes and another for 32 bit modes (the extended
  10.506 -; register is used in 32 bit modes).
  10.507 -
  10.508 -%imacro   _add  3
  10.509 -%ifdef flatmodel
  10.510 -        add     e%1, %3
  10.511 -%else
  10.512 -        add     %1, %2
  10.513 -%endif
  10.514 -%endmacro
  10.515 -
  10.516 -%imacro _sub    3
  10.517 -%ifdef flatmodel
  10.518 -        sub     e%1, %3
  10.519 -%else
  10.520 -        sub     %1, %2
  10.521 -%endif
  10.522 -%endmacro
  10.523 -
  10.524 -; Macro to clear the high order word for the 32 bit extended registers.
  10.525 -; This is used to convert an unsigned 16 bit value to an unsigned 32 bit
  10.526 -; value, and will evaluate to nothing in 16 bit modes.
  10.527 -
  10.528 -%imacro clrhi   1
  10.529 -%ifdef  flatmodel
  10.530 -        movzx   e%1,%1
  10.531 -%endif
  10.532 -%endmacro
  10.533 -
  10.534 -%imacro sgnhi   1
  10.535 -%ifdef  flatmodel
  10.536 -        movsx   e%1,%1
  10.537 -%endif
  10.538 -%endmacro
  10.539 -
  10.540 -; Macro to load an extended register with an integer value in either mode
  10.541 -
  10.542 -%imacro loadint 2
  10.543 -%ifdef flatmodel
  10.544 -        mov     e%1,%2
  10.545 -%else
  10.546 -        xor     e%1,e%1
  10.547 -        mov     %1,%2
  10.548 -%endif
  10.549 -%endmacro
  10.550 -
  10.551 -; Macros to load and store integer values with string instructions
  10.552 -
  10.553 -%imacro LODSINT 0
  10.554 -%ifdef flatmodel
  10.555 -        lodsd
  10.556 -%else
  10.557 -        lodsw
  10.558 -%endif
  10.559 -%endmacro
  10.560 -
  10.561 -%imacro STOSINT 0
  10.562 -%ifdef flatmodel
  10.563 -        stosd
  10.564 -%else
  10.565 -        stosw
  10.566 -%endif
  10.567 -%endmacro
  10.568 -
  10.569 -; Macros to provide resb, resw, resd compatibility with NASM
  10.570 -
  10.571 -%imacro dclb 1
  10.572 -times %1 db 0
  10.573 -%endmacro
  10.574 -
  10.575 -%imacro dclw 1
  10.576 -times %1 dw 0
  10.577 -%endmacro
  10.578 -
  10.579 -%imacro dcld 1
  10.580 -times %1 dd 0
  10.581 -%endmacro
  10.582 -
  10.583 -; Macro to get the addres of the GOT for Linux/FreeBSD shared
  10.584 -; libraries into the EBX register.
  10.585 -
  10.586 -%imacro     get_GOT 1
  10.587 -            call    %%getgot
  10.588 -%%getgot:   pop     %1
  10.589 -            add     %1,_GLOBAL_OFFSET_TABLE_+$$-%%getgot wrt ..gotpc
  10.590 -%endmacro
  10.591 -
  10.592 -; Macro to get the address of a *local* variable that is global to
  10.593 -; a single module in a manner that will work correctly when compiled
  10.594 -; into a Linux shared library. Note that this will *not* work for
  10.595 -; variables that are defined as global to all modules. For that
  10.596 -; use the LEA_G macro
  10.597 -
  10.598 -%macro      LEA_L    2
  10.599 -%ifdef __PIC__
  10.600 -        get_GOT %1
  10.601 -        lea     %1,[%1+%2 wrt ..gotoff]
  10.602 -%else
  10.603 -        lea     %1,[%2]
  10.604 -%endif
  10.605 -%endmacro
  10.606 -
  10.607 -; Same macro as above but for global variables public to *all*
  10.608 -; modules.
  10.609 -
  10.610 -%macro      LEA_G    2
  10.611 -%ifdef __PIC__
  10.612 -        get_GOT %1
  10.613 -        mov     %1,[%1+%2 wrt ..got]
  10.614 -%else
  10.615 -        lea     %1,[%2]
  10.616 -%endif
  10.617 -%endmacro
  10.618 -
  10.619 -; macros to declare assembler function stubs for function structures
  10.620 -
  10.621 -%imacro BEGIN_STUBS_DEF 2
  10.622 -begdataseg  _STUBS
  10.623 -%ifdef  __NOU_VAR__
  10.624 -extern %1
  10.625 -%define STUBS_START %1
  10.626 -%else
  10.627 -extern _%1
  10.628 -%define STUBS_START _%1
  10.629 -%endif
  10.630 -enddataseg  _STUBS
  10.631 -begcodeseg  _STUBS
  10.632 -%assign off %2
  10.633 -%endmacro
  10.634 -
  10.635 -%imacro   DECLARE_STUB  1
  10.636 -%ifdef __PIC__
  10.637 -        global %1:function
  10.638 -%1:
  10.639 -        get_GOT eax
  10.640 -        mov     eax,[eax+STUBS_START wrt ..got]
  10.641 -        jmp     [eax+off]
  10.642 -%else
  10.643 -%ifdef  __NOU__
  10.644 -        global %1
  10.645 -%1:
  10.646 -%else
  10.647 -        global _%1
  10.648 -_%1:
  10.649 -%endif
  10.650 -        jmp     [DWORD STUBS_START+off]
  10.651 -%endif
  10.652 -%assign off off+4
  10.653 -%endmacro
  10.654 -
  10.655 -%imacro   SKIP_STUB  1
  10.656 -%assign off off+4
  10.657 -%endmacro
  10.658 -
  10.659 -%imacro DECLARE_STDCALL 2
  10.660 -%ifdef  STDCALL_MANGLE
  10.661 -        global _%1@%2
  10.662 -_%1@%2:
  10.663 -%else
  10.664 -%ifdef STDCALL_USCORE
  10.665 -        global _%1
  10.666 -_%1:
  10.667 -%else
  10.668 -        global %1
  10.669 -%1:
  10.670 -%endif
  10.671 -%endif
  10.672 -        jmp     [DWORD STUBS_START+off]
  10.673 -%assign off off+4
  10.674 -%endmacro
  10.675 -
  10.676 -%imacro   END_STUBS_DEF 0
  10.677 -endcodeseg  _STUBS
  10.678 -%endmacro
  10.679 -
  10.680 -; macros to declare assembler import stubs for binary loadable drivers
  10.681 -
  10.682 -%imacro BEGIN_IMPORTS_DEF   1
  10.683 -BEGIN_STUBS_DEF %1,4
  10.684 -%endmacro
  10.685 -
  10.686 -ifndef LOCAL_DECLARE_IMP
  10.687 -%imacro   DECLARE_IMP   2
  10.688 -DECLARE_STUB    %1
  10.689 -%endmacro
  10.690 -
  10.691 -%imacro   DECLARE_PTR   2
  10.692 -DECLARE_STUB    %1
  10.693 -%endmacro
  10.694 -
  10.695 -%imacro   SKIP_IMP   2
  10.696 -SKIP_STUB    %1
  10.697 -%endmacro
  10.698 -
  10.699 -%imacro   SKIP_PTR   2
  10.700 -SKIP_STUB    %1
  10.701 -%endmacro
  10.702 -
  10.703 -%imacro   SKIP_IMP2   1
  10.704 -DECLARE_STUB    %1
  10.705 -%endmacro
  10.706 -
  10.707 -%imacro   SKIP_IMP3   1
  10.708 -SKIP_STUB    %1
  10.709 -%endmacro
  10.710 -endif
  10.711 -
  10.712 -%imacro   END_IMPORTS_DEF 0
  10.713 -END_STUBS_DEF
  10.714 -%endmacro
  10.715 -
  10.716 -%endif
  10.717 -