repo
string | commit
string | message
string | diff
string |
---|---|---|---|
wrobbins/yelpruby
|
a20abc337b6f6396ae0d35e9c7fd309a7a50f70e
|
Publish changes to 0.2.1; add category filter
|
diff --git a/History.txt b/History.txt
new file mode 100644
index 0000000..457942a
--- /dev/null
+++ b/History.txt
@@ -0,0 +1,31 @@
+== 0.2.2 / 2009-4-5
+* [wrobbins] Add category filter to review search.
+
+== 0.2.1 / 2007-11-24
+
+* [shaper] fixed extra dependencies specified in Rakefile to allow for proper
+ gem installation.
+
+== 0.2.0 / 2007-11-24
+
+* [shaper] fixed validation of neighborhood yelp search url to reflect
+ yelp-side url fix removing '/' from immediately following '?'.
+
+* [shaper] fixed json result validation to accept new format v1.1 specifier.
+
+* [shaper] Incorporated category result narrowing for business review search,
+ thanks to Jerry Cheung for patch.
+
+* Updated neighborhood tests to reflect additional information in the yelp
+ response.
+
+== 0.1.1 / 2007-08-06
+
+* Moved to Rubyforge now that the yelp project exists.
+
+* Fixed Yelp::Request documentation to note the correct default response
+ format as Yelp::ResponseFormat::JSON_TO_RUBY.
+
+== 0.1.0 / 2007-08-05
+
+* Initial release.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..5ab7695
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/README b/README
new file mode 100644
index 0000000..41839c1
--- /dev/null
+++ b/README
@@ -0,0 +1,121 @@
+= yelp
+
+A Ruby object-oriented interface to the local business content available
+on Yelp at http://www.yelp.com. Functionality is provided to perform
+all searches available via the developer API including:
+
+* search for business reviews by geo-bounding-box, geo-point, or address/location.
+* search for a business review by business phone number.
+* search for a neighborhood by geo-point or address/location.
+
+More detailed information on the underlying Yelp API, error response codes, and so forth is available at http://www.yelp.com/developers/getting_started.
+
+The RubyForge project is hosted at http://rubyforge.org/projects/yelp. This documentation is available at http://yelp.rubyforge.org.
+
+== About
+
+Everybody loves Yelp! For those seeking burritos in the Mission District of
+San Francisco, it's easy to feel awash in a sea of taquerias with little to go
+on for decision-making other than whether the rice has peas in it (generally a
+negatory data point) or how long the line happens to be around lunchtime.
+
+Worry no longer! Yelp is here.
+
+Why should you use this library rather than writing directly to their API, or rolling your own? A few reasons that come to mind:
+
+* we've done a variety of mini-legwork from which you, Yelp and our fellow netizens will benefit, such as making sure we inform the Yelp server that we support gzipped data over the wire to save on bandwidth.
+* we have rudimentary tests, whereas your implementation doesn't (since you haven't even written it yet).
+* we return responses (by default, configurable) as JSON data converted into a Ruby hash and appropriate data types where applicable.
+* (subjective but we know we're right) -- we think our API is a nicer layer for Ruby developers to work with than the bare-bones REST API that Yelp provides.
+
+== Requirements
+
+You must have a Yelp Web Service ID (YWSID) available at http://www.yelp.com/developers/getting_started/api_access.
+
+You must conform to the Yelp Branding Requirements when making use of content
+retrieved via their API, documented at http://www.yelp.com/developers/getting_started/api_branding.
+
+For tests to execute successfully you must have the YWSID set in your
+environment via (shell-dependent, bash example provided):
+
+ % export YWSID='YOUR_ID_HERE'
+
+== Installing
+
+We recommend installing <tt>yelp</tt> via rubygems[http://rubyforge.org/projects/rubygems/] (see also http://www.rubygems.org).
+
+Once you have +rubygems+ installed on your system, you can easily install the <tt>yelp</tt> gem by executing:
+
+% gem install --include-dependencies yelp
+
+== Usage
+
+Instantiate a Yelp::Client and use its +search+ method to make requests of
+the Yelp server.
+
+The available search request types are:
+
+* Yelp::Review::Request::BoundingBox
+* Yelp::Review::Request::GeoPoint
+* Yelp::Review::Request::Location
+* Yelp::Phone::Request::Number
+* Yelp::Neighborhood::Request::GeoPoint
+* Yelp::Neighborhood::Request::Location
+
+By default, response content is formatted as a Ruby hash converted from Yelp's
+source JSON response content. Alternate response formats (including the
+original pure JSON) can be specified on request record construction via the
+Yelp::Request +response_format+ parameter, available in all request record
+types.
+
+A few examples:
+
+ # construct a client instance
+ client = Yelp::Client.new
+
+ # perform an address/location-based search for cream puffs nearby
+ request = Yelp::Review::Request::Location.new(
+ :address => '650 Mission St',
+ :city => 'San Francisco',
+ :state => 'CA',
+ :radius => 2,
+ :term => 'cream puffs',
+ :yws_id => 'YOUR_YWSID_HERE')
+ response = client.search(request)
+
+ # perform a neighborhood name lookup for a specific geo-location point
+ # narrow by categories
+ request = Yelp::Neighborhood::Request::GeoPoint.new(
+ :latitude => 37.782093,
+ :longitude => -122.483230,
+ :category => ['bbq','steak']
+ :yws_id => 'YOUR_YWSID_HERE')
+ response = client.search(request)
+
+ # perform a neighborhood name lookup for a specific geo-location point
+ request = Yelp::Neighborhood::Request::GeoPoint.new(
+ :latitude => 37.782093,
+ :longitude => -122.483230,
+ :yws_id => 'YOUR_YWSID_HERE')
+ response = client.search(request)
+
+ # perform a business review search based on a business phone number
+ request = Yelp::Phone::Request::Number.new(
+ :phone_number => '4155551212',
+ :yws_id => 'YOUR_YWSID_HERE')
+ response = client.search(request)
+
+
+If you want to convert some addresses to latitude/longitude, or vice
+versa, for testing or what have you -- try http://stevemorse.org/jcal/latlon.php.
+
+If you want to narrow results, use the :category key. Pass an array of categories.
+--see http://www.yelp.com/developers/documentation/category_list for a category list.
+
+== License
+
+This library is provided via the GNU LGPL license at http://www.gnu.org/licenses/lgpl.html.
+
+== Authors
+
+Copyright 2007, Walter Korman <shaper@wgks.org>, http://lemurware.blogspot.com
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..2695382
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,16 @@
+require 'rubygems'
+require 'hoe'
+$:.unshift(File.dirname(__FILE__) + "/lib")
+require 'yelp'
+
+Hoe.new('yelp', Yelp::VERSION) do |p|
+ p.rubyforge_name = 'yelp'
+ p.author = 'Walter Korman'
+ p.email = 'shaper@wgks.org'
+ p.extra_deps << [ 'json', '>= 1.1.1' ]
+ p.summary = 'An object-oriented interface to the Yelp Developer API.'
+ p.description = 'An object-oriented interface to the Yelp Developer API.'
+ p.url = 'http://rubyforge.org/projects/yelp'
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+ p.remote_rdoc_dir = '' # Release to root
+end
diff --git a/TODO.txt b/TODO.txt
new file mode 100644
index 0000000..5c24267
--- /dev/null
+++ b/TODO.txt
@@ -0,0 +1,6 @@
+* look into rails partials inability to properly enumerate the response
+ business records with the :collection param.
+* think about how to gracefully report errors
+* should we use "require 'json/add/rails'" for json for rails happiness?
+* use SAX-based XML parsing rather than DOM
+* consider supporting keep-alive for high volume requests
diff --git a/lib/yelp.rb b/lib/yelp.rb
new file mode 100644
index 0000000..7b32f24
--- /dev/null
+++ b/lib/yelp.rb
@@ -0,0 +1,16 @@
+require 'yelp/client'
+require 'yelp/record'
+require 'yelp/request'
+require 'yelp/response_format'
+require 'yelp/neighborhood/request/base'
+require 'yelp/neighborhood/request/geo_point'
+require 'yelp/neighborhood/request/location'
+require 'yelp/phone/request/number'
+require 'yelp/review/request/base'
+require 'yelp/review/request/bounding_box'
+require 'yelp/review/request/geo_point'
+require 'yelp/review/request/location'
+
+class Yelp
+ VERSION = '0.2.2'
+end
diff --git a/lib/yelp/client.rb b/lib/yelp/client.rb
new file mode 100644
index 0000000..98a922d
--- /dev/null
+++ b/lib/yelp/client.rb
@@ -0,0 +1,116 @@
+require 'cgi'
+require 'logger'
+require 'open-uri'
+require 'rubygems'
+require 'json'
+require 'yaml'
+require 'zlib'
+
+class Yelp
+ # Provides access to the Yelp search facilities as documented at:
+ #
+ # http://www.yelp.com/developers/documentation
+ #
+ # Example usage:
+ #
+ # client = Yelp::Client.new
+ # request = Yelp::Review::Request::Location.new(
+ # :address => '650 Mission St',
+ # :city => 'San Francisco',
+ # :state => 'CA',
+ # :radius => 2,
+ # :term => 'cream puffs',
+ # :yws_id => 'YOUR_YWSID_HERE')
+ # response = client.search(request)
+ #
+ # By default, response content is formatted as a Ruby hash converted from
+ # Yelp's source JSON response content. Alternate response formats can be
+ # specified on request record construction via the Yelp::Request
+ # +response_format+ parameter, available in all request record types.
+ #
+ class Client
+ # allows specifying the user agent string to submit with search requests
+ attr_accessor :agent
+
+ # whether debug mode is enabled for logging purposes, defaulting to false
+ attr_accessor :debug
+
+ # the Logger compatible object with which log messages are outputted,
+ # defaulting to output to STDOUT
+ attr_accessor :logger
+
+ # the default user agent submitted with search requests
+ DEFAULT_AGENT = 'yelp for Ruby (http://www.rubyforge.org/projects/yelp/)'
+
+ # Constructs a new client that uses the supplied YWSID for submitting
+ # search requests.
+ #
+ def initialize
+ @agent = DEFAULT_AGENT
+ @debug = false
+ @logger = nil
+ end
+
+ # Submits the supplied search request to Yelp and returns the response in
+ # the format specified by the request.
+ #
+ def search (request)
+ # build the full set of hash params with which the url is constructed
+ params = request.to_yelp_params
+
+ # construct the url with which we obtain results
+ url = build_url(request.base_url, params)
+ debug_msg "submitting search [url=#{url}, request=#{request.to_yaml}]."
+
+ # submit the http request for the results
+ http_params = { 'User-Agent' => @agent }
+ http_params['Accept-Encoding'] = 'gzip,deflate' if request.compress_response?
+ source = open(url, http_params)
+
+ # read the response content
+ content = (request.compress_response?) ? Zlib::GzipReader.new(source).read : source.read
+ debug_msg((request.response_format.serialized?) ? "received response [content_length=#{content.length}]." : "received response [content_length=#{content.length}, content=#{content}].")
+
+ # format the output as specified in the request
+ format_content(request.response_format, content)
+ end
+
+ def raw_search_url(request)
+ build_url(request.base_url,request.to_yelp_params)
+ end
+
+ protected
+
+ def format_content (response_format, content)
+ (response_format == Yelp::ResponseFormat::JSON_TO_RUBY) ? JSON.parse(content) : content
+ end
+
+ def debug_msg (message)
+ return if !@debug
+ @logger = Logger.new(STDOUT) if (!@logger)
+ @logger.debug message
+ end
+
+ def build_url (base_url, params)
+ url = base_url.clone
+ url << '?'
+ param_count = 0
+ params.each do |key, value|
+ next if value.nil?
+ url << '&' if (param_count > 0)
+
+ #Yelp allows requests to filter on multiple categories
+ #these are delimited by the plus '+' symbol in the request url
+ #CGI.escape will replace the '+' character so a check
+ #must be made here.
+ if (key == :category && params[:category].is_a?(Array))
+ url << "#{key}=#{params[key].join('+')}"
+ else
+ url << "#{key}=#{CGI.escape(params[key].to_s)}"
+ end
+ param_count += 1
+ end
+ url
+ end
+ end
+end
diff --git a/lib/yelp/neighborhood/request/base.rb b/lib/yelp/neighborhood/request/base.rb
new file mode 100644
index 0000000..1a4c690
--- /dev/null
+++ b/lib/yelp/neighborhood/request/base.rb
@@ -0,0 +1,13 @@
+require 'yelp/request'
+
+class Yelp
+ module Neighborhood
+ module Request
+ class Base < Yelp::Request
+ def base_url
+ 'http://api.yelp.com/neighborhood_search'
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/neighborhood/request/geo_point.rb b/lib/yelp/neighborhood/request/geo_point.rb
new file mode 100644
index 0000000..63c1344
--- /dev/null
+++ b/lib/yelp/neighborhood/request/geo_point.rb
@@ -0,0 +1,23 @@
+require 'yelp/neighborhood/request/base'
+
+class Yelp
+ module Neighborhood
+ module Request
+ # Describes a request to search for the name of a neighborhood at a
+ # specific geo-point location.
+ #
+ class GeoPoint < Yelp::Neighborhood::Request::Base
+ # latitude of geo-point for which a neighborhood name is desired
+ attr_reader :latitude
+
+ # longitude of geo-point for which a neighborhood name is desired
+ attr_reader :longitude
+
+ def to_yelp_params
+ super.merge(:lat => latitude,
+ :long => longitude)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/neighborhood/request/location.rb b/lib/yelp/neighborhood/request/location.rb
new file mode 100644
index 0000000..cf81469
--- /dev/null
+++ b/lib/yelp/neighborhood/request/location.rb
@@ -0,0 +1,53 @@
+require 'yelp/neighborhood/request/base'
+
+class Yelp
+ module Neighborhood
+ module Request
+ # Describes a request to search for a neighborhood name for a specific
+ # address/location. You do not need to specify all of the address
+ # attributes -- some subset of the core +address+, +city+,
+ # +state+ and +zipcode+ will suffice.
+ #
+ class Location < Yelp::Neighborhood::Request::Base
+ # the street address of the location sought
+ attr_reader :address
+
+ # the city of the location sought
+ attr_reader :city
+
+ # the state of the location sought
+ attr_reader :state
+
+ # the zipcode of the location sought
+ attr_reader :zipcode
+
+ def initialize (params)
+ # we explicitly initialize the location fields since we reference
+ # them later when building a full location string and we want
+ # to know they were initialized properly (and avoid warnings)
+ super({
+ :address => nil,
+ :city => nil,
+ :state => nil,
+ :zipcode => nil
+ }.merge(params))
+ end
+
+ def to_yelp_params
+ super.merge(:location => build_location_string)
+ end
+
+ protected
+
+ # Returns the Yelp-compatible concatenated string with the various
+ # possible bits of an address-oriented location.
+ #
+ def build_location_string
+ # per the Yelp documentation, the location string is to be built
+ # as some combination of "address, city, state, or zip".
+ [ @address, @city, @state, @zipcode ].compact.join(" ")
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/phone/request/number.rb b/lib/yelp/phone/request/number.rb
new file mode 100644
index 0000000..dc63889
--- /dev/null
+++ b/lib/yelp/phone/request/number.rb
@@ -0,0 +1,24 @@
+require 'yelp/request'
+
+class Yelp
+ module Phone
+ module Request
+ # Describes a request to search for a business review for the business
+ # associated with a specific phone number.
+ #
+ class Number < Yelp::Request
+ # the phone number of the business to search for, formatted as
+ # '1112223333'. Make sure you don't have any hyphens or parentheses.
+ attr_reader :phone_number
+
+ def base_url
+ 'http://api.yelp.com/phone_search'
+ end
+
+ def to_yelp_params
+ super.merge(:phone => phone_number)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/record.rb b/lib/yelp/record.rb
new file mode 100644
index 0000000..2186a6f
--- /dev/null
+++ b/lib/yelp/record.rb
@@ -0,0 +1,16 @@
+class Yelp
+ # General-purpose record that allows passing a hash with parameters
+ # to populate object attributes defined via methods like
+ # +attr_reader+ or +attr_accessor+.
+ #
+ class Record
+ def initialize (params)
+ if !params.nil?
+ params.each do |key, value|
+ name = key.to_s
+ instance_variable_set("@#{name}", value) if respond_to?(name)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/request.rb b/lib/yelp/request.rb
new file mode 100644
index 0000000..d4c3861
--- /dev/null
+++ b/lib/yelp/request.rb
@@ -0,0 +1,45 @@
+require 'yelp/record'
+
+class Yelp
+ class Request < Yelp::Record
+ # specifies whether the response content should be transmitted
+ # over the wire compressed, defaulting to true.
+ attr_reader :compress_response
+
+ # one of the Yelp::ResponseFormat format specifiers detailing the
+ # desired format of the search results, defaulting to
+ # Yelp::ResponseFormat::JSON_TO_RUBY.
+ attr_reader :response_format
+
+ # the Yelp Web Services ID to be passed with the request for
+ # authentication purposes. See http://www.yelp.com/developers/getting_started/api_access
+ # to get your own.
+ attr_reader :yws_id
+
+ alias :compress_response? :compress_response
+
+ def initialize (params)
+ default_params = {
+ :compress_response => true,
+ :response_format => Yelp::ResponseFormat::JSON_TO_RUBY
+ }
+ super(default_params.merge(params))
+ end
+
+ def to_yelp_params
+ params = {
+ :ywsid => yws_id
+ }
+
+ # if they specified anything other than a json variant, we
+ # need to tell yelp what we're looking for
+ case @response_format
+ when Yelp::ResponseFormat::PICKLE: params[:output] = 'pickle'
+ when Yelp::ResponseFormat::PHP: params[:output] = 'php'
+ end
+
+ params
+ end
+
+ end
+end
diff --git a/lib/yelp/response_format.rb b/lib/yelp/response_format.rb
new file mode 100644
index 0000000..9ec69fc
--- /dev/null
+++ b/lib/yelp/response_format.rb
@@ -0,0 +1,36 @@
+require 'yelp/record'
+
+class Yelp
+ # Describes the available response formats when querying the Yelp web
+ # service for results.
+ #
+ class ResponseFormat < Record
+ # the name of the response format
+ attr_reader :name
+
+ # whether this response format returns serialized data (and, so, data that
+ # we probably don't want to print to a log file and suchlike)
+ attr_reader :serialized
+
+ # the format specifier to retrieve results as straight JSON content
+ JSON = Yelp::ResponseFormat.new(:name => 'json')
+
+ # the format specifier to retrieve results as Ruby objects converted
+ # from the returned JSON content via the +json+ rubygem.
+ JSON_TO_RUBY = Yelp::ResponseFormat.new(:name => 'json_to_ruby')
+
+ # the format specifier to retrieve results as a serialized Python
+ # response. We're not quite sure why you'd want to use this if
+ # you're calling it from Ruby code, but we like to see completeness
+ # in an API.
+ PICKLE = Yelp::ResponseFormat.new(:name => 'pickle', :serialized => true)
+
+ # the format specifier to retrieve results as a serialized PHP
+ # response. We're not quite sure why you'd want to use this if
+ # you're calling it from Ruby code, but we like to see completeness
+ # in an API.
+ PHP = Yelp::ResponseFormat.new(:name => 'php', :serialized => true)
+
+ alias :serialized? :serialized
+ end
+end
diff --git a/lib/yelp/review/request/base.rb b/lib/yelp/review/request/base.rb
new file mode 100644
index 0000000..f4d509e
--- /dev/null
+++ b/lib/yelp/review/request/base.rb
@@ -0,0 +1,30 @@
+require 'yelp/request'
+
+class Yelp
+ module Review
+ module Request
+ class Base < Yelp::Request
+ # specifies the number of businesses to return in the result set.
+ # default is 10. minimum value is 1 and maximum value is 20.
+ attr_reader :business_count
+
+ # string representing the name of business or search term being
+ # requested.
+ attr_reader :term
+
+ # optionally narrow the results by a category
+ attr_reader :category
+
+ def base_url
+ 'http://api.yelp.com/business_review_search'
+ end
+
+ def to_yelp_params
+ super.merge(:term => term,
+ :num_biz_requested => business_count,
+ :category => category)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/review/request/bounding_box.rb b/lib/yelp/review/request/bounding_box.rb
new file mode 100644
index 0000000..25df664
--- /dev/null
+++ b/lib/yelp/review/request/bounding_box.rb
@@ -0,0 +1,37 @@
+require 'yelp/review/request/base'
+
+class Yelp
+ module Review
+ module Request
+ # Describes a request to search for business reviews for businesses
+ # within a geo-point-specific bounding box and radius around
+ # that box.
+ #
+ class BoundingBox < Yelp::Review::Request::Base
+ # bottom right latitude of bounding box
+ attr_reader :bottom_right_latitude
+
+ # bottom right longitude of bounding box
+ attr_reader :bottom_right_longitude
+
+ # radius to use while searching around specified geo-point.
+ # default value is 1, maximum value is 25.
+ attr_reader :radius
+
+ # top left latitude of bounding box
+ attr_reader :top_left_latitude
+
+ # top left longitude of bounding box
+ attr_reader :top_left_longitude
+
+ def to_yelp_params
+ super.merge(:tl_lat => top_left_latitude,
+ :tl_long => top_left_longitude,
+ :br_lat => bottom_right_latitude,
+ :br_long => bottom_right_longitude,
+ :radius => radius)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/review/request/geo_point.rb b/lib/yelp/review/request/geo_point.rb
new file mode 100644
index 0000000..176cb6f
--- /dev/null
+++ b/lib/yelp/review/request/geo_point.rb
@@ -0,0 +1,28 @@
+require 'yelp/review/request/base'
+
+class Yelp
+ module Review
+ module Request
+ # Describes a request to search for business reviews for businesses near
+ # a specific geo-point and radius around that point.
+ #
+ class GeoPoint < Yelp::Review::Request::Base
+ # latitude of geo-point to search near
+ attr_reader :latitude
+
+ # longitude of geo-point to search near
+ attr_reader :longitude
+
+ # radius to use while searching around specified geo-point.
+ # default value is 1, maximum value is 25.
+ attr_reader :radius
+
+ def to_yelp_params
+ super.merge(:lat => latitude,
+ :long => longitude,
+ :radius => radius)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/yelp/review/request/location.rb b/lib/yelp/review/request/location.rb
new file mode 100644
index 0000000..806e369
--- /dev/null
+++ b/lib/yelp/review/request/location.rb
@@ -0,0 +1,63 @@
+require 'yelp/review/request/base'
+
+class Yelp
+ module Review
+ module Request
+ # Describes a request to search for business reviews near a specific
+ # address/location. You do not need to specify all of the address
+ # attributes -- some subset of the core +address+, +city+,
+ # +neighborhood+, +state+ and +zipcode+ will suffice.
+ #
+ class Location < Yelp::Review::Request::Base
+ # the street address of the location sought
+ attr_reader :address
+
+ # the city of the location sought
+ attr_reader :city
+
+ # the neighborhood of the location sought
+ attr_reader :neighborhood
+
+ # radius to use while searching around specified geo-point.
+ # default value is 1, maximum value is 25.
+ attr_reader :radius
+
+ # the state of the location sought
+ attr_reader :state
+
+ # the zipcode of the location sought
+ attr_reader :zipcode
+
+ def initialize (params)
+ # we explicitly initialize the location fields since we reference
+ # them later when building a full location string and we want
+ # to know they were initialized properly (and avoid warnings)
+ super({
+ :address => nil,
+ :city => nil,
+ :neighborhood => nil,
+ :state => nil,
+ :zipcode => nil
+ }.merge(params))
+ end
+
+ def to_yelp_params
+ super.merge(:location => build_location_string,
+ :radius => radius)
+ end
+
+ protected
+
+ # Returns the Yelp-compatible concatenated string with the various
+ # possible bits of an address-oriented location.
+ #
+ def build_location_string
+ # per the Yelp documentation, the location string is to be built
+ # as some combination of "address, neighborhood, city, state, or
+ # zip".
+ [ @address, @neighborhood, @city, @state, @zipcode ].compact.join(" ")
+ end
+ end
+ end
+ end
+end
diff --git a/test/test_client.rb b/test/test_client.rb
new file mode 100644
index 0000000..39eed86
--- /dev/null
+++ b/test/test_client.rb
@@ -0,0 +1,11 @@
+require 'test/unit'
+require 'yelp'
+
+class TestClient < Test::Unit::TestCase
+ def test_validation
+ # make sure we can do basic client instantiation
+ assert_nothing_raised do
+ @client = Yelp::Client.new
+ end
+ end
+end
diff --git a/test/test_neighborhood_search.rb b/test/test_neighborhood_search.rb
new file mode 100644
index 0000000..0a3db84
--- /dev/null
+++ b/test/test_neighborhood_search.rb
@@ -0,0 +1,41 @@
+require 'pp'
+require 'rubygems'
+require 'test/unit'
+require 'yelp'
+require File.dirname(__FILE__) + '/yelp_helper'
+
+class TestNeighborhoodSearch < Test::Unit::TestCase
+ include YelpHelper
+
+ def setup
+ @client = Yelp::Client.new
+ @yws_id = ENV['YWSID']
+# @client.debug = true
+ end
+
+ GORDO_LAT = 37.782093
+ GORDO_LON = -122.483230
+ GORDO_NEIGHBORHOOD = { "city" => "San Francisco", "name" => "Outer Richmond", "url" => "http://yelp.com/search?find_loc=Outer+Richmond%2C+San+Francisco%2C+CA", "state" => "CA" }
+
+ def test_geo_point_search
+ request = Yelp::Neighborhood::Request::GeoPoint.new(:latitude => GORDO_LAT,
+ :longitude => GORDO_LON,
+ :yws_id => @yws_id)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ assert_equal response['neighborhoods'].first, GORDO_NEIGHBORHOOD
+ end
+
+ GORDO_ADDRESS = '2252 Clement Street'
+
+ def test_location_search
+ request = Yelp::Neighborhood::Request::Location.new(:address => GORDO_ADDRESS,
+ :city => 'San Francisco',
+ :state => 'CA',
+ :zipcode => 94121,
+ :yws_id => @yws_id)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ assert_equal response['neighborhoods'].first, GORDO_NEIGHBORHOOD
+ end
+end
diff --git a/test/test_phone_search.rb b/test/test_phone_search.rb
new file mode 100644
index 0000000..bef2f4a
--- /dev/null
+++ b/test/test_phone_search.rb
@@ -0,0 +1,23 @@
+require 'pp'
+require 'rubygems'
+require 'test/unit'
+require 'yelp'
+require File.dirname(__FILE__) + '/yelp_helper'
+
+class TestPhoneSearch < Test::Unit::TestCase
+ include YelpHelper
+
+ def setup
+ @client = Yelp::Client.new
+ @yws_id = ENV['YWSID']
+# @client.debug = true
+ end
+
+ GORDO_PHONE_NUMBER = '4155666011'
+
+ def test_phone_search
+ request = Yelp::Phone::Request::Number.new(:phone_number => GORDO_PHONE_NUMBER, :yws_id => @yws_id)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ end
+end
diff --git a/test/test_review_search.rb b/test/test_review_search.rb
new file mode 100644
index 0000000..8971277
--- /dev/null
+++ b/test/test_review_search.rb
@@ -0,0 +1,156 @@
+require 'pp'
+require 'rubygems'
+require 'test/unit'
+require 'yelp'
+require File.dirname(__FILE__) + '/yelp_helper'
+
+class TestReviewSearch < Test::Unit::TestCase
+ include YelpHelper
+
+ def setup
+ @client = Yelp::Client.new
+ @yws_id = ENV['YWSID']
+# @client.debug = true
+ end
+
+ def test_bounding_box
+ request = Yelp::Review::Request::BoundingBox.new(
+ :bottom_right_latitude => 37.788022,
+ :bottom_right_longitude => -122.399797,
+ :top_left_latitude => 37.9,
+ :top_left_longitude => -122.5,
+# :radius => 1,
+# :business_count => 3,
+ :term => 'yelp',
+ :yws_id => @yws_id)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ end
+
+ def test_geo_point
+ request = Yelp::Review::Request::GeoPoint.new(
+ :latitude => 37.78022,
+ :longitude => -122.399797,
+ :radius => 2,
+# :business_count => 5,
+ :term => 'yelp',
+ :yws_id => @yws_id)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ end
+
+ def test_location
+ request = Yelp::Review::Request::Location.new(
+ :address => '650 Mission St',
+ :city => 'San Francisco',
+ :state => 'CA',
+ :radius => 2,
+# :business_count => 5,
+ :term => 'cream puffs',
+ :yws_id => @yws_id)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ end
+
+ def test_category
+ # perform a basic search of businesses near SOMA
+ request = Yelp::Review::Request::GeoPoint.new(
+ :latitude => 37.78022,
+ :longitude => -122.399797,
+ :radius => 5,
+ :term => 'yelp',
+ :yws_id => @yws_id)
+ response = @client.search(request)
+
+ # perform the same search focusing only on playgrounds
+ narrowed_request = Yelp::Review::Request::GeoPoint.new(
+ :latitude => 37.78022,
+ :longitude => -122.399797,
+ :radius => 5,
+ :term => 'yelp',
+ :category => 'playgrounds',
+ :yws_id => @yws_id)
+ narrowed_response = @client.search(narrowed_request)
+ pp narrowed_response
+
+ # make sure we got less for the second
+ assert(response['businesses'].length > narrowed_response['businesses'].length)
+
+ #perform the same search focusing only on playgrounds and ice cream
+ more_narrowed_request = Yelp::Review::Request::GeoPoint.new(
+ :latitude => 37.78022,
+ :longitude => -122.399797,
+ :radius => 5,
+ :term => 'yelp',
+ :category => ['playgrounds','icecream'],
+ :yws_id => @yws_id)
+ more_narrowed_response = @client.search(more_narrowed_request)
+ #pp more_narrowed_response
+ for b in more_narrowed_response['businesses']
+ assert( has_category?(b,'icecream') || has_category?(b,'playgrounds') )
+ end
+
+ end
+
+
+ def test_json_response_format
+ request = basic_request(:response_format => Yelp::ResponseFormat::JSON)
+ response = @client.search(request)
+ validate_json_response(response)
+ end
+
+ def test_json_to_ruby_response_format
+ request = basic_request(:response_format => Yelp::ResponseFormat::JSON_TO_RUBY)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ end
+
+ def test_pickle_response_format
+ request = basic_request(:response_format => Yelp::ResponseFormat::PICKLE)
+ @client.search(request)
+ # TODO: validation
+ end
+
+ def test_php_response_format
+ request = basic_request(:response_format => Yelp::ResponseFormat::PHP)
+ response = @client.search(request)
+ # TODO: validation
+ end
+
+ def test_compressed_response
+ request = basic_request(:compress_response => true)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ end
+
+ def test_uncompressed_response
+ request = basic_request(:compress_response => false)
+ response = @client.search(request)
+ validate_json_to_ruby_response(response)
+ end
+
+ protected
+
+ def basic_request (params = nil)
+ default_params = {
+ :city => 'San Francisco',
+ :state => 'CA',
+ :term => 'gordo',
+ :yws_id => @yws_id
+ }
+ Yelp::Review::Request::Location.new(default_params.merge(params))
+ end
+
+ def has_category?(business,category_name)
+
+ all_categories = []
+ #categories is an array of hashes
+ for category in business['categories']
+ all_categories.push(category['category_filter'])
+ end
+
+ all_categories.include?(category_name)
+
+ end
+
+end
diff --git a/test/yelp_helper.rb b/test/yelp_helper.rb
new file mode 100644
index 0000000..8a59d57
--- /dev/null
+++ b/test/yelp_helper.rb
@@ -0,0 +1,35 @@
+module YelpHelper
+ def validate_json_response (response)
+ assert_not_nil response
+ assert_instance_of String, response
+ assert_match(/^\{"message": \{"text": "OK", "code": 0, "version": 1\.1\}, "(businesses|neighborhoods)": .*?\}$/, response)
+ end
+
+ def validate_json_to_ruby_response (response)
+ assert_not_nil response
+ assert_instance_of Hash, response
+ assert_not_nil response['message']
+ assert(response['message']['code'] == 0)
+ assert(response['message']['text'] == 'OK')
+ assert_not_nil((response['businesses'] || response['neighborhoods']))
+ if response['businesses']
+ response['businesses'].each { |b| validate_json_to_ruby_business(b) }
+ end
+ end
+
+ YELP_BIZ_ID_LENGTH = 22
+
+ def validate_json_to_ruby_business (business)
+ # rudimentary checks to make sure it looks like a typical yelp business
+ # result converted to a ruby hash
+ assert business['id'].length == YELP_BIZ_ID_LENGTH
+ assert_valid_url business['url']
+ end
+
+ # just a rudimentary check will serve us fine
+ VALID_URL_REGEXP = /^https?:\/\/[a-z0-9]/i
+
+ def assert_valid_url (url)
+ assert_match VALID_URL_REGEXP, url
+ end
+end
|
JustRelate/base64_url
|
09ccdfc581fcb7b7f590c08ab93f914a709a5819
|
Added copyright notice and beautified code
|
diff --git a/base64_url.rb b/base64_url.rb
index 895bc14..f949f0a 100644
--- a/base64_url.rb
+++ b/base64_url.rb
@@ -1,19 +1,33 @@
-require "base64"
+=begin
+Copyright (C) 2009 Infopark AG <http://www.infopark.com/>
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details <http://www.gnu.org/licenses/>.
+=end
+
+require 'base64'
module Base64
def url_encode64(text)
return nil unless text
Base64.encode64(text).gsub('=','').gsub('+','-').gsub('/','_').gsub("\n",'')
end
def url_decode64(text)
return nil unless text
raise ArgumentError, 'bad format: text contains "+" or "/".' if text.include?('+') or text.include?('/')
text = text.gsub('-','+').gsub('_','/').gsub("\n",'')
modulo = text.length % 4
padding = (modulo == 0) ? '' : '=' * (4 - modulo)
Base64.decode64(text + padding)
end
end
diff --git a/base64_url_spec.rb b/base64_url_spec.rb
index c30ca7c..76f35ff 100644
--- a/base64_url_spec.rb
+++ b/base64_url_spec.rb
@@ -1,71 +1,87 @@
-require "base64_url"
+=begin
+Copyright (C) 2009 Infopark AG <http://www.infopark.com/>
+
+Run this test via: spec base64_url_spec.rb
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details <http://www.gnu.org/licenses/>.
+=end
+
+require 'base64_url'
describe Base64 do
before do
- @base64_text = "UG9seWZvbiB6d2l0c2NoZXJuZCBhw59lbiBNw6R4Y2hlbnMgVsO2Z2VsIFLDvGJlbiwgSm9naHVydCB1bmQgUXVhcms"
- @plain_text = "Polyfon zwitschernd aÃen Mäxchens Vögel Rüben, Joghurt und Quark"
+ @base64_text = 'UG9seWZvbiB6d2l0c2NoZXJuZCBhw59lbiBNw6R4Y2hlbnMgVsO2Z2VsIFLDvGJlbiwgSm9naHVydCB1bmQgUXVhcms'
+ @plain_text = 'Polyfon zwitschernd aÃen Mäxchens Vögel Rüben, Joghurt und Quark'
end
- describe "when encoding" do
- it "should return url-safe base64" do
+ describe 'when encoding' do
+ it 'should return url-safe base64' do
url_encode64(@plain_text).should == @base64_text
end
- it "should not contain newlines" do
- url_encode64("x" * 100).should_not include("\n")
+ it 'should not contain newlines' do
+ url_encode64('x' * 100).should_not include("\n")
end
it "should substitute url-critical characters ({ '/' => '_', '+' => '-', '[\\n=]' => '')" do
url_encode64("#\360").should == 'I_A' # instead of "I/A=\n"
url_encode64("#\340").should == 'I-A' # instead of "I+A=\n"
end
- it "should return nil, if input is nil" do
+ it 'should return nil, if input is nil' do
url_encode64(nil).should be_nil
end
end
- describe "when decoding" do
- it "should return the original utf-8 string" do
+ describe 'when decoding' do
+ it 'should return the original utf-8 string' do
url_decode64(@base64_text).should == @plain_text
end
- it "should ignore newlines" do
- url_decode64("YWJjZA\n\n==\n").should == "abcd"
- url_decode64("aW5mb3Bh\ncms").should == "infopark"
+ it 'should ignore newlines' do
+ url_decode64("YWJjZA\n\n==\n").should == 'abcd'
+ url_decode64("aW5mb3Bh\ncms").should == 'infopark'
end
- it "should decode a url-safe base64 string" do
+ it 'should decode a url-safe base64 string' do
url_decode64('I_A').should == "#\360"
url_decode64('I-A').should == "#\340"
end
it "should accept input strings containing trailing '='" do
url_decode64('I-A=').should == "#\340"
url_decode64('I-A=======').should == "#\340"
end
it "should reject input strings containing '/' or '+'" do
lambda { url_decode64('abc+') }.should raise_error(ArgumentError, 'bad format: text contains "+" or "/".')
lambda { url_decode64('abc/') }.should raise_error(ArgumentError, 'bad format: text contains "+" or "/".')
end
- it "should return nil, if input is nil" do
+ it 'should return nil, if input is nil' do
url_decode64(nil).should be_nil
end
end
- it "decoding should be the inverse of encoding" do
+ it 'decoding should be the inverse of encoding' do
text = "Dies ist ein Beispieltext, mit einigen Sonderzeichen: äÃüÃöÃÃ^à á-+/"
url_decode64(url_encode64(text)).should == text
16.times do
bytes = ''
(rand(32) + 8).times { bytes << rand(256) }
encoded = url_encode64(bytes)
url_decode64(encoded).should == bytes
end
end
end
|
javierv/rails_templates
|
082f66f8f2e794d57184823bc1b7cfdb4de7e697
|
Refactor into methods, commenting with code.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index 0326c3f..f35ed1c 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,94 +1,129 @@
-gem 'devise'
-gem 'will_paginate', ">= 3.0.pre"
-gem 'paperclip'
-gem 'haml'
-gem 'compass'
-gem 'acts-as-taggable-on'
-gem 'validation_reflection'
-gem 'RedCloth'
-gem 'validates_date_time'
-gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
-gem 'meta_where'
-gem 'meta_search'
-gem 'tabletastic', ">= 0.2.0pre4"
-
-gem 'rails3-generators', :group => :development
-
-gem 'shoulda', :group => :test
-gem 'factory_girl_rails', :group => :test
-gem 'mocha', :group => :test
-gem 'capybara', :group => :test
-gem 'display_name'
-
-run "bundle install"
+def generate_application
+ install_gems
+ configure_generators
+ run_initializers
+ configure_sass
+ copy_templates
+ copy_layout
+ copy_helpers
+ copy_javascripts
+ remove_unneeded_files
+ configure_spanish_language
+ generate_readme
+ configure_git
+ first_commit
+end
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
-# Layout
-run "rm app/views/layouts/application.html.erb"
-file "app/views/layouts/application.html.haml", read_file("application.html.haml")
-
-# SASS
-run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
-run "rm -r app/stylesheets/"
-run "cp -R #{file_path("stylesheets")} app/"
-
-# Templates
-run "cp -R #{file_path("templates")} lib/"
-
-run "cp -R #{file_path("shared")} app/views/"
-run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
-file "public/javascripts/form.js", read_file("javascripts/form.js")
-# Gitignore
-run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
-
-# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
-run "rm .gitignore"
-file ".gitignore", read_file("gitignore")
-
-# Logo e Ãndice no necesitados
-run "rm public/images/rails.png"
-run "rm public/index.html"
-
-# Javascript
-generate :"jquery:install"
-
-# Traducciones
-run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
-
-run "rm config/initializers/inflections.rb"
-file "config/initializers/inflections.rb", read_file("inflections.rb")
-file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
+def install_gems
+ gem 'devise'
+ gem 'will_paginate', ">= 3.0.pre"
+ gem 'paperclip'
+ gem 'haml'
+ gem 'compass'
+ gem 'acts-as-taggable-on'
+ gem 'validation_reflection'
+ gem 'RedCloth'
+ gem 'validates_date_time'
+ gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
+ gem 'meta_where'
+ gem 'meta_search'
+ gem 'tabletastic', ">= 0.2.0pre4"
+ gem 'display_name'
+
+ install_development_gems
+ install_test_gems
+ run "bundle install"
+end
-run "cp #{file_path("helpers")}/* app/helpers/"
+def install_development_gems
+ gem 'rails3-generators', :group => :development
+end
-# Idioma de la aplicación
-application " config.time_zone = 'Madrid'"
-application " config.i18n.default_locale = :es"
+def install_test_gems
+ ['shoulda', 'factory_girl_rails', 'mocha', 'capybara'].each do |gem_name|
+ gem gem_name, :group => :test
+ end
+end
-# Generadores por defecto
-application " config.generators do |g|
+def configure_generators
+ application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
+end
+
+def run_initializers
+ generate :"jquery:install"
+ generate :"haml:install"
+ generate :"simple_form:install"
+end
+
+def configure_sass
+ run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
+ run "rm -r app/stylesheets/"
+ run "cp -R #{file_path("stylesheets")} app/"
+end
-# Inicializadores
-generate :"haml:install"
-generate :"simple_form:install"
+def copy_templates
+ run "cp -R #{file_path("templates")} lib/"
+ run "cp -R #{file_path("shared")} app/views/"
+end
+
+def copy_layout
+ run "rm app/views/layouts/application.html.erb"
+ file "app/views/layouts/application.html.haml", read_file("application.html.haml")
+end
+
+def copy_helpers
+ run "cp #{file_path("helpers")}/* app/helpers/"
+end
+
+def copy_javascripts
+ run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
+ file "public/javascripts/form.js", read_file("javascripts/form.js")
+end
+
+def remove_unneeded_files
+ run "rm public/images/rails.png"
+ run "rm public/index.html"
+end
+
+def configure_spanish_language
+ application " config.time_zone = 'Madrid'"
+ application " config.i18n.default_locale = :es"
+ run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
+ run "rm config/initializers/inflections.rb"
+ file "config/initializers/inflections.rb", read_file("inflections.rb")
+ file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
+end
+
+def generate_readme
+ run "echo TODO > README"
+end
+
+def configure_git
+ run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
+ run "rm .gitignore"
+ file ".gitignore", read_file("gitignore")
+end
+
+def first_commit
+ git :init
+ git :add => "."
+ git :commit => "-m 'Primer commit'"
+end
-# Commit
-run "echo TODO > README"
-git :init
-git :add => "."
-git :commit => "-m 'Primer commit'"
+generate_application
\ No newline at end of file
|
javierv/rails_templates
|
d754730ba7863a28813f63b5f470fbfa69ade6e2
|
Reorganize helpers, simplifying their generation.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index 500107c..0326c3f 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,95 +1,94 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
run "cp -R #{file_path("templates")} lib/"
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
generate :"jquery:install"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
-file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
-file "app/helpers/css_js_helper.rb", read_file("css_js_helper.rb")
+run "cp #{file_path("helpers")}/* app/helpers/"
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Inicializadores
generate :"haml:install"
generate :"simple_form:install"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/css_js_helper.rb b/lib/helpers/css_js_helper.rb
similarity index 100%
rename from lib/css_js_helper.rb
rename to lib/helpers/css_js_helper.rb
diff --git a/lib/layout_helper.rb b/lib/helpers/layout_helper.rb
similarity index 100%
rename from lib/layout_helper.rb
rename to lib/helpers/layout_helper.rb
|
javierv/rails_templates
|
5547e90ccf6fca67f5777ea07064791833a8f4ce
|
Move all templates into the same directory, simplifying their generation.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index 345cbcf..500107c 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,110 +1,95 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
-file "lib/templates/shoulda/model/model.rb",
- read_file("shoulda/model/model.rb")
-
-file "lib/templates/active_record/model/model.rb",
- read_file("active_record/model/model.rb")
-
-file "lib/templates/test_unit/scaffold/functional_test.rb",
- read_file("test_unit/scaffold/functional_test.rb")
-
-file "lib/templates/rails/scaffold_controller/controller.rb",
- read_file("rails/scaffold_controller/controller.rb")
-
-run "cp -R #{file_path("haml")} lib/templates/"
-
-file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
- read_file("simple_form/scaffold/_form.html.haml.erb")
+run "cp -R #{file_path("templates")} lib/"
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
generate :"jquery:install"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
file "app/helpers/css_js_helper.rb", read_file("css_js_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Inicializadores
generate :"haml:install"
generate :"simple_form:install"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/active_record/model/model.rb b/lib/templates/active_record/model/model.rb
similarity index 100%
rename from lib/active_record/model/model.rb
rename to lib/templates/active_record/model/model.rb
diff --git a/lib/haml/scaffold/edit.html.haml.erb b/lib/templates/haml/scaffold/edit.html.haml.erb
similarity index 100%
rename from lib/haml/scaffold/edit.html.haml.erb
rename to lib/templates/haml/scaffold/edit.html.haml.erb
diff --git a/lib/haml/scaffold/index.html.haml.erb b/lib/templates/haml/scaffold/index.html.haml.erb
similarity index 100%
rename from lib/haml/scaffold/index.html.haml.erb
rename to lib/templates/haml/scaffold/index.html.haml.erb
diff --git a/lib/haml/scaffold/new.html.haml.erb b/lib/templates/haml/scaffold/new.html.haml.erb
similarity index 100%
rename from lib/haml/scaffold/new.html.haml.erb
rename to lib/templates/haml/scaffold/new.html.haml.erb
diff --git a/lib/haml/scaffold/show.html.haml.erb b/lib/templates/haml/scaffold/show.html.haml.erb
similarity index 100%
rename from lib/haml/scaffold/show.html.haml.erb
rename to lib/templates/haml/scaffold/show.html.haml.erb
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/templates/rails/scaffold_controller/controller.rb
similarity index 100%
rename from lib/rails/scaffold_controller/controller.rb
rename to lib/templates/rails/scaffold_controller/controller.rb
diff --git a/lib/shoulda/model/model.rb b/lib/templates/shoulda/model/model.rb
similarity index 100%
rename from lib/shoulda/model/model.rb
rename to lib/templates/shoulda/model/model.rb
diff --git a/lib/simple_form/scaffold/_form.html.haml.erb b/lib/templates/simple_form/scaffold/_form.html.haml.erb
similarity index 100%
rename from lib/simple_form/scaffold/_form.html.haml.erb
rename to lib/templates/simple_form/scaffold/_form.html.haml.erb
diff --git a/lib/test_unit/scaffold/functional_test.rb b/lib/templates/test_unit/scaffold/functional_test.rb
similarity index 100%
rename from lib/test_unit/scaffold/functional_test.rb
rename to lib/templates/test_unit/scaffold/functional_test.rb
|
javierv/rails_templates
|
e624a87d40d74959f6381165878f32b983a2b14b
|
Initializers for HAML and simple_form.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index 4323821..345cbcf 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,106 +1,110 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
run "cp -R #{file_path("haml")} lib/templates/"
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
generate :"jquery:install"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
file "app/helpers/css_js_helper.rb", read_file("css_js_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
+# Inicializadores
+generate :"haml:install"
+generate :"simple_form:install"
+
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
512bc31bcd917300bf038ad407737b26e062ecfc
|
Simplificación de cómo obtener jQuery.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index dbd9fe4..4323821 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,107 +1,106 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
run "cp -R #{file_path("haml")} lib/templates/"
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
-run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
-run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
+generate :"jquery:install"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
file "app/helpers/css_js_helper.rb", read_file("css_js_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
52407d9e19dace5a8de5f4b818a3656c3e1f6571
|
Simplifications assuming we use HTML 5.
|
diff --git a/lib/application.html.haml b/lib/application.html.haml
index 06c4db3..61fa9ec 100644
--- a/lib/application.html.haml
+++ b/lib/application.html.haml
@@ -1,19 +1,19 @@
-!!! Strict
+!!!
%html{html_attrs(I18n.locale)}
%head
%title= h(yield(:title) || "Untitled")
- %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}
+ %meta{:charset => "utf-8"}
= stylesheet_link_tag 'application'
= javascript_include_tag 'jquery', 'rails'
= csrf_meta_tag
= yield(:head)
%body
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_\#{name}"
- if show_title?
%h1= yield(:title)
= yield
\ No newline at end of file
|
javierv/rails_templates
|
e08fc28c41adee8008ff8eafd81e5e652556c4e2
|
Use helpers instead of elements for including CSS and JS files.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index 1019681..dbd9fe4 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,106 +1,107 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
run "cp -R #{file_path("haml")} lib/templates/"
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
+file "app/helpers/css_js_helper.rb", read_file("css_js_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/css_js_helper.rb b/lib/css_js_helper.rb
new file mode 100644
index 0000000..052fa5b
--- /dev/null
+++ b/lib/css_js_helper.rb
@@ -0,0 +1,13 @@
+module CssJsHelper
+ def js_form
+ markitup
+ css 'form'
+ javascript 'form'
+ end
+
+ def markitup
+ css '/javascripts/markitup/skins/simple/style.css',
+ '/javascripts/markitup/sets/textile/style.css'
+ javascript 'markitup/jquery.markitup', 'markitup/sets/textile/set'
+ end
+end
\ No newline at end of file
diff --git a/lib/shared/_js_form.html.haml b/lib/shared/_js_form.html.haml
deleted file mode 100644
index d8d75f3..0000000
--- a/lib/shared/_js_form.html.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-- render 'shared/markitup'
-- css 'form'
-- javascript 'form'
\ No newline at end of file
diff --git a/lib/shared/_markitup.html.haml b/lib/shared/_markitup.html.haml
deleted file mode 100644
index c83d005..0000000
--- a/lib/shared/_markitup.html.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-- css '/javascripts/markitup/skins/simple/style.css',
- '/javascripts/markitup/sets/textile/style.css'
-- javascript 'markitup/jquery.markitup', 'markitup/sets/textile/set'
\ No newline at end of file
diff --git a/lib/simple_form/scaffold/_form.html.haml.erb b/lib/simple_form/scaffold/_form.html.haml.erb
index 6d4beaa..310a8f3 100644
--- a/lib/simple_form/scaffold/_form.html.haml.erb
+++ b/lib/simple_form/scaffold/_form.html.haml.erb
@@ -1,12 +1,12 @@
-- render 'shared/js_form'
+- js_form
= simple_form_for @<%= file_name %> do |form|
= render 'shared/errors', :record => @<%= file_name %>
<%- for attribute in attributes -%>
= form.input :<%= attribute.name %>, :label => '<%= attribute.name.titleize %>'
<%- end -%>
.actions
= form.button :submit
\ No newline at end of file
|
javierv/rails_templates
|
6712934695ed837f3d961405b06f68c0a51cee79
|
Permitimos que las descripciones de los tests tengan acentos.
|
diff --git a/lib/shoulda/model/model.rb b/lib/shoulda/model/model.rb
index 0d3b953..b2027f9 100644
--- a/lib/shoulda/model/model.rb
+++ b/lib/shoulda/model/model.rb
@@ -1,8 +1,10 @@
+# encoding: utf-8
+
require 'test_helper'
class <%= class_name %>Test < ActiveSupport::TestCase
<%- for attribute in attributes -%>
should validate_presence_of(:<%= attribute.name %>)
should allow_mass_assignment_of(:<%= attribute.name %>)
<%- end -%>
end
\ No newline at end of file
diff --git a/lib/test_unit/scaffold/functional_test.rb b/lib/test_unit/scaffold/functional_test.rb
index e04c137..038680a 100644
--- a/lib/test_unit/scaffold/functional_test.rb
+++ b/lib/test_unit/scaffold/functional_test.rb
@@ -1,97 +1,99 @@
+# encoding: utf-8
+
require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
tests <%= controller_class_name %>Controller
setup do
@<%= singular_name %> = Factory(:<%= singular_name %>)
end
context "index action" do
setup do
get :index
end
should respond_with(:success)
should assign_to(:<%= plural_name %>)
end
context "new action" do
setup do
get :new
end
should render_template :new
end
context "create action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
post :create
end
should render_template :new
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
post :create
end
should redirect_to('') {<%= singular_name %>_path(assigns(:<%= singular_name %>))}
end
end
context "show action" do
setup do
get :show, :id => @<%= singular_name %>.to_param
end
should respond_with(:success)
end
context "edit action" do
setup do
get :edit, :id => @<%= singular_name %>.to_param
end
should render_template 'edit'
end
context "update action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should render_template :edit
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should redirect_to('') {<%= singular_name %>_path(@<%= singular_name %>)}
end
end
context "destroy action" do
setup do
delete :destroy, :id => @<%= singular_name %>.to_param
end
should redirect_to('index') { <%= plural_name %>_path }
should set_the_flash
should "destroy model" do
assert !<%= class_name %>.exists?(@<%= singular_name %>.id)
end
end
end
|
javierv/rails_templates
|
96a80a6fac169aad77451491ac94f2e0a9b14485
|
An image was missing.
|
diff --git a/lib/javascripts/markitup/skins/simple/images/bg-container.png b/lib/javascripts/markitup/skins/simple/images/bg-container.png
new file mode 100644
index 0000000..a28e018
Binary files /dev/null and b/lib/javascripts/markitup/skins/simple/images/bg-container.png differ
|
javierv/rails_templates
|
8f5efd3249103cace710fe2a33e0730b93767410
|
Fix indentation.
|
diff --git a/lib/shoulda/model/model.rb b/lib/shoulda/model/model.rb
index 6c61e30..0d3b953 100644
--- a/lib/shoulda/model/model.rb
+++ b/lib/shoulda/model/model.rb
@@ -1,8 +1,8 @@
require 'test_helper'
class <%= class_name %>Test < ActiveSupport::TestCase
<%- for attribute in attributes -%>
- should validate_presence_of(:<%= attribute.name %>)
- should allow_mass_assignment_of(:<%= attribute.name %>)
+ should validate_presence_of(:<%= attribute.name %>)
+ should allow_mass_assignment_of(:<%= attribute.name %>)
<%- end -%>
end
\ No newline at end of file
|
javierv/rails_templates
|
d35c08a958153b084f05b6dd6955462153235f7d
|
My fork is now on github.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index 2c416a5..1019681 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,106 +1,106 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
-gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
+gem 'simple_form', :git => 'git://github.com/javierv/simple_form.git'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
run "cp -R #{file_path("haml")} lib/templates/"
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
6b6c72cbd65714a9a70bb1c9d2c487db3e564e92
|
Parece que las variables de @content_for ya no se usan.
|
diff --git a/lib/layout_helper.rb b/lib/layout_helper.rb
index c49c2f3..642fc82 100644
--- a/lib/layout_helper.rb
+++ b/lib/layout_helper.rb
@@ -1,34 +1,34 @@
module LayoutHelper
def title(page_title, show_title = true)
- @content_for_title = page_title.to_s
+ content_for(:title) { page_title.to_s }
@show_title = show_title
end
def show_title?
@show_title
end
def stylesheet(*args)
@stylesheets ||= []
args.each do |stylesheet|
if !@stylesheets.include?(stylesheet)
content_for(:head) { stylesheet_link_tag(stylesheet) }
@stylesheets << stylesheet
end
end
end
def css(*args)
stylesheet *args
end
def javascript(*args)
@javascripts ||= []
args.each do |javascript|
if !@javascripts.include?(javascript)
content_for(:head) { javascript_include_tag(javascript) }
@javascripts << javascript
end
end
end
end
\ No newline at end of file
|
javierv/rails_templates
|
211d403279fda45b7e90b68a8e28a1cfb71d89c4
|
Fuera el template antiguo, y renovamos el nuevo.
|
diff --git a/lib/app_template.rb b/lib/app_template.rb
index a8fc471..2c416a5 100644
--- a/lib/app_template.rb
+++ b/lib/app_template.rb
@@ -1,252 +1,106 @@
-#Gems
-gem "inherited_resources"
-gem "acts-as-taggable-on"
-gem "will_paginate"
-gem "searchlogic"
-gem "formtastic"
-gem "validation_reflection"
-gem "paperclip"
-gem "RedCloth", :lib => "redcloth"
-gem "haml"
-gem "compass"
-# gem "compass-susy-plugin", :lib => 'susy'
-gem "shoulda"
-gem "webrat"
-gem "factory_girl"
-gem "mocha"
-
-rake "gems:install", :sudo => true
-
-# Layout + HAML + SASS
-run "haml --rails ."
-run "script/generate nifty_layout --haml"
-run "rm app/views/layouts/application.html.haml"
-file "app/views/layouts/application.html.haml", <<-HAML
-!!! Strict
-%html{html_attrs(I18n.locale)}
-
- %head
- %title= h(yield(:title) || "Untitled")
- %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}
- = stylesheet_link_tag 'application'
- = javascript_tag "var AUTH_TOKEN = \#{form_authenticity_token.inspect};" if protect_against_forgery?
- = javascript_include_tag "jquery", "application"
- = yield(:head)
-
- %body
- - flash.each do |name, msg|
- = content_tag :div, msg, :id => "flash_\#{name}"
-
- - if show_title?
- %h1=h yield(:title)
-
- = yield
-HAML
-run "rm -r public/stylesheets/sass"
-run "compass --rails --sass-dir app/stylesheets --css-dir public/stylesheets ."
-run "rm app/stylesheets/*.sass"
-run "mkdir app/stylesheets/partials"
-
-file "app/stylesheets/partials/_base.sass", <<-CSS
-# @import susy/susy.sass # TODO: descomentar cuando SUSY deje de estar roto (se rompió con el cambio a gemcutter).
-!extension = ""
-
-=font-face(!font,!filename, !type = "opentype")
- font-family: \#{!font}
- src: url("fonts/\#{!filename}.eot")
- @if !type == "opentype"
- !extension = "otf"
- @else
- !extension = "ttf"
-
- src: local("\#{!font} Regular"), local("\#{!font}-Regular"), local("\#{!font}"), url("fonts/\#{!filename}.\#{!extension}") format("\#{!type}")
-CSS
-file "app/stylesheets/application.sass", <<-CSS
-@import partials/base.sass
-@import form.sass
-
-*
- padding: 0
- margin: 0
- font-family: helvetica, arial, verdana, sans-serif
- font-size: 1em
-
-html
- background-color: #4b7399
-
-body
- padding: 0.5em 1%
- margin: 1em auto
- font-size: 0.85em
- width: 80em
- max-width: 98%
- border: solid 1px black
- background-color: #fdfdfd
- color: #333
-
-
-a img
- border: none
-
-#flash_notice,
-#flash_error
- padding: 5px 8px
- margin: 10px 0
-
-#flash_notice
- background-color: #CFC
- border: 1px solid #6C6
-
-#flash_error
- background-color: #FCC
- border: solid 1px #C66
-
-.fieldWithErrors
- display: inline
-CSS
-
-# Formtastic
-generate :formtastic
-run "rm public/stylesheets/*.css"
-run "wget -O app/stylesheets/partials/_formtastic_base.sass http://github.com/activestylus/formtastic-sass/raw/master/_formtastic_base.sass"
-file "app/stylesheets/form.sass", <<-CSS
-@import partials/formtastic_base.sass
-.formtastic
- +float-form
-CSS
-
-# Base de datos
-app_name = `pwd`.split('/').last.strip
-
-run "rm config/database.yml"
-file "config/database.yml", <<-FILE
-development:
- adapter: mysql
- database: #{app_name}_development
- encoding: utf8
-
-test:
- adapter: mysql
- database: #{app_name}_test
- encoding: utf8
-
-production:
- username: root
- password: password
- adapter: mysql
- database: #{app_name}_production
- pool: 5
- encoding: utf8
-FILE
-rake "db:create:all"
-run "cp config/database.yml config/example_database.yml"
-
-#Git ignore
-file ".gitignore", <<-END
-log/*.log
-nbproject/private/*
-nbproject/*
-coverage/*
-tmp/**/*
-tmp/*.html
-public/stylesheets/*.css
-config/database.yml
-.DS_Store
-webrat-*.html
-db/*.sqlite3
-END
+gem 'devise'
+gem 'will_paginate', ">= 3.0.pre"
+gem 'paperclip'
+gem 'haml'
+gem 'compass'
+gem 'acts-as-taggable-on'
+gem 'validation_reflection'
+gem 'RedCloth'
+gem 'validates_date_time'
+gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
+gem 'meta_where'
+gem 'meta_search'
+gem 'tabletastic', ">= 0.2.0pre4"
+
+gem 'rails3-generators', :group => :development
+
+gem 'shoulda', :group => :test
+gem 'factory_girl_rails', :group => :test
+gem 'mocha', :group => :test
+gem 'capybara', :group => :test
+gem 'display_name'
+
+run "bundle install"
+
+def read_file(file)
+ File.read(File.expand_path(file_path(file)))
+end
+
+def file_path(file)
+ File.join(File.dirname(__FILE__), file)
+end
+
+# Layout
+run "rm app/views/layouts/application.html.erb"
+file "app/views/layouts/application.html.haml", read_file("application.html.haml")
+
+# SASS
+run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
+run "rm -r app/stylesheets/"
+run "cp -R #{file_path("stylesheets")} app/"
+
+# Templates
+file "lib/templates/shoulda/model/model.rb",
+ read_file("shoulda/model/model.rb")
+
+file "lib/templates/active_record/model/model.rb",
+ read_file("active_record/model/model.rb")
+
+file "lib/templates/test_unit/scaffold/functional_test.rb",
+ read_file("test_unit/scaffold/functional_test.rb")
+
+file "lib/templates/rails/scaffold_controller/controller.rb",
+ read_file("rails/scaffold_controller/controller.rb")
+
+run "cp -R #{file_path("haml")} lib/templates/"
+
+file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
+ read_file("simple_form/scaffold/_form.html.haml.erb")
+
+run "cp -R #{file_path("shared")} app/views/"
+run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
+file "public/javascripts/form.js", read_file("javascripts/form.js")
+# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
-# Imágenes y Javascript
+# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
+run "rm .gitignore"
+file ".gitignore", read_file("gitignore")
+
+# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
-run "rm -f public/javascripts/*"
-run "wget -O public/javascripts/jquery.js http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"
-file "public/javascripts/application.js", <<-JS
-$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
- while(x<c.length){var m=r.exec(c.substr(x));
- if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
- }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
- o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;},
-URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;
- while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
- t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}
-});
-
-$(document).ajaxSend(function(event, request, settings) {
- if (typeof(AUTH_TOKEN) == "undefined") return;
- if (settings.type == 'GET' || settings.type == 'get') return;
- settings.data = settings.data || "";
- settings.data += (settings.data ? "&" : "") + "authenticity_token=" + $.URLEncode(AUTH_TOKEN);
- request.setRequestHeader("Content-Type", settings.contentType);
-});
-
-$(document).ready( function()
-{
- // Sustituye al método de confirmar borrado que hace Prototype por defecto en
- // el scaffold de Rails
- function confirm_destroy(action)
- {
- if (confirm('Are you sure?'))
- {
- $form = $('<form></form>')
- .attr('method', 'post')
- .attr('action', action)
- .append( $('<input />')
- .attr('type', 'hidden')
- .attr('name', '_method')
- .val('delete')
- )
- .append( $('<input />')
- .attr('type', 'hidden')
- .attr('name', 'authenticity_token')
- .val(AUTH_TOKEN)
- )
- .appendTo('body')
- .submit();
- }
-
- }
-
- $('a.destroy').click( function()
- {
- confirm_destroy(this.href.replace("/confirm_destroy", ""));
- return false;
- });
-});
-JS
+run "rm public/index.html"
+
+# Javascript
+run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
+run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
-file "config/initializers/inflections.rb", <<-PLURALES
-ActiveSupport::Inflector.inflections do |inflect|
- inflect.plural /([^aeiouáéó])$/i, '\\1es'
- inflect.singular /(.*)es$/i, '\\1'
-
- inflect.plural /(.*)z$/i, '\\1ces'
- inflect.singular /(.*)ces$/i, '\\1z'
-
- vocales = {'a' => 'á', 'e' => 'é', 'i' => 'Ã', 'o' => 'ó', 'u' => 'ú'}
- vocales.each do |vocal_sin_acento, vocal_con_acento|
- ['n', 's'].each do |consonante|
- final_singular = vocal_con_acento + consonante
- final_plural = vocal_sin_acento + consonante + 'es'
- inflect.plural /(.*)\#{final_singular}$/i, '\\1' + final_plural
- #La siguiente lÃnea la comento porque los nombres de tablas no tienen acentos
- #inflect.singular /(.*)\#{final_plural}$/i, '\\1' + final_singular
- end
- end
-
- inflect.irregular 'post', 'posts'
- inflect.irregular 'tagging', 'taggings'
- inflect.irregular 'tag', 'tags'
- inflect.irregular 'session', 'sessions'
- inflect.irregular 'job', 'jobs'
-# inflect.uncountable %w( fish sheep )
-end
-PLURALES
+
+run "rm config/initializers/inflections.rb"
+file "config/initializers/inflections.rb", read_file("inflections.rb")
+file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
+
+file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
+
+# Idioma de la aplicación
+application " config.time_zone = 'Madrid'"
+application " config.i18n.default_locale = :es"
+
+# Generadores por defecto
+application " config.generators do |g|
+ g.stylesheets false
+ g.helper false
+ g.template_engine :haml
+ g.test_framework :shoulda
+ g.fixture_replacement :factory_girl
+ g.form_builder :simple_form
+ g.fallbacks[:shoulda] = :test_unit
+ end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
deleted file mode 100644
index 2c416a5..0000000
--- a/lib/app_template_3.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-gem 'devise'
-gem 'will_paginate', ">= 3.0.pre"
-gem 'paperclip'
-gem 'haml'
-gem 'compass'
-gem 'acts-as-taggable-on'
-gem 'validation_reflection'
-gem 'RedCloth'
-gem 'validates_date_time'
-gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
-gem 'meta_where'
-gem 'meta_search'
-gem 'tabletastic', ">= 0.2.0pre4"
-
-gem 'rails3-generators', :group => :development
-
-gem 'shoulda', :group => :test
-gem 'factory_girl_rails', :group => :test
-gem 'mocha', :group => :test
-gem 'capybara', :group => :test
-gem 'display_name'
-
-run "bundle install"
-
-def read_file(file)
- File.read(File.expand_path(file_path(file)))
-end
-
-def file_path(file)
- File.join(File.dirname(__FILE__), file)
-end
-
-# Layout
-run "rm app/views/layouts/application.html.erb"
-file "app/views/layouts/application.html.haml", read_file("application.html.haml")
-
-# SASS
-run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
-run "rm -r app/stylesheets/"
-run "cp -R #{file_path("stylesheets")} app/"
-
-# Templates
-file "lib/templates/shoulda/model/model.rb",
- read_file("shoulda/model/model.rb")
-
-file "lib/templates/active_record/model/model.rb",
- read_file("active_record/model/model.rb")
-
-file "lib/templates/test_unit/scaffold/functional_test.rb",
- read_file("test_unit/scaffold/functional_test.rb")
-
-file "lib/templates/rails/scaffold_controller/controller.rb",
- read_file("rails/scaffold_controller/controller.rb")
-
-run "cp -R #{file_path("haml")} lib/templates/"
-
-file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
- read_file("simple_form/scaffold/_form.html.haml.erb")
-
-run "cp -R #{file_path("shared")} app/views/"
-run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
-file "public/javascripts/form.js", read_file("javascripts/form.js")
-# Gitignore
-run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
-
-# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
-run "rm .gitignore"
-file ".gitignore", read_file("gitignore")
-
-# Logo e Ãndice no necesitados
-run "rm public/images/rails.png"
-run "rm public/index.html"
-
-# Javascript
-run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
-run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
-
-# Traducciones
-run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
-
-run "rm config/initializers/inflections.rb"
-file "config/initializers/inflections.rb", read_file("inflections.rb")
-file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
-
-file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
-
-# Idioma de la aplicación
-application " config.time_zone = 'Madrid'"
-application " config.i18n.default_locale = :es"
-
-# Generadores por defecto
-application " config.generators do |g|
- g.stylesheets false
- g.helper false
- g.template_engine :haml
- g.test_framework :shoulda
- g.fixture_replacement :factory_girl
- g.form_builder :simple_form
- g.fallbacks[:shoulda] = :test_unit
- end"
-
-# Commit
-run "echo TODO > README"
-git :init
-git :add => "."
-git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
d60ef308758c05d9b1e287806c8ee98b7049ee59
|
Incluimos el método "title" en todas las páginas del scaffold.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 7d63f23..2c416a5 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,107 +1,106 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
-file "lib/templates/haml/scaffold/index.html.haml.erb",
- read_file("haml/scaffold/index.html.haml.erb")
+run "cp -R #{file_path("haml")} lib/templates/"
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/haml/scaffold/edit.html.haml.erb b/lib/haml/scaffold/edit.html.haml.erb
new file mode 100644
index 0000000..8e96003
--- /dev/null
+++ b/lib/haml/scaffold/edit.html.haml.erb
@@ -0,0 +1,7 @@
+- title "Editando <%= singular_name %> #{@<%= singular_name %>}"
+
+= render 'form'
+
+= link_to 'Show', @<%= singular_name %>
+\|
+= link_to 'Back', <%= plural_name %>_path
\ No newline at end of file
diff --git a/lib/haml/scaffold/new.html.haml.erb b/lib/haml/scaffold/new.html.haml.erb
new file mode 100644
index 0000000..27cf4d8
--- /dev/null
+++ b/lib/haml/scaffold/new.html.haml.erb
@@ -0,0 +1,5 @@
+- title "New <%= singular_name %>"
+
+= render 'form'
+
+= link_to 'Back', <%= plural_name %>_path
\ No newline at end of file
diff --git a/lib/haml/scaffold/show.html.haml.erb b/lib/haml/scaffold/show.html.haml.erb
new file mode 100644
index 0000000..df7d02a
--- /dev/null
+++ b/lib/haml/scaffold/show.html.haml.erb
@@ -0,0 +1,11 @@
+- title @<%= singular_name %>
+
+<% for attribute in attributes -%>
+%p
+ %b <%= attribute.human_name %>:
+ = @<%= singular_name %>.<%= attribute.name %>
+<% end -%>
+
+= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>)
+\|
+= link_to 'Back', <%= plural_name %>_path
\ No newline at end of file
|
javierv/rails_templates
|
6791c18848cb8d3c0f48329a44a7d015f7c631c1
|
Por defecto, incluimos el primer atributo especificado como display_name.
|
diff --git a/lib/active_record/model/model.rb b/lib/active_record/model/model.rb
index e6f3d14..ee4c7a2 100644
--- a/lib/active_record/model/model.rb
+++ b/lib/active_record/model/model.rb
@@ -1,6 +1,7 @@
class <%= class_name %> < ActiveRecord::Base
attr_accessible <%= attributes.map { |a| ":#{a.name}" }.join(", ") %>
<%- for attribute in attributes -%>
validates :<%= attribute.name %>, :presence => true
<%- end -%>
+ display_name :<%= attributes.first.name %>
end
\ No newline at end of file
|
javierv/rails_templates
|
baeea0e3b2e0d9ea24696bf5116fa25f553967a5
|
Incluimos display name, que es mi primer proyecto propio.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index ac54d6e..7d63f23 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,106 +1,107 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
+gem 'display_name'
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
2df1820a28d6cfcfd2ecf66ca68a7ee31dd2440c
|
Corrección: este fichero no existe.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 1417462..ac54d6e 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,108 +1,106 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm -r app/stylesheets/"
run "cp -R #{file_path("stylesheets")} app/"
-file "app/stylesheets/application.sass", read_file("application.sass")
-
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
c648ced5e7ba3178d1b24c3e9c97d742f16719eb
|
Estilo muy básico para formularios.
|
diff --git a/lib/shared/_js_form.html.haml b/lib/shared/_js_form.html.haml
index 79220cc..d8d75f3 100644
--- a/lib/shared/_js_form.html.haml
+++ b/lib/shared/_js_form.html.haml
@@ -1,2 +1,3 @@
- render 'shared/markitup'
+- css 'form'
- javascript 'form'
\ No newline at end of file
diff --git a/lib/stylesheets/form.sass b/lib/stylesheets/form.sass
new file mode 100644
index 0000000..fbb5992
--- /dev/null
+++ b/lib/stylesheets/form.sass
@@ -0,0 +1,24 @@
+form
+ div.input
+ margin-top: 1em
+
+ input, textarea
+ width: 40em
+ max-width: 95%
+
+ .markItUp
+ width: 40em
+ max-width: 95%
+
+ textarea
+ width: 100%
+ max-width: none
+
+ div.actions
+ margin-top: 0.5em
+
+ label
+ display: block
+
+ abbr
+ border: none
\ No newline at end of file
|
javierv/rails_templates
|
bc0008a452dd38c4a77a645d7aa9f5eae999ab4c
|
padding más adecuado a nuestro estilo.
|
diff --git a/lib/javascripts/markitup/skins/simple/style.css b/lib/javascripts/markitup/skins/simple/style.css
index 5a87750..403e0fe 100644
--- a/lib/javascripts/markitup/skins/simple/style.css
+++ b/lib/javascripts/markitup/skins/simple/style.css
@@ -1,88 +1,88 @@
.markItUp
{
border: 5px solid #F5F5F5;
}
.markItUpContainer
{
background: #f0f0f0 url(images/bg-container.png) repeat-x scroll left top;
border: 1px solid #3c769d;
- padding: 5px;
+ padding: 0.3em 1em;
}
.markItUpEditor
{
height: 320px;
clear: both;
display: block;
line-height:18px;
overflow: auto;
}
.markItUpPreviewFrame
{
overflow: auto;
background-color: #fff;
width: 99.9%;
height: 300px;
margin: 5px 0;
}
.markItUpFooter
{
width: 100%;
}
.markItUpResizeHandle
{
overflow: hidden;
width: 22px;
height: 5px;
margin-left: auto;
margin-right: auto;
background-image: url(images/handle.png);
cursor: n-resize;
}
/***************************************************************************************/
/* first row of buttons */
.markItUpHeader ul li
{
list-style: none;
float: left;
position: relative;
}
.markItUpHeader ul li:hover > ul
{
display: block;
}
.markItUpHeader ul .markItUpDropMenu
{
background: transparent url(images/menu.png) no-repeat 115% 50%;
margin-right: 5px;
}
.markItUpHeader ul .markItUpDropMenu li
{
margin-right: 0px;
}
.markItUpHeader ul .markItUpSeparator
{
margin: 0 10px;
width: 1px;
height: 16px;
overflow: hidden;
background-color: #ccc;
}
.markItUpHeader ul span
{
display: block;
width: 16px;
height: 16px;
text-indent: -10000px;
background-repeat: no-repeat;
padding: 3px;
margin: 0px;
}
.markItUpHeader ul span:hover
{
cursor: pointer;
}
|
javierv/rails_templates
|
2a729a2b90553d3b6e6e1f5ba89bb843cd4b77cb
|
Ponemos todas las hojas de estilo en un único sitio, y las copiamos todas.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index f54657d..1417462 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,108 +1,108 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
-run "rm app/stylesheets/*.sass"
-run "mkdir app/stylesheets/partials"
+run "rm -r app/stylesheets/"
+run "cp -R #{file_path("stylesheets")} app/"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/application.sass b/lib/stylesheets/application.sass
similarity index 100%
rename from lib/application.sass
rename to lib/stylesheets/application.sass
|
javierv/rails_templates
|
36871334c7cf5740048c416f96f8146ca40320fd
|
Elementos para incluir markitup automáticamente en los textarea de los formularios.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 8a06a24..f54657d 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,108 +1,108 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(file_path(file)))
end
def file_path(file)
File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
-file "app/views/shared/_errors.html.haml", read_file("shared/_errors.html.haml")
-
+run "cp -R #{file_path("shared")} app/views/"
run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
+file "public/javascripts/form.js", read_file("javascripts/form.js")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/javascripts/form.js b/lib/javascripts/form.js
new file mode 100644
index 0000000..a0b48d1
--- /dev/null
+++ b/lib/javascripts/form.js
@@ -0,0 +1,4 @@
+$(document).ready(function()
+{
+ $('textarea').markItUp(markitup_settings);
+});
\ No newline at end of file
diff --git a/lib/shared/_js_form.html.haml b/lib/shared/_js_form.html.haml
new file mode 100644
index 0000000..79220cc
--- /dev/null
+++ b/lib/shared/_js_form.html.haml
@@ -0,0 +1,2 @@
+- render 'shared/markitup'
+- javascript 'form'
\ No newline at end of file
diff --git a/lib/shared/_markitup.html.haml b/lib/shared/_markitup.html.haml
new file mode 100644
index 0000000..c83d005
--- /dev/null
+++ b/lib/shared/_markitup.html.haml
@@ -0,0 +1,3 @@
+- css '/javascripts/markitup/skins/simple/style.css',
+ '/javascripts/markitup/sets/textile/style.css'
+- javascript 'markitup/jquery.markitup', 'markitup/sets/textile/set'
\ No newline at end of file
diff --git a/lib/simple_form/scaffold/_form.html.haml.erb b/lib/simple_form/scaffold/_form.html.haml.erb
index ae8628e..6d4beaa 100644
--- a/lib/simple_form/scaffold/_form.html.haml.erb
+++ b/lib/simple_form/scaffold/_form.html.haml.erb
@@ -1,10 +1,12 @@
+- render 'shared/js_form'
+
= simple_form_for @<%= file_name %> do |form|
= render 'shared/errors', :record => @<%= file_name %>
<%- for attribute in attributes -%>
= form.input :<%= attribute.name %>, :label => '<%= attribute.name.titleize %>'
<%- end -%>
.actions
= form.button :submit
\ No newline at end of file
|
javierv/rails_templates
|
37f7b39cf56fa9ced0756c9dde61f5031e6be2e4
|
gitignore de netbeans.
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6b4ead1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+nbproject/*
\ No newline at end of file
|
javierv/rails_templates
|
065aebfd168ea11695ff98c4a6e6651565dd5fd7
|
Nunca me acuerdo de si el método se llama "stylesheet" o "css". Ahora valen los dos.
|
diff --git a/lib/layout_helper.rb b/lib/layout_helper.rb
index 0532385..c49c2f3 100644
--- a/lib/layout_helper.rb
+++ b/lib/layout_helper.rb
@@ -1,30 +1,34 @@
module LayoutHelper
def title(page_title, show_title = true)
@content_for_title = page_title.to_s
@show_title = show_title
end
def show_title?
@show_title
end
def stylesheet(*args)
@stylesheets ||= []
args.each do |stylesheet|
if !@stylesheets.include?(stylesheet)
content_for(:head) { stylesheet_link_tag(stylesheet) }
@stylesheets << stylesheet
end
end
end
+ def css(*args)
+ stylesheet *args
+ end
+
def javascript(*args)
@javascripts ||= []
args.each do |javascript|
if !@javascripts.include?(javascript)
content_for(:head) { javascript_include_tag(javascript) }
@javascripts << javascript
end
end
end
end
\ No newline at end of file
|
javierv/rails_templates
|
10569bcde14621f858df203c5f85f42a7bd1ebac
|
Inclusión de markItUp con textile.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 08a31a7..8a06a24 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,103 +1,108 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
- File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
+ File.read(File.expand_path(file_path(file)))
+end
+
+def file_path(file)
+ File.join(File.dirname(__FILE__), file)
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
file "app/views/shared/_errors.html.haml", read_file("shared/_errors.html.haml")
+run "cp -R #{file_path("javascripts/markitup")} public/javascripts/"
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/javascripts/markitup/jquery.markitup.js b/lib/javascripts/markitup/jquery.markitup.js
new file mode 100644
index 0000000..e2c4043
--- /dev/null
+++ b/lib/javascripts/markitup/jquery.markitup.js
@@ -0,0 +1,558 @@
+// ----------------------------------------------------------------------------
+// markItUp! Universal MarkUp Engine, JQuery plugin
+// v 1.1.6.1
+// Dual licensed under the MIT and GPL licenses.
+// ----------------------------------------------------------------------------
+// Copyright (C) 2007-2010 Jay Salvat
+// http://markitup.jaysalvat.com/
+// ----------------------------------------------------------------------------
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// ----------------------------------------------------------------------------
+(function($) {
+ $.fn.markItUp = function(settings, extraSettings) {
+ var options, ctrlKey, shiftKey, altKey;
+ ctrlKey = shiftKey = altKey = false;
+
+ options = { id: '',
+ nameSpace: '',
+ root: '',
+ previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
+ previewAutoRefresh: true,
+ previewPosition: 'after',
+ previewTemplatePath: '~/templates/preview.html',
+ previewParserPath: '',
+ previewParserVar: 'data',
+ resizeHandle: true,
+ beforeInsert: '',
+ afterInsert: '',
+ onEnter: {},
+ onShiftEnter: {},
+ onCtrlEnter: {},
+ onTab: {},
+ markupSet: [ { /* set */ } ]
+ };
+ $.extend(options, settings, extraSettings);
+
+ // compute markItUp! path
+ if (!options.root) {
+ $('script').each(function(a, tag) {
+ miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);
+ if (miuScript !== null) {
+ options.root = miuScript[1];
+ }
+ });
+ }
+
+ return this.each(function() {
+ var $$, textarea, levels, scrollPosition, caretPosition, caretOffset,
+ clicked, hash, header, footer, previewWindow, template, iFrame, abort;
+ $$ = $(this);
+ textarea = this;
+ levels = [];
+ abort = false;
+ scrollPosition = caretPosition = 0;
+ caretOffset = -1;
+
+ options.previewParserPath = localize(options.previewParserPath);
+ options.previewTemplatePath = localize(options.previewTemplatePath);
+
+ // apply the computed path to ~/
+ function localize(data, inText) {
+ if (inText) {
+ return data.replace(/("|')~\//g, "$1"+options.root);
+ }
+ return data.replace(/^~\//, options.root);
+ }
+
+ // init and build editor
+ function init() {
+ id = ''; nameSpace = '';
+ if (options.id) {
+ id = 'id="'+options.id+'"';
+ } else if ($$.attr("id")) {
+ id = 'id="markItUp'+($$.attr("id").substr(0, 1).toUpperCase())+($$.attr("id").substr(1))+'"';
+
+ }
+ if (options.nameSpace) {
+ nameSpace = 'class="'+options.nameSpace+'"';
+ }
+ $$.wrap('<div '+nameSpace+'></div>');
+ $$.wrap('<div '+id+' class="markItUp"></div>');
+ $$.wrap('<div class="markItUpContainer"></div>');
+ $$.addClass("markItUpEditor");
+
+ // add the header before the textarea
+ header = $('<div class="markItUpHeader"></div>').insertBefore($$);
+ $(dropMenus(options.markupSet)).appendTo(header);
+
+ // add the footer after the textarea
+ footer = $('<div class="markItUpFooter"></div>').insertAfter($$);
+
+ // add the resize handle after textarea
+ if (options.resizeHandle === true && $.browser.safari !== true) {
+ resizeHandle = $('<div class="markItUpResizeHandle"></div>')
+ .insertAfter($$)
+ .bind("mousedown", function(e) {
+ var h = $$.height(), y = e.clientY, mouseMove, mouseUp;
+ mouseMove = function(e) {
+ $$.css("height", Math.max(20, e.clientY+h-y)+"px");
+ return false;
+ };
+ mouseUp = function(e) {
+ $("html").unbind("mousemove", mouseMove).unbind("mouseup", mouseUp);
+ return false;
+ };
+ $("html").bind("mousemove", mouseMove).bind("mouseup", mouseUp);
+ });
+ footer.append(resizeHandle);
+ }
+
+ // listen key events
+ $$.keydown(keyPressed).keyup(keyPressed);
+
+ // bind an event to catch external calls
+ $$.bind("insertion", function(e, settings) {
+ if (settings.target !== false) {
+ get();
+ }
+ if (textarea === $.markItUp.focused) {
+ markup(settings);
+ }
+ });
+
+ // remember the last focus
+ $$.focus(function() {
+ $.markItUp.focused = this;
+ });
+ }
+
+ // recursively build header with dropMenus from markupset
+ function dropMenus(markupSet) {
+ var ul = $('<ul></ul>'), i = 0;
+ $('li:hover > ul', ul).css('display', 'block');
+ $.each(markupSet, function() {
+ var button = this, t = '', title, li, j;
+ title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||'');
+ key = (button.key) ? 'accesskey="'+button.key+'"' : '';
+ if (button.separator) {
+ li = $('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul);
+ } else {
+ i++;
+ for (j = levels.length -1; j >= 0; j--) {
+ t += levels[j]+"-";
+ }
+ li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><span '+key+' title="'+title+'">'+(button.name||'')+'</a></li>')
+ .bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click
+ return false;
+ }).click(function() {
+ return false;
+ }).mouseup(function() {
+ if (button.call) {
+ eval(button.call)();
+ }
+ markup(button);
+ return false;
+ }).hover(function() {
+ $('> ul', this).show();
+ $(document).one('click', function() { // close dropmenu if click outside
+ $('ul ul', header).hide();
+ }
+ );
+ }, function() {
+ $('> ul', this).hide();
+ }
+ ).appendTo(ul);
+ if (button.dropMenu) {
+ levels.push(i);
+ $(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));
+ }
+ }
+ });
+ levels.pop();
+ return ul;
+ }
+
+ // markItUp! markups
+ function magicMarkups(string) {
+ if (string) {
+ string = string.toString();
+ string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,
+ function(x, a) {
+ var b = a.split('|!|');
+ if (altKey === true) {
+ return (b[1] !== undefined) ? b[1] : b[0];
+ } else {
+ return (b[1] === undefined) ? "" : b[0];
+ }
+ }
+ );
+ // [![prompt]!], [![prompt:!:value]!]
+ string = string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,
+ function(x, a) {
+ var b = a.split(':!:');
+ if (abort === true) {
+ return false;
+ }
+ value = prompt(b[0], (b[1]) ? b[1] : '');
+ if (value === null) {
+ abort = true;
+ }
+ return value;
+ }
+ );
+ return string;
+ }
+ return "";
+ }
+
+ // prepare action
+ function prepare(action) {
+ if ($.isFunction(action)) {
+ action = action(hash);
+ }
+ return magicMarkups(action);
+ }
+
+ // build block to insert
+ function build(string) {
+ openWith = prepare(clicked.openWith);
+ placeHolder = prepare(clicked.placeHolder);
+ replaceWith = prepare(clicked.replaceWith);
+ closeWith = prepare(clicked.closeWith);
+ if (replaceWith !== "") {
+ block = openWith + replaceWith + closeWith;
+ } else if (selection === '' && placeHolder !== '') {
+ block = openWith + placeHolder + closeWith;
+ } else {
+ block = openWith + (string||selection) + closeWith;
+ }
+ return { block:block,
+ openWith:openWith,
+ replaceWith:replaceWith,
+ placeHolder:placeHolder,
+ closeWith:closeWith
+ };
+ }
+
+ // define markup to insert
+ function markup(button) {
+ var len, j, n, i;
+ hash = clicked = button;
+ get();
+
+ $.extend(hash, { line:"",
+ root:options.root,
+ textarea:textarea,
+ selection:(selection||''),
+ caretPosition:caretPosition,
+ ctrlKey:ctrlKey,
+ shiftKey:shiftKey,
+ altKey:altKey
+ }
+ );
+ // callbacks before insertion
+ prepare(options.beforeInsert);
+ prepare(clicked.beforeInsert);
+ if (ctrlKey === true && shiftKey === true) {
+ prepare(clicked.beforeMultiInsert);
+ }
+ $.extend(hash, { line:1 });
+
+ if (ctrlKey === true && shiftKey === true) {
+ lines = selection.split(/\r?\n/);
+ for (j = 0, n = lines.length, i = 0; i < n; i++) {
+ if ($.trim(lines[i]) !== '') {
+ $.extend(hash, { line:++j, selection:lines[i] } );
+ lines[i] = build(lines[i]).block;
+ } else {
+ lines[i] = "";
+ }
+ }
+ string = { block:lines.join('\n')};
+ start = caretPosition;
+ len = string.block.length + (($.browser.opera) ? n : 0);
+ } else if (ctrlKey === true) {
+ string = build(selection);
+ start = caretPosition + string.openWith.length;
+ len = string.block.length - string.openWith.length - string.closeWith.length;
+ len -= fixIeBug(string.block);
+ } else if (shiftKey === true) {
+ string = build(selection);
+ start = caretPosition;
+ len = string.block.length;
+ len -= fixIeBug(string.block);
+ } else {
+ string = build(selection);
+ start = caretPosition + string.block.length ;
+ len = 0;
+ start -= fixIeBug(string.block);
+ }
+ if ((selection === '' && string.replaceWith === '')) {
+ caretOffset += fixOperaBug(string.block);
+
+ start = caretPosition + string.openWith.length;
+ len = string.block.length - string.openWith.length - string.closeWith.length;
+
+ caretOffset = $$.val().substring(caretPosition, $$.val().length).length;
+ caretOffset -= fixOperaBug($$.val().substring(0, caretPosition));
+ }
+ $.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } );
+
+ if (string.block !== selection && abort === false) {
+ insert(string.block);
+ set(start, len);
+ } else {
+ caretOffset = -1;
+ }
+ get();
+
+ $.extend(hash, { line:'', selection:selection });
+
+ // callbacks after insertion
+ if (ctrlKey === true && shiftKey === true) {
+ prepare(clicked.afterMultiInsert);
+ }
+ prepare(clicked.afterInsert);
+ prepare(options.afterInsert);
+
+ // refresh preview if opened
+ if (previewWindow && options.previewAutoRefresh) {
+ refreshPreview();
+ }
+
+ // reinit keyevent
+ shiftKey = altKey = ctrlKey = abort = false;
+ }
+
+ // Substract linefeed in Opera
+ function fixOperaBug(string) {
+ if ($.browser.opera) {
+ return string.length - string.replace(/\n*/g, '').length;
+ }
+ return 0;
+ }
+ // Substract linefeed in IE
+ function fixIeBug(string) {
+ if ($.browser.msie) {
+ return string.length - string.replace(/\r*/g, '').length;
+ }
+ return 0;
+ }
+
+ // add markup
+ function insert(block) {
+ if (document.selection) {
+ var newSelection = document.selection.createRange();
+ newSelection.text = block;
+ } else {
+ $$.val($$.val().substring(0, caretPosition) + block + $$.val().substring(caretPosition + selection.length, $$.val().length));
+ }
+ }
+
+ // set a selection
+ function set(start, len) {
+ if (textarea.createTextRange){
+ // quick fix to make it work on Opera 9.5
+ if ($.browser.opera && $.browser.version >= 9.5 && len == 0) {
+ return false;
+ }
+ range = textarea.createTextRange();
+ range.collapse(true);
+ range.moveStart('character', start);
+ range.moveEnd('character', len);
+ range.select();
+ } else if (textarea.setSelectionRange ){
+ textarea.setSelectionRange(start, start + len);
+ }
+ textarea.scrollTop = scrollPosition;
+ textarea.focus();
+ }
+
+ // get the selection
+ function get() {
+ textarea.focus();
+
+ scrollPosition = textarea.scrollTop;
+ if (document.selection) {
+ selection = document.selection.createRange().text;
+ if ($.browser.msie) { // ie
+ var range = document.selection.createRange(), rangeCopy = range.duplicate();
+ rangeCopy.moveToElementText(textarea);
+ caretPosition = -1;
+ while(rangeCopy.inRange(range)) { // fix most of the ie bugs with linefeeds...
+ rangeCopy.moveStart('character');
+ caretPosition ++;
+ }
+ } else { // opera
+ caretPosition = textarea.selectionStart;
+ }
+ } else { // gecko
+ caretPosition = textarea.selectionStart;
+ selection = $$.val().substring(caretPosition, textarea.selectionEnd);
+ }
+ return selection;
+ }
+
+ // open preview window
+ function preview() {
+ if (!previewWindow || previewWindow.closed) {
+ if (options.previewInWindow) {
+ previewWindow = window.open('', 'preview', options.previewInWindow);
+ } else {
+ iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>');
+ if (options.previewPosition == 'after') {
+ iFrame.insertAfter(footer);
+ } else {
+ iFrame.insertBefore(header);
+ }
+ previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];
+ }
+ } else if (altKey === true) {
+ // Thx Stephen M. Redd for the IE8 fix
+ if (iFrame) {
+ iFrame.remove();
+ } else {
+ previewWindow.close();
+ }
+ previewWindow = iFrame = false;
+ }
+ if (!options.previewAutoRefresh) {
+ refreshPreview();
+ }
+ }
+
+ // refresh Preview window
+ function refreshPreview() {
+ renderPreview();
+ }
+
+ function renderPreview() {
+ var phtml;
+ if (options.previewParserPath !== '') {
+ $.ajax( {
+ type: 'POST',
+ url: options.previewParserPath,
+ data: options.previewParserVar+'='+encodeURIComponent($$.val()),
+ success: function(data) {
+ writeInPreview( localize(data, 1) );
+ }
+ } );
+ } else {
+ if (!template) {
+ $.ajax( {
+ url: options.previewTemplatePath,
+ success: function(data) {
+ writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) );
+ }
+ } );
+ }
+ }
+ return false;
+ }
+
+ function writeInPreview(data) {
+ if (previewWindow.document) {
+ try {
+ sp = previewWindow.document.documentElement.scrollTop
+ } catch(e) {
+ sp = 0;
+ }
+ var h = "test";
+ previewWindow.document.open();
+ previewWindow.document.write(data);
+ previewWindow.document.close();
+ previewWindow.document.documentElement.scrollTop = sp;
+ }
+ if (options.previewInWindow) {
+ previewWindow.focus();
+ }
+ }
+
+ // set keys pressed
+ function keyPressed(e) {
+ shiftKey = e.shiftKey;
+ altKey = e.altKey;
+ ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false;
+
+ if (e.type === 'keydown') {
+ if (ctrlKey === true) {
+ li = $("span[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li');
+ if (li.length !== 0) {
+ ctrlKey = false;
+ li.triggerHandler('mouseup');
+ return false;
+ }
+ }
+ if (e.keyCode === 13 || e.keyCode === 10) { // Enter key
+ if (ctrlKey === true) { // Enter + Ctrl
+ ctrlKey = false;
+ markup(options.onCtrlEnter);
+ return options.onCtrlEnter.keepDefault;
+ } else if (shiftKey === true) { // Enter + Shift
+ shiftKey = false;
+ markup(options.onShiftEnter);
+ return options.onShiftEnter.keepDefault;
+ } else { // only Enter
+ markup(options.onEnter);
+ return options.onEnter.keepDefault;
+ }
+ }
+ if (e.keyCode === 9) { // Tab key
+ if (shiftKey == true || ctrlKey == true || altKey == true) { // Thx Dr Floob.
+ return false;
+ }
+ if (caretOffset !== -1) {
+ get();
+ caretOffset = $$.val().length - caretOffset;
+ set(caretOffset, 0);
+ caretOffset = -1;
+ return false;
+ } else {
+ markup(options.onTab);
+ return options.onTab.keepDefault;
+ }
+ }
+ }
+ }
+
+ init();
+ });
+ };
+
+ $.fn.markItUpRemove = function() {
+ return this.each(function() {
+ $$ = $(this).unbind().removeClass('markItUpEditor');
+ $$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
+ }
+ );
+ };
+
+ $.markItUp = function(settings) {
+ var options = { target:false };
+ $.extend(options, settings);
+ if (options.target) {
+ return $(options.target).each(function() {
+ $(this).focus();
+ $(this).trigger('insertion', [options]);
+ });
+ } else {
+ $('textarea').trigger('insertion', [options]);
+ }
+ };
+})(jQuery);
diff --git a/lib/javascripts/markitup/sets/textile/images/bold.png b/lib/javascripts/markitup/sets/textile/images/bold.png
new file mode 100644
index 0000000..889ae80
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/bold.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/code.png b/lib/javascripts/markitup/sets/textile/images/code.png
new file mode 100644
index 0000000..63fe6ce
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/code.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/italic.png b/lib/javascripts/markitup/sets/textile/images/italic.png
new file mode 100644
index 0000000..8482ac8
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/italic.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/link.png b/lib/javascripts/markitup/sets/textile/images/link.png
new file mode 100644
index 0000000..25eacb7
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/link.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/list-bullet.png b/lib/javascripts/markitup/sets/textile/images/list-bullet.png
new file mode 100644
index 0000000..4a8672b
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/list-bullet.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/list-numeric.png b/lib/javascripts/markitup/sets/textile/images/list-numeric.png
new file mode 100644
index 0000000..33b0b8d
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/list-numeric.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/picture.png b/lib/javascripts/markitup/sets/textile/images/picture.png
new file mode 100644
index 0000000..4a158fe
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/picture.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/preview.png b/lib/javascripts/markitup/sets/textile/images/preview.png
new file mode 100644
index 0000000..a9925a0
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/preview.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/quotes.png b/lib/javascripts/markitup/sets/textile/images/quotes.png
new file mode 100644
index 0000000..e54ebeb
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/quotes.png differ
diff --git a/lib/javascripts/markitup/sets/textile/images/stroke.png b/lib/javascripts/markitup/sets/textile/images/stroke.png
new file mode 100644
index 0000000..612058a
Binary files /dev/null and b/lib/javascripts/markitup/sets/textile/images/stroke.png differ
diff --git a/lib/javascripts/markitup/sets/textile/set.js b/lib/javascripts/markitup/sets/textile/set.js
new file mode 100644
index 0000000..3ab51bf
--- /dev/null
+++ b/lib/javascripts/markitup/sets/textile/set.js
@@ -0,0 +1,29 @@
+// -------------------------------------------------------------------
+// markItUp!
+// -------------------------------------------------------------------
+// Copyright (C) 2008 Jay Salvat
+// http://markitup.jaysalvat.com/
+// -------------------------------------------------------------------
+// Textile tags example
+// http://en.wikipedia.org/wiki/Textile_(markup_language)
+// http://www.textism.com/
+// -------------------------------------------------------------------
+// Feel free to add more tags
+// -------------------------------------------------------------------
+markitup_settings = {
+ previewParserPath: '', // path to your Textile parser
+ onShiftEnter: {keepDefault:false, replaceWith:'\n\n'},
+ markupSet: [
+ {name:'Negrita', key:'B', className:'negrita', closeWith:'*', openWith:'*'},
+ {name:'Cursiva', key:'I', className:'cursiva', closeWith:'_', openWith:'_'},
+ {name:'Tachado', key:'S', className:'tachado', closeWith:'-', openWith:'-'},
+ {separator:'---------------' },
+ {name:'Lista de viñetas', className: 'lista', openWith:'(!(* |!|*)!)'},
+ {name:'Lista numerada', className:'numerada', openWith:'(!(# |!|#)!)'},
+ {separator:'---------------' },
+ {name:'Imagen', className: 'imagen', replaceWith:'![![Ruta:!:http://]!]([![Texto alternativo]!])!'},
+ {name:'Enlace', className:'enlace', openWith:'"', closeWith:'":[![Ruta:!:http://]!]', placeHolder:'Texto del enlace aquÃ...' },
+ {separator:'---------------' },
+ {name:'Cita', className:'cita', openWith:'bq(!(([![Class]!]))!). '}
+ ]
+}
\ No newline at end of file
diff --git a/lib/javascripts/markitup/sets/textile/style.css b/lib/javascripts/markitup/sets/textile/style.css
new file mode 100644
index 0000000..cd1955b
--- /dev/null
+++ b/lib/javascripts/markitup/sets/textile/style.css
@@ -0,0 +1,27 @@
+.markItUp .negrita span {
+ background-image:url(images/bold.png);
+}
+.markItUp .cursiva span {
+ background-image:url(images/italic.png);
+}
+.markItUp .tachado span {
+ background-image:url(images/stroke.png);
+}
+
+.markItUp .lista span {
+ background-image:url(images/list-bullet.png);
+}
+.markItUp .numerada span {
+ background-image:url(images/list-numeric.png);
+}
+
+.markItUp .imagen span {
+ background-image:url(images/picture.png);
+}
+.markItUp .enlace span {
+ background-image:url(images/link.png);
+}
+
+.markItUp .cita span {
+ background-image:url(images/quotes.png);
+}
\ No newline at end of file
diff --git a/lib/javascripts/markitup/skins/simple/images/handle.png b/lib/javascripts/markitup/skins/simple/images/handle.png
new file mode 100644
index 0000000..3993b20
Binary files /dev/null and b/lib/javascripts/markitup/skins/simple/images/handle.png differ
diff --git a/lib/javascripts/markitup/skins/simple/images/menu.png b/lib/javascripts/markitup/skins/simple/images/menu.png
new file mode 100644
index 0000000..44a07af
Binary files /dev/null and b/lib/javascripts/markitup/skins/simple/images/menu.png differ
diff --git a/lib/javascripts/markitup/skins/simple/images/submenu.png b/lib/javascripts/markitup/skins/simple/images/submenu.png
new file mode 100644
index 0000000..03d1977
Binary files /dev/null and b/lib/javascripts/markitup/skins/simple/images/submenu.png differ
diff --git a/lib/javascripts/markitup/skins/simple/style.css b/lib/javascripts/markitup/skins/simple/style.css
new file mode 100644
index 0000000..5a87750
--- /dev/null
+++ b/lib/javascripts/markitup/skins/simple/style.css
@@ -0,0 +1,88 @@
+.markItUp
+{
+ border: 5px solid #F5F5F5;
+}
+
+.markItUpContainer
+{
+ background: #f0f0f0 url(images/bg-container.png) repeat-x scroll left top;
+ border: 1px solid #3c769d;
+ padding: 5px;
+}
+
+.markItUpEditor
+{
+ height: 320px;
+ clear: both;
+ display: block;
+ line-height:18px;
+ overflow: auto;
+}
+.markItUpPreviewFrame
+{
+ overflow: auto;
+ background-color: #fff;
+ width: 99.9%;
+ height: 300px;
+ margin: 5px 0;
+}
+.markItUpFooter
+{
+ width: 100%;
+}
+.markItUpResizeHandle
+{
+ overflow: hidden;
+ width: 22px;
+ height: 5px;
+ margin-left: auto;
+ margin-right: auto;
+ background-image: url(images/handle.png);
+ cursor: n-resize;
+}
+/***************************************************************************************/
+/* first row of buttons */
+.markItUpHeader ul li
+{
+ list-style: none;
+ float: left;
+ position: relative;
+}
+.markItUpHeader ul li:hover > ul
+{
+ display: block;
+}
+.markItUpHeader ul .markItUpDropMenu
+{
+ background: transparent url(images/menu.png) no-repeat 115% 50%;
+ margin-right: 5px;
+}
+.markItUpHeader ul .markItUpDropMenu li
+{
+ margin-right: 0px;
+}
+
+.markItUpHeader ul .markItUpSeparator
+{
+ margin: 0 10px;
+ width: 1px;
+ height: 16px;
+ overflow: hidden;
+ background-color: #ccc;
+}
+
+.markItUpHeader ul span
+{
+ display: block;
+ width: 16px;
+ height: 16px;
+ text-indent: -10000px;
+ background-repeat: no-repeat;
+ padding: 3px;
+ margin: 0px;
+}
+
+.markItUpHeader ul span:hover
+{
+ cursor: pointer;
+}
|
javierv/rails_templates
|
48c0ea02229793f534b987d8776026e10f99a62a
|
No generamos ayudantes por cada modelo.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index a83d559..08a31a7 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,102 +1,103 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/shoulda/model/model.rb",
read_file("shoulda/model/model.rb")
file "lib/templates/active_record/model/model.rb",
read_file("active_record/model/model.rb")
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
file "app/views/shared/_errors.html.haml", read_file("shared/_errors.html.haml")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
+ g.helper false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
9a6cd36833040ff47b0dbc9a9c2f851cbfd28406
|
Por defecto, al generar un modelo, todos sus atributos son accesibles y obligatorios.
|
diff --git a/lib/active_record/model/model.rb b/lib/active_record/model/model.rb
new file mode 100644
index 0000000..e6f3d14
--- /dev/null
+++ b/lib/active_record/model/model.rb
@@ -0,0 +1,6 @@
+class <%= class_name %> < ActiveRecord::Base
+ attr_accessible <%= attributes.map { |a| ":#{a.name}" }.join(", ") %>
+ <%- for attribute in attributes -%>
+ validates :<%= attribute.name %>, :presence => true
+ <%- end -%>
+end
\ No newline at end of file
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 9fc754c..a83d559 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,96 +1,102 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
+file "lib/templates/shoulda/model/model.rb",
+ read_file("shoulda/model/model.rb")
+
+file "lib/templates/active_record/model/model.rb",
+ read_file("active_record/model/model.rb")
+
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
read_file("simple_form/scaffold/_form.html.haml.erb")
file "app/views/shared/_errors.html.haml", read_file("shared/_errors.html.haml")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/shoulda/model/model.rb b/lib/shoulda/model/model.rb
new file mode 100644
index 0000000..6c61e30
--- /dev/null
+++ b/lib/shoulda/model/model.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class <%= class_name %>Test < ActiveSupport::TestCase
+ <%- for attribute in attributes -%>
+ should validate_presence_of(:<%= attribute.name %>)
+ should allow_mass_assignment_of(:<%= attribute.name %>)
+ <%- end -%>
+end
\ No newline at end of file
|
javierv/rails_templates
|
aeac162816cd73c60de7a78b7c7c791b0c45af43
|
Separamos los errores del formulario a un fichero común.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 8079de8..9fc754c 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,91 +1,96 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
+file "lib/templates/simple_form/scaffold/_form.html.haml.erb",
+ read_file("simple_form/scaffold/_form.html.haml.erb")
+
+file "app/views/shared/_errors.html.haml", read_file("shared/_errors.html.haml")
+
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/shared/_errors.html.haml b/lib/shared/_errors.html.haml
new file mode 100644
index 0000000..fadc280
--- /dev/null
+++ b/lib/shared/_errors.html.haml
@@ -0,0 +1,6 @@
+-if record.errors.any?
+ #errorExplanation
+ %h2= "#{pluralize(record.errors.count, "error")} al rellenar el formulario:"
+ %ul
+ - record.errors.full_messages.each do |msg|
+ %li= msg
\ No newline at end of file
diff --git a/lib/simple_form/scaffold/_form.html.haml.erb b/lib/simple_form/scaffold/_form.html.haml.erb
new file mode 100644
index 0000000..ae8628e
--- /dev/null
+++ b/lib/simple_form/scaffold/_form.html.haml.erb
@@ -0,0 +1,10 @@
+= simple_form_for @<%= file_name %> do |form|
+
+ = render 'shared/errors', :record => @<%= file_name %>
+
+<%- for attribute in attributes -%>
+ = form.input :<%= attribute.name %>, :label => '<%= attribute.name.titleize %>'
+<%- end -%>
+
+ .actions
+ = form.button :submit
\ No newline at end of file
|
javierv/rails_templates
|
24f138a38afd3213d5fbe7fec4f3bf0465ab81e4
|
Ya se ha incluido mi parche en tabletastic.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 177c5ba..8079de8 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,91 +1,91 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
-gem 'tabletastic', :git => "/home/javi/programas/work/tabletastic"
+gem 'tabletastic', ">= 0.2.0pre4"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
|
javierv/rails_templates
|
517a0b2cff18f5a887da09f34cd600dde919968a
|
Incluimos tests para los plurales.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 4cd5ed5..177c5ba 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,89 +1,91 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', :git => "/home/javi/programas/work/tabletastic"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
+file "test/unit/pluralize_test.rb", read_file("pluralize_test.rb")
+
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/pluralize_test.rb b/lib/pluralize_test.rb
new file mode 100644
index 0000000..624dabd
--- /dev/null
+++ b/lib/pluralize_test.rb
@@ -0,0 +1,59 @@
+# encoding: utf-8
+
+require 'test_helper'
+
+class PluralizeTest < ActiveSupport::TestCase
+
+ test "el plural de una palabra acabada en vocal se hace con una 's'" do
+ assert_equal 'libros', 'libro'.pluralize
+ assert_equal 'libro', 'libros'.singularize
+ end
+
+ test "el plural de una palabra que acaba en consonante es -es" do
+ assert_equal 'autores', 'autor'.pluralize
+ assert_equal 'autor', 'autores'.singularize
+ end
+
+ test "las palabras acabadas en 'z' hacen su plural en 'ces'" do
+ assert_equal 'veces', 'vez'.pluralize
+ assert_equal 'vez', 'veces'.singularize
+ end
+
+ test "las palabras agudas acabadas en 'n' ó 's' hacen el plural sin acento" do
+ assert_equal 'balcones', 'balcón'.pluralize
+ assert_equal 'truhanes', 'truhán'.pluralize
+ assert_equal 'cordobeses', 'cordobés'.pluralize
+ assert_equal 'cojines', 'cojÃn'.pluralize
+ assert_equal 'trolebuses', 'trolebús'.pluralize
+ #assert_equal 'balcón', 'balcones'.singularize Peligros, ya que en la BD los nombres de tabla no tienen acentos
+ end
+
+ test "las palabras acabadas en vocal débil con acento más consonante conservan el acento" do
+ assert_equal 'raÃces', 'raÃz'.pluralize
+ assert_equal 'raÃz', 'raÃces'.singularize
+
+ assert_equal 'baúles', 'baúl'.pluralize
+ assert_equal 'baúl', 'baúles'.singularize
+ end
+
+ #TODO: cacahuete => cacahuetes. Ver en qué consonantes pueden acabar las palabras españolas.
+
+ test "las palabras acabadas en vocal cerrada con acento hace su plural en -es" do
+ assert_equal 'manatÃes', 'manatÃ'.pluralize
+ assert_equal 'manatÃ', 'manatÃes'.singularize
+
+ assert_equal 'tabúes', 'tabú'.pluralize
+ assert_equal 'tabú', 'tabúes'.singularize
+ end
+
+ test "las palabras agudas acabadas en vocal abierta hacen su plural en -s" do
+ assert_equal 'sofás', 'sofá'.pluralize
+ assert_equal 'sofá', 'sofás'.singularize
+
+ assert_equal 'comités', 'comité'.pluralize
+ assert_equal 'comité', 'comités'.singularize
+
+ assert_equal 'platós', 'plató'.pluralize
+ assert_equal 'plató', 'platós'.singularize
+ end
+end
\ No newline at end of file
|
javierv/rails_templates
|
fdeebe1a69101b1d0faf3080486d479e0c6407ac
|
Corregimos error de sintaxis que aparentemente era correcto en Ruby 1.8
|
diff --git a/lib/inflections.rb b/lib/inflections.rb
index 1bf5eb4..eaa3419 100644
--- a/lib/inflections.rb
+++ b/lib/inflections.rb
@@ -1,27 +1,27 @@
# encoding: utf-8
ActiveSupport::Inflector.inflections do |inflect|
inflect.plural /([^aeiouáéó])$/i, '\\1es'
inflect.singular /(.*)es$/i, '\\1'
inflect.plural /(.*)z$/i, '\\1ces'
inflect.singular /(.*)ces$/i, '\\1z'
vocales = {'a' => 'á', 'e' => 'é', 'i' => 'Ã', 'o' => 'ó', 'u' => 'ú'}
vocales.each do |vocal_sin_acento, vocal_con_acento|
['n', 's'].each do |consonante|
final_singular = vocal_con_acento + consonante
final_plural = vocal_sin_acento + consonante + 'es'
- inflect.plural /(.*)\#{final_singular}$/i, '\\1' + final_plural
+ inflect.plural /(.*)#{final_singular}$/i, '\\1' + final_plural
#La siguiente lÃnea la comento porque los nombres de tablas no tienen acentos
#inflect.singular /(.*)\#{final_plural}$/i, '\\1' + final_singular
end
end
inflect.irregular 'post', 'posts'
inflect.irregular 'tagging', 'taggings'
inflect.irregular 'tag', 'tags'
inflect.irregular 'session', 'sessions'
inflect.irregular 'job', 'jobs'
# inflect.uncountable %w( fish sheep )
end
|
javierv/rails_templates
|
c556dfbc8f49902f8d9638ea173a03e35752b24f
|
Generamos enlaces para ordenar el listado según un determinado campo.
|
diff --git a/lib/haml/scaffold/index.html.haml.erb b/lib/haml/scaffold/index.html.haml.erb
index 848f9ba..d4234ae 100644
--- a/lib/haml/scaffold/index.html.haml.erb
+++ b/lib/haml/scaffold/index.html.haml.erb
@@ -1,13 +1,16 @@
- title "Listado de <%= plural_name %>"
= simple_form_for @search, :class => 'search' do |form|
<%- for attribute in attributes -%>
= form.input :<%= attribute.name + "_contains" %>, :label => '<%= attribute.name.titleize %>',
:required => false
<%- end -%>
= form.submit 'Buscar'
= table_for @<%= plural_name %> do |table|
- = table.data(:actions => :all)
+ = table.data :actions => :all do
+ <%- for attribute in attributes -%>
+ = table.cell :<%= attribute.name %>, :heading => sort_link(@search, :<%= attribute.name %>)
+ <%- end -%>
= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
\ No newline at end of file
|
javierv/rails_templates
|
d8437c0530c01ab0aab5a81fb3a1a2ac2d189c01
|
after_filter no se ejecuta justo después del código de la acción, sino después de que el controlador renderice.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 1eb2d1f..732f694 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,58 +1,58 @@
# encoding: utf-8
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => [:show, :edit, :update, :destroy]
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
- after_filter :respond_with_<%= file_name %>, :except => :index
-
<% unless options[:singleton] -%>
def index
@search = <%= class_name %>.search params[:search]
@<%= table_name %> = @search.paginate :page => params[:page],
:per_page => <%= class_name %>.per_page
respond_with @<%= table_name %>
end
<% end -%>
def show
+ respond_with @<%= file_name %>
end
def new
+ respond_with @<%= file_name %>
end
def edit
+ respond_with @<%= file_name %>
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= file_name %>.save
+ respond_with @<%= file_name %>
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= file_name %>.save
+ respond_with @<%= file_name %>
end
def destroy
<%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= file_name %>.destroy
+ respond_with @<%= file_name %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
-
- def respond_with_<%= file_name %>
- respond_with @<%= file_name %>
- end
end
|
javierv/rails_templates
|
684e57fd942712cf87f6eac25a97abd0a8e493bd
|
Aunque es obvio, indicamos explÃcitamente qué controlador estamos probando.
|
diff --git a/lib/test_unit/scaffold/functional_test.rb b/lib/test_unit/scaffold/functional_test.rb
index 4fa90c6..e04c137 100644
--- a/lib/test_unit/scaffold/functional_test.rb
+++ b/lib/test_unit/scaffold/functional_test.rb
@@ -1,95 +1,97 @@
require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
+ tests <%= controller_class_name %>Controller
+
setup do
@<%= singular_name %> = Factory(:<%= singular_name %>)
end
context "index action" do
setup do
get :index
end
should respond_with(:success)
should assign_to(:<%= plural_name %>)
end
context "new action" do
setup do
get :new
end
should render_template :new
end
context "create action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
post :create
end
should render_template :new
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
post :create
end
should redirect_to('') {<%= singular_name %>_path(assigns(:<%= singular_name %>))}
end
end
context "show action" do
setup do
get :show, :id => @<%= singular_name %>.to_param
end
should respond_with(:success)
end
context "edit action" do
setup do
get :edit, :id => @<%= singular_name %>.to_param
end
should render_template 'edit'
end
context "update action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should render_template :edit
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should redirect_to('') {<%= singular_name %>_path(@<%= singular_name %>)}
end
end
context "destroy action" do
setup do
delete :destroy, :id => @<%= singular_name %>.to_param
end
should redirect_to('index') { <%= plural_name %>_path }
should set_the_flash
should "destroy model" do
assert !<%= class_name %>.exists?(@<%= singular_name %>.id)
end
end
end
|
javierv/rails_templates
|
1a001593ca5edc3462b502a8ae879f629554320e
|
Usamos filtrador en el Ãndice.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 525de9f..4cd5ed5 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,89 +1,89 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
-gem 'simple_form'
+gem 'simple_form', :git => "/home/javi/programas/work/simple_form"
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', :git => "/home/javi/programas/work/tabletastic"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Idioma de la aplicación
application " config.time_zone = 'Madrid'"
application " config.i18n.default_locale = :es"
# Generadores por defecto
application " config.generators do |g|
g.stylesheets false
g.template_engine :haml
g.test_framework :shoulda
g.fixture_replacement :factory_girl
g.form_builder :simple_form
g.fallbacks[:shoulda] = :test_unit
end"
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
diff --git a/lib/haml/scaffold/index.html.haml.erb b/lib/haml/scaffold/index.html.haml.erb
index bccd4dc..848f9ba 100644
--- a/lib/haml/scaffold/index.html.haml.erb
+++ b/lib/haml/scaffold/index.html.haml.erb
@@ -1,6 +1,13 @@
- title "Listado de <%= plural_name %>"
+= simple_form_for @search, :class => 'search' do |form|
+ <%- for attribute in attributes -%>
+ = form.input :<%= attribute.name + "_contains" %>, :label => '<%= attribute.name.titleize %>',
+ :required => false
+ <%- end -%>
+ = form.submit 'Buscar'
+
= table_for @<%= plural_name %> do |table|
= table.data(:actions => :all)
= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
\ No newline at end of file
|
javierv/rails_templates
|
a30a3dd11a6d1df27842693d698961e2eac7a29c
|
Nombre de clase más adecuado en el test de controlador.
|
diff --git a/lib/test_unit/scaffold/functional_test.rb b/lib/test_unit/scaffold/functional_test.rb
index 3f39c66..4fa90c6 100644
--- a/lib/test_unit/scaffold/functional_test.rb
+++ b/lib/test_unit/scaffold/functional_test.rb
@@ -1,95 +1,95 @@
require 'test_helper'
-class <%= class_name %>ControllerTest < ActionController::TestCase
+class <%= controller_class_name %>ControllerTest < ActionController::TestCase
setup do
@<%= singular_name %> = Factory(:<%= singular_name %>)
end
context "index action" do
setup do
get :index
end
should respond_with(:success)
should assign_to(:<%= plural_name %>)
end
context "new action" do
setup do
get :new
end
should render_template :new
end
context "create action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
post :create
end
should render_template :new
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
post :create
end
should redirect_to('') {<%= singular_name %>_path(assigns(:<%= singular_name %>))}
end
end
context "show action" do
setup do
get :show, :id => @<%= singular_name %>.to_param
end
should respond_with(:success)
end
context "edit action" do
setup do
get :edit, :id => @<%= singular_name %>.to_param
end
should render_template 'edit'
end
context "update action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should render_template :edit
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should redirect_to('') {<%= singular_name %>_path(@<%= singular_name %>)}
end
end
context "destroy action" do
setup do
delete :destroy, :id => @<%= singular_name %>.to_param
end
should redirect_to('index') { <%= plural_name %>_path }
should set_the_flash
should "destroy model" do
assert !<%= class_name %>.exists?(@<%= singular_name %>.id)
end
end
end
|
javierv/rails_templates
|
3bed2d4e2f8313892e6e8a1482e99eeda4b8707d
|
Mientras no movamos mensajes de flash a otro lado, hay que indicar que las cadenas pueden llevar acentos.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index e967bfa..1eb2d1f 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,56 +1,58 @@
+# encoding: utf-8
+
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => [:show, :edit, :update, :destroy]
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
@search = <%= class_name %>.search params[:search]
@<%= table_name %> = @search.paginate :page => params[:page],
:per_page => <%= class_name %>.per_page
respond_with @<%= table_name %>
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= file_name %>.save
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= file_name %>.save
end
def destroy
<%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= file_name %>.destroy
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
cd1466783c1ea77872386070e7834c047d8db080
|
Error tonto de sintaxis.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 115273d..e967bfa 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,56 +1,56 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
- before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
+ before_filter :find_<%= file_name %>, :only => [:show, :edit, :update, :destroy]
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
@search = <%= class_name %>.search params[:search]
@<%= table_name %> = @search.paginate :page => params[:page],
:per_page => <%= class_name %>.per_page
respond_with @<%= table_name %>
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= file_name %>.save
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= file_name %>.save
end
def destroy
<%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= file_name %>.destroy
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
975847aed270fb957ed2632af4053536046624aa
|
Por alguna razón, orm_instance ha dejado de funcionar :S.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 6711d0e..115273d 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,56 +1,56 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
@search = <%= class_name %>.search params[:search]
@<%= table_name %> = @search.paginate :page => params[:page],
:per_page => <%= class_name %>.per_page
respond_with @<%= table_name %>
end
<% end -%>
def show
end
def new
end
def edit
end
def create
- <%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= orm_instance.save %>
+ <%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= file_name %>.save
end
def update
- <%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= orm_instance.save %>
+ <%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= file_name %>.save
end
def destroy
- <%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= orm_instance.destroy %>
+ <%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= file_name %>.destroy
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
658a702089420e251bc68d8098d86b61a0e97c82
|
Sustituimos métodos que no funcionaban.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index ecb5136..6711d0e 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,56 +1,56 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
- @search = <%= orm_class.search(class_name, "params[:search]") %>
+ @search = <%= class_name %>.search params[:search]
@<%= table_name %> = @search.paginate :page => params[:page],
- :per_page => <%= orm_class.per_page(class_name) %>
+ :per_page => <%= class_name %>.per_page
respond_with @<%= table_name %>
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= orm_instance.save %>
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= orm_instance.save %>
end
def destroy
<%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= orm_instance.destroy %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
38e2e105a1f343f51a4bf77fef2403ca2be18f1f
|
Fuera paréntesis si no son necesarios.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index d5414a2..ecb5136 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,56 +1,56 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
@search = <%= orm_class.search(class_name, "params[:search]") %>
@<%= table_name %> = @search.paginate :page => params[:page],
:per_page => <%= orm_class.per_page(class_name) %>
- respond_with(@<%= table_name %>)
+ respond_with @<%= table_name %>
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= orm_instance.save %>
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= orm_instance.save %>
end
def destroy
<%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= orm_instance.destroy %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
eee9c1060bec68fb4dca19b73a2683b1fdef47ee
|
HabÃa un error de sintaxis.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index a116428..d5414a2 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,56 +1,56 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
- @search = <%= orm_class.search(class_name, "params[:search]")
+ @search = <%= orm_class.search(class_name, "params[:search]") %>
@<%= table_name %> = @search.paginate :page => params[:page],
:per_page => <%= orm_class.per_page(class_name) %>
respond_with(@<%= table_name %>)
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= orm_instance.save %>
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= orm_instance.save %>
end
def destroy
<%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= orm_instance.destroy %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
207d45822806bc3fb974b7248c96ab3c9662bdeb
|
Existe una forma de generar la configuración de la aplicación desde aquÃ. La usamos.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index e1a6986..525de9f 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,85 +1,89 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', :git => "/home/javi/programas/work/tabletastic"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
+# Idioma de la aplicación
+application " config.time_zone = 'Madrid'"
+application " config.i18n.default_locale = :es"
+
+# Generadores por defecto
+application " config.generators do |g|
+ g.stylesheets false
+ g.template_engine :haml
+ g.test_framework :shoulda
+ g.fixture_replacement :factory_girl
+ g.form_builder :simple_form
+ g.fallbacks[:shoulda] = :test_unit
+ end"
+
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
-
-# Generadores (aparte)
-#config.generators do |g|
-# g.stylesheets false
-# g.template_engine :haml
-# g.test_framework :shoulda
-# g.fixture_replacement :factory_girl
-# g.form_builder :simple_form
-# g.fallbacks[:shoulda] = :test_unit
-#end
\ No newline at end of file
|
javierv/rails_templates
|
2d185530546efd03e72ae00773041e3289fa60b1
|
Quitamos referencia a archivo que ya no existe.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index d823a8c..e1a6986 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,86 +1,85 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', :git => "/home/javi/programas/work/tabletastic"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
-file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
|
javierv/rails_templates
|
265783b3caf5a76cce6583aa39dbafb9b3c21627
|
Usamos una versión de tabletastic que funciona con HAML.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index a07bab0..d823a8c 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,86 +1,86 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
-gem 'tabletastic', :git => "http://github.com/jgdavey/tabletastic.git"
+gem 'tabletastic', :git => "/home/javi/programas/work/tabletastic"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
diff --git a/lib/haml/scaffold/index.html.haml.erb b/lib/haml/scaffold/index.html.haml.erb
index a6b5f36..bccd4dc 100644
--- a/lib/haml/scaffold/index.html.haml.erb
+++ b/lib/haml/scaffold/index.html.haml.erb
@@ -1,5 +1,6 @@
- title "Listado de <%= plural_name %>"
-= table_for(@<%= plural_name %>) {|table| table.data(:actions => :all)}
+= table_for @<%= plural_name %> do |table|
+ = table.data(:actions => :all)
= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
\ No newline at end of file
|
javierv/rails_templates
|
4c512fc8a1aac41c55254fddef4857b9e658c780
|
font-face también viene ya en compass.
|
diff --git a/lib/_base.sass b/lib/_base.sass
deleted file mode 100644
index b2c7492..0000000
--- a/lib/_base.sass
+++ /dev/null
@@ -1,10 +0,0 @@
-@import "compass/css3"
-
-=font-face($font, $filename, $type: opentype)
- font-family: $font
- src: url("fonts/#{$filename}.eot")
- @if $type == "opentype"
- $extension: otf
- @else
- $extension: ttf
- src: local("#{$font} Regular"), local("#{$font}-Regular"), local(#{$font}), url("fonts/#{$filename}.#{$extension}") format(#{$type})
diff --git a/lib/application.sass b/lib/application.sass
index 2f1526e..b30412b 100644
--- a/lib/application.sass
+++ b/lib/application.sass
@@ -1,40 +1,40 @@
-@import partials/base.sass
+@import "compass/css3"
*
padding: 0
margin: 0
font-family: helvetica, arial, verdana, sans-serif
font-size: 1em
html
background-color: #4b7399
body
padding: 0.5em 1%
margin: 1em auto
font-size: 0.85em
width: 80em
max-width: 98%
border: solid 1px black
background-color: #fdfdfd
color: #333
a img
border: none
#flash_notice,
#flash_error
padding: 5px 8px
margin: 10px 0
#flash_notice
background-color: #cfc
border: 1px solid #6c6
#flash_error
background-color: #fcc
border: solid 1px #c66
.fieldWithErrors
display: inline
\ No newline at end of file
|
javierv/rails_templates
|
07eef078c3a19b44f824c912f7fcc84208cb526f
|
Las utilidades que estábamos usando y que provenÃan de Susy ahora están directamente en compass.
|
diff --git a/lib/_base.sass b/lib/_base.sass
index 9a5d514..b2c7492 100644
--- a/lib/_base.sass
+++ b/lib/_base.sass
@@ -1,8 +1,10 @@
+@import "compass/css3"
+
=font-face($font, $filename, $type: opentype)
font-family: $font
src: url("fonts/#{$filename}.eot")
@if $type == "opentype"
$extension: otf
@else
$extension: ttf
src: local("#{$font} Regular"), local("#{$font}-Regular"), local(#{$font}), url("fonts/#{$filename}.#{$extension}") format(#{$type})
diff --git a/lib/_utils.sass b/lib/_utils.sass
deleted file mode 100644
index 5ab6d25..0000000
--- a/lib/_utils.sass
+++ /dev/null
@@ -1,211 +0,0 @@
-@import compass/utilities.sass
-
-//*
-// removes all background images and colors from the element and offspring
-// then adds a grid image of your choosing. highlights divs on modern browsers
-=show-grid($src)
- background:
- image: image_url($src)
- repeat: repeat
- position: side_gutter() + unquote("% 0")
- *
- background: transparent
- div
- background: rgba(0, 0, 0, 0.125)
-
-//*
-// brings IE in line with inline-block display
-// - using hacks if called automatically because $hacks == true
-// - or without if you call it from ie.sass
-=ie-inline-block($hack: false)
- @if $hack
- /* ugly hacks for IE6-7
- #display: inline
- // fixes alignment against native input/button on IE6
- #vertical-align: auto
- /* end ugly hacks
- @else
- display: inline
- // fixes alignment against native input/button on IE6
- vertical-align: auto
-
-//*
-// an override for compass inline-block that lets you take advantage
-// of Susys $hacks constant. if true, hacks. if false, use ie-inline-block
-// to help ie along in your ie.sass
-=inline-block
- display: -moz-inline-box
- -moz-box-orient: vertical
- display: inline-block
- vertical-align: middle
- @if $hacks
- +ie-inline-block(unquote("*"))
-
-//*
-// an inline-block list that works in IE
-// for those awkward moments when a floated horizontal list just wont cut it
-// if global $hacks == false:
-// - you'll need to fix list items in ie.sass with +ie-inline-block
-=inline-block-list($hpad: 0)
- +horizontal-list-container
- li
- +no-bullet
- white-space: no-wrap
- +inline-block
- padding:
- left: $hpad
- right: $hpad
-
-//*
-// hide an element from the viewport, but keep it around for accessability
-=hide
- position: absolute
- top: -9999em
-
-//*
-// a skip-to-content accessibility link that will appear on focus
-// set the location arguments if you care where it appears
-=skip-link($t: 0, $r: false, $b: false, $l: false)
- +hide
- display: block
- &:focus
- @if $t
- top: $t
- @if $r
- right: $r
- @if $b
- bottom: $b
- @if $l
- left: $l
- z-index: 999
-
-// EXPERIMENTAL
-
-//*
-// [Opacity rules based on those in Compass Core Edge as of 7.18.09]
-// - These will be removed from Susy once they enter a major Compass release.
-// Provides cross-browser css opacity.
-// @param $opacity
-// A number between 0 and 1, where 0 is transparent and 1 is opaque.
-=opacity($opacity)
- opacity: $opacity
- -moz-opacity: $opacity
- -khtml-opacity: $opacity
- -ms-filter: unquote("progid:DXImageTransform.Microsoft.Alpha(Opacity=") + round($opacity * 100) + unquote(")")
- filter: unquote("alpha(opacity=") + round($opacity * 100) + unquote(")")
-
-// Make an element completely transparent.
-=transparent
- +opacity(0)
-
-// Make an element completely opaque.
-=opaque
- +opacity(1)
-
-//*
-// rounded corners for Mozilla, Webkit and the future
-=border-radius($r)
- /* Mozilla (FireFox, Camino)
- -moz-border-radius: $r
- /* Webkit (Safari, Chrome)
- -webkit-border-radius: $r
- -khtml-border-radius: $r
- /* CSS3
- border-radius: $r
-
-=border-corner-radius($vert, $horz, $r)
- /* Mozilla (FireFox, Camino)
- -moz-border-radius-\#{$vert}#{$horz}: $r
- /* Webkit (Safari, Chrome)
- -webkit-border-\#{$vert}-#{$horz}-radius: $r
- /* CSS3
- border-\#{$vert}-#{$horz}-radius: $r
-
-=border-top-left-radius($r)
- +border-corner-radius(top, left, $r)
-
-=border-top-right-radius($r)
- +border-corner-radius(top, right, $r)
-
-=border-bottom-right-radius($r)
- +border-corner-radius(bottom, right, $r)
-
-=border-bottom-left-radius($r)
- +border-corner-radius(bottom, left, $r)
-
-=border-top-radius($r)
- +border-top-left-radius($r)
- +border-top-right-radius($r)
-
-=border-right-radius($r)
- +border-top-right-radius($r)
- +border-bottom-right-radius($r)
-
-=border-bottom-radius($r)
- +border-bottom-right-radius($r)
- +border-bottom-left-radius($r)
-
-=border-left-radius($r)
- +border-top-left-radius($r)
- +border-bottom-left-radius($r)
-
-//*
-// change the box model for Mozilla, Webkit, IE8 and the future
-=box-sizing($bs)
- /* Mozilla (FireFox, Camino)
- -moz-box-sizing: $bs
- /* Webkit (Safari, Chrome)
- -webkit-box-sizing: $bs
- /* IE (8)
- -ms-box-sizing: $bs
- /* CSS3
- box-sizing: $bs
-
-//*
-// box shadow for Webkit and the future
-// - arguments are horizontal offset, vertical offset, blur and color
-=box-shadow($ho, $vo, $b, $c)
- /* Webkit (Safari, Chrome)
- -webkit-box-shadow: $ho $vo $b $c
- /* Mozilla (Firefox, Camino)
- -moz-box-shadow: $ho $vo $b $c
- /* CSS3
- box-shadow: $ho $vo $b $c
-
-//*
-// CSS3 columns for Mozilla, Webkit and the Future
-
-=column-count($n)
- -moz-column-count: $n
- -webkit-column-count: $n
- column-count: $n
-
-=column-gap($u)
- -moz-column-gap: $u
- -webkit-column-gap: $u
- column-gap: $u
-
-=column-width($u)
- -moz-column-width: $u
- -webkit-column-width: $u
- column-width: $u
-
-=column-rule-width($w)
- -moz-column-rule-width: $w
- -webkit-column-rule-width: $w
- column-rule-width: $w
-
-=column-rule-style($s)
- -moz-column-rule-style: $s
- -webkit-column-rule-style: $s
- column-rule-style: $s
-
-=column-rule-color($c)
- -moz-column-rule-color: $c
- -webkit-column-rule-color: $c
- column-rule-color: $c
-
-=column-rule($w, $s: solid, $c: unquote(" "))
- +column-rule-width($w)
- +column-rule-style($s)
- +column-rule-color($c)
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 43ac5a9..a07bab0 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,87 +1,86 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'tabletastic', :git => "http://github.com/jgdavey/tabletastic.git"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
-file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
file "lib/templates/haml/scaffold/index.html.haml.erb",
read_file("haml/scaffold/index.html.haml.erb")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
|
javierv/rails_templates
|
2da3ac1409ced54b258db9ba955c4eef40791137
|
Incluimos búsqueda además de paginación.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 3ba51a5..a116428 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,54 +1,56 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
- @<%= table_name %> = <%= orm_class.paginate(class_name, :page => params[:page]) %>
+ @search = <%= orm_class.search(class_name, "params[:search]")
+ @<%= table_name %> = @search.paginate :page => params[:page],
+ :per_page => <%= orm_class.per_page(class_name) %>
respond_with(@<%= table_name %>)
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= orm_instance.save %>
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= orm_instance.save %>
end
def destroy
<%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= orm_instance.destroy %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
a9a9dc2430a7536c8ff31b80e10addc80d021dcc
|
Mensaje de flash al borrar.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 0a8ff4e..3ba51a5 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,54 +1,54 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
@<%= table_name %> = <%= orm_class.paginate(class_name, :page => params[:page]) %>
respond_with(@<%= table_name %>)
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= orm_instance.save %>
end
def update
<%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= orm_instance.save %>
end
def destroy
- @<%= orm_instance.destroy %>
+ <%= "flash[:notice] = '#{class_name} se borró correctamente.' if " %>@<%= orm_instance.destroy %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
diff --git a/lib/test_unit/scaffold/functional_test.rb b/lib/test_unit/scaffold/functional_test.rb
index 50de4b0..3f39c66 100644
--- a/lib/test_unit/scaffold/functional_test.rb
+++ b/lib/test_unit/scaffold/functional_test.rb
@@ -1,95 +1,95 @@
require 'test_helper'
class <%= class_name %>ControllerTest < ActionController::TestCase
setup do
@<%= singular_name %> = Factory(:<%= singular_name %>)
end
context "index action" do
setup do
get :index
end
should respond_with(:success)
should assign_to(:<%= plural_name %>)
end
context "new action" do
setup do
get :new
end
should render_template :new
end
context "create action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
post :create
end
should render_template :new
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
post :create
end
should redirect_to('') {<%= singular_name %>_path(assigns(:<%= singular_name %>))}
end
end
context "show action" do
setup do
get :show, :id => @<%= singular_name %>.to_param
end
should respond_with(:success)
end
context "edit action" do
setup do
get :edit, :id => @<%= singular_name %>.to_param
end
should render_template 'edit'
end
context "update action" do
context "when model is invalid" do
setup do
errors = ActiveModel::Errors.new(<%= class_name %>.new)
errors.add_on_blank(:id)
<%= class_name %>.any_instance.stubs(:errors).returns(errors)
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should render_template :edit
end
context "when model is valid" do
setup do
<%= class_name %>.any_instance.stubs(:errors).returns({})
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
end
should redirect_to('') {<%= singular_name %>_path(@<%= singular_name %>)}
end
end
context "destroy action" do
setup do
delete :destroy, :id => @<%= singular_name %>.to_param
end
should redirect_to('index') { <%= plural_name %>_path }
- # should_set_the_flash_to //
+ should set_the_flash
should "destroy model" do
assert !<%= class_name %>.exists?(@<%= singular_name %>.id)
end
end
end
|
javierv/rails_templates
|
969ec406fe38ab441a7639f9b63b0519d3a2bbc4
|
Mensajes de flash en español.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 76c785c..0a8ff4e 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,54 +1,54 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
@<%= table_name %> = <%= orm_class.paginate(class_name, :page => params[:page]) %>
respond_with(@<%= table_name %>)
end
<% end -%>
def show
end
def new
end
def edit
end
def create
- <%= "flash[:notice] = '#{class_name} was successfully created.' if " %>@<%= orm_instance.save %>
+ <%= "flash[:notice] = '#{class_name} se creó correctamente.' if " %>@<%= orm_instance.save %>
end
def update
- <%= "flash[:notice] = '#{class_name} was successfully updated.' if " %>@<%= orm_instance.save %>
+ <%= "flash[:notice] = '#{class_name} se actualizó correctamente.' if " %>@<%= orm_instance.save %>
end
def destroy
@<%= orm_instance.destroy %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
a4d9f35890fb1a3796afcb1169454efd7c7bc960
|
Incluimos paginación en el Ãndice.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 3ae34ee..76c785c 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,54 +1,54 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
after_filter :respond_with_<%= file_name %>, :except => :index
<% unless options[:singleton] -%>
def index
- @<%= table_name %> = <%= orm_class.all(class_name) %>
+ @<%= table_name %> = <%= orm_class.paginate(class_name, :page => params[:page]) %>
respond_with(@<%= table_name %>)
end
<% end -%>
def show
end
def new
end
def edit
end
def create
<%= "flash[:notice] = '#{class_name} was successfully created.' if " %>@<%= orm_instance.save %>
end
def update
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " %>@<%= orm_instance.save %>
end
def destroy
@<%= orm_instance.destroy %>
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
def respond_with_<%= file_name %>
respond_with @<%= file_name %>
end
end
|
javierv/rails_templates
|
b8e4bf8357f4b8af9aa976a1ac59e771b37e0bd2
|
after_filter con respond_with para quitar duplicación.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index 78dffb8..3ae34ee 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,52 +1,54 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
+
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
before_filter :new_<%= file_name %>, :only => [:new, :create]
before_filter :update_<%= file_name %>, :only => :update
+ after_filter :respond_with_<%= file_name %>, :except => :index
+
<% unless options[:singleton] -%>
def index
@<%= table_name %> = <%= orm_class.all(class_name) %>
respond_with(@<%= table_name %>)
end
<% end -%>
- def show
- respond_with(@<%= file_name %>)
+ def show
end
def new
- respond_with(@<%= file_name %>)
end
def edit
end
def create
- <%= "flash[:notice] = '#{class_name} was successfully created.' if " %>@<%= orm_instance.save %>
- respond_with(@<%= file_name %>)
+ <%= "flash[:notice] = '#{class_name} was successfully created.' if " %>@<%= orm_instance.save %>
end
def update
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " %>@<%= orm_instance.save %>
- respond_with(@<%= file_name %>)
end
def destroy
@<%= orm_instance.destroy %>
- respond_with(@<%= file_name %>)
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def new_<%= file_name %>
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
end
def update_<%= file_name %>
@<%= file_name %>.attributes = params[:<%= file_name %>]
end
+
+ def respond_with_<%= file_name %>
+ respond_with @<%= file_name %>
+ end
end
|
javierv/rails_templates
|
a3d506ab688c1b3d4e2b03461520dedd9030a754
|
before_filter para todas las acciones, asignando el elemento.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index f6398a8..78dffb8 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,44 +1,52 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
+ before_filter :new_<%= file_name %>, :only => [:new, :create]
+ before_filter :update_<%= file_name %>, :only => :update
<% unless options[:singleton] -%>
def index
@<%= table_name %> = <%= orm_class.all(class_name) %>
respond_with(@<%= table_name %>)
end
<% end -%>
def show
respond_with(@<%= file_name %>)
end
def new
- @<%= file_name %> = <%= orm_class.build(class_name) %>
respond_with(@<%= file_name %>)
end
def edit
end
def create
- @<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
<%= "flash[:notice] = '#{class_name} was successfully created.' if " %>@<%= orm_instance.save %>
respond_with(@<%= file_name %>)
end
def update
- <%= "flash[:notice] = '#{class_name} was successfully updated.' if " %>@<%= orm_instance.update_attributes("params[:#{file_name}]") %>
+ <%= "flash[:notice] = '#{class_name} was successfully updated.' if " %>@<%= orm_instance.save %>
respond_with(@<%= file_name %>)
end
def destroy
@<%= orm_instance.destroy %>
respond_with(@<%= file_name %>)
end
private
def find_<%= file_name %>
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
+
+ def new_<%= file_name %>
+ @<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
+ end
+
+ def update_<%= file_name %>
+ @<%= file_name %>.attributes = params[:<%= file_name %>]
+ end
end
|
javierv/rails_templates
|
d87446487ffd38d62d31b1bdcfec9b46ed9ed272
|
Usamos before_filter en el controlador para quitar duplicación.
|
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
index b308d08..f6398a8 100644
--- a/lib/rails/scaffold_controller/controller.rb
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -1,42 +1,44 @@
class <%= controller_class_name %>Controller < ApplicationController
respond_to :html
+ before_filter :find_<%= file_name %>, :only => :show, :edit, :update, :destroy
<% unless options[:singleton] -%>
def index
@<%= table_name %> = <%= orm_class.all(class_name) %>
respond_with(@<%= table_name %>)
end
<% end -%>
- def show
- @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
+ def show
respond_with(@<%= file_name %>)
end
def new
@<%= file_name %> = <%= orm_class.build(class_name) %>
respond_with(@<%= file_name %>)
end
def edit
- @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
def create
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
<%= "flash[:notice] = '#{class_name} was successfully created.' if " %>@<%= orm_instance.save %>
respond_with(@<%= file_name %>)
end
def update
- @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " %>@<%= orm_instance.update_attributes("params[:#{file_name}]") %>
respond_with(@<%= file_name %>)
end
def destroy
- @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
@<%= orm_instance.destroy %>
respond_with(@<%= file_name %>)
end
+
+private
+ def find_<%= file_name %>
+ @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
+ end
end
|
javierv/rails_templates
|
29df78f144bc9585d9a39dbb606c2efc712c603c
|
Usamos tabletastic para generar tablas en los Ãndices.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index c51c1e7..43ac5a9 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,83 +1,87 @@
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
+gem 'tabletastic', :git => "http://github.com/jgdavey/tabletastic.git"
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
file "lib/templates/rails/scaffold_controller/controller.rb",
read_file("rails/scaffold_controller/controller.rb")
+file "lib/templates/haml/scaffold/index.html.haml.erb",
+ read_file("haml/scaffold/index.html.haml.erb")
+
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
diff --git a/lib/haml/scaffold/index.html.haml.erb b/lib/haml/scaffold/index.html.haml.erb
new file mode 100644
index 0000000..a6b5f36
--- /dev/null
+++ b/lib/haml/scaffold/index.html.haml.erb
@@ -0,0 +1,5 @@
+- title "Listado de <%= plural_name %>"
+
+= table_for(@<%= plural_name %>) {|table| table.data(:actions => :all)}
+
+= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
\ No newline at end of file
|
javierv/rails_templates
|
76ef54dee72e08b3099fae325f999dab110b0998
|
Me gustan más las minúsculas.
|
diff --git a/lib/application.sass b/lib/application.sass
index afee41e..2f1526e 100644
--- a/lib/application.sass
+++ b/lib/application.sass
@@ -1,40 +1,40 @@
@import partials/base.sass
*
padding: 0
margin: 0
font-family: helvetica, arial, verdana, sans-serif
font-size: 1em
html
background-color: #4b7399
body
padding: 0.5em 1%
margin: 1em auto
font-size: 0.85em
width: 80em
max-width: 98%
border: solid 1px black
background-color: #fdfdfd
color: #333
a img
border: none
#flash_notice,
#flash_error
padding: 5px 8px
margin: 10px 0
#flash_notice
- background-color: #CFC
- border: 1px solid #6C6
+ background-color: #cfc
+ border: 1px solid #6c6
#flash_error
- background-color: #FCC
- border: solid 1px #C66
+ background-color: #fcc
+ border: solid 1px #c66
.fieldWithErrors
display: inline
\ No newline at end of file
|
javierv/rails_templates
|
21ff0c72831a217ca720466135e17bc4d2cf7d33
|
Convertimos a SASS 3.0.
|
diff --git a/lib/_base.sass b/lib/_base.sass
index 0dfe241..9a5d514 100644
--- a/lib/_base.sass
+++ b/lib/_base.sass
@@ -1,11 +1,8 @@
-extension = ""
-
-=font-face(!font,!filename, !type = "opentype")
- font-family: \#{!font}
- src: url("fonts/\#{!filename}.eot")
- @if !type == "opentype"
- !extension = "otf"
+=font-face($font, $filename, $type: opentype)
+ font-family: $font
+ src: url("fonts/#{$filename}.eot")
+ @if $type == "opentype"
+ $extension: otf
@else
- !extension = "ttf"
-
- src: local("\#{!font} Regular"), local("\#{!font}-Regular"), local("\#{!font}"), url("fonts/\#{!filename}.\#{!extension}") format("\#{!type}")
+ $extension: ttf
+ src: local("#{$font} Regular"), local("#{$font}-Regular"), local(#{$font}), url("fonts/#{$filename}.#{$extension}") format(#{$type})
diff --git a/lib/_utils.sass b/lib/_utils.sass
index 39d3ba4..5ab6d25 100644
--- a/lib/_utils.sass
+++ b/lib/_utils.sass
@@ -1,212 +1,211 @@
@import compass/utilities.sass
-//**
- removes all background images and colors from the element and offspring
- then adds a grid image of your choosing. highlights divs on modern browsers
-=show-grid(!src)
- :background
- :image= image_url(!src)
- :repeat repeat
- :position= side_gutter() + "% 0"
+//*
+// removes all background images and colors from the element and offspring
+// then adds a grid image of your choosing. highlights divs on modern browsers
+=show-grid($src)
+ background:
+ image: image_url($src)
+ repeat: repeat
+ position: side_gutter() + unquote("% 0")
*
- :background transparent
+ background: transparent
div
- :background rgba(0,0,0,.125)
-
-//**
- brings IE in line with inline-block display
- - using hacks if called automatically because !hacks == true
- - or without if you call it from ie.sass
-=ie-inline-block(!hack = false)
- @if !hack
- /* ugly hacks for IE6-7 */
- :#display inline
+ background: rgba(0, 0, 0, 0.125)
+
+//*
+// brings IE in line with inline-block display
+// - using hacks if called automatically because $hacks == true
+// - or without if you call it from ie.sass
+=ie-inline-block($hack: false)
+ @if $hack
+ /* ugly hacks for IE6-7
+ #display: inline
// fixes alignment against native input/button on IE6
- :#vertical-align auto
- /* end ugly hacks */
+ #vertical-align: auto
+ /* end ugly hacks
@else
- :display inline
+ display: inline
// fixes alignment against native input/button on IE6
- :vertical-align auto
+ vertical-align: auto
-//**
- an override for compass inline-block that lets you take advantage
- of Susys !hacks constant. if true, hacks. if false, use ie-inline-block
- to help ie along in your ie.sass
+//*
+// an override for compass inline-block that lets you take advantage
+// of Susys $hacks constant. if true, hacks. if false, use ie-inline-block
+// to help ie along in your ie.sass
=inline-block
- :display -moz-inline-box
- :-moz-box-orient vertical
- :display inline-block
- :vertical-align middle
- @if !hacks
- +ie-inline-block("*")
-
-//**
- an inline-block list that works in IE
- for those awkward moments when a floated horizontal list just wont cut it
- if global !hacks == false:
- - you'll need to fix list items in ie.sass with +ie-inline-block
-=inline-block-list(!hpad = 0)
+ display: -moz-inline-box
+ -moz-box-orient: vertical
+ display: inline-block
+ vertical-align: middle
+ @if $hacks
+ +ie-inline-block(unquote("*"))
+
+//*
+// an inline-block list that works in IE
+// for those awkward moments when a floated horizontal list just wont cut it
+// if global $hacks == false:
+// - you'll need to fix list items in ie.sass with +ie-inline-block
+=inline-block-list($hpad: 0)
+horizontal-list-container
li
+no-bullet
- :white-space no-wrap
+ white-space: no-wrap
+inline-block
- :padding
- :left= !hpad
- :right= !hpad
+ padding:
+ left: $hpad
+ right: $hpad
-//**
- hide an element from the viewport, but keep it around for accessability
+//*
+// hide an element from the viewport, but keep it around for accessability
=hide
- :position absolute
- :top -9999em
+ position: absolute
+ top: -9999em
-//**
- a skip-to-content accessibility link that will appear on focus
- set the location arguments if you care where it appears
-=skip-link(!t = 0, !r = false, !b = false, !l = false)
+//*
+// a skip-to-content accessibility link that will appear on focus
+// set the location arguments if you care where it appears
+=skip-link($t: 0, $r: false, $b: false, $l: false)
+hide
- :display block
+ display: block
&:focus
- @if !t
- :top= !t
- @if !r
- :right= !r
- @if !b
- :bottom= !b
- @if !l
- :left= !l
- :z-index 999
+ @if $t
+ top: $t
+ @if $r
+ right: $r
+ @if $b
+ bottom: $b
+ @if $l
+ left: $l
+ z-index: 999
// EXPERIMENTAL
-//**
- [Opacity rules based on those in Compass Core Edge as of 7.18.09]
- - These will be removed from Susy once they enter a major Compass release.
- Provides cross-browser css opacity.
- @param !opacity
- A number between 0 and 1, where 0 is transparent and 1 is opaque.
-=opacity(!opacity)
- :opacity= !opacity
- :-moz-opacity= !opacity
- :-khtml-opacity= !opacity
- :-ms-filter= "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + round(!opacity*100) + ")"
- :filter= "alpha(opacity=" + round(!opacity*100) + ")"
+//*
+// [Opacity rules based on those in Compass Core Edge as of 7.18.09]
+// - These will be removed from Susy once they enter a major Compass release.
+// Provides cross-browser css opacity.
+// @param $opacity
+// A number between 0 and 1, where 0 is transparent and 1 is opaque.
+=opacity($opacity)
+ opacity: $opacity
+ -moz-opacity: $opacity
+ -khtml-opacity: $opacity
+ -ms-filter: unquote("progid:DXImageTransform.Microsoft.Alpha(Opacity=") + round($opacity * 100) + unquote(")")
+ filter: unquote("alpha(opacity=") + round($opacity * 100) + unquote(")")
// Make an element completely transparent.
=transparent
+opacity(0)
// Make an element completely opaque.
=opaque
+opacity(1)
-//**
- rounded corners for Mozilla, Webkit and the future
-=border-radius(!r)
+//*
+// rounded corners for Mozilla, Webkit and the future
+=border-radius($r)
/* Mozilla (FireFox, Camino)
- -moz-border-radius = !r
+ -moz-border-radius: $r
/* Webkit (Safari, Chrome)
- -webkit-border-radius = !r
- -khtml-border-radius = !r
+ -webkit-border-radius: $r
+ -khtml-border-radius: $r
/* CSS3
- border-radius = !r
+ border-radius: $r
-=border-corner-radius(!vert, !horz, !r)
+=border-corner-radius($vert, $horz, $r)
/* Mozilla (FireFox, Camino)
- -moz-border-radius-\#{!vert}\#{!horz}= !r
+ -moz-border-radius-\#{$vert}#{$horz}: $r
/* Webkit (Safari, Chrome)
- -webkit-border-\#{!vert}-\#{!horz}-radius= !r
+ -webkit-border-\#{$vert}-#{$horz}-radius: $r
/* CSS3
- border-\#{!vert}-\#{!horz}-radius= !r
+ border-\#{$vert}-#{$horz}-radius: $r
-=border-top-left-radius(!r)
- +border-corner-radius("top", "left", !r)
+=border-top-left-radius($r)
+ +border-corner-radius(top, left, $r)
-=border-top-right-radius(!r)
- +border-corner-radius("top", "right", !r)
+=border-top-right-radius($r)
+ +border-corner-radius(top, right, $r)
-=border-bottom-right-radius(!r)
- +border-corner-radius("bottom", "right", !r)
+=border-bottom-right-radius($r)
+ +border-corner-radius(bottom, right, $r)
-=border-bottom-left-radius(!r)
- +border-corner-radius("bottom", "left", !r)
+=border-bottom-left-radius($r)
+ +border-corner-radius(bottom, left, $r)
-=border-top-radius(!r)
- +border-top-left-radius(!r)
- +border-top-right-radius(!r)
+=border-top-radius($r)
+ +border-top-left-radius($r)
+ +border-top-right-radius($r)
-=border-right-radius(!r)
- +border-top-right-radius(!r)
- +border-bottom-right-radius(!r)
+=border-right-radius($r)
+ +border-top-right-radius($r)
+ +border-bottom-right-radius($r)
-=border-bottom-radius(!r)
- +border-bottom-right-radius(!r)
- +border-bottom-left-radius(!r)
+=border-bottom-radius($r)
+ +border-bottom-right-radius($r)
+ +border-bottom-left-radius($r)
-=border-left-radius(!r)
- +border-top-left-radius(!r)
- +border-bottom-left-radius(!r)
+=border-left-radius($r)
+ +border-top-left-radius($r)
+ +border-bottom-left-radius($r)
-//**
- change the box model for Mozilla, Webkit, IE8 and the future
-=box-sizing(!bs)
+//*
+// change the box model for Mozilla, Webkit, IE8 and the future
+=box-sizing($bs)
/* Mozilla (FireFox, Camino)
- -moz-box-sizing= !bs
+ -moz-box-sizing: $bs
/* Webkit (Safari, Chrome)
- -webkit-box-sizing= !bs
+ -webkit-box-sizing: $bs
/* IE (8)
- -ms-box-sizing= !bs
+ -ms-box-sizing: $bs
/* CSS3
- box-sizing= !bs
+ box-sizing: $bs
-//**
- box shadow for Webkit and the future
- - arguments are horizontal offset, vertical offset, blur and color
-=box-shadow(!ho, !vo, !b, !c )
+//*
+// box shadow for Webkit and the future
+// - arguments are horizontal offset, vertical offset, blur and color
+=box-shadow($ho, $vo, $b, $c)
/* Webkit (Safari, Chrome)
- -webkit-box-shadow= !ho !vo !b !c
+ -webkit-box-shadow: $ho $vo $b $c
/* Mozilla (Firefox, Camino)
- -moz-box-shadow= !ho !vo !b !c
+ -moz-box-shadow: $ho $vo $b $c
/* CSS3
- box-shadow= !ho !vo !b !c
-
-
-//**
- CSS3 columns for Mozilla, Webkit and the Future
-
-=column-count(!n)
- :-moz-column-count= !n
- :-webkit-column-count= !n
- :column-count= !n
-
-=column-gap(!u)
- :-moz-column-gap= !u
- :-webkit-column-gap= !u
- :column-gap= !u
-
-=column-width(!u)
- :-moz-column-width= !u
- :-webkit-column-width= !u
- :column-width= !u
-
-=column-rule-width(!w)
- :-moz-column-rule-width= !w
- :-webkit-column-rule-width= !w
- :column-rule-width= !w
-
-=column-rule-style(!s)
- :-moz-column-rule-style= !s
- :-webkit-column-rule-style= !s
- :column-rule-style= !s
-
-=column-rule-color(!c)
- :-moz-column-rule-color= !c
- :-webkit-column-rule-color= !c
- :column-rule-color= !c
-
-=column-rule(!w, !s = "solid", !c = " ")
- +column-rule-width(!w)
- +column-rule-style(!s)
- +column-rule-color(!c)
\ No newline at end of file
+ box-shadow: $ho $vo $b $c
+
+//*
+// CSS3 columns for Mozilla, Webkit and the Future
+
+=column-count($n)
+ -moz-column-count: $n
+ -webkit-column-count: $n
+ column-count: $n
+
+=column-gap($u)
+ -moz-column-gap: $u
+ -webkit-column-gap: $u
+ column-gap: $u
+
+=column-width($u)
+ -moz-column-width: $u
+ -webkit-column-width: $u
+ column-width: $u
+
+=column-rule-width($w)
+ -moz-column-rule-width: $w
+ -webkit-column-rule-width: $w
+ column-rule-width: $w
+
+=column-rule-style($s)
+ -moz-column-rule-style: $s
+ -webkit-column-rule-style: $s
+ column-rule-style: $s
+
+=column-rule-color($c)
+ -moz-column-rule-color: $c
+ -webkit-column-rule-color: $c
+ column-rule-color: $c
+
+=column-rule($w, $s: solid, $c: unquote(" "))
+ +column-rule-width($w)
+ +column-rule-style($s)
+ +column-rule-color($c)
|
javierv/rails_templates
|
7cb53da2cf3b6ceda2c540f6b1bd0e460caad532
|
Template de controlador con respond_with. Nos evitamos asà depender de responders, y además corregimos el generador que dan ellos.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 0c50a19..c51c1e7 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,81 +1,83 @@
-gem 'responders'
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Templates
file "lib/templates/test_unit/scaffold/functional_test.rb",
read_file("test_unit/scaffold/functional_test.rb")
+file "lib/templates/rails/scaffold_controller/controller.rb",
+ read_file("rails/scaffold_controller/controller.rb")
+
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
diff --git a/lib/rails/scaffold_controller/controller.rb b/lib/rails/scaffold_controller/controller.rb
new file mode 100644
index 0000000..b308d08
--- /dev/null
+++ b/lib/rails/scaffold_controller/controller.rb
@@ -0,0 +1,42 @@
+class <%= controller_class_name %>Controller < ApplicationController
+ respond_to :html
+
+<% unless options[:singleton] -%>
+ def index
+ @<%= table_name %> = <%= orm_class.all(class_name) %>
+ respond_with(@<%= table_name %>)
+ end
+<% end -%>
+
+ def show
+ @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
+ respond_with(@<%= file_name %>)
+ end
+
+ def new
+ @<%= file_name %> = <%= orm_class.build(class_name) %>
+ respond_with(@<%= file_name %>)
+ end
+
+ def edit
+ @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
+ end
+
+ def create
+ @<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
+ <%= "flash[:notice] = '#{class_name} was successfully created.' if " %>@<%= orm_instance.save %>
+ respond_with(@<%= file_name %>)
+ end
+
+ def update
+ @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
+ <%= "flash[:notice] = '#{class_name} was successfully updated.' if " %>@<%= orm_instance.update_attributes("params[:#{file_name}]") %>
+ respond_with(@<%= file_name %>)
+ end
+
+ def destroy
+ @<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
+ @<%= orm_instance.destroy %>
+ respond_with(@<%= file_name %>)
+ end
+end
|
javierv/rails_templates
|
1408237a6b428a283542c1e6c01aa0b065e92a09
|
Incluimos template para test de controlador.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index e75005c..0c50a19 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,77 +1,81 @@
gem 'responders'
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
+# Templates
+file "lib/templates/test_unit/scaffold/functional_test.rb",
+ read_file("test_unit/scaffold/functional_test.rb")
+
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
diff --git a/lib/test_unit/scaffold/functional_test.rb b/lib/test_unit/scaffold/functional_test.rb
new file mode 100644
index 0000000..50de4b0
--- /dev/null
+++ b/lib/test_unit/scaffold/functional_test.rb
@@ -0,0 +1,95 @@
+require 'test_helper'
+
+class <%= class_name %>ControllerTest < ActionController::TestCase
+ setup do
+ @<%= singular_name %> = Factory(:<%= singular_name %>)
+ end
+
+ context "index action" do
+ setup do
+ get :index
+ end
+
+ should respond_with(:success)
+ should assign_to(:<%= plural_name %>)
+ end
+
+ context "new action" do
+ setup do
+ get :new
+ end
+ should render_template :new
+ end
+
+ context "create action" do
+ context "when model is invalid" do
+ setup do
+ errors = ActiveModel::Errors.new(<%= class_name %>.new)
+ errors.add_on_blank(:id)
+ <%= class_name %>.any_instance.stubs(:errors).returns(errors)
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ post :create
+ end
+
+ should render_template :new
+ end
+
+ context "when model is valid" do
+ setup do
+ <%= class_name %>.any_instance.stubs(:errors).returns({})
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ post :create
+ end
+ should redirect_to('') {<%= singular_name %>_path(assigns(:<%= singular_name %>))}
+ end
+ end
+
+ context "show action" do
+ setup do
+ get :show, :id => @<%= singular_name %>.to_param
+ end
+ should respond_with(:success)
+ end
+
+ context "edit action" do
+ setup do
+ get :edit, :id => @<%= singular_name %>.to_param
+ end
+ should render_template 'edit'
+ end
+
+ context "update action" do
+ context "when model is invalid" do
+ setup do
+ errors = ActiveModel::Errors.new(<%= class_name %>.new)
+ errors.add_on_blank(:id)
+ <%= class_name %>.any_instance.stubs(:errors).returns(errors)
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
+ put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
+ end
+
+ should render_template :edit
+ end
+
+ context "when model is valid" do
+ setup do
+ <%= class_name %>.any_instance.stubs(:errors).returns({})
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
+ put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
+ end
+ should redirect_to('') {<%= singular_name %>_path(@<%= singular_name %>)}
+ end
+ end
+
+ context "destroy action" do
+ setup do
+ delete :destroy, :id => @<%= singular_name %>.to_param
+ end
+
+ should redirect_to('index') { <%= plural_name %>_path }
+ # should_set_the_flash_to //
+ should "destroy model" do
+ assert !<%= class_name %>.exists?(@<%= singular_name %>.id)
+ end
+ end
+end
|
javierv/rails_templates
|
e62aa6ad347c9832cf6ec917f4bd83ec73299aba
|
Quitamos delayed_job hasta que sea 100% compatible con Rails3.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index d565903..e75005c 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,78 +1,77 @@
gem 'responders'
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
-gem 'delayed_job'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
|
javierv/rails_templates
|
4093bc6ee1871a42b52bb27b90fa06b531b2bd87
|
Quitamos bullet de momento: no es compatible con Rails 3.0RC.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 68b4cd7..d565903 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,79 +1,78 @@
gem 'responders'
gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'delayed_job'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
-gem 'bullet', :group => :development
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
|
javierv/rails_templates
|
933d3a61e6c0d8be814c448aaf3a113260d3f2b0
|
La versión estable de devise ya es compatible.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 26335e6..68b4cd7 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,79 +1,79 @@
gem 'responders'
-gem 'devise', ">= 1.1rc1"
+gem 'devise'
gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'delayed_job'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'bullet', :group => :development
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
|
javierv/rails_templates
|
3988fea37faaf668871f61b60de62c7efe27561a
|
La versión "estable" de will_paginate de momento no es compatible con Rails 3.
|
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
index 904d90c..26335e6 100644
--- a/lib/app_template_3.rb
+++ b/lib/app_template_3.rb
@@ -1,79 +1,79 @@
gem 'responders'
gem 'devise', ">= 1.1rc1"
-gem 'will_paginate'
+gem 'will_paginate', ">= 3.0.pre"
gem 'paperclip'
gem 'haml'
gem 'compass'
gem 'delayed_job'
gem 'acts-as-taggable-on'
gem 'validation_reflection'
gem 'RedCloth'
gem 'validates_date_time'
gem 'simple_form'
gem 'meta_where'
gem 'meta_search'
gem 'bullet', :group => :development
gem 'rails3-generators', :group => :development
gem 'shoulda', :group => :test
gem 'factory_girl_rails', :group => :test
gem 'mocha', :group => :test
gem 'capybara', :group => :test
run "bundle install"
def read_file(file)
File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
end
# Layout
run "rm app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", read_file("application.html.haml")
# SASS
run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
run "rm app/stylesheets/*.sass"
run "mkdir app/stylesheets/partials"
file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
file "app/stylesheets/application.sass", read_file("application.sass")
# Gitignore
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
run "rm .gitignore"
file ".gitignore", read_file("gitignore")
# Logo e Ãndice no necesitados
run "rm public/images/rails.png"
run "rm public/index.html"
# Javascript
run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
# Traducciones
run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
run "rm config/initializers/inflections.rb"
file "config/initializers/inflections.rb", read_file("inflections.rb")
file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
# Commit
run "echo TODO > README"
git :init
git :add => "."
git :commit => "-m 'Primer commit'"
# Generadores (aparte)
#config.generators do |g|
# g.stylesheets false
# g.template_engine :haml
# g.test_framework :shoulda
# g.fixture_replacement :factory_girl
# g.form_builder :simple_form
# g.fallbacks[:shoulda] = :test_unit
#end
\ No newline at end of file
|
javierv/rails_templates
|
f7c08f652046aac39d956c3b57de0b9cdadc2551
|
En vez de tener un único archivo para todo, separamos las cosas en varios archivos.
|
diff --git a/lib/_base.sass b/lib/_base.sass
new file mode 100644
index 0000000..0dfe241
--- /dev/null
+++ b/lib/_base.sass
@@ -0,0 +1,11 @@
+extension = ""
+
+=font-face(!font,!filename, !type = "opentype")
+ font-family: \#{!font}
+ src: url("fonts/\#{!filename}.eot")
+ @if !type == "opentype"
+ !extension = "otf"
+ @else
+ !extension = "ttf"
+
+ src: local("\#{!font} Regular"), local("\#{!font}-Regular"), local("\#{!font}"), url("fonts/\#{!filename}.\#{!extension}") format("\#{!type}")
diff --git a/lib/_utils.sass b/lib/_utils.sass
new file mode 100644
index 0000000..39d3ba4
--- /dev/null
+++ b/lib/_utils.sass
@@ -0,0 +1,212 @@
+@import compass/utilities.sass
+
+//**
+ removes all background images and colors from the element and offspring
+ then adds a grid image of your choosing. highlights divs on modern browsers
+=show-grid(!src)
+ :background
+ :image= image_url(!src)
+ :repeat repeat
+ :position= side_gutter() + "% 0"
+ *
+ :background transparent
+ div
+ :background rgba(0,0,0,.125)
+
+//**
+ brings IE in line with inline-block display
+ - using hacks if called automatically because !hacks == true
+ - or without if you call it from ie.sass
+=ie-inline-block(!hack = false)
+ @if !hack
+ /* ugly hacks for IE6-7 */
+ :#display inline
+ // fixes alignment against native input/button on IE6
+ :#vertical-align auto
+ /* end ugly hacks */
+ @else
+ :display inline
+ // fixes alignment against native input/button on IE6
+ :vertical-align auto
+
+//**
+ an override for compass inline-block that lets you take advantage
+ of Susys !hacks constant. if true, hacks. if false, use ie-inline-block
+ to help ie along in your ie.sass
+=inline-block
+ :display -moz-inline-box
+ :-moz-box-orient vertical
+ :display inline-block
+ :vertical-align middle
+ @if !hacks
+ +ie-inline-block("*")
+
+//**
+ an inline-block list that works in IE
+ for those awkward moments when a floated horizontal list just wont cut it
+ if global !hacks == false:
+ - you'll need to fix list items in ie.sass with +ie-inline-block
+=inline-block-list(!hpad = 0)
+ +horizontal-list-container
+ li
+ +no-bullet
+ :white-space no-wrap
+ +inline-block
+ :padding
+ :left= !hpad
+ :right= !hpad
+
+//**
+ hide an element from the viewport, but keep it around for accessability
+=hide
+ :position absolute
+ :top -9999em
+
+//**
+ a skip-to-content accessibility link that will appear on focus
+ set the location arguments if you care where it appears
+=skip-link(!t = 0, !r = false, !b = false, !l = false)
+ +hide
+ :display block
+ &:focus
+ @if !t
+ :top= !t
+ @if !r
+ :right= !r
+ @if !b
+ :bottom= !b
+ @if !l
+ :left= !l
+ :z-index 999
+
+// EXPERIMENTAL
+
+//**
+ [Opacity rules based on those in Compass Core Edge as of 7.18.09]
+ - These will be removed from Susy once they enter a major Compass release.
+ Provides cross-browser css opacity.
+ @param !opacity
+ A number between 0 and 1, where 0 is transparent and 1 is opaque.
+=opacity(!opacity)
+ :opacity= !opacity
+ :-moz-opacity= !opacity
+ :-khtml-opacity= !opacity
+ :-ms-filter= "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + round(!opacity*100) + ")"
+ :filter= "alpha(opacity=" + round(!opacity*100) + ")"
+
+// Make an element completely transparent.
+=transparent
+ +opacity(0)
+
+// Make an element completely opaque.
+=opaque
+ +opacity(1)
+
+//**
+ rounded corners for Mozilla, Webkit and the future
+=border-radius(!r)
+ /* Mozilla (FireFox, Camino)
+ -moz-border-radius = !r
+ /* Webkit (Safari, Chrome)
+ -webkit-border-radius = !r
+ -khtml-border-radius = !r
+ /* CSS3
+ border-radius = !r
+
+=border-corner-radius(!vert, !horz, !r)
+ /* Mozilla (FireFox, Camino)
+ -moz-border-radius-\#{!vert}\#{!horz}= !r
+ /* Webkit (Safari, Chrome)
+ -webkit-border-\#{!vert}-\#{!horz}-radius= !r
+ /* CSS3
+ border-\#{!vert}-\#{!horz}-radius= !r
+
+=border-top-left-radius(!r)
+ +border-corner-radius("top", "left", !r)
+
+=border-top-right-radius(!r)
+ +border-corner-radius("top", "right", !r)
+
+=border-bottom-right-radius(!r)
+ +border-corner-radius("bottom", "right", !r)
+
+=border-bottom-left-radius(!r)
+ +border-corner-radius("bottom", "left", !r)
+
+=border-top-radius(!r)
+ +border-top-left-radius(!r)
+ +border-top-right-radius(!r)
+
+=border-right-radius(!r)
+ +border-top-right-radius(!r)
+ +border-bottom-right-radius(!r)
+
+=border-bottom-radius(!r)
+ +border-bottom-right-radius(!r)
+ +border-bottom-left-radius(!r)
+
+=border-left-radius(!r)
+ +border-top-left-radius(!r)
+ +border-bottom-left-radius(!r)
+
+//**
+ change the box model for Mozilla, Webkit, IE8 and the future
+=box-sizing(!bs)
+ /* Mozilla (FireFox, Camino)
+ -moz-box-sizing= !bs
+ /* Webkit (Safari, Chrome)
+ -webkit-box-sizing= !bs
+ /* IE (8)
+ -ms-box-sizing= !bs
+ /* CSS3
+ box-sizing= !bs
+
+//**
+ box shadow for Webkit and the future
+ - arguments are horizontal offset, vertical offset, blur and color
+=box-shadow(!ho, !vo, !b, !c )
+ /* Webkit (Safari, Chrome)
+ -webkit-box-shadow= !ho !vo !b !c
+ /* Mozilla (Firefox, Camino)
+ -moz-box-shadow= !ho !vo !b !c
+ /* CSS3
+ box-shadow= !ho !vo !b !c
+
+
+//**
+ CSS3 columns for Mozilla, Webkit and the Future
+
+=column-count(!n)
+ :-moz-column-count= !n
+ :-webkit-column-count= !n
+ :column-count= !n
+
+=column-gap(!u)
+ :-moz-column-gap= !u
+ :-webkit-column-gap= !u
+ :column-gap= !u
+
+=column-width(!u)
+ :-moz-column-width= !u
+ :-webkit-column-width= !u
+ :column-width= !u
+
+=column-rule-width(!w)
+ :-moz-column-rule-width= !w
+ :-webkit-column-rule-width= !w
+ :column-rule-width= !w
+
+=column-rule-style(!s)
+ :-moz-column-rule-style= !s
+ :-webkit-column-rule-style= !s
+ :column-rule-style= !s
+
+=column-rule-color(!c)
+ :-moz-column-rule-color= !c
+ :-webkit-column-rule-color= !c
+ :column-rule-color= !c
+
+=column-rule(!w, !s = "solid", !c = " ")
+ +column-rule-width(!w)
+ +column-rule-style(!s)
+ +column-rule-color(!c)
\ No newline at end of file
diff --git a/lib/app_template.rb b/lib/app_template.rb
new file mode 100644
index 0000000..a8fc471
--- /dev/null
+++ b/lib/app_template.rb
@@ -0,0 +1,252 @@
+#Gems
+gem "inherited_resources"
+gem "acts-as-taggable-on"
+gem "will_paginate"
+gem "searchlogic"
+gem "formtastic"
+gem "validation_reflection"
+gem "paperclip"
+gem "RedCloth", :lib => "redcloth"
+gem "haml"
+gem "compass"
+# gem "compass-susy-plugin", :lib => 'susy'
+gem "shoulda"
+gem "webrat"
+gem "factory_girl"
+gem "mocha"
+
+rake "gems:install", :sudo => true
+
+# Layout + HAML + SASS
+run "haml --rails ."
+run "script/generate nifty_layout --haml"
+run "rm app/views/layouts/application.html.haml"
+file "app/views/layouts/application.html.haml", <<-HAML
+!!! Strict
+%html{html_attrs(I18n.locale)}
+
+ %head
+ %title= h(yield(:title) || "Untitled")
+ %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}
+ = stylesheet_link_tag 'application'
+ = javascript_tag "var AUTH_TOKEN = \#{form_authenticity_token.inspect};" if protect_against_forgery?
+ = javascript_include_tag "jquery", "application"
+ = yield(:head)
+
+ %body
+ - flash.each do |name, msg|
+ = content_tag :div, msg, :id => "flash_\#{name}"
+
+ - if show_title?
+ %h1=h yield(:title)
+
+ = yield
+HAML
+run "rm -r public/stylesheets/sass"
+run "compass --rails --sass-dir app/stylesheets --css-dir public/stylesheets ."
+run "rm app/stylesheets/*.sass"
+run "mkdir app/stylesheets/partials"
+
+file "app/stylesheets/partials/_base.sass", <<-CSS
+# @import susy/susy.sass # TODO: descomentar cuando SUSY deje de estar roto (se rompió con el cambio a gemcutter).
+!extension = ""
+
+=font-face(!font,!filename, !type = "opentype")
+ font-family: \#{!font}
+ src: url("fonts/\#{!filename}.eot")
+ @if !type == "opentype"
+ !extension = "otf"
+ @else
+ !extension = "ttf"
+
+ src: local("\#{!font} Regular"), local("\#{!font}-Regular"), local("\#{!font}"), url("fonts/\#{!filename}.\#{!extension}") format("\#{!type}")
+CSS
+file "app/stylesheets/application.sass", <<-CSS
+@import partials/base.sass
+@import form.sass
+
+*
+ padding: 0
+ margin: 0
+ font-family: helvetica, arial, verdana, sans-serif
+ font-size: 1em
+
+html
+ background-color: #4b7399
+
+body
+ padding: 0.5em 1%
+ margin: 1em auto
+ font-size: 0.85em
+ width: 80em
+ max-width: 98%
+ border: solid 1px black
+ background-color: #fdfdfd
+ color: #333
+
+
+a img
+ border: none
+
+#flash_notice,
+#flash_error
+ padding: 5px 8px
+ margin: 10px 0
+
+#flash_notice
+ background-color: #CFC
+ border: 1px solid #6C6
+
+#flash_error
+ background-color: #FCC
+ border: solid 1px #C66
+
+.fieldWithErrors
+ display: inline
+CSS
+
+# Formtastic
+generate :formtastic
+run "rm public/stylesheets/*.css"
+run "wget -O app/stylesheets/partials/_formtastic_base.sass http://github.com/activestylus/formtastic-sass/raw/master/_formtastic_base.sass"
+file "app/stylesheets/form.sass", <<-CSS
+@import partials/formtastic_base.sass
+.formtastic
+ +float-form
+CSS
+
+# Base de datos
+app_name = `pwd`.split('/').last.strip
+
+run "rm config/database.yml"
+file "config/database.yml", <<-FILE
+development:
+ adapter: mysql
+ database: #{app_name}_development
+ encoding: utf8
+
+test:
+ adapter: mysql
+ database: #{app_name}_test
+ encoding: utf8
+
+production:
+ username: root
+ password: password
+ adapter: mysql
+ database: #{app_name}_production
+ pool: 5
+ encoding: utf8
+FILE
+rake "db:create:all"
+run "cp config/database.yml config/example_database.yml"
+
+#Git ignore
+file ".gitignore", <<-END
+log/*.log
+nbproject/private/*
+nbproject/*
+coverage/*
+tmp/**/*
+tmp/*.html
+public/stylesheets/*.css
+config/database.yml
+.DS_Store
+webrat-*.html
+db/*.sqlite3
+END
+run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
+
+# Imágenes y Javascript
+run "rm public/images/rails.png"
+run "rm -f public/javascripts/*"
+run "wget -O public/javascripts/jquery.js http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"
+file "public/javascripts/application.js", <<-JS
+$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
+ while(x<c.length){var m=r.exec(c.substr(x));
+ if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
+ }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
+ o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;},
+URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;
+ while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
+ t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}
+});
+
+$(document).ajaxSend(function(event, request, settings) {
+ if (typeof(AUTH_TOKEN) == "undefined") return;
+ if (settings.type == 'GET' || settings.type == 'get') return;
+ settings.data = settings.data || "";
+ settings.data += (settings.data ? "&" : "") + "authenticity_token=" + $.URLEncode(AUTH_TOKEN);
+ request.setRequestHeader("Content-Type", settings.contentType);
+});
+
+$(document).ready( function()
+{
+ // Sustituye al método de confirmar borrado que hace Prototype por defecto en
+ // el scaffold de Rails
+ function confirm_destroy(action)
+ {
+ if (confirm('Are you sure?'))
+ {
+ $form = $('<form></form>')
+ .attr('method', 'post')
+ .attr('action', action)
+ .append( $('<input />')
+ .attr('type', 'hidden')
+ .attr('name', '_method')
+ .val('delete')
+ )
+ .append( $('<input />')
+ .attr('type', 'hidden')
+ .attr('name', 'authenticity_token')
+ .val(AUTH_TOKEN)
+ )
+ .appendTo('body')
+ .submit();
+ }
+
+ }
+
+ $('a.destroy').click( function()
+ {
+ confirm_destroy(this.href.replace("/confirm_destroy", ""));
+ return false;
+ });
+});
+JS
+
+# Traducciones
+run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
+file "config/initializers/inflections.rb", <<-PLURALES
+ActiveSupport::Inflector.inflections do |inflect|
+ inflect.plural /([^aeiouáéó])$/i, '\\1es'
+ inflect.singular /(.*)es$/i, '\\1'
+
+ inflect.plural /(.*)z$/i, '\\1ces'
+ inflect.singular /(.*)ces$/i, '\\1z'
+
+ vocales = {'a' => 'á', 'e' => 'é', 'i' => 'Ã', 'o' => 'ó', 'u' => 'ú'}
+ vocales.each do |vocal_sin_acento, vocal_con_acento|
+ ['n', 's'].each do |consonante|
+ final_singular = vocal_con_acento + consonante
+ final_plural = vocal_sin_acento + consonante + 'es'
+ inflect.plural /(.*)\#{final_singular}$/i, '\\1' + final_plural
+ #La siguiente lÃnea la comento porque los nombres de tablas no tienen acentos
+ #inflect.singular /(.*)\#{final_plural}$/i, '\\1' + final_singular
+ end
+ end
+
+ inflect.irregular 'post', 'posts'
+ inflect.irregular 'tagging', 'taggings'
+ inflect.irregular 'tag', 'tags'
+ inflect.irregular 'session', 'sessions'
+ inflect.irregular 'job', 'jobs'
+# inflect.uncountable %w( fish sheep )
+end
+PLURALES
+
+# Commit
+run "echo TODO > README"
+git :init
+git :add => "."
+git :commit => "-m 'Primer commit'"
diff --git a/lib/app_template_3.rb b/lib/app_template_3.rb
new file mode 100644
index 0000000..904d90c
--- /dev/null
+++ b/lib/app_template_3.rb
@@ -0,0 +1,79 @@
+gem 'responders'
+gem 'devise', ">= 1.1rc1"
+gem 'will_paginate'
+gem 'paperclip'
+gem 'haml'
+gem 'compass'
+gem 'delayed_job'
+gem 'acts-as-taggable-on'
+gem 'validation_reflection'
+gem 'RedCloth'
+gem 'validates_date_time'
+gem 'simple_form'
+gem 'meta_where'
+gem 'meta_search'
+
+gem 'bullet', :group => :development
+gem 'rails3-generators', :group => :development
+
+gem 'shoulda', :group => :test
+gem 'factory_girl_rails', :group => :test
+gem 'mocha', :group => :test
+gem 'capybara', :group => :test
+
+run "bundle install"
+
+def read_file(file)
+ File.read(File.expand_path(File.join(File.dirname(__FILE__), file)))
+end
+
+# Layout
+run "rm app/views/layouts/application.html.erb"
+file "app/views/layouts/application.html.haml", read_file("application.html.haml")
+
+# SASS
+run "compass config --app rails --sass-dir app/stylesheets --css-dir public/stylesheets"
+run "rm app/stylesheets/*.sass"
+run "mkdir app/stylesheets/partials"
+
+file "app/stylesheets/partials/_base.sass", read_file("_base.sass")
+file "app/stylesheets/partials/_utils.sass", read_file("_utils.sass")
+file "app/stylesheets/application.sass", read_file("application.sass")
+
+# Gitignore
+run "touch tmp/.gitignore log/.gitignore vendor/.gitignore public/stylesheets/.gitignore"
+
+# ¿Habrá forma de añadir sólo las 2 últimas lÃneas al final de un fichero ya existente?
+run "rm .gitignore"
+file ".gitignore", read_file("gitignore")
+
+# Logo e Ãndice no necesitados
+run "rm public/images/rails.png"
+run "rm public/index.html"
+
+# Javascript
+run "wget -O public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"
+run "wget -O public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js"
+
+# Traducciones
+run "wget -O config/locales/es.yml http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/es.yml"
+
+run "rm config/initializers/inflections.rb"
+file "config/initializers/inflections.rb", read_file("inflections.rb")
+file "app/helpers/layout_helper.rb", read_file("layout_helper.rb")
+
+# Commit
+run "echo TODO > README"
+git :init
+git :add => "."
+git :commit => "-m 'Primer commit'"
+
+# Generadores (aparte)
+#config.generators do |g|
+# g.stylesheets false
+# g.template_engine :haml
+# g.test_framework :shoulda
+# g.fixture_replacement :factory_girl
+# g.form_builder :simple_form
+# g.fallbacks[:shoulda] = :test_unit
+#end
\ No newline at end of file
diff --git a/lib/application.html.haml b/lib/application.html.haml
new file mode 100644
index 0000000..06c4db3
--- /dev/null
+++ b/lib/application.html.haml
@@ -0,0 +1,19 @@
+!!! Strict
+%html{html_attrs(I18n.locale)}
+
+ %head
+ %title= h(yield(:title) || "Untitled")
+ %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}
+ = stylesheet_link_tag 'application'
+ = javascript_include_tag 'jquery', 'rails'
+ = csrf_meta_tag
+ = yield(:head)
+
+ %body
+ - flash.each do |name, msg|
+ = content_tag :div, msg, :id => "flash_\#{name}"
+
+ - if show_title?
+ %h1= yield(:title)
+
+ = yield
\ No newline at end of file
diff --git a/lib/application.sass b/lib/application.sass
new file mode 100644
index 0000000..afee41e
--- /dev/null
+++ b/lib/application.sass
@@ -0,0 +1,40 @@
+@import partials/base.sass
+
+*
+ padding: 0
+ margin: 0
+ font-family: helvetica, arial, verdana, sans-serif
+ font-size: 1em
+
+html
+ background-color: #4b7399
+
+body
+ padding: 0.5em 1%
+ margin: 1em auto
+ font-size: 0.85em
+ width: 80em
+ max-width: 98%
+ border: solid 1px black
+ background-color: #fdfdfd
+ color: #333
+
+
+a img
+ border: none
+
+#flash_notice,
+#flash_error
+ padding: 5px 8px
+ margin: 10px 0
+
+#flash_notice
+ background-color: #CFC
+ border: 1px solid #6C6
+
+#flash_error
+ background-color: #FCC
+ border: solid 1px #C66
+
+.fieldWithErrors
+ display: inline
\ No newline at end of file
diff --git a/lib/gitignore b/lib/gitignore
new file mode 100644
index 0000000..687e046
--- /dev/null
+++ b/lib/gitignore
@@ -0,0 +1,6 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/**/*
+nbproject/*
+public/stylesheets/*.css
\ No newline at end of file
diff --git a/lib/inflections.rb b/lib/inflections.rb
new file mode 100644
index 0000000..1bf5eb4
--- /dev/null
+++ b/lib/inflections.rb
@@ -0,0 +1,27 @@
+# encoding: utf-8
+
+ActiveSupport::Inflector.inflections do |inflect|
+ inflect.plural /([^aeiouáéó])$/i, '\\1es'
+ inflect.singular /(.*)es$/i, '\\1'
+
+ inflect.plural /(.*)z$/i, '\\1ces'
+ inflect.singular /(.*)ces$/i, '\\1z'
+
+ vocales = {'a' => 'á', 'e' => 'é', 'i' => 'Ã', 'o' => 'ó', 'u' => 'ú'}
+ vocales.each do |vocal_sin_acento, vocal_con_acento|
+ ['n', 's'].each do |consonante|
+ final_singular = vocal_con_acento + consonante
+ final_plural = vocal_sin_acento + consonante + 'es'
+ inflect.plural /(.*)\#{final_singular}$/i, '\\1' + final_plural
+ #La siguiente lÃnea la comento porque los nombres de tablas no tienen acentos
+ #inflect.singular /(.*)\#{final_plural}$/i, '\\1' + final_singular
+ end
+ end
+
+ inflect.irregular 'post', 'posts'
+ inflect.irregular 'tagging', 'taggings'
+ inflect.irregular 'tag', 'tags'
+ inflect.irregular 'session', 'sessions'
+ inflect.irregular 'job', 'jobs'
+# inflect.uncountable %w( fish sheep )
+end
diff --git a/lib/layout_helper.rb b/lib/layout_helper.rb
new file mode 100644
index 0000000..0532385
--- /dev/null
+++ b/lib/layout_helper.rb
@@ -0,0 +1,30 @@
+module LayoutHelper
+ def title(page_title, show_title = true)
+ @content_for_title = page_title.to_s
+ @show_title = show_title
+ end
+
+ def show_title?
+ @show_title
+ end
+
+ def stylesheet(*args)
+ @stylesheets ||= []
+ args.each do |stylesheet|
+ if !@stylesheets.include?(stylesheet)
+ content_for(:head) { stylesheet_link_tag(stylesheet) }
+ @stylesheets << stylesheet
+ end
+ end
+ end
+
+ def javascript(*args)
+ @javascripts ||= []
+ args.each do |javascript|
+ if !@javascripts.include?(javascript)
+ content_for(:head) { javascript_include_tag(javascript) }
+ @javascripts << javascript
+ end
+ end
+ end
+end
\ No newline at end of file
|
bcd/exec09
|
642e684b9d225a6d0a3d7121ed23ba79c76b9fc5
|
Exit program after using -h option.
|
diff --git a/main.c b/main.c
index 3851618..01e06e2 100644
--- a/main.c
+++ b/main.c
@@ -1,458 +1,457 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
unsigned long max_cycles = 500000000UL;
/* When nonzero, says that the state of the machine is persistent
across runs of the simulator. */
int machine_persistent = 0;
/* When nonzero, says that the simulator is slowed down to match what a real
processor would run like. */
int machine_realtime = 0;
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
struct timeval time_started;
/**
* Return elapsed real time in milliseconds.
*/
long
time_diff (struct timeval *old, struct timeval *new)
{
long ms = (new->tv_usec - old->tv_usec) / 1000;
ms += (new->tv_sec - old->tv_sec) * 1000;
return ms;
}
long
get_elapsed_realtime (void)
{
struct timeval now;
gettimeofday (&now, NULL);
return time_diff (&time_started, &now);
}
/*
* Check if the CPU should idle.
*/
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 30;
static int count = 30;
int delay;
static int total_ms_elapsed = 0;
static int cumulative_delay = 0;
if (--count > 0)
return;
if (last.tv_sec == 0 && last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = time_diff (&last, &now);
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
if (machine->periodic)
machine->periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
cumulative_delay += delay;
if (cumulative_delay > 0)
{
usleep (50 * 1000UL);
cumulative_delay -= 50;
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
-int do_help (const char *arg __attribute__((unused)));
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
NO_NEG, NO_ARG, NULL, 0, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
{ 'R', "realtime", "Limit simulation speed to match realtime",
HAS_NEG, NO_ARG, &machine_realtime, 0, NULL, NULL },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
{ 'p', "persistent", "Use persistent machine state",
NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
- return -1;
+ exit (0);
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
sim_exit (0x70);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
gettimeofday (&time_started, NULL);
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
/* The machine loader cannot deal with S-record files.
So initialize the machine first, passing it a NULL
filename, then load the S-record file afterwards. */
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
/* Simulate some CPU time, either 1ms worth or up to the
next possible IRQ */
total += cpu_execute (mhz * 1024);
/* Call each device that needs periodic processing. */
machine_update ();
}
else
{
total += cpu_execute (cycles_per_irq);
/* TODO - this assumes periodic interrupts (WPC) */
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
sim_exit (0);
return 0;
}
|
bcd/exec09
|
c067103009e1261b7e35a85dad5ca5fcd034ff32
|
Checkin serial.c
|
diff --git a/serial.c b/serial.c
new file mode 100644
index 0000000..80fa765
--- /dev/null
+++ b/serial.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2009 by Brian Dominy <brian@oddchange.com>
+ *
+ * This file is part of GCC6809.
+ *
+ * GCC6809 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GCC6809 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GCC6809; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include "machine.h"
+
+/* Emulate a serial port. Basically this driver can be used for any byte-at-a-time
+input/output interface. */
+struct serial_port
+{
+ unsigned int ctrl;
+ unsigned int status;
+ int fin;
+ int fout;
+};
+
+/* The I/O registers exposed by this driver */
+#define SER_DATA 0 /* Data input/output */
+#define SER_CTL_STATUS 1 /* Control (write) and status (read) */
+ #define SER_CTL_ASYNC 0x1 /* Enable async mode (more realistic) */
+ #define SER_CTL_RESET 0x2 /* Reset device */
+
+ #define SER_STAT_READOK 0x1
+ #define SER_STAT_WRITEOK 0x2
+
+void serial_update (struct serial_port *port)
+{
+ fd_set infds, outfds;
+ struct timeval timeout;
+ int rc;
+
+ FD_ZERO (&infds);
+ FD_SET (port->fin, &infds);
+ FD_ZERO (&outfds);
+ FD_SET (port->fout, &outfds);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ rc = select (2, &infds, &outfds, NULL, &timeout);
+ if (FD_ISSET (port->fin, &infds))
+ port->status |= SER_STAT_READOK;
+ else
+ port->status &= ~SER_STAT_READOK;
+ if (FD_ISSET (port->fout, &outfds))
+ port->status |= SER_STAT_WRITEOK;
+ else
+ port->status &= ~SER_STAT_WRITEOK;
+}
+
+U8 serial_read (struct hw_device *dev, unsigned long addr)
+{
+ struct serial_port *port = (struct serial_port *)dev->priv;
+ serial_update (port);
+ switch (addr)
+ {
+ case SER_DATA:
+ {
+ U8 val;
+ if (!(port->status & SER_STAT_READOK))
+ return 0xFF;
+ read (port->fin, &val, 1);
+ return val;
+ }
+ case SER_CTL_STATUS:
+ return port->status;
+ }
+}
+
+void serial_write (struct hw_device *dev, unsigned long addr, U8 val)
+{
+ struct serial_port *port = (struct serial_port *)dev->priv;
+ switch (addr)
+ {
+ case SER_DATA:
+ {
+ U8 v = val;
+ write (port->fout, &v, 1);
+ break;
+ }
+ case SER_CTL_STATUS:
+ port->ctrl = val;
+ break;
+ }
+}
+
+void serial_reset (struct hw_device *dev)
+{
+ struct serial_port *port = (struct serial_port *)dev->priv;
+ port->ctrl = 0;
+ port->status = 0;
+}
+
+struct hw_class serial_class =
+{
+ .readonly = 0,
+ .reset = serial_reset,
+ .read = serial_read,
+ .write = serial_write,
+};
+
+extern U8 null_read (struct hw_device *dev, unsigned long addr);
+
+
+struct hw_device *serial_create (void)
+{
+ struct serial_port *port = malloc (sizeof (struct serial_port));
+ port->fin = STDIN_FILENO;
+ port->fout = STDOUT_FILENO;
+ return device_attach (&serial_class, 4, port);
+}
+
+struct hw_device *hostfile_create (const char *filename, int flags)
+{
+ struct serial_port *port = malloc (sizeof (struct serial_port));
+ port->fin = port->fout = open (filename, O_CREAT | flags);
+ return device_attach (&serial_class, 4, port);
+}
+
|
bcd/exec09
|
2ef84978ca4281499cb81491c3e617914bdaa54f
|
Miscellaneous changes. EON2 configuration uses new device types.
|
diff --git a/Makefile.am b/Makefile.am
index 3a06845..6b81467 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,10 @@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
symtab.c command.c fileio.c wpclib.c imux.c \
- ioexpand.c mmu.c timer.c \
+ ioexpand.c mmu.c timer.c serial.c disk.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
LIBS = $(READLINE_LIBS)
bin_PROGRAMS = m6809-run
bin_SCRIPTS = wpc-run
diff --git a/Makefile.in b/Makefile.in
index 576a920..1de4b0b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,585 +1,587 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
LIBOBJDIR =
bin_PROGRAMS = m6809-run$(EXEEXT)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING depcomp install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_m6809_run_OBJECTS = 6809.$(OBJEXT) main.$(OBJEXT) monitor.$(OBJEXT) \
machine.$(OBJEXT) eon.$(OBJEXT) wpc.$(OBJEXT) symtab.$(OBJEXT) \
command.$(OBJEXT) fileio.$(OBJEXT) wpclib.$(OBJEXT) \
imux.$(OBJEXT) ioexpand.$(OBJEXT) mmu.$(OBJEXT) \
- timer.$(OBJEXT)
+ timer.$(OBJEXT) serial.$(OBJEXT) disk.$(OBJEXT)
m6809_run_OBJECTS = $(am_m6809_run_OBJECTS)
m6809_run_LDADD = $(LDADD)
binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(bin_SCRIPTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(m6809_run_SOURCES)
DIST_SOURCES = $(m6809_run_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = $(READLINE_LIBS)
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
READLINE_LIBS = @READLINE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
symtab.c command.c fileio.c wpclib.c imux.c \
- ioexpand.c mmu.c timer.c \
+ ioexpand.c mmu.c timer.c serial.c disk.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
bin_SCRIPTS = wpc-run
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
m6809-run$(EXEEXT): $(m6809_run_OBJECTS) $(m6809_run_DEPENDENCIES)
@rm -f m6809-run$(EXEEXT)
$(LINK) $(m6809_run_LDFLAGS) $(m6809_run_OBJECTS) $(m6809_run_LDADD) $(LIBS)
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_SCRIPTS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f $$d$$p; then \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
else :; fi; \
done
uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(bin_SCRIPTS)'; for p in $$list; do \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/6809.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/disk.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eon.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioexpand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machine.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmu.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/serial.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symtab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpclib.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am: install-binPROGRAMS install-binSCRIPTS
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
uninstall-info-am
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-binSCRIPTS install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/eon.c b/eon.c
index 0a9f22a..9406975 100644
--- a/eon.c
+++ b/eon.c
@@ -1,127 +1,130 @@
+#include <fcntl.h>
#include "machine.h"
#include "eon.h"
extern int system_running;
void eon_fault (unsigned int addr, unsigned char type)
{
if (system_running)
{
sim_error (">>> Page fault: addr=%04X type=%02X PC=%04X\n", addr, type, get_pc ());
#if 0
fault_addr = addr;
fault_type = type;
irq ();
#endif
}
}
/**
* Initialize the EON machine.
*/
void eon_init (const char *boot_rom_file)
{
- struct hw_device *dev;
+ struct hw_device *dev, *ram_dev;
/* The MMU must be defined first, as all other devices
that are attached can try to hook into the MMU. */
device_define ( mmu_create (), 0,
MMU_ADDR, BUS_MAP_SIZE, MAP_READWRITE+MAP_FIXED );
/* A 1MB RAM part is mapped into all of the allowable 64KB
address space, until overriden by other devices. */
- device_define ( ram_create (RAM_SIZE), 0,
+ device_define ( ram_dev = ram_create (RAM_SIZE), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( rom_create (boot_rom_file, BOOT_ROM_SIZE), 0,
BOOT_ROM_ADDR, BOOT_ROM_SIZE, MAP_READABLE );
device_define ( dev = console_create (), 0,
CONSOLE_ADDR, BUS_MAP_SIZE, MAP_READWRITE );
device_define (dev, 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
- device_define ( disk_create ("disk.bin"), 0,
+ device_define ( disk_create ("disk.bin", ram_dev), 0,
DISK_ADDR(0), BUS_MAP_SIZE, MAP_READWRITE);
}
/*
* Initialize the second-generation EON machine (EON2).
*/
void eon2_init (const char *boot_rom_file)
{
- struct hw_device *dev, *mmudev, *iodev, *intdev;
+ struct hw_device *dev, *ram_dev, *mmudev, *iodev, *intdev;
/* Create a 1MB RAM */
- dev = ram_create (0x100000);
+ ram_dev = ram_create (0x100000);
/* Place the RAM behind a small MMU, which dynamically remaps
portions of the RAM into the processor address space */
- mmudev = small_mmu_create (dev);
+ mmudev = small_mmu_create (ram_dev);
/* Create and map in the ROM */
dev = rom_create (boot_rom_file, 0x800);
device_define (dev, 0, 0xF800, 0x0800, MAP_READABLE);
/* Create an I/O expander to hold all of the I/O registers.
Each device is allocated only 8 bytes. */
iodev = ioexpand_create ();
device_define (iodev, 0, 0xFF00, 128, MAP_READWRITE);
- ioexpand_attach (iodev, 0, console_create ());
- ioexpand_attach (iodev, 1, disk_create ("disk.bin"));
+ ioexpand_attach (iodev, 0, serial_create ());
+ ioexpand_attach (iodev, 1, disk_create ("disk.bin", ram_dev));
ioexpand_attach (iodev, 2, mmudev);
- ioexpand_attach (iodev, 3, intdev = imux_create ());
+ ioexpand_attach (iodev, 3, intdev = imux_create (1));
/* 4 = config EEPROM */
/* 5 = video display */
/* 6 = battery-backed clock */
/* 7 = power control (reboot/off) */
- /* 8 = timer(s) */
+ /* 8 = periodic timer/oscillator */
+ /* 9 = hostfile (for debug only) */
+ ioexpand_attach (iodev, 9, hostfile_create ("hostfile", O_RDWR));
/* etc. up to device 15 */
/* May need to define an I/O _multiplexer_ to support more than 16 devices */
- /* Bind interrupting devices to the interrupt multiplexor. */
+ dev = oscillator_create (intdev, 0);
}
/**
* Initialize the simple machine, which is the default
* machine that has no bells or whistles.
*/
void simple_init (const char *boot_rom_file)
{
device_define ( ram_create (MAX_CPU_ADDR), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( console_create (), 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
}
struct machine eon_machine =
{
.name = "eon",
.fault = eon_fault,
.init = eon_init,
.periodic = 0,
};
struct machine eon2_machine =
{
.name = "eon2",
.fault = eon_fault,
.init = eon2_init,
.periodic = 0,
};
struct machine simple_machine =
{
.name = "simple",
.fault = eon_fault,
.init = simple_init,
.periodic = 0,
};
diff --git a/ioexpand.c b/ioexpand.c
index 9eabbca..25e99d3 100644
--- a/ioexpand.c
+++ b/ioexpand.c
@@ -1,70 +1,89 @@
+/*
+ * Copyright 2009 by Brian Dominy <brian@oddchange.com>
+ *
+ * This file is part of GCC6809.
+ *
+ * GCC6809 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GCC6809 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GCC6809; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include <stdio.h>
#include <stdlib.h>
#include "machine.h"
/* An I/O expander allows a single, 128-byte region to be shared among multiple
devices. It subdivides the region into 16 8-byte subdevices. It is needed
to work around the inability of the system bus to handle attaching devices
less than 128 bytes wide. */
#define NR_IOEXPAND 16
#define IO_WINDOW 8
struct ioexpand
{
struct hw_device *ios[NR_IOEXPAND];
};
void ioexpand_attach (struct hw_device *expander_dev, int slot, struct hw_device *io_dev)
{
struct ioexpand *iom = (struct ioexpand *)expander_dev->priv;
iom->ios[slot] = io_dev;
}
void ioexpand_reset (struct hw_device *dev)
{
int i;
struct ioexpand *iom = (struct ioexpand *)dev->priv;
/* Propagate the reset to all devices behind the expander */
for (i=0; i < NR_IOEXPAND; i++)
if ((dev = iom->ios[i]) != NULL)
dev->class_ptr->reset (dev);
}
U8 ioexpand_read (struct hw_device *dev, unsigned long addr)
{
struct ioexpand *iom = (struct ioexpand *)dev->priv;
dev = iom->ios[addr / IO_WINDOW];
if (!dev)
sim_error ("expander read from %04X has no backing device\n", addr);
return dev->class_ptr->read (dev, addr % IO_WINDOW);
}
void ioexpand_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct ioexpand *iom = (struct ioexpand *)dev->priv;
dev = iom->ios[addr / IO_WINDOW];
if (!dev)
sim_error ("expander write %02X to %04X has no backing device\n", val, addr);
dev->class_ptr->write (dev, addr % IO_WINDOW, val);
}
struct hw_class ioexpand_class =
{
.readonly = 0,
.reset = ioexpand_reset,
.read = ioexpand_read,
.write = ioexpand_write,
};
struct hw_device *ioexpand_create (void)
{
int i;
struct ioexpand *iom = malloc (sizeof (struct ioexpand));
for (i=0; i < NR_IOEXPAND; i++)
iom->ios[i] = NULL;
return device_attach (&ioexpand_class, BUS_MAP_SIZE, iom);
}
diff --git a/machine.c b/machine.c
index 82c752f..bfaafcc 100644
--- a/machine.c
+++ b/machine.c
@@ -28,584 +28,565 @@
#define CONFIG_LEGACY
#define MISSING 0xff
#define mmu_device (device_table[0])
extern void eon_init (const char *);
extern void wpc_init (const char *);
struct machine *machine;
unsigned int device_count = 0;
struct hw_device *device_table[MAX_BUS_DEVICES];
struct hw_device *null_device;
struct bus_map busmaps[NUM_BUS_MAPS];
struct bus_map default_busmaps[NUM_BUS_MAPS];
U16 fault_addr;
U8 fault_type;
int system_running = 0;
void cpu_is_running (void)
{
system_running = 1;
}
void do_fault (unsigned int addr, unsigned int type)
{
if (system_running)
machine->fault (addr, type);
}
void exit_fault (unsigned int addr, unsigned int type)
{
monitor_on = debug_enabled;
sim_error ("Fault: addr=%04X type=%02X\n", addr, type);
exit (1);
}
/**
* Attach a new device to the bus. Only called during init.
*/
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv)
{
struct hw_device *dev = malloc (sizeof (struct hw_device));
dev->class_ptr = class_ptr;
dev->devid = device_count;
dev->size = size;
dev->priv = priv;
device_table[device_count++] = dev;
/* Attach implies reset */
class_ptr->reset (dev);
return dev;
};
/**
* Map a portion of a device into the CPU's address space.
*/
void bus_map (unsigned int addr,
unsigned int devid,
unsigned long offset,
unsigned int len,
unsigned int flags)
{
struct bus_map *map;
unsigned int start, count;
/* Warn if trying to map too much */
if (addr + len > MAX_CPU_ADDR)
{
fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n",
len, addr);
}
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
offset = ((offset + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Initialize the maps. This will let the CPU access the device. */
map = &busmaps[start];
while (count > 0)
{
if (!(map->flags & MAP_FIXED))
{
map->devid = devid;
map->offset = offset;
map->flags = flags;
}
count--;
map++;
offset += BUS_MAP_SIZE;
}
}
void device_define (struct hw_device *dev,
unsigned long offset,
unsigned int addr,
unsigned int len,
unsigned int flags)
{
/* Note: len must be a multiple of BUS_MAP_SIZE */
bus_map (addr, dev->devid, offset, len, flags);
}
void bus_unmap (unsigned int addr, unsigned int len)
{
struct bus_map *map;
unsigned int start, count;
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
{
do_fault (addr, FAULT_NO_RESPONSE);
return null_device;
}
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
* a caching scheme that cuts down on some of this.
* There is also a 16-bit version that is more efficient when
* a full word is needed, but it implies that no reads will ever
* occur across a device boundary.
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_READABLE))
machine->fault (addr, FAULT_NOT_READABLE);
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_READABLE))
do_fault (addr, FAULT_NOT_READABLE);
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return ((*class_ptr->read) (dev, phy_addr) << 8)
| (*class_ptr->read) (dev, phy_addr+1);
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_WRITABLE))
do_fault (addr, FAULT_NOT_WRITABLE);
(*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
0 /* device_table[map->devid]->size */, map->flags);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
return 0xFF;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
struct hw_class null_class =
{
.readonly = 0,
.reset = null_reset,
.read = null_read,
.write = null_write,
};
struct hw_device *null_create (void)
{
return device_attach (&null_class, 0, NULL);
}
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
mmu_regs[page][2] & MAP_READWRITE);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
mmu_write (dev, page * MMU_PAGEREGS + 2, MAP_READWRITE);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
mmu_regs[page][2] = map->flags & MAP_READWRITE;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
-struct hw_device *disk_create (const char *backing_file)
+void machine_update (void)
{
- struct disk_priv *disk = malloc (sizeof (struct disk_priv));
- int newdisk = 0;
-
- disk->fp = file_open (NULL, backing_file, "r+b");
- if (disk->fp == NULL)
+ int i;
+ for (i=0; i < device_count; i++)
{
- printf ("warning: disk does not exist, creating\n");
- disk->fp = file_open (NULL, backing_file, "w+b");
- newdisk = 1;
- if (disk->fp == NULL)
- {
- printf ("warning: disk not created\n");
- }
+ struct hw_device *dev = device_table[i];
+ if (dev->class_ptr->update)
+ dev->class_ptr->update (dev);
}
-
- disk->ram = 0;
- disk->ramdev = device_table[1];
- disk->dev = device_attach (&disk_class, BUS_MAP_SIZE, disk);
- disk->sectors = DISK_SECTOR_COUNT;
-
- if (newdisk)
- disk_format (disk->dev);
-
- return disk->dev;
}
-/**********************************************************/
-
int machine_match (const char *machine_name, const char *boot_rom_file, struct machine *m)
{
if (!strcmp (m->name, machine_name))
{
machine = m;
m->init (boot_rom_file);
return 1;
}
return 0;
}
void machine_init (const char *machine_name, const char *boot_rom_file)
{
extern struct machine simple_machine;
extern struct machine eon_machine;
extern struct machine eon2_machine;
extern struct machine wpc_machine;
int i;
/* Initialize CPU maps, so that no CPU addresses map to
anything. Default maps will trigger faults at runtime. */
null_device = null_create ();
memset (busmaps, 0, sizeof (busmaps));
for (i = 0; i < NUM_BUS_MAPS; i++)
busmaps[i].devid = INVALID_DEVID;
if (machine_match (machine_name, boot_rom_file, &simple_machine));
else if (machine_match (machine_name, boot_rom_file, &eon_machine));
else if (machine_match (machine_name, boot_rom_file, &eon2_machine));
else if (machine_match (machine_name, boot_rom_file, &wpc_machine));
else exit (1);
/* Save the default busmap configuration, before the
CPU begins to run, so that it can be restored if
necessary. */
memcpy (default_busmaps, busmaps, sizeof (busmaps));
if (!strcmp (machine_name, "eon"))
mmu_reset_complete (mmu_device);
}
diff --git a/machine.h b/machine.h
index a148887..89b9358 100644
--- a/machine.h
+++ b/machine.h
@@ -1,150 +1,151 @@
/*
* Copyright 2006-2009 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef M6809_MACHINE_H
#define M6809_MACHINE_H
/* This file defines structures used to build generic machines on a 6809. */
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned long absolute_address_t;
#define MAX_CPU_ADDR 65536
/* The generic bus architecture. */
/* Up to 32 devices may be connected. Each device is addressed by a 32-bit physical address */
#define MAX_BUS_DEVICES 32
#define INVALID_DEVID 0xff
/* Say whether or not the mapping is RO or RW (or neither). */
#define MAP_READABLE 0x1
#define MAP_WRITABLE 0x2
#define MAP_READWRITE 0x3
/* A fixed map cannot be reprogrammed. Attempts to
bus_map something differently will silently be
ignored. */
#define MAP_FIXED 0x4
#define FAULT_NONE 0
#define FAULT_NOT_WRITABLE 1
#define FAULT_NO_RESPONSE 2
#define FAULT_NOT_READABLE 3
/* A bus map is assocated with part of the 6809 address space
and says what device and which part of it is mapped into that
area. It also has associated flags which say how it is allowed
to be accessed.
A single bus map defines 128 bytes of address space; for a 64KB CPU,
that requires a total of 512 such structures.
Note that the bus map need not correspond to the page size that can
be configured by the MMU. It allows for more granularity and is
needed in some *hardcoded* mapping cases. */
#define BUS_MAP_SIZE 128
struct bus_map
{
unsigned int devid; /* The devid mapped here */
unsigned long offset; /* The offset within the device */
unsigned char flags;
};
#define NUM_BUS_MAPS (MAX_CPU_ADDR / BUS_MAP_SIZE)
/* A hardware device structure exists for each physical device
in the machine */
struct hw_device;
/* A hardware class structure exists for each type of device.
It defines the operations that are allowed on that device.
For example, if there are multiple ROM chips, then there is
a single "ROM" class and multiple ROM device objects. */
struct hw_class
{
/* Nonzero if the device is readonly */
int readonly;
/* Resets the device */
void (*reset) (struct hw_device *dev);
/* Reads a byte at a given offset from the beginning of the device. */
U8 (*read) (struct hw_device *dev, unsigned long phy_addr);
/* Writes a byte at a given offset from the beginning of the device. */
void (*write) (struct hw_device *dev, unsigned long phy_addr, U8 val);
/* Update procedure. This is called periodically and can be used for
whatever purpose. The minimum update interval is once per 1ms. Leave
NULL if not required */
void (*update) (struct hw_device *dev);
};
/* The hardware device structure exists for each instance of a device. */
struct hw_device
{
/* A pointer to the class object. This says what kind of device it is. */
struct hw_class *class_ptr;
/* The device ID assigned to it. This is filled in automatically
by the simulator. */
unsigned int devid;
/* The total size of the device in bytes. */
unsigned long size;
/* The private pointer, which is interpreted differently for each type
(hw_class) of device. */
void *priv;
};
/* The machine structure collects everything about the abstract machine.
The pointer 'machine' points to the machine that is being run. */
extern struct machine *machine;
struct machine
{
const char *name;
void (*init) (const char *boot_rom_file);
void (*fault) (unsigned int addr, unsigned char type);
void (*dump_thread) (unsigned int thread_id);
void (*periodic) (void);
+ unsigned long cycles_per_sec;
};
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv);
struct hw_device *ram_create (unsigned long size);
struct hw_device *rom_create (const char *filename, unsigned int maxsize);
struct hw_device *console_create (void);
-struct hw_device *disk_create (const char *backing_file);
+struct hw_device *disk_create (const char *backing_file, struct hw_device *ram_dev);
#endif /* _M6809_MACHINE_H */
diff --git a/main.c b/main.c
index ceb7531..3851618 100644
--- a/main.c
+++ b/main.c
@@ -1,450 +1,458 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
unsigned long max_cycles = 500000000UL;
/* When nonzero, says that the state of the machine is persistent
across runs of the simulator. */
int machine_persistent = 0;
/* When nonzero, says that the simulator is slowed down to match what a real
processor would run like. */
int machine_realtime = 0;
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
struct timeval time_started;
/**
* Return elapsed real time in milliseconds.
*/
long
time_diff (struct timeval *old, struct timeval *new)
{
long ms = (new->tv_usec - old->tv_usec) / 1000;
ms += (new->tv_sec - old->tv_sec) * 1000;
return ms;
}
long
get_elapsed_realtime (void)
{
struct timeval now;
gettimeofday (&now, NULL);
return time_diff (&time_started, &now);
}
+/*
+ * Check if the CPU should idle.
+ */
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 30;
static int count = 30;
int delay;
static int total_ms_elapsed = 0;
static int cumulative_delay = 0;
if (--count > 0)
return;
if (last.tv_sec == 0 && last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = time_diff (&last, &now);
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
if (machine->periodic)
machine->periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
cumulative_delay += delay;
if (cumulative_delay > 0)
{
usleep (50 * 1000UL);
cumulative_delay -= 50;
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
int do_help (const char *arg __attribute__((unused)));
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
NO_NEG, NO_ARG, NULL, 0, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
{ 'R', "realtime", "Limit simulation speed to match realtime",
HAS_NEG, NO_ARG, &machine_realtime, 0, NULL, NULL },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
{ 'p', "persistent", "Use persistent machine state",
NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
return -1;
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
sim_exit (0x70);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
gettimeofday (&time_started, NULL);
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
/* The machine loader cannot deal with S-record files.
So initialize the machine first, passing it a NULL
filename, then load the S-record file afterwards. */
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
- total += cpu_execute (max_cycles ? max_cycles-1 : 500000);
+ /* Simulate some CPU time, either 1ms worth or up to the
+ next possible IRQ */
+ total += cpu_execute (mhz * 1024);
+
+ /* Call each device that needs periodic processing. */
+ machine_update ();
}
else
{
total += cpu_execute (cycles_per_irq);
/* TODO - this assumes periodic interrupts (WPC) */
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
sim_exit (0);
return 0;
}
|
bcd/exec09
|
91c5accdbc74329cadb65e56789b3c24529e77c6
|
Add the device 'update' method.
|
diff --git a/machine.h b/machine.h
index 147ccfe..a148887 100644
--- a/machine.h
+++ b/machine.h
@@ -1,140 +1,150 @@
/*
- * Copyright 2006, 2007, 2008 by Brian Dominy <brian@oddchange.com>
+ * Copyright 2006-2009 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef M6809_MACHINE_H
#define M6809_MACHINE_H
/* This file defines structures used to build generic machines on a 6809. */
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned long absolute_address_t;
#define MAX_CPU_ADDR 65536
/* The generic bus architecture. */
/* Up to 32 devices may be connected. Each device is addressed by a 32-bit physical address */
#define MAX_BUS_DEVICES 32
#define INVALID_DEVID 0xff
/* Say whether or not the mapping is RO or RW (or neither). */
#define MAP_READABLE 0x1
#define MAP_WRITABLE 0x2
#define MAP_READWRITE 0x3
/* A fixed map cannot be reprogrammed. Attempts to
bus_map something differently will silently be
ignored. */
#define MAP_FIXED 0x4
#define FAULT_NONE 0
#define FAULT_NOT_WRITABLE 1
#define FAULT_NO_RESPONSE 2
#define FAULT_NOT_READABLE 3
/* A bus map is assocated with part of the 6809 address space
and says what device and which part of it is mapped into that
area. It also has associated flags which say how it is allowed
to be accessed.
A single bus map defines 128 bytes of address space; for a 64KB CPU,
that requires a total of 512 such structures.
Note that the bus map need not correspond to the page size that can
be configured by the MMU. It allows for more granularity and is
needed in some *hardcoded* mapping cases. */
#define BUS_MAP_SIZE 128
struct bus_map
{
unsigned int devid; /* The devid mapped here */
unsigned long offset; /* The offset within the device */
unsigned char flags;
};
#define NUM_BUS_MAPS (MAX_CPU_ADDR / BUS_MAP_SIZE)
/* A hardware device structure exists for each physical device
in the machine */
struct hw_device;
/* A hardware class structure exists for each type of device.
It defines the operations that are allowed on that device.
For example, if there are multiple ROM chips, then there is
a single "ROM" class and multiple ROM device objects. */
struct hw_class
{
/* Nonzero if the device is readonly */
int readonly;
/* Resets the device */
void (*reset) (struct hw_device *dev);
/* Reads a byte at a given offset from the beginning of the device. */
U8 (*read) (struct hw_device *dev, unsigned long phy_addr);
/* Writes a byte at a given offset from the beginning of the device. */
void (*write) (struct hw_device *dev, unsigned long phy_addr, U8 val);
+
+ /* Update procedure. This is called periodically and can be used for
+ whatever purpose. The minimum update interval is once per 1ms. Leave
+ NULL if not required */
+ void (*update) (struct hw_device *dev);
};
+/* The hardware device structure exists for each instance of a device. */
+
struct hw_device
{
/* A pointer to the class object. This says what kind of device it is. */
struct hw_class *class_ptr;
/* The device ID assigned to it. This is filled in automatically
by the simulator. */
unsigned int devid;
/* The total size of the device in bytes. */
unsigned long size;
/* The private pointer, which is interpreted differently for each type
(hw_class) of device. */
void *priv;
};
+/* The machine structure collects everything about the abstract machine.
+The pointer 'machine' points to the machine that is being run. */
+
extern struct machine *machine;
struct machine
{
const char *name;
void (*init) (const char *boot_rom_file);
void (*fault) (unsigned int addr, unsigned char type);
void (*dump_thread) (unsigned int thread_id);
void (*periodic) (void);
};
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv);
struct hw_device *ram_create (unsigned long size);
struct hw_device *rom_create (const char *filename, unsigned int maxsize);
struct hw_device *console_create (void);
struct hw_device *disk_create (const char *backing_file);
#endif /* _M6809_MACHINE_H */
|
bcd/exec09
|
2fe00a2a2ceb2962355bcbcedcf93ed0d41370c9
|
Store --realtime option given.
|
diff --git a/main.c b/main.c
index 77b00e9..ceb7531 100644
--- a/main.c
+++ b/main.c
@@ -1,445 +1,450 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
unsigned long max_cycles = 500000000UL;
/* When nonzero, says that the state of the machine is persistent
across runs of the simulator. */
int machine_persistent = 0;
+/* When nonzero, says that the simulator is slowed down to match what a real
+processor would run like. */
+int machine_realtime = 0;
+
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
struct timeval time_started;
/**
* Return elapsed real time in milliseconds.
*/
long
time_diff (struct timeval *old, struct timeval *new)
{
long ms = (new->tv_usec - old->tv_usec) / 1000;
ms += (new->tv_sec - old->tv_sec) * 1000;
return ms;
}
long
get_elapsed_realtime (void)
{
struct timeval now;
gettimeofday (&now, NULL);
return time_diff (&time_started, &now);
}
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 30;
static int count = 30;
int delay;
static int total_ms_elapsed = 0;
static int cumulative_delay = 0;
if (--count > 0)
return;
if (last.tv_sec == 0 && last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = time_diff (&last, &now);
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
if (machine->periodic)
machine->periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
cumulative_delay += delay;
if (cumulative_delay > 0)
{
usleep (50 * 1000UL);
cumulative_delay -= 50;
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
int do_help (const char *arg __attribute__((unused)));
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
NO_NEG, NO_ARG, NULL, 0, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
- { 'R', "realtime", "Limit simulation speed to match realtime" },
+ { 'R', "realtime", "Limit simulation speed to match realtime",
+ HAS_NEG, NO_ARG, &machine_realtime, 0, NULL, NULL },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
{ 'p', "persistent", "Use persistent machine state",
NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
return -1;
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
sim_exit (0x70);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
gettimeofday (&time_started, NULL);
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
/* The machine loader cannot deal with S-record files.
So initialize the machine first, passing it a NULL
filename, then load the S-record file afterwards. */
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
total += cpu_execute (max_cycles ? max_cycles-1 : 500000);
}
else
{
total += cpu_execute (cycles_per_irq);
/* TODO - this assumes periodic interrupts (WPC) */
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
sim_exit (0);
return 0;
}
|
bcd/exec09
|
bb05acf966d7c7bc49635da84e0bb5633840bd72
|
Move disk device into a separate file.
|
diff --git a/disk.c b/disk.c
new file mode 100644
index 0000000..a9a9203
--- /dev/null
+++ b/disk.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2006-2009 by Brian Dominy <brian@oddchange.com>
+ *
+ * This file is part of GCC6809.
+ *
+ * GCC6809 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GCC6809 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GCC6809; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include "machine.h"
+#include "eon.h"
+
+/* The disk drive is emulated as follows:
+ * The disk is capable of "bus-mastering" and is able to dump data directly
+ * into a RAM device, without CPU-involvement. (The pages do not even need to
+ * be mapped.) A transaction is initiated with the following parameters:
+ *
+ * - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
+ * Thus there are 64 possible sector locations.
+ * - address of disk sector, given as a 16-bit value. This allows for up to
+ * a 32MB disk.
+ * - direction, either to disk or from disk.
+ *
+ * Emulation is synchronous with respect to the CPU. TODO: this should use
+ * interrupts and add real some latency.
+ */
+
+struct disk_geometry
+{
+ unsigned int sectors_per_track;
+ unsigned int tracks_per_cylinder;
+};
+
+struct disk_priv
+{
+ FILE *fp;
+ struct hw_device *dev;
+ unsigned long offset;
+ struct hw_device *ramdev;
+ unsigned int sectors;
+ char *ram;
+
+ unsigned int cycles_to_irq;
+ struct hw_device *int_dev;
+ unsigned int int_line;
+};
+
+
+void disk_update (struct hw_device *dev)
+{
+ /* Simulate the way that an actual disk would work.
+ Induce some latency into the process. */
+}
+
+U8 disk_read (struct hw_device *dev, unsigned long addr)
+{
+ struct disk_priv *disk = (struct disk_priv *)dev->priv;
+}
+
+void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
+{
+ struct disk_priv *disk = (struct disk_priv *)dev->priv;
+
+ switch (addr)
+ {
+ case DSK_ADDR:
+ disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
+ break;
+ case DSK_SECTOR:
+ disk->offset = val; /* high byte */
+ break;
+ case DSK_SECTOR+1: /* low byte */
+ /* Note, only writes to the low byte cause an update. */
+ disk->offset = (disk->offset << 8) | val;
+ disk->offset *= SECTOR_SIZE;
+ fseek (disk->fp, disk->offset, SEEK_SET);
+ break;
+ case DSK_CTRL:
+ if (val & DSK_READ)
+ {
+ fread (disk->ram, SECTOR_SIZE, 1, disk->fp);
+ }
+ else if (val & DSK_WRITE)
+ {
+ fwrite (disk->ram, SECTOR_SIZE, 1, disk->fp);
+ }
+ else if (val & DSK_ERASE)
+ {
+ char empty_sector[SECTOR_SIZE];
+ memset (empty_sector, 0xff, SECTOR_SIZE);
+ fwrite (empty_sector, SECTOR_SIZE, 1, disk->fp);
+ }
+
+ if (val & DSK_FLUSH)
+ {
+ fflush (disk->fp);
+ }
+ break;
+ }
+}
+
+void disk_reset (struct hw_device *dev)
+{
+ //struct disk_priv *disk = (struct disk_priv *)dev->priv;
+ disk_write (dev, DSK_ADDR, 0);
+ disk_write (dev, DSK_SECTOR, 0);
+ disk_write (dev, DSK_SECTOR+1, 0);
+ disk_write (dev, DSK_CTRL, DSK_FLUSH);
+}
+
+void disk_format (struct hw_device *dev)
+{
+ unsigned int sector;
+ struct disk_priv *disk = (struct disk_priv *)dev->priv;
+
+ for (sector = 0; sector < disk->sectors; sector++)
+ {
+ disk_write (dev, DSK_SECTOR, sector >> 8);
+ disk_write (dev, DSK_SECTOR+1, sector & 0xFF);
+ disk_write (dev, DSK_CTRL, DSK_ERASE);
+ }
+ disk_write (dev, DSK_CTRL, DSK_FLUSH);
+}
+
+struct hw_class disk_class =
+{
+ .readonly = 0,
+ .reset = disk_reset,
+ .read = disk_read,
+ .write = disk_write,
+ .update = disk_update,
+};
+
+struct hw_device *disk_create (const char *backing_file,
+ struct hw_device *ram_dev)
+{
+ struct disk_priv *disk = malloc (sizeof (struct disk_priv));
+ int newdisk = 0;
+
+ disk->fp = file_open (NULL, backing_file, "r+b");
+ if (disk->fp == NULL)
+ {
+ printf ("warning: disk does not exist, creating\n");
+ disk->fp = file_open (NULL, backing_file, "w+b");
+ newdisk = 1;
+ if (disk->fp == NULL)
+ {
+ printf ("warning: disk not created\n");
+ }
+ }
+
+ disk->ram = 0;
+ disk->ramdev = ram_dev;
+ disk->dev = device_attach (&disk_class, 4, disk);
+ disk->sectors = DISK_SECTOR_COUNT;
+ disk->cycles_to_irq = 0;
+
+ if (newdisk)
+ disk_format (disk->dev);
+
+ return disk->dev;
+}
+
diff --git a/machine.c b/machine.c
index 5acbd49..82c752f 100644
--- a/machine.c
+++ b/machine.c
@@ -25,689 +25,587 @@
#include "machine.h"
#include "6809.h"
#include "eon.h"
#define CONFIG_LEGACY
#define MISSING 0xff
#define mmu_device (device_table[0])
extern void eon_init (const char *);
extern void wpc_init (const char *);
struct machine *machine;
unsigned int device_count = 0;
struct hw_device *device_table[MAX_BUS_DEVICES];
struct hw_device *null_device;
struct bus_map busmaps[NUM_BUS_MAPS];
struct bus_map default_busmaps[NUM_BUS_MAPS];
U16 fault_addr;
U8 fault_type;
int system_running = 0;
void cpu_is_running (void)
{
system_running = 1;
}
void do_fault (unsigned int addr, unsigned int type)
{
if (system_running)
machine->fault (addr, type);
}
void exit_fault (unsigned int addr, unsigned int type)
{
monitor_on = debug_enabled;
sim_error ("Fault: addr=%04X type=%02X\n", addr, type);
exit (1);
}
/**
* Attach a new device to the bus. Only called during init.
*/
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv)
{
struct hw_device *dev = malloc (sizeof (struct hw_device));
dev->class_ptr = class_ptr;
dev->devid = device_count;
dev->size = size;
dev->priv = priv;
device_table[device_count++] = dev;
/* Attach implies reset */
class_ptr->reset (dev);
return dev;
};
/**
* Map a portion of a device into the CPU's address space.
*/
void bus_map (unsigned int addr,
unsigned int devid,
unsigned long offset,
unsigned int len,
unsigned int flags)
{
struct bus_map *map;
unsigned int start, count;
/* Warn if trying to map too much */
if (addr + len > MAX_CPU_ADDR)
{
fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n",
len, addr);
}
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
offset = ((offset + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Initialize the maps. This will let the CPU access the device. */
map = &busmaps[start];
while (count > 0)
{
if (!(map->flags & MAP_FIXED))
{
map->devid = devid;
map->offset = offset;
map->flags = flags;
}
count--;
map++;
offset += BUS_MAP_SIZE;
}
}
void device_define (struct hw_device *dev,
unsigned long offset,
unsigned int addr,
unsigned int len,
unsigned int flags)
{
/* Note: len must be a multiple of BUS_MAP_SIZE */
bus_map (addr, dev->devid, offset, len, flags);
}
void bus_unmap (unsigned int addr, unsigned int len)
{
struct bus_map *map;
unsigned int start, count;
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
{
do_fault (addr, FAULT_NO_RESPONSE);
return null_device;
}
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
* a caching scheme that cuts down on some of this.
* There is also a 16-bit version that is more efficient when
* a full word is needed, but it implies that no reads will ever
* occur across a device boundary.
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_READABLE))
machine->fault (addr, FAULT_NOT_READABLE);
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_READABLE))
do_fault (addr, FAULT_NOT_READABLE);
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return ((*class_ptr->read) (dev, phy_addr) << 8)
| (*class_ptr->read) (dev, phy_addr+1);
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_WRITABLE))
do_fault (addr, FAULT_NOT_WRITABLE);
(*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
0 /* device_table[map->devid]->size */, map->flags);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
return 0xFF;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
struct hw_class null_class =
{
.readonly = 0,
.reset = null_reset,
.read = null_read,
.write = null_write,
};
struct hw_device *null_create (void)
{
return device_attach (&null_class, 0, NULL);
}
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
mmu_regs[page][2] & MAP_READWRITE);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
mmu_write (dev, page * MMU_PAGEREGS + 2, MAP_READWRITE);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
mmu_regs[page][2] = map->flags & MAP_READWRITE;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
-/**********************************************************/
-
-/* The disk drive is emulated as follows:
- * The disk is capable of "bus-mastering" and is able to dump data directly
- * into the RAM, without CPU-involvement. (The pages do not even need to
- * be mapped.) A transaction is initiated with the following parameters:
- *
- * - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
- * Thus there are 64 possible sector locations.
- * - address of disk sector, given as a 16-bit value. This allows for up to
- * a 32MB disk.
- * - direction, either to disk or from disk.
- *
- * Emulation is synchronous with respect to the CPU. TODO: this should use
- * interrupts and add real some latency.
- */
-
-struct disk_priv
-{
- FILE *fp;
- struct hw_device *dev;
- unsigned long offset;
- struct hw_device *ramdev;
- unsigned int sectors;
- char *ram;
-};
-
-
-U8 disk_read (struct hw_device *dev, unsigned long addr)
-{
- struct disk_priv *disk = (struct disk_priv *)dev->priv;
-}
-
-void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
-{
- struct disk_priv *disk = (struct disk_priv *)dev->priv;
-
- switch (addr)
- {
- case DSK_ADDR:
- disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
- break;
- case DSK_SECTOR:
- disk->offset = val; /* high byte */
- break;
- case DSK_SECTOR+1:
- disk->offset = (disk->offset << 8) | val;
- disk->offset *= SECTOR_SIZE;
- fseek (disk->fp, disk->offset, SEEK_SET);
- break;
- case DSK_CTRL:
- if (val & DSK_READ)
- {
- fread (disk->ram, SECTOR_SIZE, 1, disk->fp);
- }
- else if (val & DSK_WRITE)
- {
- fwrite (disk->ram, SECTOR_SIZE, 1, disk->fp);
- }
- else if (val & DSK_ERASE)
- {
- char empty_sector[SECTOR_SIZE];
- memset (empty_sector, 0xff, SECTOR_SIZE);
- fwrite (empty_sector, SECTOR_SIZE, 1, disk->fp);
- }
-
- if (val & DSK_FLUSH)
- {
- fflush (disk->fp);
- }
- break;
- }
-}
-void disk_reset (struct hw_device *dev)
-{
- struct disk_priv *disk = (struct disk_priv *)dev->priv;
- disk_write (dev, DSK_ADDR, 0);
- disk_write (dev, DSK_SECTOR, 0);
- disk_write (dev, DSK_SECTOR+1, 0);
- disk_write (dev, DSK_CTRL, DSK_FLUSH);
-}
-
-void disk_format (struct hw_device *dev)
-{
- unsigned int sector;
- struct disk_priv *disk = (struct disk_priv *)dev->priv;
-
- for (sector = 0; sector < disk->sectors; sector++)
- {
- disk_write (dev, DSK_SECTOR, sector >> 8);
- disk_write (dev, DSK_SECTOR+1, sector & 0xFF);
- disk_write (dev, DSK_CTRL, DSK_ERASE);
- }
- disk_write (dev, DSK_CTRL, DSK_FLUSH);
-}
-
-struct hw_class disk_class =
-{
- .readonly = 0,
- .reset = disk_reset,
- .read = disk_read,
- .write = disk_write,
-};
+/**********************************************************/
struct hw_device *disk_create (const char *backing_file)
{
struct disk_priv *disk = malloc (sizeof (struct disk_priv));
int newdisk = 0;
disk->fp = file_open (NULL, backing_file, "r+b");
if (disk->fp == NULL)
{
printf ("warning: disk does not exist, creating\n");
disk->fp = file_open (NULL, backing_file, "w+b");
newdisk = 1;
if (disk->fp == NULL)
{
printf ("warning: disk not created\n");
}
}
disk->ram = 0;
disk->ramdev = device_table[1];
disk->dev = device_attach (&disk_class, BUS_MAP_SIZE, disk);
disk->sectors = DISK_SECTOR_COUNT;
if (newdisk)
disk_format (disk->dev);
return disk->dev;
}
/**********************************************************/
int machine_match (const char *machine_name, const char *boot_rom_file, struct machine *m)
{
if (!strcmp (m->name, machine_name))
{
machine = m;
m->init (boot_rom_file);
return 1;
}
return 0;
}
void machine_init (const char *machine_name, const char *boot_rom_file)
{
extern struct machine simple_machine;
extern struct machine eon_machine;
extern struct machine eon2_machine;
extern struct machine wpc_machine;
int i;
/* Initialize CPU maps, so that no CPU addresses map to
anything. Default maps will trigger faults at runtime. */
null_device = null_create ();
memset (busmaps, 0, sizeof (busmaps));
for (i = 0; i < NUM_BUS_MAPS; i++)
busmaps[i].devid = INVALID_DEVID;
if (machine_match (machine_name, boot_rom_file, &simple_machine));
else if (machine_match (machine_name, boot_rom_file, &eon_machine));
else if (machine_match (machine_name, boot_rom_file, &eon2_machine));
else if (machine_match (machine_name, boot_rom_file, &wpc_machine));
else exit (1);
/* Save the default busmap configuration, before the
CPU begins to run, so that it can be restored if
necessary. */
memcpy (default_busmaps, busmaps, sizeof (busmaps));
if (!strcmp (machine_name, "eon"))
mmu_reset_complete (mmu_device);
}
|
bcd/exec09
|
1c8e408462b4b9bf6325786f543d8dc2ebda5e62
|
Fix CPU interface to the imux; also add FIRQ support.
|
diff --git a/imux.c b/imux.c
index 1c8ea18..3b52584 100644
--- a/imux.c
+++ b/imux.c
@@ -1,101 +1,135 @@
+/*
+ * Copyright 2009 by Brian Dominy <brian@oddchange.com>
+ *
+ * This file is part of GCC6809.
+ *
+ * GCC6809 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GCC6809 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GCC6809; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
/* The interrupt multiplexer */
#include "machine.h"
#include "eon.h"
struct imux
{
unsigned int in_use; /* Bits for each int that are used */
unsigned int enabled; /* Bits for each int that is enabled */
unsigned int pending; /* Bits for each int that are active */
unsigned int src; /* Source line back to CPU */
};
+
+/*
+ * Refresh the state of the interrupt line back to the CPU.
+ * src == 1 refers to IRQ, src == 2 for FIRQ.
+ */
void imux_refresh (struct imux *mux)
{
if (mux->pending & mux->enabled)
- request_irq (mux->src);
+ {
+ if (mux->src == 1)
+ request_irq (mux->src);
+ else
+ request_firq (mux->src);
+ }
else
- release_irq (mux->src);
+ {
+ if (mux->src == 1)
+ release_irq (mux->src);
+ else
+ release_firq (mux->src);
+ }
}
void imux_reset (struct hw_device *dev)
{
struct imux *mux = (struct imux *)dev->priv;
mux->enabled = 0;
mux->pending = 0;
- mux->src = 1;
}
U8 imux_read (struct hw_device *dev, unsigned long addr)
{
struct imux *mux = (struct imux *)dev->priv;
switch (addr)
{
- case IMUX_ADDR - IMUX_ENB:
+ case IMUX_ENB:
/* Return the enable bits */
return mux->enabled & 0xFF;
- case IMUX_ADDR - IMUX_PEND:
+ case IMUX_PEND:
/* Return the pending bits */
return mux->pending & 0xFF;
}
return -1;
}
void imux_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct imux *mux = (struct imux *)dev->priv;
switch (addr)
{
- case IMUX_ADDR - IMUX_ENB:
+ case IMUX_ENB:
/* Set the interrupt enables */
mux->enabled = val;
break;
- case IMUX_ADDR - IMUX_PEND:
+ case IMUX_PEND:
/* Clear pending interrupt source */
mux->pending &= ~val;
break;
}
imux_refresh (mux);
}
/*
* Register an interrupt line with the multiplexer.
* This just tracks which ones are in use.
*/
void imux_register (struct hw_device *dev, unsigned int sig)
{
struct imux *mux = (struct imux *)dev->priv;
mux->in_use |= (1 << sig);
}
/*
* Assert an edge-triggered interrupt line.
*/
void imux_assert (struct hw_device *dev, unsigned int sig)
{
struct imux *mux = (struct imux *)dev->priv;
mux->pending |= (1 << sig);
imux_refresh (mux);
}
struct hw_class imux_class =
{
.readonly = 0,
.reset = imux_reset,
.read = imux_read,
.write = imux_write,
};
-struct hw_device *imux_create (void)
+struct hw_device *imux_create (unsigned int cpu_line)
{
struct imux *imux = malloc (sizeof (struct imux));
+ imux->src = cpu_line;
return device_attach (&imux_class, BUS_MAP_SIZE, imux);
}
|
bcd/exec09
|
976548fe73d63b9ccf7943470c83bf1c14a440de
|
Generate timer interrupts correctly if enabled. Add oscillator as a special case of timers.
|
diff --git a/timer.c b/timer.c
index 442128d..6d618a3 100644
--- a/timer.c
+++ b/timer.c
@@ -1,118 +1,178 @@
+/*
+ * Copyright 2009 by Brian Dominy <brian@oddchange.com>
+ *
+ * This file is part of GCC6809.
+ *
+ * GCC6809 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GCC6809 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GCC6809; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include <stdio.h>
#include "machine.h"
/* A hardware timer counts CPU cycles and can generate interrupts periodically. */
struct hwtimer
{
int count; /* The current value of the timer */
unsigned int reload; /* Value to reload into the timer when it reaches zero */
unsigned int resolution; /* Resolution of CPU registers (cycles/tick) */
unsigned int flags;
+ unsigned long prev_cycles;
struct hw_device *int_dev; /* Which interrupt mux we use */
unsigned int int_line; /* Which interrupt to signal */
};
/* The I/O registers exposed by this driver */
#define HWT_COUNT 0 /* The 8-bit timer counter */
#define HWT_RELOAD 1 /* The 8-bit reload counter */
#define HWT_FLAGS 2 /* Misc. flags */
#define HWTF_INT 0x80 /* Generate interrupt at zero */
/*
* Called by the system to indicate that some number of CPU cycles have passed.
*/
-void hwtimer_decrement (struct hw_device *dev, unsigned int cycles)
+void hwtimer_decrement (struct hwtimer *timer, unsigned int cycles)
{
- struct hwtimer *timer = (struct hwtimer *)dev->priv;
-
/* If either the counter or the reload register is nonzero, the timer
is considered running. Otherwise, nothing to do */
if (!timer->count && !timer->reload)
return;
/* Decrement the counter. Is it zero/negative? */
timer->count -= cycles;
if (timer->count <= 0)
{
- /* If interrupt is enabled, generate that now */
- if (timer->flags & HWTF_INT)
+ /* If interrupt is configured and enabled, generate one now */
+ if (timer->int_dev && timer->flags & HWTF_INT)
{
+ imux_assert (timer->int_dev, timer->int_line);
}
/* If it is negative, we need to make it positive again.
If reload is nonzero, add that, to simulate the timer "wrapping".
Otherwise, fix it at zero. */
- if (timer->flags < 0)
+ if (timer->count < 0)
{
- if (timer->reload)
+ if (timer->reload > 0)
{
timer->count += timer->reload;
/* Note: if timer->count is still negative, the reload value
is lower than the frequency at which the system is updating the
timers, and we would need to simulate two interrupts here
perhaps. For later. */
+ if (timer->count < 0)
+ sim_error ("timer count = %d, reload = %d\n", timer->count, timer->reload);
}
else
{
timer->count = 0;
}
}
}
}
+void hwtimer_update (struct hw_device *dev)
+{
+ struct hwtimer *timer = (struct hwtimer *)dev->priv;
+ unsigned long cycles = get_cycles ();
+ hwtimer_decrement (timer, cycles - timer->prev_cycles);
+ timer->prev_cycles = cycles;
+}
+
+
U8 hwtimer_read (struct hw_device *dev, unsigned long addr)
{
struct hwtimer *timer = (struct hwtimer *)dev->priv;
switch (addr)
{
case HWT_COUNT:
return timer->count / timer->resolution;
case HWT_RELOAD:
return timer->reload / timer->resolution;
case HWT_FLAGS:
return timer->flags;
}
}
void hwtimer_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct hwtimer *timer = (struct hwtimer *)dev->priv;
switch (addr)
{
case HWT_COUNT:
timer->count = val * timer->resolution;
break;
case HWT_RELOAD:
timer->reload = val * timer->resolution;
break;
case HWT_FLAGS:
timer->flags = val;
break;
}
}
void hwtimer_reset (struct hw_device *dev)
{
struct hwtimer *timer = (struct hwtimer *)dev->priv;
timer->count = 0;
- timer->reload = 0;
+ timer->flags = 0;
timer->resolution = 128;
+ timer->prev_cycles = get_cycles ();
+}
+
+void oscillator_reset (struct hw_device *dev)
+{
+ struct hwtimer *timer = (struct hwtimer *)dev->priv;
+ hwtimer_reset (dev);
+ timer->count = timer->reload;
+ if (timer->int_dev)
+ timer->flags |= HWTF_INT;
}
struct hw_class hwtimer_class =
{
.readonly = 0,
.reset = hwtimer_reset,
.read = hwtimer_read,
.write = hwtimer_write,
+ .update = hwtimer_update,
};
-struct hw_device *hwtimer_create (void)
+struct hw_device *hwtimer_create (struct hw_device *int_dev, unsigned int int_line)
{
struct hwtimer *timer = malloc (sizeof (struct hwtimer));
+ timer->reload = 0;
+ timer->int_dev = int_dev;
+ timer->int_line = int_line;
return device_attach (&hwtimer_class, 16, timer); /* 16 = sizeof I/O window */
}
+struct hw_class oscillator_class =
+{
+ .readonly = 0,
+ .reset = oscillator_reset,
+ .read = NULL,
+ .write = NULL,
+ .update = hwtimer_update,
+};
+struct hw_device *oscillator_create (struct hw_device *int_dev, unsigned int int_line)
+{
+ struct hwtimer *timer = malloc (sizeof (struct hwtimer));
+ timer->reload = 2048; /* cycles per pulse */
+ timer->int_dev = int_dev;
+ timer->int_line = int_line;
+ return device_attach (&oscillator_class, 0, timer);
+}
|
bcd/exec09
|
0efc348534e72d8d9b99ae88ba48d40a1afa4d7f
|
Call the machine fault handler from a common function first.
|
diff --git a/machine.c b/machine.c
index 8765565..d503c6c 100644
--- a/machine.c
+++ b/machine.c
@@ -1,674 +1,690 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "machine.h"
#include "6809.h"
#include "eon.h"
#define CONFIG_LEGACY
#define MISSING 0xff
#define mmu_device (device_table[0])
extern void eon_init (const char *);
extern void wpc_init (const char *);
struct machine *machine;
unsigned int device_count = 0;
struct hw_device *device_table[MAX_BUS_DEVICES];
struct bus_map busmaps[NUM_BUS_MAPS];
struct bus_map default_busmaps[NUM_BUS_MAPS];
U16 fault_addr;
U8 fault_type;
int system_running = 0;
+
void cpu_is_running (void)
{
system_running = 1;
}
+void do_fault (unsigned int addr, unsigned int type)
+{
+ if (system_running)
+ machine->fault (addr, type);
+}
+
+
+void exit_fault (unsigned int addr, unsigned int type)
+{
+ monitor_on = debug_enabled;
+ sim_error ("Fault: addr=%04X type=%02X\n", addr, type);
+ exit (1);
+}
+
+
/**
* Attach a new device to the bus. Only called during init.
*/
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv)
{
struct hw_device *dev = malloc (sizeof (struct hw_device));
dev->class_ptr = class_ptr;
dev->devid = device_count;
dev->size = size;
dev->priv = priv;
device_table[device_count++] = dev;
/* Attach implies reset */
class_ptr->reset (dev);
return dev;
};
/**
* Map a portion of a device into the CPU's address space.
*/
void bus_map (unsigned int addr,
unsigned int devid,
unsigned long offset,
unsigned int len,
unsigned int flags)
{
struct bus_map *map;
unsigned int start, count;
/* Warn if trying to map too much */
if (addr + len > MAX_CPU_ADDR)
{
fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n",
len, addr);
}
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
offset = ((offset + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Initialize the maps. This will let the CPU access the device. */
map = &busmaps[start];
while (count > 0)
{
if (!(map->flags & MAP_FIXED))
{
map->devid = devid;
map->offset = offset;
map->flags = flags;
}
count--;
map++;
offset += BUS_MAP_SIZE;
}
}
void device_define (struct hw_device *dev,
unsigned long offset,
unsigned int addr,
unsigned int len,
unsigned int flags)
{
bus_map (addr, dev->devid, offset, len, flags);
}
void bus_unmap (unsigned int addr, unsigned int len)
{
struct bus_map *map;
unsigned int start, count;
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
- machine->fault (addr, FAULT_NO_RESPONSE);
+ do_fault (addr, FAULT_NO_RESPONSE);
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
* a caching scheme that cuts down on some of this...
* Also consider a native 16-bit read that doesn't require
* 2 separate calls here...
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_READABLE))
- machine->fault (addr, FAULT_NOT_READABLE);
+ do_fault (addr, FAULT_NOT_READABLE);
else
{
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return ((*class_ptr->read) (dev, phy_addr) << 8)
| (*class_ptr->read) (dev, phy_addr+1);
}
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
/* This can fail if the area is read-only */
if (system_running && !(map->flags & MAP_WRITABLE))
- machine->fault (addr, FAULT_NOT_WRITABLE);
+ do_fault (addr, FAULT_NOT_WRITABLE);
else
(*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
0 /* device_table[map->devid]->size */, map->flags);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
return 0;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
mmu_regs[page][2] & MAP_READWRITE);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
mmu_write (dev, page * MMU_PAGEREGS + 2, MAP_READWRITE);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
mmu_regs[page][2] = map->flags & MAP_READWRITE;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
/* The disk drive is emulated as follows:
* The disk is capable of "bus-mastering" and is able to dump data directly
* into the RAM, without CPU-involvement. (The pages do not even need to
* be mapped.) A transaction is initiated with the following parameters:
*
* - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
* Thus there are 64 possible sector locations.
* - address of disk sector, given as a 16-bit value. This allows for up to
* a 32MB disk.
* - direction, either to disk or from disk.
*
* Emulation is synchronous with respect to the CPU. TODO: this should use
* interrupts and add real some latency.
*/
struct disk_priv
{
FILE *fp;
struct hw_device *dev;
unsigned long offset;
struct hw_device *ramdev;
unsigned int sectors;
char *ram;
};
U8 disk_read (struct hw_device *dev, unsigned long addr)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
}
void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
switch (addr)
{
case DSK_ADDR:
disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
break;
case DSK_SECTOR:
disk->offset = val; /* high byte */
break;
case DSK_SECTOR+1:
disk->offset = (disk->offset << 8) | val;
disk->offset *= SECTOR_SIZE;
fseek (disk->fp, disk->offset, SEEK_SET);
break;
case DSK_CTRL:
if (val & DSK_READ)
{
fread (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_WRITE)
{
fwrite (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_ERASE)
{
char empty_sector[SECTOR_SIZE];
memset (empty_sector, 0xff, SECTOR_SIZE);
fwrite (empty_sector, SECTOR_SIZE, 1, disk->fp);
}
if (val & DSK_FLUSH)
{
fflush (disk->fp);
}
break;
}
}
void disk_reset (struct hw_device *dev)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
disk_write (dev, DSK_ADDR, 0);
disk_write (dev, DSK_SECTOR, 0);
disk_write (dev, DSK_SECTOR+1, 0);
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
void disk_format (struct hw_device *dev)
{
unsigned int sector;
struct disk_priv *disk = (struct disk_priv *)dev->priv;
for (sector = 0; sector < disk->sectors; sector++)
{
disk_write (dev, DSK_SECTOR, sector >> 8);
disk_write (dev, DSK_SECTOR+1, sector & 0xFF);
disk_write (dev, DSK_CTRL, DSK_ERASE);
}
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
struct hw_class disk_class =
{
.readonly = 0,
.reset = disk_reset,
.read = disk_read,
.write = disk_write,
};
struct hw_device *disk_create (const char *backing_file)
{
struct disk_priv *disk = malloc (sizeof (struct disk_priv));
int newdisk = 0;
disk->fp = file_open (NULL, backing_file, "r+b");
if (disk->fp == NULL)
{
printf ("warning: disk does not exist, creating\n");
disk->fp = file_open (NULL, backing_file, "w+b");
newdisk = 1;
if (disk->fp == NULL)
{
printf ("warning: disk not created\n");
}
}
disk->ram = 0;
disk->ramdev = device_table[1];
disk->dev = device_attach (&disk_class, BUS_MAP_SIZE, disk);
disk->sectors = DISK_SECTOR_COUNT;
if (newdisk)
disk_format (disk->dev);
return disk->dev;
}
/**********************************************************/
int machine_match (const char *machine_name, const char *boot_rom_file, struct machine *m)
{
if (!strcmp (m->name, machine_name))
{
machine = m;
m->init (boot_rom_file);
return 1;
}
return 0;
}
void machine_init (const char *machine_name, const char *boot_rom_file)
{
extern struct machine simple_machine;
extern struct machine eon_machine;
extern struct machine wpc_machine;
int i;
/* Initialize CPU maps, so that no CPU addresses map to
anything. Default maps will trigger faults at runtime. */
memset (busmaps, 0, sizeof (busmaps));
for (i = 0; i < NUM_BUS_MAPS; i++)
busmaps[i].devid = INVALID_DEVID;
if (machine_match (machine_name, boot_rom_file, &simple_machine));
else if (machine_match (machine_name, boot_rom_file, &eon_machine));
else if (machine_match (machine_name, boot_rom_file, &wpc_machine));
else exit (1);
/* Save the default busmap configuration, before the
CPU begins to run, so that it can be restored if
necessary. */
memcpy (default_busmaps, busmaps, sizeof (busmaps));
if (!strcmp (machine_name, "eon"))
mmu_reset_complete (mmu_device);
}
|
bcd/exec09
|
68a80d19e2f1d4e8782f54bf89939d68b4f2f4a7
|
Comments/general cleanup.
|
diff --git a/machine.c b/machine.c
index 4905c8d..8765565 100644
--- a/machine.c
+++ b/machine.c
@@ -2,672 +2,673 @@
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "machine.h"
#include "6809.h"
#include "eon.h"
#define CONFIG_LEGACY
#define MISSING 0xff
#define mmu_device (device_table[0])
extern void eon_init (const char *);
extern void wpc_init (const char *);
struct machine *machine;
unsigned int device_count = 0;
struct hw_device *device_table[MAX_BUS_DEVICES];
struct bus_map busmaps[NUM_BUS_MAPS];
struct bus_map default_busmaps[NUM_BUS_MAPS];
U16 fault_addr;
U8 fault_type;
int system_running = 0;
void cpu_is_running (void)
{
system_running = 1;
}
/**
* Attach a new device to the bus. Only called during init.
*/
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv)
{
struct hw_device *dev = malloc (sizeof (struct hw_device));
dev->class_ptr = class_ptr;
dev->devid = device_count;
dev->size = size;
dev->priv = priv;
device_table[device_count++] = dev;
/* Attach implies reset */
class_ptr->reset (dev);
return dev;
};
/**
* Map a portion of a device into the CPU's address space.
*/
void bus_map (unsigned int addr,
unsigned int devid,
unsigned long offset,
unsigned int len,
unsigned int flags)
{
struct bus_map *map;
unsigned int start, count;
/* Warn if trying to map too much */
if (addr + len > MAX_CPU_ADDR)
{
fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n",
len, addr);
}
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
offset = ((offset + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Initialize the maps. This will let the CPU access the device. */
map = &busmaps[start];
while (count > 0)
{
if (!(map->flags & MAP_FIXED))
{
map->devid = devid;
map->offset = offset;
map->flags = flags;
}
count--;
map++;
offset += BUS_MAP_SIZE;
}
}
void device_define (struct hw_device *dev,
unsigned long offset,
unsigned int addr,
unsigned int len,
unsigned int flags)
{
bus_map (addr, dev->devid, offset, len, flags);
}
void bus_unmap (unsigned int addr, unsigned int len)
{
struct bus_map *map;
unsigned int start, count;
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
machine->fault (addr, FAULT_NO_RESPONSE);
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
* a caching scheme that cuts down on some of this...
* Also consider a native 16-bit read that doesn't require
* 2 separate calls here...
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
if (system_running && !(map->flags & MAP_READABLE))
machine->fault (addr, FAULT_NOT_READABLE);
else
{
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return ((*class_ptr->read) (dev, phy_addr) << 8)
| (*class_ptr->read) (dev, phy_addr+1);
}
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
/* This can fail if the area is read-only */
if (system_running && !(map->flags & MAP_WRITABLE))
machine->fault (addr, FAULT_NOT_WRITABLE);
else
(*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
0 /* device_table[map->devid]->size */, map->flags);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
return 0;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
mmu_regs[page][2] & MAP_READWRITE);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
mmu_write (dev, page * MMU_PAGEREGS + 2, MAP_READWRITE);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
mmu_regs[page][2] = map->flags & MAP_READWRITE;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
/* The disk drive is emulated as follows:
* The disk is capable of "bus-mastering" and is able to dump data directly
* into the RAM, without CPU-involvement. (The pages do not even need to
* be mapped.) A transaction is initiated with the following parameters:
*
* - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
* Thus there are 64 possible sector locations.
* - address of disk sector, given as a 16-bit value. This allows for up to
* a 32MB disk.
* - direction, either to disk or from disk.
*
- * Emulation is synchronous with respect to the CPU.
+ * Emulation is synchronous with respect to the CPU. TODO: this should use
+ * interrupts and add real some latency.
*/
struct disk_priv
{
FILE *fp;
struct hw_device *dev;
unsigned long offset;
struct hw_device *ramdev;
unsigned int sectors;
char *ram;
};
U8 disk_read (struct hw_device *dev, unsigned long addr)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
}
void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
switch (addr)
{
case DSK_ADDR:
disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
break;
case DSK_SECTOR:
disk->offset = val; /* high byte */
break;
case DSK_SECTOR+1:
disk->offset = (disk->offset << 8) | val;
disk->offset *= SECTOR_SIZE;
fseek (disk->fp, disk->offset, SEEK_SET);
break;
case DSK_CTRL:
if (val & DSK_READ)
{
fread (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_WRITE)
{
fwrite (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_ERASE)
{
char empty_sector[SECTOR_SIZE];
memset (empty_sector, 0xff, SECTOR_SIZE);
fwrite (empty_sector, SECTOR_SIZE, 1, disk->fp);
}
if (val & DSK_FLUSH)
{
fflush (disk->fp);
}
break;
}
}
void disk_reset (struct hw_device *dev)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
disk_write (dev, DSK_ADDR, 0);
disk_write (dev, DSK_SECTOR, 0);
disk_write (dev, DSK_SECTOR+1, 0);
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
void disk_format (struct hw_device *dev)
{
unsigned int sector;
struct disk_priv *disk = (struct disk_priv *)dev->priv;
for (sector = 0; sector < disk->sectors; sector++)
{
disk_write (dev, DSK_SECTOR, sector >> 8);
disk_write (dev, DSK_SECTOR+1, sector & 0xFF);
disk_write (dev, DSK_CTRL, DSK_ERASE);
}
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
struct hw_class disk_class =
{
.readonly = 0,
.reset = disk_reset,
.read = disk_read,
.write = disk_write,
};
struct hw_device *disk_create (const char *backing_file)
{
struct disk_priv *disk = malloc (sizeof (struct disk_priv));
int newdisk = 0;
disk->fp = file_open (NULL, backing_file, "r+b");
if (disk->fp == NULL)
{
printf ("warning: disk does not exist, creating\n");
disk->fp = file_open (NULL, backing_file, "w+b");
newdisk = 1;
if (disk->fp == NULL)
{
printf ("warning: disk not created\n");
}
}
disk->ram = 0;
disk->ramdev = device_table[1];
disk->dev = device_attach (&disk_class, BUS_MAP_SIZE, disk);
disk->sectors = DISK_SECTOR_COUNT;
if (newdisk)
disk_format (disk->dev);
return disk->dev;
}
/**********************************************************/
int machine_match (const char *machine_name, const char *boot_rom_file, struct machine *m)
{
if (!strcmp (m->name, machine_name))
{
machine = m;
m->init (boot_rom_file);
return 1;
}
return 0;
}
void machine_init (const char *machine_name, const char *boot_rom_file)
{
extern struct machine simple_machine;
extern struct machine eon_machine;
extern struct machine wpc_machine;
int i;
/* Initialize CPU maps, so that no CPU addresses map to
anything. Default maps will trigger faults at runtime. */
memset (busmaps, 0, sizeof (busmaps));
for (i = 0; i < NUM_BUS_MAPS; i++)
busmaps[i].devid = INVALID_DEVID;
if (machine_match (machine_name, boot_rom_file, &simple_machine));
else if (machine_match (machine_name, boot_rom_file, &eon_machine));
else if (machine_match (machine_name, boot_rom_file, &wpc_machine));
else exit (1);
/* Save the default busmap configuration, before the
CPU begins to run, so that it can be restored if
necessary. */
memcpy (default_busmaps, busmaps, sizeof (busmaps));
if (!strcmp (machine_name, "eon"))
mmu_reset_complete (mmu_device);
}
diff --git a/monitor.c b/monitor.c
index 9f1d337..6e7aebb 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,1448 +1,1448 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "6809.h"
#include "monitor.h"
#include <ctype.h>
#include <signal.h>
/* The function call stack */
struct function_call fctab[MAX_FUNCTION_CALLS];
/* The top of the function call stack */
struct function_call *current_function_call;
/* Automatically break after executing this many instructions */
int auto_break_insn_count = 0;
int monitor_on = 0;
int dump_every_insn = 0;
enum addr_mode
{
_illegal, _implied, _imm_byte, _imm_word, _direct, _extended,
_indexed, _rel_byte, _rel_word, _reg_post, _sys_post, _usr_post
};
enum opcode
{
_undoc, _abx, _adca, _adcb, _adda, _addb, _addd, _anda, _andb,
_andcc, _asla, _aslb, _asl, _asra, _asrb, _asr, _bcc, _lbcc,
_bcs, _lbcs, _beq, _lbeq, _bge, _lbge, _bgt, _lbgt, _bhi,
_lbhi, _bita, _bitb, _ble, _lble, _bls, _lbls, _blt, _lblt,
_bmi, _lbmi, _bne, _lbne, _bpl, _lbpl, _bra, _lbra, _brn,
_lbrn, _bsr, _lbsr, _bvc, _lbvc, _bvs, _lbvs, _clra, _clrb,
_clr, _cmpa, _cmpb, _cmpd, _cmps, _cmpu, _cmpx, _cmpy, _coma,
_comb, _com, _cwai, _daa, _deca, _decb, _dec, _eora, _eorb,
_exg, _inca, _incb, _inc, _jmp, _jsr, _lda, _ldb, _ldd,
_lds, _ldu, _ldx, _ldy, _leas, _leau, _leax, _leay, _lsra,
_lsrb, _lsr, _mul, _nega, _negb, _neg, _nop, _ora, _orb,
_orcc, _pshs, _pshu, _puls, _pulu, _rola, _rolb, _rol, _rora,
_rorb, _ror, _rti, _rts, _sbca, _sbcb, _sex, _sta, _stb,
_std, _sts, _stu, _stx, _sty, _suba, _subb, _subd, _swi,
_swi2, _swi3, _sync, _tfr, _tsta, _tstb, _tst, _reset,
#ifdef H6309
_negd, _comd, _lsrd, _rord, _asrd, _rold, _decd, _incd, _tstd,
_clrd
#endif
};
char *mne[] = {
"???", "ABX", "ADCA", "ADCB", "ADDA", "ADDB", "ADDD", "ANDA", "ANDB",
"ANDCC", "ASLA", "ASLB", "ASL", "ASRA", "ASRB", "ASR", "BCC", "LBCC",
"BCS", "LBCS", "BEQ", "LBEQ", "BGE", "LBGE", "BGT", "LBGT", "BHI",
"LBHI", "BITA", "BITB", "BLE", "LBLE", "BLS", "LBLS", "BLT", "LBLT",
"BMI", "LBMI", "BNE", "LBNE", "BPL", "LBPL", "BRA", "LBRA", "BRN",
"LBRN", "BSR", "LBSR", "BVC", "LBVC", "BVS", "LBVS", "CLRA", "CLRB",
"CLR", "CMPA", "CMPB", "CMPD", "CMPS", "CMPU", "CMPX", "CMPY", "COMA",
"COMB", "COM", "CWAI", "DAA", "DECA", "DECB", "DEC", "EORA", "EORB",
"EXG", "INCA", "INCB", "INC", "JMP", "JSR", "LDA", "LDB", "LDD",
"LDS", "LDU", "LDX", "LDY", "LEAS", "LEAU", "LEAX", "LEAY", "LSRA",
"LSRB", "LSR", "MUL", "NEGA", "NEGB", "NEG", "NOP", "ORA", "ORB",
"ORCC", "PSHS", "PSHU", "PULS", "PULU", "ROLA", "ROLB", "ROL", "RORA",
"RORB", "ROR", "RTI", "RTS", "SBCA", "SBCB", "SEX", "STA", "STB",
"STD", "STS", "STU", "STX", "STY", "SUBA", "SUBB", "SUBD", "SWI",
"SWI2", "SWI3", "SYNC", "TFR", "TSTA", "TSTB", "TST", "RESET",
#ifdef H6309
"NEGD", "COMD", "LSRD", "RORD", "ASRD", "ROLD", "DECD",
"INCD", "TSTD", "CLRD",
#endif
};
typedef struct
{
UINT8 code;
UINT8 mode;
} opcode_t;
opcode_t codes[256] = {
{_neg, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_com, _direct},
{_lsr, _direct},
{_undoc, _illegal},
{_ror, _direct},
{_asr, _direct},
{_asl, _direct},
{_rol, _direct},
{_dec, _direct},
{_undoc, _illegal},
{_inc, _direct},
{_tst, _direct},
{_jmp, _direct},
{_clr, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_nop, _implied},
{_sync, _implied},
{_undoc, _illegal},
{_undoc, _illegal},
{_lbra, _rel_word},
{_lbsr, _rel_word},
{_undoc, _illegal},
{_daa, _implied},
{_orcc, _imm_byte},
{_undoc, _illegal},
{_andcc, _imm_byte},
{_sex, _implied},
{_exg, _reg_post},
{_tfr, _reg_post},
{_bra, _rel_byte},
{_brn, _rel_byte},
{_bhi, _rel_byte},
{_bls, _rel_byte},
{_bcc, _rel_byte},
{_bcs, _rel_byte},
{_bne, _rel_byte},
{_beq, _rel_byte},
{_bvc, _rel_byte},
{_bvs, _rel_byte},
{_bpl, _rel_byte},
{_bmi, _rel_byte},
{_bge, _rel_byte},
{_blt, _rel_byte},
{_bgt, _rel_byte},
{_ble, _rel_byte},
{_leax, _indexed},
{_leay, _indexed},
{_leas, _indexed},
{_leau, _indexed},
{_pshs, _sys_post},
{_puls, _sys_post},
{_pshu, _usr_post},
{_pulu, _usr_post},
{_undoc, _illegal},
{_rts, _implied},
{_abx, _implied},
{_rti, _implied},
{_cwai, _imm_byte},
{_mul, _implied},
{_reset, _implied},
{_swi, _implied},
{_nega, _implied},
{_undoc, _illegal},
{_undoc, _illegal},
{_coma, _implied},
{_lsra, _implied},
{_undoc, _illegal},
{_rora, _implied},
{_asra, _implied},
{_asla, _implied},
{_rola, _implied},
{_deca, _implied},
{_undoc, _illegal},
{_inca, _implied},
{_tsta, _implied},
{_undoc, _illegal},
{_clra, _implied},
{_negb, _implied},
{_undoc, _illegal},
{_undoc, _illegal},
{_comb, _implied},
{_lsrb, _implied},
{_undoc, _illegal},
{_rorb, _implied},
{_asrb, _implied},
{_aslb, _implied},
{_rolb, _implied},
{_decb, _implied},
{_undoc, _illegal},
{_incb, _implied},
{_tstb, _implied},
{_undoc, _illegal},
{_clrb, _implied},
{_neg, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_com, _indexed},
{_lsr, _indexed},
{_undoc, _illegal},
{_ror, _indexed},
{_asr, _indexed},
{_asl, _indexed},
{_rol, _indexed},
{_dec, _indexed},
{_undoc, _illegal},
{_inc, _indexed},
{_tst, _indexed},
{_jmp, _indexed},
{_clr, _indexed},
{_neg, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_com, _extended},
{_lsr, _extended},
{_undoc, _illegal},
{_ror, _extended},
{_asr, _extended},
{_asl, _extended},
{_rol, _extended},
{_dec, _extended},
{_undoc, _illegal},
{_inc, _extended},
{_tst, _extended},
{_jmp, _extended},
{_clr, _extended},
{_suba, _imm_byte},
{_cmpa, _imm_byte},
{_sbca, _imm_byte},
{_subd, _imm_word},
{_anda, _imm_byte},
{_bita, _imm_byte},
{_lda, _imm_byte},
{_undoc, _illegal},
{_eora, _imm_byte},
{_adca, _imm_byte},
{_ora, _imm_byte},
{_adda, _imm_byte},
{_cmpx, _imm_word},
{_bsr, _rel_byte},
{_ldx, _imm_word},
{_undoc, _illegal},
{_suba, _direct},
{_cmpa, _direct},
{_sbca, _direct},
{_subd, _direct},
{_anda, _direct},
{_bita, _direct},
{_lda, _direct},
{_sta, _direct},
{_eora, _direct},
{_adca, _direct},
{_ora, _direct},
{_adda, _direct},
{_cmpx, _direct},
{_jsr, _direct},
{_ldx, _direct},
{_stx, _direct},
{_suba, _indexed},
{_cmpa, _indexed},
{_sbca, _indexed},
{_subd, _indexed},
{_anda, _indexed},
{_bita, _indexed},
{_lda, _indexed},
{_sta, _indexed},
{_eora, _indexed},
{_adca, _indexed},
{_ora, _indexed},
{_adda, _indexed},
{_cmpx, _indexed},
{_jsr, _indexed},
{_ldx, _indexed},
{_stx, _indexed},
{_suba, _extended},
{_cmpa, _extended},
{_sbca, _extended},
{_subd, _extended},
{_anda, _extended},
{_bita, _extended},
{_lda, _extended},
{_sta, _extended},
{_eora, _extended},
{_adca, _extended},
{_ora, _extended},
{_adda, _extended},
{_cmpx, _extended},
{_jsr, _extended},
{_ldx, _extended},
{_stx, _extended},
{_subb, _imm_byte},
{_cmpb, _imm_byte},
{_sbcb, _imm_byte},
{_addd, _imm_word},
{_andb, _imm_byte},
{_bitb, _imm_byte},
{_ldb, _imm_byte},
{_undoc, _illegal},
{_eorb, _imm_byte},
{_adcb, _imm_byte},
{_orb, _imm_byte},
{_addb, _imm_byte},
{_ldd, _imm_word},
{_undoc, _illegal},
{_ldu, _imm_word},
{_undoc, _illegal},
{_subb, _direct},
{_cmpb, _direct},
{_sbcb, _direct},
{_addd, _direct},
{_andb, _direct},
{_bitb, _direct},
{_ldb, _direct},
{_stb, _direct},
{_eorb, _direct},
{_adcb, _direct},
{_orb, _direct},
{_addb, _direct},
{_ldd, _direct},
{_std, _direct},
{_ldu, _direct},
{_stu, _direct},
{_subb, _indexed},
{_cmpb, _indexed},
{_sbcb, _indexed},
{_addd, _indexed},
{_andb, _indexed},
{_bitb, _indexed},
{_ldb, _indexed},
{_stb, _indexed},
{_eorb, _indexed},
{_adcb, _indexed},
{_orb, _indexed},
{_addb, _indexed},
{_ldd, _indexed},
{_std, _indexed},
{_ldu, _indexed},
{_stu, _indexed},
{_subb, _extended},
{_cmpb, _extended},
{_sbcb, _extended},
{_addd, _extended},
{_andb, _extended},
{_bitb, _extended},
{_ldb, _extended},
{_stb, _extended},
{_eorb, _extended},
{_adcb, _extended},
{_orb, _extended},
{_addb, _extended},
{_ldd, _extended},
{_std, _extended},
{_ldu, _extended},
{_stu, _extended}
};
opcode_t codes10[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lbrn, _rel_word},
{_lbhi, _rel_word},
{_lbls, _rel_word},
{_lbcc, _rel_word},
{_lbcs, _rel_word},
{_lbne, _rel_word},
{_lbeq, _rel_word},
{_lbvc, _rel_word},
{_lbvs, _rel_word},
{_lbpl, _rel_word},
{_lbmi, _rel_word},
{_lbge, _rel_word},
{_lblt, _rel_word},
{_lbgt, _rel_word},
{_lble, _rel_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_swi2, _implied},
{_undoc, _illegal}, /* 10 40 */
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpd, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpy, _imm_word},
{_undoc, _illegal},
{_ldy, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpd, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpy, _direct},
{_undoc, _illegal},
{_ldy, _direct},
{_sty, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpd, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpy, _indexed},
{_undoc, _illegal},
{_ldy, _indexed},
{_sty, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpd, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpy, _extended},
{_undoc, _illegal},
{_ldy, _extended},
{_sty, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _direct},
{_sts, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _indexed},
{_sts, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _extended},
{_sts, _extended}
};
opcode_t codes11[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_swi3, _implied},
{_undoc, _illegal}, /* 11 40 */
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal}
};
char *reg[] = {
"D", "X", "Y", "U", "S", "PC", "??", "??",
"A", "B", "CC", "DP", "??", "??", "??", "??"
};
char index_reg[] = { 'X', 'Y', 'U', 'S' };
char *off4[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
"-16", "-15", "-14", "-13", "-12", "-11", "-10", "-9",
"-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1"
};
-/* Disassemble the current instruction. Returns the number of bytes that
+/* Disassemble the current instruction. Returns the number of bytes that
compose it. */
int
dasm (char *buf, absolute_address_t opc)
-{
+{
UINT8 op, am;
char *op_str;
absolute_address_t pc = opc;
char R;
int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */
op = fetch8 ();
if (op == 0x10)
{
op = fetch8 ();
am = codes10[op].mode;
op = codes10[op].code;
}
else if (op == 0x11)
{
op = fetch8 ();
am = codes11[op].mode;
op = codes11[op].code;
}
else
{
am = codes[op].mode;
op = codes[op].code;
}
op_str = (char *) mne[op];
buf += sprintf (buf, "%-6.6s", op_str);
switch (am)
{
case _illegal:
sprintf (buf, "???");
break;
case _implied:
break;
case _imm_byte:
sprintf (buf, "#$%02X", fetch8 ());
break;
case _imm_word:
sprintf (buf, "#$%04X", fetch16 ());
break;
case _direct:
sprintf (buf, "<%s", monitor_addr_name (fetch8 ()));
break;
case _extended:
sprintf (buf, "%s", monitor_addr_name (fetch16 ()));
break;
case _indexed:
op = fetch8 ();
R = index_reg[(op >> 5) & 0x3];
if ((op & 0x80) == 0)
{
sprintf (buf, "%s,%c", off4[op & 0x1f], R);
break;
}
switch (op & 0x1f)
{
case 0x00:
sprintf (buf, ",%c+", R);
break;
case 0x01:
sprintf (buf, ",%c++", R);
break;
case 0x02:
sprintf (buf, ",-%c", R);
break;
case 0x03:
sprintf (buf, ",--%c", R);
break;
case 0x04:
sprintf (buf, ",%c", R);
break;
case 0x05:
sprintf (buf, "B,%c", R);
break;
case 0x06:
sprintf (buf, "A,%c", R);
break;
case 0x08:
sprintf (buf, "$%02X,%c", fetch8 (), R);
break;
case 0x09:
sprintf (buf, "$%04X,%c", fetch16 (), R);
break;
case 0x0B:
sprintf (buf, "D,%c", R);
break;
case 0x0C:
sprintf (buf, "$%02X,PC", fetch8 ());
break;
case 0x0D:
sprintf (buf, "$%04X,PC", fetch16 ());
break;
case 0x11:
sprintf (buf, "[,%c++]", R);
break;
case 0x13:
sprintf (buf, "[,--%c]", R);
break;
case 0x14:
sprintf (buf, "[,%c]", R);
break;
case 0x15:
sprintf (buf, "[B,%c]", R);
break;
case 0x16:
sprintf (buf, "[A,%c]", R);
break;
case 0x18:
sprintf (buf, "[$%02X,%c]", fetch8 (), R);
break;
case 0x19:
sprintf (buf, "[$%04X,%c]", fetch16 (), R);
break;
case 0x1B:
sprintf (buf, "[D,%c]", R);
break;
case 0x1C:
sprintf (buf, "[$%02X,PC]", fetch8 ());
break;
case 0x1D:
sprintf (buf, "[$%04X,PC]", fetch16 ());
break;
case 0x1F:
sprintf (buf, "[%s]", monitor_addr_name (fetch16 ()));
break;
default:
sprintf (buf, "???");
break;
}
break;
case _rel_byte:
fetch1 = ((INT8) fetch8 ());
sprintf (buf, "%s", absolute_addr_name (fetch1 + pc));
break;
case _rel_word:
sprintf (buf, "%s", absolute_addr_name (fetch16 () + pc));
break;
case _reg_post:
op = fetch8 ();
sprintf (buf, "%s,%s", reg[op >> 4], reg[op & 15]);
break;
case _usr_post:
case _sys_post:
op = fetch8 ();
if (op & 0x80)
strcat (buf, "PC,");
if (op & 0x40)
strcat (buf, am == _usr_post ? "S," : "U,");
if (op & 0x20)
strcat (buf, "Y,");
if (op & 0x10)
strcat (buf, "X,");
if (op & 0x08)
strcat (buf, "DP,");
if ((op & 0x06) == 0x06)
strcat (buf, "D,");
else
{
if (op & 0x04)
strcat (buf, "B,");
if (op & 0x02)
strcat (buf, "A,");
}
if (op & 0x01)
strcat (buf, "CC,");
buf[strlen (buf) - 1] = '\0';
break;
}
return pc - opc;
}
int
sizeof_file (FILE * file)
{
int size;
fseek (file, 0, SEEK_END);
size = ftell (file);
rewind (file);
return size;
}
int
load_map_file (const char *name)
{
FILE *fp;
char map_filename[256];
char buf[256];
char *value_ptr, *id_ptr;
target_addr_t value;
char *file_ptr;
struct symbol *sym = NULL;
/* Try appending the suffix 'map' to the name of the program. */
sprintf (map_filename, "%s.map", name);
fp = file_open (NULL, map_filename, "r");
if (!fp)
{
/* If that fails, try replacing any existing suffix. */
sprintf (map_filename, "%s", name);
char *s = strrchr (map_filename, '.');
if (s)
{
sprintf (s+1, "map");
fp = file_open (NULL, map_filename, "r");
}
if (!fp)
{
fprintf (stderr, "warning: no symbols for %s\n", name);
return -1;
}
}
printf ("Reading symbols from '%s'...\n", map_filename);
for (;;)
{
fgets (buf, sizeof(buf)-1, fp);
if (feof (fp))
break;
value_ptr = buf;
if (!strncmp (value_ptr, "page", 4))
{
unsigned char page = strtoul (value_ptr+4, NULL, 10);
if (!strcmp (machine->name, "wpc"))
wpc_set_rom_page (page);
sym = NULL;
continue;
}
if (strncmp (value_ptr, " ", 6))
continue;
while (*value_ptr == ' ')
value_ptr++;
value = strtoul (value_ptr, &id_ptr, 16);
if (id_ptr == value_ptr)
continue;
while (*id_ptr == ' ')
id_ptr++;
id_ptr = strtok (id_ptr, " \t\n");
if (((*id_ptr == 'l') || (*id_ptr == 's')) && (id_ptr[1] == '_'))
continue;
++id_ptr;
file_ptr = strtok (NULL, " \t\n");
if (sym)
sym->ty.size = to_absolute (value) - sym->value;
sym = sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */
}
fclose (fp);
return 0;
}
int
load_hex (const char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open hex record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3)
{
printf ("line %d: invalid hex record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff) + type;
switch (type)
{
case 0:
for (; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid hex record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 1:
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid hex record checksum \n", line);
done = 0;
break;
case 2:
default:
printf ("line %d: not supported hex type %d.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
int
load_s19 (const char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open S-record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) != 3)
{
printf ("line %d: invalid S record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff);
switch (type)
{
case 1:
for (count -= 3; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 9:
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
default:
printf ("line %d: S%d not supported.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
void
monitor_call (unsigned int flags)
{
#ifdef CALL_STACK
if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call++;
current_function_call->entry_point = get_pc ();
current_function_call->flags = flags;
}
#endif
#if 0
const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ()));
if (id)
{
// printf ("In %s now\n", id);
}
#endif
}
void
monitor_return (void)
{
#ifdef CALL_STACK
if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call--;
return;
}
- while ((current_function_call->flags & FC_TAIL_CALL) &&
+ while ((current_function_call->flags & FC_TAIL_CALL) &&
(current_function_call > fctab))
{
current_function_call--;
}
if (current_function_call > fctab)
current_function_call--;
#endif
}
const char *
absolute_addr_name (absolute_address_t addr)
{
static char buf[256], *bufptr;
const char *name;
bufptr = buf;
bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%-16.16s>", name);
return buf;
}
const char *
monitor_addr_name (target_addr_t target_addr)
{
static char buf[256], *bufptr;
const char *name;
absolute_address_t addr = to_absolute (target_addr);
bufptr = buf;
bufptr += sprintf (bufptr, "0x%04X", target_addr);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%s>", name);
return buf;
}
static void
monitor_signal (int sigtype)
{
(void) sigtype;
putchar ('\n');
monitor_on = 1;
}
void
monitor_init (void)
{
int tmp;
extern int debug_enabled;
target_addr_t a;
fctab[0].entry_point = read16 (0xfffe);
memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs));
current_function_call = &fctab[0];
auto_break_insn_count = 0;
monitor_on = debug_enabled;
signal (SIGINT, monitor_signal);
}
int
check_break (void)
{
if (dump_every_insn)
print_current_insn ();
if (auto_break_insn_count > 0)
if (--auto_break_insn_count == 0)
return 1;
return 0;
}
void
monitor_backtrace (void)
{
struct function_call *fc = current_function_call;
while (fc >= &fctab[0]) {
printf ("%s\n", monitor_addr_name (fc->entry_point));
fc--;
}
}
int
monitor6809 (void)
{
int rc;
signal (SIGINT, monitor_signal);
rc = command_loop ();
monitor_on = 0;
return rc;
}
|
bcd/exec09
|
1b555afd602a3d2f79a9f8e3b1443a3fffe24921
|
Implement some 6309 instructions.
|
diff --git a/6809.c b/6809.c
index f8b0a81..0c48f7b 100644
--- a/6809.c
+++ b/6809.c
@@ -1112,1523 +1112,1565 @@ abx (void)
cpu_clk -= 3;
}
static void
addd (unsigned val)
{
unsigned arg = (A << 8) | B;
unsigned res = arg + val;
C = res & 0x10000;
Z = res &= 0xffff;
OV = ((arg ^ res) & (val ^ res)) >> 8;
A = N = res >> 8;
B = res & 0xff;
}
static void
cmp16 (unsigned arg, unsigned val)
{
unsigned res = arg - val;
C = res & 0x10000;
Z = res &= 0xffff;
N = res >> 8;
OV = ((arg ^ val) & (arg ^ res)) >> 8;
}
static void
ldd (unsigned arg)
{
unsigned res = arg;
Z = res;
A = N = res >> 8;
B = res & 0xff;
OV = 0;
}
static unsigned
ld16 (unsigned arg)
{
unsigned res = arg;
Z = res;
N = res >> 8;
OV = 0;
return res;
}
static void
sex (void)
{
unsigned res = B;
Z = res;
N = res &= 0x80;
if (res != 0)
res = 0xff;
A = res;
cpu_clk -= 2;
}
static void
std (void)
{
unsigned res = (A << 8) | B;
Z = res;
N = A;
OV = 0;
WRMEM16 (ea, res);
}
static void
st16 (unsigned arg)
{
unsigned res = arg;
Z = res;
N = res >> 8;
OV = 0;
WRMEM16 (ea, res);
}
static void
subd (unsigned val)
{
unsigned arg = (A << 8) | B;
unsigned res = arg - val;
C = res & 0x10000;
Z = res &= 0xffff;
OV = ((arg ^ val) & (arg ^ res)) >> 8;
A = N = res >> 8;
B = res & 0xff;
}
/* stack instructions */
static void
pshs (void)
{
unsigned post = imm_byte ();
cpu_clk -= 5;
if (post & 0x80)
{
cpu_clk -= 2;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
}
if (post & 0x40)
{
cpu_clk -= 2;
S = (S - 2) & 0xffff;
write_stack16 (S, U);
}
if (post & 0x20)
{
cpu_clk -= 2;
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
}
if (post & 0x10)
{
cpu_clk -= 2;
S = (S - 2) & 0xffff;
write_stack16 (S, X);
}
if (post & 0x08)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
}
if (post & 0x04)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, B);
}
if (post & 0x02)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, A);
}
if (post & 0x01)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
}
}
static void
pshu (void)
{
unsigned post = imm_byte ();
cpu_clk -= 5;
if (post & 0x80)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, PC & 0xffff);
}
if (post & 0x40)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, S);
}
if (post & 0x20)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, Y);
}
if (post & 0x10)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, X);
}
if (post & 0x08)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, DP >> 8);
}
if (post & 0x04)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, B);
}
if (post & 0x02)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, A);
}
if (post & 0x01)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, get_cc ());
}
}
static void
puls (void)
{
unsigned post = imm_byte ();
cpu_clk -= 5;
if (post & 0x01)
{
cpu_clk -= 1;
set_cc (read_stack (S));
S = (S + 1) & 0xffff;
}
if (post & 0x02)
{
cpu_clk -= 1;
A = read_stack (S);
S = (S + 1) & 0xffff;
}
if (post & 0x04)
{
cpu_clk -= 1;
B = read_stack (S);
S = (S + 1) & 0xffff;
}
if (post & 0x08)
{
cpu_clk -= 1;
DP = read_stack (S) << 8;
S = (S + 1) & 0xffff;
}
if (post & 0x10)
{
cpu_clk -= 2;
X = read_stack16 (S);
S = (S + 2) & 0xffff;
}
if (post & 0x20)
{
cpu_clk -= 2;
Y = read_stack16 (S);
S = (S + 2) & 0xffff;
}
if (post & 0x40)
{
cpu_clk -= 2;
U = read_stack16 (S);
S = (S + 2) & 0xffff;
}
if (post & 0x80)
{
monitor_return ();
cpu_clk -= 2;
PC = read_stack16 (S);
check_pc ();
S = (S + 2) & 0xffff;
}
}
static void
pulu (void)
{
unsigned post = imm_byte ();
cpu_clk -= 5;
if (post & 0x01)
{
cpu_clk -= 1;
set_cc (read_stack (U));
U = (U + 1) & 0xffff;
}
if (post & 0x02)
{
cpu_clk -= 1;
A = read_stack (U);
U = (U + 1) & 0xffff;
}
if (post & 0x04)
{
cpu_clk -= 1;
B = read_stack (U);
U = (U + 1) & 0xffff;
}
if (post & 0x08)
{
cpu_clk -= 1;
DP = read_stack (U) << 8;
U = (U + 1) & 0xffff;
}
if (post & 0x10)
{
cpu_clk -= 2;
X = read_stack16 (U);
U = (U + 2) & 0xffff;
}
if (post & 0x20)
{
cpu_clk -= 2;
Y = read_stack16 (U);
U = (U + 2) & 0xffff;
}
if (post & 0x40)
{
cpu_clk -= 2;
S = read_stack16 (U);
U = (U + 2) & 0xffff;
}
if (post & 0x80)
{
monitor_return ();
cpu_clk -= 2;
PC = read_stack16 (U);
check_pc ();
U = (U + 2) & 0xffff;
}
}
/* Miscellaneous Instructions */
static void
nop (void)
{
cpu_clk -= 2;
}
static void
jsr (void)
{
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
change_pc (ea);
monitor_call (0);
}
static void
rti (void)
{
monitor_return ();
cpu_clk -= 6;
command_exit_irq_hook (get_cycles () - irq_start_time);
set_cc (read_stack (S));
S = (S + 1) & 0xffff;
if ((EFI & E_FLAG) != 0)
{
cpu_clk -= 9;
A = read_stack (S);
S = (S + 1) & 0xffff;
B = read_stack (S);
S = (S + 1) & 0xffff;
DP = read_stack (S) << 8;
S = (S + 1) & 0xffff;
X = read_stack16 (S);
S = (S + 2) & 0xffff;
Y = read_stack16 (S);
S = (S + 2) & 0xffff;
U = read_stack16 (S);
S = (S + 2) & 0xffff;
}
PC = read_stack16 (S);
check_pc ();
S = (S + 2) & 0xffff;
}
static void
rts (void)
{
monitor_return ();
cpu_clk -= 5;
PC = read_stack16 (S);
check_pc ();
S = (S + 2) & 0xffff;
}
void
irq (void)
{
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
EFI |= I_FLAG;
irq_start_time = get_cycles ();
change_pc (read16 (0xfff8));
#if 1
irqs_pending = 0;
#endif
}
void
firq (void)
{
EFI &= ~E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
EFI |= (I_FLAG | F_FLAG);
change_pc (read16 (0xfff6));
#if 1
firqs_pending = 0;
#endif
}
void
swi (void)
{
cpu_clk -= 19;
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
EFI |= (I_FLAG | F_FLAG);
change_pc (read16 (0xfffa));
}
void
swi2 (void)
{
cpu_clk -= 20;
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
change_pc (read16 (0xfff4));
}
void
swi3 (void)
{
cpu_clk -= 20;
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
change_pc (read16 (0xfff2));
}
+#ifdef H6309
+void
+trap (void)
+{
+ cpu_clk -= 20;
+ EFI |= E_FLAG;
+ S = (S - 2) & 0xffff;
+ write_stack16 (S, PC & 0xffff);
+ S = (S - 2) & 0xffff;
+ write_stack16 (S, U);
+ S = (S - 2) & 0xffff;
+ write_stack16 (S, Y);
+ S = (S - 2) & 0xffff;
+ write_stack16 (S, X);
+ S = (S - 1) & 0xffff;
+ write_stack (S, DP >> 8);
+ S = (S - 1) & 0xffff;
+ write_stack (S, B);
+ S = (S - 1) & 0xffff;
+ write_stack (S, A);
+ S = (S - 1) & 0xffff;
+ write_stack (S, get_cc ());
+
+ change_pc (read16 (0xfff0));
+}
+#endif
+
void
cwai (void)
{
sim_error ("CWAI - not supported yet!");
}
void
sync (void)
{
cpu_clk -= 4;
sim_error ("SYNC - not supported yet!");
}
static void
orcc (void)
{
unsigned tmp = imm_byte ();
set_cc (get_cc () | tmp);
cpu_clk -= 3;
}
static void
andcc (void)
{
unsigned tmp = imm_byte ();
set_cc (get_cc () & tmp);
cpu_clk -= 3;
}
/* Branch Instructions */
#define cond_HI() ((Z != 0) && (C == 0))
#define cond_LS() ((Z == 0) || (C != 0))
#define cond_HS() (C == 0)
#define cond_LO() (C != 0)
#define cond_NE() (Z != 0)
#define cond_EQ() (Z == 0)
#define cond_VC() ((OV & 0x80) == 0)
#define cond_VS() ((OV & 0x80) != 0)
#define cond_PL() ((N & 0x80) == 0)
#define cond_MI() ((N & 0x80) != 0)
#define cond_GE() (((N^OV) & 0x80) == 0)
#define cond_LT() (((N^OV) & 0x80) != 0)
#define cond_GT() ((((N^OV) & 0x80) == 0) && (Z != 0))
#define cond_LE() ((((N^OV) & 0x80) != 0) || (Z == 0))
static void
bra (void)
{
INT8 tmp = (INT8) imm_byte ();
change_pc (PC + tmp);
}
static void
branch (unsigned cond)
{
if (cond)
bra ();
else
change_pc (PC+1);
cpu_clk -= 3;
}
static void
long_bra (void)
{
INT16 tmp = (INT16) imm_word ();
change_pc (PC + tmp);
}
static void
long_branch (unsigned cond)
{
if (cond)
{
long_bra ();
cpu_clk -= 6;
}
else
{
change_pc (PC + 2);
cpu_clk -= 5;
}
}
static void
long_bsr (void)
{
INT16 tmp = (INT16) imm_word ();
ea = PC + tmp;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
cpu_clk -= 9;
change_pc (ea);
monitor_call (0);
}
static void
bsr (void)
{
INT8 tmp = (INT8) imm_byte ();
ea = PC + tmp;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
cpu_clk -= 7;
change_pc (ea);
monitor_call (0);
}
/* Execute 6809 code for a certain number of cycles. */
int
cpu_execute (int cycles)
{
unsigned opcode;
cpu_period = cpu_clk = cycles;
do
{
command_insn_hook ();
if (check_break () != 0)
monitor_on = 1;
if (monitor_on != 0)
if (monitor6809 () != 0)
goto cpu_exit;
iPC = PC;
opcode = imm_byte ();
switch (opcode)
{
case 0x00:
direct ();
cpu_clk -= 4;
WRMEM (ea, neg (RDMEM (ea)));
break; /* NEG direct */
#ifdef H6309
case 0x01: /* OIM */
break;
case 0x02: /* AIM */
break;
#endif
case 0x03:
direct ();
cpu_clk -= 4;
WRMEM (ea, com (RDMEM (ea)));
break; /* COM direct */
case 0x04:
direct ();
cpu_clk -= 4;
WRMEM (ea, lsr (RDMEM (ea)));
break; /* LSR direct */
#ifdef H6309
case 0x05: /* EIM */
break;
#endif
case 0x06:
direct ();
cpu_clk -= 4;
WRMEM (ea, ror (RDMEM (ea)));
break; /* ROR direct */
case 0x07:
direct ();
cpu_clk -= 4;
WRMEM (ea, asr (RDMEM (ea)));
break; /* ASR direct */
case 0x08:
direct ();
cpu_clk -= 4;
WRMEM (ea, asl (RDMEM (ea)));
break; /* ASL direct */
case 0x09:
direct ();
cpu_clk -= 4;
WRMEM (ea, rol (RDMEM (ea)));
break; /* ROL direct */
case 0x0a:
direct ();
cpu_clk -= 4;
WRMEM (ea, dec (RDMEM (ea)));
break; /* DEC direct */
#ifdef H6309
case 0x0B: /* TIM */
break;
#endif
case 0x0c:
direct ();
cpu_clk -= 4;
WRMEM (ea, inc (RDMEM (ea)));
break; /* INC direct */
case 0x0d:
direct ();
cpu_clk -= 4;
tst (RDMEM (ea));
break; /* TST direct */
case 0x0e:
direct ();
cpu_clk -= 3;
PC = ea;
check_pc ();
monitor_call (FC_TAIL_CALL);
break; /* JMP direct */
case 0x0f:
direct ();
cpu_clk -= 4;
WRMEM (ea, clr (RDMEM (ea)));
break; /* CLR direct */
case 0x10:
{
opcode = imm_byte ();
switch (opcode)
{
case 0x21:
cpu_clk -= 5;
PC += 2;
break;
case 0x22:
long_branch (cond_HI ());
break;
case 0x23:
long_branch (cond_LS ());
break;
case 0x24:
long_branch (cond_HS ());
break;
case 0x25:
long_branch (cond_LO ());
break;
case 0x26:
long_branch (cond_NE ());
break;
case 0x27:
long_branch (cond_EQ ());
break;
case 0x28:
long_branch (cond_VC ());
break;
case 0x29:
long_branch (cond_VS ());
break;
case 0x2a:
long_branch (cond_PL ());
break;
case 0x2b:
long_branch (cond_MI ());
break;
case 0x2c:
long_branch (cond_GE ());
break;
case 0x2d:
long_branch (cond_LT ());
break;
case 0x2e:
long_branch (cond_GT ());
break;
case 0x2f:
long_branch (cond_LE ());
break;
#ifdef H6309
case 0x30: /* ADDR */
break;
case 0x31: /* ADCR */
break;
case 0x32: /* SUBR */
break;
case 0x33: /* SBCR */
break;
case 0x34: /* ANDR */
break;
case 0x35: /* ORR */
break;
case 0x36: /* EORR */
break;
case 0x37: /* CMPR */
break;
case 0x38: /* PSHSW */
break;
case 0x39: /* PULSW */
break;
case 0x3a: /* PSHUW */
break;
case 0x3b: /* PULUW */
break;
#endif
case 0x3f:
swi2 ();
break;
#ifdef H6309
case 0x40: /* NEGD */
break;
case 0x43: /* COMD */
break;
case 0x44: /* LSRD */
break;
case 0x46: /* RORD */
break;
case 0x47: /* ASRD */
break;
case 0x48: /* ASLD/LSLD */
break;
case 0x49: /* ROLD */
break;
case 0x4a: /* DECD */
break;
case 0x4c: /* INCD */
break;
case 0x4d: /* TSTD */
break;
case 0x4f: /* CLRD */
break;
case 0x53: /* COMW */
break;
case 0x54: /* LSRW */
break;
case 0x56: /* ??RORW */
break;
case 0x59: /* ROLW */
break;
case 0x5a: /* DECW */
break;
case 0x5c: /* INCW */
break;
case 0x5d: /* TSTW */
break;
case 0x5f: /* CLRW */
break;
case 0x80: /* SUBW */
break;
case 0x81: /* CMPW */
break;
case 0x82: /* SBCD */
break;
#endif
case 0x83:
cpu_clk -= 5;
cmp16 (get_d (), imm_word ());
break;
#ifdef H6309
case 0x84: /* ANDD */
break;
case 0x85: /* BITD */
break;
case 0x86: /* LDW */
break;
case 0x88: /* EORD */
break;
case 0x89: /* ADCD */
break;
case 0x8a: /* ORD */
break;
case 0x8b: /* ADDW */
break;
#endif
case 0x8c:
cpu_clk -= 5;
cmp16 (Y, imm_word ());
break;
case 0x8e:
cpu_clk -= 4;
Y = ld16 (imm_word ());
break;
#ifdef H6309
case 0x90: /* SUBW */
break;
case 0x91: /* CMPW */
break;
case 0x92: /* SBCD */
break;
#endif
case 0x93:
direct ();
cpu_clk -= 5;
cmp16 (get_d (), RDMEM16 (ea));
cpu_clk--;
break;
case 0x9c:
direct ();
cpu_clk -= 5;
cmp16 (Y, RDMEM16 (ea));
cpu_clk--;
break;
case 0x9e:
direct ();
cpu_clk -= 5;
Y = ld16 (RDMEM16 (ea));
break;
case 0x9f:
direct ();
cpu_clk -= 5;
st16 (Y);
break;
case 0xa3:
cpu_clk--;
indexed ();
cmp16 (get_d (), RDMEM16 (ea));
cpu_clk--;
break;
case 0xac:
cpu_clk--;
indexed ();
cmp16 (Y, RDMEM16 (ea));
cpu_clk--;
break;
case 0xae:
cpu_clk--;
indexed ();
Y = ld16 (RDMEM16 (ea));
break;
case 0xaf:
cpu_clk--;
indexed ();
st16 (Y);
break;
case 0xb3:
extended ();
cpu_clk -= 6;
cmp16 (get_d (), RDMEM16 (ea));
cpu_clk--;
break;
case 0xbc:
extended ();
cpu_clk -= 6;
cmp16 (Y, RDMEM16 (ea));
cpu_clk--;
break;
case 0xbe:
extended ();
cpu_clk -= 6;
Y = ld16 (RDMEM16 (ea));
break;
case 0xbf:
extended ();
cpu_clk -= 6;
st16 (Y);
break;
case 0xce:
cpu_clk -= 4;
S = ld16 (imm_word ());
break;
case 0xde:
direct ();
cpu_clk -= 5;
S = ld16 (RDMEM16 (ea));
break;
case 0xdf:
direct ();
cpu_clk -= 5;
st16 (S);
break;
case 0xee:
cpu_clk--;
indexed ();
S = ld16 (RDMEM16 (ea));
break;
case 0xef:
cpu_clk--;
indexed ();
st16 (S);
break;
case 0xfe:
extended ();
cpu_clk -= 6;
S = ld16 (RDMEM16 (ea));
break;
case 0xff:
extended ();
cpu_clk -= 6;
st16 (S);
break;
default:
sim_error ("invalid opcode (1) at %s\n", monitor_addr_name (iPC));
break;
}
}
break;
case 0x11:
{
opcode = imm_byte ();
switch (opcode)
{
case 0x3f:
swi3 ();
break;
+#ifdef H6309
+ case 0x80: /* SUBE */
+ case 0x81: /* CMPE */
+#endif
case 0x83:
cpu_clk -= 5;
cmp16 (U, imm_word ());
break;
+#ifdef H6309
+ case 0x86: /* LDE */
+ case 0x8B: /* ADDE */
+#endif
case 0x8c:
cpu_clk -= 5;
cmp16 (S, imm_word ());
break;
+#ifdef H6309
+ case 0x8D: /* DIVD */
+ case 0x8E: /* DIVQ */
+ case 0x8F: /* MULD */
+ case 0x90: /* SUBE */
+ case 0x91: /* CMPE */
+#endif
case 0x93:
direct ();
cpu_clk -= 5;
cmp16 (U, RDMEM16 (ea));
cpu_clk--;
break;
case 0x9c:
direct ();
cpu_clk -= 5;
cmp16 (S, RDMEM16 (ea));
cpu_clk--;
break;
case 0xa3:
cpu_clk--;
indexed ();
cmp16 (U, RDMEM16 (ea));
cpu_clk--;
break;
case 0xac:
cpu_clk--;
indexed ();
cmp16 (S, RDMEM16 (ea));
cpu_clk--;
break;
case 0xb3:
extended ();
cpu_clk -= 6;
cmp16 (U, RDMEM16 (ea));
cpu_clk--;
break;
case 0xbc:
extended ();
cpu_clk -= 6;
cmp16 (S, RDMEM16 (ea));
cpu_clk--;
break;
default:
sim_error ("invalid opcode (2) at %s\n", monitor_addr_name (iPC));
break;
}
}
break;
case 0x12:
nop ();
break;
case 0x13:
sync ();
break;
#ifdef H6309
case 0x14: /* SEXW */
break;
#endif
case 0x16:
long_bra ();
cpu_clk -= 5;
break;
case 0x17:
long_bsr ();
break;
case 0x19:
daa ();
break;
case 0x1a:
orcc ();
break;
case 0x1c:
andcc ();
break;
case 0x1d:
sex ();
break;
case 0x1e:
exg ();
break;
case 0x1f:
tfr ();
break;
case 0x20:
bra ();
cpu_clk -= 3;
break;
case 0x21:
PC++;
cpu_clk -= 3;
break;
case 0x22:
branch (cond_HI ());
break;
case 0x23:
branch (cond_LS ());
break;
case 0x24:
branch (cond_HS ());
break;
case 0x25:
branch (cond_LO ());
break;
case 0x26:
branch (cond_NE ());
break;
case 0x27:
branch (cond_EQ ());
break;
case 0x28:
branch (cond_VC ());
break;
case 0x29:
branch (cond_VS ());
break;
case 0x2a:
branch (cond_PL ());
break;
case 0x2b:
branch (cond_MI ());
break;
case 0x2c:
branch (cond_GE ());
break;
case 0x2d:
branch (cond_LT ());
break;
case 0x2e:
branch (cond_GT ());
break;
case 0x2f:
branch (cond_LE ());
break;
case 0x30:
indexed ();
Z = X = ea;
break; /* LEAX indexed */
case 0x31:
indexed ();
Z = Y = ea;
break; /* LEAY indexed */
case 0x32:
indexed ();
S = ea;
break; /* LEAS indexed */
case 0x33:
indexed ();
U = ea;
break; /* LEAU indexed */
case 0x34:
pshs ();
break; /* PSHS implied */
case 0x35:
puls ();
break; /* PULS implied */
case 0x36:
pshu ();
break; /* PSHU implied */
case 0x37:
pulu ();
break; /* PULU implied */
case 0x39:
rts ();
break; /* RTS implied */
case 0x3a:
abx ();
break; /* ABX implied */
case 0x3b:
rti ();
break; /* RTI implied */
case 0x3c:
cwai ();
break; /* CWAI implied */
case 0x3d:
mul ();
break; /* MUL implied */
case 0x3f:
swi ();
break; /* SWI implied */
case 0x40:
A = neg (A);
break; /* NEGA implied */
case 0x43:
A = com (A);
break; /* COMA implied */
case 0x44:
A = lsr (A);
break; /* LSRA implied */
case 0x46:
A = ror (A);
break; /* RORA implied */
case 0x47:
A = asr (A);
break; /* ASRA implied */
case 0x48:
A = asl (A);
break; /* ASLA implied */
case 0x49:
A = rol (A);
break; /* ROLA implied */
case 0x4a:
A = dec (A);
break; /* DECA implied */
case 0x4c:
A = inc (A);
break; /* INCA implied */
case 0x4d:
tst (A);
break; /* TSTA implied */
case 0x4f:
A = clr (A);
break; /* CLRA implied */
case 0x50:
B = neg (B);
break; /* NEGB implied */
case 0x53:
B = com (B);
break; /* COMB implied */
case 0x54:
B = lsr (B);
break; /* LSRB implied */
case 0x56:
B = ror (B);
break; /* RORB implied */
case 0x57:
B = asr (B);
break; /* ASRB implied */
case 0x58:
B = asl (B);
break; /* ASLB implied */
case 0x59:
B = rol (B);
break; /* ROLB implied */
case 0x5a:
B = dec (B);
break; /* DECB implied */
case 0x5c:
B = inc (B);
break; /* INCB implied */
case 0x5d:
tst (B);
break; /* TSTB implied */
case 0x5f:
B = clr (B);
break; /* CLRB implied */
case 0x60:
indexed ();
WRMEM (ea, neg (RDMEM (ea)));
break; /* NEG indexed */
#ifdef H6309
case 0x61: /* OIM indexed */
break;
case 0x62: /* AIM indexed */
break;
#endif
case 0x63:
indexed ();
WRMEM (ea, com (RDMEM (ea)));
break; /* COM indexed */
case 0x64:
indexed ();
WRMEM (ea, lsr (RDMEM (ea)));
break; /* LSR indexed */
#ifdef H6309
case 0x65: /* EIM indexed */
break;
#endif
case 0x66:
indexed ();
WRMEM (ea, ror (RDMEM (ea)));
break; /* ROR indexed */
case 0x67:
indexed ();
WRMEM (ea, asr (RDMEM (ea)));
break; /* ASR indexed */
case 0x68:
indexed ();
WRMEM (ea, asl (RDMEM (ea)));
break; /* ASL indexed */
case 0x69:
indexed ();
WRMEM (ea, rol (RDMEM (ea)));
break; /* ROL indexed */
case 0x6a:
indexed ();
WRMEM (ea, dec (RDMEM (ea)));
break; /* DEC indexed */
#ifdef H6309
case 0x6b: /* TIM indexed */
break;
#endif
case 0x6c:
indexed ();
WRMEM (ea, inc (RDMEM (ea)));
break; /* INC indexed */
case 0x6d:
indexed ();
tst (RDMEM (ea));
break; /* TST indexed */
case 0x6e:
indexed ();
cpu_clk += 1;
PC = ea;
check_pc ();
monitor_call (FC_TAIL_CALL);
break; /* JMP indexed */
case 0x6f:
indexed ();
WRMEM (ea, clr (RDMEM (ea)));
break; /* CLR indexed */
case 0x70:
extended ();
cpu_clk -= 5;
WRMEM (ea, neg (RDMEM (ea)));
break; /* NEG extended */
#ifdef H6309
case 0x71: /* OIM extended */
break;
case 0x72: /* AIM extended */
break;
#endif
case 0x73:
extended ();
cpu_clk -= 5;
WRMEM (ea, com (RDMEM (ea)));
break; /* COM extended */
case 0x74:
extended ();
cpu_clk -= 5;
WRMEM (ea, lsr (RDMEM (ea)));
break; /* LSR extended */
#ifdef H6309
case 0x75: /* EIM extended */
break;
#endif
case 0x76:
extended ();
cpu_clk -= 5;
WRMEM (ea, ror (RDMEM (ea)));
break; /* ROR extended */
case 0x77:
extended ();
cpu_clk -= 5;
WRMEM (ea, asr (RDMEM (ea)));
break; /* ASR extended */
case 0x78:
extended ();
cpu_clk -= 5;
WRMEM (ea, asl (RDMEM (ea)));
break; /* ASL extended */
case 0x79:
extended ();
cpu_clk -= 5;
WRMEM (ea, rol (RDMEM (ea)));
break; /* ROL extended */
case 0x7a:
extended ();
cpu_clk -= 5;
WRMEM (ea, dec (RDMEM (ea)));
break; /* DEC extended */
#ifdef H6309
case 0x7b: /* TIM indexed */
break;
#endif
case 0x7c:
extended ();
cpu_clk -= 5;
WRMEM (ea, inc (RDMEM (ea)));
break; /* INC extended */
case 0x7d:
extended ();
cpu_clk -= 5;
tst (RDMEM (ea));
break; /* TST extended */
case 0x7e:
extended ();
cpu_clk -= 4;
PC = ea;
check_pc ();
monitor_call (FC_TAIL_CALL);
break; /* JMP extended */
case 0x7f:
extended ();
cpu_clk -= 5;
WRMEM (ea, clr (RDMEM (ea)));
break; /* CLR extended */
case 0x80:
cpu_clk -= 2;
A = sub (A, imm_byte ());
break;
case 0x81:
cpu_clk -= 2;
cmp (A, imm_byte ());
break;
case 0x82:
cpu_clk -= 2;
A = sbc (A, imm_byte ());
break;
case 0x83:
cpu_clk -= 4;
subd (imm_word ());
break;
case 0x84:
cpu_clk -= 2;
A = and (A, imm_byte ());
break;
case 0x85:
cpu_clk -= 2;
bit (A, imm_byte ());
break;
case 0x86:
cpu_clk -= 2;
A = ld (imm_byte ());
break;
case 0x88:
cpu_clk -= 2;
A = eor (A, imm_byte ());
break;
case 0x89:
cpu_clk -= 2;
A = adc (A, imm_byte ());
break;
case 0x8a:
cpu_clk -= 2;
A = or (A, imm_byte ());
break;
case 0x8b:
cpu_clk -= 2;
A = add (A, imm_byte ());
break;
case 0x8c:
cpu_clk -= 4;
cmp16 (X, imm_word ());
break;
case 0x8d:
bsr ();
break;
case 0x8e:
cpu_clk -= 3;
X = ld16 (imm_word ());
break;
case 0x90:
direct ();
cpu_clk -= 4;
A = sub (A, RDMEM (ea));
break;
case 0x91:
direct ();
cpu_clk -= 4;
cmp (A, RDMEM (ea));
break;
case 0x92:
direct ();
cpu_clk -= 4;
A = sbc (A, RDMEM (ea));
break;
case 0x93:
direct ();
cpu_clk -= 4;
subd (RDMEM16 (ea));
cpu_clk--;
break;
case 0x94:
direct ();
cpu_clk -= 4;
A = and (A, RDMEM (ea));
break;
case 0x95:
direct ();
cpu_clk -= 4;
bit (A, RDMEM (ea));
break;
case 0x96:
direct ();
cpu_clk -= 4;
A = ld (RDMEM (ea));
break;
case 0x97:
direct ();
cpu_clk -= 4;
st (A);
break;
case 0x98:
direct ();
cpu_clk -= 4;
A = eor (A, RDMEM (ea));
break;
case 0x99:
direct ();
cpu_clk -= 4;
A = adc (A, RDMEM (ea));
break;
case 0x9a:
direct ();
cpu_clk -= 4;
A = or (A, RDMEM (ea));
break;
case 0x9b:
direct ();
cpu_clk -= 4;
A = add (A, RDMEM (ea));
break;
case 0x9c:
direct ();
cpu_clk -= 4;
cmp16 (X, RDMEM16 (ea));
cpu_clk--;
break;
case 0x9d:
direct ();
cpu_clk -= 7;
jsr ();
|
bcd/exec09
|
145eeb1a2e2d3ed68dcd1b02b26779e9dc877d2d
|
Several new additions:
|
diff --git a/Makefile.am b/Makefile.am
index 8714543..3a06845 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,10 @@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
- symtab.c command.c fileio.c wpclib.c \
+ symtab.c command.c fileio.c wpclib.c imux.c \
+ ioexpand.c mmu.c timer.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
LIBS = $(READLINE_LIBS)
bin_PROGRAMS = m6809-run
bin_SCRIPTS = wpc-run
diff --git a/Makefile.in b/Makefile.in
index 0c61c0c..576a920 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,593 +1,585 @@
-# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+LIBOBJDIR =
bin_PROGRAMS = m6809-run$(EXEEXT)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING depcomp install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
- configure.lineno config.status.lineno
+ configure.lineno configure.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_m6809_run_OBJECTS = 6809.$(OBJEXT) main.$(OBJEXT) monitor.$(OBJEXT) \
machine.$(OBJEXT) eon.$(OBJEXT) wpc.$(OBJEXT) symtab.$(OBJEXT) \
- command.$(OBJEXT) fileio.$(OBJEXT) wpclib.$(OBJEXT)
+ command.$(OBJEXT) fileio.$(OBJEXT) wpclib.$(OBJEXT) \
+ imux.$(OBJEXT) ioexpand.$(OBJEXT) mmu.$(OBJEXT) \
+ timer.$(OBJEXT)
m6809_run_OBJECTS = $(am_m6809_run_OBJECTS)
m6809_run_LDADD = $(LDADD)
binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(bin_SCRIPTS)
-DEFAULT_INCLUDES = -I.@am__isrc@
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(m6809_run_SOURCES)
DIST_SOURCES = $(m6809_run_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
-INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = $(READLINE_LIBS)
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
-MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
READLINE_LIBS = @READLINE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
-builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
- symtab.c command.c fileio.c wpclib.c \
+ symtab.c command.c fileio.c wpclib.c imux.c \
+ ioexpand.c mmu.c timer.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
bin_SCRIPTS = wpc-run
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
- $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+ $(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
- test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
m6809-run$(EXEEXT): $(m6809_run_OBJECTS) $(m6809_run_DEPENDENCIES)
@rm -f m6809-run$(EXEEXT)
- $(LINK) $(m6809_run_OBJECTS) $(m6809_run_LDADD) $(LIBS)
+ $(LINK) $(m6809_run_LDFLAGS) $(m6809_run_OBJECTS) $(m6809_run_LDADD) $(LIBS)
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
- test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_SCRIPTS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f $$d$$p; then \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
else :; fi; \
done
uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(bin_SCRIPTS)'; for p in $$list; do \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/6809.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eon.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioexpand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machine.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmu.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symtab.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpclib.Po@am__quote@
.c.o:
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
+ here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
- test -d $(distdir) || mkdir $(distdir)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
+ mkdir $(distdir)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
- ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+ ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
-dist-lzma: distdir
- tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
- $(am__remove_distdir)
-
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
- *.tar.lzma*) \
- unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
- sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+ sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
- test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
-install-dvi: install-dvi-am
-
install-exec-am: install-binPROGRAMS install-binSCRIPTS
-install-html: install-html-am
-
install-info: install-info-am
install-man:
-install-pdf: install-pdf-am
-
-install-ps: install-ps-am
-
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
-uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS
-
-.MAKE: install-am install-strip
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-info-am
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
- dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
- distclean distclean-compile distclean-generic distclean-hdr \
+ dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
+ distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-binSCRIPTS install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
+ install-data-am install-exec install-exec-am install-info \
+ install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
- uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS
+ uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/configure b/configure
index 899f2de..a0fd58b 100755
--- a/configure
+++ b/configure
@@ -157,1037 +157,1035 @@ $as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# CDPATH.
$as_unset CDPATH
if test "x$CONFIG_SHELL" = x; then
if (eval ":") 2>/dev/null; then
as_have_required=yes
else
as_have_required=no
fi
if test $as_have_required = yes && (eval ":
(as_func_return () {
(exit \$1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test \$exitcode = 0) || { (exit 1); exit 1; }
(
as_lineno_1=\$LINENO
as_lineno_2=\$LINENO
test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
") 2> /dev/null; then
:
else
as_candidate_shells=
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
case $as_dir in
/*)
for as_base in sh bash ksh sh5; do
as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
done;;
esac
done
IFS=$as_save_IFS
for as_shell in $as_candidate_shells $SHELL; do
# Try only shells that exist, to save several forks.
if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
{ ("$as_shell") 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
:
_ASEOF
}; then
CONFIG_SHELL=$as_shell
as_have_required=yes
if { "$as_shell" 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
:
(as_func_return () {
(exit $1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = "$1" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test $exitcode = 0) || { (exit 1); exit 1; }
(
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
_ASEOF
}; then
break
fi
fi
done
if test "x$CONFIG_SHELL" != x; then
for as_var in BASH_ENV ENV
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
fi
if test $as_have_required = no; then
echo This script requires a shell more modern than all the
echo shells that I found on your system. Please install a
echo modern shell, or manually run the script under such a
echo shell if you do have one.
{ (exit 1); exit 1; }
fi
fi
fi
(eval "as_func_return () {
(exit \$1)
}
as_func_success () {
as_func_return 0
}
as_func_failure () {
as_func_return 1
}
as_func_ret_success () {
return 0
}
as_func_ret_failure () {
return 1
}
exitcode=0
if as_func_success; then
:
else
exitcode=1
echo as_func_success failed.
fi
if as_func_failure; then
exitcode=1
echo as_func_failure succeeded.
fi
if as_func_ret_success; then
:
else
exitcode=1
echo as_func_ret_success failed.
fi
if as_func_ret_failure; then
exitcode=1
echo as_func_ret_failure succeeded.
fi
if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
:
else
exitcode=1
echo positional parameters were not saved.
fi
test \$exitcode = 0") || {
echo No shell found that supports shell functions.
echo Please tell bug-autoconf@gnu.org about your system,
echo including any error possibly output before this message.
echo This can help us improve future autoconf versions.
echo Configuration will now proceed without shell functions.
}
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line after each line using $LINENO; the second 'sed'
# does the real work. The second script uses 'N' to pair each
# line-number line with the line containing $LINENO, and appends
# trailing '-' during substitution so that $LINENO is not a special
# case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# scripts with optimization help from Paolo Bonzini. Blame Lee
# E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in
-n*)
case `echo 'x\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
*) ECHO_C='\c';;
esac;;
*)
ECHO_N='-n';;
esac
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 7<&0 </dev/null 6>&1
# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='m6809-run'
PACKAGE_TARNAME='m6809-run'
PACKAGE_VERSION='0.92'
PACKAGE_STRING='m6809-run 0.92'
PACKAGE_BUGREPORT='brian@oddchange.com'
ac_unique_file="6809.c"
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include <memory.h>
# endif
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif"
ac_subst_vars='LTLIBOBJS
READLINE_LIBS
LIBOBJS
EGREP
GREP
CPP
am__fastdepCC_FALSE
am__fastdepCC_TRUE
CCDEPMODE
AMDEPBACKSLASH
AMDEP_FALSE
AMDEP_TRUE
am__quote
am__include
DEPDIR
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
am__untar
am__tar
AMTAR
am__leading_dot
SET_MAKE
AWK
mkdir_p
-MKDIR_P
INSTALL_STRIP_PROGRAM
STRIP
install_sh
MAKEINFO
AUTOHEADER
AUTOMAKE
AUTOCONF
ACLOCAL
VERSION
PACKAGE
CYGPATH_W
-am__isrc
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
target_alias
host_alias
build_alias
LIBS
ECHO_T
ECHO_N
ECHO_C
DEFS
mandir
localedir
libdir
psdir
pdfdir
dvidir
htmldir
infodir
docdir
oldincludedir
includedir
localstatedir
sharedstatedir
sysconfdir
datadir
datarootdir
libexecdir
sbindir
bindir
program_transform_name
prefix
exec_prefix
PACKAGE_BUGREPORT
PACKAGE_STRING
PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_dependency_tracking
enable_wpc
enable_6309
enable_readline
'
ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP'
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE
# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'
ac_prev=
ac_dashdash=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval $ac_prev=\$ac_option
ac_prev=
continue
fi
case $ac_option in
*=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file=$ac_optarg ;;
--config-cache | -C)
cache_file=config.cache ;;
-datadir | --datadir | --datadi | --datad)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=*)
datadir=$ac_optarg ;;
-datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
| --dataroo | --dataro | --datar)
ac_prev=datarootdir ;;
-datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
| --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
datarootdir=$ac_optarg ;;
-disable-* | --disable-*)
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=no ;;
-docdir | --docdir | --docdi | --doc | --do)
ac_prev=docdir ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
docdir=$ac_optarg ;;
-dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
ac_prev=dvidir ;;
-dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
dvidir=$ac_optarg ;;
-enable-* | --enable-*)
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=\$ac_optarg ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix=$ac_optarg ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he | -h)
ac_init_help=long ;;
-help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
ac_init_help=recursive ;;
-help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
ac_init_help=short ;;
-host | --host | --hos | --ho)
ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
host_alias=$ac_optarg ;;
-htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
ac_prev=htmldir ;;
-htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
| --ht=*)
htmldir=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir=$ac_optarg ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir=$ac_optarg ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir=$ac_optarg ;;
-localedir | --localedir | --localedi | --localed | --locale)
ac_prev=localedir ;;
-localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
localedir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst | --locals)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
localstatedir=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir=$ac_optarg ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix=$ac_optarg ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix=$ac_optarg ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix=$ac_optarg ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name=$ac_optarg ;;
-pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
ac_prev=pdfdir ;;
-pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
pdfdir=$ac_optarg ;;
-psdir | --psdir | --psdi | --psd | --ps)
ac_prev=psdir ;;
-psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
psdir=$ac_optarg ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir=$ac_optarg ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir=$ac_optarg ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site=$ac_optarg ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
-with-* | --with-*)
ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=\$ac_optarg ;;
-without-* | --without-*)
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
{ (exit 1); exit 1; }; }
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=no ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes=$ac_optarg ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
-*) { $as_echo "$as_me: error: unrecognized option: $ac_option
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; }
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
{ $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
{ (exit 1); exit 1; }; }
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
esac
done
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
{ $as_echo "$as_me: error: missing argument to $ac_option" >&2
{ (exit 1); exit 1; }; }
fi
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no) ;;
fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
{ (exit 1); exit 1; }; } ;;
*) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
esac
fi
# Check all directory arguments for consistency.
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
case $ac_val in
*/ )
ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
eval $ac_var=\$ac_val;;
esac
# Be sure to have absolute directory names.
case $ac_val in
[\\/$]* | ?:[\\/]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
{ $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
{ (exit 1); exit 1; }; }
done
# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
@@ -1318,2611 +1316,2595 @@ By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/m6809-run]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
_ACEOF
cat <<\_ACEOF
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
_ACEOF
fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of m6809-run 0.92:";;
esac
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--enable-wpc Enable WPC address map
--enable-6309 Enable 6309 extensions
--enable-readline Enable readline library
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to <brian@oddchange.com>.
_ACEOF
ac_status=$?
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
test -d "$ac_dir" ||
{ cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
continue
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
cd "$ac_dir" || { ac_status=$?; continue; }
# Check for guested configure.
if test -f "$ac_srcdir/configure.gnu"; then
echo &&
$SHELL "$ac_srcdir/configure.gnu" --help=recursive
elif test -f "$ac_srcdir/configure"; then
echo &&
$SHELL "$ac_srcdir/configure" --help=recursive
else
$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi || ac_status=$?
cd "$ac_pwd" || { ac_status=$?; break; }
done
fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
m6809-run configure 0.92
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
exit
fi
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by m6809-run $as_me 0.92, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
_ACEOF
exec 5>>config.log
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
_ASUNAME
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
$as_echo "PATH: $as_dir"
done
IFS=$as_save_IFS
} >&5
cat >&5 <<_ACEOF
## ----------- ##
## Core tests. ##
## ----------- ##
_ACEOF
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_must_keep_next=false
for ac_pass in 1 2
do
for ac_arg
do
case $ac_arg in
-no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
continue ;;
*\'*)
ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
case $ac_pass in
1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
2)
ac_configure_args1="$ac_configure_args1 '$ac_arg'"
if test $ac_must_keep_next = true; then
ac_must_keep_next=false # Got value, back to normal.
else
case $ac_arg in
*=* | --config-cache | -C | -disable-* | --disable-* \
| -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
| -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
| -with-* | --with-* | -without-* | --without-* | --x)
case "$ac_configure_args0 " in
"$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
esac
;;
-* ) ac_must_keep_next=true ;;
esac
fi
ac_configure_args="$ac_configure_args '$ac_arg'"
;;
esac
done
done
$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log. We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
{
echo
cat <<\_ASBOX
## ---------------- ##
## Cache variables. ##
## ---------------- ##
_ASBOX
echo
# The following way of writing the cache mishandles newlines in values,
(
for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) $as_unset $ac_var ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
sed -n \
"s/'\''/'\''\\\\'\'''\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
;; #(
*)
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
)
echo
cat <<\_ASBOX
## ----------------- ##
## Output variables. ##
## ----------------- ##
_ASBOX
echo
for ac_var in $ac_subst_vars
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
if test -n "$ac_subst_files"; then
cat <<\_ASBOX
## ------------------- ##
## File substitutions. ##
## ------------------- ##
_ASBOX
echo
for ac_var in $ac_subst_files
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
fi
if test -s confdefs.h; then
cat <<\_ASBOX
## ----------- ##
## confdefs.h. ##
## ----------- ##
_ASBOX
echo
cat confdefs.h
echo
fi
test "$ac_signal" != 0 &&
$as_echo "$as_me: caught signal $ac_signal"
$as_echo "$as_me: exit $exit_status"
} >&5
rm -f core *.core core.conftest.* &&
rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
done
ac_signal=0
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h
# Predefined preprocessor variables.
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF
# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
ac_site_file1=$CONFIG_SITE
elif test "x$prefix" != xNONE; then
ac_site_file1=$prefix/share/config.site
ac_site_file2=$prefix/etc/config.site
else
ac_site_file1=$ac_default_prefix/share/config.site
ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
test "x$ac_site_file" = xNONE && continue
if test -r "$ac_site_file"; then
{ $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file"
fi
done
if test -r "$cache_file"; then
# Some versions of bash will fail to source /dev/null (special
# files actually), so we avoid doing that.
if test -f "$cache_file"; then
{ $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . "$cache_file";;
*) . "./$cache_file";;
esac
fi
else
{ $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
$as_echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in $ac_precious_vars; do
eval ac_old_set=\$ac_cv_env_${ac_var}_set
eval ac_new_set=\$ac_env_${ac_var}_set
eval ac_old_val=\$ac_cv_env_${ac_var}_value
eval ac_new_val=\$ac_env_${ac_var}_value
case $ac_old_set,$ac_new_set in
set,)
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
ac_cache_corrupted=: ;;
,set)
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
ac_cache_corrupted=: ;;
,);;
*)
if test "x$ac_old_val" != "x$ac_new_val"; then
# differences in whitespace do not lead to failure.
ac_old_val_w=`echo x $ac_old_val`
ac_new_val_w=`echo x $ac_new_val`
if test "$ac_old_val_w" != "$ac_new_val_w"; then
{ $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
ac_cache_corrupted=:
else
{ $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
eval $ac_var=\$ac_old_val
fi
{ $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5
$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
{ $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5
$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
fi;;
esac
# Pass precious variables to config.status.
if test "$ac_new_set" = set; then
case $ac_new_val in
*\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
*) ac_arg=$ac_var=$ac_new_val ;;
esac
case " $ac_configure_args " in
*" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
*) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
esac
fi
done
if $ac_cache_corrupted; then
{ $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
{ { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
{ (exit 1); exit 1; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-am__api_version='1.10'
-
+am__api_version="1.9"
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
if test -f "$ac_dir/install-sh"; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install-sh -c"
break
elif test -f "$ac_dir/install.sh"; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install.sh -c"
break
elif test -f "$ac_dir/shtool"; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/shtool install -c"
break
fi
done
if test -z "$ac_aux_dir"; then
{ { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
{ (exit 1); exit 1; }; }
fi
# These three variables are undocumented and unsupported,
# and are intended to be withdrawn in a future Autoconf release.
# They can cause serious problems if a builder's source tree is in a directory
# whose full name contains unusual characters.
ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AmigaOS /C/install, which installs bootblocks on floppy discs
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
# Reject install programs that cannot install multiple files.
{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
if test "${ac_cv_path_install+set}" = set; then
$as_echo_n "(cached) " >&6
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
# Account for people who put trailing slashes in PATH elements.
case $as_dir/ in
./ | .// | /cC/* | \
/etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
/usr/ucb/* ) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
# Don't use installbsd from OSF since it installs stuff as root
# by default.
for ac_prog in ginstall scoinst install; do
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
if test $ac_prog = install &&
grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
elif test $ac_prog = install &&
grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# program-specific install script used by HP pwplus--don't use.
:
else
rm -rf conftest.one conftest.two conftest.dir
echo one > conftest.one
echo two > conftest.two
mkdir conftest.dir
if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
test -s conftest.one && test -s conftest.two &&
test -s conftest.dir/conftest.one &&
test -s conftest.dir/conftest.two
then
ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
break 3
fi
fi
fi
done
done
;;
esac
done
IFS=$as_save_IFS
rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
# As a last resort, use the slow shell script. Don't cache a
# value for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the value is a relative name.
INSTALL=$ac_install_sh
fi
fi
{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5
$as_echo "$INSTALL" >&6; }
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5
$as_echo_n "checking whether build environment is sane... " >&6; }
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$*" != "X $srcdir/configure conftest.file" \
&& test "$*" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
{ { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
alias in your environment" >&5
$as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
alias in your environment" >&2;}
{ (exit 1); exit 1; }; }
fi
test "$2" = conftest.file
)
then
# Ok.
:
else
{ { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files!
Check your system clock" >&5
$as_echo "$as_me: error: newly created file is older than distributed files!
Check your system clock" >&2;}
{ (exit 1); exit 1; }; }
fi
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
test "$program_prefix" != NONE &&
program_transform_name="s&^&$program_prefix&;$program_transform_name"
# Use a double $ so make ignores it.
test "$program_suffix" != NONE &&
program_transform_name="s&\$&$program_suffix&;$program_transform_name"
# Double any \ or $.
# By default was `s,x,x', remove it if useless.
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
{ $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
fi
-{ $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
-$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
-if test -z "$MKDIR_P"; then
- if test "${ac_cv_path_mkdir+set}" = set; then
- $as_echo_n "(cached) " >&6
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in mkdir gmkdir; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
- case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
- 'mkdir (GNU coreutils) '* | \
- 'mkdir (coreutils) '* | \
- 'mkdir (fileutils) '4.1*)
- ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
- break 3;;
- esac
- done
- done
-done
-IFS=$as_save_IFS
-
-fi
-
- if test "${ac_cv_path_mkdir+set}" = set; then
- MKDIR_P="$ac_cv_path_mkdir -p"
+if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+ # We used to keeping the `.' as first argument, in order to
+ # allow $(mkdir_p) to be used without argument. As in
+ # $(mkdir_p) $(somedir)
+ # where $(somedir) is conditionally defined. However this is wrong
+ # for two reasons:
+ # 1. if the package is installed by a user who cannot write `.'
+ # make install will fail,
+ # 2. the above comment should most certainly read
+ # $(mkdir_p) $(DESTDIR)$(somedir)
+ # so it does not work when $(somedir) is undefined and
+ # $(DESTDIR) is not.
+ # To support the latter case, we have to write
+ # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
+ # so the `.' trick is pointless.
+ mkdir_p='mkdir -p --'
+else
+ # On NextStep and OpenStep, the `mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because `.' already
+ # exists.
+ for d in ./-p ./--version;
+ do
+ test -d $d && rmdir $d
+ done
+ # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
+ if test -f "$ac_aux_dir/mkinstalldirs"; then
+ mkdir_p='$(mkinstalldirs)'
else
- # As a last resort, use the slow shell script. Don't cache a
- # value for MKDIR_P within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
- test -d ./--version && rmdir ./--version
- MKDIR_P="$ac_install_sh -d"
+ mkdir_p='$(install_sh) -d'
fi
fi
-{ $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5
-$as_echo "$MKDIR_P" >&6; }
-
-mkdir_p="$MKDIR_P"
-case $mkdir_p in
- [\\/$]* | ?:[\\/]*) ;;
- */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
for ac_prog in gawk mawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_AWK+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$AWK"; then
ac_cv_prog_AWK="$AWK" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_AWK="$ac_prog"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
{ $as_echo "$as_me:$LINENO: result: $AWK" >&5
$as_echo "$AWK" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$AWK" && break
done
{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
set x ${MAKE-make}
ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
cat >conftest.make <<\_ACEOF
SHELL = /bin/sh
all:
@echo '@@@%%%=$(MAKE)=@@@%%%'
_ACEOF
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
case `${MAKE-make} -f conftest.make 2>/dev/null` in
*@@@%%%=?*=@@@%%%*)
eval ac_cv_prog_make_${ac_make}_set=yes;;
*)
eval ac_cv_prog_make_${ac_make}_set=no;;
esac
rm -f conftest.make
fi
if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
SET_MAKE=
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
SET_MAKE="MAKE=${MAKE-make}"
fi
rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
-if test "`cd $srcdir && pwd`" != "`pwd`"; then
- # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
- # is not polluted with repeated "-I."
- am__isrc=' -I$(srcdir)'
- # test to see if srcdir already configured
- if test -f $srcdir/config.status; then
- { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+# test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+ test -f $srcdir/config.status; then
+ { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
{ (exit 1); exit 1; }; }
- fi
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
# Define the identity of the package.
PACKAGE='m6809-run'
VERSION='0.92'
cat >>confdefs.h <<_ACEOF
#define PACKAGE "$PACKAGE"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define VERSION "$VERSION"
_ACEOF
# Some tools Automake needs.
ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
-install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
if test "$cross_compiling" != no; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_STRIP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$STRIP"; then
ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_STRIP="${ac_tool_prefix}strip"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
STRIP=$ac_cv_prog_STRIP
if test -n "$STRIP"; then
{ $as_echo "$as_me:$LINENO: result: $STRIP" >&5
$as_echo "$STRIP" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_STRIP"; then
ac_ct_STRIP=$STRIP
# Extract the first word of "strip", so it can be a program name with args.
set dummy strip; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_STRIP"; then
ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_STRIP="strip"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
if test -n "$ac_ct_STRIP"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
$as_echo "$ac_ct_STRIP" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_STRIP" = x; then
STRIP=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
STRIP=$ac_ct_STRIP
fi
else
STRIP="$ac_cv_prog_STRIP"
fi
fi
-INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
# Always define AMTAR for backward compatibility.
AMTAR=${AMTAR-"${am_missing_run}tar"}
am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
ac_config_headers="$ac_config_headers config.h"
# Checks for programs.
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
else
CC="$ac_cv_prog_CC"
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# != 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
for ac_prog in cl.exe
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:$LINENO: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in cl.exe
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$ac_ct_CC" && break
done
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
fi
fi
test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&5
$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
# Provide some information about the compiler.
$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
{ (ac_try="$ac_compiler --version >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler --version >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (ac_try="$ac_compiler -v >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler -v >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (ac_try="$ac_compiler -V >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compiler -V >&5") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
ac_rmfiles=
for ac_file in $ac_files
do
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
* ) ac_rmfiles="$ac_rmfiles $ac_file";;
esac
done
rm -f $ac_rmfiles
if { (ac_try="$ac_link_default"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link_default") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile. We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
;;
[ab].out )
# We found the default executable, but exeext='' is most
# certainly right.
break;;
*.* )
if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
then :; else
ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
fi
# We set ac_cv_exeext here because the later test for it is not
# safe: cross compilers may not add the suffix if given an `-o'
# argument, so we may need to know it at that point already.
# Even if this section looks crufty: it has the advantage of
# actually working.
break;;
* )
break;;
esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=
else
ac_file=''
fi
{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
if test -z "$ac_file"; then
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
See \`config.log' for more details." >&5
$as_echo "$as_me: error: C compiler cannot create executables
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }; }
fi
ac_exeext=$ac_cv_exeext
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
# If not cross compiling, check that we can run a simple program.
if test "$cross_compiling" != yes; then
if { ac_try='./$ac_file'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }
{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
break;;
* ) break;;
esac
done
else
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
rm -f conftest$ac_cv_exeext
{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if test "${ac_cv_objext+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
for ac_file in conftest.o conftest.obj conftest.*; do
test -f "$ac_file" || continue;
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if test "${ac_cv_c_compiler_gnu+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_compiler_gnu=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if test "${ac_cv_prog_cc_g+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
ac_cv_prog_cc_g=no
CFLAGS="-g"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_g=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
CFLAGS=""
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="-g"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_g=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
$as_echo "$ac_cv_prog_cc_g" >&6; }
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if test "${ac_cv_prog_cc_c89+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
function prototypes and stuff, but not '\xHH' hex character constants.
These don't provoke an error unfortunately, instead are silently treated
as 'x'. The following induces an error, until -std is added to get
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
array size at least. It's necessary to write '\x00'==0 to get something
that's true only with -std. */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
inside strings and character constants. */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
;
return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_prog_cc_c89=$ac_arg
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC
fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
x)
{ $as_echo "$as_me:$LINENO: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
xno)
{ $as_echo "$as_me:$LINENO: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
*)
CC="$CC $ac_cv_prog_cc_c89"
{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
DEPDIR="${am__leading_dot}deps"
ac_config_commands="$ac_config_commands depfiles"
am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
$as_echo_n "checking for style of include used by $am_make... " >&6; }
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5
$as_echo "$_am_result" >&6; }
rm -f confinc confmf
# Check whether --enable-dependency-tracking was given.
if test "${enable_dependency_tracking+set}" = set; then
enableval=$enable_dependency_tracking;
fi
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
- if test "x$enable_dependency_tracking" != xno; then
+
+
+if test "x$enable_dependency_tracking" != xno; then
AMDEP_TRUE=
AMDEP_FALSE='#'
else
AMDEP_TRUE='#'
AMDEP_FALSE=
fi
+
depcc="$CC" am_compiler_list=
{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
$as_echo_n "checking dependency style of $depcc... " >&6; }
if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_CC_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
- grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_CC_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_CC_dependencies_compiler_type=none
fi
fi
{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
- if
+
+
+if
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
am__fastdepCC_TRUE=
am__fastdepCC_FALSE='#'
else
am__fastdepCC_TRUE='#'
am__fastdepCC_FALSE=
fi
# Checks for header files.
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if test "${ac_cv_prog_CPP+set}" = set; then
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
# <limits.h> exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
Syntax error
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <ac_nonexistent.h>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
# Broken: success on invalid input.
continue
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
break
fi
done
ac_cv_prog_CPP=$CPP
fi
CPP=$ac_cv_prog_CPP
else
ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
# <limits.h> exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
Syntax error
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <ac_nonexistent.h>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
# Broken: success on invalid input.
continue
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
:
else
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&5
$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if test "${ac_cv_path_GREP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ac_count=`expr $ac_count + 1`
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
{ { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
{ (exit 1); exit 1; }; }
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if test "${ac_cv_path_EGREP+set}" = set; then
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
ac_count=`expr $ac_count + 1`
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
{ { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
{ (exit 1); exit 1; }; }
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if test "${ac_cv_header_stdc+set}" = set; then
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <float.h>
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_header_stdc=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <string.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then
:
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <ctype.h>
#include <stdlib.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
@@ -6038,1457 +6020,1437 @@ _ACEOF
fi
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems. If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
_ACEOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, we kill variables containing newlines.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(
for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) $as_unset $ac_var ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space=' '; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote
# substitution turns \\\\ into \\, and sed turns \\ into \).
sed -n \
"s/'/'\\\\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;; #(
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
) |
sed '
/^ac_cv_env_/b end
t clear
:clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
test "x$cache_file" != "x/dev/null" &&
{ $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
cat confcache >$cache_file
else
{ $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
fi
fi
rm -f confcache
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
DEFS=-DHAVE_CONFIG_H
ac_libobjs=
ac_ltlibobjs=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
# 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
# will be set to the directory where LIBOBJS objects are built.
ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
{ { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
$as_echo "$as_me: error: conditional \"AMDEP\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
{ { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=\${CONFIG_SHELL-$SHELL}
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in
*posix*) set -o posix ;;
esac
fi
# PATH needs CR
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
case $0 in
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
{ (exit 1); exit 1; }
fi
# Work around bugs in pre-3.0 UWIN ksh.
for as_var in ENV MAIL MAILPATH
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
# Name of the executable.
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# CDPATH.
$as_unset CDPATH
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line after each line using $LINENO; the second 'sed'
# does the real work. The second script uses 'N' to pair each
# line-number line with the line containing $LINENO, and appends
# trailing '-' during substitution so that $LINENO is not a special
# case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# scripts with optimization help from Paolo Bonzini. Blame Lee
# E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in
-n*)
case `echo 'x\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
*) ECHO_C='\c';;
esac;;
*)
ECHO_N='-n';;
esac
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 6>&1
# Save the log message, to keep $[0] and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by m6809-run $as_me 0.92, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
on `(hostname || uname -n) 2>/dev/null | sed 1q`
"
_ACEOF
case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac
case $ac_config_headers in *"
"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
esac
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
config_commands="$ac_config_commands"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.
Usage: $0 [OPTION]... [FILE]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
-q, --quiet, --silent
do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Configuration commands:
$config_commands
Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
m6809-run config.status 0.92
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
Copyright (C) 2008 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
ac_pwd='$ac_pwd'
srcdir='$srcdir'
INSTALL='$INSTALL'
-MKDIR_P='$MKDIR_P'
AWK='$AWK'
test -n "\$AWK" || AWK=awk
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --versio | --versi | --vers | --ver | --ve | --v | -V )
$as_echo "$ac_cs_version"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
{ $as_echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; };;
--help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) { $as_echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; } ;;
*) ac_config_targets="$ac_config_targets $1"
ac_need_defaults=false ;;
esac
shift
done
ac_configure_extra_args=
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
export CONFIG_SHELL
exec "\$@"
fi
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
$as_echo "$ac_log"
} >&5
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
#
# INIT-COMMANDS
#
AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Handling of arguments.
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
tmp=
trap 'exit_status=$?
{ test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} ||
{
$as_echo "$as_me: cannot create a temporary directory in ." >&2
{ (exit 1); exit 1; }
}
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then
ac_cr='
'
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
echo 'BEGIN {' >"$tmp/subs1.awk" &&
_ACEOF
{
echo "cat >conf$$subs.awk <<_ACEOF" &&
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
if test $ac_delim_n = $ac_delim_num; then
break
elif $ac_last_try; then
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\).*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\).*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' <conf$$subs.awk | sed '
/^[^""]/{
N
s/\n//
}
' >>$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
}
{
line = $ 0
nfields = split(line, field, "@")
substed = 0
len = length(field[1])
for (i = 2; i < nfields; i++) {
key = field[i]
keylen = length(key)
if (S_is_set[key]) {
value = S[key]
line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
len += length(value) + length(field[++i])
substed = 1
} else
len += 1 + keylen
}
print line
}
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
|| { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
$as_echo "$as_me: error: could not setup config files machinery" >&2;}
{ (exit 1); exit 1; }; }
_ACEOF
# VPATH may cause trouble with some makes, so we remove $(srcdir),
# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/
s/:*\${srcdir}:*/:/
s/:*@srcdir@:*/:/
s/^\([^=]*=[ ]*\):*/\1/
s/:*$//
s/^[^=]*=[ ]*$//
}'
fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
# Transform confdefs.h into an awk script `defines.awk', embedded as
# here-document in config.status, that substitutes the proper values into
# config.h.in to produce config.h.
# Create a delimiter string that does not exist in confdefs.h, to ease
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
ac_t=`sed -n "/$ac_delim/p" confdefs.h`
if test -z "$ac_t"; then
break
elif $ac_last_try; then
{ { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
{ (exit 1); exit 1; }; }
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
# For the awk script, D is an array of macro values keyed by name,
# likewise P contains macro parameters if any. Preserve backslash
# newline sequences.
ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
sed -n '
s/.\{148\}/&'"$ac_delim"'/g
t rset
:rset
s/^[ ]*#[ ]*define[ ][ ]*/ /
t def
d
:def
s/\\$//
t bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3"/p
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
d
:bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3\\\\\\n"\\/p
t cont
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
t cont
d
:cont
n
s/.\{148\}/&'"$ac_delim"'/g
t clear
:clear
s/\\$//
t bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/"/p
d
:bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
b cont
' <confdefs.h | sed '
s/'"$ac_delim"'/"\\\
"/g' >>$CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
for (key in D) D_is_set[key] = 1
FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
line = \$ 0
split(line, arg, " ")
if (arg[1] == "#") {
defundef = arg[2]
mac1 = arg[3]
} else {
defundef = substr(arg[1], 2)
mac1 = arg[2]
}
split(mac1, mac2, "(") #)
macro = mac2[1]
prefix = substr(line, 1, index(line, defundef) - 1)
if (D_is_set[macro]) {
# Preserve the white space surrounding the "#".
print prefix "define", macro P[macro] D[macro]
next
} else {
# Replace #undef with comments. This is necessary, for example,
# in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
if (defundef == "undef") {
print "/*", prefix defundef, macro, "*/"
next
}
}
}
{ print }
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
{ { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
{ (exit 1); exit 1; }; }
fi # test -n "$CONFIG_HEADERS"
eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
shift
for ac_tag
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
{ (exit 1); exit 1; }; };;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
ac_save_IFS=$IFS
IFS=:
set x $ac_tag
IFS=$ac_save_IFS
shift
ac_file=$1
shift
case $ac_mode in
:L) ac_source=$1;;
:[FH])
ac_file_inputs=
for ac_f
do
case $ac_f in
-) ac_f="$tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
test -f "$ac_f" ||
case $ac_f in
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
{ { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
{ (exit 1); exit 1; }; };;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
ac_file_inputs="$ac_file_inputs '$ac_f'"
done
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated by config.status. */
configure_input='Generated from '`
$as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
`' by configure.'
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ $as_echo "$as_me:$LINENO: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
fi
# Neutralize special characters interpreted by sed in replacement strings.
case $configure_input in #(
*\&* | *\|* | *\\* )
ac_sed_conf_input=`$as_echo "$configure_input" |
sed 's/[\\\\&|]/\\\\&/g'`;; #(
*) ac_sed_conf_input=$configure_input;;
esac
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
;;
esac
ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
{ as_dir="$ac_dir"
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
{ (exit 1); exit 1; }; }; }
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
case $ac_mode in
:F)
#
# CONFIG_FILE
#
case $INSTALL in
[\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
*) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
esac
- ac_MKDIR_P=$MKDIR_P
- case $MKDIR_P in
- [\\/$]* | ?:[\\/]* ) ;;
- */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
- esac
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
p
q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p
'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
{ $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_datarootdir_hack='
s&@datadir@&$datadir&g
s&@docdir@&$docdir&g
s&@infodir@&$infodir&g
s&@localedir@&$localedir&g
s&@mandir@&$mandir&g
s&\\\${datarootdir}&$datarootdir&g' ;;
esac
_ACEOF
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
-s&@MKDIR_P@&$ac_MKDIR_P&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
{ ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&2;}
rm -f "$tmp/stdin"
case $ac_file in
-) cat "$tmp/out" && rm -f "$tmp/out";;
*) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
esac \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
;;
:H)
#
# CONFIG_HEADER
#
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
} >"$tmp/config.h" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
mv "$tmp/config.h" "$ac_file" \
|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
fi
else
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
|| { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
$as_echo "$as_me: error: could not create -" >&2;}
{ (exit 1); exit 1; }; }
fi
# Compute "$ac_file"'s index in $config_headers.
-_am_arg="$ac_file"
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
- $_am_arg | $_am_arg:* )
+ "$ac_file" | "$ac_file":* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
-echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
-$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$_am_arg" : 'X\(//\)[^/]' \| \
- X"$_am_arg" : 'X\(//\)$' \| \
- X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$_am_arg" |
+echo "timestamp for "$ac_file"" >`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`/stamp-h$_am_stamp_count
;;
:C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5
$as_echo "$as_me: executing $ac_file commands" >&6;}
;;
esac
case $ac_file$ac_mode in
- "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
- # Autoconf 2.62 quotes --file arguments for eval, but not when files
- # are listed without --file. Let's play safe and only enable the eval
- # if we detect the quoting.
- case $CONFIG_FILES in
- *\'*) eval set x "$CONFIG_FILES" ;;
- *) set x $CONFIG_FILES ;;
- esac
- shift
- for mf
- do
- # Strip MF so we end up with the name of the file.
- mf=`echo "$mf" | sed -e 's/:.*$//'`
- # Check whether this is an Automake generated Makefile or not.
- # We used to match only the files named `Makefile.in', but
- # some people rename them; so instead we look at the file content.
- # Grep'ing the first line is not enough: some people post-process
- # each Makefile.in and add a new line on top of each file to say so.
- # Grep'ing the whole file is not good either: AIX grep has a line
- # limit of 2048, but all sed's we know have understand at least 4000.
- if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
- dirpart=`$as_dirname -- "$mf" ||
+ "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named `Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # So let's grep whole file.
+ if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+ dirpart=`$as_dirname -- "$mf" ||
$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$mf" : 'X\(//\)[^/]' \| \
X"$mf" : 'X\(//\)$' \| \
X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$mf" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
- else
- continue
- fi
- # Extract the definition of DEPDIR, am__include, and am__quote
- # from the Makefile without running `make'.
- DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
- test -z "$DEPDIR" && continue
- am__include=`sed -n 's/^am__include = //p' < "$mf"`
- test -z "am__include" && continue
- am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
- # When using ansi2knr, U may be empty or an underscore; expand it
- U=`sed -n 's/^U = //p' < "$mf"`
- # Find all dependency output files, they are included files with
- # $(DEPDIR) in their names. We invoke sed twice because it is the
- # simplest approach to changing $(DEPDIR) to its actual value in the
- # expansion.
- for file in `sed -n "
- s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
- # Make sure the directory exists.
- test -f "$dirpart/$file" && continue
- fdir=`$as_dirname -- "$file" ||
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running `make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # When using ansi2knr, U may be empty or an underscore; expand it
+ U=`sed -n 's/^U = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`$as_dirname -- "$file" ||
$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$file" : 'X\(//\)[^/]' \| \
X"$file" : 'X\(//\)$' \| \
X"$file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
- { as_dir=$dirpart/$fdir
+ { as_dir=$dirpart/$fdir
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
{ (exit 1); exit 1; }; }; }
- # echo "creating $dirpart/$file"
- echo '# dummy' > "$dirpart/$file"
- done
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
done
-}
+done
;;
esac
done # for ac_tag
{ (exit 0); exit 0; }
_ACEOF
chmod +x $CONFIG_STATUS
ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
{ { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
{ (exit 1); exit 1; }; }
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded. So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status. When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
ac_config_status_args=
test "$silent" = yes &&
ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
$SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
$ac_cs_success || { (exit 1); exit 1; }
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
diff --git a/eon.c b/eon.c
index 54b3c46..0a9f22a 100644
--- a/eon.c
+++ b/eon.c
@@ -1,81 +1,127 @@
#include "machine.h"
#include "eon.h"
extern int system_running;
void eon_fault (unsigned int addr, unsigned char type)
{
if (system_running)
{
sim_error (">>> Page fault: addr=%04X type=%02X PC=%04X\n", addr, type, get_pc ());
#if 0
fault_addr = addr;
fault_type = type;
irq ();
#endif
}
}
/**
* Initialize the EON machine.
*/
void eon_init (const char *boot_rom_file)
{
struct hw_device *dev;
/* The MMU must be defined first, as all other devices
that are attached can try to hook into the MMU. */
device_define ( mmu_create (), 0,
MMU_ADDR, BUS_MAP_SIZE, MAP_READWRITE+MAP_FIXED );
/* A 1MB RAM part is mapped into all of the allowable 64KB
address space, until overriden by other devices. */
device_define ( ram_create (RAM_SIZE), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( rom_create (boot_rom_file, BOOT_ROM_SIZE), 0,
BOOT_ROM_ADDR, BOOT_ROM_SIZE, MAP_READABLE );
device_define ( dev = console_create (), 0,
CONSOLE_ADDR, BUS_MAP_SIZE, MAP_READWRITE );
device_define (dev, 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
device_define ( disk_create ("disk.bin"), 0,
DISK_ADDR(0), BUS_MAP_SIZE, MAP_READWRITE);
}
+/*
+ * Initialize the second-generation EON machine (EON2).
+ */
+void eon2_init (const char *boot_rom_file)
+{
+ struct hw_device *dev, *mmudev, *iodev, *intdev;
+
+ /* Create a 1MB RAM */
+ dev = ram_create (0x100000);
+
+ /* Place the RAM behind a small MMU, which dynamically remaps
+ portions of the RAM into the processor address space */
+ mmudev = small_mmu_create (dev);
+
+ /* Create and map in the ROM */
+ dev = rom_create (boot_rom_file, 0x800);
+ device_define (dev, 0, 0xF800, 0x0800, MAP_READABLE);
+
+ /* Create an I/O expander to hold all of the I/O registers.
+ Each device is allocated only 8 bytes. */
+ iodev = ioexpand_create ();
+ device_define (iodev, 0, 0xFF00, 128, MAP_READWRITE);
+ ioexpand_attach (iodev, 0, console_create ());
+ ioexpand_attach (iodev, 1, disk_create ("disk.bin"));
+ ioexpand_attach (iodev, 2, mmudev);
+ ioexpand_attach (iodev, 3, intdev = imux_create ());
+ /* 4 = config EEPROM */
+ /* 5 = video display */
+ /* 6 = battery-backed clock */
+ /* 7 = power control (reboot/off) */
+ /* 8 = timer(s) */
+ /* etc. up to device 15 */
+ /* May need to define an I/O _multiplexer_ to support more than 16 devices */
+
+ /* Bind interrupting devices to the interrupt multiplexor. */
+}
+
+
/**
* Initialize the simple machine, which is the default
* machine that has no bells or whistles.
*/
void simple_init (const char *boot_rom_file)
{
device_define ( ram_create (MAX_CPU_ADDR), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( console_create (), 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
}
struct machine eon_machine =
{
.name = "eon",
.fault = eon_fault,
.init = eon_init,
.periodic = 0,
};
+struct machine eon2_machine =
+{
+ .name = "eon2",
+ .fault = eon_fault,
+ .init = eon2_init,
+ .periodic = 0,
+};
+
struct machine simple_machine =
{
.name = "simple",
.fault = eon_fault,
.init = simple_init,
.periodic = 0,
};
diff --git a/eon.h b/eon.h
index a37cc94..8f7c5fc 100644
--- a/eon.h
+++ b/eon.h
@@ -1,130 +1,138 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MACHINE_EON_H
#define _MACHINE_EON_H
/* This file defines the characteristics of the EON machine architecture.
EON is a little more advanced than the 'simple' architecture that runs by
default, and can be used to run more sophiscated programs for the 6809.
However, no actual hardware resembling this exists.
The computer has a total of 1MB of RAM, which is mapped to logical address
0x0000. As the 6809 only has 64KB addressable at a time, some bank
switching is required. The address space is defined into 16, 4KB pages.
The pages from 0xE000-0xFFFF are special, though, and allow access to
I/O and a read-only boot ROM. Thus, pages 0-13 can be mapped to any
of the 1MB RAM, page 14 has all of the I/O registers and some of the boot
ROM, and page 15 has the remaining boot ROM, including interrupt vectors.
The boot ROM file to use is specified as a command-line option to the
emulator.
Each I/O device comprises 128 bytes of address space. There can be up
to a maximum of 8 devices defined this way. The "device ID" is just the
offset from the beginning of the I/O region. At present, 5 devices are
defined:
Device 0 - the MMU. This provides registers for reprogramming the paging
hardware.
Device 1 - the power manager. This is not yet implemented.
Device 2 - the console. This has the basic stdin/stdout, akin to a serial
port.
Device 3 - the display. Not implemented yet, this would be akin to a
graphical interface.
Device 4 - the disk drive. See machine.c for a full description of how the
disk works. EON simulates the disk using a file named 'disk.bin', so its
contents are actually persistent. Disk transfers conceptually DMA to/from
RAM in 512-byte chunks. The maximum disk size is 32MB (16-bit sector numbers).
*/
/* RAM */
#define RAM_SIZE 0x100000
/* I/O regions (1KB) */
#define BOOT_IO_ADDR 0xE000
#define DEVICE_BASE(n) (BOOT_IO_ADDR + (BUS_MAP_SIZE * (n)))
/* The MMU */
#define MMU_DEVID 0
#define MMU_ADDR DEVICE_BASE(MMU_DEVID)
#define MMU_PAGESIZE 4096
#define MMU_PAGECOUNT (MAX_CPU_ADDR / MMU_PAGESIZE)
#define MMU_PAGEREGS 4
/* device select */
#define MMU_DEV(p) (MMU_ADDR + ((p) * MMU_PAGEREGS) + 0)
/* 4KB region to map in */
#define MMU_OFF(p) (MMU_ADDR + ((p) * MMU_PAGEREGS) + 1)
/* permissions */
#define MMU_FLG(p) (MMU_ADDR + ((p) * MMU_PAGEREGS) + 2)
#define MMU_FAULT_ADDR (MMU_ADDR + 0x60)
#define MMU_FAULT_TYPE (MMU_ADDR + 0x62)
/* The Power Manager */
#define POWERMGR_DEVID 1
#define POWERMGR_ADDR DEVICE_BASE(POWERMGR_DEVID)
#define POWER_CTRL (POWERMGR_ADDR + 0)
#define POWER_RESET_REG (POWERMGMT_ADDR + 1)
/* The Console */
#define CONSOLE_DEVID 2
#define CONSOLE_ADDR DEVICE_BASE(CONSOLE_DEVID)
#define CONSOLE_OUT (CONSOLE_ADDR + 0)
#define LEGACY_EXIT (CONSOLE_ADDR + 1)
#define CONSOLE_IN (CONSOLE_ADDR + 2)
#define CON_OUT 0
#define CON_EXIT 1
#define CON_IN 2
/* The Display */
#define DISPLAY_DEVID 3
#define DISPLAY_ADDR DEVICE_BASE(DISPLAY_DEVID)
/* The Disk Drive */
#define DISK0_DEVID 4
#define DISK_ADDR(n) DEVICE_BASE(DISK0_DEVID + (n))
#define DISK_SECTOR_COUNT 65536
#define SECTOR_SIZE 512
#define DSK_CTRL 0
#define DSK_READ 0x1
#define DSK_WRITE 0x2
#define DSK_FLUSH 0x4
#define DSK_ERASE 0x8
#define DSK_ADDR 1
#define DSK_SECTOR 2 /* and 3 */
+/* The Interrupt Multiplexer */
+
+#define IMUX_DEVID 5
+#define IMUX_ADDR DEVICE_BASE(IMUX_DEVID)
+
+#define IMUX_ENB 0
+#define IMUX_PEND 1
+
/* Boot ROM region (7KB) */
#define BOOT_ROM_ADDR 0xE400
#define BOOT_ROM_SIZE 0x1C00
#endif /* _MACHINE_EON_H */
diff --git a/imux.c b/imux.c
index 2410383..1c8ea18 100644
--- a/imux.c
+++ b/imux.c
@@ -1,97 +1,101 @@
/* The interrupt multiplexer */
#include "machine.h"
#include "eon.h"
struct imux
{
unsigned int in_use; /* Bits for each int that are used */
unsigned int enabled; /* Bits for each int that is enabled */
unsigned int pending; /* Bits for each int that are active */
- unsigned int src;
+ unsigned int src; /* Source line back to CPU */
};
void imux_refresh (struct imux *mux)
{
if (mux->pending & mux->enabled)
request_irq (mux->src);
else
release_irq (mux->src);
}
void imux_reset (struct hw_device *dev)
{
struct imux *mux = (struct imux *)dev->priv;
mux->enabled = 0;
mux->pending = 0;
mux->src = 1;
}
U8 imux_read (struct hw_device *dev, unsigned long addr)
{
struct imux *mux = (struct imux *)dev->priv;
switch (addr)
{
case IMUX_ADDR - IMUX_ENB:
/* Return the enable bits */
return mux->enabled & 0xFF;
case IMUX_ADDR - IMUX_PEND:
/* Return the pending bits */
return mux->pending & 0xFF;
}
return -1;
}
void imux_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct imux *mux = (struct imux *)dev->priv;
switch (addr)
{
case IMUX_ADDR - IMUX_ENB:
/* Set the interrupt enables */
mux->enabled = val;
break;
case IMUX_ADDR - IMUX_PEND:
/* Clear pending interrupt source */
mux->pending &= ~val;
break;
}
imux_refresh (mux);
}
/*
* Register an interrupt line with the multiplexer.
* This just tracks which ones are in use.
*/
void imux_register (struct hw_device *dev, unsigned int sig)
{
struct imux *mux = (struct imux *)dev->priv;
mux->in_use |= (1 << sig);
}
+/*
+ * Assert an edge-triggered interrupt line.
+ */
void imux_assert (struct hw_device *dev, unsigned int sig)
{
struct imux *mux = (struct imux *)dev->priv;
mux->pending |= (1 << sig);
imux_refresh (mux);
}
+
struct hw_class imux_class =
{
.readonly = 0,
.reset = imux_reset,
.read = imux_read,
.write = imux_write,
};
struct hw_device *imux_create (void)
{
struct imux *imux = malloc (sizeof (struct imux));
return device_attach (&imux_class, BUS_MAP_SIZE, imux);
}
diff --git a/ioexpand.c b/ioexpand.c
new file mode 100644
index 0000000..9eabbca
--- /dev/null
+++ b/ioexpand.c
@@ -0,0 +1,70 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "machine.h"
+
+/* An I/O expander allows a single, 128-byte region to be shared among multiple
+devices. It subdivides the region into 16 8-byte subdevices. It is needed
+to work around the inability of the system bus to handle attaching devices
+less than 128 bytes wide. */
+
+#define NR_IOEXPAND 16
+#define IO_WINDOW 8
+
+struct ioexpand
+{
+ struct hw_device *ios[NR_IOEXPAND];
+};
+
+
+void ioexpand_attach (struct hw_device *expander_dev, int slot, struct hw_device *io_dev)
+{
+ struct ioexpand *iom = (struct ioexpand *)expander_dev->priv;
+ iom->ios[slot] = io_dev;
+}
+
+void ioexpand_reset (struct hw_device *dev)
+{
+ int i;
+ struct ioexpand *iom = (struct ioexpand *)dev->priv;
+
+ /* Propagate the reset to all devices behind the expander */
+ for (i=0; i < NR_IOEXPAND; i++)
+ if ((dev = iom->ios[i]) != NULL)
+ dev->class_ptr->reset (dev);
+}
+
+U8 ioexpand_read (struct hw_device *dev, unsigned long addr)
+{
+ struct ioexpand *iom = (struct ioexpand *)dev->priv;
+ dev = iom->ios[addr / IO_WINDOW];
+ if (!dev)
+ sim_error ("expander read from %04X has no backing device\n", addr);
+ return dev->class_ptr->read (dev, addr % IO_WINDOW);
+}
+
+void ioexpand_write (struct hw_device *dev, unsigned long addr, U8 val)
+{
+ struct ioexpand *iom = (struct ioexpand *)dev->priv;
+ dev = iom->ios[addr / IO_WINDOW];
+ if (!dev)
+ sim_error ("expander write %02X to %04X has no backing device\n", val, addr);
+ dev->class_ptr->write (dev, addr % IO_WINDOW, val);
+}
+
+struct hw_class ioexpand_class =
+{
+ .readonly = 0,
+ .reset = ioexpand_reset,
+ .read = ioexpand_read,
+ .write = ioexpand_write,
+};
+
+struct hw_device *ioexpand_create (void)
+{
+ int i;
+ struct ioexpand *iom = malloc (sizeof (struct ioexpand));
+ for (i=0; i < NR_IOEXPAND; i++)
+ iom->ios[i] = NULL;
+ return device_attach (&ioexpand_class, BUS_MAP_SIZE, iom);
+}
diff --git a/machine.c b/machine.c
index 4905c8d..eb99608 100644
--- a/machine.c
+++ b/machine.c
@@ -1,673 +1,696 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "machine.h"
#include "6809.h"
#include "eon.h"
#define CONFIG_LEGACY
#define MISSING 0xff
#define mmu_device (device_table[0])
extern void eon_init (const char *);
extern void wpc_init (const char *);
struct machine *machine;
unsigned int device_count = 0;
struct hw_device *device_table[MAX_BUS_DEVICES];
+struct hw_device *null_device;
+
struct bus_map busmaps[NUM_BUS_MAPS];
struct bus_map default_busmaps[NUM_BUS_MAPS];
U16 fault_addr;
U8 fault_type;
int system_running = 0;
void cpu_is_running (void)
{
system_running = 1;
}
/**
* Attach a new device to the bus. Only called during init.
*/
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv)
{
struct hw_device *dev = malloc (sizeof (struct hw_device));
dev->class_ptr = class_ptr;
dev->devid = device_count;
dev->size = size;
dev->priv = priv;
device_table[device_count++] = dev;
/* Attach implies reset */
class_ptr->reset (dev);
return dev;
};
/**
* Map a portion of a device into the CPU's address space.
*/
void bus_map (unsigned int addr,
unsigned int devid,
unsigned long offset,
unsigned int len,
unsigned int flags)
{
struct bus_map *map;
unsigned int start, count;
/* Warn if trying to map too much */
if (addr + len > MAX_CPU_ADDR)
{
fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n",
len, addr);
}
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
offset = ((offset + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Initialize the maps. This will let the CPU access the device. */
map = &busmaps[start];
while (count > 0)
{
if (!(map->flags & MAP_FIXED))
{
map->devid = devid;
map->offset = offset;
map->flags = flags;
}
count--;
map++;
offset += BUS_MAP_SIZE;
}
}
void device_define (struct hw_device *dev,
unsigned long offset,
unsigned int addr,
unsigned int len,
unsigned int flags)
{
+ /* Note: len must be a multiple of BUS_MAP_SIZE */
bus_map (addr, dev->devid, offset, len, flags);
}
void bus_unmap (unsigned int addr, unsigned int len)
{
struct bus_map *map;
unsigned int start, count;
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
+ {
machine->fault (addr, FAULT_NO_RESPONSE);
+ return null_device;
+ }
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
- * a caching scheme that cuts down on some of this...
- * Also consider a native 16-bit read that doesn't require
- * 2 separate calls here...
+ * a caching scheme that cuts down on some of this.
+ * There is also a 16-bit version that is more efficient when
+ * a full word is needed, but it implies that no reads will ever
+ * occur across a device boundary.
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
+
+ if (system_running && !(map->flags & MAP_READABLE))
+ machine->fault (addr, FAULT_NOT_READABLE);
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
+
if (system_running && !(map->flags & MAP_READABLE))
machine->fault (addr, FAULT_NOT_READABLE);
- else
- {
- command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
- return ((*class_ptr->read) (dev, phy_addr) << 8)
- | (*class_ptr->read) (dev, phy_addr+1);
- }
+ command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
+ return ((*class_ptr->read) (dev, phy_addr) << 8) |
+ (*class_ptr->read) (dev, phy_addr+1);
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
- /* This can fail if the area is read-only */
if (system_running && !(map->flags & MAP_WRITABLE))
machine->fault (addr, FAULT_NOT_WRITABLE);
- else
- (*class_ptr->write) (dev, phy_addr, val);
+ (*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
0 /* device_table[map->devid]->size */, map->flags);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
- return 0;
+ return 0xFF;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
+struct hw_class null_class =
+{
+ .readonly = 0,
+ .reset = null_reset,
+ .read = null_read,
+ .write = null_write,
+};
+
+struct hw_device *null_create (void)
+{
+ return device_attach (&null_class, 0, NULL);
+}
+
+
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
mmu_regs[page][2] & MAP_READWRITE);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
mmu_write (dev, page * MMU_PAGEREGS + 2, MAP_READWRITE);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
mmu_regs[page][2] = map->flags & MAP_READWRITE;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
/* The disk drive is emulated as follows:
* The disk is capable of "bus-mastering" and is able to dump data directly
* into the RAM, without CPU-involvement. (The pages do not even need to
* be mapped.) A transaction is initiated with the following parameters:
*
* - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
* Thus there are 64 possible sector locations.
* - address of disk sector, given as a 16-bit value. This allows for up to
* a 32MB disk.
* - direction, either to disk or from disk.
*
* Emulation is synchronous with respect to the CPU.
*/
struct disk_priv
{
FILE *fp;
struct hw_device *dev;
unsigned long offset;
struct hw_device *ramdev;
unsigned int sectors;
char *ram;
};
U8 disk_read (struct hw_device *dev, unsigned long addr)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
}
void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
switch (addr)
{
case DSK_ADDR:
disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
break;
case DSK_SECTOR:
disk->offset = val; /* high byte */
break;
case DSK_SECTOR+1:
disk->offset = (disk->offset << 8) | val;
disk->offset *= SECTOR_SIZE;
fseek (disk->fp, disk->offset, SEEK_SET);
break;
case DSK_CTRL:
if (val & DSK_READ)
{
fread (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_WRITE)
{
fwrite (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_ERASE)
{
char empty_sector[SECTOR_SIZE];
memset (empty_sector, 0xff, SECTOR_SIZE);
fwrite (empty_sector, SECTOR_SIZE, 1, disk->fp);
}
if (val & DSK_FLUSH)
{
fflush (disk->fp);
}
break;
}
}
void disk_reset (struct hw_device *dev)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
disk_write (dev, DSK_ADDR, 0);
disk_write (dev, DSK_SECTOR, 0);
disk_write (dev, DSK_SECTOR+1, 0);
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
void disk_format (struct hw_device *dev)
{
unsigned int sector;
struct disk_priv *disk = (struct disk_priv *)dev->priv;
for (sector = 0; sector < disk->sectors; sector++)
{
disk_write (dev, DSK_SECTOR, sector >> 8);
disk_write (dev, DSK_SECTOR+1, sector & 0xFF);
disk_write (dev, DSK_CTRL, DSK_ERASE);
}
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
struct hw_class disk_class =
{
.readonly = 0,
.reset = disk_reset,
.read = disk_read,
.write = disk_write,
};
struct hw_device *disk_create (const char *backing_file)
{
struct disk_priv *disk = malloc (sizeof (struct disk_priv));
int newdisk = 0;
disk->fp = file_open (NULL, backing_file, "r+b");
if (disk->fp == NULL)
{
printf ("warning: disk does not exist, creating\n");
disk->fp = file_open (NULL, backing_file, "w+b");
newdisk = 1;
if (disk->fp == NULL)
{
printf ("warning: disk not created\n");
}
}
disk->ram = 0;
disk->ramdev = device_table[1];
disk->dev = device_attach (&disk_class, BUS_MAP_SIZE, disk);
disk->sectors = DISK_SECTOR_COUNT;
if (newdisk)
disk_format (disk->dev);
return disk->dev;
}
/**********************************************************/
int machine_match (const char *machine_name, const char *boot_rom_file, struct machine *m)
{
if (!strcmp (m->name, machine_name))
{
machine = m;
m->init (boot_rom_file);
return 1;
}
return 0;
}
void machine_init (const char *machine_name, const char *boot_rom_file)
{
extern struct machine simple_machine;
extern struct machine eon_machine;
+ extern struct machine eon2_machine;
extern struct machine wpc_machine;
int i;
/* Initialize CPU maps, so that no CPU addresses map to
anything. Default maps will trigger faults at runtime. */
+ null_device = null_create ();
memset (busmaps, 0, sizeof (busmaps));
for (i = 0; i < NUM_BUS_MAPS; i++)
busmaps[i].devid = INVALID_DEVID;
if (machine_match (machine_name, boot_rom_file, &simple_machine));
else if (machine_match (machine_name, boot_rom_file, &eon_machine));
+ else if (machine_match (machine_name, boot_rom_file, &eon2_machine));
else if (machine_match (machine_name, boot_rom_file, &wpc_machine));
else exit (1);
/* Save the default busmap configuration, before the
CPU begins to run, so that it can be restored if
necessary. */
memcpy (default_busmaps, busmaps, sizeof (busmaps));
if (!strcmp (machine_name, "eon"))
mmu_reset_complete (mmu_device);
}
diff --git a/main.c b/main.c
index d8732d2..77b00e9 100644
--- a/main.c
+++ b/main.c
@@ -1,442 +1,445 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
unsigned long max_cycles = 500000000UL;
/* When nonzero, says that the state of the machine is persistent
across runs of the simulator. */
int machine_persistent = 0;
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
struct timeval time_started;
/**
* Return elapsed real time in milliseconds.
*/
long
time_diff (struct timeval *old, struct timeval *new)
{
long ms = (new->tv_usec - old->tv_usec) / 1000;
ms += (new->tv_sec - old->tv_sec) * 1000;
return ms;
}
long
get_elapsed_realtime (void)
{
struct timeval now;
gettimeofday (&now, NULL);
return time_diff (&time_started, &now);
}
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 30;
static int count = 30;
int delay;
static int total_ms_elapsed = 0;
static int cumulative_delay = 0;
if (--count > 0)
return;
if (last.tv_sec == 0 && last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = time_diff (&last, &now);
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
if (machine->periodic)
machine->periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
cumulative_delay += delay;
if (cumulative_delay > 0)
{
usleep (50 * 1000UL);
cumulative_delay -= 50;
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
int do_help (const char *arg __attribute__((unused)));
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
NO_NEG, NO_ARG, NULL, 0, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
{ 'R', "realtime", "Limit simulation speed to match realtime" },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
{ 'p', "persistent", "Use persistent machine state",
NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
return -1;
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
sim_exit (0x70);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
gettimeofday (&time_started, NULL);
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
+ /* The machine loader cannot deal with S-record files.
+ So initialize the machine first, passing it a NULL
+ filename, then load the S-record file afterwards. */
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
total += cpu_execute (max_cycles ? max_cycles-1 : 500000);
}
else
{
total += cpu_execute (cycles_per_irq);
/* TODO - this assumes periodic interrupts (WPC) */
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
sim_exit (0);
return 0;
}
diff --git a/mmu.c b/mmu.c
new file mode 100644
index 0000000..ceed65e
--- /dev/null
+++ b/mmu.c
@@ -0,0 +1,111 @@
+
+#include <stdlib.h>
+#include "machine.h"
+
+#define SMR_PAGESIZE 4096
+
+#define SMR_SLOTS 16
+
+/* Small MMU register map */
+#define SMR_SLOT 0 /* Which slot is described by registers 8-9 */
+#define SMR_BASEL 1 /* The base page for lower 8 slots */
+#define SMR_BASEH 2 /* The base page for upper 8 slots */
+#define SMR_FAULTA 3 /* The faulting address */
+#define SMR_FAULTT 5 /* The fault type */
+#define SM_GLOBAL_REGS 6
+#define SMR_PAGE 6 /* Which 4KB page is mapped to the current slot */
+#define SMR_FLAGS 7 /* What are the page flags for this slot */
+
+/* The 'small' MMU is an I/O device that allows remapping a window of
+a single device into a fixed region of the CPU. */
+struct small_mmu
+{
+ struct hw_device *realdev;
+ unsigned int page_size;
+ U8 global_regs[8];
+ U8 slot_regs[SMR_SLOTS][2];
+};
+
+void small_mmu_update_slot (struct small_mmu *mmu, unsigned int slot)
+{
+ unsigned int page = mmu->slot_regs[slot][SMR_PAGE - SM_GLOBAL_REGS];
+ unsigned int flags = mmu->slot_regs[slot][SMR_FLAGS - SM_GLOBAL_REGS];
+ bus_map (slot * SMR_PAGESIZE, mmu->realdev->devid, page, SMR_PAGESIZE,
+ flags & MAP_READWRITE);
+}
+
+void small_mmu_update_current (struct small_mmu *mmu)
+{
+ small_mmu_update_slot (mmu, mmu->global_regs[0]);
+}
+
+void small_mmu_update_all (struct small_mmu *mmu)
+{
+ unsigned int slot;
+ for (slot = 0; slot < SMR_SLOTS; slot++)
+ small_mmu_update_slot (mmu, slot);
+}
+
+U8 small_mmu_read (struct hw_device *dev, unsigned long addr)
+{
+ struct small_mmu *mmu = (struct small_mmu *)dev->priv;
+ if (addr < SM_GLOBAL_REGS)
+ return mmu->global_regs[addr];
+ else
+ return mmu->slot_regs[mmu->global_regs[0]][addr - SM_GLOBAL_REGS];
+}
+
+void small_mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
+{
+ struct small_mmu *mmu = (struct small_mmu *)dev->priv;
+
+ if (addr < SM_GLOBAL_REGS)
+ mmu->global_regs[addr] = val;
+ else
+ mmu->slot_regs[mmu->global_regs[0]][addr - SM_GLOBAL_REGS] = val;
+
+ switch (addr)
+ {
+ case SMR_PAGE:
+ case SMR_FLAGS:
+ {
+ unsigned int slot = mmu->global_regs[0];
+ unsigned int page = mmu->slot_regs[slot][SMR_PAGE - SM_GLOBAL_REGS];
+ unsigned int flags = mmu->slot_regs[slot][SMR_FLAGS - SM_GLOBAL_REGS];
+ bus_map (slot * SMR_PAGESIZE, mmu->realdev->devid, page * SMR_PAGESIZE,
+ SMR_PAGESIZE, flags & MAP_READWRITE);
+ break;
+ }
+ }
+}
+
+void small_mmu_reset (struct hw_device *dev)
+{
+ unsigned int page;
+ struct small_mmu *mmu = (struct small_mmu *)dev->priv;
+
+ for (page = 0; page < SMR_SLOTS; page++)
+ {
+ small_mmu_write (dev, SMR_SLOT, page);
+ small_mmu_write (dev, SMR_PAGE, page);
+ small_mmu_write (dev, SMR_FLAGS, MAP_READWRITE);
+ }
+}
+
+struct hw_class small_mmu_class =
+{
+ .readonly = 0,
+ .reset = small_mmu_reset,
+ .read = small_mmu_read,
+ .write = small_mmu_write,
+};
+
+struct hw_device *small_mmu_create (struct hw_device *realdev)
+{
+ struct small_mmu *mmu = malloc (sizeof (struct small_mmu));
+ mmu->realdev = realdev;
+ mmu->page_size = SMR_PAGESIZE;
+ return device_attach (&small_mmu_class, 16, mmu); /* 16 = sizeof I/O window */
+}
+
+
diff --git a/timer.c b/timer.c
new file mode 100644
index 0000000..442128d
--- /dev/null
+++ b/timer.c
@@ -0,0 +1,118 @@
+
+#include <stdio.h>
+#include "machine.h"
+
+/* A hardware timer counts CPU cycles and can generate interrupts periodically. */
+struct hwtimer
+{
+ int count; /* The current value of the timer */
+ unsigned int reload; /* Value to reload into the timer when it reaches zero */
+ unsigned int resolution; /* Resolution of CPU registers (cycles/tick) */
+ unsigned int flags;
+ struct hw_device *int_dev; /* Which interrupt mux we use */
+ unsigned int int_line; /* Which interrupt to signal */
+};
+
+/* The I/O registers exposed by this driver */
+#define HWT_COUNT 0 /* The 8-bit timer counter */
+#define HWT_RELOAD 1 /* The 8-bit reload counter */
+#define HWT_FLAGS 2 /* Misc. flags */
+ #define HWTF_INT 0x80 /* Generate interrupt at zero */
+
+
+/*
+ * Called by the system to indicate that some number of CPU cycles have passed.
+ */
+void hwtimer_decrement (struct hw_device *dev, unsigned int cycles)
+{
+ struct hwtimer *timer = (struct hwtimer *)dev->priv;
+
+ /* If either the counter or the reload register is nonzero, the timer
+ is considered running. Otherwise, nothing to do */
+ if (!timer->count && !timer->reload)
+ return;
+
+ /* Decrement the counter. Is it zero/negative? */
+ timer->count -= cycles;
+ if (timer->count <= 0)
+ {
+ /* If interrupt is enabled, generate that now */
+ if (timer->flags & HWTF_INT)
+ {
+ }
+
+ /* If it is negative, we need to make it positive again.
+ If reload is nonzero, add that, to simulate the timer "wrapping".
+ Otherwise, fix it at zero. */
+ if (timer->flags < 0)
+ {
+ if (timer->reload)
+ {
+ timer->count += timer->reload;
+ /* Note: if timer->count is still negative, the reload value
+ is lower than the frequency at which the system is updating the
+ timers, and we would need to simulate two interrupts here
+ perhaps. For later. */
+ }
+ else
+ {
+ timer->count = 0;
+ }
+ }
+ }
+}
+
+U8 hwtimer_read (struct hw_device *dev, unsigned long addr)
+{
+ struct hwtimer *timer = (struct hwtimer *)dev->priv;
+ switch (addr)
+ {
+ case HWT_COUNT:
+ return timer->count / timer->resolution;
+ case HWT_RELOAD:
+ return timer->reload / timer->resolution;
+ case HWT_FLAGS:
+ return timer->flags;
+ }
+}
+
+void hwtimer_write (struct hw_device *dev, unsigned long addr, U8 val)
+{
+ struct hwtimer *timer = (struct hwtimer *)dev->priv;
+ switch (addr)
+ {
+ case HWT_COUNT:
+ timer->count = val * timer->resolution;
+ break;
+ case HWT_RELOAD:
+ timer->reload = val * timer->resolution;
+ break;
+ case HWT_FLAGS:
+ timer->flags = val;
+ break;
+ }
+}
+
+void hwtimer_reset (struct hw_device *dev)
+{
+ struct hwtimer *timer = (struct hwtimer *)dev->priv;
+ timer->count = 0;
+ timer->reload = 0;
+ timer->resolution = 128;
+}
+
+struct hw_class hwtimer_class =
+{
+ .readonly = 0,
+ .reset = hwtimer_reset,
+ .read = hwtimer_read,
+ .write = hwtimer_write,
+};
+
+struct hw_device *hwtimer_create (void)
+{
+ struct hwtimer *timer = malloc (sizeof (struct hwtimer));
+ return device_attach (&hwtimer_class, 16, timer); /* 16 = sizeof I/O window */
+}
+
+
|
bcd/exec09
|
0bf6c30ec38e339f69d852a3f381d059af27e6b0
|
Remove imux/stab from makefile for now.
|
diff --git a/Makefile.am b/Makefile.am
index 1100007..8714543 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,9 @@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
- symtab.c command.c fileio.c wpclib.c imux.c stab.c \
+ symtab.c command.c fileio.c wpclib.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
LIBS = $(READLINE_LIBS)
bin_PROGRAMS = m6809-run
bin_SCRIPTS = wpc-run
diff --git a/Makefile.in b/Makefile.in
index 8f86298..0c61c0c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,596 +1,593 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
bin_PROGRAMS = m6809-run$(EXEEXT)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING depcomp install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_m6809_run_OBJECTS = 6809.$(OBJEXT) main.$(OBJEXT) monitor.$(OBJEXT) \
machine.$(OBJEXT) eon.$(OBJEXT) wpc.$(OBJEXT) symtab.$(OBJEXT) \
- command.$(OBJEXT) fileio.$(OBJEXT) wpclib.$(OBJEXT) \
- imux.$(OBJEXT) stab.$(OBJEXT)
+ command.$(OBJEXT) fileio.$(OBJEXT) wpclib.$(OBJEXT)
m6809_run_OBJECTS = $(am_m6809_run_OBJECTS)
m6809_run_LDADD = $(LDADD)
binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(bin_SCRIPTS)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(m6809_run_SOURCES)
DIST_SOURCES = $(m6809_run_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = $(READLINE_LIBS)
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
READLINE_LIBS = @READLINE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
- symtab.c command.c fileio.c wpclib.c imux.c stab.c \
+ symtab.c command.c fileio.c wpclib.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
bin_SCRIPTS = wpc-run
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
m6809-run$(EXEEXT): $(m6809_run_OBJECTS) $(m6809_run_DEPENDENCIES)
@rm -f m6809-run$(EXEEXT)
$(LINK) $(m6809_run_OBJECTS) $(m6809_run_LDADD) $(LIBS)
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_SCRIPTS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f $$d$$p; then \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
else :; fi; \
done
uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(bin_SCRIPTS)'; for p in $$list; do \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/6809.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eon.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileio.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machine.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symtab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpclib.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d $(distdir) || mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-lzma: distdir
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am: install-binPROGRAMS install-binSCRIPTS
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
distclean distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-binSCRIPTS install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
|
bcd/exec09
|
aa023ca20b9b8c6082b7a294b6049174f217a11f
|
Add imux module.
|
diff --git a/imux.c b/imux.c
new file mode 100644
index 0000000..2410383
--- /dev/null
+++ b/imux.c
@@ -0,0 +1,97 @@
+
+/* The interrupt multiplexer */
+
+#include "machine.h"
+#include "eon.h"
+
+struct imux
+{
+ unsigned int in_use; /* Bits for each int that are used */
+ unsigned int enabled; /* Bits for each int that is enabled */
+ unsigned int pending; /* Bits for each int that are active */
+ unsigned int src;
+};
+
+void imux_refresh (struct imux *mux)
+{
+ if (mux->pending & mux->enabled)
+ request_irq (mux->src);
+ else
+ release_irq (mux->src);
+}
+
+
+void imux_reset (struct hw_device *dev)
+{
+ struct imux *mux = (struct imux *)dev->priv;
+ mux->enabled = 0;
+ mux->pending = 0;
+ mux->src = 1;
+}
+
+U8 imux_read (struct hw_device *dev, unsigned long addr)
+{
+ struct imux *mux = (struct imux *)dev->priv;
+ switch (addr)
+ {
+ case IMUX_ADDR - IMUX_ENB:
+ /* Return the enable bits */
+ return mux->enabled & 0xFF;
+
+ case IMUX_ADDR - IMUX_PEND:
+ /* Return the pending bits */
+ return mux->pending & 0xFF;
+ }
+ return -1;
+}
+
+
+void imux_write (struct hw_device *dev, unsigned long addr, U8 val)
+{
+ struct imux *mux = (struct imux *)dev->priv;
+ switch (addr)
+ {
+ case IMUX_ADDR - IMUX_ENB:
+ /* Set the interrupt enables */
+ mux->enabled = val;
+ break;
+ case IMUX_ADDR - IMUX_PEND:
+ /* Clear pending interrupt source */
+ mux->pending &= ~val;
+ break;
+ }
+ imux_refresh (mux);
+}
+
+/*
+ * Register an interrupt line with the multiplexer.
+ * This just tracks which ones are in use.
+ */
+void imux_register (struct hw_device *dev, unsigned int sig)
+{
+ struct imux *mux = (struct imux *)dev->priv;
+ mux->in_use |= (1 << sig);
+}
+
+void imux_assert (struct hw_device *dev, unsigned int sig)
+{
+ struct imux *mux = (struct imux *)dev->priv;
+ mux->pending |= (1 << sig);
+ imux_refresh (mux);
+}
+
+struct hw_class imux_class =
+{
+ .readonly = 0,
+ .reset = imux_reset,
+ .read = imux_read,
+ .write = imux_write,
+};
+
+struct hw_device *imux_create (void)
+{
+ struct imux *imux = malloc (sizeof (struct imux));
+ return device_attach (&imux_class, BUS_MAP_SIZE, imux);
+}
+
+
|
bcd/exec09
|
38156adb59991d6121197f1ee6a7661ee219d072
|
Change the MMU flags to support un-readable pages as well. Trying to read from such a page will also trigger a fault.
|
diff --git a/eon.c b/eon.c
index a49422b..54b3c46 100644
--- a/eon.c
+++ b/eon.c
@@ -1,81 +1,81 @@
#include "machine.h"
#include "eon.h"
extern int system_running;
void eon_fault (unsigned int addr, unsigned char type)
{
if (system_running)
{
sim_error (">>> Page fault: addr=%04X type=%02X PC=%04X\n", addr, type, get_pc ());
#if 0
fault_addr = addr;
fault_type = type;
irq ();
#endif
}
}
/**
* Initialize the EON machine.
*/
void eon_init (const char *boot_rom_file)
{
struct hw_device *dev;
/* The MMU must be defined first, as all other devices
that are attached can try to hook into the MMU. */
device_define ( mmu_create (), 0,
MMU_ADDR, BUS_MAP_SIZE, MAP_READWRITE+MAP_FIXED );
/* A 1MB RAM part is mapped into all of the allowable 64KB
address space, until overriden by other devices. */
device_define ( ram_create (RAM_SIZE), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( rom_create (boot_rom_file, BOOT_ROM_SIZE), 0,
- BOOT_ROM_ADDR, BOOT_ROM_SIZE, MAP_READONLY );
+ BOOT_ROM_ADDR, BOOT_ROM_SIZE, MAP_READABLE );
device_define ( dev = console_create (), 0,
CONSOLE_ADDR, BUS_MAP_SIZE, MAP_READWRITE );
device_define (dev, 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
device_define ( disk_create ("disk.bin"), 0,
DISK_ADDR(0), BUS_MAP_SIZE, MAP_READWRITE);
}
/**
* Initialize the simple machine, which is the default
* machine that has no bells or whistles.
*/
void simple_init (const char *boot_rom_file)
{
device_define ( ram_create (MAX_CPU_ADDR), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( console_create (), 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
}
struct machine eon_machine =
{
.name = "eon",
.fault = eon_fault,
.init = eon_init,
.periodic = 0,
};
struct machine simple_machine =
{
.name = "simple",
.fault = eon_fault,
.init = simple_init,
.periodic = 0,
};
diff --git a/machine.c b/machine.c
index 4ba9af2..4905c8d 100644
--- a/machine.c
+++ b/machine.c
@@ -1,668 +1,673 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "machine.h"
#include "6809.h"
#include "eon.h"
#define CONFIG_LEGACY
#define MISSING 0xff
#define mmu_device (device_table[0])
extern void eon_init (const char *);
extern void wpc_init (const char *);
struct machine *machine;
unsigned int device_count = 0;
struct hw_device *device_table[MAX_BUS_DEVICES];
struct bus_map busmaps[NUM_BUS_MAPS];
struct bus_map default_busmaps[NUM_BUS_MAPS];
U16 fault_addr;
U8 fault_type;
int system_running = 0;
void cpu_is_running (void)
{
system_running = 1;
}
/**
* Attach a new device to the bus. Only called during init.
*/
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv)
{
struct hw_device *dev = malloc (sizeof (struct hw_device));
dev->class_ptr = class_ptr;
dev->devid = device_count;
dev->size = size;
dev->priv = priv;
device_table[device_count++] = dev;
/* Attach implies reset */
class_ptr->reset (dev);
return dev;
};
/**
* Map a portion of a device into the CPU's address space.
*/
void bus_map (unsigned int addr,
unsigned int devid,
unsigned long offset,
unsigned int len,
unsigned int flags)
{
struct bus_map *map;
unsigned int start, count;
/* Warn if trying to map too much */
if (addr + len > MAX_CPU_ADDR)
{
fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n",
len, addr);
}
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
offset = ((offset + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Initialize the maps. This will let the CPU access the device. */
map = &busmaps[start];
while (count > 0)
{
if (!(map->flags & MAP_FIXED))
{
map->devid = devid;
map->offset = offset;
map->flags = flags;
}
count--;
map++;
offset += BUS_MAP_SIZE;
}
}
void device_define (struct hw_device *dev,
unsigned long offset,
unsigned int addr,
unsigned int len,
unsigned int flags)
{
bus_map (addr, dev->devid, offset, len, flags);
}
void bus_unmap (unsigned int addr, unsigned int len)
{
struct bus_map *map;
unsigned int start, count;
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
machine->fault (addr, FAULT_NO_RESPONSE);
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
* a caching scheme that cuts down on some of this...
* Also consider a native 16-bit read that doesn't require
* 2 separate calls here...
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
- command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
- return ((*class_ptr->read) (dev, phy_addr) << 8)
- | (*class_ptr->read) (dev, phy_addr+1);
+ if (system_running && !(map->flags & MAP_READABLE))
+ machine->fault (addr, FAULT_NOT_READABLE);
+ else
+ {
+ command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
+ return ((*class_ptr->read) (dev, phy_addr) << 8)
+ | (*class_ptr->read) (dev, phy_addr+1);
+ }
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
/* This can fail if the area is read-only */
- if (system_running && (map->flags & MAP_READONLY))
+ if (system_running && !(map->flags & MAP_WRITABLE))
machine->fault (addr, FAULT_NOT_WRITABLE);
else
(*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
- printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X\n",
+ printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
- 0 /* device_table[map->devid]->size */);
+ 0 /* device_table[map->devid]->size */, map->flags);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
return 0;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
- mmu_regs[page][2] & 0x1);
+ mmu_regs[page][2] & MAP_READWRITE);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
- mmu_write (dev, page * MMU_PAGEREGS + 2, 0);
+ mmu_write (dev, page * MMU_PAGEREGS + 2, MAP_READWRITE);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
- mmu_regs[page][2] = map->flags & 0x1;
+ mmu_regs[page][2] = map->flags & MAP_READWRITE;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
/* The disk drive is emulated as follows:
* The disk is capable of "bus-mastering" and is able to dump data directly
* into the RAM, without CPU-involvement. (The pages do not even need to
* be mapped.) A transaction is initiated with the following parameters:
*
* - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
* Thus there are 64 possible sector locations.
* - address of disk sector, given as a 16-bit value. This allows for up to
* a 32MB disk.
* - direction, either to disk or from disk.
*
* Emulation is synchronous with respect to the CPU.
*/
struct disk_priv
{
FILE *fp;
struct hw_device *dev;
unsigned long offset;
struct hw_device *ramdev;
unsigned int sectors;
char *ram;
};
U8 disk_read (struct hw_device *dev, unsigned long addr)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
}
void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
switch (addr)
{
case DSK_ADDR:
disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
break;
case DSK_SECTOR:
disk->offset = val; /* high byte */
break;
case DSK_SECTOR+1:
disk->offset = (disk->offset << 8) | val;
disk->offset *= SECTOR_SIZE;
fseek (disk->fp, disk->offset, SEEK_SET);
break;
case DSK_CTRL:
if (val & DSK_READ)
{
fread (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_WRITE)
{
fwrite (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_ERASE)
{
char empty_sector[SECTOR_SIZE];
memset (empty_sector, 0xff, SECTOR_SIZE);
fwrite (empty_sector, SECTOR_SIZE, 1, disk->fp);
}
if (val & DSK_FLUSH)
{
fflush (disk->fp);
}
break;
}
}
void disk_reset (struct hw_device *dev)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
disk_write (dev, DSK_ADDR, 0);
disk_write (dev, DSK_SECTOR, 0);
disk_write (dev, DSK_SECTOR+1, 0);
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
void disk_format (struct hw_device *dev)
{
unsigned int sector;
struct disk_priv *disk = (struct disk_priv *)dev->priv;
for (sector = 0; sector < disk->sectors; sector++)
{
disk_write (dev, DSK_SECTOR, sector >> 8);
disk_write (dev, DSK_SECTOR+1, sector & 0xFF);
disk_write (dev, DSK_CTRL, DSK_ERASE);
}
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
struct hw_class disk_class =
{
.readonly = 0,
.reset = disk_reset,
.read = disk_read,
.write = disk_write,
};
struct hw_device *disk_create (const char *backing_file)
{
struct disk_priv *disk = malloc (sizeof (struct disk_priv));
int newdisk = 0;
disk->fp = file_open (NULL, backing_file, "r+b");
if (disk->fp == NULL)
{
printf ("warning: disk does not exist, creating\n");
disk->fp = file_open (NULL, backing_file, "w+b");
newdisk = 1;
if (disk->fp == NULL)
{
printf ("warning: disk not created\n");
}
}
disk->ram = 0;
disk->ramdev = device_table[1];
disk->dev = device_attach (&disk_class, BUS_MAP_SIZE, disk);
disk->sectors = DISK_SECTOR_COUNT;
if (newdisk)
disk_format (disk->dev);
return disk->dev;
}
/**********************************************************/
int machine_match (const char *machine_name, const char *boot_rom_file, struct machine *m)
{
if (!strcmp (m->name, machine_name))
{
machine = m;
m->init (boot_rom_file);
return 1;
}
return 0;
}
void machine_init (const char *machine_name, const char *boot_rom_file)
{
extern struct machine simple_machine;
extern struct machine eon_machine;
extern struct machine wpc_machine;
int i;
/* Initialize CPU maps, so that no CPU addresses map to
anything. Default maps will trigger faults at runtime. */
memset (busmaps, 0, sizeof (busmaps));
for (i = 0; i < NUM_BUS_MAPS; i++)
busmaps[i].devid = INVALID_DEVID;
if (machine_match (machine_name, boot_rom_file, &simple_machine));
else if (machine_match (machine_name, boot_rom_file, &eon_machine));
else if (machine_match (machine_name, boot_rom_file, &wpc_machine));
else exit (1);
/* Save the default busmap configuration, before the
CPU begins to run, so that it can be restored if
necessary. */
memcpy (default_busmaps, busmaps, sizeof (busmaps));
if (!strcmp (machine_name, "eon"))
mmu_reset_complete (mmu_device);
}
diff --git a/machine.h b/machine.h
index 6b7d55e..147ccfe 100644
--- a/machine.h
+++ b/machine.h
@@ -1,138 +1,140 @@
/*
* Copyright 2006, 2007, 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef M6809_MACHINE_H
#define M6809_MACHINE_H
/* This file defines structures used to build generic machines on a 6809. */
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned long absolute_address_t;
#define MAX_CPU_ADDR 65536
/* The generic bus architecture. */
/* Up to 32 devices may be connected. Each device is addressed by a 32-bit physical address */
#define MAX_BUS_DEVICES 32
#define INVALID_DEVID 0xff
-/* Say whether or not the mapping is RO or RW. */
-#define MAP_READWRITE 0x0
-#define MAP_READONLY 0x1
+/* Say whether or not the mapping is RO or RW (or neither). */
+#define MAP_READABLE 0x1
+#define MAP_WRITABLE 0x2
+#define MAP_READWRITE 0x3
/* A fixed map cannot be reprogrammed. Attempts to
bus_map something differently will silently be
ignored. */
-#define MAP_FIXED 0x2
+#define MAP_FIXED 0x4
#define FAULT_NONE 0
#define FAULT_NOT_WRITABLE 1
#define FAULT_NO_RESPONSE 2
+#define FAULT_NOT_READABLE 3
/* A bus map is assocated with part of the 6809 address space
and says what device and which part of it is mapped into that
area. It also has associated flags which say how it is allowed
to be accessed.
A single bus map defines 128 bytes of address space; for a 64KB CPU,
that requires a total of 512 such structures.
Note that the bus map need not correspond to the page size that can
be configured by the MMU. It allows for more granularity and is
needed in some *hardcoded* mapping cases. */
#define BUS_MAP_SIZE 128
struct bus_map
{
unsigned int devid; /* The devid mapped here */
unsigned long offset; /* The offset within the device */
unsigned char flags;
};
#define NUM_BUS_MAPS (MAX_CPU_ADDR / BUS_MAP_SIZE)
/* A hardware device structure exists for each physical device
in the machine */
struct hw_device;
/* A hardware class structure exists for each type of device.
It defines the operations that are allowed on that device.
For example, if there are multiple ROM chips, then there is
a single "ROM" class and multiple ROM device objects. */
struct hw_class
{
/* Nonzero if the device is readonly */
int readonly;
/* Resets the device */
void (*reset) (struct hw_device *dev);
/* Reads a byte at a given offset from the beginning of the device. */
U8 (*read) (struct hw_device *dev, unsigned long phy_addr);
/* Writes a byte at a given offset from the beginning of the device. */
void (*write) (struct hw_device *dev, unsigned long phy_addr, U8 val);
};
struct hw_device
{
/* A pointer to the class object. This says what kind of device it is. */
struct hw_class *class_ptr;
/* The device ID assigned to it. This is filled in automatically
by the simulator. */
unsigned int devid;
/* The total size of the device in bytes. */
unsigned long size;
/* The private pointer, which is interpreted differently for each type
(hw_class) of device. */
void *priv;
};
extern struct machine *machine;
struct machine
{
const char *name;
void (*init) (const char *boot_rom_file);
void (*fault) (unsigned int addr, unsigned char type);
void (*dump_thread) (unsigned int thread_id);
void (*periodic) (void);
};
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv);
struct hw_device *ram_create (unsigned long size);
struct hw_device *rom_create (const char *filename, unsigned int maxsize);
struct hw_device *console_create (void);
struct hw_device *disk_create (const char *backing_file);
#endif /* _M6809_MACHINE_H */
diff --git a/wpc.c b/wpc.c
index 0bc589c..8abe817 100644
--- a/wpc.c
+++ b/wpc.c
@@ -1,759 +1,759 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "6809.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
#error
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/errno.h>
#include "wpclib.h"
#define WPC_RAM_BASE 0x0000
#define WPC_RAM_SIZE 0x2000
#define WPC_ROM_SIZE 0x100000
#define WPC_PAGED_REGION 0x4000
#define WPC_PAGED_SIZE 0x4000
#define WPC_FIXED_REGION 0x8000
#define WPC_FIXED_SIZE 0x8000
/* The register set of the WPC ASIC */
#define WPC_ASIC_BASE 0x3c00
#define WPC_DMD_LOW_BASE 0x3800
#define WPC_DMD_HIGH_BASE 0x3A00
#define WPC_DEBUG_DATA_PORT 0x3D60
#define WPC_DEBUG_CONTROL_PORT 0x3D61
#define WPC_DEBUG_WRITE_READY 0x1
#define WPC_DEBUG_READ_READY 0x2
#define WPC_PINMAME_CYCLE_COUNT 0x3D62
#define WPC_PINMAME_FUNC_ENTRY_HI 0x3D63
#define WPC_PINMAME_FUNC_ENTRY_LO 0x3D64
#define WPC_PINMAME_FUNC_EXIT_HI 0x3D65
#define WPC_PINMAME_FUNC_EXIT_LO 0x3D66
#define WPC_SERIAL_CONTROL_PORT 0x3E66
#define WPC_SERIAL_DATA_PORT 0x3E67
#define WPC_DMD_3200_PAGE 0x3FB8
#define WPC_DMD_3000_PAGE 0x3FB9
#define WPC_DMD_3600_PAGE 0x3FBA
#define WPC_DMD_3400_PAGE 0x3FBB
#define WPC_DMD_HIGH_PAGE 0x3FBC
#define WPC_DMD_FIRQ_ROW_VALUE 0x3FBD
#define WPC_DMD_LOW_PAGE 0x3FBE
#define WPC_DMD_ACTIVE_PAGE 0x3FBF
#define WPC_SERIAL_STATUS_PORT 0x3FC0
#define WPC_PARALLEL_DATA_PORT 0x3FC1
#define WPC_PARALLEL_STROBE_PORT 0x3FC2
#define WPC_SERIAL_DATA_OUTPUT 0x3FC3
#define WPC_SERIAL_CONTROL_OUTPUT 0x3FC4
#define WPC_SERIAL_BAUD_SELECT 0x3FC5
#define WPC_TICKET_DISPENSE 0x3FC6
#define WPC_DCS_SOUND_DATA_OUT 0x3FD0
#define WPC_DCS_SOUND_DATA_IN 0x3FD1
#define WPC_DCS_SOUND_RESET 0x3FD2
#define WPC_DCS_SOUND_DATA_READY 0x3FD3
#define WPC_FLIPTRONIC_PORT_A 0x3FD4
#define WPC_FLIPTRONIC_PORT_B 0x3FD5
#define WPCS_DATA 0x3FDC
#define WPCS_CONTROL_STATUS 0x3FDD
#define WPC_SOL_FLASH2_OUTPUT 0x3FE0
#define WPC_SOL_HIGHPOWER_OUTPUT 0x3FE1
#define WPC_SOL_FLASH1_OUTPUT 0x3FE2
#define WPC_SOL_LOWPOWER_OUTPUT 0x3FE3
#define WPC_LAMP_ROW_OUTPUT 0x3FE4
#define WPC_LAMP_COL_STROBE 0x3FE5
#define WPC_GI_TRIAC 0x3FE6
#define WPC_SW_JUMPER_INPUT 0x3FE7
#define WPC_SW_CABINET_INPUT 0x3FE8
#define WPC_SW_ROW_INPUT 0x3FE9 /* WPC */
#define WPC_SW_COL_STROBE 0x3FEA /* WPC */
#define WPCS_PIC_READ 0x3FE9 /* WPCS, WPC95 */
#define WPCS_PIC_WRITE 0x3FEA /* WPCS, WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_POS 0x3FEB
#define WPC_ALPHA_ROW1 0x3FEC
#else
#define WPC_EXTBOARD1 0x3FEB
#define WPC_EXTBOARD2 0x3FEC
#define WPC_EXTBOARD3 0x3FED
#endif
#define WPC95_FLIPPER_COIL_OUTPUT 0x3FEE /* WPC95 */
#define WPC95_FLIPPER_SWITCH_INPUT 0x3FEF /* WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_ROW2 0x3FEE
#else
#endif
#define WPC_LEDS 0x3FF2
#define WPC_RAM_BANK 0x3FF3 /* WPC95 */
#define WPC_SHIFTADDR 0x3FF4
#define WPC_SHIFTBIT 0x3FF6
#define WPC_SHIFTBIT2 0x3FF7
#define WPC_PERIPHERAL_TIMER_FIRQ_CLEAR 0x3FF8
#define WPC_ROM_LOCK 0x3FF9
#define WPC_CLK_HOURS_DAYS 0x3FFA
#define WPC_CLK_MINS 0x3FFB
#define WPC_ROM_BANK 0x3FFC
#define WPC_RAM_LOCK 0x3FFD
#define WPC_RAM_LOCKSIZE 0x3FFE
#define WPC_ZEROCROSS_IRQ_CLEAR 0x3FFF
/**
* The 'wpc_asic' struct holds all of the state
* of the ASIC. There is a single instance of this,
* named 'the_wpc', and it is pointed to by the
* global 'wpc'. Only one ASIC can be defined at
* a time.
*/
struct wpc_asic
{
struct hw_device *rom_dev;
struct hw_device *ram_dev;
struct hw_device *dmd_dev;
U8 led;
U8 rombank;
U8 ram_unlocked;
U8 ram_lock_size;
U16 shiftaddr;
U16 shiftbit;
U8 lamp_strobe;
U8 lamp_mx[8];
U8 sols[48];
U8 switch_strobe;
U8 switch_mx[10];
U8 opto_mx[10];
U8 dmd_maps[2];
unsigned int dmd_phase;
U8 dmd_visibles[3];
U8 dmd_last_visibles[3];
int curr_sw;
int curr_sw_time;
int wdog_timer;
} the_wpc;
struct wpc_asic *wpc = NULL;
int wpc_sock;
static int wpc_console_inited = 0;
static U8 wpc_get_console_state (void)
{
fd_set fds;
struct timeval timeout;
U8 rc = WPC_DEBUG_WRITE_READY;
if (!wpc_console_inited)
rc |= WPC_DEBUG_READ_READY;
#if 1
return rc;
#endif
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
rc |= WPC_DEBUG_READ_READY;
return rc;
}
static U8 wpc_console_read (void)
{
int rc;
U8 c = 0;
if (!wpc_console_inited)
{
wpc_console_inited = 1;
return 0;
}
rc = read (0, &c, 1);
return c;
}
static void wpc_console_write (U8 val)
{
putchar (val);
fflush (stdout);
}
static int scanbit (U8 val)
{
if (val & 0x80) return 7;
else if (val & 0x40) return 6;
else if (val & 0x20) return 5;
else if (val & 0x10) return 4;
else if (val & 0x08) return 3;
else if (val & 0x04) return 2;
else if (val & 0x02) return 1;
else if (val & 0x01) return 0;
else return -1;
}
unsigned int wpc_read_switch (int num)
{
unsigned int val;
val = wpc->switch_mx[num / 8] & (1 << (num % 8));
return val ? 1 : 0;
}
void wpc_write_switch (int num, int flag)
{
unsigned int col, val;
col = num / 8;
val = 1 << (num % 8);
#if 0
if (wpc->opto_mx[col] & val)
flag = !flag;
#endif
wpc->switch_mx[col] &= ~val;
if (flag)
wpc->switch_mx[col] |= val;
}
void wpc_press_switch (int num, int delay)
{
wpc_write_switch (num, 1);
wpc->curr_sw = num;
wpc->curr_sw_time = delay;
}
unsigned int wpc_read_switch_column (int col)
{
unsigned int val = 0;
int row;
for (row = 0; row < 8; row++)
if (wpc_read_switch (col * 8 + row))
val |= (1 << row);
return val;
}
void wpc_write_lamp (int num, int flag)
{
}
void wpc_write_sols (int first, U8 val)
{
int i;
for (i=0; i < 8; i++)
{
wpc->sols[first+i] = (val & (1 << i)) ? 1 : 0;
}
}
void wpc_dmd_set_visible (U8 val)
{
char *p;
struct wpc_message msg;
int rc;
int i, n;
static unsigned long last_firq_time = 0;
unsigned long now;
static int no_change_count = 0;
now = get_cycles ();
if (now - last_firq_time <= 1850 * 8)
{
//printf ("%02X ignored.\n", val);
return;
}
else if (now - last_firq_time >= 1850 * 8 * 5)
{
memset (wpc->dmd_visibles, val, 3);
wpc->dmd_phase = 0;
}
else
{
wpc->dmd_visibles[wpc->dmd_phase++] = val;
if (wpc->dmd_phase == 3)
wpc->dmd_phase = 0;
}
last_firq_time = now;
#if 0
printf ("%02X %f\n", val, get_cycles () / 1952.0);
#endif
if (!memcmp (wpc->dmd_visibles, wpc->dmd_last_visibles, 3)
&& (++no_change_count < 100))
return;
no_change_count = 0;
#if 0
printf ("%02X %02X %02X\n",
wpc->dmd_visibles[0],
wpc->dmd_visibles[1],
wpc->dmd_visibles[2]);
#endif
memcpy (wpc->dmd_last_visibles, wpc->dmd_visibles, 3);
/* Send updated page contents */
wpc_msg_init (CODE_DMD_PAGE, &msg);
for (i=0; i < 3; i++)
{
p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512;
msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i];
memcpy (&msg.u.dmdpage.phases[i].data, p, 512);
}
msg.len = sizeof (struct _dmdpage_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
/* Send status of which pages are visible now */
wpc_msg_init (CODE_DMD_VISIBLE, &msg);
for (i=0; i < 3; i++)
msg.u.dmdvisible.phases[i] = wpc->dmd_visibles[i];
msg.len = sizeof (struct _dmdvisible_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
}
void wpc_keypoll (void)
{
fd_set fds;
struct timeval timeout;
int rc;
unsigned char c;
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
{
rc = read (0, &c, 1);
#define BUTTON_DURATION 200
switch (c)
{
case '7':
wpc_press_switch (4, BUTTON_DURATION);
break;
case '8':
wpc_press_switch (5, BUTTON_DURATION);
break;
case '9':
wpc_press_switch (6, BUTTON_DURATION);
break;
case '0':
wpc_press_switch (7, BUTTON_DURATION);
break;
case ',':
wpc_press_switch (75, BUTTON_DURATION);
break;
case '.':
wpc_press_switch (73, BUTTON_DURATION);
break;
default:
printf ("wpc: invalid character '%c'\n", c);
break;
}
}
}
U8 wpc_asic_read (struct hw_device *dev, unsigned long addr)
{
U8 val;
switch (addr + WPC_ASIC_BASE)
{
case WPC_LEDS:
val = wpc->led;
break;
case WPC_ROM_BANK:
val = wpc->rombank;
break;
case WPC_DEBUG_CONTROL_PORT:
val = wpc_get_console_state ();
break;
case WPC_DEBUG_DATA_PORT:
val = wpc_console_read ();
break;
case WPC_SHIFTADDR:
val = wpc->shiftaddr >> 8;
break;
case WPC_SHIFTADDR+1:
val = (wpc->shiftaddr & 0xFF) + (wpc->shiftbit / 8);
break;
case WPC_SHIFTBIT:
val = 1 << (wpc->shiftbit % 8);
break;
case WPC_SW_ROW_INPUT:
{
/* Handle WPC and WPC-S machines differently */
if (wpc->switch_strobe >= 0x16 && wpc->switch_strobe <= 0x1F)
val = wpc_read_switch_column (wpc->switch_strobe - 0x16 + 1);
else
val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
break;
}
case WPC_SW_JUMPER_INPUT:
val = 0x55;
break;
case WPC_SW_CABINET_INPUT:
val = wpc_read_switch_column (0);
break;
case WPC_FLIPTRONIC_PORT_A:
case WPC_FLIPTRONIC_PORT_B:
case WPC95_FLIPPER_SWITCH_INPUT:
val = wpc_read_switch_column (9);
break;
default:
val = 0;
break;
}
//printf (">>> ASIC read %04X -> %02X\n", addr + WPC_ASIC_BASE, val);
return val;
}
/**
* Enforce the current read-only area of RAM.
*/
void wpc_update_ram (void)
{
unsigned int size_writable = WPC_RAM_SIZE;
if (!wpc->ram_unlocked)
{
switch (wpc->ram_lock_size)
{
default:
break;
case 0xF:
size_writable -= 256;
break;
case 0x7:
size_writable -= 512;
case 0x3:
size_writable -= 1024;
break;
case 0x1:
size_writable -= 2048;
break;
case 0:
size_writable -= 4096;
break;
}
}
bus_map (WPC_RAM_BASE, wpc->ram_dev->devid, 0, size_writable, MAP_READWRITE);
if (size_writable < WPC_RAM_SIZE)
bus_map (WPC_RAM_BASE + size_writable, wpc->ram_dev->devid, size_writable,
- WPC_RAM_SIZE - size_writable, MAP_READONLY);
+ WPC_RAM_SIZE - size_writable, MAP_READABLE);
}
void wpc_set_rom_page (unsigned char val)
{
- bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READONLY);
+ bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READABLE);
}
void wpc_set_dmd_page (unsigned int map, unsigned char val)
{
wpc->dmd_maps[map] = val;
bus_map (0x3800 + map * 0x200, 3, val * 0x200, 0x200, MAP_READWRITE);
}
void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr + WPC_ASIC_BASE)
{
case WPC_DMD_LOW_PAGE:
wpc_set_dmd_page (0, val);
break;
case WPC_DMD_HIGH_PAGE:
wpc_set_dmd_page (1, val);
break;
case WPC_DMD_FIRQ_ROW_VALUE:
break;
case WPC_DMD_ACTIVE_PAGE:
wpc_dmd_set_visible (val);
break;
case WPC_LEDS:
wpc->led = val;
break;
case WPC_ZEROCROSS_IRQ_CLEAR:
wpc->wdog_timer++;
break;
case WPC_ROM_BANK:
wpc->rombank = val;
wpc_set_rom_page (val);
break;
case WPC_DEBUG_DATA_PORT:
wpc_console_write (val);
break;
case WPC_RAM_LOCK:
wpc->ram_unlocked = val;
wpc_update_ram ();
break;
case WPC_RAM_LOCKSIZE:
wpc->ram_lock_size = val;
wpc_update_ram ();
break;
case WPC_SHIFTADDR:
wpc->shiftaddr &= 0x00FF;
wpc->shiftaddr |= val << 8;
break;
case WPC_SHIFTADDR+1:
wpc->shiftaddr &= 0xFF00;
wpc->shiftaddr |= val;
break;
case WPC_SHIFTBIT:
wpc->shiftbit = val;
break;
case WPC_LAMP_ROW_OUTPUT:
wpc->lamp_mx[scanbit (wpc->lamp_strobe)] = val;
break;
case WPC_LAMP_COL_STROBE:
wpc->lamp_strobe = val;
break;
case WPC_SW_COL_STROBE:
wpc->switch_strobe = val;
break;
case WPC_SOL_FLASH2_OUTPUT:
case WPC_SOL_HIGHPOWER_OUTPUT:
case WPC_SOL_FLASH1_OUTPUT:
case WPC_SOL_LOWPOWER_OUTPUT:
if (val != 0)
printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
break;
default:
break;
}
//printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
}
void wpc_periodic (void)
{
wpc_keypoll ();
wpc->wdog_timer -= 50;
if (wpc->wdog_timer <= 0)
{
}
if (wpc->curr_sw_time > 0)
{
wpc->curr_sw_time -= 100;
if (wpc->curr_sw_time <= 0)
{
wpc->curr_sw_time = 0;
wpc_write_switch (wpc->curr_sw, 0);
}
}
}
void wpc_asic_reset (struct hw_device *dev)
{
memset (wpc, 0, sizeof (struct wpc_asic));
wpc_write_switch (19, 1); /* Always Closed */
}
struct hw_class wpc_asic_class =
{
.reset = wpc_asic_reset,
.read = wpc_asic_read,
.write = wpc_asic_write,
};
struct hw_device *wpc_asic_create (void)
{
if (wpc)
{
fprintf (stderr, "WPC ASIC already created\n");
return NULL;
}
wpc = &the_wpc;
return device_attach (&wpc_asic_class, 0x800, wpc);
}
void wpc_fault (unsigned int addr, unsigned char type)
{
}
void wpc_dump_thread (unsigned int thread_id)
{
}
void io_sym_add (const char *name, unsigned long cpuaddr)
{
sym_add (&program_symtab, name, to_absolute (cpuaddr), 0);
}
#define IO_SYM_ADD(name) io_sym_add (#name, name)
void wpc_init (const char *boot_rom_file)
{
struct hw_device *dev;
int rc;
struct sockaddr_in myaddr;
device_define ( dev = wpc_asic_create (), 0,
WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE);
device_define ( dev = ram_create (WPC_RAM_SIZE), 0,
WPC_RAM_BASE, WPC_RAM_SIZE, MAP_READWRITE );
wpc->ram_dev = dev;
dev = rom_create (boot_rom_file, WPC_ROM_SIZE);
device_define ( dev, 0,
- WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READONLY);
+ WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READABLE);
device_define ( dev, WPC_ROM_SIZE - WPC_FIXED_SIZE,
- WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READONLY);
+ WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READABLE);
wpc->rom_dev = dev;
device_define ( dev = ram_create (16 * 512), 0,
0x3800, 0x200 * 2, MAP_READWRITE );
wpc->dmd_dev = dev;
wpc_update_ram ();
wpc_sock = udp_socket_create (9000);
if (wpc_sock < 0)
fprintf (stderr, "could not open output socket\n");
IO_SYM_ADD(WPC_DMD_LOW_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_PAGE);
IO_SYM_ADD(WPC_DMD_FIRQ_ROW_VALUE);
IO_SYM_ADD(WPC_DMD_LOW_PAGE);
IO_SYM_ADD(WPC_DMD_ACTIVE_PAGE);
IO_SYM_ADD(WPC_SERIAL_STATUS_PORT);
IO_SYM_ADD(WPC_PARALLEL_DATA_PORT);
IO_SYM_ADD(WPC_PARALLEL_STROBE_PORT);
IO_SYM_ADD(WPC_SERIAL_DATA_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_CONTROL_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_BAUD_SELECT);
IO_SYM_ADD(WPC_TICKET_DISPENSE);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_OUT);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_IN);
IO_SYM_ADD(WPC_DCS_SOUND_RESET);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_READY);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_A);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_B);
IO_SYM_ADD(WPCS_DATA);
IO_SYM_ADD(WPCS_CONTROL_STATUS);
IO_SYM_ADD(WPC_SOL_FLASH2_OUTPUT);
IO_SYM_ADD(WPC_SOL_HIGHPOWER_OUTPUT);
IO_SYM_ADD(WPC_SOL_FLASH1_OUTPUT);
IO_SYM_ADD(WPC_SOL_LOWPOWER_OUTPUT);
IO_SYM_ADD(WPC_LAMP_ROW_OUTPUT);
IO_SYM_ADD(WPC_LAMP_COL_STROBE);
IO_SYM_ADD(WPC_GI_TRIAC);
IO_SYM_ADD(WPC_SW_JUMPER_INPUT);
IO_SYM_ADD(WPC_SW_CABINET_INPUT);
IO_SYM_ADD(WPC_SW_ROW_INPUT);
IO_SYM_ADD(WPC_SW_COL_STROBE);
IO_SYM_ADD(WPC_LEDS);
IO_SYM_ADD(WPC_RAM_BANK);
IO_SYM_ADD(WPC_SHIFTADDR);
IO_SYM_ADD(WPC_SHIFTBIT);
IO_SYM_ADD(WPC_SHIFTBIT2);
IO_SYM_ADD(WPC_PERIPHERAL_TIMER_FIRQ_CLEAR);
IO_SYM_ADD(WPC_ROM_LOCK);
IO_SYM_ADD(WPC_CLK_HOURS_DAYS);
IO_SYM_ADD(WPC_CLK_MINS);
IO_SYM_ADD(WPC_ROM_BANK);
IO_SYM_ADD(WPC_RAM_LOCK);
IO_SYM_ADD(WPC_RAM_LOCKSIZE);
}
struct machine wpc_machine =
{
.name = "wpc",
.fault = wpc_fault,
.init = wpc_init,
.dump_thread = wpc_dump_thread,
.periodic = wpc_periodic,
};
struct machine wpc95_machine =
{
.name = "wpc95",
.fault = wpc_fault,
.init = wpc_init,
.dump_thread = wpc_dump_thread,
.periodic = wpc_periodic,
};
|
bcd/exec09
|
1f957aba68685d307a6f704b14f0685d3c9c8b8e
|
Fix most of the compiler warnings.
|
diff --git a/6809.h b/6809.h
index 351ca42..6d47908 100644
--- a/6809.h
+++ b/6809.h
@@ -1,243 +1,243 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef M6809_H
#define M6809_H
#include "config.h"
#include <stdio.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#else
#error
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#else
#error
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#else
#error
#endif
typedef uint8_t UINT8;
typedef signed char INT8;
typedef uint16_t UINT16;
typedef signed short INT16;
typedef uint32_t UINT32;
typedef signed int INT32;
typedef uint16_t target_addr_t;
#include "machine.h"
#define E_FLAG 0x80
#define F_FLAG 0x40
#define H_FLAG 0x20
#define I_FLAG 0x10
#define N_FLAG 0x08
#define Z_FLAG 0x04
#define V_FLAG 0x02
#define C_FLAG 0x01
extern int debug_enabled;
extern int need_flush;
extern unsigned long total;
extern int dump_cycles_on_success;
extern const char *prog_name;
long get_elapsed_realtime (void);
/* Primitive read/write macros */
#define read8(addr) cpu_read8 (addr)
#define write8(addr,val) do { cpu_write8 (addr, val); } while (0)
/* 16-bit versions */
#define read16(addr) cpu_read16(addr)
#define write16(addr,val) do { write8(addr+1, val & 0xFF); write8(addr, (val >> 8) & 0xFF); } while (0)
/* Fetch macros */
#define abs_read16(addr) ((abs_read8(addr) << 8) | abs_read8(addr+1))
#define fetch8() abs_read8 (pc++)
#define fetch16() (pc += 2, abs_read16(pc-2))
/* 6809.c */
extern int cpu_quit;
extern int cpu_execute (int);
extern void cpu_reset (void);
extern unsigned get_a (void);
extern unsigned get_b (void);
extern unsigned get_cc (void);
extern unsigned get_dp (void);
extern unsigned get_x (void);
extern unsigned get_y (void);
extern unsigned get_s (void);
extern unsigned get_u (void);
extern unsigned get_pc (void);
extern unsigned get_d (void);
extern unsigned get_flags (void);
extern void set_a (unsigned);
extern void set_b (unsigned);
extern void set_cc (unsigned);
extern void set_dp (unsigned);
extern void set_x (unsigned);
extern void set_y (unsigned);
extern void set_s (unsigned);
extern void set_u (unsigned);
extern void set_pc (unsigned);
extern void set_d (unsigned);
/* fileio.c */
struct pathlist
{
int count;
char *entry[32];
};
void path_init (struct pathlist *path);
void path_add (struct pathlist *path, const char *dir);
FILE * file_open (struct pathlist *path, const char *filename, const char *mode);
FILE * file_require_open (struct pathlist *path, const char *filename, const char *mode);
void file_close (FILE *fp);
/* monitor.c */
extern int monitor_on;
extern int check_break (void);
extern void monitor_init (void);
extern int monitor6809 (void);
extern int dasm (char *, absolute_address_t);
-extern int load_hex (char *);
-extern int load_s19 (char *);
-extern int load_bin (char *,int);
+extern int load_hex (const char *);
+extern int load_s19 (const char *);
+extern int load_bin (const char *,int);
#define MAX_STRINGSPACE 32000
#define MAX_SYMBOL_HASH 1009
#define SYM_DEFAULT 0
#define SYM_AUTO 1
typedef struct
{
unsigned char format;
unsigned int size;
} datatype_t;
/* symtab.c */
struct stringspace
{
char space[32000];
unsigned int used;
};
struct symbol
{
char *name;
unsigned long value;
datatype_t ty;
unsigned int type;
struct symbol *name_chain;
struct symbol *value_chain;
};
struct symtab
{
struct symbol *syms_by_name[MAX_SYMBOL_HASH];
struct symbol *syms_by_value[MAX_SYMBOL_HASH];
struct symtab *parent;
};
extern struct symtab program_symtab;
extern struct symtab internal_symtab;
extern struct symtab auto_symtab;
struct symbol *sym_add (struct symtab *symtab, const char *name, unsigned long value, unsigned int type);
void sym_set (struct symtab *symtab, const char *name, unsigned long value, unsigned int type);
int sym_find (struct symtab *symtab, const char *name, unsigned long *value, unsigned int type);
const char *sym_lookup (struct symtab *symtab, unsigned long value);
typedef void (*command_handler_t) (void);
typedef void (*virtual_handler_t) (unsigned long *val, int writep);
typedef unsigned int thread_id_t;
typedef struct
{
unsigned int id : 8;
unsigned int used : 1;
unsigned int enabled : 1;
unsigned int conditional : 1;
unsigned int threaded : 1;
unsigned int on_read : 1;
unsigned int on_write : 1;
unsigned int on_execute : 1;
unsigned int size : 4;
unsigned int keep_running : 1;
unsigned int temp : 1;
unsigned int last_write : 16;
unsigned int write_mask : 16;
absolute_address_t addr;
char condition[128];
thread_id_t tid;
unsigned int pass_count;
unsigned int ignore_count;
} breakpoint_t;
typedef struct
{
int used : 1;
datatype_t type;
char expr[128];
} display_t;
typedef struct
{
int id : 8;
thread_id_t tid;
} thread_t;
#define MAX_BREAKS 32
#define MAX_DISPLAYS 32
#define MAX_HISTORY 10
#define MAX_THREADS 64
void command_irq_hook (unsigned long cycles);
#endif /* M6809_H */
diff --git a/command.c b/command.c
index fae8e06..3206bdf 100644
--- a/command.c
+++ b/command.c
@@ -1,695 +1,695 @@
#include "6809.h"
#include "monitor.h"
#include "machine.h"
#include <sys/errno.h>
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#else
#error
#endif
typedef struct
{
unsigned int size;
unsigned int count;
char **strings;
} cmdqueue_t;
typedef enum
{
LVALUE,
RVALUE,
} eval_mode_t;
#define MAKE_ADDR(devno, phyaddr) ((devno * 0x10000000L) + phyaddr)
/**********************************************************/
/********************* Global Data ************************/
/**********************************************************/
unsigned int break_count = 0;
breakpoint_t breaktab[MAX_BREAKS];
unsigned int active_break_count = 0;
unsigned int display_count = 0;
display_t displaytab[MAX_DISPLAYS];
unsigned int history_count = 0;
unsigned long historytab[MAX_HISTORY];
absolute_address_t examine_addr = 0;
unsigned int examine_repeat = 1;
datatype_t examine_type;
/* Thread tracking. thread_current points to a location in
* target memory where the current thread ID is kept. thread_id
* is the debugger's current cached value of that, to avoid
* reading memory constantly. The size allows for targets to
* define the ID format differently. */
unsigned int thread_id_size = 2;
absolute_address_t thread_current;
absolute_address_t thread_id = 0;
thread_t threadtab[MAX_THREADS];
#define MAX_CMD_QUEUES 8
int command_stack_depth = -1;
cmdqueue_t command_stack[MAX_CMD_QUEUES];
#define MAX_TRACE 256
target_addr_t trace_buffer[MAX_TRACE];
unsigned int trace_offset = 0;
int stop_after_ms = 0;
datatype_t print_type;
char *command_flags;
int exit_command_loop;
#define IRQ_CYCLE_COUNTS 128
unsigned int irq_cycle_tab[IRQ_CYCLE_COUNTS] = { 0, };
unsigned int irq_cycle_entry = 0;
unsigned long irq_cycles = 0;
unsigned long eval (char *expr);
unsigned long eval_mem (char *expr, eval_mode_t mode);
extern int auto_break_insn_count;
FILE *command_input;
/**********************************************************/
/******************** 6809 Functions **********************/
/**********************************************************/
void
print_addr (absolute_address_t addr)
{
const char *name;
print_device_name (addr >> 28);
putchar (':');
printf ("0x%04X", addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
printf (" <%-16.16s>", name);
else
printf ("%-20.20s", "");
}
/**********************************************************/
/*********************** Functions ************************/
/**********************************************************/
void
syntax_error (const char *string)
{
fprintf (stderr, "error: %s\n", string);
}
void
save_value (unsigned long val)
{
historytab[history_count++ % MAX_HISTORY] = val;
}
unsigned long
eval_historical (unsigned int id)
{
return historytab[id % MAX_HISTORY];
}
void
assign_virtual (const char *name, unsigned long val)
{
unsigned long v_val;
/* First check for a special variable with this name, and
* invoke its write handler. Otherwise, store to the
* user table. */
if (!sym_find (&auto_symtab, name, &v_val, 0))
{
virtual_handler_t virtual = (virtual_handler_t)v_val;
virtual (&val, 1);
return;
}
sym_set (&internal_symtab, name, val, 0);
if (!strcmp (name, "thread_current"))
{
printf ("Thread pointer initialized to ");
print_addr (val);
putchar ('\n');
thread_current = val;
}
}
unsigned long
eval_virtual (const char *name)
{
unsigned long val;
/* The name of the virtual is looked up in the global
* symbol table, which holds the pointer to a
* variable in simulator memory, or to a function
* that can compute the value on-the-fly. */
if (!sym_find (&auto_symtab, name, &val, 0))
{
virtual_handler_t virtual = (virtual_handler_t)val;
virtual (&val, 0);
}
else if (!sym_find (&internal_symtab, name, &val, 0))
{
}
else
{
return 0;
}
return val;
}
void
-eval_assign (const char *expr, unsigned long val)
+eval_assign (char *expr, unsigned long val)
{
if (*expr == '$')
{
assign_virtual (expr+1, val);
}
else
{
absolute_address_t dst = eval_mem (expr, LVALUE);
abs_write8 (dst, val);
}
}
unsigned long
target_read (absolute_address_t addr, unsigned int size)
{
switch (size)
{
case 1:
return abs_read8 (addr);
case 2:
return abs_read16 (addr);
}
}
void
parse_format_flag (const char *flags, unsigned char *formatp)
{
while (*flags)
{
switch (*flags)
{
case 'x':
case 'd':
case 'u':
case 'o':
case 'a':
case 's':
*formatp = *flags;
break;
}
flags++;
}
}
void
parse_size_flag (const char *flags, unsigned int *sizep)
{
while (*flags)
{
switch (*flags++)
{
case 'b':
*sizep = 1;
break;
case 'w':
*sizep = 2;
break;
}
}
}
char *
match_binary (char *expr, const char *op, char **secondp)
{
char *p;
p = strstr (expr, op);
if (!p)
return NULL;
*p = '\0';
p += strlen (op);
*secondp = p;
return expr;
}
int
fold_comparisons (char *expr, unsigned long *value)
{
char *p;
if (match_binary (expr, "==", &p))
*value = (eval (expr) == eval (p));
else if (match_binary (expr, "!=", &p))
*value = (eval (expr) != eval (p));
else
return 0;
return 1;
}
int
fold_binary (char *expr, const char op, unsigned long *valp)
{
char *p;
unsigned long val1, val2;
if ((p = strchr (expr, op)) == NULL)
return 0;
/* If the operator is the first character of the expression,
* then it's really a unary and shouldn't match here. */
if (p == expr)
return 0;
*p++ = '\0';
val1 = eval (expr);
val2 = eval (p);
switch (op)
{
case '+': *valp = val1 + val2; break;
case '-': *valp = val1 - val2; break;
case '*': *valp = val1 * val2; break;
case '/': *valp = val1 / val2; break;
}
return 1;
}
/**
* Evaluate a memory expression, as an lvalue or rvalue.
*/
unsigned long
eval_mem (char *expr, eval_mode_t mode)
{
char *p;
unsigned long val;
/* First evaluate the address */
if ((p = strchr (expr, ':')) != NULL)
{
*p++ = '\0';
val = MAKE_ADDR (eval (expr), eval (p));
}
else if (isalpha (*expr))
{
if (sym_find (&program_symtab, expr, &val, 0))
val = 0;
}
else
{
/* TODO - if expr is already in absolute form,
this explodes ! */
val = to_absolute (eval (expr));
}
/* If mode is RVALUE, then dereference it */
if (mode == RVALUE)
val = target_read (val, 1);
return val;
}
/**
* Evaluate an expression, given as a string.
* The return is the value (rvalue) of the expression.
*
* TODO:
* - Support typecasts ( {TYPE}ADDR )
*
*/
unsigned long
eval (char *expr)
{
char *p;
unsigned long val;
if (fold_comparisons (expr, &val));
else if ((p = strchr (expr, '=')) != NULL)
{
*p++ = '\0';
val = eval (p);
eval_assign (expr, val);
}
else if (fold_binary (expr, '+', &val));
else if (fold_binary (expr, '-', &val));
else if (fold_binary (expr, '*', &val));
else if (fold_binary (expr, '/', &val));
else if (*expr == '$')
{
if (expr[1] == '$')
val = eval_historical (history_count - strtoul (expr+2, NULL, 10));
else if (isdigit (expr[1]))
val = eval_historical (strtoul (expr+1, NULL, 10));
else if (!expr[1])
val = eval_historical (0);
else
val = eval_virtual (expr+1);
}
else if (*expr == '&')
{
val = eval_mem (expr+1, LVALUE);
}
else if (isalpha (*expr))
{
val = eval_mem (expr, RVALUE);
}
else
{
val = strtoul (expr, NULL, 0);
}
return val;
}
void brk_enable (breakpoint_t *br, int flag)
{
if (br->enabled != flag)
{
br->enabled = flag;
if (flag)
active_break_count++;
else
active_break_count--;
}
}
breakpoint_t *
brkalloc (void)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
if (!breaktab[n].used)
{
breakpoint_t *br = &breaktab[n];
br->used = 1;
br->id = n;
br->conditional = 0;
br->threaded = 0;
br->keep_running = 0;
br->ignore_count = 0;
br->temp = 0;
brk_enable (br, 1);
return br;
}
return NULL;
}
void
brkfree (breakpoint_t *br)
{
brk_enable (br, 0);
br->used = 0;
}
void
brkfree_temps (void)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
if (breaktab[n].used && breaktab[n].temp)
{
brkfree (&breaktab[n]);
}
}
breakpoint_t *
brkfind_by_addr (absolute_address_t addr)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
if (breaktab[n].addr == addr)
return &breaktab[n];
return NULL;
}
breakpoint_t *
brkfind_by_id (unsigned int id)
{
return &breaktab[id];
}
void
brkprint (breakpoint_t *brkpt)
{
if (!brkpt->used)
return;
if (brkpt->on_execute)
printf ("Breakpoint");
else
{
printf ("Watchpoint");
if (brkpt->on_read)
printf ("(%s)", brkpt->on_write ? "RW" : "RO");
}
printf (" %d at ", brkpt->id);
print_addr (brkpt->addr);
if (!brkpt->enabled)
printf (" (disabled)");
if (brkpt->conditional)
printf (" if %s", brkpt->condition);
if (brkpt->threaded)
printf (" on thread %d", brkpt->tid);
if (brkpt->keep_running)
printf (", print-only");
if (brkpt->temp)
printf (", temp");
if (brkpt->ignore_count)
printf (", ignore %d times\n", brkpt->ignore_count);
if (brkpt->write_mask)
printf (", mask %02X\n", brkpt->write_mask);
putchar ('\n');
}
display_t *
display_alloc (void)
{
unsigned int n;
for (n = 0; n < MAX_DISPLAYS; n++)
{
display_t *ds = &displaytab[n];
if (!ds->used)
{
ds->used = 1;
return ds;
}
}
}
void
display_free (display_t *ds)
{
}
void
print_value (unsigned long val, datatype_t *typep)
{
char f[8];
switch (typep->format)
{
case 'a':
print_addr (val);
return;
case 's':
{
absolute_address_t addr = (absolute_address_t)val;
char c;
putchar ('"');
while ((c = abs_read8 (addr++)) != '\0')
putchar (c);
putchar ('"');
return;
}
case 't':
/* TODO : print as binary integer */
break;
}
if (typep->format == 'x')
{
printf ("0x");
sprintf (f, "%%0%d%c", typep->size * 2, typep->format);
}
else if (typep->format == 'o')
{
printf ("0");
sprintf (f, "%%%c", typep->format);
}
else
sprintf (f, "%%%c", typep->format);
printf (f, val);
}
void
display_print (void)
{
unsigned int n;
char comma = '\0';
for (n = 0; n < MAX_DISPLAYS; n++)
{
display_t *ds = &displaytab[n];
if (ds->used)
{
char expr[256];
strcpy (expr, ds->expr);
printf ("%c %s = ", comma, expr);
print_value (eval (expr), &ds->type);
comma = ',';
}
}
if (comma)
putchar ('\n');
}
int
print_insn (absolute_address_t addr)
{
char buf[64];
int size = dasm (buf, addr);
printf ("%s", buf);
return size;
}
void
do_examine (void)
{
unsigned int n;
unsigned int objs_per_line = 16;
if (isdigit (*command_flags))
examine_repeat = strtoul (command_flags, &command_flags, 0);
if (*command_flags == 'i')
examine_type.format = *command_flags;
else
parse_format_flag (command_flags, &examine_type.format);
parse_size_flag (command_flags, &examine_type.size);
switch (examine_type.format)
{
case 'i':
objs_per_line = 1;
break;
case 'w':
objs_per_line = 8;
break;
}
for (n = 0; n < examine_repeat; n++)
{
if ((n % objs_per_line) == 0)
{
putchar ('\n');
print_addr (examine_addr);
printf (": ");
}
switch (examine_type.format)
{
case 's': /* string */
break;
case 'i': /* instruction */
examine_addr += print_insn (examine_addr);
break;
default:
print_value (target_read (examine_addr, examine_type.size),
&examine_type);
putchar (' ');
examine_addr += examine_type.size;
}
}
putchar ('\n');
}
void
do_print (char *expr)
{
unsigned long val = eval (expr);
printf ("$%d = ", history_count);
parse_format_flag (command_flags, &print_type.format);
parse_size_flag (command_flags, &print_type.size);
print_value (val, &print_type);
putchar ('\n');
save_value (val);
}
void
do_set (char *expr)
{
(void)eval (expr);
}
/* TODO - WPC */
#define THREAD_DATA_PC 3
#define THREAD_DATA_ROMBANK 9
void
print_thread_data (absolute_address_t th)
{
U8 b;
U16 w;
absolute_address_t pc;
w = abs_read16 (th + THREAD_DATA_PC);
b = abs_read8 (th + THREAD_DATA_ROMBANK);
if (w >= 0x8000)
pc = 0xF0000 + w;
else
pc = (b * 0x4000) + (w - 0x4000);
pc = MAKE_ADDR (1, pc);
print_addr (pc);
//printf ("{ <%04X,%02X>", w, b);
}
diff --git a/machine.c b/machine.c
index 2f1e9cd..4ba9af2 100644
--- a/machine.c
+++ b/machine.c
@@ -1,537 +1,538 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "machine.h"
+#include "6809.h"
#include "eon.h"
#define CONFIG_LEGACY
#define MISSING 0xff
#define mmu_device (device_table[0])
extern void eon_init (const char *);
extern void wpc_init (const char *);
struct machine *machine;
unsigned int device_count = 0;
struct hw_device *device_table[MAX_BUS_DEVICES];
struct bus_map busmaps[NUM_BUS_MAPS];
struct bus_map default_busmaps[NUM_BUS_MAPS];
U16 fault_addr;
U8 fault_type;
int system_running = 0;
void cpu_is_running (void)
{
system_running = 1;
}
/**
* Attach a new device to the bus. Only called during init.
*/
struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv)
{
struct hw_device *dev = malloc (sizeof (struct hw_device));
dev->class_ptr = class_ptr;
dev->devid = device_count;
dev->size = size;
dev->priv = priv;
device_table[device_count++] = dev;
/* Attach implies reset */
class_ptr->reset (dev);
return dev;
};
/**
* Map a portion of a device into the CPU's address space.
*/
void bus_map (unsigned int addr,
unsigned int devid,
unsigned long offset,
unsigned int len,
unsigned int flags)
{
struct bus_map *map;
unsigned int start, count;
/* Warn if trying to map too much */
if (addr + len > MAX_CPU_ADDR)
{
fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n",
len, addr);
}
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
offset = ((offset + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Initialize the maps. This will let the CPU access the device. */
map = &busmaps[start];
while (count > 0)
{
if (!(map->flags & MAP_FIXED))
{
map->devid = devid;
map->offset = offset;
map->flags = flags;
}
count--;
map++;
offset += BUS_MAP_SIZE;
}
}
void device_define (struct hw_device *dev,
unsigned long offset,
unsigned int addr,
unsigned int len,
unsigned int flags)
{
bus_map (addr, dev->devid, offset, len, flags);
}
void bus_unmap (unsigned int addr, unsigned int len)
{
struct bus_map *map;
unsigned int start, count;
/* Round address and length to be multiples of the map unit size. */
addr = ((addr + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
machine->fault (addr, FAULT_NO_RESPONSE);
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
* a caching scheme that cuts down on some of this...
* Also consider a native 16-bit read that doesn't require
* 2 separate calls here...
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return ((*class_ptr->read) (dev, phy_addr) << 8)
| (*class_ptr->read) (dev, phy_addr+1);
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
/* This can fail if the area is read-only */
if (system_running && (map->flags & MAP_READONLY))
machine->fault (addr, FAULT_NOT_WRITABLE);
else
(*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
0 /* device_table[map->devid]->size */);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
return 0;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
mmu_regs[page][2] & 0x1);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
mmu_write (dev, page * MMU_PAGEREGS + 2, 0);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
mmu_regs[page][2] = map->flags & 0x1;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
/* The disk drive is emulated as follows:
* The disk is capable of "bus-mastering" and is able to dump data directly
* into the RAM, without CPU-involvement. (The pages do not even need to
* be mapped.) A transaction is initiated with the following parameters:
*
* - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
* Thus there are 64 possible sector locations.
* - address of disk sector, given as a 16-bit value. This allows for up to
* a 32MB disk.
* - direction, either to disk or from disk.
*
* Emulation is synchronous with respect to the CPU.
*/
struct disk_priv
{
FILE *fp;
struct hw_device *dev;
unsigned long offset;
struct hw_device *ramdev;
unsigned int sectors;
char *ram;
};
U8 disk_read (struct hw_device *dev, unsigned long addr)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
}
void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
switch (addr)
{
case DSK_ADDR:
disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
break;
case DSK_SECTOR:
disk->offset = val; /* high byte */
diff --git a/machine.h b/machine.h
index 62576e8..6b7d55e 100644
--- a/machine.h
+++ b/machine.h
@@ -1,134 +1,138 @@
/*
* Copyright 2006, 2007, 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef M6809_MACHINE_H
#define M6809_MACHINE_H
/* This file defines structures used to build generic machines on a 6809. */
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned long absolute_address_t;
#define MAX_CPU_ADDR 65536
/* The generic bus architecture. */
/* Up to 32 devices may be connected. Each device is addressed by a 32-bit physical address */
#define MAX_BUS_DEVICES 32
#define INVALID_DEVID 0xff
/* Say whether or not the mapping is RO or RW. */
#define MAP_READWRITE 0x0
#define MAP_READONLY 0x1
/* A fixed map cannot be reprogrammed. Attempts to
bus_map something differently will silently be
ignored. */
#define MAP_FIXED 0x2
#define FAULT_NONE 0
#define FAULT_NOT_WRITABLE 1
#define FAULT_NO_RESPONSE 2
/* A bus map is assocated with part of the 6809 address space
and says what device and which part of it is mapped into that
area. It also has associated flags which say how it is allowed
to be accessed.
A single bus map defines 128 bytes of address space; for a 64KB CPU,
that requires a total of 512 such structures.
Note that the bus map need not correspond to the page size that can
be configured by the MMU. It allows for more granularity and is
needed in some *hardcoded* mapping cases. */
#define BUS_MAP_SIZE 128
struct bus_map
{
unsigned int devid; /* The devid mapped here */
unsigned long offset; /* The offset within the device */
unsigned char flags;
};
#define NUM_BUS_MAPS (MAX_CPU_ADDR / BUS_MAP_SIZE)
/* A hardware device structure exists for each physical device
in the machine */
struct hw_device;
/* A hardware class structure exists for each type of device.
It defines the operations that are allowed on that device.
For example, if there are multiple ROM chips, then there is
a single "ROM" class and multiple ROM device objects. */
struct hw_class
{
/* Nonzero if the device is readonly */
int readonly;
/* Resets the device */
void (*reset) (struct hw_device *dev);
/* Reads a byte at a given offset from the beginning of the device. */
U8 (*read) (struct hw_device *dev, unsigned long phy_addr);
/* Writes a byte at a given offset from the beginning of the device. */
void (*write) (struct hw_device *dev, unsigned long phy_addr, U8 val);
};
struct hw_device
{
/* A pointer to the class object. This says what kind of device it is. */
struct hw_class *class_ptr;
/* The device ID assigned to it. This is filled in automatically
by the simulator. */
unsigned int devid;
/* The total size of the device in bytes. */
unsigned long size;
/* The private pointer, which is interpreted differently for each type
(hw_class) of device. */
void *priv;
};
extern struct machine *machine;
struct machine
{
const char *name;
- void (*init) (char *boot_rom_file);
+ void (*init) (const char *boot_rom_file);
void (*fault) (unsigned int addr, unsigned char type);
void (*dump_thread) (unsigned int thread_id);
void (*periodic) (void);
};
+struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, void *priv);
+
struct hw_device *ram_create (unsigned long size);
struct hw_device *rom_create (const char *filename, unsigned int maxsize);
+struct hw_device *console_create (void);
+struct hw_device *disk_create (const char *backing_file);
#endif /* _M6809_MACHINE_H */
diff --git a/main.c b/main.c
index 5f93ea5..d8732d2 100644
--- a/main.c
+++ b/main.c
@@ -1,440 +1,442 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
unsigned long max_cycles = 500000000UL;
/* When nonzero, says that the state of the machine is persistent
across runs of the simulator. */
int machine_persistent = 0;
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
struct timeval time_started;
/**
* Return elapsed real time in milliseconds.
*/
long
time_diff (struct timeval *old, struct timeval *new)
{
long ms = (new->tv_usec - old->tv_usec) / 1000;
ms += (new->tv_sec - old->tv_sec) * 1000;
return ms;
}
long
get_elapsed_realtime (void)
{
struct timeval now;
gettimeofday (&now, NULL);
return time_diff (&time_started, &now);
}
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 30;
static int count = 30;
int delay;
static int total_ms_elapsed = 0;
static int cumulative_delay = 0;
if (--count > 0)
return;
if (last.tv_sec == 0 && last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = time_diff (&last, &now);
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
if (machine->periodic)
machine->periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
cumulative_delay += delay;
if (cumulative_delay > 0)
{
usleep (50 * 1000UL);
cumulative_delay -= 50;
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
+int do_help (const char *arg __attribute__((unused)));
+
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
- NO_NEG, NO_ARG, NULL, NULL, 0, do_help },
+ NO_NEG, NO_ARG, NULL, 0, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
{ 'R', "realtime", "Limit simulation speed to match realtime" },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
{ 'p', "persistent", "Use persistent machine state",
NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
return -1;
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
sim_exit (0x70);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
gettimeofday (&time_started, NULL);
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
total += cpu_execute (max_cycles ? max_cycles-1 : 500000);
}
else
{
total += cpu_execute (cycles_per_irq);
/* TODO - this assumes periodic interrupts (WPC) */
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
sim_exit (0);
return 0;
}
diff --git a/monitor.c b/monitor.c
index 5b0e01c..9f1d337 100644
--- a/monitor.c
+++ b/monitor.c
@@ -660,789 +660,789 @@ opcode_t codes11[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_swi3, _implied},
{_undoc, _illegal}, /* 11 40 */
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal}
};
char *reg[] = {
"D", "X", "Y", "U", "S", "PC", "??", "??",
"A", "B", "CC", "DP", "??", "??", "??", "??"
};
char index_reg[] = { 'X', 'Y', 'U', 'S' };
char *off4[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
"-16", "-15", "-14", "-13", "-12", "-11", "-10", "-9",
"-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1"
};
/* Disassemble the current instruction. Returns the number of bytes that
compose it. */
int
dasm (char *buf, absolute_address_t opc)
{
UINT8 op, am;
char *op_str;
absolute_address_t pc = opc;
char R;
int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */
op = fetch8 ();
if (op == 0x10)
{
op = fetch8 ();
am = codes10[op].mode;
op = codes10[op].code;
}
else if (op == 0x11)
{
op = fetch8 ();
am = codes11[op].mode;
op = codes11[op].code;
}
else
{
am = codes[op].mode;
op = codes[op].code;
}
op_str = (char *) mne[op];
buf += sprintf (buf, "%-6.6s", op_str);
switch (am)
{
case _illegal:
sprintf (buf, "???");
break;
case _implied:
break;
case _imm_byte:
sprintf (buf, "#$%02X", fetch8 ());
break;
case _imm_word:
sprintf (buf, "#$%04X", fetch16 ());
break;
case _direct:
sprintf (buf, "<%s", monitor_addr_name (fetch8 ()));
break;
case _extended:
sprintf (buf, "%s", monitor_addr_name (fetch16 ()));
break;
case _indexed:
op = fetch8 ();
R = index_reg[(op >> 5) & 0x3];
if ((op & 0x80) == 0)
{
sprintf (buf, "%s,%c", off4[op & 0x1f], R);
break;
}
switch (op & 0x1f)
{
case 0x00:
sprintf (buf, ",%c+", R);
break;
case 0x01:
sprintf (buf, ",%c++", R);
break;
case 0x02:
sprintf (buf, ",-%c", R);
break;
case 0x03:
sprintf (buf, ",--%c", R);
break;
case 0x04:
sprintf (buf, ",%c", R);
break;
case 0x05:
sprintf (buf, "B,%c", R);
break;
case 0x06:
sprintf (buf, "A,%c", R);
break;
case 0x08:
sprintf (buf, "$%02X,%c", fetch8 (), R);
break;
case 0x09:
sprintf (buf, "$%04X,%c", fetch16 (), R);
break;
case 0x0B:
sprintf (buf, "D,%c", R);
break;
case 0x0C:
sprintf (buf, "$%02X,PC", fetch8 ());
break;
case 0x0D:
sprintf (buf, "$%04X,PC", fetch16 ());
break;
case 0x11:
sprintf (buf, "[,%c++]", R);
break;
case 0x13:
sprintf (buf, "[,--%c]", R);
break;
case 0x14:
sprintf (buf, "[,%c]", R);
break;
case 0x15:
sprintf (buf, "[B,%c]", R);
break;
case 0x16:
sprintf (buf, "[A,%c]", R);
break;
case 0x18:
sprintf (buf, "[$%02X,%c]", fetch8 (), R);
break;
case 0x19:
sprintf (buf, "[$%04X,%c]", fetch16 (), R);
break;
case 0x1B:
sprintf (buf, "[D,%c]", R);
break;
case 0x1C:
sprintf (buf, "[$%02X,PC]", fetch8 ());
break;
case 0x1D:
sprintf (buf, "[$%04X,PC]", fetch16 ());
break;
case 0x1F:
sprintf (buf, "[%s]", monitor_addr_name (fetch16 ()));
break;
default:
sprintf (buf, "???");
break;
}
break;
case _rel_byte:
fetch1 = ((INT8) fetch8 ());
sprintf (buf, "%s", absolute_addr_name (fetch1 + pc));
break;
case _rel_word:
sprintf (buf, "%s", absolute_addr_name (fetch16 () + pc));
break;
case _reg_post:
op = fetch8 ();
sprintf (buf, "%s,%s", reg[op >> 4], reg[op & 15]);
break;
case _usr_post:
case _sys_post:
op = fetch8 ();
if (op & 0x80)
strcat (buf, "PC,");
if (op & 0x40)
strcat (buf, am == _usr_post ? "S," : "U,");
if (op & 0x20)
strcat (buf, "Y,");
if (op & 0x10)
strcat (buf, "X,");
if (op & 0x08)
strcat (buf, "DP,");
if ((op & 0x06) == 0x06)
strcat (buf, "D,");
else
{
if (op & 0x04)
strcat (buf, "B,");
if (op & 0x02)
strcat (buf, "A,");
}
if (op & 0x01)
strcat (buf, "CC,");
buf[strlen (buf) - 1] = '\0';
break;
}
return pc - opc;
}
int
sizeof_file (FILE * file)
{
int size;
fseek (file, 0, SEEK_END);
size = ftell (file);
rewind (file);
return size;
}
int
load_map_file (const char *name)
{
FILE *fp;
char map_filename[256];
char buf[256];
char *value_ptr, *id_ptr;
target_addr_t value;
char *file_ptr;
struct symbol *sym = NULL;
/* Try appending the suffix 'map' to the name of the program. */
sprintf (map_filename, "%s.map", name);
fp = file_open (NULL, map_filename, "r");
if (!fp)
{
/* If that fails, try replacing any existing suffix. */
sprintf (map_filename, "%s", name);
char *s = strrchr (map_filename, '.');
if (s)
{
sprintf (s+1, "map");
fp = file_open (NULL, map_filename, "r");
}
if (!fp)
{
fprintf (stderr, "warning: no symbols for %s\n", name);
return -1;
}
}
printf ("Reading symbols from '%s'...\n", map_filename);
for (;;)
{
fgets (buf, sizeof(buf)-1, fp);
if (feof (fp))
break;
value_ptr = buf;
if (!strncmp (value_ptr, "page", 4))
{
unsigned char page = strtoul (value_ptr+4, NULL, 10);
if (!strcmp (machine->name, "wpc"))
wpc_set_rom_page (page);
sym = NULL;
continue;
}
if (strncmp (value_ptr, " ", 6))
continue;
while (*value_ptr == ' ')
value_ptr++;
value = strtoul (value_ptr, &id_ptr, 16);
if (id_ptr == value_ptr)
continue;
while (*id_ptr == ' ')
id_ptr++;
id_ptr = strtok (id_ptr, " \t\n");
if (((*id_ptr == 'l') || (*id_ptr == 's')) && (id_ptr[1] == '_'))
continue;
++id_ptr;
file_ptr = strtok (NULL, " \t\n");
if (sym)
sym->ty.size = to_absolute (value) - sym->value;
sym = sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */
}
fclose (fp);
return 0;
}
int
-load_hex (char *name)
+load_hex (const char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open hex record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3)
{
printf ("line %d: invalid hex record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff) + type;
switch (type)
{
case 0:
for (; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid hex record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 1:
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid hex record checksum \n", line);
done = 0;
break;
case 2:
default:
printf ("line %d: not supported hex type %d.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
int
-load_s19 (char *name)
+load_s19 (const char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open S-record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) != 3)
{
printf ("line %d: invalid S record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff);
switch (type)
{
case 1:
for (count -= 3; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 9:
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
default:
printf ("line %d: S%d not supported.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
void
monitor_call (unsigned int flags)
{
#ifdef CALL_STACK
if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call++;
current_function_call->entry_point = get_pc ();
current_function_call->flags = flags;
}
#endif
#if 0
const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ()));
if (id)
{
// printf ("In %s now\n", id);
}
#endif
}
void
monitor_return (void)
{
#ifdef CALL_STACK
if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call--;
return;
}
while ((current_function_call->flags & FC_TAIL_CALL) &&
(current_function_call > fctab))
{
current_function_call--;
}
if (current_function_call > fctab)
current_function_call--;
#endif
}
const char *
absolute_addr_name (absolute_address_t addr)
{
static char buf[256], *bufptr;
const char *name;
bufptr = buf;
bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%-16.16s>", name);
return buf;
}
const char *
monitor_addr_name (target_addr_t target_addr)
{
static char buf[256], *bufptr;
const char *name;
absolute_address_t addr = to_absolute (target_addr);
bufptr = buf;
bufptr += sprintf (bufptr, "0x%04X", target_addr);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%s>", name);
return buf;
}
static void
monitor_signal (int sigtype)
{
(void) sigtype;
putchar ('\n');
monitor_on = 1;
}
void
monitor_init (void)
{
int tmp;
extern int debug_enabled;
target_addr_t a;
fctab[0].entry_point = read16 (0xfffe);
memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs));
current_function_call = &fctab[0];
auto_break_insn_count = 0;
monitor_on = debug_enabled;
signal (SIGINT, monitor_signal);
}
int
check_break (void)
{
if (dump_every_insn)
print_current_insn ();
if (auto_break_insn_count > 0)
if (--auto_break_insn_count == 0)
return 1;
return 0;
}
void
monitor_backtrace (void)
{
struct function_call *fc = current_function_call;
while (fc >= &fctab[0]) {
printf ("%s\n", monitor_addr_name (fc->entry_point));
fc--;
}
}
int
monitor6809 (void)
{
int rc;
signal (SIGINT, monitor_signal);
rc = command_loop ();
monitor_on = 0;
return rc;
}
diff --git a/wpc.c b/wpc.c
index f5b1bc5..0bc589c 100644
--- a/wpc.c
+++ b/wpc.c
@@ -140,620 +140,620 @@ struct wpc_asic
U16 shiftaddr;
U16 shiftbit;
U8 lamp_strobe;
U8 lamp_mx[8];
U8 sols[48];
U8 switch_strobe;
U8 switch_mx[10];
U8 opto_mx[10];
U8 dmd_maps[2];
unsigned int dmd_phase;
U8 dmd_visibles[3];
U8 dmd_last_visibles[3];
int curr_sw;
int curr_sw_time;
int wdog_timer;
} the_wpc;
struct wpc_asic *wpc = NULL;
int wpc_sock;
static int wpc_console_inited = 0;
static U8 wpc_get_console_state (void)
{
fd_set fds;
struct timeval timeout;
U8 rc = WPC_DEBUG_WRITE_READY;
if (!wpc_console_inited)
rc |= WPC_DEBUG_READ_READY;
#if 1
return rc;
#endif
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
rc |= WPC_DEBUG_READ_READY;
return rc;
}
static U8 wpc_console_read (void)
{
int rc;
U8 c = 0;
if (!wpc_console_inited)
{
wpc_console_inited = 1;
return 0;
}
rc = read (0, &c, 1);
return c;
}
static void wpc_console_write (U8 val)
{
putchar (val);
fflush (stdout);
}
static int scanbit (U8 val)
{
if (val & 0x80) return 7;
else if (val & 0x40) return 6;
else if (val & 0x20) return 5;
else if (val & 0x10) return 4;
else if (val & 0x08) return 3;
else if (val & 0x04) return 2;
else if (val & 0x02) return 1;
else if (val & 0x01) return 0;
else return -1;
}
unsigned int wpc_read_switch (int num)
{
unsigned int val;
val = wpc->switch_mx[num / 8] & (1 << (num % 8));
return val ? 1 : 0;
}
void wpc_write_switch (int num, int flag)
{
unsigned int col, val;
col = num / 8;
val = 1 << (num % 8);
#if 0
if (wpc->opto_mx[col] & val)
flag = !flag;
#endif
wpc->switch_mx[col] &= ~val;
if (flag)
wpc->switch_mx[col] |= val;
}
void wpc_press_switch (int num, int delay)
{
wpc_write_switch (num, 1);
wpc->curr_sw = num;
wpc->curr_sw_time = delay;
}
unsigned int wpc_read_switch_column (int col)
{
unsigned int val = 0;
int row;
for (row = 0; row < 8; row++)
if (wpc_read_switch (col * 8 + row))
val |= (1 << row);
return val;
}
void wpc_write_lamp (int num, int flag)
{
}
void wpc_write_sols (int first, U8 val)
{
int i;
for (i=0; i < 8; i++)
{
wpc->sols[first+i] = (val & (1 << i)) ? 1 : 0;
}
}
void wpc_dmd_set_visible (U8 val)
{
char *p;
struct wpc_message msg;
int rc;
int i, n;
static unsigned long last_firq_time = 0;
unsigned long now;
static int no_change_count = 0;
now = get_cycles ();
if (now - last_firq_time <= 1850 * 8)
{
//printf ("%02X ignored.\n", val);
return;
}
else if (now - last_firq_time >= 1850 * 8 * 5)
{
memset (wpc->dmd_visibles, val, 3);
wpc->dmd_phase = 0;
}
else
{
wpc->dmd_visibles[wpc->dmd_phase++] = val;
if (wpc->dmd_phase == 3)
wpc->dmd_phase = 0;
}
last_firq_time = now;
#if 0
printf ("%02X %f\n", val, get_cycles () / 1952.0);
#endif
if (!memcmp (wpc->dmd_visibles, wpc->dmd_last_visibles, 3)
&& (++no_change_count < 100))
return;
no_change_count = 0;
#if 0
printf ("%02X %02X %02X\n",
wpc->dmd_visibles[0],
wpc->dmd_visibles[1],
wpc->dmd_visibles[2]);
#endif
memcpy (wpc->dmd_last_visibles, wpc->dmd_visibles, 3);
/* Send updated page contents */
wpc_msg_init (CODE_DMD_PAGE, &msg);
for (i=0; i < 3; i++)
{
p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512;
msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i];
memcpy (&msg.u.dmdpage.phases[i].data, p, 512);
}
msg.len = sizeof (struct _dmdpage_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
/* Send status of which pages are visible now */
wpc_msg_init (CODE_DMD_VISIBLE, &msg);
for (i=0; i < 3; i++)
msg.u.dmdvisible.phases[i] = wpc->dmd_visibles[i];
msg.len = sizeof (struct _dmdvisible_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
}
void wpc_keypoll (void)
{
fd_set fds;
struct timeval timeout;
int rc;
unsigned char c;
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
{
rc = read (0, &c, 1);
#define BUTTON_DURATION 200
switch (c)
{
case '7':
wpc_press_switch (4, BUTTON_DURATION);
break;
case '8':
wpc_press_switch (5, BUTTON_DURATION);
break;
case '9':
wpc_press_switch (6, BUTTON_DURATION);
break;
case '0':
wpc_press_switch (7, BUTTON_DURATION);
break;
case ',':
wpc_press_switch (75, BUTTON_DURATION);
break;
case '.':
wpc_press_switch (73, BUTTON_DURATION);
break;
default:
printf ("wpc: invalid character '%c'\n", c);
break;
}
}
}
U8 wpc_asic_read (struct hw_device *dev, unsigned long addr)
{
U8 val;
switch (addr + WPC_ASIC_BASE)
{
case WPC_LEDS:
val = wpc->led;
break;
case WPC_ROM_BANK:
val = wpc->rombank;
break;
case WPC_DEBUG_CONTROL_PORT:
val = wpc_get_console_state ();
break;
case WPC_DEBUG_DATA_PORT:
val = wpc_console_read ();
break;
case WPC_SHIFTADDR:
val = wpc->shiftaddr >> 8;
break;
case WPC_SHIFTADDR+1:
val = (wpc->shiftaddr & 0xFF) + (wpc->shiftbit / 8);
break;
case WPC_SHIFTBIT:
val = 1 << (wpc->shiftbit % 8);
break;
case WPC_SW_ROW_INPUT:
{
/* Handle WPC and WPC-S machines differently */
if (wpc->switch_strobe >= 0x16 && wpc->switch_strobe <= 0x1F)
val = wpc_read_switch_column (wpc->switch_strobe - 0x16 + 1);
else
val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
break;
}
case WPC_SW_JUMPER_INPUT:
val = 0x55;
break;
case WPC_SW_CABINET_INPUT:
val = wpc_read_switch_column (0);
break;
case WPC_FLIPTRONIC_PORT_A:
case WPC_FLIPTRONIC_PORT_B:
case WPC95_FLIPPER_SWITCH_INPUT:
val = wpc_read_switch_column (9);
break;
default:
val = 0;
break;
}
//printf (">>> ASIC read %04X -> %02X\n", addr + WPC_ASIC_BASE, val);
return val;
}
/**
* Enforce the current read-only area of RAM.
*/
void wpc_update_ram (void)
{
unsigned int size_writable = WPC_RAM_SIZE;
if (!wpc->ram_unlocked)
{
switch (wpc->ram_lock_size)
{
default:
break;
case 0xF:
size_writable -= 256;
break;
case 0x7:
size_writable -= 512;
case 0x3:
size_writable -= 1024;
break;
case 0x1:
size_writable -= 2048;
break;
case 0:
size_writable -= 4096;
break;
}
}
bus_map (WPC_RAM_BASE, wpc->ram_dev->devid, 0, size_writable, MAP_READWRITE);
if (size_writable < WPC_RAM_SIZE)
bus_map (WPC_RAM_BASE + size_writable, wpc->ram_dev->devid, size_writable,
WPC_RAM_SIZE - size_writable, MAP_READONLY);
}
void wpc_set_rom_page (unsigned char val)
{
bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READONLY);
}
void wpc_set_dmd_page (unsigned int map, unsigned char val)
{
wpc->dmd_maps[map] = val;
bus_map (0x3800 + map * 0x200, 3, val * 0x200, 0x200, MAP_READWRITE);
}
void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr + WPC_ASIC_BASE)
{
case WPC_DMD_LOW_PAGE:
wpc_set_dmd_page (0, val);
break;
case WPC_DMD_HIGH_PAGE:
wpc_set_dmd_page (1, val);
break;
case WPC_DMD_FIRQ_ROW_VALUE:
break;
case WPC_DMD_ACTIVE_PAGE:
wpc_dmd_set_visible (val);
break;
case WPC_LEDS:
wpc->led = val;
break;
case WPC_ZEROCROSS_IRQ_CLEAR:
wpc->wdog_timer++;
break;
case WPC_ROM_BANK:
wpc->rombank = val;
wpc_set_rom_page (val);
break;
case WPC_DEBUG_DATA_PORT:
wpc_console_write (val);
break;
case WPC_RAM_LOCK:
wpc->ram_unlocked = val;
wpc_update_ram ();
break;
case WPC_RAM_LOCKSIZE:
wpc->ram_lock_size = val;
wpc_update_ram ();
break;
case WPC_SHIFTADDR:
wpc->shiftaddr &= 0x00FF;
wpc->shiftaddr |= val << 8;
break;
case WPC_SHIFTADDR+1:
wpc->shiftaddr &= 0xFF00;
wpc->shiftaddr |= val;
break;
case WPC_SHIFTBIT:
wpc->shiftbit = val;
break;
case WPC_LAMP_ROW_OUTPUT:
wpc->lamp_mx[scanbit (wpc->lamp_strobe)] = val;
break;
case WPC_LAMP_COL_STROBE:
wpc->lamp_strobe = val;
break;
case WPC_SW_COL_STROBE:
wpc->switch_strobe = val;
break;
case WPC_SOL_FLASH2_OUTPUT:
case WPC_SOL_HIGHPOWER_OUTPUT:
case WPC_SOL_FLASH1_OUTPUT:
case WPC_SOL_LOWPOWER_OUTPUT:
if (val != 0)
printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
break;
default:
break;
}
//printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
}
void wpc_periodic (void)
{
wpc_keypoll ();
wpc->wdog_timer -= 50;
if (wpc->wdog_timer <= 0)
{
}
if (wpc->curr_sw_time > 0)
{
wpc->curr_sw_time -= 100;
if (wpc->curr_sw_time <= 0)
{
wpc->curr_sw_time = 0;
wpc_write_switch (wpc->curr_sw, 0);
}
}
}
void wpc_asic_reset (struct hw_device *dev)
{
memset (wpc, 0, sizeof (struct wpc_asic));
wpc_write_switch (19, 1); /* Always Closed */
}
struct hw_class wpc_asic_class =
{
.reset = wpc_asic_reset,
.read = wpc_asic_read,
.write = wpc_asic_write,
};
struct hw_device *wpc_asic_create (void)
{
if (wpc)
{
fprintf (stderr, "WPC ASIC already created\n");
return NULL;
}
wpc = &the_wpc;
return device_attach (&wpc_asic_class, 0x800, wpc);
}
void wpc_fault (unsigned int addr, unsigned char type)
{
}
-void wpc_dump_thread (unsigned long addr)
+void wpc_dump_thread (unsigned int thread_id)
{
}
void io_sym_add (const char *name, unsigned long cpuaddr)
{
sym_add (&program_symtab, name, to_absolute (cpuaddr), 0);
}
#define IO_SYM_ADD(name) io_sym_add (#name, name)
void wpc_init (const char *boot_rom_file)
{
struct hw_device *dev;
int rc;
struct sockaddr_in myaddr;
device_define ( dev = wpc_asic_create (), 0,
WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE);
device_define ( dev = ram_create (WPC_RAM_SIZE), 0,
WPC_RAM_BASE, WPC_RAM_SIZE, MAP_READWRITE );
wpc->ram_dev = dev;
dev = rom_create (boot_rom_file, WPC_ROM_SIZE);
device_define ( dev, 0,
WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READONLY);
device_define ( dev, WPC_ROM_SIZE - WPC_FIXED_SIZE,
WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READONLY);
wpc->rom_dev = dev;
device_define ( dev = ram_create (16 * 512), 0,
0x3800, 0x200 * 2, MAP_READWRITE );
wpc->dmd_dev = dev;
wpc_update_ram ();
wpc_sock = udp_socket_create (9000);
if (wpc_sock < 0)
fprintf (stderr, "could not open output socket\n");
IO_SYM_ADD(WPC_DMD_LOW_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_PAGE);
IO_SYM_ADD(WPC_DMD_FIRQ_ROW_VALUE);
IO_SYM_ADD(WPC_DMD_LOW_PAGE);
IO_SYM_ADD(WPC_DMD_ACTIVE_PAGE);
IO_SYM_ADD(WPC_SERIAL_STATUS_PORT);
IO_SYM_ADD(WPC_PARALLEL_DATA_PORT);
IO_SYM_ADD(WPC_PARALLEL_STROBE_PORT);
IO_SYM_ADD(WPC_SERIAL_DATA_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_CONTROL_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_BAUD_SELECT);
IO_SYM_ADD(WPC_TICKET_DISPENSE);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_OUT);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_IN);
IO_SYM_ADD(WPC_DCS_SOUND_RESET);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_READY);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_A);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_B);
IO_SYM_ADD(WPCS_DATA);
IO_SYM_ADD(WPCS_CONTROL_STATUS);
IO_SYM_ADD(WPC_SOL_FLASH2_OUTPUT);
IO_SYM_ADD(WPC_SOL_HIGHPOWER_OUTPUT);
IO_SYM_ADD(WPC_SOL_FLASH1_OUTPUT);
IO_SYM_ADD(WPC_SOL_LOWPOWER_OUTPUT);
IO_SYM_ADD(WPC_LAMP_ROW_OUTPUT);
IO_SYM_ADD(WPC_LAMP_COL_STROBE);
IO_SYM_ADD(WPC_GI_TRIAC);
IO_SYM_ADD(WPC_SW_JUMPER_INPUT);
IO_SYM_ADD(WPC_SW_CABINET_INPUT);
IO_SYM_ADD(WPC_SW_ROW_INPUT);
IO_SYM_ADD(WPC_SW_COL_STROBE);
IO_SYM_ADD(WPC_LEDS);
IO_SYM_ADD(WPC_RAM_BANK);
IO_SYM_ADD(WPC_SHIFTADDR);
IO_SYM_ADD(WPC_SHIFTBIT);
IO_SYM_ADD(WPC_SHIFTBIT2);
IO_SYM_ADD(WPC_PERIPHERAL_TIMER_FIRQ_CLEAR);
IO_SYM_ADD(WPC_ROM_LOCK);
IO_SYM_ADD(WPC_CLK_HOURS_DAYS);
IO_SYM_ADD(WPC_CLK_MINS);
IO_SYM_ADD(WPC_ROM_BANK);
IO_SYM_ADD(WPC_RAM_LOCK);
IO_SYM_ADD(WPC_RAM_LOCKSIZE);
}
struct machine wpc_machine =
{
.name = "wpc",
.fault = wpc_fault,
.init = wpc_init,
.dump_thread = wpc_dump_thread,
.periodic = wpc_periodic,
};
struct machine wpc95_machine =
{
.name = "wpc95",
.fault = wpc_fault,
.init = wpc_init,
.dump_thread = wpc_dump_thread,
.periodic = wpc_periodic,
};
|
bcd/exec09
|
0819dcdc8ed304877af1d9d5d9275830836a01b1
|
Add verbose info on the EON architecture.
|
diff --git a/eon.h b/eon.h
index 548bda0..c470b7b 100644
--- a/eon.h
+++ b/eon.h
@@ -1,92 +1,130 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MACHINE_EON_H
#define _MACHINE_EON_H
+/* This file defines the characteristics of the EON machine architecture.
+EON is a little more advanced than the 'simple' architecture that runs by
+default, and can be used to run more sophiscated programs for the 6809.
+However, no actual hardware resembling this exists.
+
+The computer has a total of 1MB of RAM, which is mapped to logical address
+0x0000. As the 6809 only has 64KB addressable at a time, some bank
+switching is required. The address space is defined into 16, 4KB pages.
+The pages from 0xE000-0xFFFF are special, though, and allow access to
+I/O and a read-only boot ROM. Thus, pages 0-13 can be mapped to any
+of the 1MB RAM, page 14 has all of the I/O registers and some of the boot
+ROM, and page 15 has the remaining boot ROM, including interrupt vectors.
+The boot ROM file to use is specified as a command-line option to the
+emulator.
+
+Each I/O device comprises 128 bytes of address space. There can be up
+to a maximum of 8 devices defined this way. The "device ID" is just the
+offset from the beginning of the I/O region. At present, 5 devices are
+defined:
+
+Device 0 - the MMU. This provides registers for reprogramming the paging
+hardware.
+
+Device 1 - the power manager. This is not yet implemented.
+
+Device 2 - the console. This has the basic stdin/stdout, akin to a serial
+port.
+
+Device 3 - the display. Not implemented yet, this would be akin to a
+graphical interface.
+
+Device 4 - the disk drive. See machine.c for a full description of how the
+disk works. EON simulates the disk using a file named 'disk.bin', so its
+contents are actually persistent. Disk transfers conceptually DMA to/from
+RAM in 512-byte chunks. The maximum disk size is 32MB (16-bit sector numbers).
+
+*/
+
/* RAM */
#define RAM_SIZE 0x100000
/* I/O regions (1KB) */
#define BOOT_IO_ADDR 0xE000
#define DEVICE_BASE(n) (BOOT_IO_ADDR + (BUS_MAP_SIZE * (n)))
/* The MMU */
#define MMU_DEVID 0
#define MMU_ADDR DEVICE_BASE(MMU_DEVID)
#define MMU_PAGESIZE 4096
#define MMU_PAGECOUNT (MAX_CPU_ADDR / MMU_PAGESIZE)
#define MMU_PAGEREGS 4
/* device select */
#define MMU_DEV(p) (MMU_ADDR + (p * MMU_PAGEREGS) + 0)
/* 4KB region to map in */
#define MMU_OFF(p) (MMU_ADDR + (p * MMU_PAGEREGS) + 1)
/* permissions */
#define MMU_FLG(p) (MMU_ADDR + (p * MMU_PAGEREGS) + 2)
#define MMU_FAULT_ADDR (MMU_ADDR + 0x60)
#define MMU_FAULT_TYPE (MMU_ADDR + 0x62)
/* The Power Manager */
#define POWERMGR_DEVID 1
#define POWERMGR_ADDR DEVICE_BASE(POWERMGR_DEVID)
#define POWER_CTRL (POWERMGR_ADDR + 0)
#define POWER_RESET_REG (POWERMGMT_ADDR + 1)
/* The Console */
#define CONSOLE_DEVID 2
#define CONSOLE_ADDR DEVICE_BASE(CONSOLE_DEVID)
#define CONSOLE_OUT (CONSOLE_ADDR + 0)
#define LEGACY_EXIT (CONSOLE_ADDR + 1)
#define CONSOLE_IN (CONSOLE_ADDR + 2)
#define CON_OUT 0
#define CON_EXIT 1
#define CON_IN 2
/* The Display */
#define DISPLAY_DEVID 3
#define DISPLAY_ADDR DEVICE_BASE(DISPLAY_DEVID)
/* The Disk Drive */
#define DISK0_DEVID 4
#define DISK_ADDR(n) DEVICE_BASE(DISK0_DEVID + (n))
#define DISK_SECTOR_COUNT 65536
#define SECTOR_SIZE 512
#define DSK_CTRL 0
#define DSK_READ 0x1
#define DSK_WRITE 0x2
#define DSK_FLUSH 0x4
#define DSK_ERASE 0x8
#define DSK_ADDR 1
#define DSK_SECTOR 2 /* and 3 */
/* Boot ROM region (7KB) */
#define BOOT_ROM_ADDR 0xE400
#define BOOT_ROM_SIZE 0x1C00
#endif /* _MACHINE_EON_H */
|
bcd/exec09
|
41dcb994024b40d6c38966db2c2a0bea10968dad
|
Fix bug where the WPC periodic function was invoked when an interrupt happened on any of the other machine types as well.
|
diff --git a/eon.c b/eon.c
index 08c5168..a49422b 100644
--- a/eon.c
+++ b/eon.c
@@ -1,79 +1,81 @@
#include "machine.h"
#include "eon.h"
extern int system_running;
void eon_fault (unsigned int addr, unsigned char type)
{
if (system_running)
{
sim_error (">>> Page fault: addr=%04X type=%02X PC=%04X\n", addr, type, get_pc ());
#if 0
fault_addr = addr;
fault_type = type;
irq ();
#endif
}
}
/**
* Initialize the EON machine.
*/
void eon_init (const char *boot_rom_file)
{
struct hw_device *dev;
/* The MMU must be defined first, as all other devices
that are attached can try to hook into the MMU. */
device_define ( mmu_create (), 0,
MMU_ADDR, BUS_MAP_SIZE, MAP_READWRITE+MAP_FIXED );
/* A 1MB RAM part is mapped into all of the allowable 64KB
address space, until overriden by other devices. */
device_define ( ram_create (RAM_SIZE), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( rom_create (boot_rom_file, BOOT_ROM_SIZE), 0,
BOOT_ROM_ADDR, BOOT_ROM_SIZE, MAP_READONLY );
device_define ( dev = console_create (), 0,
CONSOLE_ADDR, BUS_MAP_SIZE, MAP_READWRITE );
device_define (dev, 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
device_define ( disk_create ("disk.bin"), 0,
DISK_ADDR(0), BUS_MAP_SIZE, MAP_READWRITE);
}
/**
* Initialize the simple machine, which is the default
* machine that has no bells or whistles.
*/
void simple_init (const char *boot_rom_file)
{
device_define ( ram_create (MAX_CPU_ADDR), 0,
0x0000, MAX_CPU_ADDR, MAP_READWRITE );
device_define ( console_create (), 0,
0xFF00, BUS_MAP_SIZE, MAP_READWRITE );
}
struct machine eon_machine =
{
.name = "eon",
.fault = eon_fault,
.init = eon_init,
+ .periodic = 0,
};
struct machine simple_machine =
{
.name = "simple",
.fault = eon_fault,
.init = simple_init,
+ .periodic = 0,
};
diff --git a/machine.h b/machine.h
index edbd643..62576e8 100644
--- a/machine.h
+++ b/machine.h
@@ -1,133 +1,134 @@
/*
* Copyright 2006, 2007, 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef M6809_MACHINE_H
#define M6809_MACHINE_H
/* This file defines structures used to build generic machines on a 6809. */
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned long absolute_address_t;
#define MAX_CPU_ADDR 65536
/* The generic bus architecture. */
/* Up to 32 devices may be connected. Each device is addressed by a 32-bit physical address */
#define MAX_BUS_DEVICES 32
#define INVALID_DEVID 0xff
/* Say whether or not the mapping is RO or RW. */
#define MAP_READWRITE 0x0
#define MAP_READONLY 0x1
/* A fixed map cannot be reprogrammed. Attempts to
bus_map something differently will silently be
ignored. */
#define MAP_FIXED 0x2
#define FAULT_NONE 0
#define FAULT_NOT_WRITABLE 1
#define FAULT_NO_RESPONSE 2
/* A bus map is assocated with part of the 6809 address space
and says what device and which part of it is mapped into that
area. It also has associated flags which say how it is allowed
to be accessed.
A single bus map defines 128 bytes of address space; for a 64KB CPU,
that requires a total of 512 such structures.
Note that the bus map need not correspond to the page size that can
be configured by the MMU. It allows for more granularity and is
needed in some *hardcoded* mapping cases. */
#define BUS_MAP_SIZE 128
struct bus_map
{
unsigned int devid; /* The devid mapped here */
unsigned long offset; /* The offset within the device */
unsigned char flags;
};
#define NUM_BUS_MAPS (MAX_CPU_ADDR / BUS_MAP_SIZE)
/* A hardware device structure exists for each physical device
in the machine */
struct hw_device;
/* A hardware class structure exists for each type of device.
It defines the operations that are allowed on that device.
For example, if there are multiple ROM chips, then there is
a single "ROM" class and multiple ROM device objects. */
struct hw_class
{
/* Nonzero if the device is readonly */
int readonly;
/* Resets the device */
void (*reset) (struct hw_device *dev);
/* Reads a byte at a given offset from the beginning of the device. */
U8 (*read) (struct hw_device *dev, unsigned long phy_addr);
/* Writes a byte at a given offset from the beginning of the device. */
void (*write) (struct hw_device *dev, unsigned long phy_addr, U8 val);
};
struct hw_device
{
/* A pointer to the class object. This says what kind of device it is. */
struct hw_class *class_ptr;
/* The device ID assigned to it. This is filled in automatically
by the simulator. */
unsigned int devid;
/* The total size of the device in bytes. */
unsigned long size;
/* The private pointer, which is interpreted differently for each type
(hw_class) of device. */
void *priv;
};
extern struct machine *machine;
struct machine
{
const char *name;
void (*init) (char *boot_rom_file);
void (*fault) (unsigned int addr, unsigned char type);
void (*dump_thread) (unsigned int thread_id);
+ void (*periodic) (void);
};
struct hw_device *ram_create (unsigned long size);
struct hw_device *rom_create (const char *filename, unsigned int maxsize);
#endif /* _M6809_MACHINE_H */
diff --git a/main.c b/main.c
index 3ea7a5b..5f93ea5 100644
--- a/main.c
+++ b/main.c
@@ -1,438 +1,440 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
unsigned long max_cycles = 500000000UL;
/* When nonzero, says that the state of the machine is persistent
across runs of the simulator. */
int machine_persistent = 0;
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
struct timeval time_started;
/**
* Return elapsed real time in milliseconds.
*/
long
time_diff (struct timeval *old, struct timeval *new)
{
long ms = (new->tv_usec - old->tv_usec) / 1000;
ms += (new->tv_sec - old->tv_sec) * 1000;
return ms;
}
long
get_elapsed_realtime (void)
{
struct timeval now;
gettimeofday (&now, NULL);
return time_diff (&time_started, &now);
}
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 30;
static int count = 30;
int delay;
static int total_ms_elapsed = 0;
static int cumulative_delay = 0;
if (--count > 0)
return;
if (last.tv_sec == 0 && last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = time_diff (&last, &now);
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
- wpc_periodic ();
+ if (machine->periodic)
+ machine->periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
cumulative_delay += delay;
if (cumulative_delay > 0)
{
usleep (50 * 1000UL);
cumulative_delay -= 50;
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
NO_NEG, NO_ARG, NULL, NULL, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
{ 'R', "realtime", "Limit simulation speed to match realtime" },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
{ 'p', "persistent", "Use persistent machine state",
NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
return -1;
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
sim_exit (0x70);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
gettimeofday (&time_started, NULL);
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
total += cpu_execute (max_cycles ? max_cycles-1 : 500000);
}
else
{
total += cpu_execute (cycles_per_irq);
+ /* TODO - this assumes periodic interrupts (WPC) */
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
sim_exit (0);
return 0;
}
diff --git a/wpc.c b/wpc.c
index 2cccf62..f5b1bc5 100644
--- a/wpc.c
+++ b/wpc.c
@@ -235,523 +235,525 @@ unsigned int wpc_read_switch (int num)
void wpc_write_switch (int num, int flag)
{
unsigned int col, val;
col = num / 8;
val = 1 << (num % 8);
#if 0
if (wpc->opto_mx[col] & val)
flag = !flag;
#endif
wpc->switch_mx[col] &= ~val;
if (flag)
wpc->switch_mx[col] |= val;
}
void wpc_press_switch (int num, int delay)
{
wpc_write_switch (num, 1);
wpc->curr_sw = num;
wpc->curr_sw_time = delay;
}
unsigned int wpc_read_switch_column (int col)
{
unsigned int val = 0;
int row;
for (row = 0; row < 8; row++)
if (wpc_read_switch (col * 8 + row))
val |= (1 << row);
return val;
}
void wpc_write_lamp (int num, int flag)
{
}
void wpc_write_sols (int first, U8 val)
{
int i;
for (i=0; i < 8; i++)
{
wpc->sols[first+i] = (val & (1 << i)) ? 1 : 0;
}
}
void wpc_dmd_set_visible (U8 val)
{
char *p;
struct wpc_message msg;
int rc;
int i, n;
static unsigned long last_firq_time = 0;
unsigned long now;
static int no_change_count = 0;
now = get_cycles ();
if (now - last_firq_time <= 1850 * 8)
{
//printf ("%02X ignored.\n", val);
return;
}
else if (now - last_firq_time >= 1850 * 8 * 5)
{
memset (wpc->dmd_visibles, val, 3);
wpc->dmd_phase = 0;
}
else
{
wpc->dmd_visibles[wpc->dmd_phase++] = val;
if (wpc->dmd_phase == 3)
wpc->dmd_phase = 0;
}
last_firq_time = now;
#if 0
printf ("%02X %f\n", val, get_cycles () / 1952.0);
#endif
if (!memcmp (wpc->dmd_visibles, wpc->dmd_last_visibles, 3)
&& (++no_change_count < 100))
return;
no_change_count = 0;
#if 0
printf ("%02X %02X %02X\n",
wpc->dmd_visibles[0],
wpc->dmd_visibles[1],
wpc->dmd_visibles[2]);
#endif
memcpy (wpc->dmd_last_visibles, wpc->dmd_visibles, 3);
/* Send updated page contents */
wpc_msg_init (CODE_DMD_PAGE, &msg);
for (i=0; i < 3; i++)
{
p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512;
msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i];
memcpy (&msg.u.dmdpage.phases[i].data, p, 512);
}
msg.len = sizeof (struct _dmdpage_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
/* Send status of which pages are visible now */
wpc_msg_init (CODE_DMD_VISIBLE, &msg);
for (i=0; i < 3; i++)
msg.u.dmdvisible.phases[i] = wpc->dmd_visibles[i];
msg.len = sizeof (struct _dmdvisible_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
}
void wpc_keypoll (void)
{
fd_set fds;
struct timeval timeout;
int rc;
unsigned char c;
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
{
rc = read (0, &c, 1);
#define BUTTON_DURATION 200
switch (c)
{
case '7':
wpc_press_switch (4, BUTTON_DURATION);
break;
case '8':
wpc_press_switch (5, BUTTON_DURATION);
break;
case '9':
wpc_press_switch (6, BUTTON_DURATION);
break;
case '0':
wpc_press_switch (7, BUTTON_DURATION);
break;
case ',':
wpc_press_switch (75, BUTTON_DURATION);
break;
case '.':
wpc_press_switch (73, BUTTON_DURATION);
break;
default:
printf ("wpc: invalid character '%c'\n", c);
break;
}
}
}
U8 wpc_asic_read (struct hw_device *dev, unsigned long addr)
{
U8 val;
switch (addr + WPC_ASIC_BASE)
{
case WPC_LEDS:
val = wpc->led;
break;
case WPC_ROM_BANK:
val = wpc->rombank;
break;
case WPC_DEBUG_CONTROL_PORT:
val = wpc_get_console_state ();
break;
case WPC_DEBUG_DATA_PORT:
val = wpc_console_read ();
break;
case WPC_SHIFTADDR:
val = wpc->shiftaddr >> 8;
break;
case WPC_SHIFTADDR+1:
val = (wpc->shiftaddr & 0xFF) + (wpc->shiftbit / 8);
break;
case WPC_SHIFTBIT:
val = 1 << (wpc->shiftbit % 8);
break;
case WPC_SW_ROW_INPUT:
{
/* Handle WPC and WPC-S machines differently */
if (wpc->switch_strobe >= 0x16 && wpc->switch_strobe <= 0x1F)
val = wpc_read_switch_column (wpc->switch_strobe - 0x16 + 1);
else
val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
break;
}
case WPC_SW_JUMPER_INPUT:
val = 0x55;
break;
case WPC_SW_CABINET_INPUT:
val = wpc_read_switch_column (0);
break;
case WPC_FLIPTRONIC_PORT_A:
case WPC_FLIPTRONIC_PORT_B:
case WPC95_FLIPPER_SWITCH_INPUT:
val = wpc_read_switch_column (9);
break;
default:
val = 0;
break;
}
//printf (">>> ASIC read %04X -> %02X\n", addr + WPC_ASIC_BASE, val);
return val;
}
/**
* Enforce the current read-only area of RAM.
*/
void wpc_update_ram (void)
{
unsigned int size_writable = WPC_RAM_SIZE;
if (!wpc->ram_unlocked)
{
switch (wpc->ram_lock_size)
{
default:
break;
case 0xF:
size_writable -= 256;
break;
case 0x7:
size_writable -= 512;
case 0x3:
size_writable -= 1024;
break;
case 0x1:
size_writable -= 2048;
break;
case 0:
size_writable -= 4096;
break;
}
}
bus_map (WPC_RAM_BASE, wpc->ram_dev->devid, 0, size_writable, MAP_READWRITE);
if (size_writable < WPC_RAM_SIZE)
bus_map (WPC_RAM_BASE + size_writable, wpc->ram_dev->devid, size_writable,
WPC_RAM_SIZE - size_writable, MAP_READONLY);
}
void wpc_set_rom_page (unsigned char val)
{
bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READONLY);
}
void wpc_set_dmd_page (unsigned int map, unsigned char val)
{
wpc->dmd_maps[map] = val;
bus_map (0x3800 + map * 0x200, 3, val * 0x200, 0x200, MAP_READWRITE);
}
void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr + WPC_ASIC_BASE)
{
case WPC_DMD_LOW_PAGE:
wpc_set_dmd_page (0, val);
break;
case WPC_DMD_HIGH_PAGE:
wpc_set_dmd_page (1, val);
break;
case WPC_DMD_FIRQ_ROW_VALUE:
break;
case WPC_DMD_ACTIVE_PAGE:
wpc_dmd_set_visible (val);
break;
case WPC_LEDS:
wpc->led = val;
break;
case WPC_ZEROCROSS_IRQ_CLEAR:
wpc->wdog_timer++;
break;
case WPC_ROM_BANK:
wpc->rombank = val;
wpc_set_rom_page (val);
break;
case WPC_DEBUG_DATA_PORT:
wpc_console_write (val);
break;
case WPC_RAM_LOCK:
wpc->ram_unlocked = val;
wpc_update_ram ();
break;
case WPC_RAM_LOCKSIZE:
wpc->ram_lock_size = val;
wpc_update_ram ();
break;
case WPC_SHIFTADDR:
wpc->shiftaddr &= 0x00FF;
wpc->shiftaddr |= val << 8;
break;
case WPC_SHIFTADDR+1:
wpc->shiftaddr &= 0xFF00;
wpc->shiftaddr |= val;
break;
case WPC_SHIFTBIT:
wpc->shiftbit = val;
break;
case WPC_LAMP_ROW_OUTPUT:
wpc->lamp_mx[scanbit (wpc->lamp_strobe)] = val;
break;
case WPC_LAMP_COL_STROBE:
wpc->lamp_strobe = val;
break;
case WPC_SW_COL_STROBE:
wpc->switch_strobe = val;
break;
case WPC_SOL_FLASH2_OUTPUT:
case WPC_SOL_HIGHPOWER_OUTPUT:
case WPC_SOL_FLASH1_OUTPUT:
case WPC_SOL_LOWPOWER_OUTPUT:
if (val != 0)
printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
break;
default:
break;
}
//printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
}
void wpc_periodic (void)
{
wpc_keypoll ();
wpc->wdog_timer -= 50;
if (wpc->wdog_timer <= 0)
{
}
if (wpc->curr_sw_time > 0)
{
wpc->curr_sw_time -= 100;
if (wpc->curr_sw_time <= 0)
{
wpc->curr_sw_time = 0;
wpc_write_switch (wpc->curr_sw, 0);
}
}
}
void wpc_asic_reset (struct hw_device *dev)
{
memset (wpc, 0, sizeof (struct wpc_asic));
wpc_write_switch (19, 1); /* Always Closed */
}
struct hw_class wpc_asic_class =
{
.reset = wpc_asic_reset,
.read = wpc_asic_read,
.write = wpc_asic_write,
};
struct hw_device *wpc_asic_create (void)
{
if (wpc)
{
fprintf (stderr, "WPC ASIC already created\n");
return NULL;
}
wpc = &the_wpc;
return device_attach (&wpc_asic_class, 0x800, wpc);
}
void wpc_fault (unsigned int addr, unsigned char type)
{
}
void wpc_dump_thread (unsigned long addr)
{
}
void io_sym_add (const char *name, unsigned long cpuaddr)
{
sym_add (&program_symtab, name, to_absolute (cpuaddr), 0);
}
#define IO_SYM_ADD(name) io_sym_add (#name, name)
void wpc_init (const char *boot_rom_file)
{
struct hw_device *dev;
int rc;
struct sockaddr_in myaddr;
device_define ( dev = wpc_asic_create (), 0,
WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE);
device_define ( dev = ram_create (WPC_RAM_SIZE), 0,
WPC_RAM_BASE, WPC_RAM_SIZE, MAP_READWRITE );
wpc->ram_dev = dev;
dev = rom_create (boot_rom_file, WPC_ROM_SIZE);
device_define ( dev, 0,
WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READONLY);
device_define ( dev, WPC_ROM_SIZE - WPC_FIXED_SIZE,
WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READONLY);
wpc->rom_dev = dev;
device_define ( dev = ram_create (16 * 512), 0,
0x3800, 0x200 * 2, MAP_READWRITE );
wpc->dmd_dev = dev;
wpc_update_ram ();
wpc_sock = udp_socket_create (9000);
if (wpc_sock < 0)
fprintf (stderr, "could not open output socket\n");
IO_SYM_ADD(WPC_DMD_LOW_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_PAGE);
IO_SYM_ADD(WPC_DMD_FIRQ_ROW_VALUE);
IO_SYM_ADD(WPC_DMD_LOW_PAGE);
IO_SYM_ADD(WPC_DMD_ACTIVE_PAGE);
IO_SYM_ADD(WPC_SERIAL_STATUS_PORT);
IO_SYM_ADD(WPC_PARALLEL_DATA_PORT);
IO_SYM_ADD(WPC_PARALLEL_STROBE_PORT);
IO_SYM_ADD(WPC_SERIAL_DATA_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_CONTROL_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_BAUD_SELECT);
IO_SYM_ADD(WPC_TICKET_DISPENSE);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_OUT);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_IN);
IO_SYM_ADD(WPC_DCS_SOUND_RESET);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_READY);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_A);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_B);
IO_SYM_ADD(WPCS_DATA);
IO_SYM_ADD(WPCS_CONTROL_STATUS);
IO_SYM_ADD(WPC_SOL_FLASH2_OUTPUT);
IO_SYM_ADD(WPC_SOL_HIGHPOWER_OUTPUT);
IO_SYM_ADD(WPC_SOL_FLASH1_OUTPUT);
IO_SYM_ADD(WPC_SOL_LOWPOWER_OUTPUT);
IO_SYM_ADD(WPC_LAMP_ROW_OUTPUT);
IO_SYM_ADD(WPC_LAMP_COL_STROBE);
IO_SYM_ADD(WPC_GI_TRIAC);
IO_SYM_ADD(WPC_SW_JUMPER_INPUT);
IO_SYM_ADD(WPC_SW_CABINET_INPUT);
IO_SYM_ADD(WPC_SW_ROW_INPUT);
IO_SYM_ADD(WPC_SW_COL_STROBE);
IO_SYM_ADD(WPC_LEDS);
IO_SYM_ADD(WPC_RAM_BANK);
IO_SYM_ADD(WPC_SHIFTADDR);
IO_SYM_ADD(WPC_SHIFTBIT);
IO_SYM_ADD(WPC_SHIFTBIT2);
IO_SYM_ADD(WPC_PERIPHERAL_TIMER_FIRQ_CLEAR);
IO_SYM_ADD(WPC_ROM_LOCK);
IO_SYM_ADD(WPC_CLK_HOURS_DAYS);
IO_SYM_ADD(WPC_CLK_MINS);
IO_SYM_ADD(WPC_ROM_BANK);
IO_SYM_ADD(WPC_RAM_LOCK);
IO_SYM_ADD(WPC_RAM_LOCKSIZE);
}
struct machine wpc_machine =
{
.name = "wpc",
.fault = wpc_fault,
.init = wpc_init,
.dump_thread = wpc_dump_thread,
+ .periodic = wpc_periodic,
};
struct machine wpc95_machine =
{
.name = "wpc95",
.fault = wpc_fault,
.init = wpc_init,
.dump_thread = wpc_dump_thread,
+ .periodic = wpc_periodic,
};
|
bcd/exec09
|
246122ade5ae0189c9c87b7017666b5cf7ae98a7
|
Change max_cycles to 'unsigned long', and initialize it to a 5x higher value.
|
diff --git a/main.c b/main.c
index 711959d..3ea7a5b 100644
--- a/main.c
+++ b/main.c
@@ -1,438 +1,438 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
-int max_cycles = 100000000;
+unsigned long max_cycles = 500000000UL;
/* When nonzero, says that the state of the machine is persistent
across runs of the simulator. */
int machine_persistent = 0;
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
struct timeval time_started;
/**
* Return elapsed real time in milliseconds.
*/
long
time_diff (struct timeval *old, struct timeval *new)
{
long ms = (new->tv_usec - old->tv_usec) / 1000;
ms += (new->tv_sec - old->tv_sec) * 1000;
return ms;
}
long
get_elapsed_realtime (void)
{
struct timeval now;
gettimeofday (&now, NULL);
return time_diff (&time_started, &now);
}
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 30;
static int count = 30;
int delay;
static int total_ms_elapsed = 0;
static int cumulative_delay = 0;
if (--count > 0)
return;
if (last.tv_sec == 0 && last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = time_diff (&last, &now);
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
wpc_periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
cumulative_delay += delay;
if (cumulative_delay > 0)
{
usleep (50 * 1000UL);
cumulative_delay -= 50;
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
NO_NEG, NO_ARG, NULL, NULL, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
{ 'R', "realtime", "Limit simulation speed to match realtime" },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
{ 'p', "persistent", "Use persistent machine state",
NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
return -1;
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
sim_exit (0x70);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
gettimeofday (&time_started, NULL);
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
total += cpu_execute (max_cycles ? max_cycles-1 : 500000);
}
else
{
total += cpu_execute (cycles_per_irq);
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
sim_exit (0);
return 0;
}
|
bcd/exec09
|
49661d96a8a97f4c5704bda250c3a29a2d417ded
|
Add comments.
|
diff --git a/command.c b/command.c
index 40b031e..fae8e06 100644
--- a/command.c
+++ b/command.c
@@ -1031,555 +1031,562 @@ void cmd_runfor (void)
char *arg = getarg ();
char *units;
unsigned long val = atoi (arg);
units = getarg ();
if (!units || !strcmp (units, "ms"))
stop_after_ms = val;
else if (!strcmp (units, "s"))
stop_after_ms = val * 1000;
exit_command_loop = 0;
}
void cmd_measure (void)
{
absolute_address_t addr;
target_addr_t retaddr = get_pc ();
breakpoint_t *br;
/* Get the address of the function to be measured. */
char *arg = getarg ();
if (!arg)
return;
addr = eval_mem (arg, LVALUE);
printf ("Measuring ");
print_addr (addr);
printf (" back to ");
print_addr (to_absolute (retaddr));
putchar ('\n');
/* Push the current PC onto the stack for the
duration of the measurement. */
set_s (get_s () - 2);
write16 (get_s (), retaddr);
/* Set a temp breakpoint at the current PC, so that
the measurement will halt. */
br = brkalloc ();
br->addr = to_absolute (retaddr);
br->on_execute = 1;
br->temp = 1;
/* Interrupts must be disabled for this to work ! */
set_cc (get_cc () | 0x50);
/* Change the PC to the function-under-test. */
set_pc (addr);
/* Go! */
exit_command_loop = 0;
}
void cmd_dump_insns (void)
{
extern int dump_every_insn;
char *arg = getarg ();
if (arg)
dump_every_insn = strtoul (arg, NULL, 0);
printf ("Instruction dump is %s\n",
dump_every_insn ? "on" : "off");
}
void
cmd_trace_dump (void)
{
unsigned int off = (trace_offset + 1) % MAX_TRACE;
do {
target_addr_t pc = trace_buffer[off];
absolute_address_t addr = to_absolute (pc);
//const char *name = sym_lookup (&program_symtab, addr);
//printf ("%04X ", pc);
print_addr (addr);
putchar (':');
print_insn (addr);
putchar ('\n');
//putchar (name ? '\n' : ' ');
off = (off + 1) % MAX_TRACE;
} while (off != trace_offset);
fflush (stdout);
}
void cmd_dump (void)
{
}
void cmd_restore (void)
{
}
/****************** Parser ************************/
void cmd_help (void);
struct command_name
{
const char *prefix;
const char *name;
command_handler_t handler;
const char *help;
} cmdtab[] = {
{ "p", "print", cmd_print,
"Print the value of an expression" },
{ "set", "set", cmd_set,
"Set an internal variable/target memory" },
{ "x", "examine", cmd_examine,
"Examine raw memory" },
{ "b", "break", cmd_break,
"Set a breakpoint" },
{ "bl", "blist", cmd_break_list,
"List all breakpoints" },
{ "d", "delete", cmd_delete,
"Delete a breakpoint" },
{ "s", "step", cmd_step,
"Step one instruction" },
{ "n", "next", cmd_next,
"Break at the next instruction" },
{ "c", "continue", cmd_continue,
"Continue the program" },
{ "fg", "foreground", cmd_continue, NULL },
{ "q", "quit", cmd_quit,
"Quit the simulator" },
{ "re", "reset", cpu_reset,
"Reset the CPU" },
{ "h", "help", cmd_help,
"Display this help" },
{ "wa", "watch", cmd_watch,
"Add a watchpoint on write" },
{ "rwa", "rwatch", cmd_rwatch,
"Add a watchpoint on read" },
{ "awa", "awatch", cmd_awatch,
"Add a watchpoint on read/write" },
{ "?", "?", cmd_help },
{ "l", "list", cmd_list },
{ "sym", "symbol-file", cmd_symbol_file,
"Open a symbol table file" },
{ "di", "display", cmd_display,
"Add a display expression" },
{ "so", "source", cmd_source,
"Run a command script" },
{ "regs", "regs", cmd_regs,
"Show all CPU registers" },
{ "vars", "vars", cmd_vars,
"Show all program variables" },
{ "runfor", "runfor", cmd_runfor,
"Run for a certain amount of time" },
{ "me", "measure", cmd_measure,
"Measure time that a function takes" },
{ "dumpi", "dumpi", cmd_dump_insns,
"Set dump-instruction flag" },
{ "td", "tracedump", cmd_trace_dump,
"Dump the trace buffer" },
{ "dump", "du", cmd_dump,
"Dump contents of memory to a file" },
{ "restore", "res", cmd_restore,
"Restore contents of memory from a file" },
#if 0
{ "cl", "clear", cmd_clear },
{ "i", "info", cmd_info },
{ "co", "condition", cmd_condition },
{ "tr", "trace", cmd_trace },
{ "di", "disable", cmd_disable },
{ "en", "enable", cmd_enable },
{ "f", "file", cmd_file,
"Choose the program to be debugged" },
{ "exe", "exec-file", cmd_exec_file,
"Open an executable" },
#endif
{ NULL, NULL },
};
void cmd_help (void)
{
struct command_name *cn = cmdtab;
while (cn->prefix != NULL)
{
if (cn->help)
printf ("%s (%s) - %s\n",
cn->name, cn->prefix, cn->help);
cn++;
}
}
command_handler_t
command_lookup (const char *cmd)
{
struct command_name *cn;
char *p;
p = strchr (cmd, '/');
if (p)
{
*p = '\0';
command_flags = p+1;
}
else
command_flags = "";
cn = cmdtab;
while (cn->prefix != NULL)
{
if (!strcmp (cmd, cn->prefix))
return cn->handler;
if (!strcmp (cmd, cn->name))
return cn->handler;
/* TODO - look for a match anywhere between
* the minimum prefix and the full name */
cn++;
}
return NULL;
}
void
command_prompt (void)
{
fprintf (stderr, "(dbg) ");
fflush (stderr);
}
void
print_current_insn (void)
{
absolute_address_t addr = to_absolute (get_pc ());
print_addr (addr);
printf (" : ");
print_insn (addr);
putchar ('\n');
}
int
command_exec (FILE *infile)
{
char buffer[256];
static char prev_buffer[256];
char *cmd;
command_handler_t handler;
int rc;
do {
errno = 0;
fgets (buffer, 255, infile);
if (feof (infile))
return -1;
} while (errno != 0);
/* In terminal mode, a blank line means to execute
the previous command. */
if (buffer[0] == '\n')
strcpy (buffer, prev_buffer);
/* Skip comments */
if (*buffer == '#')
return 0;
cmd = strtok (buffer, " \t\n");
if (!cmd)
return 0;
strcpy (prev_buffer, cmd);
handler = command_lookup (cmd);
if (!handler)
{
syntax_error ("no such command");
return 0;
}
(*handler) ();
return 0;
}
void
keybuffering (int flag)
{
struct termios tio;
tcgetattr (0, &tio);
if (!flag) /* 0 = no buffering = not default */
tio.c_lflag &= ~ICANON;
else /* 1 = buffering = default */
tio.c_lflag |= ICANON;
tcsetattr (0, TCSANOW, &tio);
}
int
command_loop (void)
{
keybuffering (1);
brkfree_temps ();
restart:
if (command_input == stdin)
{
display_print ();
print_current_insn ();
}
exit_command_loop = -1;
while (exit_command_loop < 0)
{
if (command_input == stdin)
command_prompt ();
if (command_exec (command_input) < 0)
break;
}
if (exit_command_loop == 0)
keybuffering (0);
if (feof (command_input) && command_input != stdin)
{
fclose (command_input);
command_input = stdin;
goto restart;
}
return (exit_command_loop);
}
void
breakpoint_hit (breakpoint_t *br)
{
if (br->threaded && (thread_id != br->tid))
return;
if (br->conditional)
{
if (eval (br->condition) == 0)
return;
}
if (br->ignore_count)
{
--br->ignore_count;
return;
}
monitor_on = !br->keep_running;
}
void
command_trace_insn (target_addr_t addr)
{
trace_buffer[trace_offset++] = addr;
trace_offset %= MAX_TRACE;
}
void
command_insn_hook (void)
{
target_addr_t pc;
absolute_address_t abspc;
breakpoint_t *br;
pc = get_pc ();
command_trace_insn (pc);
if (active_break_count == 0)
return;
abspc = to_absolute (pc);
br = brkfind_by_addr (abspc);
if (br && br->enabled && br->on_execute)
{
breakpoint_hit (br);
if (monitor_on == 0)
return;
if (br->temp)
brkfree (br);
else
printf ("Breakpoint %d reached.\n", br->id);
}
}
void
command_read_hook (absolute_address_t addr)
{
breakpoint_t *br;
if (active_break_count == 0)
return;
br = brkfind_by_addr (addr);
if (br && br->enabled && br->on_read)
{
printf ("Watchpoint %d triggered. [", br->id);
print_addr (addr);
printf ("]\n");
breakpoint_hit (br);
}
}
void
command_write_hook (absolute_address_t addr, U8 val)
{
breakpoint_t *br;
if (active_break_count != 0)
{
br = brkfind_by_addr (addr);
if (br && br->enabled && br->on_write)
{
if (br->write_mask)
{
int mask_ok = ((br->last_write & br->write_mask) !=
(val & br->write_mask));
br->last_write = val;
if (!mask_ok)
return;
}
breakpoint_hit (br);
if (monitor_on == 0)
return;
printf ("Watchpoint %d triggered. [", br->id);
print_addr (addr);
printf (" = 0x%02X", val);
printf ("]\n");
}
}
/* On any write, if threading is enabled then see if the
* thread ID changed by re-reading it from the target. */
if (thread_id_size && (addr == thread_current + thread_id_size - 1))
{
command_change_thread ();
}
}
void
command_periodic (void)
{
if (stop_after_ms)
{
stop_after_ms -= 100;
if (stop_after_ms <= 0)
{
monitor_on = 1;
stop_after_ms = 0;
printf ("Stopping after time elapsed.\n");
}
}
}
void pc_virtual (unsigned long *val, int writep) {
writep ? set_pc (*val) : (*val = get_pc ());
}
void x_virtual (unsigned long *val, int writep) {
writep ? set_x (*val) : (*val = get_x ());
}
void y_virtual (unsigned long *val, int writep) {
writep ? set_y (*val) : (*val = get_y ());
}
void u_virtual (unsigned long *val, int writep) {
writep ? set_u (*val) : (*val = get_u ());
}
void s_virtual (unsigned long *val, int writep) {
writep ? set_s (*val) : (*val = get_s ());
}
void d_virtual (unsigned long *val, int writep) {
writep ? set_d (*val) : (*val = get_d ());
}
void a_virtual (unsigned long *val, int writep) {
writep ? set_a (*val) : (*val = get_a ());
}
void b_virtual (unsigned long *val, int writep) {
writep ? set_b (*val) : (*val = get_b ());
}
void dp_virtual (unsigned long *val, int writep) {
writep ? set_dp (*val) : (*val = get_dp ());
}
void cc_virtual (unsigned long *val, int writep) {
writep ? set_cc (*val) : (*val = get_cc ());
}
void irq_load_virtual (unsigned long *val, int writep) {
if (!writep)
*val = irq_cycles / IRQ_CYCLE_COUNTS;
}
void cycles_virtual (unsigned long *val, int writep)
{
if (!writep)
*val = get_cycles ();
}
void et_virtual (unsigned long *val, int writep)
{
static unsigned long last_cycles = 0;
if (!writep)
*val = get_cycles () - last_cycles;
last_cycles = get_cycles ();
}
+/**
+ * Update the $irqload virtual register, which tracks the
+ * average number of cycles spent in IRQ. This function
+ * maintains a rolling history of IRQ_CYCLE_COUNTS entries.
+ */
void
command_exit_irq_hook (unsigned long cycles)
{
irq_cycles -= irq_cycle_tab[irq_cycle_entry];
irq_cycles += cycles;
irq_cycle_tab[irq_cycle_entry] = cycles;
irq_cycle_entry = (irq_cycle_entry + 1) % IRQ_CYCLE_COUNTS;
- //printf ("IRQ took %lu cycles\n", cycles);
- //printf ("Average = %d\n", irq_cycles / IRQ_CYCLE_COUNTS);
}
void
command_init (void)
{
int rc;
+ /* Install virtual registers. These are referenced in expressions
+ * using a dollar-sign prefix (e.g. $pc). The value of the
+ * symbol is a pointer to a function (e.g. pc_virtual) which
+ * computes the value dynamically. */
sym_add (&auto_symtab, "pc", (unsigned long)pc_virtual, SYM_AUTO);
sym_add (&auto_symtab, "x", (unsigned long)x_virtual, SYM_AUTO);
sym_add (&auto_symtab, "y", (unsigned long)y_virtual, SYM_AUTO);
sym_add (&auto_symtab, "u", (unsigned long)u_virtual, SYM_AUTO);
sym_add (&auto_symtab, "s", (unsigned long)s_virtual, SYM_AUTO);
sym_add (&auto_symtab, "d", (unsigned long)d_virtual, SYM_AUTO);
sym_add (&auto_symtab, "a", (unsigned long)a_virtual, SYM_AUTO);
sym_add (&auto_symtab, "b", (unsigned long)b_virtual, SYM_AUTO);
sym_add (&auto_symtab, "dp", (unsigned long)dp_virtual, SYM_AUTO);
sym_add (&auto_symtab, "cc", (unsigned long)cc_virtual, SYM_AUTO);
sym_add (&auto_symtab, "cycles", (unsigned long)cycles_virtual, SYM_AUTO);
sym_add (&auto_symtab, "et", (unsigned long)et_virtual, SYM_AUTO);
sym_add (&auto_symtab, "irqload", (unsigned long)irq_load_virtual, SYM_AUTO);
examine_type.format = 'x';
examine_type.size = 1;
print_type.format = 'x';
print_type.size = 1;
command_input = stdin;
(void)command_exec_file (".dbinit");
}
/* vim: set ts=3: */
/* vim: set expandtab: */
diff --git a/eon.h b/eon.h
index 548bda0..13b80a6 100644
--- a/eon.h
+++ b/eon.h
@@ -1,92 +1,92 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MACHINE_EON_H
#define _MACHINE_EON_H
/* RAM */
#define RAM_SIZE 0x100000
/* I/O regions (1KB) */
#define BOOT_IO_ADDR 0xE000
#define DEVICE_BASE(n) (BOOT_IO_ADDR + (BUS_MAP_SIZE * (n)))
/* The MMU */
#define MMU_DEVID 0
#define MMU_ADDR DEVICE_BASE(MMU_DEVID)
#define MMU_PAGESIZE 4096
#define MMU_PAGECOUNT (MAX_CPU_ADDR / MMU_PAGESIZE)
#define MMU_PAGEREGS 4
/* device select */
- #define MMU_DEV(p) (MMU_ADDR + (p * MMU_PAGEREGS) + 0)
+ #define MMU_DEV(p) (MMU_ADDR + ((p) * MMU_PAGEREGS) + 0)
/* 4KB region to map in */
- #define MMU_OFF(p) (MMU_ADDR + (p * MMU_PAGEREGS) + 1)
+ #define MMU_OFF(p) (MMU_ADDR + ((p) * MMU_PAGEREGS) + 1)
/* permissions */
- #define MMU_FLG(p) (MMU_ADDR + (p * MMU_PAGEREGS) + 2)
+ #define MMU_FLG(p) (MMU_ADDR + ((p) * MMU_PAGEREGS) + 2)
#define MMU_FAULT_ADDR (MMU_ADDR + 0x60)
#define MMU_FAULT_TYPE (MMU_ADDR + 0x62)
/* The Power Manager */
#define POWERMGR_DEVID 1
#define POWERMGR_ADDR DEVICE_BASE(POWERMGR_DEVID)
#define POWER_CTRL (POWERMGR_ADDR + 0)
#define POWER_RESET_REG (POWERMGMT_ADDR + 1)
/* The Console */
#define CONSOLE_DEVID 2
#define CONSOLE_ADDR DEVICE_BASE(CONSOLE_DEVID)
#define CONSOLE_OUT (CONSOLE_ADDR + 0)
#define LEGACY_EXIT (CONSOLE_ADDR + 1)
#define CONSOLE_IN (CONSOLE_ADDR + 2)
#define CON_OUT 0
#define CON_EXIT 1
#define CON_IN 2
/* The Display */
#define DISPLAY_DEVID 3
#define DISPLAY_ADDR DEVICE_BASE(DISPLAY_DEVID)
/* The Disk Drive */
#define DISK0_DEVID 4
#define DISK_ADDR(n) DEVICE_BASE(DISK0_DEVID + (n))
#define DISK_SECTOR_COUNT 65536
#define SECTOR_SIZE 512
#define DSK_CTRL 0
#define DSK_READ 0x1
#define DSK_WRITE 0x2
#define DSK_FLUSH 0x4
#define DSK_ERASE 0x8
#define DSK_ADDR 1
#define DSK_SECTOR 2 /* and 3 */
/* Boot ROM region (7KB) */
#define BOOT_ROM_ADDR 0xE400
#define BOOT_ROM_SIZE 0x1C00
#endif /* _MACHINE_EON_H */
|
bcd/exec09
|
79ccae67df9164bc723a218f2080b90c34ce2c95
|
Only try to initialize the WPC ROM register on the WPC hardware.
|
diff --git a/monitor.c b/monitor.c
index e560d33..5b0e01c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -623,825 +623,826 @@ opcode_t codes11[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_swi3, _implied},
{_undoc, _illegal}, /* 11 40 */
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal}
};
char *reg[] = {
"D", "X", "Y", "U", "S", "PC", "??", "??",
"A", "B", "CC", "DP", "??", "??", "??", "??"
};
char index_reg[] = { 'X', 'Y', 'U', 'S' };
char *off4[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
"-16", "-15", "-14", "-13", "-12", "-11", "-10", "-9",
"-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1"
};
/* Disassemble the current instruction. Returns the number of bytes that
compose it. */
int
dasm (char *buf, absolute_address_t opc)
{
UINT8 op, am;
char *op_str;
absolute_address_t pc = opc;
char R;
int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */
op = fetch8 ();
if (op == 0x10)
{
op = fetch8 ();
am = codes10[op].mode;
op = codes10[op].code;
}
else if (op == 0x11)
{
op = fetch8 ();
am = codes11[op].mode;
op = codes11[op].code;
}
else
{
am = codes[op].mode;
op = codes[op].code;
}
op_str = (char *) mne[op];
buf += sprintf (buf, "%-6.6s", op_str);
switch (am)
{
case _illegal:
sprintf (buf, "???");
break;
case _implied:
break;
case _imm_byte:
sprintf (buf, "#$%02X", fetch8 ());
break;
case _imm_word:
sprintf (buf, "#$%04X", fetch16 ());
break;
case _direct:
sprintf (buf, "<%s", monitor_addr_name (fetch8 ()));
break;
case _extended:
sprintf (buf, "%s", monitor_addr_name (fetch16 ()));
break;
case _indexed:
op = fetch8 ();
R = index_reg[(op >> 5) & 0x3];
if ((op & 0x80) == 0)
{
sprintf (buf, "%s,%c", off4[op & 0x1f], R);
break;
}
switch (op & 0x1f)
{
case 0x00:
sprintf (buf, ",%c+", R);
break;
case 0x01:
sprintf (buf, ",%c++", R);
break;
case 0x02:
sprintf (buf, ",-%c", R);
break;
case 0x03:
sprintf (buf, ",--%c", R);
break;
case 0x04:
sprintf (buf, ",%c", R);
break;
case 0x05:
sprintf (buf, "B,%c", R);
break;
case 0x06:
sprintf (buf, "A,%c", R);
break;
case 0x08:
sprintf (buf, "$%02X,%c", fetch8 (), R);
break;
case 0x09:
sprintf (buf, "$%04X,%c", fetch16 (), R);
break;
case 0x0B:
sprintf (buf, "D,%c", R);
break;
case 0x0C:
sprintf (buf, "$%02X,PC", fetch8 ());
break;
case 0x0D:
sprintf (buf, "$%04X,PC", fetch16 ());
break;
case 0x11:
sprintf (buf, "[,%c++]", R);
break;
case 0x13:
sprintf (buf, "[,--%c]", R);
break;
case 0x14:
sprintf (buf, "[,%c]", R);
break;
case 0x15:
sprintf (buf, "[B,%c]", R);
break;
case 0x16:
sprintf (buf, "[A,%c]", R);
break;
case 0x18:
sprintf (buf, "[$%02X,%c]", fetch8 (), R);
break;
case 0x19:
sprintf (buf, "[$%04X,%c]", fetch16 (), R);
break;
case 0x1B:
sprintf (buf, "[D,%c]", R);
break;
case 0x1C:
sprintf (buf, "[$%02X,PC]", fetch8 ());
break;
case 0x1D:
sprintf (buf, "[$%04X,PC]", fetch16 ());
break;
case 0x1F:
sprintf (buf, "[%s]", monitor_addr_name (fetch16 ()));
break;
default:
sprintf (buf, "???");
break;
}
break;
case _rel_byte:
fetch1 = ((INT8) fetch8 ());
sprintf (buf, "%s", absolute_addr_name (fetch1 + pc));
break;
case _rel_word:
sprintf (buf, "%s", absolute_addr_name (fetch16 () + pc));
break;
case _reg_post:
op = fetch8 ();
sprintf (buf, "%s,%s", reg[op >> 4], reg[op & 15]);
break;
case _usr_post:
case _sys_post:
op = fetch8 ();
if (op & 0x80)
strcat (buf, "PC,");
if (op & 0x40)
strcat (buf, am == _usr_post ? "S," : "U,");
if (op & 0x20)
strcat (buf, "Y,");
if (op & 0x10)
strcat (buf, "X,");
if (op & 0x08)
strcat (buf, "DP,");
if ((op & 0x06) == 0x06)
strcat (buf, "D,");
else
{
if (op & 0x04)
strcat (buf, "B,");
if (op & 0x02)
strcat (buf, "A,");
}
if (op & 0x01)
strcat (buf, "CC,");
buf[strlen (buf) - 1] = '\0';
break;
}
return pc - opc;
}
int
sizeof_file (FILE * file)
{
int size;
fseek (file, 0, SEEK_END);
size = ftell (file);
rewind (file);
return size;
}
int
load_map_file (const char *name)
{
FILE *fp;
char map_filename[256];
char buf[256];
char *value_ptr, *id_ptr;
target_addr_t value;
char *file_ptr;
struct symbol *sym = NULL;
/* Try appending the suffix 'map' to the name of the program. */
sprintf (map_filename, "%s.map", name);
fp = file_open (NULL, map_filename, "r");
if (!fp)
{
/* If that fails, try replacing any existing suffix. */
sprintf (map_filename, "%s", name);
char *s = strrchr (map_filename, '.');
if (s)
{
sprintf (s+1, "map");
fp = file_open (NULL, map_filename, "r");
}
if (!fp)
{
fprintf (stderr, "warning: no symbols for %s\n", name);
return -1;
}
}
printf ("Reading symbols from '%s'...\n", map_filename);
for (;;)
{
fgets (buf, sizeof(buf)-1, fp);
if (feof (fp))
break;
value_ptr = buf;
if (!strncmp (value_ptr, "page", 4))
{
unsigned char page = strtoul (value_ptr+4, NULL, 10);
- wpc_set_rom_page (page); /* TODO - genericize */
+ if (!strcmp (machine->name, "wpc"))
+ wpc_set_rom_page (page);
sym = NULL;
continue;
}
if (strncmp (value_ptr, " ", 6))
continue;
while (*value_ptr == ' ')
value_ptr++;
value = strtoul (value_ptr, &id_ptr, 16);
if (id_ptr == value_ptr)
continue;
while (*id_ptr == ' ')
id_ptr++;
id_ptr = strtok (id_ptr, " \t\n");
if (((*id_ptr == 'l') || (*id_ptr == 's')) && (id_ptr[1] == '_'))
continue;
++id_ptr;
file_ptr = strtok (NULL, " \t\n");
if (sym)
sym->ty.size = to_absolute (value) - sym->value;
sym = sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */
}
fclose (fp);
return 0;
}
int
load_hex (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open hex record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3)
{
printf ("line %d: invalid hex record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff) + type;
switch (type)
{
case 0:
for (; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid hex record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 1:
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid hex record checksum \n", line);
done = 0;
break;
case 2:
default:
printf ("line %d: not supported hex type %d.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
int
load_s19 (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open S-record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) != 3)
{
printf ("line %d: invalid S record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff);
switch (type)
{
case 1:
for (count -= 3; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 9:
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
default:
printf ("line %d: S%d not supported.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
void
monitor_call (unsigned int flags)
{
#ifdef CALL_STACK
if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call++;
current_function_call->entry_point = get_pc ();
current_function_call->flags = flags;
}
#endif
#if 0
const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ()));
if (id)
{
// printf ("In %s now\n", id);
}
#endif
}
void
monitor_return (void)
{
#ifdef CALL_STACK
if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call--;
return;
}
while ((current_function_call->flags & FC_TAIL_CALL) &&
(current_function_call > fctab))
{
current_function_call--;
}
if (current_function_call > fctab)
current_function_call--;
#endif
}
const char *
absolute_addr_name (absolute_address_t addr)
{
static char buf[256], *bufptr;
const char *name;
bufptr = buf;
bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%-16.16s>", name);
return buf;
}
const char *
monitor_addr_name (target_addr_t target_addr)
{
static char buf[256], *bufptr;
const char *name;
absolute_address_t addr = to_absolute (target_addr);
bufptr = buf;
bufptr += sprintf (bufptr, "0x%04X", target_addr);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%s>", name);
return buf;
}
static void
monitor_signal (int sigtype)
{
(void) sigtype;
putchar ('\n');
monitor_on = 1;
}
void
monitor_init (void)
{
int tmp;
extern int debug_enabled;
target_addr_t a;
fctab[0].entry_point = read16 (0xfffe);
memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs));
current_function_call = &fctab[0];
auto_break_insn_count = 0;
monitor_on = debug_enabled;
signal (SIGINT, monitor_signal);
}
int
check_break (void)
{
if (dump_every_insn)
print_current_insn ();
if (auto_break_insn_count > 0)
if (--auto_break_insn_count == 0)
return 1;
return 0;
}
void
monitor_backtrace (void)
{
struct function_call *fc = current_function_call;
while (fc >= &fctab[0]) {
printf ("%s\n", monitor_addr_name (fc->entry_point));
fc--;
}
}
int
monitor6809 (void)
{
int rc;
signal (SIGINT, monitor_signal);
rc = command_loop ();
monitor_on = 0;
return rc;
}
|
bcd/exec09
|
d971d282004dcf5788f3af49bd8ca12ee9848563
|
Add TODO.
|
diff --git a/monitor.c b/monitor.c
index b06aa7e..beacba1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -622,822 +622,825 @@ opcode_t codes11[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_swi3, _implied},
{_undoc, _illegal}, /* 11 40 */
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal}
};
char *reg[] = {
"D", "X", "Y", "U", "S", "PC", "??", "??",
"A", "B", "CC", "DP", "??", "??", "??", "??"
};
char index_reg[] = { 'X', 'Y', 'U', 'S' };
char *off4[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
"-16", "-15", "-14", "-13", "-12", "-11", "-10", "-9",
"-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1"
};
/* Disassemble the current instruction. Returns the number of bytes that
compose it. */
int
dasm (char *buf, absolute_address_t opc)
{
UINT8 op, am;
char *op_str;
absolute_address_t pc = opc;
char R;
int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */
op = fetch8 ();
if (op == 0x10)
{
op = fetch8 ();
am = codes10[op].mode;
op = codes10[op].code;
}
else if (op == 0x11)
{
op = fetch8 ();
am = codes11[op].mode;
op = codes11[op].code;
}
else
{
am = codes[op].mode;
op = codes[op].code;
}
op_str = (char *) mne[op];
buf += sprintf (buf, "%-6.6s", op_str);
switch (am)
{
case _illegal:
sprintf (buf, "???");
break;
case _implied:
break;
case _imm_byte:
sprintf (buf, "#$%02X", fetch8 ());
break;
case _imm_word:
sprintf (buf, "#$%04X", fetch16 ());
break;
case _direct:
sprintf (buf, "<%s", monitor_addr_name (fetch8 ()));
break;
case _extended:
sprintf (buf, "%s", monitor_addr_name (fetch16 ()));
break;
case _indexed:
op = fetch8 ();
R = index_reg[(op >> 5) & 0x3];
if ((op & 0x80) == 0)
{
sprintf (buf, "%s,%c", off4[op & 0x1f], R);
break;
}
switch (op & 0x1f)
{
case 0x00:
sprintf (buf, ",%c+", R);
break;
case 0x01:
sprintf (buf, ",%c++", R);
break;
case 0x02:
sprintf (buf, ",-%c", R);
break;
case 0x03:
sprintf (buf, ",--%c", R);
break;
case 0x04:
sprintf (buf, ",%c", R);
break;
case 0x05:
sprintf (buf, "B,%c", R);
break;
case 0x06:
sprintf (buf, "A,%c", R);
break;
case 0x08:
sprintf (buf, "$%02X,%c", fetch8 (), R);
break;
case 0x09:
sprintf (buf, "$%04X,%c", fetch16 (), R);
break;
case 0x0B:
sprintf (buf, "D,%c", R);
break;
case 0x0C:
sprintf (buf, "$%02X,PC", fetch8 ());
break;
case 0x0D:
sprintf (buf, "$%04X,PC", fetch16 ());
break;
case 0x11:
sprintf (buf, "[,%c++]", R);
break;
case 0x13:
sprintf (buf, "[,--%c]", R);
break;
case 0x14:
sprintf (buf, "[,%c]", R);
break;
case 0x15:
sprintf (buf, "[B,%c]", R);
break;
case 0x16:
sprintf (buf, "[A,%c]", R);
break;
case 0x18:
sprintf (buf, "[$%02X,%c]", fetch8 (), R);
break;
case 0x19:
sprintf (buf, "[$%04X,%c]", fetch16 (), R);
break;
case 0x1B:
sprintf (buf, "[D,%c]", R);
break;
case 0x1C:
sprintf (buf, "[$%02X,PC]", fetch8 ());
break;
case 0x1D:
sprintf (buf, "[$%04X,PC]", fetch16 ());
break;
case 0x1F:
sprintf (buf, "[%s]", monitor_addr_name (fetch16 ()));
break;
default:
sprintf (buf, "???");
break;
}
break;
case _rel_byte:
fetch1 = ((INT8) fetch8 ());
sprintf (buf, "%s", absolute_addr_name (fetch1 + pc));
break;
case _rel_word:
sprintf (buf, "%s", absolute_addr_name (fetch16 () + pc));
break;
case _reg_post:
op = fetch8 ();
sprintf (buf, "%s,%s", reg[op >> 4], reg[op & 15]);
break;
case _usr_post:
case _sys_post:
op = fetch8 ();
if (op & 0x80)
strcat (buf, "PC,");
if (op & 0x40)
strcat (buf, am == _usr_post ? "S," : "U,");
if (op & 0x20)
strcat (buf, "Y,");
if (op & 0x10)
strcat (buf, "X,");
if (op & 0x08)
strcat (buf, "DP,");
if ((op & 0x06) == 0x06)
strcat (buf, "D,");
else
{
if (op & 0x04)
strcat (buf, "B,");
if (op & 0x02)
strcat (buf, "A,");
}
if (op & 0x01)
strcat (buf, "CC,");
buf[strlen (buf) - 1] = '\0';
break;
}
return pc - opc;
}
int
sizeof_file (FILE * file)
{
int size;
fseek (file, 0, SEEK_END);
size = ftell (file);
rewind (file);
return size;
}
int
load_map_file (const char *name)
{
FILE *fp;
char map_filename[256];
char buf[256];
char *value_ptr, *id_ptr;
target_addr_t value;
char *file_ptr;
/* Try appending the suffix 'map' to the name of the program. */
sprintf (map_filename, "%s.map", name);
fp = file_open (NULL, map_filename, "r");
if (!fp)
{
/* If that fails, try replacing any existing suffix. */
sprintf (map_filename, "%s", name);
char *s = strrchr (map_filename, '.');
if (s)
{
sprintf (s+1, "map");
fp = file_open (NULL, map_filename, "r");
}
if (!fp)
{
fprintf (stderr, "warning: no symbols for %s\n", name);
return -1;
}
}
printf ("Reading symbols from '%s'...\n", map_filename);
for (;;)
{
fgets (buf, sizeof(buf)-1, fp);
if (feof (fp))
break;
value_ptr = buf;
if (!strncmp (value_ptr, "page", 4))
{
unsigned char page = strtoul (value_ptr+4, NULL, 10);
+#if 1 /* turn into machine hook; */
+/* TODO - detect if using linker banking */
wpc_set_rom_page (page);
+#endif
continue;
}
if (strncmp (value_ptr, " ", 6))
continue;
while (*value_ptr == ' ')
value_ptr++;
value = strtoul (value_ptr, &id_ptr, 16);
if (id_ptr == value_ptr)
continue;
while (*id_ptr == ' ')
id_ptr++;
id_ptr = strtok (id_ptr, " \t\n");
if (((*id_ptr == 'l') || (*id_ptr == 's')) && (id_ptr[1] == '_'))
continue;
++id_ptr;
file_ptr = strtok (NULL, " \t\n");
sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */
}
fclose (fp);
return 0;
}
int
load_hex (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open hex record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3)
{
printf ("line %d: invalid hex record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff) + type;
switch (type)
{
case 0:
for (; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid hex record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 1:
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid hex record checksum \n", line);
done = 0;
break;
case 2:
default:
printf ("line %d: not supported hex type %d.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
int
load_s19 (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open S-record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) != 3)
{
printf ("line %d: invalid S record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff);
switch (type)
{
case 1:
for (count -= 3; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 9:
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
default:
printf ("line %d: S%d not supported.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
void
monitor_call (unsigned int flags)
{
#ifdef CALL_STACK
if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call++;
current_function_call->entry_point = get_pc ();
current_function_call->flags = flags;
}
#endif
#if 0
const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ()));
if (id)
{
// printf ("In %s now\n", id);
}
#endif
}
void
monitor_return (void)
{
#ifdef CALL_STACK
if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call--;
return;
}
while ((current_function_call->flags & FC_TAIL_CALL) &&
(current_function_call > fctab))
{
current_function_call--;
}
if (current_function_call > fctab)
current_function_call--;
#endif
}
const char *
absolute_addr_name (absolute_address_t addr)
{
static char buf[256], *bufptr;
const char *name;
bufptr = buf;
bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%-16.16s>", name);
return buf;
}
const char *
monitor_addr_name (target_addr_t target_addr)
{
static char buf[256], *bufptr;
const char *name;
absolute_address_t addr = to_absolute (target_addr);
bufptr = buf;
bufptr += sprintf (bufptr, "0x%04X", target_addr);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%s>", name);
return buf;
}
static void
monitor_signal (int sigtype)
{
(void) sigtype;
putchar ('\n');
monitor_on = 1;
}
void
monitor_init (void)
{
int tmp;
extern int debug_enabled;
target_addr_t a;
fctab[0].entry_point = read16 (0xfffe);
memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs));
current_function_call = &fctab[0];
auto_break_insn_count = 0;
monitor_on = debug_enabled;
signal (SIGINT, monitor_signal);
}
int
check_break (void)
{
if (dump_every_insn)
print_current_insn ();
if (auto_break_insn_count > 0)
if (--auto_break_insn_count == 0)
return 1;
return 0;
}
void
monitor_backtrace (void)
{
struct function_call *fc = current_function_call;
while (fc >= &fctab[0]) {
printf ("%s\n", monitor_addr_name (fc->entry_point));
fc--;
}
}
int
monitor6809 (void)
{
int rc;
signal (SIGINT, monitor_signal);
rc = command_loop ();
monitor_on = 0;
return rc;
}
|
bcd/exec09
|
db522e7147612a9274c00a6e7766fe5d26021a34
|
Several improvements to the debugger:
|
diff --git a/6809.h b/6809.h
index 5e737c0..351ca42 100644
--- a/6809.h
+++ b/6809.h
@@ -1,243 +1,243 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef M6809_H
#define M6809_H
#include "config.h"
#include <stdio.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#else
#error
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#else
#error
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#else
#error
#endif
typedef uint8_t UINT8;
typedef signed char INT8;
typedef uint16_t UINT16;
typedef signed short INT16;
typedef uint32_t UINT32;
typedef signed int INT32;
typedef uint16_t target_addr_t;
#include "machine.h"
#define E_FLAG 0x80
#define F_FLAG 0x40
#define H_FLAG 0x20
#define I_FLAG 0x10
#define N_FLAG 0x08
#define Z_FLAG 0x04
#define V_FLAG 0x02
#define C_FLAG 0x01
extern int debug_enabled;
extern int need_flush;
extern unsigned long total;
extern int dump_cycles_on_success;
extern const char *prog_name;
long get_elapsed_realtime (void);
/* Primitive read/write macros */
#define read8(addr) cpu_read8 (addr)
#define write8(addr,val) do { cpu_write8 (addr, val); } while (0)
/* 16-bit versions */
#define read16(addr) cpu_read16(addr)
#define write16(addr,val) do { write8(addr+1, val & 0xFF); write8(addr, (val >> 8) & 0xFF); } while (0)
/* Fetch macros */
#define abs_read16(addr) ((abs_read8(addr) << 8) | abs_read8(addr+1))
#define fetch8() abs_read8 (pc++)
#define fetch16() (pc += 2, abs_read16(pc-2))
/* 6809.c */
extern int cpu_quit;
extern int cpu_execute (int);
extern void cpu_reset (void);
extern unsigned get_a (void);
extern unsigned get_b (void);
extern unsigned get_cc (void);
extern unsigned get_dp (void);
extern unsigned get_x (void);
extern unsigned get_y (void);
extern unsigned get_s (void);
extern unsigned get_u (void);
extern unsigned get_pc (void);
extern unsigned get_d (void);
extern unsigned get_flags (void);
extern void set_a (unsigned);
extern void set_b (unsigned);
extern void set_cc (unsigned);
extern void set_dp (unsigned);
extern void set_x (unsigned);
extern void set_y (unsigned);
extern void set_s (unsigned);
extern void set_u (unsigned);
extern void set_pc (unsigned);
extern void set_d (unsigned);
/* fileio.c */
struct pathlist
{
int count;
char *entry[32];
};
void path_init (struct pathlist *path);
void path_add (struct pathlist *path, const char *dir);
FILE * file_open (struct pathlist *path, const char *filename, const char *mode);
FILE * file_require_open (struct pathlist *path, const char *filename, const char *mode);
void file_close (FILE *fp);
/* monitor.c */
extern int monitor_on;
extern int check_break (void);
extern void monitor_init (void);
extern int monitor6809 (void);
extern int dasm (char *, absolute_address_t);
extern int load_hex (char *);
extern int load_s19 (char *);
extern int load_bin (char *,int);
#define MAX_STRINGSPACE 32000
#define MAX_SYMBOL_HASH 1009
#define SYM_DEFAULT 0
#define SYM_AUTO 1
typedef struct
{
unsigned char format;
unsigned int size;
} datatype_t;
/* symtab.c */
struct stringspace
{
char space[32000];
unsigned int used;
};
struct symbol
{
char *name;
unsigned long value;
datatype_t ty;
unsigned int type;
struct symbol *name_chain;
struct symbol *value_chain;
};
struct symtab
{
struct symbol *syms_by_name[MAX_SYMBOL_HASH];
struct symbol *syms_by_value[MAX_SYMBOL_HASH];
struct symtab *parent;
};
extern struct symtab program_symtab;
extern struct symtab internal_symtab;
extern struct symtab auto_symtab;
-void sym_add (struct symtab *symtab, const char *name, unsigned long value, unsigned int type);
+struct symbol *sym_add (struct symtab *symtab, const char *name, unsigned long value, unsigned int type);
void sym_set (struct symtab *symtab, const char *name, unsigned long value, unsigned int type);
int sym_find (struct symtab *symtab, const char *name, unsigned long *value, unsigned int type);
const char *sym_lookup (struct symtab *symtab, unsigned long value);
typedef void (*command_handler_t) (void);
typedef void (*virtual_handler_t) (unsigned long *val, int writep);
typedef unsigned int thread_id_t;
typedef struct
{
unsigned int id : 8;
unsigned int used : 1;
unsigned int enabled : 1;
unsigned int conditional : 1;
unsigned int threaded : 1;
unsigned int on_read : 1;
unsigned int on_write : 1;
unsigned int on_execute : 1;
unsigned int size : 4;
unsigned int keep_running : 1;
unsigned int temp : 1;
unsigned int last_write : 16;
unsigned int write_mask : 16;
absolute_address_t addr;
char condition[128];
thread_id_t tid;
unsigned int pass_count;
unsigned int ignore_count;
} breakpoint_t;
typedef struct
{
int used : 1;
datatype_t type;
char expr[128];
} display_t;
typedef struct
{
int id : 8;
thread_id_t tid;
} thread_t;
#define MAX_BREAKS 32
#define MAX_DISPLAYS 32
#define MAX_HISTORY 10
#define MAX_THREADS 64
void command_irq_hook (unsigned long cycles);
#endif /* M6809_H */
diff --git a/command.c b/command.c
index 5eade79..40b031e 100644
--- a/command.c
+++ b/command.c
@@ -1,1538 +1,1585 @@
#include "6809.h"
#include "monitor.h"
#include "machine.h"
#include <sys/errno.h>
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#else
#error
#endif
typedef struct
{
unsigned int size;
unsigned int count;
char **strings;
} cmdqueue_t;
+typedef enum
+{
+ LVALUE,
+ RVALUE,
+} eval_mode_t;
+
+#define MAKE_ADDR(devno, phyaddr) ((devno * 0x10000000L) + phyaddr)
+
/**********************************************************/
/********************* Global Data ************************/
/**********************************************************/
unsigned int break_count = 0;
breakpoint_t breaktab[MAX_BREAKS];
unsigned int active_break_count = 0;
unsigned int display_count = 0;
display_t displaytab[MAX_DISPLAYS];
unsigned int history_count = 0;
unsigned long historytab[MAX_HISTORY];
absolute_address_t examine_addr = 0;
unsigned int examine_repeat = 1;
datatype_t examine_type;
+/* Thread tracking. thread_current points to a location in
+ * target memory where the current thread ID is kept. thread_id
+ * is the debugger's current cached value of that, to avoid
+ * reading memory constantly. The size allows for targets to
+ * define the ID format differently. */
unsigned int thread_id_size = 2;
absolute_address_t thread_current;
absolute_address_t thread_id = 0;
thread_t threadtab[MAX_THREADS];
#define MAX_CMD_QUEUES 8
int command_stack_depth = -1;
cmdqueue_t command_stack[MAX_CMD_QUEUES];
#define MAX_TRACE 256
target_addr_t trace_buffer[MAX_TRACE];
unsigned int trace_offset = 0;
int stop_after_ms = 0;
datatype_t print_type;
char *command_flags;
int exit_command_loop;
#define IRQ_CYCLE_COUNTS 128
unsigned int irq_cycle_tab[IRQ_CYCLE_COUNTS] = { 0, };
unsigned int irq_cycle_entry = 0;
unsigned long irq_cycles = 0;
unsigned long eval (char *expr);
-unsigned long eval_mem (char *expr);
+unsigned long eval_mem (char *expr, eval_mode_t mode);
extern int auto_break_insn_count;
FILE *command_input;
/**********************************************************/
/******************** 6809 Functions **********************/
/**********************************************************/
void
print_addr (absolute_address_t addr)
{
const char *name;
print_device_name (addr >> 28);
putchar (':');
printf ("0x%04X", addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
printf (" <%-16.16s>", name);
else
printf ("%-20.20s", "");
}
/**********************************************************/
/*********************** Functions ************************/
/**********************************************************/
void
syntax_error (const char *string)
{
fprintf (stderr, "error: %s\n", string);
}
void
save_value (unsigned long val)
{
historytab[history_count++ % MAX_HISTORY] = val;
}
unsigned long
eval_historical (unsigned int id)
{
return historytab[id % MAX_HISTORY];
}
void
assign_virtual (const char *name, unsigned long val)
{
unsigned long v_val;
+ /* First check for a special variable with this name, and
+ * invoke its write handler. Otherwise, store to the
+ * user table. */
if (!sym_find (&auto_symtab, name, &v_val, 0))
{
virtual_handler_t virtual = (virtual_handler_t)v_val;
virtual (&val, 1);
return;
}
sym_set (&internal_symtab, name, val, 0);
if (!strcmp (name, "thread_current"))
{
printf ("Thread pointer initialized to ");
print_addr (val);
putchar ('\n');
thread_current = val;
}
}
unsigned long
eval_virtual (const char *name)
{
unsigned long val;
/* The name of the virtual is looked up in the global
* symbol table, which holds the pointer to a
* variable in simulator memory, or to a function
* that can compute the value on-the-fly. */
if (!sym_find (&auto_symtab, name, &val, 0))
{
virtual_handler_t virtual = (virtual_handler_t)val;
virtual (&val, 0);
}
else if (!sym_find (&internal_symtab, name, &val, 0))
{
}
else
{
return 0;
}
return val;
}
void
eval_assign (const char *expr, unsigned long val)
{
if (*expr == '$')
{
assign_virtual (expr+1, val);
}
else
{
- absolute_address_t dst = eval_mem (expr);
- //printf ("Setting %X to %02X\n", dst, val);
+ absolute_address_t dst = eval_mem (expr, LVALUE);
abs_write8 (dst, val);
}
}
unsigned long
target_read (absolute_address_t addr, unsigned int size)
{
switch (size)
{
case 1:
return abs_read8 (addr);
case 2:
return abs_read16 (addr);
}
}
void
parse_format_flag (const char *flags, unsigned char *formatp)
{
while (*flags)
{
switch (*flags)
{
case 'x':
case 'd':
case 'u':
case 'o':
case 'a':
case 's':
*formatp = *flags;
break;
}
flags++;
}
}
void
parse_size_flag (const char *flags, unsigned int *sizep)
{
while (*flags)
{
switch (*flags++)
{
case 'b':
*sizep = 1;
break;
case 'w':
*sizep = 2;
break;
}
}
}
char *
match_binary (char *expr, const char *op, char **secondp)
{
char *p;
p = strstr (expr, op);
if (!p)
return NULL;
*p = '\0';
p += strlen (op);
*secondp = p;
return expr;
}
int
fold_comparisons (char *expr, unsigned long *value)
{
char *p;
if (match_binary (expr, "==", &p))
*value = (eval (expr) == eval (p));
else if (match_binary (expr, "!=", &p))
*value = (eval (expr) != eval (p));
else
return 0;
return 1;
}
int
fold_binary (char *expr, const char op, unsigned long *valp)
{
char *p;
unsigned long val1, val2;
if ((p = strchr (expr, op)) == NULL)
return 0;
/* If the operator is the first character of the expression,
* then it's really a unary and shouldn't match here. */
if (p == expr)
return 0;
*p++ = '\0';
val1 = eval (expr);
val2 = eval (p);
switch (op)
{
case '+': *valp = val1 + val2; break;
case '-': *valp = val1 - val2; break;
case '*': *valp = val1 * val2; break;
case '/': *valp = val1 / val2; break;
}
return 1;
}
-
+/**
+ * Evaluate a memory expression, as an lvalue or rvalue.
+ */
unsigned long
-eval_mem (char *expr)
+eval_mem (char *expr, eval_mode_t mode)
{
char *p;
unsigned long val;
+ /* First evaluate the address */
if ((p = strchr (expr, ':')) != NULL)
{
*p++ = '\0';
- val = eval (expr) * 0x10000000L + eval (p);
+ val = MAKE_ADDR (eval (expr), eval (p));
}
else if (isalpha (*expr))
{
if (sym_find (&program_symtab, expr, &val, 0))
val = 0;
}
else
{
/* TODO - if expr is already in absolute form,
this explodes ! */
val = to_absolute (eval (expr));
}
+
+ /* If mode is RVALUE, then dereference it */
+ if (mode == RVALUE)
+ val = target_read (val, 1);
+
return val;
}
+/**
+ * Evaluate an expression, given as a string.
+ * The return is the value (rvalue) of the expression.
+ *
+ * TODO:
+ * - Support typecasts ( {TYPE}ADDR )
+ *
+ */
unsigned long
eval (char *expr)
{
char *p;
unsigned long val;
if (fold_comparisons (expr, &val));
else if ((p = strchr (expr, '=')) != NULL)
{
*p++ = '\0';
val = eval (p);
eval_assign (expr, val);
}
else if (fold_binary (expr, '+', &val));
else if (fold_binary (expr, '-', &val));
else if (fold_binary (expr, '*', &val));
else if (fold_binary (expr, '/', &val));
else if (*expr == '$')
{
if (expr[1] == '$')
val = eval_historical (history_count - strtoul (expr+2, NULL, 10));
else if (isdigit (expr[1]))
val = eval_historical (strtoul (expr+1, NULL, 10));
else if (!expr[1])
val = eval_historical (0);
else
val = eval_virtual (expr+1);
}
- else if (*expr == '*')
- {
- unsigned int size = 1;
- expr++;
- if (*expr == '*')
- {
- expr++;
- size = 2;
- }
-
- absolute_address_t addr = eval_mem (expr);
- return target_read (addr, size);
- }
- else if (*expr == '@')
+ else if (*expr == '&')
{
- val = eval_mem (expr+1);
+ val = eval_mem (expr+1, LVALUE);
}
else if (isalpha (*expr))
{
- if (sym_find (&program_symtab, expr, &val, 0))
- val = 0;
+ val = eval_mem (expr, RVALUE);
}
else
{
val = strtoul (expr, NULL, 0);
}
return val;
}
void brk_enable (breakpoint_t *br, int flag)
{
if (br->enabled != flag)
{
br->enabled = flag;
if (flag)
active_break_count++;
else
active_break_count--;
}
}
breakpoint_t *
brkalloc (void)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
if (!breaktab[n].used)
{
breakpoint_t *br = &breaktab[n];
br->used = 1;
br->id = n;
br->conditional = 0;
br->threaded = 0;
br->keep_running = 0;
br->ignore_count = 0;
br->temp = 0;
brk_enable (br, 1);
return br;
}
return NULL;
}
void
brkfree (breakpoint_t *br)
{
brk_enable (br, 0);
br->used = 0;
}
void
brkfree_temps (void)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
if (breaktab[n].used && breaktab[n].temp)
{
brkfree (&breaktab[n]);
}
}
breakpoint_t *
brkfind_by_addr (absolute_address_t addr)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
if (breaktab[n].addr == addr)
return &breaktab[n];
return NULL;
}
breakpoint_t *
brkfind_by_id (unsigned int id)
{
return &breaktab[id];
}
void
brkprint (breakpoint_t *brkpt)
{
if (!brkpt->used)
return;
if (brkpt->on_execute)
printf ("Breakpoint");
else
{
printf ("Watchpoint");
if (brkpt->on_read)
printf ("(%s)", brkpt->on_write ? "RW" : "RO");
}
printf (" %d at ", brkpt->id);
print_addr (brkpt->addr);
if (!brkpt->enabled)
printf (" (disabled)");
if (brkpt->conditional)
printf (" if %s", brkpt->condition);
if (brkpt->threaded)
printf (" on thread %d", brkpt->tid);
if (brkpt->keep_running)
printf (", print-only");
if (brkpt->temp)
printf (", temp");
if (brkpt->ignore_count)
printf (", ignore %d times\n", brkpt->ignore_count);
if (brkpt->write_mask)
printf (", mask %02X\n", brkpt->write_mask);
putchar ('\n');
}
display_t *
display_alloc (void)
{
unsigned int n;
for (n = 0; n < MAX_DISPLAYS; n++)
{
display_t *ds = &displaytab[n];
if (!ds->used)
{
ds->used = 1;
return ds;
}
}
}
void
display_free (display_t *ds)
{
}
void
print_value (unsigned long val, datatype_t *typep)
{
char f[8];
switch (typep->format)
{
case 'a':
print_addr (val);
return;
case 's':
{
absolute_address_t addr = (absolute_address_t)val;
char c;
putchar ('"');
while ((c = abs_read8 (addr++)) != '\0')
putchar (c);
putchar ('"');
return;
}
+
+ case 't':
+ /* TODO : print as binary integer */
+ break;
}
if (typep->format == 'x')
{
printf ("0x");
sprintf (f, "%%0%d%c", typep->size * 2, typep->format);
}
else if (typep->format == 'o')
{
printf ("0");
sprintf (f, "%%%c", typep->format);
}
else
sprintf (f, "%%%c", typep->format);
printf (f, val);
}
void
display_print (void)
{
unsigned int n;
char comma = '\0';
for (n = 0; n < MAX_DISPLAYS; n++)
{
display_t *ds = &displaytab[n];
if (ds->used)
{
char expr[256];
strcpy (expr, ds->expr);
printf ("%c %s = ", comma, expr);
print_value (eval (expr), &ds->type);
comma = ',';
}
}
if (comma)
putchar ('\n');
}
int
print_insn (absolute_address_t addr)
{
char buf[64];
int size = dasm (buf, addr);
printf ("%s", buf);
return size;
}
void
do_examine (void)
{
unsigned int n;
unsigned int objs_per_line = 16;
if (isdigit (*command_flags))
examine_repeat = strtoul (command_flags, &command_flags, 0);
if (*command_flags == 'i')
examine_type.format = *command_flags;
else
parse_format_flag (command_flags, &examine_type.format);
parse_size_flag (command_flags, &examine_type.size);
switch (examine_type.format)
{
case 'i':
objs_per_line = 1;
break;
case 'w':
objs_per_line = 8;
break;
}
for (n = 0; n < examine_repeat; n++)
{
if ((n % objs_per_line) == 0)
{
putchar ('\n');
print_addr (examine_addr);
printf (": ");
}
switch (examine_type.format)
{
case 's': /* string */
break;
case 'i': /* instruction */
examine_addr += print_insn (examine_addr);
break;
default:
print_value (target_read (examine_addr, examine_type.size),
&examine_type);
putchar (' ');
examine_addr += examine_type.size;
}
}
putchar ('\n');
}
void
do_print (char *expr)
{
unsigned long val = eval (expr);
printf ("$%d = ", history_count);
parse_format_flag (command_flags, &print_type.format);
parse_size_flag (command_flags, &print_type.size);
print_value (val, &print_type);
putchar ('\n');
save_value (val);
}
void
do_set (char *expr)
{
- unsigned long val = eval (expr);
- save_value (val);
+ (void)eval (expr);
}
+/* TODO - WPC */
#define THREAD_DATA_PC 3
#define THREAD_DATA_ROMBANK 9
void
print_thread_data (absolute_address_t th)
{
U8 b;
U16 w;
absolute_address_t pc;
w = abs_read16 (th + THREAD_DATA_PC);
b = abs_read8 (th + THREAD_DATA_ROMBANK);
- printf ("{ PC = %04X, BANK = %02X }", w, b);
+ if (w >= 0x8000)
+ pc = 0xF0000 + w;
+ else
+ pc = (b * 0x4000) + (w - 0x4000);
+ pc = MAKE_ADDR (1, pc);
+ print_addr (pc);
+ //printf ("{ <%04X,%02X>", w, b);
}
void
command_change_thread (void)
{
target_addr_t addr = target_read (thread_current, thread_id_size);
absolute_address_t th = to_absolute (addr);
+
if (th == thread_id)
return;
-
thread_id = th;
if (machine->dump_thread && eval ("$thread_debug"))
{
if (addr)
{
printf ("[Current thread = ");
print_addr (thread_id);
machine->dump_thread (thread_id);
print_thread_data (thread_id);
printf ("]\n");
}
else
{
printf ("[ No thread ]\n");
}
}
}
void
command_stack_push (unsigned int reason)
{
cmdqueue_t *q = &command_stack[++command_stack_depth];
}
void
command_stack_pop (void)
{
cmdqueue_t *q = &command_stack[command_stack_depth];
--command_stack_depth;
}
void
command_stack_add (const char *cmd)
{
cmdqueue_t *q = &command_stack[command_stack_depth];
}
char *
getarg (void)
{
return strtok (NULL, " \t\n");
}
/****************** Command Handlers ************************/
void cmd_print (void)
{
char *arg = getarg ();
if (arg)
do_print (arg);
else
do_print ("$");
}
void cmd_set (void)
{
char *arg = getarg ();
+
+ if (!strcmp (arg, "var"))
+ arg = getarg ();
+
if (arg)
do_set (arg);
else
do_set ("$");
}
void cmd_examine (void)
{
char *arg = getarg ();
if (arg)
- examine_addr = eval_mem (arg);
+ examine_addr = eval_mem (arg, LVALUE);
do_examine ();
}
void cmd_break (void)
{
char *arg = getarg ();
if (!arg)
return;
- unsigned long val = eval_mem (arg);
+ unsigned long val = eval_mem (arg, LVALUE);
breakpoint_t *br = brkalloc ();
br->addr = val;
br->on_execute = 1;
arg = getarg ();
if (!arg);
else if (!strcmp (arg, "if"))
{
br->conditional = 1;
arg = getarg ();
strcpy (br->condition, arg);
}
else if (!strcmp (arg, "ignore"))
{
br->ignore_count = atoi (getarg ());
}
brkprint (br);
}
void cmd_watch1 (int on_read, int on_write)
{
char *arg;
arg = getarg ();
if (!arg)
return;
- absolute_address_t addr = eval_mem (arg);
+ absolute_address_t addr = eval_mem (arg, LVALUE);
breakpoint_t *br = brkalloc ();
br->addr = addr;
br->on_read = on_read;
br->on_write = on_write;
for (;;)
{
arg = getarg ();
if (!arg)
return;
if (!strcmp (arg, "print"))
br->keep_running = 1;
else if (!strcmp (arg, "mask"))
{
arg = getarg ();
br->write_mask = strtoul (arg, NULL, 0);
}
else if (!strcmp (arg, "if"))
{
arg = getarg ();
br->conditional = 1;
strcpy (br->condition, arg);
}
}
brkprint (br);
}
void cmd_watch (void)
{
cmd_watch1 (0, 1);
}
void cmd_rwatch (void)
{
cmd_watch1 (1, 0);
}
void cmd_awatch (void)
{
cmd_watch1 (1, 1);
}
void cmd_break_list (void)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
brkprint (&breaktab[n]);
}
void cmd_step (void)
{
auto_break_insn_count = 1;
exit_command_loop = 0;
}
void cmd_next (void)
{
char buf[128];
breakpoint_t *br;
unsigned long addr = to_absolute (get_pc ());
addr += dasm (buf, addr);
br = brkalloc ();
br->addr = addr;
br->on_execute = 1;
br->temp = 1;
/* TODO - for conditional branches, should also set a
temp breakpoint at the branch target */
exit_command_loop = 0;
}
void cmd_continue (void)
{
exit_command_loop = 0;
}
void cmd_quit (void)
{
cpu_quit = 0;
exit_command_loop = 1;
}
void cmd_delete (void)
{
const char *arg = getarg ();
unsigned int id;
if (!arg)
{
int n;
printf ("Deleting all breakpoints.\n");
for (id = 0; id < MAX_BREAKS; id++)
{
breakpoint_t *br = brkfind_by_id (id);
brkfree (br);
}
return;
}
id = atoi (arg);
breakpoint_t *br = brkfind_by_id (id);
if (br->used)
{
printf ("Deleting breakpoint %d\n", id);
brkfree (br);
}
}
void cmd_list (void)
{
char *arg;
static absolute_address_t lastpc = 0;
static absolute_address_t lastaddr = 0;
absolute_address_t addr;
int n;
arg = getarg ();
if (arg)
- addr = eval_mem (arg);
+ addr = eval_mem (arg, LVALUE);
else
{
addr = to_absolute (get_pc ());
if (addr == lastpc)
addr = lastaddr;
else
lastaddr = lastpc = addr;
}
for (n = 0; n < 10; n++)
{
print_addr (addr);
printf (" : ");
addr += print_insn (addr);
putchar ('\n');
}
lastaddr = addr;
}
void cmd_symbol_file (void)
{
char *arg = getarg ();
if (arg)
load_map_file (arg);
}
void cmd_display (void)
{
char *arg;
while ((arg = getarg ()) != NULL)
{
display_t *ds = display_alloc ();
strcpy (ds->expr, arg);
ds->type = print_type;
parse_format_flag (command_flags, &ds->type.format);
parse_size_flag (command_flags, &ds->type.size);
}
}
int command_exec_file (const char *filename)
{
FILE *infile;
extern int command_exec (FILE *);
infile = file_open (NULL, filename, "r");
if (!infile)
return 0;
command_input = infile;
return 1;
}
void cmd_source (void)
{
char *arg = getarg ();
if (!arg)
return;
if (command_exec_file (arg) == 0)
fprintf (stderr, "can't open %s\n", arg);
}
void cmd_regs (void)
{
}
void cmd_vars (void)
{
for_each_var (NULL);
}
void cmd_runfor (void)
{
char *arg = getarg ();
char *units;
unsigned long val = atoi (arg);
units = getarg ();
if (!units || !strcmp (units, "ms"))
stop_after_ms = val;
else if (!strcmp (units, "s"))
stop_after_ms = val * 1000;
exit_command_loop = 0;
}
void cmd_measure (void)
{
absolute_address_t addr;
target_addr_t retaddr = get_pc ();
breakpoint_t *br;
/* Get the address of the function to be measured. */
char *arg = getarg ();
if (!arg)
return;
- addr = eval_mem (arg);
+ addr = eval_mem (arg, LVALUE);
printf ("Measuring ");
print_addr (addr);
printf (" back to ");
print_addr (to_absolute (retaddr));
putchar ('\n');
/* Push the current PC onto the stack for the
duration of the measurement. */
set_s (get_s () - 2);
write16 (get_s (), retaddr);
/* Set a temp breakpoint at the current PC, so that
the measurement will halt. */
br = brkalloc ();
br->addr = to_absolute (retaddr);
br->on_execute = 1;
br->temp = 1;
/* Interrupts must be disabled for this to work ! */
set_cc (get_cc () | 0x50);
/* Change the PC to the function-under-test. */
set_pc (addr);
/* Go! */
exit_command_loop = 0;
}
-void cmd_dump (void)
+void cmd_dump_insns (void)
{
extern int dump_every_insn;
char *arg = getarg ();
if (arg)
dump_every_insn = strtoul (arg, NULL, 0);
printf ("Instruction dump is %s\n",
dump_every_insn ? "on" : "off");
}
void
cmd_trace_dump (void)
{
unsigned int off = (trace_offset + 1) % MAX_TRACE;
do {
target_addr_t pc = trace_buffer[off];
absolute_address_t addr = to_absolute (pc);
//const char *name = sym_lookup (&program_symtab, addr);
//printf ("%04X ", pc);
print_addr (addr);
putchar (':');
print_insn (addr);
putchar ('\n');
//putchar (name ? '\n' : ' ');
off = (off + 1) % MAX_TRACE;
} while (off != trace_offset);
fflush (stdout);
}
+void cmd_dump (void)
+{
+}
+
+
+void cmd_restore (void)
+{
+}
+
/****************** Parser ************************/
void cmd_help (void);
struct command_name
{
const char *prefix;
const char *name;
command_handler_t handler;
const char *help;
} cmdtab[] = {
{ "p", "print", cmd_print,
"Print the value of an expression" },
{ "set", "set", cmd_set,
"Set an internal variable/target memory" },
{ "x", "examine", cmd_examine,
"Examine raw memory" },
{ "b", "break", cmd_break,
"Set a breakpoint" },
{ "bl", "blist", cmd_break_list,
"List all breakpoints" },
{ "d", "delete", cmd_delete,
"Delete a breakpoint" },
{ "s", "step", cmd_step,
"Step one instruction" },
{ "n", "next", cmd_next,
"Break at the next instruction" },
{ "c", "continue", cmd_continue,
"Continue the program" },
+ { "fg", "foreground", cmd_continue, NULL },
{ "q", "quit", cmd_quit,
"Quit the simulator" },
{ "re", "reset", cpu_reset,
"Reset the CPU" },
{ "h", "help", cmd_help,
"Display this help" },
{ "wa", "watch", cmd_watch,
"Add a watchpoint on write" },
{ "rwa", "rwatch", cmd_rwatch,
"Add a watchpoint on read" },
{ "awa", "awatch", cmd_awatch,
"Add a watchpoint on read/write" },
{ "?", "?", cmd_help },
{ "l", "list", cmd_list },
{ "sym", "symbol-file", cmd_symbol_file,
"Open a symbol table file" },
{ "di", "display", cmd_display,
"Add a display expression" },
{ "so", "source", cmd_source,
"Run a command script" },
{ "regs", "regs", cmd_regs,
"Show all CPU registers" },
{ "vars", "vars", cmd_vars,
"Show all program variables" },
{ "runfor", "runfor", cmd_runfor,
"Run for a certain amount of time" },
{ "me", "measure", cmd_measure,
"Measure time that a function takes" },
- { "dump", "dump", cmd_dump,
+ { "dumpi", "dumpi", cmd_dump_insns,
"Set dump-instruction flag" },
{ "td", "tracedump", cmd_trace_dump,
"Dump the trace buffer" },
+ { "dump", "du", cmd_dump,
+ "Dump contents of memory to a file" },
+ { "restore", "res", cmd_restore,
+ "Restore contents of memory from a file" },
#if 0
{ "cl", "clear", cmd_clear },
{ "i", "info", cmd_info },
{ "co", "condition", cmd_condition },
{ "tr", "trace", cmd_trace },
{ "di", "disable", cmd_disable },
{ "en", "enable", cmd_enable },
{ "f", "file", cmd_file,
"Choose the program to be debugged" },
{ "exe", "exec-file", cmd_exec_file,
"Open an executable" },
#endif
{ NULL, NULL },
};
void cmd_help (void)
{
struct command_name *cn = cmdtab;
while (cn->prefix != NULL)
{
if (cn->help)
printf ("%s (%s) - %s\n",
cn->name, cn->prefix, cn->help);
cn++;
}
}
command_handler_t
command_lookup (const char *cmd)
{
struct command_name *cn;
char *p;
p = strchr (cmd, '/');
if (p)
{
*p = '\0';
command_flags = p+1;
}
else
command_flags = "";
cn = cmdtab;
while (cn->prefix != NULL)
{
if (!strcmp (cmd, cn->prefix))
return cn->handler;
if (!strcmp (cmd, cn->name))
return cn->handler;
/* TODO - look for a match anywhere between
* the minimum prefix and the full name */
cn++;
}
return NULL;
}
void
command_prompt (void)
{
fprintf (stderr, "(dbg) ");
fflush (stderr);
}
void
print_current_insn (void)
{
absolute_address_t addr = to_absolute (get_pc ());
print_addr (addr);
printf (" : ");
print_insn (addr);
putchar ('\n');
}
int
command_exec (FILE *infile)
{
char buffer[256];
static char prev_buffer[256];
char *cmd;
command_handler_t handler;
int rc;
do {
errno = 0;
fgets (buffer, 255, infile);
if (feof (infile))
return -1;
} while (errno != 0);
/* In terminal mode, a blank line means to execute
the previous command. */
if (buffer[0] == '\n')
strcpy (buffer, prev_buffer);
/* Skip comments */
if (*buffer == '#')
return 0;
cmd = strtok (buffer, " \t\n");
if (!cmd)
return 0;
strcpy (prev_buffer, cmd);
handler = command_lookup (cmd);
if (!handler)
{
syntax_error ("no such command");
return 0;
}
(*handler) ();
return 0;
}
void
keybuffering (int flag)
{
struct termios tio;
tcgetattr (0, &tio);
if (!flag) /* 0 = no buffering = not default */
tio.c_lflag &= ~ICANON;
else /* 1 = buffering = default */
tio.c_lflag |= ICANON;
tcsetattr (0, TCSANOW, &tio);
}
int
command_loop (void)
{
keybuffering (1);
brkfree_temps ();
restart:
if (command_input == stdin)
{
display_print ();
print_current_insn ();
}
exit_command_loop = -1;
while (exit_command_loop < 0)
{
if (command_input == stdin)
command_prompt ();
if (command_exec (command_input) < 0)
break;
}
if (exit_command_loop == 0)
keybuffering (0);
if (feof (command_input) && command_input != stdin)
{
fclose (command_input);
command_input = stdin;
goto restart;
}
return (exit_command_loop);
}
void
breakpoint_hit (breakpoint_t *br)
{
if (br->threaded && (thread_id != br->tid))
return;
if (br->conditional)
{
if (eval (br->condition) == 0)
return;
}
if (br->ignore_count)
{
--br->ignore_count;
return;
}
monitor_on = !br->keep_running;
}
void
command_trace_insn (target_addr_t addr)
{
trace_buffer[trace_offset++] = addr;
trace_offset %= MAX_TRACE;
}
void
command_insn_hook (void)
{
target_addr_t pc;
absolute_address_t abspc;
breakpoint_t *br;
pc = get_pc ();
command_trace_insn (pc);
if (active_break_count == 0)
return;
abspc = to_absolute (pc);
br = brkfind_by_addr (abspc);
if (br && br->enabled && br->on_execute)
{
breakpoint_hit (br);
if (monitor_on == 0)
return;
if (br->temp)
brkfree (br);
else
printf ("Breakpoint %d reached.\n", br->id);
}
}
void
command_read_hook (absolute_address_t addr)
{
breakpoint_t *br;
if (active_break_count == 0)
return;
br = brkfind_by_addr (addr);
if (br && br->enabled && br->on_read)
{
printf ("Watchpoint %d triggered. [", br->id);
print_addr (addr);
printf ("]\n");
breakpoint_hit (br);
}
}
void
command_write_hook (absolute_address_t addr, U8 val)
{
breakpoint_t *br;
if (active_break_count != 0)
{
br = brkfind_by_addr (addr);
if (br && br->enabled && br->on_write)
{
if (br->write_mask)
{
int mask_ok = ((br->last_write & br->write_mask) !=
(val & br->write_mask));
br->last_write = val;
if (!mask_ok)
return;
}
breakpoint_hit (br);
if (monitor_on == 0)
return;
printf ("Watchpoint %d triggered. [", br->id);
print_addr (addr);
printf (" = 0x%02X", val);
printf ("]\n");
}
}
+ /* On any write, if threading is enabled then see if the
+ * thread ID changed by re-reading it from the target. */
if (thread_id_size && (addr == thread_current + thread_id_size - 1))
{
command_change_thread ();
}
}
void
command_periodic (void)
{
if (stop_after_ms)
{
stop_after_ms -= 100;
if (stop_after_ms <= 0)
{
monitor_on = 1;
stop_after_ms = 0;
printf ("Stopping after time elapsed.\n");
}
}
}
void pc_virtual (unsigned long *val, int writep) {
writep ? set_pc (*val) : (*val = get_pc ());
}
void x_virtual (unsigned long *val, int writep) {
writep ? set_x (*val) : (*val = get_x ());
}
void y_virtual (unsigned long *val, int writep) {
writep ? set_y (*val) : (*val = get_y ());
}
void u_virtual (unsigned long *val, int writep) {
writep ? set_u (*val) : (*val = get_u ());
}
void s_virtual (unsigned long *val, int writep) {
writep ? set_s (*val) : (*val = get_s ());
}
void d_virtual (unsigned long *val, int writep) {
writep ? set_d (*val) : (*val = get_d ());
}
void a_virtual (unsigned long *val, int writep) {
writep ? set_a (*val) : (*val = get_a ());
}
void b_virtual (unsigned long *val, int writep) {
writep ? set_b (*val) : (*val = get_b ());
}
void dp_virtual (unsigned long *val, int writep) {
writep ? set_dp (*val) : (*val = get_dp ());
}
void cc_virtual (unsigned long *val, int writep) {
writep ? set_cc (*val) : (*val = get_cc ());
}
void irq_load_virtual (unsigned long *val, int writep) {
if (!writep)
*val = irq_cycles / IRQ_CYCLE_COUNTS;
}
void cycles_virtual (unsigned long *val, int writep)
{
if (!writep)
*val = get_cycles ();
}
void et_virtual (unsigned long *val, int writep)
{
static unsigned long last_cycles = 0;
if (!writep)
*val = get_cycles () - last_cycles;
last_cycles = get_cycles ();
}
void
command_exit_irq_hook (unsigned long cycles)
{
irq_cycles -= irq_cycle_tab[irq_cycle_entry];
irq_cycles += cycles;
irq_cycle_tab[irq_cycle_entry] = cycles;
irq_cycle_entry = (irq_cycle_entry + 1) % IRQ_CYCLE_COUNTS;
//printf ("IRQ took %lu cycles\n", cycles);
//printf ("Average = %d\n", irq_cycles / IRQ_CYCLE_COUNTS);
}
void
command_init (void)
{
int rc;
sym_add (&auto_symtab, "pc", (unsigned long)pc_virtual, SYM_AUTO);
sym_add (&auto_symtab, "x", (unsigned long)x_virtual, SYM_AUTO);
sym_add (&auto_symtab, "y", (unsigned long)y_virtual, SYM_AUTO);
sym_add (&auto_symtab, "u", (unsigned long)u_virtual, SYM_AUTO);
sym_add (&auto_symtab, "s", (unsigned long)s_virtual, SYM_AUTO);
sym_add (&auto_symtab, "d", (unsigned long)d_virtual, SYM_AUTO);
sym_add (&auto_symtab, "a", (unsigned long)a_virtual, SYM_AUTO);
sym_add (&auto_symtab, "b", (unsigned long)b_virtual, SYM_AUTO);
sym_add (&auto_symtab, "dp", (unsigned long)dp_virtual, SYM_AUTO);
sym_add (&auto_symtab, "cc", (unsigned long)cc_virtual, SYM_AUTO);
sym_add (&auto_symtab, "cycles", (unsigned long)cycles_virtual, SYM_AUTO);
sym_add (&auto_symtab, "et", (unsigned long)et_virtual, SYM_AUTO);
sym_add (&auto_symtab, "irqload", (unsigned long)irq_load_virtual, SYM_AUTO);
examine_type.format = 'x';
examine_type.size = 1;
print_type.format = 'x';
print_type.size = 1;
command_input = stdin;
(void)command_exec_file (".dbinit");
}
/* vim: set ts=3: */
/* vim: set expandtab: */
diff --git a/monitor.c b/monitor.c
index b06aa7e..e560d33 100644
--- a/monitor.c
+++ b/monitor.c
@@ -589,855 +589,859 @@ opcode_t codes10[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _indexed},
{_sts, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _extended},
{_sts, _extended}
};
opcode_t codes11[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_swi3, _implied},
{_undoc, _illegal}, /* 11 40 */
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal}
};
char *reg[] = {
"D", "X", "Y", "U", "S", "PC", "??", "??",
"A", "B", "CC", "DP", "??", "??", "??", "??"
};
char index_reg[] = { 'X', 'Y', 'U', 'S' };
char *off4[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
"-16", "-15", "-14", "-13", "-12", "-11", "-10", "-9",
"-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1"
};
/* Disassemble the current instruction. Returns the number of bytes that
compose it. */
int
dasm (char *buf, absolute_address_t opc)
{
UINT8 op, am;
char *op_str;
absolute_address_t pc = opc;
char R;
int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */
op = fetch8 ();
if (op == 0x10)
{
op = fetch8 ();
am = codes10[op].mode;
op = codes10[op].code;
}
else if (op == 0x11)
{
op = fetch8 ();
am = codes11[op].mode;
op = codes11[op].code;
}
else
{
am = codes[op].mode;
op = codes[op].code;
}
op_str = (char *) mne[op];
buf += sprintf (buf, "%-6.6s", op_str);
switch (am)
{
case _illegal:
sprintf (buf, "???");
break;
case _implied:
break;
case _imm_byte:
sprintf (buf, "#$%02X", fetch8 ());
break;
case _imm_word:
sprintf (buf, "#$%04X", fetch16 ());
break;
case _direct:
sprintf (buf, "<%s", monitor_addr_name (fetch8 ()));
break;
case _extended:
sprintf (buf, "%s", monitor_addr_name (fetch16 ()));
break;
case _indexed:
op = fetch8 ();
R = index_reg[(op >> 5) & 0x3];
if ((op & 0x80) == 0)
{
sprintf (buf, "%s,%c", off4[op & 0x1f], R);
break;
}
switch (op & 0x1f)
{
case 0x00:
sprintf (buf, ",%c+", R);
break;
case 0x01:
sprintf (buf, ",%c++", R);
break;
case 0x02:
sprintf (buf, ",-%c", R);
break;
case 0x03:
sprintf (buf, ",--%c", R);
break;
case 0x04:
sprintf (buf, ",%c", R);
break;
case 0x05:
sprintf (buf, "B,%c", R);
break;
case 0x06:
sprintf (buf, "A,%c", R);
break;
case 0x08:
sprintf (buf, "$%02X,%c", fetch8 (), R);
break;
case 0x09:
sprintf (buf, "$%04X,%c", fetch16 (), R);
break;
case 0x0B:
sprintf (buf, "D,%c", R);
break;
case 0x0C:
sprintf (buf, "$%02X,PC", fetch8 ());
break;
case 0x0D:
sprintf (buf, "$%04X,PC", fetch16 ());
break;
case 0x11:
sprintf (buf, "[,%c++]", R);
break;
case 0x13:
sprintf (buf, "[,--%c]", R);
break;
case 0x14:
sprintf (buf, "[,%c]", R);
break;
case 0x15:
sprintf (buf, "[B,%c]", R);
break;
case 0x16:
sprintf (buf, "[A,%c]", R);
break;
case 0x18:
sprintf (buf, "[$%02X,%c]", fetch8 (), R);
break;
case 0x19:
sprintf (buf, "[$%04X,%c]", fetch16 (), R);
break;
case 0x1B:
sprintf (buf, "[D,%c]", R);
break;
case 0x1C:
sprintf (buf, "[$%02X,PC]", fetch8 ());
break;
case 0x1D:
sprintf (buf, "[$%04X,PC]", fetch16 ());
break;
case 0x1F:
sprintf (buf, "[%s]", monitor_addr_name (fetch16 ()));
break;
default:
sprintf (buf, "???");
break;
}
break;
case _rel_byte:
fetch1 = ((INT8) fetch8 ());
sprintf (buf, "%s", absolute_addr_name (fetch1 + pc));
break;
case _rel_word:
sprintf (buf, "%s", absolute_addr_name (fetch16 () + pc));
break;
case _reg_post:
op = fetch8 ();
sprintf (buf, "%s,%s", reg[op >> 4], reg[op & 15]);
break;
case _usr_post:
case _sys_post:
op = fetch8 ();
if (op & 0x80)
strcat (buf, "PC,");
if (op & 0x40)
strcat (buf, am == _usr_post ? "S," : "U,");
if (op & 0x20)
strcat (buf, "Y,");
if (op & 0x10)
strcat (buf, "X,");
if (op & 0x08)
strcat (buf, "DP,");
if ((op & 0x06) == 0x06)
strcat (buf, "D,");
else
{
if (op & 0x04)
strcat (buf, "B,");
if (op & 0x02)
strcat (buf, "A,");
}
if (op & 0x01)
strcat (buf, "CC,");
buf[strlen (buf) - 1] = '\0';
break;
}
return pc - opc;
}
int
sizeof_file (FILE * file)
{
int size;
fseek (file, 0, SEEK_END);
size = ftell (file);
rewind (file);
return size;
}
int
load_map_file (const char *name)
{
FILE *fp;
char map_filename[256];
char buf[256];
char *value_ptr, *id_ptr;
target_addr_t value;
char *file_ptr;
+ struct symbol *sym = NULL;
/* Try appending the suffix 'map' to the name of the program. */
sprintf (map_filename, "%s.map", name);
fp = file_open (NULL, map_filename, "r");
if (!fp)
{
/* If that fails, try replacing any existing suffix. */
sprintf (map_filename, "%s", name);
char *s = strrchr (map_filename, '.');
if (s)
{
sprintf (s+1, "map");
fp = file_open (NULL, map_filename, "r");
}
if (!fp)
{
fprintf (stderr, "warning: no symbols for %s\n", name);
return -1;
}
}
printf ("Reading symbols from '%s'...\n", map_filename);
for (;;)
{
fgets (buf, sizeof(buf)-1, fp);
if (feof (fp))
break;
value_ptr = buf;
if (!strncmp (value_ptr, "page", 4))
{
unsigned char page = strtoul (value_ptr+4, NULL, 10);
- wpc_set_rom_page (page);
+ wpc_set_rom_page (page); /* TODO - genericize */
+ sym = NULL;
continue;
}
if (strncmp (value_ptr, " ", 6))
continue;
while (*value_ptr == ' ')
value_ptr++;
value = strtoul (value_ptr, &id_ptr, 16);
if (id_ptr == value_ptr)
continue;
while (*id_ptr == ' ')
id_ptr++;
id_ptr = strtok (id_ptr, " \t\n");
if (((*id_ptr == 'l') || (*id_ptr == 's')) && (id_ptr[1] == '_'))
continue;
++id_ptr;
file_ptr = strtok (NULL, " \t\n");
- sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */
+ if (sym)
+ sym->ty.size = to_absolute (value) - sym->value;
+ sym = sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */
}
fclose (fp);
return 0;
}
int
load_hex (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open hex record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3)
{
printf ("line %d: invalid hex record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff) + type;
switch (type)
{
case 0:
for (; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid hex record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 1:
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid hex record checksum \n", line);
done = 0;
break;
case 2:
default:
printf ("line %d: not supported hex type %d.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
int
load_s19 (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open S-record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) != 3)
{
printf ("line %d: invalid S record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff);
switch (type)
{
case 1:
for (count -= 3; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 9:
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
default:
printf ("line %d: S%d not supported.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
void
monitor_call (unsigned int flags)
{
#ifdef CALL_STACK
if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call++;
current_function_call->entry_point = get_pc ();
current_function_call->flags = flags;
}
#endif
#if 0
const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ()));
if (id)
{
// printf ("In %s now\n", id);
}
#endif
}
void
monitor_return (void)
{
#ifdef CALL_STACK
if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call--;
return;
}
while ((current_function_call->flags & FC_TAIL_CALL) &&
(current_function_call > fctab))
{
current_function_call--;
}
if (current_function_call > fctab)
current_function_call--;
#endif
}
const char *
absolute_addr_name (absolute_address_t addr)
{
static char buf[256], *bufptr;
const char *name;
bufptr = buf;
bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%-16.16s>", name);
return buf;
}
const char *
monitor_addr_name (target_addr_t target_addr)
{
static char buf[256], *bufptr;
const char *name;
absolute_address_t addr = to_absolute (target_addr);
bufptr = buf;
bufptr += sprintf (bufptr, "0x%04X", target_addr);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%s>", name);
return buf;
}
static void
monitor_signal (int sigtype)
{
(void) sigtype;
putchar ('\n');
monitor_on = 1;
}
void
monitor_init (void)
{
int tmp;
extern int debug_enabled;
target_addr_t a;
fctab[0].entry_point = read16 (0xfffe);
memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs));
current_function_call = &fctab[0];
auto_break_insn_count = 0;
monitor_on = debug_enabled;
signal (SIGINT, monitor_signal);
}
int
check_break (void)
{
if (dump_every_insn)
print_current_insn ();
if (auto_break_insn_count > 0)
if (--auto_break_insn_count == 0)
return 1;
return 0;
}
void
monitor_backtrace (void)
{
struct function_call *fc = current_function_call;
while (fc >= &fctab[0]) {
printf ("%s\n", monitor_addr_name (fc->entry_point));
fc--;
}
}
int
monitor6809 (void)
{
int rc;
signal (SIGINT, monitor_signal);
rc = command_loop ();
monitor_on = 0;
return rc;
}
diff --git a/symtab.c b/symtab.c
index f7058ce..0951329 100644
--- a/symtab.c
+++ b/symtab.c
@@ -1,233 +1,243 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of the Portable 6809 Simulator.
*
* The Simulator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The Simulator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "6809.h"
/* A pointer to the current stringspace */
struct stringspace *current_stringspace;
/* Symbol table for program variables (taken from symbol file) */
struct symtab program_symtab;
/* Symbol table for internal variables. Works identically to the
above but in a different namespace */
struct symtab internal_symtab;
/* Symbol table for the 'autocomputed virtuals'. The values
kept in the table are pointers to functions that compute the
values, allowing for dynamic variables. */
struct symtab auto_symtab;
/**
* Create a new stringspace, which is just a buffer that
* holds strings.
*/
struct stringspace *stringspace_create (void)
{
struct stringspace *ss = malloc (sizeof (struct stringspace));
ss->used = 0;
return ss;
}
/**
* Copy a string into the stringspace. This keeps it around
* permanently; the caller is allowed to free the string
* afterwards.
*/
char *stringspace_copy (const char *string)
{
unsigned int len = strlen (string) + 1;
char *result;
if (current_stringspace->used + len > MAX_STRINGSPACE)
current_stringspace = stringspace_create ();
result = current_stringspace->space + current_stringspace->used;
strcpy (result, string);
current_stringspace->used += len;
return result;
}
unsigned int sym_hash_name (const char *name)
{
unsigned int hash = *name & 0x1F;
if (*name++ != '\0')
{
hash = (hash << 11) + (544 * *name);
if (*name++ != '\0')
{
hash = (hash << 5) + (17 * *name);
}
}
return hash % MAX_SYMBOL_HASH;
}
unsigned int sym_hash_value (unsigned long value)
{
return value % MAX_SYMBOL_HASH;
}
/**
* Lookup the symbol table entry for 'name'.
* Returns NULL if the symbol is not defined.
* If VALUE is not-null, the value is also copied there.
*/
struct symbol *sym_find1 (struct symtab *symtab,
const char *name, unsigned long *value,
unsigned int type)
{
unsigned int hash = sym_hash_name (name);
/* Search starting in the current symbol table, and if that fails,
* try its parent tables. */
while (symtab != NULL)
{
/* Find the list of elements that hashed to this string. */
struct symbol *chain = symtab->syms_by_name[hash];
/* Scan the list for an exact match, and return it. */
while (chain != NULL)
{
if (!strcmp (name, chain->name))
{
if (type && (chain->type != type))
return NULL;
if (value)
*value = chain->value;
return chain;
}
chain = chain->name_chain;
}
symtab = symtab->parent;
}
return NULL;
}
/**
* Lookup the symbol 'name'.
* Returns 0 if the symbol exists (and optionally stores its value
* in *value if not NULL), or -1 if it does not exist.
*/
int sym_find (struct symtab *symtab,
const char *name, unsigned long *value, unsigned int type)
{
return sym_find1 (symtab, name, value, type) ? 0 : -1;
}
const char *sym_lookup (struct symtab *symtab, unsigned long value)
{
unsigned int hash = sym_hash_value (value);
while (symtab != NULL)
{
struct symbol *chain = symtab->syms_by_value[hash];
while (chain != NULL)
{
if (value == chain->value)
return chain->name;
chain = chain->value_chain;
}
symtab = symtab->parent;
}
return NULL;
}
-void sym_add (struct symtab *symtab,
- const char *name, unsigned long value, unsigned int type)
+struct symbol *sym_add (struct symtab *symtab,
+ const char *name, unsigned long value, unsigned int type)
{
unsigned int hash;
struct symbol *s, *chain;
s = malloc (sizeof (struct symbol));
s->name = stringspace_copy (name);
s->value = value;
s->type = type;
+ s->ty.format = 0;
+ s->ty.size = 0;
hash = sym_hash_name (name);
chain = symtab->syms_by_name[hash];
s->name_chain = chain;
symtab->syms_by_name[hash] = s;
hash = sym_hash_value (value);
chain = symtab->syms_by_value[hash];
s->value_chain = chain;
symtab->syms_by_value[hash] = s;
+
+ return s;
}
void sym_set (struct symtab *symtab,
const char *name, unsigned long value, unsigned int type)
{
struct symbol * s = sym_find1 (symtab, name, NULL, type);
if (s)
s->value = value;
else
sym_add (symtab, name, value, type);
}
void for_each_var (void (*cb) (struct symbol *, unsigned int size))
{
struct symtab *symtab = &program_symtab;
absolute_address_t addr;
- const char *sym;
- unsigned int devid = 1;
+ const char *id;
+ struct symbol *sym;
+ unsigned int devid = 1; /* TODO */
for (addr = devid << 28; addr < (devid << 28) + 0x2000; addr++)
{
- sym = sym_lookup (symtab, addr);
- if (sym)
+ id = sym_lookup (symtab, addr);
+ if (id)
{
- printf ("%s = %X\n", sym, addr);
+ sym = sym_find1 (symtab, id, NULL, 0);
+ printf ("%-20.20s %8lX %d\n", id, addr, sym->ty.size);
}
}
}
void symtab_init (struct symtab *symtab)
{
memset (symtab, 0, sizeof (struct symtab));
}
void symtab_reset (struct symtab *symtab)
{
/* TODO */
symtab_init (symtab);
}
void sym_init (void)
{
current_stringspace = stringspace_create ();
+ /* Initialize three symbol tables for general use.
+ * The program_symtab stores names found in the program's
+ * symbol table/map file. The auto symtab has special reserved
+ * names. */
symtab_init (&program_symtab);
symtab_init (&internal_symtab);
symtab_init (&auto_symtab);
}
|
bcd/exec09
|
1471d1abdb5f5f53e04af2f4ea5a4e9ec2de71ff
|
Add (dummy) dump_thread hook to WPC machine.
|
diff --git a/wpc.c b/wpc.c
index e687f8a..2cccf62 100644
--- a/wpc.c
+++ b/wpc.c
@@ -140,612 +140,618 @@ struct wpc_asic
U16 shiftaddr;
U16 shiftbit;
U8 lamp_strobe;
U8 lamp_mx[8];
U8 sols[48];
U8 switch_strobe;
U8 switch_mx[10];
U8 opto_mx[10];
U8 dmd_maps[2];
unsigned int dmd_phase;
U8 dmd_visibles[3];
U8 dmd_last_visibles[3];
int curr_sw;
int curr_sw_time;
int wdog_timer;
} the_wpc;
struct wpc_asic *wpc = NULL;
int wpc_sock;
static int wpc_console_inited = 0;
static U8 wpc_get_console_state (void)
{
fd_set fds;
struct timeval timeout;
U8 rc = WPC_DEBUG_WRITE_READY;
if (!wpc_console_inited)
rc |= WPC_DEBUG_READ_READY;
#if 1
return rc;
#endif
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
rc |= WPC_DEBUG_READ_READY;
return rc;
}
static U8 wpc_console_read (void)
{
int rc;
U8 c = 0;
if (!wpc_console_inited)
{
wpc_console_inited = 1;
return 0;
}
rc = read (0, &c, 1);
return c;
}
static void wpc_console_write (U8 val)
{
putchar (val);
fflush (stdout);
}
static int scanbit (U8 val)
{
if (val & 0x80) return 7;
else if (val & 0x40) return 6;
else if (val & 0x20) return 5;
else if (val & 0x10) return 4;
else if (val & 0x08) return 3;
else if (val & 0x04) return 2;
else if (val & 0x02) return 1;
else if (val & 0x01) return 0;
else return -1;
}
unsigned int wpc_read_switch (int num)
{
unsigned int val;
val = wpc->switch_mx[num / 8] & (1 << (num % 8));
return val ? 1 : 0;
}
void wpc_write_switch (int num, int flag)
{
unsigned int col, val;
col = num / 8;
val = 1 << (num % 8);
#if 0
if (wpc->opto_mx[col] & val)
flag = !flag;
#endif
wpc->switch_mx[col] &= ~val;
if (flag)
wpc->switch_mx[col] |= val;
}
void wpc_press_switch (int num, int delay)
{
wpc_write_switch (num, 1);
wpc->curr_sw = num;
wpc->curr_sw_time = delay;
}
unsigned int wpc_read_switch_column (int col)
{
unsigned int val = 0;
int row;
for (row = 0; row < 8; row++)
if (wpc_read_switch (col * 8 + row))
val |= (1 << row);
return val;
}
void wpc_write_lamp (int num, int flag)
{
}
void wpc_write_sols (int first, U8 val)
{
int i;
for (i=0; i < 8; i++)
{
wpc->sols[first+i] = (val & (1 << i)) ? 1 : 0;
}
}
void wpc_dmd_set_visible (U8 val)
{
char *p;
struct wpc_message msg;
int rc;
int i, n;
static unsigned long last_firq_time = 0;
unsigned long now;
static int no_change_count = 0;
now = get_cycles ();
if (now - last_firq_time <= 1850 * 8)
{
//printf ("%02X ignored.\n", val);
return;
}
else if (now - last_firq_time >= 1850 * 8 * 5)
{
memset (wpc->dmd_visibles, val, 3);
wpc->dmd_phase = 0;
}
else
{
wpc->dmd_visibles[wpc->dmd_phase++] = val;
if (wpc->dmd_phase == 3)
wpc->dmd_phase = 0;
}
last_firq_time = now;
#if 0
printf ("%02X %f\n", val, get_cycles () / 1952.0);
#endif
if (!memcmp (wpc->dmd_visibles, wpc->dmd_last_visibles, 3)
&& (++no_change_count < 100))
return;
no_change_count = 0;
#if 0
printf ("%02X %02X %02X\n",
wpc->dmd_visibles[0],
wpc->dmd_visibles[1],
wpc->dmd_visibles[2]);
#endif
memcpy (wpc->dmd_last_visibles, wpc->dmd_visibles, 3);
/* Send updated page contents */
wpc_msg_init (CODE_DMD_PAGE, &msg);
for (i=0; i < 3; i++)
{
p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512;
msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i];
memcpy (&msg.u.dmdpage.phases[i].data, p, 512);
}
msg.len = sizeof (struct _dmdpage_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
/* Send status of which pages are visible now */
wpc_msg_init (CODE_DMD_VISIBLE, &msg);
for (i=0; i < 3; i++)
msg.u.dmdvisible.phases[i] = wpc->dmd_visibles[i];
msg.len = sizeof (struct _dmdvisible_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
}
void wpc_keypoll (void)
{
fd_set fds;
struct timeval timeout;
int rc;
unsigned char c;
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
{
rc = read (0, &c, 1);
#define BUTTON_DURATION 200
switch (c)
{
case '7':
wpc_press_switch (4, BUTTON_DURATION);
break;
case '8':
wpc_press_switch (5, BUTTON_DURATION);
break;
case '9':
wpc_press_switch (6, BUTTON_DURATION);
break;
case '0':
wpc_press_switch (7, BUTTON_DURATION);
break;
case ',':
wpc_press_switch (75, BUTTON_DURATION);
break;
case '.':
wpc_press_switch (73, BUTTON_DURATION);
break;
default:
printf ("wpc: invalid character '%c'\n", c);
break;
}
}
}
U8 wpc_asic_read (struct hw_device *dev, unsigned long addr)
{
U8 val;
switch (addr + WPC_ASIC_BASE)
{
case WPC_LEDS:
val = wpc->led;
break;
case WPC_ROM_BANK:
val = wpc->rombank;
break;
case WPC_DEBUG_CONTROL_PORT:
val = wpc_get_console_state ();
break;
case WPC_DEBUG_DATA_PORT:
val = wpc_console_read ();
break;
case WPC_SHIFTADDR:
val = wpc->shiftaddr >> 8;
break;
case WPC_SHIFTADDR+1:
val = (wpc->shiftaddr & 0xFF) + (wpc->shiftbit / 8);
break;
case WPC_SHIFTBIT:
val = 1 << (wpc->shiftbit % 8);
break;
case WPC_SW_ROW_INPUT:
{
/* Handle WPC and WPC-S machines differently */
if (wpc->switch_strobe >= 0x16 && wpc->switch_strobe <= 0x1F)
val = wpc_read_switch_column (wpc->switch_strobe - 0x16 + 1);
else
val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
break;
}
case WPC_SW_JUMPER_INPUT:
val = 0x55;
break;
case WPC_SW_CABINET_INPUT:
val = wpc_read_switch_column (0);
break;
case WPC_FLIPTRONIC_PORT_A:
case WPC_FLIPTRONIC_PORT_B:
case WPC95_FLIPPER_SWITCH_INPUT:
val = wpc_read_switch_column (9);
break;
default:
val = 0;
break;
}
//printf (">>> ASIC read %04X -> %02X\n", addr + WPC_ASIC_BASE, val);
return val;
}
/**
* Enforce the current read-only area of RAM.
*/
void wpc_update_ram (void)
{
unsigned int size_writable = WPC_RAM_SIZE;
if (!wpc->ram_unlocked)
{
switch (wpc->ram_lock_size)
{
default:
break;
case 0xF:
size_writable -= 256;
break;
case 0x7:
size_writable -= 512;
case 0x3:
size_writable -= 1024;
break;
case 0x1:
size_writable -= 2048;
break;
case 0:
size_writable -= 4096;
break;
}
}
bus_map (WPC_RAM_BASE, wpc->ram_dev->devid, 0, size_writable, MAP_READWRITE);
if (size_writable < WPC_RAM_SIZE)
bus_map (WPC_RAM_BASE + size_writable, wpc->ram_dev->devid, size_writable,
WPC_RAM_SIZE - size_writable, MAP_READONLY);
}
void wpc_set_rom_page (unsigned char val)
{
bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READONLY);
}
void wpc_set_dmd_page (unsigned int map, unsigned char val)
{
wpc->dmd_maps[map] = val;
bus_map (0x3800 + map * 0x200, 3, val * 0x200, 0x200, MAP_READWRITE);
}
void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr + WPC_ASIC_BASE)
{
case WPC_DMD_LOW_PAGE:
wpc_set_dmd_page (0, val);
break;
case WPC_DMD_HIGH_PAGE:
wpc_set_dmd_page (1, val);
break;
case WPC_DMD_FIRQ_ROW_VALUE:
break;
case WPC_DMD_ACTIVE_PAGE:
wpc_dmd_set_visible (val);
break;
case WPC_LEDS:
wpc->led = val;
break;
case WPC_ZEROCROSS_IRQ_CLEAR:
wpc->wdog_timer++;
break;
case WPC_ROM_BANK:
wpc->rombank = val;
wpc_set_rom_page (val);
break;
case WPC_DEBUG_DATA_PORT:
wpc_console_write (val);
break;
case WPC_RAM_LOCK:
wpc->ram_unlocked = val;
wpc_update_ram ();
break;
case WPC_RAM_LOCKSIZE:
wpc->ram_lock_size = val;
wpc_update_ram ();
break;
case WPC_SHIFTADDR:
wpc->shiftaddr &= 0x00FF;
wpc->shiftaddr |= val << 8;
break;
case WPC_SHIFTADDR+1:
wpc->shiftaddr &= 0xFF00;
wpc->shiftaddr |= val;
break;
case WPC_SHIFTBIT:
wpc->shiftbit = val;
break;
case WPC_LAMP_ROW_OUTPUT:
wpc->lamp_mx[scanbit (wpc->lamp_strobe)] = val;
break;
case WPC_LAMP_COL_STROBE:
wpc->lamp_strobe = val;
break;
case WPC_SW_COL_STROBE:
wpc->switch_strobe = val;
break;
case WPC_SOL_FLASH2_OUTPUT:
case WPC_SOL_HIGHPOWER_OUTPUT:
case WPC_SOL_FLASH1_OUTPUT:
case WPC_SOL_LOWPOWER_OUTPUT:
if (val != 0)
printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
break;
default:
break;
}
//printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
}
void wpc_periodic (void)
{
wpc_keypoll ();
wpc->wdog_timer -= 50;
if (wpc->wdog_timer <= 0)
{
}
if (wpc->curr_sw_time > 0)
{
wpc->curr_sw_time -= 100;
if (wpc->curr_sw_time <= 0)
{
wpc->curr_sw_time = 0;
wpc_write_switch (wpc->curr_sw, 0);
}
}
}
void wpc_asic_reset (struct hw_device *dev)
{
memset (wpc, 0, sizeof (struct wpc_asic));
wpc_write_switch (19, 1); /* Always Closed */
}
struct hw_class wpc_asic_class =
{
.reset = wpc_asic_reset,
.read = wpc_asic_read,
.write = wpc_asic_write,
};
struct hw_device *wpc_asic_create (void)
{
if (wpc)
{
fprintf (stderr, "WPC ASIC already created\n");
return NULL;
}
wpc = &the_wpc;
return device_attach (&wpc_asic_class, 0x800, wpc);
}
void wpc_fault (unsigned int addr, unsigned char type)
{
}
+void wpc_dump_thread (unsigned long addr)
+{
+}
+
void io_sym_add (const char *name, unsigned long cpuaddr)
{
sym_add (&program_symtab, name, to_absolute (cpuaddr), 0);
}
#define IO_SYM_ADD(name) io_sym_add (#name, name)
void wpc_init (const char *boot_rom_file)
{
struct hw_device *dev;
int rc;
struct sockaddr_in myaddr;
device_define ( dev = wpc_asic_create (), 0,
WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE);
device_define ( dev = ram_create (WPC_RAM_SIZE), 0,
WPC_RAM_BASE, WPC_RAM_SIZE, MAP_READWRITE );
wpc->ram_dev = dev;
dev = rom_create (boot_rom_file, WPC_ROM_SIZE);
device_define ( dev, 0,
WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READONLY);
device_define ( dev, WPC_ROM_SIZE - WPC_FIXED_SIZE,
WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READONLY);
wpc->rom_dev = dev;
device_define ( dev = ram_create (16 * 512), 0,
0x3800, 0x200 * 2, MAP_READWRITE );
wpc->dmd_dev = dev;
wpc_update_ram ();
wpc_sock = udp_socket_create (9000);
if (wpc_sock < 0)
fprintf (stderr, "could not open output socket\n");
IO_SYM_ADD(WPC_DMD_LOW_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_PAGE);
IO_SYM_ADD(WPC_DMD_FIRQ_ROW_VALUE);
IO_SYM_ADD(WPC_DMD_LOW_PAGE);
IO_SYM_ADD(WPC_DMD_ACTIVE_PAGE);
IO_SYM_ADD(WPC_SERIAL_STATUS_PORT);
IO_SYM_ADD(WPC_PARALLEL_DATA_PORT);
IO_SYM_ADD(WPC_PARALLEL_STROBE_PORT);
IO_SYM_ADD(WPC_SERIAL_DATA_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_CONTROL_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_BAUD_SELECT);
IO_SYM_ADD(WPC_TICKET_DISPENSE);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_OUT);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_IN);
IO_SYM_ADD(WPC_DCS_SOUND_RESET);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_READY);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_A);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_B);
IO_SYM_ADD(WPCS_DATA);
IO_SYM_ADD(WPCS_CONTROL_STATUS);
IO_SYM_ADD(WPC_SOL_FLASH2_OUTPUT);
IO_SYM_ADD(WPC_SOL_HIGHPOWER_OUTPUT);
IO_SYM_ADD(WPC_SOL_FLASH1_OUTPUT);
IO_SYM_ADD(WPC_SOL_LOWPOWER_OUTPUT);
IO_SYM_ADD(WPC_LAMP_ROW_OUTPUT);
IO_SYM_ADD(WPC_LAMP_COL_STROBE);
IO_SYM_ADD(WPC_GI_TRIAC);
IO_SYM_ADD(WPC_SW_JUMPER_INPUT);
IO_SYM_ADD(WPC_SW_CABINET_INPUT);
IO_SYM_ADD(WPC_SW_ROW_INPUT);
IO_SYM_ADD(WPC_SW_COL_STROBE);
IO_SYM_ADD(WPC_LEDS);
IO_SYM_ADD(WPC_RAM_BANK);
IO_SYM_ADD(WPC_SHIFTADDR);
IO_SYM_ADD(WPC_SHIFTBIT);
IO_SYM_ADD(WPC_SHIFTBIT2);
IO_SYM_ADD(WPC_PERIPHERAL_TIMER_FIRQ_CLEAR);
IO_SYM_ADD(WPC_ROM_LOCK);
IO_SYM_ADD(WPC_CLK_HOURS_DAYS);
IO_SYM_ADD(WPC_CLK_MINS);
IO_SYM_ADD(WPC_ROM_BANK);
IO_SYM_ADD(WPC_RAM_LOCK);
IO_SYM_ADD(WPC_RAM_LOCKSIZE);
}
struct machine wpc_machine =
{
.name = "wpc",
.fault = wpc_fault,
.init = wpc_init,
+ .dump_thread = wpc_dump_thread,
};
struct machine wpc95_machine =
{
.name = "wpc95",
.fault = wpc_fault,
.init = wpc_init,
+ .dump_thread = wpc_dump_thread,
};
|
bcd/exec09
|
c78233f231ca4c2ef3cc731ec8436708c85c7a21
|
Cleanup.
|
diff --git a/6809.c b/6809.c
index fd66bbd..f8b0a81 100644
--- a/6809.c
+++ b/6809.c
@@ -1,528 +1,528 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006, 2007 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "6809.h"
#include "monitor.h"
#include <stdarg.h>
unsigned X, Y, S, U, PC;
unsigned A, B, DP;
unsigned H, N, Z, OV, C;
unsigned EFI;
#ifdef H6309
unsigned E, F, V, MD;
#define MD_NATIVE 0x1 /* if 1, execute in 6309 mode */
#define MD_FIRQ_LIKE_IRQ 0x2 /* if 1, FIRQ acts like IRQ */
#define MD_ILL 0x40 /* illegal instruction */
#define MD_DBZ 0x80 /* divide by zero */
#endif /* H6309 */
unsigned iPC;
unsigned long irq_start_time;
unsigned ea = 0;
long cpu_clk = 0;
long cpu_period = 0;
int cpu_quit = 1;
unsigned int irqs_pending = 0;
unsigned int firqs_pending = 0;
unsigned int cc_changed = 0;
unsigned *index_regs[4] = { &X, &Y, &U, &S };
extern int dump_cycles_on_success;
extern int trace_enabled;
extern void irq (void);
extern void firq (void);
void request_irq (unsigned int source)
{
/* If the interrupt is not masked, generate
* IRQ immediately. Else, mark it pending and
* we'll check it later when the flags change.
*/
irqs_pending |= (1 << source);
if (!(EFI & I_FLAG))
irq ();
}
void release_irq (unsigned int source)
{
irqs_pending &= ~(1 << source);
}
void request_firq (unsigned int source)
{
/* If the interrupt is not masked, generate
* IRQ immediately. Else, mark it pending and
* we'll check it later when the flags change.
*/
firqs_pending |= (1 << source);
if (!(EFI & F_FLAG))
firq ();
}
void release_firq (unsigned int source)
{
firqs_pending &= ~(1 << source);
}
static inline void
check_pc (void)
{
/* TODO */
}
static inline void
check_stack (void)
{
/* TODO */
}
void
sim_error (const char *format, ...)
{
va_list ap;
va_start (ap, format);
fprintf (stderr, "m6809-run: (at PC=%04X) ", iPC);
vfprintf (stderr, format, ap);
va_end (ap);
if (debug_enabled)
monitor_on = 1;
else
exit (2);
}
unsigned long
get_cycles (void)
{
return total + cpu_period - cpu_clk;
}
void
sim_exit (uint8_t exit_code)
{
char *s;
/* On a nonzero exit, always print an error message. */
if (exit_code != 0)
{
printf ("m6809-run: program exited with %d\n", exit_code);
if (exit_code)
monitor_backtrace ();
}
/* If a cycle count should be printed, do that last. */
if (dump_cycles_on_success)
{
printf ("%s : %ld cycles, %ld ms\n", prog_name, get_cycles (),
get_elapsed_realtime ());
}
if ((s = getenv ("LOG6809")) != NULL)
{
FILE *fp = fopen (s, "a");
if (fp)
{
fprintf (fp, "%s : %ld cycles, %ld ms\n", prog_name, get_cycles (),
get_elapsed_realtime ());
fclose (fp);
}
}
exit (exit_code);
}
static inline void
change_pc (unsigned newPC)
{
#if 0
/* TODO - will let some RAM execute for trampolines */
if ((newPC < 0x1C00) || (newPC > 0xFFFF))
{
fprintf (stderr, "m6809-run: invalid PC = %04X, previous was %s\n",
newPC, monitor_addr_name (PC));
exit (2);
}
if (trace_enabled)
{
fprintf (stderr, "PC : %s ", monitor_addr_name (PC));
fprintf (stderr, "-> %s\n", monitor_addr_name (newPC));
}
#endif
PC = newPC;
}
static inline unsigned
imm_byte (void)
{
unsigned val = read8 (PC);
PC++;
return val;
}
static inline unsigned
imm_word (void)
{
unsigned val = read16 (PC);
PC += 2;
return val;
}
#define WRMEM(addr, data) write8 (addr, data)
static void
WRMEM16 (unsigned addr, unsigned data)
{
WRMEM (addr, data >> 8);
cpu_clk--;
WRMEM ((addr + 1) & 0xffff, data & 0xff);
}
#define RDMEM(addr) read8 (addr)
static unsigned
RDMEM16 (unsigned addr)
{
unsigned val = RDMEM (addr) << 8;
cpu_clk--;
val |= RDMEM ((addr + 1) & 0xffff);
return val;
}
#define write_stack WRMEM
#define read_stack RDMEM
static void
write_stack16 (unsigned addr, unsigned data)
{
write_stack ((addr + 1) & 0xffff, data & 0xff);
write_stack (addr, data >> 8);
}
static unsigned
read_stack16 (unsigned addr)
{
return (read_stack (addr) << 8) | read_stack ((addr + 1) & 0xffff);
}
static void
direct (void)
{
unsigned val = read8 (PC) | DP;
PC++;
ea = val;
}
static void
indexed (void) /* note take 1 extra cycle */
{
unsigned post = imm_byte ();
unsigned *R = index_regs[(post >> 5) & 0x3];
if (post & 0x80)
{
switch (post & 0x1f)
{
case 0x00:
ea = *R;
*R = (*R + 1) & 0xffff;
cpu_clk -= 6;
break;
case 0x01:
ea = *R;
*R = (*R + 2) & 0xffff;
cpu_clk -= 7;
break;
case 0x02:
*R = (*R - 1) & 0xffff;
ea = *R;
cpu_clk -= 6;
break;
case 0x03:
*R = (*R - 2) & 0xffff;
ea = *R;
cpu_clk -= 7;
break;
case 0x04:
ea = *R;
cpu_clk -= 4;
break;
case 0x05:
ea = (*R + ((INT8) B)) & 0xffff;
cpu_clk -= 5;
break;
case 0x06:
ea = (*R + ((INT8) A)) & 0xffff;
cpu_clk -= 5;
break;
case 0x08:
ea = (*R + ((INT8) imm_byte ())) & 0xffff;
cpu_clk -= 5;
break;
case 0x09:
ea = (*R + imm_word ()) & 0xffff;
cpu_clk -= 8;
break;
case 0x0b:
ea = (*R + get_d ()) & 0xffff;
cpu_clk -= 8;
break;
case 0x0c:
ea = (INT8) imm_byte ();
ea = (ea + PC) & 0xffff;
cpu_clk -= 5;
break;
case 0x0d:
ea = imm_word ();
ea = (ea + PC) & 0xffff;
cpu_clk -= 9;
break;
case 0x11:
ea = *R;
*R = (*R + 2) & 0xffff;
cpu_clk -= 7;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x13:
*R = (*R - 2) & 0xffff;
ea = *R;
cpu_clk -= 7;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x14:
ea = *R;
cpu_clk -= 4;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x15:
ea = (*R + ((INT8) B)) & 0xffff;
cpu_clk -= 5;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x16:
ea = (*R + ((INT8) A)) & 0xffff;
cpu_clk -= 5;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x18:
ea = (*R + ((INT8) imm_byte ())) & 0xffff;
cpu_clk -= 5;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x19:
ea = (*R + imm_word ()) & 0xffff;
cpu_clk -= 8;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x1b:
ea = (*R + get_d ()) & 0xffff;
cpu_clk -= 8;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x1c:
ea = (INT8) imm_byte ();
ea = (ea + PC) & 0xffff;
cpu_clk -= 5;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x1d:
ea = imm_word ();
ea = (ea + PC) & 0xffff;
cpu_clk -= 9;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
case 0x1f:
ea = imm_word ();
cpu_clk -= 6;
ea = RDMEM16 (ea);
cpu_clk -= 2;
break;
default:
ea = 0;
sim_error ("invalid index post $%02X\n", post);
break;
}
}
else
{
if (post & 0x10)
post |= 0xfff0;
else
post &= 0x000f;
ea = (*R + post) & 0xffff;
cpu_clk -= 5;
}
}
static void
extended (void)
{
unsigned val = read16 (PC);
PC += 2;
ea = val;
}
/* external register functions */
unsigned
get_a (void)
{
return A;
}
unsigned
get_b (void)
{
return B;
}
unsigned
get_dp (void)
{
return DP >> 8;
}
unsigned
get_x (void)
{
return X;
}
unsigned
get_y (void)
{
return Y;
}
unsigned
get_s (void)
{
return S;
}
unsigned
get_u (void)
{
return U;
}
unsigned
get_pc (void)
{
return PC & 0xffff;
}
unsigned
get_d (void)
{
return (A << 8) | B;
}
unsigned
get_flags (void)
{
return EFI;
}
#ifdef H6309
unsigned
get_e (void)
{
return E;
}
unsigned
get_f (void)
{
return F;
}
unsigned
get_w (void)
{
return (E << 8) | F;
}
unsigned
get_q (void)
{
return (get_w () << 16) | get_d ();
}
unsigned
get_v (void)
{
return V;
}
unsigned
get_zero (void)
{
return 0;
}
unsigned
get_md (void)
{
return MD;
}
#endif
void
set_a (unsigned val)
{
A = val & 0xff;
}
void
set_b (unsigned val)
{
@@ -1224,1041 +1224,1042 @@ pshs (void)
}
if (post & 0x40)
{
cpu_clk -= 2;
S = (S - 2) & 0xffff;
write_stack16 (S, U);
}
if (post & 0x20)
{
cpu_clk -= 2;
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
}
if (post & 0x10)
{
cpu_clk -= 2;
S = (S - 2) & 0xffff;
write_stack16 (S, X);
}
if (post & 0x08)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
}
if (post & 0x04)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, B);
}
if (post & 0x02)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, A);
}
if (post & 0x01)
{
cpu_clk -= 1;
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
}
}
static void
pshu (void)
{
unsigned post = imm_byte ();
cpu_clk -= 5;
if (post & 0x80)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, PC & 0xffff);
}
if (post & 0x40)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, S);
}
if (post & 0x20)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, Y);
}
if (post & 0x10)
{
cpu_clk -= 2;
U = (U - 2) & 0xffff;
write_stack16 (U, X);
}
if (post & 0x08)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, DP >> 8);
}
if (post & 0x04)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, B);
}
if (post & 0x02)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, A);
}
if (post & 0x01)
{
cpu_clk -= 1;
U = (U - 1) & 0xffff;
write_stack (U, get_cc ());
}
}
static void
puls (void)
{
unsigned post = imm_byte ();
cpu_clk -= 5;
if (post & 0x01)
{
cpu_clk -= 1;
set_cc (read_stack (S));
S = (S + 1) & 0xffff;
}
if (post & 0x02)
{
cpu_clk -= 1;
A = read_stack (S);
S = (S + 1) & 0xffff;
}
if (post & 0x04)
{
cpu_clk -= 1;
B = read_stack (S);
S = (S + 1) & 0xffff;
}
if (post & 0x08)
{
cpu_clk -= 1;
DP = read_stack (S) << 8;
S = (S + 1) & 0xffff;
}
if (post & 0x10)
{
cpu_clk -= 2;
X = read_stack16 (S);
S = (S + 2) & 0xffff;
}
if (post & 0x20)
{
cpu_clk -= 2;
Y = read_stack16 (S);
S = (S + 2) & 0xffff;
}
if (post & 0x40)
{
cpu_clk -= 2;
U = read_stack16 (S);
S = (S + 2) & 0xffff;
}
if (post & 0x80)
{
monitor_return ();
cpu_clk -= 2;
PC = read_stack16 (S);
check_pc ();
S = (S + 2) & 0xffff;
}
}
static void
pulu (void)
{
unsigned post = imm_byte ();
cpu_clk -= 5;
if (post & 0x01)
{
cpu_clk -= 1;
set_cc (read_stack (U));
U = (U + 1) & 0xffff;
}
if (post & 0x02)
{
cpu_clk -= 1;
A = read_stack (U);
U = (U + 1) & 0xffff;
}
if (post & 0x04)
{
cpu_clk -= 1;
B = read_stack (U);
U = (U + 1) & 0xffff;
}
if (post & 0x08)
{
cpu_clk -= 1;
DP = read_stack (U) << 8;
U = (U + 1) & 0xffff;
}
if (post & 0x10)
{
cpu_clk -= 2;
X = read_stack16 (U);
U = (U + 2) & 0xffff;
}
if (post & 0x20)
{
cpu_clk -= 2;
Y = read_stack16 (U);
U = (U + 2) & 0xffff;
}
if (post & 0x40)
{
cpu_clk -= 2;
S = read_stack16 (U);
U = (U + 2) & 0xffff;
}
if (post & 0x80)
{
monitor_return ();
cpu_clk -= 2;
PC = read_stack16 (U);
check_pc ();
U = (U + 2) & 0xffff;
}
}
/* Miscellaneous Instructions */
static void
nop (void)
{
cpu_clk -= 2;
}
static void
jsr (void)
{
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
change_pc (ea);
monitor_call (0);
}
static void
rti (void)
{
monitor_return ();
cpu_clk -= 6;
command_exit_irq_hook (get_cycles () - irq_start_time);
set_cc (read_stack (S));
S = (S + 1) & 0xffff;
if ((EFI & E_FLAG) != 0)
{
cpu_clk -= 9;
A = read_stack (S);
S = (S + 1) & 0xffff;
B = read_stack (S);
S = (S + 1) & 0xffff;
DP = read_stack (S) << 8;
S = (S + 1) & 0xffff;
X = read_stack16 (S);
S = (S + 2) & 0xffff;
Y = read_stack16 (S);
S = (S + 2) & 0xffff;
U = read_stack16 (S);
S = (S + 2) & 0xffff;
}
PC = read_stack16 (S);
check_pc ();
S = (S + 2) & 0xffff;
}
static void
rts (void)
{
monitor_return ();
cpu_clk -= 5;
PC = read_stack16 (S);
check_pc ();
S = (S + 2) & 0xffff;
}
void
irq (void)
{
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
EFI |= I_FLAG;
irq_start_time = get_cycles ();
change_pc (read16 (0xfff8));
#if 1
irqs_pending = 0;
#endif
}
void
firq (void)
{
EFI &= ~E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
EFI |= (I_FLAG | F_FLAG);
change_pc (read16 (0xfff6));
#if 1
firqs_pending = 0;
#endif
}
void
swi (void)
{
cpu_clk -= 19;
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
EFI |= (I_FLAG | F_FLAG);
change_pc (read16 (0xfffa));
}
void
swi2 (void)
{
cpu_clk -= 20;
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
change_pc (read16 (0xfff4));
}
void
swi3 (void)
{
cpu_clk -= 20;
EFI |= E_FLAG;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
S = (S - 2) & 0xffff;
write_stack16 (S, U);
S = (S - 2) & 0xffff;
write_stack16 (S, Y);
S = (S - 2) & 0xffff;
write_stack16 (S, X);
S = (S - 1) & 0xffff;
write_stack (S, DP >> 8);
S = (S - 1) & 0xffff;
write_stack (S, B);
S = (S - 1) & 0xffff;
write_stack (S, A);
S = (S - 1) & 0xffff;
write_stack (S, get_cc ());
change_pc (read16 (0xfff2));
}
void
cwai (void)
{
sim_error ("CWAI - not supported yet!");
}
void
sync (void)
{
cpu_clk -= 4;
sim_error ("SYNC - not supported yet!");
}
static void
orcc (void)
{
unsigned tmp = imm_byte ();
set_cc (get_cc () | tmp);
cpu_clk -= 3;
}
static void
andcc (void)
{
unsigned tmp = imm_byte ();
set_cc (get_cc () & tmp);
cpu_clk -= 3;
}
/* Branch Instructions */
#define cond_HI() ((Z != 0) && (C == 0))
#define cond_LS() ((Z == 0) || (C != 0))
#define cond_HS() (C == 0)
#define cond_LO() (C != 0)
#define cond_NE() (Z != 0)
#define cond_EQ() (Z == 0)
#define cond_VC() ((OV & 0x80) == 0)
#define cond_VS() ((OV & 0x80) != 0)
#define cond_PL() ((N & 0x80) == 0)
#define cond_MI() ((N & 0x80) != 0)
#define cond_GE() (((N^OV) & 0x80) == 0)
#define cond_LT() (((N^OV) & 0x80) != 0)
#define cond_GT() ((((N^OV) & 0x80) == 0) && (Z != 0))
#define cond_LE() ((((N^OV) & 0x80) != 0) || (Z == 0))
static void
bra (void)
{
INT8 tmp = (INT8) imm_byte ();
change_pc (PC + tmp);
}
static void
branch (unsigned cond)
{
if (cond)
bra ();
else
change_pc (PC+1);
cpu_clk -= 3;
}
static void
long_bra (void)
{
INT16 tmp = (INT16) imm_word ();
change_pc (PC + tmp);
}
static void
long_branch (unsigned cond)
{
if (cond)
{
long_bra ();
cpu_clk -= 6;
}
else
{
change_pc (PC + 2);
cpu_clk -= 5;
}
}
static void
long_bsr (void)
{
INT16 tmp = (INT16) imm_word ();
ea = PC + tmp;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
cpu_clk -= 9;
change_pc (ea);
monitor_call (0);
}
static void
bsr (void)
{
INT8 tmp = (INT8) imm_byte ();
ea = PC + tmp;
S = (S - 2) & 0xffff;
write_stack16 (S, PC & 0xffff);
cpu_clk -= 7;
change_pc (ea);
monitor_call (0);
}
-/* execute 6809 code */
+/* Execute 6809 code for a certain number of cycles. */
int
cpu_execute (int cycles)
{
unsigned opcode;
cpu_period = cpu_clk = cycles;
do
{
command_insn_hook ();
- if (check_break () != 0)
- monitor_on = 1;
- if (monitor_on != 0)
- if (monitor6809 () != 0)
- goto cpu_exit;
+ if (check_break () != 0)
+ monitor_on = 1;
+
+ if (monitor_on != 0)
+ if (monitor6809 () != 0)
+ goto cpu_exit;
iPC = PC;
opcode = imm_byte ();
switch (opcode)
{
case 0x00:
direct ();
cpu_clk -= 4;
WRMEM (ea, neg (RDMEM (ea)));
break; /* NEG direct */
#ifdef H6309
case 0x01: /* OIM */
break;
case 0x02: /* AIM */
break;
#endif
case 0x03:
direct ();
cpu_clk -= 4;
WRMEM (ea, com (RDMEM (ea)));
break; /* COM direct */
case 0x04:
direct ();
cpu_clk -= 4;
WRMEM (ea, lsr (RDMEM (ea)));
break; /* LSR direct */
#ifdef H6309
case 0x05: /* EIM */
break;
#endif
case 0x06:
direct ();
cpu_clk -= 4;
WRMEM (ea, ror (RDMEM (ea)));
break; /* ROR direct */
case 0x07:
direct ();
cpu_clk -= 4;
WRMEM (ea, asr (RDMEM (ea)));
break; /* ASR direct */
case 0x08:
direct ();
cpu_clk -= 4;
WRMEM (ea, asl (RDMEM (ea)));
break; /* ASL direct */
case 0x09:
direct ();
cpu_clk -= 4;
WRMEM (ea, rol (RDMEM (ea)));
break; /* ROL direct */
case 0x0a:
direct ();
cpu_clk -= 4;
WRMEM (ea, dec (RDMEM (ea)));
break; /* DEC direct */
#ifdef H6309
case 0x0B: /* TIM */
break;
#endif
case 0x0c:
direct ();
cpu_clk -= 4;
WRMEM (ea, inc (RDMEM (ea)));
break; /* INC direct */
case 0x0d:
direct ();
cpu_clk -= 4;
tst (RDMEM (ea));
break; /* TST direct */
case 0x0e:
direct ();
cpu_clk -= 3;
PC = ea;
check_pc ();
monitor_call (FC_TAIL_CALL);
break; /* JMP direct */
case 0x0f:
direct ();
cpu_clk -= 4;
WRMEM (ea, clr (RDMEM (ea)));
break; /* CLR direct */
case 0x10:
{
opcode = imm_byte ();
switch (opcode)
{
case 0x21:
cpu_clk -= 5;
PC += 2;
break;
case 0x22:
long_branch (cond_HI ());
break;
case 0x23:
long_branch (cond_LS ());
break;
case 0x24:
long_branch (cond_HS ());
break;
case 0x25:
long_branch (cond_LO ());
break;
case 0x26:
long_branch (cond_NE ());
break;
case 0x27:
long_branch (cond_EQ ());
break;
case 0x28:
long_branch (cond_VC ());
break;
case 0x29:
long_branch (cond_VS ());
break;
case 0x2a:
long_branch (cond_PL ());
break;
case 0x2b:
long_branch (cond_MI ());
break;
case 0x2c:
long_branch (cond_GE ());
break;
case 0x2d:
long_branch (cond_LT ());
break;
case 0x2e:
long_branch (cond_GT ());
break;
case 0x2f:
long_branch (cond_LE ());
break;
#ifdef H6309
case 0x30: /* ADDR */
break;
case 0x31: /* ADCR */
break;
case 0x32: /* SUBR */
break;
case 0x33: /* SBCR */
break;
case 0x34: /* ANDR */
break;
case 0x35: /* ORR */
break;
case 0x36: /* EORR */
break;
case 0x37: /* CMPR */
break;
case 0x38: /* PSHSW */
break;
case 0x39: /* PULSW */
break;
case 0x3a: /* PSHUW */
break;
case 0x3b: /* PULUW */
break;
#endif
case 0x3f:
swi2 ();
break;
#ifdef H6309
case 0x40: /* NEGD */
break;
case 0x43: /* COMD */
break;
case 0x44: /* LSRD */
break;
case 0x46: /* RORD */
break;
case 0x47: /* ASRD */
break;
case 0x48: /* ASLD/LSLD */
break;
case 0x49: /* ROLD */
break;
case 0x4a: /* DECD */
break;
case 0x4c: /* INCD */
break;
case 0x4d: /* TSTD */
break;
case 0x4f: /* CLRD */
break;
case 0x53: /* COMW */
break;
case 0x54: /* LSRW */
break;
case 0x56: /* ??RORW */
break;
case 0x59: /* ROLW */
break;
case 0x5a: /* DECW */
break;
case 0x5c: /* INCW */
break;
case 0x5d: /* TSTW */
break;
case 0x5f: /* CLRW */
break;
case 0x80: /* SUBW */
break;
case 0x81: /* CMPW */
break;
case 0x82: /* SBCD */
break;
#endif
case 0x83:
cpu_clk -= 5;
cmp16 (get_d (), imm_word ());
break;
#ifdef H6309
case 0x84: /* ANDD */
break;
case 0x85: /* BITD */
break;
case 0x86: /* LDW */
break;
case 0x88: /* EORD */
break;
case 0x89: /* ADCD */
break;
case 0x8a: /* ORD */
break;
case 0x8b: /* ADDW */
break;
#endif
case 0x8c:
cpu_clk -= 5;
cmp16 (Y, imm_word ());
break;
case 0x8e:
cpu_clk -= 4;
Y = ld16 (imm_word ());
break;
#ifdef H6309
case 0x90: /* SUBW */
break;
case 0x91: /* CMPW */
break;
case 0x92: /* SBCD */
break;
#endif
case 0x93:
direct ();
cpu_clk -= 5;
cmp16 (get_d (), RDMEM16 (ea));
cpu_clk--;
break;
case 0x9c:
direct ();
cpu_clk -= 5;
cmp16 (Y, RDMEM16 (ea));
cpu_clk--;
break;
case 0x9e:
direct ();
cpu_clk -= 5;
Y = ld16 (RDMEM16 (ea));
break;
case 0x9f:
direct ();
cpu_clk -= 5;
st16 (Y);
break;
case 0xa3:
cpu_clk--;
indexed ();
cmp16 (get_d (), RDMEM16 (ea));
cpu_clk--;
break;
case 0xac:
cpu_clk--;
indexed ();
cmp16 (Y, RDMEM16 (ea));
cpu_clk--;
break;
case 0xae:
cpu_clk--;
indexed ();
Y = ld16 (RDMEM16 (ea));
break;
case 0xaf:
cpu_clk--;
indexed ();
st16 (Y);
break;
case 0xb3:
extended ();
cpu_clk -= 6;
cmp16 (get_d (), RDMEM16 (ea));
cpu_clk--;
break;
case 0xbc:
extended ();
cpu_clk -= 6;
cmp16 (Y, RDMEM16 (ea));
cpu_clk--;
break;
case 0xbe:
extended ();
cpu_clk -= 6;
Y = ld16 (RDMEM16 (ea));
break;
case 0xbf:
extended ();
cpu_clk -= 6;
st16 (Y);
break;
case 0xce:
cpu_clk -= 4;
S = ld16 (imm_word ());
break;
case 0xde:
direct ();
cpu_clk -= 5;
S = ld16 (RDMEM16 (ea));
break;
case 0xdf:
direct ();
cpu_clk -= 5;
st16 (S);
break;
case 0xee:
cpu_clk--;
indexed ();
S = ld16 (RDMEM16 (ea));
break;
case 0xef:
cpu_clk--;
indexed ();
st16 (S);
break;
case 0xfe:
extended ();
cpu_clk -= 6;
S = ld16 (RDMEM16 (ea));
break;
case 0xff:
extended ();
cpu_clk -= 6;
st16 (S);
break;
default:
sim_error ("invalid opcode (1) at %s\n", monitor_addr_name (iPC));
break;
}
}
break;
case 0x11:
{
opcode = imm_byte ();
switch (opcode)
{
case 0x3f:
swi3 ();
break;
case 0x83:
cpu_clk -= 5;
cmp16 (U, imm_word ());
break;
case 0x8c:
cpu_clk -= 5;
cmp16 (S, imm_word ());
break;
case 0x93:
direct ();
cpu_clk -= 5;
cmp16 (U, RDMEM16 (ea));
cpu_clk--;
break;
case 0x9c:
direct ();
cpu_clk -= 5;
cmp16 (S, RDMEM16 (ea));
cpu_clk--;
break;
case 0xa3:
cpu_clk--;
indexed ();
cmp16 (U, RDMEM16 (ea));
cpu_clk--;
break;
case 0xac:
cpu_clk--;
indexed ();
cmp16 (S, RDMEM16 (ea));
cpu_clk--;
break;
case 0xb3:
extended ();
cpu_clk -= 6;
cmp16 (U, RDMEM16 (ea));
cpu_clk--;
break;
case 0xbc:
extended ();
cpu_clk -= 6;
cmp16 (S, RDMEM16 (ea));
cpu_clk--;
break;
default:
sim_error ("invalid opcode (2) at %s\n", monitor_addr_name (iPC));
break;
}
}
break;
case 0x12:
nop ();
break;
case 0x13:
sync ();
break;
#ifdef H6309
case 0x14: /* SEXW */
break;
#endif
case 0x16:
long_bra ();
cpu_clk -= 5;
break;
case 0x17:
long_bsr ();
break;
case 0x19:
daa ();
break;
case 0x1a:
orcc ();
break;
case 0x1c:
andcc ();
break;
case 0x1d:
sex ();
break;
case 0x1e:
exg ();
break;
case 0x1f:
tfr ();
break;
case 0x20:
bra ();
cpu_clk -= 3;
break;
case 0x21:
PC++;
cpu_clk -= 3;
break;
case 0x22:
branch (cond_HI ());
break;
case 0x23:
branch (cond_LS ());
break;
case 0x24:
branch (cond_HS ());
break;
case 0x25:
branch (cond_LO ());
break;
case 0x26:
branch (cond_NE ());
break;
case 0x27:
branch (cond_EQ ());
break;
case 0x28:
branch (cond_VC ());
break;
case 0x29:
branch (cond_VS ());
break;
case 0x2a:
branch (cond_PL ());
break;
case 0x2b:
branch (cond_MI ());
break;
case 0x2c:
branch (cond_GE ());
break;
case 0x2d:
branch (cond_LT ());
break;
case 0x2e:
branch (cond_GT ());
break;
case 0x2f:
branch (cond_LE ());
break;
case 0x30:
indexed ();
Z = X = ea;
break; /* LEAX indexed */
case 0x31:
indexed ();
Z = Y = ea;
break; /* LEAY indexed */
case 0x32:
indexed ();
S = ea;
break; /* LEAS indexed */
case 0x33:
|
bcd/exec09
|
8a5d03380abd2dcf67d568a63a6e00bcd0b99858
|
Fix the 'runfor' command.
|
diff --git a/command.c b/command.c
index e0d68e8..5eade79 100644
--- a/command.c
+++ b/command.c
@@ -489,1026 +489,1033 @@ display_alloc (void)
display_t *ds = &displaytab[n];
if (!ds->used)
{
ds->used = 1;
return ds;
}
}
}
void
display_free (display_t *ds)
{
}
void
print_value (unsigned long val, datatype_t *typep)
{
char f[8];
switch (typep->format)
{
case 'a':
print_addr (val);
return;
case 's':
{
absolute_address_t addr = (absolute_address_t)val;
char c;
putchar ('"');
while ((c = abs_read8 (addr++)) != '\0')
putchar (c);
putchar ('"');
return;
}
}
if (typep->format == 'x')
{
printf ("0x");
sprintf (f, "%%0%d%c", typep->size * 2, typep->format);
}
else if (typep->format == 'o')
{
printf ("0");
sprintf (f, "%%%c", typep->format);
}
else
sprintf (f, "%%%c", typep->format);
printf (f, val);
}
void
display_print (void)
{
unsigned int n;
char comma = '\0';
for (n = 0; n < MAX_DISPLAYS; n++)
{
display_t *ds = &displaytab[n];
if (ds->used)
{
char expr[256];
strcpy (expr, ds->expr);
printf ("%c %s = ", comma, expr);
print_value (eval (expr), &ds->type);
comma = ',';
}
}
if (comma)
putchar ('\n');
}
int
print_insn (absolute_address_t addr)
{
char buf[64];
int size = dasm (buf, addr);
printf ("%s", buf);
return size;
}
void
do_examine (void)
{
unsigned int n;
unsigned int objs_per_line = 16;
if (isdigit (*command_flags))
examine_repeat = strtoul (command_flags, &command_flags, 0);
if (*command_flags == 'i')
examine_type.format = *command_flags;
else
parse_format_flag (command_flags, &examine_type.format);
parse_size_flag (command_flags, &examine_type.size);
switch (examine_type.format)
{
case 'i':
objs_per_line = 1;
break;
case 'w':
objs_per_line = 8;
break;
}
for (n = 0; n < examine_repeat; n++)
{
if ((n % objs_per_line) == 0)
{
putchar ('\n');
print_addr (examine_addr);
printf (": ");
}
switch (examine_type.format)
{
case 's': /* string */
break;
case 'i': /* instruction */
examine_addr += print_insn (examine_addr);
break;
default:
print_value (target_read (examine_addr, examine_type.size),
&examine_type);
putchar (' ');
examine_addr += examine_type.size;
}
}
putchar ('\n');
}
void
do_print (char *expr)
{
unsigned long val = eval (expr);
printf ("$%d = ", history_count);
parse_format_flag (command_flags, &print_type.format);
parse_size_flag (command_flags, &print_type.size);
print_value (val, &print_type);
putchar ('\n');
save_value (val);
}
void
do_set (char *expr)
{
unsigned long val = eval (expr);
save_value (val);
}
#define THREAD_DATA_PC 3
#define THREAD_DATA_ROMBANK 9
void
print_thread_data (absolute_address_t th)
{
U8 b;
U16 w;
absolute_address_t pc;
w = abs_read16 (th + THREAD_DATA_PC);
b = abs_read8 (th + THREAD_DATA_ROMBANK);
printf ("{ PC = %04X, BANK = %02X }", w, b);
}
void
command_change_thread (void)
{
target_addr_t addr = target_read (thread_current, thread_id_size);
absolute_address_t th = to_absolute (addr);
if (th == thread_id)
return;
thread_id = th;
if (machine->dump_thread && eval ("$thread_debug"))
{
if (addr)
{
printf ("[Current thread = ");
print_addr (thread_id);
machine->dump_thread (thread_id);
print_thread_data (thread_id);
printf ("]\n");
}
else
{
printf ("[ No thread ]\n");
}
}
}
void
command_stack_push (unsigned int reason)
{
cmdqueue_t *q = &command_stack[++command_stack_depth];
}
void
command_stack_pop (void)
{
cmdqueue_t *q = &command_stack[command_stack_depth];
--command_stack_depth;
}
void
command_stack_add (const char *cmd)
{
cmdqueue_t *q = &command_stack[command_stack_depth];
}
char *
getarg (void)
{
return strtok (NULL, " \t\n");
}
/****************** Command Handlers ************************/
void cmd_print (void)
{
char *arg = getarg ();
if (arg)
do_print (arg);
else
do_print ("$");
}
void cmd_set (void)
{
char *arg = getarg ();
if (arg)
do_set (arg);
else
do_set ("$");
}
void cmd_examine (void)
{
char *arg = getarg ();
if (arg)
examine_addr = eval_mem (arg);
do_examine ();
}
void cmd_break (void)
{
char *arg = getarg ();
if (!arg)
return;
unsigned long val = eval_mem (arg);
breakpoint_t *br = brkalloc ();
br->addr = val;
br->on_execute = 1;
arg = getarg ();
if (!arg);
else if (!strcmp (arg, "if"))
{
br->conditional = 1;
arg = getarg ();
strcpy (br->condition, arg);
}
else if (!strcmp (arg, "ignore"))
{
br->ignore_count = atoi (getarg ());
}
brkprint (br);
}
void cmd_watch1 (int on_read, int on_write)
{
char *arg;
arg = getarg ();
if (!arg)
return;
absolute_address_t addr = eval_mem (arg);
breakpoint_t *br = brkalloc ();
br->addr = addr;
br->on_read = on_read;
br->on_write = on_write;
for (;;)
{
arg = getarg ();
if (!arg)
return;
if (!strcmp (arg, "print"))
br->keep_running = 1;
else if (!strcmp (arg, "mask"))
{
arg = getarg ();
br->write_mask = strtoul (arg, NULL, 0);
}
else if (!strcmp (arg, "if"))
{
arg = getarg ();
br->conditional = 1;
strcpy (br->condition, arg);
}
}
brkprint (br);
}
void cmd_watch (void)
{
cmd_watch1 (0, 1);
}
void cmd_rwatch (void)
{
cmd_watch1 (1, 0);
}
void cmd_awatch (void)
{
cmd_watch1 (1, 1);
}
void cmd_break_list (void)
{
unsigned int n;
for (n = 0; n < MAX_BREAKS; n++)
brkprint (&breaktab[n]);
}
void cmd_step (void)
{
auto_break_insn_count = 1;
exit_command_loop = 0;
}
void cmd_next (void)
{
char buf[128];
breakpoint_t *br;
unsigned long addr = to_absolute (get_pc ());
addr += dasm (buf, addr);
br = brkalloc ();
br->addr = addr;
br->on_execute = 1;
br->temp = 1;
/* TODO - for conditional branches, should also set a
temp breakpoint at the branch target */
exit_command_loop = 0;
}
void cmd_continue (void)
{
exit_command_loop = 0;
}
void cmd_quit (void)
{
cpu_quit = 0;
exit_command_loop = 1;
}
void cmd_delete (void)
{
const char *arg = getarg ();
unsigned int id;
if (!arg)
{
int n;
printf ("Deleting all breakpoints.\n");
for (id = 0; id < MAX_BREAKS; id++)
{
breakpoint_t *br = brkfind_by_id (id);
brkfree (br);
}
return;
}
id = atoi (arg);
breakpoint_t *br = brkfind_by_id (id);
if (br->used)
{
printf ("Deleting breakpoint %d\n", id);
brkfree (br);
}
}
void cmd_list (void)
{
char *arg;
static absolute_address_t lastpc = 0;
static absolute_address_t lastaddr = 0;
absolute_address_t addr;
int n;
arg = getarg ();
if (arg)
addr = eval_mem (arg);
else
{
addr = to_absolute (get_pc ());
if (addr == lastpc)
addr = lastaddr;
else
lastaddr = lastpc = addr;
}
for (n = 0; n < 10; n++)
{
print_addr (addr);
printf (" : ");
addr += print_insn (addr);
putchar ('\n');
}
lastaddr = addr;
}
void cmd_symbol_file (void)
{
char *arg = getarg ();
if (arg)
load_map_file (arg);
}
void cmd_display (void)
{
char *arg;
while ((arg = getarg ()) != NULL)
{
display_t *ds = display_alloc ();
strcpy (ds->expr, arg);
ds->type = print_type;
parse_format_flag (command_flags, &ds->type.format);
parse_size_flag (command_flags, &ds->type.size);
}
}
int command_exec_file (const char *filename)
{
FILE *infile;
extern int command_exec (FILE *);
infile = file_open (NULL, filename, "r");
if (!infile)
return 0;
command_input = infile;
return 1;
}
void cmd_source (void)
{
char *arg = getarg ();
if (!arg)
return;
if (command_exec_file (arg) == 0)
fprintf (stderr, "can't open %s\n", arg);
}
void cmd_regs (void)
{
}
void cmd_vars (void)
{
for_each_var (NULL);
}
void cmd_runfor (void)
{
char *arg = getarg ();
- int secs = atoi (arg);
- stop_after_ms = secs * 1000;
+ char *units;
+ unsigned long val = atoi (arg);
+
+ units = getarg ();
+ if (!units || !strcmp (units, "ms"))
+ stop_after_ms = val;
+ else if (!strcmp (units, "s"))
+ stop_after_ms = val * 1000;
+ exit_command_loop = 0;
}
void cmd_measure (void)
{
absolute_address_t addr;
target_addr_t retaddr = get_pc ();
breakpoint_t *br;
/* Get the address of the function to be measured. */
char *arg = getarg ();
if (!arg)
return;
addr = eval_mem (arg);
printf ("Measuring ");
print_addr (addr);
printf (" back to ");
print_addr (to_absolute (retaddr));
putchar ('\n');
/* Push the current PC onto the stack for the
duration of the measurement. */
set_s (get_s () - 2);
write16 (get_s (), retaddr);
/* Set a temp breakpoint at the current PC, so that
the measurement will halt. */
br = brkalloc ();
br->addr = to_absolute (retaddr);
br->on_execute = 1;
br->temp = 1;
/* Interrupts must be disabled for this to work ! */
set_cc (get_cc () | 0x50);
/* Change the PC to the function-under-test. */
set_pc (addr);
/* Go! */
exit_command_loop = 0;
}
void cmd_dump (void)
{
extern int dump_every_insn;
char *arg = getarg ();
if (arg)
dump_every_insn = strtoul (arg, NULL, 0);
printf ("Instruction dump is %s\n",
dump_every_insn ? "on" : "off");
}
void
cmd_trace_dump (void)
{
unsigned int off = (trace_offset + 1) % MAX_TRACE;
do {
target_addr_t pc = trace_buffer[off];
absolute_address_t addr = to_absolute (pc);
//const char *name = sym_lookup (&program_symtab, addr);
//printf ("%04X ", pc);
print_addr (addr);
putchar (':');
print_insn (addr);
putchar ('\n');
//putchar (name ? '\n' : ' ');
off = (off + 1) % MAX_TRACE;
} while (off != trace_offset);
fflush (stdout);
}
/****************** Parser ************************/
void cmd_help (void);
struct command_name
{
const char *prefix;
const char *name;
command_handler_t handler;
const char *help;
} cmdtab[] = {
{ "p", "print", cmd_print,
"Print the value of an expression" },
{ "set", "set", cmd_set,
"Set an internal variable/target memory" },
{ "x", "examine", cmd_examine,
"Examine raw memory" },
{ "b", "break", cmd_break,
"Set a breakpoint" },
{ "bl", "blist", cmd_break_list,
"List all breakpoints" },
{ "d", "delete", cmd_delete,
"Delete a breakpoint" },
{ "s", "step", cmd_step,
"Step one instruction" },
{ "n", "next", cmd_next,
"Break at the next instruction" },
{ "c", "continue", cmd_continue,
"Continue the program" },
{ "q", "quit", cmd_quit,
"Quit the simulator" },
{ "re", "reset", cpu_reset,
"Reset the CPU" },
{ "h", "help", cmd_help,
"Display this help" },
{ "wa", "watch", cmd_watch,
"Add a watchpoint on write" },
{ "rwa", "rwatch", cmd_rwatch,
"Add a watchpoint on read" },
{ "awa", "awatch", cmd_awatch,
"Add a watchpoint on read/write" },
{ "?", "?", cmd_help },
{ "l", "list", cmd_list },
{ "sym", "symbol-file", cmd_symbol_file,
"Open a symbol table file" },
{ "di", "display", cmd_display,
"Add a display expression" },
{ "so", "source", cmd_source,
"Run a command script" },
{ "regs", "regs", cmd_regs,
"Show all CPU registers" },
{ "vars", "vars", cmd_vars,
"Show all program variables" },
{ "runfor", "runfor", cmd_runfor,
"Run for a certain amount of time" },
{ "me", "measure", cmd_measure,
"Measure time that a function takes" },
{ "dump", "dump", cmd_dump,
"Set dump-instruction flag" },
{ "td", "tracedump", cmd_trace_dump,
"Dump the trace buffer" },
#if 0
{ "cl", "clear", cmd_clear },
{ "i", "info", cmd_info },
{ "co", "condition", cmd_condition },
{ "tr", "trace", cmd_trace },
{ "di", "disable", cmd_disable },
{ "en", "enable", cmd_enable },
{ "f", "file", cmd_file,
"Choose the program to be debugged" },
{ "exe", "exec-file", cmd_exec_file,
"Open an executable" },
#endif
{ NULL, NULL },
};
void cmd_help (void)
{
struct command_name *cn = cmdtab;
while (cn->prefix != NULL)
{
if (cn->help)
printf ("%s (%s) - %s\n",
cn->name, cn->prefix, cn->help);
cn++;
}
}
command_handler_t
command_lookup (const char *cmd)
{
struct command_name *cn;
char *p;
p = strchr (cmd, '/');
if (p)
{
*p = '\0';
command_flags = p+1;
}
else
command_flags = "";
cn = cmdtab;
while (cn->prefix != NULL)
{
if (!strcmp (cmd, cn->prefix))
return cn->handler;
if (!strcmp (cmd, cn->name))
return cn->handler;
/* TODO - look for a match anywhere between
* the minimum prefix and the full name */
cn++;
}
return NULL;
}
void
command_prompt (void)
{
fprintf (stderr, "(dbg) ");
fflush (stderr);
}
void
print_current_insn (void)
{
absolute_address_t addr = to_absolute (get_pc ());
print_addr (addr);
printf (" : ");
print_insn (addr);
putchar ('\n');
}
int
command_exec (FILE *infile)
{
char buffer[256];
static char prev_buffer[256];
char *cmd;
command_handler_t handler;
int rc;
do {
errno = 0;
fgets (buffer, 255, infile);
if (feof (infile))
return -1;
} while (errno != 0);
/* In terminal mode, a blank line means to execute
the previous command. */
if (buffer[0] == '\n')
strcpy (buffer, prev_buffer);
/* Skip comments */
if (*buffer == '#')
return 0;
cmd = strtok (buffer, " \t\n");
if (!cmd)
return 0;
strcpy (prev_buffer, cmd);
handler = command_lookup (cmd);
if (!handler)
{
syntax_error ("no such command");
return 0;
}
(*handler) ();
return 0;
}
void
keybuffering (int flag)
{
struct termios tio;
tcgetattr (0, &tio);
if (!flag) /* 0 = no buffering = not default */
tio.c_lflag &= ~ICANON;
else /* 1 = buffering = default */
tio.c_lflag |= ICANON;
tcsetattr (0, TCSANOW, &tio);
}
int
command_loop (void)
{
keybuffering (1);
brkfree_temps ();
restart:
if (command_input == stdin)
{
display_print ();
print_current_insn ();
}
exit_command_loop = -1;
while (exit_command_loop < 0)
{
if (command_input == stdin)
command_prompt ();
if (command_exec (command_input) < 0)
break;
}
if (exit_command_loop == 0)
keybuffering (0);
if (feof (command_input) && command_input != stdin)
{
fclose (command_input);
command_input = stdin;
goto restart;
}
return (exit_command_loop);
}
void
breakpoint_hit (breakpoint_t *br)
{
if (br->threaded && (thread_id != br->tid))
return;
if (br->conditional)
{
if (eval (br->condition) == 0)
return;
}
if (br->ignore_count)
{
--br->ignore_count;
return;
}
monitor_on = !br->keep_running;
}
void
command_trace_insn (target_addr_t addr)
{
trace_buffer[trace_offset++] = addr;
trace_offset %= MAX_TRACE;
}
void
command_insn_hook (void)
{
target_addr_t pc;
absolute_address_t abspc;
breakpoint_t *br;
pc = get_pc ();
command_trace_insn (pc);
if (active_break_count == 0)
return;
abspc = to_absolute (pc);
br = brkfind_by_addr (abspc);
if (br && br->enabled && br->on_execute)
{
breakpoint_hit (br);
if (monitor_on == 0)
return;
if (br->temp)
brkfree (br);
else
printf ("Breakpoint %d reached.\n", br->id);
}
}
void
command_read_hook (absolute_address_t addr)
{
breakpoint_t *br;
if (active_break_count == 0)
return;
br = brkfind_by_addr (addr);
if (br && br->enabled && br->on_read)
{
printf ("Watchpoint %d triggered. [", br->id);
print_addr (addr);
printf ("]\n");
breakpoint_hit (br);
}
}
void
command_write_hook (absolute_address_t addr, U8 val)
{
breakpoint_t *br;
if (active_break_count != 0)
{
br = brkfind_by_addr (addr);
if (br && br->enabled && br->on_write)
{
if (br->write_mask)
{
int mask_ok = ((br->last_write & br->write_mask) !=
(val & br->write_mask));
br->last_write = val;
if (!mask_ok)
return;
}
breakpoint_hit (br);
if (monitor_on == 0)
return;
printf ("Watchpoint %d triggered. [", br->id);
print_addr (addr);
printf (" = 0x%02X", val);
printf ("]\n");
}
}
if (thread_id_size && (addr == thread_current + thread_id_size - 1))
{
command_change_thread ();
}
}
void
command_periodic (void)
{
if (stop_after_ms)
{
stop_after_ms -= 100;
if (stop_after_ms <= 0)
{
monitor_on = 1;
stop_after_ms = 0;
printf ("Stopping after time elapsed.\n");
}
}
}
void pc_virtual (unsigned long *val, int writep) {
writep ? set_pc (*val) : (*val = get_pc ());
}
void x_virtual (unsigned long *val, int writep) {
writep ? set_x (*val) : (*val = get_x ());
}
void y_virtual (unsigned long *val, int writep) {
writep ? set_y (*val) : (*val = get_y ());
}
void u_virtual (unsigned long *val, int writep) {
writep ? set_u (*val) : (*val = get_u ());
}
void s_virtual (unsigned long *val, int writep) {
writep ? set_s (*val) : (*val = get_s ());
}
void d_virtual (unsigned long *val, int writep) {
writep ? set_d (*val) : (*val = get_d ());
}
void a_virtual (unsigned long *val, int writep) {
writep ? set_a (*val) : (*val = get_a ());
}
void b_virtual (unsigned long *val, int writep) {
writep ? set_b (*val) : (*val = get_b ());
}
void dp_virtual (unsigned long *val, int writep) {
writep ? set_dp (*val) : (*val = get_dp ());
}
void cc_virtual (unsigned long *val, int writep) {
writep ? set_cc (*val) : (*val = get_cc ());
}
void irq_load_virtual (unsigned long *val, int writep) {
if (!writep)
*val = irq_cycles / IRQ_CYCLE_COUNTS;
}
void cycles_virtual (unsigned long *val, int writep)
{
if (!writep)
*val = get_cycles ();
}
void et_virtual (unsigned long *val, int writep)
{
static unsigned long last_cycles = 0;
if (!writep)
*val = get_cycles () - last_cycles;
last_cycles = get_cycles ();
}
void
command_exit_irq_hook (unsigned long cycles)
{
irq_cycles -= irq_cycle_tab[irq_cycle_entry];
irq_cycles += cycles;
irq_cycle_tab[irq_cycle_entry] = cycles;
irq_cycle_entry = (irq_cycle_entry + 1) % IRQ_CYCLE_COUNTS;
//printf ("IRQ took %lu cycles\n", cycles);
//printf ("Average = %d\n", irq_cycles / IRQ_CYCLE_COUNTS);
}
void
command_init (void)
{
int rc;
sym_add (&auto_symtab, "pc", (unsigned long)pc_virtual, SYM_AUTO);
sym_add (&auto_symtab, "x", (unsigned long)x_virtual, SYM_AUTO);
sym_add (&auto_symtab, "y", (unsigned long)y_virtual, SYM_AUTO);
sym_add (&auto_symtab, "u", (unsigned long)u_virtual, SYM_AUTO);
sym_add (&auto_symtab, "s", (unsigned long)s_virtual, SYM_AUTO);
sym_add (&auto_symtab, "d", (unsigned long)d_virtual, SYM_AUTO);
sym_add (&auto_symtab, "a", (unsigned long)a_virtual, SYM_AUTO);
sym_add (&auto_symtab, "b", (unsigned long)b_virtual, SYM_AUTO);
sym_add (&auto_symtab, "dp", (unsigned long)dp_virtual, SYM_AUTO);
|
bcd/exec09
|
80cf7c914ea8493891f616dd8a4359074bc7a906
|
Checkin new Makefile.in.
|
diff --git a/Makefile.in b/Makefile.in
index b4043d9..38e0a25 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,551 +1,576 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
bin_PROGRAMS = m6809-run$(EXEEXT)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING depcomp install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
-am__installdirs = "$(DESTDIR)$(bindir)"
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_m6809_run_OBJECTS = 6809.$(OBJEXT) main.$(OBJEXT) monitor.$(OBJEXT) \
machine.$(OBJEXT) eon.$(OBJEXT) wpc.$(OBJEXT) symtab.$(OBJEXT) \
command.$(OBJEXT) fileio.$(OBJEXT) wpclib.$(OBJEXT)
m6809_run_OBJECTS = $(am_m6809_run_OBJECTS)
m6809_run_LDADD = $(LDADD)
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(m6809_run_SOURCES)
DIST_SOURCES = $(m6809_run_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
symtab.c command.c fileio.c wpclib.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
+bin_SCRIPTS = wpc-run
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
m6809-run$(EXEEXT): $(m6809_run_OBJECTS) $(m6809_run_DEPENDENCIES)
@rm -f m6809-run$(EXEEXT)
$(LINK) $(m6809_run_LDFLAGS) $(m6809_run_OBJECTS) $(m6809_run_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f $$d$$p; then \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/6809.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eon.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machine.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symtab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpclib.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
-all-am: Makefile $(PROGRAMS) config.h
+all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h
installdirs:
- for dir in "$(DESTDIR)$(bindir)"; do \
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
-install-exec-am: install-binPROGRAMS
+install-exec-am: install-binPROGRAMS install-binSCRIPTS
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
-uninstall-am: uninstall-binPROGRAMS uninstall-info-am
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-info-am
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
- install-binPROGRAMS install-data install-data-am install-exec \
- install-exec-am install-info install-info-am install-man \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-binPROGRAMS \
+ install-binPROGRAMS install-binSCRIPTS install-data \
+ install-data-am install-exec install-exec-am install-info \
+ install-info-am install-man install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
|
bcd/exec09
|
a1a982614ccd5bf9a761687a1bb1208354f7bffe
|
WPC: Change duration of button presses.
|
diff --git a/wpc.c b/wpc.c
index b9783c6..e687f8a 100644
--- a/wpc.c
+++ b/wpc.c
@@ -1,751 +1,751 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "6809.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
#error
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/errno.h>
#include "wpclib.h"
#define WPC_RAM_BASE 0x0000
#define WPC_RAM_SIZE 0x2000
#define WPC_ROM_SIZE 0x100000
#define WPC_PAGED_REGION 0x4000
#define WPC_PAGED_SIZE 0x4000
#define WPC_FIXED_REGION 0x8000
#define WPC_FIXED_SIZE 0x8000
/* The register set of the WPC ASIC */
#define WPC_ASIC_BASE 0x3c00
#define WPC_DMD_LOW_BASE 0x3800
#define WPC_DMD_HIGH_BASE 0x3A00
#define WPC_DEBUG_DATA_PORT 0x3D60
#define WPC_DEBUG_CONTROL_PORT 0x3D61
#define WPC_DEBUG_WRITE_READY 0x1
#define WPC_DEBUG_READ_READY 0x2
#define WPC_PINMAME_CYCLE_COUNT 0x3D62
#define WPC_PINMAME_FUNC_ENTRY_HI 0x3D63
#define WPC_PINMAME_FUNC_ENTRY_LO 0x3D64
#define WPC_PINMAME_FUNC_EXIT_HI 0x3D65
#define WPC_PINMAME_FUNC_EXIT_LO 0x3D66
#define WPC_SERIAL_CONTROL_PORT 0x3E66
#define WPC_SERIAL_DATA_PORT 0x3E67
#define WPC_DMD_3200_PAGE 0x3FB8
#define WPC_DMD_3000_PAGE 0x3FB9
#define WPC_DMD_3600_PAGE 0x3FBA
#define WPC_DMD_3400_PAGE 0x3FBB
#define WPC_DMD_HIGH_PAGE 0x3FBC
#define WPC_DMD_FIRQ_ROW_VALUE 0x3FBD
#define WPC_DMD_LOW_PAGE 0x3FBE
#define WPC_DMD_ACTIVE_PAGE 0x3FBF
#define WPC_SERIAL_STATUS_PORT 0x3FC0
#define WPC_PARALLEL_DATA_PORT 0x3FC1
#define WPC_PARALLEL_STROBE_PORT 0x3FC2
#define WPC_SERIAL_DATA_OUTPUT 0x3FC3
#define WPC_SERIAL_CONTROL_OUTPUT 0x3FC4
#define WPC_SERIAL_BAUD_SELECT 0x3FC5
#define WPC_TICKET_DISPENSE 0x3FC6
#define WPC_DCS_SOUND_DATA_OUT 0x3FD0
#define WPC_DCS_SOUND_DATA_IN 0x3FD1
#define WPC_DCS_SOUND_RESET 0x3FD2
#define WPC_DCS_SOUND_DATA_READY 0x3FD3
#define WPC_FLIPTRONIC_PORT_A 0x3FD4
#define WPC_FLIPTRONIC_PORT_B 0x3FD5
#define WPCS_DATA 0x3FDC
#define WPCS_CONTROL_STATUS 0x3FDD
#define WPC_SOL_FLASH2_OUTPUT 0x3FE0
#define WPC_SOL_HIGHPOWER_OUTPUT 0x3FE1
#define WPC_SOL_FLASH1_OUTPUT 0x3FE2
#define WPC_SOL_LOWPOWER_OUTPUT 0x3FE3
#define WPC_LAMP_ROW_OUTPUT 0x3FE4
#define WPC_LAMP_COL_STROBE 0x3FE5
#define WPC_GI_TRIAC 0x3FE6
#define WPC_SW_JUMPER_INPUT 0x3FE7
#define WPC_SW_CABINET_INPUT 0x3FE8
#define WPC_SW_ROW_INPUT 0x3FE9 /* WPC */
#define WPC_SW_COL_STROBE 0x3FEA /* WPC */
#define WPCS_PIC_READ 0x3FE9 /* WPCS, WPC95 */
#define WPCS_PIC_WRITE 0x3FEA /* WPCS, WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_POS 0x3FEB
#define WPC_ALPHA_ROW1 0x3FEC
#else
#define WPC_EXTBOARD1 0x3FEB
#define WPC_EXTBOARD2 0x3FEC
#define WPC_EXTBOARD3 0x3FED
#endif
#define WPC95_FLIPPER_COIL_OUTPUT 0x3FEE /* WPC95 */
#define WPC95_FLIPPER_SWITCH_INPUT 0x3FEF /* WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_ROW2 0x3FEE
#else
#endif
#define WPC_LEDS 0x3FF2
#define WPC_RAM_BANK 0x3FF3 /* WPC95 */
#define WPC_SHIFTADDR 0x3FF4
#define WPC_SHIFTBIT 0x3FF6
#define WPC_SHIFTBIT2 0x3FF7
#define WPC_PERIPHERAL_TIMER_FIRQ_CLEAR 0x3FF8
#define WPC_ROM_LOCK 0x3FF9
#define WPC_CLK_HOURS_DAYS 0x3FFA
#define WPC_CLK_MINS 0x3FFB
#define WPC_ROM_BANK 0x3FFC
#define WPC_RAM_LOCK 0x3FFD
#define WPC_RAM_LOCKSIZE 0x3FFE
#define WPC_ZEROCROSS_IRQ_CLEAR 0x3FFF
/**
* The 'wpc_asic' struct holds all of the state
* of the ASIC. There is a single instance of this,
* named 'the_wpc', and it is pointed to by the
* global 'wpc'. Only one ASIC can be defined at
* a time.
*/
struct wpc_asic
{
struct hw_device *rom_dev;
struct hw_device *ram_dev;
struct hw_device *dmd_dev;
U8 led;
U8 rombank;
U8 ram_unlocked;
U8 ram_lock_size;
U16 shiftaddr;
U16 shiftbit;
U8 lamp_strobe;
U8 lamp_mx[8];
U8 sols[48];
U8 switch_strobe;
U8 switch_mx[10];
U8 opto_mx[10];
U8 dmd_maps[2];
unsigned int dmd_phase;
U8 dmd_visibles[3];
U8 dmd_last_visibles[3];
int curr_sw;
int curr_sw_time;
int wdog_timer;
} the_wpc;
struct wpc_asic *wpc = NULL;
int wpc_sock;
static int wpc_console_inited = 0;
static U8 wpc_get_console_state (void)
{
fd_set fds;
struct timeval timeout;
U8 rc = WPC_DEBUG_WRITE_READY;
if (!wpc_console_inited)
rc |= WPC_DEBUG_READ_READY;
#if 1
return rc;
#endif
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
rc |= WPC_DEBUG_READ_READY;
return rc;
}
static U8 wpc_console_read (void)
{
int rc;
U8 c = 0;
if (!wpc_console_inited)
{
wpc_console_inited = 1;
return 0;
}
rc = read (0, &c, 1);
return c;
}
static void wpc_console_write (U8 val)
{
putchar (val);
fflush (stdout);
}
static int scanbit (U8 val)
{
if (val & 0x80) return 7;
else if (val & 0x40) return 6;
else if (val & 0x20) return 5;
else if (val & 0x10) return 4;
else if (val & 0x08) return 3;
else if (val & 0x04) return 2;
else if (val & 0x02) return 1;
else if (val & 0x01) return 0;
else return -1;
}
unsigned int wpc_read_switch (int num)
{
unsigned int val;
val = wpc->switch_mx[num / 8] & (1 << (num % 8));
return val ? 1 : 0;
}
void wpc_write_switch (int num, int flag)
{
unsigned int col, val;
col = num / 8;
val = 1 << (num % 8);
#if 0
if (wpc->opto_mx[col] & val)
flag = !flag;
#endif
wpc->switch_mx[col] &= ~val;
if (flag)
wpc->switch_mx[col] |= val;
}
void wpc_press_switch (int num, int delay)
{
wpc_write_switch (num, 1);
wpc->curr_sw = num;
wpc->curr_sw_time = delay;
}
unsigned int wpc_read_switch_column (int col)
{
unsigned int val = 0;
int row;
for (row = 0; row < 8; row++)
if (wpc_read_switch (col * 8 + row))
val |= (1 << row);
return val;
}
void wpc_write_lamp (int num, int flag)
{
}
void wpc_write_sols (int first, U8 val)
{
int i;
for (i=0; i < 8; i++)
{
wpc->sols[first+i] = (val & (1 << i)) ? 1 : 0;
}
}
void wpc_dmd_set_visible (U8 val)
{
char *p;
struct wpc_message msg;
int rc;
int i, n;
static unsigned long last_firq_time = 0;
unsigned long now;
static int no_change_count = 0;
now = get_cycles ();
if (now - last_firq_time <= 1850 * 8)
{
//printf ("%02X ignored.\n", val);
return;
}
else if (now - last_firq_time >= 1850 * 8 * 5)
{
memset (wpc->dmd_visibles, val, 3);
wpc->dmd_phase = 0;
}
else
{
wpc->dmd_visibles[wpc->dmd_phase++] = val;
if (wpc->dmd_phase == 3)
wpc->dmd_phase = 0;
}
last_firq_time = now;
#if 0
printf ("%02X %f\n", val, get_cycles () / 1952.0);
#endif
if (!memcmp (wpc->dmd_visibles, wpc->dmd_last_visibles, 3)
&& (++no_change_count < 100))
return;
no_change_count = 0;
#if 0
printf ("%02X %02X %02X\n",
wpc->dmd_visibles[0],
wpc->dmd_visibles[1],
wpc->dmd_visibles[2]);
#endif
memcpy (wpc->dmd_last_visibles, wpc->dmd_visibles, 3);
/* Send updated page contents */
wpc_msg_init (CODE_DMD_PAGE, &msg);
for (i=0; i < 3; i++)
{
p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512;
msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i];
memcpy (&msg.u.dmdpage.phases[i].data, p, 512);
}
msg.len = sizeof (struct _dmdpage_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
/* Send status of which pages are visible now */
wpc_msg_init (CODE_DMD_VISIBLE, &msg);
for (i=0; i < 3; i++)
msg.u.dmdvisible.phases[i] = wpc->dmd_visibles[i];
msg.len = sizeof (struct _dmdvisible_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
}
void wpc_keypoll (void)
{
fd_set fds;
struct timeval timeout;
int rc;
unsigned char c;
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
{
rc = read (0, &c, 1);
-#define BUTTON_DURATION 500
+#define BUTTON_DURATION 200
switch (c)
{
case '7':
wpc_press_switch (4, BUTTON_DURATION);
break;
case '8':
wpc_press_switch (5, BUTTON_DURATION);
break;
case '9':
wpc_press_switch (6, BUTTON_DURATION);
break;
case '0':
wpc_press_switch (7, BUTTON_DURATION);
break;
case ',':
- wpc_press_switch (75, 200);
+ wpc_press_switch (75, BUTTON_DURATION);
break;
case '.':
- wpc_press_switch (73, 200);
+ wpc_press_switch (73, BUTTON_DURATION);
break;
default:
printf ("wpc: invalid character '%c'\n", c);
break;
}
}
}
U8 wpc_asic_read (struct hw_device *dev, unsigned long addr)
{
U8 val;
switch (addr + WPC_ASIC_BASE)
{
case WPC_LEDS:
val = wpc->led;
break;
case WPC_ROM_BANK:
val = wpc->rombank;
break;
case WPC_DEBUG_CONTROL_PORT:
val = wpc_get_console_state ();
break;
case WPC_DEBUG_DATA_PORT:
val = wpc_console_read ();
break;
case WPC_SHIFTADDR:
val = wpc->shiftaddr >> 8;
break;
case WPC_SHIFTADDR+1:
val = (wpc->shiftaddr & 0xFF) + (wpc->shiftbit / 8);
break;
case WPC_SHIFTBIT:
val = 1 << (wpc->shiftbit % 8);
break;
case WPC_SW_ROW_INPUT:
{
/* Handle WPC and WPC-S machines differently */
if (wpc->switch_strobe >= 0x16 && wpc->switch_strobe <= 0x1F)
val = wpc_read_switch_column (wpc->switch_strobe - 0x16 + 1);
else
val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
break;
}
case WPC_SW_JUMPER_INPUT:
val = 0x55;
break;
case WPC_SW_CABINET_INPUT:
val = wpc_read_switch_column (0);
break;
case WPC_FLIPTRONIC_PORT_A:
case WPC_FLIPTRONIC_PORT_B:
case WPC95_FLIPPER_SWITCH_INPUT:
val = wpc_read_switch_column (9);
break;
default:
val = 0;
break;
}
//printf (">>> ASIC read %04X -> %02X\n", addr + WPC_ASIC_BASE, val);
return val;
}
/**
* Enforce the current read-only area of RAM.
*/
void wpc_update_ram (void)
{
unsigned int size_writable = WPC_RAM_SIZE;
if (!wpc->ram_unlocked)
{
switch (wpc->ram_lock_size)
{
default:
break;
case 0xF:
size_writable -= 256;
break;
case 0x7:
size_writable -= 512;
case 0x3:
size_writable -= 1024;
break;
case 0x1:
size_writable -= 2048;
break;
case 0:
size_writable -= 4096;
break;
}
}
bus_map (WPC_RAM_BASE, wpc->ram_dev->devid, 0, size_writable, MAP_READWRITE);
if (size_writable < WPC_RAM_SIZE)
bus_map (WPC_RAM_BASE + size_writable, wpc->ram_dev->devid, size_writable,
WPC_RAM_SIZE - size_writable, MAP_READONLY);
}
void wpc_set_rom_page (unsigned char val)
{
bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READONLY);
}
void wpc_set_dmd_page (unsigned int map, unsigned char val)
{
wpc->dmd_maps[map] = val;
bus_map (0x3800 + map * 0x200, 3, val * 0x200, 0x200, MAP_READWRITE);
}
void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr + WPC_ASIC_BASE)
{
case WPC_DMD_LOW_PAGE:
wpc_set_dmd_page (0, val);
break;
case WPC_DMD_HIGH_PAGE:
wpc_set_dmd_page (1, val);
break;
case WPC_DMD_FIRQ_ROW_VALUE:
break;
case WPC_DMD_ACTIVE_PAGE:
wpc_dmd_set_visible (val);
break;
case WPC_LEDS:
wpc->led = val;
break;
case WPC_ZEROCROSS_IRQ_CLEAR:
wpc->wdog_timer++;
break;
case WPC_ROM_BANK:
wpc->rombank = val;
wpc_set_rom_page (val);
break;
case WPC_DEBUG_DATA_PORT:
wpc_console_write (val);
break;
case WPC_RAM_LOCK:
wpc->ram_unlocked = val;
wpc_update_ram ();
break;
case WPC_RAM_LOCKSIZE:
wpc->ram_lock_size = val;
wpc_update_ram ();
break;
case WPC_SHIFTADDR:
wpc->shiftaddr &= 0x00FF;
wpc->shiftaddr |= val << 8;
break;
case WPC_SHIFTADDR+1:
wpc->shiftaddr &= 0xFF00;
wpc->shiftaddr |= val;
break;
case WPC_SHIFTBIT:
wpc->shiftbit = val;
break;
case WPC_LAMP_ROW_OUTPUT:
wpc->lamp_mx[scanbit (wpc->lamp_strobe)] = val;
break;
case WPC_LAMP_COL_STROBE:
wpc->lamp_strobe = val;
break;
case WPC_SW_COL_STROBE:
wpc->switch_strobe = val;
break;
case WPC_SOL_FLASH2_OUTPUT:
case WPC_SOL_HIGHPOWER_OUTPUT:
case WPC_SOL_FLASH1_OUTPUT:
case WPC_SOL_LOWPOWER_OUTPUT:
if (val != 0)
printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
break;
default:
break;
}
//printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
}
void wpc_periodic (void)
{
wpc_keypoll ();
wpc->wdog_timer -= 50;
if (wpc->wdog_timer <= 0)
{
}
if (wpc->curr_sw_time > 0)
{
wpc->curr_sw_time -= 100;
if (wpc->curr_sw_time <= 0)
{
wpc->curr_sw_time = 0;
wpc_write_switch (wpc->curr_sw, 0);
}
}
}
void wpc_asic_reset (struct hw_device *dev)
{
memset (wpc, 0, sizeof (struct wpc_asic));
wpc_write_switch (19, 1); /* Always Closed */
}
struct hw_class wpc_asic_class =
{
.reset = wpc_asic_reset,
.read = wpc_asic_read,
.write = wpc_asic_write,
};
struct hw_device *wpc_asic_create (void)
{
if (wpc)
{
fprintf (stderr, "WPC ASIC already created\n");
return NULL;
}
wpc = &the_wpc;
return device_attach (&wpc_asic_class, 0x800, wpc);
}
void wpc_fault (unsigned int addr, unsigned char type)
{
}
void io_sym_add (const char *name, unsigned long cpuaddr)
{
sym_add (&program_symtab, name, to_absolute (cpuaddr), 0);
}
#define IO_SYM_ADD(name) io_sym_add (#name, name)
void wpc_init (const char *boot_rom_file)
{
struct hw_device *dev;
int rc;
struct sockaddr_in myaddr;
device_define ( dev = wpc_asic_create (), 0,
WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE);
device_define ( dev = ram_create (WPC_RAM_SIZE), 0,
WPC_RAM_BASE, WPC_RAM_SIZE, MAP_READWRITE );
wpc->ram_dev = dev;
dev = rom_create (boot_rom_file, WPC_ROM_SIZE);
device_define ( dev, 0,
WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READONLY);
device_define ( dev, WPC_ROM_SIZE - WPC_FIXED_SIZE,
WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READONLY);
wpc->rom_dev = dev;
device_define ( dev = ram_create (16 * 512), 0,
0x3800, 0x200 * 2, MAP_READWRITE );
wpc->dmd_dev = dev;
wpc_update_ram ();
wpc_sock = udp_socket_create (9000);
if (wpc_sock < 0)
fprintf (stderr, "could not open output socket\n");
IO_SYM_ADD(WPC_DMD_LOW_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_PAGE);
IO_SYM_ADD(WPC_DMD_FIRQ_ROW_VALUE);
IO_SYM_ADD(WPC_DMD_LOW_PAGE);
IO_SYM_ADD(WPC_DMD_ACTIVE_PAGE);
IO_SYM_ADD(WPC_SERIAL_STATUS_PORT);
IO_SYM_ADD(WPC_PARALLEL_DATA_PORT);
IO_SYM_ADD(WPC_PARALLEL_STROBE_PORT);
IO_SYM_ADD(WPC_SERIAL_DATA_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_CONTROL_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_BAUD_SELECT);
IO_SYM_ADD(WPC_TICKET_DISPENSE);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_OUT);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_IN);
IO_SYM_ADD(WPC_DCS_SOUND_RESET);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_READY);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_A);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_B);
IO_SYM_ADD(WPCS_DATA);
IO_SYM_ADD(WPCS_CONTROL_STATUS);
IO_SYM_ADD(WPC_SOL_FLASH2_OUTPUT);
IO_SYM_ADD(WPC_SOL_HIGHPOWER_OUTPUT);
IO_SYM_ADD(WPC_SOL_FLASH1_OUTPUT);
IO_SYM_ADD(WPC_SOL_LOWPOWER_OUTPUT);
IO_SYM_ADD(WPC_LAMP_ROW_OUTPUT);
IO_SYM_ADD(WPC_LAMP_COL_STROBE);
IO_SYM_ADD(WPC_GI_TRIAC);
IO_SYM_ADD(WPC_SW_JUMPER_INPUT);
IO_SYM_ADD(WPC_SW_CABINET_INPUT);
IO_SYM_ADD(WPC_SW_ROW_INPUT);
IO_SYM_ADD(WPC_SW_COL_STROBE);
IO_SYM_ADD(WPC_LEDS);
IO_SYM_ADD(WPC_RAM_BANK);
IO_SYM_ADD(WPC_SHIFTADDR);
IO_SYM_ADD(WPC_SHIFTBIT);
IO_SYM_ADD(WPC_SHIFTBIT2);
IO_SYM_ADD(WPC_PERIPHERAL_TIMER_FIRQ_CLEAR);
IO_SYM_ADD(WPC_ROM_LOCK);
IO_SYM_ADD(WPC_CLK_HOURS_DAYS);
IO_SYM_ADD(WPC_CLK_MINS);
IO_SYM_ADD(WPC_ROM_BANK);
IO_SYM_ADD(WPC_RAM_LOCK);
IO_SYM_ADD(WPC_RAM_LOCKSIZE);
}
struct machine wpc_machine =
{
.name = "wpc",
.fault = wpc_fault,
.init = wpc_init,
};
struct machine wpc95_machine =
{
.name = "wpc95",
.fault = wpc_fault,
.init = wpc_init,
};
|
bcd/exec09
|
e4868af4a4d5077e7a34e7bd3c870270c9e202f1
|
WPC simulation update:
|
diff --git a/wpc.c b/wpc.c
index 1fe120f..fb8093c 100644
--- a/wpc.c
+++ b/wpc.c
@@ -1,720 +1,748 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "6809.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
#error
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/errno.h>
#include "wpclib.h"
#define WPC_RAM_BASE 0x0000
#define WPC_RAM_SIZE 0x2000
#define WPC_ROM_SIZE 0x100000
#define WPC_PAGED_REGION 0x4000
#define WPC_PAGED_SIZE 0x4000
#define WPC_FIXED_REGION 0x8000
#define WPC_FIXED_SIZE 0x8000
/* The register set of the WPC ASIC */
#define WPC_ASIC_BASE 0x3c00
#define WPC_DMD_LOW_BASE 0x3800
#define WPC_DMD_HIGH_BASE 0x3A00
#define WPC_DEBUG_DATA_PORT 0x3D60
#define WPC_DEBUG_CONTROL_PORT 0x3D61
#define WPC_DEBUG_WRITE_READY 0x1
#define WPC_DEBUG_READ_READY 0x2
#define WPC_PINMAME_CYCLE_COUNT 0x3D62
#define WPC_PINMAME_FUNC_ENTRY_HI 0x3D63
#define WPC_PINMAME_FUNC_ENTRY_LO 0x3D64
#define WPC_PINMAME_FUNC_EXIT_HI 0x3D65
#define WPC_PINMAME_FUNC_EXIT_LO 0x3D66
#define WPC_SERIAL_CONTROL_PORT 0x3E66
#define WPC_SERIAL_DATA_PORT 0x3E67
#define WPC_DMD_3200_PAGE 0x3FB8
#define WPC_DMD_3000_PAGE 0x3FB9
#define WPC_DMD_3600_PAGE 0x3FBA
#define WPC_DMD_3400_PAGE 0x3FBB
#define WPC_DMD_HIGH_PAGE 0x3FBC
#define WPC_DMD_FIRQ_ROW_VALUE 0x3FBD
#define WPC_DMD_LOW_PAGE 0x3FBE
#define WPC_DMD_ACTIVE_PAGE 0x3FBF
#define WPC_SERIAL_STATUS_PORT 0x3FC0
#define WPC_PARALLEL_DATA_PORT 0x3FC1
#define WPC_PARALLEL_STROBE_PORT 0x3FC2
#define WPC_SERIAL_DATA_OUTPUT 0x3FC3
#define WPC_SERIAL_CONTROL_OUTPUT 0x3FC4
#define WPC_SERIAL_BAUD_SELECT 0x3FC5
#define WPC_TICKET_DISPENSE 0x3FC6
#define WPC_DCS_SOUND_DATA_OUT 0x3FD0
#define WPC_DCS_SOUND_DATA_IN 0x3FD1
#define WPC_DCS_SOUND_RESET 0x3FD2
#define WPC_DCS_SOUND_DATA_READY 0x3FD3
#define WPC_FLIPTRONIC_PORT_A 0x3FD4
#define WPC_FLIPTRONIC_PORT_B 0x3FD5
#define WPCS_DATA 0x3FDC
#define WPCS_CONTROL_STATUS 0x3FDD
#define WPC_SOL_FLASH2_OUTPUT 0x3FE0
#define WPC_SOL_HIGHPOWER_OUTPUT 0x3FE1
#define WPC_SOL_FLASH1_OUTPUT 0x3FE2
#define WPC_SOL_LOWPOWER_OUTPUT 0x3FE3
#define WPC_LAMP_ROW_OUTPUT 0x3FE4
#define WPC_LAMP_COL_STROBE 0x3FE5
#define WPC_GI_TRIAC 0x3FE6
#define WPC_SW_JUMPER_INPUT 0x3FE7
#define WPC_SW_CABINET_INPUT 0x3FE8
#define WPC_SW_ROW_INPUT 0x3FE9 /* WPC */
#define WPC_SW_COL_STROBE 0x3FEA /* WPC */
#define WPCS_PIC_READ 0x3FE9 /* WPCS, WPC95 */
#define WPCS_PIC_WRITE 0x3FEA /* WPCS, WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_POS 0x3FEB
#define WPC_ALPHA_ROW1 0x3FEC
#else
#define WPC_EXTBOARD1 0x3FEB
#define WPC_EXTBOARD2 0x3FEC
#define WPC_EXTBOARD3 0x3FED
#endif
#define WPC95_FLIPPER_COIL_OUTPUT 0x3FEE /* WPC95 */
#define WPC95_FLIPPER_SWITCH_INPUT 0x3FEF /* WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_ROW2 0x3FEE
#else
#endif
#define WPC_LEDS 0x3FF2
#define WPC_RAM_BANK 0x3FF3 /* WPC95 */
#define WPC_SHIFTADDR 0x3FF4
#define WPC_SHIFTBIT 0x3FF6
#define WPC_SHIFTBIT2 0x3FF7
#define WPC_PERIPHERAL_TIMER_FIRQ_CLEAR 0x3FF8
#define WPC_ROM_LOCK 0x3FF9
#define WPC_CLK_HOURS_DAYS 0x3FFA
#define WPC_CLK_MINS 0x3FFB
#define WPC_ROM_BANK 0x3FFC
#define WPC_RAM_LOCK 0x3FFD
#define WPC_RAM_LOCKSIZE 0x3FFE
#define WPC_ZEROCROSS_IRQ_CLEAR 0x3FFF
/**
* The 'wpc_asic' struct holds all of the state
* of the ASIC. There is a single instance of this,
* named 'the_wpc', and it is pointed to by the
* global 'wpc'. Only one ASIC can be defined at
* a time.
*/
struct wpc_asic
{
struct hw_device *rom_dev;
struct hw_device *ram_dev;
struct hw_device *dmd_dev;
U8 led;
U8 rombank;
U8 ram_unlocked;
U8 ram_lock_size;
U16 shiftaddr;
U16 shiftbit;
U8 lamp_strobe;
U8 lamp_mx[8];
- U8 sols[6];
+ U8 sols[48];
U8 switch_strobe;
- U8 switch_mx[8];
- U8 opto_mx[8];
+ U8 switch_mx[10];
+ U8 opto_mx[10];
U8 dmd_maps[2];
unsigned int dmd_phase;
U8 dmd_visibles[3];
U8 dmd_last_visibles[3];
int curr_sw;
int curr_sw_time;
int wdog_timer;
} the_wpc;
struct wpc_asic *wpc = NULL;
int wpc_sock;
-void wpc_asic_reset (struct hw_device *dev)
-{
- memset (wpc, 0, sizeof (struct wpc_asic));
-}
-
static int wpc_console_inited = 0;
static U8 wpc_get_console_state (void)
{
fd_set fds;
struct timeval timeout;
U8 rc = WPC_DEBUG_WRITE_READY;
if (!wpc_console_inited)
rc |= WPC_DEBUG_READ_READY;
#if 1
return rc;
#endif
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
rc |= WPC_DEBUG_READ_READY;
return rc;
}
static U8 wpc_console_read (void)
{
int rc;
U8 c = 0;
if (!wpc_console_inited)
{
wpc_console_inited = 1;
return 0;
}
rc = read (0, &c, 1);
return c;
}
static void wpc_console_write (U8 val)
{
putchar (val);
fflush (stdout);
}
static int scanbit (U8 val)
{
if (val & 0x80) return 7;
else if (val & 0x40) return 6;
else if (val & 0x20) return 5;
else if (val & 0x10) return 4;
else if (val & 0x08) return 3;
else if (val & 0x04) return 2;
else if (val & 0x02) return 1;
else if (val & 0x01) return 0;
else return -1;
}
unsigned int wpc_read_switch (int num)
{
unsigned int val;
val = wpc->switch_mx[num / 8] & (1 << (num % 8));
return val ? 1 : 0;
}
void wpc_write_switch (int num, int flag)
{
unsigned int col, val;
col = num / 8;
val = 1 << (num % 8);
if (wpc->opto_mx[col] & val)
flag = !flag;
wpc->switch_mx[col] &= ~val;
if (flag)
wpc->switch_mx[col] |= val;
}
void wpc_press_switch (int num, int delay)
{
wpc_write_switch (num, 1);
wpc->curr_sw = num;
wpc->curr_sw_time = delay;
}
unsigned int wpc_read_switch_column (int col)
{
unsigned int val = 0;
int row;
for (row = 0; row < 8; row++)
if (wpc_read_switch (col * 8 + row))
val |= (1 << row);
return val;
}
void wpc_write_lamp (int num, int flag)
{
}
-void wpc_write_sol (int num, int flag)
+void wpc_write_sols (int first, U8 val)
{
+ int i;
+ for (i=0; i < 8; i++)
+ {
+ wpc->sols[first+i] = (val & (1 << i)) ? 1 : 0;
+ }
}
void wpc_dmd_set_visible (U8 val)
{
char *p;
struct wpc_message msg;
int rc;
int i, n;
static unsigned long last_firq_time = 0;
unsigned long now;
static int no_change_count = 0;
now = get_cycles ();
if (now - last_firq_time <= 1850 * 8)
{
//printf ("%02X ignored.\n", val);
return;
}
else if (now - last_firq_time >= 1850 * 8 * 5)
{
memset (wpc->dmd_visibles, val, 3);
wpc->dmd_phase = 0;
}
else
{
wpc->dmd_visibles[wpc->dmd_phase++] = val;
if (wpc->dmd_phase == 3)
wpc->dmd_phase = 0;
}
last_firq_time = now;
#if 0
printf ("%02X %f\n", val, get_cycles () / 1952.0);
#endif
if (!memcmp (wpc->dmd_visibles, wpc->dmd_last_visibles, 3)
&& (++no_change_count < 100))
return;
no_change_count = 0;
#if 0
printf ("%02X %02X %02X\n",
wpc->dmd_visibles[0],
wpc->dmd_visibles[1],
wpc->dmd_visibles[2]);
#endif
memcpy (wpc->dmd_last_visibles, wpc->dmd_visibles, 3);
/* Send updated page contents */
wpc_msg_init (CODE_DMD_PAGE, &msg);
for (i=0; i < 3; i++)
{
p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512;
msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i];
memcpy (&msg.u.dmdpage.phases[i].data, p, 512);
}
msg.len = sizeof (struct _dmdpage_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
/* Send status of which pages are visible now */
wpc_msg_init (CODE_DMD_VISIBLE, &msg);
for (i=0; i < 3; i++)
msg.u.dmdvisible.phases[i] = wpc->dmd_visibles[i];
msg.len = sizeof (struct _dmdvisible_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
}
void wpc_keypoll (void)
{
fd_set fds;
struct timeval timeout;
int rc;
unsigned char c;
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
{
rc = read (0, &c, 1);
switch (c)
{
case '7':
wpc_press_switch (4, 200);
break;
case '8':
wpc_press_switch (5, 200);
break;
case '9':
wpc_press_switch (6, 200);
break;
case '0':
wpc_press_switch (7, 200);
break;
+ case ',':
+ wpc_press_switch (75, 200);
+ break;
+ case '.':
+ wpc_press_switch (73, 200);
+ break;
default:
break;
}
}
}
U8 wpc_asic_read (struct hw_device *dev, unsigned long addr)
{
U8 val;
switch (addr + WPC_ASIC_BASE)
{
case WPC_LEDS:
val = wpc->led;
break;
case WPC_ROM_BANK:
val = wpc->rombank;
break;
case WPC_DEBUG_CONTROL_PORT:
val = wpc_get_console_state ();
break;
case WPC_DEBUG_DATA_PORT:
val = wpc_console_read ();
break;
case WPC_SHIFTADDR:
val = wpc->shiftaddr >> 8;
break;
case WPC_SHIFTADDR+1:
val = (wpc->shiftaddr & 0xFF) + (wpc->shiftbit / 8);
break;
case WPC_SHIFTBIT:
val = 1 << (wpc->shiftbit % 8);
break;
case WPC_SW_ROW_INPUT:
- val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
+ {
+ /* Handle WPC and WPC-S machines differently */
+ if (wpc->switch_strobe >= 0x16 && wpc->switch_strobe <= 0x1F)
+ val = wpc_read_switch_column (wpc->switch_strobe - 0x16 + 1);
+ else
+ val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
break;
+ }
case WPC_SW_JUMPER_INPUT:
val = 0x55;
break;
case WPC_SW_CABINET_INPUT:
val = wpc_read_switch_column (0);
break;
case WPC_FLIPTRONIC_PORT_A:
case WPC_FLIPTRONIC_PORT_B:
case WPC95_FLIPPER_SWITCH_INPUT:
- return 0xFF;
+ val = wpc_read_switch_column (9);
+ break;
default:
val = 0;
break;
}
//printf (">>> ASIC read %04X -> %02X\n", addr + WPC_ASIC_BASE, val);
return val;
}
/**
* Enforce the current read-only area of RAM.
*/
void wpc_update_ram (void)
{
unsigned int size_writable = WPC_RAM_SIZE;
if (!wpc->ram_unlocked)
{
switch (wpc->ram_lock_size)
{
default:
break;
case 0xF:
size_writable -= 256;
break;
case 0x7:
size_writable -= 512;
case 0x3:
size_writable -= 1024;
break;
case 0x1:
size_writable -= 2048;
break;
case 0:
size_writable -= 4096;
break;
}
}
bus_map (WPC_RAM_BASE, wpc->ram_dev->devid, 0, size_writable, MAP_READWRITE);
if (size_writable < WPC_RAM_SIZE)
bus_map (WPC_RAM_BASE + size_writable, wpc->ram_dev->devid, size_writable,
WPC_RAM_SIZE - size_writable, MAP_READONLY);
}
void wpc_set_rom_page (unsigned char val)
{
bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READONLY);
}
void wpc_set_dmd_page (unsigned int map, unsigned char val)
{
wpc->dmd_maps[map] = val;
bus_map (0x3800 + map * 0x200, 3, val * 0x200, 0x200, MAP_READWRITE);
}
void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr + WPC_ASIC_BASE)
{
case WPC_DMD_LOW_PAGE:
wpc_set_dmd_page (0, val);
break;
case WPC_DMD_HIGH_PAGE:
wpc_set_dmd_page (1, val);
break;
case WPC_DMD_FIRQ_ROW_VALUE:
break;
case WPC_DMD_ACTIVE_PAGE:
wpc_dmd_set_visible (val);
break;
case WPC_LEDS:
wpc->led = val;
break;
case WPC_ZEROCROSS_IRQ_CLEAR:
wpc->wdog_timer++;
break;
case WPC_ROM_BANK:
wpc->rombank = val;
wpc_set_rom_page (val);
break;
case WPC_DEBUG_DATA_PORT:
wpc_console_write (val);
break;
case WPC_RAM_LOCK:
wpc->ram_unlocked = val;
wpc_update_ram ();
break;
case WPC_RAM_LOCKSIZE:
wpc->ram_lock_size = val;
wpc_update_ram ();
break;
case WPC_SHIFTADDR:
wpc->shiftaddr &= 0x00FF;
wpc->shiftaddr |= val << 8;
break;
case WPC_SHIFTADDR+1:
wpc->shiftaddr &= 0xFF00;
wpc->shiftaddr |= val;
break;
case WPC_SHIFTBIT:
wpc->shiftbit = val;
break;
case WPC_LAMP_ROW_OUTPUT:
wpc->lamp_mx[scanbit (wpc->lamp_strobe)] = val;
break;
case WPC_LAMP_COL_STROBE:
wpc->lamp_strobe = val;
break;
case WPC_SW_COL_STROBE:
wpc->switch_strobe = val;
+ break;
+
+ case WPC_SOL_FLASH2_OUTPUT:
+ case WPC_SOL_HIGHPOWER_OUTPUT:
+ case WPC_SOL_FLASH1_OUTPUT:
+ case WPC_SOL_LOWPOWER_OUTPUT:
+ if (val != 0)
+ printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
+ break;
default:
break;
}
//printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
}
void wpc_periodic (void)
{
wpc_keypoll ();
wpc->wdog_timer -= 50;
if (wpc->wdog_timer <= 0)
{
}
if (wpc->curr_sw_time > 0)
{
wpc->curr_sw_time -= 100;
if (wpc->curr_sw_time <= 0)
{
wpc->curr_sw_time = 0;
wpc_write_switch (wpc->curr_sw, 0);
}
}
}
+void wpc_asic_reset (struct hw_device *dev)
+{
+ memset (wpc, 0, sizeof (struct wpc_asic));
+ wpc_write_switch (19, 1); /* Always Closed */
+}
+
struct hw_class wpc_asic_class =
{
.reset = wpc_asic_reset,
.read = wpc_asic_read,
.write = wpc_asic_write,
};
struct hw_device *wpc_asic_create (void)
{
if (wpc)
{
fprintf (stderr, "WPC ASIC already created\n");
return NULL;
}
wpc = &the_wpc;
return device_attach (&wpc_asic_class, 0x800, wpc);
}
void wpc_fault (unsigned int addr, unsigned char type)
{
}
void io_sym_add (const char *name, unsigned long cpuaddr)
{
sym_add (&program_symtab, name, to_absolute (cpuaddr), 0);
}
#define IO_SYM_ADD(name) io_sym_add (#name, name)
void wpc_init (const char *boot_rom_file)
{
struct hw_device *dev;
int rc;
struct sockaddr_in myaddr;
device_define ( dev = wpc_asic_create (), 0,
WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE);
device_define ( dev = ram_create (WPC_RAM_SIZE), 0,
WPC_RAM_BASE, WPC_RAM_SIZE, MAP_READWRITE );
wpc->ram_dev = dev;
dev = rom_create (boot_rom_file, WPC_ROM_SIZE);
device_define ( dev, 0,
WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READONLY);
device_define ( dev, WPC_ROM_SIZE - WPC_FIXED_SIZE,
WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READONLY);
wpc->rom_dev = dev;
device_define ( dev = ram_create (16 * 512), 0,
0x3800, 0x200 * 2, MAP_READWRITE );
wpc->dmd_dev = dev;
wpc_update_ram ();
wpc_sock = udp_socket_create (9000);
if (wpc_sock < 0)
fprintf (stderr, "could not open output socket\n");
IO_SYM_ADD(WPC_DMD_LOW_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_PAGE);
IO_SYM_ADD(WPC_DMD_FIRQ_ROW_VALUE);
IO_SYM_ADD(WPC_DMD_LOW_PAGE);
IO_SYM_ADD(WPC_DMD_ACTIVE_PAGE);
IO_SYM_ADD(WPC_SERIAL_STATUS_PORT);
IO_SYM_ADD(WPC_PARALLEL_DATA_PORT);
IO_SYM_ADD(WPC_PARALLEL_STROBE_PORT);
IO_SYM_ADD(WPC_SERIAL_DATA_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_CONTROL_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_BAUD_SELECT);
IO_SYM_ADD(WPC_TICKET_DISPENSE);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_OUT);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_IN);
IO_SYM_ADD(WPC_DCS_SOUND_RESET);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_READY);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_A);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_B);
IO_SYM_ADD(WPCS_DATA);
IO_SYM_ADD(WPCS_CONTROL_STATUS);
IO_SYM_ADD(WPC_SOL_FLASH2_OUTPUT);
IO_SYM_ADD(WPC_SOL_HIGHPOWER_OUTPUT);
IO_SYM_ADD(WPC_SOL_FLASH1_OUTPUT);
IO_SYM_ADD(WPC_SOL_LOWPOWER_OUTPUT);
IO_SYM_ADD(WPC_LAMP_ROW_OUTPUT);
IO_SYM_ADD(WPC_LAMP_COL_STROBE);
IO_SYM_ADD(WPC_GI_TRIAC);
IO_SYM_ADD(WPC_SW_JUMPER_INPUT);
IO_SYM_ADD(WPC_SW_CABINET_INPUT);
IO_SYM_ADD(WPC_SW_ROW_INPUT);
IO_SYM_ADD(WPC_SW_COL_STROBE);
IO_SYM_ADD(WPC_LEDS);
IO_SYM_ADD(WPC_RAM_BANK);
IO_SYM_ADD(WPC_SHIFTADDR);
IO_SYM_ADD(WPC_SHIFTBIT);
IO_SYM_ADD(WPC_SHIFTBIT2);
IO_SYM_ADD(WPC_PERIPHERAL_TIMER_FIRQ_CLEAR);
IO_SYM_ADD(WPC_ROM_LOCK);
IO_SYM_ADD(WPC_CLK_HOURS_DAYS);
IO_SYM_ADD(WPC_CLK_MINS);
IO_SYM_ADD(WPC_ROM_BANK);
IO_SYM_ADD(WPC_RAM_LOCK);
IO_SYM_ADD(WPC_RAM_LOCKSIZE);
}
struct machine wpc_machine =
{
.name = "wpc",
.fault = wpc_fault,
.init = wpc_init,
};
struct machine wpc95_machine =
{
.name = "wpc95",
.fault = wpc_fault,
.init = wpc_init,
};
|
bcd/exec09
|
c70298c00cfe58f656a1474f045b6aa2fff95fe5
|
Busmaps were not initialized properly. Accesses to invalid addresses that should have called seg faults were not doing so.
|
diff --git a/machine.c b/machine.c
index a4d7ded..2f1e9cd 100644
--- a/machine.c
+++ b/machine.c
@@ -134,529 +134,534 @@ void bus_unmap (unsigned int addr, unsigned int len)
len = ((len + BUS_MAP_SIZE - 1) / BUS_MAP_SIZE) * BUS_MAP_SIZE;
/* Convert from byte addresses to unit counts */
start = addr / BUS_MAP_SIZE;
count = len / BUS_MAP_SIZE;
/* Set the maps to their defaults. */
memcpy (&busmaps[start], &default_busmaps[start],
sizeof (struct bus_map) * count);
}
/**
* Generate a page fault. ADDR says which address was accessed
* incorrectly. TYPE says what kind of violation occurred.
*/
static struct bus_map *find_map (unsigned int addr)
{
return &busmaps[addr / BUS_MAP_SIZE];
}
static struct hw_device *find_device (unsigned int addr, unsigned char id)
{
/* Fault if any invalid device is accessed */
if ((id == INVALID_DEVID) || (id >= device_count))
machine->fault (addr, FAULT_NO_RESPONSE);
return device_table[id];
}
void
print_device_name (unsigned int devno)
{
struct hw_device *dev = device_table[devno];
printf ("%02X", devno);
}
absolute_address_t
absolute_from_reladdr (unsigned int device, unsigned long reladdr)
{
return (device * 0x10000000L) + reladdr;
}
U8 abs_read8 (absolute_address_t addr)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
return (*class_ptr->read) (dev, phy_addr);
}
/**
* Called by the CPU to read a byte.
* This is the bottleneck in terms of performance. Consider
* a caching scheme that cuts down on some of this...
* Also consider a native 16-bit read that doesn't require
* 2 separate calls here...
*/
U8 cpu_read8 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return (*class_ptr->read) (dev, phy_addr);
}
U16 cpu_read16 (unsigned int addr)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
command_read_hook (absolute_from_reladdr (map->devid, phy_addr));
return ((*class_ptr->read) (dev, phy_addr) << 8)
| (*class_ptr->read) (dev, phy_addr+1);
}
/**
* Called by the CPU to write a byte.
*/
void cpu_write8 (unsigned int addr, U8 val)
{
struct bus_map *map = find_map (addr);
struct hw_device *dev = find_device (addr, map->devid);
struct hw_class *class_ptr = dev->class_ptr;
unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE;
/* This can fail if the area is read-only */
if (system_running && (map->flags & MAP_READONLY))
machine->fault (addr, FAULT_NOT_WRITABLE);
else
(*class_ptr->write) (dev, phy_addr, val);
command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val);
}
void abs_write8 (absolute_address_t addr, U8 val)
{
unsigned int id = addr >> 28;
unsigned long phy_addr = addr & 0xFFFFFFF;
struct hw_device *dev = device_table[id];
struct hw_class *class_ptr = dev->class_ptr;
class_ptr->write (dev, phy_addr, val);
}
absolute_address_t
to_absolute (unsigned long cpuaddr)
{
struct bus_map *map = find_map (cpuaddr);
struct hw_device *dev = find_device (cpuaddr, map->devid);
unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE;
return absolute_from_reladdr (map->devid, phy_addr);
}
void dump_machine (void)
{
unsigned int mapno;
unsigned int n;
for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++)
{
struct bus_map *map = &busmaps[mapno];
printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X\n",
mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset,
0 /* device_table[map->devid]->size */);
#if 0
for (n = 0; n < BUS_MAP_SIZE; n++)
printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n));
printf ("\n");
#endif
}
}
/**********************************************************/
void null_reset (struct hw_device *dev)
{
}
U8 null_read (struct hw_device *dev, unsigned long addr)
{
return 0;
}
void null_write (struct hw_device *dev, unsigned long addr, U8 val)
{
}
/**********************************************************/
void ram_reset (struct hw_device *dev)
{
memset (dev->priv, 0, dev->size);
}
U8 ram_read (struct hw_device *dev, unsigned long addr)
{
char *buf = dev->priv;
return buf[addr];
}
void ram_write (struct hw_device *dev, unsigned long addr, U8 val)
{
char *buf = dev->priv;
buf[addr] = val;
}
struct hw_class ram_class =
{
.readonly = 0,
.reset = ram_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *ram_create (unsigned long size)
{
void *buf = malloc (size);
return device_attach (&ram_class, size, buf);
}
/**********************************************************/
struct hw_class rom_class =
{
.readonly = 1,
.reset = null_reset,
.read = ram_read,
.write = ram_write,
};
struct hw_device *rom_create (const char *filename, unsigned int maxsize)
{
FILE *fp;
struct hw_device *dev;
unsigned int image_size;
char *buf;
if (filename)
{
fp = file_open (NULL, filename, "rb");
if (!fp)
return NULL;
image_size = sizeof_file (fp);
}
buf = malloc (maxsize);
dev = device_attach (&rom_class, maxsize, buf);
if (filename)
{
fread (buf, image_size, 1, fp);
fclose (fp);
maxsize -= image_size;
while (maxsize > 0)
{
memcpy (buf + image_size, buf, image_size);
buf += image_size;
maxsize -= image_size;
}
}
return dev;
}
/**********************************************************/
U8 console_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case CON_IN:
return getchar ();
default:
return MISSING;
}
}
void console_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr)
{
case CON_OUT:
putchar (val);
break;
case CON_EXIT:
sim_exit (val);
break;
default:
break;
}
}
struct hw_class console_class =
{
.readonly = 0,
.reset = null_reset,
.read = console_read,
.write = console_write,
};
struct hw_device *console_create (void)
{
return device_attach (&console_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS];
U8 mmu_read (struct hw_device *dev, unsigned long addr)
{
switch (addr)
{
case 0x60:
return fault_addr >> 8;
case 0x61:
return fault_addr & 0xFF;
case 0x62:
return fault_type;
default:
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
U8 val = mmu_regs[page][reg];
//printf ("\n%02X, %02X = %02X\n", page, reg, val);
return val;
}
}
}
void mmu_write (struct hw_device *dev, unsigned long addr, U8 val)
{
unsigned int page = (addr / MMU_PAGEREGS) % MMU_PAGECOUNT;
unsigned int reg = addr % MMU_PAGEREGS;
mmu_regs[page][reg] = val;
bus_map (page * MMU_PAGESIZE,
mmu_regs[page][0],
mmu_regs[page][1] * MMU_PAGESIZE,
MMU_PAGESIZE,
mmu_regs[page][2] & 0x1);
}
void mmu_reset (struct hw_device *dev)
{
unsigned int page;
for (page = 0; page < MMU_PAGECOUNT; page++)
{
mmu_write (dev, page * MMU_PAGEREGS + 0, 0);
mmu_write (dev, page * MMU_PAGEREGS + 1, 0);
mmu_write (dev, page * MMU_PAGEREGS + 2, 0);
}
}
void mmu_reset_complete (struct hw_device *dev)
{
unsigned int page;
const struct bus_map *map;
/* Examine all of the bus_maps in place now, and
sync with the MMU registers. */
for (page = 0; page < MMU_PAGECOUNT; page++)
{
map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)];
mmu_regs[page][0] = map->devid;
mmu_regs[page][1] = map->offset / MMU_PAGESIZE;
mmu_regs[page][2] = map->flags & 0x1;
/* printf ("%02X %02X %02X\n",
map->devid, map->offset / MMU_PAGESIZE,
map->flags); */
}
}
struct hw_class mmu_class =
{
.readonly = 0,
.reset = mmu_reset,
.read = mmu_read,
.write = mmu_write,
};
struct hw_device *mmu_create (void)
{
return device_attach (&mmu_class, BUS_MAP_SIZE, NULL);
}
/**********************************************************/
/* The disk drive is emulated as follows:
* The disk is capable of "bus-mastering" and is able to dump data directly
* into the RAM, without CPU-involvement. (The pages do not even need to
* be mapped.) A transaction is initiated with the following parameters:
*
* - address of RAM, aligned to 512 bytes, must reside in lower 32KB.
* Thus there are 64 possible sector locations.
* - address of disk sector, given as a 16-bit value. This allows for up to
* a 32MB disk.
* - direction, either to disk or from disk.
*
* Emulation is synchronous with respect to the CPU.
*/
struct disk_priv
{
FILE *fp;
struct hw_device *dev;
unsigned long offset;
struct hw_device *ramdev;
unsigned int sectors;
char *ram;
};
U8 disk_read (struct hw_device *dev, unsigned long addr)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
}
void disk_write (struct hw_device *dev, unsigned long addr, U8 val)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
switch (addr)
{
case DSK_ADDR:
disk->ram = disk->ramdev->priv + val * SECTOR_SIZE;
break;
case DSK_SECTOR:
disk->offset = val; /* high byte */
break;
case DSK_SECTOR+1:
disk->offset = (disk->offset << 8) | val;
disk->offset *= SECTOR_SIZE;
fseek (disk->fp, disk->offset, SEEK_SET);
break;
case DSK_CTRL:
if (val & DSK_READ)
{
fread (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_WRITE)
{
fwrite (disk->ram, SECTOR_SIZE, 1, disk->fp);
}
else if (val & DSK_ERASE)
{
char empty_sector[SECTOR_SIZE];
memset (empty_sector, 0xff, SECTOR_SIZE);
fwrite (empty_sector, SECTOR_SIZE, 1, disk->fp);
}
if (val & DSK_FLUSH)
{
fflush (disk->fp);
}
break;
}
}
void disk_reset (struct hw_device *dev)
{
struct disk_priv *disk = (struct disk_priv *)dev->priv;
disk_write (dev, DSK_ADDR, 0);
disk_write (dev, DSK_SECTOR, 0);
disk_write (dev, DSK_SECTOR+1, 0);
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
void disk_format (struct hw_device *dev)
{
unsigned int sector;
struct disk_priv *disk = (struct disk_priv *)dev->priv;
for (sector = 0; sector < disk->sectors; sector++)
{
disk_write (dev, DSK_SECTOR, sector >> 8);
disk_write (dev, DSK_SECTOR+1, sector & 0xFF);
disk_write (dev, DSK_CTRL, DSK_ERASE);
}
disk_write (dev, DSK_CTRL, DSK_FLUSH);
}
struct hw_class disk_class =
{
.readonly = 0,
.reset = disk_reset,
.read = disk_read,
.write = disk_write,
};
struct hw_device *disk_create (const char *backing_file)
{
struct disk_priv *disk = malloc (sizeof (struct disk_priv));
int newdisk = 0;
disk->fp = file_open (NULL, backing_file, "r+b");
if (disk->fp == NULL)
{
printf ("warning: disk does not exist, creating\n");
disk->fp = file_open (NULL, backing_file, "w+b");
newdisk = 1;
if (disk->fp == NULL)
{
printf ("warning: disk not created\n");
}
}
disk->ram = 0;
disk->ramdev = device_table[1];
disk->dev = device_attach (&disk_class, BUS_MAP_SIZE, disk);
disk->sectors = DISK_SECTOR_COUNT;
if (newdisk)
disk_format (disk->dev);
return disk->dev;
}
/**********************************************************/
int machine_match (const char *machine_name, const char *boot_rom_file, struct machine *m)
{
if (!strcmp (m->name, machine_name))
{
machine = m;
m->init (boot_rom_file);
return 1;
}
return 0;
}
void machine_init (const char *machine_name, const char *boot_rom_file)
{
extern struct machine simple_machine;
extern struct machine eon_machine;
extern struct machine wpc_machine;
+ int i;
+ /* Initialize CPU maps, so that no CPU addresses map to
+ anything. Default maps will trigger faults at runtime. */
memset (busmaps, 0, sizeof (busmaps));
+ for (i = 0; i < NUM_BUS_MAPS; i++)
+ busmaps[i].devid = INVALID_DEVID;
if (machine_match (machine_name, boot_rom_file, &simple_machine));
else if (machine_match (machine_name, boot_rom_file, &eon_machine));
else if (machine_match (machine_name, boot_rom_file, &wpc_machine));
else exit (1);
/* Save the default busmap configuration, before the
CPU begins to run, so that it can be restored if
necessary. */
memcpy (default_busmaps, busmaps, sizeof (busmaps));
if (!strcmp (machine_name, "eon"))
mmu_reset_complete (mmu_device);
}
|
bcd/exec09
|
99c8cbd9e990d674c18d7d01b2b7391a83b75827
|
WPC: Ensure the "always closed" switch is really closed.
|
diff --git a/wpc.c b/wpc.c
index 0a1c051..9c341fd 100644
--- a/wpc.c
+++ b/wpc.c
@@ -1,710 +1,715 @@
/*
* Copyright 2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "6809.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
#error
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/errno.h>
#include "wpclib.h"
#define WPC_RAM_BASE 0x0000
#define WPC_RAM_SIZE 0x2000
#define WPC_ROM_SIZE 0x100000
#define WPC_PAGED_REGION 0x4000
#define WPC_PAGED_SIZE 0x4000
#define WPC_FIXED_REGION 0x8000
#define WPC_FIXED_SIZE 0x8000
/* The register set of the WPC ASIC */
#define WPC_ASIC_BASE 0x3c00
#define WPC_DMD_LOW_BASE 0x3800
#define WPC_DMD_HIGH_BASE 0x3A00
#define WPC_DEBUG_DATA_PORT 0x3D60
#define WPC_DEBUG_CONTROL_PORT 0x3D61
#define WPC_DEBUG_WRITE_READY 0x1
#define WPC_DEBUG_READ_READY 0x2
#define WPC_PINMAME_CYCLE_COUNT 0x3D62
#define WPC_PINMAME_FUNC_ENTRY_HI 0x3D63
#define WPC_PINMAME_FUNC_ENTRY_LO 0x3D64
#define WPC_PINMAME_FUNC_EXIT_HI 0x3D65
#define WPC_PINMAME_FUNC_EXIT_LO 0x3D66
#define WPC_SERIAL_CONTROL_PORT 0x3E66
#define WPC_SERIAL_DATA_PORT 0x3E67
#define WPC_DMD_3200_PAGE 0x3FB8
#define WPC_DMD_3000_PAGE 0x3FB9
#define WPC_DMD_3600_PAGE 0x3FBA
#define WPC_DMD_3400_PAGE 0x3FBB
#define WPC_DMD_HIGH_PAGE 0x3FBC
#define WPC_DMD_FIRQ_ROW_VALUE 0x3FBD
#define WPC_DMD_LOW_PAGE 0x3FBE
#define WPC_DMD_ACTIVE_PAGE 0x3FBF
#define WPC_SERIAL_STATUS_PORT 0x3FC0
#define WPC_PARALLEL_DATA_PORT 0x3FC1
#define WPC_PARALLEL_STROBE_PORT 0x3FC2
#define WPC_SERIAL_DATA_OUTPUT 0x3FC3
#define WPC_SERIAL_CONTROL_OUTPUT 0x3FC4
#define WPC_SERIAL_BAUD_SELECT 0x3FC5
#define WPC_TICKET_DISPENSE 0x3FC6
#define WPC_DCS_SOUND_DATA_OUT 0x3FD0
#define WPC_DCS_SOUND_DATA_IN 0x3FD1
#define WPC_DCS_SOUND_RESET 0x3FD2
#define WPC_DCS_SOUND_DATA_READY 0x3FD3
#define WPC_FLIPTRONIC_PORT_A 0x3FD4
#define WPC_FLIPTRONIC_PORT_B 0x3FD5
#define WPCS_DATA 0x3FDC
#define WPCS_CONTROL_STATUS 0x3FDD
#define WPC_SOL_FLASH2_OUTPUT 0x3FE0
#define WPC_SOL_HIGHPOWER_OUTPUT 0x3FE1
#define WPC_SOL_FLASH1_OUTPUT 0x3FE2
#define WPC_SOL_LOWPOWER_OUTPUT 0x3FE3
#define WPC_LAMP_ROW_OUTPUT 0x3FE4
#define WPC_LAMP_COL_STROBE 0x3FE5
#define WPC_GI_TRIAC 0x3FE6
#define WPC_SW_JUMPER_INPUT 0x3FE7
#define WPC_SW_CABINET_INPUT 0x3FE8
#define WPC_SW_ROW_INPUT 0x3FE9 /* WPC */
#define WPC_SW_COL_STROBE 0x3FEA /* WPC */
#define WPCS_PIC_READ 0x3FE9 /* WPCS, WPC95 */
#define WPCS_PIC_WRITE 0x3FEA /* WPCS, WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_POS 0x3FEB
#define WPC_ALPHA_ROW1 0x3FEC
#else
#define WPC_EXTBOARD1 0x3FEB
#define WPC_EXTBOARD2 0x3FEC
#define WPC_EXTBOARD3 0x3FED
#endif
#define WPC95_FLIPPER_COIL_OUTPUT 0x3FEE /* WPC95 */
#define WPC95_FLIPPER_SWITCH_INPUT 0x3FEF /* WPC95 */
#if (MACHINE_DMD == 0)
#define WPC_ALPHA_ROW2 0x3FEE
#else
#endif
#define WPC_LEDS 0x3FF2
#define WPC_RAM_BANK 0x3FF3 /* WPC95 */
#define WPC_SHIFTADDR 0x3FF4
#define WPC_SHIFTBIT 0x3FF6
#define WPC_SHIFTBIT2 0x3FF7
#define WPC_PERIPHERAL_TIMER_FIRQ_CLEAR 0x3FF8
#define WPC_ROM_LOCK 0x3FF9
#define WPC_CLK_HOURS_DAYS 0x3FFA
#define WPC_CLK_MINS 0x3FFB
#define WPC_ROM_BANK 0x3FFC
#define WPC_RAM_LOCK 0x3FFD
#define WPC_RAM_LOCKSIZE 0x3FFE
#define WPC_ZEROCROSS_IRQ_CLEAR 0x3FFF
/**
* The 'wpc_asic' struct holds all of the state
* of the ASIC. There is a single instance of this,
* named 'the_wpc', and it is pointed to by the
* global 'wpc'. Only one ASIC can be defined at
* a time.
*/
struct wpc_asic
{
struct hw_device *rom_dev;
struct hw_device *ram_dev;
struct hw_device *dmd_dev;
U8 led;
U8 rombank;
U8 ram_unlocked;
U8 ram_lock_size;
U16 shiftaddr;
U16 shiftbit;
U8 lamp_strobe;
U8 lamp_mx[8];
U8 sols[6];
U8 switch_strobe;
U8 switch_mx[8];
U8 opto_mx[8];
U8 dmd_maps[2];
unsigned int dmd_phase;
U8 dmd_visibles[3];
U8 dmd_last_visibles[3];
int curr_sw;
int curr_sw_time;
int wdog_timer;
} the_wpc;
struct wpc_asic *wpc = NULL;
int wpc_sock;
-void wpc_asic_reset (struct hw_device *dev)
-{
- memset (wpc, 0, sizeof (struct wpc_asic));
-}
-
static int wpc_console_inited = 0;
static U8 wpc_get_console_state (void)
{
fd_set fds;
struct timeval timeout;
U8 rc = WPC_DEBUG_WRITE_READY;
if (!wpc_console_inited)
rc |= WPC_DEBUG_READ_READY;
#if 1
return rc;
#endif
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
rc |= WPC_DEBUG_READ_READY;
return rc;
}
static U8 wpc_console_read (void)
{
int rc;
U8 c = 0;
if (!wpc_console_inited)
{
wpc_console_inited = 1;
return 0;
}
rc = read (0, &c, 1);
return c;
}
static void wpc_console_write (U8 val)
{
putchar (val);
fflush (stdout);
}
static int scanbit (U8 val)
{
if (val & 0x80) return 7;
else if (val & 0x40) return 6;
else if (val & 0x20) return 5;
else if (val & 0x10) return 4;
else if (val & 0x08) return 3;
else if (val & 0x04) return 2;
else if (val & 0x02) return 1;
else if (val & 0x01) return 0;
else return -1;
}
unsigned int wpc_read_switch (int num)
{
unsigned int val;
val = wpc->switch_mx[num / 8] & (1 << (num % 8));
return val ? 1 : 0;
}
void wpc_write_switch (int num, int flag)
{
unsigned int col, val;
col = num / 8;
val = 1 << (num % 8);
+#if 0
if (wpc->opto_mx[col] & val)
flag = !flag;
+#endif
wpc->switch_mx[col] &= ~val;
if (flag)
wpc->switch_mx[col] |= val;
}
void wpc_press_switch (int num, int delay)
{
wpc_write_switch (num, 1);
wpc->curr_sw = num;
wpc->curr_sw_time = delay;
}
unsigned int wpc_read_switch_column (int col)
{
unsigned int val = 0;
int row;
for (row = 0; row < 8; row++)
if (wpc_read_switch (col * 8 + row))
val |= (1 << row);
return val;
}
void wpc_dmd_set_visible (U8 val)
{
char *p;
struct wpc_message msg;
int rc;
int i, n;
static unsigned long last_firq_time = 0;
unsigned long now;
static int no_change_count = 0;
now = get_cycles ();
if (now - last_firq_time <= 1850 * 8)
{
//printf ("%02X ignored.\n", val);
return;
}
else if (now - last_firq_time >= 1850 * 8 * 5)
{
memset (wpc->dmd_visibles, val, 3);
wpc->dmd_phase = 0;
}
else
{
wpc->dmd_visibles[wpc->dmd_phase++] = val;
if (wpc->dmd_phase == 3)
wpc->dmd_phase = 0;
}
last_firq_time = now;
#if 0
printf ("%02X %f\n", val, get_cycles () / 1952.0);
#endif
if (!memcmp (wpc->dmd_visibles, wpc->dmd_last_visibles, 3)
&& (++no_change_count < 100))
return;
no_change_count = 0;
#if 0
printf ("%02X %02X %02X\n",
wpc->dmd_visibles[0],
wpc->dmd_visibles[1],
wpc->dmd_visibles[2]);
#endif
memcpy (wpc->dmd_last_visibles, wpc->dmd_visibles, 3);
/* Send updated page contents */
wpc_msg_init (CODE_DMD_PAGE, &msg);
for (i=0; i < 3; i++)
{
p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512;
msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i];
memcpy (&msg.u.dmdpage.phases[i].data, p, 512);
}
msg.len = sizeof (struct _dmdpage_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
/* Send status of which pages are visible now */
wpc_msg_init (CODE_DMD_VISIBLE, &msg);
for (i=0; i < 3; i++)
msg.u.dmdvisible.phases[i] = wpc->dmd_visibles[i];
msg.len = sizeof (struct _dmdvisible_info);
wpc_msg_send (wpc_sock, 9000 ^ 1, &msg);
}
void wpc_keypoll (void)
{
fd_set fds;
struct timeval timeout;
int rc;
unsigned char c;
FD_ZERO (&fds);
FD_SET (0, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (select (1, &fds, NULL, NULL, &timeout))
{
rc = read (0, &c, 1);
+#define BUTTON_DURATION 500
switch (c)
{
case '7':
- wpc_press_switch (4, 200);
+ wpc_press_switch (4, BUTTON_DURATION);
break;
case '8':
- wpc_press_switch (5, 200);
+ wpc_press_switch (5, BUTTON_DURATION);
break;
case '9':
- wpc_press_switch (6, 200);
+ wpc_press_switch (6, BUTTON_DURATION);
break;
case '0':
- wpc_press_switch (7, 200);
+ wpc_press_switch (7, BUTTON_DURATION);
break;
default:
+ printf ("wpc: invalid character '%c'\n", c);
break;
}
}
}
U8 wpc_asic_read (struct hw_device *dev, unsigned long addr)
{
U8 val;
switch (addr + WPC_ASIC_BASE)
{
case WPC_LEDS:
val = wpc->led;
break;
case WPC_ROM_BANK:
val = wpc->rombank;
break;
case WPC_DEBUG_CONTROL_PORT:
val = wpc_get_console_state ();
break;
case WPC_DEBUG_DATA_PORT:
val = wpc_console_read ();
break;
case WPC_SHIFTADDR:
val = wpc->shiftaddr >> 8;
break;
case WPC_SHIFTADDR+1:
val = (wpc->shiftaddr & 0xFF) + (wpc->shiftbit / 8);
break;
case WPC_SHIFTBIT:
val = 1 << (wpc->shiftbit % 8);
break;
case WPC_SW_ROW_INPUT:
val = wpc_read_switch_column (1 + scanbit (wpc->switch_strobe));
break;
case WPC_SW_JUMPER_INPUT:
val = 0x55;
break;
case WPC_SW_CABINET_INPUT:
val = wpc_read_switch_column (0);
break;
case WPC_FLIPTRONIC_PORT_A:
case WPC_FLIPTRONIC_PORT_B:
case WPC95_FLIPPER_SWITCH_INPUT:
return 0xFF;
default:
val = 0;
break;
}
//printf (">>> ASIC read %04X -> %02X\n", addr + WPC_ASIC_BASE, val);
return val;
}
/**
* Enforce the current read-only area of RAM.
*/
void wpc_update_ram (void)
{
unsigned int size_writable = WPC_RAM_SIZE;
if (!wpc->ram_unlocked)
{
switch (wpc->ram_lock_size)
{
default:
break;
case 0xF:
size_writable -= 256;
break;
case 0x7:
size_writable -= 512;
case 0x3:
size_writable -= 1024;
break;
case 0x1:
size_writable -= 2048;
break;
case 0:
size_writable -= 4096;
break;
}
}
bus_map (WPC_RAM_BASE, wpc->ram_dev->devid, 0, size_writable, MAP_READWRITE);
if (size_writable < WPC_RAM_SIZE)
bus_map (WPC_RAM_BASE + size_writable, wpc->ram_dev->devid, size_writable,
WPC_RAM_SIZE - size_writable, MAP_READONLY);
}
void wpc_set_rom_page (unsigned char val)
{
bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READONLY);
}
void wpc_set_dmd_page (unsigned int map, unsigned char val)
{
wpc->dmd_maps[map] = val;
bus_map (0x3800 + map * 0x200, 3, val * 0x200, 0x200, MAP_READWRITE);
}
void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val)
{
switch (addr + WPC_ASIC_BASE)
{
case WPC_DMD_LOW_PAGE:
wpc_set_dmd_page (0, val);
break;
case WPC_DMD_HIGH_PAGE:
wpc_set_dmd_page (1, val);
break;
case WPC_DMD_FIRQ_ROW_VALUE:
break;
case WPC_DMD_ACTIVE_PAGE:
wpc_dmd_set_visible (val);
break;
case WPC_LEDS:
wpc->led = val;
break;
case WPC_ZEROCROSS_IRQ_CLEAR:
wpc->wdog_timer++;
break;
case WPC_ROM_BANK:
wpc->rombank = val;
wpc_set_rom_page (val);
break;
case WPC_DEBUG_DATA_PORT:
wpc_console_write (val);
break;
case WPC_RAM_LOCK:
wpc->ram_unlocked = val;
wpc_update_ram ();
break;
case WPC_RAM_LOCKSIZE:
wpc->ram_lock_size = val;
wpc_update_ram ();
break;
case WPC_SHIFTADDR:
wpc->shiftaddr &= 0x00FF;
wpc->shiftaddr |= val << 8;
break;
case WPC_SHIFTADDR+1:
wpc->shiftaddr &= 0xFF00;
wpc->shiftaddr |= val;
break;
case WPC_SHIFTBIT:
wpc->shiftbit = val;
break;
case WPC_LAMP_ROW_OUTPUT:
wpc->lamp_mx[scanbit (wpc->lamp_strobe)] = val;
break;
case WPC_LAMP_COL_STROBE:
wpc->lamp_strobe = val;
break;
case WPC_SW_COL_STROBE:
wpc->switch_strobe = val;
default:
break;
}
//printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val);
}
void wpc_periodic (void)
{
wpc_keypoll ();
wpc->wdog_timer -= 50;
if (wpc->wdog_timer <= 0)
{
}
if (wpc->curr_sw_time > 0)
{
wpc->curr_sw_time -= 100;
if (wpc->curr_sw_time <= 0)
{
wpc->curr_sw_time = 0;
wpc_write_switch (wpc->curr_sw, 0);
}
}
}
+void wpc_asic_reset (struct hw_device *dev)
+{
+ memset (wpc, 0, sizeof (struct wpc_asic));
+ wpc_write_switch (19, 1); /* Always Closed */
+}
+
struct hw_class wpc_asic_class =
{
.reset = wpc_asic_reset,
.read = wpc_asic_read,
.write = wpc_asic_write,
};
struct hw_device *wpc_asic_create (void)
{
if (wpc)
{
fprintf (stderr, "WPC ASIC already created\n");
return NULL;
}
wpc = &the_wpc;
return device_attach (&wpc_asic_class, 0x800, wpc);
}
void wpc_fault (unsigned int addr, unsigned char type)
{
}
void io_sym_add (const char *name, unsigned long cpuaddr)
{
sym_add (&program_symtab, name, to_absolute (cpuaddr), 0);
}
#define IO_SYM_ADD(name) io_sym_add (#name, name)
void wpc_init (const char *boot_rom_file)
{
struct hw_device *dev;
int rc;
struct sockaddr_in myaddr;
device_define ( dev = wpc_asic_create (), 0,
WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE);
device_define ( dev = ram_create (WPC_RAM_SIZE), 0,
WPC_RAM_BASE, WPC_RAM_SIZE, MAP_READWRITE );
wpc->ram_dev = dev;
dev = rom_create (boot_rom_file, WPC_ROM_SIZE);
device_define ( dev, 0,
WPC_PAGED_REGION, WPC_PAGED_SIZE, MAP_READONLY);
device_define ( dev, WPC_ROM_SIZE - WPC_FIXED_SIZE,
WPC_FIXED_REGION, WPC_FIXED_SIZE, MAP_READONLY);
wpc->rom_dev = dev;
device_define ( dev = ram_create (16 * 512), 0,
0x3800, 0x200 * 2, MAP_READWRITE );
wpc->dmd_dev = dev;
wpc_update_ram ();
wpc_sock = udp_socket_create (9000);
if (wpc_sock < 0)
fprintf (stderr, "could not open output socket\n");
IO_SYM_ADD(WPC_DMD_LOW_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_BASE);
IO_SYM_ADD(WPC_DMD_HIGH_PAGE);
IO_SYM_ADD(WPC_DMD_FIRQ_ROW_VALUE);
IO_SYM_ADD(WPC_DMD_LOW_PAGE);
IO_SYM_ADD(WPC_DMD_ACTIVE_PAGE);
IO_SYM_ADD(WPC_SERIAL_STATUS_PORT);
IO_SYM_ADD(WPC_PARALLEL_DATA_PORT);
IO_SYM_ADD(WPC_PARALLEL_STROBE_PORT);
IO_SYM_ADD(WPC_SERIAL_DATA_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_CONTROL_OUTPUT);
IO_SYM_ADD(WPC_SERIAL_BAUD_SELECT);
IO_SYM_ADD(WPC_TICKET_DISPENSE);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_OUT);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_IN);
IO_SYM_ADD(WPC_DCS_SOUND_RESET);
IO_SYM_ADD(WPC_DCS_SOUND_DATA_READY);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_A);
IO_SYM_ADD(WPC_FLIPTRONIC_PORT_B);
IO_SYM_ADD(WPCS_DATA);
IO_SYM_ADD(WPCS_CONTROL_STATUS);
IO_SYM_ADD(WPC_SOL_FLASH2_OUTPUT);
IO_SYM_ADD(WPC_SOL_HIGHPOWER_OUTPUT);
IO_SYM_ADD(WPC_SOL_FLASH1_OUTPUT);
IO_SYM_ADD(WPC_SOL_LOWPOWER_OUTPUT);
IO_SYM_ADD(WPC_LAMP_ROW_OUTPUT);
IO_SYM_ADD(WPC_LAMP_COL_STROBE);
IO_SYM_ADD(WPC_GI_TRIAC);
IO_SYM_ADD(WPC_SW_JUMPER_INPUT);
IO_SYM_ADD(WPC_SW_CABINET_INPUT);
IO_SYM_ADD(WPC_SW_ROW_INPUT);
IO_SYM_ADD(WPC_SW_COL_STROBE);
IO_SYM_ADD(WPC_LEDS);
IO_SYM_ADD(WPC_RAM_BANK);
IO_SYM_ADD(WPC_SHIFTADDR);
IO_SYM_ADD(WPC_SHIFTBIT);
IO_SYM_ADD(WPC_SHIFTBIT2);
IO_SYM_ADD(WPC_PERIPHERAL_TIMER_FIRQ_CLEAR);
IO_SYM_ADD(WPC_ROM_LOCK);
IO_SYM_ADD(WPC_CLK_HOURS_DAYS);
IO_SYM_ADD(WPC_CLK_MINS);
IO_SYM_ADD(WPC_ROM_BANK);
IO_SYM_ADD(WPC_RAM_LOCK);
IO_SYM_ADD(WPC_RAM_LOCKSIZE);
}
struct machine wpc_machine =
{
.name = "wpc",
.fault = wpc_fault,
.init = wpc_init,
};
struct machine wpc95_machine =
{
.name = "wpc95",
.fault = wpc_fault,
.init = wpc_init,
};
|
bcd/exec09
|
12961600cfe2e80985efa4fbdf70cd7f21a055cb
|
Change IRQ frequency for WPC machine.
|
diff --git a/wpc-run b/wpc-run
index cbc544d..214880f 100755
--- a/wpc-run
+++ b/wpc-run
@@ -1,2 +1,2 @@
#!/bin/sh
-m6809-run -s wpc -I 1952 -b -C -d -m -1 $*
+m6809-run -s wpc -I 2049 -b -C -d -m -1 $*
|
bcd/exec09
|
01b970d086507d0f181995f32e890821ce60e10a
|
Add wpc-run shell script. It is a frontend to the emulator with the right options to select the WPC machine type.
|
diff --git a/Makefile.am b/Makefile.am
index b937dc1..3ab7281 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
m6809_run_SOURCES = \
6809.c main.c monitor.c machine.c eon.c wpc.c \
symtab.c command.c fileio.c wpclib.c \
6809.h config.h eon.h machine.h monitor.h wpclib.h
bin_PROGRAMS = m6809-run
+bin_SCRIPTS = wpc-run
diff --git a/wpc-run b/wpc-run
new file mode 100755
index 0000000..cbc544d
--- /dev/null
+++ b/wpc-run
@@ -0,0 +1,2 @@
+#!/bin/sh
+m6809-run -s wpc -I 1952 -b -C -d -m -1 $*
|
bcd/exec09
|
a16c9201f6bd8e0326cdbf49859ae9e9776dad3d
|
Add -p (persistent) option, for causing RAM devices to be saved on exit. Not yet implemented.
|
diff --git a/main.c b/main.c
index e778eb5..4544150 100644
--- a/main.c
+++ b/main.c
@@ -1,408 +1,414 @@
/*
* Copyright 2001 by Arto Salmi and Joze Fabcic
* Copyright 2006-2008 by Brian Dominy <brian@oddchange.com>
*
* This file is part of GCC6809.
*
* GCC6809 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GCC6809 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GCC6809; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include "6809.h"
enum
{ HEX, S19, BIN };
/* The total number of cycles that have executed */
unsigned long total = 0;
/* The frequency of the emulated CPU, in megahertz */
unsigned int mhz = 1;
/* When nonzero, indicates that the IRQ should be triggered periodically,
every so many cycles. By default no periodic IRQ is generated. */
unsigned int cycles_per_irq = 0;
/* When nonzero, indicates that the FIRQ should be triggered periodically,
every so many cycles. By default no periodic FIRQ is generated. */
unsigned int cycles_per_firq = 0;
/* Nonzero if debugging support is turned on */
int debug_enabled = 0;
/* Nonzero if tracing is enabled */
int trace_enabled = 0;
/* When nonzero, causes the program to print the total number of cycles
on a successful exit. */
int dump_cycles_on_success = 0;
/* When nonzero, indicates the total number of cycles before an automated
exit. This is to help speed through test cases that never finish. */
int max_cycles = 100000000;
+/* When nonzero, says that the state of the machine is persistent
+across runs of the simulator. */
+int machine_persistent = 0;
+
static int type = S19;
char *exename;
const char *machine_name = "simple";
const char *prog_name = NULL;
FILE *stat_file = NULL;
void
idle_loop (void)
{
struct timeval now;
static struct timeval last = { 0, 0 };
int real_ms;
static unsigned long last_cycles = 0;
unsigned long cycles;
int sim_ms;
const int cycles_per_ms = 2000;
static int period = 100;
static int count = 100;
int delay;
static int total_ms_elapsed = 0;
if (--count > 0)
return;
if (last.tv_usec == 0)
gettimeofday (&last, NULL);
gettimeofday (&now, NULL);
real_ms = (now.tv_usec - last.tv_usec) / 1000;
if (real_ms < 0)
real_ms += 1000;
last = now;
cycles = get_cycles ();
sim_ms = (cycles - last_cycles) / cycles_per_ms;
if (sim_ms < 0)
sim_ms += cycles_per_ms;
last_cycles = cycles;
total_ms_elapsed += sim_ms;
if (total_ms_elapsed > 100)
{
total_ms_elapsed -= 100;
wpc_periodic ();
command_periodic ();
}
delay = sim_ms - real_ms;
if (delay > 0)
{
if (delay > 60)
period -= 5;
else if (delay < 20)
period += 5;
usleep (delay * 1000UL);
}
count = period;
}
int do_help (const char *arg __attribute__((unused)));
#define NO_NEG 0
#define HAS_NEG 1
#define NO_ARG 0
#define HAS_ARG 1
struct option
{
char o_short;
const char *o_long;
const char *help;
unsigned int can_negate : 1;
unsigned int takes_arg : 1;
int *int_value;
int default_value;
const char **string_value;
int (*handler) (const char *arg);
} option_table[] = {
{ 'd', "debug", "Enter the monitor immediately",
HAS_NEG, NO_ARG, &debug_enabled, 1, NULL, NULL },
{ 'h', "help", NULL,
NO_NEG, NO_ARG, NULL, NULL, 0, do_help },
{ 'b', "binary", "",
NO_NEG, NO_ARG, &type, BIN, NULL, NULL },
{ 'M', "mhz", "", NO_NEG, HAS_ARG },
{ '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" },
{ '-', "68b09", "Emulate the 68B09 variation (2Mhz)" },
{ 'R', "realtime", "Limit simulation speed to match realtime" },
{ 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL },
{ 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically",
NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL },
{ 'C', "cycledump", "",
HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL},
{ 't', "loadmap", "" },
{ 'T', "trace", "",
NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL },
{ 'm', "maxcycles", "Sets maximum number of cycles to run",
NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL },
{ 's', "machine", "Specify the machine (exact hardware) to emulate",
NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL },
+ { 'p', "persistent", "Use persistent machine state",
+ NO_NEG, NO_ARG, &machine_persistent, 1, NULL, NULL },
{ '\0', NULL },
};
int
do_help (const char *arg __attribute__((unused)))
{
struct option *opt = option_table;
printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION);
printf ("m6809-run [options] [program]\n\n");
printf ("Options:\n");
while (opt->o_long != NULL)
{
if (opt->help)
{
if (opt->o_short == '-')
printf (" --%-16.16s %s\n", opt->o_long, opt->help);
else
printf (" -%c, --%-16.16s%s\n", opt->o_short, opt->o_long, opt->help);
}
opt++;
}
return -1;
}
void usage (void)
{
do_help (NULL);
}
/**
* Returns positive if an argument was taken.
* Returns zero if no argument was taken.
* Returns negative on error.
*/
int
process_option (struct option *opt, const char *arg)
{
int rc;
//printf ("Processing option '%s'\n", opt->o_long);
if (opt->takes_arg)
{
if (!arg)
{
//printf (" Takes argument but none given.\n");
rc = 0;
}
else
{
if (opt->int_value)
{
*(opt->int_value) = strtoul (arg, NULL, 0);
//printf (" Integer argument '%d' taken.\n", *(opt->int_value));
}
else if (opt->string_value)
{
*(opt->string_value) = arg;
//printf (" String argument '%s' taken.\n", *(opt->string_value));
}
rc = 1;
}
}
else
{
if (arg)
//printf (" Takes no argument but one given, ignored.\n");
if (opt->int_value)
{
*(opt->int_value) = opt->default_value;
//printf (" Integer argument 1 implied.\n");
}
rc = 0;
}
if (opt->handler)
{
rc = opt->handler (arg);
//printf (" Handler called, rc=%d\n", rc);
}
if (rc < 0)
exit (0);
return rc;
}
int
process_plain_argument (const char *arg)
{
//printf ("plain argument '%s'\n", arg);
if (!prog_name)
prog_name = arg;
}
int
parse_args (int argc, char *argv[])
{
int argn = 1;
struct option *opt;
next_arg:
while (argn < argc)
{
char *arg = argv[argn];
if (arg[0] == '-')
{
if (arg[1] == '-')
{
char *rest = strchr (arg+2, '=');
if (rest)
*rest++ = '\0';
opt = option_table;
while (opt->o_long != NULL)
{
if (!strcmp (opt->o_long, arg+2))
{
argn++;
(void)process_option (opt, rest);
goto next_arg;
}
opt++;
}
printf ("long option '%s' not recognized.\n", arg+2);
}
else
{
opt = option_table;
while (opt->o_long != NULL)
{
if (opt->o_short == arg[1])
{
argn++;
if (process_option (opt, argv[argn]))
argn++;
goto next_arg;
}
opt++;
}
printf ("short option '%c' not recognized.\n", arg[1]);
}
argn++;
}
else
{
process_plain_argument (argv[argn++]);
}
}
}
int
main (int argc, char *argv[])
{
int off = 0;
int i, j, n;
int argn = 1;
unsigned int loops = 0;
exename = argv[0];
/* TODO - enable different options by default
based on the executable name. */
parse_args (argc, argv);
sym_init ();
switch (type)
{
case HEX:
if (prog_name && load_hex (prog_name))
usage ();
break;
case S19:
machine_init (machine_name, NULL);
if (prog_name && load_s19 (prog_name))
usage ();
break;
default:
machine_init (machine_name, prog_name);
break;
}
/* Try to load a map file */
if (prog_name)
load_map_file (prog_name);
/* Enable debugging if no executable given yet. */
if (!prog_name)
debug_enabled = 1;
else
/* OK, ready to run. Reset the CPU first. */
cpu_reset ();
monitor_init ();
command_init ();
keybuffering (0);
/* Now, iterate through the instructions.
* If no IRQs or FIRQs are enabled, we can just call cpu_execute()
* and let it run for a long time; otherwise, we need to come back
* here periodically and do the interrupt handling. */
for (cpu_quit = 1; cpu_quit != 0;)
{
if ((cycles_per_irq == 0) && (cycles_per_firq == 0))
{
total += cpu_execute (max_cycles ? max_cycles-1 : 500000);
}
else
{
total += cpu_execute (cycles_per_irq);
request_irq (0);
{
/* TODO - FIRQ frequency not handled yet */
static int firq_freq = 0;
if (++firq_freq == 8)
{
request_firq (0);
firq_freq = 0;
}
}
}
idle_loop ();
/* Check for a rogue program that won't end */
if ((max_cycles > 0) && (total > max_cycles))
{
sim_error ("maximum cycle count exceeded at %s\n",
monitor_addr_name (get_pc ()));
}
}
printf ("m6809-run stopped after %d cycles\n", total);
return 0;
}
|
bcd/exec09
|
6baa3a6e2d0be4a9149dcfd6f0097ca5b532a597
|
Improve symbol/mapfile loading. If symbols cannot be loaded, a warning message is printed. Also try various forms of the filename requested.
|
diff --git a/monitor.c b/monitor.c
index 2fd38a1..b06aa7e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -590,838 +590,854 @@ opcode_t codes10[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _indexed},
{_sts, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_lds, _extended},
{_sts, _extended}
};
opcode_t codes11[256] = {
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_swi3, _implied},
{_undoc, _illegal}, /* 11 40 */
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _imm_word},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _direct},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _indexed},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmpu, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_cmps, _extended},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal},
{_undoc, _illegal}
};
char *reg[] = {
"D", "X", "Y", "U", "S", "PC", "??", "??",
"A", "B", "CC", "DP", "??", "??", "??", "??"
};
char index_reg[] = { 'X', 'Y', 'U', 'S' };
char *off4[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
"-16", "-15", "-14", "-13", "-12", "-11", "-10", "-9",
"-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1"
};
/* Disassemble the current instruction. Returns the number of bytes that
compose it. */
int
dasm (char *buf, absolute_address_t opc)
{
UINT8 op, am;
char *op_str;
absolute_address_t pc = opc;
char R;
int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */
op = fetch8 ();
if (op == 0x10)
{
op = fetch8 ();
am = codes10[op].mode;
op = codes10[op].code;
}
else if (op == 0x11)
{
op = fetch8 ();
am = codes11[op].mode;
op = codes11[op].code;
}
else
{
am = codes[op].mode;
op = codes[op].code;
}
op_str = (char *) mne[op];
buf += sprintf (buf, "%-6.6s", op_str);
switch (am)
{
case _illegal:
sprintf (buf, "???");
break;
case _implied:
break;
case _imm_byte:
sprintf (buf, "#$%02X", fetch8 ());
break;
case _imm_word:
sprintf (buf, "#$%04X", fetch16 ());
break;
case _direct:
sprintf (buf, "<%s", monitor_addr_name (fetch8 ()));
break;
case _extended:
sprintf (buf, "%s", monitor_addr_name (fetch16 ()));
break;
case _indexed:
op = fetch8 ();
R = index_reg[(op >> 5) & 0x3];
if ((op & 0x80) == 0)
{
sprintf (buf, "%s,%c", off4[op & 0x1f], R);
break;
}
switch (op & 0x1f)
{
case 0x00:
sprintf (buf, ",%c+", R);
break;
case 0x01:
sprintf (buf, ",%c++", R);
break;
case 0x02:
sprintf (buf, ",-%c", R);
break;
case 0x03:
sprintf (buf, ",--%c", R);
break;
case 0x04:
sprintf (buf, ",%c", R);
break;
case 0x05:
sprintf (buf, "B,%c", R);
break;
case 0x06:
sprintf (buf, "A,%c", R);
break;
case 0x08:
sprintf (buf, "$%02X,%c", fetch8 (), R);
break;
case 0x09:
sprintf (buf, "$%04X,%c", fetch16 (), R);
break;
case 0x0B:
sprintf (buf, "D,%c", R);
break;
case 0x0C:
sprintf (buf, "$%02X,PC", fetch8 ());
break;
case 0x0D:
sprintf (buf, "$%04X,PC", fetch16 ());
break;
case 0x11:
sprintf (buf, "[,%c++]", R);
break;
case 0x13:
sprintf (buf, "[,--%c]", R);
break;
case 0x14:
sprintf (buf, "[,%c]", R);
break;
case 0x15:
sprintf (buf, "[B,%c]", R);
break;
case 0x16:
sprintf (buf, "[A,%c]", R);
break;
case 0x18:
sprintf (buf, "[$%02X,%c]", fetch8 (), R);
break;
case 0x19:
sprintf (buf, "[$%04X,%c]", fetch16 (), R);
break;
case 0x1B:
sprintf (buf, "[D,%c]", R);
break;
case 0x1C:
sprintf (buf, "[$%02X,PC]", fetch8 ());
break;
case 0x1D:
sprintf (buf, "[$%04X,PC]", fetch16 ());
break;
case 0x1F:
sprintf (buf, "[%s]", monitor_addr_name (fetch16 ()));
break;
default:
sprintf (buf, "???");
break;
}
break;
case _rel_byte:
fetch1 = ((INT8) fetch8 ());
sprintf (buf, "%s", absolute_addr_name (fetch1 + pc));
break;
case _rel_word:
sprintf (buf, "%s", absolute_addr_name (fetch16 () + pc));
break;
case _reg_post:
op = fetch8 ();
sprintf (buf, "%s,%s", reg[op >> 4], reg[op & 15]);
break;
case _usr_post:
case _sys_post:
op = fetch8 ();
if (op & 0x80)
strcat (buf, "PC,");
if (op & 0x40)
strcat (buf, am == _usr_post ? "S," : "U,");
if (op & 0x20)
strcat (buf, "Y,");
if (op & 0x10)
strcat (buf, "X,");
if (op & 0x08)
strcat (buf, "DP,");
if ((op & 0x06) == 0x06)
strcat (buf, "D,");
else
{
if (op & 0x04)
strcat (buf, "B,");
if (op & 0x02)
strcat (buf, "A,");
}
if (op & 0x01)
strcat (buf, "CC,");
buf[strlen (buf) - 1] = '\0';
break;
}
return pc - opc;
}
int
sizeof_file (FILE * file)
{
int size;
fseek (file, 0, SEEK_END);
size = ftell (file);
rewind (file);
return size;
}
int
load_map_file (const char *name)
{
FILE *fp;
char map_filename[256];
char buf[256];
char *value_ptr, *id_ptr;
target_addr_t value;
char *file_ptr;
+ /* Try appending the suffix 'map' to the name of the program. */
sprintf (map_filename, "%s.map", name);
-
fp = file_open (NULL, map_filename, "r");
if (!fp)
- return -1;
+ {
+ /* If that fails, try replacing any existing suffix. */
+ sprintf (map_filename, "%s", name);
+ char *s = strrchr (map_filename, '.');
+ if (s)
+ {
+ sprintf (s+1, "map");
+ fp = file_open (NULL, map_filename, "r");
+ }
+
+ if (!fp)
+ {
+ fprintf (stderr, "warning: no symbols for %s\n", name);
+ return -1;
+ }
+ }
+ printf ("Reading symbols from '%s'...\n", map_filename);
for (;;)
{
fgets (buf, sizeof(buf)-1, fp);
if (feof (fp))
break;
value_ptr = buf;
if (!strncmp (value_ptr, "page", 4))
{
unsigned char page = strtoul (value_ptr+4, NULL, 10);
wpc_set_rom_page (page);
continue;
}
if (strncmp (value_ptr, " ", 6))
continue;
while (*value_ptr == ' ')
value_ptr++;
value = strtoul (value_ptr, &id_ptr, 16);
if (id_ptr == value_ptr)
continue;
while (*id_ptr == ' ')
id_ptr++;
id_ptr = strtok (id_ptr, " \t\n");
if (((*id_ptr == 'l') || (*id_ptr == 's')) && (id_ptr[1] == '_'))
continue;
++id_ptr;
file_ptr = strtok (NULL, " \t\n");
sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */
}
fclose (fp);
return 0;
}
int
load_hex (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open hex record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3)
{
printf ("line %d: invalid hex record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff) + type;
switch (type)
{
case 0:
for (; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid hex record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 1:
checksum = (-checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid hex record checksum \n", line);
done = 0;
break;
case 2:
default:
printf ("line %d: not supported hex type %d.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
int
load_s19 (char *name)
{
FILE *fp;
int count, addr, type, data, checksum;
int done = 1;
int line = 0;
fp = file_open (NULL, name, "r");
if (fp == NULL)
{
printf ("failed to open S-record file %s.\n", name);
return 1;
}
while (done != 0)
{
line++;
if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) != 3)
{
printf ("line %d: invalid S record information.\n", line);
break;
}
checksum = count + (addr >> 8) + (addr & 0xff);
switch (type)
{
case 1:
for (count -= 3; count != 0; count--, addr++, checksum += data)
{
fscanf (fp, "%2x", &data);
write8 (addr, (UINT8) data);
}
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
{
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
}
(void) fgetc (fp); /* skip CR/LF/NULL */
break;
case 9:
checksum = (~checksum) & 0xff;
fscanf (fp, "%2x", &data);
if (data != checksum)
printf ("line %d: invalid S record checksum.\n", line);
done = 0;
break;
default:
printf ("line %d: S%d not supported.\n", line, type);
done = 0;
break;
}
}
fclose (fp);
return 0;
}
void
monitor_call (unsigned int flags)
{
#ifdef CALL_STACK
if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call++;
current_function_call->entry_point = get_pc ();
current_function_call->flags = flags;
}
#endif
#if 0
const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ()));
if (id)
{
// printf ("In %s now\n", id);
}
#endif
}
void
monitor_return (void)
{
#ifdef CALL_STACK
if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1])
{
current_function_call--;
return;
}
while ((current_function_call->flags & FC_TAIL_CALL) &&
(current_function_call > fctab))
{
current_function_call--;
}
if (current_function_call > fctab)
current_function_call--;
#endif
}
const char *
absolute_addr_name (absolute_address_t addr)
{
static char buf[256], *bufptr;
const char *name;
bufptr = buf;
bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%-16.16s>", name);
return buf;
}
const char *
monitor_addr_name (target_addr_t target_addr)
{
static char buf[256], *bufptr;
const char *name;
absolute_address_t addr = to_absolute (target_addr);
bufptr = buf;
bufptr += sprintf (bufptr, "0x%04X", target_addr);
name = sym_lookup (&program_symtab, addr);
if (name)
bufptr += sprintf (bufptr, " <%s>", name);
return buf;
}
static void
monitor_signal (int sigtype)
{
(void) sigtype;
putchar ('\n');
monitor_on = 1;
}
void
monitor_init (void)
{
int tmp;
extern int debug_enabled;
target_addr_t a;
fctab[0].entry_point = read16 (0xfffe);
memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs));
current_function_call = &fctab[0];
auto_break_insn_count = 0;
monitor_on = debug_enabled;
signal (SIGINT, monitor_signal);
}
int
check_break (void)
{
if (dump_every_insn)
print_current_insn ();
if (auto_break_insn_count > 0)
if (--auto_break_insn_count == 0)
return 1;
return 0;
}
void
monitor_backtrace (void)
{
struct function_call *fc = current_function_call;
while (fc >= &fctab[0]) {
printf ("%s\n", monitor_addr_name (fc->entry_point));
fc--;
}
}
int
monitor6809 (void)
{
int rc;
signal (SIGINT, monitor_signal);
rc = command_loop ();
monitor_on = 0;
return rc;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.