Răsfoiți Sursa

copy from cunix

rain 5 ani în urmă
comite
0262c90cca

+ 674 - 0
LICENSE

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 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.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 46 - 0
LINES

@@ -0,0 +1,46 @@
+2021-2-8 0.326: 326 lines, 2 files, rain
+
+2021-2-9 0.385: 385 lines, 3 files, rain
+
+2021-2-11 0.391: 391 lines, 3 files, rain
+
+2021-2-15 0.432: 432 lines, 4 files, rain
+
+2021-2-15 0.451: 451 lines, 4 files, rain
+
+2021-2-15 0.466: 466 lines, 5 files, rain
+
+2021-2-15 0.487: 487 lines, 5 files, rain
+
+2021-2-23 0.484: 484 lines, 5 files, rain
+
+2021-2-23 0.509: 509 lines, 6 files, rain
+
+2021-2-23 0.556: 556 lines, 6 files, rain
+
+2021-2-25 0.619: 619 lines, 6 files, rain
+
+2021-2-25 0.566: 566 lines, 6 files, rain
+
+2021-2-25 0.790: 790 lines, 10 files, rain
+
+2021-3-12 1.384: 1384 lines, 20 files, rain
+
+2021-3-13 1.440: 1440 lines, 21 files, rain
+
+2021-4-10 1.562: 1562 lines, 22 files, rain
+
+2021-5-2 1.217: 1217 lines, 17 files, rain
+
+2021-5-3 1.302: 1302 lines, 19 files, rain
+
+2021-5-9 1.690: 1690 lines, 22 files, rain
+
+2021-5-9 1.727: 1727 lines, 22 files, rain
+
+2021-5-9 1.760: 1760 lines, 22 files, rain
+
+2021-5-15 1.879: 1879 lines, 23 files, rain
+
+2021-5-16 2.086: 2086 lines, 25 files, rain
+

+ 21 - 0
Makefile

@@ -0,0 +1,21 @@
+all:
+	touch boot/x86/bootloader.bin
+	make -C boot/x86/
+	make -C kernel/
+	make delphin.img
+
+clear:
+	make -C kernel/ clear
+	make -C boot/x86/ clear
+	rm delphin.img bootable
+
+
+
+lines:
+	wc -l `find ./ -name *.c -o -name *.asm -o -name *.s -o -name *.inc -o -name *.h -o -name *.S`
+
+
+delphin.img: boot/x86/bootloader.bin kernel/kernel.bin
+	dd if=/dev/zero of=delphin.img bs=1024 count=1440
+	cat boot/x86/bootloader.bin kernel/kernel.bin > bootable
+	dd if=bootable of=delphin.img conv=notrunc

+ 90 - 0
README.md

@@ -0,0 +1,90 @@
+Cunix kernel
+============
+
+# Versions
+`0.362s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;`Boot` read `loader` from `boot-device`, then it jumps to it. <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;Loader doesn't load anything, it just enable long-mode and paging. <br/> 
+&nbsp;&nbsp;&nbsp;&nbsp;Loader defines temporary page table at `0x70000` (0x0000:0x7000), <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;it uses `2MB` page to make 0-12 MB memory to `0x0000 - 0xc0000`. <br/>
+
+
+`0.385s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;rebuild `boot` and `loader`. <br/>
+
+
+`0.391s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;`loader` forgot open A20 line, so `0.385` and `0.362` just can <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;use 1MB memory like real-mode. <br/>
+
+
+`0.432s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;make directory `include/`, and add segment.inc, but it doesn't work. :-)  <br/>
+
+
+`0.451s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;`boot` can load 8 sectors (4KB) of loader (not 1 sector).  <br/>
+
+
+`0.466s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;rebuild `boot` <br/>
+    
+
+`0.487s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;`loader` let FS can access 4GB memory in real-mode. because <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;`loader` loaded GDT and load a data-segment to fs, then disable <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;protect-mode. <br/>
+
+
+`0.484s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;let `readdisk.inc` smaller, but we just can use CHS or LBA, not both. <br/>
+
+
+`0.509s-kernel`:   
+&nbsp;&nbsp;&nbsp;&nbsp;load kernel to 0x8200-0x9200 for 4KB, kernel.asm display 'K' to screen. <br/>
+
+`0.556s-int`:  
+&nbsp;&nbsp;&nbsp;&nbsp;init IDT at 0x0000-0x1000, and set all handler at `ignore_int`, but it do nothing. <br/>
+
+`0.619s-boot`:  
+&nbsp;&nbsp;&nbsp;&nbsp;load 180KB of disk, not 4KB <br/>
+
+`0.566s-kernel`:  
+&nbsp;&nbsp;&nbsp;&nbsp;write in C. <br/>
+
+`0.790s-kernel`:  
+&nbsp;&nbsp;&nbsp;&nbsp;make some structs <br/>
+
+`1.384s-hal`:  
+&nbsp;&nbsp;&nbsp;&nbsp;use text VGA mode, and make a file-operations of it. <br/>
+
+`1.440s-lib`:  
+&nbsp;&nbsp;&nbsp;&nbsp;make some macros about assembly. <br/>
+
+
+`1.562s-init`:  
+&nbsp;&nbsp;&nbsp;&nbsp;new head.s, re-init GDT and IDT. <br/>
+
+`1.217s-init`:  
+&nbsp;&nbsp;&nbsp;&nbsp;nt for file-operations, and remove all modules. <br/>
+
+`1.302s-module`:  
+&nbsp;&nbsp;&nbsp;&nbsp;there is a bug with loader: it cannot load kernel because 0 - 8 = -8 (not 0). <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;so we read it byte by byte. and we used assembly to wrote a tty driver. It just can putchar now. <br/>
+
+`1.690s-module`:  
+&nbsp;&nbsp;&nbsp;&nbsp;new function printf, put format string on screen. <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;and, new panic.S to `kernel panic`. <br/>
+
+
+`1.727s-module`:  
+&nbsp;&nbsp;&nbsp;&nbsp;add support '\n' for printf. <br/>
+
+`1.760s-module`:  
+&nbsp;&nbsp;&nbsp;&nbsp;accept fault or interrupt in head.s <br/>
+
+`1.879s-memory`:  
+&nbsp;&nbsp;&nbsp;&nbsp;init page table in head.S, it can map 0-64MB memory (32 pages). <br/>
+
+`2.086s-module`:  
+&nbsp;&nbsp;&nbsp;&nbsp;support 'roll' screen, and create some functions (string.h). <br/>

+ 21 - 0
boot/x86/Makefile

@@ -0,0 +1,21 @@
+ASM_FLAGS = -I ../../include/ 
+
+remake: 
+	rm bootloader.bin
+	make first
+
+first: 
+	make bootloader.bin
+
+boot.bin: boot.asm
+	nasm boot.asm -o boot.bin $(ASM_FLAGS) -l boot.lst
+
+loader.bin: loader.asm
+	nasm loader.asm -o loader.bin $(ASM_FLAGS) -l loader.lst
+
+bootloader.bin: boot.bin loader.bin 
+	cat boot.bin loader.bin >> bootloader.bin
+
+clear:
+	rm *.bin *.lst
+

+ 228 - 0
boot/x86/boot.asm

@@ -0,0 +1,228 @@
+; Copyright (C) 2021 Rain
+
+; This file is part of Cunix. 
+; Cunix 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) and later version. 
+
+; Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+
+
+
+
+CYLINDERS_NEED equ 10
+
+org 0x7c00
+align 8
+
+_start:
+	xor ax, ax
+
+	mov ds, ax
+	mov es, ax
+
+	mov ss, ax
+	mov sp, 0x7c00
+
+	; display message: `Cunix is booting...`
+
+
+	; boot device driver number is in DL (by BIOS-19)
+	mov [BI_BOOTDEV], dl
+
+	call get_e820
+	call read_it
+	call set_vbe_mode
+
+	jmp 0x0000:0x8000
+
+
+diskpanic_message: db "read disk failed", 0x0d, 0x0a, 0x00
+e820panic_message: db "get E820 info failed", 0x0d, 0x0a, 0x00
+panic_message: db "boot panic: ", 0x00
+
+%include "arch/x86/readdisk.inc"
+
+print:
+	; SI: message address
+	mov al, [si]
+	add si, 1
+
+	cmp al, 0x00
+	je .ret
+
+	mov ah, 0x0e
+	mov bx, 0x0f
+	int 0x10
+
+	jmp print
+
+.ret:
+	ret
+
+
+get_e820:
+	xor ebx, ebx
+	xor ax, ax
+	mov es, ax
+
+	; address of E820 buffer
+	mov di, 0x6000
+	
+.get_loop:
+	mov eax, 0x0000e820
+	mov ecx, 20
+	mov edx, 0x534d4150
+	int 0x15
+	jc .get_failed
+
+	add di, 20
+	cmp ebx, 0
+	jne .get_loop
+
+	ret
+
+.get_failed:
+	mov di, e820panic_message
+	call panic
+
+
+read_it:
+	; segment address of loader+kernel
+	mov ax, 0x0800
+	mov es, ax
+
+	; cylinder 0
+	mov ch, 0
+	; header 0
+	mov dh, 0
+	; start sector 2
+	mov cl, 2
+
+.read_loop:
+	; I know it use to save source-address, but there isn't another 
+	; register free. 
+
+	; error counts
+	mov si, 0
+
+.retry:
+	mov ah, 0x02
+	; one sector
+	mov al, 1
+
+	; offset 0x0000
+	mov bx, 0
+
+	; boot device
+	mov dl, [BI_BOOTDEV]
+
+	; call -> BIOS
+	int 0x13
+
+	; if not error
+	jnc .cont_read
+	
+	; okay, something wrong. best way is reset it. 
+.error:
+	add si, 1
+	; we try it for 5 times
+	mov di, diskpanic_message
+
+	cmp si, 5
+	jae panic
+
+.reset_disk:
+	mov ah, 0x00
+	mov dl, [BI_BOOTDEV]
+
+	int 0x13
+
+	; and retry
+
+	jmp .retry
+
+.cont_read:
+	; add for 0x0020 (not 0x0200)
+	mov ax, es
+	add ax, 0x0020
+	mov es, ax
+
+	; we've been read one sector
+	add cl, 1
+
+	; if read done
+
+SECTORS_1_TRACK equ 18
+
+	cmp cl, SECTORS_1_TRACK
+	jbe .read_loop
+
+.update_track:
+	mov cl, 1
+	add dh, 1
+HEADS_1_CYLINDER equ 2
+	cmp dh, HEADS_1_CYLINDER
+	
+	jb .read_loop
+
+.update_head:
+	mov dh, 0
+	add ch, 1
+	cmp ch, CYLINDERS_NEED
+	jb .read_loop
+
+	ret
+
+
+set_vbe_mode:
+	mov bx, 0x10c
+
+.set_repeat:
+	mov ax, 0x4f02
+	; we can use mode 0x108-0x10c, and save it
+	push bx
+	int 0x10
+
+	; failed? 
+	cmp ax, 0x4f
+	je .ret
+
+.set_retry:
+	pop bx
+
+	; bx--
+	dec bx
+	cmp bx, 0x107
+	ja .set_repeat
+
+	; set failed, use default
+	ret
+	
+.ret:
+	pop bx
+	ret
+
+
+panic:
+	mov si, panic_message
+	call print
+
+	mov si, di
+	call print
+
+die:	hlt
+	jmp die
+
+
+
+times 510 - ($ - $$) db 0x00
+db 0x55, 0xaa
+

+ 192 - 0
boot/x86/loader.asm

@@ -0,0 +1,192 @@
+; Copyright (C) 2021 Rain
+
+; This file is part of Cunix. 
+
+; Cunix is free software: you can redistribute it and/or modify 
+; it under the terms of the GNU General Public Licene and published by 
+; the Free Software Foundation, either version 3 of the License, or 
+; (at your option) any later version. 
+
+; Cunix 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 recceived a copy of the GNU General Public License 
+; along with Cunix. If not, see <https://www.gnu.org/licenses/>. 
+
+
+
+
+org 0x8000
+align 8
+
+jmp _start
+
+CYLINDERS_READ equ 10
+SECTORS_READ equ CYLINDERS_READ * 2 * 18
+SIZE_READ equ SECTORS_READ * 512
+
+%include "arch/x86/segment.inc"
+%include "arch/x86/paging.inc"
+
+bits 16
+
+_start:	
+	; enable A20 address 20 line
+.open_a20:
+	in al, 0x92
+	or al, 0x02
+	out 0x92, al
+
+.to_protect_mode:
+	cli
+	lgdt [gdt32_descriptor]
+
+
+	mov eax, cr0
+	; set CR0.bit 1 (Protect-mode Enable)
+	or eax, 1
+	mov cr0, eax
+
+	jmp dword code32:init_protect_mode
+
+
+bits 32
+
+init_protect_mode:
+	mov ax, 0x10
+	mov ds, ax
+	mov es, ax
+	mov fs, ax
+	mov gs, ax
+
+	mov ss, ax
+	mov esp, 0x00007c00
+
+.copy_kernel:
+	mov esi, 0x8200
+	mov edi, 0x100000
+	mov ecx, SIZE_READ
+
+	call memcpy
+
+.to_long_mode:
+	; page map at 0x7000
+	; set pagemap level-4
+	mov dword [0x70000], 0x71000 | PAGE_USER
+	mov dword [0x70004], 0x00000
+	mov dword [0x70800], 0x70000 | PAGE_USER
+	mov dword [0x70804], 0x00000
+
+	; ...and, page directory pointer table
+	mov dword [0x71000], 0x72000 | PAGE_USER
+	mov dword [0x71008], 0x00000
+
+	; then, page directory entry (2 MB size)
+	mov dword [0x72000], 0x000000 | PAGE_KERNEL
+	mov dword [0x72004], 0x000000
+
+	mov dword [0x72008], 0x200000 | PAGE_KERNEL
+	mov dword [0x7200c], 0x000000
+
+	mov dword [0x72010], 0x400000 | PAGE_KERNEL
+	mov dword [0x72014], 0x000000
+
+
+	lgdt [gdt64_descriptor]
+
+	mov ax, 0x10
+	mov ds, ax
+	mov es, ax
+	mov fs, ax
+	mov gs, ax
+
+	mov ss, ax
+	mov esp, 0x00007c00
+
+	mov eax, cr4
+	bts eax, 5
+	mov cr4, eax
+
+	; page table
+	mov eax, 0x70000
+	mov cr3, eax
+
+	; enable long-mode before paging
+	mov ecx, 0xc0000080
+	rdmsr
+
+	bts eax, 8
+	wrmsr
+
+	mov eax, cr0
+	or eax, 1
+	bts eax, 31
+	mov cr0, eax
+
+	mov ax, 0x10
+	mov ds, ax
+	mov es, ax
+	mov fs, ax
+	mov gs, ax
+	mov ss, ax
+	
+	jmp code64:0x100000
+
+
+memcpy:
+	; if no this, loop will --ecx and ecx will be 0xffffffff. 
+	cmp ecx, 0
+	jne .copy
+
+	ret
+
+.copy:
+	lodsb
+	stosb
+
+	loop .copy
+
+	ret
+
+gdt32:
+	dd 0x00000000, 0x00000000
+
+gdt32_code:
+	dd 0x0000ffff, 0x00cf9a00
+
+gdt32_data:
+	dd 0x0000ffff, 0x00cf9200
+
+gdt32_len equ $ - gdt32
+
+gdt32_descriptor:
+	dw gdt32_len - 1
+	dd gdt32
+
+code32 equ gdt32_code - gdt32
+data32 equ gdt32_data - gdt32
+
+
+gdt64:
+	dq 0x0000000000000000
+
+gdt64_code:
+	dq 0x0020980000000000
+
+gdt64_data:
+	dq 0x0000920000000000
+
+gdt64_len equ $ - gdt64
+
+gdt64_descriptor:
+	dw gdt64_len - 1
+	dd gdt64
+
+code64 equ gdt64_code - gdt64
+data64 equ gdt64_data - gdt64
+
+
+times 512 - ($ - $$) db 0x00
+

+ 64 - 0
include/arch/io.h

@@ -0,0 +1,64 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+#ifndef INCLUDED_IO_H
+#define INCLUDED_IO_H
+
+#include <kernel/types.h>
+
+
+typedef __uint16_t port_t;
+
+
+#define inb(port) ({ \
+	__uint8_t _r; \
+	__asm__ volatile ("inb %%dx, %%al" : "=a" (_r) : "d" (port)); \
+	_r; \
+})
+
+#define inw(port) ({ \
+	__uint16_t _r; \
+	__asm__ volatile ("inw %%dx, %%ax" : "=a" (_r) : "d" (port)); \
+	_r; \
+})
+
+#define inl(port) ({ \
+	__uint32_t _r; \
+	__asm__ volatile ("inl %%dx, %%eax" : "=a" (_r) : "d" (port)); \
+	_r; \
+})
+
+
+#define outb(value, port) \
+	__asm__ volatile ("outb %%al, %%dx" :: "a" (value), "d" (port));
+
+#define outw(value, port) \
+	__asm__ volatile ("outw %%ax, %%dx" :: "a" (value), "d" (port));
+
+#define outl(value, port) \
+	__asm__ volatile ("outl %%eax, %%dx" :: "a" (value), "d" (port));
+
+
+#endif

+ 71 - 0
include/arch/sys.h

@@ -0,0 +1,71 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+#ifndef INCLUDED_SYS_H
+#define INCLUDED_SYS_H
+
+#include <kernel/types.h>
+
+
+#define sgdt(addr) __asm__ __volatile__ ("sgdt %0" : "=m" (addr) : :)
+#define lgdt(addr) __asm__ __volatile__ ("lgdt %0" : : "m" (addr))
+
+#define sidt(addr) __asm__ __volatile__ ("sidt %0" : "=m" (addr) : :)
+#define lidt(addr) __asm__ __volatile__ ("lidt %0" : : "m" (addr))
+
+
+#define pause() __asm__ __volatile__ ("pause");
+#define nop() __asm__ __volatile__ ("nop");
+#define hlt() __asm__ __volatile__ ("hlt");
+
+
+#define getreg(regname) ({ \
+	__uint64_t res; \
+	__asm__ __volatile__ ("movq %%" regname ", %0" : "=r" (res)); \
+	res; \
+})
+
+#define get_rax() getreg("rax")
+#define get_rcx() getreg("rcx")
+#define get_rdx() getreg("rdx")
+#define get_rbx() getreg("rbx")
+
+#define get_rsp() getreg("rsp")
+#define get_rbp() getreg("rbp")
+#define get_rsi() getreg("rsi")
+#define get_rdi() getreg("rdi")
+
+#define get_r8()  getreg("r8")
+#define get_r9()  getreg("r9")
+#define get_r10() getreg("r10")
+#define get_r11() getreg("r11")
+
+#define get_r12() getreg("r12")
+#define get_r13() getreg("r13")
+#define get_r14() getreg("r14")
+#define get_r15() getreg("r15")
+
+
+#endif

+ 62 - 0
include/arch/x86/paging.h

@@ -0,0 +1,62 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+#ifndef INCLUDED_PAGING_H
+#define INCLUDED_PAING_H
+
+
+#define PAGE_PRESENT  0x0001
+
+#define PAGE_RDWR     0x0002
+
+#define PAGE_USER     0x0004
+
+#define PAGE_NWRBACK  0x0008
+
+#define PAGE_NOCACHE  0x0010
+
+#define PAGE_ACCESSED 0x0020
+
+#define PAGE_DIRTY    0x0040
+
+#define PAGE_PAT      0x0080
+
+#define PAGE_GLOBAL   0x0100
+
+
+/* 0x83 */
+#define PATT_KERNEL (PAGE_PRESENT | PAGE_RDWR | PAGE_PAT)
+
+/* 0x07 */
+#define PATT_USER   (PAGE_PRESENT | PAGE_RDWR | PAGE_USER)
+
+
+#define PML4_ADDR 0x70000
+#define PDPT_ADDR 0x71000
+#define PTE_ADDR  0x72000
+
+#define PAGE_SIZE 0x200000
+
+#endif

+ 55 - 0
include/arch/x86/paging.inc

