Compare commits

..

20 Commits

Author SHA1 Message Date
ondra05 415756bc3e Skeleton for architecture-specific things 2022-12-06 23:04:28 +01:00
ondra05 a398498352 Threw stuff from the microkernel. Start of moving core parts there. 2022-12-06 23:04:26 +01:00
ondra05 9152dbb57f clippy 2022-12-06 23:04:11 +01:00
ondra05 1c41494cc9 removed module that I forgot to remove + 1.65 stuff 2022-12-06 23:04:09 +01:00
ondra05 60a38212c0 removed sus messaging module 2022-12-06 23:04:04 +01:00
ondra05 67a3b89234 »fixed« scratchpad 2022-12-06 22:39:52 +01:00
Able 8847bfa5c6
remove path 2022-12-06 13:24:04 -06:00
ondra05 76e2bd286b repbuild r uses udisks 2022-12-03 17:47:10 +01:00
Able edbdf9456f
Consolidating limine graphics 2022-12-02 08:51:21 -06:00
Able 9b243410ab
forgor smp is broked 2022-11-30 01:14:34 -06:00
Able 5cb1ef8d65 framebuffer + smp work 2022-11-24 07:20:16 -06:00
Able b2ab5219f5 Ready 2022-11-24 03:35:55 -06:00
ondra05 2ddbb320c4 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 0917c0cb02
Revert "get ableOS running proper on limine sans graphics"
This reverts commit 5ea2794aa2.
2022-11-23 06:00:38 -06:00
Able 5ea2794aa2
get ableOS running proper on limine sans graphics 2022-11-23 05:06:38 -06:00
Able af2610c0b0
limine compiling booting and not panicking 2022-11-23 04:02:02 -06:00
TheOddGarlic 1e873874cf progress on porting to limine 2022-08-20 09:28:48 +03:00
TheOddGarlic 13c41340d0 interrupts: page fault handler 2022-08-20 09:26:59 +03:00
TheOddGarlic 6c2fea9dff repbuild: generate disk image with limine 2022-08-19 09:22:05 +03:00
TheOddGarlic f5088d0bd1 build: fix rust-toolchain configuration 2022-08-18 09:32:14 +03:00
38 changed files with 1717 additions and 504 deletions

6
.gitignore vendored
View File

@ -1,8 +1,8 @@
userland/root_fs/mnt/
target/
limine/
.disk.img
.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,45 +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",
"-audiodev", "id=pa,driver=pa",
"-machine", "pcspk-audiodev=pa",
# "-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",
@ -147,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,17 +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", "ableos::filesystem::vfs"]
# Exact paths required
[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

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
@ -256,7 +270,7 @@ pub fn bsod(src: BSODSource) -> ! {
let image = code
.render::<char>()
.quiet_zone(false)
.module_dimensions(1, 1)
.module_dimensions(2, 1)
.build();
println!("{}", image);

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

@ -184,61 +184,56 @@ impl Display for PciFullClass {
write!(f, " Class: ")?;
match self {
PciFullClass::Unclassified_NonVgaCompatible => write!(f, "\u{001A}LIGHTBLUE\u{001A}")?,
PciFullClass::Unclassified_VgaCompatible => write!(f, "\u{001A}LIGHTBLUE\u{001A}")?,
PciFullClass::MassStorage_ScsiBus => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_IDE => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_Floppy => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_IpiBus => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_RAID => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_ATA => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_SATA => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_SerialSCSI => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_NVM => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::MassStorage_Other => write!(f, "\u{001A}CYAN\u{001A}")?,
PciFullClass::Network_Ethernet => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_TokenRing => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_FDDI => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_ATM => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_ISDN => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_WorldFlip => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_PICMG => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_Infiniband => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_Fabric => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Network_Other => write!(f, "\u{001A}MAGENTA\u{001A}")?,
PciFullClass::Display_VGA => write!(f, "\u{001A}YELLOW\u{001A}")?,
PciFullClass::Display_XGA => write!(f, "\u{001A}YELLOW\u{001A}")?,
PciFullClass::Display_3D => write!(f, "\u{001A}YELLOW\u{001A}")?,
PciFullClass::Display_Other => write!(f, "\u{001A}YELLOW\u{001A}")?,
PciFullClass::Multimedia_Video => write!(f, "\u{001A}LIGHTBLUE\u{001A}")?,
PciFullClass::Multimedia_AudioController => write!(f, "\u{001A}LIGHTBLUE\u{001A}")?,
PciFullClass::Multimedia_Telephony => write!(f, "\u{001A}LIGHTBLUE\u{001A}")?,
PciFullClass::Multimedia_AudioDevice => write!(f, "\u{001A}LIGHTBLUE\u{001A}")?,
PciFullClass::Multimedia_Other => write!(f, "\u{001A}LIGHTBLUE\u{001A}")?,
PciFullClass::Memory_RAM => write!(f, "\u{001A}BLUE\u{001A}")?,
PciFullClass::Memory_Flash => write!(f, "\u{001A}WHITE\u{001A}")?,
PciFullClass::Memory_Other => write!(f, "\u{001A}LIGHTGREY\u{001A}")?,
PciFullClass::Bridge_Host => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_ISA => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_EISA => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_MCA => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_PciToPci => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_PCMCIA => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_NuBus => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_CardBus => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_RACEway => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_PciToPciSemiTransparent => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_InfinibandToPci => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Bridge_Other => write!(f, "\u{001A}GREEN\u{001A}")?,
PciFullClass::Unknown => write!(f, "\u{001A}RED\u{001A}")?,
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})\u{001A}RESET\u{001A}",
self,
self.as_u16()
)?;
write!(f, "{:?} ({:#06X})\0RESET\0", self, self.as_u16())?;
Ok(())
}

