Compare commits

...

328 Commits

Author SHA1 Message Date
Philipp Oppermann
e3e8a3e112 Align the double fault stack through a new wrapper type 2020-02-19 10:27:26 +01:00
Philipp Oppermann
c211412ce2 Update Github Actions badge for post-06 2019-12-12 09:30:51 +01:00
Philipp Oppermann
93d3de6feb Merge branch 'post-05' into post-06 2019-12-12 09:30:37 +01:00
Philipp Oppermann
6dcf5c61fb Update Github Actions badge for post-05 2019-12-12 09:30:17 +01:00
Philipp Oppermann
96683c596b Merge branch 'post-04' into post-05 2019-12-12 09:30:03 +01:00
Philipp Oppermann
029d6bee78 Update Github Actions badge for post-04 2019-12-12 09:29:31 +01:00
Philipp Oppermann
0fc6fedd82 Merge branch 'post-03' into post-04 2019-12-12 09:29:14 +01:00
Philipp Oppermann
0489c09d05 Update Github Actions badge for post-03 2019-12-12 09:28:56 +01:00
Philipp Oppermann
99b139ddff Merge branch 'post-02' into post-03 2019-12-12 09:28:44 +01:00
Philipp Oppermann
651c629ffd Merge branch 'post-05' into post-06 2019-12-12 09:23:30 +01:00
Philipp Oppermann
5ac91e5e38 Merge branch 'post-04' into post-05 2019-12-12 09:23:30 +01:00
Philipp Oppermann
56cf71df9f Merge branch 'post-03' into post-04 2019-12-12 09:23:30 +01:00
Philipp Oppermann
abd2f4c5e2 Merge branch 'post-02' into post-03 2019-12-12 09:23:30 +01:00
Philipp Oppermann
8d8a7e0973 Merge branch 'post-05' into post-06 2019-12-10 17:31:24 +01:00
Philipp Oppermann
ec933ab329 Merge branch 'post-04' into post-05 2019-12-10 17:31:24 +01:00
Philipp Oppermann
adcb547765 Update to x86_64 0.8.1 2019-12-10 17:31:21 +01:00
Philipp Oppermann
423b6e49cc Merge pull request #702 from phil-opp/post-06-fix
Make double fault handlers diverging
2019-12-10 17:17:00 +01:00
Philipp Oppermann
d1cf8000a3 Make double fault handlers diverging
Required by x86_64 0.8.0.
2019-12-10 17:02:46 +01:00
Philipp Oppermann
76483ab6bf Merge branch 'post-04' into post-05 2019-12-10 16:55:41 +01:00
Philipp Oppermann
16c499f966 Merge branch 'post-05' into post-06 2019-12-10 16:55:41 +01:00
Philipp Oppermann
faf097fd06 Merge branch 'post-03' into post-04 2019-12-10 16:55:36 +01:00
Philipp Oppermann
dbb3db2dc7 Merge branch 'post-02' into post-03 2019-12-10 16:55:29 +01:00
Philipp Oppermann
1636196d54 Merge pull request #701 from phil-opp/post-04-update
Update to x86_64 0.8.0
2019-12-10 16:54:51 +01:00
Philipp Oppermann
5c964dc7b9 Update to x86_64 0.8.0 2019-12-10 16:45:34 +01:00
Philipp Oppermann
9d6ba0d31e Merge branch 'post-05' into post-06 2019-11-28 14:06:28 +01:00
Philipp Oppermann
3a65487f17 Merge branch 'post-04' into post-05 2019-11-28 14:06:08 +01:00
Philipp Oppermann
0c3e6f95f6 Update post-04 to new lockfile format 2019-11-28 14:05:44 +01:00
Philipp Oppermann
23d8bb948e Merge branch 'post-03' into post-04 2019-11-28 14:05:02 +01:00
Philipp Oppermann
748365bf62 Update post-03 to new lockfile format 2019-11-28 14:04:38 +01:00
Philipp Oppermann
2b1f72ccd8 Merge branch 'post-02' into post-03 2019-11-28 14:04:16 +01:00
Philipp Oppermann
590585da33 Merge branch 'post-05' into post-06 2019-11-25 13:24:09 +01:00
Philipp Oppermann
6828849bc4 Remove cfg(not(windows)) from interrupt module
This is no longer required and was already removed from the post in commit 992b958414.
2019-11-25 13:19:07 +01:00
Philipp Oppermann
a604e1fa14 Merge branch 'post-06' of github.com:phil-opp/blog_os into post-06 2019-11-22 16:04:09 +01:00
Philipp Oppermann
ea998c9267 Merge branch 'post-03' into post-04 2019-11-22 15:57:18 +01:00
Philipp Oppermann
679e453509 Merge branch 'post-02' into post-03 2019-11-22 15:57:18 +01:00
Philipp Oppermann
29063f4531 Merge branch 'post-04' into post-05 2019-11-22 15:57:18 +01:00
Philipp Oppermann
05c3a17c49 Merge branch 'post-05' into post-06 2019-11-22 15:57:18 +01:00
Philipp Oppermann
3470636653 Use panic! instead of println! + loop in double fault handler (#687)
This avoids an endless loop when a double fault occurs while running `cargo xtest`.
2019-11-22 15:56:56 +01:00
Philipp Oppermann
79ad84c502 Merge branch 'post-03' into post-04 2019-10-08 19:44:38 +02:00
Philipp Oppermann
4f90781b3f Merge branch 'post-02' into post-03 2019-10-08 19:44:38 +02:00
Philipp Oppermann
6979a125cf Merge branch 'post-04' into post-05 2019-10-08 19:44:38 +02:00
Philipp Oppermann
1a1ce5120f Merge branch 'post-05' into post-06 2019-10-08 19:44:38 +02:00
Philipp Oppermann
78fdba7606 Merge branch 'post-05' into post-06 2019-09-25 13:20:13 +02:00
Philipp Oppermann
215900cb39 Merge branch 'post-04' into post-05 2019-09-25 13:19:55 +02:00
Philipp Oppermann
2a1f4d047c Run cargo update 2019-09-25 13:19:46 +02:00
Philipp Oppermann
01d9a028a3 Merge branch 'post-03' into post-04 2019-09-25 13:19:32 +02:00
Philipp Oppermann
515d98645e Merge branch 'post-02' into post-03 2019-09-25 13:18:58 +02:00
Philipp Oppermann
8d6915beba Merge branch 'post-05' into post-06 2019-09-13 17:43:25 +02:00
Philipp Oppermann
df1e2c1c41 Merge branch 'post-04' into post-05 2019-09-13 17:43:25 +02:00
Philipp Oppermann
6e012e5e42 Merge branch 'post-03' into post-04 2019-09-13 17:43:20 +02:00
Philipp Oppermann
a86fe5c2af Merge branch 'post-02' into post-03 2019-09-13 17:42:32 +02:00
Philipp Oppermann
0eaaa3ff2b Merge branch 'post-05' into post-06 2019-09-13 10:53:50 +02:00
Philipp Oppermann
b851eb01a8 Merge branch 'post-04' into post-05 2019-09-13 10:53:50 +02:00
Philipp Oppermann
f4ed1fce81 Merge branch 'post-03' into post-04 2019-09-13 10:53:50 +02:00
Philipp Oppermann
ab10af6f99 Merge branch 'post-02' into post-03 2019-09-13 10:53:50 +02:00
Philipp Oppermann
086304c9c4 Merge branch 'post-05' into post-06 2019-09-11 13:18:19 +02:00
Philipp Oppermann
3f8c629f28 Merge branch 'post-04' into post-05 2019-09-11 13:18:19 +02:00
Philipp Oppermann
086c3a02d3 Set x86_64 version to 0.7.5 2019-09-11 13:18:16 +02:00
Philipp Oppermann
14b38a3ea4 Merge branch 'post-03' into post-04 2019-09-11 13:14:02 +02:00
Philipp Oppermann
bcafb60069 Update spin and volatile dependencies 2019-09-11 13:13:34 +02:00
Philipp Oppermann
2e27b91220 Merge branch 'post-05' into post-06 2019-09-11 11:21:15 +02:00
Philipp Oppermann
06929ee840 Merge branch 'post-04' into post-05 2019-09-11 11:21:15 +02:00
Philipp Oppermann
b1121cdee2 Merge branch 'post-03' into post-04 2019-09-11 11:21:15 +02:00
Philipp Oppermann
465eb45cfe Merge branch 'post-02' into post-03 2019-09-11 11:21:15 +02:00
Philipp Oppermann
cb77074476 Merge branch 'post-05' into post-06 2019-09-11 10:58:02 +02:00
Philipp Oppermann
e43daca563 Merge branch 'post-04' into post-05 2019-09-11 10:58:02 +02:00
Philipp Oppermann
e27666cd75 Run cargo update 2019-09-11 10:57:58 +02:00
Philipp Oppermann
6771c2cc7f Merge branch 'post-03' into post-04 2019-09-11 10:57:21 +02:00
Philipp Oppermann
c6d5a4d567 Run cargo update 2019-09-11 10:57:07 +02:00
Philipp Oppermann
fe5e1fd92c Merge branch 'post-02' into post-03 2019-09-11 10:56:41 +02:00
Philipp Oppermann
d0afb95b50 Merge branch 'post-05' into post-06 2019-09-11 10:32:57 +02:00
Philipp Oppermann
baa2c3b445 Merge branch 'post-04' into post-05 2019-09-11 10:32:57 +02:00
Philipp Oppermann
1d60156fce Merge branch 'post-03' into post-04 2019-09-11 10:32:57 +02:00
Philipp Oppermann
a1060f79f0 Merge branch 'post-02' into post-03 2019-09-11 10:32:57 +02:00
Philipp Oppermann
1b0378f87e Merge branch 'post-05' into post-06 2019-09-11 10:12:46 +02:00
Philipp Oppermann
c58570fbea Merge branch 'post-04' into post-05 2019-09-11 10:12:46 +02:00
Philipp Oppermann
467300126b Merge branch 'post-03' into post-04 2019-09-11 10:12:46 +02:00
Philipp Oppermann
3765c27020 Merge branch 'post-02' into post-03 2019-09-11 10:12:46 +02:00
Philipp Oppermann
b91f71784d Merge branch 'post-05' into post-06 2019-09-11 10:11:25 +02:00
Philipp Oppermann
17c3138763 Merge branch 'post-04' into post-05 2019-09-11 10:10:49 +02:00
Philipp Oppermann
19b8ab1c4e Merge branch 'post-03' into post-04 2019-09-11 10:10:31 +02:00
Philipp Oppermann
70b339a4a5 Merge branch 'post-02' into post-03 2019-09-11 10:09:32 +02:00
Philipp Oppermann
6316a0e1df Merge branch 'post-05' into post-06 2019-09-11 10:02:41 +02:00
Philipp Oppermann
d85274ca2a Merge branch 'post-04' into post-05 2019-09-11 10:02:41 +02:00
Philipp Oppermann
f927742601 Merge pull request #663 from phil-opp/post-04-actions
Set up GitHub Actions for post-04 branch
2019-09-11 10:02:07 +02:00
Philipp Oppermann
210af19293 Github Actions: Install QEMU and run cargo xtest 2019-09-11 09:49:32 +02:00
Philipp Oppermann
6f90ee89fd Merge branch 'post-03' into post-04-actions 2019-09-11 09:47:01 +02:00
Philipp Oppermann
153beec1c4 Merge branch 'post-02' into post-03 2019-09-11 09:46:34 +02:00
Philipp Oppermann
38cfb5e324 Merge branch 'post-05' into post-06 2019-09-10 11:12:54 +02:00
Philipp Oppermann
aa084dd539 Merge branch 'post-04' into post-05 2019-09-10 11:12:54 +02:00
Philipp Oppermann
20ef920fc6 Add [package.metadata.bootimage] again
Was accidentally removed when resolving a merge conflict.
2019-09-10 11:12:47 +02:00
Philipp Oppermann
a9921e9448 Merge branch 'post-05' into post-06 2019-09-10 10:21:14 +02:00
Philipp Oppermann
0d87aa7e98 Merge branch 'post-04' into post-05 2019-09-10 10:21:14 +02:00
Philipp Oppermann
9602f4e16d Merge branch 'post-03' into post-04 2019-09-10 10:21:08 +02:00
Philipp Oppermann
bfde53de79 Merge branch 'post-02' into post-03 2019-09-10 10:20:47 +02:00
Philipp Oppermann
9770d481f2 Merge branch 'post-05' into post-06 2019-08-07 12:40:04 +02:00
Philipp Oppermann
6797b2b70e Merge branch 'post-04' into post-05 2019-08-07 12:40:04 +02:00
Philipp Oppermann
d3e4c55fc5 Merge pull request #651 from phil-opp/post-04-update
Update post_04 branch for new should_panic test
2019-08-07 12:39:19 +02:00
Philipp Oppermann
f1ae82b220 Disable the test harness for the should_panic test 2019-08-07 11:02:19 +02:00
Philipp Oppermann
aad98c0611 Add a should_panic test 2019-08-07 11:00:01 +02:00
Philipp Oppermann
f98145d556 Delete panic handler test 2019-08-07 10:38:46 +02:00
Philipp Oppermann
7baa3b0155 Merge branch 'post-05' into post-06 2019-07-22 10:36:23 +02:00
Philipp Oppermann
752a65e4da Merge branch 'post-04' into post-05 2019-07-22 10:36:23 +02:00
Philipp Oppermann
99ea302aaa Regenerate Cargo.lock 2019-07-22 10:36:11 +02:00
Philipp Oppermann
133f73ab0b Merge branch 'post-03' into post-04 2019-07-22 10:34:02 +02:00
Philipp Oppermann
298ec5f4b6 Merge branch 'post-02' into post-03 2019-07-22 10:33:24 +02:00
Philipp Oppermann
08bf4405a9 Merge branch 'post-05' into post-06 2019-07-18 10:17:05 +02:00
Philipp Oppermann
b6683d95ec Merge branch 'post-04' into post-05 2019-07-18 10:17:05 +02:00
Philipp Oppermann
28d5eeb9c4 Run cargo update 2019-07-18 10:17:01 +02:00
Philipp Oppermann
5adfe28cf4 Merge branch 'post-03' into post-04 2019-07-18 10:16:43 +02:00
Philipp Oppermann
ff8afb814e Merge branch 'post-02' into post-03 2019-07-18 10:16:01 +02:00
Philipp Oppermann
9d5b5f33f1 Merge branch 'post-05' into post-06 2019-06-23 18:07:34 +02:00
Philipp Oppermann
a7710b3d5c Merge branch 'post-04' into post-05 2019-06-23 18:07:34 +02:00
Philipp Oppermann
d2e0d38218 Run brew update on macOS to fix travis CI failure (#623) 2019-06-23 18:07:19 +02:00
Philipp Oppermann
9b4b810bd3 Merge branch 'post-05' into post-06 2019-06-17 17:28:32 +02:00
Philipp Oppermann
618d10eac8 Merge branch 'post-04' into post-05 2019-06-17 17:28:32 +02:00
Philipp Oppermann
7003268b9f Merge branch 'post-03' into post-04 2019-06-17 17:28:32 +02:00
Philipp Oppermann
fcd849f471 Fix deprecated range syntax 2019-06-17 17:28:27 +02:00
Philipp Oppermann
7a45083975 Merge branch 'post-05' into post-06 2019-05-23 12:39:35 +02:00
Philipp Oppermann
2faeaa8964 Merge branch 'post-04' into post-05 2019-05-23 12:39:35 +02:00
Philipp Oppermann
c8d1bbeef8 Update code for PR #611
PR at https://github.com/phil-opp/blog_os/pull/611
2019-05-22 12:43:15 +02:00
Philipp Oppermann
01040fc643 Merge branch 'post-05' into post-06 2019-05-09 14:59:55 +02:00
Philipp Oppermann
2dfc5e838a Merge branch 'post-04' into post-05 2019-05-09 14:59:55 +02:00
bors[bot]
158aed0c18 Merge #604 #606
604: Use `-serial stdio` instead of `-serial mon:stdio` r=phil-opp a=phil-opp

Fixes #602 

Post update in https://github.com/phil-opp/blog_os/pull/605

606: Update x86_64 to version 0.7.0 r=phil-opp a=phil-opp

[Changelog](https://github.com/rust-osdev/x86_64/blob/master/Changelog.md#070):

- **Breaking**: `Port::read` and `PortReadOnly::read` now take `&mut self` instead of `&self` ([#76](https://github.com/rust-osdev/x86_64/pull/76)).

Post update in https://github.com/phil-opp/blog_os/pull/607

Co-authored-by: Philipp Oppermann <dev@phil-opp.com>
2019-05-09 12:42:42 +00:00
Philipp Oppermann
3098be9653 Update x86_64 to version 0.7.0 2019-05-09 14:37:18 +02:00
Philipp Oppermann
86b57f696f Use -serial stdio instead of -serial mon:stdio 2019-05-08 16:10:23 +02:00
Philipp Oppermann
5a68816b45 Merge branch 'post-05' into post-06 2019-05-03 18:36:45 +02:00
Philipp Oppermann
12c08d72e4 Merge branch 'post-04' into post-05 2019-05-03 18:36:45 +02:00
Philipp Oppermann
ac9b661395 Update to x86_64 0.6.0 2019-05-03 18:36:39 +02:00
Philipp Oppermann
111c3e1029 Comment out stack_overflow() call to keep cargo xtest working 2019-04-26 15:48:59 +02:00
Philipp Oppermann
70d981e179 Simplify stack_overflow test 2019-04-26 15:14:38 +02:00
Philipp Oppermann
ee3d2219ab Disable test harness for stack_overflow test 2019-04-26 15:14:38 +02:00
Philipp Oppermann
c5a39e0902 Add a stack overflow integration test 2019-04-26 15:14:38 +02:00
Philipp Oppermann
4774893a93 Call gdt::init from blog_os::init 2019-04-26 15:14:38 +02:00
Philipp Oppermann
3c59321b54 Remove old bootimage test integration test 2019-04-26 15:14:38 +02:00
Philipp Oppermann
f5345db3e6 Update post number for Readme badge 2019-04-26 15:11:49 +02:00
Philipp Oppermann
94622ebfd5 Merge branch 'post-05-new' into post-06-new-rebased 2019-04-26 15:11:24 +02:00
Philipp Oppermann
53f3236754 Update post number for Readme badge 2019-04-26 15:09:17 +02:00
Philipp Oppermann
82014268da Merge branch 'post-05-new' into post-06-new-rebased 2019-04-26 15:05:55 +02:00
Philipp Oppermann
a5b6422785 Add a test for the breakpoint exception 2019-04-26 14:57:14 +02:00
Philipp Oppermann
b7eefae5f9 Delete old bootimage test integration tests 2019-04-26 14:57:14 +02:00
Philipp Oppermann
df8335f8c7 Add a new blog_os::init function instead of calling init_idt directly 2019-04-26 14:57:14 +02:00
Philipp Oppermann
f301ae461a Merge branch 'post-04-new' into post-05-new 2019-04-26 14:56:25 +02:00
Philipp Oppermann
ad99afae98 Fix panic_handler test by fixing line number 2019-04-26 13:42:20 +02:00
Philipp Oppermann
8374aa6ab6 Run cargo fmt 2019-04-26 13:42:20 +02:00
Philipp Oppermann
c8087cdd6f Update Readme for Testing post 2019-04-26 13:42:20 +02:00
Philipp Oppermann
ccb8b79ef8 Add a panic handler test 2019-04-26 13:42:20 +02:00
Philipp Oppermann
a55ced6b7f Add a basic test to basic_boot 2019-04-26 13:42:20 +02:00
Philipp Oppermann
2e5f192f35 Make exit_qemu safe 2019-04-26 13:42:20 +02:00
Philipp Oppermann
c2f36e086e Install qemu on CI 2019-04-26 13:42:10 +02:00
Philipp Oppermann
cdd91df869 Run cargo xtest on CI 2019-04-26 13:42:04 +02:00
Philipp Oppermann
a2d628cabe Complete the basic_boot integration test 2019-04-26 13:41:19 +02:00
Philipp Oppermann
48e1f72d23 Split off a library 2019-04-26 13:41:19 +02:00
Philipp Oppermann
3b13211579 Add the skeleton for an integration test 2019-04-26 13:41:19 +02:00
Philipp Oppermann
d0629ba5a2 Import serial_println only in test mode 2019-04-26 13:41:19 +02:00
Philipp Oppermann
46bb44b95d Run cargo fmt 2019-04-26 13:41:19 +02:00
Philipp Oppermann
4cbac20b40 Add tests for the VGA buffer 2019-04-26 13:41:19 +02:00
Philipp Oppermann
d4ebbc291a Hide QEMU in test mode 2019-04-26 13:41:19 +02:00
Philipp Oppermann
3ecf9a9b56 Exit qemu on panic 2019-04-26 13:41:19 +02:00
Philipp Oppermann
1559493802 Print test results over serial port 2019-04-26 13:41:19 +02:00
Philipp Oppermann
98a0e605be Interpret exit code 33 as test success 2019-04-26 13:41:19 +02:00
Philipp Oppermann
dbdd46da9a Exit qemu after running tests 2019-04-26 13:41:17 +02:00
Philipp Oppermann
3aa6151729 Add a trivial_assertion test 2019-04-26 13:41:07 +02:00
Philipp Oppermann
0beb0d80f8 Add a custom test runner 2019-04-26 13:41:07 +02:00
Philipp Oppermann
3c421e9ccb Merge branch 'post-03-new' into post-04-new 2019-04-26 12:46:01 +02:00
Philipp Oppermann
23cbafab1c Reset code to post-03 branch 2019-04-26 12:44:33 +02:00
Philipp Oppermann
70c24b76d0 Merge branch 'post-02' into post-03 2019-04-26 11:27:45 +02:00
Philipp Oppermann
16a314ab8d Merge branch 'post-02' into post-03 2019-04-26 11:24:17 +02:00
Philipp Oppermann
e0d68fee24 Merge branch 'post-06' into post-07 2019-04-25 11:08:11 +02:00
Philipp Oppermann
8f76952ff0 Merge branch 'post-05' into post-06 2019-04-25 11:08:11 +02:00
Philipp Oppermann
4eb7f94171 Merge branch 'post-03' into post-04 2019-04-25 11:08:11 +02:00
Philipp Oppermann
f875a933e5 Merge branch 'post-02' into post-03 2019-04-25 11:08:11 +02:00
Philipp Oppermann
57b30bf346 Merge branch 'post-04' into post-05 2019-04-25 11:08:11 +02:00
Philipp Oppermann
6f623dc7b4 Merge branch 'post-06' into post-07 2019-04-11 15:32:21 +02:00
Philipp Oppermann
c6ebca363b Merge branch 'post-05' into post-06 2019-04-11 15:32:21 +02:00
Philipp Oppermann
d497d12649 Merge branch 'post-03' into post-04 2019-04-11 15:32:21 +02:00
Philipp Oppermann
652d91154f Merge branch 'post-02' into post-03 2019-04-11 15:32:21 +02:00
Philipp Oppermann
3bbc72f92b Merge branch 'post-04' into post-05 2019-04-11 15:32:21 +02:00
Philipp Oppermann
dc1f862177 Merge branch 'post-06' into post-07 2019-04-06 17:35:17 +02:00
Philipp Oppermann
f5996c1e22 Merge branch 'post-05' into post-06 2019-04-06 17:35:17 +02:00
Philipp Oppermann
eafcd8b269 Merge branch 'post-04' into post-05 2019-04-06 17:35:17 +02:00
Philipp Oppermann
66f79fa254 Merge branch 'post-03' into post-04 2019-04-06 17:35:16 +02:00
Philipp Oppermann
9a879e69c5 Merge branch 'post-02' into post-03 2019-04-06 17:35:16 +02:00
Philipp Oppermann
fdf0fe617b Merge branch 'post-06' into post-07 2019-04-06 17:31:13 +02:00
Philipp Oppermann
daf5ed954d Merge branch 'post-05' into post-06 2019-04-06 17:30:54 +02:00
Philipp Oppermann
4753c0e1c8 Run cargo update 2019-04-06 17:30:31 +02:00
Philipp Oppermann
dddc314b7c Merge branch 'post-04' into post-05 2019-04-06 17:27:37 +02:00
Philipp Oppermann
5422f555cf Merge branch 'post-03' into post-04 2019-04-06 16:55:46 +02:00
Philipp Oppermann
186321623a Run cargo update 2019-04-06 16:55:17 +02:00
Philipp Oppermann
1246fc4df9 Merge branch 'post-02' into post-03 2019-04-06 16:54:48 +02:00
Philipp Oppermann
23fcb9f20b Merge branch 'post-06' into post-07 2019-04-06 16:49:01 +02:00
Philipp Oppermann
5531e437c4 Merge branch 'post-05' into post-06 2019-04-06 16:49:01 +02:00
Philipp Oppermann
0cd92f9567 Merge branch 'post-04' into post-05 2019-04-06 16:48:51 +02:00
Philipp Oppermann
ceaa5c2dab Merge branch 'post-03' into post-04 2019-04-06 16:48:32 +02:00
Philipp Oppermann
03da22d8e1 Merge branch 'post-02' into post-03 2019-04-06 16:47:45 +02:00
Philipp Oppermann
ffb76038bc Merge branch 'post-06' into post-07
# Conflicts:
#	README.md
2019-04-03 10:46:46 +02:00
Philipp Oppermann
555a76b559 Merge branch 'post-05' into post-06
# Conflicts:
#	README.md
2019-04-03 10:46:34 +02:00
Philipp Oppermann
802c7151e4 Merge branch 'post-04' into post-05
# Conflicts:
#	README.md
2019-04-03 10:46:23 +02:00
Philipp Oppermann
768c09dffe Merge branch 'post-03' into post-04
# Conflicts:
#	README.md
2019-04-03 10:46:10 +02:00
Philipp Oppermann
d98a4d0cbc Merge branch 'post-02' into post-03
# Conflicts:
#	README.md
2019-04-03 10:45:48 +02:00
Philipp Oppermann
f42461b99b Merge branch 'post-06' into post-07 2019-03-26 13:26:56 +01:00
Philipp Oppermann
19db8f6095 Merge branch 'post-05' into post-06 2019-03-26 13:26:56 +01:00
Philipp Oppermann
3a273540f4 CI: Run apt update before installing qemu 2019-03-26 13:26:24 +01:00
Philipp Oppermann
701823742e Merge branch 'post-06' into post-07 2019-03-14 11:18:22 +01:00
Philipp Oppermann
ea096a561a Merge branch 'post-05' into post-06 2019-03-14 11:18:22 +01:00
Philipp Oppermann
6d45ffd4d7 Merge branch 'post-04' into post-05 2019-03-14 11:17:58 +01:00
Philipp Oppermann
cc949a2ef3 Merge branch 'post-03' into post-04 2019-03-14 11:15:56 +01:00
Philipp Oppermann
93b2134692 Merge branch 'post-02' into post-03 2019-03-14 11:14:01 +01:00
Philipp Oppermann
b533bf6596 Merge branch 'post-06' into post-07 2019-03-12 17:48:11 +01:00
Philipp Oppermann
7648993b8f Merge branch 'post-05' into post-06 2019-03-12 17:48:11 +01:00
Philipp Oppermann
17bd271573 Update x86_64 to version 0.5.2 2019-03-12 17:45:09 +01:00
Philipp Oppermann
1ed76411f7 Fix remaining use of ExceptionStackFrame in test 2019-03-09 14:21:03 +01:00
Philipp Oppermann
8e5b6a3e3f Update post-07 code for changes in x86_64 0.5.0 2019-03-09 12:34:49 +01:00
Philipp Oppermann
be0ed3a54d Merge branch 'post-06' into post-07 2019-03-09 12:32:03 +01:00
Philipp Oppermann
b895f8c745 Update code for changes in x86_64 0.5.0 2019-03-09 12:29:44 +01:00
Philipp Oppermann
eee9d7b899 Merge branch 'post-05' into post-06 2019-03-09 12:10:27 +01:00
Philipp Oppermann
9787e6dce6 Update to x86_64 0.5.0 2019-03-09 12:10:18 +01:00
Philipp Oppermann
f5b6094521 Merge branch 'post-06' into post-07 2019-02-25 16:37:30 +01:00
Philipp Oppermann
a4f675739a Merge branch 'post-05' into post-06 2019-02-25 16:37:30 +01:00
Philipp Oppermann
b1cca8de88 Merge branch 'post-04' into post-05 2019-02-25 16:37:18 +01:00
Philipp Oppermann
c6aaa66420 Merge branch 'post-03' into post-04 2019-02-25 16:35:03 +01:00
Philipp Oppermann
4d405d5098 Merge branch 'post-02' into post-03 2019-02-25 16:34:15 +01:00
Philipp Oppermann
38bd9a65b6 Merge branch 'post-06' into post-07 2019-02-07 18:46:32 +01:00
Philipp Oppermann
493fcb5d84 Merge branch 'post-05' into post-06 2019-02-07 18:46:32 +01:00
Philipp Oppermann
b651214f1e Merge branch 'post-04' into post-05 2019-02-07 18:46:32 +01:00
Philipp Oppermann
0bec03e080 Merge branch 'post-03' into post-04 2019-02-07 18:46:32 +01:00
Philipp Oppermann
e3f9cd42b0 Merge branch 'post-02' into post-03 2019-02-07 18:46:32 +01:00
Philipp Oppermann
b3e94470e4 Merge branch 'post-06' into post-07 2019-02-07 16:15:10 +01:00
Philipp Oppermann
3fca470487 Merge branch 'post-05' into post-06 2019-02-07 16:15:10 +01:00
Philipp Oppermann
bac8703e04 Merge branch 'post-04' into post-05 2019-02-07 16:15:10 +01:00
Philipp Oppermann
71099663ad Merge branch 'post-03' into post-04 2019-02-07 16:15:10 +01:00
Philipp Oppermann
61f524f040 Merge branch 'post-02' into post-03 2019-02-07 16:15:10 +01:00
Philipp Oppermann
7b01e9c862 Merge branch 'post-06' into post-07 2019-02-05 15:23:49 +01:00
Philipp Oppermann
290ee927e8 Merge branch 'post-05' into post-06 2019-02-05 15:23:49 +01:00
Philipp Oppermann
99171b003e Merge branch 'post-04' into post-05 2019-02-05 15:23:49 +01:00
Philipp Oppermann
a53f0573d8 Merge branch 'post-03' into post-04 2019-02-05 15:23:48 +01:00
Philipp Oppermann
3f9072e8b5 Merge branch 'post-02' into post-03 2019-02-05 15:23:48 +01:00
Philipp Oppermann
5452e0f455 Merge branch 'post-06' into post-07 2019-02-05 14:59:15 +01:00
Philipp Oppermann
86b17ea139 Merge branch 'post-05' into post-06 2019-02-05 14:59:15 +01:00
Philipp Oppermann
f15bbaea3f Update azure pipelines script for integration tests 2019-02-05 14:58:51 +01:00
Philipp Oppermann
b66b7563c2 Merge branch 'post-04' into post-05 2019-02-05 14:58:20 +01:00
Philipp Oppermann
b71e0644bf Update azure pipelines script for unit testing post 2019-02-05 14:57:46 +01:00
Philipp Oppermann
078aebe32a Merge branch 'post-03' into post-04 2019-02-05 14:55:54 +01:00
Philipp Oppermann
bac4a3c549 Merge branch 'post-02' into post-03 2019-02-05 14:55:29 +01:00
Philipp Oppermann
202902f30d Merge branch 'post-06' into post-07 2019-02-05 10:46:08 +01:00
Philipp Oppermann
223ce459a1 Merge branch 'post-05' into post-06 2019-02-05 10:46:08 +01:00
Philipp Oppermann
d808cbff94 Merge branch 'post-04' into post-05 2019-02-05 10:46:08 +01:00
Philipp Oppermann
afc89c9e4c Merge branch 'post-03' into post-04 2019-02-05 10:46:08 +01:00
Philipp Oppermann
4bfcea2368 Merge branch 'post-02' into post-03 2019-02-05 10:46:08 +01:00
Philipp Oppermann
3bb30fd1e8 Merge branch 'post-06' into post-07 2019-02-05 10:45:12 +01:00
Philipp Oppermann
62e2cee989 Merge branch 'post-05' into post-06 2019-02-05 10:45:12 +01:00
Philipp Oppermann
69ab78108b Merge branch 'post-04' into post-05 2019-02-05 10:45:12 +01:00
Philipp Oppermann
2db616bd7d Merge branch 'post-03' into post-04 2019-02-05 10:45:11 +01:00
Philipp Oppermann
af0b258279 Make vga_buffer::{ScreenChar, Buffer} repr(transparent) 2019-02-05 10:44:52 +01:00
Philipp Oppermann
41e36b4afa Merge branch 'post-06' into post-07 2019-01-29 12:16:54 +01:00
Philipp Oppermann
a7ada29c5e Merge branch 'post-05' into post-06 2019-01-29 12:16:54 +01:00
Philipp Oppermann
968620dce8 Merge branch 'post-04' into post-05 2019-01-29 12:16:54 +01:00
Philipp Oppermann
237a848459 Merge branch 'post-03' into post-04 2019-01-29 12:16:54 +01:00
Philipp Oppermann
de2b99f0d2 Merge branch 'post-02' into post-03 2019-01-29 12:16:54 +01:00
Philipp Oppermann
f76ec1ae32 Only set double fault handler once 2019-01-28 11:50:59 +01:00
Philipp Oppermann
1a801e3d35 Merge branch 'post-05' into post-06 2019-01-28 11:44:14 +01:00
Philipp Oppermann
efe92e5004 Merge branch 'post-06' into post-07 2019-01-28 11:44:14 +01:00
Philipp Oppermann
f0580e82a1 Merge branch 'post-04' into post-05 2019-01-28 11:42:39 +01:00
Philipp Oppermann
053216ffd4 Make array-init a dev-dependency 2019-01-28 11:40:00 +01:00
Philipp Oppermann
233943310c Update Readme for Double Faults post 2019-01-27 17:12:21 +01:00
Philipp Oppermann
ef6d69f82b Merge branch 'post-06' into post-07 2019-01-27 17:11:38 +01:00
Philipp Oppermann
94014b5a39 Update Readme for CPU Exceptions post 2019-01-27 17:11:08 +01:00
Philipp Oppermann
680aab362e Merge branch 'post-05' into post-06 2019-01-27 17:10:50 +01:00
Philipp Oppermann
92cc34712c Update Readme for Integration Tests post 2019-01-27 17:09:37 +01:00
Philipp Oppermann
bdbbd219d0 Merge branch 'post-04' into post-05 2019-01-27 17:09:11 +01:00
Philipp Oppermann
61d10d686b Update Readme for Unit Testing post 2019-01-27 17:08:41 +01:00
Philipp Oppermann
52bc8ea29f Merge branch 'post-03' into post-04 2019-01-27 17:08:15 +01:00
Philipp Oppermann
8c1e98752a Update Readme for VGA Text Mode post 2019-01-27 17:07:48 +01:00
Philipp Oppermann
ceb5cf4eed Merge branch 'post-02' into post-03 2019-01-27 17:07:24 +01:00
Philipp Oppermann
637b517f47 Merge branch 'post-06' into post-07 2019-01-27 16:33:54 +01:00
Philipp Oppermann
ab8d8b46e2 Merge branch 'post-05' into post-06 2019-01-27 16:33:54 +01:00
Philipp Oppermann
3cd7427ed8 Merge branch 'post-04' into post-05 2019-01-27 16:33:54 +01:00
Philipp Oppermann
5b3e3642ca Merge branch 'post-03' into post-04 2019-01-27 16:33:54 +01:00
Philipp Oppermann
1d5bc372a0 Merge branch 'post-02' into post-03 2019-01-27 16:33:54 +01:00
Philipp Oppermann
5802c97938 Merge branch 'z_post_06' into z_post_07 2019-01-27 15:46:59 +01:00
Philipp Oppermann
33f9f14391 Merge branch 'z_post_05' into z_post_06 2019-01-27 15:46:59 +01:00
Philipp Oppermann
68d09db7c5 Update CI scripts for integration test post 2019-01-27 15:46:08 +01:00
Philipp Oppermann
6bbd12ba7a Merge branch 'z_post_04' into z_post_05 2019-01-27 15:44:11 +01:00
Philipp Oppermann
d516dac0c3 Update CI scripts for unit testing post 2019-01-27 15:43:18 +01:00
Philipp Oppermann
c0fcb5f922 Merge branch 'z_post_03' into z_post_04 2019-01-27 15:42:59 +01:00
Philipp Oppermann
0874a50544 Merge branch 'z_post_02' into z_post_03 2019-01-27 15:37:53 +01:00
Philipp Oppermann
29ee6b15dd Merge branch 'z_post_06' into z_post_07 2019-01-27 14:28:55 +01:00
Philipp Oppermann
15b394f0eb Merge branch 'z_post_05' into z_post_06 2019-01-27 14:28:51 +01:00
Philipp Oppermann
17f2699277 Update to x86_64 0.4.0 2019-01-27 14:12:10 +01:00
Philipp Oppermann
90ad333e90 Merge branch 'z_post_06' into z_post_07 2019-01-25 14:46:29 +01:00
Philipp Oppermann
cc3a868863 Merge branch 'z_post_05' into z_post_06 2019-01-25 14:46:17 +01:00
Philipp Oppermann
d1545e7fbf Merge branch 'z_post_04' into z_post_05 2019-01-25 14:46:04 +01:00
Philipp Oppermann
be46130322 Merge branch 'z_post_03' into z_post_04 2019-01-25 14:45:46 +01:00
Philipp Oppermann
afe8dc3dcf Add stack overflow integration test 2019-01-25 14:45:02 +01:00
Philipp Oppermann
8bb0187f35 Run rustfmt 2019-01-25 14:44:42 +01:00
Philipp Oppermann
b5c05193e1 Document vga buffer methods 2019-01-25 14:39:47 +01:00
Philipp Oppermann
e0ed423e52 Explain the LLVM bug on Windows in more detail 2019-01-25 14:37:46 +01:00
Philipp Oppermann
d8edfccca4 Set the stack_index for the double fault handler 2019-01-25 14:01:29 +01:00
Philipp Oppermann
ff25a7d86c Reload code and TSS selector registers 2019-01-25 13:59:09 +01:00
Philipp Oppermann
b5202e26a1 Load the GDT 2019-01-25 13:57:40 +01:00
Philipp Oppermann
ea1b031fd3 Create a static GDT 2019-01-25 13:57:08 +01:00
Philipp Oppermann
db4e879c34 Create a new GDT module and a static TSS 2019-01-25 13:56:40 +01:00
Philipp Oppermann
7fd29c9cbe Trigger a double fault through a stack overflow -> triple fault 2019-01-25 13:55:42 +01:00
Philipp Oppermann
218cb9399e Add a double fault handler and test it 2019-01-25 13:54:44 +01:00
Philipp Oppermann
b96636984c Workaround an LLVM bug 2019-01-25 13:53:17 +01:00
Philipp Oppermann
b9dd088dc1 Create test-exception-breakpoint integration test 2019-01-25 13:51:39 +01:00
Philipp Oppermann
c6bd48e812 Load and test our new IDT 2019-01-25 13:51:06 +01:00
Philipp Oppermann
9448b0e025 Create a new IDT 2019-01-25 13:49:09 +01:00
Philipp Oppermann
ade6c99885 Add an interrupts module 2019-01-25 13:47:28 +01:00
Philipp Oppermann
59579108a7 Add test-basic-boot and test-panic integration tests 2019-01-25 13:45:38 +01:00
Philipp Oppermann
bd39105793 Split crate into lib.rs and main.rs 2019-01-25 13:44:04 +01:00
Philipp Oppermann
d007aae993 Exit qemu 2019-01-25 13:38:26 +01:00
Philipp Oppermann
c21f051300 Add a serial module 2019-01-25 13:37:20 +01:00
Philipp Oppermann
76110c1dd8 Add a write_formatted test 2019-01-25 13:32:00 +01:00
Philipp Oppermann
92c4206e86 Add a write_byte test 2019-01-25 13:31:34 +01:00
Philipp Oppermann
a15e01f2eb Construct a vga buffer for testing 2019-01-25 13:31:06 +01:00
Philipp Oppermann
76a65ca3ee Include the standard library for unit tests 2019-01-25 13:29:02 +01:00
Philipp Oppermann
8e74084d52 Silence unused import warnings for cargo test 2019-01-25 13:25:24 +01:00
Philipp Oppermann
5366fe2ff8 Make cargo test work 2019-01-25 13:24:54 +01:00
Philipp Oppermann
6c427e7cee Print the PanicInfo on panic 2019-01-25 13:23:04 +01:00
Philipp Oppermann
c43d6191c5 Implement print!/println! macros 2019-01-25 13:22:33 +01:00
Philipp Oppermann
c1e3fa57c6 Add a global interface 2019-01-25 13:21:39 +01:00
Philipp Oppermann
3574958d5f Implement new_line method 2019-01-25 13:18:58 +01:00
Philipp Oppermann
cbfe6221bd Implement support for Rust's formatting macros 2019-01-25 13:18:13 +01:00
Philipp Oppermann
d1897af515 Use volatile writes for accessing the VGA buffer 2019-01-25 13:16:44 +01:00
Philipp Oppermann
d71e6a7cb6 Test the vga buffer module through a print_something function 2019-01-25 12:26:05 +01:00
Philipp Oppermann
27f2c4c2ff Add methods to write bytes and strings 2019-01-25 12:25:46 +01:00
Philipp Oppermann
19de9e560d Add a VGA buffer module 2019-01-25 12:21:51 +01:00
13 changed files with 722 additions and 13 deletions

View File

@@ -53,6 +53,32 @@ jobs:
- name: "Create Bootimage"
run: cargo bootimage
# install QEMU
- name: Install QEMU (Linux)
run: sudo apt update && sudo apt install qemu-system-x86
if: runner.os == 'Linux'
- name: Install QEMU (macOS)
run: brew install qemu
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
- name: Install Scoop (Windows)
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
echo ::add-path::$HOME\scoop\shims
if: runner.os == 'Windows'
shell: pwsh
- name: Install QEMU (Windows)
run: scoop install qemu
if: runner.os == 'Windows'
shell: pwsh
- name: "Print QEMU Version"
run: qemu-system-x86_64 --version
- name: "Run cargo xtest"
run: cargo xtest
check_formatting:
name: "Check Formatting"

127
Cargo.lock generated
View File

@@ -1,10 +1,36 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "array-init"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72"
dependencies = [
"nodrop",
]
[[package]]
name = "bit_field"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "blog_os"
version = "0.1.0"
dependencies = [
"bootloader",
"lazy_static",
"spin",
"uart_16550",
"volatile",
"x86_64 0.8.1",
]
[[package]]
@@ -12,3 +38,104 @@ name = "bootloader"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d596849a47f28abdea62d7a6a25c4f6e69c3d9b09b0a2877db6e9cda004ca993"
[[package]]
name = "cast"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
dependencies = [
"rustc_version",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
dependencies = [
"spin",
]
[[package]]
name = "nodrop"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver",
]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "uart_16550"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "803ea8cb602dbb32c1a657a866d2dd79fe7dbeab0fb2ac667cb4dcc7de12a58b"
dependencies = [
"bitflags",
"x86_64 0.7.7",
]
[[package]]
name = "ux"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f"
[[package]]
name = "volatile"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af0edf5b4faacc31fc51159244d78d65ec580f021afcef7bd53c04aeabc7f29"
[[package]]
name = "x86_64"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f27d9168654aee1b0c1b73746caeb4aa33248f8b8c8f6e100e697fcc2a794b2"
dependencies = [
"array-init",
"bit_field",
"bitflags",
"cast",
"ux",
]
[[package]]
name = "x86_64"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f21672dcbed52bc09eea030d189600c0189c66c97bc5b31779eb780e064a201f"
dependencies = [
"array-init",
"bit_field",
"bitflags",
"cast",
]

View File

@@ -4,5 +4,29 @@ version = "0.1.0"
authors = ["Philipp Oppermann <dev@phil-opp.com>"]
edition = "2018"
[[test]]
name = "should_panic"
harness = false
[[test]]
name = "stack_overflow"
harness = false
[dependencies]
bootloader = "0.8.0"
volatile = "0.2.6"
spin = "0.5.2"
x86_64 = "0.8.1"
uart_16550 = "0.2.0"
[dependencies.lazy_static]
version = "1.0"
features = ["spin_no_std"]
[package.metadata.bootimage]
test-args = [
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", "-serial", "stdio",
"-display", "none"
]
test-success-exit-code = 33 # (0x10 << 1) | 1

View File

@@ -1,10 +1,10 @@
# Blog OS (A Minimal Rust Kernel)
# Blog OS (Double Faults)
[![Build Status](https://github.com/phil-opp/blog_os/workflows/Build%20Code/badge.svg?branch=post-02)](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Build+Code%22+branch%3Apost-02)
[![Build Status](https://github.com/phil-opp/blog_os/workflows/Build%20Code/badge.svg?branch=post-06)](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Build+Code%22+branch%3Apost-06)
This repository contains the source code for the [A Minimal Rust Kernel][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
This repository contains the source code for the [Double Faults][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
[post]: https://os.phil-opp.com/minimal-rust-kernel/
[post]: https://os.phil-opp.com/double-fault-exceptions/
**Check out the [master branch](https://github.com/phil-opp/blog_os) for more information.**
@@ -52,6 +52,10 @@ dd if=target/x86_64-blog_os/debug/bootimage-blog_os.bin of=/dev/sdX && sync
Where `sdX` is the device name of your USB stick. **Be careful** to choose the correct device name, because everything on that device is overwritten.
## Testing
To run the unit and integration tests, execute `cargo xtest`.
## License
Licensed under either of

56
src/gdt.rs Normal file
View File

@@ -0,0 +1,56 @@
use lazy_static::lazy_static;
use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector};
use x86_64::structures::tss::TaskStateSegment;
use x86_64::VirtAddr;
pub const DOUBLE_FAULT_IST_INDEX: u16 = 0;
lazy_static! {
static ref TSS: TaskStateSegment = {
let mut tss = TaskStateSegment::new();
tss.interrupt_stack_table[DOUBLE_FAULT_IST_INDEX as usize] = {
const STACK_SIZE: usize = 4096;
#[repr(align(16))]
struct Stack([u8; STACK_SIZE]);
static mut STACK: Stack = Stack([0; STACK_SIZE]);
let stack_start = VirtAddr::from_ptr(unsafe { &STACK });
let stack_end = stack_start + STACK_SIZE;
stack_end
};
tss
};
}
lazy_static! {
static ref GDT: (GlobalDescriptorTable, Selectors) = {
let mut gdt = GlobalDescriptorTable::new();
let code_selector = gdt.add_entry(Descriptor::kernel_code_segment());
let tss_selector = gdt.add_entry(Descriptor::tss_segment(&TSS));
(
gdt,
Selectors {
code_selector,
tss_selector,
},
)
};
}
struct Selectors {
code_selector: SegmentSelector,
tss_selector: SegmentSelector,
}
pub fn init() {
use x86_64::instructions::segmentation::set_cs;
use x86_64::instructions::tables::load_tss;
GDT.0.load();
unsafe {
set_cs(GDT.1.code_selector);
load_tss(GDT.1.tss_selector);
}
}

42
src/interrupts.rs Normal file
View File

@@ -0,0 +1,42 @@
use crate::{gdt, println};
use lazy_static::lazy_static;
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
lazy_static! {
static ref IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new();
idt.breakpoint.set_handler_fn(breakpoint_handler);
unsafe {
idt.double_fault
.set_handler_fn(double_fault_handler)
.set_stack_index(gdt::DOUBLE_FAULT_IST_INDEX);
}
idt
};
}
pub fn init_idt() {
IDT.load();
}
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
}
extern "x86-interrupt" fn double_fault_handler(
stack_frame: &mut InterruptStackFrame,
_error_code: u64,
) -> ! {
panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
}
#[cfg(test)]
use crate::{serial_print, serial_println};
#[test_case]
fn test_breakpoint_exception() {
serial_print!("test_breakpoint_exception...");
// invoke a breakpoint exception
x86_64::instructions::interrupts::int3();
serial_println!("[ok]");
}

64
src/lib.rs Normal file
View File

@@ -0,0 +1,64 @@
#![no_std]
#![cfg_attr(test, no_main)]
#![feature(custom_test_frameworks)]
#![feature(abi_x86_interrupt)]
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"]
use core::panic::PanicInfo;
pub mod gdt;
pub mod interrupts;
pub mod serial;
pub mod vga_buffer;
pub fn init() {
gdt::init();
interrupts::init_idt();
}
pub fn test_runner(tests: &[&dyn Fn()]) {
serial_println!("Running {} tests", tests.len());
for test in tests {
test();
}
exit_qemu(QemuExitCode::Success);
}
pub fn test_panic_handler(info: &PanicInfo) -> ! {
serial_println!("[failed]\n");
serial_println!("Error: {}\n", info);
exit_qemu(QemuExitCode::Failed);
loop {}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum QemuExitCode {
Success = 0x10,
Failed = 0x11,
}
pub fn exit_qemu(exit_code: QemuExitCode) {
use x86_64::instructions::port::Port;
unsafe {
let mut port = Port::new(0xf4);
port.write(exit_code as u32);
}
}
/// Entry point for `cargo xtest`
#[cfg(test)]
#[no_mangle]
pub extern "C" fn _start() -> ! {
init();
test_main();
loop {}
}
#[cfg(test)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
test_panic_handler(info)
}

View File

@@ -1,26 +1,42 @@
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(blog_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
use blog_os::println;
use core::panic::PanicInfo;
static HELLO: &[u8] = b"Hello World!";
#[no_mangle]
pub extern "C" fn _start() -> ! {
let vga_buffer = 0xb8000 as *mut u8;
println!("Hello World{}", "!");
for (i, &byte) in HELLO.iter().enumerate() {
unsafe {
*vga_buffer.offset(i as isize * 2) = byte;
*vga_buffer.offset(i as isize * 2 + 1) = 0xb;
}
blog_os::init();
fn stack_overflow() {
stack_overflow(); // for each recursion, the return address is pushed
}
// uncomment line below to trigger a stack overflow
// stack_overflow();
#[cfg(test)]
test_main();
println!("It did not crash!");
loop {}
}
/// This function is called on panic.
#[cfg(not(test))]
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
loop {}
}
#[cfg(test)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
blog_os::test_panic_handler(info)
}

37
src/serial.rs Normal file
View File

@@ -0,0 +1,37 @@
use lazy_static::lazy_static;
use spin::Mutex;
use uart_16550::SerialPort;
lazy_static! {
pub static ref SERIAL1: Mutex<SerialPort> = {
let mut serial_port = unsafe { SerialPort::new(0x3F8) };
serial_port.init();
Mutex::new(serial_port)
};
}
#[doc(hidden)]
pub fn _print(args: ::core::fmt::Arguments) {
use core::fmt::Write;
SERIAL1
.lock()
.write_fmt(args)
.expect("Printing to serial failed");
}
/// Prints to the host through the serial interface.
#[macro_export]
macro_rules! serial_print {
($($arg:tt)*) => {
$crate::serial::_print(format_args!($($arg)*));
};
}
/// Prints to the host through the serial interface, appending a newline.
#[macro_export]
macro_rules! serial_println {
() => ($crate::serial_print!("\n"));
($fmt:expr) => ($crate::serial_print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => ($crate::serial_print!(
concat!($fmt, "\n"), $($arg)*));
}

204
src/vga_buffer.rs Normal file
View File

@@ -0,0 +1,204 @@
use core::fmt;
use lazy_static::lazy_static;
use spin::Mutex;
use volatile::Volatile;
#[cfg(test)]
use crate::{serial_print, serial_println};
lazy_static! {
/// A global `Writer` instance that can be used for printing to the VGA text buffer.
///
/// Used by the `print!` and `println!` macros.
pub static ref WRITER: Mutex<Writer> = Mutex::new(Writer {
column_position: 0,
color_code: ColorCode::new(Color::Yellow, Color::Black),
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) },
});
}
/// The standard color palette in VGA text mode.
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3,
Red = 4,
Magenta = 5,
Brown = 6,
LightGray = 7,
DarkGray = 8,
LightBlue = 9,
LightGreen = 10,
LightCyan = 11,
LightRed = 12,
Pink = 13,
Yellow = 14,
White = 15,
}
/// A combination of a foreground and a background color.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
struct ColorCode(u8);
impl ColorCode {
/// Create a new `ColorCode` with the given foreground and background colors.
fn new(foreground: Color, background: Color) -> ColorCode {
ColorCode((background as u8) << 4 | (foreground as u8))
}
}
/// A screen character in the VGA text buffer, consisting of an ASCII character and a `ColorCode`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
struct ScreenChar {
ascii_character: u8,
color_code: ColorCode,
}
/// The height of the text buffer (normally 25 lines).
const BUFFER_HEIGHT: usize = 25;
/// The width of the text buffer (normally 80 columns).
const BUFFER_WIDTH: usize = 80;
/// A structure representing the VGA text buffer.
#[repr(transparent)]
struct Buffer {
chars: [[Volatile<ScreenChar>; BUFFER_WIDTH]; BUFFER_HEIGHT],
}
/// A writer type that allows writing ASCII bytes and strings to an underlying `Buffer`.
///
/// Wraps lines at `BUFFER_WIDTH`. Supports newline characters and implements the
/// `core::fmt::Write` trait.
pub struct Writer {
column_position: usize,
color_code: ColorCode,
buffer: &'static mut Buffer,
}
impl Writer {
/// Writes an ASCII byte to the buffer.
///
/// Wraps lines at `BUFFER_WIDTH`. Supports the `\n` newline character.
pub fn write_byte(&mut self, byte: u8) {
match byte {
b'\n' => self.new_line(),
byte => {
if self.column_position >= BUFFER_WIDTH {
self.new_line();
}
let row = BUFFER_HEIGHT - 1;
let col = self.column_position;
let color_code = self.color_code;
self.buffer.chars[row][col].write(ScreenChar {
ascii_character: byte,
color_code,
});
self.column_position += 1;
}
}
}
/// Writes the given ASCII string to the buffer.
///
/// Wraps lines at `BUFFER_WIDTH`. Supports the `\n` newline character. Does **not**
/// support strings with non-ASCII characters, since they can't be printed in the VGA text
/// mode.
fn write_string(&mut self, s: &str) {
for byte in s.bytes() {
match byte {
// printable ASCII byte or newline
0x20..=0x7e | b'\n' => self.write_byte(byte),
// not part of printable ASCII range
_ => self.write_byte(0xfe),
}
}
}
/// Shifts all lines one line up and clears the last row.
fn new_line(&mut self) {
for row in 1..BUFFER_HEIGHT {
for col in 0..BUFFER_WIDTH {
let character = self.buffer.chars[row][col].read();
self.buffer.chars[row - 1][col].write(character);
}
}
self.clear_row(BUFFER_HEIGHT - 1);
self.column_position = 0;
}
/// Clears a row by overwriting it with blank characters.
fn clear_row(&mut self, row: usize) {
let blank = ScreenChar {
ascii_character: b' ',
color_code: self.color_code,
};
for col in 0..BUFFER_WIDTH {
self.buffer.chars[row][col].write(blank);
}
}
}
impl fmt::Write for Writer {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.write_string(s);
Ok(())
}
}
/// Like the `print!` macro in the standard library, but prints to the VGA text buffer.
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ($crate::vga_buffer::_print(format_args!($($arg)*)));
}
/// Like the `println!` macro in the standard library, but prints to the VGA text buffer.
#[macro_export]
macro_rules! println {
() => ($crate::print!("\n"));
($($arg:tt)*) => ($crate::print!("{}\n", format_args!($($arg)*)));
}
/// Prints the given formatted string to the VGA text buffer through the global `WRITER` instance.
#[doc(hidden)]
pub fn _print(args: fmt::Arguments) {
use core::fmt::Write;
WRITER.lock().write_fmt(args).unwrap();
}
#[test_case]
fn test_println_simple() {
serial_print!("test_println... ");
println!("test_println_simple output");
serial_println!("[ok]");
}
#[test_case]
fn test_println_many() {
serial_print!("test_println_many... ");
for _ in 0..200 {
println!("test_println_many output");
}
serial_println!("[ok]");
}
#[test_case]
fn test_println_output() {
serial_print!("test_println_output... ");
let s = "Some test string that fits on a single line";
println!("{}", s);
for (i, c) in s.chars().enumerate() {
let screen_char = WRITER.lock().buffer.chars[BUFFER_HEIGHT - 2][i].read();
assert_eq!(char::from(screen_char.ascii_character), c);
}
serial_println!("[ok]");
}

27
tests/basic_boot.rs Normal file
View File

@@ -0,0 +1,27 @@
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(blog_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
use blog_os::{println, serial_print, serial_println};
use core::panic::PanicInfo;
#[no_mangle] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
test_main();
loop {}
}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
blog_os::test_panic_handler(info)
}
#[test_case]
fn test_println() {
serial_print!("test_println... ");
println!("test_println output");
serial_println!("[ok]");
}

25
tests/should_panic.rs Normal file
View File

@@ -0,0 +1,25 @@
#![no_std]
#![no_main]
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn _start() -> ! {
should_fail();
serial_println!("[test did not panic]");
exit_qemu(QemuExitCode::Failed);
loop {}
}
fn should_fail() {
serial_print!("should_fail... ");
assert_eq!(0, 1);
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
serial_println!("[ok]");
exit_qemu(QemuExitCode::Success);
loop {}
}

57
tests/stack_overflow.rs Normal file
View File

@@ -0,0 +1,57 @@
#![no_std]
#![no_main]
#![feature(abi_x86_interrupt)]
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
use core::panic::PanicInfo;
use lazy_static::lazy_static;
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
#[no_mangle]
pub extern "C" fn _start() -> ! {
serial_print!("stack_overflow... ");
blog_os::gdt::init();
init_test_idt();
// trigger a stack overflow
stack_overflow();
panic!("Execution continued after stack overflow");
}
#[allow(unconditional_recursion)]
fn stack_overflow() {
stack_overflow(); // for each recursion, the return address is pushed
}
lazy_static! {
static ref TEST_IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new();
unsafe {
idt.double_fault
.set_handler_fn(test_double_fault_handler)
.set_stack_index(blog_os::gdt::DOUBLE_FAULT_IST_INDEX);
}
idt
};
}
pub fn init_test_idt() {
TEST_IDT.load();
}
extern "x86-interrupt" fn test_double_fault_handler(
_stack_frame: &mut InterruptStackFrame,
_error_code: u64,
) -> ! {
serial_println!("[ok]");
exit_qemu(QemuExitCode::Success);
loop {}
}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
blog_os::test_panic_handler(info)
}