diff --git a/COPYING b/COPYING
deleted file mode 100644
index 20d40b6..0000000
--- a/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- 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.
-
-
- Copyright (C)
-
- 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 .
-
-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:
-
- Copyright (C)
- 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
-.
-
- 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
-.
\ No newline at end of file
diff --git a/x64/CMakeLists.txt b/x64/CMakeLists.txt
index 22db75b..c3d6a31 100644
--- a/x64/CMakeLists.txt
+++ b/x64/CMakeLists.txt
@@ -1,19 +1,6 @@
cmake_minimum_required(VERSION 2.8.4)
project(Workspace)
-MACRO(HEADER_DIRECTORIES return_list)
- FILE(GLOB_RECURSE new_list ./*.h)
- SET(dir_list "")
- FOREACH(file_path ${new_list})
- GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
- SET(dir_list ${dir_list} ${dir_path})
- ENDFOREACH()
- LIST(REMOVE_DUPLICATES dir_list)
- SET(${return_list} ${dir_list})
-ENDMACRO()
-
-HEADER_DIRECTORIES(header_dirs)
-
include_directories(src/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
diff --git a/x64/src/kernel/hal/addr.inc b/x64/src/hal/addr.inc
similarity index 100%
rename from x64/src/kernel/hal/addr.inc
rename to x64/src/hal/addr.inc
diff --git a/x64/src/kernel/hal/boot.asm b/x64/src/hal/boot.asm
similarity index 100%
rename from x64/src/kernel/hal/boot.asm
rename to x64/src/hal/boot.asm
diff --git a/x64/src/kernel/hal/arch.asm b/x64/src/hal/cpu.asm
similarity index 100%
rename from x64/src/kernel/hal/arch.asm
rename to x64/src/hal/cpu.asm
diff --git a/x64/src/kernel/hal/init.c b/x64/src/hal/init.c
similarity index 80%
rename from x64/src/kernel/hal/init.c
rename to x64/src/hal/init.c
index 60eccbb..6a49935 100644
--- a/x64/src/kernel/hal/init.c
+++ b/x64/src/hal/init.c
@@ -3,12 +3,12 @@
* See COPYING under root for details
*/
-#include "print.h"
-#include "mem.h"
-#include "intr.h"
-#include "arch.h"
-#include "sxtdlib.h"
-#include "../../sxkrnl/arch/amd64/boot.h"
+#include "hal/print.h"
+#include "hal/mem.h"
+#include "hal/intr.h"
+#include "hal/cpu.h"
+#include "lib/sxtdlib.h"
+#include "hal/boot.h"
extern char HAL_KERNEL_START_VADDR[];
extern char HAL_KERNEL_END_VADDR[];
@@ -38,8 +38,8 @@ void KABI hal_main(void *m_info)
boot_info_t* boot_info = halloc(sizeof(boot_info_t));
// set up HAL def
- boot_info->krnl_start = (uint64_t)HAL_KERNEL_START_VADDR;
- boot_info->krnl_end = (uint64_t)HAL_KERNEL_END_VADDR;
+ boot_info->krnl_start = (virtual_addr_t)HAL_KERNEL_START_VADDR;
+ boot_info->krnl_end = (virtual_addr_t)HAL_KERNEL_END_VADDR;
// obtain cpu info
halp_obtain_cpu_info(boot_info);
diff --git a/x64/src/kernel/hal/intr.asm b/x64/src/hal/intr.asm
similarity index 100%
rename from x64/src/kernel/hal/intr.asm
rename to x64/src/hal/intr.asm
diff --git a/x64/src/kernel/hal/intr.c b/x64/src/hal/intr.c
similarity index 95%
rename from x64/src/kernel/hal/intr.c
rename to x64/src/hal/intr.c
index 502ac2b..c1364fb 100644
--- a/x64/src/kernel/hal/intr.c
+++ b/x64/src/hal/intr.c
@@ -1,21 +1,28 @@
-/* Copyright 2016 secXsQuared
- * Distributed under GPL license
- * See COPYING under root for details
- */
-#include "arch.h"
-#include "abi.h"
#include "type.h"
-#include "intr.h"
-#include "print.h"
-#include "mem.h"
+#include "hal/cpu.h"
+#include "hal/intr.h"
+#include "hal/print.h"
+#include "hal/mem.h"
#include "lib/sxtdlib.h"
static uint8_t _idts[HAL_CORE_COUNT][IDT_ENTRY_NUM*IDT_ENTRY_SIZE];
-hal_idt_ptr_t _idt_ptrs[HAL_CORE_COUNT];
-static k_intr_handler_t _intr_handler_table[HAL_CORE_COUNT][IDT_ENTRY_NUM];
+static hal_idt_ptr_t _idt_ptrs[HAL_CORE_COUNT];
+static intr_handler_t _intr_handler_table[HAL_CORE_COUNT][IDT_ENTRY_NUM];
static void* _intr_handler_context_table[HAL_CORE_COUNT][IDT_ENTRY_NUM];
-static k_exc_handler_t _exc_handler_table[HAL_CORE_COUNT][IDT_ENTRY_NUM];
+static exc_handler_t _exc_handler_table[HAL_CORE_COUNT][IDT_ENTRY_NUM];
+
+irql_t KABI hal_set_irql(irql_t irql)
+{
+ hal_assert(false,"Unimplemented function called.");
+ return 0;
+}
+
+irql_t KABI hal_get_irql(void)
+{
+ hal_assert(false,"Unimplemented function called.");
+ return 0;
+}
void KABI hal_write_gate(void *const gate,
@@ -55,13 +62,13 @@ void KABI hal_set_interrupt_handler(uint64_t index,
void KABI hal_issue_interrupt(uint32_t target_core, uint32_t vector)
{
- // TODO
UNREFERENCED(target_core);
UNREFERENCED(vector);
+ hal_assert(false,"Unimplemented function called.");
return;
}
-void KABI hal_register_interrupt_handler(uint32_t coreid, uint32_t index, k_intr_handler_t handler, void* context)
+void KABI hal_register_interrupt_handler(uint32_t coreid, uint32_t index, intr_handler_t handler, void* context)
{
if (index < IDT_ENTRY_NUM && coreid < HAL_CORE_COUNT)
{
@@ -80,7 +87,7 @@ void KABI hal_deregister_interrupt_handler(uint32_t coreid, uint32_t index)
return;
}
-void KABI hal_register_exception_handler(uint32_t coreid, uint32_t index, k_exc_handler_t handler)
+void KABI hal_register_exception_handler(uint32_t coreid, uint32_t index, exc_handler_t handler)
{
if (index < IDT_ENTRY_NUM && coreid < HAL_CORE_COUNT)
{
@@ -98,18 +105,7 @@ void KABI hal_deregister_exception_handler(uint32_t coreid, uint32_t index)
return;
}
-void KABI hal_assert(int64_t expression,
- char *message)
-{
- if (!expression)
- {
- hal_printf("HAL: Assertion failed. Detail: %s", message == NULL ? "NULL" : message);
- hal_halt_cpu();
- }
- return;
-}
-
-void KABI hal_interrupt_dispatcher(uint64_t int_vec, hal_intr_context_t *context)
+static void KABI hal_interrupt_dispatcher(uint64_t int_vec, hal_interrupt_context_t *context)
{
uint32_t coreid = hal_get_core_id();
if (_intr_handler_table[int_vec] == NULL)
@@ -123,7 +119,7 @@ void KABI hal_interrupt_dispatcher(uint64_t int_vec, hal_intr_context_t *context
return;
}
-void KABI hal_exception_dispatcher(uint64_t exc_vec, hal_intr_context_t* context, uint64_t errorcode)
+static void KABI hal_exception_dispatcher(uint64_t exc_vec, hal_interrupt_context_t* context, uint64_t errorcode)
{
uint32_t coreid = hal_get_core_id();
if (_exc_handler_table[exc_vec] == NULL)
@@ -400,6 +396,7 @@ static void KABI halp_populate_idt()
uint32_t KABI hal_get_core_id(void)
{
+ // TODO
return 0;
}
@@ -442,17 +439,19 @@ int32_t KABI hal_interrupt_init(void)
hal_read_msr(&ecx, &edx, &eax);
apic_base_reg = ((uint64_t) edx << 32) + (uint64_t) eax;
apic_base = apic_base_reg & lb_bit_field_mask(12, 35);
+
//hal_printf("APIC Base: 0x%X\n", apic_base);
//hal_printf("APIC Enabled: %s\n", apic_base_reg & bit_mask_64(11) ? "Yes" : "No");
//hal_printf("BSP: %s\n", apic_base_reg & bit_mask_64(8) ? "Yes" : "No");
//hal_printf("APIC Spour: 0x%X\n", *(uint32_t *) ((char *) apic_base + APIC_SPURIOUS_INT_VEC_REG_OFFSET));
+
// hardware enable APIC
ecx = MSR_IA32_APIC_BASE;
eax = (uint32_t) ((apic_base_reg & lb_bit_field_mask(0, 31)) | lb_bit_mask(11));
hal_write_msr(&ecx, &edx, &eax);
// software enable APIC
- hal_write_mem_32((char *) apic_base + APIC_SPURIOUS_INT_VEC_REG_OFFSET, *(uint32_t *) (apic_base + APIC_SPURIOUS_INT_VEC_REG_OFFSET) | (uint32_t)lb_bit_mask(8));
+ // hal_write_mem_32((char *) apic_base + APIC_SPURIOUS_INT_VEC_REG_OFFSET, *(uint32_t *) (apic_base + APIC_SPURIOUS_INT_VEC_REG_OFFSET) | (uint32_t)lb_bit_mask(8));
// hal_issue_interrupt(1, 255);
// hal_enable_interrupt();
diff --git a/x64/src/kernel/hal/mem.c b/x64/src/hal/mem.c
similarity index 96%
rename from x64/src/kernel/hal/mem.c
rename to x64/src/hal/mem.c
index f73cd11..da3cc87 100644
--- a/x64/src/kernel/hal/mem.c
+++ b/x64/src/hal/mem.c
@@ -1,13 +1,9 @@
-/* Copyright 2016 secXsQuared
- * Distributed under GPL license
- * See COPYING under root for details
- */
-#include "../common/inc/abi.h"
-#include "../common/inc/type.h"
-#include "mem.h"
-#include "salloc.h"
-#include "arch.h"
-#include "intr.h"
+
+#include "type.h"
+#include "hal/mem.h"
+#include "hal/cpu.h"
+#include "lib/salloc.h"
+#include "hal/intr.h"
static uint8_t _gdts[HAL_CORE_COUNT][GDT_ENTRY_NUM * GDT_ENTRY_SIZE];
static hal_gdt_ptr_t _gdt_ptrs[HAL_CORE_COUNT];
diff --git a/x64/src/kernel/hal/print.c b/x64/src/hal/print.c
similarity index 93%
rename from x64/src/kernel/hal/print.c
rename to x64/src/hal/print.c
index 02952cf..f1893d4 100644
--- a/x64/src/kernel/hal/print.c
+++ b/x64/src/hal/print.c
@@ -3,13 +3,13 @@
* See COPYING under root for details
*/
-#include "abi.h"
#include "type.h"
#include "lib/sxtdlib.h"
-#include "print.h"
+#include "hal/print.h"
+#include "hal/cpu.h"
-#define get_column(pos) (pos % 80)
-#define get_row(pos) (pos / 80)
+#define get_column(pos) ((pos) % 80)
+#define get_row(pos) ((pos) / 80)
#define get_pos(row,col) ((row) * 80 + (col))
static uint64_t text_pos;
@@ -201,3 +201,13 @@ void KABI hal_printf(char const *format, ...)
hal_vprintf(format, args);
va_end(args);
}
+
+void KABI hal_assert(uint32_t expression, char *message)
+{
+ if (!expression)
+ {
+ hal_printf("HAL: Assertion failed. Detail: %s", message == NULL ? "NULL" : message);
+ hal_halt_cpu();
+ }
+ return;
+}
\ No newline at end of file
diff --git a/x64/src/include/abi.h b/x64/src/include/abi.h
deleted file mode 100644
index 940d098..0000000
--- a/x64/src/include/abi.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2016 secXsQuared
- * Distributed under GPL license
- * See COPYING under root for details
- */
-
-#ifndef _G_ABI_H_
-#define _G_ABI_H_
-
-#define KABI __attribute__((sysv_abi))
-#define UAPI __attribute__((sysv_abi))
-
-#endif
diff --git a/x64/src/include/hal/boot.h b/x64/src/include/hal/boot.h
new file mode 100644
index 0000000..4d9210a
--- /dev/null
+++ b/x64/src/include/hal/boot.h
@@ -0,0 +1,6 @@
+#ifndef _HAL_BOOT_H_
+#define _HAL_BOOT_H_
+
+#include "kernel/hal/boot.h"
+
+#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/hal/arch.h b/x64/src/include/hal/cpu.h
similarity index 81%
rename from x64/src/include/kernel/hal/arch.h
rename to x64/src/include/hal/cpu.h
index 02771a8..af175b2 100644
--- a/x64/src/include/kernel/hal/arch.h
+++ b/x64/src/include/hal/cpu.h
@@ -1,8 +1,8 @@
-#ifndef _HAL_ARCH_H_
-#define _HAL_ARCH_H_
+#ifndef _HAL_CPU_H_
+#define _HAL_CPU_H_
-#include "abi.h"
#include "type.h"
+#include "kernel/hal/atomic.h"
#define HAL_CORE_COUNT 1
@@ -18,24 +18,22 @@ typedef struct
uint64_t base;
} STRUCT_PACKED hal_idt_ptr_t;
-extern int32_t KABI hal_interlocked_increment_32(int32_t *target, int32_t increment);
-
-extern int32_t KABI hal_interlocked_compare_exchange_32(int32_t *dst, int32_t compare, int32_t val);
-
-extern int32_t KABI hal_interlocked_exchange_32(int32_t *target, int32_t val);
+/**
+ * CPU Instructions
+ */
extern void KABI hal_cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
-#define MSR_IA32_APIC_BASE 0x1B
-extern void KABI hal_read_msr(uint32_t *ecx, uint32_t *edx, uint32_t *eax);
-
-extern void KABI hal_write_msr(uint32_t *ecx, uint32_t *edx, uint32_t *eax);
+extern void KABI hal_halt_cpu(void);
extern void KABI hal_enable_interrupt(void);
extern void KABI hal_disable_interrupt(void);
-extern void KABI hal_halt_cpu(void);
+
+/**
+ * IO Port Operations
+ */
extern int8_t KABI hal_read_port_8(uint16_t port);
@@ -49,6 +47,11 @@ extern void KABI hal_write_port_16(uint16_t port, uint16_t data);
extern void KABI hal_write_port_32(uint16_t port, uint32_t data);
+
+/**
+ * CPU Structure Operations
+ */
+
extern void KABI hal_flush_gdt(hal_gdt_ptr_t *gdt_ptr, uint64_t code_slct, uint64_t data_slct);
extern void KABI hal_flush_tlb(void);
@@ -57,6 +60,14 @@ extern void KABI hal_flush_idt(hal_idt_ptr_t *idt_ptr);
extern void KABI hal_read_idt(hal_idt_ptr_t **idt_ptr);
+/**
+ * Control Register Operations
+ */
+#define MSR_IA32_APIC_BASE 0x1B
+extern void KABI hal_read_msr(uint32_t *ecx, uint32_t *edx, uint32_t *eax);
+
+extern void KABI hal_write_msr(uint32_t *ecx, uint32_t *edx, uint32_t *eax);
+
extern void KABI hal_write_cr3(uint64_t base);
extern uint64_t KABI hal_read_cr3(void);
@@ -65,4 +76,6 @@ extern void KABI hal_write_cr8(uint64_t pri);
extern uint64_t KABI hal_read_cr8(void);
+
+
#endif
\ No newline at end of file
diff --git a/x64/src/kernel/hal/intr.h b/x64/src/include/hal/intr.h
similarity index 89%
rename from x64/src/kernel/hal/intr.h
rename to x64/src/include/hal/intr.h
index b5b7239..89b1ab1 100644
--- a/x64/src/kernel/hal/intr.h
+++ b/x64/src/include/hal/intr.h
@@ -1,15 +1,25 @@
-/* Copyright 2016 secXsQuared
- * Distributed under GPL license
- * See COPYING under root for details
+#ifndef _HAL_INTR_H_
+#define _HAL_INTR_H_
+
+#include "type.h"
+#include "kernel/hal/intr.h"
+
+/**
+ * Interrupt context structure
*/
+typedef struct
+{
+ const uint64_t rip;
+ const uint64_t cs;
+ const uint64_t rflags;
+ const uint64_t rsp;
+ const uint64_t ss;
+} hal_interrupt_context_t;
-#ifndef _HAL_IO_H_
-#define _HAL_IO_H_
-
-#include "../../../sxkrnl/arch/amd64/intr.h"
-#include "../../common/inc/abi.h"
-#include "../../common/inc/type.h"
+/**
+ * IDT Defns
+ */
#define GATE_DPL_0 (0ull << 13)
#define GATE_DPL_1 (1ull << 13)
#define GATE_DPL_2 (2ull << 13)
@@ -22,556 +32,276 @@
#define IDT_ENTRY_NUM 256
#define IDT_ENTRY_SIZE 16
-#define APIC_SPURIOUS_INT_VEC_REG_OFFSET 0xF0
-#define APIC_LVT_CMCI_REG_OFFSET 0x2F0
-#define APIC_LVT_TIMER_REG_OFFSET 0x320
-#define APIC_LVT_THERMA_MONITOR_REG 0x330
-#define APIC_LVT_PERFORMANCE_COUNTER_REG 0x340
-#define APIC_LVT_LINT0_REG 0x350
-#define APIC_LVT_LINT1_REG 0x360
-#define APIC_LVT_ERROR_REG 0x370
-
-typedef struct
-{
- const uint64_t rip;
- const uint64_t cs;
- const uint64_t rflags;
- const uint64_t rsp;
- const uint64_t ss;
-} hal_intr_context_t;
-
-// SYSTEM INTERRUPT HANDLERS
-extern void KABI hal_interrupt_handler_0(void);
-
-extern void KABI hal_interrupt_handler_1(void);
-
-extern void KABI hal_interrupt_handler_2(void);
-
-extern void KABI hal_interrupt_handler_3(void);
-
-extern void KABI hal_interrupt_handler_4(void);
-
-extern void KABI hal_interrupt_handler_5(void);
-
-extern void KABI hal_interrupt_handler_6(void);
-
-extern void KABI hal_interrupt_handler_7(void);
-
-extern void KABI hal_interrupt_handler_8(void);
-
-extern void KABI hal_interrupt_handler_9(void);
-
-extern void KABI hal_interrupt_handler_10(void);
-
-extern void KABI hal_interrupt_handler_11(void);
-
-extern void KABI hal_interrupt_handler_12(void);
-
-extern void KABI hal_interrupt_handler_13(void);
-
-extern void KABI hal_interrupt_handler_14(void);
-
-extern void KABI hal_interrupt_handler_15(void);
-
-extern void KABI hal_interrupt_handler_16(void);
-
-extern void KABI hal_interrupt_handler_17(void);
-
-extern void KABI hal_interrupt_handler_18(void);
-
-extern void KABI hal_interrupt_handler_19(void);
-
-extern void KABI hal_interrupt_handler_20(void);
-
-extern void KABI hal_interrupt_handler_21(void);
-
-extern void KABI hal_interrupt_handler_22(void);
-
-extern void KABI hal_interrupt_handler_23(void);
-
-extern void KABI hal_interrupt_handler_24(void);
-
-extern void KABI hal_interrupt_handler_25(void);
-
-extern void KABI hal_interrupt_handler_26(void);
-
-extern void KABI hal_interrupt_handler_27(void);
-
-extern void KABI hal_interrupt_handler_28(void);
-
-extern void KABI hal_interrupt_handler_29(void);
-
-extern void KABI hal_interrupt_handler_30(void);
-
-extern void KABI hal_interrupt_handler_31(void);
-
-// USER DEFINED INTERRUPT_HANDLERS
-extern void KABI hal_interrupt_handler_32(void);
-
-extern void KABI hal_interrupt_handler_33(void);
-
-extern void KABI hal_interrupt_handler_34(void);
-
-extern void KABI hal_interrupt_handler_35(void);
-
-extern void KABI hal_interrupt_handler_36(void);
-
-extern void KABI hal_interrupt_handler_37(void);
-
-extern void KABI hal_interrupt_handler_38(void);
-
-extern void KABI hal_interrupt_handler_39(void);
-
-extern void KABI hal_interrupt_handler_40(void);
-
-extern void KABI hal_interrupt_handler_41(void);
-
-extern void KABI hal_interrupt_handler_42(void);
-
-extern void KABI hal_interrupt_handler_43(void);
-
-extern void KABI hal_interrupt_handler_44(void);
-
-extern void KABI hal_interrupt_handler_45(void);
-
-extern void KABI hal_interrupt_handler_46(void);
-
-extern void KABI hal_interrupt_handler_47(void);
-
-extern void KABI hal_interrupt_handler_48(void);
-
-extern void KABI hal_interrupt_handler_49(void);
-
-extern void KABI hal_interrupt_handler_50(void);
-
-extern void KABI hal_interrupt_handler_51(void);
-
-extern void KABI hal_interrupt_handler_52(void);
-
-extern void KABI hal_interrupt_handler_53(void);
-
-extern void KABI hal_interrupt_handler_54(void);
-
-extern void KABI hal_interrupt_handler_55(void);
-
-extern void KABI hal_interrupt_handler_56(void);
-
-extern void KABI hal_interrupt_handler_57(void);
-
-extern void KABI hal_interrupt_handler_58(void);
-
-extern void KABI hal_interrupt_handler_59(void);
-
-extern void KABI hal_interrupt_handler_60(void);
-
-extern void KABI hal_interrupt_handler_61(void);
-
-extern void KABI hal_interrupt_handler_62(void);
-
-extern void KABI hal_interrupt_handler_63(void);
-
-extern void KABI hal_interrupt_handler_64(void);
-
-extern void KABI hal_interrupt_handler_65(void);
-
-extern void KABI hal_interrupt_handler_66(void);
-
-extern void KABI hal_interrupt_handler_67(void);
-
-extern void KABI hal_interrupt_handler_68(void);
-
-extern void KABI hal_interrupt_handler_69(void);
-
-extern void KABI hal_interrupt_handler_70(void);
-
-extern void KABI hal_interrupt_handler_71(void);
-
-extern void KABI hal_interrupt_handler_72(void);
-
-extern void KABI hal_interrupt_handler_73(void);
-
-extern void KABI hal_interrupt_handler_74(void);
-
-extern void KABI hal_interrupt_handler_75(void);
-
-extern void KABI hal_interrupt_handler_76(void);
-
-extern void KABI hal_interrupt_handler_77(void);
-
-extern void KABI hal_interrupt_handler_78(void);
-
-extern void KABI hal_interrupt_handler_79(void);
-
-extern void KABI hal_interrupt_handler_80(void);
-
-extern void KABI hal_interrupt_handler_81(void);
-
-extern void KABI hal_interrupt_handler_82(void);
-
-extern void KABI hal_interrupt_handler_83(void);
-
-extern void KABI hal_interrupt_handler_84(void);
-
-extern void KABI hal_interrupt_handler_85(void);
-
-extern void KABI hal_interrupt_handler_86(void);
-
-extern void KABI hal_interrupt_handler_87(void);
-
-extern void KABI hal_interrupt_handler_88(void);
-
-extern void KABI hal_interrupt_handler_89(void);
-
-extern void KABI hal_interrupt_handler_90(void);
-
-extern void KABI hal_interrupt_handler_91(void);
-
-extern void KABI hal_interrupt_handler_92(void);
-
-extern void KABI hal_interrupt_handler_93(void);
-
-extern void KABI hal_interrupt_handler_94(void);
-
-extern void KABI hal_interrupt_handler_95(void);
-
-extern void KABI hal_interrupt_handler_96(void);
-
-extern void KABI hal_interrupt_handler_97(void);
-
-extern void KABI hal_interrupt_handler_98(void);
-
-extern void KABI hal_interrupt_handler_99(void);
-
-extern void KABI hal_interrupt_handler_100(void);
-
-extern void KABI hal_interrupt_handler_101(void);
-
-extern void KABI hal_interrupt_handler_102(void);
-
-extern void KABI hal_interrupt_handler_103(void);
-
-extern void KABI hal_interrupt_handler_104(void);
-
-extern void KABI hal_interrupt_handler_105(void);
-
-extern void KABI hal_interrupt_handler_106(void);
-
-extern void KABI hal_interrupt_handler_107(void);
-
-extern void KABI hal_interrupt_handler_108(void);
-
-extern void KABI hal_interrupt_handler_109(void);
-
-extern void KABI hal_interrupt_handler_110(void);
-
-extern void KABI hal_interrupt_handler_111(void);
-
-extern void KABI hal_interrupt_handler_112(void);
-
-extern void KABI hal_interrupt_handler_113(void);
-
-extern void KABI hal_interrupt_handler_114(void);
-
-extern void KABI hal_interrupt_handler_115(void);
-
-extern void KABI hal_interrupt_handler_116(void);
-
-extern void KABI hal_interrupt_handler_117(void);
-
-extern void KABI hal_interrupt_handler_118(void);
-
-extern void KABI hal_interrupt_handler_119(void);
-
-extern void KABI hal_interrupt_handler_120(void);
-
-extern void KABI hal_interrupt_handler_121(void);
-
-extern void KABI hal_interrupt_handler_122(void);
-
-extern void KABI hal_interrupt_handler_123(void);
-
-extern void KABI hal_interrupt_handler_124(void);
-
-extern void KABI hal_interrupt_handler_125(void);
-
-extern void KABI hal_interrupt_handler_126(void);
-
-extern void KABI hal_interrupt_handler_127(void);
-
-extern void KABI hal_interrupt_handler_128(void);
-
-extern void KABI hal_interrupt_handler_129(void);
-
-extern void KABI hal_interrupt_handler_130(void);
-
-extern void KABI hal_interrupt_handler_131(void);
-
-extern void KABI hal_interrupt_handler_132(void);
-
-extern void KABI hal_interrupt_handler_133(void);
-
-extern void KABI hal_interrupt_handler_134(void);
-
-extern void KABI hal_interrupt_handler_135(void);
-
-extern void KABI hal_interrupt_handler_136(void);
-
-extern void KABI hal_interrupt_handler_137(void);
-
-extern void KABI hal_interrupt_handler_138(void);
-
-extern void KABI hal_interrupt_handler_139(void);
-
-extern void KABI hal_interrupt_handler_140(void);
-
-extern void KABI hal_interrupt_handler_141(void);
-
-extern void KABI hal_interrupt_handler_142(void);
-
-extern void KABI hal_interrupt_handler_143(void);
-
-extern void KABI hal_interrupt_handler_144(void);
-
-extern void KABI hal_interrupt_handler_145(void);
-
-extern void KABI hal_interrupt_handler_146(void);
-
-extern void KABI hal_interrupt_handler_147(void);
-
-extern void KABI hal_interrupt_handler_148(void);
-
-extern void KABI hal_interrupt_handler_149(void);
-
-extern void KABI hal_interrupt_handler_150(void);
-
-extern void KABI hal_interrupt_handler_151(void);
-
-extern void KABI hal_interrupt_handler_152(void);
-
-extern void KABI hal_interrupt_handler_153(void);
-
-extern void KABI hal_interrupt_handler_154(void);
-
-extern void KABI hal_interrupt_handler_155(void);
-
-extern void KABI hal_interrupt_handler_156(void);
-
-extern void KABI hal_interrupt_handler_157(void);
-
-extern void KABI hal_interrupt_handler_158(void);
-
-extern void KABI hal_interrupt_handler_159(void);
-
-extern void KABI hal_interrupt_handler_160(void);
-
-extern void KABI hal_interrupt_handler_161(void);
-
-extern void KABI hal_interrupt_handler_162(void);
-
-extern void KABI hal_interrupt_handler_163(void);
-
-extern void KABI hal_interrupt_handler_164(void);
-
-extern void KABI hal_interrupt_handler_165(void);
-
-extern void KABI hal_interrupt_handler_166(void);
-
-extern void KABI hal_interrupt_handler_167(void);
-
-extern void KABI hal_interrupt_handler_168(void);
-
-extern void KABI hal_interrupt_handler_169(void);
-
-extern void KABI hal_interrupt_handler_170(void);
-
-extern void KABI hal_interrupt_handler_171(void);
-
-extern void KABI hal_interrupt_handler_172(void);
-
-extern void KABI hal_interrupt_handler_173(void);
-
-extern void KABI hal_interrupt_handler_174(void);
-
-extern void KABI hal_interrupt_handler_175(void);
-
-extern void KABI hal_interrupt_handler_176(void);
-
-extern void KABI hal_interrupt_handler_177(void);
-
-extern void KABI hal_interrupt_handler_178(void);
-
-extern void KABI hal_interrupt_handler_179(void);
-
-extern void KABI hal_interrupt_handler_180(void);
-
-extern void KABI hal_interrupt_handler_181(void);
-
-extern void KABI hal_interrupt_handler_182(void);
-
-extern void KABI hal_interrupt_handler_183(void);
-
-extern void KABI hal_interrupt_handler_184(void);
-
-extern void KABI hal_interrupt_handler_185(void);
-
-extern void KABI hal_interrupt_handler_186(void);
-
-extern void KABI hal_interrupt_handler_187(void);
-
-extern void KABI hal_interrupt_handler_188(void);
-
-extern void KABI hal_interrupt_handler_189(void);
-
-extern void KABI hal_interrupt_handler_190(void);
-
-extern void KABI hal_interrupt_handler_191(void);
-
-extern void KABI hal_interrupt_handler_192(void);
-
-extern void KABI hal_interrupt_handler_193(void);
-
-extern void KABI hal_interrupt_handler_194(void);
-
-extern void KABI hal_interrupt_handler_195(void);
-
-extern void KABI hal_interrupt_handler_196(void);
-
-extern void KABI hal_interrupt_handler_197(void);
-
-extern void KABI hal_interrupt_handler_198(void);
-
-extern void KABI hal_interrupt_handler_199(void);
-
-extern void KABI hal_interrupt_handler_200(void);
-
-extern void KABI hal_interrupt_handler_201(void);
-
-extern void KABI hal_interrupt_handler_202(void);
-
-extern void KABI hal_interrupt_handler_203(void);
-
-extern void KABI hal_interrupt_handler_204(void);
-
-extern void KABI hal_interrupt_handler_205(void);
-
-extern void KABI hal_interrupt_handler_206(void);
-
-extern void KABI hal_interrupt_handler_207(void);
-
-extern void KABI hal_interrupt_handler_208(void);
-
-extern void KABI hal_interrupt_handler_209(void);
-
-extern void KABI hal_interrupt_handler_210(void);
-
-extern void KABI hal_interrupt_handler_211(void);
-
-extern void KABI hal_interrupt_handler_212(void);
-
-extern void KABI hal_interrupt_handler_213(void);
-
-extern void KABI hal_interrupt_handler_214(void);
-
-extern void KABI hal_interrupt_handler_215(void);
-
-extern void KABI hal_interrupt_handler_216(void);
-
-extern void KABI hal_interrupt_handler_217(void);
-
-extern void KABI hal_interrupt_handler_218(void);
-
-extern void KABI hal_interrupt_handler_219(void);
-
-extern void KABI hal_interrupt_handler_220(void);
-
-extern void KABI hal_interrupt_handler_221(void);
-
-extern void KABI hal_interrupt_handler_222(void);
-
-extern void KABI hal_interrupt_handler_223(void);
-
-extern void KABI hal_interrupt_handler_224(void);
-
-extern void KABI hal_interrupt_handler_225(void);
-
-extern void KABI hal_interrupt_handler_226(void);
-
-extern void KABI hal_interrupt_handler_227(void);
-
-extern void KABI hal_interrupt_handler_228(void);
-
-extern void KABI hal_interrupt_handler_229(void);
-
-extern void KABI hal_interrupt_handler_230(void);
-
-extern void KABI hal_interrupt_handler_231(void);
-
-extern void KABI hal_interrupt_handler_232(void);
-
-extern void KABI hal_interrupt_handler_233(void);
-
-extern void KABI hal_interrupt_handler_234(void);
-
-extern void KABI hal_interrupt_handler_235(void);
-
-extern void KABI hal_interrupt_handler_236(void);
-
-extern void KABI hal_interrupt_handler_237(void);
-
-extern void KABI hal_interrupt_handler_238(void);
-
-extern void KABI hal_interrupt_handler_239(void);
-
-extern void KABI hal_interrupt_handler_240(void);
-
-extern void KABI hal_interrupt_handler_241(void);
-
-extern void KABI hal_interrupt_handler_242(void);
-
-extern void KABI hal_interrupt_handler_243(void);
-
-extern void KABI hal_interrupt_handler_244(void);
-
-extern void KABI hal_interrupt_handler_245(void);
-
-extern void KABI hal_interrupt_handler_246(void);
-
-extern void KABI hal_interrupt_handler_247(void);
-
-extern void KABI hal_interrupt_handler_248(void);
-
-extern void KABI hal_interrupt_handler_249(void);
-
-extern void KABI hal_interrupt_handler_250(void);
-
-extern void KABI hal_interrupt_handler_251(void);
-
-extern void KABI hal_interrupt_handler_252(void);
-
-extern void KABI hal_interrupt_handler_253(void);
-
-extern void KABI hal_interrupt_handler_254(void);
-
-extern void KABI hal_interrupt_handler_255(void);
-
-void KABI hal_register_interrupt_handler(uint32_t coreid, uint32_t index, k_intr_handler_t handler, void* context);
-
-void KABI hal_deregister_interrupt_handler(uint32_t coreid, uint32_t index);
-
-void KABI hal_register_exception_handler(uint32_t coreid, uint32_t index, k_exc_handler_t handler);
-
-void KABI hal_deregister_exception_handler(uint32_t coreid, uint32_t index);
-
-void KABI hal_issue_interrupt(uint32_t core_id, uint32_t vector);
-
-void KABI hal_set_interrupt_handler(uint64_t index, void (*handler)(void));
-
-void KABI hal_write_gate(void *const gate, uint64_t const offset, uint32_t const selector, uint32_t const attr);
-
-void KABI hal_assert(int64_t exp, char *message);
+/**
+ * intr.h
+ */
int32_t KABI hal_interrupt_init(void);
-uint32_t KABI hal_get_core_id(void);
+
+/**
+ * System exception Handlers
+ */
+extern void KABI hal_interrupt_handler_0(void);
+extern void KABI hal_interrupt_handler_1(void);
+extern void KABI hal_interrupt_handler_2(void);
+extern void KABI hal_interrupt_handler_3(void);
+extern void KABI hal_interrupt_handler_4(void);
+extern void KABI hal_interrupt_handler_5(void);
+extern void KABI hal_interrupt_handler_6(void);
+extern void KABI hal_interrupt_handler_7(void);
+extern void KABI hal_interrupt_handler_8(void);
+extern void KABI hal_interrupt_handler_9(void);
+extern void KABI hal_interrupt_handler_10(void);
+extern void KABI hal_interrupt_handler_11(void);
+extern void KABI hal_interrupt_handler_12(void);
+extern void KABI hal_interrupt_handler_13(void);
+extern void KABI hal_interrupt_handler_14(void);
+extern void KABI hal_interrupt_handler_15(void);
+extern void KABI hal_interrupt_handler_16(void);
+extern void KABI hal_interrupt_handler_17(void);
+extern void KABI hal_interrupt_handler_18(void);
+extern void KABI hal_interrupt_handler_19(void);
+extern void KABI hal_interrupt_handler_20(void);
+extern void KABI hal_interrupt_handler_21(void);
+extern void KABI hal_interrupt_handler_22(void);
+extern void KABI hal_interrupt_handler_23(void);
+extern void KABI hal_interrupt_handler_24(void);
+extern void KABI hal_interrupt_handler_25(void);
+extern void KABI hal_interrupt_handler_26(void);
+extern void KABI hal_interrupt_handler_27(void);
+extern void KABI hal_interrupt_handler_28(void);
+extern void KABI hal_interrupt_handler_29(void);
+extern void KABI hal_interrupt_handler_30(void);
+extern void KABI hal_interrupt_handler_31(void);
+
+/**
+ * Kernel defined interrupt handlers
+ */
+extern void KABI hal_interrupt_handler_32(void);
+extern void KABI hal_interrupt_handler_33(void);
+extern void KABI hal_interrupt_handler_34(void);
+extern void KABI hal_interrupt_handler_35(void);
+extern void KABI hal_interrupt_handler_36(void);
+extern void KABI hal_interrupt_handler_37(void);
+extern void KABI hal_interrupt_handler_38(void);
+extern void KABI hal_interrupt_handler_39(void);
+extern void KABI hal_interrupt_handler_40(void);
+extern void KABI hal_interrupt_handler_41(void);
+extern void KABI hal_interrupt_handler_42(void);
+extern void KABI hal_interrupt_handler_43(void);
+extern void KABI hal_interrupt_handler_44(void);
+extern void KABI hal_interrupt_handler_45(void);
+extern void KABI hal_interrupt_handler_46(void);
+extern void KABI hal_interrupt_handler_47(void);
+extern void KABI hal_interrupt_handler_48(void);
+extern void KABI hal_interrupt_handler_49(void);
+extern void KABI hal_interrupt_handler_50(void);
+extern void KABI hal_interrupt_handler_51(void);
+extern void KABI hal_interrupt_handler_52(void);
+extern void KABI hal_interrupt_handler_53(void);
+extern void KABI hal_interrupt_handler_54(void);
+extern void KABI hal_interrupt_handler_55(void);
+extern void KABI hal_interrupt_handler_56(void);
+extern void KABI hal_interrupt_handler_57(void);
+extern void KABI hal_interrupt_handler_58(void);
+extern void KABI hal_interrupt_handler_59(void);
+extern void KABI hal_interrupt_handler_60(void);
+extern void KABI hal_interrupt_handler_61(void);
+extern void KABI hal_interrupt_handler_62(void);
+extern void KABI hal_interrupt_handler_63(void);
+extern void KABI hal_interrupt_handler_64(void);
+extern void KABI hal_interrupt_handler_65(void);
+extern void KABI hal_interrupt_handler_66(void);
+extern void KABI hal_interrupt_handler_67(void);
+extern void KABI hal_interrupt_handler_68(void);
+extern void KABI hal_interrupt_handler_69(void);
+extern void KABI hal_interrupt_handler_70(void);
+extern void KABI hal_interrupt_handler_71(void);
+extern void KABI hal_interrupt_handler_72(void);
+extern void KABI hal_interrupt_handler_73(void);
+extern void KABI hal_interrupt_handler_74(void);
+extern void KABI hal_interrupt_handler_75(void);
+extern void KABI hal_interrupt_handler_76(void);
+extern void KABI hal_interrupt_handler_77(void);
+extern void KABI hal_interrupt_handler_78(void);
+extern void KABI hal_interrupt_handler_79(void);
+extern void KABI hal_interrupt_handler_80(void);
+extern void KABI hal_interrupt_handler_81(void);
+extern void KABI hal_interrupt_handler_82(void);
+extern void KABI hal_interrupt_handler_83(void);
+extern void KABI hal_interrupt_handler_84(void);
+extern void KABI hal_interrupt_handler_85(void);
+extern void KABI hal_interrupt_handler_86(void);
+extern void KABI hal_interrupt_handler_87(void);
+extern void KABI hal_interrupt_handler_88(void);
+extern void KABI hal_interrupt_handler_89(void);
+extern void KABI hal_interrupt_handler_90(void);
+extern void KABI hal_interrupt_handler_91(void);
+extern void KABI hal_interrupt_handler_92(void);
+extern void KABI hal_interrupt_handler_93(void);
+extern void KABI hal_interrupt_handler_94(void);
+extern void KABI hal_interrupt_handler_95(void);
+extern void KABI hal_interrupt_handler_96(void);
+extern void KABI hal_interrupt_handler_97(void);
+extern void KABI hal_interrupt_handler_98(void);
+extern void KABI hal_interrupt_handler_99(void);
+extern void KABI hal_interrupt_handler_100(void);
+extern void KABI hal_interrupt_handler_101(void);
+extern void KABI hal_interrupt_handler_102(void);
+extern void KABI hal_interrupt_handler_103(void);
+extern void KABI hal_interrupt_handler_104(void);
+extern void KABI hal_interrupt_handler_105(void);
+extern void KABI hal_interrupt_handler_106(void);
+extern void KABI hal_interrupt_handler_107(void);
+extern void KABI hal_interrupt_handler_108(void);
+extern void KABI hal_interrupt_handler_109(void);
+extern void KABI hal_interrupt_handler_110(void);
+extern void KABI hal_interrupt_handler_111(void);
+extern void KABI hal_interrupt_handler_112(void);
+extern void KABI hal_interrupt_handler_113(void);
+extern void KABI hal_interrupt_handler_114(void);
+extern void KABI hal_interrupt_handler_115(void);
+extern void KABI hal_interrupt_handler_116(void);
+extern void KABI hal_interrupt_handler_117(void);
+extern void KABI hal_interrupt_handler_118(void);
+extern void KABI hal_interrupt_handler_119(void);
+extern void KABI hal_interrupt_handler_120(void);
+extern void KABI hal_interrupt_handler_121(void);
+extern void KABI hal_interrupt_handler_122(void);
+extern void KABI hal_interrupt_handler_123(void);
+extern void KABI hal_interrupt_handler_124(void);
+extern void KABI hal_interrupt_handler_125(void);
+extern void KABI hal_interrupt_handler_126(void);
+extern void KABI hal_interrupt_handler_127(void);
+extern void KABI hal_interrupt_handler_128(void);
+extern void KABI hal_interrupt_handler_129(void);
+extern void KABI hal_interrupt_handler_130(void);
+extern void KABI hal_interrupt_handler_131(void);
+extern void KABI hal_interrupt_handler_132(void);
+extern void KABI hal_interrupt_handler_133(void);
+extern void KABI hal_interrupt_handler_134(void);
+extern void KABI hal_interrupt_handler_135(void);
+extern void KABI hal_interrupt_handler_136(void);
+extern void KABI hal_interrupt_handler_137(void);
+extern void KABI hal_interrupt_handler_138(void);
+extern void KABI hal_interrupt_handler_139(void);
+extern void KABI hal_interrupt_handler_140(void);
+extern void KABI hal_interrupt_handler_141(void);
+extern void KABI hal_interrupt_handler_142(void);
+extern void KABI hal_interrupt_handler_143(void);
+extern void KABI hal_interrupt_handler_144(void);
+extern void KABI hal_interrupt_handler_145(void);
+extern void KABI hal_interrupt_handler_146(void);
+extern void KABI hal_interrupt_handler_147(void);
+extern void KABI hal_interrupt_handler_148(void);
+extern void KABI hal_interrupt_handler_149(void);
+extern void KABI hal_interrupt_handler_150(void);
+extern void KABI hal_interrupt_handler_151(void);
+extern void KABI hal_interrupt_handler_152(void);
+extern void KABI hal_interrupt_handler_153(void);
+extern void KABI hal_interrupt_handler_154(void);
+extern void KABI hal_interrupt_handler_155(void);
+extern void KABI hal_interrupt_handler_156(void);
+extern void KABI hal_interrupt_handler_157(void);
+extern void KABI hal_interrupt_handler_158(void);
+extern void KABI hal_interrupt_handler_159(void);
+extern void KABI hal_interrupt_handler_160(void);
+extern void KABI hal_interrupt_handler_161(void);
+extern void KABI hal_interrupt_handler_162(void);
+extern void KABI hal_interrupt_handler_163(void);
+extern void KABI hal_interrupt_handler_164(void);
+extern void KABI hal_interrupt_handler_165(void);
+extern void KABI hal_interrupt_handler_166(void);
+extern void KABI hal_interrupt_handler_167(void);
+extern void KABI hal_interrupt_handler_168(void);
+extern void KABI hal_interrupt_handler_169(void);
+extern void KABI hal_interrupt_handler_170(void);
+extern void KABI hal_interrupt_handler_171(void);
+extern void KABI hal_interrupt_handler_172(void);
+extern void KABI hal_interrupt_handler_173(void);
+extern void KABI hal_interrupt_handler_174(void);
+extern void KABI hal_interrupt_handler_175(void);
+extern void KABI hal_interrupt_handler_176(void);
+extern void KABI hal_interrupt_handler_177(void);
+extern void KABI hal_interrupt_handler_178(void);
+extern void KABI hal_interrupt_handler_179(void);
+extern void KABI hal_interrupt_handler_180(void);
+extern void KABI hal_interrupt_handler_181(void);
+extern void KABI hal_interrupt_handler_182(void);
+extern void KABI hal_interrupt_handler_183(void);
+extern void KABI hal_interrupt_handler_184(void);
+extern void KABI hal_interrupt_handler_185(void);
+extern void KABI hal_interrupt_handler_186(void);
+extern void KABI hal_interrupt_handler_187(void);
+extern void KABI hal_interrupt_handler_188(void);
+extern void KABI hal_interrupt_handler_189(void);
+extern void KABI hal_interrupt_handler_190(void);
+extern void KABI hal_interrupt_handler_191(void);
+extern void KABI hal_interrupt_handler_192(void);
+extern void KABI hal_interrupt_handler_193(void);
+extern void KABI hal_interrupt_handler_194(void);
+extern void KABI hal_interrupt_handler_195(void);
+extern void KABI hal_interrupt_handler_196(void);
+extern void KABI hal_interrupt_handler_197(void);
+extern void KABI hal_interrupt_handler_198(void);
+extern void KABI hal_interrupt_handler_199(void);
+extern void KABI hal_interrupt_handler_200(void);
+extern void KABI hal_interrupt_handler_201(void);
+extern void KABI hal_interrupt_handler_202(void);
+extern void KABI hal_interrupt_handler_203(void);
+extern void KABI hal_interrupt_handler_204(void);
+extern void KABI hal_interrupt_handler_205(void);
+extern void KABI hal_interrupt_handler_206(void);
+extern void KABI hal_interrupt_handler_207(void);
+extern void KABI hal_interrupt_handler_208(void);
+extern void KABI hal_interrupt_handler_209(void);
+extern void KABI hal_interrupt_handler_210(void);
+extern void KABI hal_interrupt_handler_211(void);
+extern void KABI hal_interrupt_handler_212(void);
+extern void KABI hal_interrupt_handler_213(void);
+extern void KABI hal_interrupt_handler_214(void);
+extern void KABI hal_interrupt_handler_215(void);
+extern void KABI hal_interrupt_handler_216(void);
+extern void KABI hal_interrupt_handler_217(void);
+extern void KABI hal_interrupt_handler_218(void);
+extern void KABI hal_interrupt_handler_219(void);
+extern void KABI hal_interrupt_handler_220(void);
+extern void KABI hal_interrupt_handler_221(void);
+extern void KABI hal_interrupt_handler_222(void);
+extern void KABI hal_interrupt_handler_223(void);
+extern void KABI hal_interrupt_handler_224(void);
+extern void KABI hal_interrupt_handler_225(void);
+extern void KABI hal_interrupt_handler_226(void);
+extern void KABI hal_interrupt_handler_227(void);
+extern void KABI hal_interrupt_handler_228(void);
+extern void KABI hal_interrupt_handler_229(void);
+extern void KABI hal_interrupt_handler_230(void);
+extern void KABI hal_interrupt_handler_231(void);
+extern void KABI hal_interrupt_handler_232(void);
+extern void KABI hal_interrupt_handler_233(void);
+extern void KABI hal_interrupt_handler_234(void);
+extern void KABI hal_interrupt_handler_235(void);
+extern void KABI hal_interrupt_handler_236(void);
+extern void KABI hal_interrupt_handler_237(void);
+extern void KABI hal_interrupt_handler_238(void);
+extern void KABI hal_interrupt_handler_239(void);
+extern void KABI hal_interrupt_handler_240(void);
+extern void KABI hal_interrupt_handler_241(void);
+extern void KABI hal_interrupt_handler_242(void);
+extern void KABI hal_interrupt_handler_243(void);
+extern void KABI hal_interrupt_handler_244(void);
+extern void KABI hal_interrupt_handler_245(void);
+extern void KABI hal_interrupt_handler_246(void);
+extern void KABI hal_interrupt_handler_247(void);
+extern void KABI hal_interrupt_handler_248(void);
+extern void KABI hal_interrupt_handler_249(void);
+extern void KABI hal_interrupt_handler_250(void);
+extern void KABI hal_interrupt_handler_251(void);
+extern void KABI hal_interrupt_handler_252(void);
+extern void KABI hal_interrupt_handler_253(void);
+extern void KABI hal_interrupt_handler_254(void);
+extern void KABI hal_interrupt_handler_255(void);
+
#endif
\ No newline at end of file
diff --git a/x64/src/kernel/hal/mem.h b/x64/src/include/hal/mem.h
similarity index 90%
rename from x64/src/kernel/hal/mem.h
rename to x64/src/include/hal/mem.h
index 1bd707d..2e27ad2 100644
--- a/x64/src/kernel/hal/mem.h
+++ b/x64/src/include/hal/mem.h
@@ -1,24 +1,43 @@
-/* Copyright 2016 secXsQuared
- * Distributed under GPL license
- * See COPYING under root for details
- */
-
#ifndef _HAL_MEM_H_
#define _HAL_MEM_H_
-#include "../../common/inc/abi.h"
-#include "../../common/inc/type.h"
-#include "linked_list.h"
+#include "type.h"
+#include "kernel/hal/mem.h"
+
+/**
+ Global Descriptors Table Definitions
+**/
#define GDT_ENTRY_SIZE 8
#define GDT_ENTRY_NUM 9
+#define SEG_GRANULARITY (1ull << 55)
+#define SEG_LONG (1ull << 53)
+#define SEG_DPL_0 (0ull << 45)
+#define SEG_DPL_1 (1ull << 45)
+#define SEG_DPL_2 (2ull << 45)
+#define SEG_DPL_3 (3ull << 45)
+#define SEG_PRESENT (1ull << 47)
+#define SEG_CODE_DATA (1ull << 44)
+#define SEG_TYPE_DATA_RW (2ull << 40)
+#define SEG_TYPE_DATA_R (0ull << 40)
+#define SEG_TYPE_CODE_X (8ull << 40)
+#define SEG_TYPE_CODE_XR (10ull << 40)
+#define SEG_TYPE_CODE_XC (12ull << 40)
+#define SEG_TYPE_CODE_XRC (14ull << 40)
+#define SEG_AVAILABLE (1ull << 52)
+#define SEG_32_BITS (1ull << 54)
static inline uint32_t KABI seg_selector(uint32_t index, uint32_t rpl)
{
return (index << 3) + rpl;
}
+void KABI hal_write_segment_descriptor(void *const gdt, uint32_t const base, uint32_t const limit, uint64_t const attr);
+
+/**
+ Page Table Definitions
+**/
#define PML4_PRESENT (1ull << 0)
#define PML4_WRITE (1ull << 1)
@@ -55,23 +74,6 @@ static inline uint32_t KABI seg_selector(uint32_t index, uint32_t rpl)
#define PT_GLOBAL (1ull << 8)
#define PT_EXECUTION_DISABLED (1ull << 63)
-#define SEG_GRANULARITY (1ull << 55)
-#define SEG_LONG (1ull << 53)
-#define SEG_DPL_0 (0ull << 45)
-#define SEG_DPL_1 (1ull << 45)
-#define SEG_DPL_2 (2ull << 45)
-#define SEG_DPL_3 (3ull << 45)
-#define SEG_PRESENT (1ull << 47)
-#define SEG_CODE_DATA (1ull << 44)
-#define SEG_TYPE_DATA_RW (2ull << 40)
-#define SEG_TYPE_DATA_R (0ull << 40)
-#define SEG_TYPE_CODE_X (8ull << 40)
-#define SEG_TYPE_CODE_XR (10ull << 40)
-#define SEG_TYPE_CODE_XC (12ull << 40)
-#define SEG_TYPE_CODE_XRC (14ull << 40)
-#define SEG_AVAILABLE (1ull << 52)
-#define SEG_32_BITS (1ull << 54)
-
#define PML4_ENTRY_NUM(mem) ((mem) / (4096ull * 512ull * 512ull * 512ull))
#define PDPT_ENTRY_NUM(mem) ((mem) / (4096ull * 512ull * 512ull))
#define PD_ENTRY_NUM(mem) ((mem) / (4096ull*512ull))
@@ -79,16 +81,6 @@ static inline uint32_t KABI seg_selector(uint32_t index, uint32_t rpl)
#define PAGE_ENTRY_BASE(PAGE_ENTRY) ((PAGE_ENTRY) & 0xFFFFFFFFFF000)
-#define PHYSICAL_PAGE_SIZE 4096
-
-void* KABI halloc(uint32_t size);
-
-void KABI hfree(void *ptr);
-
-void KABI hal_mem_init();
-
-void KABI hal_write_segment_descriptor(void *const gdt, uint32_t const base, uint32_t const limit, uint64_t const attr);
-
void KABI hal_write_pml4_entry(void *const base, uint64_t const pdpt_addr, uint64_t const attr);
void KABI hal_write_pdpt_entry(void *const base, uint64_t const pd_addr, uint64_t const attr);
@@ -97,4 +89,15 @@ void KABI hal_write_pd_entry(void *const base, uint64_t const pt_addr, uint64_t
void KABI hal_write_pt_entry(void *const base, uint64_t const p_addr, uint64_t const attr);
-#endif
+
+/**
+ Function Defn
+**/
+
+void *KABI halloc(uint32_t size);
+
+void KABI hfree(void *ptr);
+
+void KABI hal_mem_init();
+
+#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/hal/multiboot.h b/x64/src/include/hal/multiboot.h
similarity index 99%
rename from x64/src/include/kernel/hal/multiboot.h
rename to x64/src/include/hal/multiboot.h
index 5e68068..55fbaa4 100644
--- a/x64/src/include/kernel/hal/multiboot.h
+++ b/x64/src/include/hal/multiboot.h
@@ -19,8 +19,8 @@
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef MULTIBOOT_HEADER
-#define MULTIBOOT_HEADER 1
+#ifndef _HAL_MULTIBOOT_H_
+#define _HAL_MULTIBOOT_H_
/* How many bytes from the start of the file we search for the header. */
#define MULTIBOOT_SEARCH 32768
diff --git a/x64/src/include/hal/print.h b/x64/src/include/hal/print.h
new file mode 100644
index 0000000..aaa5643
--- /dev/null
+++ b/x64/src/include/hal/print.h
@@ -0,0 +1,15 @@
+#ifndef _HAL_PRINT_H_
+#define _HAL_PRINT_H_
+
+#include "type.h"
+#include "kernel/hal/print.h"
+
+void KABI hal_assert(uint32_t expression, char *message);
+
+void KABI hal_printf(const char *str, ...);
+
+void KABI hal_clear_screen();
+
+void KABI hal_print_init();
+
+#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/hal/atomic.h b/x64/src/include/kernel/hal/atomic.h
index a03702f..4cab10d 100644
--- a/x64/src/include/kernel/hal/atomic.h
+++ b/x64/src/include/kernel/hal/atomic.h
@@ -1,8 +1,12 @@
-#ifndef _S_ATOMIC_H_
-#define _S_ATOMIC_H_
-#include "abi.h"
+#ifndef _KERNEL_HAL_ATOMIC_H_
+#define _KERNEL_HAL_ATOMIC_H_
+
#include "type.h"
+/**
+ * Atomic operations
+ */
+
extern int32_t KABI hal_interlocked_exchange_32(int32_t *target, int32_t val);
extern int32_t KABI hal_interlocked_increment_32(int32_t *target, int32_t increment);
diff --git a/x64/src/include/kernel/hal/boot.h b/x64/src/include/kernel/hal/boot.h
index a68f4f3..d64346d 100644
--- a/x64/src/include/kernel/hal/boot.h
+++ b/x64/src/include/kernel/hal/boot.h
@@ -1,24 +1,22 @@
-#ifndef _S_BOOT_H_
-#define _S_BOOT_H_
+#ifndef _KERNEL_HAL_BOOT_H_
+#define _KERNEL_HAL_BOOT_H_
-#include "../../abi.h"
-#include "../../../mm/arch/amd64/mm.h"
-#include "intr.h"
-#include "../../status.h"
+#include "type.h"
+#include "kernel/hal/intr.h"
+#include "kernel/hal/mem.h"
+
+/**
+ * Required OS boot info
+ */
-//
-// HAL Boot Info
-//
typedef struct
{
- uint64_t krnl_start;
- uint64_t krnl_end;
+ virtual_addr_t krnl_start;
+ virtual_addr_t krnl_end;
intr_info_t intr_info;
- pmm_info_t* pmm_info;
char cpu_vd_str[13];
} boot_info_t;
-extern status_t KABI hal_init (_IN void* multiboot_info,
- _OUT boot_info_t** boot_info);
+void KABI ke_main(boot_info_t* info);
#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/hal/context.h b/x64/src/include/kernel/hal/context.h
deleted file mode 100644
index 6b33b12..0000000
--- a/x64/src/include/kernel/hal/context.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _S_CONTEXT_H_
-#define _S_CONTEXT_H_
-
-#include "abi.h"
-#include "../../../mm/arch/amd64/mem.h"
-#include "intr.h"
-
-// This function should never return and directly context switches to the target
-// on x86, it should save the context, switch stack, build exc frame and iret
-// This function always assumes interrupt context
-extern void KABI hal_context_switch(void *intr_stack,
- void *cur_context, void *next_context,
- physical_addr_t old_addr_space,
- physical_addr_t next_addr_space);
-
-extern void KABI hal_create_context(void *context, void *pc, void *sp, void *ksp, irql_t irql, void *arg);
-
-extern void KABI hal_destroy_context(void *context);
-
-#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/hal/intr.h b/x64/src/include/kernel/hal/intr.h
index a037561..7edf3ec 100644
--- a/x64/src/include/kernel/hal/intr.h
+++ b/x64/src/include/kernel/hal/intr.h
@@ -1,9 +1,24 @@
-#ifndef _S_INTR_H_
-#define _S_INTR_H_
+#ifndef _KERNEL_HAL_INTR_H_
+#define _KERNEL_HAL_INTR_H_
-#include "abi.h"
#include "type.h"
+/**
+ * IRQL Definitions
+ */
+typedef uint32_t irql_t;
+#define IRQL_DISABLED_LEVEL (1 << 3)
+#define IRQL_DPC_LEVEL (1 << 2)
+#define IRQL_APC_LEVEL (1 << 1)
+#define IRQL_PASSIVE_LEVEL (1 << 0)
+
+irql_t KABI hal_set_irql(irql_t irql);
+irql_t KABI hal_get_irql(void);
+uint32_t KABI hal_get_core_id(void);
+
+/**
+ * Interrupt Handler Registration
+ */
typedef struct
{
uint32_t timer_intr_vec;
@@ -11,6 +26,15 @@ typedef struct
uint32_t dpc_intr_vec;
} intr_info_t;
+typedef void (KABI * intr_handler_t)(void *context, void *intr_stack);
+
+void KABI hal_register_interrupt_handler(uint32_t coreid, uint32_t index, intr_handler_t handler, void* context);
+
+void KABI hal_deregister_interrupt_handler(uint32_t coreid, uint32_t index);
+
+/**
+ * Exception Handler Registration
+ */
typedef enum
{
unrecoverable_exc,
@@ -22,51 +46,10 @@ typedef enum
debug_exc
} exc_type_t;
-// IRQL APIs
-typedef uint32_t irql_t;
-#define K_IRQL_DISABLED_LEVEL (1 << 3)
-#define K_IRQL_DPC_LEVEL (1 << 2)
-#define K_IRQL_APC_LEVEL (1 << 1)
-#define K_IRQL_PASSIVE_LEVEL (1 << 0)
+typedef void (KABI *exc_handler_t)(uint64_t exc_addr, uint64_t exc_stack, uint64_t error_code);
-//
-// interrupt functions
-//
-extern void KABI hal_disable_interrupt(void);
+void KABI hal_register_exception_handler(uint32_t coreid, uint32_t index, exc_handler_t handler);
-extern void KABI hal_enable_interrupt(void);
-
-extern void KABI hal_set_timer_timeout(uint64_t millis);
-
-extern void KABI hal_halt_cpu(void);
-
-extern int32_t KABI hal_get_current_core(void);
-
-extern void KABI hal_set_irql(irql_t irql);
-
-extern irql_t KABI hal_get_irql(void);
-
-extern void KABI hal_issue_interrupt(uint32_t core_id, uint32_t vector);
-
-//
-// Interrupt handler registration
-//
-// context is a parameter passed by the kernel. HAL must pass back.
-// intr_stack is a parameter passed by the HAL. Used by some HAL interrupt context functions.
-//
-typedef void (KABI * k_intr_handler_t)(void *context, void *intr_stack);
-
-extern void KABI hal_register_intr_handler(uint32_t index, k_intr_handler_t handler, void *context);
-
-extern k_intr_handler_t KABI hal_deregister_intr_handler(uint32_t index);
-
-//
-// Exception handler registration
-//
-typedef void (KABI *k_exc_handler_t)(uint64_t exc_addr, uint64_t exc_stack, uint64_t error_code);
-
-extern void KABI ke_register_exc_handler(exc_type_t type, k_exc_handler_t handler);
-
-extern k_exc_handler_t KABI ke_deregister_exc_handler(uint64_t index);
+void KABI hal_deregister_exception_handler(uint32_t coreid, uint32_t index);
#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/hal/mem.h b/x64/src/include/kernel/hal/mem.h
new file mode 100644
index 0000000..65161c6
--- /dev/null
+++ b/x64/src/include/kernel/hal/mem.h
@@ -0,0 +1,56 @@
+#ifndef _KERNEL_HAL_MEM_H_
+#define _KERNEL_HAL_MEM_H_
+
+#include "type.h"
+#include "lib/linked_list.h"
+
+/**
+ Kernel Memory Layout
+**/
+typedef uintptr_t physical_addr_t;
+typedef uintptr_t virtual_addr_t;
+
+#define KERNEL_PAGE_SIZE (0x1000ull)
+
+#define KERNEL_AREA_START_VADDR (0xFFFF800000000000ull)
+#define KERNEL_AREA_SIZE (0xFFFFFFFFFFFFFFFF - KERNEL_AREA_START_VADDR + 1)
+
+#define KERNEL_PAGE_TABLE_VADDR (0xFFFFFF0000000000ull)
+#define KERNEL_PAGE_TABLE_SIZE (0x8000000000ull)
+
+// 510 GB
+#define KERNEL_DYN_VADDR (KERNEL_PAGE_TABLE_VADDR + KERNEL_PAGE_TABLE_SIZE)
+#define KERNEL_DYN_SIZE (0x7F80000000ull)
+
+#define KERNEL_HEAP_VADDR KERNEL_DYN_VADDR
+#define KERNEL_INITIAL_HEAP_SIZE (0x1000ull)
+
+#define KERNEL_INITIAL_STACK_SIZE (0x1000ull)
+#define KERNEL_STACK_VADDR (KERNEL_DYN_VADDR + KERNEL_DYN_SIZE - KERNEL_INITIAL_STACK_SIZE)
+
+// address space that is reserved for HAL to map its own stuff
+#define KERNEL_HAL_VADDR (KERNEL_DYN_VADDR + KERNEL_DYN_SIZE)
+// 16MB Virtual Address Space
+#define KERNEL_HAL_VADDR_LIMIT (0x1000000ull)
+
+#define KERNEL_LOAD_VADDR (KERNEL_HAL_VADDR + KERNEL_HAL_VADDR_LIMIT)
+#define KERNEL_LOAD_SIZE (0xFFFFFFFFFFFFFFFF - KERNEL_LOAD_VADDR + 1)
+
+/**
+ * PMM init info
+ */
+typedef struct
+{
+ physical_addr_t base;
+ uint64_t size;
+ uint32_t attr;
+} pmm_node_t;
+
+typedef struct
+{
+ uint32_t num_of_nodes;
+ pmm_node_t nodes[];
+} pmm_info_t;
+
+
+#endif
diff --git a/x64/src/include/kernel/hal/print.h b/x64/src/include/kernel/hal/print.h
index e7ae056..88371c2 100644
--- a/x64/src/include/kernel/hal/print.h
+++ b/x64/src/include/kernel/hal/print.h
@@ -1,13 +1,8 @@
-#ifndef _S_PRINT_H_
-#define _S_PRINT_H_
+#ifndef _KERNEL_HAL_PRINT_H_
+#define _KERNEL_HAL_PRINT_H_
-#include "abi.h"
#include "type.h"
-void KABI hal_printf(const char* str, ...);
void KABI hal_vprintf(const char* str, va_list args);
-void KABI hal_clear_screen();
-void KABI hal_print_init();
-
#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/hal/status.h b/x64/src/include/kernel/hal/status.h
new file mode 100644
index 0000000..e17181f
--- /dev/null
+++ b/x64/src/include/kernel/hal/status.h
@@ -0,0 +1,4 @@
+#ifndef _KERNEL_HAL_STATUS_H_
+#define _KERNEL_HAL_STATUS_H_
+
+#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/ke/alloc.h b/x64/src/include/kernel/ke/alloc.h
index f96ad17..926a915 100644
--- a/x64/src/include/kernel/ke/alloc.h
+++ b/x64/src/include/kernel/ke/alloc.h
@@ -1,6 +1,6 @@
-#ifndef _ALLOC_H_
-#define _ALLOC_H_
-#include "abi.h"
+#ifndef _KERNEL_KE_ALLOC_H_
+#define _KERNEL_KE_ALLOC_H_
+
#include "type.h"
void KABI ke_alloc_init();
diff --git a/x64/src/include/kernel/ke/assert.h b/x64/src/include/kernel/ke/assert.h
index dffec86..48221ba 100644
--- a/x64/src/include/kernel/ke/assert.h
+++ b/x64/src/include/kernel/ke/assert.h
@@ -1,8 +1,7 @@
-#ifndef _ASSERT_H_
-#define _ASSERT_H_
+#ifndef _KERNEL_KE_ASSERT_H_
+#define _KERNEL_KE_ASSERT_H_
#include "type.h"
-#include "abi.h"
void KABI ke_assert_ex(const char* expr_str, const char* file, int32_t line, int32_t expr);
diff --git a/x64/src/include/kernel/ke/atomic.h b/x64/src/include/kernel/ke/atomic.h
index 8ff1841..bad3a23 100644
--- a/x64/src/include/kernel/ke/atomic.h
+++ b/x64/src/include/kernel/ke/atomic.h
@@ -1,8 +1,8 @@
-#ifndef _ATOMIC_H_
-#define _ATOMIC_H_
+#ifndef _KERNEL_KE_ATOMIC_H_
+#define _KERNEL_KE_ATOMIC_H_
-#include "../../../common/inc/type.h"
-#include "../../../common/inc/abi.h"
+#include "type.h"
+#include "kernel/hal/atomic.h"
int32_t KABI ke_interlocked_exchange_32(int32_t *target, int32_t val);
diff --git a/x64/src/include/kernel/ke/boot.h b/x64/src/include/kernel/ke/boot.h
new file mode 100644
index 0000000..4b0ef19
--- /dev/null
+++ b/x64/src/include/kernel/ke/boot.h
@@ -0,0 +1,6 @@
+#ifndef _KERNEL_KE_BOOT_H_
+#define _KERNEL_KE_BOOT_H_
+
+#include "kernel/hal/boot.h"
+
+#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/ke/bug_check.h b/x64/src/include/kernel/ke/bug_check.h
index 9d44462..8d6425b 100644
--- a/x64/src/include/kernel/ke/bug_check.h
+++ b/x64/src/include/kernel/ke/bug_check.h
@@ -1,12 +1,10 @@
-#ifndef _BUG_CHECK_H_
-#define _BUG_CHECK_H_
+#ifndef _KERNEL_KE_BUG_CHECK_H_
+#define _KERNEL_KE_BUG_CHECK_H_
-#include "../../../common/inc/type.h"
-#include "../../../common/inc/abi.h"
-#include "intr.h"
+#include "type.h"
-#define K_BUG_CHECK_IRQL_MISMATCH 0
-#define K_BUG_CHECK_PMM_UNALIGNED 1
+#define BUG_CHECK_IRQL_MISMATCH 0
+#define BUG_CHECK_PMM_UNALIGNED 1
void KABI ke_bug_check(uint64_t reason);
diff --git a/x64/src/include/kernel/ke/intr.h b/x64/src/include/kernel/ke/intr.h
index 87a40ae..3271b84 100644
--- a/x64/src/include/kernel/ke/intr.h
+++ b/x64/src/include/kernel/ke/intr.h
@@ -1,9 +1,8 @@
-#ifndef _INTR_H_
-#define _INTR_H_
+#ifndef _KERNEL_KE_INTR_H_
+#define _KERNEL_KE_INTR_H_
-#include "../../arch/amd64/intr.h"
-#include "../../../common/inc/type.h"
-#include "../../../common/inc/abi.h"
+#include "kernel/hal/intr.h"
+#include "type.h"
irql_t KABI ke_raise_irql(irql_t irql);
@@ -13,4 +12,6 @@ int KABI ke_get_current_core();
irql_t KABI ke_get_irql();
+void KABI ke_halt_cpu();
+
#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/ke/print.h b/x64/src/include/kernel/ke/print.h
index f3da1dc..a9889bf 100644
--- a/x64/src/include/kernel/ke/print.h
+++ b/x64/src/include/kernel/ke/print.h
@@ -1,7 +1,8 @@
-#ifndef _KE_PRINT_H_
-#define _KE_PRINT_H_
+#ifndef _KERNEL_KE_PRINT_H_
+#define _KERNEL_KE_PRINT_H_
-#include "abi.h"
+#include "type.h"
+#include "kernel/hal/print.h"
void KABI ke_printf(const char* str, ...);
void KABI ke_vprintf(const char* str, va_list args);
diff --git a/x64/src/include/kernel/ke/rwwlock.h b/x64/src/include/kernel/ke/rwwlock.h
index 299a8a2..8668983 100644
--- a/x64/src/include/kernel/ke/rwwlock.h
+++ b/x64/src/include/kernel/ke/rwwlock.h
@@ -1,7 +1,7 @@
-#ifndef _RWLOCK_H_
-#define _RWLOCK_H_
-#include "spin_lock.h"
-#include "../../../common/inc/type.h"
+#ifndef _KERNEL_KE_RWLOCK_H_
+#define _KERNEL_KE_RWLOCK_H_
+#include "kernel/ke/spin_lock.h"
+#include "type.h"
typedef struct
{
diff --git a/x64/src/include/kernel/ke/spin_lock.h b/x64/src/include/kernel/ke/spin_lock.h
index cf69a2c..b5850a6 100644
--- a/x64/src/include/kernel/ke/spin_lock.h
+++ b/x64/src/include/kernel/ke/spin_lock.h
@@ -1,9 +1,8 @@
-#ifndef _SPIN_LOCK_H_
-#define _SPIN_LOCK_H_
+#ifndef _KERNEL_KE_SPIN_LOCK_H_
+#define _KERNEL_KE_SPIN_LOCK_H_
-#include "../../../common/inc/type.h"
-#include "../../../common/inc/abi.h"
-#include "intr.h"
+#include "type.h"
+#include "kernel/ke/intr.h"
typedef struct
{
diff --git a/x64/src/include/kernel/ke/status.h b/x64/src/include/kernel/ke/status.h
index 46f6e89..d19e6ca 100644
--- a/x64/src/include/kernel/ke/status.h
+++ b/x64/src/include/kernel/ke/status.h
@@ -1,8 +1,11 @@
-#ifndef _STATUS_H_
-#define _STATUS_H_
+#ifndef _KERNEL_KE_STATUS_H_
+#define _KERNEL_KE_STATUS_H_
#include "type.h"
-#include "sxtdlib.h"
+#include "lib/sxtdlib.h"
+#include "kernel/hal/status.h"
+
+typedef uint32_t status_t;
//
// 32 bit ints
@@ -51,6 +54,4 @@ enum _status_t
PMM_STATUS_NOT_ENOUGH_PAGE = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_PMM, 5),
};
-typedef uint32_t status_t;
-
#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/mm/mem.h b/x64/src/include/kernel/mm/mem.h
index 185c222..f7223fb 100644
--- a/x64/src/include/kernel/mm/mem.h
+++ b/x64/src/include/kernel/mm/mem.h
@@ -1,75 +1,6 @@
-#ifndef _S_VMM_H_
-#define _S_VMM_H_
+#ifndef _KERNEL_MM_MEM_H_
+#define _KERNEL_MM_MEM_H_
-#include "abi.h"
-#include "type.h"
-
-typedef uintptr_t address_space_t;
-typedef uintptr_t physical_addr_t;
-typedef uintptr_t virtual_addr_t;
-
-#define KERNEL_PAGE_SIZE (0x1000ull)
-
-#define KERNEL_AREA_START_VADDR (0xFFFF800000000000ull)
-#define KERNEL_AREA_SIZE (0xFFFFFFFFFFFFFFFF - KERNEL_AREA_START_VADDR + 1)
-
-#define KERNEL_PAGE_TABLE_VADDR (0xFFFFFF0000000000ull)
-#define KERNEL_PAGE_TABLE_SIZE (0x8000000000ull)
-
-// 510 GB
-#define KERNEL_DYN_VADDR (KERNEL_PAGE_TABLE_VADDR + KERNEL_PAGE_TABLE_SIZE)
-#define KERNEL_DYN_SIZE (0x7F80000000ull)
-
-#define KERNEL_HEAP_VADDR KERNEL_DYN_VADDR
-#define KERNEL_INITIAL_HEAP_SIZE (0x1000ull)
-
-#define KERNEL_INITIAL_STACK_SIZE (0x1000ull)
-#define KERNEL_STACK_VADDR (KERNEL_DYN_VADDR + KERNEL_DYN_SIZE - KERNEL_INITIAL_STACK_SIZE)
-
-// address space that is reserved for HAL to map its own stuff
-#define KERNEL_HAL_VADDR (KERNEL_DYN_VADDR + KERNEL_DYN_SIZE)
-// 16MB Virtual Address Space
-#define KERNEL_HAL_VADDR_LIMIT (0x1000000ull)
-
-#define KERNEL_LOAD_VADDR (KERNEL_HAL_VADDR + KERNEL_HAL_VADDR_LIMIT)
-#define KERNEL_LOAD_SIZE (0xFFFFFFFFFFFFFFFF - KERNEL_LOAD_VADDR + 1)
-
-//
-// all the address spaces passed by the kernel would be initialized by k_create_address_space
-// which means the kernel area/ as well as the HAL reserved vaddr ranges would be properly mapped
-//
-
-typedef physical_addr_t (KABI *page_alloc_func_t)();
-
-typedef void (KABI *page_free_func_t)(physical_addr_t page);
-
-#define K_PAGE_ATTR_KERNEL (1 << 2)
-#define K_PAGE_ATTR_CACHED (1 << 3)
-#define K_PAGE_ATTR_NOT_EXECUTABLE (1 << 63)
-#define K_PAGE_ATTR_WRITABLE (1 << 1)
-
-// this function should map the v_addr to p_addr for the target address space
-extern void KABI hal_map_virtual_addr(physical_addr_t addr_space,
- virtual_addr_t v_addr,
- physical_addr_t p_addr,
- uint64_t attribute,
- page_alloc_func_t alloc);
-
-// this function always returns the physical address of the new address space
-// the function should identity refer to the virtual address K_BASE_VADDR to K_END_VADDR according to the current address space
-// so that these pages are global (modifying the mapping in this area affects everyone)
-// the K_BASE_VADDR to K_END_VADDR includes the reserved virtual addr space by the HAL
-// if HAL's reserved virtual addr will be mapped to different physical pages, the HAL should make the change
-address_space_t KABI hal_create_address_space(address_space_t address_space,
- page_alloc_func_t alloc);
-
-// this function destroys the target address space without destroying the K_BASE_VADDR to K_END_VADDR
-// target_addr_space is guaranteed to be not the same as the current address space
-// when the function returns, the current address space must stay unchanged
-void KABI hal_destroy_address_space(address_space_t address_space,
- page_free_func_t free);
-
-// as the name implies
-void KABI hal_switch_address_space(address_space_t target_addr_space);
+#include "kernel/hal/mem.h"
#endif
\ No newline at end of file
diff --git a/x64/src/include/kernel/mm/pmm.h b/x64/src/include/kernel/mm/pmm.h
index 7b5e55a..c657550 100644
--- a/x64/src/include/kernel/mm/pmm.h
+++ b/x64/src/include/kernel/mm/pmm.h
@@ -1,12 +1,12 @@
#ifndef _PMM_H_
#define _PMM_H_
-#include "avl_tree.h"
-#include "linked_list.h"
-#include "../../../common/inc/abi.h"
-#include "../arch/amd64/mm.h"
-#include "atomic.h"
-#include "../../../common/inc/status.h"
+#include "type.h"
+#include "lib/avl_tree.h"
+#include "lib/linked_list.h"
+#include "kernel/mm/mem.h"
+#include "kernel/ke/atomic.h"
+#include "kernel/ke/status.h"
//#define PMM_PAGE_ATTR_FREE_BIT 0
//#define PMM_PAGE_ATTR_PAGED_BIT 1
diff --git a/x64/src/include/kernel/mm/vmm.h b/x64/src/include/kernel/mm/vmm.h
deleted file mode 100644
index 7d38f42..0000000
--- a/x64/src/include/kernel/mm/vmm.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _K_VMM_H_
-#define _K_VMM_H_
-
-#include "../arch/amd64/mem.h"
-#include "avl_tree.h"
-#include "atomic.h"
-#include "spin_lock.h"
-
-#define VMM_STATUS_SUCCESS 0
-#define VMM_STATUS_INVALID_ARGUMENTS 1
-#define VMM_STATUS_CANNOT_ALLOC_NODE 2
-
-typedef struct
-{
- uint32_t attr;
-} virtual_addr_attribute_t;
-
-typedef struct
-{
- avl_tree_t region_tree;
- _Bool initialized;
- k_spin_lock_t lock;
-} vmm_descriptor_t;
-
-int32_t KABI mm_vmm_init(vmm_descriptor_t *desc);
-
-int32_t KABI mm_alloc_virtual_address(vmm_descriptor_t *desc,
- virtual_addr_t base,
- uint64_t size,
- virtual_addr_attribute_t attr);
-
-int64_t KABI mm_query_virtual_address(vmm_descriptor_t *desc, virtual_addr_t v_addr, uint64_t *out);
-
-int64_t KABI mm_free_virtual_address(vmm_descriptor_t *desc, virtual_addr_t base);
-
-#endif
diff --git a/x64/src/include/kernel/rf/ref.h b/x64/src/include/kernel/rf/ref.h
index a2b127a..3f66f56 100644
--- a/x64/src/include/kernel/rf/ref.h
+++ b/x64/src/include/kernel/rf/ref.h
@@ -1,8 +1,8 @@
#ifndef _K_REF_H_
#define _K_REF_H_
-#include "../../../common/inc/type.h"
-#include "../../../common/inc/status.h"
+#include "type.h"
+#include "kernel/ke/status.h"
typedef uint32_t handle_t;
diff --git a/x64/src/include/lib/avl_tree.h b/x64/src/include/lib/avl_tree.h
index 3adf41d..b9188a9 100644
--- a/x64/src/include/lib/avl_tree.h
+++ b/x64/src/include/lib/avl_tree.h
@@ -3,12 +3,11 @@
* See COPYING under root for details
*/
-#ifndef _K_AVL_TREE_H_
-#define _K_AVL_TREE_H_
+#ifndef _LIB_AVL_TREE_H_
+#define _LIB_AVL_TREE_H_
-#include "../../common/inc/type.h"
-#include "../../common/inc/abi.h"
-#include "sxtdlib.h"
+#include "type.h"
+#include "lib/sxtdlib.h"
typedef struct _k_avl_tree_node_t
{
diff --git a/x64/src/include/lib/linked_list.h b/x64/src/include/lib/linked_list.h
index 4d31696..d385f7f 100644
--- a/x64/src/include/lib/linked_list.h
+++ b/x64/src/include/lib/linked_list.h
@@ -3,11 +3,10 @@
* See COPYING under root for details
*/
-#ifndef _K_LINKED_LIST_H_
-#define _K_LINKED_LIST_H_
+#ifndef _LIB_LINKED_LIST_H_
+#define _LIB_LINKED_LIST_H_
-#include "../../common/inc/abi.h"
-#include "../../common/inc/type.h"
+#include "type.h"
typedef struct _linked_list_node_t
{
diff --git a/x64/src/include/lib/salloc.h b/x64/src/include/lib/salloc.h
index 9e270c2..dce3d53 100644
--- a/x64/src/include/lib/salloc.h
+++ b/x64/src/include/lib/salloc.h
@@ -3,11 +3,10 @@
* See COPYING under root for details
*/
-#ifndef _SALLOC_H_
-#define _SALLOC_H_
+#ifndef _LIB_SALLOC_H_
+#define _LIB_SALLOC_H_
-#include "../../common/inc/abi.h"
-#include "../../common/inc/type.h"
+#include "type.h"
void KABI lb_salloc_init(void *base, uint32_t size);
diff --git a/x64/src/include/lib/sxtdlib.h b/x64/src/include/lib/sxtdlib.h
index 8a66689..c0e50a5 100644
--- a/x64/src/include/lib/sxtdlib.h
+++ b/x64/src/include/lib/sxtdlib.h
@@ -3,11 +3,10 @@
* See COPYING under root for details
*/
-#ifndef _STD_LIB_H_
-#define _STD_LIB_H_
+#ifndef _LIB_SXTDLIB_H_
+#define _LIB_SXTDLIB_H_
-#include "../../common/inc/abi.h"
-#include "../../common/inc/type.h"
+#include "type.h"
uint32_t KABI rand( void );
diff --git a/x64/src/test/inc/driver.h b/x64/src/include/test/driver.h
similarity index 55%
rename from x64/src/test/inc/driver.h
rename to x64/src/include/test/driver.h
index b6c8194..8563333 100644
--- a/x64/src/test/inc/driver.h
+++ b/x64/src/include/test/driver.h
@@ -1,8 +1,7 @@
-#ifndef _K_TEST_DRIVER_H_
-#define _K_TEST_DRIVER_H_
+#ifndef _TEST_DRIVER_H_
+#define _TEST_DRIVER_H_
-#include "../../common/inc/type.h"
-#include "../../common/inc/abi.h"
+#include "type.h"
void KABI test_begin(char *name);
diff --git a/x64/src/test/inc/test_case.h b/x64/src/include/test/test_case.h
similarity index 62%
rename from x64/src/test/inc/test_case.h
rename to x64/src/include/test/test_case.h
index 7f023ba..ebc5a6a 100644
--- a/x64/src/test/inc/test_case.h
+++ b/x64/src/include/test/test_case.h
@@ -1,5 +1,7 @@
-#ifndef _LIB_TEST_H_
-#define _LIB_TEST_H_
+#ifndef _TEST_TEST_H_
+#define _TEST_TEST_H_
+
+#include "type.h"
void KABI linked_list_test(void);
diff --git a/x64/src/include/type.h b/x64/src/include/type.h
index 60685d3..14a7218 100644
--- a/x64/src/include/type.h
+++ b/x64/src/include/type.h
@@ -3,8 +3,11 @@
* See COPYING under root for details
*/
-#ifndef _G_TYPE_H_
-#define _G_TYPE_H_
+#ifndef _TYPE_H_
+#define _TYPE_H_
+
+#define KABI __attribute__((sysv_abi))
+#define UAPI __attribute__((sysv_abi))
#include
#include
@@ -17,10 +20,4 @@ typedef int32_t (*callback_func_t)(void *kernel_args, void *user_args);
#define UNREFERENCED(x) {(x) = (x);}
-#define _OUT
-#define _IN
-#define _IN_OUT
-#define _IN_OPT
-#define _OUT_OPT
-
#endif
\ No newline at end of file
diff --git a/x64/src/kernel/hal/print.h b/x64/src/kernel/hal/print.h
deleted file mode 100644
index 85b6302..0000000
--- a/x64/src/kernel/hal/print.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2016 secXsQuared
- * Distributed under GPL license
- * See COPYING under root for details
- */
-
-#ifndef _HAL_PRINT_H_
-#define _HAL_PRINT_H_
-#include "../../common/inc/abi.h"
-#include "../../common/inc/type.h"
-
-#define get_column(pos) (pos % 80)
-#define get_row(pos) (pos / 80)
-#define get_pos(row,col) ((row) * 80 + (col))
-
-void KABI hal_clear_screen();
-void KABI hal_print_init();
-void KABI hal_printf(char const *format, ...);
-
-#endif
\ No newline at end of file
diff --git a/x64/src/kernel/ke/alloc.c b/x64/src/kernel/ke/alloc.c
index fd3c742..15a5595 100644
--- a/x64/src/kernel/ke/alloc.c
+++ b/x64/src/kernel/ke/alloc.c
@@ -1,8 +1,6 @@
-#include "abi.h"
#include "type.h"
#include "kernel/ke/alloc.h"
#include "lib/salloc.h"
-#include "kernel/ke/atomic.h"
#define K_KERNEL_HEAP_SIZE 8192
diff --git a/x64/src/kernel/ke/assert.c b/x64/src/kernel/ke/assert.c
index 9aba1ab..37bbe30 100644
--- a/x64/src/kernel/ke/assert.c
+++ b/x64/src/kernel/ke/assert.c
@@ -1,6 +1,6 @@
-#include "assert.h"
-#include "kernel/ke/print.h"
#include "type.h"
+#include "kernel/ke/assert.h"
+#include "kernel/ke/print.h"
void ke_assert_ex(const char* expr_str, const char* file, int32_t line, int32_t expr)
{
diff --git a/x64/src/kernel/ke/atomic.c b/x64/src/kernel/ke/atomic.c
index 4095dce..19da3c8 100644
--- a/x64/src/kernel/ke/atomic.c
+++ b/x64/src/kernel/ke/atomic.c
@@ -1,5 +1,5 @@
+#include "type.h"
#include "kernel/ke/atomic.h"
-#include "kernel/hal/atomic.h"
int32_t KABI ke_interlocked_exchange_32(int32_t *target, int32_t val)
{
diff --git a/x64/src/kernel/ke/boot.c b/x64/src/kernel/ke/boot.c
index 7c7052d..6586877 100644
--- a/x64/src/kernel/ke/boot.c
+++ b/x64/src/kernel/ke/boot.c
@@ -3,15 +3,14 @@
* See COPYING under root for details
*/
-#include "../arch/amd64/boot.h"
-#include "kernel/mm/pmm.h"
+#include "kernel/ke/boot.h"
#include "kernel/ke/alloc.h"
-#include "test_case.h"
+#include "test/test_case.h"
extern void KABI hal_printf(char const *, ...);
// returning from this function results in halting the cpu
-void KABI ke_system_startup(void *boot_info)
+void KABI ke_main(boot_info_t *boot_info)
{
if (boot_info == NULL)
{
diff --git a/x64/src/kernel/ke/bug_check.c b/x64/src/kernel/ke/bug_check.c
index 8d76b9e..4d44aad 100644
--- a/x64/src/kernel/ke/bug_check.c
+++ b/x64/src/kernel/ke/bug_check.c
@@ -1,10 +1,9 @@
-#include "print.h"
-#include "../../common/inc/abi.h"
-#include "../../common/inc/type.h"
-#include "bug_check.h"
+#include "type.h"
+#include "kernel/ke/print.h"
+#include "kernel/ke/bug_check.h"
void KABI ke_bug_check(uint64_t reason)
{
ke_printf("BugCheck: Reason - %ul\n", reason);
- ke_halt_cpu();
+ while(true){};
}
\ No newline at end of file
diff --git a/x64/src/kernel/ke/intr.c b/x64/src/kernel/ke/intr.c
index 91ba7e3..80c2ae3 100644
--- a/x64/src/kernel/ke/intr.c
+++ b/x64/src/kernel/ke/intr.c
@@ -1,9 +1,5 @@
-#include "assert.h"
-#include "intr.h"
-
-//
-// End HAL
-//
+#include "kernel/ke/assert.h"
+#include "kernel/ke/intr.h"
irql_t KABI ke_raise_irql(irql_t irql)
{
@@ -25,5 +21,5 @@ irql_t KABI ke_get_irql()
int KABI ke_get_current_core()
{
- return hal_get_current_core();
+ return hal_get_core_id();
}
\ No newline at end of file
diff --git a/x64/src/kernel/ke/print.c b/x64/src/kernel/ke/print.c
index af70f58..1adb225 100644
--- a/x64/src/kernel/ke/print.c
+++ b/x64/src/kernel/ke/print.c
@@ -1,4 +1,3 @@
-#include "kernel/hal/print.h"
#include "kernel/ke/print.h"
void KABI ke_printf(const char* str, ...)
diff --git a/x64/src/kernel/ke/rwwlock.c b/x64/src/kernel/ke/rwwlock.c
index 9c84830..cfd494c 100644
--- a/x64/src/kernel/ke/rwwlock.c
+++ b/x64/src/kernel/ke/rwwlock.c
@@ -1,4 +1,5 @@
-#include "rwwlock.h"
+
+#include "kernel/ke/rwwlock.h"
void ke_rwwlock_init(k_rwwlock_t *lock)
{
diff --git a/x64/src/kernel/ke/spin_lock.c b/x64/src/kernel/ke/spin_lock.c
index f89d742..0bf2670 100644
--- a/x64/src/kernel/ke/spin_lock.c
+++ b/x64/src/kernel/ke/spin_lock.c
@@ -1,5 +1,5 @@
-#include "atomic.h"
-#include "spin_lock.h"
+#include "kernel/ke/atomic.h"
+#include "kernel/ke/spin_lock.h"
void KABI ke_spin_lock_init(k_spin_lock_t *lock)
{
diff --git a/x64/src/kernel/mm/pmm.c b/x64/src/kernel/mm/pmm.c
index a1dc08f..de285aa 100644
--- a/x64/src/kernel/mm/pmm.c
+++ b/x64/src/kernel/mm/pmm.c
@@ -1,8 +1,8 @@
-#include "assert.h"
-#include "rwwlock.h"
-#include "../../common/inc/status.h"
-#include "alloc.h"
-#include "pmm.h"
+#include "kernel/ke/assert.h"
+#include "kernel/ke/rwwlock.h"
+#include "kernel/ke/status.h"
+#include "kernel/ke/alloc.h"
+#include "kernel/mm/pmm.h"
typedef struct
{
@@ -60,7 +60,7 @@ status_t KABI sx_pmm_init(pmm_info_t *info)
{
pmm_node_t *each_node = &info->nodes[i];
- ke_assert (each_node->base % K_PAGE_SIZE != 0);
+ ke_assert (each_node->base % KERNEL_PAGE_SIZE != 0);
for (uint64_t j = 0; j <= each_node->size; j++)
{
@@ -100,7 +100,7 @@ status_t KABI mm_alloc_page(physical_addr_t *out)
return PMM_STATUS_INVALID_ARGUMENTS;
}
- irql_t irql = ke_rwwlock_writer_lock_raise_irql(&lock, K_IRQL_DISABLED_LEVEL);
+ irql_t irql = ke_rwwlock_writer_lock_raise_irql(&lock, IRQL_DISABLED_LEVEL);
status_t result = STATUS_SUCCESS;
linked_list_node_t *node = NULL;
physical_page_descriptor_t *page_info = NULL;
@@ -134,7 +134,7 @@ status_t KABI mm_query_page_attr(physical_addr_t base,
return PMM_STATUS_INVALID_ARGUMENTS;
}
- irql_t irql = ke_rwwlock_reader_lock_raise_irql(&lock, K_IRQL_DISABLED_LEVEL);
+ irql_t irql = ke_rwwlock_reader_lock_raise_irql(&lock, IRQL_DISABLED_LEVEL);
status_t result = STATUS_SUCCESS;
avl_tree_node_t *node = NULL;
// search for dummy
@@ -165,7 +165,7 @@ status_t KABI mm_free_page(physical_addr_t base)
}
// just lock since not sharing with anyone
- irql_t irql = ke_rwwlock_writer_lock_raise_irql(&lock, K_IRQL_DISABLED_LEVEL);
+ irql_t irql = ke_rwwlock_writer_lock_raise_irql(&lock, IRQL_DISABLED_LEVEL);
status_t result = STATUS_SUCCESS;
avl_tree_node_t *node = NULL;
// search for dummy
diff --git a/x64/src/kernel/mm/vmm.c b/x64/src/kernel/mm/vmm.c
deleted file mode 100644
index 8bb2538..0000000
--- a/x64/src/kernel/mm/vmm.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "alloc.h"
-#include "vmm.h"
-
-typedef struct
-{
- avl_tree_node_t tree_node;
- virtual_addr_attribute_t attribute;
- virtual_addr_t base;
- uint64_t size;
-} virtual_addr_descriptor_t;
-
-/*
- * A comparison function between tree_node and your_node
- * Returns:
- * < 0 if tree_node < your_node
- * = 0 if tree_node == your_node
- * > 0 if tree_node > your_node
- */
-static int32_t mmp_base_addr_compare(void *tree_node, void *my_node)
-{
- virtual_addr_descriptor_t *that = OBTAIN_STRUCT_ADDR(tree_node,
- virtual_addr_descriptor_t,
- tree_node);
- virtual_addr_descriptor_t *mine = OBTAIN_STRUCT_ADDR(my_node,
- virtual_addr_descriptor_t,
- tree_node);
-
- // if overlap, consider them to be the same
- if (lb_is_overlap(that->base, that->base + that->size, mine->base, mine->base + mine->size) == 1)
- return 0;
- else if (that->base < mine->base)
- return -1;
- else
- return 1;
-}
-
-int32_t KABI mm_vmm_init(vmm_descriptor_t *desc)
-{
- if (desc == NULL || desc->initialized)
- {
- return VMM_STATUS_INVALID_ARGUMENTS;
- }
- lb_avl_tree_init(&desc->region_tree, mmp_base_addr_compare);
-
- return VMM_STATUS_SUCCESS;
-}
-
-int32_t KABI mm_alloc_virtual_address(vmm_descriptor_t *desc,
- virtual_addr_t base,
- uint64_t size,
- virtual_addr_attribute_t attr)
-{
- if(desc == NULL || !desc->initialized)
- {
- return VMM_STATUS_INVALID_ARGUMENTS;
- }
- virtual_addr_descriptor_t* node = ke_alloc(sizeof(virtual_addr_descriptor_t));
-
- if(node == NULL)
- {
- return VMM_STATUS_CANNOT_ALLOC_NODE;
- }
-
- node->base =base;
- node->size = size;
- node->attribute = attr;
-
- lb_avl_tree_insert(&desc->region_tree, &node->tree_node);
-
- return VMM_STATUS_SUCCESS;
-}
-
-int64_t KABI mm_query_virtual_address(vmm_descriptor_t *desc, virtual_addr_t v_addr, uint64_t *out)
-{
- UNREFERENCED(desc);
- UNREFERENCED(v_addr);
- UNREFERENCED(out);
- return 0;
-}
-
-int64_t KABI mm_free_virtual_address(vmm_descriptor_t *desc, virtual_addr_t base)
-{
- UNREFERENCED(desc);
- UNREFERENCED(base);
- return 0;
-}
\ No newline at end of file
diff --git a/x64/src/kernel/rf/ref.c b/x64/src/kernel/rf/ref.c
index 8aac645..f5cc608 100644
--- a/x64/src/kernel/rf/ref.c
+++ b/x64/src/kernel/rf/ref.c
@@ -1,9 +1,9 @@
-#include "ref.h"
-#include "alloc.h"
-#include "spin_lock.h"
-#include "assert.h"
-#include "atomic.h"
-#include "avl_tree.h"
+#include "kernel/rf/ref.h"
+#include "kernel/ke/alloc.h"
+#include "kernel/ke/spin_lock.h"
+#include "kernel/ke/assert.h"
+#include "kernel/ke/atomic.h"
+#include "lib/avl_tree.h"
typedef struct
{
@@ -66,7 +66,7 @@ status_t KABI rf_reference_setup()
status_t KABI rf_reference_create(ref_node_t *ref,
callback_func_t free_func)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (ref == NULL || free_func == NULL)
return REF_STATUS_INVALID_ARGUMENTS;
@@ -79,7 +79,7 @@ status_t KABI rf_reference_create(ref_node_t *ref,
status_t KABI rf_reference_obj(ref_node_t *ref_node)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (ref_node == NULL)
return REF_STATUS_INVALID_ARGUMENTS;
@@ -93,7 +93,7 @@ status_t KABI rf_reference_obj(ref_node_t *ref_node)
status_t KABI rf_dereference_obj(ref_node_t *ref_node)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (ref_node == NULL)
return REF_STATUS_INVALID_ARGUMENTS;
@@ -115,7 +115,7 @@ status_t KABI rf_dereference_obj(ref_node_t *ref_node)
static status_t KABI rf_open_obj_by_handle(handle_t handle, ref_node_t **out)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (!initialized)
{
@@ -132,7 +132,7 @@ static status_t KABI rf_open_obj_by_handle(handle_t handle, ref_node_t **out)
ref_node_t *ref = NULL;
- irql = ke_spin_lock_raise_irql(&handle_tree_lock, K_IRQL_DPC_LEVEL);
+ irql = ke_spin_lock_raise_irql(&handle_tree_lock, IRQL_DPC_LEVEL);
handle_node_t *handle_node = rfp_search_handle_node(handle);
if (handle_node == NULL)
{
@@ -160,7 +160,7 @@ static status_t KABI rf_create_handle(ref_node_t *ref,
handle_node_t *node,
handle_t *out)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (!initialized)
return REF_STATUS_UNINITIALIZED;
@@ -177,7 +177,7 @@ static status_t KABI rf_create_handle(ref_node_t *ref,
// TODO: CHECK OVERFLOW
node->handle = (handle_t) ke_interlocked_increment_32(&handle_base, 1);
node->ref = ref;
- irql = ke_spin_lock_raise_irql(&handle_tree_lock, K_IRQL_DPC_LEVEL);
+ irql = ke_spin_lock_raise_irql(&handle_tree_lock, IRQL_DPC_LEVEL);
handle_node_t *existing_node = rfp_search_handle_node(node->handle);
if (existing_node == NULL)
{
@@ -205,7 +205,7 @@ static status_t KABI rf_create_handle(ref_node_t *ref,
static status_t KABI rf_close_handle(handle_t handle)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (!initialized)
return REF_STATUS_UNINITIALIZED;
@@ -215,7 +215,7 @@ static status_t KABI rf_close_handle(handle_t handle)
ref_node_t *ref = NULL;
bool free = false;
- irql = ke_spin_lock_raise_irql(&handle_tree_lock, K_IRQL_DPC_LEVEL);
+ irql = ke_spin_lock_raise_irql(&handle_tree_lock, IRQL_DPC_LEVEL);
handle_node_t *handle_node = rfp_search_handle_node(handle);
if (handle_node == NULL)
{
@@ -249,7 +249,7 @@ static status_t KABI rf_close_handle(handle_t handle)
status_t KABI sx_create_handle(ref_node_t *ref, handle_t *out)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (!initialized)
return REF_STATUS_UNINITIALIZED;
@@ -268,7 +268,7 @@ status_t KABI sx_create_handle(ref_node_t *ref, handle_t *out)
status_t KABI sx_close_handle(handle_t handle)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (!initialized)
return REF_STATUS_UNINITIALIZED;
@@ -280,7 +280,7 @@ status_t KABI sx_close_handle(handle_t handle)
status_t KABI sx_open_obj_by_handle(handle_t handle, ref_node_t **out)
{
- ke_assert(ke_get_irql() <= K_IRQL_DPC_LEVEL);
+ ke_assert(ke_get_irql() <= IRQL_DPC_LEVEL);
if (!initialized)
return REF_STATUS_UNINITIALIZED;
diff --git a/x64/src/lib/avl_tree.c b/x64/src/lib/avl_tree.c
index 0fb2d30..2f57966 100644
--- a/x64/src/lib/avl_tree.c
+++ b/x64/src/lib/avl_tree.c
@@ -3,7 +3,7 @@
* See COPYING under root for details
*/
-#include "avl_tree.h"
+#include "lib/avl_tree.h"
static inline int32_t KABI lbp_avl_tree_node_get_height(avl_tree_node_t *node)
{
diff --git a/x64/src/lib/linked_list.c b/x64/src/lib/linked_list.c
index 529979b..20593cd 100644
--- a/x64/src/lib/linked_list.c
+++ b/x64/src/lib/linked_list.c
@@ -3,7 +3,7 @@
* See COPYING under root for details
*/
-#include "linked_list.h"
+#include "lib/linked_list.h"
static void KABI lbp_init_linked_list_node(linked_list_node_t *node)
{
diff --git a/x64/src/lib/salloc.c b/x64/src/lib/salloc.c
index 1d814be..ab12822 100644
--- a/x64/src/lib/salloc.c
+++ b/x64/src/lib/salloc.c
@@ -3,9 +3,9 @@
* See COPYING under root for details
*/
-#include "../common/inc/abi.h"
-#include "../common/inc/type.h"
-#include "sxtdlib.h"
+#include "abi.h"
+#include "type.h"
+#include "lib/sxtdlib.h"
typedef union
{
diff --git a/x64/src/lib/sxtdlib.c b/x64/src/lib/sxtdlib.c
index d0aef19..11ab991 100644
--- a/x64/src/lib/sxtdlib.c
+++ b/x64/src/lib/sxtdlib.c
@@ -3,9 +3,9 @@
* See COPYING under root for details
*/
-#include "../common/inc/type.h"
-#include "../common/inc/abi.h"
-#include "sxtdlib.h"
+#include "type.h"
+#include "abi.h"
+#include "lib/sxtdlib.h"
void KABI lb_mem_copy(void *src, void *dst, uint64_t size)
{
diff --git a/x64/src/test/avl_tree_test.c b/x64/src/test/avl_tree_test.c
index 2e82185..af0dd83 100644
--- a/x64/src/test/avl_tree_test.c
+++ b/x64/src/test/avl_tree_test.c
@@ -1,5 +1,5 @@
-#include "driver.h"
-#include "avl_tree.h"
+#include "test/driver.h"
+#include "lib/avl_tree.h"
typedef struct
{
diff --git a/x64/src/test/driver.c b/x64/src/test/driver.c
index f506629..45d92a2 100644
--- a/x64/src/test/driver.c
+++ b/x64/src/test/driver.c
@@ -1,6 +1,6 @@
-#include "print.h"
-#include "driver.h"
-#include "mem.h"
+#include "kernel/ke/print.h"
+#include "test/driver.h"
+#include "kernel/ke/alloc.h"
#define GAT_SIZE 256
#define CASE_NUM 32
@@ -18,17 +18,17 @@ static char *test_name;
static void test_info()
{
- hal_printf("[TD-INFO][%s] - ", test_name);
+ ke_printf("[TD-INFO][%s] - ", test_name);
}
static void test_warning()
{
- hal_printf("[TD-WARN][%s] - ", test_name);
+ ke_printf("[TD-WARN][%s] - ", test_name);
}
static void test_error()
{
- hal_printf("[TD-ERR][%s] - ", test_name);
+ ke_printf("[TD-ERR][%s] - ", test_name);
}
static void gat_push(void *ptr)
@@ -61,7 +61,7 @@ static void gat_free()
{
if (gat[i] != NULL)
{
- hfree(gat[i]);
+ ke_free(gat[i]);
gat[i] = NULL;
}
}
@@ -81,7 +81,7 @@ static void ginfo_push(char *case_name, bool success)
}
}
test_warning();
- hal_printf("GINFO full, [%s] result not recorded.\n", r_case_name);
+ ke_printf("GINFO full, [%s] result not recorded.\n", r_case_name);
}
void KABI test_begin(char *name)
@@ -117,15 +117,15 @@ void KABI test_end()
}
}
test_info();
- hal_printf("%s\n", failed > 0 ? "FAIL" : "PASS");
- hal_printf(" %d cases executed. S: %d. F: %d.\n", total, success, failed);
+ ke_printf("%s\n", failed > 0 ? "FAIL" : "PASS");
+ ke_printf(" %d cases executed. S: %d. F: %d.\n", total, success, failed);
if (failed > 0)
{
for (int i = 0; i < CASE_NUM; i++)
{
if (ginfo[i].used && !ginfo[i].success)
{
- hal_printf(" %s FAILED\n", ginfo[i].case_name);
+ ke_printf(" %s FAILED\n", ginfo[i].case_name);
}
}
}
@@ -139,14 +139,14 @@ void KABI *talloc(uint32_t size)
{
if (!gat_full())
{
- void *result = halloc(size);
+ void *result = ke_alloc(size);
gat_push(result);
return result;
}
else
{
test_error();
- hal_printf("GAT full, rejecting further allocations.\n");
+ ke_printf("GAT full, rejecting further allocations.\n");
}
return NULL;
}
diff --git a/x64/src/test/linked_list_test.c b/x64/src/test/linked_list_test.c
index 699d644..6d3f897 100644
--- a/x64/src/test/linked_list_test.c
+++ b/x64/src/test/linked_list_test.c
@@ -1,7 +1,7 @@
-#include "driver.h"
-#include "linked_list.h"
-#include "test_case.h"
-#include "sxtdlib.h"
+#include "test/driver.h"
+#include "lib/linked_list.h"
+#include "test/test_case.h"
+#include "lib/sxtdlib.h"
typedef struct
{
diff --git a/x64/src/test/salloc_test.c b/x64/src/test/salloc_test.c
index 0e51dc3..9370293 100644
--- a/x64/src/test/salloc_test.c
+++ b/x64/src/test/salloc_test.c
@@ -1,5 +1,5 @@
-#include "driver.h"
-#include "salloc.h"
+#include "test/driver.h"
+#include "lib/salloc.h"
typedef union
{