@@ -0,0 +1,55 @@
+; Copyright (C) 2021 Rain
+
+; This file is part of Cunix. 
+
+; Cunix is free software: you can redistribute it and/or modify 
+; it under the terms of the GNU General Public Licene and published by 
+; the Free Software Foundation, either version 3 of the License, or 
+; (at your option) any later version. 
+
+; Cunix 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 recceived a copy of the GNU General Public License 
+; along with Cunix. If not, see <https://www.gnu.org/licenses/>. 
+
+
+
+
+; this page is already in memory (it's not swapped)
+PATT_PRESENT 	equ 0x00000001
+
+; read + write
+PATT_RDWR	equ 0x00000002
+
+; user mode or kernel mode
+PATT_USER	equ 0x00000004
+
+; write cache + memory or cache only
+PATT_CACHEMEM	equ 0x00000008
+
+; this page cannot cache
+PATT_NCACHE	equ 0x00000010
+
+; this page has been accessed
+PATT_ACCESSED	equ 0x00000020
+
+; this page is dirty
+PATT_DIRTY 	equ 0x00000040
+
+; this page is in PAT
+PATT_PAT	equ 0x00000080
+
+; this is a global page
+PATT_GLOBAL	equ 0x00000100
+
+
+; 0x83
+PAGE_KERNEL equ PATT_PRESENT | PATT_RDWR | PATT_PAT
+
+; 0x07
+PAGE_USER equ PATT_RDWR | PATT_USER | PATT_PRESENT
+
+

+ 59 - 0
include/arch/x86/readdisk.inc

@@ -0,0 +1,59 @@
+; Copyright (C) 2021 Rain
+
+; This file is part of Cunix. 
+
+; Cunix is free software: you can redistribute it and/or modify 
+; it under the terms of the GNU General Public Licene and published by 
+; the Free Software Foundation, either version 3 of the License, or 
+; (at your option) any later version. 
+
+; Cunix 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 recceived a copy of the GNU General Public License 
+; along with Cunix. If not, see <https://www.gnu.org/licenses/>. 
+
+
+
+
+%define DISK_CHS
+
+BI_BOOTDEV equ 0x7e00
+
+read_sector:
+
+%ifdef DISK_CHS
+read_sector_chs:
+	mov ax, 0x0201
+	xor ch, ch
+
+	xor dh, dh
+
+	mov dl, [BI_BOOTDEV]
+	
+	int 0x13
+	ret
+
+%else
+
+read_sector_lba:
+	push dword 0x00000000
+	push dword ecx
+	push word es
+	push word bx
+
+	push word 0x0001
+	push word 0x0010
+	
+	mov ah, 0x42
+	mov dl, [BI_BOOTDEV]
+
+	int 0x13
+	add sp, 0x10
+
+	ret
+
+%endif
+

+ 40 - 0
include/arch/x86/segment.inc

@@ -0,0 +1,40 @@
+; Copyright (C) 2021 Rain
+
+; This file is part of Cunix. 
+
+; Cunix is free software: you can redistribute it and/or modify 
+; it under the terms of the GNU General Public Licene and published by 
+; the Free Software Foundation, either version 3 of the License, or 
+; (at your option) any later version. 
+
+; Cunix 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 recceived a copy of the GNU General Public License 
+; along with Cunix. If not, see <https://www.gnu.org/licenses/>. 
+
+
+
+
+; 32 bit segment descriptor: 
+; BASE | G  | 32/16 | 64 | LIMIT | PRESENT | PERMISSION | SYSSEG | TYPE | BASE | LIMIT
+; 63   | 55 | 54    | 53 | 51	 | 47	   | 46		| 44     | 43	| 39   | 15
+
+
+; type-bit 0: accessed
+; type-bit 1: readable / writable
+; type-bit 2: conforming / expansion-direction
+; type-bit 3: 1 / 0
+
+; permision: DPL 0-2
+
+; G: 
+; if G = 1: 
+; 	limit = limit * 4KB
+
+; else:
+;	limit = limit  * 1B
+
+

+ 78 - 0
include/kernel/errno.h

@@ -0,0 +1,78 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_ERRNO_H
+#define INCLUDED_ERRNO_H
+
+typedef __uint32_t errno_t;
+
+
+/* error in kernel */
+#define E_KERROR 0x20000000
+
+/* error io port */
+#define E_IOERROR 0x00000001 | E_KERROR
+
+/* no enough memory for this call */
+#define E_NOMEM	  0x00000002 | E_KERROR
+
+/* call interrupted by signal */
+#define E_SIGNAL  0x00000003 | E_KERROR
+
+/* kernel not supported */
+#define E_NOSUPP  0x00000004 | E_KERROR
+
+
+/* no permision */
+#define E_DENIED 0x40000000
+
+/* need root to call this */
+#define E_NDROOT 0x00000001 | E_DENIED
+
+/* no io passport */
+#define E_IODND  0x00000002 | E_DENIED
+
+/* need hardware super 0 */
+#define E_HARDSP 0x00000003 | E_DENIED
+
+/* hardware no support */
+#define E_HNOSUP 0x00000004 | E_DENIED
+
+/* user error (caller) */
+#define E_UERROR 0x80000000
+
+
+/* syntax error for this call (invalid argument) */
+#define E_SYNERR 0x00000001 | E_UERROR
+
+/* error because address is invalid */
+#define E_ADDRE  0x00000002 | E_UERROR
+
+/* call out of range */
+#define E_OUTRAG 0x00000003 | E_UERROR
+
+#endif
+

+ 95 - 0
include/kernel/init.h

@@ -0,0 +1,95 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_INIT_H
+#define INCLUDED_INIT_H
+
+
+#include <kernel/types.h>
+#include <kernel/errno.h>
+
+
+
+#define KERNEL_CS 0x0008
+#define KERNEL_DS 0x0010
+
+
+struct inode_desc {
+	/* this struct is a general descriptor, so we must know
+	 * how big is it. */
+
+	__uint32_t size;
+
+	/* file descriptor */
+	__uint32_t fd;
+
+	/* this is optional (offset) */
+	__uint32_t off;
+
+	/* this is optional too */
+	char *name;
+
+	/* real inode saves here */
+	void *real_inode;
+};
+
+
+struct file_operations {
+	/* open a file */
+	struct inode_desc * (* open) (char *, __uint32_t, __uint32_t, errno_t *);
+
+	/* or create one */
+
+	/* `creat` doesn't return file-descriptor, it returns errno */
+	errno_t (* creat) (char *, __uint32_t, __uint32_t);
+
+	/* `fill` fills a inode descriptor */
+	errno_t (* fill) (char *, __uint32_t, __uint32_t, struct inode_desc *);
+
+
+	/* read from file-descriptor */
+	errno_t (* read) (struct inode_desc *, char *, __uint64_t);
+	
+	/* write to file-descriptor */
+	errno_t (* write) (struct inode_desc *, char *, __uint64_t);
+
+	/* change position */
+
+	/* 'seg' = whence */
+
+#define SEEK_SET 0x0001
+#define SEEK_CUR 0x0002
+#define SEEK_END 0x0003
+
+	__uint32_t (* lseek) (struct inode_desc *, __uint32_t, __uint32_t);
+
+	/* close a file-descriptor */
+	void (* close) (struct inode_desc *);
+};
+
+
+#endif
+

+ 88 - 0
include/kernel/mm.h

@@ -0,0 +1,88 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_MM_H
+#define INCLUDED_MM_H
+
+
+#include <kernel/types.h>
+#include <kernel/errno.h>
+
+#include <lib/bitman.h>
+
+
+/* we should use &_end, not _end because they're empty symbols. */
+/* define in kernel.lds */
+
+extern __uint64_t _text, _etext; 
+extern __uint64_t _data, _edata;
+extern __uint64_t _rodata, _erodata;
+extern __uint64_t _bss, _ebss;
+extern __uint64_t _end;
+
+
+struct e820_entry {
+	__uint64_t addr;
+	__uint64_t len;
+	__uint32_t type;
+} __attribute__ ((packed));
+
+
+/* |  1MB  |        | total pages / 8  |             | */
+/* | E820  | KERNEL |   PAGE BITMAP    | HIGH MEMORY | */
+
+struct mm {
+	__uint64_t total_ram;
+	__uint64_t total_pages;
+
+	__uint64_t usable_pages;
+
+	struct e820_entry *e820;
+
+	__uint64_t e820_entries;
+
+	struct bitmap_manager pages_bitman;
+};
+
+extern struct mm mman;
+
+#define E820_ADDR ((struct e820_entry *) 0x0000000000006000)
+
+errno_t mem_init(void);
+void *palloc(void);
+void pfree(void *addr);
+
+
+#define PAGE_2M_SIZE 0x200000UL
+#define PAGE_2M_SHIFT 21UL
+#define PAGE_2M_MASK (~(PAGE_2M_SIZE - 1))
+
+#define PAGE_4K_SIZE 0x1000UL
+#define PAGE_4K_SHIFT 12UL
+#define PAGE_4K_MASK (~(PAGE_4K_SIZE - 1))
+
+#endif
+

+ 35 - 0
include/kernel/panic.h

@@ -0,0 +1,35 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_PANIC_H
+#define INCLUDED_PANIC_H
+
+
+/* kernel/asm/panic.S */
+void panic(char *s);
+
+#endif
+

+ 52 - 0
include/kernel/types.h

@@ -0,0 +1,52 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_TYPES_H
+#define INCLUDED_TYPES_H
+
+#define NULL (void *) 0
+
+
+typedef char 		__schar_t;
+typedef unsigned char 	__uchar_t;
+
+typedef short		__sshort_t;
+typedef unsigned short 	__ushort_t;
+
+typedef int 		__sint_t;
+typedef unsigned int	__uint_t;
+
+typedef long		__slong_t;
+typedef unsigned long	__ulong_t;
+
+typedef __uchar_t 	__uint8_t;
+typedef __ushort_t 	__uint16_t;
+typedef __uint_t 	__uint32_t;
+typedef __ulong_t 	__uint64_t;
+
+
+#endif
+

+ 39 - 0
include/lib/bitman.h

@@ -0,0 +1,39 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_BITMAN_H
+#define INCLUDED_BITMAN_H
+
+struct bitmap_manager {
+	unsigned char *bitmap;
+	unsigned int next_free;
+};
+
+unsigned int bitman_alloc(struct bitmap_manager *bm);
+void bitman_free(struct bitmap_manager *bm, unsigned int pos);
+
+#endif
+

+ 34 - 0
include/lib/bitmap.h

@@ -0,0 +1,34 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_BITMAP_H
+#define INCLUDED_BITMAP_H
+
+extern char *bitmap_init(unsigned int size);
+extern void bitmap_set(unsigned char *bitmap, unsigned int pos, unsigned char value);
+extern char bitmap_read(unsigned char *bitmap, unsigned int pos);
+
+#endif

+ 33 - 0
include/lib/rlib.h

@@ -0,0 +1,33 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_RLIB_H
+#define INCLUDED_RLIB_H
+
+#include <lib/bitmap.h>
+#include <lib/bitman.h>
+
+#endif

+ 50 - 0
include/lib/string.h

@@ -0,0 +1,50 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_STRING_H
+#define INCLUDED_STRING_H
+
+
+
+/* copy src to dest for n bytes */
+void *memcpy(void *dest, void *src, __uint64_t n);
+
+/* set n to src for n bytes */
+void *memset(void *dest, char c, __uint64_t n);
+
+/* set n to src for n words (n must be power of 2) */
+void *memsetw(void *dest, __uint16_t c, __uint64_t n);
+
+/* set n to src for n dwords (n must be power of 4) */
+void *memsetl(void *dest, __uint32_t c, __uint64_t n);
+
+/* set n to src for n quads (n must be power of 8) */
+void *memsetq(void *dest, __uint64_t c, __uint64_t n);
+
+
+
+#endif
+

+ 74 - 0
include/modules/tty.h

@@ -0,0 +1,74 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#ifndef INCLUDED_TTY_H
+#define INCLUDED_TTY_H
+
+/* index register of cursor */
+#define CURSOR_INDEX 0x03d4
+
+/* data register of cursor */
+#define CURSOR_DATA  0x03d5
+
+/* write to CURSOR_INDEX */
+#define CURSORCTL_POSHI 0x0e
+#define CURSORCTL_POSLO 0x0f
+
+#define TEXT_VGA_X 80
+#define TEXT_VGA_Y 25
+
+#ifndef ASSEMBLY
+
+#include <stdarg.h>
+
+/* kernel/asm/tty.c */
+
+void tty_init(void);
+
+void putc(char c);
+
+/* kernel/modules/tty.c */
+
+/* return value: length of string printed */
+
+/* we use number formats (1B per format), not % */
+__uint64_t printf(const char *fmt, ...);
+
+__uint64_t printint(long, int, int);
+
+__uint16_t read_cursor(void);
+
+__uint64_t printptr(__uint64_t);
+
+void write_cursor(__uint16_t pos);
+
+void clear_line(int line);
+
+
+#endif
+
+
+#endif

+ 25 - 0
kernel/Makefile

@@ -0,0 +1,25 @@
+OBJS = init/head.o init/main.o lib/bitmap.o lib/bitman.o asm/tty.o modules/tty.o asm/panic.o init/panic.o mm/page.o lib/string.o
+
+default:
+	make -C init/
+	make -C lib/
+	make -C asm/
+	make -C mm/
+	make -C modules/
+	make kernel.bin
+
+kernel.o: $(OBJS)
+	ld -b elf64-x86-64 -o kernel.o $(OBJS) -T kernel.lds
+	
+kernel.bin: kernel.o
+	objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary kernel.o kernel.bin
+
+
+clear:
+	make -C init/ clear
+	make -C lib/ clear
+	make -C asm/ clear
+	make -C mm/ clear
+	make -C modules/ clear
+	rm kernel.o kernel.bin
+

+ 9 - 0
kernel/asm/Makefile

@@ -0,0 +1,9 @@
+all: tty.o panic.o
+
+%.o: %.S
+	gcc -E $*.S -I ../../include > $*.s
+	as --64 $*.s -o $*.o 
+
+clear:
+	rm *.o *.s
+

+ 45 - 0
kernel/asm/panic.S

@@ -0,0 +1,45 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+.text
+.align 8
+
+
+.globl __stack_chk_fail
+
+__stack_chk_fail:
+	/* display on screen: kernel panic: stack check failed. */
+	leaq stackfail_msg(%rip), %rdi
+	call panic
+
+	/* it never go here */
+
+
+.data
+.align 8
+
+stackfail_msg: .asciz "stack check failed"
+

+ 83 - 0
kernel/asm/tty.S

@@ -0,0 +1,83 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#define ASSEMBLY
+#include <modules/tty.h>
+
+
+
+.text
+.align 8
+
+
+
+.globl tty_init
+
+tty_init:
+	pushq %rsi
+	pushq %rdi
+
+	/* set cursor position */
+	movw $0x0000, %di
+	call write_cursor
+
+	popq %rdi
+	popq %rsi
+
+	ret
+	
+
+.globl putc
+
+putc:
+	pushq %rdi
+
+	/* character is in EDI */
+	movl %edi, %eax
+
+	/* rdi = *framebuffer */
+	movq framebuffer(%rip), %rdi
+	movb $0x0f, %ah
+
+	cld
+	stosw
+
+	movq %rdi, framebuffer(%rip)
+	
+	/* return 0 */
+	xorq %rax, %rax
+
+	popq %rdi
+	ret
+
+
+.data
+.align 8
+
+.globl framebuffer
+framebuffer: .quad 0x00000000000b8000
+
+

+ 15 - 0
kernel/init/Makefile

@@ -0,0 +1,15 @@
+C_FLAGS = -mcmodel=large -fno-builtin -m64 -I ../../include/ -Wall -Werror -O3
+
+all: main.o panic.o head.o
+
+%.o: %.c
+	gcc -c $*.c $(C_FLAGS)
+
+head.o: head.S
+	gcc -E head.S -I ../../include/ > head.s
+	as --64 head.s -o head.o 
+
+
+clear:
+	rm *.o head.s
+

+ 219 - 0
kernel/init/head.S

@@ -0,0 +1,219 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <arch/x86/paging.h>
+
+
+.align 8
+.text
+
+.globl _start
+
+/* 
+ * We can't use any symbol addresses before we setup PML4-entry. 
+ * Because linker use 0xffff8000 to fill all addresses (see kernel/kernel.lds). 
+ * So, we must setup PML4E first. 
+ */
+_start:
+	movq $PML4_ADDR, %rax
+	movq $PDPT_ADDR | PATT_USER, 2048(%rax)
+	movq %rax, %cr3
+
+	/* ok, now we can use addresses because we had been set PML4E */
+
+	lgdt gdt_desc(%rip)
+	lidt idt_desc(%rip)
+
+	/* first, setup segment descriptor */
+	leaq switch_segment(%rip), %rax
+
+	pushq $0x08
+	pushq %rax
+	lretq
+
+
+
+switch_segment:
+	/* segment registers are 16-bits, but use `rax` is faster than `ax` */
+	movq $0x10, %rax
+	movq %rax, %ds
+	movq %rax, %es
+	movq %rax, %fs
+	movq %rax, %gs
+
+	movq %rax, %ss
+	movq $0x0000000000007c00, %rsp
+
+	callq setup_idt
+
+	/* enable interrupt in init() */
+
+	leaq init(%rip), %rax
+	pushq $0x08
+	pushq %rax
+
+	lretq
+
+
+
+/* setup paging */
+setup_paging:
+	/* set attributes for 0 - 64MB pages */
+
+	/* start address 0 */
+	xorq %rax, %rax
+
+	/* page address (first set in boot/x86/loader.asm) */
+	movq $PTE_ADDR, %rdi
+
+	/* count of entries will set */
+	movq $64 * 1048576 / PAGE_SIZE, %rcx
+
+	cld
+
+rep_spage:
+	orq $PATT_KERNEL, %rax
+
+	/* repeat while rcx > 0, then rcx-- */
+	stosq
+	addq $PAGE_SIZE, %rax
+
+	loop rep_spage
+
+	ret
+
+	
+	
+
+
+/* setup IDT entries */
+
+setup_idt:
+	/* offset address of interrupt handler */
+	leaq default_int(%rip), %rdx
+
+	/* RAX is low 64 bit of IDT-entry */
+	/* selector: 0x08 */
+	movq $(0x08 << 16), %rax
+	movw %dx, %ax
+	/* 8E means present, DPL = 0, TYPE = E, and IST = 0 */
+	movq $(0x8e00 << 32), %rcx
+	addq %rcx, %rax
+
+	/* offset low 32 bit to RCX */
+	movl %edx, %ecx
+	/* only high 16 bits */
+	shrl $16, %ecx
+	shlq $48, %rcx
+
+	addq %rcx, %rax
+
+	/* only high 32 bits */
+	shrq $32, %rdx
+
+	leaq idt_table(%rip), %rdi
+	/* entries in IDT */
+	movq $256, %rcx
+
+rep_sidt:
+	movq %rax, (%rdi)
+	movq %rdx, 8(%rdi)
+	addq $0x10, %rdi
+	dec %rcx
+	jnz rep_sidt
+
+	retq
+
+
+
+default_int:
+	leaq int_msg(%rip), %rdi
+	call printf
+
+default_int_die:
+	hlt
+	jmp default_int_die
+
+	iretq
+
+
+
+.section .rodata
+.align 8
+
+int_msg: .asciz "unknow interrupt or fault"
+
+.data
+
+.globl gdt_table
+
+gdt_table:
+	/* first entry must be a null descriptor */
+	.quad 0x0000000000000000
+
+	/* kernel code 64-bits */
+	.quad 0x0020980000000000
+
+	/* kernel data 64-bits */
+	.quad 0x0000920000000000
+
+	/* user code 64-bits */
+	.quad 0x0020f80000000000
+
+	/* user data 64-bits */
+	.quad 0x0000f20000000000
+
+	/* kernel code 32-bits */
+	.quad 0x00cf9a000000ffff
+
+	/* kernel data 32-bits */
+	.quad 0x00cf92000000ffff
+
+	.fill 10, 8, 0
+
+end_gdt:
+
+gdt_desc:
+	.word end_gdt - gdt_table
+	.quad gdt_table
+
+.globl idt_table
+
+idt_table:
+	/* this will takes a warning */
+	/* .fill 256, 16, 0 */
+
+	.fill 512, 8, 0
+
+
+end_idt:
+
+idt_desc:
+	.word end_idt - idt_table
+	.quad idt_table
+
+
+

+ 57 - 0
kernel/init/main.c

@@ -0,0 +1,57 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <kernel/init.h>
+#include <kernel/types.h>
+#include <kernel/errno.h>
+
+#include <kernel/panic.h>
+#include <kernel/mm.h>
+
+#include <modules/tty.h>
+
+
+void init(void) {
+	tty_init();
+	mem_init();
+
+	printf("Cunix kernel %d is starting...\n", 1879);
+
+	void *a, *b;
+
+	a = palloc();
+	b = palloc();
+
+	printf("alloc one page: 0x%p\n", &a);
+	printf("alloc another page: 0x%p\n", &b);
+
+	pfree(a);
+	a = palloc();
+
+	printf("free first page and alloc one page: 0x%p\n", &a);
+
+	for (;;);
+}

+ 66 - 0
kernel/init/panic.c

@@ -0,0 +1,66 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <kernel/init.h>
+#include <kernel/types.h>
+#include <kernel/errno.h>
+
+#include <arch/sys.h>
+#include <modules/tty.h>
+
+
+
+void panic(char *s) {
+	__uint64_t a, b, c;
+
+	a = get_rax(); b = get_rcx(); c = get_rdx();
+
+	printf("RAX: %p  RCX: %p  RDX: %p\n", a, b, c);
+
+	a = get_rbx(); b = get_rsp(); c = get_rbp();
+
+	printf("RBX: %p  RSP: %p  RBP: %p\n", a, b, c);
+
+	a = get_rsi(); b = get_rdi(); c = get_r8();
+
+	printf("RSI: %p  RDI: %p  R8 : %p\n", a, b, c);
+
+	a = get_r9(); b = get_r10(); c = get_r11();
+
+	printf("R9: %p   R10: %p  R11: %p\n", a, b, c);
+
+	a = get_r12(); b = get_r13(); c = get_r14();
+
+	printf("R12: %p  R13: %p  R14: %p\n", a, b, c);
+
+	a = get_r15();
+
+	printf("R15: %p\n", a);
+
+	printf("\nKernel panic: %s\n", s);
+
+	for (;;);
+}

+ 33 - 0
kernel/kernel.lds

@@ -0,0 +1,33 @@
+OUTPUT_FORMAT("elf64-x86-64","elf64-x86-64", "elf64-x86-64")
+OUTPUT_ARCH(i386:x86-64)
+ENTRY(_start)
+
+SECTIONS {
+	. = 0xffff800000000000 + 0x100000;
+	.text : {
+		_text = .;
+		*(.text)
+		_etext = .;
+	}
+
+	. = ALIGN(8);
+	.data : {
+		_data = .;
+		*(.data);
+		_edata = .;
+	}
+
+	.rodata : {
+		_rodata = .;
+		*(.rodata)
+		.erodata = .;
+	}
+
+	.bss : {
+		_bss = .;
+		*(.bss)
+		_ebss = .;
+	}
+
+	_end = .;
+}

+ 1720 - 0
kernel/kernel.s

@@ -0,0 +1,1720 @@
+
+kernel.o:     file format elf64-x86-64
+
+
+Disassembly of section .text:
+
+ffff800000100000 <_start>:
+ffff800000100000:	48 c7 c0 00 00 07 00 	mov    $0x70000,%rax
+ffff800000100007:	48 c7 80 00 08 00 00 	movq   $0x71007,0x800(%rax)
+ffff80000010000e:	07 10 07 00 
+ffff800000100012:	0f 22 d8             	mov    %rax,%cr3
+ffff800000100015:	0f 01 15 14 0f 00 00 	lgdt   0xf14(%rip)        # ffff800000100f30 <end_gdt>
+ffff80000010001c:	0f 01 1d 17 1f 00 00 	lidt   0x1f17(%rip)        # ffff800000101f3a <end_idt>
+ffff800000100023:	48 8d 05 05 00 00 00 	lea    0x5(%rip),%rax        # ffff80000010002f <switch_segment>
+ffff80000010002a:	6a 08                	pushq  $0x8
+ffff80000010002c:	50                   	push   %rax
+ffff80000010002d:	48 cb                	lretq  
+
+ffff80000010002f <switch_segment>:
+ffff80000010002f:	48 c7 c0 10 00 00 00 	mov    $0x10,%rax
+ffff800000100036:	48 8e d8             	mov    %rax,%ds
+ffff800000100039:	48 8e c0             	mov    %rax,%es
+ffff80000010003c:	48 8e e0             	mov    %rax,%fs
+ffff80000010003f:	48 8e e8             	mov    %rax,%gs
+ffff800000100042:	48 8e d0             	mov    %rax,%ss
+ffff800000100045:	48 c7 c4 00 7c 00 00 	mov    $0x7c00,%rsp
+ffff80000010004c:	e8 2f 00 00 00       	callq  ffff800000100080 <setup_idt>
+ffff800000100051:	48 8d 05 88 00 00 00 	lea    0x88(%rip),%rax        # ffff8000001000e0 <init>
+ffff800000100058:	6a 08                	pushq  $0x8
+ffff80000010005a:	50                   	push   %rax
+ffff80000010005b:	48 cb                	lretq  
+
+ffff80000010005d <setup_paging>:
+ffff80000010005d:	48 31 c0             	xor    %rax,%rax
+ffff800000100060:	48 c7 c7 00 20 07 00 	mov    $0x72000,%rdi
+ffff800000100067:	48 c7 c1 20 00 00 00 	mov    $0x20,%rcx
+ffff80000010006e:	fc                   	cld    
+
+ffff80000010006f <rep_spage>:
+ffff80000010006f:	48 0d 83 00 00 00    	or     $0x83,%rax
+ffff800000100075:	48 ab                	stos   %rax,%es:(%rdi)
+ffff800000100077:	48 05 00 00 20 00    	add    $0x200000,%rax
+ffff80000010007d:	e2 f0                	loop   ffff80000010006f <rep_spage>
+ffff80000010007f:	c3                   	retq   
+
+ffff800000100080 <setup_idt>:
+ffff800000100080:	48 8d 15 46 00 00 00 	lea    0x46(%rip),%rdx        # ffff8000001000cd <default_int>
+ffff800000100087:	48 c7 c0 00 00 08 00 	mov    $0x80000,%rax
+ffff80000010008e:	66 89 d0             	mov    %dx,%ax
+ffff800000100091:	48 b9 00 00 00 00 00 	movabs $0x8e0000000000,%rcx
+ffff800000100098:	8e 00 00 
+ffff80000010009b:	48 01 c8             	add    %rcx,%rax
+ffff80000010009e:	89 d1                	mov    %edx,%ecx
+ffff8000001000a0:	c1 e9 10             	shr    $0x10,%ecx
+ffff8000001000a3:	48 c1 e1 30          	shl    $0x30,%rcx
+ffff8000001000a7:	48 01 c8             	add    %rcx,%rax
+ffff8000001000aa:	48 c1 ea 20          	shr    $0x20,%rdx
+ffff8000001000ae:	48 8d 3d 85 0e 00 00 	lea    0xe85(%rip),%rdi        # ffff800000100f3a <idt_table>
+ffff8000001000b5:	48 c7 c1 00 01 00 00 	mov    $0x100,%rcx
+
+ffff8000001000bc <rep_sidt>:
+ffff8000001000bc:	48 89 07             	mov    %rax,(%rdi)
+ffff8000001000bf:	48 89 57 08          	mov    %rdx,0x8(%rdi)
+ffff8000001000c3:	48 83 c7 10          	add    $0x10,%rdi
+ffff8000001000c7:	48 ff c9             	dec    %rcx
+ffff8000001000ca:	75 f0                	jne    ffff8000001000bc <rep_sidt>
+ffff8000001000cc:	c3                   	retq   
+
+ffff8000001000cd <default_int>:
+ffff8000001000cd:	48 8d 3d bc 1e 00 00 	lea    0x1ebc(%rip),%rdi        # ffff800000101f90 <_rodata>
+ffff8000001000d4:	e8 17 03 00 00       	callq  ffff8000001003f0 <printf>
+
+ffff8000001000d9 <default_int_die>:
+ffff8000001000d9:	f4                   	hlt    
+ffff8000001000da:	eb fd                	jmp    ffff8000001000d9 <default_int_die>
+ffff8000001000dc:	48 cf                	iretq  
+ffff8000001000de:	66 90                	xchg   %ax,%ax
+
+ffff8000001000e0 <init>:
+ffff8000001000e0:	49 bb 98 1e 00 00 00 	movabs $0x1e98,%r11
+ffff8000001000e7:	00 00 00 
+ffff8000001000ea:	41 57                	push   %r15
+ffff8000001000ec:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff8000001000e0 <init>
+ffff8000001000f3:	41 54                	push   %r12
+ffff8000001000f5:	4d 01 df             	add    %r11,%r15
+ffff8000001000f8:	55                   	push   %rbp
+ffff8000001000f9:	48 bd 58 ee ff ff ff 	movabs $0xffffffffffffee58,%rbp
+ffff800000100100:	ff ff ff 
+ffff800000100103:	53                   	push   %rbx
+ffff800000100104:	4c 01 fd             	add    %r15,%rbp
+ffff800000100107:	48 bb 78 e4 ff ff ff 	movabs $0xffffffffffffe478,%rbx
+ffff80000010010e:	ff ff ff 
+ffff800000100111:	4c 01 fb             	add    %r15,%rbx
+ffff800000100114:	48 83 ec 28          	sub    $0x28,%rsp
+ffff800000100118:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
+ffff80000010011f:	00 00 
+ffff800000100121:	48 89 44 24 18       	mov    %rax,0x18(%rsp)
+ffff800000100126:	48 b8 68 e3 ff ff ff 	movabs $0xffffffffffffe368,%rax
+ffff80000010012d:	ff ff ff 
+ffff800000100130:	4c 8d 64 24 08       	lea    0x8(%rsp),%r12
+ffff800000100135:	4c 01 f8             	add    %r15,%rax
+ffff800000100138:	ff d0                	callq  *%rax
+ffff80000010013a:	48 b8 e8 ec ff ff ff 	movabs $0xffffffffffffece8,%rax
+ffff800000100141:	ff ff ff 
+ffff800000100144:	4c 01 f8             	add    %r15,%rax
+ffff800000100147:	ff d0                	callq  *%rax
+ffff800000100149:	be 57 07 00 00       	mov    $0x757,%esi
+ffff80000010014e:	48 b8 50 00 00 00 00 	movabs $0x50,%rax
+ffff800000100155:	00 00 00 
+ffff800000100158:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff80000010015c:	31 c0                	xor    %eax,%eax
+ffff80000010015e:	ff d3                	callq  *%rbx
+ffff800000100160:	ff d5                	callq  *%rbp
+ffff800000100162:	48 89 44 24 08       	mov    %rax,0x8(%rsp)
+ffff800000100167:	ff d5                	callq  *%rbp
+ffff800000100169:	4c 89 e6             	mov    %r12,%rsi
+ffff80000010016c:	48 89 44 24 10       	mov    %rax,0x10(%rsp)
+ffff800000100171:	48 b8 fc 00 00 00 00 	movabs $0xfc,%rax
+ffff800000100178:	00 00 00 
+ffff80000010017b:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff80000010017f:	31 c0                	xor    %eax,%eax
+ffff800000100181:	ff d3                	callq  *%rbx
+ffff800000100183:	48 8d 74 24 10       	lea    0x10(%rsp),%rsi
+ffff800000100188:	48 b8 12 01 00 00 00 	movabs $0x112,%rax
+ffff80000010018f:	00 00 00 
+ffff800000100192:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100196:	31 c0                	xor    %eax,%eax
+ffff800000100198:	ff d3                	callq  *%rbx
+ffff80000010019a:	48 8b 7c 24 08       	mov    0x8(%rsp),%rdi
+ffff80000010019f:	48 b8 98 ee ff ff ff 	movabs $0xffffffffffffee98,%rax
+ffff8000001001a6:	ff ff ff 
+ffff8000001001a9:	4c 01 f8             	add    %r15,%rax
+ffff8000001001ac:	ff d0                	callq  *%rax
+ffff8000001001ae:	ff d5                	callq  *%rbp
+ffff8000001001b0:	4c 89 e6             	mov    %r12,%rsi
+ffff8000001001b3:	48 89 44 24 08       	mov    %rax,0x8(%rsp)
+ffff8000001001b8:	48 b8 70 00 00 00 00 	movabs $0x70,%rax
+ffff8000001001bf:	00 00 00 
+ffff8000001001c2:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff8000001001c6:	31 c0                	xor    %eax,%eax
+ffff8000001001c8:	ff d3                	callq  *%rbx
+ffff8000001001ca:	eb fe                	jmp    ffff8000001001ca <init+0xea>
+ffff8000001001cc:	0f 1f 40 00          	nopl   0x0(%rax)
+
+ffff8000001001d0 <bitmap_set>:
+ffff8000001001d0:	89 f1                	mov    %esi,%ecx
+ffff8000001001d2:	b8 80 00 00 00       	mov    $0x80,%eax
+ffff8000001001d7:	c1 ee 03             	shr    $0x3,%esi
+ffff8000001001da:	41 89 d0             	mov    %edx,%r8d
+ffff8000001001dd:	83 e1 07             	and    $0x7,%ecx
+ffff8000001001e0:	48 01 fe             	add    %rdi,%rsi
+ffff8000001001e3:	d3 f8                	sar    %cl,%eax
+ffff8000001001e5:	89 c2                	mov    %eax,%edx
+ffff8000001001e7:	0a 06                	or     (%rsi),%al
+ffff8000001001e9:	f7 d2                	not    %edx
+ffff8000001001eb:	22 16                	and    (%rsi),%dl
+ffff8000001001ed:	45 84 c0             	test   %r8b,%r8b
+ffff8000001001f0:	0f 44 c2             	cmove  %edx,%eax
+ffff8000001001f3:	88 06                	mov    %al,(%rsi)
+ffff8000001001f5:	c3                   	retq   
+ffff8000001001f6:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
+ffff8000001001fd:	00 00 00 
+
+ffff800000100200 <bitmap_read>:
+ffff800000100200:	89 f1                	mov    %esi,%ecx
+ffff800000100202:	c1 ee 03             	shr    $0x3,%esi
+ffff800000100205:	b8 80 00 00 00       	mov    $0x80,%eax
+ffff80000010020a:	83 e1 07             	and    $0x7,%ecx
+ffff80000010020d:	0f b6 14 37          	movzbl (%rdi,%rsi,1),%edx
+ffff800000100211:	d3 f8                	sar    %cl,%eax
+ffff800000100213:	21 c2                	and    %eax,%edx
+ffff800000100215:	38 c2                	cmp    %al,%dl
+ffff800000100217:	0f 94 c0             	sete   %al
+ffff80000010021a:	c3                   	retq   
+ffff80000010021b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+
+ffff800000100220 <bitman_alloc>:
+ffff800000100220:	41 57                	push   %r15
+ffff800000100222:	4c 8d 3d f7 ff ff ff 	lea    -0x9(%rip),%r15        # ffff800000100220 <bitman_alloc>
+ffff800000100229:	ba 01 00 00 00       	mov    $0x1,%edx
+ffff80000010022e:	49 bb 58 1d 00 00 00 	movabs $0x1d58,%r11
+ffff800000100235:	00 00 00 
+ffff800000100238:	48 b8 58 e2 ff ff ff 	movabs $0xffffffffffffe258,%rax
+ffff80000010023f:	ff ff ff 
+ffff800000100242:	41 54                	push   %r12
+ffff800000100244:	4d 01 df             	add    %r11,%r15
+ffff800000100247:	55                   	push   %rbp
+ffff800000100248:	4c 01 f8             	add    %r15,%rax
+ffff80000010024b:	48 bd 88 e2 ff ff ff 	movabs $0xffffffffffffe288,%rbp
+ffff800000100252:	ff ff ff 
+ffff800000100255:	53                   	push   %rbx
+ffff800000100256:	48 89 fb             	mov    %rdi,%rbx
+ffff800000100259:	4c 01 fd             	add    %r15,%rbp
+ffff80000010025c:	48 83 ec 08          	sub    $0x8,%rsp
+ffff800000100260:	44 8b 67 08          	mov    0x8(%rdi),%r12d
+ffff800000100264:	48 8b 3f             	mov    (%rdi),%rdi
+ffff800000100267:	44 89 e6             	mov    %r12d,%esi
+ffff80000010026a:	ff d0                	callq  *%rax
+ffff80000010026c:	8b 73 08             	mov    0x8(%rbx),%esi
+ffff80000010026f:	eb 10                	jmp    ffff800000100281 <bitman_alloc+0x61>
+ffff800000100271:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+ffff800000100278:	8b 43 08             	mov    0x8(%rbx),%eax
+ffff80000010027b:	8d 70 01             	lea    0x1(%rax),%esi
+ffff80000010027e:	89 73 08             	mov    %esi,0x8(%rbx)
+ffff800000100281:	48 8b 3b             	mov    (%rbx),%rdi
+ffff800000100284:	ff d5                	callq  *%rbp
+ffff800000100286:	3c 01                	cmp    $0x1,%al
+ffff800000100288:	74 ee                	je     ffff800000100278 <bitman_alloc+0x58>
+ffff80000010028a:	48 83 c4 08          	add    $0x8,%rsp
+ffff80000010028e:	44 89 e0             	mov    %r12d,%eax
+ffff800000100291:	5b                   	pop    %rbx
+ffff800000100292:	5d                   	pop    %rbp
+ffff800000100293:	41 5c                	pop    %r12
+ffff800000100295:	41 5f                	pop    %r15
+ffff800000100297:	c3                   	retq   
+ffff800000100298:	0f 1f 84 00 00 00 00 	nopl   0x0(%rax,%rax,1)
+ffff80000010029f:	00 
+
+ffff8000001002a0 <bitman_free>:
+ffff8000001002a0:	49 bb d8 1c 00 00 00 	movabs $0x1cd8,%r11
+ffff8000001002a7:	00 00 00 
+ffff8000001002aa:	41 57                	push   %r15
+ffff8000001002ac:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff8000001002a0 <bitman_free>
+ffff8000001002b3:	31 d2                	xor    %edx,%edx
+ffff8000001002b5:	48 b8 58 e2 ff ff ff 	movabs $0xffffffffffffe258,%rax
+ffff8000001002bc:	ff ff ff 
+ffff8000001002bf:	55                   	push   %rbp
+ffff8000001002c0:	4d 01 df             	add    %r11,%r15
+ffff8000001002c3:	89 f5                	mov    %esi,%ebp
+ffff8000001002c5:	53                   	push   %rbx
+ffff8000001002c6:	48 89 fb             	mov    %rdi,%rbx
+ffff8000001002c9:	4c 01 f8             	add    %r15,%rax
+ffff8000001002cc:	48 8b 3f             	mov    (%rdi),%rdi
+ffff8000001002cf:	ff d0                	callq  *%rax
+ffff8000001002d1:	39 6b 08             	cmp    %ebp,0x8(%rbx)
+ffff8000001002d4:	76 03                	jbe    ffff8000001002d9 <bitman_free+0x39>
+ffff8000001002d6:	89 6b 08             	mov    %ebp,0x8(%rbx)
+ffff8000001002d9:	5b                   	pop    %rbx
+ffff8000001002da:	5d                   	pop    %rbp
+ffff8000001002db:	41 5f                	pop    %r15
+ffff8000001002dd:	c3                   	retq   
+ffff8000001002de:	66 90                	xchg   %ax,%ax
+
+ffff8000001002e0 <tty_init>:
+ffff8000001002e0:	56                   	push   %rsi
+ffff8000001002e1:	57                   	push   %rdi
+ffff8000001002e2:	66 bf 00 00          	mov    $0x0,%di
+ffff8000001002e6:	e8 55 00 00 00       	callq  ffff800000100340 <write_cursor>
+ffff8000001002eb:	5f                   	pop    %rdi
+ffff8000001002ec:	5e                   	pop    %rsi
+ffff8000001002ed:	c3                   	retq   
+
+ffff8000001002ee <putc>:
+ffff8000001002ee:	57                   	push   %rdi
+ffff8000001002ef:	89 f8                	mov    %edi,%eax
+ffff8000001002f1:	48 8b 3d 50 1c 00 00 	mov    0x1c50(%rip),%rdi        # ffff800000101f48 <framebuffer>
+ffff8000001002f8:	b4 0f                	mov    $0xf,%ah
+ffff8000001002fa:	fc                   	cld    
+ffff8000001002fb:	66 ab                	stos   %ax,%es:(%rdi)
+ffff8000001002fd:	48 89 3d 44 1c 00 00 	mov    %rdi,0x1c44(%rip)        # ffff800000101f48 <framebuffer>
+ffff800000100304:	48 31 c0             	xor    %rax,%rax
+ffff800000100307:	5f                   	pop    %rdi
+ffff800000100308:	c3                   	retq   
+ffff800000100309:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+
+ffff800000100310 <read_cursor>:
+ffff800000100310:	bf d4 03 00 00       	mov    $0x3d4,%edi
+ffff800000100315:	b8 0f 00 00 00       	mov    $0xf,%eax
+ffff80000010031a:	89 fa                	mov    %edi,%edx
+ffff80000010031c:	ee                   	out    %al,(%dx)
+ffff80000010031d:	be d5 03 00 00       	mov    $0x3d5,%esi
+ffff800000100322:	89 f2                	mov    %esi,%edx
+ffff800000100324:	ec                   	in     (%dx),%al
+ffff800000100325:	0f b6 c8             	movzbl %al,%ecx
+ffff800000100328:	89 fa                	mov    %edi,%edx
+ffff80000010032a:	b8 0e 00 00 00       	mov    $0xe,%eax
+ffff80000010032f:	ee                   	out    %al,(%dx)
+ffff800000100330:	89 f2                	mov    %esi,%edx
+ffff800000100332:	ec                   	in     (%dx),%al
+ffff800000100333:	c1 e0 08             	shl    $0x8,%eax
+ffff800000100336:	09 c8                	or     %ecx,%eax
+ffff800000100338:	c3                   	retq   
+ffff800000100339:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+
+ffff800000100340 <write_cursor>:
+ffff800000100340:	be d4 03 00 00       	mov    $0x3d4,%esi
+ffff800000100345:	b8 0f 00 00 00       	mov    $0xf,%eax
+ffff80000010034a:	89 f2                	mov    %esi,%edx
+ffff80000010034c:	ee                   	out    %al,(%dx)
+ffff80000010034d:	b9 d5 03 00 00       	mov    $0x3d5,%ecx
+ffff800000100352:	89 f8                	mov    %edi,%eax
+ffff800000100354:	89 ca                	mov    %ecx,%edx
+ffff800000100356:	ee                   	out    %al,(%dx)
+ffff800000100357:	b8 0e 00 00 00       	mov    $0xe,%eax
+ffff80000010035c:	89 f2                	mov    %esi,%edx
+ffff80000010035e:	ee                   	out    %al,(%dx)
+ffff80000010035f:	66 c1 ef 08          	shr    $0x8,%di
+ffff800000100363:	89 ca                	mov    %ecx,%edx
+ffff800000100365:	89 f8                	mov    %edi,%eax
+ffff800000100367:	ee                   	out    %al,(%dx)
+ffff800000100368:	c3                   	retq   
+ffff800000100369:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+
+ffff800000100370 <update_cursor>:
+ffff800000100370:	48 8d 35 f9 ff ff ff 	lea    -0x7(%rip),%rsi        # ffff800000100370 <update_cursor>
+ffff800000100377:	41 b8 d4 03 00 00    	mov    $0x3d4,%r8d
+ffff80000010037d:	49 bb 08 1c 00 00 00 	movabs $0x1c08,%r11
+ffff800000100384:	00 00 00 
+ffff800000100387:	48 b8 e8 04 00 00 00 	movabs $0x4e8,%rax
+ffff80000010038e:	00 00 00 
+ffff800000100391:	4c 01 de             	add    %r11,%rsi
+ffff800000100394:	44 89 c2             	mov    %r8d,%edx
+ffff800000100397:	8b 0c 06             	mov    (%rsi,%rax,1),%ecx
+ffff80000010039a:	48 b8 ec 04 00 00 00 	movabs $0x4ec,%rax
+ffff8000001003a1:	00 00 00 
+ffff8000001003a4:	8d 0c 89             	lea    (%rcx,%rcx,4),%ecx
+ffff8000001003a7:	c1 e1 04             	shl    $0x4,%ecx
+ffff8000001003aa:	66 03 0c 30          	add    (%rax,%rsi,1),%cx
+ffff8000001003ae:	b8 0f 00 00 00       	mov    $0xf,%eax
+ffff8000001003b3:	ee                   	out    %al,(%dx)
+ffff8000001003b4:	bf d5 03 00 00       	mov    $0x3d5,%edi
+ffff8000001003b9:	89 c8                	mov    %ecx,%eax
+ffff8000001003bb:	89 fa                	mov    %edi,%edx
+ffff8000001003bd:	ee                   	out    %al,(%dx)
+ffff8000001003be:	b8 0e 00 00 00       	mov    $0xe,%eax
+ffff8000001003c3:	44 89 c2             	mov    %r8d,%edx
+ffff8000001003c6:	ee                   	out    %al,(%dx)
+ffff8000001003c7:	89 c8                	mov    %ecx,%eax
+ffff8000001003c9:	89 fa                	mov    %edi,%edx
+ffff8000001003cb:	66 c1 e8 08          	shr    $0x8,%ax
+ffff8000001003cf:	ee                   	out    %al,(%dx)
+ffff8000001003d0:	48 b8 f0 ff ff ff ff 	movabs $0xfffffffffffffff0,%rax
+ffff8000001003d7:	ff ff ff 
+ffff8000001003da:	0f b7 c9             	movzwl %cx,%ecx
+ffff8000001003dd:	48 8b 04 06          	mov    (%rsi,%rax,1),%rax
+ffff8000001003e1:	48 8d 94 09 00 80 0b 	lea    0xb8000(%rcx,%rcx,1),%rdx
+ffff8000001003e8:	00 
+ffff8000001003e9:	48 89 10             	mov    %rdx,(%rax)
+ffff8000001003ec:	c3                   	retq   
+ffff8000001003ed:	0f 1f 00             	nopl   (%rax)
+
+ffff8000001003f0 <printf>:
+ffff8000001003f0:	49 bb 88 1b 00 00 00 	movabs $0x1b88,%r11
+ffff8000001003f7:	00 00 00 
+ffff8000001003fa:	41 57                	push   %r15
+ffff8000001003fc:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff8000001003f0 <printf>
+ffff800000100403:	41 56                	push   %r14
+ffff800000100405:	4d 01 df             	add    %r11,%r15
+ffff800000100408:	41 55                	push   %r13
+ffff80000010040a:	41 54                	push   %r12
+ffff80000010040c:	55                   	push   %rbp
+ffff80000010040d:	53                   	push   %rbx
+ffff80000010040e:	48 81 ec a8 00 00 00 	sub    $0xa8,%rsp
+ffff800000100415:	48 89 74 24 78       	mov    %rsi,0x78(%rsp)
+ffff80000010041a:	48 89 94 24 80 00 00 	mov    %rdx,0x80(%rsp)
+ffff800000100421:	00 
+ffff800000100422:	48 89 8c 24 88 00 00 	mov    %rcx,0x88(%rsp)
+ffff800000100429:	00 
+ffff80000010042a:	4c 89 84 24 90 00 00 	mov    %r8,0x90(%rsp)
+ffff800000100431:	00 
+ffff800000100432:	4c 89 8c 24 98 00 00 	mov    %r9,0x98(%rsp)
+ffff800000100439:	00 
+ffff80000010043a:	44 0f b6 2f          	movzbl (%rdi),%r13d
+ffff80000010043e:	48 89 3c 24          	mov    %rdi,(%rsp)
+ffff800000100442:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
+ffff800000100449:	00 00 
+ffff80000010044b:	48 89 44 24 68       	mov    %rax,0x68(%rsp)
+ffff800000100450:	31 c0                	xor    %eax,%eax
+ffff800000100452:	48 8d 84 24 e0 00 00 	lea    0xe0(%rsp),%rax
+ffff800000100459:	00 
+ffff80000010045a:	c7 44 24 28 08 00 00 	movl   $0x8,0x28(%rsp)
+ffff800000100461:	00 
+ffff800000100462:	48 89 44 24 30       	mov    %rax,0x30(%rsp)
+ffff800000100467:	48 8d 44 24 70       	lea    0x70(%rsp),%rax
+ffff80000010046c:	48 89 44 24 38       	mov    %rax,0x38(%rsp)
+ffff800000100471:	45 84 ed             	test   %r13b,%r13b
+ffff800000100474:	0f 84 e6 00 00 00    	je     ffff800000100560 <printf+0x170>
+ffff80000010047a:	45 31 f6             	xor    %r14d,%r14d
+ffff80000010047d:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%rsp)
+ffff800000100484:	00 
+ffff800000100485:	31 ed                	xor    %ebp,%ebp
+ffff800000100487:	45 31 e4             	xor    %r12d,%r12d
+ffff80000010048a:	48 b8 2c 01 00 00 00 	movabs $0x12c,%rax
+ffff800000100491:	00 00 00 
+ffff800000100494:	48 bb 76 e3 ff ff ff 	movabs $0xffffffffffffe376,%rbx
+ffff80000010049b:	ff ff ff 
+ffff80000010049e:	48 89 44 24 18       	mov    %rax,0x18(%rsp)
+ffff8000001004a3:	4c 01 fb             	add    %r15,%rbx
+ffff8000001004a6:	44 89 f0             	mov    %r14d,%eax
+ffff8000001004a9:	45 89 ee             	mov    %r13d,%r14d
+ffff8000001004ac:	eb 30                	jmp    ffff8000001004de <printf+0xee>
+ffff8000001004ae:	66 90                	xchg   %ax,%ax
+ffff8000001004b0:	41 80 fe 25          	cmp    $0x25,%r14b
+ffff8000001004b4:	74 7a                	je     ffff800000100530 <printf+0x140>
+ffff8000001004b6:	41 80 fe 0a          	cmp    $0xa,%r14b
+ffff8000001004ba:	0f 85 80 00 00 00    	jne    ffff800000100540 <printf+0x150>
+ffff8000001004c0:	83 44 24 0c 01       	addl   $0x1,0xc(%rsp)
+ffff8000001004c5:	0f 1f 00             	nopl   (%rax)
+ffff8000001004c8:	48 8b 34 24          	mov    (%rsp),%rsi
+ffff8000001004cc:	49 83 c4 01          	add    $0x1,%r12
+ffff8000001004d0:	46 0f b6 34 26       	movzbl (%rsi,%r12,1),%r14d
+ffff8000001004d5:	45 84 f6             	test   %r14b,%r14b
+ffff8000001004d8:	0f 84 92 00 00 00    	je     ffff800000100570 <printf+0x180>
+ffff8000001004de:	84 c0                	test   %al,%al
+ffff8000001004e0:	74 ce                	je     ffff8000001004b0 <printf+0xc0>
+ffff8000001004e2:	41 80 fe 64          	cmp    $0x64,%r14b
+ffff8000001004e6:	0f 84 54 01 00 00    	je     ffff800000100640 <printf+0x250>
+ffff8000001004ec:	41 80 fe 78          	cmp    $0x78,%r14b
+ffff8000001004f0:	0f 84 2a 02 00 00    	je     ffff800000100720 <printf+0x330>
+ffff8000001004f6:	41 80 fe 70          	cmp    $0x70,%r14b
+ffff8000001004fa:	0f 84 c8 02 00 00    	je     ffff8000001007c8 <printf+0x3d8>
+ffff800000100500:	41 80 fe 73          	cmp    $0x73,%r14b
+ffff800000100504:	0f 84 de 03 00 00    	je     ffff8000001008e8 <printf+0x4f8>
+ffff80000010050a:	48 83 c5 01          	add    $0x1,%rbp
+ffff80000010050e:	41 80 fe 63          	cmp    $0x63,%r14b
+ffff800000100512:	0f 84 68 03 00 00    	je     ffff800000100880 <printf+0x490>
+ffff800000100518:	bf 25 00 00 00       	mov    $0x25,%edi
+ffff80000010051d:	41 80 fe 25          	cmp    $0x25,%r14b
+ffff800000100521:	74 06                	je     ffff800000100529 <printf+0x139>
+ffff800000100523:	ff d3                	callq  *%rbx
+ffff800000100525:	41 0f be fe          	movsbl %r14b,%edi
+ffff800000100529:	ff d3                	callq  *%rbx
+ffff80000010052b:	31 c0                	xor    %eax,%eax
+ffff80000010052d:	eb 99                	jmp    ffff8000001004c8 <printf+0xd8>
+ffff80000010052f:	90                   	nop
+ffff800000100530:	b8 25 00 00 00       	mov    $0x25,%eax
+ffff800000100535:	eb 91                	jmp    ffff8000001004c8 <printf+0xd8>
+ffff800000100537:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
+ffff80000010053e:	00 00 
+ffff800000100540:	88 44 24 10          	mov    %al,0x10(%rsp)
+ffff800000100544:	41 0f be fe          	movsbl %r14b,%edi
+ffff800000100548:	48 83 c5 01          	add    $0x1,%rbp
+ffff80000010054c:	ff d3                	callq  *%rbx
+ffff80000010054e:	0f b6 44 24 10       	movzbl 0x10(%rsp),%eax
+ffff800000100553:	e9 70 ff ff ff       	jmpq   ffff8000001004c8 <printf+0xd8>
+ffff800000100558:	0f 1f 84 00 00 00 00 	nopl   0x0(%rax,%rax,1)
+ffff80000010055f:	00 
+ffff800000100560:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%rsp)
+ffff800000100567:	00 
+ffff800000100568:	31 ed                	xor    %ebp,%ebp
+ffff80000010056a:	45 31 e4             	xor    %r12d,%r12d
+ffff80000010056d:	0f 1f 00             	nopl   (%rax)
+ffff800000100570:	48 bb ec 04 00 00 00 	movabs $0x4ec,%rbx
+ffff800000100577:	00 00 00 
+ffff80000010057a:	49 bd e8 04 00 00 00 	movabs $0x4e8,%r13
+ffff800000100581:	00 00 00 
+ffff800000100584:	42 03 2c 3b          	add    (%rbx,%r15,1),%ebp
+ffff800000100588:	43 8b 44 3d 00       	mov    0x0(%r13,%r15,1),%eax
+ffff80000010058d:	42 89 2c 3b          	mov    %ebp,(%rbx,%r15,1)
+ffff800000100591:	83 fd 50             	cmp    $0x50,%ebp
+ffff800000100594:	7e 10                	jle    ffff8000001005a6 <printf+0x1b6>
+ffff800000100596:	ba 50 00 00 00       	mov    $0x50,%edx
+ffff80000010059b:	83 c0 01             	add    $0x1,%eax
+ffff80000010059e:	29 ea                	sub    %ebp,%edx
+ffff8000001005a0:	42 89 14 3b          	mov    %edx,(%rbx,%r15,1)
+ffff8000001005a4:	89 d5                	mov    %edx,%ebp
+ffff8000001005a6:	8b 74 24 0c          	mov    0xc(%rsp),%esi
+ffff8000001005aa:	01 f0                	add    %esi,%eax
+ffff8000001005ac:	43 89 44 3d 00       	mov    %eax,0x0(%r13,%r15,1)
+ffff8000001005b1:	85 f6                	test   %esi,%esi
+ffff8000001005b3:	74 0a                	je     ffff8000001005bf <printf+0x1cf>
+ffff8000001005b5:	42 c7 04 3b 00 00 00 	movl   $0x0,(%rbx,%r15,1)
+ffff8000001005bc:	00 
+ffff8000001005bd:	31 ed                	xor    %ebp,%ebp
+ffff8000001005bf:	83 f8 19             	cmp    $0x19,%eax
+ffff8000001005c2:	0f 8f e8 02 00 00    	jg     ffff8000001008b0 <printf+0x4c0>
+ffff8000001005c8:	8d 04 80             	lea    (%rax,%rax,4),%eax
+ffff8000001005cb:	be d4 03 00 00       	mov    $0x3d4,%esi
+ffff8000001005d0:	c1 e0 04             	shl    $0x4,%eax
+ffff8000001005d3:	89 f2                	mov    %esi,%edx
+ffff8000001005d5:	01 c5                	add    %eax,%ebp
+ffff8000001005d7:	b8 0f 00 00 00       	mov    $0xf,%eax
+ffff8000001005dc:	ee                   	out    %al,(%dx)
+ffff8000001005dd:	b9 d5 03 00 00       	mov    $0x3d5,%ecx
+ffff8000001005e2:	89 e8                	mov    %ebp,%eax
+ffff8000001005e4:	89 ca                	mov    %ecx,%edx
+ffff8000001005e6:	ee                   	out    %al,(%dx)
+ffff8000001005e7:	b8 0e 00 00 00       	mov    $0xe,%eax
+ffff8000001005ec:	89 f2                	mov    %esi,%edx
+ffff8000001005ee:	ee                   	out    %al,(%dx)
+ffff8000001005ef:	89 e8                	mov    %ebp,%eax
+ffff8000001005f1:	89 ca                	mov    %ecx,%edx
+ffff8000001005f3:	66 c1 e8 08          	shr    $0x8,%ax
+ffff8000001005f7:	ee                   	out    %al,(%dx)
+ffff8000001005f8:	48 b8 f0 ff ff ff ff 	movabs $0xfffffffffffffff0,%rax
+ffff8000001005ff:	ff ff ff 
+ffff800000100602:	0f b7 ed             	movzwl %bp,%ebp
+ffff800000100605:	49 8b 04 07          	mov    (%r15,%rax,1),%rax
+ffff800000100609:	48 8d 94 2d 00 80 0b 	lea    0xb8000(%rbp,%rbp,1),%rdx
+ffff800000100610:	00 
+ffff800000100611:	48 89 10             	mov    %rdx,(%rax)
+ffff800000100614:	48 8b 44 24 68       	mov    0x68(%rsp),%rax
+ffff800000100619:	64 48 2b 04 25 28 00 	sub    %fs:0x28,%rax
+ffff800000100620:	00 00 
+ffff800000100622:	0f 85 58 03 00 00    	jne    ffff800000100980 <printf+0x590>
+ffff800000100628:	48 81 c4 a8 00 00 00 	add    $0xa8,%rsp
+ffff80000010062f:	4c 89 e0             	mov    %r12,%rax
+ffff800000100632:	5b                   	pop    %rbx
+ffff800000100633:	5d                   	pop    %rbp
+ffff800000100634:	41 5c                	pop    %r12
+ffff800000100636:	41 5d                	pop    %r13
+ffff800000100638:	41 5e                	pop    %r14
+ffff80000010063a:	41 5f                	pop    %r15
+ffff80000010063c:	c3                   	retq   
+ffff80000010063d:	0f 1f 00             	nopl   (%rax)
+ffff800000100640:	8b 44 24 28          	mov    0x28(%rsp),%eax
+ffff800000100644:	83 f8 2f             	cmp    $0x2f,%eax
+ffff800000100647:	0f 87 eb 01 00 00    	ja     ffff800000100838 <printf+0x448>
+ffff80000010064d:	89 c2                	mov    %eax,%edx
+ffff80000010064f:	83 c0 08             	add    $0x8,%eax
+ffff800000100652:	48 03 54 24 38       	add    0x38(%rsp),%rdx
+ffff800000100657:	89 44 24 28          	mov    %eax,0x28(%rsp)
+ffff80000010065b:	48 63 0a             	movslq (%rdx),%rcx
+ffff80000010065e:	31 f6                	xor    %esi,%esi
+ffff800000100660:	48 85 c9             	test   %rcx,%rcx
+ffff800000100663:	79 08                	jns    ffff80000010066d <printf+0x27d>
+ffff800000100665:	48 f7 d9             	neg    %rcx
+ffff800000100668:	be 01 00 00 00       	mov    $0x1,%esi
+ffff80000010066d:	4c 8d 5c 24 40       	lea    0x40(%rsp),%r11
+ffff800000100672:	45 31 ed             	xor    %r13d,%r13d
+ffff800000100675:	49 b8 38 00 00 00 00 	movabs $0x38,%r8
+ffff80000010067c:	00 00 00 
+ffff80000010067f:	49 ba cd cc cc cc cc 	movabs $0xcccccccccccccccd,%r10
+ffff800000100686:	cc cc cc 
+ffff800000100689:	4c 89 df             	mov    %r11,%rdi
+ffff80000010068c:	4d 01 f8             	add    %r15,%r8
+ffff80000010068f:	90                   	nop
+ffff800000100690:	48 89 c8             	mov    %rcx,%rax
+ffff800000100693:	49 89 ce             	mov    %rcx,%r14
+ffff800000100696:	4d 63 cd             	movslq %r13d,%r9
+ffff800000100699:	48 83 c7 01          	add    $0x1,%rdi
+ffff80000010069d:	49 f7 e2             	mul    %r10
+ffff8000001006a0:	41 83 c5 01          	add    $0x1,%r13d
+ffff8000001006a4:	48 c1 ea 03          	shr    $0x3,%rdx
+ffff8000001006a8:	48 8d 04 92          	lea    (%rdx,%rdx,4),%rax
+ffff8000001006ac:	48 01 c0             	add    %rax,%rax
+ffff8000001006af:	49 29 c6             	sub    %rax,%r14
+ffff8000001006b2:	43 0f b6 04 30       	movzbl (%r8,%r14,1),%eax
+ffff8000001006b7:	88 47 ff             	mov    %al,-0x1(%rdi)
+ffff8000001006ba:	48 89 c8             	mov    %rcx,%rax
+ffff8000001006bd:	48 89 d1             	mov    %rdx,%rcx
+ffff8000001006c0:	48 83 f8 09          	cmp    $0x9,%rax
+ffff8000001006c4:	77 ca                	ja     ffff800000100690 <printf+0x2a0>
+ffff8000001006c6:	85 f6                	test   %esi,%esi
+ffff8000001006c8:	74 12                	je     ffff8000001006dc <printf+0x2ec>
+ffff8000001006ca:	49 63 d5             	movslq %r13d,%rdx
+ffff8000001006cd:	41 8d 41 02          	lea    0x2(%r9),%eax
+ffff8000001006d1:	4d 63 cd             	movslq %r13d,%r9
+ffff8000001006d4:	c6 44 14 40 2d       	movb   $0x2d,0x40(%rsp,%rdx,1)
+ffff8000001006d9:	41 89 c5             	mov    %eax,%r13d
+ffff8000001006dc:	4b 8d 44 0b ff       	lea    -0x1(%r11,%r9,1),%rax
+ffff8000001006e1:	4f 8d 34 0b          	lea    (%r11,%r9,1),%r14
+ffff8000001006e5:	48 89 6c 24 10       	mov    %rbp,0x10(%rsp)
+ffff8000001006ea:	4c 29 c8             	sub    %r9,%rax
+ffff8000001006ed:	4c 89 f5             	mov    %r14,%rbp
+ffff8000001006f0:	49 89 c6             	mov    %rax,%r14
+ffff8000001006f3:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+ffff8000001006f8:	0f be 7d 00          	movsbl 0x0(%rbp),%edi
+ffff8000001006fc:	48 83 ed 01          	sub    $0x1,%rbp
+ffff800000100700:	ff d3                	callq  *%rbx
+ffff800000100702:	49 39 ee             	cmp    %rbp,%r14
+ffff800000100705:	75 f1                	jne    ffff8000001006f8 <printf+0x308>
+ffff800000100707:	48 8b 6c 24 10       	mov    0x10(%rsp),%rbp
+ffff80000010070c:	49 63 f5             	movslq %r13d,%rsi
+ffff80000010070f:	31 c0                	xor    %eax,%eax
+ffff800000100711:	48 01 f5             	add    %rsi,%rbp
+ffff800000100714:	e9 af fd ff ff       	jmpq   ffff8000001004c8 <printf+0xd8>
+ffff800000100719:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+ffff800000100720:	8b 44 24 28          	mov    0x28(%rsp),%eax
+ffff800000100724:	83 f8 2f             	cmp    $0x2f,%eax
+ffff800000100727:	0f 87 23 01 00 00    	ja     ffff800000100850 <printf+0x460>
+ffff80000010072d:	89 c2                	mov    %eax,%edx
+ffff80000010072f:	83 c0 08             	add    $0x8,%eax
+ffff800000100732:	48 03 54 24 38       	add    0x38(%rsp),%rdx
+ffff800000100737:	89 44 24 28          	mov    %eax,0x28(%rsp)
+ffff80000010073b:	4c 8d 5c 24 40       	lea    0x40(%rsp),%r11
+ffff800000100740:	48 8b 02             	mov    (%rdx),%rax
+ffff800000100743:	45 31 ed             	xor    %r13d,%r13d
+ffff800000100746:	49 b8 38 00 00 00 00 	movabs $0x38,%r8
+ffff80000010074d:	00 00 00 
+ffff800000100750:	4c 89 d9             	mov    %r11,%rcx
+ffff800000100753:	4d 01 f8             	add    %r15,%r8
+ffff800000100756:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
+ffff80000010075d:	00 00 00 
+ffff800000100760:	48 89 c2             	mov    %rax,%rdx
+ffff800000100763:	49 63 fd             	movslq %r13d,%rdi
+ffff800000100766:	48 83 c1 01          	add    $0x1,%rcx
+ffff80000010076a:	41 83 c5 01          	add    $0x1,%r13d
+ffff80000010076e:	83 e2 0f             	and    $0xf,%edx
+ffff800000100771:	41 0f b6 14 10       	movzbl (%r8,%rdx,1),%edx
+ffff800000100776:	88 51 ff             	mov    %dl,-0x1(%rcx)
+ffff800000100779:	48 89 c2             	mov    %rax,%rdx
+ffff80000010077c:	48 c1 e8 04          	shr    $0x4,%rax
+ffff800000100780:	48 83 fa 0f          	cmp    $0xf,%rdx
+ffff800000100784:	77 da                	ja     ffff800000100760 <printf+0x370>
+ffff800000100786:	49 8d 44 3b ff       	lea    -0x1(%r11,%rdi,1),%rax
+ffff80000010078b:	4d 8d 34 3b          	lea    (%r11,%rdi,1),%r14
+ffff80000010078f:	48 89 6c 24 10       	mov    %rbp,0x10(%rsp)
+ffff800000100794:	48 29 f8             	sub    %rdi,%rax
+ffff800000100797:	4c 89 f5             	mov    %r14,%rbp
+ffff80000010079a:	49 89 c6             	mov    %rax,%r14
+ffff80000010079d:	0f 1f 00             	nopl   (%rax)
+ffff8000001007a0:	0f be 7d 00          	movsbl 0x0(%rbp),%edi
+ffff8000001007a4:	48 83 ed 01          	sub    $0x1,%rbp
+ffff8000001007a8:	ff d3                	callq  *%rbx
+ffff8000001007aa:	49 39 ee             	cmp    %rbp,%r14
+ffff8000001007ad:	75 f1                	jne    ffff8000001007a0 <printf+0x3b0>
+ffff8000001007af:	48 8b 6c 24 10       	mov    0x10(%rsp),%rbp
+ffff8000001007b4:	49 63 d5             	movslq %r13d,%rdx
+ffff8000001007b7:	31 c0                	xor    %eax,%eax
+ffff8000001007b9:	48 01 d5             	add    %rdx,%rbp
+ffff8000001007bc:	e9 07 fd ff ff       	jmpq   ffff8000001004c8 <printf+0xd8>
+ffff8000001007c1:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+ffff8000001007c8:	8b 44 24 28          	mov    0x28(%rsp),%eax
+ffff8000001007cc:	83 f8 2f             	cmp    $0x2f,%eax
+ffff8000001007cf:	0f 87 93 00 00 00    	ja     ffff800000100868 <printf+0x478>
+ffff8000001007d5:	89 c2                	mov    %eax,%edx
+ffff8000001007d7:	83 c0 08             	add    $0x8,%eax
+ffff8000001007da:	48 03 54 24 38       	add    0x38(%rsp),%rdx
+ffff8000001007df:	89 44 24 28          	mov    %eax,0x28(%rsp)
+ffff8000001007e3:	4c 8b 32             	mov    (%rdx),%r14
+ffff8000001007e6:	41 bd 3c 00 00 00    	mov    $0x3c,%r13d
+ffff8000001007ec:	eb 15                	jmp    ffff800000100803 <printf+0x413>
+ffff8000001007ee:	66 90                	xchg   %ax,%ax
+ffff8000001007f0:	83 c7 57             	add    $0x57,%edi
+ffff8000001007f3:	41 83 ed 04          	sub    $0x4,%r13d
+ffff8000001007f7:	40 0f b6 ff          	movzbl %dil,%edi
+ffff8000001007fb:	ff d3                	callq  *%rbx
+ffff8000001007fd:	41 83 fd fc          	cmp    $0xfffffffc,%r13d
+ffff800000100801:	74 25                	je     ffff800000100828 <printf+0x438>
+ffff800000100803:	4c 89 f7             	mov    %r14,%rdi
+ffff800000100806:	44 89 e9             	mov    %r13d,%ecx
+ffff800000100809:	48 d3 ef             	shr    %cl,%rdi
+ffff80000010080c:	83 e7 0f             	and    $0xf,%edi
+ffff80000010080f:	40 80 ff 09          	cmp    $0x9,%dil
+ffff800000100813:	7f db                	jg     ffff8000001007f0 <printf+0x400>
+ffff800000100815:	83 c7 30             	add    $0x30,%edi
+ffff800000100818:	41 83 ed 04          	sub    $0x4,%r13d
+ffff80000010081c:	40 0f b6 ff          	movzbl %dil,%edi
+ffff800000100820:	ff d3                	callq  *%rbx
+ffff800000100822:	41 83 fd fc          	cmp    $0xfffffffc,%r13d
+ffff800000100826:	75 db                	jne    ffff800000100803 <printf+0x413>
+ffff800000100828:	48 83 c5 10          	add    $0x10,%rbp
+ffff80000010082c:	31 c0                	xor    %eax,%eax
+ffff80000010082e:	e9 95 fc ff ff       	jmpq   ffff8000001004c8 <printf+0xd8>
+ffff800000100833:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+ffff800000100838:	48 8b 54 24 30       	mov    0x30(%rsp),%rdx
+ffff80000010083d:	48 8d 42 08          	lea    0x8(%rdx),%rax
+ffff800000100841:	48 89 44 24 30       	mov    %rax,0x30(%rsp)
+ffff800000100846:	e9 10 fe ff ff       	jmpq   ffff80000010065b <printf+0x26b>
+ffff80000010084b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+ffff800000100850:	48 8b 54 24 30       	mov    0x30(%rsp),%rdx
+ffff800000100855:	48 8d 42 08          	lea    0x8(%rdx),%rax
+ffff800000100859:	48 89 44 24 30       	mov    %rax,0x30(%rsp)
+ffff80000010085e:	e9 d8 fe ff ff       	jmpq   ffff80000010073b <printf+0x34b>
+ffff800000100863:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+ffff800000100868:	48 8b 54 24 30       	mov    0x30(%rsp),%rdx
+ffff80000010086d:	48 8d 42 08          	lea    0x8(%rdx),%rax
+ffff800000100871:	48 89 44 24 30       	mov    %rax,0x30(%rsp)
+ffff800000100876:	e9 68 ff ff ff       	jmpq   ffff8000001007e3 <printf+0x3f3>
+ffff80000010087b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+ffff800000100880:	8b 44 24 28          	mov    0x28(%rsp),%eax
+ffff800000100884:	83 f8 2f             	cmp    $0x2f,%eax
+ffff800000100887:	0f 87 b3 00 00 00    	ja     ffff800000100940 <printf+0x550>
+ffff80000010088d:	89 c2                	mov    %eax,%edx
+ffff80000010088f:	83 c0 08             	add    $0x8,%eax
+ffff800000100892:	48 03 54 24 38       	add    0x38(%rsp),%rdx
+ffff800000100897:	89 44 24 28          	mov    %eax,0x28(%rsp)
+ffff80000010089b:	0f be 3a             	movsbl (%rdx),%edi
+ffff80000010089e:	ff d3                	callq  *%rbx
+ffff8000001008a0:	31 c0                	xor    %eax,%eax
+ffff8000001008a2:	e9 21 fc ff ff       	jmpq   ffff8000001004c8 <printf+0xd8>
+ffff8000001008a7:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
+ffff8000001008ae:	00 00 
+ffff8000001008b0:	ba a0 00 00 00       	mov    $0xa0,%edx
+ffff8000001008b5:	be 20 07 00 00       	mov    $0x720,%esi
+ffff8000001008ba:	bf 00 80 0b 00       	mov    $0xb8000,%edi
+ffff8000001008bf:	48 b8 f8 ee ff ff ff 	movabs $0xffffffffffffeef8,%rax
+ffff8000001008c6:	ff ff ff 
+ffff8000001008c9:	43 c7 44 3d 00 00 00 	movl   $0x0,0x0(%r13,%r15,1)
+ffff8000001008d0:	00 00 
+ffff8000001008d2:	4c 01 f8             	add    %r15,%rax
+ffff8000001008d5:	ff d0                	callq  *%rax
+ffff8000001008d7:	43 8b 44 3d 00       	mov    0x0(%r13,%r15,1),%eax
+ffff8000001008dc:	42 8b 2c 3b          	mov    (%rbx,%r15,1),%ebp
+ffff8000001008e0:	e9 e3 fc ff ff       	jmpq   ffff8000001005c8 <printf+0x1d8>
+ffff8000001008e5:	0f 1f 00             	nopl   (%rax)
+ffff8000001008e8:	8b 44 24 28          	mov    0x28(%rsp),%eax
+ffff8000001008ec:	83 f8 2f             	cmp    $0x2f,%eax
+ffff8000001008ef:	77 67                	ja     ffff800000100958 <printf+0x568>
+ffff8000001008f1:	89 c2                	mov    %eax,%edx
+ffff8000001008f3:	83 c0 08             	add    $0x8,%eax
+ffff8000001008f6:	48 03 54 24 38       	add    0x38(%rsp),%rdx
+ffff8000001008fb:	89 44 24 28          	mov    %eax,0x28(%rsp)
+ffff8000001008ff:	4c 8b 2a             	mov    (%rdx),%r13
+ffff800000100902:	4d 85 ed             	test   %r13,%r13
+ffff800000100905:	74 69                	je     ffff800000100970 <printf+0x580>
+ffff800000100907:	41 0f b6 45 00       	movzbl 0x0(%r13),%eax
+ffff80000010090c:	84 c0                	test   %al,%al
+ffff80000010090e:	0f 84 b4 fb ff ff    	je     ffff8000001004c8 <printf+0xd8>
+ffff800000100914:	49 89 ee             	mov    %rbp,%r14
+ffff800000100917:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
+ffff80000010091e:	00 00 
+ffff800000100920:	0f be f8             	movsbl %al,%edi
+ffff800000100923:	49 83 c6 01          	add    $0x1,%r14
+ffff800000100927:	ff d3                	callq  *%rbx
+ffff800000100929:	4c 89 e8             	mov    %r13,%rax
+ffff80000010092c:	48 29 e8             	sub    %rbp,%rax
+ffff80000010092f:	42 0f b6 04 30       	movzbl (%rax,%r14,1),%eax
+ffff800000100934:	84 c0                	test   %al,%al
+ffff800000100936:	75 e8                	jne    ffff800000100920 <printf+0x530>
+ffff800000100938:	4c 89 f5             	mov    %r14,%rbp
+ffff80000010093b:	e9 88 fb ff ff       	jmpq   ffff8000001004c8 <printf+0xd8>
+ffff800000100940:	48 8b 54 24 30       	mov    0x30(%rsp),%rdx
+ffff800000100945:	48 8d 42 08          	lea    0x8(%rdx),%rax
+ffff800000100949:	48 89 44 24 30       	mov    %rax,0x30(%rsp)
+ffff80000010094e:	e9 48 ff ff ff       	jmpq   ffff80000010089b <printf+0x4ab>
+ffff800000100953:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+ffff800000100958:	48 8b 54 24 30       	mov    0x30(%rsp),%rdx
+ffff80000010095d:	48 8d 42 08          	lea    0x8(%rdx),%rax
+ffff800000100961:	48 89 44 24 30       	mov    %rax,0x30(%rsp)
+ffff800000100966:	eb 97                	jmp    ffff8000001008ff <printf+0x50f>
+ffff800000100968:	0f 1f 84 00 00 00 00 	nopl   0x0(%rax,%rax,1)
+ffff80000010096f:	00 
+ffff800000100970:	48 8b 44 24 18       	mov    0x18(%rsp),%rax
+ffff800000100975:	4d 8d 2c 07          	lea    (%r15,%rax,1),%r13
+ffff800000100979:	b8 28 00 00 00       	mov    $0x28,%eax
+ffff80000010097e:	eb 94                	jmp    ffff800000100914 <printf+0x524>
+ffff800000100980:	48 b8 f8 eb ff ff ff 	movabs $0xffffffffffffebf8,%rax
+ffff800000100987:	ff ff ff 
+ffff80000010098a:	4c 01 f8             	add    %r15,%rax
+ffff80000010098d:	ff d0                	callq  *%rax
+ffff80000010098f:	90                   	nop
+
+ffff800000100990 <printint>:
+ffff800000100990:	49 bb e8 15 00 00 00 	movabs $0x15e8,%r11
+ffff800000100997:	00 00 00 
+ffff80000010099a:	41 57                	push   %r15
+ffff80000010099c:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff800000100990 <printint>
+ffff8000001009a3:	41 55                	push   %r13
+ffff8000001009a5:	4d 01 df             	add    %r11,%r15
+ffff8000001009a8:	41 54                	push   %r12
+ffff8000001009aa:	55                   	push   %rbp
+ffff8000001009ab:	53                   	push   %rbx
+ffff8000001009ac:	48 83 ec 30          	sub    $0x30,%rsp
+ffff8000001009b0:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
+ffff8000001009b7:	00 00 
+ffff8000001009b9:	48 89 44 24 28       	mov    %rax,0x28(%rsp)
+ffff8000001009be:	31 c0                	xor    %eax,%eax
+ffff8000001009c0:	48 85 ff             	test   %rdi,%rdi
+ffff8000001009c3:	0f 89 b7 00 00 00    	jns    ffff800000100a80 <printint+0xf0>
+ffff8000001009c9:	85 d2                	test   %edx,%edx
+ffff8000001009cb:	0f 84 af 00 00 00    	je     ffff800000100a80 <printint+0xf0>
+ffff8000001009d1:	48 f7 df             	neg    %rdi
+ffff8000001009d4:	41 bb 01 00 00 00    	mov    $0x1,%r11d
+ffff8000001009da:	49 89 e1             	mov    %rsp,%r9
+ffff8000001009dd:	48 63 f6             	movslq %esi,%rsi
+ffff8000001009e0:	31 ed                	xor    %ebp,%ebp
+ffff8000001009e2:	49 ba 38 00 00 00 00 	movabs $0x38,%r10
+ffff8000001009e9:	00 00 00 
+ffff8000001009ec:	4c 89 c9             	mov    %r9,%rcx
+ffff8000001009ef:	4d 01 fa             	add    %r15,%r10
+ffff8000001009f2:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
+ffff8000001009f8:	48 89 f8             	mov    %rdi,%rax
+ffff8000001009fb:	31 d2                	xor    %edx,%edx
+ffff8000001009fd:	4c 63 c5             	movslq %ebp,%r8
+ffff800000100a00:	48 83 c1 01          	add    $0x1,%rcx
+ffff800000100a04:	48 f7 f6             	div    %rsi
+ffff800000100a07:	83 c5 01             	add    $0x1,%ebp
+ffff800000100a0a:	41 0f b6 14 12       	movzbl (%r10,%rdx,1),%edx
+ffff800000100a0f:	88 51 ff             	mov    %dl,-0x1(%rcx)
+ffff800000100a12:	48 89 fa             	mov    %rdi,%rdx
+ffff800000100a15:	48 89 c7             	mov    %rax,%rdi
+ffff800000100a18:	48 39 f2             	cmp    %rsi,%rdx
+ffff800000100a1b:	73 db                	jae    ffff8000001009f8 <printint+0x68>
+ffff800000100a1d:	45 85 db             	test   %r11d,%r11d
+ffff800000100a20:	74 10                	je     ffff800000100a32 <printint+0xa2>
+ffff800000100a22:	48 63 d5             	movslq %ebp,%rdx
+ffff800000100a25:	41 8d 40 02          	lea    0x2(%r8),%eax
+ffff800000100a29:	4c 63 c5             	movslq %ebp,%r8
+ffff800000100a2c:	c6 04 14 2d          	movb   $0x2d,(%rsp,%rdx,1)
+ffff800000100a30:	89 c5                	mov    %eax,%ebp
+ffff800000100a32:	4f 8d 6c 01 ff       	lea    -0x1(%r9,%r8,1),%r13
+ffff800000100a37:	4b 8d 1c 01          	lea    (%r9,%r8,1),%rbx
+ffff800000100a3b:	49 bc 76 e3 ff ff ff 	movabs $0xffffffffffffe376,%r12
+ffff800000100a42:	ff ff ff 
+ffff800000100a45:	4d 29 c5             	sub    %r8,%r13
+ffff800000100a48:	4d 01 fc             	add    %r15,%r12
+ffff800000100a4b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+ffff800000100a50:	0f be 3b             	movsbl (%rbx),%edi
+ffff800000100a53:	48 83 eb 01          	sub    $0x1,%rbx
+ffff800000100a57:	41 ff d4             	callq  *%r12
+ffff800000100a5a:	4c 39 eb             	cmp    %r13,%rbx
+ffff800000100a5d:	75 f1                	jne    ffff800000100a50 <printint+0xc0>
+ffff800000100a5f:	48 63 c5             	movslq %ebp,%rax
+ffff800000100a62:	48 8b 4c 24 28       	mov    0x28(%rsp),%rcx
+ffff800000100a67:	64 48 2b 0c 25 28 00 	sub    %fs:0x28,%rcx
+ffff800000100a6e:	00 00 
+ffff800000100a70:	75 16                	jne    ffff800000100a88 <printint+0xf8>
+ffff800000100a72:	48 83 c4 30          	add    $0x30,%rsp
+ffff800000100a76:	5b                   	pop    %rbx
+ffff800000100a77:	5d                   	pop    %rbp
+ffff800000100a78:	41 5c                	pop    %r12
+ffff800000100a7a:	41 5d                	pop    %r13
+ffff800000100a7c:	41 5f                	pop    %r15
+ffff800000100a7e:	c3                   	retq   
+ffff800000100a7f:	90                   	nop
+ffff800000100a80:	45 31 db             	xor    %r11d,%r11d
+ffff800000100a83:	e9 52 ff ff ff       	jmpq   ffff8000001009da <printint+0x4a>
+ffff800000100a88:	48 b8 f8 eb ff ff ff 	movabs $0xffffffffffffebf8,%rax
+ffff800000100a8f:	ff ff ff 
+ffff800000100a92:	4c 01 f8             	add    %r15,%rax
+ffff800000100a95:	ff d0                	callq  *%rax
+ffff800000100a97:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
+ffff800000100a9e:	00 00 
+
+ffff800000100aa0 <printptr>:
+ffff800000100aa0:	49 bb d8 14 00 00 00 	movabs $0x14d8,%r11
+ffff800000100aa7:	00 00 00 
+ffff800000100aaa:	41 57                	push   %r15
+ffff800000100aac:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff800000100aa0 <printptr>
+ffff800000100ab3:	41 54                	push   %r12
+ffff800000100ab5:	4d 01 df             	add    %r11,%r15
+ffff800000100ab8:	41 bc 3c 00 00 00    	mov    $0x3c,%r12d
+ffff800000100abe:	55                   	push   %rbp
+ffff800000100abf:	48 bd 76 e3 ff ff ff 	movabs $0xffffffffffffe376,%rbp
+ffff800000100ac6:	ff ff ff 
+ffff800000100ac9:	53                   	push   %rbx
+ffff800000100aca:	4c 01 fd             	add    %r15,%rbp
+ffff800000100acd:	48 89 fb             	mov    %rdi,%rbx
+ffff800000100ad0:	48 83 ec 08          	sub    $0x8,%rsp
+ffff800000100ad4:	eb 1d                	jmp    ffff800000100af3 <printptr+0x53>
+ffff800000100ad6:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
+ffff800000100add:	00 00 00 
+ffff800000100ae0:	83 c7 57             	add    $0x57,%edi
+ffff800000100ae3:	41 83 ec 04          	sub    $0x4,%r12d
+ffff800000100ae7:	40 0f b6 ff          	movzbl %dil,%edi
+ffff800000100aeb:	ff d5                	callq  *%rbp
+ffff800000100aed:	41 83 fc fc          	cmp    $0xfffffffc,%r12d
+ffff800000100af1:	74 25                	je     ffff800000100b18 <printptr+0x78>
+ffff800000100af3:	48 89 df             	mov    %rbx,%rdi
+ffff800000100af6:	44 89 e1             	mov    %r12d,%ecx
+ffff800000100af9:	48 d3 ef             	shr    %cl,%rdi
+ffff800000100afc:	83 e7 0f             	and    $0xf,%edi
+ffff800000100aff:	40 80 ff 09          	cmp    $0x9,%dil
+ffff800000100b03:	7f db                	jg     ffff800000100ae0 <printptr+0x40>
+ffff800000100b05:	83 c7 30             	add    $0x30,%edi
+ffff800000100b08:	41 83 ec 04          	sub    $0x4,%r12d
+ffff800000100b0c:	40 0f b6 ff          	movzbl %dil,%edi
+ffff800000100b10:	ff d5                	callq  *%rbp
+ffff800000100b12:	41 83 fc fc          	cmp    $0xfffffffc,%r12d
+ffff800000100b16:	75 db                	jne    ffff800000100af3 <printptr+0x53>
+ffff800000100b18:	48 83 c4 08          	add    $0x8,%rsp
+ffff800000100b1c:	b8 10 00 00 00       	mov    $0x10,%eax
+ffff800000100b21:	5b                   	pop    %rbx
+ffff800000100b22:	5d                   	pop    %rbp
+ffff800000100b23:	41 5c                	pop    %r12
+ffff800000100b25:	41 5f                	pop    %r15
+ffff800000100b27:	c3                   	retq   
+ffff800000100b28:	0f 1f 84 00 00 00 00 	nopl   0x0(%rax,%rax,1)
+ffff800000100b2f:	00 
+
+ffff800000100b30 <clear_line>:
+ffff800000100b30:	8d 3c bf             	lea    (%rdi,%rdi,4),%edi
+ffff800000100b33:	41 57                	push   %r15
+ffff800000100b35:	ba a0 00 00 00       	mov    $0xa0,%edx
+ffff800000100b3a:	be 20 07 00 00       	mov    $0x720,%esi
+ffff800000100b3f:	4c 8d 3d ea ff ff ff 	lea    -0x16(%rip),%r15        # ffff800000100b30 <clear_line>
+ffff800000100b46:	c1 e7 05             	shl    $0x5,%edi
+ffff800000100b49:	49 bb 48 14 00 00 00 	movabs $0x1448,%r11
+ffff800000100b50:	00 00 00 
+ffff800000100b53:	48 b8 f8 ee ff ff ff 	movabs $0xffffffffffffeef8,%rax
+ffff800000100b5a:	ff ff ff 
+ffff800000100b5d:	4d 01 df             	add    %r11,%r15
+ffff800000100b60:	81 c7 00 80 0b 00    	add    $0xb8000,%edi
+ffff800000100b66:	4c 01 f8             	add    %r15,%rax
+ffff800000100b69:	48 63 ff             	movslq %edi,%rdi
+ffff800000100b6c:	41 5f                	pop    %r15
+ffff800000100b6e:	ff e0                	jmpq   *%rax
+
+ffff800000100b70 <__stack_chk_fail>:
+ffff800000100b70:	48 8d 3d d9 13 00 00 	lea    0x13d9(%rip),%rdi        # ffff800000101f50 <stackfail_msg>
+ffff800000100b77:	e8 04 00 00 00       	callq  ffff800000100b80 <panic>
+ffff800000100b7c:	0f 1f 40 00          	nopl   0x0(%rax)
+
+ffff800000100b80 <panic>:
+ffff800000100b80:	49 bb f8 13 00 00 00 	movabs $0x13f8,%r11
+ffff800000100b87:	00 00 00 
+ffff800000100b8a:	41 57                	push   %r15
+ffff800000100b8c:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff800000100b80 <panic>
+ffff800000100b93:	55                   	push   %rbp
+ffff800000100b94:	4d 01 df             	add    %r11,%r15
+ffff800000100b97:	48 89 fd             	mov    %rdi,%rbp
+ffff800000100b9a:	53                   	push   %rbx
+ffff800000100b9b:	48 89 c6             	mov    %rax,%rsi
+ffff800000100b9e:	48 89 ca             	mov    %rcx,%rdx
+ffff800000100ba1:	48 89 d1             	mov    %rdx,%rcx
+ffff800000100ba4:	48 b8 33 01 00 00 00 	movabs $0x133,%rax
+ffff800000100bab:	00 00 00 
+ffff800000100bae:	48 bb 78 e4 ff ff ff 	movabs $0xffffffffffffe478,%rbx
+ffff800000100bb5:	ff ff ff 
+ffff800000100bb8:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100bbc:	4c 01 fb             	add    %r15,%rbx
+ffff800000100bbf:	31 c0                	xor    %eax,%eax
+ffff800000100bc1:	ff d3                	callq  *%rbx
+ffff800000100bc3:	48 89 de             	mov    %rbx,%rsi
+ffff800000100bc6:	48 89 e2             	mov    %rsp,%rdx
+ffff800000100bc9:	48 89 e9             	mov    %rbp,%rcx
+ffff800000100bcc:	48 b8 4e 01 00 00 00 	movabs $0x14e,%rax
+ffff800000100bd3:	00 00 00 
+ffff800000100bd6:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100bda:	31 c0                	xor    %eax,%eax
+ffff800000100bdc:	ff d3                	callq  *%rbx
+ffff800000100bde:	48 89 f6             	mov    %rsi,%rsi
+ffff800000100be1:	48 89 fa             	mov    %rdi,%rdx
+ffff800000100be4:	4c 89 c1             	mov    %r8,%rcx
+ffff800000100be7:	48 b8 69 01 00 00 00 	movabs $0x169,%rax
+ffff800000100bee:	00 00 00 
+ffff800000100bf1:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100bf5:	31 c0                	xor    %eax,%eax
+ffff800000100bf7:	ff d3                	callq  *%rbx
+ffff800000100bf9:	4c 89 ce             	mov    %r9,%rsi
+ffff800000100bfc:	4c 89 d2             	mov    %r10,%rdx
+ffff800000100bff:	4c 89 d9             	mov    %r11,%rcx
+ffff800000100c02:	48 b8 84 01 00 00 00 	movabs $0x184,%rax
+ffff800000100c09:	00 00 00 
+ffff800000100c0c:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100c10:	31 c0                	xor    %eax,%eax
+ffff800000100c12:	ff d3                	callq  *%rbx
+ffff800000100c14:	4c 89 e6             	mov    %r12,%rsi
+ffff800000100c17:	4c 89 ea             	mov    %r13,%rdx
+ffff800000100c1a:	4c 89 f1             	mov    %r14,%rcx
+ffff800000100c1d:	48 b8 9f 01 00 00 00 	movabs $0x19f,%rax
+ffff800000100c24:	00 00 00 
+ffff800000100c27:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100c2b:	31 c0                	xor    %eax,%eax
+ffff800000100c2d:	ff d3                	callq  *%rbx
+ffff800000100c2f:	4c 89 fe             	mov    %r15,%rsi
+ffff800000100c32:	48 b8 ba 01 00 00 00 	movabs $0x1ba,%rax
+ffff800000100c39:	00 00 00 
+ffff800000100c3c:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100c40:	31 c0                	xor    %eax,%eax
+ffff800000100c42:	ff d3                	callq  *%rbx
+ffff800000100c44:	48 89 ee             	mov    %rbp,%rsi
+ffff800000100c47:	48 b8 c3 01 00 00 00 	movabs $0x1c3,%rax
+ffff800000100c4e:	00 00 00 
+ffff800000100c51:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100c55:	31 c0                	xor    %eax,%eax
+ffff800000100c57:	ff d3                	callq  *%rbx
+ffff800000100c59:	eb fe                	jmp    ffff800000100c59 <panic+0xd9>
+ffff800000100c5b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
+
+ffff800000100c60 <mem_init>:
+ffff800000100c60:	41 57                	push   %r15
+ffff800000100c62:	4c 8d 3d f7 ff ff ff 	lea    -0x9(%rip),%r15        # ffff800000100c60 <mem_init>
+ffff800000100c69:	45 31 c0             	xor    %r8d,%r8d
+ffff800000100c6c:	31 d2                	xor    %edx,%edx
+ffff800000100c6e:	49 bb 18 13 00 00 00 	movabs $0x1318,%r11
+ffff800000100c75:	00 00 00 
+ffff800000100c78:	41 55                	push   %r13
+ffff800000100c7a:	b8 00 60 00 00       	mov    $0x6000,%eax
+ffff800000100c7f:	41 54                	push   %r12
+ffff800000100c81:	4d 01 df             	add    %r11,%r15
+ffff800000100c84:	55                   	push   %rbp
+ffff800000100c85:	53                   	push   %rbx
+ffff800000100c86:	48 bb 08 05 00 00 00 	movabs $0x508,%rbx
+ffff800000100c8d:	00 00 00 
+ffff800000100c90:	4a 8b 34 3b          	mov    (%rbx,%r15,1),%rsi
+ffff800000100c94:	49 89 f1             	mov    %rsi,%r9
+ffff800000100c97:	8b 48 10             	mov    0x10(%rax),%ecx
+ffff800000100c9a:	8d 79 ff             	lea    -0x1(%rcx),%edi
+ffff800000100c9d:	83 ff 03             	cmp    $0x3,%edi
+ffff800000100ca0:	0f 86 da 00 00 00    	jbe    ffff800000100d80 <mem_init+0x120>
+ffff800000100ca6:	45 84 c0             	test   %r8b,%r8b
+ffff800000100ca9:	0f 85 01 01 00 00    	jne    ffff800000100db0 <mem_init+0x150>
+ffff800000100caf:	48 63 ea             	movslq %edx,%rbp
+ffff800000100cb2:	48 b8 a0 00 00 00 00 	movabs $0xa0,%rax
+ffff800000100cb9:	00 00 00 
+ffff800000100cbc:	48 c1 ee 14          	shr    $0x14,%rsi
+ffff800000100cc0:	49 bc 78 e4 ff ff ff 	movabs $0xffffffffffffe478,%r12
+ffff800000100cc7:	ff ff ff 
+ffff800000100cca:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100cce:	4d 01 fc             	add    %r15,%r12
+ffff800000100cd1:	31 c0                	xor    %eax,%eax
+ffff800000100cd3:	41 ff d4             	callq  *%r12
+ffff800000100cd6:	4a 8b 14 3b          	mov    (%rbx,%r15,1),%rdx
+ffff800000100cda:	31 f6                	xor    %esi,%esi
+ffff800000100cdc:	48 89 d0             	mov    %rdx,%rax
+ffff800000100cdf:	48 c1 ea 18          	shr    $0x18,%rdx
+ffff800000100ce3:	48 c1 e8 15          	shr    $0x15,%rax
+ffff800000100ce7:	4a 89 44 3b 08       	mov    %rax,0x8(%rbx,%r15,1)
+ffff800000100cec:	48 b8 f8 ff ff ff ff 	movabs $0xfffffffffffffff8,%rax
+ffff800000100cf3:	ff ff ff 
+ffff800000100cf6:	4d 8b 2c 07          	mov    (%r15,%rax,1),%r13
+ffff800000100cfa:	48 b8 e8 ee ff ff ff 	movabs $0xffffffffffffeee8,%rax
+ffff800000100d01:	ff ff ff 
+ffff800000100d04:	4c 01 f8             	add    %r15,%rax
+ffff800000100d07:	4c 89 ef             	mov    %r13,%rdi
+ffff800000100d0a:	48 81 e7 00 f0 ff ff 	and    $0xfffffffffffff000,%rdi
+ffff800000100d11:	4a 89 7c 3b 28       	mov    %rdi,0x28(%rbx,%r15,1)
+ffff800000100d16:	ff d0                	callq  *%rax
+ffff800000100d18:	4a 8b 4c 3b 28       	mov    0x28(%rbx,%r15,1),%rcx
+ffff800000100d1d:	4a 8b 74 3b 08       	mov    0x8(%rbx,%r15,1),%rsi
+ffff800000100d22:	4c 89 ea             	mov    %r13,%rdx
+ffff800000100d25:	48 b8 d8 00 00 00 00 	movabs $0xd8,%rax
+ffff800000100d2c:	00 00 00 
+ffff800000100d2f:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100d33:	31 c0                	xor    %eax,%eax
+ffff800000100d35:	41 ff d4             	callq  *%r12
+ffff800000100d38:	4a 8b 44 3b 08       	mov    0x8(%rbx,%r15,1),%rax
+ffff800000100d3d:	4a 89 6c 3b 20       	mov    %rbp,0x20(%rbx,%r15,1)
+ffff800000100d42:	31 f6                	xor    %esi,%esi
+ffff800000100d44:	4a c7 44 3b 18 00 60 	movq   $0x6000,0x18(%rbx,%r15,1)
+ffff800000100d4b:	00 00 
+ffff800000100d4d:	4a 8b 7c 3b 28       	mov    0x28(%rbx,%r15,1),%rdi
+ffff800000100d52:	ba 01 00 00 00       	mov    $0x1,%edx
+ffff800000100d57:	48 83 e8 01          	sub    $0x1,%rax
+ffff800000100d5b:	4a 89 44 3b 10       	mov    %rax,0x10(%rbx,%r15,1)
+ffff800000100d60:	48 b8 58 e2 ff ff ff 	movabs $0xffffffffffffe258,%rax
+ffff800000100d67:	ff ff ff 
+ffff800000100d6a:	4c 01 f8             	add    %r15,%rax
+ffff800000100d6d:	ff d0                	callq  *%rax
+ffff800000100d6f:	5b                   	pop    %rbx
+ffff800000100d70:	31 c0                	xor    %eax,%eax
+ffff800000100d72:	5d                   	pop    %rbp
+ffff800000100d73:	41 5c                	pop    %r12
+ffff800000100d75:	41 5d                	pop    %r13
+ffff800000100d77:	41 5f                	pop    %r15
+ffff800000100d79:	c3                   	retq   
+ffff800000100d7a:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
+ffff800000100d80:	83 f9 01             	cmp    $0x1,%ecx
+ffff800000100d83:	75 0a                	jne    ffff800000100d8f <mem_init+0x12f>
+ffff800000100d85:	4c 03 48 08          	add    0x8(%rax),%r9
+ffff800000100d89:	41 b8 01 00 00 00    	mov    $0x1,%r8d
+ffff800000100d8f:	83 c2 01             	add    $0x1,%edx
+ffff800000100d92:	48 83 c0 14          	add    $0x14,%rax
+ffff800000100d96:	83 fa 20             	cmp    $0x20,%edx
+ffff800000100d99:	0f 85 f8 fe ff ff    	jne    ffff800000100c97 <mem_init+0x37>
+ffff800000100d9f:	45 84 c0             	test   %r8b,%r8b
+ffff800000100da2:	75 18                	jne    ffff800000100dbc <mem_init+0x15c>
+ffff800000100da4:	bd 20 00 00 00       	mov    $0x20,%ebp
+ffff800000100da9:	e9 04 ff ff ff       	jmpq   ffff800000100cb2 <mem_init+0x52>
+ffff800000100dae:	66 90                	xchg   %ax,%ax
+ffff800000100db0:	4e 89 0c 3b          	mov    %r9,(%rbx,%r15,1)
+ffff800000100db4:	4c 89 ce             	mov    %r9,%rsi
+ffff800000100db7:	e9 f3 fe ff ff       	jmpq   ffff800000100caf <mem_init+0x4f>
+ffff800000100dbc:	4e 89 0c 3b          	mov    %r9,(%rbx,%r15,1)
+ffff800000100dc0:	4c 89 ce             	mov    %r9,%rsi
+ffff800000100dc3:	eb df                	jmp    ffff800000100da4 <mem_init+0x144>
+ffff800000100dc5:	66 66 2e 0f 1f 84 00 	data16 nopw %cs:0x0(%rax,%rax,1)
+ffff800000100dcc:	00 00 00 00 
+
+ffff800000100dd0 <palloc>:
+ffff800000100dd0:	49 bb a8 11 00 00 00 	movabs $0x11a8,%r11
+ffff800000100dd7:	00 00 00 
+ffff800000100dda:	41 57                	push   %r15
+ffff800000100ddc:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff800000100dd0 <palloc>
+ffff800000100de3:	48 b8 30 05 00 00 00 	movabs $0x530,%rax
+ffff800000100dea:	00 00 00 
+ffff800000100ded:	4d 01 df             	add    %r11,%r15
+ffff800000100df0:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100df4:	48 b8 a8 e2 ff ff ff 	movabs $0xffffffffffffe2a8,%rax
+ffff800000100dfb:	ff ff ff 
+ffff800000100dfe:	4c 01 f8             	add    %r15,%rax
+ffff800000100e01:	ff d0                	callq  *%rax
+ffff800000100e03:	41 5f                	pop    %r15
+ffff800000100e05:	89 c0                	mov    %eax,%eax
+ffff800000100e07:	48 c1 e0 15          	shl    $0x15,%rax
+ffff800000100e0b:	c3                   	retq   
+ffff800000100e0c:	0f 1f 40 00          	nopl   0x0(%rax)
+
+ffff800000100e10 <pfree>:
+ffff800000100e10:	49 bb 68 11 00 00 00 	movabs $0x1168,%r11
+ffff800000100e17:	00 00 00 
+ffff800000100e1a:	41 57                	push   %r15
+ffff800000100e1c:	4c 8d 3d ed ff ff ff 	lea    -0x13(%rip),%r15        # ffff800000100e10 <pfree>
+ffff800000100e23:	48 89 fe             	mov    %rdi,%rsi
+ffff800000100e26:	4d 01 df             	add    %r11,%r15
+ffff800000100e29:	48 c1 ee 15          	shr    $0x15,%rsi
+ffff800000100e2d:	48 b8 30 05 00 00 00 	movabs $0x530,%rax
+ffff800000100e34:	00 00 00 
+ffff800000100e37:	49 8d 3c 07          	lea    (%r15,%rax,1),%rdi
+ffff800000100e3b:	48 b8 28 e3 ff ff ff 	movabs $0xffffffffffffe328,%rax
+ffff800000100e42:	ff ff ff 
+ffff800000100e45:	4c 01 f8             	add    %r15,%rax
+ffff800000100e48:	41 5f                	pop    %r15
+ffff800000100e4a:	ff e0                	jmpq   *%rax
+ffff800000100e4c:	0f 1f 40 00          	nopl   0x0(%rax)
+
+ffff800000100e50 <memcpy>:
+ffff800000100e50:	48 89 f8             	mov    %rdi,%rax
+ffff800000100e53:	48 89 d1             	mov    %rdx,%rcx
+ffff800000100e56:	fc                   	cld    
+ffff800000100e57:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi)
+ffff800000100e59:	c3                   	retq   
+ffff800000100e5a:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
+
+ffff800000100e60 <memset>:
+ffff800000100e60:	48 89 d1             	mov    %rdx,%rcx
+ffff800000100e63:	89 f0                	mov    %esi,%eax
+ffff800000100e65:	fc                   	cld    
+ffff800000100e66:	f3 aa                	rep stos %al,%es:(%rdi)
+ffff800000100e68:	48 89 f8             	mov    %rdi,%rax
+ffff800000100e6b:	c3                   	retq   
+ffff800000100e6c:	0f 1f 40 00          	nopl   0x0(%rax)
+
+ffff800000100e70 <memsetw>:
+ffff800000100e70:	48 89 d1             	mov    %rdx,%rcx
+ffff800000100e73:	89 f0                	mov    %esi,%eax
+ffff800000100e75:	48 d1 e9             	shr    %rcx
+ffff800000100e78:	fc                   	cld    
+ffff800000100e79:	66 f3 ab             	rep stos %ax,%es:(%rdi)
+ffff800000100e7c:	48 89 f8             	mov    %rdi,%rax
+ffff800000100e7f:	c3                   	retq   
+
+ffff800000100e80 <memsetl>:
+ffff800000100e80:	48 89 d1             	mov    %rdx,%rcx
+ffff800000100e83:	89 f0                	mov    %esi,%eax
+ffff800000100e85:	48 c1 e9 02          	shr    $0x2,%rcx
+ffff800000100e89:	fc                   	cld    
+ffff800000100e8a:	f3 ab                	rep stos %eax,%es:(%rdi)
+ffff800000100e8c:	48 89 f8             	mov    %rdi,%rax
+ffff800000100e8f:	c3                   	retq   
+
+ffff800000100e90 <memsetq>:
+ffff800000100e90:	48 89 d1             	mov    %rdx,%rcx
+ffff800000100e93:	48 89 f0             	mov    %rsi,%rax
+ffff800000100e96:	48 c1 e9 03          	shr    $0x3,%rcx
+ffff800000100e9a:	fc                   	cld    
+ffff800000100e9b:	f3 48 ab             	rep stos %rax,%es:(%rdi)
+ffff800000100e9e:	48 89 f8             	mov    %rdi,%rax
+ffff800000100ea1:	c3                   	retq   
+
+Disassembly of section .data:
+
+ffff800000100ea8 <_data>:
+	...
+ffff800000100eb4:	00 98 20 00 00 00    	add    %bl,0x20(%rax)
+ffff800000100eba:	00 00                	add    %al,(%rax)
+ffff800000100ebc:	00 92 00 00 00 00    	add    %dl,0x0(%rdx)
+ffff800000100ec2:	00 00                	add    %al,(%rax)
+ffff800000100ec4:	00 f8                	add    %bh,%al
+ffff800000100ec6:	20 00                	and    %al,(%rax)
+ffff800000100ec8:	00 00                	add    %al,(%rax)
+ffff800000100eca:	00 00                	add    %al,(%rax)
+ffff800000100ecc:	00 f2                	add    %dh,%dl
+ffff800000100ece:	00 00                	add    %al,(%rax)
+ffff800000100ed0:	ff                   	(bad)  
+ffff800000100ed1:	ff 00                	incl   (%rax)
+ffff800000100ed3:	00 00                	add    %al,(%rax)
+ffff800000100ed5:	9a                   	(bad)  
+ffff800000100ed6:	cf                   	iret   
+ffff800000100ed7:	00 ff                	add    %bh,%bh
+ffff800000100ed9:	ff 00                	incl   (%rax)
+ffff800000100edb:	00 00                	add    %al,(%rax)
+ffff800000100edd:	92                   	xchg   %eax,%edx
+ffff800000100ede:	cf                   	iret   
+	...
+
+ffff800000100f30 <end_gdt>:
+ffff800000100f30:	88 00                	mov    %al,(%rax)
+ffff800000100f32:	a8 0e                	test   $0xe,%al
+ffff800000100f34:	10 00                	adc    %al,(%rax)
+ffff800000100f36:	00 80 ff ff      	add    %al,0xffff(%rax)
+
+ffff800000100f3a <idt_table>:
+	...
+
+ffff800000101f3a <end_idt>:
+ffff800000101f3a:	00 10                	add    %dl,(%rax)
+ffff800000101f3c:	3a 0f                	cmp    (%rdi),%cl
+ffff800000101f3e:	10 00                	adc    %al,(%rax)
+ffff800000101f40:	00 80 ff ff 00 00    	add    %al,0xffff(%rax)
+	...
+
+ffff800000101f48 <framebuffer>:
+ffff800000101f48:	00 80 0b 00 00 00    	add    %al,0xb(%rax)
+	...
+
+ffff800000101f50 <stackfail_msg>:
+ffff800000101f50:	73 74                	jae    ffff800000101fc6 <.erodata+0x5>
+ffff800000101f52:	61                   	(bad)  
+ffff800000101f53:	63 6b 20             	movsxd 0x20(%rbx),%ebp
+ffff800000101f56:	63 68 65             	movsxd 0x65(%rax),%ebp
+ffff800000101f59:	63 6b 20             	movsxd 0x20(%rbx),%ebp
+ffff800000101f5c:	66 61                	data16 (bad) 
+ffff800000101f5e:	69                   	.byte 0x69
+ffff800000101f5f:	6c                   	insb   (%dx),%es:(%rdi)
+ffff800000101f60:	65                   	gs
+ffff800000101f61:	64                   	fs
+	...
+
+Disassembly of section .got:
+
+ffff800000101f68 <.got>:
+ffff800000101f68:	48 1f                	rex.W (bad) 
+ffff800000101f6a:	10 00                	adc    %al,(%rax)
+ffff800000101f6c:	00 80 ff ff b8 24    	add    %al,0x24b8ffff(%rax)
+ffff800000101f72:	10 00                	adc    %al,(%rax)
+ffff800000101f74:	00                   	.byte 0x0
+ffff800000101f75:	80 ff ff             	cmp    $0xff,%bh
+
+Disassembly of section .got.plt:
+
+ffff800000101f78 <_GLOBAL_OFFSET_TABLE_>:
+	...
+
+Disassembly of section .rodata:
+
+ffff800000101f90 <_rodata>:
+ffff800000101f90:	75 6e                	jne    ffff800000102000 <.erodata+0x3f>
+ffff800000101f92:	6b 6e 6f 77          	imul   $0x77,0x6f(%rsi),%ebp
+ffff800000101f96:	20 69 6e             	and    %ch,0x6e(%rcx)
+ffff800000101f99:	74 65                	je     ffff800000102000 <.erodata+0x3f>
+ffff800000101f9b:	72 72                	jb     ffff80000010200f <.erodata+0x4e>
+ffff800000101f9d:	75 70                	jne    ffff80000010200f <.erodata+0x4e>
+ffff800000101f9f:	74 20                	je     ffff800000101fc1 <.erodata>
+ffff800000101fa1:	6f                   	outsl  %ds:(%rsi),(%dx)
+ffff800000101fa2:	72 20                	jb     ffff800000101fc4 <.erodata+0x3>
+ffff800000101fa4:	66 61                	data16 (bad) 
+ffff800000101fa6:	75 6c                	jne    ffff800000102014 <.erodata+0x53>
+ffff800000101fa8:	74 00                	je     ffff800000101faa <_rodata+0x1a>
+ffff800000101faa:	00 00                	add    %al,(%rax)
+ffff800000101fac:	00 00                	add    %al,(%rax)
+	...
+
+ffff800000101fb0 <digits>:
+ffff800000101fb0:	30 31                	xor    %dh,(%rcx)
+ffff800000101fb2:	32 33                	xor    (%rbx),%dh
+ffff800000101fb4:	34 35                	xor    $0x35,%al
+ffff800000101fb6:	36 37                	ss (bad) 
+ffff800000101fb8:	38 39                	cmp    %bh,(%rcx)
+ffff800000101fba:	61                   	(bad)  
+ffff800000101fbb:	62 63 64 65 66       	(bad)
+	...
+
+Disassembly of section .rodata.str1.8:
+
+ffff800000101fc8 <.rodata.str1.8>:
+ffff800000101fc8:	43 75 6e             	rex.XB jne ffff800000102039 <.erodata+0x78>
+ffff800000101fcb:	69 78 20 6b 65 72 6e 	imul   $0x6e72656b,0x20(%rax),%edi
+ffff800000101fd2:	65 6c                	gs insb (%dx),%es:(%rdi)
+ffff800000101fd4:	20 25 64 20 69 73    	and    %ah,0x73692064(%rip)        # ffff80007379403e <_ebss+0x73691b86>
+ffff800000101fda:	20 73 74             	and    %dh,0x74(%rbx)
+ffff800000101fdd:	61                   	(bad)  
+ffff800000101fde:	72 74                	jb     ffff800000102054 <.erodata+0x93>
+ffff800000101fe0:	69 6e 67 2e 2e 2e 0a 	imul   $0xa2e2e2e,0x67(%rsi),%ebp
+ffff800000101fe7:	00 66 72             	add    %ah,0x72(%rsi)
+ffff800000101fea:	65 65 20 66 69       	gs and %ah,%gs:0x69(%rsi)
+ffff800000101fef:	72 73                	jb     ffff800000102064 <.erodata+0xa3>
+ffff800000101ff1:	74 20                	je     ffff800000102013 <.erodata+0x52>
+ffff800000101ff3:	70 61                	jo     ffff800000102056 <.erodata+0x95>
+ffff800000101ff5:	67 65 20 61 6e       	and    %ah,%gs:0x6e(%ecx)
+ffff800000101ffa:	64 20 61 6c          	and    %ah,%fs:0x6c(%rcx)
+ffff800000101ffe:	6c                   	insb   (%dx),%es:(%rdi)
+ffff800000101fff:	6f                   	outsl  %ds:(%rsi),(%dx)
+ffff800000102000:	63 20                	movsxd (%rax),%esp
+ffff800000102002:	6f                   	outsl  %ds:(%rsi),(%dx)
+ffff800000102003:	6e                   	outsb  %ds:(%rsi),(%dx)
+ffff800000102004:	65 20 70 61          	and    %dh,%gs:0x61(%rax)
+ffff800000102008:	67 65 3a 20          	cmp    %gs:(%eax),%ah
+ffff80000010200c:	30 78 25             	xor    %bh,0x25(%rax)
+ffff80000010200f:	70 0a                	jo     ffff80000010201b <.erodata+0x5a>
+ffff800000102011:	00 00                	add    %al,(%rax)
+ffff800000102013:	00 00                	add    %al,(%rax)
+ffff800000102015:	00 00                	add    %al,(%rax)
+ffff800000102017:	00 74 6f 74          	add    %dh,0x74(%rdi,%rbp,2)
+ffff80000010201b:	61                   	(bad)  
+ffff80000010201c:	6c                   	insb   (%dx),%es:(%rdi)
+ffff80000010201d:	20 75 73             	and    %dh,0x73(%rbp)
+ffff800000102020:	61                   	(bad)  
+ffff800000102021:	62                   	(bad)  
+ffff800000102022:	6c                   	insb   (%dx),%es:(%rdi)
+ffff800000102023:	65 20 52 41          	and    %dl,%gs:0x41(%rdx)
+ffff800000102027:	4d 3a 20             	rex.WRB cmp (%r8),%r12b
+ffff80000010202a:	25 64 20 4d 42       	and    $0x424d2064,%eax
+ffff80000010202f:	2c 20                	sub    $0x20,%al
+ffff800000102031:	74 6f                	je     ffff8000001020a2 <.erodata+0xe1>
+ffff800000102033:	74 61                	je     ffff800000102096 <.erodata+0xd5>
+ffff800000102035:	6c                   	insb   (%dx),%es:(%rdi)
+ffff800000102036:	20 45 38             	and    %al,0x38(%rbp)
+ffff800000102039:	32 30                	xor    (%rax),%dh
+ffff80000010203b:	20 65 6e             	and    %ah,0x6e(%rbp)
+ffff80000010203e:	74 72                	je     ffff8000001020b2 <.erodata+0xf1>
+ffff800000102040:	69 65 73 3a 20 25 64 	imul   $0x6425203a,0x73(%rbp),%esp
+ffff800000102047:	0a 00                	or     (%rax),%al
+ffff800000102049:	00 00                	add    %al,(%rax)
+ffff80000010204b:	00 00                	add    %al,(%rax)
+ffff80000010204d:	00 00                	add    %al,(%rax)
+ffff80000010204f:	00 74 6f 74          	add    %dh,0x74(%rdi,%rbp,2)
+ffff800000102053:	61                   	(bad)  
+ffff800000102054:	6c                   	insb   (%dx),%es:(%rdi)
+ffff800000102055:	20 70 61             	and    %dh,0x61(%rax)
+ffff800000102058:	67 65 73 3a          	addr32 gs jae ffff800000102096 <.erodata+0xd5>
+ffff80000010205c:	20 25 64 20 70 61    	and    %ah,0x61702064(%rip)        # ffff8000618040c6 <_ebss+0x61701c0e>
+ffff800000102062:	67 65 73 20          	addr32 gs jae ffff800000102086 <.erodata+0xc5>
+ffff800000102066:	62                   	(bad)  
+ffff800000102067:	69 74 6d 61 70 3a 20 	imul   $0x30203a70,0x61(%rbp,%rbp,2),%esi
+ffff80000010206e:	30 
+ffff80000010206f:	78 25                	js     ffff800000102096 <.erodata+0xd5>
+ffff800000102071:	70 0a                	jo     ffff80000010207d <.erodata+0xbc>
+	...
+
+Disassembly of section .rodata.str1.1:
+
+ffff800000102074 <.rodata.str1.1>:
+ffff800000102074:	61                   	(bad)  
+ffff800000102075:	6c                   	insb   (%dx),%es:(%rdi)
+ffff800000102076:	6c                   	insb   (%dx),%es:(%rdi)
+ffff800000102077:	6f                   	outsl  %ds:(%rsi),(%dx)
+ffff800000102078:	63 20                	movsxd (%rax),%esp
+ffff80000010207a:	6f                   	outsl  %ds:(%rsi),(%dx)
+ffff80000010207b:	6e                   	outsb  %ds:(%rsi),(%dx)
+ffff80000010207c:	65 20 70 61          	and    %dh,%gs:0x61(%rax)
+ffff800000102080:	67 65 3a 20          	cmp    %gs:(%eax),%ah
+ffff800000102084:	30 78 25             	xor    %bh,0x25(%rax)
+ffff800000102087:	70 0a                	jo     ffff800000102093 <.erodata+0xd2>
+ffff800000102089:	00 61 6c             	add    %ah,0x6c(%rcx)
+ffff80000010208c:	6c                   	insb   (%dx),%es:(%rdi)
+ffff80000010208d:	6f                   	outsl  %ds:(%rsi),(%dx)
+ffff80000010208e:	63 20                	movsxd (%rax),%esp
+ffff800000102090:	61                   	(bad)  
+ffff800000102091:	6e                   	outsb  %ds:(%rsi),(%dx)
+ffff800000102092:	6f                   	outsl  %ds:(%rsi),(%dx)
+ffff800000102093:	74 68                	je     ffff8000001020fd <.erodata+0x13c>
+ffff800000102095:	65 72 20             	gs jb  ffff8000001020b8 <.erodata+0xf7>
+ffff800000102098:	70 61                	jo     ffff8000001020fb <.erodata+0x13a>
+ffff80000010209a:	67 65 3a 20          	cmp    %gs:(%eax),%ah
+ffff80000010209e:	30 78 25             	xor    %bh,0x25(%rax)
+ffff8000001020a1:	70 0a                	jo     ffff8000001020ad <.erodata+0xec>
+ffff8000001020a3:	00 28                	add    %ch,(%rax)
+ffff8000001020a5:	6e                   	outsb  %ds:(%rsi),(%dx)
+ffff8000001020a6:	75 6c                	jne    ffff800000102114 <.erodata+0x153>
+ffff8000001020a8:	6c                   	insb   (%dx),%es:(%rdi)
+ffff8000001020a9:	29 00                	sub    %eax,(%rax)
+ffff8000001020ab:	52                   	push   %rdx
+ffff8000001020ac:	41 58                	pop    %r8
+ffff8000001020ae:	3a 20                	cmp    (%rax),%ah
+ffff8000001020b0:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff8000001020b5:	43 58                	rex.XB pop %r8
+ffff8000001020b7:	3a 20                	cmp    (%rax),%ah
+ffff8000001020b9:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff8000001020be:	44 58                	rex.R pop %rax
+ffff8000001020c0:	3a 20                	cmp    (%rax),%ah
+ffff8000001020c2:	25 70 0a 00 52       	and    $0x52000a70,%eax
+ffff8000001020c7:	42 58                	rex.X pop %rax
+ffff8000001020c9:	3a 20                	cmp    (%rax),%ah
+ffff8000001020cb:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff8000001020d0:	53                   	push   %rbx
+ffff8000001020d1:	50                   	push   %rax
+ffff8000001020d2:	3a 20                	cmp    (%rax),%ah
+ffff8000001020d4:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff8000001020d9:	42 50                	rex.X push %rax
+ffff8000001020db:	3a 20                	cmp    (%rax),%ah
+ffff8000001020dd:	25 70 0a 00 52       	and    $0x52000a70,%eax
+ffff8000001020e2:	53                   	push   %rbx
+ffff8000001020e3:	49 3a 20             	rex.WB cmp (%r8),%spl
+ffff8000001020e6:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff8000001020eb:	44                   	rex.R
+ffff8000001020ec:	49 3a 20             	rex.WB cmp (%r8),%spl
+ffff8000001020ef:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff8000001020f4:	38 20                	cmp    %ah,(%rax)
+ffff8000001020f6:	3a 20                	cmp    (%rax),%ah
+ffff8000001020f8:	25 70 0a 00 52       	and    $0x52000a70,%eax
+ffff8000001020fd:	39 3a                	cmp    %edi,(%rdx)
+ffff8000001020ff:	20 25 70 20 20 20    	and    %ah,0x20202070(%rip)        # ffff800020304175 <_ebss+0x20201cbd>
+ffff800000102105:	52                   	push   %rdx
+ffff800000102106:	31 30                	xor    %esi,(%rax)
+ffff800000102108:	3a 20                	cmp    (%rax),%ah
+ffff80000010210a:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff80000010210f:	31 31                	xor    %esi,(%rcx)
+ffff800000102111:	3a 20                	cmp    (%rax),%ah
+ffff800000102113:	25 70 0a 00 52       	and    $0x52000a70,%eax
+ffff800000102118:	31 32                	xor    %esi,(%rdx)
+ffff80000010211a:	3a 20                	cmp    (%rax),%ah
+ffff80000010211c:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff800000102121:	31 33                	xor    %esi,(%rbx)
+ffff800000102123:	3a 20                	cmp    (%rax),%ah
+ffff800000102125:	25 70 20 20 52       	and    $0x52202070,%eax
+ffff80000010212a:	31 34 3a             	xor    %esi,(%rdx,%rdi,1)
+ffff80000010212d:	20 25 70 0a 00 52    	and    %ah,0x52000a70(%rip)        # ffff800052102ba3 <_ebss+0x520006eb>
+ffff800000102133:	31 35 3a 20 25 70    	xor    %esi,0x7025203a(%rip)        # ffff800070354173 <_ebss+0x70251cbb>
+ffff800000102139:	0a 00                	or     (%rax),%al
+ffff80000010213b:	0a 4b 65             	or     0x65(%rbx),%cl
+ffff80000010213e:	72 6e                	jb     ffff8000001021ae <.erodata+0x1ed>
+ffff800000102140:	65 6c                	gs insb (%dx),%es:(%rdi)
+ffff800000102142:	20 70 61             	and    %dh,0x61(%rax)
+ffff800000102145:	6e                   	outsb  %ds:(%rsi),(%dx)
+ffff800000102146:	69 63 3a 20 25 73 0a 	imul   $0xa732520,0x3a(%rbx),%esp
+	...
+
+Disassembly of section .eh_frame:
+
+ffff800000102150 <.eh_frame>:
+ffff800000102150:	14 00                	adc    $0x0,%al
+ffff800000102152:	00 00                	add    %al,(%rax)
+ffff800000102154:	00 00                	add    %al,(%rax)
+ffff800000102156:	00 00                	add    %al,(%rax)
+ffff800000102158:	01 7a 52             	add    %edi,0x52(%rdx)
+ffff80000010215b:	00 01                	add    %al,(%rcx)
+ffff80000010215d:	78 10                	js     ffff80000010216f <.erodata+0x1ae>
+ffff80000010215f:	01 1b                	add    %ebx,(%rbx)
+ffff800000102161:	0c 07                	or     $0x7,%al
+ffff800000102163:	08 90 01 00 00 24    	or     %dl,0x24000001(%rax)
+ffff800000102169:	00 00                	add    %al,(%rax)
+ffff80000010216b:	00 1c 00             	add    %bl,(%rax,%rax,1)
+ffff80000010216e:	00 00                	add    %al,(%rax)
+ffff800000102170:	70 df                	jo     ffff800000102151 <.erodata+0x190>
+ffff800000102172:	ff                   	(bad)  
+ffff800000102173:	ff                   	(bad)  
+ffff800000102174:	ec                   	in     (%dx),%al
+ffff800000102175:	00 00                	add    %al,(%rax)
+ffff800000102177:	00 00                	add    %al,(%rax)
+ffff800000102179:	4c 0e                	rex.WR (bad) 
+ffff80000010217b:	10 8f 02 49 0e 18    	adc    %cl,0x180e4902(%rdi)
+ffff800000102181:	8c 03                	mov    %es,(%rbx)
+ffff800000102183:	44 0e                	rex.R (bad) 
+ffff800000102185:	20 86 04 4b 0e 28    	and    %al,0x280e4b04(%rsi)
+ffff80000010218b:	83 05 54 0e 50 10 00 	addl   $0x0,0x10500e54(%rip)        # ffff800010602fe6 <_ebss+0x10500b2e>
+ffff800000102192:	00 00                	add    %al,(%rax)
+ffff800000102194:	44 00 00             	add    %r8b,(%rax)
+ffff800000102197:	00 38                	add    %bh,(%rax)
+ffff800000102199:	e0 ff                	loopne ffff80000010219a <.erodata+0x1d9>
+ffff80000010219b:	ff 26                	jmpq   *(%rsi)
+ffff80000010219d:	00 00                	add    %al,(%rax)
+ffff80000010219f:	00 00                	add    %al,(%rax)
+ffff8000001021a1:	00 00                	add    %al,(%rax)
+ffff8000001021a3:	00 10                	add    %dl,(%rax)
+ffff8000001021a5:	00 00                	add    %al,(%rax)
+ffff8000001021a7:	00 58 00             	add    %bl,0x0(%rax)
+ffff8000001021aa:	00 00                	add    %al,(%rax)
+ffff8000001021ac:	54                   	push   %rsp
+ffff8000001021ad:	e0 ff                	loopne ffff8000001021ae <.erodata+0x1ed>
+ffff8000001021af:	ff 1b                	lcall  *(%rbx)
+ffff8000001021b1:	00 00                	add    %al,(%rax)
+ffff8000001021b3:	00 00                	add    %al,(%rax)
+ffff8000001021b5:	00 00                	add    %al,(%rax)
+ffff8000001021b7:	00 34 00             	add    %dh,(%rax,%rax,1)
+ffff8000001021ba:	00 00                	add    %al,(%rax)
+ffff8000001021bc:	6c                   	insb   (%dx),%es:(%rdi)
+ffff8000001021bd:	00 00                	add    %al,(%rax)
+ffff8000001021bf:	00 60 e0             	add    %ah,-0x20(%rax)
+ffff8000001021c2:	ff                   	(bad)  
+ffff8000001021c3:	ff                   	(bad)  
+ffff8000001021c4:	78 00                	js     ffff8000001021c6 <.erodata+0x205>
+ffff8000001021c6:	00 00                	add    %al,(%rax)
+ffff8000001021c8:	00 42 0e             	add    %al,0xe(%rdx)
+ffff8000001021cb:	10 8f 02 62 0e 18    	adc    %cl,0x180e6202(%rdi)
+ffff8000001021d1:	8c 03                	mov    %es,(%rbx)
+ffff8000001021d3:	44 0e                	rex.R (bad) 
+ffff8000001021d5:	20 86 04 4e 0e 28    	and    %al,0x280e4e04(%rsi)
+ffff8000001021db:	83 05 4a 0e 30 6e 0e 	addl   $0xe,0x6e300e4a(%rip)        # ffff80006e40302c <_ebss+0x6e300b74>
+ffff8000001021e2:	28 44 0e 20          	sub    %al,0x20(%rsi,%rcx,1)
+ffff8000001021e6:	41 0e                	rex.B (bad) 
+ffff8000001021e8:	18 42 0e             	sbb    %al,0xe(%rdx)
+ffff8000001021eb:	10 42 0e             	adc    %al,0xe(%rdx)
+ffff8000001021ee:	08 00                	or     %al,(%rax)
+ffff8000001021f0:	2c 00                	sub    $0x0,%al
+ffff8000001021f2:	00 00                	add    %al,(%rax)
+ffff8000001021f4:	a4                   	movsb  %ds:(%rsi),%es:(%rdi)
+ffff8000001021f5:	00 00                	add    %al,(%rax)
+ffff8000001021f7:	00 a8 e0 ff ff 3e    	add    %ch,0x3effffe0(%rax)
+ffff8000001021fd:	00 00                	add    %al,(%rax)
+ffff8000001021ff:	00 00                	add    %al,(%rax)
+ffff800000102201:	4c 0e                	rex.WR (bad) 
+ffff800000102203:	10 8f 02 54 0e 18    	adc    %cl,0x180e5402(%rdi)
+ffff800000102209:	86 03                	xchg   %al,(%rbx)
+ffff80000010220b:	46 0e                	rex.RX (bad) 
+ffff80000010220d:	20 83 04 54 0e 18    	and    %al,0x180e5404(%rbx)
+ffff800000102213:	41 0e                	rex.B (bad) 
+ffff800000102215:	10 42 0e             	adc    %al,0xe(%rdx)
+ffff800000102218:	08 00                	or     %al,(%rax)
+ffff80000010221a:	00 00                	add    %al,(%rax)
+ffff80000010221c:	00 00                	add    %al,(%rax)
+ffff80000010221e:	00 00                	add    %al,(%rax)
+ffff800000102220:	10 00                	adc    %al,(%rax)
+ffff800000102222:	00 00                	add    %al,(%rax)
+ffff800000102224:	d4                   	(bad)  
+ffff800000102225:	00 00                	add    %al,(%rax)
+ffff800000102227:	00 e8                	add    %ch,%al
+ffff800000102229:	e0 ff                	loopne ffff80000010222a <.erodata+0x269>
+ffff80000010222b:	ff 29                	ljmp   *(%rcx)
+ffff80000010222d:	00 00                	add    %al,(%rax)
+ffff80000010222f:	00 00                	add    %al,(%rax)
+ffff800000102231:	00 00                	add    %al,(%rax)
+ffff800000102233:	00 10                	add    %dl,(%rax)
+ffff800000102235:	00 00                	add    %al,(%rax)
+ffff800000102237:	00 e8                	add    %ch,%al
+ffff800000102239:	00 00                	add    %al,(%rax)
+ffff80000010223b:	00 04 e1             	add    %al,(%rcx,%riz,8)
+ffff80000010223e:	ff                   	(bad)  
+ffff80000010223f:	ff 29                	ljmp   *(%rcx)
+ffff800000102241:	00 00                	add    %al,(%rax)
+ffff800000102243:	00 00                	add    %al,(%rax)
+ffff800000102245:	00 00                	add    %al,(%rax)
+ffff800000102247:	00 10                	add    %dl,(%rax)
+ffff800000102249:	00 00                	add    %al,(%rax)
+ffff80000010224b:	00 fc                	add    %bh,%ah
+ffff80000010224d:	00 00                	add    %al,(%rax)
+ffff80000010224f:	00 20                	add    %ah,(%rax)
+ffff800000102251:	e1 ff                	loope  ffff800000102252 <.erodata+0x291>
+ffff800000102253:	ff                   	(bad)  
+ffff800000102254:	7d 00                	jge    ffff800000102256 <.erodata+0x295>
+ffff800000102256:	00 00                	add    %al,(%rax)
+ffff800000102258:	00 00                	add    %al,(%rax)
+ffff80000010225a:	00 00                	add    %al,(%rax)
+ffff80000010225c:	4c 00 00             	rex.WR add %r8b,(%rax)
+ffff80000010225f:	00 10                	add    %dl,(%rax)
+ffff800000102261:	01 00                	add    %eax,(%rax)
+ffff800000102263:	00 8c e1 ff ff 9f 05 	add    %cl,0x59fffff(%rcx,%riz,8)
+ffff80000010226a:	00 00                	add    %al,(%rax)
+ffff80000010226c:	00 4c 0e 10          	add    %cl,0x10(%rsi,%rcx,1)
+ffff800000102270:	8f 02                	popq   (%rdx)
+ffff800000102272:	49 0e                	rex.WB (bad) 
+ffff800000102274:	18 8e 03 45 0e 20    	sbb    %cl,0x200e4503(%rsi)
+ffff80000010227a:	8d 04 42             	lea    (%rdx,%rax,2),%eax
+ffff80000010227d:	0e                   	(bad)  
+ffff80000010227e:	28 8c 05 41 0e 30 86 	sub    %cl,-0x79cff1bf(%rbp,%rax,1)
+ffff800000102285:	06                   	(bad)  
+ffff800000102286:	41 0e                	rex.B (bad) 
+ffff800000102288:	38 83 07 47 0e e0    	cmp    %al,-0x1ff1b8f9(%rbx)
+ffff80000010228e:	01 03                	add    %eax,(%rbx)
+ffff800000102290:	1a 02                	sbb    (%rdx),%al
+ffff800000102292:	0a 0e                	or     (%rsi),%cl
+ffff800000102294:	38 44 0e 30          	cmp    %al,0x30(%rsi,%rcx,1)
+ffff800000102298:	41 0e                	rex.B (bad) 
+ffff80000010229a:	28 42 0e             	sub    %al,0xe(%rdx)
+ffff80000010229d:	20 42 0e             	and    %al,0xe(%rdx)
+ffff8000001022a0:	18 42 0e             	sbb    %al,0xe(%rdx)
+ffff8000001022a3:	10 42 0e             	adc    %al,0xe(%rdx)
+ffff8000001022a6:	08 44 0b 00          	or     %al,0x0(%rbx,%rcx,1)
+ffff8000001022aa:	00 00                	add    %al,(%rax)
+ffff8000001022ac:	40 00 00             	add    %al,(%rax)
+ffff8000001022af:	00 60 01             	add    %ah,0x1(%rax)
+ffff8000001022b2:	00 00                	add    %al,(%rax)
+ffff8000001022b4:	dc e6                	fsub   %st,%st(6)
+ffff8000001022b6:	ff                   	(bad)  
+ffff8000001022b7:	ff 07                	incl   (%rdi)
+ffff8000001022b9:	01 00                	add    %eax,(%rax)
+ffff8000001022bb:	00 00                	add    %al,(%rax)
+ffff8000001022bd:	4c 0e                	rex.WR (bad) 
+ffff8000001022bf:	10 8f 02 49 0e 18    	adc    %cl,0x180e4902(%rdi)
+ffff8000001022c5:	8d 03                	lea    (%rbx),%eax
+ffff8000001022c7:	45 0e                	rex.RB (bad) 
+ffff8000001022c9:	20 8c 04 41 0e 28 86 	and    %cl,-0x79d7f1bf(%rsp,%rax,1)
+ffff8000001022d0:	05 41 0e 30 83       	add    $0x83300e41,%eax
+ffff8000001022d5:	06                   	(bad)  
+ffff8000001022d6:	44 0e                	rex.R (bad) 
+ffff8000001022d8:	60                   	(bad)  
+ffff8000001022d9:	02 c6                	add    %dh,%al
+ffff8000001022db:	0a 0e                	or     (%rsi),%cl
+ffff8000001022dd:	30 41 0e             	xor    %al,0xe(%rcx)
+ffff8000001022e0:	28 41 0e             	sub    %al,0xe(%rcx)
+ffff8000001022e3:	20 42 0e             	and    %al,0xe(%rdx)
+ffff8000001022e6:	18 42 0e             	sbb    %al,0xe(%rdx)
+ffff8000001022e9:	10 42 0e             	adc    %al,0xe(%rdx)
+ffff8000001022ec:	08 42 0b             	or     %al,0xb(%rdx)
+ffff8000001022ef:	00 34 00             	add    %dh,(%rax,%rax,1)
+ffff8000001022f2:	00 00                	add    %al,(%rax)
+ffff8000001022f4:	a4                   	movsb  %ds:(%rsi),%es:(%rdi)
+ffff8000001022f5:	01 00                	add    %eax,(%rax)
+ffff8000001022f7:	00 a8 e7 ff ff 88    	add    %ch,-0x77000019(%rax)
+ffff8000001022fd:	00 00                	add    %al,(%rax)
+ffff8000001022ff:	00 00                	add    %al,(%rax)
+ffff800000102301:	4c 0e                	rex.WR (bad) 
+ffff800000102303:	10 8f 02 49 0e 18    	adc    %cl,0x180e4902(%rdi)
+ffff800000102309:	8c 03                	mov    %es,(%rbx)
+ffff80000010230b:	4a 0e                	rex.WX (bad) 
+ffff80000010230d:	20 86 04 4b 0e 28    	and    %al,0x280e4b04(%rsi)
+ffff800000102313:	83 05 4a 0e 30 02 48 	addl   $0x48,0x2300e4a(%rip)        # ffff800002403164 <_ebss+0x2300cac>
+ffff80000010231a:	0e                   	(bad)  
+ffff80000010231b:	28 46 0e             	sub    %al,0xe(%rsi)
+ffff80000010231e:	20 41 0e             	and    %al,0xe(%rcx)
+ffff800000102321:	18 42 0e             	sbb    %al,0xe(%rdx)
+ffff800000102324:	10 42 0e             	adc    %al,0xe(%rdx)
+ffff800000102327:	08 1c 00             	or     %bl,(%rax,%rax,1)
+ffff80000010232a:	00 00                	add    %al,(%rax)
+ffff80000010232c:	dc 01                	faddl  (%rcx)
+ffff80000010232e:	00 00                	add    %al,(%rax)
+ffff800000102330:	00 e8                	add    %ch,%al
+ffff800000102332:	ff                   	(bad)  
+ffff800000102333:	ff 40 00             	incl   0x0(%rax)
+ffff800000102336:	00 00                	add    %al,(%rax)
+ffff800000102338:	00 45 0e             	add    %al,0xe(%rbp)
+ffff80000010233b:	10 8f 02 79 0e 08    	adc    %cl,0x80e7902(%rdi)
+ffff800000102341:	00 00                	add    %al,(%rax)
+ffff800000102343:	00 00                	add    %al,(%rax)
+ffff800000102345:	00 00                	add    %al,(%rax)
+ffff800000102347:	00 1c 00             	add    %bl,(%rax,%rax,1)
+ffff80000010234a:	00 00                	add    %al,(%rax)
+ffff80000010234c:	fc                   	cld    
+ffff80000010234d:	01 00                	add    %eax,(%rax)
+ffff80000010234f:	00 30                	add    %dh,(%rax)
+ffff800000102351:	e8 ff ff db 00       	callq  ffff800000ec2355 <_ebss+0xdbfe9d>
+ffff800000102356:	00 00                	add    %al,(%rax)
+ffff800000102358:	00 4c 0e 10          	add    %cl,0x10(%rsi,%rcx,1)
+ffff80000010235c:	8f 02                	popq   (%rdx)
+ffff80000010235e:	48 0e                	rex.W (bad) 
+ffff800000102360:	18 86 03 47 0e 20    	sbb    %al,0x200e4703(%rsi)
+ffff800000102366:	83 04 3c 00          	addl   $0x0,(%rsp,%rdi,1)
+ffff80000010236a:	00 00                	add    %al,(%rax)
+ffff80000010236c:	1c 02                	sbb    $0x2,%al
+ffff80000010236e:	00 00                	add    %al,(%rax)
+ffff800000102370:	f0 e8 ff ff 65 01    	lock callq ffff800001762375 <_ebss+0x165febd>
+ffff800000102376:	00 00                	add    %al,(%rax)
+ffff800000102378:	00 42 0e             	add    %al,0xe(%rdx)
+ffff80000010237b:	10 8f 02 58 0e 18    	adc    %cl,0x180e5802(%rdi)
+ffff800000102381:	8d 03                	lea    (%rbx),%eax
+ffff800000102383:	47 0e                	rex.RXB (bad) 
+ffff800000102385:	20 8c 04 44 0e 28 86 	and    %cl,-0x79d7f1bc(%rsp,%rax,1)
+ffff80000010238c:	05 41 0e 30 83       	add    $0x83300e41,%eax
+ffff800000102391:	06                   	(bad)  
+ffff800000102392:	02 ea                	add    %dl,%ch
+ffff800000102394:	0a 0e                	or     (%rsi),%cl
+ffff800000102396:	28 43 0e             	sub    %al,0xe(%rbx)
+ffff800000102399:	20 42 0e             	and    %al,0xe(%rdx)
+ffff80000010239c:	18 42 0e             	sbb    %al,0xe(%rdx)
+ffff80000010239f:	10 42 0e             	adc    %al,0xe(%rdx)
+ffff8000001023a2:	08 47 0b             	or     %al,0xb(%rdi)
+ffff8000001023a5:	00 00                	add    %al,(%rax)
+ffff8000001023a7:	00 18                	add    %bl,(%rax)
+ffff8000001023a9:	00 00                	add    %al,(%rax)
+ffff8000001023ab:	00 5c 02 00          	add    %bl,0x0(%rdx,%rax,1)
+ffff8000001023af:	00 20                	add    %ah,(%rax)
+ffff8000001023b1:	ea                   	(bad)  
+ffff8000001023b2:	ff                   	(bad)  
+ffff8000001023b3:	ff                   	(bad)  
+ffff8000001023b4:	3c 00                	cmp    $0x0,%al
+ffff8000001023b6:	00 00                	add    %al,(%rax)
+ffff8000001023b8:	00 4c 0e 10          	add    %cl,0x10(%rsi,%rcx,1)
+ffff8000001023bc:	8f 02                	popq   (%rdx)
+ffff8000001023be:	69 0e 08 00 00 00    	imul   $0x8,(%rsi),%ecx
+ffff8000001023c4:	18 00                	sbb    %al,(%rax)
+ffff8000001023c6:	00 00                	add    %al,(%rax)
+ffff8000001023c8:	78 02                	js     ffff8000001023cc <.erodata+0x40b>
+ffff8000001023ca:	00 00                	add    %al,(%rax)
+ffff8000001023cc:	44 ea                	rex.R (bad) 
+ffff8000001023ce:	ff                   	(bad)  
+ffff8000001023cf:	ff                   	(bad)  
+ffff8000001023d0:	3c 00                	cmp    $0x0,%al
+ffff8000001023d2:	00 00                	add    %al,(%rax)
+ffff8000001023d4:	00 4c 0e 10          	add    %cl,0x10(%rsi,%rcx,1)
+ffff8000001023d8:	8f 02                	popq   (%rdx)
+ffff8000001023da:	6e                   	outsb  %ds:(%rsi),(%dx)
+ffff8000001023db:	0e                   	(bad)  
+ffff8000001023dc:	08 00                	or     %al,(%rax)
+ffff8000001023de:	00 00                	add    %al,(%rax)
+ffff8000001023e0:	10 00                	adc    %al,(%rax)
+ffff8000001023e2:	00 00                	add    %al,(%rax)
+ffff8000001023e4:	94                   	xchg   %eax,%esp
+ffff8000001023e5:	02 00                	add    (%rax),%al
+ffff8000001023e7:	00 68 ea             	add    %ch,-0x16(%rax)
+ffff8000001023ea:	ff                   	(bad)  
+ffff8000001023eb:	ff 0a                	decl   (%rdx)
+ffff8000001023ed:	00 00                	add    %al,(%rax)
+ffff8000001023ef:	00 00                	add    %al,(%rax)
+ffff8000001023f1:	00 00                	add    %al,(%rax)
+ffff8000001023f3:	00 10                	add    %dl,(%rax)
+ffff8000001023f5:	00 00                	add    %al,(%rax)
+ffff8000001023f7:	00 a8 02 00 00 64    	add    %ch,0x64000002(%rax)
+ffff8000001023fd:	ea                   	(bad)  
+ffff8000001023fe:	ff                   	(bad)  
+ffff8000001023ff:	ff 0c 00             	decl   (%rax,%rax,1)
+ffff800000102402:	00 00                	add    %al,(%rax)
+ffff800000102404:	00 00                	add    %al,(%rax)
+ffff800000102406:	00 00                	add    %al,(%rax)
+ffff800000102408:	10 00                	adc    %al,(%rax)
+ffff80000010240a:	00 00                	add    %al,(%rax)
+ffff80000010240c:	bc 02 00 00 60       	mov    $0x60000002,%esp
+ffff800000102411:	ea                   	(bad)  
+ffff800000102412:	ff                   	(bad)  
+ffff800000102413:	ff 10                	callq  *(%rax)
+ffff800000102415:	00 00                	add    %al,(%rax)
+ffff800000102417:	00 00                	add    %al,(%rax)
+ffff800000102419:	00 00                	add    %al,(%rax)
+ffff80000010241b:	00 10                	add    %dl,(%rax)
+ffff80000010241d:	00 00                	add    %al,(%rax)
+ffff80000010241f:	00 d0                	add    %dl,%al
+ffff800000102421:	02 00                	add    (%rax),%al
+ffff800000102423:	00 5c ea ff          	add    %bl,-0x1(%rdx,%rbp,8)
+ffff800000102427:	ff 10                	callq  *(%rax)
+ffff800000102429:	00 00                	add    %al,(%rax)
+ffff80000010242b:	00 00                	add    %al,(%rax)
+ffff80000010242d:	00 00                	add    %al,(%rax)
+ffff80000010242f:	00 10                	add    %dl,(%rax)
+ffff800000102431:	00 00                	add    %al,(%rax)
+ffff800000102433:	00 e4                	add    %ah,%ah
+ffff800000102435:	02 00                	add    (%rax),%al
+ffff800000102437:	00 58 ea             	add    %bl,-0x16(%rax)
+ffff80000010243a:	ff                   	(bad)  
+ffff80000010243b:	ff 12                	callq  *(%rdx)
+ffff80000010243d:	00 00                	add    %al,(%rax)
+ffff80000010243f:	00 00                	add    %al,(%rax)
+ffff800000102441:	00 00                	add    %al,(%rax)
+	...
+
+Disassembly of section .bss:
+
+ffff800000102460 <y>:
+ffff800000102460:	00 00                	add    %al,(%rax)
+	...
+
+ffff800000102464 <x>:
+	...
+
+ffff800000102480 <mman>:
+	...
+
+Disassembly of section .comment:
+
+0000000000000000 <.comment>:
+   0:	47                   	rex.RXB
+   1:	43                   	rex.XB
+   2:	43 3a 20             	rex.XB cmp (%r8),%spl
+   5:	28 47 4e             	sub    %al,0x4e(%rdi)
+   8:	55                   	push   %rbp
+   9:	29 20                	sub    %esp,(%rax)
+   b:	31 30                	xor    %esi,(%rax)
+   d:	2e 32 2e             	xor    %cs:(%rsi),%ch
+  10:	30 00                	xor    %al,(%rax)

