Compare commits

...

333 Commits

Author SHA1 Message Date
Philipp Oppermann
0df06162c8 Merge branch 'post-09' into post-10 2025-09-03 17:58:33 +02:00
Philipp Oppermann
cb66922dfa Merge branch 'post-08' into post-09 2025-09-03 17:58:33 +02:00
Philipp Oppermann
43f767cfa4 Merge branch 'post-07' into post-08 2025-09-03 17:58:33 +02:00
Philipp Oppermann
e12866e19b Merge branch 'post-06' into post-07 2025-09-03 17:58:33 +02:00
Philipp Oppermann
18ec73ebf0 Merge branch 'post-05' into post-06 2025-09-03 17:58:33 +02:00
Philipp Oppermann
d788a21b40 Merge branch 'post-04' into post-05 2025-09-03 17:58:33 +02:00
Philipp Oppermann
bb5899e437 Merge branch 'post-03' into post-04 2025-09-03 17:58:33 +02:00
Philipp Oppermann
93d0daa1e0 Merge branch 'post-02' into post-03 2025-09-03 17:58:28 +02:00
Philipp Oppermann
83e6c0bc00 Merge pull request #1436 from phil-opp/post-02-fix-target
Fix: `target-pointer-width` field now expects an integer
2025-09-03 17:56:38 +02:00
Philipp Oppermann
2b11ad8397 Fix: target-pointer-width field now expects an integer 2025-09-03 17:53:14 +02:00
Philipp Oppermann
fa51f3adbf Update to latest bootloader version 2025-09-03 17:52:56 +02:00
Philipp Oppermann
a9f5ed6e74 Merge branch 'post-09' into post-10 2025-08-26 16:41:45 +02:00
Philipp Oppermann
9e2562c7c8 Merge branch 'post-08' into post-09 2025-08-26 16:41:45 +02:00
Philipp Oppermann
53cec5e822 Merge branch 'post-07' into post-08 2025-08-26 16:41:45 +02:00
Philipp Oppermann
8002474616 Merge branch 'post-06' into post-07 2025-08-26 16:41:45 +02:00
Philipp Oppermann
aaaa58d1ab Merge branch 'post-05' into post-06 2025-08-26 16:41:45 +02:00
Philipp Oppermann
0b61e748fb Merge branch 'post-04' into post-05 2025-08-26 16:41:45 +02:00
Philipp Oppermann
ceb91f955a Merge pull request #1434 from phil-opp/post-04-test-true
Set `test=true` to enable `main.rs` testing again
2025-08-26 16:41:21 +02:00
Philipp Oppermann
3340babf51 Set test=true to enable main.rs testing again
We set `test=false` for previous posts in https://github.com/phil-opp/blog_os/pull/1412 to avoid errors e.g. in rust-analyzer. For this testing post, we want to set it back to `true`.
2025-08-26 16:21:28 +02:00
Philipp Oppermann
360a40b5a7 Run cargo update 2025-08-18 09:49:11 +02:00
Philipp Oppermann
86a3c7065e Merge branch 'post-09' into post-10 2025-08-18 09:48:14 +02:00
Philipp Oppermann
be2b2db06d Merge branch 'post-08' into post-09 2025-08-18 09:47:01 +02:00
Philipp Oppermann
45122f09c9 Merge branch 'post-07' into post-08 2025-08-18 09:47:01 +02:00
Philipp Oppermann
8c7e0127db Run cargo update 2025-08-18 09:46:59 +02:00
Philipp Oppermann
28b6a96eed Merge branch 'post-06' into post-07 2025-08-18 09:46:48 +02:00
Philipp Oppermann
86352f9b8f Merge branch 'post-05' into post-06 2025-08-18 09:44:29 +02:00
Philipp Oppermann
a862287880 Merge branch 'post-04' into post-05 2025-08-18 09:44:29 +02:00
Philipp Oppermann
37a0ae0097 Run cargo update 2025-08-18 09:44:27 +02:00
Philipp Oppermann
6fc9fbfb7d Merge branch 'post-03' into post-04 2025-08-18 09:44:16 +02:00
Philipp Oppermann
1f097bba71 Run cargo update 2025-08-18 09:43:39 +02:00
Philipp Oppermann
99fbbad9b0 Merge branch 'post-02' into post-03 2025-08-18 09:43:25 +02:00
Philipp Oppermann
94d14d8d62 Run cargo update for bootloader crate 2025-08-18 09:42:41 +02:00
Philipp Oppermann
7172bed760 Merge branch 'post-09' into post-10 2025-08-07 13:09:45 +02:00
Philipp Oppermann
4f48a36887 Merge branch 'post-08' into post-09 2025-08-07 13:09:45 +02:00
Philipp Oppermann
5ef9960d51 Merge branch 'post-09' into post-10 2025-08-07 13:08:03 +02:00
Philipp Oppermann
99432ab712 Merge branch 'post-08' into post-09 2025-08-07 13:08:03 +02:00
Philipp Oppermann
569232322e Run cargo fmt for post-10 2025-03-27 16:14:35 +01:00
Philipp Oppermann
27b56832c1 Merge branch 'post-08' into post-09 2025-03-27 16:13:38 +01:00
Philipp Oppermann
34195ec8b7 Merge branch 'post-09' into post-10 2025-03-27 16:13:38 +01:00
Philipp Oppermann
a7c5741ab5 Merge branch 'post-08' into post-09 2025-03-27 16:13:24 +01:00
Philipp Oppermann
9799487962 Merge branch 'post-09' into post-10 2025-03-27 16:13:24 +01:00
Philipp Oppermann
d43aa8aebf Merge branch 'post-09' into post-10 2025-03-27 15:51:56 +01:00
Philipp Oppermann
2049f23abb Merge branch 'post-08' into post-09 2025-03-27 15:51:38 +01:00
Philipp Oppermann
dc03bde076 Merge branch 'post-09' into post-10 2025-03-27 15:23:08 +01:00
Philipp Oppermann
3a988748de Unsafe operations in unsafe functions require an unsafe block since Rust 2024 2025-03-27 15:21:52 +01:00
Philipp Oppermann
e8f6e7300d Merge branch 'post-09' into post-10 2025-03-27 15:15:29 +01:00
Philipp Oppermann
889ceba24a Merge branch 'post-08' into post-09 2025-03-27 15:14:37 +01:00
Philipp Oppermann
d849a7dea5 Merge branch 'post-09' into post-10 2025-03-24 11:09:24 +01:00
Philipp Oppermann
bb2c57e1b4 Merge branch 'post-08' into post-09 2025-03-24 11:09:24 +01:00
Philipp Oppermann
722093e2c4 Merge branch 'post-09' into post-10 2025-02-10 12:36:07 +01:00
Philipp Oppermann
ba7b36aa21 Merge branch 'post-08' into post-09 2025-02-10 12:36:07 +01:00
Philipp Oppermann
4dd9c6bce7 Merge branch 'post-09' into post-10 2025-02-10 11:16:22 +01:00
Philipp Oppermann
28c9558a7a Merge branch 'post-08' into post-09 2025-02-10 11:16:22 +01:00
Philipp Oppermann
f63e0dacca Merge branch 'post-09' into post-10 2025-01-15 19:58:30 +01:00
Philipp Oppermann
bb3beb22da Merge branch 'post-08' into post-09 2025-01-15 19:58:30 +01:00
Philipp Oppermann
3743997479 Merge branch 'post-09' into post-10 2024-05-30 11:00:16 +02:00
Philipp Oppermann
2870ac4e13 Merge branch 'post-08' into post-09 2024-05-30 10:59:56 +02:00
Philipp Oppermann
486975e4dc Merge branch 'post-09' into post-10 2024-04-30 15:39:16 +02:00
Philipp Oppermann
c250dd0a91 Merge branch 'post-08' into post-09 2024-04-30 15:39:16 +02:00
Philipp Oppermann
268b5b6856 Merge branch 'post-09' into post-10 2024-02-16 15:59:40 +01:00
Philipp Oppermann
2fdc7c3b5c Merge branch 'post-08' into post-09 2024-02-16 15:59:40 +01:00
Philipp Oppermann
d54e691261 Merge branch 'post-09' into post-10 2024-02-16 13:23:46 +01:00
Philipp Oppermann
be58db8907 Merge branch 'post-08' into post-09 2024-02-16 13:22:33 +01:00
Philipp Oppermann
1550e83094 Merge branch 'post-09' into post-10 2024-02-16 13:14:09 +01:00
Philipp Oppermann
b654651a85 Merge branch 'post-08' into post-09 2024-02-16 13:14:09 +01:00
Philipp Oppermann
cd244cc604 Merge branch 'post-09' into post-10 2024-02-16 12:39:56 +01:00
Philipp Oppermann
bf7cf4c65d Merge branch 'post-08' into post-09 2024-02-16 12:39:56 +01:00
Philipp Oppermann
6b51fa467e Merge branch 'post-09' into post-10 2024-01-28 11:45:38 +01:00
Philipp Oppermann
4343f9be6a Merge branch 'post-08' into post-09 2024-01-28 11:45:38 +01:00
Philipp Oppermann
92f197c2e5 Merge pull request #1216 from phil-opp/remove-alloc-error-handler
The `#[alloc_error_handler]` attribute was removed
2023-04-29 12:20:26 +02:00
Philipp Oppermann
af909cab1e The #[alloc_error_handler] attribute was removed
Allocation errors now always panic.
2023-04-29 12:13:06 +02:00
Philipp Oppermann
b6437c5cc1 Merge branch 'post-08' into post-09 2022-09-25 11:32:07 +02:00
Philipp Oppermann
5fc6566d45 Merge branch 'post-09' into post-10 2022-09-25 11:32:07 +02:00
Philipp Oppermann
ee550a64e0 Merge branch 'post-08' into post-09 2022-04-08 10:07:31 +02:00
Philipp Oppermann
f0149947cf Merge branch 'post-09' into post-10 2022-04-08 10:07:31 +02:00
Philipp Oppermann
a249900aed Merge branch 'post-08' into post-09 2022-01-18 10:06:44 +01:00
Philipp Oppermann
09a3ac4f80 Merge branch 'post-09' into post-10 2022-01-18 10:06:44 +01:00
Philipp Oppermann
e56cd71689 Merge branch 'post-08' into post-09 2021-12-22 09:27:53 +01:00
Philipp Oppermann
506a1d1961 Merge branch 'post-09' into post-10 2021-12-22 09:27:53 +01:00
Philipp Oppermann
17e1ae2508 Merge branch 'post-08' into post-09 2021-12-21 13:56:10 +01:00
Philipp Oppermann
e41ff18ea0 Merge branch 'post-09' into post-10 2021-12-21 13:56:10 +01:00
Philipp Oppermann
f345162ee5 Merge branch 'post-08' into post-09 2021-08-22 14:44:44 +02:00
Philipp Oppermann
0af790efa6 Merge branch 'post-09' into post-10 2021-08-22 14:44:44 +02:00
Philipp Oppermann
8452f2617a Merge branch 'post-09' into post-10
# Conflicts:
#	README.md
2021-05-21 19:57:58 +02:00
Philipp Oppermann
01f42c65e8 Merge branch 'post-08' into post-09
# Conflicts:
#	README.md
2021-05-21 19:57:31 +02:00
Philipp Oppermann
71e6fb1c40 Merge branch 'post-09' into post-10 2021-05-20 14:33:10 +02:00
Philipp Oppermann
3c1db5e79f Merge branch 'post-08' into post-09 2021-05-20 14:33:10 +02:00
Philipp Oppermann
f2d93a4e27 Update linked_list_allocator dependency to v0.9.0 2021-05-17 12:50:29 +02:00
Philipp Oppermann
0e1efb591c Merge branch 'post-08' into post-09 2021-05-17 12:47:38 +02:00
Philipp Oppermann
31d907a1f2 Merge branch 'post-09' into post-10 2021-05-17 12:47:38 +02:00
Philipp Oppermann
6c161ff3e0 Merge branch 'post-08' into post-09 2021-05-17 12:45:11 +02:00
Philipp Oppermann
62378b25df Merge branch 'post-09' into post-10 2021-05-17 12:45:11 +02:00
Philipp Oppermann
66d0d5d11c Merge branch 'post-08' into post-09 2021-05-17 11:47:14 +02:00
Philipp Oppermann
51caf33232 Merge branch 'post-09' into post-10 2021-05-17 11:47:14 +02:00
Philipp Oppermann
b5d4b9b212 Merge branch 'post-08' into post-09 2021-05-17 11:44:50 +02:00
Philipp Oppermann
7653ffcb40 Merge branch 'post-09' into post-10 2021-05-17 11:44:50 +02:00
Philipp Oppermann
3c2b79b1f0 Merge branch 'post-08' into post-09 2021-05-17 11:41:30 +02:00
Philipp Oppermann
20dce91c5b Merge branch 'post-09' into post-10 2021-05-17 11:41:30 +02:00
Philipp Oppermann
b19100a021 Run cargo update for linked_list_allocator crate 2021-05-17 11:30:58 +02:00
Philipp Oppermann
8f20817ea3 Merge branch 'post-08' into post-09 2021-05-17 11:30:02 +02:00
Philipp Oppermann
abb90be792 Merge branch 'post-09' into post-10 2021-05-17 11:30:02 +02:00
Philipp Oppermann
d21dbc7c58 Merge branch 'post-08' into post-09 2021-05-17 11:29:23 +02:00
Philipp Oppermann
98c9de82b5 Merge branch 'post-09' into post-10 2021-05-17 11:29:23 +02:00
Philipp Oppermann
3532a12264 Merge branch 'post-08' into post-09 2021-03-10 09:23:02 +01:00
Philipp Oppermann
ffd34a58f9 Merge branch 'post-09' into post-10 2021-03-10 09:23:02 +01:00
Philipp Oppermann
4bcfdf4b03 Merge branch 'post-08' into post-09 2021-03-10 09:15:58 +01:00
Philipp Oppermann
2e5107d6e8 Merge branch 'post-09' into post-10 2021-03-10 09:15:58 +01:00
Philipp Oppermann
c79bf064c8 Merge branch 'post-08' into post-09 2021-03-10 09:13:39 +01:00
Philipp Oppermann
9783bf99ca Merge branch 'post-09' into post-10 2021-03-10 09:13:39 +01:00
Philipp Oppermann
71a70a3b95 Merge branch 'post-08' into post-09 2021-03-10 08:53:42 +01:00
Philipp Oppermann
ccc507a243 Merge branch 'post-09' into post-10 2021-03-10 08:53:42 +01:00
Philipp Oppermann
722c5579de Merge branch 'post-08' into post-09 2021-02-02 11:06:38 +01:00
Philipp Oppermann
8ca3aa3846 Merge branch 'post-09' into post-10 2021-02-02 11:06:38 +01:00
Philipp Oppermann
31d3eef0da Merge branch 'post-08' into post-09 2021-02-02 10:52:06 +01:00
Philipp Oppermann
0404f437f9 Merge branch 'post-09' into post-10 2021-02-02 10:52:06 +01:00
Philipp Oppermann
ce20cc8661 Merge branch 'post-08' into post-09 2020-11-22 13:46:58 +01:00
Philipp Oppermann
162071d611 Merge branch 'post-09' into post-10 2020-11-22 13:46:58 +01:00
Philipp Oppermann
3a230d0624 Remove dangerous create_example_mapping test function 2020-10-08 17:01:55 +02:00
Philipp Oppermann
76282b9981 Merge branch 'post-09' into post-10 2020-10-02 23:37:44 +02:00
Philipp Oppermann
93844bee41 Merge branch 'post-08' into post-09 2020-10-02 23:36:43 +02:00
Philipp Oppermann
c1133b0948 Merge branch 'post-09' into post-10 2020-09-29 12:22:06 +02:00
Philipp Oppermann
92238b15b0 Merge branch 'post-08' into post-09 2020-09-29 12:22:06 +02:00
Philipp Oppermann
6742a16d50 Merge branch 'post-09' into post-10 2020-09-29 12:19:54 +02:00
Philipp Oppermann
624596adf1 Merge branch 'post-08' into post-09 2020-09-29 12:19:54 +02:00
Philipp Oppermann
4e08f97310 Run cargo update for linked-list-allocator
To fix build on latest nightly.
2020-09-24 10:34:22 +02:00
Philipp Oppermann
ff72429a55 Merge branch 'post-08' into post-09 2020-09-24 10:28:11 +02:00
Philipp Oppermann
aa800ddc83 Merge branch 'post-09' into post-10 2020-09-24 10:28:11 +02:00
Philipp Oppermann
deb95c5ead Run cargo update for post-10 2020-09-24 09:10:53 +02:00
Philipp Oppermann
d820839541 Merge branch 'post-09' into post-10 2020-09-24 09:10:36 +02:00
Philipp Oppermann
df3a464cec Merge branch 'post-08' into post-09 2020-09-24 09:10:19 +02:00
Philipp Oppermann
6ebeb28fdb Merge branch 'post-09' into post-10 2020-08-16 18:03:09 +02:00
Philipp Oppermann
c2ef594a78 Merge branch 'post-08' into post-09 2020-08-16 18:03:09 +02:00
Philipp Oppermann
f48eed487c Merge branch 'post-09' into post-10 2020-08-16 17:59:56 +02:00
Philipp Oppermann
d2e7a4a970 Merge branch 'post-08' into post-09 2020-08-16 17:59:56 +02:00
Philipp Oppermann
287fed94ef Merge branch 'post-09' into post-10 2020-07-17 15:57:35 +02:00
Philipp Oppermann
6bbaf9de16 Merge branch 'post-08' into post-09 2020-07-17 15:57:35 +02:00
Philipp Oppermann
9af48bae17 Merge branch 'post-09' into post-10 2020-07-17 11:48:35 +02:00
Philipp Oppermann
4cec056568 Merge branch 'post-08' into post-09 2020-07-17 11:48:35 +02:00
Philipp Oppermann
d215eb07c2 Add alloc crate to build-std crates 2020-07-17 11:29:11 +02:00
Philipp Oppermann
69c7df8a30 Merge branch 'post-09' into post-10 2020-07-17 11:28:30 +02:00
Philipp Oppermann
b7835f3976 Merge branch 'post-08' into post-09 2020-07-17 11:28:04 +02:00
Philipp Oppermann
472ddcc696 Merge branch 'post-08' into post-09 2020-07-17 11:25:03 +02:00
Philipp Oppermann
e68f7a1d31 Merge branch 'post-09' into post-10 2020-06-08 12:30:28 +02:00
Philipp Oppermann
832ab43bdd Merge branch 'post-08' into post-09 2020-06-08 12:30:28 +02:00
Philipp Oppermann
e7fd27b648 Remove superfluous printing from heap_allocation tests 2020-06-08 12:08:25 +02:00
Philipp Oppermann
cecab1a310 Merge branch 'post-08' into post-09 2020-06-08 12:06:37 +02:00
Philipp Oppermann
9809ea57ae Merge branch 'post-09' into post-10 2020-06-08 12:06:37 +02:00
Philipp Oppermann
b567d06108 Improve simple_allocation test
Proposed in https://github.com/phil-opp/blog_os/issues/627#issuecomment-632578270.
2020-05-22 10:54:49 +02:00
Philipp Oppermann
8b90c04c62 Merge branch 'post-08' into post-09 2020-05-21 09:29:56 +02:00
Philipp Oppermann
384902502c Merge branch 'post-09' into post-10 2020-05-21 09:29:56 +02:00
Philipp Oppermann
5e510e41ee Merge branch 'post-08' into post-09 2020-05-20 14:56:19 +02:00
Philipp Oppermann
0db15e5ee5 Merge branch 'post-09' into post-10 2020-05-20 14:56:19 +02:00
Philipp Oppermann
44ab90f92d Update allocator code for x86_64 v0.11.0 2020-05-20 14:30:48 +02:00
Philipp Oppermann
7a5d91cb96 Merge branch 'post-09' into post-10 2020-05-20 14:29:43 +02:00
Philipp Oppermann
491889a237 Update paging code for x86_64 v0.11.0 2020-05-20 14:29:36 +02:00
Philipp Oppermann
a2f07828e4 Merge branch 'post-08' into post-09 2020-05-20 14:27:06 +02:00
Philipp Oppermann
1eab81f58d Merge branch 'post-09' into post-10 2020-05-20 14:09:09 +02:00
Philipp Oppermann
d94b9513e7 Merge branch 'post-08' into post-09 2020-05-20 14:08:32 +02:00
Philipp Oppermann
02c36bae29 Merge branch 'post-09' into post-10 2020-03-08 14:39:38 +01:00
Philipp Oppermann
70deb3168e Merge branch 'post-08' into post-09 2020-03-08 14:39:38 +01:00
Philipp Oppermann
7b0d8f05ba Fix code for x86_64 v0.9.5 update 2020-03-08 14:30:33 +01:00
Philipp Oppermann
f230ee4258 Merge branch 'post-09' into post-10 2020-03-08 14:29:00 +01:00
Philipp Oppermann
a5d409b777 Merge branch 'post-08' into post-09 2020-03-08 14:28:03 +01:00
Philipp Oppermann
39f14b6d0b Merge pull request #763 from phil-opp/post-10-update-linked-list-alloc
Update linked_list_allocator to v0.8.0
2020-03-06 11:58:23 +01:00
Philipp Oppermann
dd1daf2652 Update linked_list_allocator to v0.8.0 2020-03-06 11:47:49 +01:00
Philipp Oppermann
9a415c85b9 Merge branch 'post-09' into post-10 2020-02-26 12:47:51 +01:00
Philipp Oppermann
79a0172ace Merge branch 'post-08' into post-09 2020-02-26 12:47:32 +01:00
Philipp Oppermann
c7cc718ae3 Merge branch 'post-09' into post-10 2020-02-26 12:22:06 +01:00
Philipp Oppermann
8fc746555d Merge branch 'post-08' into post-09 2020-02-26 12:21:28 +01:00
Philipp Oppermann
5ed04baab0 Update linked_list_allocator dependency 2020-02-04 09:38:52 +01:00
Philipp Oppermann
882c83f9de Update many_boxes test to scale with heap size (#716)
Instead of using a hardcoded number of boxes, use the HEAP_SIZE constant. This ensures that we get a test failure because of an out-of-memory error when the allocator does not reuse freed memory.
2020-01-09 12:58:29 +01:00
Philipp Oppermann
869a69e531 Move #[global_allocator] into allocator module (#714)
The Rust issue that the #[global_allocator] cannot be defined in submodules was fixed.
2020-01-08 12:38:06 +01:00
Philipp Oppermann
817267e51c Update Github Actions badge for post-10 2019-12-12 09:32:59 +01:00
Philipp Oppermann
9e75078dab Merge branch 'post-09' into post-10 2019-12-12 09:32:46 +01:00
Philipp Oppermann
ed3af8e984 Update Github Actions badge for post-09 2019-12-12 09:32:30 +01:00
Philipp Oppermann
1d1075b35e Merge branch 'post-08' into post-09 2019-12-12 09:32:16 +01:00
Philipp Oppermann
41f38d92f2 Merge branch 'post-09' into post-10 2019-12-12 09:23:31 +01:00
Philipp Oppermann
8eb44dcbd5 Merge branch 'post-08' into post-09 2019-12-12 09:23:31 +01:00
Philipp Oppermann
3ac5318c94 Remove now unneeded unsafe block
The `map_to` method is safe since x86_64 0.8.1.
2019-12-11 16:47:45 +01:00
Philipp Oppermann
e94a489a31 Merge branch 'post-09' into post-10 2019-12-11 16:38:08 +01:00
Philipp Oppermann
f392d8a7f5 Merge pull request #703 from phil-opp/post-09-fix
Update frame allocation code to x86_64 0.8.1
2019-12-11 16:37:49 +01:00
Philipp Oppermann
c7bc26d8ee Update frame allocation code to x86_64 0.8.1 2019-12-11 16:26:38 +01:00
Philipp Oppermann
9da9ecb515 Merge branch 'post-09' into post-10 2019-12-10 17:31:24 +01:00
Philipp Oppermann
6c1594ea24 Merge branch 'post-08' into post-09 2019-12-10 17:31:24 +01:00
Philipp Oppermann
f226ba0c3f Merge branch 'post-09' into post-10 2019-12-10 17:17:53 +01:00
Philipp Oppermann
94aa2c4093 Merge branch 'post-08' into post-09 2019-12-10 17:17:53 +01:00
Philipp Oppermann
c1fc7171fb Merge branch 'post-09' into post-10 2019-12-10 16:55:41 +01:00
Philipp Oppermann
259742a5e3 Merge branch 'post-08' into post-09 2019-12-10 16:55:41 +01:00
Philipp Oppermann
cf527e9ce7 Update post-10 to new lockfile format 2019-11-28 14:08:28 +01:00
Philipp Oppermann
c891acb234 Merge branch 'post-09' into post-10 2019-11-28 14:08:08 +01:00
Philipp Oppermann
6876e82fc5 Merge branch 'post-08' into post-09 2019-11-28 14:07:43 +01:00
Philipp Oppermann
b9a0702bc0 Merge branch 'post-09' into post-10 2019-11-25 13:35:20 +01:00
Philipp Oppermann
84ddda6a3f Merge branch 'post-08' into post-09 2019-11-25 13:35:20 +01:00
Philipp Oppermann
2919cbdefc Merge branch 'post-09' into post-10 2019-11-25 13:25:15 +01:00
Philipp Oppermann
f85664fd6b Merge branch 'post-08' into post-09 2019-11-25 13:25:15 +01:00
Philipp Oppermann
059ea76848 Merge branch 'post-09' into post-10 2019-11-22 16:33:23 +01:00
Philipp Oppermann
a65573b061 Merge branch 'post-08' into post-09 2019-11-22 16:33:23 +01:00
Philipp Oppermann
2f085b7310 Merge branch 'post-09' into post-10 2019-11-22 16:05:13 +01:00
Philipp Oppermann
385004cab2 Merge branch 'post-08' into post-09 2019-11-22 16:05:13 +01:00
Philipp Oppermann
cc713e4570 Merge branch 'post-09' into post-10 2019-11-22 15:57:18 +01:00
Philipp Oppermann
9696612b2b Merge branch 'post-08' into post-09 2019-11-22 15:57:18 +01:00
Philipp Oppermann
b3066e9a78 Merge branch 'post-09' into post-10 2019-10-08 19:44:38 +02:00
Philipp Oppermann
d5d7db0de6 Merge branch 'post-08' into post-09 2019-10-08 19:44:38 +02:00
Philipp Oppermann
66c3a0de76 Merge branch 'post-09' into post-10 2019-09-25 13:21:18 +02:00
Philipp Oppermann
45375d1f1b Merge branch 'post-08' into post-09 2019-09-25 13:21:06 +02:00
Philipp Oppermann
96d9de76b0 Fix: memory::init expects a VirtAddr 2019-09-15 10:56:15 +02:00
Philipp Oppermann
f56e4d24e3 Add missing import 2019-09-14 19:08:53 +02:00
Philipp Oppermann
8d3d712cef Merge branch 'post-09' into post-10 2019-09-14 19:06:30 +02:00
Philipp Oppermann
4897e9c4d5 Merge pull request #667 from phil-opp/post-09-offset_page_table
Update post-09 branch for improved Paging Implementation Post
2019-09-14 19:04:53 +02:00
Philipp Oppermann
5cced71fb0 Directly use OffsetPageTable for create_example_mapping instead of impl trait 2019-09-14 18:33:37 +02:00
Philipp Oppermann
7ec727f69f Update comment 2019-09-14 18:33:16 +02:00
Philipp Oppermann
5f66b437d5 Merge branch 'post-09' into post-10 2019-09-13 17:43:25 +02:00
Philipp Oppermann
8059c229c5 Merge branch 'post-08' into post-09 2019-09-13 17:43:25 +02:00
Philipp Oppermann
0694f29946 Merge branch 'post-09' into post-10 2019-09-13 10:53:50 +02:00
Philipp Oppermann
bc2099d31d Merge branch 'post-08' into post-09 2019-09-13 10:53:50 +02:00
Philipp Oppermann
211ec3898b Use OffsetPageTable instead of MappedPageTable 2019-09-11 13:40:36 +02:00
Philipp Oppermann
889c0771d6 Merge branch 'post-09' into post-10 2019-09-11 13:33:07 +02:00
Philipp Oppermann
2227fa434f Merge branch 'post-08' into post-09 2019-09-11 13:29:14 +02:00
Philipp Oppermann
e74d9753f2 Merge branch 'post-09' into post-10 2019-09-11 11:21:15 +02:00
Philipp Oppermann
23d554548a Merge branch 'post-08' into post-09 2019-09-11 11:21:15 +02:00
Philipp Oppermann
9fc71547d7 Run cargo update 2019-09-11 10:59:31 +02:00
Philipp Oppermann
caa9d8b0e4 Merge branch 'post-09' into post-10 2019-09-11 10:59:18 +02:00
Philipp Oppermann
091f7ef153 Merge branch 'post-08' into post-09 2019-09-11 10:58:56 +02:00
Philipp Oppermann
29512ddd31 Merge branch 'post-09' into post-10 2019-09-11 10:32:57 +02:00
Philipp Oppermann
38d606b4d1 Merge branch 'post-08' into post-09 2019-09-11 10:32:57 +02:00
Philipp Oppermann
a7943e7e55 Merge branch 'post-09' into post-10 2019-09-11 10:12:46 +02:00
Philipp Oppermann
ae75d8b209 Merge branch 'post-08' into post-09 2019-09-11 10:12:46 +02:00
Philipp Oppermann
bcdadec5b6 Merge branch 'post-09' into post-10 2019-09-11 10:11:25 +02:00
Philipp Oppermann
e0d5cdd625 Merge branch 'post-08' into post-09 2019-09-11 10:11:25 +02:00
Philipp Oppermann
17f8866264 Merge branch 'post-09' into post-10 2019-09-11 10:02:41 +02:00
Philipp Oppermann
3f95494ae8 Merge branch 'post-08' into post-09 2019-09-11 10:02:41 +02:00
Philipp Oppermann
a7ef4012d0 Merge branch 'post-09' into post-10 2019-09-10 11:12:54 +02:00
Philipp Oppermann
cabbbec72f Merge branch 'post-08' into post-09 2019-09-10 11:12:54 +02:00
Philipp Oppermann
6f07c2b666 Merge branch 'post-09' into post-10 2019-09-10 10:21:14 +02:00
Philipp Oppermann
1dd7f03a7a Merge branch 'post-08' into post-09 2019-09-10 10:21:14 +02:00
Philipp Oppermann
e89c77398d Merge branch 'post-09' into post-10 2019-08-07 12:40:04 +02:00
Philipp Oppermann
66c4eae9cf Merge branch 'post-08' into post-09 2019-08-07 12:40:04 +02:00
Philipp Oppermann
f3a7689f33 Merge branch 'post-09' into post-10 2019-07-22 10:46:35 +02:00
Philipp Oppermann
e721878e4b Merge branch 'post-08' into post-09 2019-07-22 10:46:35 +02:00
Philipp Oppermann
14d0e07b3e Merge branch 'post-09' into post-10 2019-07-22 10:36:58 +02:00
Philipp Oppermann
f2eb6cec9a Merge branch 'post-08' into post-09 2019-07-22 10:36:51 +02:00
Philipp Oppermann
9651eb7a3b Merge branch 'post-09' into post-10 2019-07-18 10:17:50 +02:00
Philipp Oppermann
bc4ddcef05 Merge branch 'post-08' into post-09 2019-07-18 10:17:37 +02:00
Philipp Oppermann
89e3e2b190 Use correct build badge in post-10 Readme 2019-07-07 11:26:15 +02:00
Philipp Oppermann
004282138c Merge branch 'post-09' into post-10 2019-07-07 11:25:48 +02:00
Philipp Oppermann
4580b85fe2 Use correct build badge in post-09 Readme 2019-07-07 11:25:40 +02:00
Philipp Oppermann
8c575388cf Merge pull request #626 from phil-opp/code-heap
Code for new heap allocation post
2019-06-26 21:30:42 +02:00
Philipp Oppermann
4792ec41b1 Adjust comments to be equal with post 2019-06-26 21:08:08 +02:00
Philipp Oppermann
df75f7f4e8 Add an integration test for heap allocation 2019-06-26 17:45:32 +02:00
Philipp Oppermann
5cf3884396 Run cargo fmt 2019-06-26 16:59:38 +02:00
Philipp Oppermann
e5b6ba38ac Update Readme for new post 2019-06-26 16:33:20 +02:00
Philipp Oppermann
f429a8ab03 Example use of Box, Vec, and Rc in kernel_main 2019-06-26 15:06:40 +02:00
Philipp Oppermann
d7484ab48b Use linked_list_allocator crate instead of dummy allocator 2019-06-26 15:05:57 +02:00
Philipp Oppermann
06fc63028a Create a heap memory area 2019-06-26 13:14:56 +02:00
Philipp Oppermann
d4623419b0 Try to use Box type in main.rs
This causes an allocation error because the Dummy::alloc function always returns a null pointer.
2019-06-26 12:34:57 +02:00
Philipp Oppermann
417c44159e Add a alloc_error_handler function 2019-06-26 12:34:57 +02:00
Philipp Oppermann
ebbc6d55d2 Use dummy allocator as global allocator 2019-06-26 12:34:57 +02:00
Philipp Oppermann
c0367074ac Create an allocator module with a dummy allocator 2019-06-26 12:34:57 +02:00
Philipp Oppermann
48e2175bac Add a dependency on the alloc crate 2019-06-26 12:34:57 +02:00
Philipp Oppermann
45e1e99390 Merge branch 'post-08' into post-09 2019-06-23 18:07:34 +02:00
Philipp Oppermann
b5793c34c6 Merge branch 'post-08' into post-09 2019-06-17 17:28:32 +02:00
Philipp Oppermann
67ee45090d Merge branch 'post-08' into post-09 2019-05-23 12:39:35 +02:00
Philipp Oppermann
64d1a587e7 Merge branch 'post-08' into post-09 2019-05-09 15:38:47 +02:00
Philipp Oppermann
fbe279831e Merge branch 'post-08' into post-09 2019-05-09 14:59:55 +02:00
Philipp Oppermann
375d4d0479 Merge pull request #599 from phil-opp/post-09-new
Update `post-09` branch for version 0.6.0 of `x86_64` crate
2019-05-03 19:41:29 +02:00
Philipp Oppermann
7796d4c14a FrameAllocator is an unsafe trait now
Make `BootInfoFrameAllocator` unsafe because the caller must guarantee that the given memory map is valid.
2019-05-03 19:29:14 +02:00
Philipp Oppermann
78e4b22a2f Merge branch 'post-08' into post-09 2019-05-03 18:36:45 +02:00
Philipp Oppermann
a867450e3b Merge pull request #595 from phil-opp/redesign-frame-allocator
Avoid generic impl trait parameters in BootInfoFrameAllocator
2019-04-30 13:24:43 +02:00
Philipp Oppermann
b5ee44621c Use an import for initializing BootInfoFrameAllocator 2019-04-30 13:10:53 +02:00
Philipp Oppermann
24a9e7abd2 Simplify FrameAllocator implementation using Iterator::nth 2019-04-30 12:47:45 +02:00
Philipp Oppermann
180c77d1f4 Avoid generic impl trait parameters in BootInfoFrameAllocator 2019-04-30 11:14:23 +02:00
Philipp Oppermann
247af45791 Merge branch 'post-08-new' into post-09-new 2019-04-26 15:50:18 +02:00
Philipp Oppermann
fd0646fecf Improve formatting 2019-04-26 15:29:43 +02:00
Philipp Oppermann
c8821cb226 Use entry_point macro in lib.rs too 2019-04-26 15:29:43 +02:00
Philipp Oppermann
2e531850b8 Remove redundant import 2019-04-26 15:29:43 +02:00
Philipp Oppermann
65dbb5ac48 Merge branch 'post-08-new' into post-09-new 2019-04-26 15:28:56 +02:00
Philipp Oppermann
16cf7e8e42 Merge branch 'post-09' into post-10 2019-04-25 11:08:11 +02:00
Philipp Oppermann
19556d9e68 Merge branch 'post-09' into post-10 2019-04-11 15:32:21 +02:00
Philipp Oppermann
338833262c Merge branch 'post-09' into post-10 2019-04-06 17:35:17 +02:00
Philipp Oppermann
77800d9212 Merge branch 'post-09' into post-10 2019-04-06 17:33:49 +02:00
Philipp Oppermann
be618df7f5 Merge branch 'post-09' into post-10 2019-04-06 16:49:18 +02:00
Philipp Oppermann
ff85a2e502 Merge branch 'post-09' into post-10
# Conflicts:
#	README.md
2019-04-03 10:47:15 +02:00
Philipp Oppermann
74675346c9 Merge branch 'post-09' into post-10 2019-03-26 13:26:56 +01:00
Philipp Oppermann
e9344ae046 Remove unneeded into_iter() in init_frame_allocator 2019-03-14 13:20:26 +01:00
Philipp Oppermann
4acf12bb69 Merge branch 'post-09' into post-10 2019-03-14 11:18:40 +01:00
Philipp Oppermann
161d5fe7be Merge pull request #569 from phil-opp/post-10-new
Update post-10 branch for new "Paging Implementation" post
2019-03-14 10:49:55 +01:00
Philipp Oppermann
9bf4ea7341 Use BootInfoFrameAllocator to create a 0xdeadbeaf000 mapping 2019-03-14 10:30:37 +01:00
Philipp Oppermann
a1bf5651fc Create an init_frame_allocator function 2019-03-14 10:30:37 +01:00
Philipp Oppermann
763228c859 Create a generic BootInfoFrameAllocator type 2019-03-14 10:30:37 +01:00
Philipp Oppermann
770af27d75 Create a new mapping and write through it to the screen 2019-03-14 10:30:37 +01:00
Philipp Oppermann
3e59283c19 Create an EmptyFrameAllocator 2019-03-14 10:30:37 +01:00
Philipp Oppermann
6146ccba2d Add a memory::create_example_mapping function 2019-03-14 10:30:37 +01:00
Philipp Oppermann
b0e1527a95 Delete our memory::translate_addr function again 2019-03-14 10:30:37 +01:00
Philipp Oppermann
cb4410c84e Update kernel_main to use MapperAllSizes::translate_addr 2019-03-14 10:30:37 +01:00
Philipp Oppermann
98b5976656 Create a memory::init function that initializes a MappedPageTable 2019-03-14 10:30:37 +01:00
Philipp Oppermann
9335386928 Add and test a memory::translate_addr function 2019-03-14 10:30:37 +01:00
Philipp Oppermann
7c30d62f33 Also show non-empty level 3 table entries 2019-03-14 10:30:37 +01:00
Philipp Oppermann
61683bccda Print non-empty level 4 table entries 2019-03-14 10:30:37 +01:00
Philipp Oppermann
e1ec5159b8 Add boot info argument and use entry_point macro 2019-03-14 10:30:37 +01:00
Philipp Oppermann
7b7d19592f Enable map_physical_memory feature of bootloader 2019-03-14 10:30:37 +01:00
Philipp Oppermann
e387c0b6b8 Create a memory::active_level_4_table function 2019-03-14 10:30:37 +01:00
Philipp Oppermann
d5abc119f3 Update Readme for Paging Implementation post 2019-03-14 10:30:37 +01:00
Philipp Oppermann
59da6e5620 Update bootloader to version 0.4.0 2019-03-14 10:30:37 +01:00
Philipp Oppermann
ef1cc0ed4f Reset code to post-09 branch for new 'Paging Implementation' post 2019-03-14 10:20:46 +01:00
Philipp Oppermann
90f0caec1a Merge branch 'post-09' into post-10 2019-03-14 10:17:37 +01:00
Philipp Oppermann
5c0fb63f33 Merge branch 'post-09' into post-10 2019-03-12 17:48:43 +01:00
Philipp Oppermann
036a8e7608 Merge branch 'post-09' into post-10 2019-03-09 14:21:12 +01:00
Philipp Oppermann
10c4d0509d Update post-10 code for changes in x86_64 0.5.0
We no longer need a custom translate function as we can directly use MapperAllSizes::translate_addr.
2019-03-09 12:40:27 +01:00
Philipp Oppermann
57998ea4f8 Merge branch 'post-09' into post-10 2019-03-09 12:39:25 +01:00
Philipp Oppermann
ef9a629ddc Merge branch 'post-09' into post-10 2019-02-25 17:04:56 +01:00
Philipp Oppermann
d974cf5200 Merge branch 'post-09' into post-10 2019-02-25 16:37:31 +01:00
Philipp Oppermann
36d6c6d0e9 Merge branch 'post-09' into post-10 2019-02-12 19:31:09 +01:00
Philipp Oppermann
ff49104764 Merge branch 'post-09' into post-10 2019-02-07 18:48:39 +01:00
Philipp Oppermann
03e43da9f9 Merge branch 'post-09' into post-10 2019-02-07 16:17:54 +01:00
Philipp Oppermann
e696d65b60 Merge branch 'post-09' into post-10 2019-02-05 15:23:49 +01:00
Philipp Oppermann
ebf626061f Merge branch 'post-09' into post-10 2019-02-05 14:59:15 +01:00
Philipp Oppermann
c3d023ad40 Merge branch 'post-09' into post-10 2019-02-05 10:46:08 +01:00
Philipp Oppermann
0a10b3e784 Merge branch 'post-09' into post-10 2019-02-05 10:45:12 +01:00
Philipp Oppermann
e0f66a8196 Merge branch 'post-09' into post-10 2019-01-29 12:16:54 +01:00
Philipp Oppermann
e5dfbd4b23 Merge branch 'post-09' into post-10 2019-01-28 11:51:35 +01:00
Philipp Oppermann
5ad2962389 Merge branch 'post-09' into post-10 2019-01-28 11:44:14 +01:00
Philipp Oppermann
a56e22b6fc Use BootInfoFrameAllocator instead of EmptyFrameAllocator 2019-01-28 11:30:27 +01:00
Philipp Oppermann
67f536d7c6 Add a BootInfoFrameAllocator 2019-01-28 11:28:51 +01:00
Philipp Oppermann
741224411b Use the BootInfo struct passed by the bootloader 2019-01-28 11:24:16 +01:00
Philipp Oppermann
818417d119 Try to create example mapping for page 0xdeadbeaf000 2019-01-28 11:23:46 +01:00
Philipp Oppermann
f272785861 Create example mapping for page 0x1000 2019-01-28 11:19:46 +01:00
Philipp Oppermann
5d807ee622 Run rustfmt 2019-01-28 11:19:34 +01:00
Philipp Oppermann
90c3cdf0f3 Update Readme for Advanced Paging post 2019-01-27 17:14:58 +01:00
Philipp Oppermann
2bc233b2f6 Merge branch 'post-09' into post-10 2019-01-27 17:14:12 +01:00
Philipp Oppermann
051b23f577 Merge branch 'post-09' into post-10 2019-01-27 16:33:54 +01:00
Philipp Oppermann
f2bc2d33f0 Rewrite translation function on top of RecursivePageTable 2019-01-27 14:38:49 +01:00
Philipp Oppermann
38a121a887 Test translate_addr by translating some virtual addresses 2019-01-27 14:38:49 +01:00
Philipp Oppermann
8b380f0692 Create a new memory module with a translate_addr function 2019-01-27 14:38:49 +01:00
10 changed files with 341 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
[unstable]
build-std = ["core", "compiler_builtins"]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]
[build]

