Compare commits

...

403 commits

Author SHA1 Message Date
koniifer a551b2672f buffer awaiting -> free performance and free bugs 2024-11-27 16:53:17 +00:00
koniifer fd26ec734b temp interrupt fix, problem with sds_search_service 2024-11-27 12:52:48 +00:00
koniifer 9d1c59b65d consolidate simple tests, bug revealed 2024-11-27 12:41:51 +00:00
able cda022e6f0 Merge pull request 'Ktest major improvements' (#23) from funky/ableos:ktest_merge_conflict_fix into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/23
2024-11-27 06:16:25 -06:00
funky 95cf948d59 Ktest major improvements 2024-11-27 19:09:15 +11:00
koniifer f6a8a78b6c mini size fixes 2024-11-26 22:02:54 +00:00
kodin 5d152811b2 Interrupt Forwarding (#22)
Co-authored-by: Talha Qamar <qamartalha@proton.me>
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/22
Co-authored-by: kodin <kodin@yourmoms.house>
Co-committed-by: kodin <kodin@yourmoms.house>
2024-11-26 15:53:50 -06:00
koniifer 685c6f0b20 task scheduler weirdness 2024-11-26 19:32:19 +00:00
Able 1b3dc153e8 SDoom + pcspkr: Both prerelease 2024-11-26 07:39:16 -06:00
Able 9aa84a0f40 👍 checkpoint 2024-11-24 23:51:37 -06:00
Able bdb762c986 Magic function style guide 2024-11-24 23:50:46 -06:00
koniifer 0b57c2e9bb simple foldhash implementation 2024-11-24 20:58:14 +00:00
Able 8c88c0b5ae defer in alloc 2024-11-24 12:43:15 -06:00
Able 8b2b50e433 Style guide update, vscode config to make tab indent follow the style guide 2024-11-24 12:22:06 -06:00
Able d7e0d573e2 Style guide commit. Feel free to bikeshed about it. What should be added etcetc 2024-11-24 11:57:06 -06:00
Able 0ee8b7a4e4 janky error handling 2024-11-24 11:08:22 -06:00
Able 2261f36101 simply just dont inline 2024-11-24 11:04:12 -06:00
Able 6f82c92c30 sorta alloc support. Compiler error checkpoint 2024-11-24 11:03:06 -06:00
koniifer 5ea3ee9fe1 able sanity check 2024-11-24 16:39:24 +00:00
Able 241139f5af changes 2024-11-24 10:18:09 -06:00
Able 5c4056bc5c commit checkpoint 2024-11-24 10:00:24 -06:00
able b505622601 Merge pull request 'Ktest + Nix Flake' (#20) from FunkyEgg/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/20
2024-11-23 21:13:23 -06:00
funky 80ae717dd9 Introduced kernel testing system ktest
This commit also fixed a small issue with panic handler formatting
2024-11-24 11:21:39 +11:00
funky ab8b2309ae Nix Flake Support
nix-shell is broken on both my systems, so better be safe than sorry.
2024-11-24 11:12:24 +11:00
koniifer 7b7e02976d random change 2024-11-23 18:06:48 +00:00
koniifer c1c02ffefd silly string 2024-11-23 16:51:39 +00:00
able 8602ceb0d3 nightly revert 2024-11-23 04:59:32 -06:00
Able 6b673bc7e6 labels now have bg/fg color 2024-11-18 09:19:04 -06:00
koniifer 0af4d142a4 bad process spawning, compiler updates 2024-11-17 20:29:32 +00:00
koniifer 36f0d357cf arm cpuid fix 2024-11-17 10:52:13 +00:00
koniifer ccddf36050 fix 2024-11-17 10:11:14 +00:00
koniifer da5f1a7a19 compiler update 2024-11-16 20:42:16 +00:00
koniifer 2808bc9e7c various fixes, update to latest rust nightly 2024-11-16 16:34:45 +00:00
koniifer d958a103fa fix 2024-11-16 09:34:17 +00:00
koniifer ee82bc5705 minor changes 2024-11-16 09:30:53 +00:00
Able 3d53b641bf interrupt work 2024-11-16 02:51:58 -06:00
koniifer cea7f1fa5c use new register allocator by default 2024-11-15 19:46:36 +00:00
Able 614bef7ec5 ok now there is colors 2024-11-14 18:40:44 -06:00
Able b0f6aa53bd Mouse updates 2024-11-14 18:33:29 -06:00
Able d5f4ce18a3 push changes 2024-11-14 18:09:54 -06:00
koniifer 907c0d0dd4 multi-client support and demo 2024-11-14 21:28:21 +00:00
koniifer 95b4a921dc improve & optimise window decoration code 2024-11-14 16:43:23 +00:00
koniifer b6261d014d bad frame synchronisation implementation 2024-11-13 23:08:20 +00:00
Able 56ee0fe851 misc 2024-11-13 14:17:15 -06:00
koniifer b07bac1f1f broken 2024-11-13 17:03:31 +00:00
koniifer dc9273b3c1 various opts and keeping on top of compiler changes 2024-11-12 20:14:37 +00:00
Able e6d8f5c822 todo changes 2024-11-11 17:49:11 -06:00
koniifer 8ad7542b9c sunset work, stn changes, and fiddling with kernel logging clutter 2024-11-11 21:48:43 +00:00
Able e40a22fccd Commit 2024-11-11 01:23:14 -06:00
koniifer cf917927a5 incomplete sunset redesign 2024-11-11 01:03:01 +00:00
koniifer 97ceb12d6e double skill issue 2024-11-10 20:07:03 +00:00
koniifer bae58ade61 skill issue fix 2024-11-10 20:04:49 +00:00
koniifer b21c05e924 compiler bugfix 2024-11-10 19:37:37 +00:00
Able 2f5bc73665 The List 2024-11-10 13:13:38 -06:00
Able 0003464099 sunsetting sunset 2024-11-10 13:00:41 -06:00
koniifer 77a708d41e sunrising sunset 2024-11-10 18:57:48 +00:00
peony 3409f5051a Circle rendering support (janky) (#18)
circle rendering
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/18
Co-authored-by: peony <peony@email.com>
Co-committed-by: peony <peony@email.com>
2024-11-10 09:03:14 -06:00
Able 8c7b95277d reorg 2024-11-10 06:18:23 -06:00
koniifer 7da32b263f make the cursor more visible 2024-11-10 11:58:42 +00:00
Able 2439722c88 misc 2024-11-10 05:52:51 -06:00
koniifer 3333b1706f minor optimisations 2024-11-10 11:48:55 +00:00
Able 8808ed5bfe misc 2024-11-10 04:33:50 -06:00
koniifer 68d3236cc0 misc 2024-11-10 10:11:40 +00:00
Able eea23d967b mouse cursor functional 2024-11-10 02:36:37 -06:00
Able d2152537ad clean up 2024-11-09 22:34:24 -06:00
Able 7723799e76 changes or something idk 2024-11-09 20:44:10 -06:00
koniifer 8b04b275f3 text editor is actually a text editor 2024-11-09 01:54:33 +00:00
Able 1345f294b8 changes 2024-11-08 14:42:58 -06:00
Able 818bcb458f widgets 2024-11-08 10:29:06 -06:00
Able d2b5f09511 changes + lui examples 2024-11-08 10:16:24 -06:00
Jakub Doka 2676bd7b62
fixing error messages 2024-11-08 15:04:10 +01:00
koniifer 444fcdb0c4 more text editor work 2024-11-08 13:47:24 +00:00
koniifer adbf32d970 text editor work and misc changes 2024-11-08 01:48:17 +00:00
Able 7f01b0e0f8 👍 2024-11-07 09:57:50 -06:00
Able e8edee4ccc broken 👍 2024-11-07 09:57:39 -06:00
koniifer ba59233ce7 untested string.contains(haystack, needle) 2024-11-07 02:22:58 +00:00
Able f13c682171 refactor and widgeting magic 2024-11-06 20:11:36 -06:00
Able b6b097a872 widgeting work 2024-11-06 19:57:47 -06:00
koniifer 6a8d92d2c2 mostly qoi image support
refactor image loader for multiple filetypes
port some broken math stuff
make logger more readable
2024-11-07 01:55:29 +00:00
Able ab8522fbe1 widget UI 2024-11-06 11:43:40 -06:00
Able a49ac7bca0 Label Widget inside horizon 2024-11-06 09:36:17 -06:00
Able 12883ac926 Remove busy loop 2024-11-05 23:04:29 -06:00
Able 6a319c55b0 Proper Y direction 2024-11-05 23:01:15 -06:00
Able 879bbfa173 rework logic 2024-11-05 23:01:06 -06:00
Able 795f10986f Add partial support for sending mouse position updates 2024-11-05 22:58:52 -06:00
Able 85e63eb51c Add backspace 2024-11-05 22:16:08 -06:00
koniifer aafe047b51 forgor 2024-11-06 01:50:28 +00:00
koniifer 404ea22c46 rebase 2024-11-06 01:49:57 +00:00
koniifer 664334fd00 unicode stuff for psf rendering
make silly keyboard app
2024-11-06 01:47:33 +00:00
Able 086948d47a rename 2024-11-03 19:53:09 -06:00
Able b795215b62 enable horizon and ps2 driver 2024-11-03 19:38:40 -06:00
Able 16135ae536 mouse render 2024-11-03 18:37:39 -06:00
Able 941eed0ac9 patch 2024-11-03 18:34:48 -06:00
Able f4ad4b6856 mouse driver 2024-11-03 16:48:36 -06:00
koniifer 9e83707a28 misc changes 2024-11-03 22:31:53 +00:00
Able 6894ef2360 keycode nonsense 2024-11-02 11:09:31 -05:00
Able 69c95c35b5 fix serial argument 2024-11-01 17:37:47 -05:00
Able 80d363bc59 panic func in stn 2024-11-01 15:11:33 -05:00
Able 3c3c156eb0 misc changes + mouse driver work 2024-11-01 13:09:12 -05:00
koniifer eaace7d9c1 unoptimised text load & render 2024-10-26 09:23:28 +01:00
koniifer 5af5631755 minor changes 2024-10-25 16:37:38 +01:00
Able fac573837f Work 2024-10-25 09:17:37 -05:00
koniifer 6ff65eee41 kaboom 2024-10-23 21:49:40 +01:00
koniifer b35b430047 display_int radices 2024-10-20 13:31:44 +01:00
koniifer bcfaf89ed0 fix buffer mutating message 2024-10-20 12:36:34 +01:00
koniifer 2ba2dcb464 change logger message format so it doesn't mutate the string 2024-10-20 12:11:29 +01:00
koniifer 41d9c0b82a miscellaneous changes, free performance tweaks, and fiddle with enabling avx finally 2024-10-19 19:45:41 +01:00
koniifer a94332370a various render changes, implement sine & cosine for stn.math 2024-10-19 15:54:19 +01:00
koniifer 7caa47b9fb make surface example cooler 2024-10-17 15:31:42 +01:00
Able 34101d2e8c Windowing changes 2024-10-15 20:30:24 -05:00
Able 2bc13cd7d8 fix 👍 2024-10-15 18:06:37 -05:00
koniifer 086cc4aef0 patch minor logging bug 2024-10-16 00:03:23 +01:00
Able 84f86488c7 buggy code 2024-10-15 17:25:11 -05:00
Able ed7c8f20cb animal crossing new Horizon beginnings 2024-10-15 17:06:38 -05:00
koniifer 34cbd9a5e6 fiddling 2024-10-15 21:43:23 +01:00
koniifer 0ebb1f200e make surface example more interesting, optimise memory filling 2024-10-15 21:11:06 +01:00
Able fc06820332 fix visibility 2024-10-15 03:44:12 -05:00
koniifer 2a082d8283 rudimentary render surfaces 2024-10-15 01:24:29 +01:00
koniifer 1eee33ce8b fix icky pointer misalignment
move dt_api to stn for ease of use
do away with now redundant strobe example (colour example is basically strobe now)
2024-10-14 18:54:53 +01:00
Able 6fa1c829fd Horizon work 2024-10-13 22:34:33 -05:00
koniifer 820c3e459b optimisations 2024-10-14 01:31:23 +01:00
koniifer 3af28f1666 use able image 2024-10-13 23:41:17 +01:00
koniifer 96c2bd5cd5 bitmap image support & better mem opts
restructure render lib
add peony's render api additions and example
add image example
fix some dubious bugs i had made in unused code in mem_serve.rs
remove tetris stub (now in peony's fork)
update hblang
2024-10-13 23:38:43 +01:00
koniifer ea8eca1089 various stn & render-api changes 2024-10-12 21:39:09 +01:00
koniifer 7f4a040505 WIP help doc 2024-10-12 15:53:32 +01:00
koniifer 82f5cdbe21 add --noaccel flag to disable vm acceleration, update repbuild help 2024-10-12 15:02:55 +01:00
koniifer aac6d61dc6 stupid fix 2024-10-12 13:39:23 +01:00
koniifer 3df6f18c85 fix buffers
update hblang
auto cpu feature detection for repbuild
less verbose buffer api
add peony's tetris stub
2024-10-12 13:35:49 +01:00
koniifer 07ee8de9f1 push it to prod 😄
experimental avx stuff (enable it yourself, coward)
update hblang & fiddle with stuff
2024-09-30 21:45:57 +01:00
Able f64f654610 Device work 2024-09-21 19:20:38 -05:00
Able 7d4b12a103 remove debugging info + fix the updating of hbvm 2024-09-21 19:20:14 -05:00
Able 758629df0a thumbs up 2024-09-20 05:06:08 -05:00
Able 04a449965b + 2024-09-20 04:02:58 -05:00
koniifer 0bbc76124f minor changes, svga work 2024-09-19 20:40:10 +01:00
Able 6ad68dabac hblang executable format update 2024-09-19 07:11:57 -05:00
Able 07c7d52b8c misc 2024-09-19 06:05:11 -05:00
Able 2edc8148ca no merge whamies pls 2024-09-18 03:41:41 -05:00
mlokr 5f59f05dce
removing deprecated rel: path prefix 2024-09-18 10:38:49 +02:00
Able 0bc757164f Input work 2024-09-17 19:26:37 -05:00
Able f5f68bc2df my changes and then boom 2024-09-17 17:23:32 -05:00
Able 7a256dde68 single file change 2024-09-17 12:08:19 -05:00
Able 570b566310 svga device struct updated to mostly reflect real device 2024-09-17 10:02:43 -05:00
Able d2488689fe fixs 2024-09-17 09:52:27 -05:00
Able fe70d81bd0 fat32 stub 2024-09-17 09:49:19 -05:00
Able cc076d9540 pumpkin print 2024-09-17 09:48:10 -05:00
Able 3173b63c93 minor changes 2024-09-17 09:47:53 -05:00
koniifer 48027196b1 omfg it's fixed 🙏 2024-09-17 09:47:53 -05:00
koniifer 78553a3190 let's just use strings for now 2024-09-17 09:47:11 -05:00
koniifer df74b09134 please bugs begone 2024-09-17 09:47:11 -05:00
koniifer 2321efd2e7 bug squashing & testing 2024-09-17 09:46:31 -05:00
Able d9caa17f3c commits 2024-09-17 09:39:46 -05:00
Able b0ecbfa168 fat32 stub 2024-09-17 08:01:16 -05:00
Able 1fe20360f6 pumpkin print 2024-09-16 20:59:24 -05:00
Able fb42351638 minor changes 2024-09-16 20:45:00 -05:00
able 5f2b181f22 Merge pull request 'good luck able' (#17) from koniifer/ableos-framebuffer:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/17
2024-09-14 16:44:05 +00:00
koniifer 43ea77c18f merge mainline branch and do some housekeeping 2024-09-14 11:26:32 +01:00
Able 2b2e0c514b multiline 2024-09-14 04:28:45 -05:00
Able fcca015866 minor changes 2024-09-14 04:05:40 -05:00
Able cc9337348e PCI+SVGA skeleton 2024-09-14 03:51:57 -05:00
Able 028949559b ignim checkpoint 2024-09-14 00:31:35 -05:00
Able 91380539d9 Ignim work 2024-09-13 23:11:50 -05:00
Able ec25c0f207 update on the logger
Further changes pending on the IDL
2024-09-13 20:50:12 -05:00
Able 1b5cb54a2b ignim work 2024-09-13 20:17:47 -05:00
Able 9686349476 add support for the device tree 2024-09-13 18:11:23 -05:00
koniifer f8c7873978 squash 2024-09-13 22:41:31 +01:00
Able 40cc412ab3 Horizon API work 2024-09-13 16:40:05 -05:00
Able cd369b39d5 more changes to make konii so anger 2024-09-12 15:34:28 -05:00
mlokr 331cbf5da1
fixing arm compilation errors 2024-09-10 21:52:57 +02:00
koniifer 63e2f546c5 Merge pull request 'adding disasembly in case something goes wrong' (#1) from mlokis/ableos-framebuffer:disasm into master
Reviewed-on: https://git.ablecorp.us/koniifer/ableos-framebuffer/pulls/1
2024-09-04 17:32:19 +00:00
mlokr 1a2b60b53b
foo 2024-09-04 19:14:30 +02:00
koniifer a7517005de update to latest hblang 2024-09-04 16:08:01 +01:00
Able 0594b99a59 cleanup 2024-09-03 03:34:29 -05:00
Able 1855307cd9 IDL tokenization 2024-09-02 21:50:43 -05:00
koniifer e3f7a2d455 inline fb_driver, update to latest hblang 2024-09-02 04:36:03 +01:00
koniifer 19992595fc update hblang to latest git
remove old ps/2 driver
remove defunct time driver
clean up stuff
i promise im done fiddling with ecah.rs and memory.hb
2024-09-02 01:04:00 +01:00
koniifer f7b970eaf0 hexadecimal support!!
remove fb_driver_stresstest, move examples back to fb_driver, update hblang, update Cargo.lock
2024-09-01 22:29:42 +01:00
koniifer c752028c73 fix ecah.rs, implement -d, --debuginfo to print debug info in serial (requires recompilation) 2024-08-31 19:34:14 +01:00
koniifer 8577920d90 port ecah changes from svga_driver branch 2024-08-31 15:38:15 +01:00
Able 7426bf479f idl work 2024-08-30 12:31:45 -05:00
koniifer 12ee3a9b87 fix random
implement hardware_random_u32
implement math.max, alter math.min
remove unneeded dependencies from fb_driver
2024-08-30 16:22:13 +01:00
koniifer 58bc6facbc Merge remote-tracking branch 'origin/kodin/keyboard-driver' 2024-08-30 14:55:22 +01:00
Talha Qamar 1615297536 Detecting keypresses 2024-08-30 18:06:24 +05:00
Talha Qamar 0d3641e199 just getting started 2024-08-30 18:04:10 +05:00
Able 6295a7118e Added beef to ableOS 2024-08-30 07:38:04 -05:00
koniifer ad85f82be3 begin work for fb_driver interface
create hardware rng buffer & stn.random.uint_64 (currently weird)
move examples out of fb_driver (currently broken)
remove literal kernel panic from `info!("AHHH")`
re-implement stn.buffer.send_message()
2024-08-29 21:37:49 +01:00
Able 9100b3ce44 dev update 2024-08-29 06:51:48 -05:00
Able 1c491e70e0 dev tool prototype 2024-08-28 14:35:08 -05:00
Able 0444fe4dfa readme update 2024-08-27 12:35:52 -05:00
able db08a249e1 Merge pull request 'fb driver' (#16) from aurlex/ableos-framebuffer:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/16
2024-08-21 03:26:45 +00:00
aurlex acc9d19a32 fb driver 2024-08-20 13:03:39 +01:00
Able 6fd47695a6 changes 2024-08-19 13:13:58 -05:00
Able fb8a835926 this ia bad way to handle this but oh well 2024-08-12 08:21:31 -05:00
Able f4246ae387 SEARCHING for dynamically created buffers now works using buffer.create / buffer.search 2024-08-12 08:15:50 -05:00
Able c7214a5a9b commit 2024-08-11 15:10:36 -05:00
Able bf86d9219c disable all programs 2024-07-25 09:28:56 -05:00
Able ea6ba3bdb0 in/out b 2024-07-23 19:37:43 -05:00
Able 3f183e231d compiler update 2024-07-22 18:43:19 -05:00
Able 514dadc667 rename 2024-07-21 06:47:25 -05:00
Able 9ec3bb1f99 fix 2024-07-20 12:54:58 -05:00
Able b99cb09a74 cleanup 2024-07-20 04:10:15 -05:00
Able 528b1fc66c formatted code 2024-07-19 08:53:45 -05:00
Able f0956b529c formater 2024-07-19 07:31:01 -05:00
Able bb37de554f update the compiler 2024-07-19 05:47:59 -05:00
able 0f3c94c0c9 Merge pull request 'String Library Update' (#15) from Trees/ableos_time:my-branch into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/15
2024-07-17 01:52:52 +00:00
Sam Buckley 314523fce7 Reenable fb driver 2024-07-17 01:28:04 +01:00
Sam Buckley 9f9c7af85f Add string stuff to library 2024-07-17 01:24:24 +01:00
Sam Buckley f59776e792 Update string lib for num format - Trees 2024-07-16 22:42:49 +01:00
Able 1adc381399 Hack in an inb/outb api 2024-07-15 16:56:46 -05:00
Able f33cc0bf70 did some stuff /shrug 2024-07-07 08:35:07 -05:00
Able 5f136a66af patch in the fb stuff 2024-07-06 11:23:44 -05:00
Able 54d7e6b02b work 2024-07-06 09:24:23 -05:00
Able 62c181fb6a checkpoint 2024-06-14 11:48:53 -05:00
Able e9e813220b update 2024-06-08 15:18:21 -05:00
able 02455e2cd8 deprecate the old assembler 2024-05-31 13:35:46 -05:00
able e08eab8627 patching together some broken stuff 2024-05-31 13:31:06 -05:00
able c57ef99948 Merge pull request 'un-hard-code the tests' (#14) from wildwestrom/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/14
2024-05-31 15:44:43 +00:00
Christian Westrom b0358efab8 factor out separating path names from the boot prefix 2024-06-01 00:43:40 +09:00
Christian Westrom da606facb0 un-hard-code the tests 2024-06-01 00:31:04 +09:00
able b427ae1c27 Probably this works on someone elses machine. 2024-05-31 10:07:22 -05:00
able a511e99606 Update ecalls to match the spec 2024-05-31 09:15:55 -05:00
able d90016f28e checkpoint 2024-05-31 09:11:45 -05:00
able c20376464e reorg sysdata 2024-05-23 16:59:17 -05:00
able bbe29d54ab Merge pull request 'Repbuild will add files to the disk image programmatically' (#13) from wildwestrom/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/13
2024-05-05 15:54:56 +00:00
Christian Westrom a5cab167c5 load the modules programmatically instead of manually 2024-05-06 00:48:37 +09:00
Christian Westrom b96927d61a remove the fuckywucky memory shit 2024-05-06 00:48:24 +09:00
able edda52e857 Make repbuild safe(er) again. 2024-05-05 05:52:49 -05:00
able d7efa8ca20 Spec typification 2024-05-05 05:08:42 -05:00
able 5fc2e2a6be spec work 2024-05-04 14:46:24 -05:00
able d21654dd4b Starting to spec out the interface with the kernel 2024-05-04 13:20:30 -05:00
able 38986193ca mem stuff 2024-05-04 12:41:47 -05:00
able 779f3bdd1f perchance it works 2024-04-29 05:30:42 -05:00
able f767362ad0 fix :thumb: 2024-04-29 04:43:47 -05:00
able 088e628cde Hypothetical ideas laid out 2024-04-24 23:08:34 -05:00
able 1cc414eaaf meta info 2024-04-24 20:09:45 -05:00
able 5e73e7a370 begin work on ipc protocols 2024-03-22 05:13:17 -05:00
able cc4de4ab5e sds prelim work 2024-03-22 03:58:59 -05:00
able 634d05acea UI Lisp idea 2024-03-13 05:10:45 -05:00
able 189ad503c7 remove a random binary that was checked in 2024-03-11 09:49:11 -05:00
able fac1f77270 memory service 2024-03-11 09:48:56 -05:00
able eb30ee3c12 example of a new build tool for programs 2024-02-15 15:24:01 -06:00
able 89b495d318 more changes 2024-02-15 14:21:00 -06:00
able 7c68609af5 Worked on various small bits 2024-02-15 14:19:51 -06:00
able dfacc91f40 fix the dang lock file 2024-02-10 16:28:51 -06:00
able 307020b96b Un fucked the thingy 2024-02-10 16:15:33 -06:00
able d8cb4d4e64 reorganization 2024-01-18 02:36:24 -06:00
able 195192db8a compiling on arm works again 2023-12-13 04:21:32 -06:00
able 5fba1eb890 Merge pull request 'ECAH: Add error handling for accessing non-existant buffers. As well as add keyboard driver.' (#12) from jcodefox/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/12
2023-12-05 06:04:34 +00:00
Jcodefox 0a6085061a ECAH: Add a simple keyboard driver 2023-12-05 00:56:23 -05:00
Jcodefox 6f061153e6 Log number with buffer error 2023-12-01 10:02:56 -05:00
Jcodefox cb66c07a5f Add check for non-existent buffer 2023-12-01 09:48:57 -05:00
able 15515e6643 add in a Memory Service
Currently it fully ignores messages and only allocates blocks in 4096 byte chunks
2023-12-01 06:11:33 -06:00
able 7a2372d32a Donation 2023-11-27 07:12:04 -06:00
able 65b6f52d2e POC serial driver for arm
Does not work for x86 yet
2023-11-21 03:56:18 -06:00
able 562fb7c9b2 meow 2023-11-20 03:13:18 -06:00
able 762b2aa3ae working on logs 2023-11-19 18:15:03 -06:00
able fe6cccc70d attempt to log arguments in the limine framebuffer
Still needs work having to do with setting the log level
2023-11-18 02:17:54 -06:00
able 815c424248 Minor fixes 2023-11-18 01:32:09 -06:00
Erin b8ce78b6dd Sussy stuff 2023-11-15 19:41:44 +01:00
Erin d396da5f3c Stack grows downwards, baka. 2023-11-15 19:37:52 +01:00
Erin 0f7525b7e3 Stack for programs 2023-11-15 19:33:21 +01:00
able ebf31cba3d add in liberapay 2023-11-14 15:02:50 -06:00
able f074527e42 Arguments are actually passed into programs 2023-11-13 23:51:30 -06:00
Erin f2e561e242 Merge pull request 'Refactored project structure to make it more clean.' (#11) from struct-refactor into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/11
2023-11-11 15:12:02 +00:00
Erin 2c1d24ab37 Little reorg 2023-11-11 15:45:45 +01:00
Erin 4e9b75a517 kernel(detail): remove logging on memory load 2023-11-11 13:58:52 +01:00
able 0af4758a45 beop 2023-11-03 08:25:31 -05:00
Erin fd575a17c9 Fixed memory bug 2023-11-03 09:04:22 +01:00
able bda8659747 beepo 2023-11-02 14:12:10 -05:00
able 631e1dc288 Panic rn 2023-11-02 14:08:48 -05:00
able b7f9b071bf :) limine 2023-10-29 09:25:13 -05:00
able 94569624f6 update the limine CFG 2023-10-29 08:41:20 -05:00
able 080bb8b188 More work on the psuedo STD lib and IPC 2023-10-29 07:27:10 -05:00
able 1ae1d2ceac Logging works enough. Still unstructured however. 2023-10-28 23:14:36 -05:00
able 707528ef86 A nice stopping point so I can lament work 2023-10-28 08:43:32 -05:00
able c8f500470e Getting some basic userland logger setup 2023-10-28 08:28:07 -05:00
Erin 6885f1cdaf Updated HBVM version 2023-10-28 03:26:04 +02:00
able fa328add42 remove redundant comment bb 2023-10-25 08:36:12 -05:00
able d1d1bd7fd7 cursed-ness 2023-10-23 09:12:43 -05:00
Erin ebfc9c1c4e Zero memory on allocation 2023-10-08 11:24:55 +02:00
able ada43910d2 edits to support multi-arch iso 2023-09-20 12:26:36 -05:00
able 29bcce58b3 CPUID support 2023-09-20 12:01:12 -05:00
able 9105469c3b Arm now logs to the framebuffer 2023-09-17 17:13:23 -05:00
able e7bbb9a375 Arm is now feature parity with x86 2023-09-17 16:03:32 -05:00
able 008a8eb336 More tracing 2023-09-13 02:19:37 -05:00
able e0aa63bebf DOC: Improved driver dependencies and such 2023-09-11 01:36:13 -05:00
able 9cf6f93949 TODO updates 2023-09-09 15:52:01 -05:00
able 1be13d30d1 Ecall work 2023-09-09 02:35:16 -05:00
able 8fec90db95 X86 Timer cleanup 2023-09-09 02:34:43 -05:00
able c16c235c95 Module fix 2023-09-09 02:34:29 -05:00
able 54844b46a0 ECALL work and expanded errors on HBVM shutdown 2023-09-07 14:36:53 -05:00
able b04ee13185 Register dump on panic 2023-09-07 14:31:31 -05:00
Erin 0e8fb17f3a REPBUILD: Fix 2023-08-30 01:12:40 +02:00
Erin 3c45720fa3 Better example 2023-08-22 15:57:57 +02:00
Erin cbed32526b KERNEL: Fixed holeybytes 2023-08-22 15:52:30 +02:00
Erin 0f151fdd52 阿呆: changed trait impls 2023-08-22 15:31:28 +02:00
Erin f948e35e3f Updated deps
+ manage your local editor ignores locally, we are not here for supporting all possible editors on the world.
2023-08-22 15:17:27 +02:00
Erin 88213a7df0 AMOGUS: Fixed compilation 2023-08-13 02:36:26 +02:00
able 239ee43064 Merge pull request 'ARM: Add serial console logging' (#9) from microtau/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/9
2023-07-20 11:03:57 +00:00
microtau c9ab181d95 REPBUILD: Always regenerate the image 2023-07-20 10:42:48 +00:00
microtau f474f0fb69 CLEAN: Remove env_logger dependency 2023-07-20 10:02:10 +00:00
microtau d0a2f436a8 CLEAN: Remove unnecessary dependencies 2023-07-20 09:24:33 +00:00
microtau 7865bca782 ARM: Add serial console logging 2023-07-20 09:21:00 +00:00
able c0744d5596 Merge pull request 'LIMINE: Bump version' (#8) from microtau/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/8
2023-07-19 17:14:08 +00:00
microtau ea49841de2 LIMINE: Bump version 2023-07-19 16:54:01 +00:00
able 84757f7060 Revert "LIMINE: I think this updates the submodule?"
This reverts commit 2dcd096de9.
2023-07-19 11:21:15 -05:00
able e7b46f639c SUBMODULE: Removed it temporarily 2023-07-19 10:55:58 -05:00
able 2dcd096de9 LIMINE: I think this updates the submodule? 2023-07-17 09:51:57 -05:00
able 9225d2d773 ARM: checkpoint from micro-tau 2023-07-17 09:36:39 -05:00
able ede52eb1db ARM: work done on getting the bootloader working 2023-07-17 00:36:06 -05:00
able 81e2603c4d Merge pull request 'x86_64: Refactor device info fetching' (#7) from JohnyTheCarrot/ableos:chore/refactor-device-info into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/7

LG2M
2023-07-15 13:05:33 +00:00
JohnyTheCarrot af7bcc8efb Merge remote-tracking branch 'origin/chore/refactor-device-info' into chore/refactor-device-info 2023-07-15 15:05:01 +02:00
JohnyTheCarrot f0be41ec49 make requested changes 2023-07-15 15:04:53 +02:00
JohnyTheCarrot c955f3a0de Merge branch 'master' into chore/refactor-device-info 2023-07-15 12:50:07 +00:00
JohnyTheCarrot 53fca04786 x86_64: Refactor device info fetching 2023-07-15 14:47:46 +02:00
able 4cf933c62b TODO: Add some more info 2023-07-15 06:16:00 -05:00
able 6c4eee0c56 SCHED: Two programs are now running in ableOS 2023-07-15 05:51:19 -05:00
able d3e019ffe1 ARM: Commit the sin of binarys into a git repo 2023-07-15 05:50:54 -05:00
able a8005728bf ARM: moved dep to proper location 2023-07-14 23:13:29 -05:00
able 80bfcb83b9 CLEAN: remove old data and set default target to x86 2023-07-14 20:30:47 -05:00
able 3a62f65cd1 ARM: Whoe knows 2023-07-14 20:00:50 -05:00
able d8a68aabee Merge branch 'master' of ssh://git.ablecorp.us:20/AbleOS/ableos 2023-07-14 19:38:46 -05:00
able 9bbc0e19a1 ARM: it compiles but does not yet run :V 2023-07-14 19:38:13 -05:00
able 490f15db48 Merge pull request 'another shrimple macro!' (#6) from IntoTheNight/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/6
2023-07-15 00:12:03 +00:00
able 4dd3699e0e frowny 2023-07-13 22:41:09 -05:00
IntoTheNight bea92d996c Merge branch 'master' into master 2023-07-13 14:25:20 +00:00
IntoTheNight 6a404b8227 another shrimple macro!
(NOTE: I was unable to test on my Nix system for some reason, QEMU just refuses to work even though I ran it within the Nix Shell environment)
2023-07-13 19:50:44 +05:30
able a9350952b7 SCHED: Set a sane TQ 2023-07-13 03:41:15 -05:00
able b9af2ae9c4 SCHEDULER: added in some super simple bootmodules and run them 2023-07-13 03:27:47 -05:00
Erin aa5ea3fb8f Auto-fetch OVMF 2023-07-13 03:21:33 +02:00
able 3b6dce674d SCHEDULER: add register dumps 2023-07-12 12:24:52 -05:00
able 2f24089938 SCHEDULER: cut out deadcode and added ifguard 2023-07-12 12:22:13 -05:00
able d1a6e627ef Increase the default heapsize 2023-07-12 12:21:31 -05:00
able 1455f1712c Merge pull request 'master' (#5) from IntoTheNight/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/5
2023-07-12 16:48:02 +00:00
able 473598d5df Merge branch 'master' into master 2023-07-12 16:47:55 +00:00
MunirG05 56ec28550f does this fix the issue?? 2023-07-12 22:16:14 +05:30
able a18ca4335f REPBUILD: Space 2023-07-12 11:27:42 -05:00
able de8661be62 COMMUNITY: Discord link update 2023-07-12 10:04:20 -05:00
able c264865d49 X86: cpuid changes 2023-07-12 09:01:58 -05:00
able 340d76fd13 CAPS: Changing the printing of caps 2023-07-12 06:03:29 -05:00
able b7da4f17c2 REPBUILD: default devices changed 2023-07-12 06:03:06 -05:00
MunirG05 2af7684532 fix the dumb 2023-07-11 13:32:40 +05:30
MunirG05 7a00dff4b9 fix the dumb 2023-07-11 13:30:45 +05:30
able ae321a9923 CAPS: Adding in capabilities 2023-07-10 22:54:05 -05:00
MunirG05 bb27f48f4a scheduler but i stole the code from the engine and tried to stuff it into the scheduler and i have no idea if it works or not but it porbably does 2023-07-10 23:43:42 +05:30
MunirG05 359d62c1b0 i pushed so i can work on it in windows thanks 2023-07-10 17:14:11 +05:30
able a2a2b509bb Merge pull request 'master' (#4) from IntoTheNight/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/4
2023-07-09 12:46:49 +00:00
IntoTheNight 4252719a72 another shrimple macro! 2023-07-09 17:18:41 +05:30
IntoTheNight 7ac33efcbc uauhfa 2023-07-09 16:37:13 +05:30
IntoTheNight 87c3d0bb3a add a shrimple macro
add a shrimple macro
2023-07-09 16:33:47 +05:30
IntoTheNight dc03601ac0 add a shrimple macro 2023-07-09 16:30:16 +05:30
able 8e8289f5ba BOOT: Work on boot modules 2023-07-08 23:22:44 -05:00
able c276476068 WORKSPACE: fix resolver 2023-07-08 23:22:13 -05:00
able e8d854a171 REPBUILD: Fix disk.img generation 2023-07-08 23:21:27 -05:00
able 06868b516f fix compile error 2023-06-26 18:42:55 -05:00
able 567871d18e Scheduler work 2023-06-26 07:55:37 -05:00
able 1dd330e604 Revert "prelim scheduler work"
This reverts commit 1be36455e4.
2023-06-26 07:54:48 -05:00
able 1be36455e4 prelim scheduler work 2023-06-26 07:54:37 -05:00
able 36f2a8336f most recent HBVM works 2023-06-26 06:36:30 -05:00
able 432af37737 TODO: init stuff 2023-06-25 22:34:24 -05:00
able 0508140f40 CLEANUP: turned if statement into match 2023-06-21 17:16:22 -05:00
able 65f1695b46 ROADMAP 2023-06-16 06:09:22 -05:00
able c2b8341667 FORMAT 2023-06-16 05:20:37 -05:00
able 1a98fe8908 CONFIG: adding in a spawn command 2023-06-15 03:45:27 -05:00
able d4670cb85d REPBUILD: Minor todo fix 2023-06-13 21:03:09 -05:00
able 16ccd51e4a cleanup and docs 2023-06-13 06:00:11 -05:00
able b9b798efff DOCS: adding in some docs in various spots and added a contrib guide 2023-05-28 04:51:51 -05:00
able 03667f6039 CPU: minor changes in cpuid 2023-05-28 02:04:20 -05:00
able 8eebd50179 ALLOCATOR: misc 2023-05-28 02:01:11 -05:00
able bb3c1b6120 CPU: Added more cpu feature detection 2023-05-28 02:00:54 -05:00
able b9bfd99335 GRAPHICS: Line thickness change for the HBVM logo 2023-05-26 06:31:52 -05:00
able 49105e668d LOGGING: Begin work on consistent logging style 2023-05-26 06:30:17 -05:00
able 40c072ad99 ROADMAP: Taking down notes on the order in which things should proceed with ableOS 2023-05-25 07:15:53 -05:00
able a2bf48f56b minor cleanups 2023-05-25 07:04:19 -05:00
able 5af29efe17 Remove warnings 2023-05-23 05:16:14 -05:00
able e513caf499 nix WORKS 2023-05-23 04:52:26 -05:00
able ad22051a20 Working on booting on nixOS 2023-05-23 04:26:32 -05:00
Able 2744e8e67b tack inplace hbvm 2023-05-15 02:19:34 -05:00
Able 282688d48b purge wasm 2023-05-08 04:42:02 -05:00
Able 88df7c2c34 remove interp and all wasm related code 2023-05-08 04:35:37 -05:00
Able 4a8b56a474 dynamically support display discovery 2023-05-08 03:53:15 -05:00
Able 308592cbf9 fix 2023-05-06 07:05:45 -05:00
Able fb0dcc786d ableos update 2023-05-06 06:50:24 -05:00
able e53d7896a7 Merge pull request 'Add some minimal instructions' (#3) from wildwestrom/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/3
2023-04-30 04:20:14 +00:00
Christian Westrom 6843023a44 add some minimal instructions 2023-04-30 13:19:03 +09:00
Able 174b621acd add an example system.toml 2023-04-26 14:33:40 -05:00
Able 01cdd68b28 cleanup + rustfmt config 2023-04-12 13:08:07 -05:00
Able ec7a80c93a Change 2023-04-10 01:16:30 -05:00
Able 530a8a9d60 changes 2023-04-07 16:44:33 -05:00
Able 20e3ce15be hacking in a wasm interpreter 2023-04-05 12:29:20 -05:00
Erin 0a77e691d7 boom! 2023-03-30 23:43:04 +02:00
Able d6e27bc1f4 add a pci device view on boot 2022-11-30 01:47:15 -06:00
Able 64a02bbf01 solid 2022-11-23 06:23:36 -06:00
Able 40c99b47b5 changing color parsing from \0 to \1a 2022-11-23 02:32:12 -06:00
Able 1f8ea529f9 fix echo command and add traces to vfs 2022-11-23 01:55:09 -06:00
Erin f396c3642d Skeleton for architecture-specific things 2022-11-07 21:21:16 +01:00
Erin 4812e59c09 Threw stuff from the microkernel. Start of moving core parts there. 2022-11-07 20:29:42 +01:00
Erin d31f17f07e clippy 2022-11-05 01:43:41 +01:00
Erin 4e6bed0b57 removed module that I forgot to remove + 1.65 stuff 2022-11-05 01:40:38 +01:00
Erin 56700a7986 removed sus messaging module 2022-11-05 00:39:37 +01:00
Erin b943714093 update 2022-10-29 19:53:08 +02:00
Erin 8ebaf1b244 fixed sound 2022-10-29 19:20:23 +02:00
Erin 84f163f534 merge 2022-08-28 22:04:55 +02:00
Erin 3b1e51d1ba fixed qr code 2022-08-21 11:45:28 +02:00
461 changed files with 13036 additions and 26036 deletions

View file

@ -1,2 +1,3 @@
[alias] [alias]
repbuild = "run --manifest-path ./repbuild/Cargo.toml --" repbuild = "run --manifest-path ./repbuild/Cargo.toml -- "
dev = "run --manifest-path ./dev/Cargo.toml -r --"

View file

@ -1,4 +0,0 @@
set history save on
file target/x86_64-ableos/debug/ableos
target remote localhost:9000
tui enable

View file

@ -1,22 +0,0 @@
name: Build
on:
- push
- pull_request
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: rust-src
- uses: actions-rs/cargo@v1
with:
command: repbuild
args: run

5
.gitignore vendored
View file

@ -1,6 +1 @@
userland/root_fs/mnt/
target/ target/
.gdb_history
!*/.gitkeep
__pycache__/
debug.log

5
.gitmodules vendored Normal file
View file

@ -0,0 +1,5 @@
[submodule "limine"]
path = limine
url = https://github.com/limine-bootloader/limine.git
branch = v4.x-branch-binary
shallow = true

View file

@ -1,6 +1,7 @@
{ {
"files.associations": { "editor.insertSpaces": false,
"stddef.h": "c" "editor.detectIndentation": false,
},
"rust-analyzer.checkOnSave.allTargets": false, "rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.showUnlinkedFileNotification": false,
"C_Cpp.errorSquiggles": "disabled"
} }

1299
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,9 @@
[workspace] [workspace]
members = [ resolver = "2"
"ableos", members = ["dev", "kernel", "repbuild"]
"asl",
"ext2-rs", # [profile.release]
"kernel", # strip = "symbols"
"facepalm", # codegen-units = 1
"repbuild" # lto = true
] # panic = "abort"

69
HELP.md Normal file
View file

@ -0,0 +1,69 @@
### What are the requirements?
- A machine with [Rustc Tier 1 platform support](https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-1-with-host-tools)
- Rustup
- QEMU (for executing)
- GIT CLI
### How do I run ableos?
- It is recommended to run ableos under QEMU. Here is how:
- Install QEMU
- Clone ableos
- Go to ableos directory
- Pull the limine submodule with `git submodule update --init`
- Run `cargo repbuild help`
### How can I contribute?
- [Contribute code](#how-do-i-contribute-code)
- [Run ableos on your machine](#how-do-i-run-ableos)
- Find bugs
- Create media showing ableos
### How do I contribute code?
- Start by forking ableos
- Write something that runs in the userspace, for example:
- System drivers
- Programs
- Libraries
- Patch bugs and improve code in the kernel
- Ensure that the code is OK to be maintained by asking in the [discord](https://discord.gg/t5Wt3K4YNA)
- When you have finished your changes, you can submit a pull request for review [here](https://git.ablecorp.us/ableos/ableos)
### repbuild and kernel compile, but QEMU isn't starting
- Ensure you have the `qemu-desktop-{arch}` for your OS and target architecture installed
- Try running again with `--noaccel` if you have QEMU already
### I have run using repbuild but it's slow
- Ensure release mode is enabled with the `-r` flag
- Remove the `--noaccel` flag if you can
- If both of these are already done, there may be a problem with thee VM, kernel, your program, or the hblang compiler
### Compiler is complaining about "reg id leaked"
- [Submit](#how-do-i-report-a-compiler-bug) an issue, reg id leaked is a bug
### My program isn't running
- Refer to [here](#i-have-run-using-repbuild-but-its-slow), it may be that your program is simply starting slowly
- Ensure that your program has a properly written meta.toml file
- Ensure that your program is enabled in [system_config.toml](sysdata/system_config.toml)
- Try running again with `--noaccel`, there is a known bug with some systems that prevents programs from starting.
### Kernel panic??? Huh???
- Kernel panics can be caused by improperly using memory (e.g, writing out of bounds)
- Kernel panics are most likely to be caused when accessing memory or using `@eca` for kernel ecalls
- [Report](#how-do-i-report-an-ableos-bug) a kernel panic
### I am running in release mode but I have no debug info
- Add the `-d` flag for debug info
### What is `@eca`? How do I use it?
- Eca is an ecall. They are similar to syscalls
- The `@eca` directive takes the following arguments:
- `@eca(ecall_number, reg_1, ..., reg_n)`
- The various ecalls have different arguments that are given by register values
- Most ecalls are wrapped by `stn`, for example, `random`, `buffer`, and `memory` all make use of ecalls
- All ecalls can be found [ecah.rs](kernel/src/holeybytes/ecah.rs)
### How do I report an ableos bug?
- Submit an issue [here](https://git.ablecorp.us/ableos/ableos/issues) or report it in the [discord](https://discord.gg/t5Wt3K4YNA)
### How do I report a compiler bug?
- Submit an issue [here](https://git.ablecorp.us/ableos/holey-bytes/issues) or report it in the [discord](https://discord.gg/t5Wt3K4YNA)

View file

@ -1,26 +1,16 @@
# ableOS # AbleOS
![Discord](https://img.shields.io/discord/831368967385120810) ![Code Size](https://img.shields.io/github/languages/code-size/abletheabove/ableos) An UNIX-unlike micro-kernel written in rust with an embedded bytecode virtual machine.
## Set up
Install [Qemu](https://www.qemu.org/)
> On Windows be sure to add `C:\Program Files\qemu` to your `PATH` variable Please note that a custom target directory is not supported and support will not be added.
`rustup component add rust-src` # Community
[Discord](https://discord.gg/JrKVukDtgs)
`rustup component add llvm-tools-preview` Donations can be made [here on Liberapay](https://liberapay.com/AbleTheAbove) or on [Patreon](https://www.patreon.com/ablecorp)
<img src="https://img.shields.io/liberapay/patrons/AbleTheAbove.svg?logo=liberapay">
`cargo install bootimage` # Compiling
See [HELP.md](HELP.md)
# Developing
## Running There is a new work in progress developer tool for hblang. (see: dev folder)
repbuild can be used to run and build docs for able os
`cargo repbuild doc`
`cargo repbuild run`
## Testing on real hardware
I recommend using an old x86_64 computer
* `cargo run --release` to generate a binary image that is bootable
* flash it to a USB device via `dd` or balenaEtcher
* Remove said USB device and plug into test machine
* assure test machine boots from USB devices

77
STYLE_GUIDE.md Normal file
View file

@ -0,0 +1,77 @@
# Style Guide
This style guide has two modes that a guideline may be.
`strict` means that prs will be rejected if they do not follow the guideline.
`loose` means that a pr would be accepted but should later be fixed.
## Empty Functions | loose
Empty functions are typically a sign of an unfinished program or driver.
In cases where there is a clear reason to have an empty function it will be allowed.
For example FakeAlloc is only empty functions because it is a example of an the allocator api.
### Allowed
```rust
/// in example.hb
a := fn(): void {}
```
### Not Allowed
```rust
/// in fat32.hb
a := fn(): void {}
```
## Magic Functions | loose
'Magic functions' are what I am calling small helper functions that do one or two things.
### Example
```rust
a := null
magic_a := fn(){
a = 10
}
```
The exact policy I want to have here is a bit fuzzy. I think that functions like this are nice in certain situations and not in others.
Regardless of if you use them or not, put a comment above the function explaining rational.
## Magic Numbers | loose
The policy on magic numbers is make them const and have a comment above them. Typically linking to a source of information about the magic number.
This helps cut down on magic numbers while making acceptable names and atleast half assed documentation.
Constants are inlined anyways, so its the same thing in the binary.
```rust
// The standard vga port is mapped at 0xB8000
$VGA_PTR := 0xB8000
```
## Tabs Vs Spaces | strict
I prefer for hblang code to use hard tabs.
The rational behind this is that a tab is `1 Indent` which some developers might want to be various different sizes when displayed
Soft tabs do not allow this user/editor specific as soft tabs always become spaces.
Bottom line is this is an accessibility feature.
There are some samples below.
```
\t means hard tab
\n means new line
\0x20 means space
```
### Allowed
```rust
if x == y {\n
\tlog(z)\n
}\n
```
### Not Allowed
```rust
if x == y {\n
\0x20\0x20\0x20\0x20log(z)\n
}\n
```

46
TODO.md
View file

@ -1,46 +0,0 @@
# AbleOS
## General
- [ ] Improve EXT2
- [ ] Remove x86 specific code and refine the boot process
## Capabilities
A new process should not have any capabilities at all until it is given them or requests them and is approved.
- [ ] Filesystem cap
- [ ] Create a new filesystem
- [ ] Unmount/Mount a filesystem
- [ ] read a file
- [ ] write a file
- [ ] delete a file
- [ ] Network cap
- [ ] open/close socket
- [ ] bind/unbind socket
- [ ] Manage Process cap
- [ ] spawn Process cap
- [ ] kill Process cap
## Riscv
## ARM
- [ ] Get arm-version booting on real hardware
## Drivers
- [ ] Slim down driver specific program code
- [ ] Remove entry/exit functions for drivers
## Filesystem
- [ ] Create a vfs that ties into the capability system
- [ ] Remote home directory
- [ ] local file caching
- [ ] remote file changes
- [ ] Update file if the remote file changes
# Tooling
## Repbuild
- [ ] make generation of the ext2 image possible

View file

@ -1,15 +0,0 @@
[build]
# target = "riscv64gc-unknown-none-elf"
target = "json_targets/x86_64-ableos.json"
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]
[target.'cfg(target_arch = "x86_64")']
rustflags = ["-C", "target-feature=+rdrand"]
runner = "bootimage runner"
[target.riscv64gc-unknown-none-elf]
rustflags = "-C link-arg=-Tableos/src/arch/riscv/virt.lds"
# ableos/src/arch/riscv/virt.lds

View file

@ -1,166 +0,0 @@
[package]
edition = "2021"
name = "ableos"
version = "0.1.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.release]
panic = "abort"
[package.metadata.bootimage]
run-command = [
"qemu-system-x86_64",
"-device",
"piix4-ide,id=ide",
"-drive",
"file={},format=raw,if=none,id=disk",
"-device",
"ide-hd,drive=disk,bus=ide.0"
]
run-args = [
# "--nodefaults",
"-cpu",
"Broadwell-v3",
"-m",
"4G",
"-serial",
"stdio",
"-smp",
"cores=2",
"-soundhw",
"pcspk",
# "-device",
# "VGA",
# "-device",
# "virtio-gpu-pci",
"-device",
"vmware-svga",
"-device",
"sb16",
# "-machine", "pcspk-audiodev=0",
# "-qmp",
# "unix:../qmp-sock,server,nowait",
]
test-args = [
"-device",
"isa-debug-exit,iobase=0xf4,iosize=0x04",
"-serial",
"stdio",
]
[dependencies]
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
qrcode = { path = "../qrcode-rust" }
bitflags = "1.3"
lliw = "0.2.0"
spin = "0.9"
pretty-hex = "0.2.1"
unicode-width = "0.1.7"
picorand = "0.1.0"
watson = "0.4"
genfs = "0.1.0"
axel = { git = "https://git.ablecorp.us/able/aos_userland" }
versioning = { git = "https://git.ablecorp.us/able/aos_userland" }
# embedded-graphics = "*"
pc-keyboard = "0.5"
# mini-backtrace = "0.1"
clparse = { git = "https://git.ablecorp.us/able/core_utils", default-features = false }
seq-macro = "0.3"
[dependencies.linked_list_allocator]
version = "0.9.0"
features = ["use_spin_nightly"]
[dependencies.log]
version = "0.4.17"
default-features = false
[dependencies.logos]
version = "0.12"
default-features = false
features = ["export_derive"]
[dependencies.rdrand]
version = "0.8"
default-features = false
[dependencies.kernel]
path = "../kernel"
[dependencies.serde]
version = "1.0"
default-features = false
features = ["derive", "alloc"]
[dependencies.hashbrown]
version = "0.12"
default-features = false
features = ["inline-more"]
[dependencies.rkyv]
version = "0.7"
default-features = false
features = ["size_64", "alloc"]
# [dependencies.smoltcp]
# version = "0.8.0"
# default-features = false
# features = ["log", "proto-ipv4"]
[dependencies.y-compositor-protocol]
git = "https://git.ablecorp.us:443/able/y-compositor-protocol.git"
[dependencies.ext2]
path = "../ext2-rs"
[dependencies.toml]
git = "https://git.ablecorp.us:443/theoddgarlic/toml-rs"
# version = "0.5.8"
default-features = false
[dependencies.facepalm]
path = "../facepalm"
[dependencies.ab_glyph]
version = "*"
default-features = false
features = ["libm"]
[dependencies.wasmi]
default-features = false
features = ["core"]
version = "*"
[dependencies.libwasm]
git = "https://git.ablecorp.us:443/able/libwasm.git"
default-features = false
[dependencies.externc-libm]
git = "https://git.ablecorp.us:443/able/externc-libm.git"
[target.'cfg(target_arch = "riscv")'.dependencies]
riscv = "*"
[target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = { version = "0.9.8", features = ["map_physical_memory"] }
cpuio = { git = "https://git.ablecorp.us/ondra05/cpuio.git" }
pic8259 = "0.10.1"
uart_16550 = "0.2.0"
volatile = "0.2.6"
x86_64 = "0.14.8"
pc-beeper = { git = "https://github.com/AbleOS/pc-beeper" }
acpi = "4.1.0"
vga = { git = "https://git.ablecorp.us:443/able/vga.git" }
# vga = { path = "../../vga" }

View file

@ -1,11 +0,0 @@
,-""""-. OS: \0BLUE\0 AbleOS \0RESET\0
,'\ _ _`. Host: ???
/ \)_)-)_)-\ Kernel: AKern-{}-v{}
: : Uptime: {}
\ / Packages: None
\ / Shell: BuiltinShell
`. ,' Resolution: 640x480
`. ,' Terminal: VGABuffer
`.,' CPU: {}
/\`. ,-._ GPU: VGA Compatible
`-' Memory: {}/{}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,16 +0,0 @@
[boot]
system_processes = []
user_processes = ["shell"]
[logging]
enabled = true
level = "Trace"
log_to_serial = true
log_to_vterm = false
filter = ["ableos::ps2_mouse", "ableos::vterm"]
[tests]
run_tests = false
run_demos = false
run_shader_tests = false

View file

@ -1,17 +0,0 @@
pub struct KeyEvent{
lctrl 1
rctrl 2
lalt 3
ralt 4
lsup 5
rsup 6
lshift 7
rshift 8
caps 9
down 10
# Keycodes
key 11-32
}

View file

@ -1 +0,0 @@
{"rustc_fingerprint":3542195962280373086,"outputs":{"17598535894874457435":{"success":true,"status":"","code":0,"stdout":"rustc 1.58.0-nightly (efd048394 2021-10-20)\nbinary: rustc\ncommit-hash: efd0483949496b067cd5f7569d1b28cd3d5d3c72\ncommit-date: 2021-10-20\nhost: x86_64-unknown-linux-gnu\nrelease: 1.58.0-nightly\nLLVM version: 13.0.0\n","stderr":""},"2797684049618456168":{"success":false,"status":"exit status: 1","code":1,"stdout":"","stderr":"error: `-Csplit-debuginfo` is unstable on this platform\n\n"},"15537503139010883884":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n","stderr":""},"931469667778813386":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/elfein/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}

View file

@ -1,15 +0,0 @@
{
"llvm-target": "arm-none-eabihf",
"target-endian": "little",
"target-pointer-width": "32",
"target-c-int-width": "32",
"os": "ableos",
"env": "eabi",
"vendor": "unknown",
"arch": "arm",
"linker-flavor": "gcc",
"linker": "arm-none-eabi-gcc",
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
"executables": true,
"relocation-model": "static"
}

View file

@ -1,24 +0,0 @@
{
"arch": "aarch64",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
"disable-redzone": true,
"env": "",
"executables": true,
"features": "+strict-align,+neon,+fp-armv8",
"is-builtin": false,
"linker": "rust-lld",
"linker-flavor": "ld.lld",
"linker-is-gnu": true,
"pre-link-args": {
"ld.lld": ["-Tsrc/arch/aarch64/aarch64-qemu.ld"]
},
"llvm-target": "aarch64-unknown-none",
"max-atomic-width": 128,
"os": "none",
"panic-strategy": "abort",
"relocation-model": "static",
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64",
"vendor": ""
}

View file

@ -1,15 +0,0 @@
{
"llvm-target": "arm-none-eabihf",
"target-endian": "little",
"target-pointer-width": "32",
"target-c-int-width": "32",
"os": "ableos",
"env": "eabi",
"vendor": "unknown",
"arch": "arm",
"linker-flavor": "gcc",
"linker": "arm-none-eabi-gcc",
"data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
"executables": true,
"relocation-model": "static"
}

View file

@ -1,15 +0,0 @@
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}

View file

@ -1,256 +0,0 @@
0-
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20-
21-
22-
23-
24-
25-
26-
27-
28-
29-
30-
31-
32-
33-
34-
35-
36-
37-
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
69-
70-
71-
72-
73-
74-
75-
76-
77-
78-
79-
80-
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-
91-
92-
93-
94-
95-
96-
97-
98-
99-
100-
101-
102-
103-
104-
105-
106-
107-
108-
109-
110-
111-
112-
113-
114-
115-
116-
117-
118-
119-
120-
121-
122-
123-
124-
125-
126-
127-
128-
129-
130-
131-
132-
133-
134-
135-
136-
137-
138-
139-
140-
141-
142-
143-
144-
145-
146-
147-
148-
149-
150-
151-
152-
153-
154-
155-
156-
157-
158-
159-
160-
161-
162-
163-
164-
165-
166-
167-
168-
169-
170-
171-
172-
173-
174-
175-
176-
177-
178-
179-
180-
181-
182-
183-
184-
185-
186-
187-
188-
189-
190-
191-
192-
193-
194-
195-
196-
197-
198-
199-
200-
201-
202-
203-
204-
205-
206-
207-
208-
209-
210-
211-
212-
213-
214-
215-
216-
217-
218-
219-
220-
221-
222-
223-
224-
225-
226-
227-
228-
229-
230-
231-
232-
233-
234-
235-
236-
237-
238-
239-
240-
241-
242-
243-
244-
245-
246-
247-
248-
249-
250-
251-
252-
253-
254-
255-

View file

@ -1,252 +0,0 @@
# Able doesn't have a full keyboard
0-NONE
1-
2-
3-BACKSPACE
4-
5-
6-
7-
8-
9-TAB
10-
11-
12-
13-ENTER
14-
15-
16-SHIFT
17-CONTROL
18-ALT
19-PAUSE
20-CAPS_LOCK
21-
22-
23-
24-
25-
26-
27-
28-
29-
30-
31-
32-SPACE
33-PAGE_UP
34-PAGE_DOWN
35-END
36-HOME
37-ARROW_LEFT
38-ARROW_UP
39-ARROW_RIGHT
40-ARROW_DOWN
41-
42-
43-
44-
45-INSERT
46-DELETE
47-
48-0
49-1
50-2
51-3
52-4
53-5
54-6
55-7
56-8
57-9
58-
59-SEMICOLON
60-
61-EQUAL
62-
63-
64-
65-a
66-b
67-c
68-d
69-e
70-f
71-g
72-h
73-i
74-j
75-k
76-l
77-m
78-n
79-o
80-p
81-q
82-r
83-s
84-t
85-u
86-v
87-w
88-x
89-y
90-z
91-
92-
93-
94-
95-
96-
97-
98-
99-
100-
101-
102-
103-
106-
107-
108-
109-
110-
111-
112-FUNCTION_1
113-FUNCTION_2
114-FUNCTION_3
115-FUNCTION_4
116-FUNCTION_5
117-FUNCTION_6
118-FUNCTION_7
119-FUNCTION_8
120-FUNCTION_9
121-FUNCTION_10
122-FUNCTION_11
123-FUNCTION_12
124-
125-
126-
127-
128-
129-
130-
131-
132-
134-
135-
136-
137-
138-
139-
140-
141-
142-
143-
145-SCROLL_LOCK
146-
147-
148-
149-
150-
151-
152-
153-
154-
155-
156-
157-
158-
159-
160-
161-
162-
163-
164-
165-
166-
167-
168-
169-
170-
171-
172-
173-MINUS
174-
175-
176-
177-
178-
179-
180-
181-
182-
183-
184-
185-
186-
187-
188-COMMA
189-
190-PERIOD
191-FORWARD_SLASH
192-GRAVE
193-
194-
195-
196-
197-
198-
199-
200-
201-
202-
203-
204-
205-
206-
207-
208-
209-
210-
211-
212-
213-
214-
215-
216-
218-
219-BRACKET_LEFT
220-BACK_SLASH
221-BRACKET_RIGHT
222-QUOTE
223-
224-
225-
226-
227-
228-
229-
230-
231-
232-
233-
234-
235-
236-
237-
238-
239-
240-
241-
242-
243-
244-
245-
246-
247-
248-
249-
250-
251-
252-
253-
254-
255-

View file

@ -1 +0,0 @@
nightly-2022-01-04

View file

@ -1,73 +0,0 @@
//! The allocator to be implemented by ableOS
//!
//! NOTE: All memory regions are taken from https://wiki.osdev.org/Memory_Map_(x86)
use alloc::alloc::{GlobalAlloc, Layout};
use core::{fmt::Display, ptr::null_mut};
const HEAP_START: usize = 600_000_000;
const BLOCK_SIZE: usize = 1024;
const BLOCK_COUNT: usize = 512;
#[derive(Debug, Clone, Copy)]
pub struct MemoryRegion {
_start: usize,
_end: usize,
}
#[derive(Debug, Clone, Copy)]
pub struct AAlloc {
current_region: usize,
memory_regions: [Option<MemoryRegion>; 512],
}
impl AAlloc {
pub fn add_region(&mut self, mem: MemoryRegion) {
self.memory_regions[self.current_region] = Some(mem);
self.current_region += 1;
}
pub fn intialize() {
info!("Heap Start: {}", HEAP_START);
info!("Heap Size: {}", BLOCK_SIZE * BLOCK_COUNT);
info!("Heap End: {}", HEAP_START + BLOCK_SIZE * BLOCK_COUNT);
let mut aalloc = AAlloc {
current_region: 0,
memory_regions: [None; 512],
};
aalloc.add_region(MemoryRegion {
_start: 0x00100000,
_end: 0x00EFFFFF,
});
debug!("{}", aalloc);
}
}
impl Display for AAlloc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "AAlloc {{\n\tcurrent_region: {},\n", self.current_region)?;
for x in 0..self.current_region {
if let Some(region) = self.memory_regions[x] {
write!(f, "\tRegion {}: {:?}\n", x, region)?;
}
}
write!(f, "}}")?;
Ok(())
}
}
unsafe impl GlobalAlloc for AAlloc {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
println!("Allocating memory");
println!("{}", _layout.size());
println!("{}", _layout.align());
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should be never called")
}
}

View file

@ -1,19 +0,0 @@
pub mod aalloc;
pub use aalloc::*;
pub const HEAP_START: usize = 0x_4444_4444_0000;
pub const HEAP_MULTIPLIER: usize = 100000;
pub const HEAP_BASE: usize = 100;
pub const HEAP_SIZE: usize = HEAP_BASE * HEAP_MULTIPLIER;
/*
#[global_allocator]
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
#[alloc_error_handler]
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
panic!("allocation error: {:?}", layout)
}
*/

View file

@ -1,14 +0,0 @@
ENTRY(_start)
SECTIONS
{
. = 0x40000000;
.text.boot : { *(.text.boot) }
.text : { *(.text) }
.data : { *(.data) }
.rodata : { *(.rodata) }
.bss : { *(.bss) }
. = ALIGN(8);
. = . + 0x4000;
LD_STACK_PTR = .;
}

View file

@ -1,15 +0,0 @@
.globl _start
.extern LD_STACK_PTR
.section ".text.boot"
_start:
ldr x30, =LD_STACK_PTR
mov sp, x30
bl not_main
.equ PSCI_SYSTEM_OFF, 0x84000008
.globl system_off
system_off:
ldr x0, =PSCI_SYSTEM_OFF
hvc #0

View file

@ -1,13 +0,0 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
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

@ -1,37 +0,0 @@
use crate::driver_traits::graphics::{Graphics, Point, Rgb};
pub struct GraphicsBuffer;
#[allow(unused)]
impl Graphics for GraphicsBuffer {
fn put_line(coords_start: Point, coords_end: Point, thickness: u32, color: Rgb) {
todo!()
}
fn put_rect(coords_start: Point, coords_end: Point, color: Rgb) {
todo!()
}
fn put_circle(coords: Point, radius: u32) {
todo!()
}
fn put_triangle(coords_1: Point, coords_2: Point, coords_3: Point, thickness: u32, color: Rgb) {
todo!();
}
fn put_pixel(coords: Point, color: Rgb) {
todo!()
}
fn paint_cursor(coords: Point) {
todo!()
}
fn hide_cursor() {}
fn show_cursor() {}
fn draw() {}
fn clear() {
todo!()
}
}

View file

@ -1,4 +0,0 @@
pub mod allocator;
pub mod graphics;
pub mod nrf52;
pub mod serial;

View file

@ -1,70 +0,0 @@
//! A not-very-useful abstraction of GPIOs in Rust
#![allow(dead_code)]
use core::sync::atomic::{AtomicBool, Ordering::SeqCst};
const REG_P0_PIN_CNF_BASE: *mut u32 = 0x5000_0700 as *mut u32;
const REG_P0_OUT_SET: *mut u32 = 0x5000_0508 as *mut u32;
const REG_P0_OUT_CLR: *mut u32 = 0x5000_050C as *mut u32;
const PIN_CNF_DIR_OUTPUT: u32 = 0x0000_0001;
const PIN_CNF_INPUT_CONNECT: u32 = 0x0000_0000;
const PIN_CNF_PULL_DISABLED: u32 = 0x0000_0000;
const PIN_CNF_DRIVE_S0S1: u32 = 0x0000_0000;
const PIN_CNF_SENSE_DISABLED: u32 = 0x0000_0000;
/// A struct that represents an nRF52 Pin
pub struct Pin(u8);
impl Pin {
/// Set a pin to be a push pull output
pub fn set_push_pull_output(&mut self, level: Level) {
// set level
match level {
Level::High => self.set_high(),
Level::Low => self.set_low(),
}
let set_val = PIN_CNF_DIR_OUTPUT
| PIN_CNF_INPUT_CONNECT
| PIN_CNF_PULL_DISABLED
| PIN_CNF_DRIVE_S0S1
| PIN_CNF_SENSE_DISABLED;
unsafe {
core::ptr::write_volatile(REG_P0_PIN_CNF_BASE.offset(self.0 as isize), set_val);
}
}
/// Set a pin to output level low
pub fn set_low(&mut self) {
unsafe { core::ptr::write_volatile(REG_P0_OUT_SET, 1 << (self.0 as u32)) }
}
/// Set a pin to output level high
pub fn set_high(&mut self) {
unsafe { core::ptr::write_volatile(REG_P0_OUT_CLR, 1 << (self.0 as u32)) }
}
}
/// The level of a GPIO
#[derive(Copy, Clone)]
pub enum Level {
Low,
High,
}
/// A struct that represents P0 of the nRF52
pub struct Pins {
pub p0_31: Pin,
}
impl Pins {
/// A function to obtain a Port 0 singleton structure
pub fn take() -> Self {
static TAKEN: AtomicBool = AtomicBool::new(false);
// Enforce this as a singleton
assert!(!TAKEN.swap(true, SeqCst));
Self { p0_31: Pin(31) }
}
}

View file

@ -1,13 +0,0 @@
/// Prints to the host through the serial interface.
#[macro_export]
macro_rules! serial_print {
($($arg:tt)*) => {};
}
/// Prints to the host through the serial interface, appending a newline.
#[macro_export]
macro_rules! serial_println {
() => {};
($fmt:expr) => {};
($fmt:expr, $($arg:tt)*) => {};
}

View file

@ -1 +0,0 @@
pub fn init() {}

View file

@ -1,66 +0,0 @@
pub mod drivers;
pub mod init;
use crate::arch::drivers::nrf52::{Level, Pins};
use core::ptr;
use core::ptr::write_volatile;
global_asm!(include_str!("boot.s"));
fn delay(ticks: usize) {
static mut DUMMY: usize = 0;
// Reduce the number of iterations when in debug mode
#[cfg(debug_assertions)]
let ticks = ticks / 128;
for t in 0..ticks {
// Prevent the optimizer from removing this loop
unsafe {
write_volatile(&mut DUMMY, t);
}
}
}
use crate::print;
#[no_mangle]
pub extern "C" fn not_main() {
const UART0: *mut u8 = 0x0900_0000 as *mut u8;
for byte in b"ableOS Arm 64" {
unsafe {
ptr::write_volatile(UART0, *byte);
}
}
// let gpios = Pins::take();
// let mut led = gpios.p0_31;
//
// loop {
// led.set_high();
// delay(2_000_000);
//
// led.set_low();
// delay(6_000_000);
// }
//
// led.set_push_pull_output(Level::Low);
crate::kmain::kernel_main();
sloop();
}
pub fn sloop() -> ! {
loop {}
}
pub fn print() {
for byte in b"ableOS Arm 64" {
const UART0: *mut u8 = 0x0900_0000 as *mut u8;
unsafe {
ptr::write_volatile(UART0, *byte);
}
}
}
pub fn shutdown() {}

View file

@ -1,4 +0,0 @@
cargo build --target=json_targets/aarch64-ableos.json --release &&\
qemu-system-aarch64 -machine virt -m 1024M -cpu cortex-a53 \
-kernel target/aarch64-ableos/release/ableos -serial stdio \
-device virtio-keyboard

View file

@ -1,13 +0,0 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
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

@ -1,37 +0,0 @@
use crate::driver_traits::graphics::{Graphics, Point, Rgb};
pub struct GraphicsBuffer;
#[allow(unused)]
impl Graphics for GraphicsBuffer {
fn put_line(coords_start: Point, coords_end: Point, thickness: u32, color: Rgb) {
todo!()
}
fn put_rect(coords_start: Point, coords_end: Point, color: Rgb) {
todo!()
}
fn put_circle(coords: Point, radius: u32) {
todo!()
}
fn put_triangle(coords_1: Point, coords_2: Point, coords_3: Point, thickness: u32, color: Rgb) {
todo!();
}
fn put_pixel(coords: Point, color: Rgb) {
todo!()
}
fn paint_cursor(coords: Point) {
todo!()
}
fn hide_cursor() {}
fn show_cursor() {}
fn draw() {}
fn clear() {
todo!()
}
}

View file

@ -1,35 +0,0 @@
/// # Safety
///
/// We label the mmio function unsafe since
/// we will be working with raw memory. Rust cannot
/// make any guarantees when we do this.
#[inline(always)]
fn mmio_write(address: usize, offset: usize, value: u8) {
// Set the pointer based off of the address
let reg = address as *mut u8;
// write_volatile is a member of the *mut raw
// and we can use the .add() to give us another pointer
// at an offset based on the original pointer's memory
// address. NOTE: The add uses pointer arithmetic so it is
// new_pointer = old_pointer + sizeof(pointer_type) * offset
unsafe {
reg.add(offset).write_volatile(value);
}
}
/// # Safety
///
/// We label the mmio function unsafe since
/// we will be working with raw memory. Rust cannot
/// make any guarantees when we do this.
fn mmio_read(address: usize, offset: usize, value: u8) -> u8 {
// Set the pointer based off of the address
let reg = address as *mut u8;
// read_volatile() is much like write_volatile() except it
// will grab 8-bits from the pointer and give that value to us.
// We don't add a semi-colon at the end here so that the value
// is "returned".
unsafe { reg.add(offset).read_volatile() }
}

View file

@ -1,5 +0,0 @@
pub mod allocator;
pub mod graphics;
pub mod mmio;
pub mod sysinfo;
pub mod uart;

View file

@ -1,23 +0,0 @@
pub fn sysinfo() {}
pub fn master() -> Option<Master> {
Some(Master {
brand_string: Some("riscv".to_string()),
})
}
pub struct Master {
// TODO: Rename struct
// version_information: Option<VersionInformation>,
// thermal_power_management_information: Option<ThermalPowerManagementInformation>,
// structured_extended_information: Option<StructuredExtendedInformation>,
// extended_processor_signature: Option<ExtendedProcessorSignature>,
pub brand_string: Option<String>,
// cache_line: Option<CacheLine>,
// time_stamp_counter: Option<TimeStampCounter>,
// physical_address_size: Option<PhysicalAddressSize>,
}
impl Master {
pub fn brand_string(&self) -> Option<&str> {
self.brand_string.as_deref()
}
}

View file

@ -1,129 +0,0 @@
use core::fmt::{Error, Write};
/// Initialize the UART driver by setting
/// the word length, FIFOs, and interrupts
pub fn uart_init(base_addr: usize) {
let ptr = base_addr as *mut u8;
unsafe {
// First, set the word length, which
// are bits 0, and 1 of the line control register (LCR)
// which is at base_address + 3
// We can easily write the value 3 here or 0b11, but I'm
// extending it so that it is clear we're setting two individual
// fields
// Word 0 Word 1
// ~~~~~~ ~~~~~~
let lcr = (1 << 0) | (1 << 1);
ptr.add(3).write_volatile(lcr);
// Now, enable the FIFO, which is bit index 0 of the FIFO
// control register (FCR at offset 2).
// Again, we can just write 1 here, but when we use left shift,
// it's easier to see that we're trying to write bit index #0.
ptr.add(2).write_volatile(1 << 0);
// Enable receiver buffer interrupts, which is at bit index
// 0 of the interrupt enable register (IER at offset 1).
ptr.add(1).write_volatile(1 << 0);
// If we cared about the divisor, the code below would set the divisor
// from a global clock rate of 22.729 MHz (22,729,000 cycles per second)
// to a signaling rate of 2400 (BAUD). We usually have much faster signalling
// rates nowadays, but this demonstrates what the divisor actually does.
// The formula given in the NS16500A specification for calculating the divisor
// is:
// divisor = ceil( (clock_hz) / (baud_sps x 16) )
// So, we substitute our values and get:
// divisor = ceil( 22_729_000 / (2400 x 16) )
// divisor = ceil( 22_729_000 / 38_400 )
// divisor = ceil( 591.901 ) = 592
// The divisor register is two bytes (16 bits), so we need to split the value
// 592 into two bytes. Typically, we would calculate this based on measuring
// the clock rate, but again, for our purposes [qemu], this doesn't really do
// anything.
let divisor: u16 = 592;
let divisor_least: u8 = (divisor & 0xff).try_into().unwrap();
let divisor_most: u8 = (divisor >> 8).try_into().unwrap();
// Notice that the divisor register DLL (divisor latch least) and DLM (divisor
// latch most) have the same base address as the receiver/transmitter and the
// interrupt enable register. To change what the base address points to, we
// open the "divisor latch" by writing 1 into the Divisor Latch Access Bit
// (DLAB), which is bit index 7 of the Line Control Register (LCR) which
// is at base_address + 3.
ptr.add(3).write_volatile(lcr | 1 << 7);
// Now, base addresses 0 and 1 point to DLL and DLM, respectively.
// Put the lower 8 bits of the divisor into DLL
ptr.add(0).write_volatile(divisor_least);
ptr.add(1).write_volatile(divisor_most);
// Now that we've written the divisor, we never have to touch this again. In
// hardware, this will divide the global clock (22.729 MHz) into one suitable
// for 2,400 signals per second. So, to once again get access to the
// RBR/THR/IER registers, we need to close the DLAB bit by clearing it to 0.
ptr.add(3).write_volatile(lcr);
}
}
fn uart_get(base_addr: usize) -> Option<u8> {
let ptr = base_addr as *mut u8;
unsafe {
// Bit index #5 is the Line Control Register.
if ptr.add(5).read_volatile() & 1 == 0 {
// The DR bit is 0, meaning no data
None
} else {
// The DR bit is 1, meaning data!
Some(ptr.add(0).read_volatile())
}
}
}
fn uart_put(base_addr: usize, c: u8) {
let ptr = base_addr as *mut u8;
unsafe {
// If we get here, the transmitter is empty, so transmit
// our stuff!
ptr.add(0).write_volatile(c);
}
}
pub struct Uart {
base_address: usize,
}
impl Uart {
pub fn new(base_address: usize) -> Self {
Uart { base_address }
}
pub fn get(&self) -> Option<u8> {
uart_get(self.base_address)
}
pub fn put(&self, c: u8) {
uart_put(self.base_address, c);
}
pub fn init(&self) {
uart_init(self.base_address);
}
}
// This is a slightly different syntax. Write is this "trait", meaning it is much like
// an interface where we're just guaranteeing a certain function signature. In the Write
// trait, one is absolutely required to be implemented, which is write_str. There are other
// functions, but they all rely on write_str(), so their default implementation is OK for now.
impl Write for Uart {
// The trait Write expects us to write the function write_str
// which looks like:
fn write_str(&mut self, s: &str) -> Result<(), Error> {
for c in s.bytes() {
self.put(c);
}
// Return that we succeeded.
Ok(())
}
}

View file

@ -1 +0,0 @@
pub fn init() {}

View file

@ -1,99 +0,0 @@
pub mod drivers;
pub mod init;
use crate::print;
use crate::println;
use core::arch::asm;
#[naked]
#[no_mangle]
unsafe extern "C" fn _boot() -> ! {
#[rustfmt::skip]
asm!("
csrw sie, zero
csrci sstatus, 2
.option push
.option norelax
lla gp, __global_pointer$
.option pop
lla sp, __tmp_stack_top
lla t0, __bss_start
lla t1, __bss_end
1:
beq t0, t1, 2f
sd zero, (t0)
addi t0, t0, 8
j 1b
2:
j {}
",
sym _start, options(noreturn));
}
extern "C" fn _start() -> ! {
use crate::serial_println;
let uart = crate::arch::drivers::uart::Uart::new(0x1000_0000);
uart.init();
log!("Hello, world!\r");
loop {
if let Some(c) = uart.get() {
match c {
66 => break,
10 | 13 => {
uart.put('\n' as u8);
uart.put('\r' as u8);
}
/*
91 => {
if let Some(ch) = uart.get() {
match ch as char {
'A' => {
serial_println!("That's the up arrow!");
}
'B' => {
serial_println!("That's the down arrow!");
}
'C' => {
serial_println!("That's the right arrow!");
}
'D' => {
serial_println!("That's the left arrow!");
}
_ => {
serial_println!("That's something else!");
}
}
}
}
*/
_ => {
uart.put(c);
}
}
}
}
serial_println!("Serial connection closed.\r");
sloop()
}
pub fn sloop() -> ! {
loop {
unsafe {
asm!("wfi");
};
}
}
pub fn shutdown() {}
pub fn generate_process_pass() -> u128 {
123
}

View file

@ -1,64 +0,0 @@
OUTPUT_ARCH(riscv64gc)
ENTRY(_boot);
SECTIONS {
. = 0x80200000;
.text : {
PROVIDE(__text_start = .);
PROVIDE(KERNEL_START = .);
*(.init.boot)
*(.init.rust)
*(.text .text.*)
. = ALIGN(4K);
PROVIDE(__text_end = .);
}
.data : {
PROVIDE(__data_start = .);
*(.data .data.* .rodata .rodata.*)
. = ALIGN(8);
PROVIDE(__tmp_stack_bottom = .);
. += 1024 * 1024 * 4;
PROVIDE(__tmp_stack_top = .);
. += 4096;
PROVIDE(__scratch_stack = .);
. = ALIGN(8);
}
. = ALIGN(8);
.sdata : {
PROVIDE(__global_pointer$ = .);
*(.sdata .sdata.*)
. = ALIGN(4K);
PROVIDE(__data_end = .);
}
PROVIDE(__bss_start = .);
.sbss : {
*(.sbss .sbss.*);
}
.bss : {
*(.bss .bss.*)
}
. = ALIGN(4K);
PROVIDE(__bss_end = .);
.tdata : {
. = ALIGN(4K);
PROVIDE(__tdata_start = .);
*(.tdata .tdata.*)
. = ALIGN(4K);
PROVIDE(__tdata_end = .);
}
. = ALIGN(2M);
PROVIDE(KERNEL_END = .);
/DISCARD/ : { *(.eh_frame_hdr .eh_frame) }
}

View file

@ -1,48 +0,0 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
use kernel::allocator::{HEAP_SIZE, HEAP_START};
use x86_64::{
structures::paging::{
mapper::MapToError, FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB,
},
VirtAddr,
};
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")
}
}
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 {
kernel::allocator::ALLOCATOR
.lock()
.init(HEAP_START, HEAP_SIZE);
}
Ok(())
}

View file

@ -1,42 +0,0 @@
use crate::driver_traits::graphics::{Graphics, Point, Rgb};
use cpuio::outw;
pub struct GraphicsBuffer;
#[allow(unused)]
impl Graphics for GraphicsBuffer {
fn put_line(coords_start: Point, coords_end: Point, thickness: u32, color: Rgb) {
todo!()
}
fn put_rect(coords_start: Point, coords_end: Point, color: Rgb) {}
fn put_circle(coords: Point, radius: u32) {
todo!()
}
fn put_triangle(coords_1: Point, coords_2: Point, coords_3: Point, thickness: u32, color: Rgb) {
todo!();
}
fn put_pixel(coords: Point, color: Rgb) {
todo!()
}
fn paint_cursor(coords: Point) {
todo!()
}
fn hide_cursor() {
unsafe {
outw(0x0A, 0x3D4);
outw(0x20, 0x3D5);
}
}
fn show_cursor() {}
fn draw() {}
fn clear() {
todo!()
}
}

View file

@ -1,8 +0,0 @@
pub mod allocator;
// pub mod graphics;
pub mod serial;
pub mod sysinfo;
pub mod timer;
#[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")]
pub mod vga;

View file

@ -1,36 +0,0 @@
use spin::{Lazy, Mutex};
use uart_16550::SerialPort;
pub static SERIAL1: Lazy<Mutex<SerialPort>> = Lazy::new(|| {
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! sprint {
($($arg:tt)*) => {
$crate::arch::drivers::serial::_print(format_args!($($arg)*));
};
}
/// Prints to the host through the serial interface, appending a newline.
#[macro_export]
macro_rules! sprintln {
() => ($crate::sprint!("\n"));
($fmt:expr) => ($crate::sprint!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => ($crate::sprint!(
concat!($fmt, "\n"), $($arg)*));
}

View file

@ -1,2 +0,0 @@
/// This magic value is the herts of the timer interupts normalized
pub const TIMER_INTERRUPT_HERTZ: f64 = 1193182.0;

View file

@ -1,47 +0,0 @@
use spin::Lazy;
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;
struct Selectors {
code_selector: SegmentSelector,
tss_selector: SegmentSelector,
}
static TSS: Lazy<TaskStateSegment> = Lazy::new(|| {
let mut tss = TaskStateSegment::new();
tss.interrupt_stack_table[DOUBLE_FAULT_IST_INDEX as usize] = {
const STACK_SIZE: usize = 4096 * 5;
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
let stack_start = VirtAddr::from_ptr(unsafe { &STACK });
stack_start + STACK_SIZE
};
tss
});
static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| {
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,
},
)
});
pub fn init() {
use x86_64::instructions::segmentation::{Segment, CS};
use x86_64::instructions::tables::load_tss;
GDT.0.load();
unsafe {
CS::set_reg(GDT.1.code_selector);
load_tss(GDT.1.tss_selector);
}
}

View file

@ -1,31 +0,0 @@
// #![allow(clippy::print_literal)]
use super::{gdt, interrupts};
use crate::{logger, serial_println, TERM};
/// x86_64 initialization
pub fn init() {
// use crate::{network::socket::SimpleSock, relib::network::socket::Socket};
// let mut log_socket_id = SimpleSock::new();
// log_socket_id.register_protocol("Logger".to_string());
let result = logger::init();
match result {
Ok(_) => {
info!("Logger initialized");
}
Err(err) => serial_println!("{}", err),
}
let mut term = TERM.lock();
// term.initialize();
term.set_dirty(true);
term.draw_term();
drop(term);
gdt::init();
interrupts::init_idt();
unsafe { interrupts::PICS.lock().initialize() };
x86_64::instructions::interrupts::enable();
}

View file

@ -1,271 +0,0 @@
/*
* Copyright (c) 2022, able <abl3theabove@gmail.com>
*
* SPDX-License-Identifier: MPL-2.0
*/
use core::panic::PanicInfo;
use crate::{arch::gdt, println, rhai_shell::KEYBUFF};
use cpuio::outb;
use pic8259::ChainedPics;
use qrcode::QrCode;
use seq_macro::seq;
use spin::Lazy;
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
use super::sloop;
pub const PIC_1_OFFSET: u8 = 32;
pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
pub static PICS: spin::Mutex<ChainedPics> =
spin::Mutex::new(unsafe { ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET) });
/// Interrupt offsets.
#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum InterruptIndex {
Timer = PIC_1_OFFSET,
Keyboard,
/// Mouse offset
Mouse = 44,
/// Disk offset
Disk = 46,
// SecondInterrupt = PIC_2_OFFSET,
Cmos = 0x70,
}
impl InterruptIndex {
fn as_u8(self) -> u8 {
self as u8
}
fn as_usize(self) -> usize {
usize::from(self.as_u8())
}
}
static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
reset_pit_for_cpu();
let mut idt = InterruptDescriptorTable::new();
seq!(N in 32..=255 {
idt[N].set_handler_fn(undefined_handler_~N);
});
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[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler);
idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_interrupt_handler);
idt[InterruptIndex::Mouse.as_usize()].set_handler_fn(crate::hardware::mouse_interrupt_handler);
// run `a + b + l + e + o + s print;` in ablescript and its 54 thats why this seemingly arbitrary number was chosen
idt[54].set_handler_fn(software_int_handler);
idt
});
seq!(N in 32..=255 {
extern "x86-interrupt" fn undefined_handler_~N(stack_frame: InterruptStackFrame) {
error!("INT {}: {:?}", N, stack_frame);
unsafe {
PICS.lock()
.notify_end_of_interrupt(N);
}
}
});
extern "x86-interrupt" fn software_int_handler(stack_frame: InterruptStackFrame) {
trace!("EXCEPTION: SOFTWARE INT\n{:#?}", stack_frame);
unsafe {
PICS.lock().notify_end_of_interrupt(54);
}
}
extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
trace!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
}
extern "x86-interrupt" fn double_fault_handler(
stack_frame: InterruptStackFrame,
// NOTE(able): ignore this always is 0
_error_code: u64,
) -> ! {
bsod(BSODSource::DoubleFault(&stack_frame));
// panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
}
/* SAFETY
* DO NOT TOUCH
* The `#[naked]` macro removes various error/bounds checks that
* the Rust compiler would normally add.
* *Early return* and *enabling interrupts* in this function are
* undefined behavior.
* As long as nothing in this function does something that would
* normally trigger an error, this function is relatively safe.
*/
extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFrame) {
crate::kmain::tick();
unsafe {
PICS.lock()
.notify_end_of_interrupt(InterruptIndex::Timer.as_u8());
}
}
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
use pc_keyboard::{
layouts::Us104Key, DecodedKey, HandleControl, KeyCode, Keyboard, ScancodeSet1,
};
use spin::Mutex;
use x86_64::instructions::port::Port;
static KEYBOARD: Lazy<Mutex<Keyboard<Us104Key, ScancodeSet1>>> =
Lazy::new(|| Mutex::new(Keyboard::new(Us104Key, ScancodeSet1, HandleControl::Ignore)));
let mut keyboard = KEYBOARD.lock();
if let Ok(Some(key)) = keyboard
.add_byte(unsafe { Port::new(0x60).read() })
.map(|x| x.and_then(|ev| keyboard.process_keyevent(ev)))
{
// trace!("{key:?}");
match key {
DecodedKey::Unicode(chr) => match chr {
'\n' => {
KEYBUFF.lock().push('\n');
}
// Backspace
'\u{8}' => {
// TODO: Fix this and apply to new term
KEYBUFF.lock().push(8.into());
// trace!("8");
// print!("\u{8}");
}
// '^' => KERNEL_STATE.lock().shutdown(),
chr => {
KEYBUFF.lock().push(chr);
// trace!("{chr}");
// print!("{chr}");
}
},
DecodedKey::RawKey(key) => {
use KeyCode::*;
match KeyCode::from(key) {
AltLeft | AltRight => (),
ArrowDown | ArrowRight | ArrowLeft | ArrowUp => {
// warn!("ArrowKeys are unsupported currently");
}
_kc => {
// trace!("Unprintable key: {kc:?}"),
}
};
}
}
}
unsafe {
PICS.lock()
.notify_end_of_interrupt(InterruptIndex::Keyboard.as_u8());
}
}
pub fn init_idt() {
IDT.load();
}
/// https://wiki.osdev.org/Pit
///
const PIT_MAX_FREQ: u32 = 1193182;
pub fn set_pit_frequency(pit: u16, freq: u32) {
// Dividing the maximum frequency by the desired frequency
// gives roughly what the maximum value for the timer
// counter should be to run at the desired frequency.
let ret = (PIT_MAX_FREQ / freq).try_into();
// Type-bounded counter maximum.
let divisor: u16 = match ret {
Ok(div) => div,
Err(err) => {
error!("{}", err);
warn!("Defaulting to 1000 on PIT{}", pit);
1000
}
};
unsafe {
outb(0x36, 0x43);
outb((divisor & 0xFF) as u8, 0x39 + pit);
outb((divisor >> 8) as u8, 0x40 + pit);
}
}
pub fn set_pit_1(freq: u32) {
set_pit_frequency(1, freq);
}
pub fn set_pit_2(freq: u32) {
set_pit_frequency(2, freq);
}
pub fn set_pit_3(freq: u32) {
set_pit_frequency(3, freq);
}
pub fn reset_pit_for_cpu() {
set_pit_1(1000);
set_pit_2(1000);
set_pit_3(1000);
}
pub fn bsod(src: BSODSource) -> ! {
let src1 = match src {
BSODSource::DoubleFault(_) => "DoubleFault".to_string(),
BSODSource::Panic(panic_info) => {
let strr = format!("PANIC: {}", panic_info);
strr
}
};
let st = format!(
"We fucked up ඞ : \n{}\nThe following qr code will link you to the wiki which hopefully solves your problems",
src1
);
println!("\n{}", st);
// let sf = format!("https://git.ablecorp.us/able/ableos/wiki/Double-Faults");
let sd = match src {
BSODSource::DoubleFault(_) => "https://git.ablecorp.us/able/ableos/wiki/Double-Faults",
BSODSource::Panic(_) => {
trace!("panic");
"https://git.ablecorp.us/able/ableos/wiki/Panic"
}
};
let code = QrCode::new(sd).unwrap();
let image = code
.render::<char>()
.quiet_zone(false)
.module_dimensions(2, 1)
.build();
println!("{}", image);
sloop();
}
#[derive(Debug)]
pub enum BSODSource<'a> {
DoubleFault(&'a InterruptStackFrame),
Panic(&'a PanicInfo<'a>),
}

View file

@ -1,118 +0,0 @@
use bootloader::bootinfo::{MemoryMap, MemoryRegionType};
use x86_64::{
structures::paging::{
FrameAllocator, FrameDeallocator, Mapper, OffsetPageTable, Page, PageTable, PhysFrame,
Size4KiB,
},
PhysAddr, VirtAddr,
};
pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> {
let level_4_table = active_level_4_table(physical_memory_offset);
OffsetPageTable::new(level_4_table, physical_memory_offset)
}
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();
// THIS IS UNSAFE
&mut *page_table_ptr
}
fn translate_addr_inner(addr: VirtAddr, physical_memory_offset: VirtAddr) -> Option<PhysAddr> {
use x86_64::registers::control::Cr3;
use x86_64::structures::paging::page_table::FrameError;
let (level_4_table_frame, _) = Cr3::read();
let table_indexes = [
addr.p4_index(),
addr.p3_index(),
addr.p2_index(),
addr.p1_index(),
];
let mut frame = level_4_table_frame;
for &index in &table_indexes {
// convert the frame into a page table reference
let virt = physical_memory_offset + frame.start_address().as_u64();
let table_ptr: *const PageTable = virt.as_ptr();
let table = unsafe { &*table_ptr };
let entry = &table[index];
frame = match entry.frame() {
Ok(frame) => frame,
Err(FrameError::FrameNotPresent) => return None,
Err(FrameError::HugeFrame) => panic!["huge pages not supported"],
};
}
Some(frame.start_address() + u64::from(addr.page_offset()))
}
pub unsafe fn translate_addr(addr: VirtAddr, physical_memory_offset: VirtAddr) -> Option<PhysAddr> {
translate_addr_inner(addr, physical_memory_offset)
}
pub fn create_example_mapping(
page: Page,
mapper: &mut OffsetPageTable,
frame_allocator: &mut impl FrameAllocator<Size4KiB>,
) {
use x86_64::structures::paging::PageTableFlags as Flags;
let frame = PhysFrame::containing_address(PhysAddr::new(0xb8000));
let flags = Flags::PRESENT | Flags::WRITABLE;
let map_to_result = unsafe { mapper.map_to(page, frame, flags, frame_allocator) };
map_to_result.expect("map_to failed").flush();
}
pub struct EmptyFrameAllocator;
unsafe impl FrameAllocator<Size4KiB> for EmptyFrameAllocator {
fn allocate_frame(&mut self) -> Option<PhysFrame<Size4KiB>> {
None
}
}
pub struct BootInfoFrameAllocator {
memory_map: &'static MemoryMap,
next: usize,
}
impl BootInfoFrameAllocator {
pub unsafe fn init(memory_map: &'static MemoryMap) -> Self {
Self {
memory_map,
next: 0,
}
}
fn usable_frames(&self) -> impl Iterator<Item = PhysFrame> {
let regions = self.memory_map.iter();
let usable_regions = regions.filter(|r| r.region_type == MemoryRegionType::Usable);
let addr_range = usable_regions.map(|r| r.range.start_addr()..r.range.end_addr());
let frame_address = addr_range.flat_map(|r| r.step_by(4096));
frame_address.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)))
}
}
unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {
fn allocate_frame(&mut self) -> Option<PhysFrame<Size4KiB>> {
let frame = self.usable_frames().nth(self.next);
self.next += 1;
frame
}
}
impl FrameDeallocator<Size4KiB> for BootInfoFrameAllocator {
unsafe fn deallocate_frame(&mut self, _frame: PhysFrame<Size4KiB>) {
// TODO
}
}

View file

@ -1,63 +0,0 @@
/*
* Copyright (c) 2022, able <abl3theabove@gmail.com>
*
* SPDX-License-Identifier: MPL-2.0
*/
pub mod drivers;
pub mod gdt;
pub mod init;
pub mod interrupts;
pub mod memory;
use crate::arch::drivers::allocator;
use bootloader::{entry_point, BootInfo};
use x86_64::{instructions::hlt, VirtAddr};
#[cfg(not(test))]
entry_point![start];
#[cfg(not(test))]
#[no_mangle]
pub fn start(boot_info: &'static BootInfo) -> ! {
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 { memory::BootInfoFrameAllocator::init(&boot_info.memory_map) };
// let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000));
// memory::create_example_mapping(page, &mut mapper, &mut frame_allocator);
//
// let page_ptr: *mut u64 = page.start_address().as_mut_ptr();
// unsafe { page_ptr.offset(400).write_volatile(0xf021_f077_f065_804e) };
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
crate::kmain::kernel_main(mapper, frame_allocator);
}
#[allow(unused)]
pub fn shutdown() -> ! {
info!("Shutting down");
unsafe {
cpuio::outw(0x2000, 0x604);
}
sloop();
}
pub fn sloop() -> ! {
loop {
hlt();
}
}
// TODO: Split up into the randomness and the password generation
pub fn generate_process_pass() -> u128 {
// TODO: Move this into entropy_pool module
use rdrand::RdRand;
let gen = RdRand::new().unwrap();
(gen.try_next_u64().unwrap() as u128) << 64 | (gen.try_next_u64().unwrap() as u128)
}

View file

@ -1,70 +0,0 @@
use log::LevelFilter;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Debug, Deserialize)]
pub enum LogLevel {
/// A level lower than all log levels.
Off,
/// Corresponds to the `Error` log level.
Error,
/// Corresponds to the `Warn` log level.
Warn,
/// Corresponds to the `Info` log level.
Info,
/// Corresponds to the `Debug` log level.
Debug,
/// Corresponds to the `Trace` log level.
Trace,
}
#[derive(Serialize, Debug, Deserialize)]
pub struct KernelConfig {
pub boot: BootConfig,
pub logging: LoggingConfig,
pub tests: TestsConfig,
}
impl KernelConfig {
pub fn new() -> Self {
toml::from_str(include_str!("../assets/kernel.toml")).unwrap()
}
pub fn log_level(&self) -> LevelFilter {
use LevelFilter::*;
match self.logging.level {
LogLevel::Off => Off,
LogLevel::Error => Error,
LogLevel::Warn => Warn,
LogLevel::Info => Info,
LogLevel::Debug => Debug,
LogLevel::Trace => Trace,
}
}
}
impl Default for KernelConfig {
fn default() -> Self {
Self::new()
}
}
#[derive(Serialize, Debug, Deserialize)]
pub struct LoggingConfig {
pub enabled: bool,
pub log_to_serial: bool,
pub log_to_vterm: bool,
pub level: LogLevel,
pub filter: Vec<String>,
}
#[derive(Serialize, Debug, Deserialize)]
pub struct TestsConfig {
pub run_tests: bool,
pub run_demos: bool,
pub run_shader_tests: bool,
}
#[derive(Serialize, Debug, Deserialize)]
pub struct BootConfig {
pub system_processes: Vec<String>,
pub user_processes: Vec<String>,
}

View file

@ -1,29 +0,0 @@
use kernel::device_interface::CharacterDevice;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DevNull;
impl CharacterDevice for DevNull {
fn can_read(&self) -> bool {
true
}
fn can_write(&self) -> bool {
true
}
fn read_char(&mut self) -> Option<char> {
Some(0x00 as char)
}
fn write_char(&mut self, _: char) -> bool {
true
}
fn reset(&mut self) {
todo!()
}
fn initialize(&mut self) -> bool {
todo!()
}
}

View file

@ -1,49 +0,0 @@
use kernel::device_interface::CharacterDevice;
#[derive(Debug)]
pub struct DevUnicode {
pub next_write_char: char,
pub next_read_char: char,
}
impl CharacterDevice for DevUnicode {
fn can_read(&self) -> bool {
true
}
fn can_write(&self) -> bool {
true
}
fn read_char(&mut self) -> Option<char> {
let c = self.next_read_char;
self.next_read_char = add1_char(c);
Some(c)
}
fn write_char(&mut self, c: char) -> bool {
if self.next_write_char != c {
return false;
}
true
}
fn reset(&mut self) {
self.next_write_char = 0x00 as char;
self.next_read_char = 0x00 as char;
}
fn initialize(&mut self) -> bool {
true
}
}
fn add1_char(c: char) -> char {
if c == char::MAX {
return 0x00 as char;
}
char::from_u32(c as u32 + 1).unwrap()
}

View file

@ -1,27 +0,0 @@
use kernel::device_interface::CharacterDevice;
#[derive(Debug)]
pub struct DevZero;
impl CharacterDevice for DevZero {
fn can_read(&self) -> bool {
true
}
fn can_write(&self) -> bool {
true
}
fn read_char(&mut self) -> Option<char> {
Some(0 as char)
}
fn write_char(&mut self, _: char) -> bool {
true
}
fn reset(&mut self) {}
fn initialize(&mut self) -> bool {
true
}
}

View file

@ -1,5 +0,0 @@
pub mod dev_null;
pub mod dev_unicode;
pub mod dev_zero;
pub use kernel::device_interface::CharacterDevice;

View file

@ -1,265 +0,0 @@
// ! A virtual terminal device.
use core::ops::Not;
use core::sync::atomic::AtomicU32;
use core::sync::atomic::Ordering;
use kernel::device_interface::CharacterDevice;
use crate::pixel_format::Rgba64;
pub const VTERM_HEIGHT: u32 = 40;
pub const VTERM_WIDTH: u32 = 100;
pub static VIRTUAL_TERMINAL_COUNT: AtomicU32 = AtomicU32::new(0);
/// Fg and bg colors for vterm
pub type ColorCharacter = (Rgba64, Rgba64);
/// A vterm representation of a character
#[derive(Debug, Clone, Copy)]
pub struct VtermCharacter {
pub character: char,
//
pub style: Style,
//
pub char_color: ColorCharacter,
}
#[derive(Default, Debug, Clone, Copy)]
pub struct Style(pub u8);
impl Style {
pub fn bold(&self) -> bool {
(self.0 & 0x01) > 0
}
pub fn underlined(&self) -> bool {
(self.0 & 0x02) > 0
}
pub fn italic(&self) -> bool {
(self.0 & 0x04) > 0
}
pub fn blinking(&self) -> bool {
(self.0 & 0x08) > 0
}
pub fn reversed(&self) -> bool {
(self.0 & 0x10) > 0
}
pub fn struck(&self) -> bool {
(self.0 & 0x20) > 0
}
#[must_use]
pub fn set_bold(mut self, v: bool) -> Self {
if v {
self.0 |= 0x01;
} else {
self.0 &= 0x01u8.not();
}
self
}
#[must_use]
pub fn set_underlined(mut self, v: bool) -> Self {
if v {
self.0 |= 0x02;
} else {
self.0 &= 0x02u8.not();
}
self
}
#[must_use]
pub fn set_italic(mut self, v: bool) -> Self {
if v {
self.0 |= 0x04;
} else {
self.0 &= 0x04u8.not();
}
self
}
#[must_use]
pub fn set_blinking(mut self, v: bool) -> Self {
if v {
self.0 |= 0x08;
} else {
self.0 &= 0x08u8.not();
}
self
}
#[must_use]
pub fn set_reversed(mut self, v: bool) -> Self {
if v {
self.0 |= 0x10;
} else {
self.0 &= 0x10u8.not();
}
self
}
#[must_use]
pub fn set_struck(mut self, v: bool) -> Self {
if v {
self.0 |= 0x20;
} else {
self.0 &= 0x20u8.not();
}
self
}
}
#[derive(Debug)]
pub struct VTerm {
pub characters: [[VtermCharacter; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
pub cursor_visible: bool,
/// Internal ID of the vterm
iid: u32,
/// The internal representation of the vterm
style: Style,
/// The cursor position in layout x,y
cursor_position: (u32, u32),
key_buff: Vec<char>,
}
impl Default for VTerm {
fn default() -> Self {
VTerm {
iid: 0,
characters: [[VtermCharacter {
character: 0x00 as char,
char_color: (0xff_ff_ff_ff, 0x00_00_00_00),
style: Style::default(),
}; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
cursor_position: (0, 0),
cursor_visible: true,
style: Style::default(),
key_buff: vec![],
}
}
}
/// The primitive interface for a vterm
impl VTerm {
pub fn new() -> Self {
let mut vterm = VTerm::default();
let mut vtc = VIRTUAL_TERMINAL_COUNT.load(Ordering::Relaxed);
vterm.iid = vtc;
vtc += 1;
VIRTUAL_TERMINAL_COUNT.store(vtc, Ordering::Relaxed);
vterm
}
/// Set the vterm cursor to the given position
pub fn set_cursor_position(&mut self, x: u32, y: u32) {
if x > VTERM_WIDTH {
self.cursor_position.0 = VTERM_WIDTH;
error!("Cursor x position out of bounds");
} else {
self.cursor_position.0 = x;
}
if y > VTERM_HEIGHT {
error!("Cursor y position out of bounds");
self.cursor_position.1 = VTERM_HEIGHT;
} else {
self.cursor_position.1 = y;
}
}
/// Set the vterm style
pub fn set_vterm_style(&mut self, style: Style) {
self.style = style;
}
}
impl CharacterDevice for VTerm {
fn can_read(&self) -> bool {
true
}
fn can_write(&self) -> bool {
true
}
fn read_char(&mut self) -> Option<char> {
if let Some(c) = self.key_buff.pop() {
return Some(c);
}
None
}
fn write_char(&mut self, c: char) -> bool {
match c {
'\n' => {
self.cursor_position.1 += 1;
self.cursor_position.0 = 0;
true
}
'\r' => {
self.cursor_position.0 = 0;
true
}
'\t' => {
self.cursor_position.0 += 4;
true
}
'\x08' => {
self.cursor_position.0 -= 1;
self.characters[self.cursor_position.1 as usize][self.cursor_position.0 as usize]
.character = ' ';
true
}
// This is a form feed, which is used to clear the screen
'\x0c' => {
self.characters = [[VtermCharacter {
character: ' ',
char_color: (0xff_ff_ff_ff, 0x00_00_00_00),
style: Style::default(),
}; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize];
true
}
_ => {
self.characters[self.cursor_position.1 as usize][self.cursor_position.0 as usize]
.character = c;
self.characters[self.cursor_position.1 as usize][self.cursor_position.0 as usize]
.char_color = (0xff_ff_ff_ff, 0x00_00_00_00);
self.characters[self.cursor_position.1 as usize][self.cursor_position.0 as usize]
.style = self.style;
if self.cursor_position.0 < VTERM_WIDTH {
self.cursor_position.0 += 1;
true
} else {
self.cursor_position.0 = 0;
self.cursor_position.1 += 1;
true
}
}
}
}
fn reset(&mut self) {
self.characters = [[VtermCharacter {
character: ' ',
char_color: (0xff_ff_ff_ff, 0x00_00_00_00),
style: Style::default(),
}; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize];
self.cursor_position = (0, 0);
self.cursor_visible = true;
self.style = Style::default();
}
fn initialize(&mut self) -> bool {
true
}
}

View file

@ -1,14 +0,0 @@
#[derive(Debug)]
pub enum Vendor {
Unknown = 0,
Ati = 1002,
}
pub fn match_vendor(id: u16) -> Vendor {
use Vendor::*;
match id {
1002 => Ati,
_ => Unknown,
}
}

View file

@ -1,59 +0,0 @@
pub mod character_devs;
mod dev_vterm;
pub mod id;
pub mod pci;
pub use self::Device::*;
use crate::devices::dev_vterm::VTerm;
use character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero};
use hashbrown::HashMap;
use kernel::device_interface::{BlockDevice, CharacterDevice};
use spin::Lazy;
pub static DEVICE_TABLE: Lazy<spin::Mutex<DeviceTable>> =
Lazy::new(|| spin::Mutex::new(DeviceTable::new()));
// FIXME: This is a hack to hold a device.
// #[derive(Debug)]
pub enum Device {
Block(Box<dyn BlockDevice>),
Character(Box<dyn CharacterDevice>),
Vterm(Box<VTerm>),
}
unsafe impl Sync for Device {}
unsafe impl Send for Device {}
pub struct DeviceTable {
pub devices: HashMap<String, Device>,
}
impl DeviceTable {
pub fn new() -> Self {
DeviceTable {
devices: [
("null", Character(Box::new(DevNull))),
("zero", Character(Box::new(DevZero))),
(
"unicode",
Character(Box::new(DevUnicode {
next_write_char: 0x00 as char,
next_read_char: 0x00 as char,
})),
),
("kvterm", Vterm(Box::new(VTerm::new()))),
]
.into_iter()
.map(|(k, v)| (k.to_string(), v))
.collect(),
}
}
}
impl Default for DeviceTable {
fn default() -> Self {
Self::new()
}
}

View file

@ -1,240 +0,0 @@
/*
* Copyright (c) 2022, able <abl3theabove@gmail.com>
* Copyright (c) 2022, Umut İnan Erdoğan <umutinanerdogan@pm.me>
*
* SPDX-License-Identifier: MPL-2.0
*/
use core::fmt::Display;
#[allow(non_camel_case_types, dead_code)]
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C)]
/// Class specification for a PCI device
pub enum PciClass {
Unclassified = 0x00,
MassStorage = 0x01,
Network = 0x02,
Display = 0x03,
Multimedia = 0x04,
Memory = 0x05,
Bridge = 0x06,
Unknown = 0xFF,
}
impl From<u8> for PciClass {
/// Convert a u8 into the corresponding PciClass
fn from(n: u8) -> Self {
use PciClass::*;
match n {
0x00 => Unclassified,
0x01 => MassStorage,
0x02 => Network,
0x03 => Display,
0x04 => Multimedia,
0x05 => Memory,
0x06 => Bridge,
_ => Unknown,
}
}
}
#[allow(non_camel_case_types, dead_code)]
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C)]
/// Full class specification (type and subtype) for a PCI device.
///
/// Uses non-camel-case types for readability.
pub enum PciFullClass {
Unclassified_NonVgaCompatible = 0x0000,
Unclassified_VgaCompatible = 0x0001,
MassStorage_ScsiBus = 0x0100,
MassStorage_IDE = 0x0101,
MassStorage_Floppy = 0x0102,
MassStorage_IpiBus = 0x0103,
MassStorage_RAID = 0x0104,
MassStorage_ATA = 0x0105,
MassStorage_SATA = 0x0106,
MassStorage_SerialSCSI = 0x0107,
MassStorage_NVM = 0x0108,
MassStorage_Other = 0x0180,
Network_Ethernet = 0x0200,
Network_TokenRing = 0x0201,
Network_FDDI = 0x0202,
Network_ATM = 0x0203,
Network_ISDN = 0x0204,
Network_WorldFlip = 0x0205,
Network_PICMG = 0x0206,
Network_Infiniband = 0x0207,
Network_Fabric = 0x0208,
Network_Other = 0x0280,
Display_VGA = 0x0300,
Display_XGA = 0x0301,
Display_3D = 0x0302,
Display_Other = 0x0380,
Multimedia_Video = 0x0400,
Multimedia_AudioController = 0x0401,
Multimedia_Telephony = 0x0402,
Multimedia_AudioDevice = 0x0403,
Multimedia_Other = 0x0480,
Memory_RAM = 0x0500,
Memory_Flash = 0x0501,
Memory_Other = 0x0580,
Bridge_Host = 0x0600,
Bridge_ISA = 0x0601,
Bridge_EISA = 0x0602,
Bridge_MCA = 0x0603,
Bridge_PciToPci = 0x0604,
Bridge_PCMCIA = 0x0605,
Bridge_NuBus = 0x0606,
Bridge_CardBus = 0x0607,
Bridge_RACEway = 0x0608,
Bridge_PciToPciSemiTransparent = 0x0609,
Bridge_InfinibandToPci = 0x060A,
Bridge_Other = 0x0680,
Unknown = 0xFFFF,
}
impl PciFullClass {
// listen, i know this sucks, but i didn't want to include
// `num`, `num-traits` and `num-derive` as dependencies for
// this crate just for a convenience function
/// Convert a u16 into the corresponding PciFullClass
pub fn from_u16(n: u16) -> PciFullClass {
match n {
0x0000 => PciFullClass::Unclassified_NonVgaCompatible,
0x0001 => PciFullClass::Unclassified_VgaCompatible,
0x0100 => PciFullClass::MassStorage_ScsiBus,
0x0101 => PciFullClass::MassStorage_IDE,
0x0102 => PciFullClass::MassStorage_Floppy,
0x0103 => PciFullClass::MassStorage_IpiBus,
0x0104 => PciFullClass::MassStorage_RAID,
0x0105 => PciFullClass::MassStorage_ATA,
0x0106 => PciFullClass::MassStorage_SATA,
0x0107 => PciFullClass::MassStorage_SerialSCSI,
0x0108 => PciFullClass::MassStorage_NVM,
0x0180 => PciFullClass::MassStorage_Other,
0x0200 => PciFullClass::Network_Ethernet,
0x0201 => PciFullClass::Network_TokenRing,
0x0202 => PciFullClass::Network_FDDI,
0x0203 => PciFullClass::Network_ATM,
0x0204 => PciFullClass::Network_ISDN,
0x0205 => PciFullClass::Network_WorldFlip,
0x0206 => PciFullClass::Network_PICMG,
0x0207 => PciFullClass::Network_Infiniband,
0x0208 => PciFullClass::Network_Fabric,
0x0280 => PciFullClass::Network_Other,
0x0300 => PciFullClass::Display_VGA,
0x0301 => PciFullClass::Display_XGA,
0x0302 => PciFullClass::Display_3D,
0x0380 => PciFullClass::Display_Other,
0x0400 => PciFullClass::Multimedia_Video,
0x0401 => PciFullClass::Multimedia_AudioController,
0x0402 => PciFullClass::Multimedia_Telephony,
0x0403 => PciFullClass::Multimedia_AudioDevice,
0x0480 => PciFullClass::Multimedia_Other,
0x0500 => PciFullClass::Memory_RAM,
0x0501 => PciFullClass::Memory_Flash,
0x0580 => PciFullClass::Memory_Other,
0x0600 => PciFullClass::Bridge_Host,
0x0601 => PciFullClass::Bridge_ISA,
0x0602 => PciFullClass::Bridge_EISA,
0x0603 => PciFullClass::Bridge_MCA,
0x0604 => PciFullClass::Bridge_PciToPci,
0x0605 => PciFullClass::Bridge_PCMCIA,
0x0606 => PciFullClass::Bridge_NuBus,
0x0607 => PciFullClass::Bridge_CardBus,
0x0608 => PciFullClass::Bridge_RACEway,
0x0609 => PciFullClass::Bridge_PciToPciSemiTransparent,
0x060A => PciFullClass::Bridge_InfinibandToPci,
0x0680 => PciFullClass::Bridge_Other,
_ => PciFullClass::Unknown,
}
}
/// Convert a PciFullClass to its u16 representation
pub fn as_u16(&self) -> u16 {
*self as u16
}
}
impl From<u16> for PciFullClass {
/// Convert a u16 into the corresponding PciFullClass
fn from(n: u16) -> Self {
Self::from_u16(n)
}
}
impl Display for PciFullClass {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, " Class: ")?;
match self {
PciFullClass::Unclassified_NonVgaCompatible => write!(f, "\0LIGHTBLUE\0")?,
PciFullClass::Unclassified_VgaCompatible => write!(f, "\0LIGHTBLUE\0")?,
PciFullClass::MassStorage_ScsiBus => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_IDE => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_Floppy => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_IpiBus => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_RAID => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_ATA => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_SATA => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_SerialSCSI => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_NVM => write!(f, "\0CYAN\0")?,
PciFullClass::MassStorage_Other => write!(f, "\0CYAN\0")?,
PciFullClass::Network_Ethernet => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_TokenRing => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_FDDI => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_ATM => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_ISDN => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_WorldFlip => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_PICMG => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_Infiniband => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_Fabric => write!(f, "\0MAGENTA\0")?,
PciFullClass::Network_Other => write!(f, "\0MAGENTA\0")?,
PciFullClass::Display_VGA => write!(f, "\0YELLOW\0")?,
PciFullClass::Display_XGA => write!(f, "\0YELLOW\0")?,
PciFullClass::Display_3D => write!(f, "\0YELLOW\0")?,
PciFullClass::Display_Other => write!(f, "\0YELLOW\0")?,
PciFullClass::Multimedia_Video => write!(f, "\0LIGHTBLUE\0")?,
PciFullClass::Multimedia_AudioController => write!(f, "\0LIGHTBLUE\0")?,
PciFullClass::Multimedia_Telephony => write!(f, "\0LIGHTBLUE\0")?,
PciFullClass::Multimedia_AudioDevice => write!(f, "\0LIGHTBLUE\0")?,
PciFullClass::Multimedia_Other => write!(f, "\0LIGHTBLUE\0")?,
PciFullClass::Memory_RAM => write!(f, "\0BLUE\0")?,
PciFullClass::Memory_Flash => write!(f, "\0WHITE\0")?,
PciFullClass::Memory_Other => write!(f, "\0LIGHTGREY\0")?,
PciFullClass::Bridge_Host => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_ISA => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_EISA => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_MCA => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_PciToPci => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_PCMCIA => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_NuBus => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_CardBus => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_RACEway => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_PciToPciSemiTransparent => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_InfinibandToPci => write!(f, "\0GREEN\0")?,
PciFullClass::Bridge_Other => write!(f, "\0GREEN\0")?,
PciFullClass::Unknown => write!(f, "\0RED\0")?,
}
write!(f, "{:?} ({:#06X})\0RESET\0", self, self.as_u16())?;
Ok(())
}
}

View file

@ -1,194 +0,0 @@
/*
* Copyright (c) 2022, able <abl3theabove@gmail.com>
* Copyright (c) 2022, Umut İnan Erdoğan <umutinanerdogan@pm.me>
*
* SPDX-License-Identifier: MPL-2.0
*/
use core::fmt;
use x86_64::instructions::port::Port;
use super::{
vendors::Vendor::{self, *},
PciClass, PciFullClass,
};
// FIXME: Unknown class
pub const S3_TRIO64V2: DeviceID = DeviceID::new(S3Inc, 0x8900);
// MassStorage_IDE (0x0101)
pub const INTEL_PIIX3_IDE: DeviceID = DeviceID::new(IntelCorp, 0x7010);
pub const INTEL_PIIX4_IDE: DeviceID = DeviceID::new(IntelCorp, 0x7111);
// Display_VGA (0x0300)
pub const VMWARE_SVGA2: DeviceID = DeviceID::new(VMWareInc, 0x0405);
#[derive(Copy, Clone, Debug)]
/// A struct containing info about a PCI device.
pub struct PciDeviceInfo {
pub header_type: u8,
pub device: u8,
pub bus: u8,
pub device_id: DeviceID,
pub full_class: PciFullClass,
pub rev_id: u8,
}
impl PciDeviceInfo {
/// Get the class of the PCI device as a PciClass
pub fn class(&self) -> PciClass {
(((self.full_class.as_u16() >> 8) & 0xFF) as u8).into()
}
/// Get the bar, 0-indexed
pub fn bar(&self, bar: u8) -> u32 {
assert!(bar < 6);
unsafe { self.read(0, 0x10 + bar * 4) }
}
/// Get the interrupt pin
pub fn interrupt_pin(&self) -> u8 {
let last_row = unsafe { self.read(0, 0x3C) };
((last_row >> 8) & 0xFF) as u8
}
/// Enable bus mastering. This allows the PCI device to do DMA
pub fn enable_bus_mastering(&self) {
let command = unsafe { self.read(0, 4) } | 1 << 2;
unsafe { self.write(0, 4, command) }
}
/// Read from configuration space
pub unsafe fn read(&self, func: u8, offset: u8) -> u32 {
pci_config_read(self.bus, self.device, func, offset)
}
/// Write to IO space
pub unsafe fn write(&self, func: u8, offset: u8, value: u32) {
pci_config_write(self.bus, self.device, func, offset, value)
}
}
impl fmt::Display for PciDeviceInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
let vendor_name = &self.device_id.vendor;
let device_id = &self.device_id.id;
writeln!(
f,
"Device: {} | Bus: 0x{:X} | Vendor: {} | Device ID: 0x{:X}",
self.device, self.bus, vendor_name, device_id,
)?;
writeln!(f, "{}", self.full_class)?;
writeln!(f, " Header type: 0x{:X}", self.header_type)?;
writeln!(f, " Revision ID: {}", self.rev_id)?;
// write!(f, " Supported functions: 0")?;
// for (i, b) in self.supported_fns.iter().enumerate().skip(1) {
// if *b {
// write!(f, ", {}", i)?;
// }
// }
// writeln!(f)?;
// write!(f, " BARs: [ ")?;
// for i in self.bars.iter() {
// if *i == 0 {
// write!(f, "0x0 ")?;
// } else {
// write!(f, "{:#010X} ", i)?;
// }
// }
// writeln!(f, "]")?;
// writeln!(
// f,
// " Interrupt line / pin: {} / {}",
// self.interrupt_line, self.interrupt_pin
// )?;
Ok(())
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct DeviceID {
pub vendor: Vendor,
pub id: u16,
}
impl DeviceID {
pub const fn new(vendor: Vendor, id: u16) -> Self {
Self { vendor, id }
}
}
pub fn check_device(bus: u8, device: u8) -> Option<PciDeviceInfo> {
assert!(device < 32);
let (device_id, vendor_id) = get_ids(bus, device, 0);
if vendor_id == 0xFFFF {
// Device doesn't exist
return None;
}
let reg2 = unsafe { pci_config_read(bus, device, 0, 0x8) };
let class = ((reg2 >> 16) & 0x0000FFFF) as u16;
let pci_class = PciFullClass::from_u16(class);
let header_type = get_header_type(bus, device, 0);
Some(PciDeviceInfo {
header_type,
device,
bus,
device_id: DeviceID {
vendor: vendor_id.into(),
id: device_id,
},
full_class: pci_class,
rev_id: (reg2 & 0x000000FF) as u8,
})
}
unsafe fn pci_config_read(bus: u8, device: u8, func: u8, offset: u8) -> u32 {
let bus = bus as u32;
let device = device as u32;
let func = func as u32;
let offset = offset as u32;
// construct address param
let address =
((bus << 16) | (device << 11) | (func << 8) | (offset & 0xfc) | 0x80000000) as u32;
// write address
Port::new(0xCF8).write(address);
// read data
Port::new(0xCFC).read()
}
unsafe fn pci_config_write(bus: u8, device: u8, func: u8, offset: u8, value: u32) {
let bus = bus as u32;
let device = device as u32;
let func = func as u32;
let offset = offset as u32;
// construct address param
let address =
((bus << 16) | (device << 11) | (func << 8) | (offset & 0xfc) | 0x80000000) as u32;
// write address
Port::new(0xCF8).write(address);
// write data
Port::new(0xCFC).write(value);
}
fn get_header_type(bus: u8, device: u8, function: u8) -> u8 {
assert!(device < 32);
assert!(function < 8);
let res = unsafe { pci_config_read(bus, device, function, 0x0C) };
((res >> 16) & 0xFF) as u8
}
fn get_ids(bus: u8, device: u8, function: u8) -> (u16, u16) {
assert!(device < 32);
assert!(function < 8);
let res = unsafe { pci_config_read(bus, device, function, 0) };
let dev_id = ((res >> 16) & 0xFFFF) as u16;
let vnd_id = (res & 0xFFFF) as u16;
(dev_id, vnd_id)
}

View file

@ -1,674 +0,0 @@
/*
* Copyright (c) 2022, Umut İnan Erdoğan <umutinanerdogan@pm.me>
*
* SPDX-License-Identifier: MPL-2.0
*/
use core::num::TryFromIntError;
// FIXME: platform agnostic-ify these
use x86_64::instructions::{interrupts, port::Port};
use x86_64::structures::paging::{mapper::MapToError, Mapper, Page, PhysFrame, Size4KiB};
use x86_64::structures::paging::{FrameAllocator, FrameDeallocator};
use x86_64::VirtAddr;
use crate::arch::memory::BootInfoFrameAllocator;
use crate::devices::pci::check_device;
use super::PciDeviceInfo;
// FIXME: un-hardcode these
const PRDT_START: u64 = 0xffff_ffff_0000_0000;
const BUFFER_START: u64 = 0xffff_ffff_0000_1000;
/// ATA logical sector size, in bytes
const SECTOR_SIZE: u16 = 512;
/// Bus Master IDE Command
const BMIC_OFFSET: u16 = 0;
/// Bus Master IDE Status
const BMIS_OFFSET: u16 = 2;
/// Bus Master IDE Descriptor Table Pointer
const BMIDTP_OFFSET: u16 = 4;
/// Bus Master IDE Secondary Offset
const BMI_SECONDARY: u16 = 8;
/// Primary command block offset
const PRIMARY_COMMAND: u16 = 0x01F0;
/// Secondary command block offset
const SECONDARY_COMMAND: u16 = 0x0170;
/// Data register offset
const DATA_OFFSET: u16 = 0;
/// Sector count register offset
const SECCOUNT_OFFSET: u16 = 2;
/// LBA0 register offset
const LBA0_OFFSET: u16 = 3;
/// LBA1 register offset
const LBA1_OFFSET: u16 = 4;
/// LBA2 register offset
const LBA2_OFFSET: u16 = 5;
/// Drive/Head register offset
const DRIVE_HEAD_OFFSET: u16 = 6;
/// Command/status register offset
const COMMAND_STATUS_OFFSET: u16 = 7;
/// Secondary control block offset
const SECONDARY_CONTROL: u16 = 0x0374;
/// Primary control block offset
const PRIMARY_CONTROL: u16 = 0x03F4;
/// Alternative status offset
const ALT_STATUS_OFFSET: u16 = 2;
/// ATA identification command
const CMD_IDENTIFY: u8 = 0xEC;
/// ATA read using LBA28 DMA command
const CMD_READ_DMA: u8 = 0xC8;
/// ATA write using LBA28 DMA command
const CMD_WRITE_DMA: u8 = 0xCA;
/// ATA read using LBA48 DMA command
const CMD_READ_DMA_EXT: u8 = 0x25;
/// ATA write using LBA48 DMA command
const CMD_WRITE_DMA_EXT: u8 = 0x35;
pub struct PciIde {
device_info: PciDeviceInfo,
ide_devices: Vec<IdeDevice>,
prdt_frame: Option<PhysFrame>,
buffer_frames: Option<Vec<PhysFrame>>,
bmiba: u16,
}
impl PciIde {
// FIXME: make this return a Result
pub fn new(bus: u8, device: u8) -> Option<Self> {
let device_info = check_device(bus, device)?;
device_info.enable_bus_mastering();
let idetim = unsafe { device_info.read(0, 0x40) };
trace!("idetim: {idetim:b}");
// FIXME: enable the right bits in idetim (and sidetim) to use fast timings
let mut ide_devices = Vec::with_capacity(4);
for ch in 0..2 {
let channel = if ch == 0 {
Channel::Primary
} else {
Channel::Secondary
};
'drive: for dr in 0..2 {
let drive = if dr == 0 { Drive::Master } else { Drive::Slave };
unsafe {
select_drive(drive, channel);
// FIXME: clear sector count and lba0, lba1, lba2 registers
let status = ata_send_command(CMD_IDENTIFY, channel);
if status == 0 {
continue; // If status = 0, no device
}
loop {
let status = {
let addr = if channel.secondary() {
SECONDARY_COMMAND
} else {
PRIMARY_COMMAND
} + COMMAND_STATUS_OFFSET;
Port::<u8>::new(addr).read()
};
if status & 1 == 1 {
// if error (bit 0), device is not ATA
// FIXME: ATAPI devices
continue 'drive;
}
if !((status >> 7) & 1 == 1) && (status >> 3) & 1 == 1 {
// BSY cleared, DRQ set, everything is right
break;
}
}
// Read identification space of device
let addr = if channel.secondary() {
SECONDARY_COMMAND
} else {
PRIMARY_COMMAND
} + DATA_OFFSET;
let mut buffer = [0_u8; 512];
read_dword_buffer(addr, buffer.as_mut_ptr() as *mut _, 128);
// for (i, byte) in buffer.iter().enumerate() {
// if byte.is_ascii() {
// trace!("byte {i}: {byte:b}, ascii: {}", *byte as char);
// } else {
// trace!("byte {i}: {byte:b}");
// }
// }
if buffer[99] & 1 != 1 {
// FIXME: PIO mode support
error!("IDE drive {channel:?}/{drive:?} does not support DMA");
continue;
}
// FIXME: CHS support
let lba48 = (buffer[167] >> 2) & 1 == 1;
let size = buffer[200] as u64
| (buffer[201] as u64) << 8
| (buffer[202] as u64) << 16
| (buffer[203] as u64) << 24
| (buffer[204] as u64) << 32
| (buffer[205] as u64) << 40
| (buffer[206] as u64) << 48
| (buffer[207] as u64) << 54;
trace!("IDE drive {channel:?}/{drive:?} has {size} sectors");
ide_devices.push(IdeDevice {
channel,
drive,
size,
lba48_support: lba48,
});
}
}
}
let bmiba = device_info.bar(4) & 0xFFFFFFFC;
Some(Self {
device_info,
ide_devices,
prdt_frame: None,
buffer_frames: None,
bmiba: bmiba.try_into().ok()?,
})
}
pub fn allocate_dma_frame(
&mut self,
mapper: &mut impl Mapper<Size4KiB>,
frame_allocator: &mut BootInfoFrameAllocator,
) -> Result<(), MapToError<Size4KiB>> {
use x86_64::structures::paging::PageTableFlags as Flags;
let prdt_frame = frame_allocator
.allocate_frame()
.ok_or(MapToError::FrameAllocationFailed)?;
let buffer_frames = {
let mut frame = frame_allocator
.allocate_frame()
.ok_or(MapToError::FrameAllocationFailed)?;
while !frame.start_address().is_aligned(0x10000u64) {
unsafe {
frame_allocator.deallocate_frame(frame);
}
frame = frame_allocator
.allocate_frame()
.ok_or(MapToError::FrameAllocationFailed)?;
}
let mut frames = Vec::with_capacity(16);
frames.push(frame);
for _ in 0..15 {
let frame = frame_allocator
.allocate_frame()
.ok_or(MapToError::FrameAllocationFailed)?;
frames.push(frame);
}
frames
};
let flags = Flags::NO_CACHE | Flags::PRESENT | Flags::WRITABLE;
unsafe {
mapper
.map_to(
Page::containing_address(VirtAddr::new(PRDT_START)),
prdt_frame,
flags,
frame_allocator,
)?
.flush();
for (i, frame) in buffer_frames.iter().enumerate() {
mapper
.map_to(
Page::containing_address(VirtAddr::new(BUFFER_START + i as u64 * 0x1000)),
*frame,
flags,
frame_allocator,
)?
.flush()
}
}
self.prdt_frame = Some(prdt_frame);
self.buffer_frames = Some(buffer_frames);
Ok(())
}
pub fn read(
&mut self,
channel: Channel,
drive: Drive,
lba: u64,
sector_count: u16,
buffer: &mut Vec<u8>,
) -> Result<(), TryFromIntError> {
let lba48_support = self
.ide_devices
.iter()
.find(|d| d.channel == channel && d.drive == drive)
.map(|d| d.lba48_support)
.unwrap(); // FIXME: make this an error
let lba48 = lba > 0xFFFFFFF && lba48_support;
// FIXME: make this an error
assert!((lba48 && lba > 0xFFFFFFF) || (!lba48 && lba <= 0xFFFFFFF));
let byte_count = sector_count * SECTOR_SIZE;
// prepare PRD table
let prd = PRDT_START as *mut PhysRegionDescriptor;
unsafe {
(*prd).data_buffer = self.buffer_frames.as_ref().unwrap()[0]
.start_address()
.as_u64()
.try_into()?;
(*prd).byte_count = byte_count;
// this is the end of table
(*prd).eot = 1 << 7;
// this byte is reserved, we should probably set it to 0
(*prd)._0 = 0;
}
unsafe {
self.load_prdt(channel);
self.stop(channel);
self.set_read(channel);
self.clear_bmi_status(channel);
select_drive(drive, channel);
set_lba(channel, lba, sector_count, lba48);
if lba48 {
ata_send_command(CMD_READ_DMA_EXT, channel);
} else {
ata_send_command(CMD_READ_DMA, channel);
}
self.start(channel);
}
loop {
let status = unsafe { self.bmi_status(channel) };
// FIXME: error handling
// Bit 2 (INT) set?
if (status >> 2) & 1 == 1 {
break;
}
}
unsafe {
// Stop DMA
self.stop(channel);
// Clear the interrupt bit
self.clear_bmi_status(channel);
}
for i in 0..byte_count as u64 {
let addr = (BUFFER_START + i) as *mut u8;
buffer.push(unsafe { *addr });
}
Ok(())
}
pub fn write(
&mut self,
channel: Channel,
drive: Drive,
lba: u64,
data: &[u8],
) -> Result<(), TryFromIntError> {
// FIXME: make this an error
assert!(data.len() % SECTOR_SIZE as usize == 0);
let lba48_support = self
.ide_devices
.iter()
.find(|d| d.channel == channel && d.drive == drive)
.map(|d| d.lba48_support)
.unwrap(); // FIXME: make this an error
let lba48 = lba > 0xFFFFFFF && lba48_support;
// FIXME: make this an error
assert!((lba48 && lba > 0xFFFFFFF) || (!lba48 && lba <= 0xFFFFFFF));
let byte_count = data.len() as u16;
let sector_count = byte_count / SECTOR_SIZE;
// prepare PRD table
let prd = PRDT_START as *mut PhysRegionDescriptor;
unsafe {
(*prd).data_buffer = self.buffer_frames.as_ref().unwrap()[0]
.start_address()
.as_u64()
.try_into()?;
(*prd).byte_count = byte_count;
// this is the end of table
(*prd).eot = 1 << 7;
// this byte is reserved, we should probably set it to 0
(*prd)._0 = 0;
}
// copy the data over to the DMA buffer
for i in 0..byte_count {
let addr = (BUFFER_START + i as u64) as *mut u8;
unsafe {
*addr = *data.get(i as usize).unwrap_or(&0);
}
}
unsafe {
self.load_prdt(channel);
self.stop(channel);
self.set_write(channel);
self.clear_bmi_status(channel);
select_drive(drive, channel);
set_lba(channel, lba, sector_count, lba48);
if lba48 {
ata_send_command(CMD_WRITE_DMA_EXT, channel);
} else {
ata_send_command(CMD_WRITE_DMA, channel);
}
self.start(channel);
}
loop {
let status = unsafe { self.bmi_status(channel) };
// FIXME: error handling
// Bit 2 (INT) set?
if (status >> 2) & 1 == 1 {
break;
}
}
unsafe {
// Stop DMA
self.stop(channel);
// Clear the interrupt bit
self.clear_bmi_status(channel);
}
Ok(())
}
pub fn device_info(&self) -> PciDeviceInfo {
self.device_info
}
unsafe fn load_prdt(&self, channel: Channel) {
let addr = if channel.secondary() {
BMI_SECONDARY
} else {
0
} + self.bmiba
+ BMIDTP_OFFSET;
Port::<u32>::new(addr).write(
self.prdt_frame
.unwrap()
.start_address()
.as_u64()
.try_into()
.unwrap(),
);
}
unsafe fn start(&self, channel: Channel) {
let addr = if channel.secondary() {
BMI_SECONDARY
} else {
0
} + self.bmiba
+ BMIC_OFFSET;
let mut port: Port<u8> = Port::new(addr);
let mut bmic = port.read();
// start transfer
bmic |= 1;
// write the new bmic
port.write(bmic);
}
unsafe fn stop(&self, channel: Channel) {
let addr = if channel.secondary() {
BMI_SECONDARY
} else {
0
} + self.bmiba
+ BMIC_OFFSET;
let mut port: Port<u8> = Port::new(addr);
let mut bmic = port.read();
// stop ongoing transfer
bmic &= !1;
// write the new bmic
port.write(bmic);
}
unsafe fn set_read(&self, channel: Channel) {
let addr = if channel.secondary() {
BMI_SECONDARY
} else {
0
} + self.bmiba
+ BMIC_OFFSET;
let mut port: Port<u8> = Port::new(addr);
let mut bmic = port.read();
// mark bit 3 as 0 (read)
bmic &= !(1 << 3);
// write the new bmic
port.write(bmic);
}
unsafe fn set_write(&self, channel: Channel) {
let addr = if channel.secondary() {
BMI_SECONDARY
} else {
0
} + self.bmiba
+ BMIC_OFFSET;
let mut port: Port<u8> = Port::new(addr);
let mut bmic = port.read();
// mark bit 3 as 1 (write)
bmic |= 1 << 3;
// write the new bmic
port.write(bmic);
}
unsafe fn bmi_status(&self, channel: Channel) -> u8 {
let addr = if channel.secondary() {
BMI_SECONDARY
} else {
0
} + self.bmiba
+ BMIS_OFFSET;
let mut port = Port::new(addr);
port.read()
}
unsafe fn clear_bmi_status(&self, channel: Channel) {
let addr = if channel.secondary() {
BMI_SECONDARY
} else {
0
} + self.bmiba
+ BMIS_OFFSET;
let mut port: Port<u8> = Port::new(addr);
let mut bmis = port.read();
// write 1 to bits 1 (DMA error) and 2 (int status) which clears them
bmis |= 1 << 1 | 1 << 2;
// write the new bmis
port.write(bmis);
}
}
unsafe fn select_drive(drive: Drive, channel: Channel) {
let addr = if channel.secondary() {
SECONDARY_COMMAND
} else {
PRIMARY_COMMAND
} + DRIVE_HEAD_OFFSET;
let mut port: Port<u8> = Port::new(addr);
// FIXME: CHS support
let drive_command = if drive.slave() {
// slave & LBA
0b11110000
} else {
// master & LBA
0b11100000
};
// write the new drive/head register
port.write(drive_command);
ata_delay(channel);
}
/// Send ATA command and read status afterwards
unsafe fn ata_send_command(command: u8, channel: Channel) -> u8 {
let addr = if channel.secondary() {
SECONDARY_COMMAND
} else {
PRIMARY_COMMAND
} + COMMAND_STATUS_OFFSET;
let mut port = Port::new(addr);
port.write(command);
ata_delay(channel);
port.read()
}
/// Read the alternate status register 14 times to create a ~420ns delay
unsafe fn ata_delay(channel: Channel) {
let addr = if channel.secondary() {
SECONDARY_CONTROL
} else {
PRIMARY_CONTROL
} + ALT_STATUS_OFFSET;
let mut port: Port<u8> = Port::new(addr);
for _ in 0..14 {
port.read();
}
}
/// Set LBA and sector count registers. sector_count of 0 means 65536 sectors
unsafe fn set_lba(channel: Channel, lba: u64, sector_count: u16, lba48: bool) {
let command_block = if channel.secondary() {
SECONDARY_COMMAND
} else {
PRIMARY_COMMAND
};
let mut seccount = Port::new(command_block + SECCOUNT_OFFSET);
let mut lba0 = Port::new(command_block + LBA0_OFFSET);
let mut lba1 = Port::new(command_block + LBA1_OFFSET);
let mut lba2 = Port::new(command_block + LBA2_OFFSET);
let mut head = Port::new(command_block + DRIVE_HEAD_OFFSET);
let head_value: u8 = head.read();
let lba_bytes = lba.to_le_bytes();
let sector_count_bytes = sector_count.to_le_bytes();
// write the new LBA & sector count registers
// FIXME: CHS support
if lba48 {
seccount.write(sector_count_bytes[1]);
lba0.write(lba_bytes[3]);
lba1.write(lba_bytes[4]);
lba2.write(lba_bytes[5]);
} else {
head.write(head_value | (lba_bytes[3] & 0x0F));
}
seccount.write(sector_count_bytes[0]);
lba0.write(lba_bytes[0]);
lba1.write(lba_bytes[1]);
lba2.write(lba_bytes[2]);
}
unsafe fn read_dword_buffer(port: u16, buffer: *mut u32, mut count: u32) {
// FIXME: this assumes x86-64
interrupts::without_interrupts(|| {
asm!("
cld
repne
insd",
in("di") buffer,
in("dx") port,
inout("cx") count,
)
});
}
struct IdeDevice {
pub channel: Channel,
pub drive: Drive,
pub size: u64, // in sectors
pub lba48_support: bool,
// FIXME: model
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Channel {
Primary,
Secondary,
}
impl Channel {
fn secondary(&self) -> bool {
matches!(self, Self::Secondary)
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Drive {
Master,
Slave,
}
impl Drive {
fn slave(&self) -> bool {
matches!(self, Self::Slave)
}
}
#[repr(C, packed)]
struct PhysRegionDescriptor {
/// Pointer to the data buffer
pub data_buffer: u32,
/// Byte count, 64K maximum per PRD transfer. 0 means 64K
pub byte_count: u16,
/// Reserved byte
pub _0: u8,
/// MSB marks end of transfer
pub eot: u8,
}

View file

@ -1,71 +0,0 @@
/*
* Copyright (c) 2022, Umut İnan Erdoğan <umutinanerdogan@pm.me>
*
* SPDX-License-Identifier: MPL-2.0
*/
pub mod class;
pub mod device;
pub mod vendors;
// MassStorage_IDE (0x0101)
pub mod ide;
use alloc::sync::Arc;
pub use class::*;
pub use device::*;
use lazy_static::lazy_static;
use spin::Mutex;
use x86_64::structures::paging::{Mapper, Size4KiB};
use crate::arch::memory::BootInfoFrameAllocator;
// MassStorage_IDE (0x0101)
use self::ide::PciIde;
lazy_static! {
pub static ref PCI_DEVICES: Mutex<Vec<Arc<Mutex<PciDevice>>>> = Default::default();
}
#[non_exhaustive]
pub enum PciDevice {
Ide(PciIde),
// Variant so that we aren't about irrefutable if-let patterns
// FIXME: remove as soon as we have other variants
_0,
}
/// Enumerate PCI devices and run initialisation routines on ones we support
pub fn init(mapper: &mut impl Mapper<Size4KiB>, frame_allocator: &mut BootInfoFrameAllocator) {
for bus in 0..=255 {
for device in 0..32 {
if let Some(device_info) = device::check_device(bus, device) {
trace!("{device_info}");
match device_info.device_id {
// FIXME: Unknown class
S3_TRIO64V2 => {}
// MassStorage_IDE (0x0101)
ide_controller if device_info.full_class == PciFullClass::MassStorage_IDE => {
if !matches!(ide_controller, INTEL_PIIX3_IDE | INTEL_PIIX4_IDE) {
// not one of our tested IDE controllers, but
// we shouldn't have any problems
warn!("Unsupported PCI IDE controller device {device} on bus {bus}")
}
let mut ide = PciIde::new(bus, device).unwrap();
ide.allocate_dma_frame(mapper, frame_allocator).unwrap();
let mut devices = PCI_DEVICES.lock();
devices.push(Arc::new(Mutex::new(PciDevice::Ide(ide))));
}
// Display_VGA (0x0300)
VMWARE_SVGA2 => {}
_ => {
trace!("Unknown PCI device {device} on bus {bus}")
}
}
}
}
}
}

View file

@ -1,180 +0,0 @@
/*
* Copyright (c) 2022, able <abl3theabove@gmail.com>
*
* SPDX-License-Identifier: MPL-2.0
*/
use core::fmt::Display;
#[derive(PartialEq, Debug, Copy, Clone, Eq)]
#[repr(u16)]
pub enum Vendor {
ThreeDfxInteractiveInc = 0x121a,
ThreeDLabs = 0x3d3d,
AllianceSemiconductorCorp = 0x1142,
ARKLogicInc = 0xedd8,
ATITechnologiesInc = 0x1002,
AvanceLogicIncALI = 0x1005,
ChipsandTechnologies = 0x102c,
CirrusLogic = 0x1013,
Compaq = 0x0e11,
CyrixCorp = 0x1078,
DiamondMultimediaSystems = 0x1092,
DigitalEquipmentCorp = 0x1011,
Iit = 0x1061,
IntegratedMicroSolutionsInc = 0x10e0,
IntelCorp = 0x8086,
IntergraphicsSystems = 0x10ea,
MacronixInc = 0x10d9,
MatroxGraphicsInc = 0x102b,
MiroComputersProductsAG = 0x1031,
NationalSemiconductorCorp = 0x100b,
NeoMagicCorp = 0x10c8,
Number9ComputerCompany = 0x105d,
NVidiaCorporation = 0x10de,
NVidiaSgsthomson = 0x12d2,
OakTechnologyInc = 0x104e,
Qemu = 0x1234,
QuantumDesignsHKLtd = 0x1098,
Real3D = 0x003d,
Rendition = 0x1163,
S3Inc = 0x5333,
SierraSemiconductor = 0x10a8,
SiliconIntegratedSystemsSiS = 0x1039,
SiliconMotionInc = 0x126f,
STBSystemsInc = 0x10b4,
TexasInstruments = 0x104c,
ToshibaAmericaInfoSystems = 0x1179,
TridentMicrosystems = 0x1023,
TsengLabsInc = 0x100c,
TundraSemiconductorCorp = 0x10e3,
VIATechnologiesInc = 0x1106,
VirtIO = 0x1AF4,
VMWareInc = 0x15ad,
Weitek = 0x100e,
Unknown(u16),
}
impl From<u16> for Vendor {
fn from(vendor_id: u16) -> Self {
use Vendor::*;
match vendor_id {
0x121a => ThreeDfxInteractiveInc,
0x3d3d => ThreeDLabs,
0x1142 => AllianceSemiconductorCorp,
0xedd8 => ARKLogicInc,
0x1002 => ATITechnologiesInc,
0x1005 => AvanceLogicIncALI,
0x102c => ChipsandTechnologies,
0x1013 => CirrusLogic,
0x0e11 => Compaq,
0x1078 => CyrixCorp,
0x1092 => DiamondMultimediaSystems,
0x1011 => DigitalEquipmentCorp,
0x1061 => Iit,
0x10e0 => IntegratedMicroSolutionsInc,
0x8086 => IntelCorp,
0x10ea => IntergraphicsSystems,
0x10d9 => MacronixInc,
0x102b => MatroxGraphicsInc,
0x1031 => MiroComputersProductsAG,
0x100b => NationalSemiconductorCorp,
0x10c8 => NeoMagicCorp,
0x105d => Number9ComputerCompany,
0x10de => NVidiaCorporation,
0x12d2 => NVidiaSgsthomson,
0x104e => OakTechnologyInc,
0x1234 => Qemu,
0x1098 => QuantumDesignsHKLtd,
0x003d => Real3D,
0x1163 => Rendition,
0x5333 => S3Inc,
0x10a8 => SierraSemiconductor,
0x1039 => SiliconIntegratedSystemsSiS,
0x126f => SiliconMotionInc,
0x10b4 => STBSystemsInc,
0x104c => TexasInstruments,
0x1179 => ToshibaAmericaInfoSystems,
0x1023 => TridentMicrosystems,
0x100c => TsengLabsInc,
0x10e3 => TundraSemiconductorCorp,
0x1106 => VIATechnologiesInc,
0x1AF4 => VirtIO,
0x15ad => VMWareInc,
0x100e => Weitek,
id => Unknown(id),
}
}
}
impl Into<u16> for Vendor {
fn into(self) -> u16 {
use Vendor::*;
match self {
ThreeDfxInteractiveInc => 0x121a,
ThreeDLabs => 0x3d3d,
AllianceSemiconductorCorp => 0x1142,
ARKLogicInc => 0xedd8,
ATITechnologiesInc => 0x1002,
AvanceLogicIncALI => 0x1005,
ChipsandTechnologies => 0x102c,
CirrusLogic => 0x1013,
Compaq => 0x0e11,
CyrixCorp => 0x1078,
DiamondMultimediaSystems => 0x1092,
DigitalEquipmentCorp => 0x1011,
Iit => 0x1061,
IntegratedMicroSolutionsInc => 0x10e0,
IntelCorp => 0x8086,
IntergraphicsSystems => 0x10ea,
MacronixInc => 0x10d9,
MatroxGraphicsInc => 0x102b,
MiroComputersProductsAG => 0x1031,
NationalSemiconductorCorp => 0x100b,
NeoMagicCorp => 0x10c8,
Number9ComputerCompany => 0x105d,
NVidiaCorporation => 0x10de,
NVidiaSgsthomson => 0x12d2,
OakTechnologyInc => 0x104e,
Qemu => 0x1234,
QuantumDesignsHKLtd => 0x1098,
Real3D => 0x003d,
Rendition => 0x1163,
S3Inc => 0x5333,
SierraSemiconductor => 0x10a8,
SiliconIntegratedSystemsSiS => 0x1039,
SiliconMotionInc => 0x126f,
STBSystemsInc => 0x10b4,
TexasInstruments => 0x104c,
ToshibaAmericaInfoSystems => 0x1179,
TridentMicrosystems => 0x1023,
TsengLabsInc => 0x100c,
TundraSemiconductorCorp => 0x10e3,
VIATechnologiesInc => 0x1106,
VirtIO => 0x1AF4,
VMWareInc => 0x15ad,
Weitek => 0x100e,
Unknown(id) => id,
}
}
}
impl Display for Vendor {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
use Vendor::*;
match self {
Qemu => write!(f, "{}", "\0PINK\0QEMU (0x1234)"),
VirtIO => write!(f, "{}", "\0PINK\0VirtIO (0x1AF4)"),
VMWareInc => write!(f, "{}", "\0PINK\0VMWARE (0x15AD)"),
S3Inc => write!(f, "{}", "\0YELLOW\0S3 Incorporated (0x5333)"),
IntelCorp => write!(f, "{}", "\0BLUE\0Intel Corp. (0x8086)"),
ATITechnologiesInc => write!(f, "{}", "\0RED\0ATI (0x1002)"),
Unknown(id) => write!(f, "\0RED\0Unknown ({:#6})", id),
other => write!(f, "{other:?}"),
}?;
write!(f, "\0RESET\0")?;
Ok(())
}
}

View file

@ -1,44 +0,0 @@
#![allow(unused)]
pub const REFRESH_RATE: u8 = 60;
pub type RefreshRate = u8;
pub type Resolution = (usize, usize);
pub type Point = (GCoord, GCoord);
pub type GCoord = usize;
pub enum GModes {
Vga800x600,
Custom(u16, u16),
}
// TODO remap to a bitmasked u32
// REASON: More effecient memory wise so less overhead on the wasm memory
// Current: u32+u32+u32
// Proposed: u32 with bitmaps
pub struct Rgb {
pub r: u32,
pub g: u32,
pub b: u32,
}
impl Rgb {
fn to_vga_color() {
todo!();
}
}
pub struct FrameBuffer;
pub trait Graphics {
fn put_line(coords_start: Point, coords_end: Point, thickness: u32, color: Rgb);
fn put_rect(coords_start: Point, coords_end: Point, color: Rgb);
fn put_circle(coords: Point, radius: u32);
fn put_pixel(coords: Point, color: Rgb);
fn put_triangle(coords_1: Point, coords_2: Point, coords_3: Point, thickness: u32, color: Rgb);
fn paint_cursor(coords: Point);
fn hide_cursor();
fn show_cursor();
/// Actually move the double buffer to the single buffer and "update" the screen
fn draw();
fn clear();
}

View file

@ -1,2 +0,0 @@
pub mod graphics;
pub mod serial;

View file

@ -1,16 +0,0 @@
// TODO: Bitmasking
pub enum Mouse {
Button1,
Button2,
Button3,
Button4,
Button5,
X(i8),
Y(i8),
Wheel(i8),
}
pub trait PS2Mouse {
fn movement();
fn button();
}

View file

@ -1,37 +0,0 @@
use kernel::device_interface::CharacterDevice;
pub struct Serial {
pub base: usize,
}
impl CharacterDevice for Serial {
fn can_read(&self) -> bool {
true
}
fn can_write(&self) -> bool {
true
}
fn read_char(&mut self) -> Option<char> {
todo!()
}
fn write_char(&mut self, _c: char) -> bool {
todo!()
}
fn reset(&mut self) {
todo!()
}
fn initialize(&mut self) -> bool {
false
}
}
pub fn new_serial_test() {
let mut serial = Serial { base: 0x3F8 };
serial.initialize();
serial.write_char('a');
}

View file

@ -1 +0,0 @@
Anything in experiments is heavily unstable and likely to change

View file

@ -1,107 +0,0 @@
use logos::{Lexer, Logos};
// TODO improve tokenizer/parser
pub fn colorify(eval: &str) {
let y = eval.split('$');
for z in y {
match z {
"BLACK" => {
// set_vga_color(Color::Black, Color::Black);
}
"RED" => {
// set_vga_color(Color::Red, Color::Black);
}
"GREEN" => {
// set_vga_color(Color::Green, Color::Black);
}
"BLUE" => {
// set_vga_color(Color::Blue, Color::Black);
}
"CYAN" => {
// set_vga_color(Color::Cyan, Color::Black);
}
"MAGENTA" => {
// set_vga_color(Color::Magenta, Color::Black);
}
"BROWN" => {
// set_vga_color(Color::Brown, Color::Black);
}
"LIGHTGRAY" => {
// set_vga_color(Color::LightGray, Color::Black);
}
"DARKGRAY" => {
// set_vga_color(Color::DarkGray, Color::Black);
}
"LIGHTBLUE" => {
// set_vga_color(Color::LightBlue, Color::Black);
}
"LIGHTGREEN" => {
// set_vga_color(Color::LightGreen, Color::Black);
}
"LIGHTCYAN" => {
// set_vga_color(Color::LightCyan, Color::Black);
}
"LIGHTRED" => {
// set_vga_color(Color::LightRed, Color::Black);
}
"PINK" => {
// set_vga_color(Color::Pink, Color::Black);
}
"YELLOW" => {
// set_vga_color(Color::Yellow, Color::Black);
}
"WHITE" => {
// set_vga_color(Color::White, Color::Black);
}
"RESET" => {
// set_vga_color(Color::White, Color::Black);
}
_elk => {
// kprint!("{}", elk);
}
}
}
}
#[derive(Logos, Debug, PartialEq)]
pub enum Token {
// Hex(u32),
#[regex(r"\$RED\$")]
Red,
#[regex(r"\$RESET\$")]
Reset,
#[regex("[a-zA-Z!@#$%^&*\">()\n ]+", parse_text, priority = 2)]
Text(String),
#[error]
#[regex(r"[ \t\n\f]+", logos::skip)]
Error,
}
pub fn colorify_2(eval: &str) {
let lexer = Token::lexer(eval);
for token in lexer {
use Token::*;
match token {
Red => {
// set_vga_color(Color::Red, Color::Black);
}
Reset => {
// set_vga_color(Color::White, Color::Black);
}
Text(_text) => {
// kprint!("{}", text);
}
err => {
error!("Error parsing {:?}", err);
}
}
}
}
fn parse_text(lex: &mut Lexer<Token>) -> Option<String> {
let slice = lex.slice();
Some(String::from(slice))
}

View file

@ -1,7 +0,0 @@
##### #####
## ##### # ###### ## ## # #
# # # # # # # # #
# # ##### # ##### # # #####
###### # # # # # # #
# # # # # # ## ## # #
# # ##### ###### ###### ##### #####

View file

@ -1,53 +0,0 @@
use alloc::{string::String, vec, vec::Vec};
pub static CLIPBOARD: spin::Mutex<Clipboard> = spin::Mutex::new(Clipboard::new());
#[derive(Debug)]
pub enum Mime {
None,
Text(String),
}
// ctrl+v paste but not pop and pastes
// ctrl+shift+v pops from the stack and pastes
// ctrl+c pushes to the stack
// ctrl+shift+< move stack pointer left
// ctrl+shift+> move stack pointer right
pub struct Clipboard {
pub index: usize,
pub pages: Vec<Mime>,
}
impl Clipboard {
pub const fn new() -> Clipboard {
Clipboard {
index: 0,
pages: vec![],
}
}
pub fn clear(&mut self) {
self.pages = vec![];
}
pub fn set_index(&mut self, index_new: usize) {
self.index = index_new;
}
pub fn clip_end(&mut self) {
self.index = 0;
}
pub fn clip_home(&mut self) {
self.index = self.pages.len();
}
pub fn copy(&mut self, copy_mime: Mime) {
self.pages.push(copy_mime);
}
pub fn paste(&mut self) -> &Mime {
&self.pages[self.index] as _
}
}

View file

@ -1,22 +0,0 @@
struct Permissions {
write_files: bool,
read_files: bool,
execute_files: bool,
// Every other user is part of global
global_write_files: bool,
global_read_files: bool,
global_execute_files: bool,
}
pub struct File {
owner: u8,
permissions: Permissions,
data: Vec<u8>,
}
pub struct Folder {
owner: u8,
permissions: Permissions,
folders: Vec<Folder>,
files: Vec<File>,
}

View file

@ -1,15 +0,0 @@
<user>/home/app1
<user>/conf/app1
<user>/apps/app1
file:app1
conf:app1
apps:app1
// Discouraged
raw:
/<user>/<protocol>/app1
protocol.toml
hi = ""

View file

@ -1,57 +0,0 @@
use core::time::Duration;
pub struct AtomicU32(u32);
impl AtomicU32 {
//if v != current value
pub fn wait(&self, _v: u32) {
todo!();
}
pub fn wait_timeout(&self, _v: u32, _timeout: Duration) -> bool {
todo!();
}
pub fn wake_single(&self) {
todo!();
}
pub fn wake_all(&self) {
todo!();
}
}
/*
// SUPER HANDWAVEY
// YOU WILL NEED LOCKING THAT I DIDNT WRITE OUT (you == zuurr#9735)
// all the red is by design
pub fn futex_wait(atom: &AtomicU32, value: usize, current_thread: ThreadID) {
let address = atomic as *const _ as usize;
let waiters = waiters_for(address); // Hold lock
waiters.add(current_thread);
if self.load() == value {
current_thread.sleep();
} else {
waiters.remove(current_thread);
}
}
pub fn futex_wake(atom: &AtomicU32, threads_to_wake: usize) {
let address = atomic as *const _ as usize;
let waiters = waiters_for(address);
for waiting_thread in waiters.into_iter().take(threads_to_wake) {
waiting_thread.wake()
}
}
*/
struct FutexWaitlist {
address: u8,
// data: Vec<ThreadID>,
}
impl FutexWaitlist {
pub fn remove(&mut self) {
todo!();
}
pub fn add(&mut self) {
todo!();
}
}

View file

@ -1,75 +0,0 @@
use super::systeminfo::SystemMemory;
use crate::arch::drivers::sysinfo::master;
use core::fmt::Display;
use kernel::allocator::ALLOCATOR;
use versioning::Version;
use x86_64::instructions::interrupts::{disable, enable};
pub enum CpuType {
RiscV(String),
X86_64(String),
}
impl Display for CpuType {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(
f,
"{}",
match self {
CpuType::RiscV(s) => s,
CpuType::X86_64(s) => s,
}
)
}
}
/// simple info you would want to know in a neofetch like program
pub struct KernelInfo {
// os: String,
// host: String,
pub kernel_version: Version,
pub cpu: CpuType,
// gpu: String,
pub memory: SystemMemory,
}
impl KernelInfo {
pub fn get() -> KernelInfo {
disable();
let allocator = ALLOCATOR.lock();
let total = allocator.size();
let used = allocator.used();
enable();
let cpu = CpuType::X86_64(master().unwrap().brand_string().unwrap().to_string());
KernelInfo {
kernel_version: Version {
major: 0,
minor: 0,
patch: 0,
},
cpu,
memory: SystemMemory { total, used },
}
}
}
impl Display for KernelInfo {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(
f,
"
OS: AbleOS
Host: {{}}
Kernel: {}.{}.{}
CPU: {}
Memory: {}/{}
",
self.kernel_version.major,
self.kernel_version.minor,
self.kernel_version.patch,
self.cpu,
self.memory.used,
self.memory.total
)
}
}

View file

@ -1,113 +0,0 @@
#![allow(dead_code)]
// TODO: Evaluate variable sized mailboxes
pub struct MailBoxes {
flags: u8,
mailboxes: [u64; 4],
}
impl MailBoxes {
pub fn new() -> Self {
Self {
flags: 0b0000_0000,
mailboxes: [0; 4],
}
}
pub fn reset(&mut self) {
self.flags = 0b0000_0000;
self.mailboxes = [0; 4];
}
pub fn set_mailbox(&mut self, mailbox_num: u8, mailbox_data: u64) {
if let 0..=3 = mailbox_num {
self.mailboxes[mailbox_num as usize] = mailbox_data
}
}
pub fn set_flag(&mut self, flag_num: u8) {
match flag_num {
0 => {
self.flags |= 0b0000_0001;
}
1 => {
self.flags |= 0b0000_0010;
}
2 => {
self.flags |= 0b0000_0100;
}
3 => {
self.flags |= 0b0000_1000;
}
4 => {
self.flags |= 0b0001_0000;
}
5 => {
self.flags |= 0b0010_0000;
}
6 => {
self.flags |= 0b0100_0000;
}
7 => {
self.flags |= 0b1000_0000;
}
_ => {}
}
}
pub fn dump_flags(&self) {
trace!(
"Flag 0: {:08b} | {}",
self.flags & 0b0000_0001,
self.flags & 0b0000_0001
);
trace!(
"Flag 1: {:08b} | {}",
self.flags & 0b0000_0010,
self.flags >> 1 & 0b0000_0001
);
trace!(
"Flag 2: {:08b} | {}",
self.flags & 0b0000_0100,
self.flags >> 2 & 0b0000_0001
);
trace!(
"Flag 3: {:08b} | {}",
self.flags & 0b0000_1000,
self.flags >> 3 & 0b0000_0001
);
trace!(
"Flag 4: {:08b} | {}",
self.flags & 0b0001_0000,
self.flags >> 4 & 0b0000_0001
);
trace!(
"Flag 5: {:08b} | {}",
self.flags & 0b0010_0000,
self.flags >> 5 & 0b0000_0001
);
trace!(
"Flag 6: {:08b} | {}",
self.flags & 0b0100_0000,
self.flags >> 6 & 0b0000_0001
);
trace!(
"Flag 7: {:08b} | {}",
self.flags & 0b1000_0000,
self.flags >> 7 & 0b0000_0001
);
}
}
impl Default for MailBoxes {
fn default() -> Self {
Self::new()
}
}

View file

@ -1,13 +0,0 @@
#![allow(dead_code)]
pub mod absi;
pub mod clip;
pub mod futex;
pub mod kinfo;
pub mod mail;
pub mod server;
pub mod systeminfo;
pub mod virtual_memory;
pub mod y_compositor;
pub const BANNER: &str = include_str!("banner.txt");

View file

@ -1,7 +0,0 @@
pub type thumbnail = u8;
pub struct Notification {
thumbnail: thumbnail,
text_body: String,
time: u64,
}

View file

@ -1,45 +0,0 @@
use crate::experiments::kinfo::SemanticVersion;
// Scuffed
pub type Hash = u8;
pub type PackageName = String;
pub struct MetaPackage {
pub name: u8,
pub version: SemanticVersion,
pub authors: [u8; 8],
pub support_email: u8,
pub hash: Hash,
}
impl MetaPackage {
pub fn new() -> Self {
Self {
name: 0,
version: SemanticVersion {
major: 0,
minor: 0,
patch: 0,
},
authors: [0; 8],
support_email: 8,
hash: 0,
}
}
fn validate_hash(&self) {}
}
impl core::fmt::Display {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(
f,
"Packname: {}
Version: {}
Authors: {:?}
Support Email: {}
Hash: {}",
self.name, self.version, self.authors, self.support_email, self.hash
)
}
}

View file

@ -1,13 +0,0 @@
pub trait Server {
/// Initialize the server and return a number
fn initialize() -> u32;
/// kill the server
fn kill() -> bool;
// put data in the servers outbox
fn send();
// put data in the servers inbox and notify it
fn recieve();
}

View file

@ -1,39 +0,0 @@
| low \\ high | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| ----------- | ------------------- | ------------------------ | ------------------------------------------------------------------------------------------ | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
| 0 | **kill** | <sub>reserved</sub> | **sleep** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 1 | **stdout_reset** | <sub>reserved</sub> | **sleep_until** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 2 | **stdin** | <sub>reserved</sub> | [**nanosleep**](https://www.reddit.com/r/anime/comments/e7sg7g/nichijou_trouble_sleeping/) | **aes_encrypt** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 3 | **stdout** | <sub>reserved</sub> | **nanosleep_until** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 4 | **stdin_get_title** | <sub>reserved</sub> | **get_time** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 5 | **stdin_set_title** | <sub>reserved</sub> | **set_time** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 6 | **get_pid** | **make_directory** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 7 | **pinfo** | **delete_directory** | **socket_bind** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 8 | <sub>reserved</sub> | **rename_directory** | **socket_connect** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 9 | <sub>reserved</sub> | **set_directory_access** | **socket_disconnect** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| A | **set_priority** | **make_file** | **socket_send** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| B | **get_priority** | **delete_file** | **socket_receive** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| C | **get_hostname** | **rename_file** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| D | **set_hostname** | **set_file_access** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| E | <sub>reserved</sub> | **file_read** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| F | <sub>reserved</sub> | **file_write** | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| low \\ high | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 1A | 1B | 1C | 1D | 1E | 1F |
| ----------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
| 0 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 1 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 2 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 3 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 4 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 5 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 6 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 7 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 8 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| 9 | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| A | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| B | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| C | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| D | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| E | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |
| F | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> | <sub>reserved</sub> |

View file

@ -1,21 +0,0 @@
// Can be standardized
// NOTE: move the file to the src/ dir
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(debug_assertions)]
/// A constant to check if the kernel is in debug mode
pub const RELEASE_TYPE: &str = "debug";
#[cfg(not(debug_assertions))]
/// A constant to check if the kernel is in release mode
pub const RELEASE_TYPE: &str = "release";
pub struct SystemMemory {
pub used: usize,
pub total: usize,
}
impl core::fmt::Display for SystemMemory {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "{} Bytes / {} Bytes", self.used, self.total)
}
}

View file

@ -1,4 +0,0 @@
pub struct User {
id: u8,
clipboard: Clipboard,
}

View file

@ -1,7 +0,0 @@
#![allow(dead_code)]
pub struct Scheduler {
executables: usize,
}
pub struct RunQueue;

View file

@ -1,12 +0,0 @@
pub struct Compositor;
impl Compositor {
pub fn new() -> Self {
Self
}
}
impl Default for Compositor {
fn default() -> Self {
Self::new()
}
}

View file

@ -1,3 +0,0 @@
//!
pub mod compositor;
pub mod window;

View file

@ -1,37 +0,0 @@
// use crate::driver_traits::graphics::Point;
pub type MenuBar = Vec<MenuOption>;
pub struct MenuOption {
symbol: char,
}
pub struct Window {
title: String,
// position: Point,
fullscreen: bool,
}
// all of these should return a result
impl Window {
pub fn new(title: String, /*position: Point,*/ fullscreen: bool) -> Self {
Self {
title,
// position,
fullscreen,
}
}
pub fn fullscreen(&mut self) {
self.fullscreen = true;
}
pub fn revert_fullscreen(&mut self) {
self.fullscreen = false;
}
pub fn set_title(&mut self) {
todo!();
}
pub fn set_position(&mut self /*pos: Point*/) {
// self.position = pos;
}
}

View file

@ -1,42 +0,0 @@
/*
* Copyright (c) 2022, Umut İnan Erdoğan <umutinanerdogan@pm.me>
*
* SPDX-License-Identifier: MPL-2.0
*/
#[derive(Copy, Clone, Debug)]
pub enum FsError {
EndOfFile,
InodeNotFound,
InvalidDevice,
InvalidPath,
IsDirectory,
NotAbsolute,
NotADirectory,
NotFound,
Recursion,
UnsupportedOperation,
}
impl Into<FsError> for ext2::error::Error {
fn into(self) -> FsError {
match self {
ext2::error::Error::Other(_) => todo!(),
ext2::error::Error::BadMagic { magic: _ } => todo!(),
ext2::error::Error::OutOfBounds { index: _ } => todo!(),
ext2::error::Error::AddressOutOfBounds {
sector: _,
offset: _,
size: _,
} => todo!(),
ext2::error::Error::BadBlockGroupCount {
by_blocks: _,
by_inodes: _,
} => todo!(),
ext2::error::Error::InodeNotFound { inode: _ } => FsError::InodeNotFound,
ext2::error::Error::NotADirectory { inode: _, name: _ } => FsError::NotADirectory,
ext2::error::Error::NotAbsolute { name: _ } => todo!(),
ext2::error::Error::NotFound { name: _ } => FsError::NotFound,
}
}
}

Some files were not shown because too many files have changed in this diff Show more