+ 11 - 0
kernel/lib/Makefile

@@ -0,0 +1,11 @@
+C_FLAGS = -mcmodel=large -m64 -fno-builtin -nostdlib -I ../../include/ -Wall -Werror -O3
+
+all: bitmap.c bitman.c bitmap.o bitman.o string.c string.o
+
+%.o: %.c
+	gcc -c $*.c $(C_FLAGS)
+
+
+clear:
+	rm *.o
+

+ 63 - 0
kernel/lib/bitman.c

@@ -0,0 +1,63 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <lib/rlib.h>
+
+
+/*
+	find a new bit in bm->bitmap. 
+
+	STEPS: 
+		1. save free position. 
+		2. find a new free position. 
+		3. save new free position. 
+*/
+unsigned int bitman_alloc(struct bitmap_manager *bm) {
+	unsigned int p = bm->next_free;
+	bitmap_set(bm->bitmap, bm->next_free, 1);
+
+	for (; bitmap_read(bm->bitmap, bm->next_free) == 1; bm->next_free++);
+
+	return p;
+}
+
+
+/*
+	free a bit. 
+
+	STEPS: 
+		1. free bit pos. 
+		2. if pos is lowwer than bm->next_free
+			2a. set bm->next_free = pos. 
+*/
+void bitman_free(struct bitmap_manager *bm, unsigned int pos) {
+	bitmap_set(bm->bitmap, pos, 0);
+
+	if (pos < bm->next_free) {
+		bm->next_free = pos;
+	}
+	return;
+}