107
Cargo.lock generated
View File

@@ -3,16 +3,28 @@
version = 4
[[package]]
name = "bit_field"
version = "0.10.1"
name = "autocfg"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]]
name = "bit_field"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
[[package]]
name = "bitflags"
version = "1.2.1"
version = "1.3.2"
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]]
name = "blog_os"
@@ -20,9 +32,10 @@ version = "0.1.0"
dependencies = [
"bootloader",
"lazy_static",
"linked_list_allocator",
"pc-keyboard",
"pic8259",
"spin",
"spin 0.5.2",
"uart_16550",
"volatile 0.2.7",
"x86_64",
@@ -30,17 +43,36 @@ dependencies = [
[[package]]
name = "bootloader"
version = "0.9.31"
version = "0.9.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "974e79cf1b0b737839f01330fb5393095daf1124d52693696494e32523ae9ef5"
checksum = "7bdfddac270bbdd45903296bc1caf29a7fdce6b326aaf0bbab7f04c5f98b7447"
[[package]]
name = "lazy_static"
version = "1.4.0"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
dependencies = [
"spin",
"spin 0.9.8",
]
[[package]]
name = "linked_list_allocator"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "549ce1740e46b291953c4340adcd74c59bcf4308f4cac050fd33ba91b7168f4a"
dependencies = [
"spinning_top",
]
[[package]]
name = "lock_api"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
@@ -51,13 +83,25 @@ checksum = "ed089a1fbffe3337a1a345501c981f1eb1e47e69de5a40e852433e12953c3174"
[[package]]
name = "pic8259"
version = "0.10.1"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08cc920d83ee33c0f9b73aa441e75468bf2d10c959a3eb6260cf720b05ac91a1"
checksum = "cb844b5b01db1e0b17938685738f113bfc903846f18932b378bc0eabfa40e194"
dependencies = [
"x86_64",
]
[[package]]
name = "rustversion"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "spin"
version = "0.5.2"
@@ -65,12 +109,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "uart_16550"
version = "0.2.14"
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "503a6c0e6d82daa87985e662d120c0176b09587c92a68db22781b28ae95405dd"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "spinning_top"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0"
dependencies = [
"bitflags",
"lock_api",
]
[[package]]
name = "uart_16550"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e"
dependencies = [
"bitflags 1.3.2",
"rustversion",
"x86_64",
]
@@ -82,17 +142,18 @@ checksum = "f6b06ad3ed06fef1713569d547cdbdb439eafed76341820fb0e0344f29a41945"
[[package]]
name = "volatile"
version = "0.4.4"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4c2dbd44eb8b53973357e6e207e370f0c1059990df850aca1eca8947cf464f0"
checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
[[package]]
name = "x86_64"
version = "0.14.7"
version = "0.14.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb611915c917c6296d11e23f71ff1ecfe49c5766daba92cd3df52df6b58285b6"
checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491"
dependencies = [
"bit_field",
"bitflags",
"volatile 0.4.4",
"bitflags 2.9.2",
"rustversion",
"volatile 0.4.6",
]

View File

@@ -13,13 +13,14 @@ name = "stack_overflow"
harness = false
[dependencies]
bootloader = "0.9"
bootloader = { version = "0.9", features = ["map_physical_memory"] }
volatile = "0.2.6"
spin = "0.5.2"
x86_64 = "0.14.2"
uart_16550 = "0.2.0"
pic8259 = "0.10.1"
pc-keyboard = "0.7.0"
linked_list_allocator = "0.9.0"
[dependencies.lazy_static]
version = "1.0"
@@ -27,7 +28,7 @@ features = ["spin_no_std"]
[[bin]]
name = "blog_os"
test = false
test = true
bench = false

View File

@@ -1,10 +1,10 @@
# Blog OS (Introduction to Paging)
# Blog OS (Heap Allocation)
[![Build Status](https://github.com/phil-opp/blog_os/workflows/Code/badge.svg?branch=post-08)](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Code%22+branch%3Apost-08)
[![Build Status](https://github.com/phil-opp/blog_os/workflows/Code/badge.svg?branch=post-10)](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Code%22+branch%3Apost-10)
This repository contains the source code for the [Introduction to Paging][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
This repository contains the source code for the [Heap Allocation][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
[post]: https://os.phil-opp.com/paging-introduction/
[post]: https://os.phil-opp.com/heap-allocation/
**Check out the [master branch](https://github.com/phil-opp/blog_os) for more information.**

54
src/allocator.rs Normal file
View File

@@ -0,0 +1,54 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
use linked_list_allocator::LockedHeap;
use x86_64::{
VirtAddr,
structures::paging::{
FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB, mapper::MapToError,
},
};
pub const HEAP_START: usize = 0x_4444_4444_0000;
pub const HEAP_SIZE: usize = 100 * 1024; // 100 KiB
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
pub fn init_heap(
mapper: &mut impl Mapper<Size4KiB>,
frame_allocator: &mut impl FrameAllocator<Size4KiB>,
) -> Result<(), MapToError<Size4KiB>> {
let page_range = {
let heap_start = VirtAddr::new(HEAP_START as u64);
let heap_end = heap_start + HEAP_SIZE - 1u64;
let heap_start_page = Page::containing_address(heap_start);
let heap_end_page = Page::containing_address(heap_end);
Page::range_inclusive(heap_start_page, heap_end_page)
};
for page in page_range {
let frame = frame_allocator
.allocate_frame()
.ok_or(MapToError::FrameAllocationFailed)?;
let flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;
unsafe { mapper.map_to(page, frame, flags, frame_allocator)?.flush() };
}
unsafe {
ALLOCATOR.lock().init(HEAP_START, HEAP_SIZE);
}
Ok(())
}
pub struct Dummy;
unsafe impl GlobalAlloc for Dummy {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should be never called")
}
}

View File

@@ -5,10 +5,13 @@
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"]
extern crate alloc;
use core::panic::PanicInfo;
pub mod allocator;
pub mod gdt;
pub mod interrupts;
pub mod memory;
pub mod serial;
pub mod vga_buffer;
@@ -70,10 +73,15 @@ pub fn hlt_loop() -> ! {
}
}
#[cfg(test)]
use bootloader::{BootInfo, entry_point};
#[cfg(test)]
entry_point!(test_kernel_main);
/// Entry point for `cargo xtest`
#[cfg(test)]
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
fn test_kernel_main(_boot_info: &'static BootInfo) -> ! {
init();
test_main();
hlt_loop();

View File

@@ -4,20 +4,51 @@
#![test_runner(blog_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
extern crate alloc;
use alloc::{boxed::Box, rc::Rc, vec, vec::Vec};
use blog_os::println;
use bootloader::{BootInfo, entry_point};
use core::panic::PanicInfo;
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
use x86_64::registers::control::Cr3;
println!("Hello World{}", "!");
entry_point!(kernel_main);
fn kernel_main(boot_info: &'static BootInfo) -> ! {
use blog_os::allocator;
use blog_os::memory::{self, BootInfoFrameAllocator};
use x86_64::VirtAddr;
println!("Hello World{}", "!");
blog_os::init();
let (level_4_page_table, _) = Cr3::read();
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
let mut mapper = unsafe { memory::init(phys_mem_offset) };
let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) };
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!(
"Level 4 page table at: {:?}",
level_4_page_table.start_address()
"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)]

86
src/memory.rs Normal file
View File

@@ -0,0 +1,86 @@
use bootloader::bootinfo::{MemoryMap, MemoryRegionType};
use x86_64::{
PhysAddr, VirtAddr,
structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB},
};
/// Initialize a new OffsetPageTable.
///
/// This function is unsafe because the caller must guarantee that the
/// complete physical memory is mapped to virtual memory at the passed
/// `physical_memory_offset`. Also, this function must be only called once
/// to avoid aliasing `&mut` references (which is undefined behavior).
pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> {
unsafe {
let level_4_table = active_level_4_table(physical_memory_offset);
OffsetPageTable::new(level_4_table, physical_memory_offset)
}
}
/// Returns a mutable reference to the active level 4 table.
///
/// This function is unsafe because the caller must guarantee that the
/// complete physical memory is mapped to virtual memory at the passed
/// `physical_memory_offset`. Also, this function must be only called once
/// to avoid aliasing `&mut` references (which is undefined behavior).
unsafe fn active_level_4_table(physical_memory_offset: VirtAddr) -> &'static mut PageTable {
use x86_64::registers::control::Cr3;
let (level_4_table_frame, _) = Cr3::read();
let phys = level_4_table_frame.start_address();
let virt = physical_memory_offset + phys.as_u64();
let page_table_ptr: *mut PageTable = virt.as_mut_ptr();
unsafe { &mut *page_table_ptr }
}
/// A FrameAllocator that always returns `None`.
pub struct EmptyFrameAllocator;
unsafe impl FrameAllocator<Size4KiB> for EmptyFrameAllocator {
fn allocate_frame(&mut self) -> Option<PhysFrame> {
None
}
}
/// A FrameAllocator that returns usable frames from the bootloader's memory map.
pub struct BootInfoFrameAllocator {
memory_map: &'static MemoryMap,
next: usize,
}
impl BootInfoFrameAllocator {
/// Create a FrameAllocator from the passed memory map.
///
/// This function is unsafe because the caller must guarantee that the passed
/// memory map is valid. The main requirement is that all frames that are marked
/// as `USABLE` in it are really unused.
pub unsafe fn init(memory_map: &'static MemoryMap) -> Self {
BootInfoFrameAllocator {
memory_map,
next: 0,
}
}
/// Returns an iterator over the usable frames specified in the memory map.
fn usable_frames(&self) -> impl Iterator<Item = PhysFrame> {
// get usable regions from memory map
let regions = self.memory_map.iter();
let usable_regions = regions.filter(|r| r.region_type == MemoryRegionType::Usable);
// map each region to its address range
let addr_ranges = usable_regions.map(|r| r.range.start_addr()..r.range.end_addr());
// transform to an iterator of frame start addresses
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
// create `PhysFrame` types from the start addresses
frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)))
}
}
unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {
fn allocate_frame(&mut self) -> Option<PhysFrame> {
let frame = self.usable_frames().nth(self.next);
self.next += 1;
frame
}
}

60
tests/heap_allocation.rs Normal file
View File

@@ -0,0 +1,60 @@
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(blog_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
extern crate alloc;
use alloc::{boxed::Box, vec::Vec};
use blog_os::allocator::HEAP_SIZE;
use bootloader::{BootInfo, entry_point};
use core::panic::PanicInfo;
entry_point!(main);
fn main(boot_info: &'static BootInfo) -> ! {
use blog_os::allocator;
use blog_os::memory::{self, BootInfoFrameAllocator};
use x86_64::VirtAddr;
blog_os::init();
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
let mut mapper = unsafe { memory::init(phys_mem_offset) };
let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) };
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
test_main();
loop {}
}
#[test_case]
fn simple_allocation() {
let heap_value_1 = Box::new(41);
let heap_value_2 = Box::new(13);
assert_eq!(*heap_value_1, 41);
assert_eq!(*heap_value_2, 13);
}
#[test_case]
fn large_vec() {
let n = 1000;
let mut vec = Vec::new();
for i in 0..n {
vec.push(i);
}
assert_eq!(vec.iter().sum::<u64>(), (n - 1) * n / 2);
}
#[test_case]
fn many_boxes() {
for i in 0..HEAP_SIZE {
let x = Box::new(i);
assert_eq!(*x, i);
}
}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
blog_os::test_panic_handler(info)
}

View File

@@ -3,7 +3,7 @@
"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",
"target-endian": "little",
"target-pointer-width": "64",
"target-pointer-width": 64,
"target-c-int-width": 32,
"os": "none",
"executables": true,