View File

@ -84,7 +84,7 @@ const CMD_READ_DMA_EXT: u8 = 0x25;
/// ATA write using LBA48 DMA command
const CMD_WRITE_DMA_EXT: u8 = 0x35;
#[derive(Debug)]
pub struct PciIde {
device_info: PciDeviceInfo,
ide_devices: Vec<IdeDevice>,
@ -629,7 +629,6 @@ unsafe fn read_dword_buffer(port: u16, buffer: *mut u32, mut count: u32) {
});
}
#[derive(Debug)]
struct IdeDevice {
pub channel: Channel,
pub drive: Drive,

View File

@ -28,7 +28,6 @@ lazy_static! {
}
#[non_exhaustive]
#[derive(Debug)]
pub enum PciDevice {
Ide(PciIde),
// Variant so that we aren't about irrefutable if-let patterns
@ -42,7 +41,6 @@ pub fn init(mapper: &mut impl Mapper<Size4KiB>, frame_allocator: &mut BootInfoFr
for device in 0..32 {
if let Some(device_info) = device::check_device(bus, device) {
trace!("{device_info}");
println!("{device_info}");
match device_info.device_id {
// FIXME: Unknown class
S3_TRIO64V2 => {}

View File

@ -164,17 +164,17 @@ impl Display for Vendor {
use Vendor::*;
match self {
Qemu => write!(f, "{}", "\u{001A}PINK\u{001A}QEMU (0x1234)"),
VirtIO => write!(f, "{}", "\u{001A}PINK\u{001A}VirtIO (0x1AF4)"),
VMWareInc => write!(f, "{}", "\u{001A}PINK\u{001A}VMWARE (0x15AD)"),
S3Inc => write!(f, "{}", "\u{001A}YELLOW\u{001A}S3 Incorporated (0x5333)"),
IntelCorp => write!(f, "{}", "\u{001A}BLUE\u{001A}Intel Corp. (0x8086)"),
ATITechnologiesInc => write!(f, "{}", "\u{001A}RED\u{001A}ATI (0x1002)"),
Unknown(id) => write!(f, "\u{001A}RED\u{001A}Unknown ({:#6})", id),
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, "\u{001A}RESET\u{001A}")?;
write!(f, "\0RESET\0")?;
Ok(())
}
}

View File

@ -4,8 +4,6 @@
* SPDX-License-Identifier: MPL-2.0
*/
use core::fmt::Display;
#[derive(Copy, Clone, Debug)]
pub enum FsError {
EndOfFile,
@ -19,11 +17,6 @@ pub enum FsError {
Recursion,
UnsupportedOperation,
}
impl Display for FsError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:?}", self)
}
}
impl Into<FsError> for ext2::error::Error {
fn into(self) -> FsError {

View File

@ -51,26 +51,23 @@ impl VirtualFileSystem {
if !path.starts_with('/') {
// FIXME: use current process working directory for relative paths?
error!("Nonabsolute path {}", path);
Err(FsError::NotAbsolute)?;
}
trace!("Splitting path up");
let mut components = path.split_terminator('/');
components.next(); // throw the empty string caused by the root /
// will be initialised beforehand so okay to unwrap
let mut resolved_node = self.root_handle.unwrap();
// let mut symlink_recursion_level = 0;
for component in components {
trace!("iterating through split up path");
// if symlink_recursion_level >= SYMLINK_RECURSION_LIMIT {
// Err(FsError::Recursion)?;
// }
if component == "" {
error!("Invalid Path {}", path);
Err(FsError::InvalidPath)?;
}
trace!("Getting parent of file");
// checked by previous iteration so okay to unwrap
let parent = self.fs_node(resolved_node).unwrap();
@ -80,18 +77,16 @@ impl VirtualFileSystem {
// that's just more boilerplate in StorageDevice impls
// we should probably check that here instead to reduce
// required boilerplate
if !parent.is_dir() {
error!("file parent {:?} is not a directory", parent);
Err(FsError::NotADirectory)?;
}
// if !parent.is_dir() {
// Err(FsError::NotADirectory)?;
// }
// FIXME: handle mount points
// FIXME: handle symlinks
trace!("resolving node");
resolved_node = parent.find_dir(self, component)?;
}
trace!("returning resolved node");
Ok(resolved_node)
}
@ -112,7 +107,6 @@ impl VirtualFileSystem {
}
pub fn fs_node(&self, handle: Handle) -> Option<Arc<FsNode>> {
trace!("Cloning file node and returning");
self.fs_nodes.get(&handle).cloned()
}
@ -218,16 +212,12 @@ impl FsNode {
}
pub fn find_dir(&self, vfs: &mut VirtualFileSystem, name: &str) -> Result<Handle> {
trace!("Locking the kernel state");
let state = KERNEL_STATE.lock();
trace!("Grabbing storage device");
let device = state
.storage_device(self.device_handle)
.ok_or_else(|| FsError::InvalidDevice)?;
trace!("locating directory");
let ret = device.find_dir(vfs, self, name);
trace!("returning directory");
ret
device.find_dir(vfs, self, name)
}
pub fn directory(self: Arc<Self>) -> Option<Directory> {

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

@ -14,12 +14,12 @@
#![feature(
abi_x86_interrupt,
alloc_error_handler,
arbitrary_enum_discriminant,
asm_sym, // Needed for RISC-V
custom_test_frameworks,
naked_functions,
prelude_import,
)]
#![feature(arbitrary_enum_discriminant)]
#![feature(custom_test_frameworks)]
#![reexport_test_harness_main = "test_main"]
#![test_runner(crate::test_runner)]
@ -82,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;

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() {
@ -87,10 +80,10 @@ pub fn scratchpad() {
println!(
"{}
,-------. OS: \u{001A}BLUE\u{001A}AbleOS\u{001A}RESET\u{001A}
,'\\ _ _`. Host: \u{001A}PINK\u{001A}{}\u{001A}RESET\u{001A}
/ \\)_)-)_)-\\ Kernel: \u{001A}RED\u{001A}AKern-{}-v{}\u{001A}RESET\u{001A}
: : Uptime: \u{001A}GREEN\u{001A}{}\u{001A}RESET\u{001A}
,-------. OS: \0BLUE\0AbleOS\0RESET\0
,'\\ _ _`. Host: \0PINK\0{}\0RESET\0
/ \\)_)-)_)-\\ Kernel: \0RED\0AKern-{}-v{}\0RESET\0
: : Uptime: \0GREEN\0{}\0RESET\0
\\ / Packages: None
\\ / Shell: BuiltinShell
`. ,' Resolution: 640x480
@ -120,8 +113,7 @@ pub fn scratchpad() {
.iter()
.find_map(|device_ref| {
let device = device_ref.lock();
if let PciDevice::Ide(dev) = &*device {
println!("IDE Device found: {}", dev.device_info());
if let PciDevice::Ide(_) = &*device {
Some(device_ref.clone())
} else {
None
@ -137,7 +129,7 @@ pub fn scratchpad() {
device
.read(Channel::Primary, Drive::Master, 0, 1, &mut first_sector)
.unwrap();
// trace!("IDE Primary/Master sector 0: {first_sector:?}");
trace!("IDE Primary/Master sector 0: {first_sector:?}");
}
}
@ -215,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) {
@ -326,53 +237,18 @@ pub fn sound_off() {
}
pub fn echo_file(path: String) {
println!("{}", path);
let mut current_path = String::from("");
let mut current_path = String::from("/");
current_path.push_str(&path);
debug!("Aquiring lock");
let mut vfs = VFS.lock();
debug!("Resolving path");
let maybe_handle = vfs.resolve(&current_path);
match maybe_handle {
Ok(handle) => {
debug!("Loading file");
let maybe_file = vfs.fs_node(handle);
let handle = vfs.resolve(&current_path).unwrap();
let file = vfs.fs_node(handle).unwrap();
match maybe_file {
Some(file) => {
trace!("checking is directory");
if file.is_dir() {
println!(
"\u{001A}RED\u{001A}ERROR\u{001A}RESET\u{001A} {} is a directory",
path
);
error!("{} is a directory", path);
} else {
trace!("allocating buffer for file contents");
let mut file_contents = Vec::new();
trace!("Reading file {} into buffer", path);
file.read(0, file.size(), &mut file_contents).unwrap();
trace!("Converting file bytes into string");
let file_contents_str = String::from_utf8_lossy(&file_contents);
println!("{}", file_contents_str);
}
}
None => {
error!("File {} doesn't exist", path);
println!(
"\u{001A}RED\u{001A}ERROR\u{001A}RESET\u{001A}: File {} doesn't exist",
path
);
}
}
}
Err(err) => {
println!(
"\u{001A}RED\u{001A}ERROR\u{001A}RESET\u{001A}: path {} Error {}",
path, err
);
error!("path {} Error {}", path, err);
}
if file.is_dir() {
// println!("{} is a directory", path);
} else {
let mut file_contents = Vec::new();
file.read(0, file.size(), &mut file_contents).unwrap();
let file_contents_str = String::from_utf8_lossy(&file_contents);
println!("{}", file_contents_str);
}
}

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();
@ -36,7 +37,7 @@ impl VTerm {
dirty: false,
x: 0,
back_buffer: [0; 640 * 480],
term: [('\u{001A}', Color16::DarkGrey); 80 * 60],
term: [('\0', Color16::DarkGrey); 80 * 60],
color: Color16::White,
}
}
@ -88,7 +89,7 @@ impl VTerm {
}
// trace!("C");
match c {
'\u{001A}' => {
'\0' => {
self.term[TERM_MINUS_ONE_LINE + (self.x as usize)] =
(c, self.color);
self.x += 1;
@ -101,7 +102,7 @@ impl VTerm {
}
self.x -= 1;
self.term[TERM_MINUS_ONE_LINE + (self.x as usize)] =
('\u{001A}', Color16::LightGrey);
('\0', Color16::LightGrey);
}
'\n' => {
self.move_up();
@ -124,7 +125,7 @@ impl VTerm {
pub fn move_up(&mut self) {
self.term.rotate_left(80);
for x in 0..80 {
self.term[TERM_MINUS_ONE_LINE + x] = ('\u{001A}', Color16::DarkGrey);
self.term[TERM_MINUS_ONE_LINE + x] = ('\0', Color16::DarkGrey);
}
self.x = 0;
}
@ -211,40 +212,40 @@ enum Token {
#[error]
Error,
#[token("\u{001A}RESET\u{001A}", priority = 10)]
#[token("\0RESET\0", priority = 10)]
Reset,
#[token("\u{001A}BLACK\u{001A}", priority = 10)]
#[token("\0BLACK\0", priority = 10)]
TBlack,
#[regex("\u{001A}BLUE\u{001A}", priority = 10)]
#[regex("\0BLUE\0", priority = 10)]
TBlue,
#[token("\u{001A}GREEN\u{001A}", priority = 10)]
#[token("\0GREEN\0", priority = 10)]
TGreen,
#[token("\u{001A}CYAN\u{001A}", priority = 10)]
#[token("\0CYAN\0", priority = 10)]
TCyan,
#[token("\u{001A}RED\u{001A}", priority = 10)]
#[token("\0RED\0", priority = 10)]
TRed,
#[token("\u{001A}MAGENTA\u{001A}", priority = 10)]
#[token("\0MAGENTA\0", priority = 10)]
TMagenta,
#[token("\u{001A}BROWN\u{001A}", priority = 10)]
#[token("\0BROWN\0", priority = 10)]
TBrown,
#[token("\u{001A}LIGHTGREY\u{001A}", priority = 10)]
#[token("\0LIGHTGREY\0", priority = 10)]
TLightGrey,
#[token("\u{001A}DARKGREY\u{001A}", priority = 10)]
#[token("\0DARKGREY\0", priority = 10)]
TDarkGrey,
#[token("\u{001A}LIGHTBLUE\u{001A}", priority = 10)]
#[token("\0LIGHTBLUE\0", priority = 10)]
TLightBlue,
#[token("\u{001A}LIGHTGREEN\u{001A}", priority = 10)]
#[token("\0LIGHTGREEN\0", priority = 10)]
TLightGreen,
#[token("\u{001A}LIGHTCYAN\u{001A}", priority = 10)]
#[token("\0LIGHTCYAN\0", priority = 10)]
TLightCyan,
#[token("\u{001A}LIGHTRED\u{001A}", priority = 10)]
#[token("\0LIGHTRED\0", priority = 10)]
TLightRed,
#[token("\u{001A}PINK\u{001A}", priority = 10)]
#[token("\0PINK\0", priority = 10)]
TPink,
#[token("\u{001A}YELLOW\u{001A}", priority = 10)]
#[token("\0YELLOW\0", priority = 10)]
TYellow,
#[token("\u{001A}WHITE\u{001A}", priority = 10)]
#[token("\0WHITE\0", priority = 10)]
TWhite,
// #[token(" ")]

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

BIN
disk.img

Binary file not shown.

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)
}

1
limine

@ -1 +0,0 @@
Subproject commit 2b12406a79d9bd0a4bc0c06f6261ecb72f51c9c2

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 {