mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Compare commits
270 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2be70976ca | ||
|
|
699fc57e0a | ||
|
|
f3bb2e5259 | ||
|
|
34120fc4c1 | ||
|
|
e52fd8eacf | ||
|
|
a97073848c | ||
|
|
03b2d0dac7 | ||
|
|
cfeeba4400 | ||
|
|
45b52633bb | ||
|
|
b9af081a44 | ||
|
|
d75b9c22d4 | ||
|
|
e20c53f193 | ||
|
|
6d4a32b6e8 | ||
|
|
63a5c2da00 | ||
|
|
bdcd0c2fda | ||
|
|
1be929b9d5 | ||
|
|
d11dd0c3f9 | ||
|
|
e08e00790f | ||
|
|
8b3356e9d8 | ||
|
|
cd30126f17 | ||
|
|
2c444dccd6 | ||
|
|
bd490c4c7b | ||
|
|
3a67e461de | ||
|
|
972ef39295 | ||
|
|
4c41205e73 | ||
|
|
f6b4a4a103 | ||
| 327cd93c04 | |||
| 0e6b27e741 | |||
| db8a14720b | |||
| 87a7293ac1 | |||
| 5787aff866 | |||
| 7bdde2d359 | |||
| 2e3d7b1656 | |||
| bf600a7608 | |||
| 6b00805d04 | |||
| 82b7082fc5 | |||
| 8bb9e22218 | |||
| 2ad90dcb5c | |||
| 97ea77bd27 | |||
| 1904e240cf | |||
| 4ccaa2dfea | |||
| da38006f44 | |||
| 87b0a93d32 | |||
| ff78c951f0 | |||
| 2d44e8112b | |||
| f7f8bb3f45 | |||
| 67ebc58812 | |||
| 13aee1755e | |||
| 0e0975e5f6 | |||
| d4283731e4 | |||
| 6780ab1b67 | |||
| 41eac2764a | |||
| 113d14c440 | |||
| abe523be77 | |||
| 1b392a0551 | |||
| deb2fa0a09 | |||
| 671a0ce0fb | |||
| ac67111b83 | |||
| 09575370ce | |||
| 9aa08a70cf | |||
| ca7f78565d | |||
| dcb4d1823f | |||
| e8564c755b | |||
| 9dee5e4138 | |||
| 245f260d67 | |||
| 5f27727e52 | |||
| 1238608430 | |||
| 71cd7af17b | |||
| 8490472581 | |||
| 8534d8d3c5 | |||
| 53d260cc6e | |||
| 53a4682418 | |||
| 42455873ff | |||
| 724b846ee4 | |||
| f27b133089 | |||
| 773617cbf3 | |||
| 44e29b3c4a | |||
| 95a35cd0bf | |||
| 28b800a497 | |||
| 838776d7df | |||
| e19fa377d7 | |||
| d63a30728c | |||
| 4819920b4e | |||
| bbb9aae198 | |||
| 0d94776c46 | |||
| 565a5ee960 | |||
| e7f9d8f1d7 | |||
| 55bc49598e | |||
| 579eaaf4a0 | |||
| b98334db28 | |||
| e1b1b5d357 | |||
| cf582c4ce4 | |||
| 911b4c0b10 | |||
| 94c1f0d3fc | |||
| 73221dfe34 | |||
| 4ffd4949ca | |||
| 3f137805bc | |||
| 6a00057817 | |||
| 58bc5acb1e | |||
| d3e9d92466 | |||
| ae3290c53d | |||
| 4cf222a5bb | |||
| c3abe035c8 | |||
| ef5c333030 | |||
| f4cbb9498f | |||
| 794c86f9b4 | |||
|
|
8687fe3786 | ||
|
|
0a28d2db07 | ||
|
|
6c468a134b | ||
|
|
9b67f87062 | ||
|
|
b4adc29d7f | ||
|
|
a10aca573d | ||
|
|
ea1224e213 | ||
|
|
64ad65fa1b | ||
|
|
b881b2639d | ||
|
|
a5f72edf82 | ||
|
|
ea2a3e6f16 | ||
|
|
2125f043b6 | ||
|
|
655b5c88d4 | ||
|
|
88b090fe94 | ||
|
|
c6c3a556b3 | ||
|
|
67b5f33d46 | ||
|
|
b675dfd014 | ||
|
|
fc2b884af9 | ||
|
|
cbd19fa070 | ||
|
|
83b330bf2b | ||
|
|
cc9cde9bfe | ||
|
|
774f6fc334 | ||
|
|
bfd13e7a9b | ||
|
|
35b1d37df0 | ||
|
|
fc3d919f25 | ||
|
|
75641a4394 | ||
|
|
ce0bcbd3b6 | ||
|
|
3194b460cc | ||
|
|
e1d148a34d | ||
|
|
b491a09686 | ||
|
|
6a538ad4f3 | ||
|
|
6ccc172f33 | ||
|
|
66ca3a3f9b | ||
|
|
4f4a35a7be | ||
|
|
c9722a07f3 | ||
|
|
42dfa6ccfe | ||
|
|
2adef874ee | ||
|
|
a6e4995963 | ||
|
|
2bd91c2d94 | ||
|
|
c713f4ff6f | ||
|
|
21b0b08908 | ||
|
|
88ace0a99f | ||
|
|
10c8f6e4b5 | ||
|
|
9aa749e877 | ||
|
|
f78a99927a | ||
|
|
ec794f4f99 | ||
|
|
884182217c | ||
|
|
d94907ae79 | ||
|
|
4accfd136e | ||
|
|
1a223d6ef5 | ||
|
|
36b3ad8154 | ||
|
|
460973954e | ||
|
|
303a78065e | ||
|
|
93f0b70eba | ||
|
|
6f5a2a3d3f | ||
|
|
ec563ea8e4 | ||
|
|
570638bba6 | ||
|
|
f627ea7de0 | ||
|
|
521c132801 | ||
|
|
bc5115b9ea | ||
|
|
6963304c01 | ||
|
|
ae651a4fcd | ||
|
|
17c2fe6e4e | ||
|
|
f066ac3ffd | ||
|
|
edcf633e84 | ||
|
|
d09a454b8b | ||
|
|
d6329ea9bf | ||
|
|
83897048ab | ||
|
|
7cc59770b8 | ||
|
|
b056d95920 | ||
|
|
19cd01ef8d | ||
|
|
b3f88bbe02 | ||
|
|
f57f38edbd | ||
|
|
12377ae730 | ||
|
|
bb93dcef44 | ||
|
|
678a12dc90 | ||
|
|
c3dacb2906 | ||
|
|
3a68ec439d | ||
|
|
7ce418aabc | ||
|
|
8ee5091f41 | ||
|
|
6285517ef7 | ||
|
|
2b0cd6f2f2 | ||
|
|
a653c55941 | ||
|
|
ce035d2a43 | ||
|
|
2d54eb5143 | ||
|
|
b9c8edb657 | ||
|
|
88315c25a5 | ||
|
|
806bfd1fbf | ||
|
|
910b5116f4 | ||
|
|
6302e8b73a | ||
|
|
fd1adc0262 | ||
|
|
070be0b005 | ||
|
|
5034ffbe59 | ||
|
|
cd13b88540 | ||
|
|
e050d6f151 | ||
|
|
863555ec6b | ||
|
|
c605793a9d | ||
|
|
8375870af6 | ||
|
|
11a53e792f | ||
|
|
ca2362f858 | ||
|
|
5cdbedd4d1 | ||
|
|
ee6d69bcd2 | ||
|
|
f9193b4602 | ||
|
|
979e5f036e | ||
|
|
39baec852b | ||
|
|
ed3f9410a6 | ||
|
|
b18243f098 | ||
|
|
9472dab522 | ||
|
|
9067f8d298 | ||
|
|
866073ae8a | ||
|
|
91cb00fde2 | ||
|
|
c435bcfb67 | ||
|
|
7fe1b7d1f5 | ||
|
|
39524b2b9f | ||
|
|
c592f5f537 | ||
|
|
94c491d286 | ||
|
|
645938a194 | ||
|
|
73756820bd | ||
|
|
33374ab257 | ||
|
|
bf8286d15f | ||
|
|
6410c898c5 | ||
|
|
be007c6278 | ||
|
|
f7558e3d18 | ||
|
|
97e8f2c69a | ||
|
|
49bdf47514 | ||
|
|
81162f30dc | ||
|
|
4379256c11 | ||
|
|
870ca1db45 | ||
|
|
74a5c301f8 | ||
|
|
2955e6c9c1 | ||
|
|
cd2ccb4e06 | ||
|
|
722ee4c52c | ||
|
|
67b9f45004 | ||
|
|
2035fffa1c | ||
|
|
97ac3c09fa | ||
|
|
241e1dacb0 | ||
|
|
ac19d3f532 | ||
|
|
194527e0fe | ||
|
|
28cf5562ac | ||
|
|
8cdc39fdee | ||
|
|
626eec4a31 | ||
|
|
5901237fee | ||
|
|
24316ca0c4 | ||
|
|
f9d964cccb | ||
|
|
a9ac30b991 | ||
|
|
61df9cf32c | ||
|
|
bbd31929ba | ||
|
|
ec20e9f3d9 | ||
|
|
3bcd83f5a3 | ||
|
|
341ba5146a | ||
|
|
83b37ef536 | ||
|
|
1965197ccd | ||
|
|
29747f4891 | ||
|
|
aca442ee87 | ||
|
|
8e85ae5318 | ||
|
|
8c32471e0d | ||
|
|
79711be46a | ||
|
|
863e5bda15 | ||
|
|
d19cedb12a | ||
|
|
f2d39f7df8 | ||
|
|
579f6f64e6 | ||
|
|
a71af1be96 | ||
|
|
237c242f96 | ||
|
|
c4dc52c06c |
11
.git-commit-template
Normal file
11
.git-commit-template
Normal file
@@ -0,0 +1,11 @@
|
||||
[section] Imperative-voiced title in less than 50
|
||||
|
||||
# Body describes what was done, and why. New obviously-needed features
|
||||
# don't necessarily require a why.
|
||||
|
||||
# Links to relevant bugs or web pages
|
||||
See: Github bug #242
|
||||
See: [frobozz blog post](https://jsix.dev/posts/frobozz/)
|
||||
|
||||
# Tags and keywords useful for searching
|
||||
Tags:
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -2,8 +2,9 @@
|
||||
/build*
|
||||
*.bak
|
||||
tags
|
||||
.gdbinit
|
||||
popcorn.log
|
||||
jsix.log
|
||||
*.o
|
||||
*.a
|
||||
sysroot
|
||||
.gdb_history
|
||||
.peru
|
||||
|
||||
447
LICENSE.md
447
LICENSE.md
@@ -1,123 +1,354 @@
|
||||
# Popcorn
|
||||
# License
|
||||
|
||||
Popcorn itself is released under the terms of the MIT license:
|
||||
jsix is (c) 2017-2019 Justin C Miller, and distributed under the terms of the
|
||||
Mozilla Public License 2.0.
|
||||
|
||||
> Copyright © 2018 Justin C. Miller, https://devjustinian.com
|
||||
> <justin@devjustinian.com>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the “Software”), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
---
|
||||
|
||||
# Included works
|
||||
## Mozilla Public License Version 2.0
|
||||
|
||||
Popcorn includes and/or is derived from a number of other works, listed here.
|
||||
### 1. Definitions
|
||||
|
||||
## Catch2
|
||||
#### 1.1. "Contributor"
|
||||
|
||||
Popcorn uses [Catch2](https://github.com/catchorg/Catch2) for testing. Catch2 is
|
||||
released under the terms of the Boost Software license:
|
||||
means each individual or legal entity that creates, contributes to the creation
|
||||
of, or owns Covered Software.
|
||||
|
||||
> Boost Software License - Version 1.0 - August 17th, 2003
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person or organization
|
||||
> obtaining a copy of the software and accompanying documentation covered by
|
||||
> this license (the "Software") to use, reproduce, display, distribute,
|
||||
> execute, and transmit the Software, and to prepare derivative works of the
|
||||
> Software, and to permit third-parties to whom the Software is furnished to
|
||||
> do so, all subject to the following:
|
||||
>
|
||||
> The copyright notices in the Software and this entire statement, including
|
||||
> the above license grant, this restriction and the following disclaimer,
|
||||
> must be included in all copies of the Software, in whole or in part, and
|
||||
> all derivative works of the Software, unless such copies or derivative
|
||||
> works are solely in the form of machine-executable object code generated by
|
||||
> a source language processor.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
> SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
> FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
> ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
> DEALINGS IN THE SOFTWARE.
|
||||
#### 1.2. "Contributor Version"
|
||||
|
||||
## cpptoml
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor's Contribution.
|
||||
|
||||
Popcorn uses the [cpptoml](https://github.com/skystrife/cpptoml) library for
|
||||
parsing TOML configuration files. cpptoml is released under the terms of the
|
||||
MIT license:
|
||||
#### 1.3. "Contribution
|
||||
|
||||
> Copyright (c) 2014 Chase Geigle
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
> this software and associated documentation files (the "Software"), to deal in
|
||||
> the Software without restriction, including without limitation the rights to
|
||||
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
> the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
> subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
## GNU-EFI
|
||||
#### 1.4. "Covered Software"
|
||||
|
||||
Popcorn's UEFI bootloader initially used
|
||||
[GNU-EFI](https://gnu-efi.sourceforge.net), and still uses one file (the linker
|
||||
script for the bootloader) from that project. GNU-EFI claims to be released
|
||||
under the BSD license. Again, I could not find its specific license file, so I
|
||||
am reproducing a generic 3-clause BSD license (the most restrictive, so as not
|
||||
to assume any extra rights that may not actually be granted) for it here:
|
||||
means Source Code Form to which the initial Contributor has attached the notice
|
||||
in Exhibit A, the Executable Form of such Source Code Form, and Modifications
|
||||
of such Source Code Form, in each case including portions thereof.
|
||||
|
||||
> Copyright © Nigel Croxon
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without
|
||||
> modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> 1. Redistributions of source code must retain the above copyright notice, this
|
||||
> list of conditions and the following disclaimer.
|
||||
>
|
||||
> 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
> this list of conditions and the following disclaimer in the documentation
|
||||
> and/or other materials provided with the distribution.
|
||||
>
|
||||
> 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
> may be used to endorse or promote products derived from this software
|
||||
> without specific prior written permission.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
> ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
> WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
> DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
> OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#### 1.5. "Incompatible With Secondary Licenses"
|
||||
|
||||
## Intel EFI Application Toolkit
|
||||
means
|
||||
|
||||
* **(a)** that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
* **(b)** that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the terms of a
|
||||
Secondary License.
|
||||
|
||||
#### 1.6. "Executable Form"
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
#### 1.7. "Larger Work"
|
||||
|
||||
means a work that combines Covered Software with other material, in a separate
|
||||
file or files, that is not Covered Software.
|
||||
|
||||
#### 1.8. "License"
|
||||
|
||||
means this document.
|
||||
|
||||
#### 1.9. "Licensable"
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether at the
|
||||
time of the initial grant or subsequently, any and all of the rights conveyed
|
||||
by this License.
|
||||
|
||||
#### 1.10. "Modifications"
|
||||
|
||||
means any of the following:
|
||||
|
||||
* **(a)** any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered Software; or
|
||||
* **(b)** any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
#### 1.11. "Patent Claims" of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method, process, and
|
||||
apparatus claims, in any patent Licensable by such Contributor that would be
|
||||
infringed, but for the grant of the License, by the making, using, selling,
|
||||
offering for sale, having made, import, or transfer of either its Contributions
|
||||
or its Contributor Version.
|
||||
|
||||
#### 1.12. "Secondary License"
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public License,
|
||||
Version 3.0, or any later versions of those licenses.
|
||||
|
||||
#### 1.13. "Source Code Form"
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
#### 1.14. "You" (or "Your")
|
||||
|
||||
means an individual or a legal entity exercising rights under this License. For
|
||||
legal entities, "You" includes any entity that controls, is controlled by, or
|
||||
is under common control with You. For purposes of this definition, "control"
|
||||
means **(a)** the power, direct or indirect, to cause the direction or
|
||||
management of such entity, whether by contract or otherwise, or **(b)**
|
||||
ownership of more than fifty percent (50%) of the outstanding shares or
|
||||
beneficial ownership of such entity.
|
||||
|
||||
|
||||
### 2. License Grants and Conditions
|
||||
|
||||
#### 2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive
|
||||
license:
|
||||
|
||||
* **(a)** under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available, modify,
|
||||
display, perform, distribute, and otherwise exploit its Contributions, either
|
||||
on an unmodified basis, with Modifications, or as part of a Larger Work; and
|
||||
* **(b)** under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its Contributions or
|
||||
its Contributor Version.
|
||||
|
||||
#### 2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||
effective for each Contribution on the date the Contributor first distributes
|
||||
such Contribution.
|
||||
|
||||
#### 2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under this
|
||||
License. No additional rights or licenses will be implied from the distribution
|
||||
or licensing of Covered Software under this License. Notwithstanding Section
|
||||
2.1(b) above, no patent license is granted by a Contributor:
|
||||
|
||||
* **(a)** for any code that a Contributor has removed from Covered Software; or
|
||||
* **(b)** for infringements caused by: **(i)** Your and any other third party's
|
||||
modifications of Covered Software, or **(ii)** the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
* **(c)** under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks, or
|
||||
logos of any Contributor (except as may be necessary to comply with the notice
|
||||
requirements in Section 3.4).
|
||||
|
||||
#### 2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to distribute
|
||||
the Covered Software under a subsequent version of this License (see Section
|
||||
10.2) or under the terms of a Secondary License (if permitted under the terms
|
||||
of Section 3.3).
|
||||
|
||||
#### 2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its Contributions are
|
||||
its original creation(s) or it has sufficient rights to grant the rights to its
|
||||
Contributions conveyed by this License.
|
||||
|
||||
#### 2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under applicable
|
||||
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||
|
||||
#### 2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
### 3. Responsibilities
|
||||
|
||||
#### 3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under the
|
||||
terms of this License. You must inform recipients that the Source Code Form of
|
||||
the Covered Software is governed by the terms of this License, and how they can
|
||||
obtain a copy of this License. You may not attempt to alter or restrict the
|
||||
recipients' rights in the Source Code Form.
|
||||
|
||||
#### 3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
* **(a)** such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost of
|
||||
distribution to the recipient; and
|
||||
* **(b)** You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the license
|
||||
for the Executable Form does not attempt to limit or alter the recipients'
|
||||
rights in the Source Code Form under this License.
|
||||
|
||||
#### 3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for the
|
||||
Covered Software. If the Larger Work is a combination of Covered Software with
|
||||
a work governed by one or more Secondary Licenses, and the Covered Software is
|
||||
not Incompatible With Secondary Licenses, this License permits You to
|
||||
additionally distribute such Covered Software under the terms of such Secondary
|
||||
License(s), so that the recipient of the Larger Work may, at their option,
|
||||
further distribute the Covered Software under the terms of either this License
|
||||
or such Secondary License(s).
|
||||
|
||||
#### 3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices (including
|
||||
copyright notices, patent notices, disclaimers of warranty, or limitations of
|
||||
liability) contained within the Source Code Form of the Covered Software,
|
||||
except that You may alter any license notices to the extent required to remedy
|
||||
known factual inaccuracies.
|
||||
|
||||
#### 3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support, indemnity
|
||||
or liability obligations to one or more recipients of Covered Software.
|
||||
However, You may do so only on Your own behalf, and not on behalf of any
|
||||
Contributor. You must make it absolutely clear that any such warranty, support,
|
||||
indemnity, or liability obligation is offered by You alone, and You hereby
|
||||
agree to indemnify every Contributor for any liability incurred by such
|
||||
Contributor as a result of warranty, support, indemnity or liability terms You
|
||||
offer. You may include additional disclaimers of warranty and limitations of
|
||||
liability specific to any jurisdiction.
|
||||
|
||||
|
||||
### 4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute, judicial
|
||||
order, or regulation then You must: **(a)** comply with the terms of this
|
||||
License to the maximum extent possible; and **(b)** describe the limitations
|
||||
and the code they affect. Such description must be placed in a text file
|
||||
included with all distributions of the Covered Software under this License.
|
||||
Except to the extent prohibited by statute or regulation, such description must
|
||||
be sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
|
||||
### 5. Termination
|
||||
|
||||
**5.1.** The rights granted under this License will terminate automatically if
|
||||
You fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor are
|
||||
reinstated **(a)** provisionally, unless and until such Contributor explicitly
|
||||
and finally terminates Your grants, and **(b)** on an ongoing basis, if such
|
||||
Contributor fails to notify You of the non-compliance by some reasonable means
|
||||
prior to 60 days after You have come back into compliance. Moreover, Your
|
||||
grants from a particular Contributor are reinstated on an ongoing basis if such
|
||||
Contributor notifies You of the non-compliance by some reasonable means, this
|
||||
is the first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after Your
|
||||
receipt of the notice.
|
||||
|
||||
**5.2.** If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions, counter-claims, and
|
||||
cross-claims) alleging that a Contributor Version directly or indirectly
|
||||
infringes any patent, then the rights granted to You by any and all
|
||||
Contributors for the Covered Software under Section 2.1 of this License shall
|
||||
terminate.
|
||||
|
||||
**5.3.** In the event of termination under Sections 5.1 or 5.2 above, all end
|
||||
user license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
|
||||
### 6. Disclaimer of Warranty
|
||||
|
||||
> Covered Software is provided under this License on an "as is" basis, without
|
||||
> warranty of any kind, either expressed, implied, or statutory, including,
|
||||
> without limitation, warranties that the Covered Software is free of defects,
|
||||
> merchantable, fit for a particular purpose or non-infringing. The entire risk
|
||||
> as to the quality and performance of the Covered Software is with You.
|
||||
> Should any Covered Software prove defective in any respect, You (not any
|
||||
> Contributor) assume the cost of any necessary servicing, repair, or
|
||||
> correction. This disclaimer of warranty constitutes an essential part of this
|
||||
> License. No use of any Covered Software is authorized under this License
|
||||
> except under this disclaimer.
|
||||
|
||||
### 7. Limitation of Liability
|
||||
|
||||
> Under no circumstances and under no legal theory, whether tort (including
|
||||
> negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
> distributes Covered Software as permitted above, be liable to You for any
|
||||
> direct, indirect, special, incidental, or consequential damages of any
|
||||
> character including, without limitation, damages for lost profits, loss of
|
||||
> goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
> other commercial damages or losses, even if such party shall have been
|
||||
> informed of the possibility of such damages. This limitation of liability
|
||||
> shall not apply to liability for death or personal injury resulting from such
|
||||
> party's negligence to the extent applicable law prohibits such limitation.
|
||||
> Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||
> consequential damages, so this exclusion and limitation may not apply to You.
|
||||
|
||||
|
||||
### 8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts of a
|
||||
jurisdiction where the defendant maintains its principal place of business and
|
||||
such litigation shall be governed by laws of that jurisdiction, without
|
||||
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||
prevent a party's ability to bring cross-claims or counter-claims.
|
||||
|
||||
|
||||
### 9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject matter
|
||||
hereof. If any provision of this License is held to be unenforceable, such
|
||||
provision shall be reformed only to the extent necessary to make it
|
||||
enforceable. Any law or regulation which provides that the language of a
|
||||
contract shall be construed against the drafter shall not be used to construe
|
||||
this License against a Contributor.
|
||||
|
||||
|
||||
### 10. Versions of the License
|
||||
|
||||
#### 10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section 10.3,
|
||||
no one other than the license steward has the right to modify or publish new
|
||||
versions of this License. Each version will be given a distinguishing version
|
||||
number.
|
||||
|
||||
#### 10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version of the
|
||||
License under which You originally received the Covered Software, or under the
|
||||
terms of any subsequent version published by the license steward.
|
||||
|
||||
#### 10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to create a
|
||||
new license for such software, you may create and use a modified version of
|
||||
this License if you rename the license and remove any references to the name of
|
||||
the license steward (except to note that such modified license differs from
|
||||
this License).
|
||||
|
||||
#### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the notice
|
||||
described in Exhibit B of this License must be attached.
|
||||
|
||||
### Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||
directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
### Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as defined
|
||||
by the Mozilla Public License, v. 2.0.
|
||||
|
||||
Popcorn's UEFI loader uses code from Intel's EFI Application toolkit. Relevant
|
||||
code includes license statements at the top of each file.
|
||||
|
||||
16
NOTES.md
16
NOTES.md
@@ -2,7 +2,9 @@
|
||||
|
||||
## TODO
|
||||
|
||||
- Better page-allocation model
|
||||
- Paging manager
|
||||
- Copy-on-write pages
|
||||
- Better page-allocation model?
|
||||
- Allow for more than one IOAPIC in ACPI module
|
||||
- The objects get created, but GSI lookup only uses the one at index 0
|
||||
- mark kernel memory pages global
|
||||
@@ -19,12 +21,18 @@
|
||||
- Parse initrd and pre-load certain ELF images, eg the process loader process?
|
||||
- Do initial memory bootstrap?
|
||||
- Calling global ctors
|
||||
|
||||
|
||||
- Device Tree
|
||||
- Actual serial driver
|
||||
- Disk driver
|
||||
- File system
|
||||
- Multiprocessing
|
||||
- Syscalls
|
||||
- Fast syscalls using syscall/sysret
|
||||
|
||||
### Build
|
||||
|
||||
- Clean up build generator and its templates
|
||||
- More robust objects to represent modules & targets to pass to templates
|
||||
- Read project setup from a simple JSON/TOML/etc
|
||||
- Better compartmentalizing when doing template inheritance
|
||||
- Move to LLD as sysroot linker
|
||||
|
||||
|
||||
54
README.md
54
README.md
@@ -1,6 +1,6 @@
|
||||
# popcorn: A toy OS kernel
|
||||
# jsix: A toy OS kernel
|
||||
|
||||
**popcorn** is the kernel for the hobby OS that I am currently building. It's
|
||||
**jsix** is the kernel for the hobby OS that I am currently building. It's
|
||||
far from finished, or even being usable. Instead, it's a sandbox for me to play
|
||||
with kernel-level code and explore architectures.
|
||||
|
||||
@@ -25,36 +25,54 @@ The design goals of the project are:
|
||||
temporarily) in some places to allow me to play around with the related
|
||||
hardware.
|
||||
|
||||
A note on the name: This kernel was originally named Popcorn, but I have since
|
||||
discovered that the Popcorn Linux project is also developing a kernel with that
|
||||
name, started around the same time as this project. So I've renamed this kernel
|
||||
jsix (Always styled _jsix_ or `j6`, never capitalized) as an homage to L4, xv6,
|
||||
and my wonderful wife.
|
||||
|
||||
## Building
|
||||
|
||||
Popcorn uses the `ninja` build tool, and generates the build files for it with
|
||||
the `generate_build.py` script. The other requirements are:
|
||||
jsix uses the [Ninja][] build tool, and generates the build files for it with a
|
||||
custom tool called [Bonnibel][]. Bonnibel can be installed with [Cargo][], or
|
||||
downloaded as a prebuilt binary from its Github repository.
|
||||
|
||||
* python 3 for generating the build config
|
||||
* The Jinja2 package is also required
|
||||
* clang
|
||||
* mtools
|
||||
[Ninja]: https://ninja-build.org
|
||||
[Bonnibel]: https://github.com/justinian/bonnibel
|
||||
[Cargo]: https://crates.io/crates/bonnibel
|
||||
|
||||
Requrirements:
|
||||
|
||||
* bonnibel
|
||||
* ninja
|
||||
* clang
|
||||
* nasm
|
||||
* mtools
|
||||
* curl for downloading the toolchain
|
||||
|
||||
### Setting up the cross toolchain
|
||||
|
||||
If you have `clang` and `curl` installed, runing the `scripts/build_sysroot_clang.sh`
|
||||
script will download and build a nasm/binutils/LLVM toolchain configured for building
|
||||
Popcorn host binaries.
|
||||
Running `pb sync` will download and unpack the toolchain into `sysroot`.
|
||||
|
||||
### Building and running Popcorn
|
||||
#### Compiling the toolchain yourself
|
||||
|
||||
Once the toolchain has been set up, running `generate_build.py` will set up the
|
||||
build configuration, and `ninja -C build` will actually run the build. If you
|
||||
have `qemu-system-x86_64` installed, the `qemu.sh` script will to run Popcorn
|
||||
If you have `clang` and `curl` installed, runing the `scripts/build_sysroot.sh`
|
||||
script will download and build a LLVM toolchain configured for building jsix
|
||||
host binaries.
|
||||
|
||||
### Building and running jsix
|
||||
|
||||
Once the toolchain has been set up, running Bonnibel's `pb init` command will
|
||||
set up the build configuration, and `pb build` will actually run the build. If
|
||||
you have `qemu-system-x86_64` installed, the `qemu.sh` script will to run jsix
|
||||
in QEMU `-nographic` mode.
|
||||
|
||||
I personally run this either from a real debian amd64 testing/buster machine or
|
||||
a windows WSL debian testing/buster installation. The following should be
|
||||
enough to set up such a system to build the kernel:
|
||||
|
||||
sudo apt install qemu-system-x86 nasm clang-6.0 mtools
|
||||
sudo update-alternatives /usr/bin/clang clang /usr/bin/clang-6.0 1000
|
||||
sudo update-alternatives /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 1000
|
||||
sudo apt install qemu-system-x86 nasm clang-6.0 mtools curl
|
||||
sudo update-alternatives /usr/bin/clang clang /usr/bin/clang-6.0 1000
|
||||
sudo update-alternatives /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 1000
|
||||
curl -L -o pb https://github.com/justinian/bonnibel/releases/download/2.0.0/pb_linux_amd64 && chmod a+x pb
|
||||
|
||||
|
||||
63
assets/debugging/jsix.elf-gdb.py
Normal file
63
assets/debugging/jsix.elf-gdb.py
Normal file
@@ -0,0 +1,63 @@
|
||||
import gdb
|
||||
|
||||
class PrintStackCommand(gdb.Command):
|
||||
def __init__(self):
|
||||
super().__init__("j6stack", gdb.COMMAND_DATA)
|
||||
|
||||
def invoke(self, arg, from_tty):
|
||||
args = gdb.string_to_argv(arg)
|
||||
|
||||
base = "$rsp"
|
||||
if len(args) > 0:
|
||||
base = args[0]
|
||||
|
||||
depth = 22
|
||||
if len(args) > 1:
|
||||
depth = int(args[1])
|
||||
|
||||
for i in range(depth-1, -1, -1):
|
||||
try:
|
||||
offset = i * 8
|
||||
base_addr = gdb.parse_and_eval(base)
|
||||
value = gdb.parse_and_eval(f"*(uint64_t*)({base} + {offset})")
|
||||
print("{:016x} (+{:04x}): {:016x}".format(int(base_addr) + offset, offset, int(value)))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
continue
|
||||
|
||||
|
||||
class PrintBacktraceCommand(gdb.Command):
|
||||
def __init__(self):
|
||||
super().__init__("j6bt", gdb.COMMAND_DATA)
|
||||
|
||||
def invoke(self, arg, from_tty):
|
||||
args = gdb.string_to_argv(arg)
|
||||
|
||||
depth = 30
|
||||
if len(args) > 0:
|
||||
depth = int(args[0])
|
||||
|
||||
frame = "$rbp"
|
||||
if len(args) > 1:
|
||||
frame = args[1]
|
||||
|
||||
for i in range(depth-1, -1, -1):
|
||||
ret = gdb.parse_and_eval(f"*(uint64_t*)({frame} + 8)")
|
||||
frame = gdb.parse_and_eval(f"*(uint64_t*)({frame})")
|
||||
|
||||
name = ""
|
||||
block = gdb.block_for_pc(int(ret))
|
||||
if block:
|
||||
name = block.function or ""
|
||||
|
||||
print("{:016x} {}".format(int(ret), name))
|
||||
|
||||
if frame == 0 or ret == 0:
|
||||
return
|
||||
|
||||
|
||||
PrintStackCommand()
|
||||
PrintBacktraceCommand()
|
||||
|
||||
gdb.execute("target remote :1234")
|
||||
gdb.execute("display/i $rip")
|
||||
@@ -12,12 +12,17 @@
|
||||
dest = "screenfont.psf"
|
||||
source = "../assets/fonts/tamsyn8x16r.psf"
|
||||
|
||||
[[files]]
|
||||
dest = "symbol_table.dat"
|
||||
source = "symbol_table.dat"
|
||||
symbols = true
|
||||
|
||||
[[files]]
|
||||
dest = "nulldrv1"
|
||||
source = "host/nulldrv"
|
||||
source = "user/nulldrv"
|
||||
executable = true
|
||||
|
||||
[[files]]
|
||||
dest = "nulldrv2"
|
||||
source = "host/nulldrv"
|
||||
source = "user/nulldrv"
|
||||
executable = true
|
||||
|
||||
Binary file not shown.
BIN
assets/ovmf/x64/ovmf_code.fd
Normal file
BIN
assets/ovmf/x64/ovmf_code.fd
Normal file
Binary file not shown.
BIN
assets/ovmf/x64/ovmf_vars.fd
Normal file
BIN
assets/ovmf/x64/ovmf_vars.fd
Normal file
Binary file not shown.
BIN
assets/ovmf/x64/ovmf_vars_d.fd
Normal file
BIN
assets/ovmf/x64/ovmf_vars_d.fd
Normal file
Binary file not shown.
8522
src/tests/catch.hpp → external/catch/catch.hpp
vendored
8522
src/tests/catch.hpp → external/catch/catch.hpp
vendored
File diff suppressed because it is too large
Load Diff
101
external/uefi/boot_services.h
vendored
Normal file
101
external/uefi/boot_services.h
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_boot_services_h_
|
||||
#define _uefi_boot_services_h_
|
||||
|
||||
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||
// not distributed with this file, You can obtain one at
|
||||
// http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <uefi/tables.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace bs_impl {
|
||||
using allocate_pages = status (*)(allocate_type, memory_type, size_t, void**);
|
||||
using get_memory_map = status (*)(size_t*, memory_descriptor*, size_t*, size_t*, uint32_t*);
|
||||
using allocate_pool = status (*)(memory_type, uint64_t, void**);
|
||||
using handle_protocol = status (*)(handle, const guid*, void**);
|
||||
using create_event = status (*)(evt, tpl, event_notify, void*, event*);
|
||||
using exit_boot_services = status (*)(handle, size_t);
|
||||
using locate_protocol = status (*)(const guid*, void*, void**);
|
||||
using copy_mem = void (*)(void*, void*, size_t);
|
||||
using set_mem = void (*)(void*, uint64_t, uint8_t);
|
||||
}
|
||||
|
||||
struct boot_services {
|
||||
static constexpr uint64_t signature = 0x56524553544f4f42ull;
|
||||
|
||||
table_header header;
|
||||
|
||||
// Task Priority Level management
|
||||
void *raise_tpl;
|
||||
void *restore_tpl;
|
||||
|
||||
// Memory Services
|
||||
bs_impl::allocate_pages allocate_pages;
|
||||
void *free_pages;
|
||||
bs_impl::get_memory_map get_memory_map;
|
||||
bs_impl::allocate_pool allocate_pool;
|
||||
void *free_pool;
|
||||
|
||||
// Event & Timer Services
|
||||
bs_impl::create_event create_event;
|
||||
void *set_timer;
|
||||
void *wait_for_event;
|
||||
void *signal_event;
|
||||
void *close_event;
|
||||
void *check_event;
|
||||
|
||||
// Protocol Handler Services
|
||||
void *install_protocol_interface;
|
||||
void *reinstall_protocol_interface;
|
||||
void *uninstall_protocol_interface;
|
||||
bs_impl::handle_protocol handle_protocol;
|
||||
void *_reserved;
|
||||
void *register_protocol_notify;
|
||||
void *locate_handle;
|
||||
void *locate_device_path;
|
||||
void *install_configuration_table;
|
||||
|
||||
// Image Services
|
||||
void *load_image;
|
||||
void *start_image;
|
||||
void *exit;
|
||||
void *unload_image;
|
||||
bs_impl::exit_boot_services exit_boot_services;
|
||||
|
||||
// Miscellaneous Services
|
||||
void *get_next_monotonic_count;
|
||||
void *stall;
|
||||
void *set_watchdog_timer;
|
||||
|
||||
// DriverSupport Services
|
||||
void *connect_controller;
|
||||
void *disconnect_controller;
|
||||
|
||||
// Open and Close Protocol Services
|
||||
void *open_protocol;
|
||||
void *close_protocol;
|
||||
void *open_protocol_information;
|
||||
|
||||
// Library Services
|
||||
void *protocols_per_handle;
|
||||
void *locate_handle_buffer;
|
||||
bs_impl::locate_protocol locate_protocol;
|
||||
void *install_multiple_protocol_interfaces;
|
||||
void *uninstall_multiple_protocol_interfaces;
|
||||
|
||||
// 32-bit CRC Services
|
||||
void *calculate_crc32;
|
||||
|
||||
// Miscellaneous Services
|
||||
bs_impl::copy_mem copy_mem;
|
||||
bs_impl::set_mem set_mem;
|
||||
void *create_event_ex;
|
||||
};
|
||||
|
||||
} // namespace uefi
|
||||
|
||||
#endif
|
||||
39
external/uefi/errors.inc
vendored
Normal file
39
external/uefi/errors.inc
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
STATUS_WARNING( warn_unknown_glyph, 1)
|
||||
STATUS_WARNING( warn_delete_failure, 2)
|
||||
STATUS_WARNING( warn_write_failure, 3)
|
||||
STATUS_WARNING( warn_buffer_too_small,4)
|
||||
STATUS_WARNING( warn_stale_data, 5)
|
||||
STATUS_WARNING( warn_file_system, 6)
|
||||
|
||||
STATUS_ERROR( load_error, 1)
|
||||
STATUS_ERROR( invalid_parameter, 2)
|
||||
STATUS_ERROR( unsupported, 3)
|
||||
STATUS_ERROR( bad_buffer_size, 4)
|
||||
STATUS_ERROR( buffer_too_small, 5)
|
||||
STATUS_ERROR( not_ready, 6)
|
||||
STATUS_ERROR( device_error, 7)
|
||||
STATUS_ERROR( write_protected, 8)
|
||||
STATUS_ERROR( out_of_resources, 9)
|
||||
STATUS_ERROR( volume_corrupted, 10)
|
||||
STATUS_ERROR( volume_full, 11)
|
||||
STATUS_ERROR( no_media, 12)
|
||||
STATUS_ERROR( media_changed, 13)
|
||||
STATUS_ERROR( not_found, 14)
|
||||
STATUS_ERROR( access_denied, 15)
|
||||
STATUS_ERROR( no_response, 16)
|
||||
STATUS_ERROR( no_mapping, 17)
|
||||
STATUS_ERROR( timeout, 18)
|
||||
STATUS_ERROR( not_started, 19)
|
||||
STATUS_ERROR( already_started, 20)
|
||||
STATUS_ERROR( aborted, 21)
|
||||
STATUS_ERROR( icmp_error, 22)
|
||||
STATUS_ERROR( tftp_error, 23)
|
||||
STATUS_ERROR( protocol_error, 24)
|
||||
STATUS_ERROR( incompatible_version, 25)
|
||||
STATUS_ERROR( security_violation, 26)
|
||||
STATUS_ERROR( crc_error, 27)
|
||||
STATUS_ERROR( end_of_media, 28)
|
||||
STATUS_ERROR( end_of_file, 31)
|
||||
STATUS_ERROR( invalid_language, 32)
|
||||
STATUS_ERROR( compromised_data, 33)
|
||||
STATUS_ERROR( http_error, 35)
|
||||
92
external/uefi/graphics.h
vendored
Normal file
92
external/uefi/graphics.h
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_graphics_h_
|
||||
#define _uefi_graphics_h_
|
||||
|
||||
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||
// not distributed with this file, You can obtain one at
|
||||
// http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace uefi {
|
||||
|
||||
struct text_output_mode
|
||||
{
|
||||
int32_t max_mode;
|
||||
int32_t mode;
|
||||
int32_t attribute;
|
||||
int32_t cursor_column;
|
||||
int32_t cursor_row;
|
||||
bool cursor_visible;
|
||||
};
|
||||
|
||||
struct pixel_bitmask
|
||||
{
|
||||
uint32_t red_mask;
|
||||
uint32_t green_mask;
|
||||
uint32_t blue_mask;
|
||||
uint32_t reserved_mask;
|
||||
};
|
||||
|
||||
enum class pixel_format
|
||||
{
|
||||
rgb8,
|
||||
bgr8,
|
||||
bitmask,
|
||||
blt_only
|
||||
};
|
||||
|
||||
struct graphics_output_mode_info
|
||||
{
|
||||
uint32_t version;
|
||||
uint32_t horizontal_resolution;
|
||||
uint32_t vertical_resolution;
|
||||
pixel_format pixel_format;
|
||||
pixel_bitmask pixel_information;
|
||||
uint32_t pixels_per_scanline;
|
||||
};
|
||||
|
||||
struct graphics_output_mode
|
||||
{
|
||||
uint32_t max_mode;
|
||||
uint32_t mode;
|
||||
graphics_output_mode_info *info;
|
||||
uint64_t size_of_info;
|
||||
uintptr_t frame_buffer_base;
|
||||
uint64_t frame_buffer_size;
|
||||
};
|
||||
|
||||
enum class attribute : uint64_t
|
||||
{
|
||||
black,
|
||||
blue,
|
||||
green,
|
||||
cyan,
|
||||
red,
|
||||
magenta,
|
||||
brown,
|
||||
light_gray,
|
||||
dark_gray,
|
||||
light_blue,
|
||||
light_green,
|
||||
light_cyan,
|
||||
light_red,
|
||||
light_magenta,
|
||||
yellow,
|
||||
white,
|
||||
|
||||
background_black = 0x00,
|
||||
background_blue = 0x10,
|
||||
background_green = 0x20,
|
||||
background_cyan = 0x30,
|
||||
background_red = 0x40,
|
||||
background_magenta = 0x50,
|
||||
background_brown = 0x60,
|
||||
background_light_gray = 0x70,
|
||||
};
|
||||
|
||||
} // namespace uefi
|
||||
|
||||
#endif
|
||||
29
external/uefi/guid.h
vendored
Normal file
29
external/uefi/guid.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_guid_h_
|
||||
#define _uefi_guid_h_
|
||||
|
||||
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||
// not distributed with this file, You can obtain one at
|
||||
// http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace uefi {
|
||||
|
||||
struct guid
|
||||
{
|
||||
uint32_t data1;
|
||||
uint16_t data2;
|
||||
uint16_t data3;
|
||||
uint8_t data4[8];
|
||||
|
||||
inline bool operator==(const guid &other) const {
|
||||
return reinterpret_cast<const uint64_t*>(this)[0] == reinterpret_cast<const uint64_t*>(&other)[0]
|
||||
&& reinterpret_cast<const uint64_t*>(this)[1] == reinterpret_cast<const uint64_t*>(&other)[1];
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace uefi
|
||||
|
||||
#endif
|
||||
30
external/uefi/protos/device_path.h
vendored
Normal file
30
external/uefi/protos/device_path.h
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_protos_device_path_h_
|
||||
#define _uefi_protos_device_path_h_
|
||||
|
||||
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace protos {
|
||||
struct device_path;
|
||||
|
||||
struct device_path
|
||||
{
|
||||
static constexpr uefi::guid guid{ 0x09576e91,0x6d3f,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||
|
||||
uint8_t type;
|
||||
uint8_t sub_type;
|
||||
uint16_t length;
|
||||
|
||||
protected:
|
||||
public:
|
||||
};
|
||||
|
||||
} // namespace protos
|
||||
} // namespace uefi
|
||||
|
||||
#endif // _uefi_protos_device_path_h_
|
||||
126
external/uefi/protos/file.h
vendored
Normal file
126
external/uefi/protos/file.h
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_protos_file_h_
|
||||
#define _uefi_protos_file_h_
|
||||
|
||||
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace protos {
|
||||
struct file;
|
||||
|
||||
struct file
|
||||
{
|
||||
|
||||
|
||||
inline uefi::status open(file ** new_handle, const wchar_t * file_name, file_mode open_mode, file_attr attributes) {
|
||||
return _open(this, new_handle, file_name, open_mode, attributes);
|
||||
}
|
||||
|
||||
inline uefi::status close() {
|
||||
return _close(this);
|
||||
}
|
||||
|
||||
inline uefi::status delete_file() {
|
||||
return _delete_file(this);
|
||||
}
|
||||
|
||||
inline uefi::status read(uint64_t * buffer_size, void * buffer) {
|
||||
return _read(this, buffer_size, buffer);
|
||||
}
|
||||
|
||||
inline uefi::status write(uint64_t * buffer_size, void * buffer) {
|
||||
return _write(this, buffer_size, buffer);
|
||||
}
|
||||
|
||||
inline uefi::status get_position(uint64_t * position) {
|
||||
return _get_position(this, position);
|
||||
}
|
||||
|
||||
inline uefi::status set_position(uint64_t position) {
|
||||
return _set_position(this, position);
|
||||
}
|
||||
|
||||
inline uefi::status get_info(const guid * info_type, uint64_t * buffer_size, void * buffer) {
|
||||
return _get_info(this, info_type, buffer_size, buffer);
|
||||
}
|
||||
|
||||
inline uefi::status set_info(const guid * info_type, uint64_t buffer_size, void * buffer) {
|
||||
return _set_info(this, info_type, buffer_size, buffer);
|
||||
}
|
||||
|
||||
inline uefi::status flush() {
|
||||
return _flush(this);
|
||||
}
|
||||
|
||||
inline uefi::status open_ex(file ** new_handle, const wchar_t * file_name, uint64_t open_mode, uint64_t attributes, file_io_token * token) {
|
||||
return _open_ex(this, new_handle, file_name, open_mode, attributes, token);
|
||||
}
|
||||
|
||||
inline uefi::status read_ex(file_io_token * token) {
|
||||
return _read_ex(this, token);
|
||||
}
|
||||
|
||||
inline uefi::status write_ex(file_io_token * token) {
|
||||
return _write_ex(this, token);
|
||||
}
|
||||
|
||||
inline uefi::status flush_ex(file_io_token * token) {
|
||||
return _flush_ex(this, token);
|
||||
}
|
||||
|
||||
uint64_t revision;
|
||||
|
||||
protected:
|
||||
using _open_def = uefi::status (*)(uefi::protos::file *, file **, const wchar_t *, file_mode, file_attr);
|
||||
_open_def _open;
|
||||
|
||||
using _close_def = uefi::status (*)(uefi::protos::file *);
|
||||
_close_def _close;
|
||||
|
||||
using _delete_file_def = uefi::status (*)(uefi::protos::file *);
|
||||
_delete_file_def _delete_file;
|
||||
|
||||
using _read_def = uefi::status (*)(uefi::protos::file *, uint64_t *, void *);
|
||||
_read_def _read;
|
||||
|
||||
using _write_def = uefi::status (*)(uefi::protos::file *, uint64_t *, void *);
|
||||
_write_def _write;
|
||||
|
||||
using _get_position_def = uefi::status (*)(uefi::protos::file *, uint64_t *);
|
||||
_get_position_def _get_position;
|
||||
|
||||
using _set_position_def = uefi::status (*)(uefi::protos::file *, uint64_t);
|
||||
_set_position_def _set_position;
|
||||
|
||||
using _get_info_def = uefi::status (*)(uefi::protos::file *, const guid *, uint64_t *, void *);
|
||||
_get_info_def _get_info;
|
||||
|
||||
using _set_info_def = uefi::status (*)(uefi::protos::file *, const guid *, uint64_t, void *);
|
||||
_set_info_def _set_info;
|
||||
|
||||
using _flush_def = uefi::status (*)(uefi::protos::file *);
|
||||
_flush_def _flush;
|
||||
|
||||
using _open_ex_def = uefi::status (*)(uefi::protos::file *, file **, const wchar_t *, uint64_t, uint64_t, file_io_token *);
|
||||
_open_ex_def _open_ex;
|
||||
|
||||
using _read_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *);
|
||||
_read_ex_def _read_ex;
|
||||
|
||||
using _write_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *);
|
||||
_write_ex_def _write_ex;
|
||||
|
||||
using _flush_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *);
|
||||
_flush_ex_def _flush_ex;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
} // namespace protos
|
||||
} // namespace uefi
|
||||
|
||||
#endif // _uefi_protos_file_h_
|
||||
35
external/uefi/protos/file_info.h
vendored
Normal file
35
external/uefi/protos/file_info.h
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_protos_file_info_h_
|
||||
#define _uefi_protos_file_info_h_
|
||||
|
||||
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace protos {
|
||||
struct file_info;
|
||||
|
||||
struct file_info
|
||||
{
|
||||
static constexpr uefi::guid guid{ 0x09576e92,0x6d3f,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||
|
||||
uint64_t size;
|
||||
uint64_t file_size;
|
||||
uint64_t physical_size;
|
||||
time create_time;
|
||||
time last_access_time;
|
||||
time modification_time;
|
||||
uint64_t attribute;
|
||||
wchar_t file_name[];
|
||||
|
||||
protected:
|
||||
public:
|
||||
};
|
||||
|
||||
} // namespace protos
|
||||
} // namespace uefi
|
||||
|
||||
#endif // _uefi_protos_file_info_h_
|
||||
50
external/uefi/protos/graphics_output.h
vendored
Normal file
50
external/uefi/protos/graphics_output.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_protos_graphics_output_h_
|
||||
#define _uefi_protos_graphics_output_h_
|
||||
|
||||
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/graphics.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace protos {
|
||||
struct graphics_output;
|
||||
|
||||
struct graphics_output
|
||||
{
|
||||
static constexpr uefi::guid guid{ 0x9042a9de,0x23dc,0x4a38,{0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a} };
|
||||
|
||||
inline uefi::status query_mode(uint32_t mode_number, uint64_t * size_of_info, uefi::graphics_output_mode_info ** info) {
|
||||
return _query_mode(this, mode_number, size_of_info, info);
|
||||
}
|
||||
|
||||
inline uefi::status set_mode(uint32_t mode_number) {
|
||||
return _set_mode(this, mode_number);
|
||||
}
|
||||
|
||||
inline uefi::status blt() {
|
||||
return _blt(this);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
using _query_mode_def = uefi::status (*)(uefi::protos::graphics_output *, uint32_t, uint64_t *, uefi::graphics_output_mode_info **);
|
||||
_query_mode_def _query_mode;
|
||||
|
||||
using _set_mode_def = uefi::status (*)(uefi::protos::graphics_output *, uint32_t);
|
||||
_set_mode_def _set_mode;
|
||||
|
||||
using _blt_def = uefi::status (*)(uefi::protos::graphics_output *);
|
||||
_blt_def _blt;
|
||||
|
||||
public:
|
||||
uefi::graphics_output_mode * mode;
|
||||
};
|
||||
|
||||
} // namespace protos
|
||||
} // namespace uefi
|
||||
|
||||
#endif // _uefi_protos_graphics_output_h_
|
||||
48
external/uefi/protos/loaded_image.h
vendored
Normal file
48
external/uefi/protos/loaded_image.h
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_protos_loaded_image_h_
|
||||
#define _uefi_protos_loaded_image_h_
|
||||
|
||||
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/tables.h>
|
||||
#include <uefi/protos/device_path.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace protos {
|
||||
struct loaded_image;
|
||||
|
||||
struct loaded_image
|
||||
{
|
||||
static constexpr uefi::guid guid{ 0x5b1b31a1,0x9562,0x11d2,{0x8e,0x3f,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||
|
||||
inline uefi::status unload(uefi::handle image_handle) {
|
||||
return _unload(image_handle);
|
||||
}
|
||||
|
||||
uint32_t revision;
|
||||
uefi::handle parent_handle;
|
||||
uefi::system_table * system_table;
|
||||
uefi::handle device_handle;
|
||||
uefi::protos::device_path * file_path;
|
||||
void * reserved;
|
||||
uint32_t load_options_size;
|
||||
void * load_options;
|
||||
void * image_base;
|
||||
uint64_t image_size;
|
||||
uefi::memory_type image_code_type;
|
||||
uefi::memory_type image_data_type;
|
||||
|
||||
protected:
|
||||
using _unload_def = uefi::status (*)(uefi::handle);
|
||||
_unload_def _unload;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
} // namespace protos
|
||||
} // namespace uefi
|
||||
|
||||
#endif // _uefi_protos_loaded_image_h_
|
||||
36
external/uefi/protos/simple_file_system.h
vendored
Normal file
36
external/uefi/protos/simple_file_system.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_protos_simple_file_system_h_
|
||||
#define _uefi_protos_simple_file_system_h_
|
||||
|
||||
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/protos/file.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace protos {
|
||||
struct simple_file_system;
|
||||
|
||||
struct simple_file_system
|
||||
{
|
||||
static constexpr uefi::guid guid{ 0x0964e5b22,0x6459,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||
|
||||
inline uefi::status open_volume(uefi::protos::file ** root) {
|
||||
return _open_volume(this, root);
|
||||
}
|
||||
|
||||
uint64_t revision;
|
||||
|
||||
protected:
|
||||
using _open_volume_def = uefi::status (*)(uefi::protos::simple_file_system *, uefi::protos::file **);
|
||||
_open_volume_def _open_volume;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
} // namespace protos
|
||||
} // namespace uefi
|
||||
|
||||
#endif // _uefi_protos_simple_file_system_h_
|
||||
92
external/uefi/protos/simple_text_output.h
vendored
Normal file
92
external/uefi/protos/simple_text_output.h
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_protos_simple_text_output_h_
|
||||
#define _uefi_protos_simple_text_output_h_
|
||||
|
||||
// This file was auto generated by the j6-uefi-headers project. Please see
|
||||
// https://github.com/justinian/j6-uefi-headers for more information.
|
||||
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/graphics.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace protos {
|
||||
struct simple_text_output;
|
||||
|
||||
struct simple_text_output
|
||||
{
|
||||
static constexpr uefi::guid guid{ 0x387477c2,0x69c7,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} };
|
||||
|
||||
inline uefi::status reset(bool extended_verification) {
|
||||
return _reset(this, extended_verification);
|
||||
}
|
||||
|
||||
inline uefi::status output_string(const wchar_t * string) {
|
||||
return _output_string(this, string);
|
||||
}
|
||||
|
||||
inline uefi::status test_string(const wchar_t * string) {
|
||||
return _test_string(this, string);
|
||||
}
|
||||
|
||||
inline uefi::status query_mode(uint64_t mode_number, uint64_t * columns, uint64_t * rows) {
|
||||
return _query_mode(this, mode_number, columns, rows);
|
||||
}
|
||||
|
||||
inline uefi::status set_mode(uint64_t mode_number) {
|
||||
return _set_mode(this, mode_number);
|
||||
}
|
||||
|
||||
inline uefi::status set_attribute(uefi::attribute attribute) {
|
||||
return _set_attribute(this, attribute);
|
||||
}
|
||||
|
||||
inline uefi::status clear_screen() {
|
||||
return _clear_screen(this);
|
||||
}
|
||||
|
||||
inline uefi::status set_cursor_position(uint64_t column, uint64_t row) {
|
||||
return _set_cursor_position(this, column, row);
|
||||
}
|
||||
|
||||
inline uefi::status enable_cursor(bool visible) {
|
||||
return _enable_cursor(this, visible);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
using _reset_def = uefi::status (*)(uefi::protos::simple_text_output *, bool);
|
||||
_reset_def _reset;
|
||||
|
||||
using _output_string_def = uefi::status (*)(uefi::protos::simple_text_output *, const wchar_t *);
|
||||
_output_string_def _output_string;
|
||||
|
||||
using _test_string_def = uefi::status (*)(uefi::protos::simple_text_output *, const wchar_t *);
|
||||
_test_string_def _test_string;
|
||||
|
||||
using _query_mode_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t, uint64_t *, uint64_t *);
|
||||
_query_mode_def _query_mode;
|
||||
|
||||
using _set_mode_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t);
|
||||
_set_mode_def _set_mode;
|
||||
|
||||
using _set_attribute_def = uefi::status (*)(uefi::protos::simple_text_output *, uefi::attribute);
|
||||
_set_attribute_def _set_attribute;
|
||||
|
||||
using _clear_screen_def = uefi::status (*)(uefi::protos::simple_text_output *);
|
||||
_clear_screen_def _clear_screen;
|
||||
|
||||
using _set_cursor_position_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t, uint64_t);
|
||||
_set_cursor_position_def _set_cursor_position;
|
||||
|
||||
using _enable_cursor_def = uefi::status (*)(uefi::protos::simple_text_output *, bool);
|
||||
_enable_cursor_def _enable_cursor;
|
||||
|
||||
public:
|
||||
uefi::text_output_mode * mode;
|
||||
};
|
||||
|
||||
} // namespace protos
|
||||
} // namespace uefi
|
||||
|
||||
#endif // _uefi_protos_simple_text_output_h_
|
||||
52
external/uefi/runtime_services.h
vendored
Normal file
52
external/uefi/runtime_services.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_runtime_services_h_
|
||||
#define _uefi_runtime_services_h_
|
||||
|
||||
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||
// not distributed with this file, You can obtain one at
|
||||
// http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <uefi/tables.h>
|
||||
|
||||
namespace uefi {
|
||||
namespace rs_impl {
|
||||
using convert_pointer = uefi::status (*)(uint64_t, void **);
|
||||
using set_virtual_address_map = uefi::status (*)(size_t, size_t, uint32_t, memory_descriptor *);
|
||||
}
|
||||
|
||||
struct runtime_services {
|
||||
static constexpr uint64_t signature = 0x56524553544e5552ull;
|
||||
|
||||
table_header header;
|
||||
|
||||
// Time Services
|
||||
void *get_time;
|
||||
void *set_time;
|
||||
void *get_wakeup_time;
|
||||
void *set_wakeup_time;
|
||||
|
||||
// Virtual Memory Services
|
||||
rs_impl::set_virtual_address_map set_virtual_address_map;
|
||||
rs_impl::convert_pointer convert_pointer;
|
||||
|
||||
// Variable Services
|
||||
void *get_variable;
|
||||
void *get_next_variable_name;
|
||||
void *set_variable;
|
||||
|
||||
// Miscellaneous Services
|
||||
void *get_next_high_monotonic_count;
|
||||
void *reset_system;
|
||||
|
||||
// UEFI 2.0 Capsule Services
|
||||
void *update_capsule;
|
||||
void *query_capsule_capabilities;
|
||||
|
||||
// Miscellaneous UEFI 2.0 Service
|
||||
void *query_variable_info;
|
||||
};
|
||||
|
||||
} // namespace uefi
|
||||
#endif
|
||||
73
external/uefi/tables.h
vendored
Normal file
73
external/uefi/tables.h
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_tables_h_
|
||||
#define _uefi_tables_h_
|
||||
|
||||
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||
// not distributed with this file, You can obtain one at
|
||||
// http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace uefi {
|
||||
|
||||
struct runtime_services;
|
||||
struct boot_services;
|
||||
namespace protos {
|
||||
struct simple_text_input;
|
||||
struct simple_text_output;
|
||||
}
|
||||
|
||||
struct table_header
|
||||
{
|
||||
uint64_t signature;
|
||||
uint32_t revision;
|
||||
uint32_t header_size;
|
||||
uint32_t crc32;
|
||||
uint32_t reserved;
|
||||
};
|
||||
|
||||
struct configuration_table
|
||||
{
|
||||
guid vendor_guid;
|
||||
void *vendor_table;
|
||||
};
|
||||
|
||||
struct system_table
|
||||
{
|
||||
table_header header;
|
||||
|
||||
char16_t *firmware_vendor;
|
||||
uint32_t firmware_revision;
|
||||
|
||||
handle console_in_handle;
|
||||
protos::simple_text_input *con_in;
|
||||
handle console_out_handle;
|
||||
protos::simple_text_output *con_out;
|
||||
handle standard_error_handle;
|
||||
protos::simple_text_output *std_err;
|
||||
|
||||
runtime_services *runtime_services;
|
||||
boot_services *boot_services;
|
||||
|
||||
unsigned int number_of_table_entries;
|
||||
configuration_table *configuration_table;
|
||||
};
|
||||
|
||||
constexpr uint32_t make_system_table_revision(int major, int minor) {
|
||||
return (major << 16) | minor;
|
||||
}
|
||||
|
||||
constexpr uint64_t system_table_signature = 0x5453595320494249ull;
|
||||
constexpr uint32_t system_table_revision = make_system_table_revision(2, 70);
|
||||
constexpr uint32_t specification_revision = system_table_revision;
|
||||
|
||||
namespace vendor_guids {
|
||||
constexpr guid acpi1{ 0xeb9d2d30,0x2d88,0x11d3,{0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d} };
|
||||
constexpr guid acpi2{ 0x8868e871,0xe4f1,0x11d3,{0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81} };
|
||||
} // namespace vendor_guids
|
||||
} // namespace uefi
|
||||
|
||||
#endif
|
||||
157
external/uefi/types.h
vendored
Normal file
157
external/uefi/types.h
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
#pragma once
|
||||
#ifndef _uefi_types_h_
|
||||
#define _uefi_types_h_
|
||||
|
||||
// This Source Code Form is part of the j6-uefi-headers project and is subject
|
||||
// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was
|
||||
// not distributed with this file, You can obtain one at
|
||||
// http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace uefi {
|
||||
|
||||
using handle = void *;
|
||||
|
||||
|
||||
//
|
||||
// Error and status code definitions
|
||||
//
|
||||
constexpr uint64_t error_bit = 0x8000000000000000ull;
|
||||
constexpr uint64_t make_error(uint64_t e) { return e|error_bit; }
|
||||
|
||||
enum class status : uint64_t
|
||||
{
|
||||
success = 0,
|
||||
|
||||
#define STATUS_WARNING(name, num) name = num,
|
||||
#define STATUS_ERROR(name, num) name = make_error(num),
|
||||
#include "uefi/errors.inc"
|
||||
#undef STATUS_WARNING
|
||||
#undef STATUS_ERROR
|
||||
};
|
||||
|
||||
inline bool is_error(status s) { return static_cast<uint64_t>(s) & error_bit; }
|
||||
inline bool is_warning(status s) { return !is_error(s) && s != status::success; }
|
||||
|
||||
|
||||
//
|
||||
// Time defitions
|
||||
//
|
||||
struct time
|
||||
{
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
uint8_t _pad0;
|
||||
uint32_t nanosecond;
|
||||
int16_t time_zone;
|
||||
uint8_t daylight;
|
||||
uint8_t _pad1;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Memory and allocation defitions
|
||||
//
|
||||
enum class memory_type : uint32_t
|
||||
{
|
||||
reserved,
|
||||
loader_code,
|
||||
loader_data,
|
||||
boot_services_code,
|
||||
boot_services_data,
|
||||
runtime_services_code,
|
||||
runtime_services_data,
|
||||
conventional_memory,
|
||||
unusable_memory,
|
||||
acpi_reclaim_memory,
|
||||
acpi_memory_nvs,
|
||||
memory_mapped_io,
|
||||
memory_mapped_io_port_space,
|
||||
pal_code,
|
||||
persistent_memory,
|
||||
max_memory_type
|
||||
};
|
||||
|
||||
enum class allocate_type : uint32_t
|
||||
{
|
||||
any_pages,
|
||||
max_address,
|
||||
address
|
||||
};
|
||||
|
||||
struct memory_descriptor
|
||||
{
|
||||
memory_type type;
|
||||
uintptr_t physical_start;
|
||||
uintptr_t virtual_start;
|
||||
uint64_t number_of_pages;
|
||||
uint64_t attribute;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Event handling defitions
|
||||
//
|
||||
using event = void *;
|
||||
|
||||
enum class evt : uint32_t
|
||||
{
|
||||
notify_wait = 0x00000100,
|
||||
notify_signal = 0x00000200,
|
||||
|
||||
signal_exit_boot_services = 0x00000201,
|
||||
signal_virtual_address_change = 0x60000202,
|
||||
|
||||
runtime = 0x40000000,
|
||||
timer = 0x80000000
|
||||
};
|
||||
|
||||
enum class tpl : uint64_t
|
||||
{
|
||||
application = 4,
|
||||
callback = 8,
|
||||
notify = 16,
|
||||
high_level = 31
|
||||
};
|
||||
|
||||
using event_notify = void (*)(event, void*);
|
||||
|
||||
|
||||
//
|
||||
// File IO defitions
|
||||
//
|
||||
struct file_io_token
|
||||
{
|
||||
event event;
|
||||
status status;
|
||||
uint64_t buffer_size;
|
||||
void *buffer;
|
||||
};
|
||||
|
||||
enum class file_mode : uint64_t
|
||||
{
|
||||
read = 0x0000000000000001ull,
|
||||
write = 0x0000000000000002ull,
|
||||
|
||||
create = 0x8000000000000000ull
|
||||
};
|
||||
|
||||
enum class file_attr : uint64_t
|
||||
{
|
||||
none = 0,
|
||||
read_only = 0x0000000000000001ull,
|
||||
hidden = 0x0000000000000002ull,
|
||||
system = 0x0000000000000004ull,
|
||||
reserved = 0x0000000000000008ull,
|
||||
directory = 0x0000000000000010ull,
|
||||
archive = 0x0000000000000020ull
|
||||
};
|
||||
|
||||
} // namespace uefi
|
||||
|
||||
#endif
|
||||
@@ -1,165 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
library = namedtuple('library', ['path', 'deps'])
|
||||
program = namedtuple('program', ['path', 'deps', 'output', 'targets'])
|
||||
source = namedtuple('source', ['name', 'input', 'output', 'action'])
|
||||
version = namedtuple('version', ['major', 'minor', 'patch', 'sha', 'dirty'])
|
||||
|
||||
MODULES = {
|
||||
"elf": library('src/libraries/elf', ['kutil']),
|
||||
"initrd": library('src/libraries/initrd', ["kutil"]),
|
||||
"kutil": library('src/libraries/kutil', []),
|
||||
|
||||
"makerd": program('src/tools/makerd', ["initrd", "kutil"], "makerd", ["native"]),
|
||||
|
||||
"boot": program('src/boot', [], "boot.elf", ["boot"]),
|
||||
|
||||
"nulldrv": program('src/drivers/nulldrv', [], "nulldrv", ["host"]),
|
||||
"kernel": program('src/kernel', ["elf", "initrd", "kutil"], "popcorn.elf", ["host"]),
|
||||
}
|
||||
|
||||
|
||||
def get_template(env, typename, name):
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
try:
|
||||
return env.get_template("{}.{}.ninja.j2".format(typename, name))
|
||||
except TemplateNotFound:
|
||||
return env.get_template("{}.default.ninja.j2".format(typename))
|
||||
|
||||
|
||||
def get_sources(path, srcroot):
|
||||
import os
|
||||
from os.path import abspath, join, relpath, splitext
|
||||
|
||||
actions = {'.c': 'cc', '.cpp': 'cxx', '.s': 'nasm'}
|
||||
|
||||
sources = []
|
||||
for root, dirs, files in os.walk(path):
|
||||
for f in files:
|
||||
base, ext = splitext(f)
|
||||
if not ext in actions: continue
|
||||
name = join(root, f)
|
||||
sources.append(
|
||||
source(
|
||||
relpath(name, srcroot),
|
||||
abspath(name),
|
||||
relpath(abspath(name), path) + ".o",
|
||||
actions[ext]))
|
||||
|
||||
return sources
|
||||
|
||||
|
||||
def get_git_version():
|
||||
from subprocess import run
|
||||
cp = run(['git', 'describe', '--dirty', '--abbrev=7'],
|
||||
check=True, capture_output=True)
|
||||
full_version = cp.stdout.decode('utf-8').strip()
|
||||
|
||||
dirty = False
|
||||
parts1 = full_version.split('-')
|
||||
if parts1[-1] == "dirty":
|
||||
dirty = True
|
||||
parts1 = parts1[:-1]
|
||||
|
||||
parts2 = parts1[0].split('.')
|
||||
|
||||
return version(
|
||||
parts2[0],
|
||||
parts2[1],
|
||||
parts2[2],
|
||||
parts1[-1][1:],
|
||||
dirty)
|
||||
|
||||
|
||||
def main(buildroot):
|
||||
import os
|
||||
from os.path import abspath, dirname, isdir, join
|
||||
|
||||
generator = abspath(__file__)
|
||||
srcroot = dirname(generator)
|
||||
|
||||
if buildroot is None:
|
||||
buildroot = join(srcroot, "build")
|
||||
|
||||
if not isdir(buildroot):
|
||||
os.mkdir(buildroot)
|
||||
|
||||
git_version = get_git_version()
|
||||
print("Generating build files for Popcorn {}.{}.{}-{}...".format(
|
||||
git_version.major, git_version.minor, git_version.patch, git_version.sha))
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader(join(srcroot, "scripts", "templates")))
|
||||
|
||||
targets = {}
|
||||
templates = set()
|
||||
buildfiles = []
|
||||
for name, mod in MODULES.items():
|
||||
if isinstance(mod, program):
|
||||
for target in mod.targets:
|
||||
if not target in targets:
|
||||
targets[target] = set()
|
||||
|
||||
open_list = [name]
|
||||
while open_list:
|
||||
depname = open_list.pop()
|
||||
dep = MODULES[depname]
|
||||
open_list.extend(dep.deps)
|
||||
targets[target].add(depname)
|
||||
|
||||
sources = get_sources(join(srcroot, mod.path), join(srcroot, "src"))
|
||||
buildfile = join(buildroot, name + ".ninja")
|
||||
buildfiles.append(buildfile)
|
||||
with open(buildfile, 'w') as out:
|
||||
#print("Generating module", name)
|
||||
template = get_template(env, type(mod).__name__, name)
|
||||
templates.add(template.filename)
|
||||
out.write(template.render(
|
||||
name=name,
|
||||
module=mod,
|
||||
sources=sources,
|
||||
buildfile=buildfile,
|
||||
version=git_version))
|
||||
|
||||
for target, mods in targets.items():
|
||||
root = join(buildroot, target)
|
||||
if not isdir(root):
|
||||
os.mkdir(root)
|
||||
|
||||
buildfile = join(root, "target.ninja")
|
||||
buildfiles.append(buildfile)
|
||||
with open(buildfile, 'w') as out:
|
||||
#print("Generating target", target)
|
||||
template = get_template(env, "target", target)
|
||||
templates.add(template.filename)
|
||||
out.write(template.render(
|
||||
target=target,
|
||||
modules=mods,
|
||||
buildfile=buildfile,
|
||||
version=git_version))
|
||||
|
||||
buildfile = join(buildroot, "build.ninja")
|
||||
buildfiles.append(buildfile)
|
||||
with open(buildfile, 'w') as out:
|
||||
#print("Generating main build.ninja")
|
||||
template = env.get_template('build.ninja.j2')
|
||||
templates.add(template.filename)
|
||||
|
||||
out.write(template.render(
|
||||
targets=targets,
|
||||
buildroot=buildroot,
|
||||
srcroot=srcroot,
|
||||
buildfile=buildfile,
|
||||
buildfiles=buildfiles,
|
||||
templates=[abspath(f) for f in templates],
|
||||
generator=generator,
|
||||
version=git_version))
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
buildroot = None
|
||||
if len(sys.argv) > 1:
|
||||
buildroot = sys.argv[1]
|
||||
main(buildroot)
|
||||
321
modules.yaml
Normal file
321
modules.yaml
Normal file
@@ -0,0 +1,321 @@
|
||||
name: jsix
|
||||
templates: scripts/templates
|
||||
modules:
|
||||
kernel:
|
||||
kind: exe
|
||||
output: jsix.elf
|
||||
target: host
|
||||
deps:
|
||||
- cpu
|
||||
- kutil
|
||||
includes:
|
||||
- src/kernel
|
||||
source:
|
||||
- src/kernel/apic.cpp
|
||||
- src/kernel/assert.cpp
|
||||
- src/kernel/boot.s
|
||||
- src/kernel/clock.cpp
|
||||
- src/kernel/console.cpp
|
||||
- src/kernel/cpprt.cpp
|
||||
- src/kernel/cpu.cpp
|
||||
- src/kernel/debug.cpp
|
||||
- src/kernel/debug.s
|
||||
- src/kernel/device_manager.cpp
|
||||
- src/kernel/frame_allocator.cpp
|
||||
- src/kernel/fs/gpt.cpp
|
||||
- src/kernel/gdt.cpp
|
||||
- src/kernel/gdt.s
|
||||
- src/kernel/hpet.cpp
|
||||
- src/kernel/interrupts.cpp
|
||||
- src/kernel/interrupts.s
|
||||
- src/kernel/io.cpp
|
||||
- src/kernel/loader.s
|
||||
- src/kernel/log.cpp
|
||||
- src/kernel/main.cpp
|
||||
- src/kernel/memory_bootstrap.cpp
|
||||
- src/kernel/msr.cpp
|
||||
- src/kernel/objects/channel.cpp
|
||||
- src/kernel/objects/endpoint.cpp
|
||||
- src/kernel/objects/kobject.cpp
|
||||
- src/kernel/objects/thread.cpp
|
||||
- src/kernel/objects/process.cpp
|
||||
- src/kernel/objects/system.cpp
|
||||
- src/kernel/objects/vm_area.cpp
|
||||
- src/kernel/page_table.cpp
|
||||
- src/kernel/pci.cpp
|
||||
- src/kernel/scheduler.cpp
|
||||
- src/kernel/serial.cpp
|
||||
- src/kernel/symbol_table.cpp
|
||||
- src/kernel/syscall.cpp
|
||||
- src/kernel/syscall.s
|
||||
- src/kernel/syscalls/channel.cpp
|
||||
- src/kernel/syscalls/endpoint.cpp
|
||||
- src/kernel/syscalls/object.cpp
|
||||
- src/kernel/syscalls/process.cpp
|
||||
- src/kernel/syscalls/system.cpp
|
||||
- src/kernel/syscalls/thread.cpp
|
||||
- src/kernel/syscalls/vm_area.cpp
|
||||
- src/kernel/task.s
|
||||
- src/kernel/vm_mapper.cpp
|
||||
- src/kernel/vm_space.cpp
|
||||
|
||||
boot:
|
||||
kind: exe
|
||||
target: boot
|
||||
output: boot.efi
|
||||
deps:
|
||||
- cpu
|
||||
source:
|
||||
- src/boot/main.cpp
|
||||
- src/boot/console.cpp
|
||||
- src/boot/error.cpp
|
||||
- src/boot/fs.cpp
|
||||
- src/boot/hardware.cpp
|
||||
- src/boot/loader.cpp
|
||||
- src/boot/memory.cpp
|
||||
- src/boot/paging.cpp
|
||||
- src/boot/status.cpp
|
||||
- src/boot/support.cpp
|
||||
|
||||
nulldrv:
|
||||
kind: exe
|
||||
target: user
|
||||
output: nulldrv.elf
|
||||
deps:
|
||||
- libc
|
||||
source:
|
||||
- src/drivers/nulldrv/io.cpp
|
||||
- src/drivers/nulldrv/main.cpp
|
||||
- src/drivers/nulldrv/serial.cpp
|
||||
|
||||
fb:
|
||||
kind: exe
|
||||
target: user
|
||||
output: fb.elf
|
||||
deps:
|
||||
- libc
|
||||
source:
|
||||
- src/drivers/fb/font.cpp
|
||||
- src/drivers/fb/main.cpp
|
||||
- src/drivers/fb/screen.cpp
|
||||
- src/drivers/fb/scrollback.cpp
|
||||
|
||||
kutil:
|
||||
kind: lib
|
||||
output: libkutil.a
|
||||
includes:
|
||||
- src/libraries/kutil/include
|
||||
source:
|
||||
- src/libraries/kutil/assert.cpp
|
||||
- src/libraries/kutil/bip_buffer.cpp
|
||||
- src/libraries/kutil/heap_allocator.cpp
|
||||
- src/libraries/kutil/logger.cpp
|
||||
- src/libraries/kutil/memory.cpp
|
||||
- src/libraries/kutil/printf.c
|
||||
|
||||
cpu:
|
||||
kind: lib
|
||||
output: libcpu.a
|
||||
includes:
|
||||
- src/libraries/cpu/include
|
||||
source:
|
||||
- src/libraries/cpu/cpu.cpp
|
||||
|
||||
|
||||
libc:
|
||||
kind: lib
|
||||
output: libc.a
|
||||
includes:
|
||||
- src/libraries/libc/include
|
||||
target: user
|
||||
defines:
|
||||
- DISABLE_SSE
|
||||
- LACKS_UNISTD_H
|
||||
- LACKS_FCNTL_H
|
||||
- LACKS_SYS_PARAM_H
|
||||
- LACKS_SYS_MMAN_H
|
||||
- LACKS_SCHED_H
|
||||
- LACKS_STRINGS_H
|
||||
- HAVE_MMAP=0
|
||||
#- LACKS_STRING_H
|
||||
#- LACKS_ERRNO_H
|
||||
#- LACKS_STDLIB_H
|
||||
#- LACKS_TIME_H
|
||||
source:
|
||||
- src/libraries/libc/arch/x86_64/_Exit.s
|
||||
- src/libraries/libc/arch/x86_64/crt0.s
|
||||
- src/libraries/libc/arch/x86_64/init_libc.c
|
||||
- src/libraries/libc/arch/x86_64/syscalls.s
|
||||
- src/libraries/libc/ctype/isalnum.c
|
||||
- src/libraries/libc/ctype/isalpha.c
|
||||
- src/libraries/libc/ctype/isblank.c
|
||||
- src/libraries/libc/ctype/iscntrl.c
|
||||
- src/libraries/libc/ctype/isdigit.c
|
||||
- src/libraries/libc/ctype/isgraph.c
|
||||
- src/libraries/libc/ctype/islower.c
|
||||
- src/libraries/libc/ctype/isprint.c
|
||||
- src/libraries/libc/ctype/ispunct.c
|
||||
- src/libraries/libc/ctype/isspace.c
|
||||
- src/libraries/libc/ctype/isupper.c
|
||||
- src/libraries/libc/ctype/isxdigit.c
|
||||
- src/libraries/libc/ctype/tolower.c
|
||||
- src/libraries/libc/ctype/toupper.c
|
||||
- src/libraries/libc/inttypes/imaxabs.c
|
||||
- src/libraries/libc/inttypes/imaxdiv.c
|
||||
- src/libraries/libc/inttypes/strtoimax.c
|
||||
- src/libraries/libc/inttypes/strtoumax.c
|
||||
- src/libraries/libc/locale/localeconv.c
|
||||
- src/libraries/libc/locale/setlocale.c
|
||||
- src/libraries/libc/j6libc/assert.c
|
||||
- src/libraries/libc/j6libc/errno.c
|
||||
- src/libraries/libc/j6libc/allocpages.c
|
||||
- src/libraries/libc/j6libc/atomax.c
|
||||
- src/libraries/libc/j6libc/closeall.c
|
||||
- src/libraries/libc/j6libc/close.c
|
||||
- src/libraries/libc/j6libc/digits.c
|
||||
- src/libraries/libc/j6libc/filemode.c
|
||||
- src/libraries/libc/j6libc/fillbuffer.c
|
||||
- src/libraries/libc/j6libc/flushbuffer.c
|
||||
- src/libraries/libc/j6libc/is_leap.c
|
||||
- src/libraries/libc/j6libc/load_lc_collate.c
|
||||
- src/libraries/libc/j6libc/load_lc_ctype.c
|
||||
- src/libraries/libc/j6libc/load_lc_messages.c
|
||||
- src/libraries/libc/j6libc/load_lc_monetary.c
|
||||
- src/libraries/libc/j6libc/load_lc_numeric.c
|
||||
- src/libraries/libc/j6libc/load_lc_time.c
|
||||
- src/libraries/libc/j6libc/load_lines.c
|
||||
- src/libraries/libc/j6libc/open.c
|
||||
- src/libraries/libc/j6libc/prepread.c
|
||||
- src/libraries/libc/j6libc/prepwrite.c
|
||||
- src/libraries/libc/j6libc/print.c
|
||||
- src/libraries/libc/j6libc/rename.c
|
||||
- src/libraries/libc/j6libc/scan.c
|
||||
- src/libraries/libc/j6libc/seed.c
|
||||
- src/libraries/libc/j6libc/seek.c
|
||||
- src/libraries/libc/j6libc/stdinit.c
|
||||
- src/libraries/libc/j6libc/strtox_main.c
|
||||
- src/libraries/libc/j6libc/strtox_prelim.c
|
||||
- src/libraries/libc/j6libc/sbrk.c
|
||||
- src/libraries/libc/signal/raise.c
|
||||
- src/libraries/libc/signal/signal.c
|
||||
- src/libraries/libc/stdio/clearerr.c
|
||||
- src/libraries/libc/stdio/fclose.c
|
||||
- src/libraries/libc/stdio/feof.c
|
||||
- src/libraries/libc/stdio/ferror.c
|
||||
- src/libraries/libc/stdio/fflush.c
|
||||
- src/libraries/libc/stdio/fgetc.c
|
||||
- src/libraries/libc/stdio/fgetpos.c
|
||||
- src/libraries/libc/stdio/fgets.c
|
||||
- src/libraries/libc/stdio/fopen.c
|
||||
- src/libraries/libc/stdio/fprintf.c
|
||||
- src/libraries/libc/stdio/fputc.c
|
||||
- src/libraries/libc/stdio/fputs.c
|
||||
- src/libraries/libc/stdio/fread.c
|
||||
- src/libraries/libc/stdio/freopen.c
|
||||
- src/libraries/libc/stdio/fscanf.c
|
||||
- src/libraries/libc/stdio/fseek.c
|
||||
- src/libraries/libc/stdio/fsetpos.c
|
||||
- src/libraries/libc/stdio/ftell.c
|
||||
- src/libraries/libc/stdio/fwrite.c
|
||||
- src/libraries/libc/stdio/getc.c
|
||||
- src/libraries/libc/stdio/getchar.c
|
||||
- src/libraries/libc/stdio/perror.c
|
||||
- src/libraries/libc/stdio/printf.c
|
||||
- src/libraries/libc/stdio/putc.c
|
||||
- src/libraries/libc/stdio/putchar.c
|
||||
- src/libraries/libc/stdio/puts.c
|
||||
- src/libraries/libc/stdio/remove.c
|
||||
- src/libraries/libc/stdio/rename.c
|
||||
- src/libraries/libc/stdio/rewind.c
|
||||
- src/libraries/libc/stdio/scanf.c
|
||||
- src/libraries/libc/stdio/setbuf.c
|
||||
- src/libraries/libc/stdio/setvbuf.c
|
||||
- src/libraries/libc/stdio/snprintf.c
|
||||
- src/libraries/libc/stdio/sprintf.c
|
||||
- src/libraries/libc/stdio/sscanf.c
|
||||
- src/libraries/libc/stdio/tmpfile.c
|
||||
- src/libraries/libc/stdio/tmpnam.c
|
||||
- src/libraries/libc/stdio/ungetc.c
|
||||
- src/libraries/libc/stdio/vfprintf.c
|
||||
- src/libraries/libc/stdio/vfscanf.c
|
||||
- src/libraries/libc/stdio/vprintf.c
|
||||
- src/libraries/libc/stdio/vscanf.c
|
||||
- src/libraries/libc/stdio/vsnprintf.c
|
||||
- src/libraries/libc/stdio/vsprintf.c
|
||||
- src/libraries/libc/stdio/vsscanf.c
|
||||
- src/libraries/libc/stdlib/abort.c
|
||||
- src/libraries/libc/stdlib/abs.c
|
||||
- src/libraries/libc/stdlib/atexit.c
|
||||
- src/libraries/libc/stdlib/atoi.c
|
||||
- src/libraries/libc/stdlib/atol.c
|
||||
- src/libraries/libc/stdlib/atoll.c
|
||||
- src/libraries/libc/stdlib/bsearch.c
|
||||
- src/libraries/libc/stdlib/div.c
|
||||
- src/libraries/libc/stdlib/exit.c
|
||||
- src/libraries/libc/stdlib/_Exit.c
|
||||
- src/libraries/libc/stdlib/getenv.c
|
||||
- src/libraries/libc/stdlib/labs.c
|
||||
- src/libraries/libc/stdlib/ldiv.c
|
||||
- src/libraries/libc/stdlib/llabs.c
|
||||
- src/libraries/libc/stdlib/lldiv.c
|
||||
- src/libraries/libc/stdlib/malloc.c
|
||||
- src/libraries/libc/stdlib/qsort.c
|
||||
- src/libraries/libc/stdlib/rand.c
|
||||
- src/libraries/libc/stdlib/srand.c
|
||||
- src/libraries/libc/stdlib/strtol.c
|
||||
- src/libraries/libc/stdlib/strtoll.c
|
||||
- src/libraries/libc/stdlib/strtoul.c
|
||||
- src/libraries/libc/stdlib/strtoull.c
|
||||
- src/libraries/libc/stdlib/system.c
|
||||
- src/libraries/libc/string/memchr.c
|
||||
- src/libraries/libc/string/memcmp.c
|
||||
- src/libraries/libc/string/memcpy.c
|
||||
- src/libraries/libc/string/memmove.c
|
||||
- src/libraries/libc/string/memset.c
|
||||
- src/libraries/libc/string/strcat.c
|
||||
- src/libraries/libc/string/strchr.c
|
||||
- src/libraries/libc/string/strcmp.c
|
||||
- src/libraries/libc/string/strcoll.c
|
||||
- src/libraries/libc/string/strcpy.c
|
||||
- src/libraries/libc/string/strcspn.c
|
||||
- src/libraries/libc/string/strerror.c
|
||||
- src/libraries/libc/string/strlen.c
|
||||
- src/libraries/libc/string/strncat.c
|
||||
- src/libraries/libc/string/strncmp.c
|
||||
- src/libraries/libc/string/strncpy.c
|
||||
- src/libraries/libc/string/strpbrk.c
|
||||
- src/libraries/libc/string/strrchr.c
|
||||
- src/libraries/libc/string/strspn.c
|
||||
- src/libraries/libc/string/strstr.c
|
||||
- src/libraries/libc/string/strtok.c
|
||||
- src/libraries/libc/string/strxfrm.c
|
||||
- src/libraries/libc/time/asctime.c
|
||||
- src/libraries/libc/time/clock.c
|
||||
- src/libraries/libc/time/ctime.c
|
||||
- src/libraries/libc/time/difftime.c
|
||||
- src/libraries/libc/time/gmtime.c
|
||||
- src/libraries/libc/time/localtime.c
|
||||
- src/libraries/libc/time/mktime.c
|
||||
- src/libraries/libc/time/strftime.c
|
||||
- src/libraries/libc/time/time.c
|
||||
- src/libraries/libc/time/timespec_get.c
|
||||
|
||||
tests:
|
||||
kind: exe
|
||||
target: native
|
||||
output: tests
|
||||
deps:
|
||||
- kutil
|
||||
source:
|
||||
- src/tests/constexpr_hash.cpp
|
||||
- src/tests/linked_list.cpp
|
||||
- src/tests/logger.cpp
|
||||
- src/tests/heap_allocator.cpp
|
||||
- src/tests/main.cpp
|
||||
- src/tests/map.cpp
|
||||
- src/tests/vector.cpp
|
||||
overlays:
|
||||
- url: https://f000.backblazeb2.com/file/jsix-os/sysroot-llvm8-20190706.tar.bz2
|
||||
path: sysroot
|
||||
- url: https://f000.backblazeb2.com/file/jsix-os/sysroot-j6libc-8cb8ce7.tar.bz2
|
||||
path: sysroot
|
||||
89
other_software.md
Normal file
89
other_software.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Included works
|
||||
|
||||
jsix includes and/or is derived from a number of other works, listed here.
|
||||
|
||||
## Catch2
|
||||
|
||||
jsix uses [Catch2][] for testing. Catch2 is released under the terms of the
|
||||
Boost Software license:
|
||||
|
||||
[Catch2]: https://github.com/catchorg/Catch2
|
||||
|
||||
> Boost Software License - Version 1.0 - August 17th, 2003
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person or organization
|
||||
> obtaining a copy of the software and accompanying documentation covered by
|
||||
> this license (the "Software") to use, reproduce, display, distribute,
|
||||
> execute, and transmit the Software, and to prepare derivative works of the
|
||||
> Software, and to permit third-parties to whom the Software is furnished to
|
||||
> do so, all subject to the following:
|
||||
>
|
||||
> The copyright notices in the Software and this entire statement, including
|
||||
> the above license grant, this restriction and the following disclaimer,
|
||||
> must be included in all copies of the Software, in whole or in part, and
|
||||
> all derivative works of the Software, unless such copies or derivative
|
||||
> works are solely in the form of machine-executable object code generated by
|
||||
> a source language processor.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
> SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
> FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
> ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
> DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## cpptoml
|
||||
|
||||
jsix uses the [cpptoml][] library for parsing TOML configuration files. cpptoml
|
||||
is released under the terms of the MIT license:
|
||||
|
||||
[cpptoml]: https://github.com/skystrife/cpptoml
|
||||
|
||||
> Copyright (c) 2014 Chase Geigle
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
> this software and associated documentation files (the "Software"), to deal in
|
||||
> the Software without restriction, including without limitation the rights to
|
||||
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
> the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
> subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## printf
|
||||
|
||||
jsix uses Marco Paland's tiny [printf][] library for its `*printf()` functions,
|
||||
which is also released under the terms of the MIT license:
|
||||
|
||||
[printf]: https://github.com/mpaland/printf
|
||||
|
||||
> The MIT License (MIT)
|
||||
>
|
||||
> Copyright (c) 2014 Marco Paland
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
82
qemu.sh
82
qemu.sh
@@ -1,22 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
build=${1:-"$(dirname $0)/build"}
|
||||
ninja -C $build
|
||||
|
||||
build="$(dirname $0)/build"
|
||||
assets="$(dirname $0)/assets"
|
||||
debug=""
|
||||
debugtarget="${build}/jsix.elf"
|
||||
flash_name="ovmf_vars"
|
||||
gfx="-nographic"
|
||||
vga="-vga none"
|
||||
kvm=""
|
||||
if [[ -f /dev/kvm ]]; then
|
||||
kvm="--enable-kvm"
|
||||
cpu="Broadwell,+pdpe1gb"
|
||||
|
||||
for arg in $@; do
|
||||
case "${arg}" in
|
||||
--debugboot)
|
||||
debug="-s -S"
|
||||
debugtarget="${build}/boot/boot.efi"
|
||||
flash_name="ovmf_vars_d"
|
||||
;;
|
||||
--debug)
|
||||
debug="-s -S"
|
||||
flash_name="ovmf_vars_d"
|
||||
;;
|
||||
--gfx)
|
||||
gfx=""
|
||||
vga=""
|
||||
;;
|
||||
--vga)
|
||||
vga=""
|
||||
;;
|
||||
--kvm)
|
||||
kvm="-enable-kvm"
|
||||
cpu="host"
|
||||
;;
|
||||
*)
|
||||
build="${arg}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! -c /dev/kvm ]]; then
|
||||
kvm=""
|
||||
fi
|
||||
|
||||
if ! ninja -C "${build}"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n $TMUX ]]; then
|
||||
if [[ -n $debug ]]; then
|
||||
tmux split-window -h "gdb ${debugtarget}" &
|
||||
else
|
||||
tmux split-window -h -l 80 "sleep 1; telnet localhost 45455" &
|
||||
tmux last-pane
|
||||
tmux split-window -l 10 "sleep 1; telnet localhost 45454" &
|
||||
fi
|
||||
elif [[ $DESKTOP_SESSION = "i3" ]]; then
|
||||
if [[ -n $debug ]]; then
|
||||
i3-msg exec i3-sensible-terminal -- -e "gdb ${PWD}/${build}/jsix.elf" &
|
||||
else
|
||||
i3-msg exec i3-sensible-terminal -- -e 'telnet localhost 45454' &
|
||||
fi
|
||||
fi
|
||||
|
||||
exec qemu-system-x86_64 \
|
||||
-drive "if=pflash,format=raw,file=${build}/flash.img" \
|
||||
-drive "format=raw,file=${build}/popcorn.img" \
|
||||
-smp 1 \
|
||||
-drive "if=pflash,format=raw,readonly,file=${assets}/ovmf/x64/ovmf_code.fd" \
|
||||
-drive "if=pflash,format=raw,file=${build}/${flash_name}.fd" \
|
||||
-drive "format=raw,file=${build}/jsix.img" \
|
||||
-device "isa-debug-exit,iobase=0xf4,iosize=0x04" \
|
||||
-monitor telnet:localhost:45454,server,nowait \
|
||||
-serial stdio \
|
||||
-serial telnet:localhost:45455,server,nowait \
|
||||
-smp 4 \
|
||||
-m 512 \
|
||||
-d mmu,int,guest_errors \
|
||||
-D popcorn.log \
|
||||
-cpu Broadwell \
|
||||
-D jsix.log \
|
||||
-cpu "${cpu}" \
|
||||
-M q35 \
|
||||
-no-reboot \
|
||||
-nographic \
|
||||
$kvm
|
||||
$gfx $vga $kvm $debug
|
||||
|
||||
75
scripts/build_symbol_table.py
Executable file
75
scripts/build_symbol_table.py
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Generate the jsix style symbol table. The format in memory of this table
|
||||
# is as follows:
|
||||
#
|
||||
# <num_entires> : 8 bytes
|
||||
# <index> : 16 * N bytes
|
||||
# <name data> : variable
|
||||
#
|
||||
# Each index entry has the format
|
||||
# <symbol address> : 8 bytes
|
||||
# <offset of name> : 8 bytes
|
||||
#
|
||||
# Name offsets are from the start of the symbol table as a whole. (ie,
|
||||
# where <num_entries> is located.)
|
||||
|
||||
def parse_syms(infile):
|
||||
"""Take the output of the `nm` command, and parse it into a tuple
|
||||
representing the symbols in the text segment of the binary. Returns
|
||||
a list of (address, symbol_name)."""
|
||||
|
||||
from cxxfilt import demangle, InvalidName
|
||||
|
||||
syms = []
|
||||
for line in sys.stdin:
|
||||
addr, t, mangled = line.split()
|
||||
if t not in "tTvVwW": continue
|
||||
|
||||
try:
|
||||
name = demangle(mangled)
|
||||
except InvalidName:
|
||||
continue
|
||||
|
||||
addr = int(addr, base=16)
|
||||
syms.append((addr, name))
|
||||
|
||||
return sorted(syms)
|
||||
|
||||
|
||||
def write_table(syms, outfile):
|
||||
"""Write the given symbol table as generated by parse_syms()
|
||||
to the outfile, index first, and then name character data."""
|
||||
|
||||
import struct
|
||||
|
||||
outfile.write(struct.pack("@Q", len(syms)))
|
||||
index_pos = outfile.tell()
|
||||
|
||||
outfile.seek(struct.calcsize("@QQ") * len(syms), 1)
|
||||
nul = b'\0'
|
||||
|
||||
positions = {}
|
||||
for s in syms:
|
||||
addr, name = s
|
||||
positions[addr] = outfile.tell()
|
||||
|
||||
data = name.encode('utf-8')
|
||||
outfile.write(name.encode('utf-8'))
|
||||
outfile.write(nul)
|
||||
|
||||
outfile.seek(index_pos)
|
||||
for s in syms:
|
||||
addr = s[0]
|
||||
pos = positions[addr]
|
||||
outfile.write(struct.pack("@QQ", addr, pos))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} <output>")
|
||||
sys.exit(1)
|
||||
|
||||
outfile = open(sys.argv[1], "wb")
|
||||
write_table(parse_syms(sys.stdin), outfile)
|
||||
131
scripts/build_sysroot.sh
Executable file
131
scripts/build_sysroot.sh
Executable file
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TARGET="x86_64-elf"
|
||||
LLVM_BRANCH="release_80"
|
||||
|
||||
TOOLS="clang lld" # lld libunwind libcxxabi libcxx"
|
||||
PROJECTS="compiler-rt libcxxabi libcxx libunwind"
|
||||
#RUNTIMES="compiler-rt libcxxabi libcxx libunwind"
|
||||
|
||||
set -e
|
||||
|
||||
README=$(realpath "$(dirname $0)/readme_for_prebuilt_sysroots.md")
|
||||
SYSROOT=$(realpath "$(dirname $0)/../sysroot")
|
||||
WORK=$(realpath "$(dirname $0)/sysroot")
|
||||
mkdir -p "${SYSROOT}"
|
||||
mkdir -p "${WORK}"
|
||||
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
|
||||
if [[ ! -d "${WORK}/llvm" ]]; then
|
||||
echo "Downloading LLVM..."
|
||||
git clone -q \
|
||||
--branch "${LLVM_BRANCH}" \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/llvm.git" "${WORK}/llvm"
|
||||
fi
|
||||
|
||||
for tool in ${TOOLS}; do
|
||||
if [[ ! -d "${WORK}/llvm/tools/${tool}" ]]; then
|
||||
echo "Downloading ${tool}..."
|
||||
git clone -q \
|
||||
--branch "${LLVM_BRANCH}" \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/${tool}.git" "${WORK}/llvm/tools/${tool}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -d "${WORK}/llvm/tools/clang/tools/extra" ]]; then
|
||||
echo "Downloading clang-tools-extra..."
|
||||
git clone -q \
|
||||
--branch "${LLVM_BRANCH}" \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/clang-tools-extra.git" "${WORK}/llvm/tools/clang/tools/extra"
|
||||
fi
|
||||
|
||||
for proj in ${PROJECTS}; do
|
||||
if [[ ! -d "${WORK}/llvm/projects/${proj}" ]]; then
|
||||
echo "Downloading ${proj}..."
|
||||
git clone -q \
|
||||
--branch "${LLVM_BRANCH}" \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/${proj}.git" "${WORK}/llvm/projects/${proj}"
|
||||
fi
|
||||
done
|
||||
|
||||
for proj in ${RUNTIMES}; do
|
||||
if [[ ! -d "${WORK}/llvm/runtimes/${proj}" ]]; then
|
||||
echo "Downloading ${proj}..."
|
||||
git clone -q \
|
||||
--branch "${LLVM_BRANCH}" \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/${proj}.git" "${WORK}/llvm/runtime/${proj}"
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p "${WORK}/build/llvm"
|
||||
pushd "${WORK}/build/llvm"
|
||||
|
||||
echo "Configuring LLVM..."
|
||||
|
||||
cmake -G Ninja \
|
||||
-DCLANG_DEFAULT_RTLIB=compiler-rt \
|
||||
-DCLANG_DEFAULT_STD_C=c11 \
|
||||
-DCLANG_DEFAULT_STD_CXX=cxx14 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER="clang" \
|
||||
-DCMAKE_CXX_COMPILER="clang++" \
|
||||
-DCMAKE_CXX_FLAGS="-Wno-unused-parameter -D_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -D_LIBUNWIND_IS_BAREMETAL=1 -U_LIBUNWIND_SUPPORT_DWARF_UNWIND" \
|
||||
-DCMAKE_INSTALL_PREFIX="${SYSROOT}" \
|
||||
-DCMAKE_MAKE_PROGRAM=`which ninja` \
|
||||
-DDEFAULT_SYSROOT="${SYSROOT}" \
|
||||
-DLIBCXX_CXX_ABI=libcxxabi \
|
||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="${WORK}/llvm/projects/libcxxabi/include" \
|
||||
-DLIBCXX_CXX_ABI_LIBRARY_PATH=lib \
|
||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
|
||||
-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
||||
-DLIBCXX_ENABLE_THREADS=OFF \
|
||||
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
|
||||
-DLIBCXX_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=OFF \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON \
|
||||
-DLIBCXXABI_ENABLE_THREADS=OFF \
|
||||
-DLIBCXXABI_LIBCXX_PATH="${WORK}/llvm/projects/libcxx" \
|
||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
|
||||
-DLIBUNWIND_ENABLE_SHARED=OFF \
|
||||
-DLIBUNWIND_ENABLE_THREADS=OFF \
|
||||
-DLIBUNWIND_USE_COMPILER_RT=ON \
|
||||
-DLLVM_CONFIG_PATH="${SYSROOT}/bin/llvm-config" \
|
||||
-DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-unknown-elf" \
|
||||
-DLLVM_ENABLE_LIBCXX=ON \
|
||||
-DLLVM_ENABLE_LLD=ON \
|
||||
-DLLVM_ENABLE_PIC=OFF \
|
||||
-DLLVM_ENABLE_THREADS=OFF \
|
||||
-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD="X86" \
|
||||
${WORK}/llvm > cmake_configure.log
|
||||
|
||||
# -DCMAKE_ASM_COMPILER=nasm \
|
||||
# -DCMAKE_LINKER="${SYSROOT}/bin/ld.lld" \
|
||||
# -DCOMPILER_RT_ENABLE_LLD=ON \
|
||||
# -DLIBCXX_ENABLE_LLD=ON \
|
||||
# -DLIBCXX_ENABLE_STATIC_UNWINDER=ON \
|
||||
# -DLIBCXXABI_ENABLE_LLD=ON \
|
||||
# -DLIBUNWIND_ENABLE_LLD=ON \
|
||||
# -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi;libunwind;compiler-rt" \
|
||||
# -DCOMPILER_RT_BAREMETAL_BUILD=ON \
|
||||
# -DLIBCXXABI_BAREMETAL=ON \
|
||||
|
||||
echo "Building LLVM..."
|
||||
ninja && ninja install
|
||||
ninja cxx cxxabi compiler-rt
|
||||
ninja install-compiler-rt install-cxx install-cxxabi
|
||||
popd
|
||||
|
||||
|
||||
cp "${README}" "${SYSROOT}/README.md"
|
||||
@@ -1,220 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TARGET="x86_64-elf"
|
||||
NASM_VERSION="2.13.03"
|
||||
BINUTILS_VERSION="2.31.1"
|
||||
|
||||
TOOLS="clang" # lld libunwind libcxxabi libcxx"
|
||||
PROJECTS="compiler-rt libcxxabi libcxx libunwind"
|
||||
#RUNTIMES="compiler-rt libcxxabi libcxx libunwind"
|
||||
|
||||
set -e
|
||||
|
||||
SYSROOT=$(realpath "$(dirname $0)/../sysroot")
|
||||
WORK=$(realpath "$(dirname $0)/sysroot")
|
||||
mkdir -p "${SYSROOT}"
|
||||
mkdir -p "${WORK}"
|
||||
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
|
||||
function build_nasm() {
|
||||
if [[ ! -d "${WORK}/nasm-${NASM_VERSION}" ]]; then
|
||||
echo "Downloading NASM..."
|
||||
tarball="nasm-${NASM_VERSION}.tar.gz"
|
||||
curl -sSOL "https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/${tarball}"
|
||||
tar xzf "${tarball}" -C "${WORK}" && rm "${tarball}"
|
||||
fi
|
||||
|
||||
mkdir -p "${WORK}/build/nasm"
|
||||
pushd "${WORK}/build/nasm"
|
||||
|
||||
if [[ ! -f "${WORK}/build/nasm/config.cache" ]]; then
|
||||
echo "Configuring NASM..."
|
||||
"${WORK}/nasm-${NASM_VERSION}/configure" \
|
||||
--quiet \
|
||||
--config-cache \
|
||||
--disable-werror \
|
||||
--prefix="${SYSROOT}" \
|
||||
--srcdir="${WORK}/nasm-${NASM_VERSION}"
|
||||
fi
|
||||
|
||||
echo "Building NASM..."
|
||||
(make -j && make install) > "${WORK}/build/nasm_build.log"
|
||||
popd
|
||||
}
|
||||
|
||||
function build_binutils() {
|
||||
if [[ ! -d "${WORK}/binutils-${BINUTILS_VERSION}" ]]; then
|
||||
echo "Downloading binutils..."
|
||||
tarball="binutils-${BINUTILS_VERSION}.tar.gz"
|
||||
curl -sSOL "https://ftp.gnu.org/gnu/binutils/${tarball}"
|
||||
tar xzf "${tarball}" -C "${WORK}" && rm "${tarball}"
|
||||
fi
|
||||
|
||||
mkdir -p "${WORK}/build/binutils"
|
||||
pushd "${WORK}/build/binutils"
|
||||
|
||||
if [[ ! -f "${WORK}/build/binutils/config.cache" ]]; then
|
||||
echo "Configuring binutils..."
|
||||
"${WORK}/binutils-${BINUTILS_VERSION}/configure" \
|
||||
--quiet \
|
||||
--config-cache \
|
||||
--target="${TARGET}" \
|
||||
--prefix="${SYSROOT}" \
|
||||
--with-sysroot="${SYSROOT}" \
|
||||
--with-lib-path="${SYSROOT}/lib" \
|
||||
--disable-nls \
|
||||
--disable-werror
|
||||
fi
|
||||
|
||||
echo "Building binutils..."
|
||||
(make -j && make install) > "${WORK}/build/binutils_build.log"
|
||||
popd
|
||||
}
|
||||
|
||||
function build_llvm() {
|
||||
if [[ ! -d "${WORK}/llvm" ]]; then
|
||||
echo "Downloading LLVM..."
|
||||
git clone -q \
|
||||
--branch release_70 \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/llvm.git" "${WORK}/llvm"
|
||||
fi
|
||||
|
||||
for tool in ${TOOLS}; do
|
||||
if [[ ! -d "${WORK}/llvm/tools/${tool}" ]]; then
|
||||
echo "Downloading ${tool}..."
|
||||
git clone -q \
|
||||
--branch release_70 \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/${tool}.git" "${WORK}/llvm/tools/${tool}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -d "${WORK}/llvm/tools/clang/tools/extra" ]]; then
|
||||
echo "Downloading clang-tools-extra..."
|
||||
git clone -q \
|
||||
--branch release_70 \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/clang-tools-extra.git" "${WORK}/llvm/tools/clang/tools/extra"
|
||||
fi
|
||||
|
||||
for proj in ${PROJECTS}; do
|
||||
if [[ ! -d "${WORK}/llvm/projects/${proj}" ]]; then
|
||||
echo "Downloading ${proj}..."
|
||||
git clone -q \
|
||||
--branch release_70 \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/${proj}.git" "${WORK}/llvm/projects/${proj}"
|
||||
fi
|
||||
done
|
||||
|
||||
for proj in ${RUNTIMES}; do
|
||||
if [[ ! -d "${WORK}/llvm/runtimes/${proj}" ]]; then
|
||||
echo "Downloading ${proj}..."
|
||||
git clone -q \
|
||||
--branch release_70 \
|
||||
--depth 1 \
|
||||
"https://git.llvm.org/git/${proj}.git" "${WORK}/llvm/runtime/${proj}"
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p "${WORK}/build/llvm"
|
||||
pushd "${WORK}/build/llvm"
|
||||
|
||||
echo "Configuring LLVM..."
|
||||
|
||||
cmake -G Ninja \
|
||||
-DCLANG_DEFAULT_RTLIB=compiler-rt \
|
||||
-DCLANG_DEFAULT_STD_C=c11 \
|
||||
-DCLANG_DEFAULT_STD_CXX=cxx14 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER="clang" \
|
||||
-DCMAKE_CXX_COMPILER="clang++" \
|
||||
-DCMAKE_CXX_FLAGS="-Wno-unused-parameter -D_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -D_LIBUNWIND_IS_BAREMETAL=1 -U_LIBUNWIND_SUPPORT_DWARF_UNWIND" \
|
||||
-DCMAKE_INSTALL_PREFIX="${SYSROOT}" \
|
||||
-DCMAKE_MAKE_PROGRAM=`which ninja` \
|
||||
-DDEFAULT_SYSROOT="${SYSROOT}" \
|
||||
-DLIBCXX_CXX_ABI=libcxxabi \
|
||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="${WORK}/llvm/projects/libcxxabi/include" \
|
||||
-DLIBCXX_CXX_ABI_LIBRARY_PATH=lib \
|
||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
|
||||
-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
||||
-DLIBCXX_ENABLE_THREADS=OFF \
|
||||
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
|
||||
-DLIBCXX_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=OFF \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON \
|
||||
-DLIBCXXABI_ENABLE_THREADS=OFF \
|
||||
-DLIBCXXABI_LIBCXX_PATH="${WORK}/llvm/projects/libcxx" \
|
||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
|
||||
-DLIBUNWIND_ENABLE_SHARED=OFF \
|
||||
-DLIBUNWIND_ENABLE_THREADS=OFF \
|
||||
-DLIBUNWIND_USE_COMPILER_RT=ON \
|
||||
-DLLVM_CONFIG_PATH="${SYSROOT}/bin/llvm-config" \
|
||||
-DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-unknown-elf" \
|
||||
-DLLVM_ENABLE_LIBCXX=ON \
|
||||
-DLLVM_ENABLE_PIC=OFF \
|
||||
-DLLVM_ENABLE_THREADS=OFF \
|
||||
-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD="X86" \
|
||||
${WORK}/llvm > cmake_configure.log
|
||||
|
||||
# -DCMAKE_ASM_COMPILER=nasm \
|
||||
# -DCMAKE_LINKER="${SYSROOT}/bin/ld.lld" \
|
||||
# -DCOMPILER_RT_ENABLE_LLD=ON \
|
||||
# -DLIBCXX_ENABLE_LLD=ON \
|
||||
# -DLIBCXX_ENABLE_STATIC_UNWINDER=ON \
|
||||
# -DLIBCXXABI_ENABLE_LLD=ON \
|
||||
# -DLIBUNWIND_ENABLE_LLD=ON \
|
||||
# -DLLVM_ENABLE_LLD=ON \
|
||||
# -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi;libunwind;compiler-rt" \
|
||||
# -DCOMPILER_RT_BAREMETAL_BUILD=ON \
|
||||
# -DLIBCXXABI_BAREMETAL=ON \
|
||||
|
||||
echo "Building LLVM..."
|
||||
ninja && ninja install
|
||||
ninja cxx cxxabi compiler-rt
|
||||
ninja install-compiler-rt install-cxx install-cxxabi
|
||||
popd
|
||||
}
|
||||
|
||||
function build_libc() {
|
||||
if [[ ! -d "${WORK}/poplibc" ]]; then
|
||||
echo "Downloading poplibc..."
|
||||
git clone \
|
||||
"https://github.com/justinian/poplibc.git" \
|
||||
"${WORK}/poplibc"
|
||||
else
|
||||
echo "Updating poplibc..."
|
||||
git -C "${WORK}/poplibc" pull
|
||||
fi
|
||||
|
||||
pushd "${WORK}/poplibc"
|
||||
echo "Building poplibc..."
|
||||
make install PREFIX="${SYSROOT}"
|
||||
popd
|
||||
}
|
||||
|
||||
function update_links() {
|
||||
for exe in `ls "${SYSROOT}/bin/${TARGET}-"*`; do
|
||||
base=$(echo "$exe" | sed -e "s/${TARGET}-//")
|
||||
ln -fs "${exe}" "${base}"
|
||||
done
|
||||
}
|
||||
|
||||
build_nasm
|
||||
build_binutils
|
||||
build_libc
|
||||
build_llvm
|
||||
update_links
|
||||
|
||||
export CC="${SYSROOT}/bin/clang"
|
||||
export CXX="${SYSROOT}/bin/clang++"
|
||||
export LD="${SYSROOT}/bin/ld.lld"
|
||||
build_libc
|
||||
@@ -1,186 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TARGET="x86_64-elf"
|
||||
NASM_VERSION="2.14.02"
|
||||
GCC_VERSION="7.4.0"
|
||||
BINUTILS_VERSION="2.31.1"
|
||||
|
||||
SYSROOT=$(realpath "$(dirname $0)/../sysroot")
|
||||
WORK=$(realpath "$(dirname $0)/sysroot")
|
||||
|
||||
echo "Not currently supported"
|
||||
exit 1
|
||||
|
||||
set -e
|
||||
mkdir -p "${SYSROOT}"
|
||||
mkdir -p "${WORK}"
|
||||
|
||||
|
||||
function build_nasm() {
|
||||
if [[ ! -d "${WORK}/nasm-${NASM_VERSION}" ]]; then
|
||||
echo "Downloading NASM..."
|
||||
tarball="nasm-${NASM_VERSION}.tar.gz"
|
||||
curl -sSOL "https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/${tarball}"
|
||||
tar xzf "${tarball}" -C "${WORK}" && rm "${tarball}"
|
||||
fi
|
||||
|
||||
mkdir -p "${WORK}/build/nasm"
|
||||
pushd "${WORK}/build/nasm"
|
||||
|
||||
if [[ ! -f "${WORK}/build/nasm/config.cache" ]]; then
|
||||
echo "Configuring NASM..."
|
||||
"${WORK}/nasm-${NASM_VERSION}/configure" \
|
||||
--quiet \
|
||||
--config-cache \
|
||||
--disable-werror \
|
||||
--prefix="${SYSROOT}" \
|
||||
--srcdir="${WORK}/nasm-${NASM_VERSION}"
|
||||
fi
|
||||
|
||||
echo "Building NASM..."
|
||||
(make -j && make install) > "${WORK}/build/nasm_build.log"
|
||||
popd
|
||||
}
|
||||
|
||||
function build_binutils() {
|
||||
if [[ ! -d "${WORK}/binutils-${BINUTILS_VERSION}" ]]; then
|
||||
echo "Downloading binutils..."
|
||||
tarball="binutils-${BINUTILS_VERSION}.tar.gz"
|
||||
curl -sSOL "https://ftp.gnu.org/gnu/binutils/${tarball}"
|
||||
tar xzf "${tarball}" -C "${WORK}" && rm "${tarball}"
|
||||
fi
|
||||
|
||||
mkdir -p "${WORK}/build/binutils"
|
||||
pushd "${WORK}/build/binutils"
|
||||
|
||||
if [[ ! -f "${WORK}/build/binutils/config.cache" ]]; then
|
||||
echo "Configuring binutils..."
|
||||
"${WORK}/binutils-${BINUTILS_VERSION}/configure" \
|
||||
--quiet \
|
||||
--config-cache \
|
||||
--target="${TARGET}" \
|
||||
--prefix="${SYSROOT}" \
|
||||
--with-sysroot="${SYSROOT}" \
|
||||
--with-lib-path="${SYSROOT}/lib" \
|
||||
--disable-nls \
|
||||
--disable-werror
|
||||
fi
|
||||
|
||||
echo "Building binutils..."
|
||||
(make -j && make install) > "${WORK}/build/binutils_build.log"
|
||||
popd
|
||||
}
|
||||
|
||||
function build_gcc() {
|
||||
if [[ ! -d "${WORK}/gcc-${GCC_VERSION}" ]]; then
|
||||
echo "Downloading GCC..."
|
||||
tarball="gcc-${GCC_VERSION}.tar.gz"
|
||||
curl -sSOL "https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/${tarball}"
|
||||
tar xzf "${tarball}" -C "${WORK}" && rm "${tarball}"
|
||||
|
||||
# no-red-zone support version of libgcc
|
||||
echo "MULTILIB_OPTIONS += mno-red-zone" > "${WORK}/gcc-${GCC_VERSION}/gcc/config/i386/t-${TARGET}"
|
||||
echo "MULTILIB_DIRNAMES += no-red-zone" >> "${WORK}/gcc-${GCC_VERSION}/gcc/config/i386/t-${TARGET}"
|
||||
|
||||
cat <<EOF >> "${WORK}/gcc-${GCC_VERSION}/gcc/config.gcc"
|
||||
case \${target} in
|
||||
${TARGET})
|
||||
tmake_file="\${tmake_file} i386/t-${TARGET}"
|
||||
;;
|
||||
esac
|
||||
EOF
|
||||
fi
|
||||
|
||||
mkdir -p "${WORK}/build/gcc"
|
||||
pushd "${WORK}/build/gcc"
|
||||
|
||||
if [[ ! -f "${WORK}/build/gcc/config.cache" ]]; then
|
||||
echo "Configuring GCC..."
|
||||
"${WORK}/gcc-${GCC_VERSION}/configure" \
|
||||
--quiet \
|
||||
--config-cache \
|
||||
--target="${TARGET}" \
|
||||
--prefix="${SYSROOT}" \
|
||||
--with-sysroot="${SYSROOT}" \
|
||||
--with-native-system-header-dir="${SYSROOT}/include" \
|
||||
--with-newlib \
|
||||
--without-headers \
|
||||
--disable-nls \
|
||||
--enable-languages=c,c++ \
|
||||
--disable-shared \
|
||||
--disable-multilib \
|
||||
--disable-decimal-float \
|
||||
--disable-threads \
|
||||
--disable-libatomic \
|
||||
--disable-libgomp \
|
||||
--disable-libmpx \
|
||||
--disable-libquadmath \
|
||||
--disable-libssp \
|
||||
--disable-libvtv \
|
||||
--disable-libstdcxx
|
||||
fi
|
||||
|
||||
echo "Building GCC..."
|
||||
(make -j all-gcc && make -j all-target-libgcc && \
|
||||
make install-gcc && make install-target-libgcc) > "${WORK}/build/gcc_build.log"
|
||||
popd
|
||||
}
|
||||
|
||||
function build_libstdcxx() {
|
||||
mkdir -p "${WORK}/build/libstdcxx"
|
||||
pushd "${WORK}/build/libstdcxx"
|
||||
|
||||
if [[ ! -f "${WORK}/build/libstdcxx/config.cache" ]]; then
|
||||
echo "Configuring libstdc++..."
|
||||
CFLAGS="-I${SYSROOT}/include" \
|
||||
CXXFLAGS="-I${SYSROOT}/include" \
|
||||
"${WORK}/gcc-${GCC_VERSION}/libstdc++-v3/configure" \
|
||||
--config-cache \
|
||||
--host="${TARGET}" \
|
||||
--target="${TARGET}" \
|
||||
--prefix="${SYSROOT}" \
|
||||
--disable-nls \
|
||||
--disable-multilib \
|
||||
--with-newlib \
|
||||
--disable-libstdcxx-threads \
|
||||
--disable-libstdcxx-pch \
|
||||
--with-gxx-include-dir="${SYSROOT}/include/c++"
|
||||
fi
|
||||
|
||||
echo "Building libstdc++..."
|
||||
(make -j && make install) > "${WORK}/build/libstdcxx_build.log"
|
||||
popd
|
||||
}
|
||||
|
||||
function build_libc() {
|
||||
if [[ ! -d "${WORK}/poplibc" ]]; then
|
||||
echo "Downloading poplibc..."
|
||||
git clone \
|
||||
"https://github.com/justinian/poplibc.git" \
|
||||
"${WORK}/poplibc"
|
||||
else
|
||||
echo "Updating poplibc..."
|
||||
git -C "${WORK}/poplibc" pull
|
||||
fi
|
||||
|
||||
pushd "${WORK}/poplibc"
|
||||
echo "Building poplibc..."
|
||||
make install PREFIX="${SYSROOT}"
|
||||
popd
|
||||
}
|
||||
|
||||
function update_links() {
|
||||
for exe in `ls "${SYSROOT}/bin/${TARGET}-"*`; do
|
||||
base=$(echo "$exe" | sed -e "s/${TARGET}-//")
|
||||
ln -fs "${exe}" "${base}"
|
||||
done
|
||||
}
|
||||
|
||||
build_nasm
|
||||
build_binutils
|
||||
build_gcc
|
||||
|
||||
update_links
|
||||
export PATH="${SYSROOT}/bin:${PATH}"
|
||||
build_libc
|
||||
build_libstdcxx
|
||||
75
scripts/fontpsf.py
Normal file
75
scripts/fontpsf.py
Normal file
@@ -0,0 +1,75 @@
|
||||
_MAGIC = (0x72, 0xb5, 0x4a, 0x86)
|
||||
_VERSION = 0
|
||||
|
||||
class PSF2:
|
||||
from collections import namedtuple
|
||||
Header = namedtuple("PSF2Header",
|
||||
["version", "offset", "flags", "count", "charsize", "height", "width"])
|
||||
|
||||
def __init__(self, filename, header, data):
|
||||
self.__filename = filename
|
||||
self.__header = header
|
||||
self.__data = data
|
||||
|
||||
data = property(lambda self: self.__data)
|
||||
header = property(lambda self: self.__header)
|
||||
count = property(lambda self: self.__header.count)
|
||||
charsize = property(lambda self: self.__header.charsize)
|
||||
dimension = property(lambda self: (self.__header.width, self.__header.height))
|
||||
filename = property(lambda self: self.__filename)
|
||||
|
||||
@classmethod
|
||||
def load(cls, filename):
|
||||
from os.path import basename
|
||||
from struct import unpack_from
|
||||
|
||||
data = open(filename, 'rb').read()
|
||||
|
||||
fmt = "BBBBIIIIIII"
|
||||
values = unpack_from(fmt, data)
|
||||
|
||||
if values[:len(_MAGIC)] != _MAGIC:
|
||||
raise Exception("Bad magic number in header")
|
||||
|
||||
header = PSF2.Header(*values[len(_MAGIC):])
|
||||
if header.version != _VERSION:
|
||||
raise Exception(f"Bad version {header.version} in header")
|
||||
|
||||
return cls(basename(filename), header, data)
|
||||
|
||||
class Glyph:
|
||||
__slots__ = ['index', 'data']
|
||||
def __init__(self, i, data):
|
||||
self.index = i
|
||||
self.data = data
|
||||
def __index__(self):
|
||||
return self.index
|
||||
def empty(self):
|
||||
return not bool([b for b in self.data if b != 0])
|
||||
def description(self):
|
||||
c = chr(self.index)
|
||||
if c.isprintable():
|
||||
return "Glyph {:02x}: '{}'".format(self.index, c)
|
||||
else:
|
||||
return "Glyph {:02x}".format(self.index)
|
||||
|
||||
def __getitem__(self, i):
|
||||
c = self.__header.charsize
|
||||
n = i * c + self.__header.offset
|
||||
return PSF2.Glyph(i, self.__data[n:n+c])
|
||||
|
||||
class __iter:
|
||||
__slots__ = ['font', 'n']
|
||||
def __init__(self, font):
|
||||
self.font = font
|
||||
self.n = 0
|
||||
def __next__(self):
|
||||
if self.n < self.font.count:
|
||||
glyph = self.font[self.n]
|
||||
self.n += 1
|
||||
return glyph
|
||||
else:
|
||||
raise StopIteration
|
||||
|
||||
def __iter__(self):
|
||||
return PSF2.__iter(self)
|
||||
34
scripts/parse_font.py
Normal file → Executable file
34
scripts/parse_font.py
Normal file → Executable file
@@ -1,21 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
MAGIC = (0x72, 0xb5, 0x4a, 0x86)
|
||||
|
||||
from collections import namedtuple
|
||||
PSF2 = namedtuple("PSF2", ["version", "offset", "flags", "count", "charsize", "height", "width"])
|
||||
|
||||
def read_header(data):
|
||||
from struct import unpack_from, calcsize
|
||||
|
||||
fmt = "BBBBIIIIIII"
|
||||
|
||||
values = unpack_from(fmt, data)
|
||||
if values[:len(MAGIC)] != MAGIC:
|
||||
raise Exception("Bad magic number in header")
|
||||
|
||||
return PSF2(*values[len(MAGIC):])
|
||||
|
||||
from fontpsf import PSF2
|
||||
|
||||
def print_glyph(header, data):
|
||||
bw = (header.width + 7) // 8
|
||||
@@ -28,16 +13,15 @@ def print_glyph(header, data):
|
||||
|
||||
|
||||
def display_font(filename):
|
||||
data = open(filename, 'rb').read()
|
||||
font = PSF2.load(filename)
|
||||
print(font.header)
|
||||
|
||||
header = read_header(data)
|
||||
print(header)
|
||||
|
||||
c = header.charsize
|
||||
for i in range(0, header.count):
|
||||
n = i * c + header.offset
|
||||
print("Glyph {}:".format(i))
|
||||
print_glyph(header, data[n:n+c])
|
||||
for glyph in font:
|
||||
if glyph.empty():
|
||||
print("{}: BLANK".format(glyph.description()))
|
||||
else:
|
||||
print("{}:".format(glyph.description()))
|
||||
print_glyph(font.header, glyph.data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
10
scripts/parse_syms.py
Executable file
10
scripts/parse_syms.py
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
def parse_elf(filename):
|
||||
import struct
|
||||
with open(filename, 'rb') as elf:
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
for arg in sys.argv[1:]:
|
||||
parse_elf(arg)
|
||||
27
scripts/psf_to_cpp.py
Executable file
27
scripts/psf_to_cpp.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from fontpsf import PSF2
|
||||
|
||||
def print_header(filename):
|
||||
font = PSF2.load(filename)
|
||||
|
||||
print("#pragma once")
|
||||
print(f"// This file was autogenerated by psf_to_cpp.py from {font.filename}\n")
|
||||
|
||||
print(f"const uint8_t font_glyph_size = {font.charsize};")
|
||||
print(f"const uint8_t font_glyph_width = {font.dimension[0]};")
|
||||
print(f"const uint8_t font_glyph_height = {font.dimension[1]};")
|
||||
print(f"const uint16_t font_glyph_count = {font.count};\n")
|
||||
|
||||
print('const uint8_t font_glyph_data[] = {')
|
||||
|
||||
for glyph in font:
|
||||
print(" ", "".join([f"0x{b:02x}," for b in glyph.data]), end="")
|
||||
print(" // {}".format(glyph.description()))
|
||||
|
||||
print("};")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
for filename in sys.argv[1:]:
|
||||
print_header(filename)
|
||||
14
scripts/readme_for_prebuilt_sysroots.md
Normal file
14
scripts/readme_for_prebuilt_sysroots.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# jsix OS sysroot
|
||||
|
||||
This is a pre-built sysroot for building the jsix operating system kernel,
|
||||
bootloader, and utilities. This package is provided as a convenience, and
|
||||
contains software from the following repositories.
|
||||
|
||||
## The LLVM toolchain
|
||||
|
||||
The LLVM sources as downloaded via git from [llvm.org][llvm] under the terms of
|
||||
the [Apache License v2.0][apache2], modified [as described here][llvmlic].
|
||||
|
||||
[llvm]: https://llvm.org
|
||||
[apache2]: https://www.apache.org/licenses/LICENSE-2.0
|
||||
[llvmlic]: https://llvm.org/docs/DeveloperPolicy.html#new-llvm-project-license-framework
|
||||
@@ -1,6 +1,11 @@
|
||||
ninja_required_version = 1.3
|
||||
builddir = {{ buildroot }}
|
||||
srcroot = {{ srcroot }}
|
||||
modulefile = {{ modulefile }}
|
||||
|
||||
{%- for var, value in vars %}
|
||||
{{ var }} = {{ value }}
|
||||
{%- endfor %}
|
||||
|
||||
warnflags = $
|
||||
-Wformat=2 $
|
||||
@@ -23,42 +28,67 @@ warnflags = $
|
||||
-Wno-unused-result $
|
||||
-Wno-deprecated-declarations $
|
||||
-Wno-unused-function $
|
||||
-Wno-address-of-packed-member $
|
||||
-Werror
|
||||
|
||||
ccflags = $
|
||||
-I${srcroot}/src/include $
|
||||
-I${srcroot}/src/include/x86_64 $
|
||||
-DVERSION_MAJOR={{ version.major }} $
|
||||
-DVERSION_MINOR={{ version.minor }} $
|
||||
-DVERSION_PATCH={{ version.patch }} $
|
||||
-DVERSION_GITSHA=0x{% if version.dirty %}1{% else %}0{% endif %}{{ version.sha }} $
|
||||
-DGIT_VERSION=\"{{ version.major }}.{{ version.minor }}.{{ version.patch }}-{{ version.sha }}\" $
|
||||
-DGIT_VERSION_WIDE=L\"{{ version.major }}.{{ version.minor }}.{{ version.patch }}-{{ version.sha }}\" $
|
||||
-fcolor-diagnostics $
|
||||
-DVERSION_MAJOR={{ version_major }} $
|
||||
-DVERSION_MINOR={{ version_minor }} $
|
||||
-DVERSION_PATCH={{ version_patch }} $
|
||||
-DVERSION_GITSHA=0x0{{ version_sha }} $
|
||||
-DGIT_VERSION=\"{{ version }}\" $
|
||||
-DGIT_VERSION_WIDE=L\"{{ version }}\" $
|
||||
$warnflags
|
||||
|
||||
asflags = $
|
||||
-DVERSION_MAJOR={{ version.major }} $
|
||||
-DVERSION_MINOR={{ version.minor }} $
|
||||
-DVERSION_PATCH={{ version.patch }} $
|
||||
-DVERSION_GITSHA=0x{% if version.dirty %}1{% else %}0{% endif %}{{ version.sha }}
|
||||
-DVERSION_MAJOR={{ version_major }} $
|
||||
-DVERSION_MINOR={{ version_minor }} $
|
||||
-DVERSION_PATCH={{ version_patch }} $
|
||||
-DVERSION_GITSHA=0x{{ version_sha }} $
|
||||
-I${srcroot}/src/include
|
||||
|
||||
cflags = -std=c11
|
||||
cxxflags = -std=c++14
|
||||
cxxflags = -std=c++17
|
||||
libs =
|
||||
|
||||
rule cc
|
||||
rule c
|
||||
deps = gcc
|
||||
depfile = $out.d
|
||||
description = Compiling $name
|
||||
command = $cc -MMD -MF $out.d $ccflags $cflags -o $out -c $in
|
||||
|
||||
rule cxx
|
||||
rule dump_c_defs
|
||||
description = Dumping C defines for $target
|
||||
command = echo "" | $cc $ccflags $cflags -dM -E - > $out
|
||||
|
||||
rule dump_c_run
|
||||
description = Dumping C arguments for $target
|
||||
command = $
|
||||
echo "#!/bin/bash" > $out; $
|
||||
echo '$cc $ccflags $cflags $$*' >> $out; $
|
||||
chmod a+x $out
|
||||
|
||||
rule cpp
|
||||
deps = gcc
|
||||
depfile = $out.d
|
||||
description = Compiling $name
|
||||
command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in
|
||||
|
||||
rule nasm
|
||||
rule dump_cpp_defs
|
||||
description = Dumping C++ defines for $target
|
||||
command = echo "" | $cxx -x c++ $cxxflags $ccflags -dM -E - > $out
|
||||
|
||||
rule dump_cpp_run
|
||||
description = Dumping C++ arguments for $target
|
||||
command = $
|
||||
echo "#!/bin/bash" > $out; $
|
||||
echo '$cc $cxxflags $ccflags $$*' >> $out; $
|
||||
chmod a+x $out
|
||||
|
||||
rule s
|
||||
deps = gcc
|
||||
depfile = $out.d
|
||||
description = Assembling $name
|
||||
@@ -75,15 +105,23 @@ rule lib
|
||||
rule regen
|
||||
generator = true
|
||||
description = Regenrating build files
|
||||
command = {{ generator }} $builddir
|
||||
command = $
|
||||
{{ generator }} $
|
||||
--file $modulefile $
|
||||
--dir $builddir $
|
||||
generate
|
||||
|
||||
rule cp
|
||||
description = Copying $name
|
||||
command = cp $in $out
|
||||
|
||||
rule makerd
|
||||
description = Making init ramdisk
|
||||
command = $builddir/native/makerd $in $out
|
||||
rule dump
|
||||
description = Dumping decompiled $name
|
||||
command = objdump -DSC -M intel $in > $out
|
||||
|
||||
rule makest
|
||||
description = Making symbol table
|
||||
command = nm $in | ${srcroot}/scripts/build_symbol_table.py $out
|
||||
|
||||
rule makeefi
|
||||
description = Converting $name
|
||||
@@ -103,7 +141,15 @@ rule makefat
|
||||
description = Creating $name
|
||||
command = $
|
||||
cp $srcroot/assets/diskbase.img $out; $
|
||||
mcopy -s -D o -i $out@@1024K $builddir/fatroot/* ::/
|
||||
mcopy -s -D o -i $out@@1M $builddir/fatroot/* ::/
|
||||
|
||||
rule strip
|
||||
description = Stripping $name
|
||||
command = $
|
||||
cp $in $out; $
|
||||
objcopy --only-keep-debug $out $out.debug; $
|
||||
strip -g $out; $
|
||||
objcopy --add-gnu-debuglink=$out.debug $out
|
||||
|
||||
{% for target in targets %}
|
||||
subninja {{ target }}/target.ninja
|
||||
@@ -117,26 +163,52 @@ build $
|
||||
{%- for template in templates %}
|
||||
{{ template }} $
|
||||
{%- endfor %}
|
||||
$modulefile $
|
||||
{{ generator }}
|
||||
|
||||
build $builddir/flash.img : cp $srcroot/assets/ovmf/x64/OVMF.fd
|
||||
name = flash.img
|
||||
build $builddir/ovmf_vars.fd : cp $srcroot/assets/ovmf/x64/ovmf_vars.fd
|
||||
name = ovmf_vars.fd
|
||||
|
||||
build $builddir/fatroot/popcorn.elf : cp $builddir/host/popcorn.elf
|
||||
build $builddir/ovmf_vars_d.fd : cp $srcroot/assets/ovmf/x64/ovmf_vars_d.fd
|
||||
name = ovmf_vars_d.fd
|
||||
|
||||
build $builddir/jsix.elf | $builddir/jsix.elf.debug : strip $builddir/host/jsix.elf
|
||||
name = kernel
|
||||
|
||||
build $builddir/jsix.dump : dump $builddir/host/jsix.elf
|
||||
name = kernel
|
||||
|
||||
build $builddir/jsix.elf-gdb.py : cp ${srcroot}/assets/debugging/jsix.elf-gdb.py
|
||||
name = kernel debug python scripts
|
||||
|
||||
build $builddir/fatroot/jsix.elf : cp $builddir/jsix.elf
|
||||
name = kernel to FAT image
|
||||
|
||||
build $builddir/fatroot/efi/boot/bootx64.efi : cp $builddir/boot/boot.efi
|
||||
name = bootloader to FAT image
|
||||
|
||||
build $builddir/fatroot/initrd.img : makerd ${srcroot}/assets/initrd.toml | $
|
||||
${builddir}/native/makerd $
|
||||
${builddir}/host/nulldrv
|
||||
build $builddir/fatroot/nulldrv.elf : cp $builddir/user/nulldrv.elf
|
||||
name = null driver to FAT image
|
||||
|
||||
build $builddir/popcorn.img : makefat | $
|
||||
$builddir/fatroot/initrd.img $
|
||||
$builddir/fatroot/popcorn.elf $
|
||||
build $builddir/fatroot/fb.elf : cp $builddir/user/fb.elf
|
||||
name = fb driver to FAT image
|
||||
|
||||
build ${builddir}/fatroot/symbol_table.dat : makest ${builddir}/jsix.elf
|
||||
|
||||
build $builddir/jsix.img : makefat | $
|
||||
$builddir/fatroot/symbol_table.dat $
|
||||
$builddir/fatroot/nulldrv.elf $
|
||||
$builddir/fatroot/fb.elf $
|
||||
$builddir/fatroot/jsix.elf $
|
||||
$builddir/fatroot/efi/boot/bootx64.efi
|
||||
name = popcorn.img
|
||||
name = jsix.img
|
||||
|
||||
# vim: et ts=4 sts=4 sw=4
|
||||
default $
|
||||
$builddir/ovmf_vars.fd $
|
||||
$builddir/ovmf_vars_d.fd $
|
||||
$builddir/jsix.dump $
|
||||
$builddir/jsix.elf-gdb.py $
|
||||
$builddir/jsix.img
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
|
||||
14
scripts/templates/exe.boot.j2
Normal file
14
scripts/templates/exe.boot.j2
Normal file
@@ -0,0 +1,14 @@
|
||||
{% extends "exe.default.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
ccflags = $ccflags $
|
||||
-g3 $
|
||||
-DKERNEL_FILENAME=L\"jsix.elf\" $
|
||||
-I${srcroot}/external/include $
|
||||
-I${srcroot}/external/include/X64
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
8
scripts/templates/exe.default.j2
Normal file
8
scripts/templates/exe.default.j2
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends "module.base.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{% extends "program.default.ninja.j2" %}
|
||||
{% extends "exe.default.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
asflags = $asflags -I${srcroot}/src/kernel/
|
||||
libs = $libs
|
||||
ldflags = $ldflags -T ${srcroot}/src/arch/x86_64/kernel.ld
|
||||
ccflags = $ccflags -I${srcroot}/external
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
10
scripts/templates/exe.makerd.j2
Normal file
10
scripts/templates/exe.makerd.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
{% extends "exe.default.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
ccflags = $ccflags -I${srcroot}/external/cpptoml
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
10
scripts/templates/exe.tests.j2
Normal file
10
scripts/templates/exe.tests.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
{% extends "exe.default.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
ccflags = $ccflags -ggdb -I${srcroot}/external/catch
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
4
scripts/templates/lib.default.j2
Normal file
4
scripts/templates/lib.default.j2
Normal file
@@ -0,0 +1,4 @@
|
||||
{% extends "module.base.j2" %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{% extends "module.base.ninja.j2" %}
|
||||
45
scripts/templates/module.base.j2
Normal file
45
scripts/templates/module.base.j2
Normal file
@@ -0,0 +1,45 @@
|
||||
moddir = ${builddir}/{{ name }}.dir
|
||||
|
||||
{% block variables %}
|
||||
ccflags = $ccflags $
|
||||
{%- for dep in depmods %}
|
||||
{%- for inc in dep.includes %}
|
||||
-I${srcroot}/{{ inc }} $
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
{%- for inc in module.includes %}
|
||||
-I${srcroot}/{{ inc }} $
|
||||
{%- endfor %}
|
||||
{%- for define in module.defines %}
|
||||
-D{{ define }} $
|
||||
{%- endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% for source in module.source %}
|
||||
build ${moddir}/{{ source.output }} : {{ source.action }} ${srcroot}/{{ source.input }} || {{ buildfile }}
|
||||
name = {{ source.name }}
|
||||
{% endfor %}
|
||||
|
||||
build ${builddir}/{{ module.output }} : {{ module.kind }} $
|
||||
{%- for source in module.source %}
|
||||
${moddir}/{{ source.output }} $
|
||||
{%- endfor -%}
|
||||
{%- for dep in deplibs %}
|
||||
${builddir}/{{ dep.output }} $
|
||||
{%- endfor %}
|
||||
| $
|
||||
{%- for dep in depexes %}
|
||||
${builddir}/{{ dep.output }} $
|
||||
{%- endfor %}
|
||||
{{ buildfile }}
|
||||
name = {{ name }}
|
||||
|
||||
{% if module.default %}
|
||||
default ${builddir}/{{ module.output }}
|
||||
{% endif %}
|
||||
|
||||
{% block extra %}
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
moddir = ${builddir}/{{ name }}.dir
|
||||
|
||||
{% block variables %}
|
||||
ccflags = $ccflags $
|
||||
{%- for dep in module.deps %}
|
||||
-I${srcroot}/src/libraries/{{ dep }}/include $
|
||||
{%- endfor %}
|
||||
-I${srcroot}/{{ module.path }} $
|
||||
-I${srcroot}/{{ module.path }}/include
|
||||
{% endblock %}
|
||||
|
||||
{% for source in sources %}
|
||||
build ${moddir}/{{ source.output }} : {{ source.action }} {{ source.input }} || {{ buildfile }}
|
||||
name = {{ source.name }}
|
||||
{% endfor %}
|
||||
|
||||
build {% block artifact %} ${builddir}/lib{{ name }}.a : lib {% endblock %} $
|
||||
{%- block extrasources %}{% endblock -%}
|
||||
{%- for source in sources %}
|
||||
${moddir}/{{ source.output }}{% if not loop.last %} ${% endif %}
|
||||
{%- endfor -%}
|
||||
{%- if module.deps %}| {% for dep in module.deps %} ${builddir}/lib{{ dep }}.a {% endfor %}{% endif %}
|
||||
name = {{ name }}
|
||||
|
||||
{% block extra %}
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
{% extends "program.default.ninja.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
ld = ld
|
||||
cc = clang
|
||||
cxx = clang++
|
||||
|
||||
ccflags = $ccflags $
|
||||
-DKERNEL_FILENAME=L\"popcorn.elf\" $
|
||||
-DGNU_EFI_USE_MS_ABI $
|
||||
-DHAVE_USE_MS_ABI $
|
||||
-DEFI_DEBUG=0 $
|
||||
-DEFI_DEBUG_CLEAR_MEMORY=0 $
|
||||
-fPIC $
|
||||
-fshort-wchar
|
||||
|
||||
ldflags = $ldflags $
|
||||
-T ${srcroot}/src/arch/x86_64/boot.ld $
|
||||
-shared
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra %}
|
||||
|
||||
build $builddir/boot.efi : makeefi ${builddir}/{{ module.output }}
|
||||
name = boot.efi
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,13 +0,0 @@
|
||||
{% extends "module.base.ninja.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
libs = $
|
||||
-L${builddir} $
|
||||
{%- for dep in module.deps %}
|
||||
-l{{dep}} $
|
||||
{%- endfor %}
|
||||
$libs
|
||||
|
||||
{% endblock %}
|
||||
{% block artifact %}${builddir}/{{ module.output }} : exe{% endblock %}
|
||||
38
scripts/templates/target.boot.j2
Normal file
38
scripts/templates/target.boot.j2
Normal file
@@ -0,0 +1,38 @@
|
||||
{% extends "target.default.j2" %}
|
||||
|
||||
{% block binaries %}
|
||||
cc = clang
|
||||
cxx = clang++
|
||||
ld = clang++
|
||||
ar = ar
|
||||
nasm = nasm
|
||||
objcopy = objcopy
|
||||
{% endblock %}
|
||||
|
||||
{% block variables %}
|
||||
|
||||
ccflags = $ccflags $
|
||||
-I $srcroot/external $
|
||||
--target=x86_64-unknown-windows $
|
||||
-ffreestanding $
|
||||
-mno-red-zone $
|
||||
-fshort-wchar $
|
||||
-fno-omit-frame-pointer $
|
||||
-ggdb
|
||||
|
||||
cxxflags = $cxxflags $
|
||||
-fno-rtti $
|
||||
-fno-exceptions
|
||||
|
||||
ldflags = $ldflags $
|
||||
--target=x86_64-unknown-windows $
|
||||
-nostdlib $
|
||||
-Wl,-entry:efi_main $
|
||||
-Wl,-subsystem:efi_application $
|
||||
-fuse-ld=lld-link $
|
||||
-g
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
{% extends "target.default.ninja.j2" %}
|
||||
|
||||
{% block binaries %}
|
||||
ld = ld
|
||||
cc = clang
|
||||
cxx = clang++
|
||||
nasm = nasm
|
||||
{% endblock %}
|
||||
|
||||
{% block variables %}
|
||||
|
||||
ccflags = $ccflags $
|
||||
-ggdb $
|
||||
-nostdlib $
|
||||
-ffreestanding $
|
||||
-nodefaultlibs $
|
||||
-fno-builtin $
|
||||
-mno-sse $
|
||||
-fno-omit-frame-pointer $
|
||||
-mno-red-zone
|
||||
|
||||
cxxflags = $cxxflags $
|
||||
-nostdlibinc $
|
||||
-isystem${srcroot}/sysroot/include/c++/v1 $
|
||||
-fno-exceptions $
|
||||
-fno-rtti
|
||||
|
||||
ldflags = $ldflags $
|
||||
-g $
|
||||
-nostdlib $
|
||||
-znocombreloc $
|
||||
-Bsymbolic $
|
||||
-nostartfiles
|
||||
|
||||
{% endblock %}
|
||||
31
scripts/templates/target.default.j2
Normal file
31
scripts/templates/target.default.j2
Normal file
@@ -0,0 +1,31 @@
|
||||
builddir = $builddir/{{ target }}
|
||||
target = {{ target }}
|
||||
|
||||
{% block variables %}
|
||||
{% endblock %}
|
||||
|
||||
{% block binaries %}
|
||||
cc = clang
|
||||
cxx = clang++
|
||||
ld = ld
|
||||
ar = ar
|
||||
nasm = nasm
|
||||
objcopy = objcopy
|
||||
{% endblock %}
|
||||
|
||||
{% for module in modules %}
|
||||
subninja {{ module }}.ninja
|
||||
{% endfor %}
|
||||
|
||||
build ${builddir}/c.defs : dump_c_defs | {{ buildfile }}
|
||||
build ${builddir}/cpp.defs : dump_cpp_defs | {{ buildfile }}
|
||||
build ${builddir}/c.run : dump_c_run | {{ buildfile }}
|
||||
build ${builddir}/cpp.run : dump_cpp_run | {{ buildfile }}
|
||||
|
||||
default ${builddir}/c.defs
|
||||
default ${builddir}/cpp.defs
|
||||
default ${builddir}/c.run
|
||||
default ${builddir}/cpp.run
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
builddir = $builddir/{{ target }}
|
||||
|
||||
{% block variables %}
|
||||
{% endblock %}
|
||||
|
||||
{% block binaries %}
|
||||
cc = clang
|
||||
cxx = clang++
|
||||
ld = clang++
|
||||
ar = ar
|
||||
nasm = nasm
|
||||
objcopy = objcopy
|
||||
{% endblock %}
|
||||
|
||||
{% for module in modules %}
|
||||
subninja {{ module }}.ninja
|
||||
{% endfor %}
|
||||
@@ -1,11 +1,12 @@
|
||||
{% extends "target.default.ninja.j2" %}
|
||||
{% extends "target.default.j2" %}
|
||||
|
||||
{% block binaries %}
|
||||
cc = ${srcroot}/sysroot/bin/clang
|
||||
cxx = ${srcroot}/sysroot/bin/clang++
|
||||
ld = ${srcroot}/sysroot/bin/x86_64-elf-ld
|
||||
ar = ${srcroot}/sysroot/bin/x86_64-elf-ar
|
||||
nasm = ${srcroot}/sysroot/bin/nasm
|
||||
objcopy = ${srcroot}/sysroot/bin/x86_64-elf-objcopy
|
||||
ld = ${srcroot}/sysroot/bin/ld.lld
|
||||
ar = ${srcroot}/sysroot/bin/ar
|
||||
nasm = nasm
|
||||
objcopy = ${srcroot}/sysroot/bin/objcopy
|
||||
{% endblock %}
|
||||
|
||||
{% block variables %}
|
||||
@@ -21,8 +22,9 @@ ccflags = $ccflags $
|
||||
-g $
|
||||
-mcmodel=large $
|
||||
-D__ELF__ $
|
||||
-D__POPCORN__ $
|
||||
-D__JSIX__ $
|
||||
-isystem${srcroot}/sysroot/include $
|
||||
-isystem${srcroot}/src/libraries/libc/include $
|
||||
--sysroot="${srcroot}/sysroot"
|
||||
|
||||
cxxflags = $cxxflags $
|
||||
@@ -33,10 +35,10 @@ cxxflags = $cxxflags $
|
||||
ldflags = $ldflags $
|
||||
-g $
|
||||
-nostdlib $
|
||||
-znocombreloc $
|
||||
-Bsymbolic $
|
||||
-nostartfiles $
|
||||
-Bstatic
|
||||
|
||||
{% endblock %}
|
||||
# vim: et ts=4 sts=4 sw=4
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
15
scripts/templates/target.native.j2
Normal file
15
scripts/templates/target.native.j2
Normal file
@@ -0,0 +1,15 @@
|
||||
{% extends "target.default.j2" %}
|
||||
|
||||
{% block binaries %}
|
||||
{{ super() }}
|
||||
ld = clang++
|
||||
{% endblock %}
|
||||
|
||||
{% block variables %}
|
||||
|
||||
ccflags = $ccflags -g -ggdb
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{% extends "target.default.ninja.j2" %}
|
||||
45
scripts/templates/target.user.j2
Normal file
45
scripts/templates/target.user.j2
Normal file
@@ -0,0 +1,45 @@
|
||||
{% extends "target.default.j2" %}
|
||||
|
||||
{% block binaries %}
|
||||
cc = ${srcroot}/sysroot/bin/clang
|
||||
cxx = ${srcroot}/sysroot/bin/clang++
|
||||
ld = ${srcroot}/sysroot/bin/ld.lld
|
||||
ar = ${srcroot}/sysroot/bin/ar
|
||||
nasm = nasm
|
||||
objcopy = ${srcroot}/sysroot/bin/objcopy
|
||||
{% endblock %}
|
||||
|
||||
{% block variables %}
|
||||
|
||||
ccflags = $ccflags $
|
||||
-nostdlib $
|
||||
-nodefaultlibs $
|
||||
-fno-builtin $
|
||||
-mno-sse $
|
||||
-fno-omit-frame-pointer $
|
||||
-mno-red-zone $
|
||||
-g $
|
||||
-mcmodel=large $
|
||||
-D__ELF__ $
|
||||
-D__JSIX__ $
|
||||
-isystem${srcroot}/sysroot/include $
|
||||
-isystem${srcroot}/src/libraries/libc/include $
|
||||
--sysroot="${srcroot}/sysroot"
|
||||
|
||||
cxxflags = $cxxflags $
|
||||
-fno-exceptions $
|
||||
-fno-rtti $
|
||||
-isystem${srcroot}/sysroot/include/c++/v1
|
||||
|
||||
ldflags = $ldflags $
|
||||
-g $
|
||||
-nostdlib $
|
||||
-Bsymbolic $
|
||||
-Bstatic $
|
||||
--sysroot="${srcroot}/sysroot" $
|
||||
-L "${srcroot}/sysroot/lib" $
|
||||
|
||||
{% endblock %}
|
||||
|
||||
# vim: ft=ninja et ts=4 sts=4 sw=4
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/* Linker script originally from GNU-EFI project
|
||||
* https://sourceforge.net/p/gnu-efi/
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
ImageBase = .;
|
||||
/* .hash and/or .gnu.hash MUST come first! */
|
||||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
. = ALIGN(4096);
|
||||
.eh_frame :
|
||||
{
|
||||
*(.eh_frame)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.text :
|
||||
{
|
||||
_text = .;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
. = ALIGN(16);
|
||||
}
|
||||
_etext = .;
|
||||
_text_size = . - _text;
|
||||
. = ALIGN(4096);
|
||||
.reloc :
|
||||
{
|
||||
*(.reloc)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.data :
|
||||
{
|
||||
_data = .;
|
||||
*(.rodata*)
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.data*)
|
||||
*(.sdata)
|
||||
/* the EFI loader doesn't seem to like a .bss section, so we stick
|
||||
it all into .data: */
|
||||
*(.sbss)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
*(.rel.local)
|
||||
}
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
|
||||
_edata = .;
|
||||
_data_size = . - _etext;
|
||||
. = ALIGN(4096);
|
||||
.dynamic : { *(.dynamic) }
|
||||
. = ALIGN(4096);
|
||||
.rela :
|
||||
{
|
||||
*(.rela.data*)
|
||||
*(.rela.got)
|
||||
*(.rela.stab)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
.dynsym : { *(.dynsym) }
|
||||
. = ALIGN(4096);
|
||||
.dynstr : { *(.dynstr) }
|
||||
. = ALIGN(4096);
|
||||
.ignored.reloc :
|
||||
{
|
||||
*(.rela.reloc)
|
||||
*(.eh_frame)
|
||||
*(.note.GNU-stack)
|
||||
}
|
||||
.comment 0 : { *(.comment) }
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
ENTRY(_start)
|
||||
ENTRY(_kernel_start)
|
||||
SECTIONS
|
||||
{
|
||||
OFFSET = 0xFFFFFF0000000000;
|
||||
. = OFFSET + 0x100000;
|
||||
. = 0xFFFF800000000000;
|
||||
|
||||
.header : {
|
||||
__header_start = .;
|
||||
@@ -10,29 +9,32 @@ SECTIONS
|
||||
__header_end = .;
|
||||
}
|
||||
|
||||
.text : {
|
||||
.text ALIGN(4096) : {
|
||||
*(.text)
|
||||
*(.isrs)
|
||||
}
|
||||
|
||||
.data : {
|
||||
.data ALIGN(4096) : {
|
||||
*(.data)
|
||||
*(.rodata)
|
||||
}
|
||||
|
||||
.isrs : {
|
||||
*(.isrs)
|
||||
.ctors : ALIGN(8) {
|
||||
__ctors = .;
|
||||
KEEP(*(.ctors))
|
||||
__ctors_end = .;
|
||||
}
|
||||
|
||||
.bss ALIGN(4096) : {
|
||||
__bss_start = .;
|
||||
*(.bss)
|
||||
__bss_end = .;
|
||||
}
|
||||
|
||||
.note : {
|
||||
*(.note.*)
|
||||
}
|
||||
|
||||
.bss ALIGN(16) : {
|
||||
__bss_start = .;
|
||||
*(.bss)
|
||||
__bss_end = .;
|
||||
}
|
||||
|
||||
.eh_frame : {
|
||||
__eh_frame_start = .;
|
||||
KEEP(*(.eh_frame))
|
||||
|
||||
@@ -1,307 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "guids.h"
|
||||
#include "utility.h"
|
||||
|
||||
size_t ROWS = 0;
|
||||
size_t COLS = 0;
|
||||
|
||||
static EFI_SIMPLE_TEXT_OUT_PROTOCOL *con_out = 0;
|
||||
|
||||
const CHAR16 digits[] = {u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'a', u'b', u'c', u'd', u'e', u'f'};
|
||||
|
||||
EFI_STATUS
|
||||
con_pick_mode(EFI_BOOT_SERVICES *bootsvc)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *gfx_out_proto;
|
||||
status = bootsvc->LocateProtocol(&guid_gfx_out, NULL, (void **)&gfx_out_proto);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "LocateProtocol gfx");
|
||||
|
||||
const uint32_t modes = gfx_out_proto->Mode->MaxMode;
|
||||
uint32_t best = gfx_out_proto->Mode->Mode;
|
||||
|
||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info =
|
||||
(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)gfx_out_proto->Mode;
|
||||
|
||||
uint32_t res = info->HorizontalResolution * info->VerticalResolution;
|
||||
int is_fb = info->PixelFormat != PixelBltOnly;
|
||||
|
||||
for (uint32_t i = 0; i < modes; ++i) {
|
||||
size_t size = 0;
|
||||
status = gfx_out_proto->QueryMode(gfx_out_proto, i, &size, &info);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "QueryMode");
|
||||
|
||||
#ifdef MAX_HRES
|
||||
if (info->HorizontalResolution > MAX_HRES) continue;
|
||||
#endif
|
||||
|
||||
const uint32_t new_res = info->HorizontalResolution * info->VerticalResolution;
|
||||
const int new_is_fb = info->PixelFormat == PixelBltOnly;
|
||||
|
||||
if (new_is_fb > is_fb && new_res >= res) {
|
||||
best = i;
|
||||
res = new_res;
|
||||
}
|
||||
}
|
||||
|
||||
status = gfx_out_proto->SetMode(gfx_out_proto, best);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "SetMode %d/%d", best, modes);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
con_initialize(EFI_SYSTEM_TABLE *system_table, const CHAR16 *version)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
|
||||
EFI_BOOT_SERVICES *bootsvc = system_table->BootServices;
|
||||
con_out = system_table->ConOut;
|
||||
|
||||
// Might not find a video device at all, so ignore not found errors
|
||||
status = con_pick_mode(bootsvc);
|
||||
if (status != EFI_NOT_FOUND)
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "con_pick_mode");
|
||||
|
||||
status = con_out->QueryMode(con_out, con_out->Mode->Mode, &COLS, &ROWS);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "QueryMode");
|
||||
|
||||
status = con_out->ClearScreen(con_out);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "ClearScreen");
|
||||
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTCYAN);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"Popcorn loader ");
|
||||
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTMAGENTA);
|
||||
con_out->OutputString(con_out, (CHAR16 *)version);
|
||||
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L" booting...\r\n\n");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
size_t
|
||||
con_print_hex(uint32_t n)
|
||||
{
|
||||
CHAR16 buffer[9];
|
||||
CHAR16 *p = buffer;
|
||||
for (int i = 7; i >= 0; --i) {
|
||||
uint8_t nibble = (n & (0xf << (i*4))) >> (i*4);
|
||||
*p++ = digits[nibble];
|
||||
}
|
||||
*p = 0;
|
||||
con_out->OutputString(con_out, buffer);
|
||||
return 8;
|
||||
}
|
||||
|
||||
size_t
|
||||
con_print_long_hex(uint64_t n)
|
||||
{
|
||||
CHAR16 buffer[17];
|
||||
CHAR16 *p = buffer;
|
||||
for (int i = 15; i >= 0; --i) {
|
||||
uint8_t nibble = (n & (0xf << (i*4))) >> (i*4);
|
||||
*p++ = digits[nibble];
|
||||
}
|
||||
*p = 0;
|
||||
con_out->OutputString(con_out, buffer);
|
||||
return 16;
|
||||
}
|
||||
|
||||
size_t
|
||||
con_print_dec(uint32_t n)
|
||||
{
|
||||
CHAR16 buffer[11];
|
||||
CHAR16 *p = buffer + 10;
|
||||
*p-- = 0;
|
||||
do {
|
||||
*p-- = digits[n % 10];
|
||||
n /= 10;
|
||||
} while (n != 0);
|
||||
|
||||
con_out->OutputString(con_out, ++p);
|
||||
return 10 - (p - buffer);
|
||||
}
|
||||
|
||||
size_t
|
||||
con_print_long_dec(uint64_t n)
|
||||
{
|
||||
CHAR16 buffer[21];
|
||||
CHAR16 *p = buffer + 20;
|
||||
*p-- = 0;
|
||||
do {
|
||||
*p-- = digits[n % 10];
|
||||
n /= 10;
|
||||
} while (n != 0);
|
||||
|
||||
con_out->OutputString(con_out, ++p);
|
||||
return 20 - (p - buffer);
|
||||
}
|
||||
|
||||
size_t
|
||||
con_printf(const CHAR16 *fmt, ...)
|
||||
{
|
||||
CHAR16 buffer[256];
|
||||
const CHAR16 *r = fmt;
|
||||
CHAR16 *w = buffer;
|
||||
va_list args;
|
||||
size_t count = 0;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
while (r && *r) {
|
||||
if (*r != L'%') {
|
||||
count++;
|
||||
*w++ = *r++;
|
||||
continue;
|
||||
}
|
||||
|
||||
*w = 0;
|
||||
con_out->OutputString(con_out, buffer);
|
||||
w = buffer;
|
||||
|
||||
r++; // chomp the %
|
||||
|
||||
switch (*r++) {
|
||||
case L'%':
|
||||
con_out->OutputString(con_out, L"%");
|
||||
count++;
|
||||
break;
|
||||
|
||||
case L'x':
|
||||
count += con_print_hex(va_arg(args, uint32_t));
|
||||
break;
|
||||
|
||||
case L'd':
|
||||
case L'u':
|
||||
count += con_print_dec(va_arg(args, uint32_t));
|
||||
break;
|
||||
|
||||
case L's':
|
||||
{
|
||||
CHAR16 *s = va_arg(args, CHAR16*);
|
||||
count += wstrlen(s);
|
||||
con_out->OutputString(con_out, s);
|
||||
}
|
||||
break;
|
||||
|
||||
case L'l':
|
||||
switch (*r++) {
|
||||
case L'x':
|
||||
count += con_print_long_hex(va_arg(args, uint64_t));
|
||||
break;
|
||||
|
||||
case L'd':
|
||||
case L'u':
|
||||
count += con_print_long_dec(va_arg(args, uint64_t));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*w = 0;
|
||||
con_out->OutputString(con_out, buffer);
|
||||
|
||||
va_end(args);
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
con_status_begin(const CHAR16 *message)
|
||||
{
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)message);
|
||||
}
|
||||
|
||||
void
|
||||
con_status_ok()
|
||||
{
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"[");
|
||||
con_out->SetAttribute(con_out, EFI_GREEN);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L" ok ");
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"]\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
con_status_fail(const CHAR16 *error)
|
||||
{
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"[");
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTRED);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"failed");
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"]\r\n");
|
||||
|
||||
con_out->SetAttribute(con_out, EFI_RED);
|
||||
con_out->OutputString(con_out, (CHAR16 *)error);
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"\r\n");
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
con_get_framebuffer(
|
||||
EFI_BOOT_SERVICES *bootsvc,
|
||||
void **buffer,
|
||||
size_t *buffer_size,
|
||||
uint32_t *hres,
|
||||
uint32_t *vres,
|
||||
uint32_t *rmask,
|
||||
uint32_t *gmask,
|
||||
uint32_t *bmask)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
|
||||
status = bootsvc->LocateProtocol(&guid_gfx_out, NULL, (void **)&gop);
|
||||
if (status != EFI_NOT_FOUND) {
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "LocateProtocol gfx");
|
||||
|
||||
*buffer = (void *)gop->Mode->FrameBufferBase;
|
||||
*buffer_size = gop->Mode->FrameBufferSize;
|
||||
*hres = gop->Mode->Info->HorizontalResolution;
|
||||
*vres = gop->Mode->Info->VerticalResolution;
|
||||
|
||||
switch (gop->Mode->Info->PixelFormat) {
|
||||
case PixelRedGreenBlueReserved8BitPerColor:
|
||||
*rmask = 0x0000ff;
|
||||
*gmask = 0x00ff00;
|
||||
*bmask = 0xff0000;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
case PixelBlueGreenRedReserved8BitPerColor:
|
||||
*bmask = 0x0000ff;
|
||||
*gmask = 0x00ff00;
|
||||
*rmask = 0xff0000;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
case PixelBitMask:
|
||||
*rmask = gop->Mode->Info->PixelInformation.RedMask;
|
||||
*gmask = gop->Mode->Info->PixelInformation.GreenMask;
|
||||
*bmask = gop->Mode->Info->PixelInformation.BlueMask;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
default:
|
||||
// Not a framebuffer, fall through to zeroing out
|
||||
// values below.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*buffer = NULL;
|
||||
*buffer_size = *hres = *vres = 0;
|
||||
*rmask = *gmask = *bmask = 0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
304
src/boot/console.cpp
Normal file
304
src/boot/console.cpp
Normal file
@@ -0,0 +1,304 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/graphics.h>
|
||||
#include <uefi/protos/graphics_output.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifndef GIT_VERSION_WIDE
|
||||
#define GIT_VERSION_WIDE L"no version"
|
||||
#endif
|
||||
|
||||
namespace boot {
|
||||
|
||||
size_t ROWS = 0;
|
||||
size_t COLS = 0;
|
||||
|
||||
console *console::s_console = nullptr;
|
||||
|
||||
static const wchar_t digits[] = {u'0', u'1', u'2', u'3', u'4', u'5',
|
||||
u'6', u'7', u'8', u'9', u'a', u'b', u'c', u'd', u'e', u'f'};
|
||||
|
||||
|
||||
static size_t
|
||||
wstrlen(const wchar_t *s)
|
||||
{
|
||||
size_t count = 0;
|
||||
while (s && *s++) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
console::console(uefi::boot_services *bs, uefi::protos::simple_text_output *out) :
|
||||
m_rows {0},
|
||||
m_cols {0},
|
||||
m_out {out},
|
||||
m_fb {0, 0}
|
||||
{
|
||||
pick_mode(bs);
|
||||
|
||||
try_or_raise(
|
||||
m_out->query_mode(m_out->mode->mode, &m_cols, &m_rows),
|
||||
L"Failed to get text output mode.");
|
||||
|
||||
try_or_raise(
|
||||
m_out->clear_screen(),
|
||||
L"Failed to clear screen");
|
||||
|
||||
m_out->set_attribute(uefi::attribute::light_cyan);
|
||||
m_out->output_string(L"jsix loader ");
|
||||
|
||||
m_out->set_attribute(uefi::attribute::light_magenta);
|
||||
m_out->output_string(GIT_VERSION_WIDE);
|
||||
|
||||
m_out->set_attribute(uefi::attribute::light_gray);
|
||||
m_out->output_string(L" booting...\r\n\n");
|
||||
|
||||
if (m_fb.type != kernel::args::fb_type::none) {
|
||||
wchar_t const * type = nullptr;
|
||||
switch (m_fb.type) {
|
||||
case kernel::args::fb_type::rgb8:
|
||||
type = L"rgb8";
|
||||
break;
|
||||
case kernel::args::fb_type::bgr8:
|
||||
type = L"bgr8";
|
||||
break;
|
||||
default:
|
||||
type = L"unknown";
|
||||
}
|
||||
|
||||
printf(L"Found framebuffer: %dx%d[%d] type %s @0x%x\r\n",
|
||||
m_fb.horizontal, m_fb.vertical, m_fb.scanline, type, m_fb.phys_addr);
|
||||
} else {
|
||||
printf(L"No framebuffer found.\r\n");
|
||||
}
|
||||
|
||||
s_console = this;
|
||||
}
|
||||
|
||||
void
|
||||
console::pick_mode(uefi::boot_services *bs)
|
||||
{
|
||||
uefi::status status;
|
||||
uefi::protos::graphics_output *gfx_out_proto;
|
||||
uefi::guid guid = uefi::protos::graphics_output::guid;
|
||||
|
||||
m_fb.type = kernel::args::fb_type::none;
|
||||
|
||||
uefi::status has_gop = bs->locate_protocol(&guid, nullptr,
|
||||
(void **)&gfx_out_proto);
|
||||
|
||||
if (has_gop != uefi::status::success)
|
||||
// No video output found, skip it
|
||||
return;
|
||||
|
||||
const uint32_t modes = gfx_out_proto->mode->max_mode;
|
||||
uint32_t best = gfx_out_proto->mode->mode;
|
||||
|
||||
uefi::graphics_output_mode_info *info =
|
||||
(uefi::graphics_output_mode_info *)gfx_out_proto->mode;
|
||||
|
||||
uint32_t res = info->horizontal_resolution * info->vertical_resolution;
|
||||
int pixmode = static_cast<int>(info->pixel_format);
|
||||
|
||||
for (uint32_t i = 0; i < modes; ++i) {
|
||||
size_t size = 0;
|
||||
|
||||
try_or_raise(
|
||||
gfx_out_proto->query_mode(i, &size, &info),
|
||||
L"Failed to find a graphics mode the driver claimed to support");
|
||||
|
||||
#ifdef MAX_HRES
|
||||
if (info->horizontal_resolution > MAX_HRES) continue;
|
||||
#endif
|
||||
|
||||
const uint32_t new_res = info->horizontal_resolution * info->vertical_resolution;
|
||||
int new_pixmode = static_cast<int>(info->pixel_format);
|
||||
|
||||
if (new_pixmode <= pixmode && new_res >= res) {
|
||||
best = i;
|
||||
res = new_res;
|
||||
pixmode = new_pixmode;
|
||||
}
|
||||
}
|
||||
|
||||
try_or_raise(
|
||||
gfx_out_proto->set_mode(best),
|
||||
L"Failed to set graphics mode");
|
||||
|
||||
if (pixmode <= static_cast<int>(uefi::pixel_format::bgr8)) {
|
||||
m_fb.phys_addr = gfx_out_proto->mode->frame_buffer_base;
|
||||
m_fb.size = gfx_out_proto->mode->frame_buffer_size;
|
||||
m_fb.vertical = gfx_out_proto->mode->info->vertical_resolution;
|
||||
m_fb.horizontal = gfx_out_proto->mode->info->horizontal_resolution;
|
||||
m_fb.scanline = gfx_out_proto->mode->info->pixels_per_scanline;
|
||||
|
||||
switch (gfx_out_proto->mode->info->pixel_format) {
|
||||
case uefi::pixel_format::rgb8:
|
||||
m_fb.type = kernel::args::fb_type::rgb8;
|
||||
break;
|
||||
case uefi::pixel_format::bgr8:
|
||||
m_fb.type = kernel::args::fb_type::bgr8;
|
||||
break;
|
||||
default:
|
||||
m_fb.type = kernel::args::fb_type::none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
console::print_hex(uint32_t n) const
|
||||
{
|
||||
wchar_t buffer[9];
|
||||
wchar_t *p = buffer;
|
||||
for (int i = 7; i >= 0; --i) {
|
||||
uint8_t nibble = (n >> (i*4)) & 0xf;
|
||||
*p++ = digits[nibble];
|
||||
}
|
||||
*p = 0;
|
||||
m_out->output_string(buffer);
|
||||
return 8;
|
||||
}
|
||||
|
||||
size_t
|
||||
console::print_long_hex(uint64_t n) const
|
||||
{
|
||||
wchar_t buffer[17];
|
||||
wchar_t *p = buffer;
|
||||
for (int i = 15; i >= 0; --i) {
|
||||
uint8_t nibble = (n >> (i*4)) & 0xf;
|
||||
*p++ = digits[nibble];
|
||||
}
|
||||
*p = 0;
|
||||
m_out->output_string(buffer);
|
||||
return 16;
|
||||
}
|
||||
|
||||
size_t
|
||||
console::print_dec(uint32_t n) const
|
||||
{
|
||||
wchar_t buffer[11];
|
||||
wchar_t *p = buffer + 10;
|
||||
*p-- = 0;
|
||||
do {
|
||||
*p-- = digits[n % 10];
|
||||
n /= 10;
|
||||
} while (n != 0);
|
||||
|
||||
m_out->output_string(++p);
|
||||
return 10 - (p - buffer);
|
||||
}
|
||||
|
||||
size_t
|
||||
console::print_long_dec(uint64_t n) const
|
||||
{
|
||||
wchar_t buffer[21];
|
||||
wchar_t *p = buffer + 20;
|
||||
*p-- = 0;
|
||||
do {
|
||||
*p-- = digits[n % 10];
|
||||
n /= 10;
|
||||
} while (n != 0);
|
||||
|
||||
m_out->output_string(++p);
|
||||
return 20 - (p - buffer);
|
||||
}
|
||||
|
||||
size_t
|
||||
console::vprintf(const wchar_t *fmt, va_list args) const
|
||||
{
|
||||
wchar_t buffer[256];
|
||||
const wchar_t *r = fmt;
|
||||
wchar_t *w = buffer;
|
||||
size_t count = 0;
|
||||
|
||||
while (r && *r) {
|
||||
if (*r != L'%') {
|
||||
count++;
|
||||
*w++ = *r++;
|
||||
continue;
|
||||
}
|
||||
|
||||
*w = 0;
|
||||
m_out->output_string(buffer);
|
||||
w = buffer;
|
||||
|
||||
r++; // chomp the %
|
||||
|
||||
switch (*r++) {
|
||||
case L'%':
|
||||
m_out->output_string(const_cast<wchar_t*>(L"%"));
|
||||
count++;
|
||||
break;
|
||||
|
||||
case L'x':
|
||||
count += print_hex(va_arg(args, uint32_t));
|
||||
break;
|
||||
|
||||
case L'd':
|
||||
case L'u':
|
||||
count += print_dec(va_arg(args, uint32_t));
|
||||
break;
|
||||
|
||||
case L's':
|
||||
{
|
||||
wchar_t *s = va_arg(args, wchar_t*);
|
||||
count += wstrlen(s);
|
||||
m_out->output_string(s);
|
||||
}
|
||||
break;
|
||||
|
||||
case L'l':
|
||||
switch (*r++) {
|
||||
case L'x':
|
||||
count += print_long_hex(va_arg(args, uint64_t));
|
||||
break;
|
||||
|
||||
case L'd':
|
||||
case L'u':
|
||||
count += print_long_dec(va_arg(args, uint64_t));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*w = 0;
|
||||
m_out->output_string(buffer);
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t
|
||||
console::printf(const wchar_t *fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
size_t result = vprintf(fmt, args);
|
||||
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t
|
||||
console::print(const wchar_t *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
size_t result = get().vprintf(fmt, args);
|
||||
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace boot
|
||||
@@ -1,20 +1,45 @@
|
||||
/// \file console.h
|
||||
/// Text output handler
|
||||
#pragma once
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <efi/efi.h>
|
||||
#include <uefi/boot_services.h>
|
||||
#include <uefi/protos/simple_text_output.h>
|
||||
#include "kernel_args.h"
|
||||
#include "types.h"
|
||||
|
||||
EFI_STATUS con_initialize(EFI_SYSTEM_TABLE *system_table, const CHAR16 *version);
|
||||
void con_status_begin(const CHAR16 *message);
|
||||
void con_status_ok();
|
||||
void con_status_fail(const CHAR16 *error);
|
||||
size_t con_printf(const CHAR16 *fmt, ...);
|
||||
namespace boot {
|
||||
|
||||
EFI_STATUS
|
||||
con_get_framebuffer(
|
||||
EFI_BOOT_SERVICES *bootsvc,
|
||||
void **buffer,
|
||||
size_t *buffer_size,
|
||||
uint32_t *hres,
|
||||
uint32_t *vres,
|
||||
uint32_t *rmask,
|
||||
uint32_t *gmask,
|
||||
uint32_t *bmask);
|
||||
/// Object providing basic output functionality to the UEFI console
|
||||
class console
|
||||
{
|
||||
public:
|
||||
using framebuffer = kernel::args::framebuffer;
|
||||
|
||||
console(uefi::boot_services *bs, uefi::protos::simple_text_output *out);
|
||||
|
||||
size_t print_hex(uint32_t n) const;
|
||||
size_t print_dec(uint32_t n) const;
|
||||
size_t print_long_hex(uint64_t n) const;
|
||||
size_t print_long_dec(uint64_t n) const;
|
||||
size_t printf(const wchar_t *fmt, ...) const;
|
||||
|
||||
const framebuffer & fb() const { return m_fb; };
|
||||
|
||||
static console & get() { return *s_console; }
|
||||
static size_t print(const wchar_t *fmt, ...);
|
||||
|
||||
private:
|
||||
friend class status_line;
|
||||
|
||||
void pick_mode(uefi::boot_services *bs);
|
||||
size_t vprintf(const wchar_t *fmt, va_list args) const;
|
||||
|
||||
size_t m_rows, m_cols;
|
||||
uefi::protos::simple_text_output *m_out;
|
||||
framebuffer m_fb;
|
||||
|
||||
static console *s_console;
|
||||
};
|
||||
|
||||
} // namespace boot
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
; crt0-efi-x86_64.S - x86_64 EFI startup code.
|
||||
; Copyright (C) 1999 Hewlett-Packard Co.
|
||||
; Contributed by David Mosberger <davidm@hpl.hp.com>.
|
||||
; Copyright (C) 2005 Intel Co.
|
||||
; Contributed by Fenghua Yu <fenghua.yu@intel.com>.
|
||||
;
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions
|
||||
; are met:
|
||||
;
|
||||
; * Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; * Redistributions in binary form must reproduce the above
|
||||
; copyright notice, this list of conditions and the following
|
||||
; disclaimer in the documentation and/or other materials
|
||||
; provided with the distribution.
|
||||
; * Neither the name of Hewlett-Packard Co. nor the names of its
|
||||
; contributors may be used to endorse or promote products derived
|
||||
; from this software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
; BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
; OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
; TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
; THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
; SUCH DAMAGE.
|
||||
;
|
||||
; 2018-05-05 Converted to NASM syntax by Justin C. Miller
|
||||
|
||||
extern ImageBase
|
||||
extern _DYNAMIC
|
||||
extern _relocate
|
||||
extern efi_main
|
||||
|
||||
section .text
|
||||
align 4
|
||||
|
||||
global _start
|
||||
_start:
|
||||
sub rsp, 8
|
||||
push rcx
|
||||
push rdx
|
||||
|
||||
; These are already in RDI/RSI from EFI calling us, right? -justin
|
||||
;lea rdi, [ImageBase]
|
||||
;lea rsi, [_DYNAMIC]
|
||||
|
||||
pop rcx
|
||||
pop rdx
|
||||
push rcx
|
||||
push rdx
|
||||
call _relocate
|
||||
|
||||
pop rdi
|
||||
pop rsi
|
||||
|
||||
call efi_main
|
||||
add rsp, 8
|
||||
|
||||
.exit:
|
||||
ret
|
||||
|
||||
; hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
|
||||
section .data
|
||||
dummy:
|
||||
dd 0
|
||||
|
||||
|
||||
%define IMAGE_REL_ABSOLUTE 0
|
||||
|
||||
section .reloc
|
||||
label1:
|
||||
dd 0 ; Page RVA
|
||||
dd 10 ; Block Size (2*4+2)
|
||||
dw (IMAGE_REL_ABSOLUTE<<12) + 0 ; reloc for dummy
|
||||
|
||||
@@ -1,46 +1,32 @@
|
||||
/// \file elf.h
|
||||
/// Definitions and related constants for ELF64 structures
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef ELF_VERSION
|
||||
#define ELF_VERSION 1
|
||||
#endif
|
||||
namespace boot {
|
||||
namespace elf {
|
||||
|
||||
#ifndef ELF_WORDSIZE
|
||||
#define ELF_WORDSIZE 2
|
||||
#endif
|
||||
constexpr uint8_t version = 1;
|
||||
constexpr uint8_t word_size = 2;
|
||||
constexpr uint8_t endianness = 1;
|
||||
constexpr uint8_t os_abi = 0;
|
||||
constexpr uint16_t machine = 0x3e;
|
||||
|
||||
#ifndef ELF_ENDIAN
|
||||
#define ELF_ENDIAN 1
|
||||
#endif
|
||||
const unsigned PT_LOAD = 1;
|
||||
const unsigned ST_PROGBITS = 1;
|
||||
const unsigned ST_NOBITS = 8;
|
||||
const unsigned long SHF_ALLOC = 0x2;
|
||||
|
||||
#ifndef ELF_OSABI
|
||||
#define ELF_OSABI 0
|
||||
#endif
|
||||
|
||||
#ifndef ELF_MACHINE
|
||||
#define ELF_MACHINE 0x3e
|
||||
#endif
|
||||
|
||||
const unsigned ELF_PT_LOAD = 1;
|
||||
const unsigned ELF_ST_PROGBITS = 1;
|
||||
const unsigned ELF_ST_NOBITS = 8;
|
||||
const unsigned long ELF_SHF_ALLOC = 0x2;
|
||||
|
||||
struct elf_ident
|
||||
struct header
|
||||
{
|
||||
char magic[4];
|
||||
|
||||
uint8_t word_size;
|
||||
uint8_t endianness;
|
||||
uint8_t version;
|
||||
uint8_t header_version;
|
||||
uint8_t os_abi;
|
||||
|
||||
uint64_t reserved;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct elf_header
|
||||
{
|
||||
struct elf_ident ident;
|
||||
|
||||
uint16_t type;
|
||||
uint16_t machine;
|
||||
@@ -64,7 +50,7 @@ struct elf_header
|
||||
uint16_t sh_str_idx;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct elf_program_header
|
||||
struct program_header
|
||||
{
|
||||
uint32_t type;
|
||||
uint32_t flags;
|
||||
@@ -79,7 +65,7 @@ struct elf_program_header
|
||||
uint64_t align;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct elf_section_header
|
||||
struct section_header
|
||||
{
|
||||
uint32_t name;
|
||||
uint32_t type;
|
||||
@@ -92,3 +78,6 @@ struct elf_section_header
|
||||
uint64_t align;
|
||||
uint64_t entry_size;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
} // namespace elf
|
||||
} // namespace boot
|
||||
|
||||
69
src/boot/error.cpp
Normal file
69
src/boot/error.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "error.h"
|
||||
#include "console.h"
|
||||
#include "kernel_args.h"
|
||||
#include "status.h"
|
||||
|
||||
namespace boot {
|
||||
namespace error {
|
||||
|
||||
struct error_code_desc {
|
||||
uefi::status code;
|
||||
const wchar_t *name;
|
||||
};
|
||||
|
||||
struct error_code_desc error_table[] = {
|
||||
#define STATUS_ERROR(name, num) { uefi::status::name, L#name },
|
||||
#define STATUS_WARNING(name, num) { uefi::status::name, L#name },
|
||||
#include "uefi/errors.inc"
|
||||
#undef STATUS_ERROR
|
||||
#undef STATUS_WARNING
|
||||
{ uefi::status::success, nullptr }
|
||||
};
|
||||
|
||||
const wchar_t *
|
||||
message(uefi::status status)
|
||||
{
|
||||
int32_t i = -1;
|
||||
while (error_table[++i].name != nullptr) {
|
||||
if (error_table[i].code == status) return error_table[i].name;
|
||||
}
|
||||
|
||||
if (uefi::is_error(status))
|
||||
return L"Unknown Error";
|
||||
else
|
||||
return L"Unknown Warning";
|
||||
}
|
||||
|
||||
[[ noreturn ]] static void
|
||||
cpu_assert(uefi::status s, const wchar_t *message)
|
||||
{
|
||||
asm volatile (
|
||||
"movq $0xeeeeeeebadbadbad, %%r8;"
|
||||
"movq %0, %%r9;"
|
||||
"movq %1, %%r10;"
|
||||
"movq $0, %%rdx;"
|
||||
"divq %%rdx;"
|
||||
:
|
||||
: "r"((uint64_t)s), "r"(message)
|
||||
: "rax", "rdx", "r8", "r9", "r10");
|
||||
while (1) asm("hlt");
|
||||
}
|
||||
|
||||
[[ noreturn ]] void
|
||||
raise(uefi::status status, const wchar_t *message)
|
||||
{
|
||||
if(status_line::fail(message, status))
|
||||
while (1) asm("hlt");
|
||||
else
|
||||
cpu_assert(status, message);
|
||||
}
|
||||
|
||||
|
||||
} // namespace error
|
||||
} // namespace boot
|
||||
|
||||
void debug_break()
|
||||
{
|
||||
volatile int go = 0;
|
||||
while (!go);
|
||||
}
|
||||
33
src/boot/error.h
Normal file
33
src/boot/error.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/// \file error.h
|
||||
/// Error handling definitions
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace boot {
|
||||
|
||||
class console;
|
||||
|
||||
namespace error {
|
||||
|
||||
/// Halt or exit the program with the given error status/message
|
||||
[[ noreturn ]] void raise(uefi::status status, const wchar_t *message);
|
||||
|
||||
const wchar_t * message(uefi::status status);
|
||||
|
||||
} // namespace error
|
||||
} // namespace boot
|
||||
|
||||
/// Debugging psuedo-breakpoint.
|
||||
void debug_break();
|
||||
|
||||
/// Helper macro to raise an error if an operation fails.
|
||||
/// \arg s An expression evaluating to a UEFI status
|
||||
/// \arg m The error message to use on failure
|
||||
#define try_or_raise(s, m) \
|
||||
do { \
|
||||
uefi::status _s = (s); \
|
||||
if (uefi::is_error(_s)) ::boot::error::raise(_s, (m)); \
|
||||
} while(0)
|
||||
|
||||
114
src/boot/fs.cpp
Normal file
114
src/boot/fs.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/protos/file.h>
|
||||
#include <uefi/protos/file_info.h>
|
||||
#include <uefi/protos/loaded_image.h>
|
||||
#include <uefi/protos/simple_file_system.h>
|
||||
|
||||
#include "fs.h"
|
||||
#include "console.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
#include "status.h"
|
||||
|
||||
namespace boot {
|
||||
namespace fs {
|
||||
|
||||
file::file(uefi::protos::file *f, uefi::boot_services *bs) :
|
||||
m_file(f),
|
||||
m_bs(bs)
|
||||
{
|
||||
}
|
||||
|
||||
file::file(file &o) :
|
||||
m_file(o.m_file),
|
||||
m_bs(o.m_bs)
|
||||
{
|
||||
o.m_file = nullptr;
|
||||
}
|
||||
|
||||
file::file(file &&o) :
|
||||
m_file(o.m_file),
|
||||
m_bs(o.m_bs)
|
||||
{
|
||||
o.m_file = nullptr;
|
||||
}
|
||||
|
||||
file::~file()
|
||||
{
|
||||
if (m_file)
|
||||
m_file->close();
|
||||
}
|
||||
|
||||
file
|
||||
file::open(const wchar_t *path)
|
||||
{
|
||||
uefi::protos::file *fh = nullptr;
|
||||
|
||||
try_or_raise(
|
||||
m_file->open(&fh, path, uefi::file_mode::read, uefi::file_attr::none),
|
||||
L"Could not open relative path to file");
|
||||
|
||||
return file(fh, m_bs);
|
||||
}
|
||||
|
||||
buffer
|
||||
file::load(uefi::memory_type mem_type)
|
||||
{
|
||||
uint8_t info_buf[sizeof(uefi::protos::file_info) + 100];
|
||||
size_t size = sizeof(info_buf);
|
||||
uefi::guid info_guid = uefi::protos::file_info::guid;
|
||||
|
||||
try_or_raise(
|
||||
m_file->get_info(&info_guid, &size, &info_buf),
|
||||
L"Could not get file info");
|
||||
|
||||
uefi::protos::file_info *info =
|
||||
reinterpret_cast<uefi::protos::file_info*>(&info_buf);
|
||||
|
||||
size_t pages = memory::bytes_to_pages(info->file_size);
|
||||
void *data = nullptr;
|
||||
try_or_raise(
|
||||
m_bs->allocate_pages(
|
||||
uefi::allocate_type::any_pages,
|
||||
mem_type, pages, &data),
|
||||
L"Could not allocate pages to load file");
|
||||
|
||||
size = info->file_size;
|
||||
try_or_raise(
|
||||
m_file->read(&size, data),
|
||||
L"Could not read from file");
|
||||
|
||||
return { .data = data, .size = size };
|
||||
}
|
||||
|
||||
file
|
||||
get_boot_volume(uefi::handle image, uefi::boot_services *bs)
|
||||
{
|
||||
status_line status(L"Looking up boot volume");
|
||||
|
||||
const uefi::guid le_guid = uefi::protos::loaded_image::guid;
|
||||
uefi::protos::loaded_image *loaded_image = nullptr;
|
||||
|
||||
try_or_raise(
|
||||
bs->handle_protocol(image, &le_guid,
|
||||
reinterpret_cast<void**>(&loaded_image)),
|
||||
L"Could not find currently running UEFI loaded image");
|
||||
|
||||
const uefi::guid sfs_guid = uefi::protos::simple_file_system::guid;
|
||||
uefi::protos::simple_file_system *fs;
|
||||
try_or_raise(
|
||||
bs->handle_protocol(loaded_image->device_handle, &sfs_guid,
|
||||
reinterpret_cast<void**>(&fs)),
|
||||
L"Could not find filesystem protocol for boot volume");
|
||||
|
||||
uefi::protos::file *f;
|
||||
try_or_raise(
|
||||
fs->open_volume(&f),
|
||||
L"Could not open the boot volume");
|
||||
|
||||
return file(f, bs);
|
||||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace boot
|
||||
|
||||
45
src/boot/fs.h
Normal file
45
src/boot/fs.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/// \file fs.h
|
||||
/// Definitions for dealing with UEFI's disk access functions
|
||||
#pragma once
|
||||
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/boot_services.h>
|
||||
#include <uefi/protos/file.h>
|
||||
#include "types.h"
|
||||
|
||||
namespace boot {
|
||||
namespace fs {
|
||||
|
||||
/// A file or directory in a filesystem.
|
||||
class file
|
||||
{
|
||||
public:
|
||||
file(file &&o);
|
||||
file(file &o);
|
||||
~file();
|
||||
|
||||
/// Open another file or directory, relative to this one.
|
||||
/// \arg path Relative path to the target file from this one
|
||||
file open(const wchar_t *path);
|
||||
|
||||
/// Load the contents of this file into memory.
|
||||
/// \arg mem_type The UEFI memory type to use for allocation
|
||||
/// \returns A buffer describing the loaded memory. The
|
||||
/// memory will be page-aligned.
|
||||
buffer load(uefi::memory_type mem_type = uefi::memory_type::loader_data);
|
||||
|
||||
private:
|
||||
friend file get_boot_volume(uefi::handle, uefi::boot_services*);
|
||||
|
||||
file(uefi::protos::file *f, uefi::boot_services *bs);
|
||||
|
||||
uefi::protos::file *m_file;
|
||||
uefi::boot_services *m_bs;
|
||||
};
|
||||
|
||||
/// Get the filesystem this loader was loaded from.
|
||||
/// \returns A `file` object representing the root directory of the volume
|
||||
file get_boot_volume(uefi::handle image, uefi::boot_services *bs);
|
||||
|
||||
} // namespace fs
|
||||
} // namespace boot
|
||||
@@ -3,5 +3,9 @@ GUID(0x8868e871,0xe4f1,0x11d3,0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81, guid_acpi
|
||||
GUID(0x09576e92,0x6d3f,0x11d2,0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b, guid_file_info);
|
||||
GUID(0x9042a9de,0x23dc,0x4a38,0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a, guid_gfx_out);
|
||||
GUID(0x964e5b22,0x6459,0x11d2,0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b, guid_simple_filesystem);
|
||||
GUID(0x09576e91,0x6d3f,0x11d2,0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b, guid_device_path);
|
||||
GUID(0x8b843e20,0x8132,0x4852,0x90,0xcc,0x55,0x1a,0x4e,0x4a,0x7f,0x1c, guid_device_path_to_text);
|
||||
|
||||
GUID(0x10d0669c,0x9ec6,0x4268,0xbc,0x48,0xff,0x74,0x75,0x21,0xfe,0x07, guid_jsix_vendor);
|
||||
|
||||
// vim: ft=c
|
||||
|
||||
55
src/boot/hardware.cpp
Normal file
55
src/boot/hardware.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "hardware.h"
|
||||
#include "console.h"
|
||||
#include "error.h"
|
||||
#include "status.h"
|
||||
|
||||
namespace boot {
|
||||
namespace hw {
|
||||
|
||||
void *
|
||||
find_acpi_table(uefi::system_table *st)
|
||||
{
|
||||
status_line status(L"Searching for ACPI table");
|
||||
|
||||
// Find ACPI tables. Ignore ACPI 1.0 if a 2.0 table is found.
|
||||
uintptr_t acpi1_table = 0;
|
||||
|
||||
for (size_t i = 0; i < st->number_of_table_entries; ++i) {
|
||||
uefi::configuration_table *table = &st->configuration_table[i];
|
||||
|
||||
// If we find an ACPI 2.0 table, return it immediately
|
||||
if (table->vendor_guid == uefi::vendor_guids::acpi2)
|
||||
return table->vendor_table;
|
||||
|
||||
if (table->vendor_guid == uefi::vendor_guids::acpi1) {
|
||||
// Mark a v1 table with the LSB high
|
||||
acpi1_table = reinterpret_cast<uintptr_t>(table->vendor_table);
|
||||
acpi1_table |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!acpi1_table) {
|
||||
error::raise(uefi::status::not_found, L"Could not find ACPI table");
|
||||
} else if (acpi1_table & 1) {
|
||||
status_line::warn(L"Only found ACPI 1.0 table");
|
||||
}
|
||||
|
||||
return reinterpret_cast<void*>(acpi1_table);
|
||||
}
|
||||
|
||||
void
|
||||
setup_cr4()
|
||||
{
|
||||
uint64_t cr4 = 0;
|
||||
asm volatile ( "mov %%cr4, %0" : "=r" (cr4) );
|
||||
cr4 |=
|
||||
0x000080 | // Enable global pages
|
||||
0x000200 | // Enable FXSAVE/FXRSTOR
|
||||
0x010000 | // Enable FSGSBASE
|
||||
0x020000 | // Enable PCIDs
|
||||
0;
|
||||
asm volatile ( "mov %0, %%cr4" :: "r" (cr4) );
|
||||
}
|
||||
|
||||
} // namespace hw
|
||||
} // namespace boot
|
||||
20
src/boot/hardware.h
Normal file
20
src/boot/hardware.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/// \file hardware.h
|
||||
/// Functions and definitions for detecting and dealing with hardware
|
||||
#pragma once
|
||||
|
||||
#include <uefi/tables.h>
|
||||
|
||||
namespace boot {
|
||||
namespace hw {
|
||||
|
||||
/// Find the ACPI table in the system configuration tables
|
||||
/// and return a pointer to it. If only an ACPI 1.0 table is
|
||||
/// available, the returned pointer will have its least
|
||||
/// significant bit set to 1.
|
||||
void * find_acpi_table(uefi::system_table *st);
|
||||
|
||||
/// Enable CPU options in CR4 for the kernel starting state.
|
||||
void setup_cr4();
|
||||
|
||||
} // namespace hw
|
||||
} // namespace boot
|
||||
@@ -1,255 +0,0 @@
|
||||
#include "elf.h"
|
||||
#include "guids.h"
|
||||
#include "loader.h"
|
||||
#include "memory.h"
|
||||
#include "utility.h"
|
||||
|
||||
#define PAGE_SIZE 0x1000
|
||||
|
||||
static CHAR16 kernel_name[] = KERNEL_FILENAME;
|
||||
static CHAR16 initrd_name[] = INITRD_FILENAME;
|
||||
|
||||
EFI_STATUS
|
||||
loader_alloc_pages(
|
||||
EFI_BOOT_SERVICES *bootsvc,
|
||||
EFI_MEMORY_TYPE mem_type,
|
||||
size_t *length,
|
||||
void **pages)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
|
||||
size_t page_count = ((*length - 1) / PAGE_SIZE) + 1;
|
||||
EFI_PHYSICAL_ADDRESS addr = (EFI_PHYSICAL_ADDRESS)*pages;
|
||||
|
||||
status = bootsvc->AllocatePages(AllocateAddress, mem_type, page_count, &addr);
|
||||
if (status == EFI_NOT_FOUND || status == EFI_OUT_OF_RESOURCES) {
|
||||
// couldn't get the address we wanted, try loading the kernel anywhere
|
||||
status =
|
||||
bootsvc->AllocatePages(AllocateAnyPages, mem_type, page_count, &addr);
|
||||
}
|
||||
CHECK_EFI_STATUS_OR_RETURN(status,
|
||||
L"Allocating %d kernel pages type %x",
|
||||
page_count, mem_type);
|
||||
|
||||
*length = page_count * PAGE_SIZE;
|
||||
*pages = (void *)addr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
loader_load_initrd(
|
||||
EFI_BOOT_SERVICES *bootsvc,
|
||||
EFI_FILE_PROTOCOL *root,
|
||||
struct loader_data *data)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
|
||||
EFI_FILE_PROTOCOL *file = NULL;
|
||||
status = root->Open(root, &file, (CHAR16 *)initrd_name, EFI_FILE_MODE_READ,
|
||||
EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM);
|
||||
|
||||
if (status == EFI_NOT_FOUND)
|
||||
return status;
|
||||
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Opening file %s", initrd_name);
|
||||
|
||||
char info[sizeof(EFI_FILE_INFO) + 100];
|
||||
size_t info_length = sizeof(info);
|
||||
|
||||
status = file->GetInfo(file, &guid_file_info, &info_length, info);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Getting file info");
|
||||
|
||||
data->initrd_length = ((EFI_FILE_INFO *)info)->FileSize;
|
||||
|
||||
status = loader_alloc_pages(
|
||||
bootsvc,
|
||||
INITRD_MEMTYPE,
|
||||
&data->initrd_length,
|
||||
&data->initrd);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Allocating pages");
|
||||
|
||||
status = file->Read(file, &data->initrd_length, data->initrd);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Reading file");
|
||||
|
||||
status = file->Close(file);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Closing file handle");
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
loader_load_elf(
|
||||
EFI_BOOT_SERVICES *bootsvc,
|
||||
EFI_FILE_PROTOCOL *root,
|
||||
struct loader_data *data)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
|
||||
con_debug(L"Opening kernel file %s\r\n", (CHAR16 *)kernel_name);
|
||||
|
||||
EFI_FILE_PROTOCOL *file = NULL;
|
||||
status = root->Open(root, &file, (CHAR16 *)kernel_name, EFI_FILE_MODE_READ,
|
||||
EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM);
|
||||
|
||||
if (status == EFI_NOT_FOUND)
|
||||
return status;
|
||||
|
||||
uint64_t length = 0;
|
||||
data->kernel = 0;
|
||||
data->kernel_entry = 0;
|
||||
data->kernel_length = 0;
|
||||
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Opening file %s", kernel_name);
|
||||
|
||||
struct elf_header header;
|
||||
|
||||
length = sizeof(struct elf_header);
|
||||
status = file->Read(file, &length, &header);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Reading ELF header");
|
||||
|
||||
con_debug(L"Read %u bytes of ELF header\r\n", length);
|
||||
|
||||
if (length < sizeof(struct elf_header))
|
||||
CHECK_EFI_STATUS_OR_RETURN(EFI_LOAD_ERROR, L"Incomplete read of ELF header");
|
||||
|
||||
static const char expected[] = {0x7f, 'E', 'L', 'F'};
|
||||
for (int i = 0; i < sizeof(expected); ++i) {
|
||||
if (header.ident.magic[i] != expected[i])
|
||||
CHECK_EFI_STATUS_OR_RETURN(EFI_LOAD_ERROR, L"Bad ELF magic number");
|
||||
}
|
||||
|
||||
if (header.ident.word_size != ELF_WORDSIZE)
|
||||
CHECK_EFI_STATUS_OR_RETURN(EFI_LOAD_ERROR, L"ELF load error: 32 bit ELF not supported");
|
||||
|
||||
if (header.ph_entsize != sizeof(struct elf_program_header))
|
||||
CHECK_EFI_STATUS_OR_RETURN(EFI_LOAD_ERROR, L"ELF load error: program header size mismatch");
|
||||
|
||||
if (header.ident.version != ELF_VERSION ||
|
||||
header.version != ELF_VERSION)
|
||||
CHECK_EFI_STATUS_OR_RETURN(EFI_LOAD_ERROR, L"ELF load error: wrong ELF version");
|
||||
|
||||
if (header.ident.endianness != 1 ||
|
||||
header.ident.os_abi != 0 ||
|
||||
header.machine != 0x3e)
|
||||
CHECK_EFI_STATUS_OR_RETURN(EFI_LOAD_ERROR, L"ELF load error: wrong machine architecture");
|
||||
|
||||
con_debug(L"ELF is valid, entrypoint %lu\r\n", header.entrypoint);
|
||||
|
||||
data->kernel_entry = (void *)header.entrypoint;
|
||||
|
||||
struct elf_program_header prog_header;
|
||||
for (int i = 0; i < header.ph_num; ++i) {
|
||||
con_debug(L"Reading ELF program header %d\r\n", i);
|
||||
|
||||
status = file->SetPosition(file, header.ph_offset + i * header.ph_entsize);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Setting ELF file position");
|
||||
|
||||
length = header.ph_entsize;
|
||||
status = file->Read(file, &length, &prog_header);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Reading ELF program header");
|
||||
|
||||
if (prog_header.type != ELF_PT_LOAD) continue;
|
||||
|
||||
length = prog_header.mem_size;
|
||||
void *addr = (void *)(prog_header.vaddr - KERNEL_VIRT_ADDRESS);
|
||||
status = loader_alloc_pages(bootsvc, KERNEL_MEMTYPE, &length, &addr);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Allocating kernel pages");
|
||||
|
||||
if (data->kernel == 0)
|
||||
data->kernel = addr;
|
||||
data->kernel_length = (uint64_t)addr + length - (uint64_t)data->kernel;
|
||||
}
|
||||
|
||||
struct elf_section_header sec_header;
|
||||
for (int i = 0; i < header.sh_num; ++i) {
|
||||
con_debug(L"Reading ELF section header %d ", i);
|
||||
|
||||
status = file->SetPosition(file, header.sh_offset + i * header.sh_entsize);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Setting ELF file position");
|
||||
|
||||
length = header.sh_entsize;
|
||||
status = file->Read(file, &length, &sec_header);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Reading ELF section header");
|
||||
|
||||
if ((sec_header.flags & ELF_SHF_ALLOC) == 0) {
|
||||
con_debug(L"SHF_ALLOC section\r\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
void *addr = (void *)(sec_header.addr - KERNEL_VIRT_ADDRESS);
|
||||
|
||||
if (sec_header.type == ELF_ST_PROGBITS) {
|
||||
con_debug(L"PROGBITS section\r\n");
|
||||
status = file->SetPosition(file, sec_header.offset);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Setting ELF file position");
|
||||
|
||||
length = sec_header.size;
|
||||
status = file->Read(file, &length, addr);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Reading file");
|
||||
} else if (sec_header.type == ELF_ST_NOBITS) {
|
||||
con_debug(L"NOBITS section\r\n");
|
||||
bootsvc->SetMem(addr, sec_header.size, 0);
|
||||
} else {
|
||||
con_debug(L"other section\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
status = file->Close(file);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"Closing file handle");
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
loader_load_kernel(
|
||||
EFI_BOOT_SERVICES *bootsvc,
|
||||
struct loader_data *data)
|
||||
{
|
||||
if (data == NULL)
|
||||
CHECK_EFI_STATUS_OR_RETURN(EFI_INVALID_PARAMETER, L"NULL loader_data");
|
||||
|
||||
EFI_STATUS status;
|
||||
EFI_HANDLE *handles = NULL;
|
||||
size_t handleCount = 0;
|
||||
|
||||
status = bootsvc->LocateHandleBuffer(ByProtocol, &guid_simple_filesystem, NULL, &handleCount, &handles);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"LocateHandleBuffer");
|
||||
|
||||
for (unsigned i = 0; i < handleCount; ++i) {
|
||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fileSystem = NULL;
|
||||
|
||||
status = bootsvc->HandleProtocol(handles[i], &guid_simple_filesystem, (void **)&fileSystem);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"HandleProtocol");
|
||||
|
||||
EFI_FILE_PROTOCOL *root = NULL;
|
||||
status = fileSystem->OpenVolume(fileSystem, &root);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"OpenVolume");
|
||||
|
||||
status = loader_load_elf(bootsvc, root, data);
|
||||
if (status == EFI_NOT_FOUND)
|
||||
continue;
|
||||
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"loader_load_elf: %s", kernel_name);
|
||||
|
||||
data->initrd = (void *)((uint64_t)data->kernel + data->kernel_length);
|
||||
status = loader_load_initrd(bootsvc, root, data);
|
||||
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"loader_load_file: %s", initrd_name);
|
||||
|
||||
data->data = (void *)((uint64_t)data->initrd + data->initrd_length);
|
||||
data->data_length += PAGE_SIZE; // extra page for map growth
|
||||
status = loader_alloc_pages(
|
||||
bootsvc,
|
||||
KERNEL_DATA_MEMTYPE,
|
||||
&data->data_length,
|
||||
&data->data);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, L"loader_alloc_pages: kernel data");
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
110
src/boot/loader.cpp
Normal file
110
src/boot/loader.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#include <uefi/boot_services.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
#include "loader.h"
|
||||
#include "console.h"
|
||||
#include "elf.h"
|
||||
#include "error.h"
|
||||
#include "fs.h"
|
||||
#include "memory.h"
|
||||
#include "paging.h"
|
||||
#include "status.h"
|
||||
|
||||
namespace args = kernel::args;
|
||||
|
||||
namespace boot {
|
||||
namespace loader {
|
||||
|
||||
buffer
|
||||
load_file(
|
||||
fs::file &disk,
|
||||
const wchar_t *name,
|
||||
const wchar_t *path,
|
||||
uefi::memory_type type)
|
||||
{
|
||||
status_line status(L"Loading file", name);
|
||||
|
||||
fs::file file = disk.open(path);
|
||||
buffer b = file.load(type);
|
||||
|
||||
console::print(L" Loaded at: 0x%lx, %d bytes\r\n", b.data, b.size);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
is_elfheader_valid(const elf::header *header)
|
||||
{
|
||||
return
|
||||
header->magic[0] == 0x7f &&
|
||||
header->magic[1] == 'E' &&
|
||||
header->magic[2] == 'L' &&
|
||||
header->magic[3] == 'F' &&
|
||||
header->word_size == elf::word_size &&
|
||||
header->endianness == elf::endianness &&
|
||||
header->os_abi == elf::os_abi &&
|
||||
header->machine == elf::machine &&
|
||||
header->header_version == elf::version;
|
||||
}
|
||||
|
||||
void
|
||||
load_program(
|
||||
args::program &program,
|
||||
const wchar_t *name,
|
||||
buffer data,
|
||||
uefi::boot_services *bs)
|
||||
{
|
||||
status_line status(L"Loading program:", name);
|
||||
const elf::header *header = reinterpret_cast<const elf::header*>(data.data);
|
||||
|
||||
if (data.size < sizeof(elf::header) || !is_elfheader_valid(header))
|
||||
error::raise(uefi::status::load_error, L"ELF file not valid");
|
||||
|
||||
uintptr_t prog_base = uintptr_t(-1);
|
||||
uintptr_t prog_end = 0;
|
||||
|
||||
for (int i = 0; i < header->ph_num; ++i) {
|
||||
ptrdiff_t offset = header->ph_offset + i * header->ph_entsize;
|
||||
const elf::program_header *pheader =
|
||||
offset_ptr<elf::program_header>(data.data, offset);
|
||||
|
||||
if (pheader->type != elf::PT_LOAD)
|
||||
continue;
|
||||
|
||||
uintptr_t end = pheader->vaddr + pheader->mem_size;
|
||||
if (pheader->vaddr < prog_base) prog_base = pheader->vaddr;
|
||||
if (end > prog_end) prog_end = end;
|
||||
}
|
||||
|
||||
size_t total_size = prog_end - prog_base;
|
||||
size_t num_pages = memory::bytes_to_pages(total_size);
|
||||
void *pages = nullptr;
|
||||
|
||||
try_or_raise(
|
||||
bs->allocate_pages(uefi::allocate_type::any_pages,
|
||||
uefi::memory_type::loader_data, num_pages, &pages),
|
||||
L"Failed allocating space for program");
|
||||
|
||||
bs->set_mem(pages, total_size, 0);
|
||||
|
||||
for (int i = 0; i < header->ph_num; ++i) {
|
||||
ptrdiff_t offset = header->ph_offset + i * header->ph_entsize;
|
||||
const elf::program_header *pheader =
|
||||
offset_ptr<elf::program_header>(data.data, offset);
|
||||
|
||||
if (pheader->type != elf::PT_LOAD)
|
||||
continue;
|
||||
|
||||
void *src_start = offset_ptr<void>(data.data, pheader->offset);
|
||||
void *dest_start = offset_ptr<void>(pages, pheader->vaddr - prog_base);
|
||||
bs->copy_mem(dest_start, src_start, pheader->file_size);
|
||||
}
|
||||
|
||||
program.phys_addr = reinterpret_cast<uintptr_t>(pages);
|
||||
program.size = total_size;
|
||||
program.virt_addr = prog_base;
|
||||
program.entrypoint = header->entrypoint;
|
||||
}
|
||||
|
||||
} // namespace loader
|
||||
} // namespace boot
|
||||
@@ -1,47 +1,41 @@
|
||||
/// \file loader.h
|
||||
/// Definitions for loading the kernel into memory
|
||||
#pragma once
|
||||
#include <efi/efi.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define PAGE_SIZE 0x1000
|
||||
#include <uefi/boot_services.h>
|
||||
|
||||
#ifndef KERNEL_PHYS_ADDRESS
|
||||
#define KERNEL_PHYS_ADDRESS 0x100000
|
||||
#endif
|
||||
#include "kernel_args.h"
|
||||
#include "memory.h"
|
||||
#include "types.h"
|
||||
|
||||
#ifndef KERNEL_VIRT_ADDRESS
|
||||
#define KERNEL_VIRT_ADDRESS 0xFFFFFF0000000000
|
||||
#endif
|
||||
namespace boot {
|
||||
|
||||
#ifndef KERNEL_MEMTYPE
|
||||
#define KERNEL_MEMTYPE 0x80000000
|
||||
#endif
|
||||
namespace fs { class file; }
|
||||
|
||||
#ifndef INITRD_MEMTYPE
|
||||
#define INITRD_MEMTYPE 0x80000001
|
||||
#endif
|
||||
namespace loader {
|
||||
|
||||
#ifndef KERNEL_DATA_MEMTYPE
|
||||
#define KERNEL_DATA_MEMTYPE 0x80000002
|
||||
#endif
|
||||
/// Load a file from disk into memory.
|
||||
/// \arg disk The opened UEFI filesystem to load from
|
||||
/// \arg name Name of the module (informational only)
|
||||
/// \arg path Path on `disk` of the file to load
|
||||
/// \arg type Memory type to use for allocation
|
||||
buffer
|
||||
load_file(
|
||||
fs::file &disk,
|
||||
const wchar_t *name,
|
||||
const wchar_t *path,
|
||||
uefi::memory_type type = uefi::memory_type::loader_data);
|
||||
|
||||
#ifndef KERNEL_FILENAME
|
||||
#define KERNEL_FILENAME L"kernel.elf"
|
||||
#endif
|
||||
/// Parse and load an ELF file in memory into a loaded image.
|
||||
/// \arg program The program structure to fill
|
||||
/// \arg data Buffer of the ELF file in memory
|
||||
/// \arg bs Boot services
|
||||
void
|
||||
load_program(
|
||||
kernel::args::program &program,
|
||||
const wchar_t *name,
|
||||
buffer data,
|
||||
uefi::boot_services *bs);
|
||||
|
||||
#ifndef INITRD_FILENAME
|
||||
#define INITRD_FILENAME L"initrd.img"
|
||||
#endif
|
||||
|
||||
struct loader_data {
|
||||
void *kernel;
|
||||
void *kernel_entry;
|
||||
size_t kernel_length;
|
||||
|
||||
void *initrd;
|
||||
size_t initrd_length;
|
||||
|
||||
void *data;
|
||||
size_t data_length;
|
||||
};
|
||||
|
||||
EFI_STATUS loader_load_kernel(EFI_BOOT_SERVICES *bootsvc, struct loader_data *data);
|
||||
} // namespace loader
|
||||
} // namespace boot
|
||||
|
||||
171
src/boot/main.c
171
src/boot/main.c
@@ -1,171 +0,0 @@
|
||||
#include <stdalign.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <efi/efi.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "guids.h"
|
||||
#include "kernel_data.h"
|
||||
#include "loader.h"
|
||||
#include "memory.h"
|
||||
#include "utility.h"
|
||||
|
||||
#ifndef GIT_VERSION_WIDE
|
||||
#define GIT_VERSION_WIDE L"no version"
|
||||
#endif
|
||||
|
||||
#define KERNEL_HEADER_MAGIC 0x600db007
|
||||
#define KERNEL_HEADER_VERSION 1
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct kernel_header {
|
||||
uint32_t magic;
|
||||
uint16_t version;
|
||||
uint16_t length;
|
||||
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
uint16_t patch;
|
||||
uint32_t gitsha;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
EFI_STATUS
|
||||
efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
EFI_BOOT_SERVICES *bootsvc = system_table->BootServices;
|
||||
EFI_RUNTIME_SERVICES *runsvc = system_table->RuntimeServices;
|
||||
|
||||
// When checking console initialization, use CHECK_EFI_STATUS_OR_RETURN
|
||||
// because we can't be sure if the console was fully set up
|
||||
status = con_initialize(system_table, GIT_VERSION_WIDE);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "con_initialize");
|
||||
// From here on out, we can use CHECK_EFI_STATUS_OR_FAIL instead
|
||||
|
||||
memory_init_pointer_fixup(bootsvc, runsvc);
|
||||
|
||||
// Find ACPI tables. Ignore ACPI 1.0 if a 2.0 table is found.
|
||||
//
|
||||
void *acpi_table = NULL;
|
||||
for (size_t i=0; i<system_table->NumberOfTableEntries; ++i) {
|
||||
EFI_CONFIGURATION_TABLE *efi_table = &system_table->ConfigurationTable[i];
|
||||
if (is_guid(&efi_table->VendorGuid, &guid_acpi2)) {
|
||||
acpi_table = efi_table->VendorTable;
|
||||
break;
|
||||
} else if (is_guid(&efi_table->VendorGuid, &guid_acpi1)) {
|
||||
// Mark a v1 table with the LSB high
|
||||
acpi_table = (void *)((intptr_t)efi_table->VendorTable | 0x1);
|
||||
}
|
||||
}
|
||||
|
||||
// Compute necessary number of data pages
|
||||
//
|
||||
size_t data_length = 0;
|
||||
status = memory_get_map_length(bootsvc, &data_length);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
|
||||
size_t header_size = sizeof(struct popcorn_data);
|
||||
const size_t header_align = alignof(struct popcorn_data);
|
||||
if (header_size % header_align)
|
||||
header_size += header_align - (header_size % header_align);
|
||||
|
||||
data_length += header_size;
|
||||
|
||||
|
||||
// Load the kernel image from disk and check it
|
||||
//
|
||||
con_printf(L"Loading kernel into memory...\r\n");
|
||||
|
||||
struct loader_data load;
|
||||
load.data_length = data_length;
|
||||
status = loader_load_kernel(bootsvc, &load);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
|
||||
con_printf(L" %u image bytes at 0x%x\r\n", load.kernel_length, load.kernel);
|
||||
con_printf(L" %u initrd bytes at 0x%x\r\n", load.initrd_length, load.initrd);
|
||||
con_printf(L" %u data bytes at 0x%x\r\n", load.data_length, load.data);
|
||||
|
||||
struct kernel_header *version = (struct kernel_header *)load.kernel;
|
||||
if (version->magic != KERNEL_HEADER_MAGIC) {
|
||||
con_printf(L" bad magic %x\r\n", version->magic);
|
||||
CHECK_EFI_STATUS_OR_FAIL(EFI_CRC_ERROR);
|
||||
}
|
||||
|
||||
con_printf(L" Kernel version %d.%d.%d %x%s\r\n",
|
||||
version->major, version->minor, version->patch, version->gitsha & 0x0fffffff,
|
||||
version->gitsha & 0xf0000000 ? "*" : "");
|
||||
con_printf(L" Entrypoint 0x%x\r\n", load.kernel_entry);
|
||||
|
||||
void (*kernel_main)() = load.kernel_entry;
|
||||
memory_mark_pointer_fixup((void **)&kernel_main);
|
||||
|
||||
// Set up the kernel data pages to pass to the kernel
|
||||
//
|
||||
struct popcorn_data *data_header = (struct popcorn_data *)load.data;
|
||||
memory_mark_pointer_fixup((void **)&data_header);
|
||||
|
||||
data_header->magic = DATA_HEADER_MAGIC;
|
||||
data_header->version = DATA_HEADER_VERSION;
|
||||
data_header->length = sizeof(struct popcorn_data);
|
||||
|
||||
data_header->flags = 0;
|
||||
|
||||
data_header->initrd = load.initrd;
|
||||
data_header->initrd_length = load.initrd_length;
|
||||
memory_mark_pointer_fixup((void **)&data_header->initrd);
|
||||
|
||||
data_header->data = load.data;
|
||||
data_header->data_length = load.data_length;
|
||||
memory_mark_pointer_fixup((void **)&data_header->data);
|
||||
|
||||
data_header->memory_map = (EFI_MEMORY_DESCRIPTOR *)(data_header + 1);
|
||||
memory_mark_pointer_fixup((void **)&data_header->memory_map);
|
||||
|
||||
data_header->runtime = runsvc;
|
||||
memory_mark_pointer_fixup((void **)&data_header->runtime);
|
||||
|
||||
data_header->acpi_table = acpi_table;
|
||||
memory_mark_pointer_fixup((void **)&data_header->acpi_table);
|
||||
|
||||
data_header->_reserved0 = 0;
|
||||
data_header->_reserved1 = 0;
|
||||
|
||||
// Figure out the framebuffer (if any) and add that to the data header
|
||||
//
|
||||
status = con_get_framebuffer(
|
||||
bootsvc,
|
||||
&data_header->frame_buffer,
|
||||
&data_header->frame_buffer_length,
|
||||
&data_header->hres,
|
||||
&data_header->vres,
|
||||
&data_header->rmask,
|
||||
&data_header->gmask,
|
||||
&data_header->bmask);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
memory_mark_pointer_fixup((void **)&data_header->frame_buffer);
|
||||
|
||||
// Save the memory map and tell the firmware we're taking control.
|
||||
//
|
||||
struct memory_map map;
|
||||
map.entries = data_header->memory_map;
|
||||
map.length = (load.data_length - header_size);
|
||||
|
||||
status = memory_get_map(bootsvc, &map);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
|
||||
data_header->memory_map_length = map.length;
|
||||
data_header->memory_map_desc_size = map.size;
|
||||
|
||||
// bootsvc->Stall(5000000);
|
||||
|
||||
status = bootsvc->ExitBootServices(image_handle, map.key);
|
||||
CHECK_EFI_STATUS_OR_ASSERT(status, 0);
|
||||
|
||||
memory_virtualize(runsvc, &map);
|
||||
|
||||
// Hand control to the kernel
|
||||
//
|
||||
kernel_main(data_header);
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
211
src/boot/main.cpp
Normal file
211
src/boot/main.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/guid.h>
|
||||
#include <uefi/tables.h>
|
||||
#include <uefi/protos/simple_text_output.h>
|
||||
|
||||
#include <stdalign.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "cpu/cpu.h"
|
||||
#include "error.h"
|
||||
#include "fs.h"
|
||||
#include "hardware.h"
|
||||
#include "loader.h"
|
||||
#include "memory.h"
|
||||
#include "paging.h"
|
||||
#include "status.h"
|
||||
|
||||
#include "kernel_args.h"
|
||||
|
||||
namespace kernel {
|
||||
#include "kernel_memory.h"
|
||||
}
|
||||
|
||||
namespace args = kernel::args;
|
||||
|
||||
namespace boot {
|
||||
|
||||
constexpr int max_modules = 5; // Max modules to allocate room for
|
||||
constexpr int max_programs = 5; // Max programs to allocate room for
|
||||
|
||||
struct program_desc
|
||||
{
|
||||
const wchar_t *name;
|
||||
const wchar_t *path;
|
||||
};
|
||||
|
||||
const program_desc program_list[] = {
|
||||
{L"kernel", L"jsix.elf"},
|
||||
{L"null driver", L"nulldrv.elf"},
|
||||
{L"fb driver", L"fb.elf"},
|
||||
};
|
||||
|
||||
/// Change a pointer to point to the higher-half linear-offset version
|
||||
/// of the address it points to.
|
||||
template <typename T>
|
||||
void change_pointer(T *&pointer)
|
||||
{
|
||||
pointer = offset_ptr<T>(pointer, kernel::memory::page_offset);
|
||||
}
|
||||
|
||||
/// Allocate space for kernel args. Allocates enough space from pool
|
||||
/// memory for the args header and the module and program headers.
|
||||
args::header *
|
||||
allocate_args_structure(
|
||||
uefi::boot_services *bs,
|
||||
size_t max_modules,
|
||||
size_t max_programs)
|
||||
{
|
||||
status_line status {L"Setting up kernel args memory"};
|
||||
|
||||
args::header *args = nullptr;
|
||||
|
||||
size_t args_size =
|
||||
sizeof(args::header) + // The header itself
|
||||
max_modules * sizeof(args::module) + // The module structures
|
||||
max_programs * sizeof(args::program); // The program structures
|
||||
|
||||
try_or_raise(
|
||||
bs->allocate_pool(uefi::memory_type::loader_data, args_size,
|
||||
reinterpret_cast<void**>(&args)),
|
||||
L"Could not allocate argument memory");
|
||||
|
||||
bs->set_mem(args, args_size, 0);
|
||||
|
||||
args->modules =
|
||||
reinterpret_cast<args::module*>(args + 1);
|
||||
args->num_modules = 0;
|
||||
|
||||
args->programs =
|
||||
reinterpret_cast<args::program*>(args->modules + max_modules);
|
||||
args->num_programs = 0;
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
/// Add a module to the kernel args list
|
||||
inline void
|
||||
add_module(args::header *args, args::mod_type type, buffer &data)
|
||||
{
|
||||
args::module &m = args->modules[args->num_modules++];
|
||||
m.type = type;
|
||||
m.location = data.data;
|
||||
m.size = data.size;
|
||||
}
|
||||
|
||||
/// Check that all required cpu features are supported
|
||||
void
|
||||
check_cpu_supported()
|
||||
{
|
||||
status_line status {L"Checking CPU features"};
|
||||
|
||||
cpu::cpu_id cpu;
|
||||
uint64_t missing = cpu.missing();
|
||||
if (missing) {
|
||||
#define CPU_FEATURE_OPT(...)
|
||||
#define CPU_FEATURE_REQ(name, ...) \
|
||||
if (!cpu.has_feature(cpu::feature::name)) { \
|
||||
status::fail(L"CPU required feature " L ## #name, uefi::status::unsupported); \
|
||||
}
|
||||
#include "cpu/features.inc"
|
||||
#undef CPU_FEATURE_REQ
|
||||
#undef CPU_FEATURE_OPT
|
||||
|
||||
error::raise(uefi::status::unsupported, L"CPU not supported");
|
||||
}
|
||||
}
|
||||
|
||||
/// The main procedure for the portion of the loader that runs while
|
||||
/// UEFI is still in control of the machine. (ie, while the loader still
|
||||
/// has access to boot services.
|
||||
args::header *
|
||||
uefi_preboot(uefi::handle image, uefi::system_table *st)
|
||||
{
|
||||
status_line status {L"Performing UEFI pre-boot"};
|
||||
|
||||
uefi::boot_services *bs = st->boot_services;
|
||||
uefi::runtime_services *rs = st->runtime_services;
|
||||
memory::init_pointer_fixup(bs, rs);
|
||||
|
||||
args::header *args =
|
||||
allocate_args_structure(bs, max_modules, max_programs);
|
||||
|
||||
args->magic = args::magic;
|
||||
args->version = args::version;
|
||||
args->runtime_services = rs;
|
||||
args->acpi_table = hw::find_acpi_table(st);
|
||||
paging::allocate_tables(args, bs);
|
||||
|
||||
memory::mark_pointer_fixup(&args->runtime_services);
|
||||
|
||||
fs::file disk = fs::get_boot_volume(image, bs);
|
||||
|
||||
buffer symbols = loader::load_file(disk, L"symbol table", L"symbol_table.dat",
|
||||
uefi::memory_type::loader_data);
|
||||
add_module(args, args::mod_type::symbol_table, symbols);
|
||||
|
||||
for (auto &desc : program_list) {
|
||||
buffer buf = loader::load_file(disk, desc.name, desc.path);
|
||||
args::program &program = args->programs[args->num_programs++];
|
||||
loader::load_program(program, desc.name, buf, bs);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < args->num_modules; ++i) {
|
||||
args::module &mod = args->modules[i];
|
||||
change_pointer(mod.location);
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
memory::efi_mem_map
|
||||
uefi_exit(args::header *args, uefi::handle image, uefi::boot_services *bs)
|
||||
{
|
||||
status_line status {L"Exiting UEFI"};
|
||||
|
||||
memory::efi_mem_map map =
|
||||
memory::build_kernel_mem_map(args, bs);
|
||||
|
||||
try_or_raise(
|
||||
bs->exit_boot_services(image, map.key),
|
||||
L"Failed to exit boot services");
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
} // namespace boot
|
||||
|
||||
/// The UEFI entrypoint for the loader.
|
||||
extern "C" uefi::status
|
||||
efi_main(uefi::handle image, uefi::system_table *st)
|
||||
{
|
||||
using namespace boot;
|
||||
console con(st->boot_services, st->con_out);
|
||||
check_cpu_supported();
|
||||
|
||||
args::header *args = uefi_preboot(image, st);
|
||||
memory::efi_mem_map map = uefi_exit(args, image, st->boot_services);
|
||||
|
||||
args->video = con.fb();
|
||||
status_bar status {con.fb()}; // Switch to fb status display
|
||||
|
||||
args::program &kernel = args->programs[0];
|
||||
paging::map_pages(args, kernel.phys_addr, kernel.virt_addr, kernel.size);
|
||||
kernel::entrypoint kentry =
|
||||
reinterpret_cast<kernel::entrypoint>(kernel.entrypoint);
|
||||
status.next();
|
||||
|
||||
memory::virtualize(args->pml4, map, st->runtime_services);
|
||||
status.next();
|
||||
|
||||
change_pointer(args->pml4);
|
||||
hw::setup_cr4();
|
||||
status.next();
|
||||
|
||||
kentry(args);
|
||||
debug_break();
|
||||
return uefi::status::unsupported;
|
||||
}
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include "loader.h"
|
||||
#include "memory.h"
|
||||
#include "utility.h"
|
||||
|
||||
#define INCREMENT_DESC(p, b) (EFI_MEMORY_DESCRIPTOR*)(((uint8_t*)(p))+(b))
|
||||
|
||||
size_t fixup_pointer_index = 0;
|
||||
void **fixup_pointers[64];
|
||||
uint64_t *new_pml4 = 0;
|
||||
|
||||
const CHAR16 *memory_type_names[] = {
|
||||
L"EfiReservedMemoryType",
|
||||
L"EfiLoaderCode",
|
||||
L"EfiLoaderData",
|
||||
L"EfiBootServicesCode",
|
||||
L"EfiBootServicesData",
|
||||
L"EfiRuntimeServicesCode",
|
||||
L"EfiRuntimeServicesData",
|
||||
L"EfiConventionalMemory",
|
||||
L"EfiUnusableMemory",
|
||||
L"EfiACPIReclaimMemory",
|
||||
L"EfiACPIMemoryNVS",
|
||||
L"EfiMemoryMappedIO",
|
||||
L"EfiMemoryMappedIOPortSpace",
|
||||
L"EfiPalCode",
|
||||
L"EfiPersistentMemory",
|
||||
};
|
||||
|
||||
static const CHAR16 *
|
||||
memory_type_name(UINT32 value)
|
||||
{
|
||||
if (value >= (sizeof(memory_type_names) / sizeof(CHAR16 *))) {
|
||||
if (value == KERNEL_DATA_MEMTYPE) return L"Kernel Data";
|
||||
else if (value == KERNEL_MEMTYPE) return L"Kernel Image";
|
||||
else return L"Bad Type Value";
|
||||
}
|
||||
return memory_type_names[value];
|
||||
}
|
||||
|
||||
void EFIAPI
|
||||
memory_update_marked_addresses(EFI_EVENT UNUSED *event, void *context)
|
||||
{
|
||||
EFI_RUNTIME_SERVICES *runsvc = (EFI_RUNTIME_SERVICES*)context;
|
||||
for (size_t i = 0; i < fixup_pointer_index; ++i) {
|
||||
if (fixup_pointers[i])
|
||||
runsvc->ConvertPointer(0, fixup_pointers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
memory_init_pointer_fixup(EFI_BOOT_SERVICES *bootsvc, EFI_RUNTIME_SERVICES *runsvc)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
EFI_EVENT event;
|
||||
|
||||
status = bootsvc->CreateEvent(
|
||||
EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
|
||||
TPL_CALLBACK,
|
||||
(EFI_EVENT_NOTIFY)&memory_update_marked_addresses,
|
||||
runsvc,
|
||||
&event);
|
||||
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "Failed to initialize pointer update event.");
|
||||
|
||||
// Reserve a page for our replacement PML4, plus some pages for the kernel to use
|
||||
// as page tables while it gets started.
|
||||
EFI_PHYSICAL_ADDRESS addr = 0;
|
||||
status = bootsvc->AllocatePages(AllocateAnyPages, EfiLoaderData, 16, &addr);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "Failed to allocate page table pages.");
|
||||
|
||||
new_pml4 = (uint64_t *)addr;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
memory_mark_pointer_fixup(void **p)
|
||||
{
|
||||
if (fixup_pointer_index == 0) {
|
||||
const size_t count = sizeof(fixup_pointers) / sizeof(void*);
|
||||
for (size_t i = 0; i < count; ++i) fixup_pointers[i] = 0;
|
||||
}
|
||||
fixup_pointers[fixup_pointer_index++] = p;
|
||||
}
|
||||
|
||||
void
|
||||
copy_desc(EFI_MEMORY_DESCRIPTOR *src, EFI_MEMORY_DESCRIPTOR *dst, size_t len)
|
||||
{
|
||||
uint8_t *srcb = (uint8_t *)src;
|
||||
uint8_t *dstb = (uint8_t *)dst;
|
||||
uint8_t *endb = srcb + len;
|
||||
while (srcb < endb)
|
||||
*dstb++ = *srcb++;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
memory_get_map_length(EFI_BOOT_SERVICES *bootsvc, size_t *size)
|
||||
{
|
||||
if (size == NULL)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
EFI_STATUS status;
|
||||
size_t key, desc_size;
|
||||
uint32_t desc_version;
|
||||
*size = 0;
|
||||
status = bootsvc->GetMemoryMap(size, 0, &key, &desc_size, &desc_version);
|
||||
if (status != EFI_BUFFER_TOO_SMALL) {
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "Failed to get memory map size");
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
memory_get_map(EFI_BOOT_SERVICES *bootsvc, struct memory_map *map)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
|
||||
if (map == NULL)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
size_t needs_size = 0;
|
||||
status = memory_get_map_length(bootsvc, &needs_size);
|
||||
if (EFI_ERROR(status)) return status;
|
||||
|
||||
if (map->length < needs_size)
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
|
||||
status = bootsvc->GetMemoryMap(&map->length, map->entries, &map->key, &map->size, &map->version);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "Failed to load memory map");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
memory_dump_map(struct memory_map *map)
|
||||
{
|
||||
if (map == NULL)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
const size_t count = map->length / map->size;
|
||||
|
||||
con_printf(L"Memory map:\n");
|
||||
con_printf(L"\t Descriptor Count: %d (%d bytes)\n", count, map->length);
|
||||
con_printf(L"\t Descriptor Size: %d bytes\n", map->size);
|
||||
con_printf(L"\t Type offset: %d\n\n", offsetof(EFI_MEMORY_DESCRIPTOR, Type));
|
||||
|
||||
EFI_MEMORY_DESCRIPTOR *end = INCREMENT_DESC(map->entries, map->length);
|
||||
EFI_MEMORY_DESCRIPTOR *d = map->entries;
|
||||
while (d < end) {
|
||||
int runtime = (d->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME;
|
||||
con_printf(L"%s%s ", memory_type_name(d->Type), runtime ? L"*" : L" ");
|
||||
con_printf(L"%lx ", d->PhysicalStart);
|
||||
con_printf(L"%lx ", d->VirtualStart);
|
||||
con_printf(L"[%4d]\n", d->NumberOfPages);
|
||||
|
||||
d = INCREMENT_DESC(d, map->size);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
memory_virtualize(EFI_RUNTIME_SERVICES *runsvc, struct memory_map *map)
|
||||
{
|
||||
memory_mark_pointer_fixup((void **)&runsvc);
|
||||
memory_mark_pointer_fixup((void **)&map);
|
||||
|
||||
// Get the pointer to the start of PML4
|
||||
uint64_t* cr3 = 0;
|
||||
__asm__ __volatile__ ( "mov %%cr3, %0" : "=r" (cr3) );
|
||||
|
||||
// PML4 is indexed with bits 39:47 of the virtual address
|
||||
uint64_t offset = (KERNEL_VIRT_ADDRESS >> 39) & 0x1ff;
|
||||
|
||||
// Double map the lower half pages that are present into the higher half
|
||||
for (unsigned i = 0; i < offset; ++i) {
|
||||
if (cr3[i] & 0x1)
|
||||
new_pml4[i] = new_pml4[offset+i] = cr3[i];
|
||||
else
|
||||
new_pml4[i] = new_pml4[offset+i] = 0;
|
||||
}
|
||||
|
||||
// Write our new PML4 pointer back to CR3
|
||||
__asm__ __volatile__ ( "mov %0, %%cr3" :: "r" (new_pml4) );
|
||||
|
||||
EFI_MEMORY_DESCRIPTOR *end = INCREMENT_DESC(map->entries, map->length);
|
||||
EFI_MEMORY_DESCRIPTOR *d = map->entries;
|
||||
while (d < end) {
|
||||
switch (d->Type) {
|
||||
case KERNEL_MEMTYPE:
|
||||
case INITRD_MEMTYPE:
|
||||
case KERNEL_DATA_MEMTYPE:
|
||||
d->Attribute |= EFI_MEMORY_RUNTIME;
|
||||
d->VirtualStart = d->PhysicalStart + KERNEL_VIRT_ADDRESS;
|
||||
|
||||
default:
|
||||
if (d->Attribute & EFI_MEMORY_RUNTIME) {
|
||||
d->VirtualStart = d->PhysicalStart + KERNEL_VIRT_ADDRESS;
|
||||
}
|
||||
}
|
||||
d = INCREMENT_DESC(d, map->size);
|
||||
}
|
||||
|
||||
runsvc->SetVirtualAddressMap(map->length, map->size, map->version, map->entries);
|
||||
}
|
||||
268
src/boot/memory.cpp
Normal file
268
src/boot/memory.cpp
Normal file
@@ -0,0 +1,268 @@
|
||||
#include <stddef.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
#include "kernel_memory.h"
|
||||
|
||||
#include "console.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
#include "paging.h"
|
||||
#include "status.h"
|
||||
|
||||
namespace boot {
|
||||
namespace memory {
|
||||
|
||||
using mem_entry = kernel::args::mem_entry;
|
||||
using mem_type = kernel::args::mem_type;
|
||||
|
||||
size_t fixup_pointer_index = 0;
|
||||
void **fixup_pointers[64];
|
||||
|
||||
static const wchar_t *memory_type_names[] = {
|
||||
L"reserved memory type",
|
||||
L"loader code",
|
||||
L"loader data",
|
||||
L"boot services code",
|
||||
L"boot services data",
|
||||
L"runtime services code",
|
||||
L"runtime services data",
|
||||
L"conventional memory",
|
||||
L"unusable memory",
|
||||
L"acpi reclaim memory",
|
||||
L"acpi memory nvs",
|
||||
L"memory mapped io",
|
||||
L"memory mapped io port space",
|
||||
L"pal code",
|
||||
L"persistent memory"
|
||||
};
|
||||
|
||||
static const wchar_t *kernel_memory_type_names[] = {
|
||||
L"free",
|
||||
L"pending",
|
||||
L"acpi",
|
||||
L"uefi_runtime",
|
||||
L"mmio",
|
||||
L"persistent"
|
||||
};
|
||||
|
||||
static const wchar_t *
|
||||
memory_type_name(uefi::memory_type t)
|
||||
{
|
||||
if (t < uefi::memory_type::max_memory_type)
|
||||
return memory_type_names[static_cast<uint32_t>(t)];
|
||||
|
||||
return L"Bad Type Value";
|
||||
}
|
||||
|
||||
static const wchar_t *
|
||||
kernel_memory_type_name(kernel::args::mem_type t)
|
||||
{
|
||||
return kernel_memory_type_names[static_cast<uint32_t>(t)];
|
||||
}
|
||||
|
||||
void
|
||||
update_marked_addresses(uefi::event, void *context)
|
||||
{
|
||||
uefi::runtime_services *rs =
|
||||
reinterpret_cast<uefi::runtime_services*>(context);
|
||||
|
||||
for (size_t i = 0; i < fixup_pointer_index; ++i) {
|
||||
if (fixup_pointers[i])
|
||||
rs->convert_pointer(0, fixup_pointers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
init_pointer_fixup(uefi::boot_services *bs, uefi::runtime_services *rs)
|
||||
{
|
||||
status_line status(L"Initializing pointer virtualization event");
|
||||
|
||||
uefi::event event;
|
||||
bs->set_mem(&fixup_pointers, sizeof(fixup_pointers), 0);
|
||||
fixup_pointer_index = 0;
|
||||
|
||||
try_or_raise(
|
||||
bs->create_event(
|
||||
uefi::evt::signal_virtual_address_change,
|
||||
uefi::tpl::callback,
|
||||
(uefi::event_notify)&update_marked_addresses,
|
||||
rs,
|
||||
&event),
|
||||
L"Error creating memory virtualization event");
|
||||
}
|
||||
|
||||
void
|
||||
mark_pointer_fixup(void **p)
|
||||
{
|
||||
fixup_pointers[fixup_pointer_index++] = p;
|
||||
}
|
||||
|
||||
bool
|
||||
can_merge(mem_entry &prev, mem_type type, uefi::memory_descriptor *next)
|
||||
{
|
||||
return
|
||||
prev.type == type &&
|
||||
prev.start + (page_size * prev.pages) == next->physical_start &&
|
||||
prev.attr == (next->attribute & 0xffffffff);
|
||||
}
|
||||
|
||||
void
|
||||
get_uefi_mappings(efi_mem_map *map, bool allocate, uefi::boot_services *bs)
|
||||
{
|
||||
size_t length = 0;
|
||||
uefi::status status = bs->get_memory_map(
|
||||
&length, nullptr, &map->key, &map->size, &map->version);
|
||||
|
||||
if (status != uefi::status::buffer_too_small)
|
||||
error::raise(status, L"Error getting memory map size");
|
||||
|
||||
map->length = length;
|
||||
|
||||
if (allocate) {
|
||||
map->length += 10*map->size;
|
||||
|
||||
try_or_raise(
|
||||
bs->allocate_pool(
|
||||
uefi::memory_type::loader_data, map->length,
|
||||
reinterpret_cast<void**>(&map->entries)),
|
||||
L"Allocating space for memory map");
|
||||
|
||||
try_or_raise(
|
||||
bs->get_memory_map(&map->length, map->entries, &map->key, &map->size, &map->version),
|
||||
L"Getting UEFI memory map");
|
||||
}
|
||||
}
|
||||
|
||||
efi_mem_map
|
||||
build_kernel_mem_map(kernel::args::header *args, uefi::boot_services *bs)
|
||||
{
|
||||
status_line status {L"Creating kernel memory map"};
|
||||
|
||||
efi_mem_map map;
|
||||
get_uefi_mappings(&map, false, bs);
|
||||
|
||||
size_t map_size = map.num_entries() * sizeof(mem_entry);
|
||||
|
||||
kernel::args::mem_entry *kernel_map = nullptr;
|
||||
try_or_raise(
|
||||
bs->allocate_pages(
|
||||
uefi::allocate_type::any_pages,
|
||||
uefi::memory_type::loader_data,
|
||||
bytes_to_pages(map_size),
|
||||
reinterpret_cast<void**>(&kernel_map)),
|
||||
L"Error allocating kernel memory map module space");
|
||||
|
||||
bs->set_mem(kernel_map, map_size, 0);
|
||||
get_uefi_mappings(&map, true, bs);
|
||||
|
||||
size_t i = 0;
|
||||
bool first = true;
|
||||
for (auto desc : map) {
|
||||
/*
|
||||
// EFI map dump
|
||||
console::print(L" Range %lx (%lx) %x(%s) [%lu]\r\n",
|
||||
desc->physical_start, desc->attribute, desc->type, memory_type_name(desc->type), desc->number_of_pages);
|
||||
*/
|
||||
|
||||
mem_type type;
|
||||
switch (desc->type) {
|
||||
case uefi::memory_type::reserved:
|
||||
case uefi::memory_type::unusable_memory:
|
||||
case uefi::memory_type::acpi_memory_nvs:
|
||||
case uefi::memory_type::pal_code:
|
||||
continue;
|
||||
|
||||
case uefi::memory_type::loader_code:
|
||||
case uefi::memory_type::boot_services_code:
|
||||
case uefi::memory_type::boot_services_data:
|
||||
case uefi::memory_type::conventional_memory:
|
||||
type = mem_type::free;
|
||||
break;
|
||||
|
||||
case uefi::memory_type::loader_data:
|
||||
type = mem_type::pending;
|
||||
break;
|
||||
|
||||
case uefi::memory_type::runtime_services_code:
|
||||
case uefi::memory_type::runtime_services_data:
|
||||
type = mem_type::uefi_runtime;
|
||||
break;
|
||||
|
||||
case uefi::memory_type::acpi_reclaim_memory:
|
||||
type = mem_type::acpi;
|
||||
break;
|
||||
|
||||
case uefi::memory_type::memory_mapped_io:
|
||||
case uefi::memory_type::memory_mapped_io_port_space:
|
||||
type = mem_type::mmio;
|
||||
break;
|
||||
|
||||
case uefi::memory_type::persistent_memory:
|
||||
type = mem_type::persistent;
|
||||
break;
|
||||
|
||||
default:
|
||||
error::raise(
|
||||
uefi::status::invalid_parameter,
|
||||
L"Got an unexpected memory type from UEFI memory map");
|
||||
}
|
||||
|
||||
// TODO: validate uefi's map is sorted
|
||||
if (first) {
|
||||
first = false;
|
||||
kernel_map[i].start = desc->physical_start;
|
||||
kernel_map[i].pages = desc->number_of_pages;
|
||||
kernel_map[i].type = type;
|
||||
kernel_map[i].attr = (desc->attribute & 0xffffffff);
|
||||
continue;
|
||||
}
|
||||
|
||||
mem_entry &prev = kernel_map[i];
|
||||
if (can_merge(prev, type, desc)) {
|
||||
prev.pages += desc->number_of_pages;
|
||||
} else {
|
||||
mem_entry &next = kernel_map[++i];
|
||||
next.start = desc->physical_start;
|
||||
next.pages = desc->number_of_pages;
|
||||
next.type = type;
|
||||
next.attr = (desc->attribute & 0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
// Give just the actually-set entries in the header
|
||||
args->mem_map = kernel_map;
|
||||
args->map_count = i;
|
||||
|
||||
/*
|
||||
// kernel map dump
|
||||
for (unsigned i = 0; i < args->map_count; ++i) {
|
||||
const kernel::args::mem_entry &e = kernel_map[i];
|
||||
console::print(L" Range %lx (%lx) %x(%s) [%lu]\r\n",
|
||||
e.start, e.attr, e.type, kernel_memory_type_name(e.type), e.pages);
|
||||
}
|
||||
*/
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
void
|
||||
virtualize(void *pml4, efi_mem_map &map, uefi::runtime_services *rs)
|
||||
{
|
||||
paging::add_current_mappings(reinterpret_cast<paging::page_table*>(pml4));
|
||||
|
||||
for (auto desc : map)
|
||||
desc->virtual_start = desc->physical_start + ::memory::page_offset;
|
||||
|
||||
// Write our new PML4 pointer to CR3
|
||||
asm volatile ( "mov %0, %%cr3" :: "r" (pml4) );
|
||||
__sync_synchronize();
|
||||
|
||||
try_or_raise(
|
||||
rs->set_virtual_address_map(
|
||||
map.length, map.size, map.version, map.entries),
|
||||
L"Error setting virtual address map");
|
||||
}
|
||||
|
||||
|
||||
} // namespace boot
|
||||
} // namespace memory
|
||||
@@ -1,19 +1,75 @@
|
||||
/// \file memory.h
|
||||
/// Memory-related constants and functions.
|
||||
#pragma once
|
||||
#include <efi/efi.h>
|
||||
#include <uefi/boot_services.h>
|
||||
#include <uefi/runtime_services.h>
|
||||
#include <stdint.h>
|
||||
#include "kernel_args.h"
|
||||
#include "pointer_manipulation.h"
|
||||
|
||||
struct memory_map {
|
||||
size_t length;
|
||||
size_t size;
|
||||
size_t key;
|
||||
uint32_t version;
|
||||
EFI_MEMORY_DESCRIPTOR *entries;
|
||||
namespace boot {
|
||||
namespace memory {
|
||||
|
||||
/// UEFI specifies that pages are always 4 KiB.
|
||||
constexpr size_t page_size = 0x1000;
|
||||
|
||||
/// Get the number of pages needed to hold `bytes` bytes
|
||||
inline constexpr size_t bytes_to_pages(size_t bytes) {
|
||||
return ((bytes - 1) / page_size) + 1;
|
||||
}
|
||||
|
||||
/// \defgroup pointer_fixup
|
||||
/// Memory virtualization pointer fixup functions. Handles changing affected pointers
|
||||
/// when calling UEFI's `set_virtual_address_map` function to change the location of
|
||||
/// runtime services in virtual memory.
|
||||
/// @{
|
||||
|
||||
/// Set up the pointer fixup UEFI events. This registers the necessary callbacks for
|
||||
/// runtime services to call when `set_virtual_address_map` is called.
|
||||
void init_pointer_fixup(uefi::boot_services *bs, uefi::runtime_services *rs);
|
||||
|
||||
/// Mark a given pointer as needing to be updated when doing pointer fixup.
|
||||
void mark_pointer_fixup(void **p);
|
||||
|
||||
/// @}
|
||||
|
||||
/// Struct that represents UEFI's memory map. Contains a pointer to the map data
|
||||
/// as well as the data on how to read it.
|
||||
struct efi_mem_map
|
||||
{
|
||||
using desc = uefi::memory_descriptor;
|
||||
using iterator = offset_iterator<desc>;
|
||||
|
||||
size_t length; ///< Total length of the map data
|
||||
size_t size; ///< Size of an entry in the array
|
||||
size_t key; ///< Key for detecting changes
|
||||
uint32_t version; ///< Version of the `memory_descriptor` struct
|
||||
desc *entries; ///< The array of UEFI descriptors
|
||||
|
||||
efi_mem_map() : length(0), size(0), key(0), version(0), entries(nullptr) {}
|
||||
|
||||
/// Get the count of entries in the array
|
||||
inline size_t num_entries() const { return length / size; }
|
||||
|
||||
/// Return an iterator to the beginning of the array
|
||||
iterator begin() { return iterator(entries, size); }
|
||||
|
||||
/// Return an iterator to the end of the array
|
||||
iterator end() { return offset_ptr<desc>(entries, length); }
|
||||
};
|
||||
|
||||
EFI_STATUS memory_init_pointer_fixup(EFI_BOOT_SERVICES *bootsvc, EFI_RUNTIME_SERVICES *runsvc);
|
||||
void memory_mark_pointer_fixup(void **p);
|
||||
/// Add the kernel's memory map as a module to the kernel args.
|
||||
/// \returns The uefi memory map used to build the kernel map
|
||||
efi_mem_map build_kernel_mem_map(kernel::args::header *args, uefi::boot_services *bs);
|
||||
|
||||
EFI_STATUS memory_get_map_length(EFI_BOOT_SERVICES *bootsvc, size_t *size);
|
||||
EFI_STATUS memory_get_map(EFI_BOOT_SERVICES *bootsvc, struct memory_map *map);
|
||||
EFI_STATUS memory_dump_map(struct memory_map *map);
|
||||
/// Activate the given memory mappings. Sets the given page tables live as well
|
||||
/// as informs UEFI runtime services of the new mappings.
|
||||
/// \arg pml4 The root page table for the new mappings
|
||||
/// \arg map The UEFI memory map, used to update runtime services
|
||||
void virtualize(
|
||||
void *pml4,
|
||||
efi_mem_map &map,
|
||||
uefi::runtime_services *rs);
|
||||
|
||||
void memory_virtualize(EFI_RUNTIME_SERVICES *runsvc, struct memory_map *map);
|
||||
} // namespace boot
|
||||
} // namespace memory
|
||||
|
||||
253
src/boot/paging.cpp
Normal file
253
src/boot/paging.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
#include "kernel_memory.h"
|
||||
|
||||
#include "console.h"
|
||||
#include "error.h"
|
||||
#include "loader.h"
|
||||
#include "memory.h"
|
||||
#include "paging.h"
|
||||
#include "pointer_manipulation.h"
|
||||
#include "status.h"
|
||||
|
||||
namespace boot {
|
||||
namespace paging {
|
||||
|
||||
using memory::page_size;
|
||||
using ::memory::pml4e_kernel;
|
||||
using ::memory::table_entries;
|
||||
|
||||
// Flags: 0 0 0 1 0 0 0 0 0 0 1 1 = 0x0103
|
||||
// IGN | | | | | | | | +- Present
|
||||
// | | | | | | | +--- Writeable
|
||||
// | | | | | | +----- Usermode access (supervisor only)
|
||||
// | | | | | +------- PWT (determining memory type for page)
|
||||
// | | | | +---------- PCD (determining memory type for page)
|
||||
// | | | +------------ Accessed flag (not accessed yet)
|
||||
// | | +-------------- Dirty (not dirtied yet)
|
||||
// | +---------------- PAT (determining memory type for page)
|
||||
// +------------------- Global
|
||||
/// Page table entry flags for entries pointing at a page
|
||||
constexpr uint16_t page_flags = 0x103;
|
||||
|
||||
// Flags: 0 0 0 0 1 1 0 0 0 1 0 1 1 = 0x018b
|
||||
// | IGN | | | | | | | | +- Present
|
||||
// | | | | | | | | +--- Writeable
|
||||
// | | | | | | | +----- Supervisor only
|
||||
// | | | | | | +------- PWT (determining memory type for page)
|
||||
// | | | | | +---------- PCD (determining memory type for page)
|
||||
// | | | | +------------ Accessed flag (not accessed yet)
|
||||
// | | | +-------------- Dirty (not dirtied yet)
|
||||
// | | +---------------- Page size (1GiB page)
|
||||
// | +------------------- Global
|
||||
// +---------------------------- PAT (determining memory type for page)
|
||||
/// Page table entry flags for entries pointing at a huge page
|
||||
constexpr uint16_t huge_page_flags = 0x183;
|
||||
|
||||
// Flags: 0 0 0 0 0 0 0 0 0 0 1 1 = 0x0003
|
||||
// IGNORED | | | | | | | +- Present
|
||||
// | | | | | | +--- Writeable
|
||||
// | | | | | +----- Usermode access (Supervisor only)
|
||||
// | | | | +------- PWT (determining memory type for pdpt)
|
||||
// | | | +---------- PCD (determining memory type for pdpt)
|
||||
// | | +------------ Accessed flag (not accessed yet)
|
||||
// | +-------------- Ignored
|
||||
// +---------------- Reserved 0 (Table pointer, not page)
|
||||
/// Page table entry flags for entries pointing at another table
|
||||
constexpr uint16_t table_flags = 0x003;
|
||||
|
||||
/// Iterator over page table entries.
|
||||
template <unsigned D = 4>
|
||||
class page_entry_iterator
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
/// \arg virt Virtual address this iterator is starting at
|
||||
/// \arg pml4 Root of the page tables to iterate
|
||||
/// \arg page_cache Pointer to pages that can be used for page tables
|
||||
/// \arg page_count Number of pages pointed to by `page_cache`
|
||||
page_entry_iterator(
|
||||
uintptr_t virt,
|
||||
page_table *pml4,
|
||||
void *&page_cache,
|
||||
size_t &cache_count) :
|
||||
m_page_cache(page_cache),
|
||||
m_cache_count(cache_count)
|
||||
{
|
||||
m_table[0] = pml4;
|
||||
for (unsigned i = 0; i < D; ++i) {
|
||||
m_index[i] = static_cast<uint16_t>((virt >> (12 + 9*(3-i))) & 0x1ff);
|
||||
ensure_table(i);
|
||||
}
|
||||
}
|
||||
|
||||
uintptr_t vaddress() const {
|
||||
uintptr_t address = 0;
|
||||
for (unsigned i = 0; i < D; ++i)
|
||||
address |= static_cast<uintptr_t>(m_index[i]) << (12 + 9*(3-i));
|
||||
if (address & (1ull<<47)) // canonicalize the address
|
||||
address |= (0xffffull<<48);
|
||||
return address;
|
||||
}
|
||||
|
||||
void increment()
|
||||
{
|
||||
for (unsigned i = D - 1; i >= 0; --i) {
|
||||
if (++m_index[i] <= 511) {
|
||||
for (unsigned j = i + 1; j < D; ++j)
|
||||
ensure_table(j);
|
||||
return;
|
||||
}
|
||||
|
||||
m_index[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t & operator*() { return entry(D-1); }
|
||||
|
||||
private:
|
||||
inline uint64_t & entry(unsigned level) { return m_table[level]->entries[m_index[level]]; }
|
||||
|
||||
void ensure_table(unsigned level)
|
||||
{
|
||||
// We're only dealing with D levels of paging, and
|
||||
// there must always be a PML4.
|
||||
if (level < 1 || level >= D)
|
||||
return;
|
||||
|
||||
// Entry in the parent that points to the table we want
|
||||
uint64_t & parent_ent = entry(level - 1);
|
||||
|
||||
if (!(parent_ent & 1)) {
|
||||
if (!m_cache_count--)
|
||||
error::raise(uefi::status::out_of_resources, L"Page table cache empty");
|
||||
|
||||
page_table *table = reinterpret_cast<page_table*>(m_page_cache);
|
||||
m_page_cache = offset_ptr<void>(m_page_cache, page_size);
|
||||
|
||||
parent_ent = (reinterpret_cast<uintptr_t>(table) & ~0xfffull) | table_flags;
|
||||
m_table[level] = table;
|
||||
} else {
|
||||
m_table[level] = reinterpret_cast<page_table*>(parent_ent & ~0xfffull);
|
||||
}
|
||||
}
|
||||
|
||||
void *&m_page_cache;
|
||||
size_t &m_cache_count;
|
||||
page_table *m_table[D];
|
||||
uint16_t m_index[D];
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
add_offset_mappings(page_table *pml4, void *&page_cache, size_t &num_pages)
|
||||
{
|
||||
uintptr_t phys = 0;
|
||||
uintptr_t virt = ::memory::page_offset; // Start of offset-mapped area
|
||||
size_t pages = 64 * 1024; // 64 TiB of 1 GiB pages
|
||||
constexpr size_t GiB = 0x40000000ull;
|
||||
|
||||
page_entry_iterator<2> iterator{
|
||||
virt, pml4,
|
||||
page_cache,
|
||||
num_pages};
|
||||
|
||||
while (true) {
|
||||
*iterator = phys | huge_page_flags;
|
||||
if (--pages == 0)
|
||||
break;
|
||||
|
||||
iterator.increment();
|
||||
phys += GiB;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_kernel_pds(page_table *pml4, void *&page_cache, size_t &num_pages)
|
||||
{
|
||||
for (unsigned i = pml4e_kernel; i < table_entries; ++i) {
|
||||
pml4->set(i, page_cache, table_flags);
|
||||
page_cache = offset_ptr<void>(page_cache, page_size);
|
||||
num_pages--;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
add_current_mappings(page_table *new_pml4)
|
||||
{
|
||||
// Get the pointer to the current PML4
|
||||
page_table *old_pml4 = 0;
|
||||
asm volatile ( "mov %%cr3, %0" : "=r" (old_pml4) );
|
||||
|
||||
// Only copy mappings in the lower half
|
||||
for (int i = 0; i < ::memory::pml4e_kernel; ++i) {
|
||||
uint64_t entry = old_pml4->entries[i];
|
||||
if (entry & 1)
|
||||
new_pml4->entries[i] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
allocate_tables(kernel::args::header *args, uefi::boot_services *bs)
|
||||
{
|
||||
status_line status(L"Allocating initial page tables");
|
||||
|
||||
static constexpr size_t pd_tables = 256; // number of pages for kernelspace PDs
|
||||
static constexpr size_t extra_tables = 49; // number of extra pages
|
||||
|
||||
// number of pages for kernelspace PDs + PML4
|
||||
static constexpr size_t kernel_tables = pd_tables + 1;
|
||||
|
||||
static constexpr size_t tables_needed = kernel_tables + extra_tables;
|
||||
|
||||
void *addr = nullptr;
|
||||
try_or_raise(
|
||||
bs->allocate_pages(
|
||||
uefi::allocate_type::any_pages,
|
||||
uefi::memory_type::loader_data,
|
||||
tables_needed,
|
||||
&addr),
|
||||
L"Error allocating page table pages.");
|
||||
|
||||
bs->set_mem(addr, tables_needed*page_size, 0);
|
||||
|
||||
page_table *pml4 = reinterpret_cast<page_table*>(addr);
|
||||
|
||||
args->pml4 = pml4;
|
||||
args->table_count = tables_needed - 1;
|
||||
args->page_tables = offset_ptr<void>(addr, page_size);
|
||||
|
||||
console::print(L" First page (pml4) at: 0x%lx\r\n", pml4);
|
||||
|
||||
add_kernel_pds(pml4, args->page_tables, args->table_count);
|
||||
add_offset_mappings(pml4, args->page_tables, args->table_count);
|
||||
|
||||
console::print(L" Set up initial mappings, %d spare tables.\r\n", args->table_count);
|
||||
}
|
||||
|
||||
void
|
||||
map_pages(
|
||||
kernel::args::header *args,
|
||||
uintptr_t phys, uintptr_t virt,
|
||||
size_t size)
|
||||
{
|
||||
paging::page_table *pml4 =
|
||||
reinterpret_cast<paging::page_table*>(args->pml4);
|
||||
|
||||
size_t pages = memory::bytes_to_pages(size);
|
||||
page_entry_iterator<4> iterator{
|
||||
virt, pml4,
|
||||
args->page_tables,
|
||||
args->table_count};
|
||||
|
||||
while (true) {
|
||||
*iterator = phys | page_flags;
|
||||
if (--pages == 0)
|
||||
break;
|
||||
|
||||
iterator.increment();
|
||||
phys += page_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace paging
|
||||
} // namespace boot
|
||||
52
src/boot/paging.h
Normal file
52
src/boot/paging.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
/// \file paging.h
|
||||
/// Page table structure and related definitions
|
||||
#include <stdint.h>
|
||||
#include <uefi/boot_services.h>
|
||||
#include "kernel_args.h"
|
||||
|
||||
namespace boot {
|
||||
namespace paging {
|
||||
|
||||
/// Struct to allow easy accessing of a memory page being used as a page table.
|
||||
struct page_table
|
||||
{
|
||||
uint64_t entries[512];
|
||||
|
||||
inline page_table * get(int i, uint16_t *flags = nullptr) const {
|
||||
uint64_t entry = entries[i];
|
||||
if ((entry & 1) == 0) return nullptr;
|
||||
if (flags) *flags = entry & 0xfff;
|
||||
return reinterpret_cast<page_table *>(entry & ~0xfffull);
|
||||
}
|
||||
|
||||
inline void set(int i, void *p, uint16_t flags) {
|
||||
entries[i] = reinterpret_cast<uint64_t>(p) | (flags & 0xfff);
|
||||
}
|
||||
};
|
||||
|
||||
/// Allocate memory to be used for initial page tables. Initial offset-mapped
|
||||
/// page tables are pre-filled. All pages are saved as a module in kernel args
|
||||
/// and kernel args' `page_table_cache` and `num_free_tables` are updated with
|
||||
/// the leftover space.
|
||||
void allocate_tables(
|
||||
kernel::args::header *args,
|
||||
uefi::boot_services *bs);
|
||||
|
||||
/// Copy existing page table entries to a new page table. Does not do a deep
|
||||
/// copy - the new PML4 is updated to point to the existing next-level page
|
||||
/// tables in the current PML4.
|
||||
void add_current_mappings(page_table *new_pml4);
|
||||
|
||||
/// Map a physical address to a virtual address in the given page tables.
|
||||
/// \arg args The kernel args header, used for the page table cache and pml4
|
||||
/// \arg phys The phyiscal address to map in
|
||||
/// \arg virt The virtual address to map in
|
||||
/// \arg size The size in bytes of the mapping
|
||||
void map_pages(
|
||||
kernel::args::header *args,
|
||||
uintptr_t phys, uintptr_t virt,
|
||||
size_t bytes);
|
||||
|
||||
} // namespace paging
|
||||
} // namespace boot
|
||||
41
src/boot/pointer_manipulation.h
Normal file
41
src/boot/pointer_manipulation.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/// \file pointer_manipulation.h
|
||||
/// Helper functions and types for doing type-safe byte-wise pointer math.
|
||||
#pragma once
|
||||
|
||||
namespace boot {
|
||||
|
||||
/// Return a pointer offset from `input` by `offset` bytes.
|
||||
/// \tparam T Cast the return value to a pointer to `T`
|
||||
/// \tparam S The type pointed to by the `input` pointer
|
||||
template <typename T, typename S>
|
||||
inline T* offset_ptr(S* input, ptrdiff_t offset) {
|
||||
return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(input) + offset);
|
||||
}
|
||||
|
||||
/// Iterator for an array of `T` whose size is known at runtime
|
||||
/// \tparam T Type of the objects in the array, whose size might not be
|
||||
/// what is returned by sizeof(T).
|
||||
template <typename T>
|
||||
class offset_iterator
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
/// \arg t Pointer to the first item in the array
|
||||
/// \arg off Offset applied to reach successive items. Default is 0,
|
||||
/// which creates an effectively constant iterator.
|
||||
offset_iterator(T* t, size_t off=0) : m_t(t), m_off(off) {}
|
||||
|
||||
T* operator++() { m_t = offset_ptr<T>(m_t, m_off); return m_t; }
|
||||
T* operator++(int) { T* tmp = m_t; operator++(); return tmp; }
|
||||
bool operator==(T* p) { return p == m_t; }
|
||||
|
||||
T* operator*() const { return m_t; }
|
||||
operator T*() const { return m_t; }
|
||||
T* operator->() const { return m_t; }
|
||||
|
||||
private:
|
||||
T* m_t;
|
||||
size_t m_off;
|
||||
};
|
||||
|
||||
} // namespace boot
|
||||
@@ -1,96 +0,0 @@
|
||||
/* reloc_x86_64.c - position independent x86_64 ELF shared object relocator
|
||||
Copyright (C) 1999 Hewlett-Packard Co.
|
||||
Contributed by David Mosberger <davidm@hpl.hp.com>.
|
||||
Copyright (C) 2005 Intel Co.
|
||||
Contributed by Fenghua Yu <fenghua.yu@intel.com>.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
* Neither the name of Hewlett-Packard Co. nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <efi/efi.h>
|
||||
#include <elf.h>
|
||||
|
||||
EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn,
|
||||
EFI_HANDLE image EFI_UNUSED,
|
||||
EFI_SYSTEM_TABLE *systab EFI_UNUSED)
|
||||
{
|
||||
long relsz = 0, relent = 0;
|
||||
Elf64_Rel *rel = 0;
|
||||
unsigned long *addr;
|
||||
int i;
|
||||
|
||||
for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
|
||||
switch (dyn[i].d_tag) {
|
||||
case DT_RELA:
|
||||
rel = (Elf64_Rel*)
|
||||
((unsigned long)dyn[i].d_un.d_ptr
|
||||
+ ldbase);
|
||||
break;
|
||||
|
||||
case DT_RELASZ:
|
||||
relsz = dyn[i].d_un.d_val;
|
||||
break;
|
||||
|
||||
case DT_RELAENT:
|
||||
relent = dyn[i].d_un.d_val;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rel && relent == 0)
|
||||
return EFI_SUCCESS;
|
||||
|
||||
if (!rel || relent == 0)
|
||||
return EFI_LOAD_ERROR;
|
||||
|
||||
while (relsz > 0) {
|
||||
/* apply the relocs */
|
||||
switch (ELF64_R_TYPE (rel->r_info)) {
|
||||
case R_X86_64_NONE:
|
||||
break;
|
||||
|
||||
case R_X86_64_RELATIVE:
|
||||
addr = (unsigned long *)
|
||||
(ldbase + rel->r_offset);
|
||||
*addr += ldbase;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
rel = (Elf64_Rel*) ((char *) rel + relent);
|
||||
relsz -= relent;
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
263
src/boot/status.cpp
Normal file
263
src/boot/status.cpp
Normal file
@@ -0,0 +1,263 @@
|
||||
#include <uefi/types.h>
|
||||
#include <uefi/graphics.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "error.h"
|
||||
#include "kernel_args.h"
|
||||
#include "status.h"
|
||||
|
||||
constexpr int num_boxes = 30;
|
||||
|
||||
namespace boot {
|
||||
|
||||
static constexpr int level_ok = 0;
|
||||
static constexpr int level_warn = 1;
|
||||
static constexpr int level_fail = 2;
|
||||
|
||||
static const wchar_t *level_tags[] = {
|
||||
L" ok ",
|
||||
L" warn ",
|
||||
L"failed"
|
||||
};
|
||||
|
||||
static const uefi::attribute level_colors[] = {
|
||||
uefi::attribute::green,
|
||||
uefi::attribute::brown,
|
||||
uefi::attribute::light_red
|
||||
};
|
||||
|
||||
status *status::s_current = nullptr;
|
||||
unsigned status::s_current_type = 0;
|
||||
unsigned status_bar::s_count = 0;
|
||||
|
||||
status_line::status_line(const wchar_t *message, const wchar_t *context) :
|
||||
m_level(level_ok),
|
||||
m_depth(0),
|
||||
m_outer(nullptr)
|
||||
{
|
||||
if (status::s_current_type == status_line::type) {
|
||||
m_outer = static_cast<status_line*>(s_current);
|
||||
m_depth = (m_outer ? 1 + m_outer->m_depth : 0);
|
||||
}
|
||||
s_current = this;
|
||||
s_current_type = status_line::type;
|
||||
|
||||
auto out = console::get().m_out;
|
||||
m_line = out->mode->cursor_row;
|
||||
|
||||
int indent = 2 * m_depth;
|
||||
out->set_cursor_position(indent, m_line);
|
||||
out->set_attribute(uefi::attribute::light_gray);
|
||||
out->output_string(message);
|
||||
|
||||
if (context) {
|
||||
out->output_string(L": ");
|
||||
out->output_string(context);
|
||||
}
|
||||
|
||||
out->output_string(L"\r\n");
|
||||
print_status_tag();
|
||||
}
|
||||
|
||||
status_line::~status_line()
|
||||
{
|
||||
if (s_current != this)
|
||||
error::raise(uefi::status::unsupported, L"Destroying non-current status_line");
|
||||
|
||||
if (m_outer && m_level > m_outer->m_level) {
|
||||
m_outer->m_level = m_level;
|
||||
m_outer->print_status_tag();
|
||||
}
|
||||
s_current = m_outer;
|
||||
}
|
||||
|
||||
void
|
||||
status_line::print_status_tag()
|
||||
{
|
||||
auto out = console::get().m_out;
|
||||
int row = out->mode->cursor_row;
|
||||
int col = out->mode->cursor_column;
|
||||
|
||||
uefi::attribute color = level_colors[m_level];
|
||||
const wchar_t *tag = level_tags[m_level];
|
||||
|
||||
out->set_cursor_position(50, m_line);
|
||||
|
||||
out->set_attribute(uefi::attribute::light_gray);
|
||||
out->output_string(L"[");
|
||||
out->set_attribute(color);
|
||||
out->output_string(tag);
|
||||
out->set_attribute(uefi::attribute::light_gray);
|
||||
out->output_string(L"]\r\n");
|
||||
|
||||
out->set_cursor_position(col, row);
|
||||
}
|
||||
|
||||
void
|
||||
status_line::do_warn(const wchar_t *message, uefi::status status)
|
||||
{
|
||||
auto out = console::get().m_out;
|
||||
int row = out->mode->cursor_row;
|
||||
|
||||
if (m_level < level_warn) {
|
||||
m_level = level_warn;
|
||||
print_status_tag();
|
||||
}
|
||||
|
||||
int indent = 2 + 2 * m_depth;
|
||||
out->set_cursor_position(indent, row);
|
||||
out->set_attribute(uefi::attribute::yellow);
|
||||
out->output_string(message);
|
||||
|
||||
const wchar_t *error = error::message(status);
|
||||
if (error) {
|
||||
out->output_string(L": ");
|
||||
out->output_string(error);
|
||||
}
|
||||
|
||||
out->set_attribute(uefi::attribute::light_gray);
|
||||
out->output_string(L"\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
status_line::do_fail(const wchar_t *message, uefi::status status)
|
||||
{
|
||||
auto out = console::get().m_out;
|
||||
int row = out->mode->cursor_row;
|
||||
|
||||
if (m_level < level_fail) {
|
||||
m_level = level_fail;
|
||||
print_status_tag();
|
||||
}
|
||||
|
||||
int indent = 2 + 2 * m_depth;
|
||||
out->set_cursor_position(indent, row);
|
||||
out->set_attribute(uefi::attribute::red);
|
||||
out->output_string(message);
|
||||
|
||||
const wchar_t *error = error::message(status);
|
||||
if (error) {
|
||||
out->output_string(L": ");
|
||||
out->output_string(error);
|
||||
}
|
||||
|
||||
out->set_attribute(uefi::attribute::light_gray);
|
||||
out->output_string(L"\r\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
status_bar::status_bar(kernel::args::framebuffer const &fb) :
|
||||
m_outer(nullptr)
|
||||
{
|
||||
m_size = (fb.vertical / num_boxes) - 1;
|
||||
m_top = fb.vertical - m_size;
|
||||
m_horiz = fb.horizontal;
|
||||
m_fb = reinterpret_cast<uint32_t*>(fb.phys_addr);
|
||||
m_type = static_cast<uint16_t>(fb.type);
|
||||
next();
|
||||
|
||||
if (status::s_current_type == status_bar::type)
|
||||
m_outer = static_cast<status_bar*>(s_current);
|
||||
s_current = this;
|
||||
s_current_type = status_bar::type;
|
||||
}
|
||||
|
||||
status_bar::~status_bar()
|
||||
{
|
||||
if (s_current != this)
|
||||
error::raise(uefi::status::unsupported, L"Destroying non-current status_bar");
|
||||
draw_box();
|
||||
s_current = m_outer;
|
||||
}
|
||||
|
||||
void
|
||||
status_bar::do_warn(const wchar_t *message, uefi::status status)
|
||||
{
|
||||
m_status = status;
|
||||
if (m_level < level_warn) {
|
||||
m_level = level_warn;
|
||||
draw_box();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
status_bar::do_fail(const wchar_t *message, uefi::status status)
|
||||
{
|
||||
m_status = status;
|
||||
if (m_level < level_fail) {
|
||||
m_level = level_fail;
|
||||
draw_box();
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
make_color(uint8_t r, uint8_t g, uint8_t b, uint16_t type)
|
||||
{
|
||||
switch (static_cast<kernel::args::fb_type>(type)) {
|
||||
case kernel::args::fb_type::bgr8:
|
||||
return
|
||||
(static_cast<uint32_t>(b) << 0) |
|
||||
(static_cast<uint32_t>(g) << 8) |
|
||||
(static_cast<uint32_t>(r) << 16);
|
||||
|
||||
case kernel::args::fb_type::rgb8:
|
||||
return
|
||||
(static_cast<uint32_t>(r) << 0) |
|
||||
(static_cast<uint32_t>(g) << 8) |
|
||||
(static_cast<uint32_t>(b) << 16);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
status_bar::draw_box()
|
||||
{
|
||||
static const uint32_t colors[] = {0x909090, 0xf0f0f0};
|
||||
constexpr unsigned ncolors = sizeof(colors) / sizeof(uint32_t);
|
||||
|
||||
if (m_fb == nullptr)
|
||||
return;
|
||||
|
||||
unsigned x0 = m_current * m_size;
|
||||
unsigned x1 = x0 + m_size - 3;
|
||||
unsigned y0 = m_top;
|
||||
unsigned y1 = m_top + m_size - 3;
|
||||
|
||||
uint32_t color = 0;
|
||||
switch (m_level) {
|
||||
case level_ok:
|
||||
color = colors[m_current % ncolors];
|
||||
break;
|
||||
case level_warn:
|
||||
color = make_color(0xff, 0xb2, 0x34, m_type);
|
||||
break;
|
||||
case level_fail:
|
||||
color = make_color(0xfb, 0x0a, 0x1e, m_type);
|
||||
break;
|
||||
default:
|
||||
color = 0;
|
||||
}
|
||||
|
||||
for (unsigned y = y0; y < y1; ++y)
|
||||
for (unsigned x = x0; x < x1; ++x)
|
||||
m_fb[y * m_horiz + x] = color;
|
||||
|
||||
if (m_level > level_ok) {
|
||||
unsigned nbars = static_cast<uint64_t>(m_status) & 0xffff;
|
||||
constexpr unsigned bar_height = 4;
|
||||
|
||||
for (unsigned i = 1; i <= nbars; ++i) {
|
||||
y0 = m_top - 2 * i * bar_height;
|
||||
y1 = y0 + bar_height;
|
||||
|
||||
for (unsigned y = y0; y < y1; ++y)
|
||||
for (unsigned x = x0; x < x1; ++x)
|
||||
m_fb[y * m_horiz + x] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace boot
|
||||
122
src/boot/status.h
Normal file
122
src/boot/status.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/// \file status.h
|
||||
/// Status message and indicator handling
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
namespace kernel {
|
||||
namespace args {
|
||||
class framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
namespace boot {
|
||||
|
||||
// Abstract base class for status reporters.
|
||||
class status
|
||||
{
|
||||
public:
|
||||
virtual void do_warn(const wchar_t *message, uefi::status status) = 0;
|
||||
virtual void do_fail(const wchar_t *message, uefi::status status) = 0;
|
||||
|
||||
/// Set the state to warning, and print a message. If the state is already at
|
||||
/// warning or error, the state is unchanged but the message is still printed.
|
||||
/// \arg message The warning message to print, if text is supported
|
||||
/// \arg status If set, the error or warning code that should be represented
|
||||
/// \returns True if there was a status handler to display the warning
|
||||
inline static bool warn(const wchar_t *message, uefi::status status = uefi::status::success) {
|
||||
if (!s_current) return false;
|
||||
s_current->do_warn(message, status);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Set the state to error, and print a message. If the state is already at
|
||||
/// error, the state is unchanged but the message is still printed.
|
||||
/// \arg message The error message to print, if text is supported
|
||||
/// \arg status The error or warning code that should be represented
|
||||
/// \returns True if there was a status handler to display the failure
|
||||
inline static bool fail(const wchar_t *message, uefi::status status) {
|
||||
if (!s_current) return false;
|
||||
s_current->do_fail(message, status);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
static status *s_current;
|
||||
static unsigned s_current_type;
|
||||
};
|
||||
|
||||
/// Scoped status line reporter. Prints a message and an "OK" if no errors
|
||||
/// or warnings were reported before destruction, otherwise reports the
|
||||
/// error or warning.
|
||||
class status_line :
|
||||
public status
|
||||
{
|
||||
public:
|
||||
constexpr static unsigned type = 1;
|
||||
|
||||
/// Constructor.
|
||||
/// \arg message Description of the operation in progress
|
||||
/// \arg context If non-null, printed after `message` and a colon
|
||||
status_line(const wchar_t *message, const wchar_t *context = nullptr);
|
||||
~status_line();
|
||||
|
||||
virtual void do_warn(const wchar_t *message, uefi::status status) override;
|
||||
virtual void do_fail(const wchar_t *message, uefi::status status) override;
|
||||
|
||||
private:
|
||||
void print_status_tag();
|
||||
|
||||
size_t m_line;
|
||||
int m_level;
|
||||
int m_depth;
|
||||
|
||||
status_line *m_outer;
|
||||
};
|
||||
|
||||
/// Scoped status bar reporter. Draws a row of boxes along the bottom of
|
||||
/// the screen, turning one red if there's an error in that step.
|
||||
class status_bar :
|
||||
public status
|
||||
{
|
||||
public:
|
||||
constexpr static unsigned type = 2;
|
||||
|
||||
using framebuffer = kernel::args::framebuffer;
|
||||
|
||||
/// Constructor.
|
||||
/// \arg fb The framebuffer descriptor to draw to
|
||||
status_bar(kernel::args::framebuffer const &fb);
|
||||
~status_bar();
|
||||
|
||||
virtual void do_warn(const wchar_t *message, uefi::status status) override;
|
||||
virtual void do_fail(const wchar_t *message, uefi::status status) override;
|
||||
|
||||
inline void next() {
|
||||
m_current = s_count++;
|
||||
m_level = 0;
|
||||
m_status = uefi::status::success;
|
||||
draw_box();
|
||||
}
|
||||
|
||||
private:
|
||||
void draw_box();
|
||||
|
||||
uint32_t *m_fb;
|
||||
uint32_t m_size;
|
||||
uint32_t m_top;
|
||||
uint32_t m_horiz;
|
||||
|
||||
int m_level;
|
||||
uefi::status m_status;
|
||||
|
||||
uint16_t m_type;
|
||||
uint16_t m_current;
|
||||
|
||||
status_bar *m_outer;
|
||||
|
||||
static unsigned s_count;
|
||||
};
|
||||
|
||||
} // namespace boot
|
||||
39
src/boot/support.cpp
Normal file
39
src/boot/support.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "error.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
/// Basic memcpy() implementation for clang. Clang requires freestanding code
|
||||
/// implement memcpy(), as it may emit references to it. This basic memcpy is
|
||||
/// not the most efficient, but will get linked if no other memcpy exists.
|
||||
__attribute__ ((__weak__))
|
||||
void *memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
uint8_t *cdest = reinterpret_cast<uint8_t*>(dest);
|
||||
const uint8_t *csrc = reinterpret_cast<const uint8_t*>(src);
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
cdest[i] = csrc[i];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/// Basic memset() implementation for clang. Clang requires freestanding code
|
||||
/// implement memset(), as it may emit references to it. This basic memset is
|
||||
/// not the most efficient, but will get linked if no other memcpy exists.
|
||||
__attribute__ ((__weak__))
|
||||
void *memset(void *dest, int c, size_t n)
|
||||
{
|
||||
uint8_t *cdest = reinterpret_cast<uint8_t*>(dest);
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
cdest[i] = static_cast<uint8_t>(c);
|
||||
return dest;
|
||||
}
|
||||
|
||||
int _purecall()
|
||||
{
|
||||
::boot::error::raise(uefi::status::unsupported, L"Pure virtual call");
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
void operator delete (void *) {}
|
||||
13
src/boot/types.h
Normal file
13
src/boot/types.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/// \file types.h
|
||||
/// Definitions of shared types used throughout the bootloader
|
||||
#pragma once
|
||||
|
||||
namespace boot {
|
||||
|
||||
struct buffer
|
||||
{
|
||||
size_t size;
|
||||
void *data;
|
||||
};
|
||||
|
||||
} // namespace boot
|
||||
@@ -1,71 +0,0 @@
|
||||
#include "utility.h"
|
||||
|
||||
struct error_code_desc {
|
||||
EFI_STATUS code;
|
||||
CHAR16 *name;
|
||||
};
|
||||
|
||||
// Based off the gnu-efi table
|
||||
struct error_code_desc error_table[] = {
|
||||
{ EFI_SUCCESS, L"Success" },
|
||||
{ EFI_LOAD_ERROR, L"Load Error" },
|
||||
{ EFI_INVALID_PARAMETER, L"Invalid Parameter" },
|
||||
{ EFI_UNSUPPORTED, L"Unsupported" },
|
||||
{ EFI_BAD_BUFFER_SIZE, L"Bad Buffer Size" },
|
||||
{ EFI_BUFFER_TOO_SMALL, L"Buffer Too Small" },
|
||||
{ EFI_NOT_READY, L"Not Ready" },
|
||||
{ EFI_DEVICE_ERROR, L"Device Error" },
|
||||
{ EFI_WRITE_PROTECTED, L"Write Protected" },
|
||||
{ EFI_OUT_OF_RESOURCES, L"Out of Resources" },
|
||||
{ EFI_VOLUME_CORRUPTED, L"Volume Corrupt" },
|
||||
{ EFI_VOLUME_FULL, L"Volume Full" },
|
||||
{ EFI_NO_MEDIA, L"No Media" },
|
||||
{ EFI_MEDIA_CHANGED, L"Media changed" },
|
||||
{ EFI_NOT_FOUND, L"Not Found" },
|
||||
{ EFI_ACCESS_DENIED, L"Access Denied" },
|
||||
{ EFI_NO_RESPONSE, L"No Response" },
|
||||
{ EFI_NO_MAPPING, L"No mapping" },
|
||||
{ EFI_TIMEOUT, L"Time out" },
|
||||
{ EFI_NOT_STARTED, L"Not started" },
|
||||
{ EFI_ALREADY_STARTED, L"Already started" },
|
||||
{ EFI_ABORTED, L"Aborted" },
|
||||
{ EFI_ICMP_ERROR, L"ICMP Error" },
|
||||
{ EFI_TFTP_ERROR, L"TFTP Error" },
|
||||
{ EFI_PROTOCOL_ERROR, L"Protocol Error" },
|
||||
{ EFI_INCOMPATIBLE_VERSION, L"Incompatible Version" },
|
||||
{ EFI_SECURITY_VIOLATION, L"Security Policy Violation" },
|
||||
{ EFI_CRC_ERROR, L"CRC Error" },
|
||||
{ EFI_END_OF_MEDIA, L"End of Media" },
|
||||
{ EFI_END_OF_FILE, L"End of File" },
|
||||
{ EFI_INVALID_LANGUAGE, L"Invalid Languages" },
|
||||
{ EFI_COMPROMISED_DATA, L"Compromised Data" },
|
||||
|
||||
{ EFI_WARN_UNKOWN_GLYPH, L"Warning Unknown Glyph" },
|
||||
{ EFI_WARN_DELETE_FAILURE, L"Warning Delete Failure" },
|
||||
{ EFI_WARN_WRITE_FAILURE, L"Warning Write Failure" },
|
||||
{ EFI_WARN_BUFFER_TOO_SMALL, L"Warning Buffer Too Small" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const CHAR16 *
|
||||
util_error_message(EFI_STATUS status)
|
||||
{
|
||||
int32_t i = -1;
|
||||
while (error_table[++i].name != NULL) {
|
||||
if (error_table[i].code == status) return error_table[i].name;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(status))
|
||||
return L"Unknown Error";
|
||||
else
|
||||
return L"Unknown Warning";
|
||||
}
|
||||
|
||||
size_t
|
||||
wstrlen(const CHAR16 *s)
|
||||
{
|
||||
size_t count = 0;
|
||||
while (s && *s++) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#include <stddef.h>
|
||||
#include <efi/efi.h>
|
||||
|
||||
#include "console.h"
|
||||
|
||||
#define UNUSED __attribute__((unused))
|
||||
|
||||
size_t wstrlen(const CHAR16 *s);
|
||||
const CHAR16 *util_error_message(EFI_STATUS status);
|
||||
|
||||
#define CHECK_EFI_STATUS_OR_RETURN(s, msg, ...) \
|
||||
if (EFI_ERROR((s))) { \
|
||||
con_printf(L"ERROR: " msg L": %s\r\n", ##__VA_ARGS__, util_error_message(s)); \
|
||||
return (s); \
|
||||
}
|
||||
|
||||
#define CHECK_EFI_STATUS_OR_FAIL(s) \
|
||||
if (EFI_ERROR((s))) { \
|
||||
con_status_fail(util_error_message(s)); \
|
||||
while (1) __asm__("hlt"); \
|
||||
}
|
||||
|
||||
#define CHECK_EFI_STATUS_OR_ASSERT(s, d) \
|
||||
if (EFI_ERROR((s))) { \
|
||||
__asm__ __volatile__( \
|
||||
"movq %0, %%r8;" \
|
||||
"movq %1, %%r9;" \
|
||||
"movq %2, %%r10;" \
|
||||
"movq $0, %%rdx;" \
|
||||
"divq %%rdx;" \
|
||||
: \
|
||||
: "r"((uint64_t)s), "r"((uint64_t)d), "r"((uint64_t)__LINE__) \
|
||||
: "rax", "rdx", "r8", "r9", "r10"); \
|
||||
}
|
||||
|
||||
#ifdef BOOTLOADER_DEBUG
|
||||
#define con_debug(...) con_printf(L"DEBUG: " __VA_ARGS__)
|
||||
#else
|
||||
#define con_debug(...)
|
||||
#endif
|
||||
390
src/drivers/fb/default_font.inc
Normal file
390
src/drivers/fb/default_font.inc
Normal file
@@ -0,0 +1,390 @@
|
||||
0x72, 0xb5, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
|
||||
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0xf8,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xf8, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0f,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x0f, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0xf8, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xff, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
|
||||
0x22, 0x20, 0x20, 0xf8, 0x20, 0x20, 0x72, 0x8c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x7e, 0x24, 0x24,
|
||||
0x24, 0x7e, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08,
|
||||
0x1e, 0x20, 0x20, 0x1c, 0x02, 0x02, 0x3c, 0x08, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x30, 0x49, 0x4a, 0x34, 0x08, 0x16, 0x29, 0x49, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x48, 0x48, 0x48, 0x30, 0x31,
|
||||
0x49, 0x46, 0x46, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10,
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08,
|
||||
0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x24, 0x18, 0x7e, 0x18, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7f, 0x08, 0x08, 0x08, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x18, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08,
|
||||
0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
|
||||
0x42, 0x46, 0x4a, 0x52, 0x62, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x02, 0x02, 0x04,
|
||||
0x08, 0x10, 0x20, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e,
|
||||
0x04, 0x08, 0x1c, 0x02, 0x02, 0x02, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x0c, 0x14, 0x24, 0x44, 0x7e, 0x04, 0x04, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x7c, 0x02,
|
||||
0x02, 0x02, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
|
||||
0x20, 0x40, 0x40, 0x7c, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7e, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x3c,
|
||||
0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
|
||||
0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x04, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x18, 0x18, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04,
|
||||
0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42,
|
||||
0x02, 0x04, 0x08, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1c, 0x22, 0x41, 0x4f, 0x51, 0x51, 0x51, 0x53, 0x4d, 0x40,
|
||||
0x20, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42,
|
||||
0x7e, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
|
||||
0x42, 0x42, 0x42, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1e, 0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x1e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42,
|
||||
0x42, 0x42, 0x44, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e,
|
||||
0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x20, 0x40, 0x40, 0x46,
|
||||
0x42, 0x42, 0x22, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42,
|
||||
0x42, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42,
|
||||
0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x63, 0x55, 0x49, 0x49,
|
||||
0x41, 0x41, 0x41, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42,
|
||||
0x62, 0x52, 0x4a, 0x46, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c,
|
||||
0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
|
||||
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x04, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x48, 0x44, 0x42, 0x42,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x40, 0x40, 0x20, 0x18,
|
||||
0x04, 0x02, 0x02, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42,
|
||||
0x24, 0x24, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41,
|
||||
0x41, 0x41, 0x41, 0x49, 0x49, 0x49, 0x55, 0x63, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x41, 0x41, 0x22, 0x14, 0x08, 0x14, 0x22, 0x41, 0x41,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x22, 0x14, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e,
|
||||
0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1e, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10,
|
||||
0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x78, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00, 0x00,
|
||||
0x00, 0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x7c, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3c, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x42,
|
||||
0x7e, 0x40, 0x40, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x10,
|
||||
0x10, 0x7e, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e,
|
||||
0x02, 0x02, 0x3c, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x7c, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08,
|
||||
0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x04, 0x04, 0x00, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x04, 0x38, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x44, 0x48, 0x50,
|
||||
0x70, 0x48, 0x44, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7c,
|
||||
0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x2e, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x40, 0x20, 0x18, 0x04, 0x02, 0x7c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7e, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41,
|
||||
0x49, 0x49, 0x55, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e,
|
||||
0x02, 0x02, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x04, 0x08,
|
||||
0x10, 0x20, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xe0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0e, 0x00, 0x00,
|
||||
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x00, 0x00, 0x00, 0x70, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x70, 0x00, 0x00, 0x00, 0x00, 0x31, 0x49,
|
||||
0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x08, 0x08,
|
||||
0x1c, 0x22, 0x40, 0x40, 0x40, 0x22, 0x1c, 0x08, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x20, 0x20, 0xf8, 0x20, 0x20, 0x72, 0x8c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x3c, 0x24, 0x24,
|
||||
0x24, 0x3c, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41,
|
||||
0x22, 0x14, 0x08, 0x3e, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x08, 0x08,
|
||||
0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x41, 0x4d, 0x51, 0x51, 0x4d, 0x41, 0x22,
|
||||
0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x09, 0x12, 0x24, 0x48, 0x24, 0x12, 0x09, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x08, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x24, 0x12, 0x09, 0x12, 0x24, 0x48,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00,
|
||||
0x00, 0x08, 0x10, 0x20, 0x40, 0x42, 0x3c, 0x00, 0x20, 0x10, 0x00, 0x18,
|
||||
0x18, 0x24, 0x24, 0x24, 0x7e, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x08, 0x00, 0x18, 0x18, 0x24, 0x24, 0x24, 0x7e, 0x42, 0x42, 0x42,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x00, 0x18, 0x18, 0x24, 0x24, 0x24,
|
||||
0x7e, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x18,
|
||||
0x18, 0x24, 0x24, 0x24, 0x7e, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00,
|
||||
0x24, 0x24, 0x00, 0x18, 0x18, 0x24, 0x24, 0x24, 0x7e, 0x42, 0x42, 0x42,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x24,
|
||||
0x7e, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
|
||||
0x14, 0x14, 0x24, 0x27, 0x3c, 0x44, 0x44, 0x47, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1e, 0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x1e,
|
||||
0x08, 0x08, 0x30, 0x00, 0x20, 0x10, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c,
|
||||
0x40, 0x40, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x7e,
|
||||
0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x24, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x7e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x7c,
|
||||
0x40, 0x40, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x3e,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x08, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x3e,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3c, 0x22, 0x21, 0x21, 0x79, 0x21, 0x21, 0x22, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x42, 0x62, 0x52, 0x4a, 0x46,
|
||||
0x42, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x1c,
|
||||
0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x08, 0x00, 0x1c, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x00, 0x1c, 0x22, 0x41, 0x41, 0x41,
|
||||
0x41, 0x41, 0x22, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x1c,
|
||||
0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x24, 0x24, 0x00, 0x1c, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x14,
|
||||
0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3c,
|
||||
0x42, 0x46, 0x4a, 0x52, 0x62, 0x42, 0x42, 0x3c, 0x40, 0x00, 0x00, 0x00,
|
||||
0x20, 0x10, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x00, 0x42,
|
||||
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x24, 0x24, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x41, 0x41, 0x22, 0x14, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
|
||||
0x40, 0x7c, 0x42, 0x42, 0x42, 0x7c, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3c, 0x42, 0x44, 0x4c, 0x42, 0x42, 0x42, 0x44, 0x58,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x3c, 0x02, 0x02,
|
||||
0x3e, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08,
|
||||
0x00, 0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x24, 0x00, 0x00, 0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x3c, 0x02, 0x02,
|
||||
0x3e, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24,
|
||||
0x00, 0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x24, 0x24, 0x18, 0x00, 0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x09, 0x39,
|
||||
0x4f, 0x48, 0x48, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3c, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3c, 0x08, 0x08, 0x30, 0x00,
|
||||
0x00, 0x00, 0x20, 0x10, 0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x3c, 0x42, 0x42,
|
||||
0x7e, 0x40, 0x40, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x00,
|
||||
0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x24, 0x24, 0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x38, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08,
|
||||
0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x24, 0x00, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x00, 0x38, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x06, 0x1a,
|
||||
0x01, 0x1d, 0x23, 0x41, 0x41, 0x41, 0x22, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x32, 0x4c, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x3c, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08,
|
||||
0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x24, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x3c, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24,
|
||||
0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3c, 0x46, 0x4a,
|
||||
0x52, 0x62, 0x42, 0x3c, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10,
|
||||
0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x04, 0x08, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x00, 0x00, 0x42, 0x42, 0x42,
|
||||
0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24,
|
||||
0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x04, 0x08, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e,
|
||||
0x02, 0x02, 0x3c, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5c, 0x62, 0x41,
|
||||
0x41, 0x41, 0x62, 0x5c, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x24, 0x24,
|
||||
0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x3c, 0x00,
|
||||
0xff, 0xff, 0xe2, 0x96, 0x92, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc2, 0xb0,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe2, 0x94, 0x98, 0xff, 0xe2, 0x94, 0x90, 0xff,
|
||||
0xe2, 0x94, 0x8c, 0xff, 0xe2, 0x94, 0x94, 0xff, 0xe2, 0x94, 0xbc, 0xff,
|
||||
0xff, 0xff, 0xe2, 0x94, 0x80, 0xff, 0xff, 0xff, 0xe2, 0x94, 0x9c, 0xff,
|
||||
0xe2, 0x94, 0xa4, 0xff, 0xe2, 0x94, 0xb4, 0xff, 0xe2, 0x94, 0xac, 0xff,
|
||||
0xe2, 0x94, 0x82, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc2, 0xa3, 0xff, 0xff,
|
||||
0x20, 0xff, 0x21, 0xff, 0x22, 0xff, 0x23, 0xff, 0x24, 0xff, 0x25, 0xff,
|
||||
0x26, 0xff, 0x27, 0xff, 0x28, 0xff, 0x29, 0xff, 0x2a, 0xff, 0x2b, 0xff,
|
||||
0x2c, 0xff, 0x2d, 0xff, 0x2e, 0xff, 0x2f, 0xff, 0x30, 0xff, 0x31, 0xff,
|
||||
0x32, 0xff, 0x33, 0xff, 0x34, 0xff, 0x35, 0xff, 0x36, 0xff, 0x37, 0xff,
|
||||
0x38, 0xff, 0x39, 0xff, 0x3a, 0xff, 0x3b, 0xff, 0x3c, 0xff, 0x3d, 0xff,
|
||||
0x3e, 0xff, 0x3f, 0xff, 0x40, 0xff, 0x41, 0xff, 0x42, 0xff, 0x43, 0xff,
|
||||
0x44, 0xff, 0x45, 0xff, 0x46, 0xff, 0x47, 0xff, 0x48, 0xff, 0x49, 0xff,
|
||||
0x4a, 0xff, 0x4b, 0xff, 0x4c, 0xff, 0x4d, 0xff, 0x4e, 0xff, 0x4f, 0xff,
|
||||
0x50, 0xff, 0x51, 0xff, 0x52, 0xff, 0x53, 0xff, 0x54, 0xff, 0x55, 0xff,
|
||||
0x56, 0xff, 0x57, 0xff, 0x58, 0xff, 0x59, 0xff, 0x5a, 0xff, 0x5b, 0xff,
|
||||
0x5c, 0xff, 0x5d, 0xff, 0x5e, 0xff, 0x5f, 0xff, 0x60, 0xff, 0x61, 0xff,
|
||||
0x62, 0xff, 0x63, 0xff, 0x64, 0xff, 0x65, 0xff, 0x66, 0xff, 0x67, 0xff,
|
||||
0x68, 0xff, 0x69, 0xff, 0x6a, 0xff, 0x6b, 0xff, 0x6c, 0xff, 0x6d, 0xff,
|
||||
0x6e, 0xff, 0x6f, 0xff, 0x70, 0xff, 0x71, 0xff, 0x72, 0xff, 0x73, 0xff,
|
||||
0x74, 0xff, 0x75, 0xff, 0x76, 0xff, 0x77, 0xff, 0x78, 0xff, 0x79, 0xff,
|
||||
0x7a, 0xff, 0x7b, 0xff, 0x7c, 0xff, 0x7d, 0xff, 0x7e, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc2, 0xa0, 0xff, 0xc2, 0xa1,
|
||||
0xff, 0xc2, 0xa2, 0xff, 0xc2, 0xa3, 0xff, 0xc2, 0xa4, 0xff, 0xc2, 0xa5,
|
||||
0xff, 0xc2, 0xa6, 0xff, 0xff, 0xc2, 0xa8, 0xff, 0xc2, 0xa9, 0xff, 0xff,
|
||||
0xc2, 0xab, 0xff, 0xff, 0xc2, 0xad, 0xff, 0xff, 0xff, 0xc2, 0xb0, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc2, 0xb8, 0xff, 0xff, 0xff,
|
||||
0xc2, 0xbb, 0xff, 0xff, 0xff, 0xff, 0xc2, 0xbf, 0xff, 0xc3, 0x80, 0xff,
|
||||
0xc3, 0x81, 0xff, 0xc3, 0x82, 0xff, 0xc3, 0x83, 0xff, 0xc3, 0x84, 0xff,
|
||||
0xc3, 0x85, 0xff, 0xc3, 0x86, 0xff, 0xc3, 0x87, 0xff, 0xc3, 0x88, 0xff,
|
||||
0xc3, 0x89, 0xff, 0xc3, 0x8a, 0xff, 0xc3, 0x8b, 0xff, 0xc3, 0x8c, 0xff,
|
||||
0xc3, 0x8d, 0xff, 0xc3, 0x8e, 0xff, 0xc3, 0x8f, 0xff, 0xc3, 0x90, 0xff,
|
||||
0xc3, 0x91, 0xff, 0xc3, 0x92, 0xff, 0xc3, 0x93, 0xff, 0xc3, 0x94, 0xff,
|
||||
0xc3, 0x95, 0xff, 0xc3, 0x96, 0xff, 0xc3, 0x97, 0xff, 0xc3, 0x98, 0xff,
|
||||
0xc3, 0x99, 0xff, 0xc3, 0x9a, 0xff, 0xc3, 0x9b, 0xff, 0xc3, 0x9c, 0xff,
|
||||
0xc3, 0x9d, 0xff, 0xc3, 0x9e, 0xff, 0xc3, 0x9f, 0xff, 0xc3, 0xa0, 0xff,
|
||||
0xc3, 0xa1, 0xff, 0xc3, 0xa2, 0xff, 0xc3, 0xa3, 0xff, 0xc3, 0xa4, 0xff,
|
||||
0xc3, 0xa5, 0xff, 0xc3, 0xa6, 0xff, 0xc3, 0xa7, 0xff, 0xc3, 0xa8, 0xff,
|
||||
0xc3, 0xa9, 0xff, 0xc3, 0xaa, 0xff, 0xc3, 0xab, 0xff, 0xc3, 0xac, 0xff,
|
||||
0xc3, 0xad, 0xff, 0xc3, 0xae, 0xff, 0xc3, 0xaf, 0xff, 0xc3, 0xb0, 0xff,
|
||||
0xc3, 0xb1, 0xff, 0xc3, 0xb2, 0xff, 0xc3, 0xb3, 0xff, 0xc3, 0xb4, 0xff,
|
||||
0xc3, 0xb5, 0xff, 0xc3, 0xb6, 0xff, 0xc3, 0xb7, 0xff, 0xc3, 0xb8, 0xff,
|
||||
0xc3, 0xb9, 0xff, 0xc3, 0xba, 0xff, 0xc3, 0xbb, 0xff, 0xc3, 0xbc, 0xff,
|
||||
0xc3, 0xbd, 0xff, 0xc3, 0xbe, 0xff, 0xc3, 0xbf, 0xff
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "kutil/assert.h"
|
||||
#include <assert.h>
|
||||
#include "font.h"
|
||||
|
||||
|
||||
/* PSF2 header format
|
||||
* Taken from the Linux KBD documentation
|
||||
* http://www.win.tue.nl/~aeb/linux/kbd/font-formats-1.html
|
||||
@@ -27,43 +28,51 @@ struct psf2_header {
|
||||
uint32_t height, width; // max dimensions of glyphs
|
||||
};
|
||||
|
||||
const uint8_t default_font[] = {
|
||||
// xxd -i < font_file.psf > default_font.inc
|
||||
#include "default_font.inc"
|
||||
};
|
||||
|
||||
font::font(void const *data) :
|
||||
m_size(0, 0),
|
||||
m_count(0),
|
||||
m_data(nullptr)
|
||||
m_sizex {0},
|
||||
m_sizey {0},
|
||||
m_count {0},
|
||||
m_data {nullptr}
|
||||
{
|
||||
if (!data)
|
||||
data = default_font;
|
||||
|
||||
psf2_header const *psf2 = static_cast<psf2_header const *>(data);
|
||||
for (int i = 0; i < sizeof(magic); ++i) {
|
||||
kassert(psf2->magic[i] == magic[i], "Bad font magic number.");
|
||||
assert(psf2->magic[i] == magic[i] && "Bad font magic number.");
|
||||
}
|
||||
|
||||
m_data = static_cast<uint8_t const *>(data) + psf2->header_size;
|
||||
m_size.x = psf2->width;
|
||||
m_size.y = psf2->height;
|
||||
m_sizex = psf2->width;
|
||||
m_sizey = psf2->height;
|
||||
m_count = psf2->length;
|
||||
}
|
||||
|
||||
void
|
||||
font::draw_glyph(
|
||||
screen *s,
|
||||
screen &s,
|
||||
uint32_t glyph,
|
||||
screen::pixel_t fg,
|
||||
screen::pixel_t bg,
|
||||
unsigned x,
|
||||
unsigned y) const
|
||||
{
|
||||
unsigned bwidth = (m_size.x+7)/8;
|
||||
unsigned bwidth = (m_sizex+7)/8;
|
||||
uint8_t const *data = m_data + (glyph * glyph_bytes());
|
||||
|
||||
for (int dy = 0; dy < m_size.y; ++dy) {
|
||||
for (int dy = 0; dy < m_sizey; ++dy) {
|
||||
for (int dx = 0; dx < bwidth; ++dx) {
|
||||
uint8_t byte = data[dy * bwidth + dx];
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (dx*8 + i >= m_size.x) continue;
|
||||
if (dx*8 + i >= m_sizex) break;
|
||||
const uint8_t mask = 1 << (7-i);
|
||||
uint32_t c = (byte & mask) ? fg : bg;
|
||||
s->draw_pixel(x + dx*8 + i, y + dy, c);
|
||||
s.draw_pixel(x + dx*8 + i, y + dy, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/drivers/fb/font.h
Normal file
33
src/drivers/fb/font.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
class font
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
/// \arg data The font data to load. If null, will load the default
|
||||
/// built-in font.
|
||||
font(void const *data = nullptr);
|
||||
|
||||
unsigned glyph_bytes() const { return m_sizey * ((m_sizex + 7) / 8); }
|
||||
unsigned count() const { return m_count; }
|
||||
unsigned width() const { return m_sizex; }
|
||||
unsigned height() const { return m_sizey; }
|
||||
bool valid() const { return m_count > 0; }
|
||||
|
||||
void draw_glyph(
|
||||
screen &s,
|
||||
uint32_t glyph,
|
||||
screen::pixel_t fg,
|
||||
screen::pixel_t bg,
|
||||
unsigned x,
|
||||
unsigned y) const;
|
||||
|
||||
private:
|
||||
unsigned m_sizex, m_sizey;
|
||||
unsigned m_count;
|
||||
uint8_t const *m_data;
|
||||
};
|
||||
|
||||
105
src/drivers/fb/main.cpp
Normal file
105
src/drivers/fb/main.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "j6/init.h"
|
||||
#include "j6/errors.h"
|
||||
#include "j6/signals.h"
|
||||
#include "j6/types.h"
|
||||
|
||||
#include <j6libc/syscalls.h>
|
||||
|
||||
#include "font.h"
|
||||
#include "screen.h"
|
||||
#include "scrollback.h"
|
||||
|
||||
extern "C" {
|
||||
int main(int, const char **);
|
||||
void _get_init(size_t *initc, struct j6_init_value **initv);
|
||||
}
|
||||
|
||||
extern j6_handle_t __handle_sys;
|
||||
|
||||
struct entry
|
||||
{
|
||||
uint8_t bytes;
|
||||
uint8_t area;
|
||||
uint8_t severity;
|
||||
uint8_t sequence;
|
||||
char message[0];
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
_syscall_system_log("fb driver starting");
|
||||
|
||||
size_t initc = 0;
|
||||
j6_init_value *initv = nullptr;
|
||||
_get_init(&initc, &initv);
|
||||
|
||||
j6_init_framebuffer *fb = nullptr;
|
||||
for (unsigned i = 0; i < initc; ++i) {
|
||||
if (initv[i].type == j6_init_desc_framebuffer) {
|
||||
fb = reinterpret_cast<j6_init_framebuffer*>(initv[i].value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fb || fb->addr == nullptr) {
|
||||
_syscall_system_log("fb driver didn't find a framebuffer, exiting");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const screen::pixel_order order = (fb->flags & 1) ?
|
||||
screen::pixel_order::bgr8 : screen::pixel_order::rgb8;
|
||||
|
||||
screen scr(fb->addr, fb->horizontal, fb->vertical, order);
|
||||
font fnt;
|
||||
|
||||
screen::pixel_t fg = scr.color(0xb0, 0xb0, 0xb0);
|
||||
screen::pixel_t bg = scr.color(49, 79, 128);
|
||||
scr.fill(bg);
|
||||
scr.update();
|
||||
|
||||
constexpr int margin = 2;
|
||||
const unsigned xstride = (margin + fnt.width());
|
||||
const unsigned ystride = (margin + fnt.height());
|
||||
const unsigned rows = (scr.height() - margin) / ystride;
|
||||
const unsigned cols = (scr.width() - margin) / xstride;
|
||||
|
||||
scrollback scroll(rows, cols);
|
||||
|
||||
int pending = 0;
|
||||
constexpr int pending_threshold = 10;
|
||||
|
||||
char message_buffer[256];
|
||||
while (true) {
|
||||
size_t size = sizeof(message_buffer);
|
||||
_syscall_system_get_log(__handle_sys, message_buffer, &size);
|
||||
if (size != 0) {
|
||||
entry *e = reinterpret_cast<entry*>(&message_buffer);
|
||||
|
||||
size_t eom = e->bytes - sizeof(entry);
|
||||
e->message[eom] = 0;
|
||||
|
||||
scroll.add_line(e->message, eom);
|
||||
if (++pending > pending_threshold) {
|
||||
scroll.render(scr, fnt);
|
||||
scr.update();
|
||||
pending = 0;
|
||||
}
|
||||
} else {
|
||||
if (pending) {
|
||||
scroll.render(scr, fnt);
|
||||
scr.update();
|
||||
pending = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_syscall_system_log("fb driver done, exiting");
|
||||
return 0;
|
||||
}
|
||||
|
||||
50
src/drivers/fb/screen.cpp
Normal file
50
src/drivers/fb/screen.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "screen.h"
|
||||
|
||||
screen::screen(void *addr, unsigned hres, unsigned vres, pixel_order order) :
|
||||
m_fb(static_cast<pixel_t *>(addr)),
|
||||
m_order(order),
|
||||
m_resx(hres),
|
||||
m_resy(vres)
|
||||
{
|
||||
m_back = reinterpret_cast<pixel_t*>(malloc(hres*vres*sizeof(pixel_t)));
|
||||
}
|
||||
|
||||
screen::pixel_t
|
||||
screen::color(uint8_t r, uint8_t g, uint8_t b) const
|
||||
{
|
||||
switch (m_order) {
|
||||
case pixel_order::bgr8:
|
||||
return
|
||||
(static_cast<uint32_t>(b) << 0) |
|
||||
(static_cast<uint32_t>(g) << 8) |
|
||||
(static_cast<uint32_t>(r) << 16);
|
||||
|
||||
case pixel_order::rgb8:
|
||||
return
|
||||
(static_cast<uint32_t>(r) << 0) |
|
||||
(static_cast<uint32_t>(g) << 8) |
|
||||
(static_cast<uint32_t>(b) << 16);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
screen::fill(pixel_t color)
|
||||
{
|
||||
const size_t len = m_resx * m_resy;
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
m_back[i] = color;
|
||||
}
|
||||
|
||||
void
|
||||
screen::draw_pixel(unsigned x, unsigned y, pixel_t color)
|
||||
{
|
||||
m_back[x + y * m_resx] = color;
|
||||
}
|
||||
|
||||
void
|
||||
screen::update()
|
||||
{
|
||||
memcpy(m_fb, m_back, m_resx*m_resy*sizeof(pixel_t));
|
||||
}
|
||||
30
src/drivers/fb/screen.h
Normal file
30
src/drivers/fb/screen.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class screen
|
||||
{
|
||||
public:
|
||||
using pixel_t = uint32_t;
|
||||
|
||||
enum class pixel_order : uint8_t { bgr8, rgb8, };
|
||||
|
||||
screen(void *addr, unsigned hres, unsigned vres, pixel_order order);
|
||||
|
||||
unsigned width() const { return m_resx; }
|
||||
unsigned height() const { return m_resy; }
|
||||
|
||||
pixel_t color(uint8_t r, uint8_t g, uint8_t b) const;
|
||||
|
||||
void fill(pixel_t color);
|
||||
void draw_pixel(unsigned x, unsigned y, pixel_t color);
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
pixel_t *m_fb, *m_back;
|
||||
pixel_order m_order;
|
||||
unsigned m_resx, m_resy;
|
||||
|
||||
screen() = delete;
|
||||
};
|
||||
56
src/drivers/fb/scrollback.cpp
Normal file
56
src/drivers/fb/scrollback.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "font.h"
|
||||
#include "screen.h"
|
||||
#include "scrollback.h"
|
||||
|
||||
scrollback::scrollback(unsigned lines, unsigned cols, unsigned margin) :
|
||||
m_rows {lines},
|
||||
m_cols {cols},
|
||||
m_count {0},
|
||||
m_margin {margin}
|
||||
{
|
||||
m_data = reinterpret_cast<char*>(malloc(lines*cols));
|
||||
m_lines = reinterpret_cast<char**>(malloc(lines*sizeof(char*)));
|
||||
for (unsigned i = 0; i < lines; ++i)
|
||||
m_lines[i] = &m_data[i*cols];
|
||||
|
||||
memset(m_data, ' ', lines*cols);
|
||||
}
|
||||
|
||||
void
|
||||
scrollback::add_line(const char *line, size_t len)
|
||||
{
|
||||
unsigned i = m_count++ % m_rows;
|
||||
|
||||
if (len > m_cols)
|
||||
len = m_cols;
|
||||
|
||||
memcpy(m_lines[i], line, len);
|
||||
if (len < m_cols)
|
||||
memset(m_lines[i]+len, ' ', m_cols - len);
|
||||
}
|
||||
|
||||
char *
|
||||
scrollback::get_line(unsigned i)
|
||||
{
|
||||
return m_lines[(i+m_count)%m_rows];
|
||||
}
|
||||
|
||||
void
|
||||
scrollback::render(screen &scr, font &fnt)
|
||||
{
|
||||
screen::pixel_t fg = scr.color(0xb0, 0xb0, 0xb0);
|
||||
screen::pixel_t bg = scr.color(49, 79, 128);
|
||||
|
||||
const unsigned xstride = (m_margin + fnt.width());
|
||||
const unsigned ystride = (m_margin + fnt.height());
|
||||
|
||||
for (unsigned y = 0; y < m_rows; ++y) {
|
||||
char *line = get_line(y);
|
||||
for (unsigned x = 0; x < m_cols; ++x) {
|
||||
fnt.draw_glyph(scr, line[x], fg, bg, m_margin+x*xstride, m_margin+y*ystride);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user