+ 48 - 0
kernel/lib/bitmap.c

@@ -0,0 +1,48 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <kernel/types.h>
+
+
+
+void bitmap_set(unsigned char *bitmap, unsigned int pos, unsigned char value) {
+	unsigned char mask = 0x80 >> (pos & 0x7);
+
+	/* set bit */
+	if (value) {
+		bitmap[pos >> 3] |= mask;
+	}
+	else {
+		bitmap[pos >> 3] &= ~mask;
+	}
+}
+
+char bitmap_read(unsigned char *bitmap, unsigned int pos) {
+	unsigned char mask = 0x80 >> (pos & 0x7);
+
+	return (mask & bitmap[pos >> 3]) == mask ? 1 : 0;
+}
+

+ 93 - 0
kernel/lib/string.c

@@ -0,0 +1,93 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <kernel/types.h>
+
+
+/* copy src to dest for n bytes */
+void *memcpy(void *dest, void *src, __uint64_t n) {
+	__asm__ (
+		"cld\n\t"
+		"rep movsb\n\t"
+
+		:: "c" (n), "S" (src), "D" (dest)
+	);
+
+	return dest;
+}
+
+
+/* set n to src for n bytes */
+void *memset(void *dest, char c, __uint64_t n) {
+	__asm__ (
+		"cld\n\t"
+		"rep stosb\n\t"
+
+		:: "c" (n), "D" (dest), "a" (c)
+	);
+
+	return dest;
+}
+
+
+/* set n to src for n words (n must be power of 2) */
+void *memsetw(void *dest, __uint16_t c, __uint64_t n) {
+	__asm__ (
+		"cld\n\t"
+		"rep stosw\n\t"
+
+		:: "c" (n >> 1), "D" (dest), "a" (c)
+	);
+
+	return dest;
+}
+
+
+/* set n to src for n dwords (n must be power of 4) */
+void *memsetl(void *dest, __uint32_t c, __uint64_t n) {
+	__asm__ (
+		"cld\n\t"
+		"rep stosl\n\t"
+
+		:: "c" (n >> 2), "D" (dest), "a" (c)
+	);
+
+	return dest;
+}
+
+
+/* set n to src for n quads (n must be power of 8) */
+void *memsetq(void *dest, __uint64_t c, __uint64_t n) {
+	__asm__ (
+		"cld\n\t"
+		"rep stosq\n\t"
+
+		:: "c" (n >> 3), "D" (dest), "a" (c)
+	);
+
+	return dest;
+}
+

