Compare commits

...

20 commits

Author SHA1 Message Date
Erin eae4891071 Skeleton for architecture-specific things 2022-12-06 23:04:28 +01:00
Erin fa82e49dc3 Threw stuff from the microkernel. Start of moving core parts there. 2022-12-06 23:04:26 +01:00
Erin 87fdb2e0bf clippy 2022-12-06 23:04:11 +01:00
Erin aaf840c5b4 removed module that I forgot to remove + 1.65 stuff 2022-12-06 23:04:09 +01:00
Erin 9c2b8573d9 removed sus messaging module 2022-12-06 23:04:04 +01:00
Erin b2cf3621b5 »fixed« scratchpad 2022-12-06 22:39:52 +01:00
Able 82a48f5c98 remove path 2022-12-06 13:24:04 -06:00
Erin 403e410797 repbuild r uses udisks 2022-12-03 17:47:10 +01:00
Able 78a52f7102 Consolidating limine graphics 2022-12-02 08:51:21 -06:00
Able d94e50be39 forgor smp is broked 2022-11-30 01:14:34 -06:00
Able e8712d7c39 framebuffer + smp work 2022-11-24 07:20:16 -06:00
Able 65bb92e02b Ready 2022-11-24 03:35:55 -06:00
Erin 2114b9a346 UNIX fans hate him, he replaced process spawns with IPC!
Doesn't require root permissions now.

TODO: Please replicate BuildImage changes to different places.
2022-11-24 00:22:58 +01:00
Able a2d6d7245a Revert "get ableOS running proper on limine sans graphics"
This reverts commit 1e1d004240.
2022-11-23 06:00:38 -06:00
Able 1e1d004240 get ableOS running proper on limine sans graphics 2022-11-23 05:06:38 -06:00
Able 6e20d33817 limine compiling booting and not panicking 2022-11-23 04:02:02 -06:00
TheOddGarlic 23c355762c progress on porting to limine 2022-08-20 09:28:48 +03:00
TheOddGarlic fe69e31b91 interrupts: page fault handler 2022-08-20 09:26:59 +03:00
TheOddGarlic 346d3a9166 repbuild: generate disk image with limine 2022-08-19 09:22:05 +03:00
TheOddGarlic 643db212ef build: fix rust-toolchain configuration 2022-08-18 09:32:14 +03:00
55 changed files with 1651 additions and 797 deletions

4
.gitignore vendored
View file

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

783
Cargo.lock generated
View file

