mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-17 06:47:49 +00:00
Compare commits
202 Commits
c9cdf562f2
...
post-11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a129329b0a | ||
|
|
0df06162c8 | ||
|
|
cb66922dfa | ||
|
|
43f767cfa4 | ||
|
|
e12866e19b | ||
|
|
18ec73ebf0 | ||
|
|
d788a21b40 | ||
|
|
bb5899e437 | ||
|
|
93d0daa1e0 | ||
|
|
83e6c0bc00 | ||
|
|
2b11ad8397 | ||
|
|
fa51f3adbf | ||
|
|
fe04fb8093 | ||
|
|
a9f5ed6e74 | ||
|
|
9e2562c7c8 | ||
|
|
53cec5e822 | ||
|
|
8002474616 | ||
|
|
aaaa58d1ab | ||
|
|
0b61e748fb | ||
|
|
ceb91f955a | ||
|
|
3340babf51 | ||
|
|
200695fcc8 | ||
|
|
360a40b5a7 | ||
|
|
86a3c7065e | ||
|
|
be2b2db06d | ||
|
|
45122f09c9 | ||
|
|
8c7e0127db | ||
|
|
28b6a96eed | ||
|
|
86352f9b8f | ||
|
|
a862287880 | ||
|
|
37a0ae0097 | ||
|
|
6fc9fbfb7d | ||
|
|
1f097bba71 | ||
|
|
99fbbad9b0 | ||
|
|
94d14d8d62 | ||
|
|
70b46ee8cf | ||
|
|
7172bed760 | ||
|
|
4f48a36887 | ||
|
|
f090d8b01b | ||
|
|
2f06d875da | ||
|
|
f4c35f7091 | ||
|
|
d46aef945f | ||
|
|
ebfc7c5f7e | ||
|
|
6f0be666f3 | ||
|
|
d9fa84edd6 | ||
|
|
4b368f2e5b | ||
|
|
5ef9960d51 | ||
|
|
99432ab712 | ||
|
|
0eb93f9325 | ||
|
|
f8c6732c88 | ||
|
|
41f4b88041 | ||
|
|
e24e33f6ff | ||
|
|
d1bf96108a | ||
|
|
97de98df33 | ||
|
|
9684f75819 | ||
|
|
d6cc562907 | ||
|
|
b44d8ab7fc | ||
|
|
c551fec1ce | ||
|
|
121dc393f8 | ||
|
|
08a6e13df4 | ||
|
|
569232322e | ||
|
|
27b56832c1 | ||
|
|
48dfc6d027 | ||
|
|
94149c93f9 | ||
|
|
34195ec8b7 | ||
|
|
e9e75e759e | ||
|
|
a7c5741ab5 | ||
|
|
65d8ef5478 | ||
|
|
194fa3c3fe | ||
|
|
9799487962 | ||
|
|
c6c0e1a7f0 | ||
|
|
c407c26224 | ||
|
|
0da8a4bc6b | ||
|
|
d43aa8aebf | ||
|
|
2049f23abb | ||
|
|
0dab4b7ec2 | ||
|
|
3e814722d0 | ||
|
|
5b088bffeb | ||
|
|
e9ca6b83c4 | ||
|
|
62b2c8a0b5 | ||
|
|
1d0aa17531 | ||
|
|
6de3aeaac3 | ||
|
|
a26d6c1b54 | ||
|
|
dc03bde076 | ||
|
|
3a988748de | ||
|
|
aa4f62187e | ||
|
|
e8f6e7300d | ||
|
|
889ceba24a | ||
|
|
1489b0aa06 | ||
|
|
08831b4ba1 | ||
|
|
3d94346f43 | ||
|
|
f19372d58a | ||
|
|
e4b3ed6d42 | ||
|
|
b1aec7eb66 | ||
|
|
e2a3e76a32 | ||
|
|
16bbb8f972 | ||
|
|
430e2143f8 | ||
|
|
86ffa24e8e | ||
|
|
69fe1aed12 | ||
|
|
d849a7dea5 | ||
|
|
bb2c57e1b4 | ||
|
|
18fd90b7a7 | ||
|
|
d83ab74e53 | ||
|
|
caa829db01 | ||
|
|
168dc5c2be | ||
|
|
a6141e8d2e | ||
|
|
df0c0b5783 | ||
|
|
c27eb1da9c | ||
|
|
bc7335ce6c | ||
|
|
722093e2c4 | ||
|
|
ba7b36aa21 | ||
|
|
8b5ae877b8 | ||
|
|
2a0126b9d2 | ||
|
|
90d1551665 | ||
|
|
45c058c622 | ||
|
|
deb7c82872 | ||
|
|
2a61f88d8a | ||
|
|
a90a8bea67 | ||
|
|
6dc837db7c | ||
|
|
4dd9c6bce7 | ||
|
|
28c9558a7a | ||
|
|
96af1fdc88 | ||
|
|
0422be52fa | ||
|
|
e9f9035f89 | ||
|
|
1d87e3b699 | ||
|
|
fda382c6bc | ||
|
|
f52872f3b9 | ||
|
|
688a21e4ed | ||
|
|
4f6558c021 | ||
|
|
f63e0dacca | ||
|
|
bb3beb22da | ||
|
|
b20e62e86b | ||
|
|
8d067be8ac | ||
|
|
aa9d0fff74 | ||
|
|
9ea911b0bb | ||
|
|
39ee714093 | ||
|
|
3743997479 | ||
|
|
2870ac4e13 | ||
|
|
aa13e0388c | ||
|
|
1edd07c3fd | ||
|
|
6854937268 | ||
|
|
75354fe142 | ||
|
|
61fc3c65bc | ||
|
|
9c546d4899 | ||
|
|
486975e4dc | ||
|
|
c250dd0a91 | ||
|
|
1deebed468 | ||
|
|
7a0597192c | ||
|
|
07d6c9c84e | ||
|
|
2265ddecad | ||
|
|
a44ac64c10 | ||
|
|
9edc2c59c7 | ||
|
|
27888e99b5 | ||
|
|
e59a2d1249 | ||
|
|
268b5b6856 | ||
|
|
2fdc7c3b5c | ||
|
|
d909d2456e | ||
|
|
0b51e0a320 | ||
|
|
3bc023ec2d | ||
|
|
38604da92f | ||
|
|
9bcbf17073 | ||
|
|
d54e691261 | ||
|
|
be58db8907 | ||
|
|
defd01c032 | ||
|
|
6e7c2f4344 | ||
|
|
26222f866f | ||
|
|
614ae005a2 | ||
|
|
bd12d5b8e1 | ||
|
|
1a53a115da | ||
|
|
c6990cb52d | ||
|
|
bd148f9bf2 | ||
|
|
1550e83094 | ||
|
|
b654651a85 | ||
|
|
45a8a03449 | ||
|
|
3916bebd15 | ||
|
|
d61a13bbad | ||
|
|
7bd3ecb9dc | ||
|
|
d830e5db29 | ||
|
|
ef9bb1a087 | ||
|
|
2bc4490404 | ||
|
|
64aeb0e98e | ||
|
|
cd244cc604 | ||
|
|
bf7cf4c65d | ||
|
|
5cb7baa983 | ||
|
|
f45954e7e4 | ||
|
|
8b7d009ba5 | ||
|
|
1f6c000970 | ||
|
|
6b7bb6f7a8 | ||
|
|
7288459bdf | ||
|
|
7959b77ebd | ||
|
|
bebad6d5a9 | ||
|
|
06f064aefa | ||
|
|
6b51fa467e | ||
|
|
4343f9be6a | ||
|
|
67c3180a7f | ||
|
|
c73b412ec6 | ||
|
|
431a956388 | ||
|
|
e738b599e0 | ||
|
|
4877991587 | ||
|
|
6c8fea8b00 | ||
|
|
b99c3f6d1d | ||
|
|
66c1792034 |
173
Cargo.lock
generated
173
Cargo.lock
generated
@@ -1,38 +1,41 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.0.1"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit_field"
|
name = "bit_field"
|
||||||
version = "0.10.1"
|
version = "0.10.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
|
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.2.1"
|
version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blog_os"
|
name = "blog_os"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bootloader",
|
"bootloader",
|
||||||
"conquer-once",
|
|
||||||
"crossbeam-queue",
|
|
||||||
"futures-util",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"linked_list_allocator",
|
"linked_list_allocator",
|
||||||
"pc-keyboard",
|
"pc-keyboard",
|
||||||
"pic8259",
|
"pic8259",
|
||||||
"spin",
|
"spin 0.5.2",
|
||||||
"uart_16550",
|
"uart_16550",
|
||||||
"volatile 0.2.7",
|
"volatile 0.2.7",
|
||||||
"x86_64",
|
"x86_64",
|
||||||
@@ -40,142 +43,64 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bootloader"
|
name = "bootloader"
|
||||||
version = "0.9.23"
|
version = "0.9.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6e02311b16c9819e7c72866d379cdd3026c3b7b25c1edf161f548f8e887e7ff"
|
checksum = "7bdfddac270bbdd45903296bc1caf29a7fdce6b326aaf0bbab7f04c5f98b7447"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "conquer-once"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "96eb12fb69466716fbae9009d389e6a30830ae8975e170eff2d2cff579f9efa3"
|
|
||||||
dependencies = [
|
|
||||||
"conquer-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "conquer-util"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "654fb2472cc369d311c547103a1fa81d467bef370ae7a0680f65939895b1182a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-queue"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"crossbeam-utils",
|
|
||||||
"maybe-uninit",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-utils"
|
|
||||||
version = "0.7.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"cfg-if",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-core"
|
|
||||||
version = "0.3.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-task"
|
|
||||||
version = "0.3.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-util"
|
|
||||||
version = "0.3.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"futures-core",
|
|
||||||
"futures-task",
|
|
||||||
"pin-project-lite",
|
|
||||||
"pin-utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"spin",
|
"spin 0.9.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linked_list_allocator"
|
name = "linked_list_allocator"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d0b725207570aa16096962d0b20c79f8a543df2280bd3c903022b9b0b4d7ea68"
|
checksum = "549ce1740e46b291953c4340adcd74c59bcf4308f4cac050fd33ba91b7168f4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"spinning_top",
|
"spinning_top",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
version = "0.4.4"
|
version = "0.4.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
|
checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "maybe-uninit"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pc-keyboard"
|
name = "pc-keyboard"
|
||||||
version = "0.5.1"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c6f2d937e3b8d63449b01401e2bae4041bc9dd1129c2e3e0d239407cf6635ac"
|
checksum = "ed089a1fbffe3337a1a345501c981f1eb1e47e69de5a40e852433e12953c3174"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pic8259"
|
name = "pic8259"
|
||||||
version = "0.10.1"
|
version = "0.10.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08cc920d83ee33c0f9b73aa441e75468bf2d10c959a3eb6260cf720b05ac91a1"
|
checksum = "cb844b5b01db1e0b17938685738f113bfc903846f18932b378bc0eabfa40e194"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "rustversion"
|
||||||
version = "0.2.6"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pin-utils"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin"
|
name = "spin"
|
||||||
@@ -184,21 +109,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spinning_top"
|
name = "spin"
|
||||||
version = "0.2.4"
|
version = "0.9.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "75adad84ee84b521fb2cca2d4fd0f1dab1d8d026bda3c5bea4ca63b5f9f9293c"
|
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spinning_top"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uart_16550"
|
name = "uart_16550"
|
||||||
version = "0.2.14"
|
version = "0.2.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "503a6c0e6d82daa87985e662d120c0176b09587c92a68db22781b28ae95405dd"
|
checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags 1.3.2",
|
||||||
|
"rustversion",
|
||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -210,17 +142,18 @@ checksum = "f6b06ad3ed06fef1713569d547cdbdb439eafed76341820fb0e0344f29a41945"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "volatile"
|
name = "volatile"
|
||||||
version = "0.4.4"
|
version = "0.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e4c2dbd44eb8b53973357e6e207e370f0c1059990df850aca1eca8947cf464f0"
|
checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x86_64"
|
name = "x86_64"
|
||||||
version = "0.14.7"
|
version = "0.14.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fb611915c917c6296d11e23f71ff1ecfe49c5766daba92cd3df52df6b58285b6"
|
checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"bitflags",
|
"bitflags 2.9.2",
|
||||||
"volatile 0.4.4",
|
"rustversion",
|
||||||
|
"volatile 0.4.6",
|
||||||
]
|
]
|
||||||
|
|||||||
30
Cargo.toml
30
Cargo.toml
@@ -2,7 +2,7 @@
|
|||||||
name = "blog_os"
|
name = "blog_os"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Philipp Oppermann <dev@phil-opp.com>"]
|
authors = ["Philipp Oppermann <dev@phil-opp.com>"]
|
||||||
edition = "2018"
|
edition = "2024"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "should_panic"
|
name = "should_panic"
|
||||||
@@ -13,36 +13,32 @@ name = "stack_overflow"
|
|||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bootloader = { version = "0.9.8", features = ["map_physical_memory"]}
|
bootloader = { version = "0.9", features = ["map_physical_memory"] }
|
||||||
volatile = "0.2.6"
|
volatile = "0.2.6"
|
||||||
spin = "0.5.2"
|
spin = "0.5.2"
|
||||||
x86_64 = "0.14.2"
|
x86_64 = "0.14.2"
|
||||||
uart_16550 = "0.2.0"
|
uart_16550 = "0.2.0"
|
||||||
pic8259 = "0.10.1"
|
pic8259 = "0.10.1"
|
||||||
pc-keyboard = "0.5.0"
|
pc-keyboard = "0.7.0"
|
||||||
linked_list_allocator = "0.9.0"
|
linked_list_allocator = "0.9.0"
|
||||||
|
|
||||||
[dependencies.lazy_static]
|
[dependencies.lazy_static]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
features = ["spin_no_std"]
|
features = ["spin_no_std"]
|
||||||
|
|
||||||
[dependencies.crossbeam-queue]
|
[[bin]]
|
||||||
version = "0.2.1"
|
name = "blog_os"
|
||||||
default-features = false
|
test = true
|
||||||
features = ["alloc"]
|
bench = false
|
||||||
|
|
||||||
[dependencies.conquer-once]
|
|
||||||
version = "0.2.0"
|
|
||||||
default-features = false
|
|
||||||
|
|
||||||
[dependencies.futures-util]
|
|
||||||
version = "0.3.4"
|
|
||||||
default-features = false
|
|
||||||
features = ["alloc"]
|
|
||||||
|
|
||||||
[package.metadata.bootimage]
|
[package.metadata.bootimage]
|
||||||
test-args = [
|
test-args = [
|
||||||
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", "-serial", "stdio",
|
"-device",
|
||||||
"-display", "none"
|
"isa-debug-exit,iobase=0xf4,iosize=0x04",
|
||||||
|
"-serial",
|
||||||
|
"stdio",
|
||||||
|
"-display",
|
||||||
|
"none",
|
||||||
]
|
]
|
||||||
test-success-exit-code = 33 # (0x10 << 1) | 1
|
test-success-exit-code = 33 # (0x10 << 1) | 1
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# Blog OS (Async/Await)
|
# Blog OS (Allocator Designs)
|
||||||
|
|
||||||
[](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Code%22+branch%3Apost-12)
|
[](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Code%22+branch%3Apost-11)
|
||||||
|
|
||||||
This repository contains the source code for the [Async/Await][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
|
This repository contains the source code for the [Allocator Designs][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
|
||||||
|
|
||||||
[post]: https://os.phil-opp.com/async-await/
|
[post]: https://os.phil-opp.com/allocator-designs/
|
||||||
|
|
||||||
**Check out the [master branch](https://github.com/phil-opp/blog_os) for more information.**
|
**Check out the [master branch](https://github.com/phil-opp/blog_os) for more information.**
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ use alloc::alloc::{GlobalAlloc, Layout};
|
|||||||
use core::ptr::null_mut;
|
use core::ptr::null_mut;
|
||||||
use fixed_size_block::FixedSizeBlockAllocator;
|
use fixed_size_block::FixedSizeBlockAllocator;
|
||||||
use x86_64::{
|
use x86_64::{
|
||||||
structures::paging::{
|
|
||||||
mapper::MapToError, FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB,
|
|
||||||
},
|
|
||||||
VirtAddr,
|
VirtAddr,
|
||||||
|
structures::paging::{
|
||||||
|
FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB, mapper::MapToError,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod bump;
|
pub mod bump;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use super::{align_up, Locked};
|
use super::{Locked, align_up};
|
||||||
use alloc::alloc::{GlobalAlloc, Layout};
|
use alloc::alloc::{GlobalAlloc, Layout};
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,10 @@ impl FixedSizeBlockAllocator {
|
|||||||
/// heap bounds are valid and that the heap is unused. This method must be
|
/// heap bounds are valid and that the heap is unused. This method must be
|
||||||
/// called only once.
|
/// called only once.
|
||||||
pub unsafe fn init(&mut self, heap_start: usize, heap_size: usize) {
|
pub unsafe fn init(&mut self, heap_start: usize, heap_size: usize) {
|
||||||
|
unsafe {
|
||||||
self.fallback_allocator.init(heap_start, heap_size);
|
self.fallback_allocator.init(heap_start, heap_size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Allocates using the fallback allocator.
|
/// Allocates using the fallback allocator.
|
||||||
fn fallback_alloc(&mut self, layout: Layout) -> *mut u8 {
|
fn fallback_alloc(&mut self, layout: Layout) -> *mut u8 {
|
||||||
@@ -91,13 +93,17 @@ unsafe impl GlobalAlloc for Locked<FixedSizeBlockAllocator> {
|
|||||||
assert!(mem::size_of::<ListNode>() <= BLOCK_SIZES[index]);
|
assert!(mem::size_of::<ListNode>() <= BLOCK_SIZES[index]);
|
||||||
assert!(mem::align_of::<ListNode>() <= BLOCK_SIZES[index]);
|
assert!(mem::align_of::<ListNode>() <= BLOCK_SIZES[index]);
|
||||||
let new_node_ptr = ptr as *mut ListNode;
|
let new_node_ptr = ptr as *mut ListNode;
|
||||||
|
unsafe {
|
||||||
new_node_ptr.write(new_node);
|
new_node_ptr.write(new_node);
|
||||||
allocator.list_heads[index] = Some(&mut *new_node_ptr);
|
allocator.list_heads[index] = Some(&mut *new_node_ptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
let ptr = NonNull::new(ptr).unwrap();
|
let ptr = NonNull::new(ptr).unwrap();
|
||||||
|
unsafe {
|
||||||
allocator.fallback_allocator.deallocate(ptr, layout);
|
allocator.fallback_allocator.deallocate(ptr, layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use super::{align_up, Locked};
|
use super::{Locked, align_up};
|
||||||
use alloc::alloc::{GlobalAlloc, Layout};
|
use alloc::alloc::{GlobalAlloc, Layout};
|
||||||
use core::{mem, ptr};
|
use core::{mem, ptr};
|
||||||
|
|
||||||
@@ -39,8 +39,10 @@ impl LinkedListAllocator {
|
|||||||
/// heap bounds are valid and that the heap is unused. This method must be
|
/// heap bounds are valid and that the heap is unused. This method must be
|
||||||
/// called only once.
|
/// called only once.
|
||||||
pub unsafe fn init(&mut self, heap_start: usize, heap_size: usize) {
|
pub unsafe fn init(&mut self, heap_start: usize, heap_size: usize) {
|
||||||
|
unsafe {
|
||||||
self.add_free_region(heap_start, heap_size);
|
self.add_free_region(heap_start, heap_size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds the given memory region to the front of the list.
|
/// Adds the given memory region to the front of the list.
|
||||||
unsafe fn add_free_region(&mut self, addr: usize, size: usize) {
|
unsafe fn add_free_region(&mut self, addr: usize, size: usize) {
|
||||||
@@ -52,8 +54,10 @@ impl LinkedListAllocator {
|
|||||||
let mut node = ListNode::new(size);
|
let mut node = ListNode::new(size);
|
||||||
node.next = self.head.next.take();
|
node.next = self.head.next.take();
|
||||||
let node_ptr = addr as *mut ListNode;
|
let node_ptr = addr as *mut ListNode;
|
||||||
|
unsafe {
|
||||||
node_ptr.write(node);
|
node_ptr.write(node);
|
||||||
self.head.next = Some(&mut *node_ptr)
|
self.head.next = Some(&mut *node_ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Looks for a free region with the given size and alignment and removes
|
/// Looks for a free region with the given size and alignment and removes
|
||||||
@@ -128,8 +132,10 @@ unsafe impl GlobalAlloc for Locked<LinkedListAllocator> {
|
|||||||
let alloc_end = alloc_start.checked_add(size).expect("overflow");
|
let alloc_end = alloc_start.checked_add(size).expect("overflow");
|
||||||
let excess_size = region.end_addr() - alloc_end;
|
let excess_size = region.end_addr() - alloc_end;
|
||||||
if excess_size > 0 {
|
if excess_size > 0 {
|
||||||
|
unsafe {
|
||||||
allocator.add_free_region(alloc_end, excess_size);
|
allocator.add_free_region(alloc_end, excess_size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
alloc_start as *mut u8
|
alloc_start as *mut u8
|
||||||
} else {
|
} else {
|
||||||
ptr::null_mut()
|
ptr::null_mut()
|
||||||
@@ -140,6 +146,6 @@ unsafe impl GlobalAlloc for Locked<LinkedListAllocator> {
|
|||||||
// perform layout adjustments
|
// perform layout adjustments
|
||||||
let (size, _) = LinkedListAllocator::size_align(layout);
|
let (size, _) = LinkedListAllocator::size_align(layout);
|
||||||
|
|
||||||
self.lock().add_free_region(ptr as usize, size)
|
unsafe { self.lock().add_free_region(ptr as usize, size) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use x86_64::VirtAddr;
|
||||||
use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector};
|
use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector};
|
||||||
use x86_64::structures::tss::TaskStateSegment;
|
use x86_64::structures::tss::TaskStateSegment;
|
||||||
use x86_64::VirtAddr;
|
|
||||||
|
|
||||||
pub const DOUBLE_FAULT_IST_INDEX: u16 = 0;
|
pub const DOUBLE_FAULT_IST_INDEX: u16 = 0;
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ lazy_static! {
|
|||||||
const STACK_SIZE: usize = 4096 * 5;
|
const STACK_SIZE: usize = 4096 * 5;
|
||||||
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
|
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
|
||||||
|
|
||||||
let stack_start = VirtAddr::from_ptr(unsafe { &STACK });
|
let stack_start = VirtAddr::from_ptr(&raw const STACK);
|
||||||
let stack_end = stack_start + STACK_SIZE;
|
let stack_end = stack_start + STACK_SIZE;
|
||||||
stack_end
|
stack_end
|
||||||
};
|
};
|
||||||
@@ -41,7 +41,7 @@ struct Selectors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
use x86_64::instructions::segmentation::{Segment, CS};
|
use x86_64::instructions::segmentation::{CS, Segment};
|
||||||
use x86_64::instructions::tables::load_tss;
|
use x86_64::instructions::tables::load_tss;
|
||||||
|
|
||||||
GDT.0.load();
|
GDT.0.load();
|
||||||
|
|||||||
@@ -80,11 +80,31 @@ extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
||||||
|
use pc_keyboard::{DecodedKey, HandleControl, Keyboard, ScancodeSet1, layouts};
|
||||||
|
use spin::Mutex;
|
||||||
use x86_64::instructions::port::Port;
|
use x86_64::instructions::port::Port;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref KEYBOARD: Mutex<Keyboard<layouts::Us104Key, ScancodeSet1>> =
|
||||||
|
Mutex::new(Keyboard::new(
|
||||||
|
ScancodeSet1::new(),
|
||||||
|
layouts::Us104Key,
|
||||||
|
HandleControl::Ignore
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut keyboard = KEYBOARD.lock();
|
||||||
let mut port = Port::new(0x60);
|
let mut port = Port::new(0x60);
|
||||||
|
|
||||||
let scancode: u8 = unsafe { port.read() };
|
let scancode: u8 = unsafe { port.read() };
|
||||||
crate::task::keyboard::add_scancode(scancode);
|
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
|
||||||
|
if let Some(key) = keyboard.process_keyevent(key_event) {
|
||||||
|
match key {
|
||||||
|
DecodedKey::Unicode(character) => print!("{}", character),
|
||||||
|
DecodedKey::RawKey(key) => print!("{:?}", key),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
PICS.lock()
|
PICS.lock()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#![cfg_attr(test, no_main)]
|
#![cfg_attr(test, no_main)]
|
||||||
#![feature(custom_test_frameworks)]
|
#![feature(custom_test_frameworks)]
|
||||||
#![feature(abi_x86_interrupt)]
|
#![feature(abi_x86_interrupt)]
|
||||||
#![feature(const_mut_refs)]
|
|
||||||
#![test_runner(crate::test_runner)]
|
#![test_runner(crate::test_runner)]
|
||||||
#![reexport_test_harness_main = "test_main"]
|
#![reexport_test_harness_main = "test_main"]
|
||||||
|
|
||||||
@@ -14,7 +13,6 @@ pub mod gdt;
|
|||||||
pub mod interrupts;
|
pub mod interrupts;
|
||||||
pub mod memory;
|
pub mod memory;
|
||||||
pub mod serial;
|
pub mod serial;
|
||||||
pub mod task;
|
|
||||||
pub mod vga_buffer;
|
pub mod vga_buffer;
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
@@ -76,7 +74,7 @@ pub fn hlt_loop() -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use bootloader::{entry_point, BootInfo};
|
use bootloader::{BootInfo, entry_point};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
entry_point!(test_kernel_main);
|
entry_point!(test_kernel_main);
|
||||||
|
|||||||
43
src/main.rs
43
src/main.rs
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::{boxed::Box, rc::Rc, vec, vec::Vec};
|
||||||
use blog_os::println;
|
use blog_os::println;
|
||||||
use blog_os::task::{executor::Executor, keyboard, Task};
|
use bootloader::{BootInfo, entry_point};
|
||||||
use bootloader::{entry_point, BootInfo};
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
entry_point!(kernel_main);
|
entry_point!(kernel_main);
|
||||||
@@ -27,13 +27,35 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
|||||||
|
|
||||||
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
|
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
|
||||||
|
|
||||||
|
// allocate a number on the heap
|
||||||
|
let heap_value = Box::new(41);
|
||||||
|
println!("heap_value at {:p}", heap_value);
|
||||||
|
|
||||||
|
// create a dynamically sized vector
|
||||||
|
let mut vec = Vec::new();
|
||||||
|
for i in 0..500 {
|
||||||
|
vec.push(i);
|
||||||
|
}
|
||||||
|
println!("vec at {:p}", vec.as_slice());
|
||||||
|
|
||||||
|
// create a reference counted vector -> will be freed when count reaches 0
|
||||||
|
let reference_counted = Rc::new(vec![1, 2, 3]);
|
||||||
|
let cloned_reference = reference_counted.clone();
|
||||||
|
println!(
|
||||||
|
"current reference count is {}",
|
||||||
|
Rc::strong_count(&cloned_reference)
|
||||||
|
);
|
||||||
|
core::mem::drop(reference_counted);
|
||||||
|
println!(
|
||||||
|
"reference count is {} now",
|
||||||
|
Rc::strong_count(&cloned_reference)
|
||||||
|
);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
test_main();
|
test_main();
|
||||||
|
|
||||||
let mut executor = Executor::new();
|
println!("It did not crash!");
|
||||||
executor.spawn(Task::new(example_task()));
|
blog_os::hlt_loop();
|
||||||
executor.spawn(Task::new(keyboard::print_keypresses()));
|
|
||||||
executor.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function is called on panic.
|
/// This function is called on panic.
|
||||||
@@ -50,15 +72,6 @@ fn panic(info: &PanicInfo) -> ! {
|
|||||||
blog_os::test_panic_handler(info)
|
blog_os::test_panic_handler(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn async_number() -> u32 {
|
|
||||||
42
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn example_task() {
|
|
||||||
let number = async_number().await;
|
|
||||||
println!("async number: {}", number);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn trivial_assertion() {
|
fn trivial_assertion() {
|
||||||
assert_eq!(1, 1);
|
assert_eq!(1, 1);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use bootloader::bootinfo::{MemoryMap, MemoryRegionType};
|
use bootloader::bootinfo::{MemoryMap, MemoryRegionType};
|
||||||
use x86_64::{
|
use x86_64::{
|
||||||
structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB},
|
|
||||||
PhysAddr, VirtAddr,
|
PhysAddr, VirtAddr,
|
||||||
|
structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initialize a new OffsetPageTable.
|
/// Initialize a new OffsetPageTable.
|
||||||
@@ -11,9 +11,11 @@ use x86_64::{
|
|||||||
/// `physical_memory_offset`. Also, this function must be only called once
|
/// `physical_memory_offset`. Also, this function must be only called once
|
||||||
/// to avoid aliasing `&mut` references (which is undefined behavior).
|
/// to avoid aliasing `&mut` references (which is undefined behavior).
|
||||||
pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> {
|
pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> {
|
||||||
|
unsafe {
|
||||||
let level_4_table = active_level_4_table(physical_memory_offset);
|
let level_4_table = active_level_4_table(physical_memory_offset);
|
||||||
OffsetPageTable::new(level_4_table, physical_memory_offset)
|
OffsetPageTable::new(level_4_table, physical_memory_offset)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a mutable reference to the active level 4 table.
|
/// Returns a mutable reference to the active level 4 table.
|
||||||
///
|
///
|
||||||
@@ -30,7 +32,7 @@ unsafe fn active_level_4_table(physical_memory_offset: VirtAddr) -> &'static mut
|
|||||||
let virt = physical_memory_offset + phys.as_u64();
|
let virt = physical_memory_offset + phys.as_u64();
|
||||||
let page_table_ptr: *mut PageTable = virt.as_mut_ptr();
|
let page_table_ptr: *mut PageTable = virt.as_mut_ptr();
|
||||||
|
|
||||||
&mut *page_table_ptr // unsafe
|
unsafe { &mut *page_table_ptr }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A FrameAllocator that always returns `None`.
|
/// A FrameAllocator that always returns `None`.
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
use super::{Task, TaskId};
|
|
||||||
use alloc::{collections::BTreeMap, sync::Arc, task::Wake};
|
|
||||||
use core::task::{Context, Poll, Waker};
|
|
||||||
use crossbeam_queue::ArrayQueue;
|
|
||||||
|
|
||||||
pub struct Executor {
|
|
||||||
tasks: BTreeMap<TaskId, Task>,
|
|
||||||
task_queue: Arc<ArrayQueue<TaskId>>,
|
|
||||||
waker_cache: BTreeMap<TaskId, Waker>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Executor {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Executor {
|
|
||||||
tasks: BTreeMap::new(),
|
|
||||||
task_queue: Arc::new(ArrayQueue::new(100)),
|
|
||||||
waker_cache: BTreeMap::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn spawn(&mut self, task: Task) {
|
|
||||||
let task_id = task.id;
|
|
||||||
if self.tasks.insert(task.id, task).is_some() {
|
|
||||||
panic!("task with same ID already in tasks");
|
|
||||||
}
|
|
||||||
self.task_queue.push(task_id).expect("queue full");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(&mut self) -> ! {
|
|
||||||
loop {
|
|
||||||
self.run_ready_tasks();
|
|
||||||
self.sleep_if_idle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_ready_tasks(&mut self) {
|
|
||||||
// destructure `self` to avoid borrow checker errors
|
|
||||||
let Self {
|
|
||||||
tasks,
|
|
||||||
task_queue,
|
|
||||||
waker_cache,
|
|
||||||
} = self;
|
|
||||||
|
|
||||||
while let Ok(task_id) = task_queue.pop() {
|
|
||||||
let task = match tasks.get_mut(&task_id) {
|
|
||||||
Some(task) => task,
|
|
||||||
None => continue, // task no longer exists
|
|
||||||
};
|
|
||||||
let waker = waker_cache
|
|
||||||
.entry(task_id)
|
|
||||||
.or_insert_with(|| TaskWaker::new(task_id, task_queue.clone()));
|
|
||||||
let mut context = Context::from_waker(waker);
|
|
||||||
match task.poll(&mut context) {
|
|
||||||
Poll::Ready(()) => {
|
|
||||||
// task done -> remove it and its cached waker
|
|
||||||
tasks.remove(&task_id);
|
|
||||||
waker_cache.remove(&task_id);
|
|
||||||
}
|
|
||||||
Poll::Pending => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sleep_if_idle(&self) {
|
|
||||||
use x86_64::instructions::interrupts::{self, enable_and_hlt};
|
|
||||||
|
|
||||||
interrupts::disable();
|
|
||||||
if self.task_queue.is_empty() {
|
|
||||||
enable_and_hlt();
|
|
||||||
} else {
|
|
||||||
interrupts::enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TaskWaker {
|
|
||||||
task_id: TaskId,
|
|
||||||
task_queue: Arc<ArrayQueue<TaskId>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskWaker {
|
|
||||||
fn new(task_id: TaskId, task_queue: Arc<ArrayQueue<TaskId>>) -> Waker {
|
|
||||||
Waker::from(Arc::new(TaskWaker {
|
|
||||||
task_id,
|
|
||||||
task_queue,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wake_task(&self) {
|
|
||||||
self.task_queue.push(self.task_id).expect("task_queue full");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Wake for TaskWaker {
|
|
||||||
fn wake(self: Arc<Self>) {
|
|
||||||
self.wake_task();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wake_by_ref(self: &Arc<Self>) {
|
|
||||||
self.wake_task();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
use crate::{print, println};
|
|
||||||
use conquer_once::spin::OnceCell;
|
|
||||||
use core::{
|
|
||||||
pin::Pin,
|
|
||||||
task::{Context, Poll},
|
|
||||||
};
|
|
||||||
use crossbeam_queue::ArrayQueue;
|
|
||||||
use futures_util::{
|
|
||||||
stream::{Stream, StreamExt},
|
|
||||||
task::AtomicWaker,
|
|
||||||
};
|
|
||||||
use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1};
|
|
||||||
|
|
||||||
static SCANCODE_QUEUE: OnceCell<ArrayQueue<u8>> = OnceCell::uninit();
|
|
||||||
static WAKER: AtomicWaker = AtomicWaker::new();
|
|
||||||
|
|
||||||
/// Called by the keyboard interrupt handler
|
|
||||||
///
|
|
||||||
/// Must not block or allocate.
|
|
||||||
pub(crate) fn add_scancode(scancode: u8) {
|
|
||||||
if let Ok(queue) = SCANCODE_QUEUE.try_get() {
|
|
||||||
if let Err(_) = queue.push(scancode) {
|
|
||||||
println!("WARNING: scancode queue full; dropping keyboard input");
|
|
||||||
} else {
|
|
||||||
WAKER.wake();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("WARNING: scancode queue uninitialized");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ScancodeStream {
|
|
||||||
_private: (),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ScancodeStream {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
SCANCODE_QUEUE
|
|
||||||
.try_init_once(|| ArrayQueue::new(100))
|
|
||||||
.expect("ScancodeStream::new should only be called once");
|
|
||||||
ScancodeStream { _private: () }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Stream for ScancodeStream {
|
|
||||||
type Item = u8;
|
|
||||||
|
|
||||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<u8>> {
|
|
||||||
let queue = SCANCODE_QUEUE
|
|
||||||
.try_get()
|
|
||||||
.expect("scancode queue not initialized");
|
|
||||||
|
|
||||||
// fast path
|
|
||||||
if let Ok(scancode) = queue.pop() {
|
|
||||||
return Poll::Ready(Some(scancode));
|
|
||||||
}
|
|
||||||
|
|
||||||
WAKER.register(&cx.waker());
|
|
||||||
match queue.pop() {
|
|
||||||
Ok(scancode) => {
|
|
||||||
WAKER.take();
|
|
||||||
Poll::Ready(Some(scancode))
|
|
||||||
}
|
|
||||||
Err(crossbeam_queue::PopError) => Poll::Pending,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn print_keypresses() {
|
|
||||||
let mut scancodes = ScancodeStream::new();
|
|
||||||
let mut keyboard = Keyboard::new(layouts::Us104Key, ScancodeSet1, HandleControl::Ignore);
|
|
||||||
|
|
||||||
while let Some(scancode) = scancodes.next().await {
|
|
||||||
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
|
|
||||||
if let Some(key) = keyboard.process_keyevent(key_event) {
|
|
||||||
match key {
|
|
||||||
DecodedKey::Unicode(character) => print!("{}", character),
|
|
||||||
DecodedKey::RawKey(key) => print!("{:?}", key),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
use alloc::boxed::Box;
|
|
||||||
use core::{
|
|
||||||
future::Future,
|
|
||||||
pin::Pin,
|
|
||||||
sync::atomic::{AtomicU64, Ordering},
|
|
||||||
task::{Context, Poll},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub mod executor;
|
|
||||||
pub mod keyboard;
|
|
||||||
pub mod simple_executor;
|
|
||||||
|
|
||||||
pub struct Task {
|
|
||||||
id: TaskId,
|
|
||||||
future: Pin<Box<dyn Future<Output = ()>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Task {
|
|
||||||
pub fn new(future: impl Future<Output = ()> + 'static) -> Task {
|
|
||||||
Task {
|
|
||||||
id: TaskId::new(),
|
|
||||||
future: Box::pin(future),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn poll(&mut self, context: &mut Context) -> Poll<()> {
|
|
||||||
self.future.as_mut().poll(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
|
||||||
struct TaskId(u64);
|
|
||||||
|
|
||||||
impl TaskId {
|
|
||||||
fn new() -> Self {
|
|
||||||
static NEXT_ID: AtomicU64 = AtomicU64::new(0);
|
|
||||||
TaskId(NEXT_ID.fetch_add(1, Ordering::Relaxed))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
use super::Task;
|
|
||||||
use alloc::collections::VecDeque;
|
|
||||||
use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
|
|
||||||
|
|
||||||
pub struct SimpleExecutor {
|
|
||||||
task_queue: VecDeque<Task>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SimpleExecutor {
|
|
||||||
pub fn new() -> SimpleExecutor {
|
|
||||||
SimpleExecutor {
|
|
||||||
task_queue: VecDeque::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn spawn(&mut self, task: Task) {
|
|
||||||
self.task_queue.push_back(task)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
|
||||||
while let Some(mut task) = self.task_queue.pop_front() {
|
|
||||||
let waker = dummy_waker();
|
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
match task.poll(&mut context) {
|
|
||||||
Poll::Ready(()) => {} // task done
|
|
||||||
Poll::Pending => self.task_queue.push_back(task),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dummy_raw_waker() -> RawWaker {
|
|
||||||
fn no_op(_: *const ()) {}
|
|
||||||
fn clone(_: *const ()) -> RawWaker {
|
|
||||||
dummy_raw_waker()
|
|
||||||
}
|
|
||||||
|
|
||||||
let vtable = &RawWakerVTable::new(clone, no_op, no_op, no_op);
|
|
||||||
RawWaker::new(0 as *const (), vtable)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dummy_waker() -> Waker {
|
|
||||||
unsafe { Waker::from_raw(dummy_raw_waker()) }
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
use blog_os::println;
|
use blog_os::println;
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[no_mangle] // don't mangle the name of this function
|
#[unsafe(no_mangle)] // don't mangle the name of this function
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
test_main();
|
test_main();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ extern crate alloc;
|
|||||||
|
|
||||||
use alloc::{boxed::Box, vec::Vec};
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
use blog_os::allocator::HEAP_SIZE;
|
use blog_os::allocator::HEAP_SIZE;
|
||||||
use bootloader::{entry_point, BootInfo};
|
use bootloader::{BootInfo, entry_point};
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
entry_point!(main);
|
entry_point!(main);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
|
use blog_os::{QemuExitCode, exit_qemu, serial_print, serial_println};
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[no_mangle]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
should_fail();
|
should_fail();
|
||||||
serial_println!("[test did not panic]");
|
serial_println!("[test did not panic]");
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(abi_x86_interrupt)]
|
#![feature(abi_x86_interrupt)]
|
||||||
|
|
||||||
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
|
use blog_os::{QemuExitCode, exit_qemu, serial_print, serial_println};
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
||||||
|
|
||||||
#[no_mangle]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
serial_print!("stack_overflow::stack_overflow...\t");
|
serial_print!("stack_overflow::stack_overflow...\t");
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"llvm-target": "x86_64-unknown-none",
|
"llvm-target": "x86_64-unknown-none",
|
||||||
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
|
||||||
"arch": "x86_64",
|
"arch": "x86_64",
|
||||||
"target-endian": "little",
|
"target-endian": "little",
|
||||||
"target-pointer-width": "64",
|
"target-pointer-width": 64,
|
||||||
"target-c-int-width": "32",
|
"target-c-int-width": 32,
|
||||||
"os": "none",
|
"os": "none",
|
||||||
"executables": true,
|
"executables": true,
|
||||||
"linker-flavor": "ld.lld",
|
"linker-flavor": "ld.lld",
|
||||||
"linker": "rust-lld",
|
"linker": "rust-lld",
|
||||||
"panic-strategy": "abort",
|
"panic-strategy": "abort",
|
||||||
"disable-redzone": true,
|
"disable-redzone": true,
|
||||||
"features": "-mmx,-sse,+soft-float"
|
"features": "-mmx,-sse,+soft-float",
|
||||||
|
"rustc-abi": "x86-softfloat"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user