+ 10 - 0
kernel/mm/Makefile

@@ -0,0 +1,10 @@
+C_FLAGS = -mcmodel=large -fno-builtin -m64 -I ../../include/ -Wall -Werror -O3
+
+all: page.o
+
+%.o: %.c
+	gcc -c $*.c $(C_FLAGS)
+
+clear:
+	rm *.o 
+

+ 102 - 0
kernel/mm/page.c

@@ -0,0 +1,102 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <kernel/init.h>
+#include <kernel/types.h>
+#include <kernel/errno.h>
+
+#include <kernel/panic.h>
+#include <kernel/mm.h>
+
+#include <lib/string.h>
+#include <lib/bitman.h>
+#include <lib/bitmap.h>
+
+#include <modules/tty.h>
+
+
+
+struct mm mman;
+
+
+errno_t mem_init(void) {
+	/* get E820 info (from BIOS) */
+	int i;
+	struct e820_entry *p;
+
+	p = E820_ADDR;
+
+	for (i = 0; i < 32; i++) {
+		if (p->type && p->type < 5) {
+			if (p->type == 1) 
+				mman.total_ram += p->len;
+
+			p++;
+
+			continue;
+		}
+
+		break;
+	}
+
+	printf("total usable RAM: %d MB, total E820 entries: %d\n", mman.total_ram >> 20, i);
+
+	/* get total pages */
+	mman.total_pages = mman.total_ram >> PAGE_2M_SHIFT;
+	mman.pages_bitman.bitmap = (unsigned char *) (((__uint64_t) &_end) & PAGE_4K_MASK);
+
+	memset(mman.pages_bitman.bitmap, 0x00, mman.total_pages >> 3);
+
+	printf("total pages: %d pages bitmap: 0x%p\n", mman.total_pages, &_end, mman.pages_bitman.bitmap);
+
+
+	/* first page is in using and it never free */
+	mman.usable_pages = mman.total_pages - 1;
+
+	mman.e820 = E820_ADDR;
+
+	mman.e820_entries = i;
+
+	bitmap_set(mman.pages_bitman.bitmap, 0, 1);
+
+	return 0;
+}
+
+
+
+
+void *palloc(void) {
+	return (void *) (((__uint64_t) bitman_alloc(&mman.pages_bitman)) << PAGE_2M_SHIFT);
+}
+
+
+void pfree(void *addr) {
+	bitman_free(&mman.pages_bitman, (__uint32_t) (((__uint64_t) addr) >> PAGE_2M_SHIFT));
+
+	return;
+}
+
+