@ -30,7 +30,6 @@ dependencies = [
"acpi",
"axel",
"bitflags",
"bootloader",
"clparse",
"cpuio",
"ext2",
@ -41,6 +40,7 @@ dependencies = [
"kernel",
"lazy_static",
"libwasm",
"limine",
"linked_list_allocator",
"lliw",
"log",
@ -57,7 +57,7 @@ dependencies = [
"seq-macro",
"serde",
"spin 0.9.4",
"toml",
"toml 0.5.9 (git+https://git.ablecorp.us/theoddgarlic/toml-rs)",
"uart_16550",
"unicode-width",
"versioning",
@ -91,6 +91,15 @@ dependencies = [
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]
[[package]]
name = "asl"
version = "0.1.0"
@ -98,6 +107,100 @@ dependencies = [
"logos",
]
[[package]]
name = "async-broadcast"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d26004fe83b2d1cd3a97609b21e39f9a31535822210fe83205d2ce48866ea61"
dependencies = [
"event-listener",
"futures-core",
"parking_lot",
]
[[package]]
name = "async-channel"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28"
dependencies = [
"concurrent-queue 1.2.4",
"event-listener",
"futures-core",
]
[[package]]
name = "async-executor"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b"
dependencies = [
"async-lock",
"async-task",
"concurrent-queue 2.0.0",
"fastrand",
"futures-lite",
"slab",
]
[[package]]
name = "async-io"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8121296a9f05be7f34aa4196b1747243b3b62e048bb7906f644f3fbfc490cf7"
dependencies = [
"async-lock",
"autocfg",
"concurrent-queue 1.2.4",
"futures-lite",
"libc",
"log",
"parking",
"polling",
"slab",
"socket2",
"waker-fn",
"winapi",
]
[[package]]
name = "async-lock"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685"
dependencies = [
"event-listener",
"futures-lite",
]
[[package]]
name = "async-recursion"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "async-task"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
[[package]]
name = "async-trait"
version = "0.1.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -151,10 +254,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bootloader"
version = "0.9.22"
name = "byteorder"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de78decc37247c7cfac5dbf3495c7298c6ac97cb355161caa7e15969c6648e6c"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "cache-padded"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "cc"
version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
[[package]]
name = "cfg-if"
@ -169,7 +284,7 @@ source = "git+https://git.ablecorp.us/able/core_utils#46a97f827bd11f3cea8dcab797
dependencies = [
"hashbrown",
"log",
"toml",
"toml 0.5.9 (git+https://git.ablecorp.us/theoddgarlic/toml-rs)",
]
[[package]]
@ -183,6 +298,24 @@ dependencies = [
"winapi",
]
[[package]]
name = "concurrent-queue"
version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c"
dependencies = [
"cache-padded",
]
[[package]]
name = "concurrent-queue"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "conquer-once"
version = "0.3.2"
@ -222,6 +355,37 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "dirs"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "downcast-rs"
version = "1.2.0"
@ -238,6 +402,33 @@ dependencies = [
"void",
]
[[package]]
name = "enumflags2"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb"
dependencies = [
"enumflags2_derive",
"serde",
]
[[package]]
name = "enumflags2_derive"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "event-listener"
version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
name = "ext2"
version = "0.1.1"
@ -263,6 +454,15 @@ dependencies = [
"log",
]
[[package]]
name = "fastrand"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
dependencies = [
"instant",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -275,6 +475,59 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e"
[[package]]
name = "futures-core"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac"
[[package]]
name = "futures-io"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb"
[[package]]
name = "futures-lite"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"memchr",
"parking",
"pin-project-lite",
"waker-fn",
]
[[package]]
name = "futures-sink"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9"
[[package]]
name = "futures-task"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea"
[[package]]
name = "futures-util"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6"
dependencies = [
"futures-core",
"futures-sink",
"futures-task",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]]
name = "genfs"
version = "0.1.4"
@ -310,6 +563,21 @@ dependencies = [
"libc",
]
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]]
name = "kernel"
version = "0.1.2"
@ -333,9 +601,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.126"
version = "0.2.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]]
name = "libm"
@ -348,6 +616,12 @@ name = "libwasm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/able/libwasm.git#4ffcd290f8bc918ca4adf5e23ce2097968e4a8b2"
[[package]]
name = "limine"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eac64618e505bab2387986e5b1014f5d344130d609685bbd8b71a10af3ee599d"
[[package]]
name = "linked_list_allocator"
version = "0.9.1"
@ -405,6 +679,21 @@ dependencies = [
"syn",
]
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memoffset"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]]
name = "memory_units"
version = "0.3.0"
@ -426,6 +715,19 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae"
[[package]]
name = "nix"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6"
dependencies = [
"bitflags",
"cc",
"cfg-if",
"libc",
"memoffset",
]
[[package]]
name = "num-integer"
version = "0.1.45"
@ -462,6 +764,16 @@ version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "ordered-stream"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44630c059eacfd6e08bdaa51b1db2ce33119caa4ddc1235e923109aa5f25ccb1"
dependencies = [
"futures-core",
"pin-project-lite",
]
[[package]]
name = "owned_ttf_parser"
version = "0.15.1"
@ -477,6 +789,35 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92"
[[package]]
name = "parking"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-sys",
]
[[package]]
name = "pc-beeper"
version = "0.1.0"
@ -506,6 +847,38 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6fc30519d2508c7e20e01da371cd27b1d4533fdb98e279955cb636b50210688"
[[package]]
name = "pin-project-lite"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "polling"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2"
dependencies = [
"autocfg",
"cfg-if",
"libc",
"log",
"wepoll-ffi",
"winapi",
]
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "pretty-hex"
version = "0.2.1"
@ -513,10 +886,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131"
[[package]]
name = "proc-macro2"
version = "1.0.43"
name = "proc-macro-crate"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9"
dependencies = [
"once_cell",
"thiserror",
"toml 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [
"unicode-ident",
]
@ -554,11 +938,35 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom",
]
[[package]]
name = "rdrand"
@ -569,17 +977,59 @@ dependencies = [
"rand_core",
]
[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"redox_syscall",
"thiserror",
]
[[package]]
name = "regex"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi",
]
[[package]]
name = "repbuild"
version = "0.1.0"
dependencies = [
"colored",
"udisks",
"zbus",
]
[[package]]
@ -675,6 +1125,32 @@ dependencies = [
"syn",
]
[[package]]
name = "serde_repr"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "sha1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
dependencies = [
"sha1_smol",
]
[[package]]
name = "sha1_smol"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
[[package]]
name = "slab"
version = "0.4.7"
@ -684,6 +1160,22 @@ dependencies = [
"autocfg",
]
[[package]]
name = "smallvec"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "socket2"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "spin"
version = "0.5.2"
@ -709,16 +1201,65 @@ dependencies = [
]
[[package]]
name = "syn"
version = "1.0.99"
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if",
"fastrand",
"libc",
"redox_syscall",
"remove_dir_all",
"winapi",
]
[[package]]
name = "thiserror"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "toml"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]
[[package]]
name = "toml"
version = "0.5.9"
@ -728,6 +1269,38 @@ dependencies = [
"serde",
]
[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
dependencies = [
"once_cell",
]
[[package]]
name = "ttf-parser"
version = "0.15.2"
@ -745,6 +1318,26 @@ dependencies = [
"x86_64",
]
[[package]]
name = "udisks"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55c5fe7da3b0a73f1c7c96cbb00e9684e93ee5b8141851bfeb0f073cfed39069"
dependencies = [
"serde",
"zbus",
]
[[package]]
name = "uds_windows"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d"
dependencies = [
"tempfile",
"winapi",
]
[[package]]
name = "unicode-ident"
version = "1.0.2"
@ -805,6 +1398,12 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3ca98349dda8a60ae74e04fd90c7fb4d6a4fbe01e6d3be095478aa0b76f6c0c"
[[package]]
name = "waker-fn"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@ -851,6 +1450,15 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d1a10e1dedffff9cfcbdd33c289c65b87da634259a460a3f23d513649fa7a8c"
[[package]]
name = "wepoll-ffi"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb"
dependencies = [
"cc",
]
[[package]]
name = "winapi"
version = "0.3.9"
@ -873,6 +1481,63 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
[[package]]
name = "x86_64"
version = "0.14.10"
@ -893,3 +1558,93 @@ dependencies = [
"rkyv",
"serde",
]
[[package]]
name = "zbus"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d8f1a037b2c4a67d9654dc7bdfa8ff2e80555bbefdd3c1833c1d1b27c963a6b"
dependencies = [
"async-broadcast",
"async-channel",
"async-executor",
"async-io",
"async-lock",
"async-recursion",
"async-task",
"async-trait",
"byteorder",
"derivative",
"dirs",
"enumflags2",
"event-listener",
"futures-core",
"futures-sink",
"futures-util",
"hex",
"lazy_static",
"nix",
"once_cell",
"ordered-stream",
"rand",
"serde",
"serde_repr",
"sha1",
"static_assertions",
"tracing",
"uds_windows",
"winapi",
"zbus_macros",
"zbus_names",
"zvariant",
]
[[package]]
name = "zbus_macros"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f8fb5186d1c87ae88cf234974c240671238b4a679158ad3b94ec465237349a6"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"regex",
"syn",
]
[[package]]
name = "zbus_names"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d69bb79b44e1901ed8b217e485d0f01991aec574479b68cb03415f142bc7ae67"
dependencies = [
"serde",
"static_assertions",
"zvariant",
]
[[package]]
name = "zvariant"
version = "3.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c817f416f05fcbc833902f1e6064b72b1778573978cfeac54731451ccc9e207"
dependencies = [
"byteorder",
"enumflags2",
"libc",
"serde",
"static_assertions",
"zvariant_derive",
]
[[package]]
name = "zvariant_derive"
version = "3.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdd24fffd02794a76eb10109de463444064c88f5adb9e9d1a78488adc332bfef"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]

View file

@ -8,7 +8,6 @@ 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"

View file

@ -8,52 +8,6 @@ version = "0.1.1"
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",
@ -154,7 +108,7 @@ git = "https://git.ablecorp.us:443/able/externc-libm.git"
riscv = "*"
[target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = { version = "0.9.8", features = ["map_physical_memory"] }
limine = "0.1"
cpuio = { git = "https://git.ablecorp.us/ondra05/cpuio.git" }
pic8259 = "0.10.1"
uart_16550 = "0.2.0"

View file

@ -1,16 +1,6 @@
[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
filter = ["ableos::ps2_mouse", "ableos::vterm", "ableos::devices::pci"]

View file

@ -11,5 +11,12 @@
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
"features": "-mmx,-sse,+soft-float",
"code-model": "kernel",
"pre-link-args": {
"ld.lld": [
"--gc-sections",
"--script=ableos/src/arch/x86_64/kernel.ld"
]
}
}

View file

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

View file

@ -1,6 +1,7 @@
// #![allow(clippy::print_literal)]
use super::{gdt, interrupts};
use crate::{logger, serial_println, TERM};
// use crate::{logger, serial_println, TERM};
use crate::{logger, serial_println};
/// x86_64 initialization
pub fn init() {
@ -17,15 +18,21 @@ pub fn init() {
Err(err) => serial_println!("{}", err),
}
let mut term = TERM.lock();
// term.initialize();
term.set_dirty(true);
term.draw_term();
drop(term);
trace!("gdt");
gdt::init();
trace!("idt");
interrupts::init_idt();
unsafe { interrupts::PICS.lock().initialize() };
// trace!("term");
// let term = &*TERM;
// trace!("term.lock()");
// let mut term = term.lock();
// term.initialize();
// term.set_dirty(true);
// term.draw_term();
// drop(term);
x86_64::instructions::interrupts::enable();
}

View file

@ -12,7 +12,10 @@ use pic8259::ChainedPics;
use qrcode::QrCode;
use seq_macro::seq;
use spin::Lazy;
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
use x86_64::{
registers::control::Cr2,
structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode},
};
use super::sloop;
@ -56,6 +59,7 @@ static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
});
idt.breakpoint.set_handler_fn(breakpoint_handler);
idt.page_fault.set_handler_fn(page_fault_handler);
unsafe {
idt.double_fault
.set_handler_fn(double_fault_handler)
@ -93,13 +97,23 @@ extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
trace!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
}
extern "x86-interrupt" fn page_fault_handler(
stack_frame: InterruptStackFrame,
error_code: PageFaultErrorCode,
) {
error!("EXCEPTION: PAGE FAULT {error_code:?}\n{:#?}", stack_frame);
trace!("CR2: {:x}", Cr2::read_raw());
trace!("SCREE");
loop {}
}
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);
// bsod(BSODSource::DoubleFault(&stack_frame));
panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
}
/* SAFETY

View file

@ -0,0 +1,48 @@
/* Tell the linker that we want an x86_64 ELF64 output file */
OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
/* We want the symbol `x86_64_start` to be our entry point */
ENTRY(x86_64_start)
/* Define the program headers we want so the bootloader gives us the right */
/* MMU permissions */
PHDRS
{
null PT_NULL FLAGS(0) ; /* Null segment */
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */
data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */
}
SECTIONS
{
/* We wanna be placed in the topmost 2GiB of the address space, for optimisations */
/* and because that is what the Limine spec mandates. */
/* Any address in this region will do, but often 0xffffffff80000000 is chosen as */
/* that is the beginning of the region. */
. = 0xffffffff80000000;
.text : {
*(.text .text.*)
} :text
/* Move to the next memory page for .rodata */
. += CONSTANT(MAXPAGESIZE);
.rodata : {
*(.rodata .rodata.*)
} :rodata
/* Move to the next memory page for .data */
. += CONSTANT(MAXPAGESIZE);
.data : {
*(.data .data.*)
} :data
.bss : {
*(COMMON)
*(.bss .bss.*)
} :data
}