+ 11 - 0
kernel/modules/Makefile

@@ -0,0 +1,11 @@
+SRCS = tty.o
+C_FLAGS = -mcmodel=large -fno-builtin -m64 -I ../../include -Wall -Werror -O3 
+
+all: $(SRCS)
+
+%.o: %.c
+	gcc -c $*.c $(C_FLAGS)
+
+clear:
+	rm *.o
+

+ 11 - 0
kernel/modules/module_makefile

@@ -0,0 +1,11 @@
+CFLAGS = -mcmodel=large -fno-builtin -m64 -I ../../../include -Wall -Werror -O3 -fno-stackcheck
+
+
+all: $(OBJS)
+
+%.o: %.c
+	gcc -c $*.c $(CFLAGS)
+
+clear: 
+	rm *.o
+

+ 272 - 0
kernel/modules/tty.c

@@ -0,0 +1,272 @@
+/* Copyright (C) 2021 Rain */
+
+/* This file is part of Cunix. */
+
+/* 
+  Cunix 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) and later version. 
+*/
+
+/*
+  Cunix 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 Cunix. If not, see <https://www.gnu.org/licenses/>.  
+*/
+
+
+
+
+#include <kernel/init.h>
+#include <kernel/types.h>
+#include <kernel/errno.h>
+
+#include <modules/tty.h>
+#include <arch/io.h>
+#include <arch/sys.h>
+
+#include <lib/string.h>
+
+#include <stdarg.h>
+
+
+
+
+/* variables in .data will initialize by value 0 */
+int x, y;
+
+extern __uint64_t framebuffer;
+
+__uint16_t read_cursor(void) {
+	__uint16_t pos = 0;
+
+	outb(CURSORCTL_POSLO, CURSOR_INDEX);
+	pos |= inb(CURSOR_DATA);
+
+	outb(CURSORCTL_POSHI, CURSOR_INDEX);
+	pos |= ((__uint16_t) inb(CURSOR_DATA)) << 8;
+
+	return pos;
+}
+
+
+
+void write_cursor(__uint16_t pos) {
+	outb(CURSORCTL_POSLO, CURSOR_INDEX);
+	outb((__uint8_t) (pos & 0xff), CURSOR_DATA);
+
+	outb(CURSORCTL_POSHI, CURSOR_INDEX);
+	outb((__uint8_t) ((pos >> 8) & 0xff), CURSOR_DATA);
+
+	return;
+}
+
+
+
+void update_cursor(void) {
+	__uint16_t pos = y * TEXT_VGA_X + x;
+	write_cursor(pos);
+
+	framebuffer = 0xb8000 + pos * 2;
+
+	return;
+}
+
+
+
+__uint64_t printf(const char *s, ...) {
+	/* l: character puts (no '%') */
+	__uint64_t i, l;
+	/* if prev character is '%', state = '%' */
+	char state, c;
+	/* fmt_s only use in %s, but we cannot define variables in switch-case */
+	char *fmt_s;
+	va_list values;
+
+	int newlines;
+
+	va_start(values, s);
+	state = 0;
+	newlines = 0;
+
+	for (i = 0, l = 0; s[i]; i++) {
+		c = s[i];
+		/* check state */
+		if (!state) {
+			if (c == '%') {
+				state = '%';
+				continue;
+			}
+
+			/* c != '%' (it's not a formater), put it */
+			else {
+				/* if it's \n */
+				if (c == '\n') {
+					/* new line, and reset x */
+					newlines++;
+				}
+
+				else {
+					putc(c);
+					l++;
+				}
+
+				continue;
+			}
+		}
+
+		/* it's a formater */
+		else {
+			if (c == 'd') {
+				l += printint((int) va_arg(values, int), 10, 1);
+			}
+
+			else if (c == 'x') {
+				/* `x` is 64-bits, I think it's */
+				l += printint((long) va_arg(values, long), 16, 0);
+			}
+
+			else if (c == 'p') {
+				/* zeros at high bits should display, not like `%x` or `%d` */
+				l += printptr((__uint64_t) va_arg(values, __uint64_t));
+			}
+
+			else if (c == 's') {
+				fmt_s = (char *) va_arg(values, char *);
+				if (!fmt_s) 
+					fmt_s = "(null)";
+						
+				/* put while end of fmt_s */
+				while (*fmt_s) {
+					putc(*fmt_s);
+					fmt_s++;
+					l++;
+				}
+			}
+			
+			else if (c == 'c') {
+				/* `char` aligned to `int` in GCC */
+				putc((char) va_arg(values, int));
+				l++;
+			}
+
+			else if (c == '%') {
+				/* put % on screen */
+				putc(c);
+				l++;
+			}
+
+			else {
+				/* don't forget to put % */
+				putc('%');
+				putc(c);
+				l++;
+			}
+
+			state = 0;
+		}
+	}
+
+
+	/* update cursor position */
+	x += l;
+	if (x > TEXT_VGA_X) {
+		x = TEXT_VGA_X - x;
+		y++;
+	}
+
+	y += newlines;
+
+	if (newlines) 
+		x = 0;
+
+	if (y > TEXT_VGA_Y) {
+		y = 0;
+		clear_line(0);
+	}
+
+	update_cursor();
+
+	va_end(values);
+
+	return i;
+}
+ 
+
+static char digits[] = {"0123456789abcdef"};
+
+
+__uint64_t printint(long n, int base, int sign) {
+	char buf[32];
+	/* neg: x < 0 && signed interger */
+	int i, neg, j;
+	/* x: real number should put */
+	__uint64_t x;
+
+	if (n < 0 && sign) {
+		neg = 1;
+		x = -n;
+	}
+
+	else {
+		neg = 0;
+		x = n;
+	}
+
+	i = 0;
+	do {
+		/* get string of based-number */
+		/* the first bit of 10-based digit is at buf[15] */
+		buf[i++] = digits[x % base];
+	} while (x /= base);
+
+	if (neg) 
+		buf[i++] = '-';
+
+	j = i;
+	while (--j >= 0) 
+		putc(buf[j]);
+
+	return i;
+}
+
+
+
+__uint64_t printptr(__uint64_t p) {
+	int i;
+
+	for (i = 15; i >= 0; i--) {
+		char c = (p >> (i * 4)) & 0x0f;
+
+		if (c > 9) 
+			c = c - 10 + 'a';
+		
+		else 
+			c += '0';
+
+		putc(c);
+	}
+
+	return 16;
+}
+
+
+#define LINE_ADDR(l) ((char *) (__uint64_t) (0xb8000 + (l) * TEXT_VGA_X * 2))
+
+
+void clear_line(int line) {
+	char *p = LINE_ADDR(line);
+
+	memsetw(p, 0x0720, TEXT_VGA_X * 2);
+
+	return;
+}
+
+