View file

@ -1,7 +1,7 @@
use bootloader::bootinfo::{MemoryMap, MemoryRegionType};
use limine::{LimineMemmapResponse, LimineMemoryMapEntryType};
use x86_64::{
structures::paging::{
FrameAllocator, FrameDeallocator, Mapper, OffsetPageTable, Page, PageTable, PhysFrame,
FrameAllocator, FrameDeallocator, OffsetPageTable, PageTable, PhysFrame,
Size4KiB,
},
PhysAddr, VirtAddr,
@ -25,69 +25,13 @@ unsafe fn active_level_4_table(physical_memory_offset: VirtAddr) -> &'static mut
&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,
memory_map: &'static LimineMemmapResponse,
next: usize,
}
impl BootInfoFrameAllocator {
pub unsafe fn init(memory_map: &'static MemoryMap) -> Self {
pub unsafe fn init(memory_map: &'static LimineMemmapResponse) -> Self {
Self {
memory_map,
next: 0,
@ -95,11 +39,11 @@ impl BootInfoFrameAllocator {
}
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)))
self.memory_map.mmap().unwrap().iter()
.filter(|r| r.typ == LimineMemoryMapEntryType::Usable)
.map(|r| r.base..r.base + r.len)
.flat_map(|r| r.step_by(4096))
.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)))
}
}

View file

@ -10,27 +10,24 @@ pub mod init;
pub mod interrupts;
pub mod memory;
use crate::arch::drivers::allocator;
use bootloader::{entry_point, BootInfo};
use limine::*;
use x86_64::{instructions::hlt, VirtAddr};
#[cfg(not(test))]
entry_point![start];
use crate::serial_println;
use self::drivers::allocator;
static HHDM: LimineHhdmRequest = LimineHhdmRequest::new(0);
static MMAP: LimineMmapRequest = LimineMmapRequest::new(0);
#[cfg(not(test))]
#[no_mangle]
pub fn start(boot_info: &'static BootInfo) -> ! {
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
pub fn x86_64_start() -> ! {
let hhdm = HHDM.get_response().get().unwrap();
let mmap = MMAP.get_response().get().unwrap();
let phys_mem_offset = VirtAddr::new(hhdm.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) };
let mut frame_allocator = unsafe { memory::BootInfoFrameAllocator::init(mmap) };
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");

View file

@ -19,16 +19,22 @@ pub enum LogLevel {
#[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()
KernelConfig::default()
}
pub fn load_from_string(toml_string: &str) -> Self {
match toml::from_str(toml_string) {
Ok(kernel_conf) => kernel_conf,
Err(err) => {
error!("Error {}", err);
KernelConfig::new()
}
}
}
pub fn log_level(&self) -> LevelFilter {
use LevelFilter::*;
match self.logging.level {
@ -44,7 +50,15 @@ impl KernelConfig {
impl Default for KernelConfig {
fn default() -> Self {
Self::new()
Self {
logging: LoggingConfig {
enabled: true,
log_to_serial: true,
log_to_vterm: false,
level: LogLevel::Trace,
filter: Vec::new(),
},
}
}
}
@ -56,15 +70,3 @@ pub struct LoggingConfig {
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,4 +1,4 @@
use kernel::device_interface::CharacterDevice;
use crate::device_interface::CharacterDevice;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DevNull;

View file

@ -1,4 +1,4 @@
use kernel::device_interface::CharacterDevice;
use crate::device_interface::CharacterDevice;
#[derive(Debug)]
pub struct DevUnicode {

View file

@ -1,4 +1,4 @@
use kernel::device_interface::CharacterDevice;
use crate::device_interface::CharacterDevice;
#[derive(Debug)]
pub struct DevZero;

View file

@ -2,4 +2,4 @@ pub mod dev_null;
pub mod dev_unicode;
pub mod dev_zero;
pub use kernel::device_interface::CharacterDevice;
pub use crate::device_interface::CharacterDevice;

View file

@ -1,9 +1,9 @@
// ! A virtual terminal device.
use crate::device_interface::CharacterDevice;
use core::ops::Not;
use core::sync::atomic::AtomicU32;
use core::sync::atomic::Ordering;
use kernel::device_interface::CharacterDevice;
use crate::pixel_format::Rgba64;

View file

@ -6,10 +6,10 @@ pub mod pci;
pub use self::Device::*;
use crate::device_interface::{BlockDevice, CharacterDevice};
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>> =

View file

@ -1,4 +1,4 @@
use kernel::device_interface::CharacterDevice;
use crate::device_interface::CharacterDevice;
pub struct Serial {
pub base: usize,

View file

@ -0,0 +1,24 @@
// TODO: Reorganize and make part of this into a limine agnostic API for general purpose graphics
use crate::kmain::FRAMEBUFFER;
pub fn clear_screen() {
{
// TODO: setup a proper framebuffer handler
let fb_response = FRAMEBUFFER.get_response().get().unwrap();
for fb in fb_response.framebuffers().unwrap() {
trace!("Framebuffer {}x{}", fb.width, fb.height);
trace!("{}", fb.memory_model);
trace!("{}", fb.bpp);
let mut count = 0;
let total = fb.width * fb.height * 3;
while count != total {
unsafe {
let fb_ptr = fb.address.as_mut_ptr().unwrap();
*fb_ptr.offset((count).try_into().unwrap()) = 0x00;
*fb_ptr.offset((count + 1).try_into().unwrap()) = 0x00;
*fb_ptr.offset((count + 2).try_into().unwrap()) = 0x00;
}
count += 3;
}
}
}
}

View file

@ -103,9 +103,9 @@ fn on_complete(mouse_state: MouseState) {
mouse.change_y(delta_y);
x86_64::instructions::interrupts::without_interrupts(|| {
use crate::TERM;
let mut term = TERM.lock();
term.set_dirty(true);
// use crate::TERM;
// let mut term = TERM.lock();
// term.set_dirty(true);
});
// draw_mouse((mouse.get_x() as usize, mouse.get_y() as usize));

View file

@ -12,9 +12,13 @@ use crate::arch::memory::BootInfoFrameAllocator;
use crate::arch::{drivers::sysinfo::master, init, sloop};
use crate::devices::pci;
use crate::relib::network::socket::{SimpleSock, Socket};
use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE, TERM};
use crate::{filesystem, hardware};
use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE};
// use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE, TERM};
use crate::{filesystem, graphics_limine, hardware};
use kernel::KERNEL_VERSION;
use limine::LimineSmpInfo;
use limine::{LimineFramebufferRequest, LimineSmpRequest};
use spin::Lazy;
// FIXME: platform agnostic paging stuff
@ -22,6 +26,8 @@ use x86_64::structures::paging::{Mapper, Size4KiB};
// TODO: Change this structure to allow for multiple cores loaded
pub static KERNEL_CONF: Lazy<KernelConfig> = Lazy::new(KernelConfig::new);
pub static FRAMEBUFFER: LimineFramebufferRequest = LimineFramebufferRequest::new(0);
pub static SMP: LimineSmpRequest = LimineSmpRequest::new(0);
/// The main entry point of the kernel
pub fn kernel_main(
@ -30,14 +36,20 @@ pub fn kernel_main(
) -> ! {
init::init();
// /*
{
// TODO: Setup config loaded from disk
let mut kptr = KERNEL_CONF.as_mut_ptr();
unsafe {
*kptr = KernelConfig::new();
}
}
if KERNEL_CONF.logging.enabled {
log::set_max_level(KERNEL_CONF.log_level());
// println!("{:#?}", *KERNEL_CONF);
} else {
log::set_max_level(log::LevelFilter::Off);
}
// */
// let mut term = TERM.lock();
// term.initialize();
// term.set_dirty(true);
@ -82,46 +94,52 @@ pub fn kernel_main(
/*
log_version_data();
// */
{
// TODO: setup a proper framebuffer handler
let fb_response = FRAMEBUFFER.get_response().get().unwrap();
for fb in fb_response.framebuffers().unwrap() {
trace!("Framebuffer {}x{}", fb.width, fb.height);
trace!("{}", fb.memory_model);
trace!("{}", fb.bpp);
let mut count = 0;
let total = fb.width * fb.height * 3;
while count != total {
unsafe {
let fb_ptr = fb.address.as_mut_ptr().unwrap();
*fb_ptr.offset((count).try_into().unwrap()) = 0xff;
*fb_ptr.offset((count + 1).try_into().unwrap()) = 0xff;
*fb_ptr.offset((count + 2).try_into().unwrap()) = 0xff;
*fb_ptr.offset((count + 3).try_into().unwrap()) = 0x00;
*fb_ptr.offset((count + 4).try_into().unwrap()) = 0x00;
*fb_ptr.offset((count + 5).try_into().unwrap()) = 0x00;
// *fb_ptr.offset((count + 6).try_into().unwrap()) = 0x00;
}
count += 6;
}
}
}
// // SMP
// {
// let smp = SMP.get_response().get().unwrap();
// for cpu in smp.cpus().unwrap() {
// // unsafe {
// // cpu.goto_address = *(trace_hcf as *const u64);
// // }
// }
// }
graphics_limine::clear_screen();
scratchpad();
sloop()
}
pub fn traceloop() {
// TODO: Having an empty function double faults
// let mut last_time = 0.0;
/*
loop {
// FIXME: the following double faults
/*
let time = fetch_time();
if time > last_time {
last_time = time;
trace!("Timer");
}
*/
}
*/
/* TODO: This also double faults
let fs = &*crate::filesystem::FILE_SYSTEM.lock();
let path = format!("/home/able/bins/aos_test.wasm");
let home_exec_file = fs.open(&path.as_bytes(), OpenOptions::new().read(true));
drop(fs);
let mut binary_prog: Vec<u8> = vec![];
match home_exec_file {
Ok(file) => {
let ret = file.read_to_end(&mut binary_prog).unwrap();
}
_ => {}
}
wasm_jumploader::run_program(&binary_prog);
*/
extern "C" fn trace_hcf(info: *const LimineSmpInfo) -> ! {
trace!("CPU BOOT");
loop {}
}
pub fn cpu_socket_startup() {
@ -144,9 +162,9 @@ pub static TICK: AtomicU64 = AtomicU64::new(0);
pub fn tick() {
x86_64::instructions::interrupts::without_interrupts(|| {
let mut term = TERM.lock();
// let mut term = TERM.lock();
term.draw_term();
// term.draw_term();
use core::sync::atomic::Ordering::Relaxed;
let mut data = TICK.load(Relaxed);

View file

@ -57,6 +57,7 @@ pub mod print;
pub mod serial_print;
pub mod boot_conf;
pub mod device_interface;
pub mod devices;
pub mod driver_traits;
pub mod experiments;
@ -81,6 +82,7 @@ pub mod wasm_jumploader;
pub mod allocator;
// pub use allocator as aalloc;
pub mod graphics_limine;
pub mod handle;
pub mod hardware;
pub mod ipc;
@ -97,7 +99,6 @@ pub use driver_traits::*;
pub use experiments::*;
pub use graphics::*;
pub use kernel;
pub use kernel::messaging;
// pub use kernel::panic;
pub use kernel_state::*;
pub use keyboard::*;

View file

@ -23,7 +23,7 @@ impl core::fmt::Write for Stdout {
fn write_str(&mut self, s: &str) -> Result<(), Error> {
// use mini_backtrace::Backtrace;
use crate::TERM;
// use crate::TERM;
// Capture up to 16 frames. This is returned using an ArrayVec that doesn't
// perform any dynamic memory allocation.
@ -38,14 +38,15 @@ impl core::fmt::Write for Stdout {
}
*/
// trace!("printing");
trace!("printing");
trace!("PRINT: {}", s);
// x86_64::instructions::interrupts::without_interrupts(|| {
let mut term = TERM.lock();
// let mut term = TERM.lock();
term.set_dirty(true);
term.print(s);
// term.set_dirty(true);
// term.print(s);
drop(term);
// drop(term);
// });
// trace!("Finished printing");
Ok(())

View file

@ -43,26 +43,19 @@ impl acpi::AcpiHandler for AcpiStruct {
}
}
pub static TERM: Lazy<spin::Mutex<VTerm>> = Lazy::new(|| spin::Mutex::new(VTerm::new()));
// pub static TERM: Lazy<spin::Mutex<VTerm>> = Lazy::new(|| {
// trace!("mutex");
#[derive(Debug)]
pub struct Path {
pub path: Vec<String>,
}
impl Path {
pub fn new(path: String) -> Self {
let mut path_vec_string = vec![];
for part in path.split(&['\\', '/'][..]) {
path_vec_string.push(part.to_string());
}
Path {
path: path_vec_string,
}
}
}
// loop {}
// let mutex = spin::Mutex::new({
// trace!("vterm");
// let vterm = VTerm::new();
// trace!("vterm-done");
// vterm
// });
// trace!("mutex-done");
// mutex
// });
/// Experimental scratchpad for testing.
pub fn scratchpad() {
@ -133,7 +126,9 @@ pub fn scratchpad() {
let mut pci_ide_device = pci_ide_device.lock();
if let PciDevice::Ide(device) = &mut *pci_ide_device {
let mut first_sector = Vec::with_capacity(512);
device.read(Channel::Primary, Drive::Master, 0, 1, &mut first_sector).unwrap();
device
.read(Channel::Primary, Drive::Master, 0, 1, &mut first_sector)
.unwrap();
trace!("IDE Primary/Master sector 0: {first_sector:?}");
}
}
@ -212,88 +207,7 @@ pub fn real_shell() {
}
pub fn command_parser(user: String, command: String) {
let mut iter = command.split_whitespace();
let current_path = Path::new("/home/able".to_string());
trace!("Current path: {:?}", current_path);
let current_path = "/home/able/";
let bin_name = iter.next().unwrap();
let mut strin = String::new();
for stri in iter.clone() {
trace!("{}", stri);
strin.push_str(stri);
}
let conf_args;
match clparse::Arguments::parse_from_string(strin) {
Ok(ok) => conf_args = ok,
Err(err) => {
println!("ERROR: {}", err);
error!("{}", err);
return;
}
};
match bin_name {
// note: able asked for rhaish to stay in the repo but will be removed
// in the future so just comment it out for now
// "rhai" => {
// shell();
// }
"list" | "ls" => {
let mut vfs = VFS.lock();
let handle = vfs.resolve(current_path).unwrap();
let dir = vfs.fs_node(handle).unwrap();
drop(vfs);
for dir_entry in dir.directory().unwrap() {
println!("{}", dir_entry.name());
}
}
"echo" => match conf_args.1.arguments.get("p") {
Some(path) => echo_file(path.to_string()),
None => println!("No path provided"),
},
"test" => {}
"quit" => shutdown(),
"tree" => filesystem::tree("/").unwrap(),
_ => {
let file = {
let mut vfs = VFS.lock();
let path = format!("/home/{user}/bins/{bin_name}.wasm");
let handle = if let Ok(file) = vfs.resolve(path) {
file
} else {
let path = format!("/shared/bins/{bin_name}.wasm");
if let Ok(file) = vfs.resolve(path) {
file
} else {
let path = format!("/system/bins/{bin_name}.wasm");
match vfs.resolve(path) {
Ok(file) => file,
Err(error) => {
trace!("{:?}", error);
println!("No such binary: {}", bin_name);
error!("No such binary: {}", bin_name);
return;
}
}
}
};
vfs.fs_node(handle).unwrap()
};
let mut binary = vec![];
file.read(0, file.size(), &mut binary).unwrap();
let args = iter.collect::<Vec<&str>>();
println!("{:?}", args);
run_program(&binary);
}
}
unimplemented!()
}
pub fn sound(n_frequency: u32) {

View file

@ -1,7 +1,7 @@
use {
crate::device_interface::CharacterDevice,
crate::devices::Device::{Block, Character, Vterm},
core::fmt::{Arguments, Error, Write},
kernel::device_interface::CharacterDevice,
};
#[derive(Debug, Clone)]

View file

@ -66,5 +66,3 @@ pub fn test_kernel_main(boot_info: &'static BootInfo) -> ! {
loop {}
}
use bootloader::{entry_point, BootInfo};
use crate::test_main;

View file

@ -27,6 +27,7 @@ pub struct VTerm {
impl VTerm {
/// Construct a new VTerm
pub fn new() -> Self {
trace!("Setting vga mode");
let mode = VGAE.lock();
mode.set_mode();
// let fb = mode.get_frame_buffer();

4
base/README.md Normal file
View file

@ -0,0 +1,4 @@
# Base Root Filesystem
This is the base root filesystem for ableOS. It's used by tepbuild while
building the disk image.

7
base/boot/kernel.toml Normal file
View file

@ -0,0 +1,7 @@
[logging]
enabled = true
level = "Trace"
log_to_serial = true
log_to_vterm = false
filter = ["ableos::ps2_mouse", "ableos::vterm", "ableos::devices::pci"]

22
base/boot/limine.cfg Normal file
View file

@ -0,0 +1,22 @@
${ABLEOS_KERNEL}=boot:///boot/kernel
# TODO: Make a boot background image for ableOS
# ${WALLPAPER_PATH}=boot:///boot/bg.bmp
DEFAULT_ENTRY=1
TIMEOUT=3
VERBOSE=yes
INTERFACE_RESOLUTION=800x600
# Terminal related settings
# TERM_WALLPAPER=${WALLPAPER_PATH}
TERM_BACKDROP=008080
:ableOS
COMMENT=Default ableOS boot entry.
PROTOCOL=limine
KERNEL_PATH=${ABLEOS_KERNEL}
KERNEL_CMDLINE=
# Setting a default resolution for the framebuffer
RESOLUTION=800x600x24
MODULE_PATH=boot:///boot/initrd.tar
MODULE_CMDLINE=This is the first module.

BIN
base/home/able/bins/aos_test.wasm Executable file

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,252 @@
# 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-

14
base/home/able/layout.txt Normal file
View file

@ -0,0 +1,14 @@
boot/
├─ kernel.img
home/
├─ able/
│ ├─ bins/
│ ├─ config/
│ │ ├─ able_edit/
│ │ │ ├─ config.toml
│ ├─ irl_pic.png
│ ├─ password.txt
system/
├─ bins/
├─ configs/
│ ├─ kernel.toml

View file

@ -1,122 +0,0 @@
//! The allocator to be implemented by ableOS
//!
//! NOTE: All memory regions are taken from https://wiki.osdev.org/Memory_Map_(x86)
#![allow(missing_docs)]
use alloc::alloc::{GlobalAlloc, Layout};
use core::{fmt::Display, ptr::null_mut};
use log::{debug, info};
// const HEAP_START: usize = 600_000_000;
const HEAP_START: usize = 0x00100000;
const BLOCK_SIZE: usize = 1024;
const BLOCK_COUNT: usize = 512;
#[derive(Debug, Clone, Copy)]
pub struct MemoryRegion {
start: usize,
end: usize,
}
impl Display for MemoryRegion {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
writeln!(
f,
"MemoryRegion {{ start: {}, end: {}, size: {} bytes}}",
self.start,
self.end,
self.end - self.start
)
}
}
impl MemoryRegion {
pub fn new(start: usize, end: usize) -> MemoryRegion {
MemoryRegion { start, end }
}
pub fn test_region(&self) -> bool {
unsafe {
let mutptr = self.start as *mut u8;
core::ptr::write(mutptr, 0xFF);
// trace!("{}", core::ptr::read(mutptr));
}
true
}
}
#[derive(Debug, Clone, Copy)]
pub struct AAlloc {
current_region: usize,
memory_regions: [Option<MemoryRegion>; 512],
}
impl AAlloc {
fn test_regions(&self) {
for x in 0..self.current_region {
if let Some(region) = self.memory_regions[x] {
debug!("Region {}: {:?}", x, region);
}
}
}
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],
};
// BS MEMORY REGION
aalloc.add_region(MemoryRegion::new(HEAP_START, HEAP_START + 10));
aalloc.add_region(MemoryRegion::new(0x00007E00, 0x0007FFFF));
aalloc.add_region(MemoryRegion::new(0x00100000, 0x00EFFFFF));
// ISA Memory Hole
aalloc.add_region(MemoryRegion::new(0x00F00000, 0x00FFFFFF));
aalloc.add_region(MemoryRegion::new(0x0000000100000000, 0x0000000100000000));
aalloc.memory_regions[0].unwrap().test_region();
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 {}: {}", x, region)?;
}
}
write!(f, "}}")?;
Ok(())
}
}
unsafe impl GlobalAlloc for AAlloc {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
info!("Allocating memory");
info!("{}", _layout.size());
info!("{}", _layout.align());
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should be never called")
}
}

View file

@ -1,12 +0,0 @@
#![allow(missing_docs)]
pub mod aalloc;
pub use aalloc::*;
/*
#[alloc_error_handler]
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
panic!("allocation error: {:?}", layout)
}
*/

View file

@ -1,6 +1,7 @@
//! Memory allocator
use linked_list_allocator::LockedHeap;
use log::trace;
///
pub const HEAP_START: usize = 0x_4444_4444_0000;
@ -20,5 +21,7 @@ pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
#[alloc_error_handler]
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
panic!("allocation error: {:?}", layout)
trace!("allocation error: {:?}", layout);
loop {}
// panic!("allocation error: {:?}", layout)
}

View file

@ -0,0 +1 @@
//!

View file

@ -1,6 +1,16 @@
//! Architecture-specific code.
//! Architecture specific code
/// X86 specific code
#[cfg(target_arch = "x86_64")]
#[path = "x86_64/mod.rs"]
pub mod arch;
macro_rules! arch_cond {
($($arch:ident: $str:literal),* $(,)?) => {$(
#[cfg(target_arch = $str)]
pub mod $arch;
#[cfg(target_arch = $str)]
pub use $arch::*;
)*};
}
arch_cond!(
aarch64: "aarch64",
riscv64: "riscv64",
x86_64: "x86_64",
);

View file

@ -0,0 +1 @@
//!

View file

@ -1,9 +1 @@
///
pub fn sloop() {
loop {
unsafe {
core::arch::asm!("hlt");
}
}
}
//!

View file

@ -1,47 +1,20 @@
//! The ableOS kernel.
#![feature(alloc_error_handler)]
#![feature(arbitrary_enum_discriminant)]
#![feature(prelude_import)]
#![feature(alloc_error_handler, prelude_import)]
#![no_std]
#![deny(missing_docs)]
extern crate alloc;
pub mod aalloc;
pub mod allocator;
pub mod arch;
pub mod device_interface;
pub mod messaging;
// pub mod panic;
pub mod proccess;
pub mod syscalls;
pub mod task;
pub mod time;
use core::arch::asm;
use versioning::Version;
/// The number of ticks since the first CPU was started
// pub static TICK: AtomicU64 = AtomicU64::new(0);
/// Kernel's version
pub const KERNEL_VERSION: Version = Version {
major: 0,
minor: 1,
patch: 2,
};
/*
/// called by arch specific timers to tick up all kernel related functions
pub fn tick() {
let mut data = TICK.load(Relaxed);
data = data.wrapping_add(1);
TICK.store(data, Relaxed)
}
*/
/// Cause a software interrupt
pub fn software_int() {
unsafe { asm!("int 54") }
}

View file

@ -1,193 +0,0 @@
//! Interprocess communication.
use alloc::vec::Vec;
use crate::{proccess::PID, time::Time};
extern crate alloc;
/// 131070 * 128
pub const TINY_MESSAGE_COUNT: usize = 131070;
/// 16384 * 1024
pub const SMALL_MESSAGE_COUNT: usize = 16384;
/// 65536 * 256
pub const MEDIUM_MESSAGE_COUNT: usize = 256;
/// 262144 * 16
pub const LARGE_MESSAGE_COUNT: usize = 16;
/// 16777216 * 4
pub const HUGE_MESSAGE_COUNT: usize = 4;
/// 128 Bytes
pub type Tiny = [u8; 128];
/// 1 KiB
pub type Small = [u8; 1024];
/// 65.536 KiB
pub type Medium = [u8; 65536];
/// 1MiB
pub type Large = [u8; 1048576];
/// 16MiB
pub type Huge = [u8; 16777216];
/// An internal message to be held in a process message
pub enum Message {
/// A Tiny message
///
/// The message is 128 bytes long
Tiny(Tiny),
/// A Small message
///
/// The message is 1 KiB long
Small(Small),
/// A Medium message
///
/// The message is 65.536 KiB long
Medium(Medium),
/// A Large message
///
/// The message is 1 MiB long
Large(Large),
/// A Huge message
///
/// The message is 16 MiB long
Huge(Huge),
}
/// A message that can be sent between processes
pub struct ProcessMessage {
/// The sender of the message
pub to_pid: PID,
/// The receiver of the message
pub from_pid: PID,
/// The message
pub message: Message,
/// The time the message was sent
pub sender_time: Time,
/// The time the message was received
pub receiver_time: Time,
}
impl ProcessMessage {
/// Return the size of the message
pub fn size(&self) -> usize {
match &self.message {
Message::Tiny(_) => 128,
Message::Small(_) => 1024,
Message::Medium(_) => 65536,
Message::Large(_) => 1048576,
Message::Huge(_) => 16777216,
}
}
}
#[derive(Debug)]
/// An enum of all possible errors that can occur when sending a message
pub enum MessagingError {
/// The message is too large to be sent
MessageTooLarge,
/// The reciever of the message is not valid
ProcessNonExistant,
/// The message Queue is full
TooManyMessages,
}
/// A mailbox that holds messages and PipeState
pub struct Mailbox {
/// The messages in the mailbox
pub messages: Vec<ProcessMessage>,
/// The count of messages in the mailbox
pub message_count: MessageCount,
}
impl Mailbox {
/// append a message to the mailbox
pub fn append(&mut self, message: ProcessMessage) -> Result<(), MessagingError> {
let msg_size = message.size();
if self.message_count.total() > 147730 {
return Err(MessagingError::TooManyMessages);
}
match msg_size {
TINY_MESSAGE_COUNT => {
if self.message_count.tiny < TINY_MESSAGE_COUNT {
self.messages.push(message);
self.message_count.tiny += 1;
Ok(())
} else {
Err(MessagingError::TooManyMessages)
}
}
SMALL_MESSAGE_COUNT => {
if self.message_count.small < SMALL_MESSAGE_COUNT {
self.messages.push(message);
self.message_count.small += 1;
Ok(())
} else {
Err(MessagingError::TooManyMessages)
}
}
MEDIUM_MESSAGE_COUNT => {
if self.message_count.medium < MEDIUM_MESSAGE_COUNT {
self.messages.push(message);
self.message_count.medium += 1;
Ok(())
} else {
Err(MessagingError::TooManyMessages)
}
}
LARGE_MESSAGE_COUNT => {
if self.message_count.large < LARGE_MESSAGE_COUNT {
self.messages.push(message);
self.message_count.large += 1;
Ok(())
} else {
Err(MessagingError::TooManyMessages)
}
}
HUGE_MESSAGE_COUNT => {
if self.message_count.huge < HUGE_MESSAGE_COUNT {
self.messages.push(message);
self.message_count.huge += 1;
Ok(())
} else {
return Err(MessagingError::TooManyMessages);
}
}
_ => Err(MessagingError::MessageTooLarge),
}
}
}
/// A proper struct to list the number of messages in the mailbox
pub struct MessageCount {
/// The number of tiny messages in the mailbox
pub tiny: usize,
/// The number of small messages in the mailbox
pub small: usize,
/// The number of medium messages in the mailbox
pub medium: usize,
/// The number of large messages in the mailbox
pub large: usize,
/// The number of huge messages in the mailbox
pub huge: usize,
}
impl MessageCount {
/// Return the total number of messages in the mailbox
pub fn total(&self) -> usize {
self.tiny + self.small + self.medium + self.large + self.huge
}
}
impl Default for MessageCount {
fn default() -> Self {
MessageCount {
tiny: 0,
small: 0,
medium: 0,
large: 0,
huge: 0,
}
}
}

View file

@ -1,11 +0,0 @@
//! Panic-related stuff
use core::panic::PanicInfo;
use log::error;
#[panic_handler]
fn panic_handler(info: &PanicInfo) -> ! {
error!("{}", info);
loop {}
}

View file

@ -1,14 +0,0 @@
//! Platform agnostic process
/// A process ID
pub type PID = u64;
/// Signals that can be sent to a process
#[repr(C)]
pub enum Signals {
/// Terminate the process
Terminate,
/// Shutdown the process and allow it to shutdown cleanly
Quit,
}

View file

@ -1,26 +0,0 @@
//!
use crate::proccess::{Signals, PID};
/// All possible system calls
pub enum Syscall {
/// Create a new process and return its PID
CreateProcess,
/// Send a signal to a process
SendSignal(PID, Signals),
/// Get the current process ID
GetPID,
/// Get the current time
GetTime,
/// Set the time
SetTime,
// ListInodes,
// CreateInode,
// RemoveInode,
// OpenInode,
// CloseInode,
}

View file

@ -87,16 +87,16 @@ impl Executor {
.map(|t| TaskId(self.tasks.insert(t)))
.or_else(|| self.queue.pop())
{
let task = match self.tasks.get_mut(id.0) {
Some(t) => t,
None => panic!("attempted to get non-extant task with id {}", id.0),
let Some(task) = self.tasks.get_mut(id.0) else {
panic!("attempted to get non-extant task with id {}", id.0)
};
let mut cx = Context::from_waker(
self.wakers
.entry(id)
.or_insert_with(|| TaskWaker::new(id, Arc::clone(&self.queue))),
);
let mut cx = Context::from_waker(self.wakers.entry(id).or_insert_with(|| {
Waker::from(Arc::new(TaskWaker {
id,
queue: Arc::clone(&self.queue),
}))
}));
match task.poll(&mut cx) {
Poll::Ready(()) => {
@ -138,12 +138,6 @@ struct TaskWaker {
queue: TaskQueue,
}
impl TaskWaker {
fn new(id: TaskId, queue: TaskQueue) -> Waker {
Waker::from(Arc::new(Self { id, queue }))
}
}
impl Wake for TaskWaker {
fn wake(self: Arc<Self>) {
self.wake_by_ref();

View file

@ -1,10 +0,0 @@
//! Time
/// An internal structure that is used to keep track of the time
pub struct Time {
/// The number of seconds since the kernel was started
pub seconds: u64,
/// The number of nanoseconds since the kernel was started
pub nanoseconds: u32,
}

View file

@ -7,3 +7,5 @@ edition = "2021"
[dependencies]
colored = "2.0"
udisks = "0.1"
zbus = "2.3"

View file

@ -5,9 +5,16 @@
* SPDX-License-Identifier: MPL-2.0
*/
use std::{fs, process::Command};
use colored::*;
use std::{
fs::{self, File},
os::fd::AsRawFd,
process::Command,
};
use udisks::{
filesystem::{MountOptions, UnMountOptions},
manager::LoopSetupOptions,
};
struct Options {
pub subcommand: Subcommand,
@ -15,6 +22,7 @@ struct Options {
}
enum Subcommand {
BuildImage,
Doc,
Help,
Run,
@ -27,6 +35,7 @@ enum Subcommand {
impl Subcommand {
fn from_str<S: AsRef<str>>(str: S) -> Subcommand {
match str.as_ref() {
"build-image" => Subcommand::BuildImage,
"doc" => Subcommand::Doc,
"help" => Subcommand::Help,
"run" | "r" => Subcommand::Run,
@ -44,10 +53,152 @@ enum MachineType {
Unknown(String),
}
fn main() {
fn main() -> Result<(), Box<dyn std::error::Error>> {
let options = options();
match options.subcommand {
Subcommand::BuildImage => {
let machine_text = options.arguments.get(0).cloned().unwrap_or_default();
match machine(machine_text) {
MachineType::X86_64 => {
// Cleanup
// NOTE: we are not unwrapping these, as we don't want this to fail if they
// don't exist yet, probably not the best idea tho.
// FIXME: figure out a better way to ignore errors about these not existing
#[allow(unused_must_use)]
{
fs::remove_dir_all("./limine");
fs::remove_dir_all("./disk");
fs::remove_file("./disk.img");
}
// Build ableOS in release mode
Command::new("cargo")
.args(["build", "--release"])
.current_dir(fs::canonicalize("./ableos").unwrap())
.status()
.unwrap();
// Create disk directory
fs::create_dir("./disk").unwrap();
// Clone limine 3.X binaries
Command::new("git")
.arg("clone")
.arg("https://github.com/limine-bootloader/limine.git")
.arg("--branch=v3.0-branch-binary")
.arg("--depth=1")
.status()
.unwrap();
println!("{}", "Building limine".bold());
Command::new("make")
.args(["-C", "limine"])
.status()
.unwrap();
println!("{}", "Allocating new disk image".bold());
Command::new("fallocate")
.args(["-l", "256M", "disk.img"])
.status()
.unwrap();
println!("{}", "Partitioning disk image".bold());
let dbus_conn = zbus::blocking::Connection::system()?;
// Setup loop device
let disk_img = File::options().read(true).write(true).open("disk.img")?;
let loopdev = udisks::manager::UDisks2ManagerProxyBlocking::new(&dbus_conn)?
.loop_setup(
disk_img.as_raw_fd().into(),
LoopSetupOptions {
no_user_interaction: true,
offset: 0,
size: 0,
readonly: false,
no_part_scan: false,
},
)?;
// Create MBR
udisks::block::BlockProxyBlocking::builder(&dbus_conn)
.path(&loopdev)?
.build()?
.format("dos", Default::default())?;
// Create and format partition
let filesystem =
udisks::partition::PartitionTableProxyBlocking::builder(&dbus_conn)
.destination("org.freedesktop.UDisks2")?
.path(&loopdev)?
.build()?
.create_partition_and_format(
0,
0,
"",
"",
Default::default(),
"ext2",
[("take-ownership", true.into())].into_iter().collect(),
)?;
let fsproxy = udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn)
.path(&filesystem)?
.build()?;
// Obtain mountpoint
let mountpoint = loop {
if let Some(m) = fsproxy.mount_points()?.get(0) {
break m.to_string();
}
};
// copy ./base/* over to ./disk
Command::new("sh")
.arg("-c")
.arg(format!("cp -r ./base/* {mountpoint}"))
.status()?;
// copy ./limine/limine.sys over to ./disk/boot
Command::new("cp")
.args(["./limine/limine.sys", &format!("{mountpoint}/boot")])
.status()?;
// copy the kernel over to ./disk/boot/kernel
Command::new("cp")
.arg("./target/x86_64-ableos/release/ableos")
.arg(&format!("{mountpoint}/boot/kernel"))
.status()?;
// Unmount the filesystem (and the rest of things will follow)
fsproxy.unmount(UnMountOptions {
no_user_interaction: true,
force: false,
})?;
println!("{}", "Deploying limine".bold());
Command::new("./limine/limine-deploy")
.arg("./disk.img")
.status()
.unwrap();
}
MachineType::Unknown(unknown) => {
eprintln!(
"{}: unknown machine type `{}`",
"error".red().bold(),
unknown.bold(),
);
eprintln!("expected one of x86_64, riscv64 or aarch64");
}
_ => {
eprintln!(
"{}: build-image not implemented for this machine type",
"error".red().bold(),
);
}
}
}
Subcommand::Test => {
Command::new("cargo")
.args(["test", "--target=json_targets/x86_64-ableos.json"])
@ -100,18 +251,157 @@ fn main() {
match machine(machine_text) {
MachineType::X86_64 if debug => {
// Build ableOS
Command::new("cargo")
.args(["run", "--", "-S", "-gdb", "tcp:9000"])
.arg("build")
.current_dir(fs::canonicalize("./ableos").unwrap())
.status()
.unwrap();
// Setup loopback device for disk.img, with partitions
// FIXME: don't do ths if running without changes
// Setup loop device
let disk_img = File::options().read(true).write(true).open("disk.img")?;
let dbus_conn = zbus::blocking::Connection::system()?;
let loopdev = udisks::manager::UDisks2ManagerProxyBlocking::new(&dbus_conn)?
.loop_setup(
disk_img.as_raw_fd().into(),
LoopSetupOptions {
no_user_interaction: true,
offset: 0,
size: 0,
readonly: false,
no_part_scan: false,
},
)?;
let parts = udisks::partition::PartitionTableProxyBlocking::builder(&dbus_conn)
.destination("org.freedesktop.UDisks2")?
.path(loopdev)?
.build()?
.partitions()?;
let fsobjpath = parts.get(0).ok_or("missing boot partition")?;
let mountpoint =
udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn)
.path(fsobjpath)?
.build()?
.mount(MountOptions {
no_user_interaction: true,
fs_type: String::new(),
mount_options: String::new(),
})?;
// copy the kernel over to ./disk/boot/kernel
Command::new("cp")
.arg("./target/x86_64-ableos/debug/ableos")
.arg(format!("{mountpoint}/boot/kernel"))
.status()
.unwrap();
udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn)
.path(fsobjpath)?
.build()?
.unmount(UnMountOptions {
no_user_interaction: true,
force: false,
})?;
// run qemu with "-S", "-gdb", "tcp:9000"
Command::new("qemu-system-x86_64")
.args(["-device", "piix4-ide,id=ide"])
.arg("-drive")
.arg("file=./disk.img,format=raw,if=none,id=disk")
.args(["-device", "ide-hd,drive=disk,bus=ide.0"])
// .arg("--nodefaults")
.args(["-cpu", "Broadwell-v3"])
.args(["-m", "4G"])
.args(["-serial", "stdio"])
.args(["-smp", "cores=2"])
// .args(["-soundhw", "pcspk"])
// .args(["-device", "VGA"])
// .args(["-device", "virtio-gpu-pci"])
.args(["-device", "vmware-svga"])
.args(["-device", "sb16"])
// .args(["-machine", "pcspk-audiodev=0"])
// .args(["-qmp", "unix:../qmp-sock,server,nowait"])
.args(["-S", "-gdb", "tcp:9000"])
.status()
.unwrap();
}
MachineType::X86_64 => {
// Build ableOS
Command::new("cargo")
.args(["run", "--release"])
.args(["build", "--release"])
.current_dir(fs::canonicalize("./ableos").unwrap())
.status()
.unwrap();
// Setup loopback device for disk.img, with partitions
// FIXME: don't do ths if running without changes
let disk_img = File::options().read(true).write(true).open("disk.img")?;
let dbus_conn = zbus::blocking::Connection::system()?;
let loopdev = udisks::manager::UDisks2ManagerProxyBlocking::new(&dbus_conn)?
.loop_setup(
disk_img.as_raw_fd().into(),
LoopSetupOptions {
no_user_interaction: true,
offset: 0,
size: 0,
readonly: false,
no_part_scan: false,
},
)?;
let parts = udisks::partition::PartitionTableProxyBlocking::builder(&dbus_conn)
.destination("org.freedesktop.UDisks2")?
.path(loopdev)?
.build()?
.partitions()?;
let fsproxy = udisks::filesystem::FilesystemProxyBlocking::builder(&dbus_conn)
.path(&parts[0])?
.build()?;
// Obtain mountpoint
let mountpoint = loop {
if let Some(m) = fsproxy.mount_points()?.get(0) {
break m.to_string();
}
};
// copy the kernel over to ./disk/boot/kernel
Command::new("cp")
.arg("./target/x86_64-ableos/release/ableos")
.arg(format!("{mountpoint}/boot/kernel"))
.status()
.unwrap();
fsproxy.unmount(UnMountOptions {
no_user_interaction: true,
force: false,
})?;
// run qemu
Command::new("qemu-system-x86_64")
.args(["-device", "piix4-ide,id=ide"])
.arg("-drive")
.arg("file=./disk.img,format=raw,if=none,id=disk")
.args(["-device", "ide-hd,drive=disk,bus=ide.0"])
// .arg("--nodefaults")
.args(["-cpu", "Broadwell-v3"])
.args(["-m", "4G"])
.args(["-serial", "stdio"])
.args(["-smp", "cores=2"])
// .args(["-soundhw", "pcspk"])
// .args(["-device", "VGA"])
// .args(["-device", "virtio-gpu-pci"])
.args(["-device", "vmware-svga"])
.args(["-device", "sb16"])
// .args(["-machine", "pcspk-audiodev=0"])
// .args(["-qmp", "unix:../qmp-sock,server,nowait"])
.status()
.unwrap();
}
MachineType::RiscV64 if debug => {
eprintln!(
@ -189,6 +479,8 @@ fn main() {
help();
}
}
Ok(())
}
fn options() -> Options {