Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92fe618a99 | |||
| 192100be7a | |||
| 2915d0c879 | |||
| 9852cb14eb | |||
| db8dbff9f2 | |||
| 2178215a01 | |||
| 821759ec63 | |||
| ac0b47a45c | |||
| 15f59e68d5 | |||
| b7397d8a1b | |||
| 4fe6109e5b | |||
| e294a13a91 | |||
| 752800a3ca | |||
| 177fddcf7d | |||
| 375c5aa561 | |||
| b945416665 | |||
| 27ee8226d8 | |||
| 00d3a1de72 | |||
| f7723a3944 | |||
| 438ef7a748 | |||
| 2f7ab8fe6b | |||
| ca1c695e32 | |||
| 1c22f89665 | |||
| 1c147dd933 | |||
| 91044f5fad | |||
| d5b15826e2 | |||
| 39f1f4905d | |||
| 03a3469d20 | |||
| 2cbe9641aa | |||
| e303ecf5a4 | |||
| 2f08835d69 | |||
| 8d57540566 | |||
| 03290e52a3 | |||
| 8908a6a281 | |||
| aefc368d41 | |||
| 76ec29b7ec | |||
| d9bbdff08c | |||
| 7ff33659fe | |||
| efe3034ad0 | |||
| d9b66f8008 | |||
| 2be5b63af7 | |||
| 7e62bdae35 | |||
| b8aa203c05 | |||
| 9f83c5f295 | |||
| 914cb4e409 | |||
| 43b1db41ca | |||
| c763f512f1 | |||
| 5dc73e7000 | |||
| ca906767db | |||
| ef8d028211 | |||
| 2886fe5ecf | |||
| c2c552ef25 | |||
| e722874cee | |||
| 27b0ed634c |
+13
-2
@@ -9,5 +9,16 @@ build-std-features = ["compiler-builtins-mem"]
|
||||
[env]
|
||||
RUST_TARGET_PATH = { value = "kernel", relative = true }
|
||||
|
||||
[target.x86_64-kernel]
|
||||
runner = "scripts/run.sh"
|
||||
# Run in debug mode.
|
||||
[target.'cfg(all(target_arch = "x86_64", target_os = "none", debug_assertions))']
|
||||
runner = "scripts/run_debug.sh"
|
||||
|
||||
# Otherwise we run in release mode.
|
||||
[target.'cfg(all(target_arch = "x86_64", target_os = "none", not(debug_assertions)))']
|
||||
runner = "scripts/run_release.sh"
|
||||
|
||||
# [registry]
|
||||
# default = "gitea"
|
||||
|
||||
[registries.gitea]
|
||||
index = "sparse+https://git.zxq5.dev/api/packages/OsDev/cargo/" # Sparse index
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
[submodule "lib/lib_application"]
|
||||
path = lib/lib_application
|
||||
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_application.git
|
||||
[submodule "lib/lib_ascii"]
|
||||
path = lib/lib_ascii
|
||||
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_ascii.git
|
||||
[submodule "lib/lib_framebuffer"]
|
||||
path = lib/lib_framebuffer
|
||||
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_framebuffer.git
|
||||
[submodule "lib/lib_serial"]
|
||||
path = lib/lib_serial
|
||||
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_serial.git
|
||||
[submodule "lib/lib_alloc"]
|
||||
path = lib/lib_alloc
|
||||
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_alloc.git
|
||||
Vendored
+2
-2
@@ -4,6 +4,6 @@
|
||||
"[rust]": {
|
||||
"editor.defaultFormatter": "rust-lang.rust-analyzer",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"rust-analyzer.check.command": "clippy",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Generated
+167
-38
@@ -22,22 +22,95 @@ checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.14"
|
||||
version = "1.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
|
||||
checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-queue",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.20.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.20.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.20.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foundry_os"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"lib_alloc",
|
||||
"lib_ascii",
|
||||
"lib_framebuffer",
|
||||
"lib_serial",
|
||||
"libk",
|
||||
"limine",
|
||||
"pc-keyboard",
|
||||
"pic8259",
|
||||
@@ -46,54 +119,57 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
name = "futures-core"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||
dependencies = [
|
||||
"spin",
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lib_alloc"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"linked_list_allocator",
|
||||
"x86_64",
|
||||
]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "lib_application"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"lib_ascii",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lib_ascii"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"lib_framebuffer",
|
||||
"spin",
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lib_framebuffer"
|
||||
name = "libk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"crossbeam",
|
||||
"futures-util",
|
||||
"libm",
|
||||
"limine",
|
||||
"linked_list_allocator",
|
||||
"pc-keyboard",
|
||||
"spin",
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lib_serial"
|
||||
name = "libm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"spin",
|
||||
"x86_64",
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -139,6 +215,36 @@ dependencies = [
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.19"
|
||||
@@ -175,6 +281,29 @@ dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
|
||||
|
||||
[[package]]
|
||||
name = "volatile"
|
||||
version = "0.4.6"
|
||||
|
||||
+6
-9
@@ -1,21 +1,18 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"lib/lib_framebuffer",
|
||||
"lib/lib_serial",
|
||||
"lib/lib_ascii",
|
||||
"kernel",
|
||||
"lib/lib_application",
|
||||
"lib/lib_alloc",
|
||||
]
|
||||
members = ["kernel", "libk", "libm"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
authors = ["The FoundryOS Contributors"]
|
||||
|
||||
[profile.dev]
|
||||
opt-level = "z"
|
||||
debug = true
|
||||
# Leave this on to force Cargo to use the debug runner,
|
||||
# which adds the necessary flags for GDB debugging if you
|
||||
# set $USE_GDB (to any value) e.g. USE_GDB=1 cargo run
|
||||
debug-assertions = true
|
||||
overflow-checks = true
|
||||
lto = false
|
||||
|
||||
@@ -1,22 +1,52 @@
|
||||
# FoundryOS
|
||||
|
||||
## Cloning and building
|
||||
## Cloning
|
||||
```sh
|
||||
git clone https://git.zxq5.dev/OsDev/FoundryOS.git
|
||||
```
|
||||
|
||||
Here are some simple steps to get started:
|
||||
## Build dependencies
|
||||
|
||||
* latest rust nightly release
|
||||
* all necessary rust components installed
|
||||
* xorriso: creates ISO images to be booted from.
|
||||
* (Optional / Recommended) qemu: to run the kernel. (this may be packaged as qemu-desktop)
|
||||
* (Optional) GDB: for debugging the kernel.
|
||||
|
||||
```sh
|
||||
# If you have not yet cloned the repo:
|
||||
git clone --recurse-submodules https://git.zxq5.dev/OsDev/FoundryOS.git
|
||||
# If you already cloned the repo:
|
||||
git submodule update --init --recursive
|
||||
rustup update
|
||||
rustup override set nightly
|
||||
rustup component add rust-src
|
||||
rustup component add llvm-tools-preview
|
||||
```
|
||||
|
||||
cargo build
|
||||
# This will build the binaries if required - no need to call cargo build.
|
||||
## Building & Running in qemu
|
||||
```sh
|
||||
cargo run
|
||||
```
|
||||
|
||||
### Build dependencies
|
||||
## Running in GDB
|
||||
```sh
|
||||
USE_GDB=1 cargo run
|
||||
```
|
||||
|
||||
* jq: checks whether the app is to be run in debugging mode.
|
||||
* libisoburn: creates ISO images to be booted from.
|
||||
* qemu: to run the kernel.
|
||||
## Build errors
|
||||
|
||||
If you see a qemu error like this:
|
||||
|
||||
```
|
||||
qemu-system-x86_64: -drive if=pflash,format=raw,readonly=on,file=<...>/OVMF_CODE.fd: Could not open '<...>/OVMF_CODE.fd': No such file or directory
|
||||
```
|
||||
|
||||
Simply delete the ./build directory and try to rebuild the program. Using the runner script or `cargo run` will download the required files for you, this is because the script only checks for the presence of one file and not the VARS file.
|
||||
|
||||
Alternatively, you may disable using a UEFI firmware with qemu like so:
|
||||
```sh
|
||||
USE_LEGACY_BIOS=1 cargo run
|
||||
```
|
||||
|
||||
## Debugging
|
||||
|
||||
See [debugging](docs/Debugging/DEBUGGING.md) for some help with this, including commands to help with disassembly.
|
||||
|
||||
If you have any other issues, feel free to create an issue or a PR.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Timeout in seconds that Limine will use before automatically booting.
|
||||
timeout: 1
|
||||
timeout: 0
|
||||
|
||||
# The entry name that will be displayed in the boot menu.
|
||||
/foundry-os
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
[0;32m[1m Running kernel in debug mode.
|
||||
[0;34m[1minfo[0m: Creating build directory structure
|
||||
[0;34m[1minfo[0m: Copying files to ISO root
|
||||
[0;32m[1m Copying[0m: /home/fantasypvp/Projects/OSdev/FoundryOS/build/target/x86_64-kernel/debug/kernel to /home/fantasypvp/Projects/OSdev/FoundryOS/build/iso_root/boot/kernel
|
||||
[0;32m[1m Copying[0m: /home/fantasypvp/Projects/OSdev/FoundryOS/config/limine.conf to /home/fantasypvp/Projects/OSdev/FoundryOS/build/iso_root/boot/limine/limine.conf
|
||||
[0;32m[1m Copying[0m: /home/fantasypvp/Projects/OSdev/FoundryOS/build/limine/limine-bios-cd.bin to /home/fantasypvp/Projects/OSdev/FoundryOS/build/iso_root/boot/limine/
|
||||
[0;32m[1m Copying[0m: /home/fantasypvp/Projects/OSdev/FoundryOS/build/limine/limine-uefi-cd.bin to /home/fantasypvp/Projects/OSdev/FoundryOS/build/iso_root/boot/limine/
|
||||
[0;32m[1m Copying[0m: /home/fantasypvp/Projects/OSdev/FoundryOS/build/limine/limine-bios.sys to /home/fantasypvp/Projects/OSdev/FoundryOS/build/iso_root/boot/limine/
|
||||
[0;32m[1m Copying[0m: /home/fantasypvp/Projects/OSdev/FoundryOS/build/limine/BOOTX64.EFI to /home/fantasypvp/Projects/OSdev/FoundryOS/build/iso_root/EFI/BOOT/
|
||||
[0;32m[1m Copying[0m: /home/fantasypvp/Projects/OSdev/FoundryOS/build/limine/BOOTIA32.EFI to /home/fantasypvp/Projects/OSdev/FoundryOS/build/iso_root/EFI/BOOT/
|
||||
[0;32m[1mBuilding[0m: bootable ISO image
|
||||
[0;34m[1minfo[0m: Installing Limine bootloader
|
||||
[0;34m[1minfo[0m: KVM acceleration enabled
|
||||
[0;34m[1minfo[0m: Running OS in QEMU...
|
||||
[2J[01;01H[=3h[2J[01;01H[2J[01;01H[=3h[2J[01;01H[2J[01;01H[=3h[2J[01;01HBdsDxe: loading Boot0001 "UEFI QEMU DVD-ROM QM00005 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x2,0xFFFF,0x0)
|
||||
BdsDxe: starting Boot0001 "UEFI QEMU DVD-ROM QM00005 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x2,0xFFFF,0x0)
|
||||
[2J[01;01H[01;01H[2J[01;01H[01;01Hmap worked!got apic base
|
||||
Vendored
+1
-1
@@ -189,7 +189,7 @@
|
||||
"command-palette:Open command palette": false
|
||||
}
|
||||
},
|
||||
"active": "e1fb15cab546d0b6",
|
||||
"active": "add883d295e04659",
|
||||
"lastOpenFiles": [
|
||||
"Usage",
|
||||
"Welcome.md",
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Debugging the Kernel
|
||||
|
||||
Here we will add some helpful tips on debugging the kernel.
|
||||
|
||||
## Disassembling a public function
|
||||
|
||||
To disassemble a public function, first we need a symbol in the public symbol table, so start by making the function fully public (including any parent modules). Do this as though you are trying to make a public function for a library crate (this includes the `kernel` crate). Simply mark the function and any parent modules as public, up until the point of [lib.rs (kernel link)](../../kernel/src/lib.rs).
|
||||
|
||||
Then, we need to find the specific demangled symbol to disassemble, because the default objdump output can be very verbose.
|
||||
|
||||
```sh
|
||||
# Change as required, I pipe to less and /SEARCH FOR FUNCTION HERE.
|
||||
nm --demangle ./build/target/x86_64-kernel/debug/kernel | less
|
||||
# Now just paste the symbol where it says YOUR_SYMBOL_HERE and profit. Use -Mintel for Intel assembly syntax.
|
||||
objdump -Matt --source --line-numbers --visualize-jumps ./build/target/x86_64-kernel/debug/kernel --demangle=rust --disassemble="YOUR_SYMBOL_HERE"
|
||||
```
|
||||
+5
-6
@@ -1,14 +1,12 @@
|
||||
[package]
|
||||
name = "foundry_os"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
[dependencies]
|
||||
limine = "0.3.1"
|
||||
lib_framebuffer = { path = "../lib/lib_framebuffer" }
|
||||
lib_serial = { path = "../lib/lib_serial" }
|
||||
lib_ascii = { path = "../lib/lib_ascii" }
|
||||
lib_alloc = { path = "../lib/lib_alloc" }
|
||||
libk = { path = "../libk" }
|
||||
x86_64 = "0.15.2"
|
||||
spin = "0.9.8"
|
||||
pic8259 = "0.11.0"
|
||||
@@ -23,3 +21,4 @@ default = []
|
||||
[[bin]]
|
||||
name = "kernel"
|
||||
path = "src/main.rs"
|
||||
test = false
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
use cc;
|
||||
use std::process::Command;
|
||||
use std::{env, path::Path};
|
||||
|
||||
fn main() {
|
||||
// Tell cargo to rerun if these files change
|
||||
println!("cargo:rerun-if-changed=src");
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
#![allow(unused)] // TODO: Remove this when ready.
|
||||
use core::arch::x86_64::__cpuid;
|
||||
|
||||
use x86_64::{
|
||||
PhysAddr, VirtAddr,
|
||||
structures::paging::{Mapper, Size4KiB},
|
||||
};
|
||||
|
||||
use crate::serial_print;
|
||||
|
||||
use super::{cpu::model_specific_registers::*, mem::memmap::PHYSICAL_MEMORY_OFFSET};
|
||||
|
||||
const IA32_APIC_BASE_MSR: u32 = 0x1b;
|
||||
const IA32_APIC_BASE_MSR_BSP: u64 = 0x100;
|
||||
const IA32_APIC_BASE_MSR_ENABLE: u64 = 0x800;
|
||||
const IA32_APIC_BASE_MSR_DISABLE: u64 = !IA32_APIC_BASE_MSR_ENABLE;
|
||||
|
||||
const CPUID_FEAT_EDX_APIC: u64 = 1 << 9; // the cpuid instruction will return this flag if it supports APIC
|
||||
|
||||
// const APIC_VIRTUAL_ADDRESS: Lazy<VirtAddr> = Lazy::new(|| {
|
||||
// let apic_base = get_apic_base();
|
||||
// let virt_addr = unsafe { phys_to_virt(apic_base) };
|
||||
|
||||
// virt_addr
|
||||
// });
|
||||
|
||||
fn set_apic_base_enable(apic: PhysAddr) {
|
||||
let rax = (apic.as_u64() & 0xfffff0000) | IA32_APIC_BASE_MSR_ENABLE;
|
||||
cpu_set_msr(IA32_APIC_BASE_MSR, rax);
|
||||
}
|
||||
|
||||
fn set_apic_base_disable(apic: PhysAddr) {
|
||||
let rax = (apic.as_u64() & 0xfffff0000) & IA32_APIC_BASE_MSR_DISABLE;
|
||||
cpu_set_msr(IA32_APIC_BASE_MSR, rax);
|
||||
}
|
||||
|
||||
fn get_apic_base() -> PhysAddr {
|
||||
let mut value: u64 = 0;
|
||||
cpu_get_msr(IA32_APIC_BASE_MSR, &mut value);
|
||||
PhysAddr::new(value & 0xfffff0000)
|
||||
}
|
||||
|
||||
fn write_apic_register(apic_base: &VirtAddr, reg: u8, value: u32) {
|
||||
let apic_base = apic_base.as_u64();
|
||||
let reg_addr = (apic_base & 0xFFFFF0000) + reg as u64;
|
||||
unsafe { *(reg_addr as *mut u32) = value };
|
||||
}
|
||||
|
||||
fn read_apic_register(apic_base: &VirtAddr, reg: u8) -> u32 {
|
||||
let apic_base = apic_base.as_u64();
|
||||
|
||||
serial_print!("got apic base");
|
||||
|
||||
let reg_addr = (apic_base & 0xFFFFF0000) + reg as u64;
|
||||
unsafe { *(reg_addr as *const u32) }
|
||||
}
|
||||
|
||||
pub fn check_apic() -> bool {
|
||||
let res = unsafe { __cpuid(1) };
|
||||
res.edx as u64 & CPUID_FEAT_EDX_APIC != 0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn phys_to_virt(phys: PhysAddr) -> VirtAddr {
|
||||
let phys = phys.as_u64();
|
||||
phys.checked_add(*PHYSICAL_MEMORY_OFFSET).map_or_else(
|
||||
|| {
|
||||
serial_print!("THIS IS A PROBLEM");
|
||||
panic!("overflow")
|
||||
},
|
||||
|virt| {
|
||||
serial_print!("map worked!");
|
||||
VirtAddr::new(virt)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn enable_apic(
|
||||
_mapper: &mut impl Mapper<Size4KiB>,
|
||||
// TODO: Fix this function.
|
||||
// frame_allocator: &mut FoundryOSFrameAllocator,
|
||||
) {
|
||||
unimplemented!();
|
||||
|
||||
// let apic_phys_addr = get_apic_base();
|
||||
// set_apic_base_enable(apic_phys_addr);
|
||||
// map virt address of apic
|
||||
|
||||
// let apic_virt = unsafe { phys_to_virt(apic_phys_addr) };
|
||||
// let page: Page<Size4KiB> = Page::containing_address(apic_virt);
|
||||
// let frame: PhysFrame<Size4KiB> = PhysFrame::containing_address(apic_phys_addr);
|
||||
// let flags: PageTableFlags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;
|
||||
|
||||
// unsafe {
|
||||
// match mapper.map_to(page, frame, flags, frame_allocator) {
|
||||
// Ok(_) => {}
|
||||
// Err(why) => panic!("failed to map apic: {:?}", why),
|
||||
// }
|
||||
// }
|
||||
|
||||
// // FIXME: this causes a page fault
|
||||
// // TODO: map to virtual memor
|
||||
|
||||
// let reg = read_apic_register(&apic_virt, 0xF0);
|
||||
|
||||
// serial_print!("ok2");
|
||||
|
||||
// write_apic_register(&apic_virt, 0xF0, reg | 0x100);
|
||||
}
|
||||
|
||||
pub struct Apic {}
|
||||
|
||||
pub enum ApicVector {}
|
||||
@@ -0,0 +1,26 @@
|
||||
pub mod model_specific_registers {
|
||||
use core::arch::x86_64::__cpuid;
|
||||
use spin::Lazy;
|
||||
use x86_64::registers::model_specific::Msr;
|
||||
|
||||
const _CPUID_FLAG_MSR: u32 = 1 << 5;
|
||||
static _EDX: Lazy<u32> = Lazy::new(|| unsafe { __cpuid(1).edx });
|
||||
|
||||
pub fn _cpu_has_msr() -> bool {
|
||||
*_EDX & _CPUID_FLAG_MSR != 0
|
||||
}
|
||||
|
||||
pub fn cpu_get_msr(msr: u32, value: &mut u64) {
|
||||
let msr = Msr::new(msr);
|
||||
unsafe {
|
||||
*value = msr.read();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cpu_set_msr(msr: u32, value: u64) {
|
||||
let mut msr = Msr::new(msr);
|
||||
unsafe {
|
||||
msr.write(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ static TSS: Lazy<TaskStateSegment> = Lazy::new(|| {
|
||||
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
|
||||
|
||||
let stack_start = VirtAddr::from_ptr(&raw const STACK);
|
||||
let stack_end = stack_start + STACK_SIZE.try_into().unwrap();
|
||||
stack_end
|
||||
|
||||
stack_start + STACK_SIZE.try_into().unwrap()
|
||||
};
|
||||
tss
|
||||
});
|
||||
@@ -40,8 +40,8 @@ static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| {
|
||||
Selectors {
|
||||
code_selector,
|
||||
data_selector,
|
||||
user_code_selector,
|
||||
user_data_selector,
|
||||
_user_code_selector: user_code_selector,
|
||||
_user_data_selector: user_data_selector,
|
||||
tss_selector,
|
||||
},
|
||||
)
|
||||
@@ -50,8 +50,8 @@ static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| {
|
||||
struct Selectors {
|
||||
code_selector: SegmentSelector,
|
||||
data_selector: SegmentSelector,
|
||||
user_code_selector: SegmentSelector,
|
||||
user_data_selector: SegmentSelector,
|
||||
_user_code_selector: SegmentSelector,
|
||||
_user_data_selector: SegmentSelector,
|
||||
tss_selector: SegmentSelector,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use lib_ascii::{print, println_log};
|
||||
use lib_serial::serial_println;
|
||||
use x86_64::instructions::port::Port;
|
||||
use x86_64::registers::control::Cr2;
|
||||
// use libk::drivers::mem::{FRAME_ALLOCATOR, OFFSET_PAGE_TABLE};
|
||||
use libk::prelude::*;
|
||||
use pic8259::ChainedPics;
|
||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||
|
||||
use pic8259::ChainedPics;
|
||||
use spin::{Lazy, Mutex};
|
||||
|
||||
use super::gdt;
|
||||
@@ -42,7 +40,7 @@ pub enum InterruptIndex {
|
||||
}
|
||||
|
||||
impl InterruptIndex {
|
||||
fn as_u8(self) -> u8 {
|
||||
const fn as_u8(self) -> u8 {
|
||||
self as u8
|
||||
}
|
||||
|
||||
@@ -53,12 +51,22 @@ impl InterruptIndex {
|
||||
|
||||
pub fn init_idt() {
|
||||
IDT.load();
|
||||
}
|
||||
|
||||
pub fn enable_pic() {
|
||||
unsafe {
|
||||
PICS.lock().initialize();
|
||||
PICS.lock().write_masks(0xfc, 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(unused)]
|
||||
pub fn disable_pic() {
|
||||
unsafe {
|
||||
PICS.lock().disable();
|
||||
}
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
|
||||
serial_println!("Exception: Breakpoint\n{:#?}", stack_frame);
|
||||
println_log!("Exception: Breakpoint\n{:#?}", stack_frame);
|
||||
@@ -81,30 +89,24 @@ extern "x86-interrupt" fn double_fault_handler(
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
||||
use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1};
|
||||
use pc_keyboard::{HandleControl, Keyboard, ScancodeSet1, layouts};
|
||||
// use pc_keyboard::DecodedKey;
|
||||
use spin::Mutex;
|
||||
use x86_64::instructions::port::Port;
|
||||
|
||||
static KEYBOARD: Lazy<Mutex<Keyboard<layouts::Us104Key, ScancodeSet1>>> = Lazy::new(|| {
|
||||
static KEYBOARD: Lazy<Mutex<Keyboard<layouts::Uk105Key, ScancodeSet1>>> = Lazy::new(|| {
|
||||
Mutex::new(Keyboard::new(
|
||||
ScancodeSet1::new(),
|
||||
layouts::Us104Key,
|
||||
layouts::Uk105Key,
|
||||
HandleControl::Ignore,
|
||||
))
|
||||
});
|
||||
|
||||
let mut keyboard = KEYBOARD.lock();
|
||||
let _keyboard = KEYBOARD.lock();
|
||||
let mut port = Port::new(0x60);
|
||||
|
||||
let scancode: u8 = unsafe { port.read() };
|
||||
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
|
||||
if let Some(key) = keyboard.process_keyevent(key_event) {
|
||||
match key {
|
||||
DecodedKey::Unicode(character) => print!("{}", character),
|
||||
DecodedKey::RawKey(key) => print!("{:?}", key),
|
||||
}
|
||||
}
|
||||
}
|
||||
libk::drivers::io::keyboard::add_scancode(scancode);
|
||||
|
||||
unsafe {
|
||||
PICS.lock()
|
||||
@@ -120,13 +122,32 @@ extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFr
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn page_fault_handler(
|
||||
stack_frame: InterruptStackFrame,
|
||||
error_code: PageFaultErrorCode,
|
||||
_stack_frame: InterruptStackFrame,
|
||||
_error_code: PageFaultErrorCode,
|
||||
) {
|
||||
serial_println!("Exception: Page Fault");
|
||||
serial_println!("Accessed Address: {:?}", Cr2::read());
|
||||
serial_println!("Error Code: {:?}", error_code);
|
||||
serial_println!("{:#?}", stack_frame);
|
||||
todo!("Get this working again.")
|
||||
// serial_println!("Exception: Page Fault");
|
||||
// serial_println!("Accessed Address: {:?}", Cr2::read());
|
||||
// serial_println!("Error Code: {:?}", error_code);
|
||||
// serial_println!("{:#?}", stack_frame);
|
||||
|
||||
crate::hcf();
|
||||
// if let Some(frame_allocator) = FRAME_ALLOCATOR.get() {
|
||||
// let mut f = frame_allocator.lock();
|
||||
|
||||
// let frame = f.allocate_frame().unwrap();
|
||||
// let flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;
|
||||
// let page: Page<Size4KiB> = Page::containing_address(Cr2::read().unwrap());
|
||||
|
||||
// unsafe {
|
||||
// let mut mapper = OFFSET_PAGE_TABLE.get().unwrap().lock();
|
||||
|
||||
// match mapper.map_to(page, frame, flags, &mut *f) {
|
||||
// Ok(_) => {}
|
||||
// Err(why) => panic!("failed to map page: {:?}", why),
|
||||
// }
|
||||
// }
|
||||
// MapperFlushAll::new().flush_all();
|
||||
// } else {
|
||||
// panic!("failed to get frame allocator");
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -7,13 +7,17 @@ use limine::{
|
||||
use spin::Lazy;
|
||||
|
||||
#[used]
|
||||
#[link_section = ".requests"]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static MEMORY_MAP_REQUEST: MemoryMapRequest = MemoryMapRequest::new();
|
||||
|
||||
#[used]
|
||||
#[link_section = ".requests"]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static HIGHER_HALF_DIRECT_MAP_REQUEST: HhdmRequest = HhdmRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static KERNEL_ADDRESS_REQUEST: KernelAddressRequest = KernelAddressRequest::new();
|
||||
|
||||
/// ```rs
|
||||
/// let virt_addr = phys_addr + offset;
|
||||
/// let phys_addr = virt_addr - offset; // (given VA is in the HHDM). Do not use for executable code.
|
||||
@@ -25,17 +29,13 @@ pub static PHYSICAL_MEMORY_OFFSET: Lazy<u64> = Lazy::new(|| {
|
||||
.offset()
|
||||
});
|
||||
|
||||
#[used]
|
||||
#[link_section = ".requests"]
|
||||
static KERNEL_ADDRESS_REQUEST: KernelAddressRequest = KernelAddressRequest::new();
|
||||
|
||||
/// Converts virtual addresses in the kernel to a physical address like this:
|
||||
/// ```rs
|
||||
/// let phys_addr = virt_addr - virtual_base + physical_base;
|
||||
/// ```
|
||||
///
|
||||
/// Returns (virtual_base, physical_base)
|
||||
pub static KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
||||
pub static _KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
||||
let resp = KERNEL_ADDRESS_REQUEST.get_response().unwrap();
|
||||
|
||||
// These are base addresses, using Limine's built in page table.
|
||||
@@ -48,9 +48,8 @@ pub static KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
||||
///
|
||||
/// Panics if the memory map was not found in MEMORY_MAP_REQUEST.
|
||||
pub fn get_memory_map() -> &'static MemoryMapResponse {
|
||||
if let Some(memory_map) = MEMORY_MAP_REQUEST.get_response() {
|
||||
return memory_map;
|
||||
} else {
|
||||
unreachable!("Could not fetch memory map from Limine.")
|
||||
}
|
||||
MEMORY_MAP_REQUEST.get_response().map_or_else(
|
||||
|| unreachable!("Could not fetch memory map from Limine."),
|
||||
|memory_map| memory_map,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod memmap;
|
||||
pub mod pmm;
|
||||
@@ -1,134 +0,0 @@
|
||||
use lib_alloc::allocator::FoundryAllocator;
|
||||
use limine::{memory_map::EntryType, response::MemoryMapResponse};
|
||||
use x86_64::{
|
||||
addr,
|
||||
registers::control::Cr3,
|
||||
structures::paging::{
|
||||
page_table::FrameError, FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB,
|
||||
},
|
||||
PhysAddr, VirtAddr,
|
||||
};
|
||||
|
||||
/// Returns a mutable reference to the current level 4 page table.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure that the level 4 page table is not modified
|
||||
/// simultaneously. The caller must also ensure that the physical memory offset
|
||||
/// is correct, to ensure that the correct virtual address is constructed.
|
||||
unsafe fn active_l4_table(physical_memory_offset: VirtAddr) -> &'static mut PageTable {
|
||||
let (level_4_frame, _) = Cr3::read();
|
||||
|
||||
let phys_addr = level_4_frame.start_address();
|
||||
let virt = phys_addr.as_u64() + physical_memory_offset.as_u64();
|
||||
&mut *(virt as *mut PageTable)
|
||||
}
|
||||
|
||||
/// Initializes the `OffsetPageTable` for the current CPU architecture.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This function must be called only once and should be called before any
|
||||
/// memory operations are performed that rely on virtual memory management.
|
||||
/// The provided `physical_memory_offset` must be accurate to ensure correct
|
||||
/// translation of physical addresses.
|
||||
///
|
||||
/// # Parameters
|
||||
///
|
||||
/// - `physical_memory_offset`: The offset to convert physical addresses to
|
||||
/// virtual addresses in the higher-half direct map.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Returns an `OffsetPageTable` that allows for manipulation of the page
|
||||
/// tables for the current CPU architecture.
|
||||
pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> {
|
||||
let l4_table = active_l4_table(physical_memory_offset);
|
||||
OffsetPageTable::new(l4_table, physical_memory_offset)
|
||||
}
|
||||
|
||||
pub(crate) struct FoundryOSFrameAllocator {
|
||||
memory_map: &'static MemoryMapResponse,
|
||||
next: usize,
|
||||
}
|
||||
|
||||
impl FoundryOSFrameAllocator {
|
||||
/// Creates a new `FoundryOSFrameAllocator` from a memory map.
|
||||
///
|
||||
/// This function takes a reference to a `MemoryMapResponse` and initializes a
|
||||
/// `FoundryOSFrameAllocator` with it. The `next` field is set to 0, indicating that
|
||||
/// the first frame to be allocated is the first frame in the memory map.
|
||||
pub unsafe fn init(memory_map: &'static MemoryMapResponse) -> FoundryOSFrameAllocator {
|
||||
FoundryOSFrameAllocator {
|
||||
memory_map,
|
||||
next: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over all usable frames in the memory map.
|
||||
///
|
||||
/// Yields one `PhysFrame` for each available 4KiB frame in the memory map.
|
||||
///
|
||||
/// This function is used to allocate frames for the pagemap.
|
||||
fn usable_frames(&self) -> impl Iterator<Item = PhysFrame> {
|
||||
let regions = self.memory_map.entries().iter();
|
||||
let usable_regions = regions.filter(|region| region.entry_type == EntryType::USABLE);
|
||||
|
||||
let addr_ranges = usable_regions.map(|region| region.base..region.base + region.length);
|
||||
|
||||
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
|
||||
|
||||
frame_addresses.map(|addr| PhysFrame::from_start_address(PhysAddr::new(addr)).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl FrameAllocator<Size4KiB> for FoundryOSFrameAllocator {
|
||||
/// Allocates a frame from the list of usable frames.
|
||||
///
|
||||
/// This function returns the next available `PhysFrame` from the memory map,
|
||||
/// if one exists. Once a frame is allocated, the internal counter is incremented
|
||||
/// to point to the next frame for future allocations.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// - `Some(PhysFrame)`: If a usable frame is available.
|
||||
/// - `None`: If there are no more usable frames to allocate.
|
||||
|
||||
fn allocate_frame(&mut self) -> Option<PhysFrame> {
|
||||
let frame = self.usable_frames().nth(self.next);
|
||||
self.next += 1;
|
||||
frame
|
||||
}
|
||||
}
|
||||
|
||||
// pub unsafe fn translate_addr(addr: VirtAddr, physical_memory_offset: VirtAddr) -> Option<PhysAddr> {
|
||||
// translate_addr_inner(addr, physical_memory_offset)
|
||||
// }
|
||||
|
||||
// fn translate_addr_inner(addr: VirtAddr, physical_memory_offset: VirtAddr) -> Option<PhysAddr> {
|
||||
// let (l4_table_frame, _) = Cr3::read();
|
||||
|
||||
// let table_indexes = [
|
||||
// addr.p4_index(),
|
||||
// addr.p3_index(),
|
||||
// addr.p2_index(),
|
||||
// addr.p1_index(),
|
||||
// ];
|
||||
// let mut frame = l4_table_frame;
|
||||
|
||||
// for &i in &table_indexes {
|
||||
// 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[i];
|
||||
|
||||
// frame = match entry.frame() {
|
||||
// Ok(frame) => frame,
|
||||
// Err(FrameError::FrameNotPresent) => return None,
|
||||
// Err(FrameError::HugeFrame) => panic!("huge frames are not supported!"),
|
||||
// };
|
||||
// }
|
||||
|
||||
// Some(frame.start_address() + u64::from(addr.page_offset()))
|
||||
// }
|
||||
@@ -1,7 +1,5 @@
|
||||
pub mod apic;
|
||||
pub mod cpu;
|
||||
pub mod gdt;
|
||||
|
||||
pub mod interrupts;
|
||||
|
||||
pub mod memory;
|
||||
|
||||
pub(crate) mod memmap;
|
||||
pub mod mem;
|
||||
|
||||
+42
-26
@@ -1,17 +1,25 @@
|
||||
#![no_std]
|
||||
#![feature(abi_x86_interrupt)]
|
||||
#![warn(
|
||||
clippy::correctness,
|
||||
clippy::nursery,
|
||||
clippy::unnecessary_cast,
|
||||
clippy::all,
|
||||
clippy::suspicious,
|
||||
clippy::perf,
|
||||
rustdoc::missing_errors_doc,
|
||||
rustdoc::missing_panics_doc
|
||||
)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
// use arch::x86_64::apic::enable_apic;
|
||||
use core::arch::asm;
|
||||
use lib_alloc::allocator::init_heap;
|
||||
use limine::request::{RequestsEndMarker, RequestsStartMarker};
|
||||
// use libk::drivers::mem::pmm;
|
||||
use limine::BaseRevision;
|
||||
|
||||
pub use lib_ascii::{print, print_log, println, println_log, WRITER};
|
||||
pub use lib_serial::{serial_print, serial_println, serial_read};
|
||||
use x86_64::structures::paging::Translate;
|
||||
use x86_64::{PhysAddr, VirtAddr};
|
||||
// use libk::drivers::alloc::allocator::init_heap;
|
||||
use libk::prelude::*;
|
||||
|
||||
mod arch;
|
||||
|
||||
@@ -20,17 +28,9 @@ mod arch;
|
||||
/// Be sure to mark all limine requests with #[used], otherwise they may be removed by the compiler.
|
||||
#[used]
|
||||
// The .requests section allows limine to find the requests faster and more safely.
|
||||
#[link_section = ".requests"]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static BASE_REVISION: BaseRevision = BaseRevision::new();
|
||||
|
||||
/// Define the stand and end markers for Limine requests.
|
||||
#[used]
|
||||
#[link_section = ".requests_start_marker"]
|
||||
static _START_MARKER: RequestsStartMarker = RequestsStartMarker::new();
|
||||
#[used]
|
||||
#[link_section = ".requests_end_marker"]
|
||||
static _END_MARKER: RequestsEndMarker = RequestsEndMarker::new();
|
||||
|
||||
#[panic_handler]
|
||||
fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
println!("Kernel panic: {}", _info);
|
||||
@@ -56,13 +56,16 @@ pub fn boot() -> Result<(), &'static str> {
|
||||
return Err("base revision not supported");
|
||||
}
|
||||
|
||||
use arch::x86_64::{gdt, interrupts, memmap, memory};
|
||||
use arch::x86_64::{gdt, interrupts, mem::memmap};
|
||||
|
||||
let memory_map = memmap::get_memory_map();
|
||||
let _memory_map = memmap::get_memory_map();
|
||||
|
||||
print_log!(" Initialising Serial... ");
|
||||
lib_serial::init()?;
|
||||
if libk::drivers::io::serial::init().is_err() {
|
||||
println_log!("[Not Detected]")
|
||||
} else {
|
||||
println_log!("[Success]");
|
||||
}
|
||||
|
||||
print_log!(" Setting Up Global Descriptor Table... ");
|
||||
gdt::init();
|
||||
@@ -72,21 +75,34 @@ pub fn boot() -> Result<(), &'static str> {
|
||||
interrupts::init_idt();
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Setting Up Page Table... ");
|
||||
let mut frame_allocator = unsafe { memory::FoundryOSFrameAllocator::init(memory_map) };
|
||||
print_log!(" Initialising Memory Subsystem... ");
|
||||
// let physical_memory_offset = VirtAddr::new(*memmap::PHYSICAL_MEMORY_OFFSET);
|
||||
// pmm::init_page_table(physical_memory_offset);
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Initialising Memory Subsystem... ");
|
||||
let physical_memory_offset = VirtAddr::new(*memmap::PHYSICAL_MEMORY_OFFSET);
|
||||
let mut l4_table = unsafe { memory::init(physical_memory_offset) };
|
||||
print_log!(" Setting Up Page Table... ");
|
||||
// pmm::init_frame_allocator(memory_map);
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Initialising Heap... ");
|
||||
if let Err(e) = init_heap(&mut l4_table, &mut frame_allocator) {
|
||||
return Err("Failed to initialise heap");
|
||||
}
|
||||
// TODO: Reenable the heap.
|
||||
// if init_heap().is_err() {
|
||||
// return Err("Failed to initialise heap: error");
|
||||
// }
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Enabling PICs... ");
|
||||
interrupts::enable_pic();
|
||||
println_log!("[Success]");
|
||||
|
||||
// print_log!(" Disabling PICs... ");
|
||||
// interrupts::disable_pic();
|
||||
// println_log!("[Success]");
|
||||
//
|
||||
// print_log!(" Initialising APIC");
|
||||
// enable_apic(&mut l4_table, &mut frame_allocator);
|
||||
// println_log!("[Success]");
|
||||
|
||||
print_log!(" Enabling Interrupts... ");
|
||||
x86_64::instructions::interrupts::enable();
|
||||
println_log!("[Success]");
|
||||
|
||||
+21
-31
@@ -3,15 +3,17 @@
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use foundry_os::{println, println_log};
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn kmain() -> ! {
|
||||
// All limine requests must also be referenced in a called function, otherwise they may be
|
||||
// removed by the linker.
|
||||
use libk::{
|
||||
drivers::{
|
||||
async_io::task::{Executor, Task},
|
||||
io,
|
||||
},
|
||||
prelude::*,
|
||||
util::shell::shell,
|
||||
};
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
extern "C" fn kmain() -> ! {
|
||||
println_log!(" [ Initialising Kernel Systems ] ");
|
||||
if let Err(err) = foundry_os::boot() {
|
||||
panic!("{}", err);
|
||||
@@ -19,32 +21,20 @@ unsafe extern "C" fn kmain() -> ! {
|
||||
|
||||
println_log!("[ Kernel Initialised Successfully ] ");
|
||||
|
||||
let dimensions = lib_ascii::screensize_chars();
|
||||
let dimensions2 = lib_framebuffer::screensize_px();
|
||||
let dimensions = io::ascii::screensize_chars();
|
||||
let dimensions2 = io::framebuffer::display::screensize_px();
|
||||
|
||||
println!("Dimensions: {}x{} (px)", dimensions2.0, dimensions2.1);
|
||||
println!("Dimensions: {}x{} (chars)", dimensions.0, dimensions.1);
|
||||
|
||||
println!(
|
||||
"
|
||||
$$$$$$$$\\ $$\\
|
||||
$$ _____| $$ |
|
||||
$$ | $$$$$$\\ $$\\ $$\\ $$$$$$$\\ $$$$$$$ | $$$$$$\\ $$\\ $$\\
|
||||
$$$$$\\ $$ __$$\\ $$ | $$ |$$ __$$\\ $$ __$$ |$$ __$$\\ $$ | $$ |
|
||||
$$ __|$$ / $$ |$$ | $$ |$$ | $$ |$$ / $$ |$$ | \\__|$$ | $$ |
|
||||
$$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | $$ |
|
||||
$$ | \\$$$$$$ |\\$$$$$$ |$$ | $$ |\\$$$$$$$ |$$ | \\$$$$$$$ |
|
||||
\\__| \\______/ \\______/ \\__| \\__| \\_______|\\__| \\____$$ |
|
||||
$$$$$$\\ $$$$$$\\ $$\\ $$\\ $$\\ $$\\ $$ |
|
||||
$$ __$$\\ $$ __$$\\ $$ | $$ |$$$$ | \\$$$$$$ |
|
||||
$$ / $$ |$$ / \\__| $$ | $$ |\\_$$ | \\______/
|
||||
$$ | $$ |\\$$$$$$\\ \\$$\\ $$ | $$ |
|
||||
$$ | $$ | \\____$$\\ \\$$\\$$ / $$ |
|
||||
$$ | $$ |$$\\ $$ | \\$$$ / $$ |
|
||||
$$$$$$ |\\$$$$$$ | \\$ / $$$$$$\\
|
||||
\\______/ \\______/ \\_/ \\______|
|
||||
"
|
||||
);
|
||||
let mut executor = Executor::new();
|
||||
|
||||
loop {}
|
||||
let mut v = Vec::with_capacity(1000 * 1000);
|
||||
for i in 0..1000 * 1000 {
|
||||
v.push(i);
|
||||
}
|
||||
println!("v.len(): {}", v.len());
|
||||
|
||||
executor.spawn(Task::new(shell()));
|
||||
executor.run();
|
||||
}
|
||||
|
||||
Submodule lib/lib_alloc deleted from af814bf2ab
Submodule lib/lib_application deleted from 4b1c60676a
Submodule lib/lib_ascii deleted from 70d528b2e8
Submodule lib/lib_framebuffer deleted from 53553278d1
Submodule lib/lib_serial deleted from ed2fa6b501
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "libk"
|
||||
publish = ["gitea"]
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
description = "A library crate used to write the kernel for Foundry OS."
|
||||
|
||||
[dependencies]
|
||||
limine = "0.3.1"
|
||||
x86_64 = "0.15.2"
|
||||
crossbeam = { version = "0.8.4", default-features = false, features = [
|
||||
"alloc",
|
||||
"crossbeam-queue",
|
||||
] }
|
||||
pc-keyboard = "0.8.0"
|
||||
spin = "0.9.8"
|
||||
futures-util = { version = "0.3.31", default-features = false, features = [
|
||||
"alloc",
|
||||
] }
|
||||
linked_list_allocator = "0.10.5"
|
||||
libm = { path = "../libm" }
|
||||
@@ -0,0 +1,24 @@
|
||||
# libk is for the code that did not make the kernel*
|
||||
|
||||
\*crate, lol.
|
||||
|
||||
libk is an attempt to move away from the godforsaken git submodules that plagued our forefathers. Now we have a crate containing a bunch of code that didn't quite make the core kernel crate, which should be:
|
||||
|
||||
* simpler to maintain
|
||||
* has a catchier name
|
||||
* less fighting with Cargo.toml manifests
|
||||
|
||||
## TODO:
|
||||
|
||||
A lot of things must be improved and worked on, feel free to add extra TODOs below.
|
||||
|
||||
[] Create a kernel logging abstraction similar to Linux. (this should probably just use the serial drivers)
|
||||
|
||||
The rationale behind this is that we want some sort of debug log/tracing support so we aren't just printf debugging forever.
|
||||
|
||||
## Authors
|
||||
|
||||
Again, write your name below if you like:
|
||||
|
||||
* @zxq5 (wrote most of the libraries as of 23/02/25)
|
||||
* @nullndvoid (made this lushious library crate)
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
pub mod task;
|
||||
@@ -0,0 +1,147 @@
|
||||
//! Allows creation of asynchronous IO bound tasks.
|
||||
//!
|
||||
//! Written by @zxq5 for the most part with code from
|
||||
//! [here](https://github.com/phil-opp/blog_os/).
|
||||
//!
|
||||
use crate::prelude::*;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::task::Wake;
|
||||
use core::{
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
sync::atomic::AtomicU64,
|
||||
task::{Context, Poll, Waker},
|
||||
};
|
||||
use crossbeam::queue::ArrayQueue;
|
||||
use x86_64::instructions::interrupts::{self, enable_and_hlt};
|
||||
|
||||
pub struct Task {
|
||||
id: TaskId,
|
||||
future: Pin<Box<dyn Future<Output = ()>>>,
|
||||
}
|
||||
|
||||
impl Task {
|
||||
pub fn new(future: impl Future<Output = ()> + 'static) -> Self {
|
||||
Self {
|
||||
id: TaskId::new(),
|
||||
future: Box::pin(future),
|
||||
}
|
||||
}
|
||||
|
||||
fn poll(&mut self, context: &mut Context) -> Poll<()> {
|
||||
self.future.as_mut().poll(context)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
struct TaskId(u64);
|
||||
|
||||
impl TaskId {
|
||||
fn new() -> Self {
|
||||
static NEXT: AtomicU64 = AtomicU64::new(0);
|
||||
Self(NEXT.fetch_add(1, core::sync::atomic::Ordering::Relaxed))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Executor {
|
||||
tasks: BTreeMap<TaskId, Task>,
|
||||
task_queue: Arc<ArrayQueue<TaskId>>,
|
||||
waker_cache: BTreeMap<TaskId, Waker>,
|
||||
}
|
||||
|
||||
impl Executor {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
tasks: BTreeMap::new(),
|
||||
task_queue: Arc::new(ArrayQueue::new(100)),
|
||||
waker_cache: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spawn(&mut self, task: Task) {
|
||||
let task_id = task.id;
|
||||
if self.tasks.insert(task.id, task).is_some() {
|
||||
panic!("task with same id already in tasks");
|
||||
}
|
||||
self.task_queue.push(task_id).expect("queue full");
|
||||
}
|
||||
|
||||
fn run_ready_tasks(&mut self) {
|
||||
// destructure `self` to avoid borrow checker errors
|
||||
let Self {
|
||||
tasks,
|
||||
task_queue,
|
||||
waker_cache,
|
||||
} = self;
|
||||
|
||||
while let Some(task_id) = task_queue.pop() {
|
||||
let task = match tasks.get_mut(&task_id) {
|
||||
Some(task) => task,
|
||||
None => continue, // task no longer exists
|
||||
};
|
||||
let waker = waker_cache
|
||||
.entry(task_id)
|
||||
.or_insert_with(|| TaskWaker::new_waker(task_id, task_queue.clone()));
|
||||
let mut context = Context::from_waker(waker);
|
||||
match task.poll(&mut context) {
|
||||
Poll::Ready(()) => {
|
||||
// task done -> remove it and its cached waker
|
||||
tasks.remove(&task_id);
|
||||
waker_cache.remove(&task_id);
|
||||
}
|
||||
Poll::Pending => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(&mut self) -> ! {
|
||||
loop {
|
||||
self.run_ready_tasks();
|
||||
self.sleep_if_idle();
|
||||
}
|
||||
}
|
||||
|
||||
fn sleep_if_idle(&self) {
|
||||
interrupts::disable();
|
||||
if self.task_queue.is_empty() {
|
||||
enable_and_hlt();
|
||||
} else {
|
||||
interrupts::enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Executor {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
struct TaskWaker {
|
||||
task_id: TaskId,
|
||||
task_queue: Arc<ArrayQueue<TaskId>>,
|
||||
}
|
||||
|
||||
impl TaskWaker {
|
||||
fn wake_task(&self) {
|
||||
self.task_queue.push(self.task_id).expect("task_queue full");
|
||||
}
|
||||
|
||||
fn new_waker(task_id: TaskId, task_queue: Arc<ArrayQueue<TaskId>>) -> Waker {
|
||||
Waker::from(Arc::new(Self {
|
||||
task_id,
|
||||
task_queue,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl Wake for TaskWaker {
|
||||
fn wake(self: Arc<Self>) {
|
||||
self.wake_task();
|
||||
}
|
||||
|
||||
fn wake_by_ref(self: &Arc<Self>) {
|
||||
self.wake_task();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
use core::fmt;
|
||||
use spin::{Lazy, Mutex};
|
||||
use x86_64::instructions::interrupts;
|
||||
|
||||
use super::framebuffer::{colour::Colour, display::FRAMEBUFFER_WRITER};
|
||||
|
||||
use crate::resources::font::{FONT_SPLEEN_8X16, Font};
|
||||
|
||||
static FONT_WIDTH: u32 = 8;
|
||||
static FONT_HEIGHT: u32 = 16;
|
||||
|
||||
pub static WRITER: Lazy<Mutex<Writer>> = Lazy::new(|| Mutex::new(Writer::new()));
|
||||
|
||||
pub fn screensize_chars() -> (u32, u32) {
|
||||
let writer = WRITER.lock();
|
||||
(writer.screen_width, writer.screen_height)
|
||||
}
|
||||
|
||||
pub struct Writer {
|
||||
font: &'static Font,
|
||||
/// Measured in chars not pixels.
|
||||
screen_width: u32,
|
||||
/// Measured in chars not pixels.
|
||||
screen_height: u32,
|
||||
/// 16 pixels tall.
|
||||
text_line: u32,
|
||||
/// 8 pixels wide.
|
||||
text_col: u32,
|
||||
|
||||
fg_color: Colour,
|
||||
bg_color: Colour,
|
||||
}
|
||||
|
||||
impl Default for Writer {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Writer {
|
||||
pub fn new() -> Self {
|
||||
FRAMEBUFFER_WRITER.lock().as_mut().map_or_else(
|
||||
|| {
|
||||
panic!("Framebuffer writer not initialized.");
|
||||
},
|
||||
|writer| Self {
|
||||
font: &FONT_SPLEEN_8X16,
|
||||
screen_width: writer.width() / 8,
|
||||
screen_height: writer.height() / 16,
|
||||
text_line: 0,
|
||||
text_col: 0,
|
||||
fg_color: Colour::White,
|
||||
bg_color: Colour::Black,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub const fn set_font(&mut self, font: &'static Font) {
|
||||
self.font = font;
|
||||
}
|
||||
|
||||
/// This is sent when the user types a backspace.
|
||||
const BACKSPACE: u8 = 8;
|
||||
|
||||
pub fn write_glyph(&mut self, c: u8) {
|
||||
if c == b'\n' {
|
||||
self.newline();
|
||||
return;
|
||||
} else if c == Self::BACKSPACE {
|
||||
self.backspace();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the character data from the font array. -- each byte is a row of pixels
|
||||
let data: &[u8] = &self.font.glyphs[c as usize];
|
||||
|
||||
if let Some(writer) = FRAMEBUFFER_WRITER.lock().as_mut() {
|
||||
for (row, line) in data.iter().enumerate().take(16) {
|
||||
for col in 0..8 {
|
||||
let pixel_x: u32 = self.text_col * FONT_WIDTH + col;
|
||||
let pixel_y: u32 = self.text_line * FONT_HEIGHT + row as u32;
|
||||
|
||||
if line & (0x80 >> col) != 0 {
|
||||
// Write the foreground color
|
||||
writer.write_pixel(pixel_x as usize, pixel_y as usize, self.fg_color);
|
||||
} else {
|
||||
// Write the background color
|
||||
writer.write_pixel(pixel_x as usize, pixel_y as usize, self.bg_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Go to next position
|
||||
if self.text_col + 1 >= self.screen_width {
|
||||
self.newline();
|
||||
} else {
|
||||
self.text_col += 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn dimensions(&self) -> (u32, u32) {
|
||||
(self.screen_width, self.screen_height)
|
||||
}
|
||||
|
||||
pub const fn next_char(&mut self) {
|
||||
self.text_col += 1;
|
||||
}
|
||||
|
||||
pub const fn newline(&mut self) {
|
||||
self.text_col = 0;
|
||||
|
||||
if self.text_line + 1 >= self.screen_height {
|
||||
self.text_line = 0;
|
||||
} else {
|
||||
self.text_line += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles the backspace character. TODO: Implement VT-100 style terminal control
|
||||
/// codes alongside a shell. Not simple.
|
||||
pub fn backspace(&mut self) {
|
||||
if self.text_col > 0 {
|
||||
self.text_col -= 1;
|
||||
// Blank out the previous char.
|
||||
self.write_glyph(b' ');
|
||||
self.text_col -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_string(&mut self, s: &str) {
|
||||
for c in s.chars() {
|
||||
self.write_glyph(c as u8);
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn set_colour(&mut self, fg: Colour, bg: Colour) {
|
||||
self.fg_color = fg;
|
||||
self.bg_color = bg;
|
||||
}
|
||||
|
||||
pub const fn reset_colour(&mut self) {
|
||||
self.fg_color = Colour::White;
|
||||
self.bg_color = Colour::Black;
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Write for Writer {
|
||||
fn write_str(&mut self, s: &str) -> core::fmt::Result {
|
||||
self.write_string(s);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn write(args: fmt::Arguments, fg: Colour, bg: Colour) {
|
||||
use core::fmt::Write;
|
||||
|
||||
interrupts::without_interrupts(|| {
|
||||
let mut writer = WRITER.lock();
|
||||
writer.set_colour(fg, bg);
|
||||
writer.write_fmt(args).unwrap();
|
||||
writer.reset_colour();
|
||||
});
|
||||
}
|
||||
|
||||
pub fn _print(args: fmt::Arguments) {
|
||||
x86_64::instructions::interrupts::without_interrupts(|| {
|
||||
write(args, Colour::White, Colour::Black);
|
||||
})
|
||||
}
|
||||
|
||||
pub fn _print_err(args: fmt::Arguments) {
|
||||
x86_64::instructions::interrupts::without_interrupts(|| {
|
||||
write(args, Colour::Red, Colour::Black);
|
||||
})
|
||||
}
|
||||
|
||||
pub fn _print_log(args: fmt::Arguments) {
|
||||
x86_64::instructions::interrupts::without_interrupts(|| {
|
||||
write(args, Colour::Yellow, Colour::Black);
|
||||
})
|
||||
}
|
||||
|
||||
pub fn clear_screen() {
|
||||
interrupts::without_interrupts(|| {
|
||||
let mut writer = WRITER.lock();
|
||||
writer.text_line = 0;
|
||||
writer.text_col = 0;
|
||||
|
||||
if let Some(writer) = FRAMEBUFFER_WRITER.lock().as_mut() {
|
||||
writer.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub fn reset_cursor() {
|
||||
interrupts::without_interrupts(|| {
|
||||
let mut writer = WRITER.lock();
|
||||
writer.text_line = 0;
|
||||
writer.text_col = 0;
|
||||
});
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! println_log {
|
||||
() => ($crate::print_log!("\n"));
|
||||
($($arg:tt)*) => ($crate::print_log!("{}\n", format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print_log {
|
||||
($($arg:tt)*) => ($crate::_print_log(format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! println {
|
||||
() => ($crate::print!("\n"));
|
||||
($($arg:tt)*) => ($crate::print!("{}\n", format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print {
|
||||
($($arg:tt)*) => ($crate::_print(format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! printlnerr {
|
||||
() => ($crate::printerr!("\n"));
|
||||
($($arg:tt)*) => ($crate::printerr!("{}\n", format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! printerr {
|
||||
($($arg:tt)*) => ($crate::_print_err(format_args!($($arg)*)));
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#[repr(u32)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum Colour {
|
||||
ARGB(u8, u8, u8, u8),
|
||||
RGB(u8, u8, u8),
|
||||
HexARGB(u32),
|
||||
Black = 0x000000FF,
|
||||
Blue = 0x0000FFFF,
|
||||
Green = 0x00FF00FF,
|
||||
Cyan = 0x00FFFFFF,
|
||||
Red = 0xFF0000FF,
|
||||
Magenta = 0xFF00FFFF,
|
||||
Yellow = 0xFFFF00FF,
|
||||
White = 0xFFFFFFFF,
|
||||
}
|
||||
|
||||
#[allow(clippy::use_self)]
|
||||
impl From<Colour> for u32 {
|
||||
fn from(val: Colour) -> Self {
|
||||
match val {
|
||||
Colour::ARGB(a, r, g, b) => {
|
||||
(a as u32) << 24 | (r as u32) << 16 | (g as u32) << 8 | (b as u32)
|
||||
}
|
||||
Colour::RGB(r, g, b) => ((r as u32) << 16) | (g as u32) << 8 | (b as u32),
|
||||
Colour::HexARGB(hex) => hex,
|
||||
Colour::Black => 0xFF000000,
|
||||
Colour::Blue => 0xFF0000FF,
|
||||
Colour::Green => 0xFF00FF00,
|
||||
Colour::Cyan => 0xFF00FFFF,
|
||||
Colour::Red => 0xFFFF0000,
|
||||
Colour::Magenta => 0xFFFF00FF,
|
||||
Colour::Yellow => 0xFFFFFF00,
|
||||
Colour::White => 0xFFFFFFFF,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for Colour {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
Self::ARGB(r, g, b, a) => write!(f, "RGBA(#{:x}{:x}{:x}{:x})", r, g, b, a),
|
||||
Self::RGB(r, g, b) => write!(f, "RGB(#{:x}{:x}{:x})", r, g, b),
|
||||
Self::HexARGB(hex) => write!(f, "Hex(#{:x})", hex),
|
||||
Self::Black => write!(f, "Black"),
|
||||
Self::Blue => write!(f, "Blue"),
|
||||
Self::Green => write!(f, "Green"),
|
||||
Self::Cyan => write!(f, "Cyan"),
|
||||
Self::Red => write!(f, "Red"),
|
||||
Self::Magenta => write!(f, "Magenta"),
|
||||
Self::Yellow => write!(f, "Yellow"),
|
||||
Self::White => write!(f, "White"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
use limine::request::FramebufferRequest;
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static FRAMEBUFFER_REQUEST: FramebufferRequest = FramebufferRequest::new();
|
||||
|
||||
use super::colour::Colour;
|
||||
use core::panic;
|
||||
|
||||
use limine::framebuffer::Framebuffer;
|
||||
use spin::{Lazy, Mutex};
|
||||
|
||||
pub static FRAMEBUFFER_WRITER: Lazy<Mutex<Option<FramebufferWriter>>> = Lazy::new(|| {
|
||||
Mutex::new(FRAMEBUFFER_REQUEST.get_response().map_or_else(
|
||||
|| {
|
||||
panic!("Framebuffer request failed");
|
||||
},
|
||||
|framebuffer_response| {
|
||||
let framebuffer = framebuffer_response.framebuffers().next().unwrap();
|
||||
Some(FramebufferWriter::new(framebuffer))
|
||||
},
|
||||
))
|
||||
});
|
||||
|
||||
/// The updated writer stores necessary fields from the [Framebuffer].
|
||||
/// This ensures that the contained types are Send, as Framebuffer was
|
||||
/// not marked as Send.
|
||||
///
|
||||
/// It also avoids the requirement for lifetimes.
|
||||
///
|
||||
/// Note this does not implement Writer as these functions only handle drawing pixels.
|
||||
pub struct FramebufferWriter {
|
||||
pitch: u64,
|
||||
bpp: u16,
|
||||
addr: *mut u8,
|
||||
width: u64,
|
||||
height: u64,
|
||||
}
|
||||
|
||||
unsafe impl Send for FramebufferWriter {}
|
||||
unsafe impl Sync for FramebufferWriter {}
|
||||
|
||||
impl FramebufferWriter {
|
||||
pub fn new(framebuffer: Framebuffer) -> Self {
|
||||
Self {
|
||||
pitch: framebuffer.pitch(),
|
||||
bpp: framebuffer.bpp(),
|
||||
addr: framebuffer.addr(),
|
||||
width: framebuffer.width(),
|
||||
height: framebuffer.height(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_pixel(&self, x: usize, y: usize, color: Colour) {
|
||||
let pitch = self.pitch as usize;
|
||||
let bpp = (self.bpp / 8) as usize;
|
||||
let pixel_offset = y * pitch + x * bpp;
|
||||
|
||||
unsafe {
|
||||
*(self.addr.add(pixel_offset) as *mut u32) = color.into();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_frame(&self, buffer: &[Colour; 1280 * 800]) {
|
||||
for (y, row) in buffer.chunks(1280).enumerate() {
|
||||
for (x, pixel) in row.iter().enumerate() {
|
||||
self.write_pixel(x, y, *pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn width(&self) -> u32 {
|
||||
self.width as u32
|
||||
}
|
||||
|
||||
pub const fn height(&self) -> u32 {
|
||||
self.height as u32
|
||||
}
|
||||
|
||||
pub fn clear(&self) {
|
||||
let width = self.width as usize;
|
||||
let height = self.height as usize;
|
||||
|
||||
for y in 0..height {
|
||||
for x in 0..width {
|
||||
self.write_pixel(x, y, Colour::Black);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn screensize_px() -> (u32, u32) {
|
||||
FRAMEBUFFER_WRITER
|
||||
.lock()
|
||||
.as_mut()
|
||||
.map_or_else(|| (0, 0), |writer| (writer.width(), writer.height()))
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod colour;
|
||||
pub mod display;
|
||||
@@ -0,0 +1,206 @@
|
||||
use core::{
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use crossbeam::queue::ArrayQueue;
|
||||
use futures_util::{Stream, StreamExt, task::AtomicWaker};
|
||||
use pc_keyboard::{
|
||||
DecodedKey, HandleControl, KeyCode, Keyboard, ScancodeSet1,
|
||||
layouts::{self, Uk105Key},
|
||||
};
|
||||
use spin::{Lazy, Mutex, Once};
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
static KBD_QUEUE: Once<ArrayQueue<u8>> = Once::new();
|
||||
static WAKER: AtomicWaker = AtomicWaker::new();
|
||||
|
||||
pub static KEYBOARD: Lazy<Mutex<Keyboard<Uk105Key, ScancodeSet1>>> = Lazy::new(|| {
|
||||
Mutex::new(Keyboard::new(
|
||||
ScancodeSet1::new(),
|
||||
// TODO: Expose an API to change the default KB layout.
|
||||
layouts::Uk105Key,
|
||||
HandleControl::Ignore,
|
||||
))
|
||||
});
|
||||
pub static SCANCODE_STREAM: Lazy<Mutex<ScancodeStream>> =
|
||||
Lazy::new(|| Mutex::new(ScancodeStream::new()));
|
||||
|
||||
pub fn add_scancode(scancode: u8) {
|
||||
if let Some(queue) = KBD_QUEUE.get() {
|
||||
if queue.push(scancode).is_err() {
|
||||
println!("WARNING: scancode queue full; dropping keyboard input");
|
||||
} else {
|
||||
WAKER.wake();
|
||||
}
|
||||
} else {
|
||||
println!("WARNING: scancode queue not initialized");
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ScancodeStream {
|
||||
_private: (),
|
||||
}
|
||||
|
||||
impl ScancodeStream {
|
||||
pub fn new() -> Self {
|
||||
KBD_QUEUE.call_once(|| ArrayQueue::new(5));
|
||||
Self { _private: () }
|
||||
}
|
||||
|
||||
pub fn try_next(&mut self) -> Option<u8> {
|
||||
KBD_QUEUE.get().and_then(|queue| queue.pop())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ScancodeStream {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Stream for ScancodeStream {
|
||||
type Item = u8;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let queue = KBD_QUEUE.get().unwrap();
|
||||
|
||||
if let Some(scancode) = queue.pop() {
|
||||
return Poll::Ready(Some(scancode));
|
||||
}
|
||||
|
||||
WAKER.register(cx.waker());
|
||||
WAKER.register(cx.waker());
|
||||
|
||||
queue.pop().map_or(Poll::Pending, |scancode| {
|
||||
WAKER.take();
|
||||
Poll::Ready(Some(scancode))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_keystroke_async() -> KeyStroke {
|
||||
loop {
|
||||
if let Some(scancode) = SCANCODE_STREAM.lock().next().await {
|
||||
if let Ok(keystroke) = KeyStroke::try_from(scancode) {
|
||||
return keystroke;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_keystroke_optional() -> Option<KeyStroke> {
|
||||
if let Some(scancode) = SCANCODE_STREAM.lock().try_next() {
|
||||
if let Ok(keystroke) = KeyStroke::try_from(scancode) {
|
||||
return Some(keystroke);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum KeyStroke {
|
||||
Char(char),
|
||||
Ctrl,
|
||||
RCtrl,
|
||||
Alt,
|
||||
RAlt,
|
||||
Shift,
|
||||
RShift,
|
||||
Meta,
|
||||
RMeta,
|
||||
Backspace,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
None,
|
||||
Enter,
|
||||
Escape,
|
||||
Del,
|
||||
}
|
||||
|
||||
impl KeyStroke {
|
||||
pub const fn from_keycode(key: KeyCode) -> Self {
|
||||
match key {
|
||||
KeyCode::LControl => Self::Ctrl,
|
||||
KeyCode::RControl => Self::RCtrl,
|
||||
KeyCode::LAlt => Self::Alt,
|
||||
KeyCode::RAlt2 => Self::RAlt,
|
||||
KeyCode::LShift => Self::Shift,
|
||||
KeyCode::RShift => Self::RShift,
|
||||
KeyCode::LWin => Self::Meta,
|
||||
KeyCode::RWin => Self::RMeta,
|
||||
KeyCode::Backspace => Self::Backspace,
|
||||
KeyCode::ArrowLeft => Self::Left,
|
||||
KeyCode::ArrowRight => Self::Right,
|
||||
KeyCode::ArrowUp => Self::Up,
|
||||
KeyCode::ArrowDown => Self::Down,
|
||||
KeyCode::Return => Self::Enter,
|
||||
KeyCode::Escape => Self::Escape,
|
||||
KeyCode::Delete => Self::Del,
|
||||
_ => Self::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for KeyStroke {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(code: u8) -> Result<Self, Self::Error> {
|
||||
let mut keyboard = KEYBOARD.lock();
|
||||
|
||||
let key = match keyboard.add_byte(code) {
|
||||
Ok(Some(event)) => match keyboard.process_keyevent(event) {
|
||||
Some(key) => key,
|
||||
_ => return Err(()),
|
||||
},
|
||||
_ => return Err(()),
|
||||
};
|
||||
|
||||
match key {
|
||||
DecodedKey::Unicode(ch) => Ok(Self::Char(ch)),
|
||||
DecodedKey::RawKey(key) => match Self::from_keycode(key) {
|
||||
Self::None => Err(()),
|
||||
key => Ok(key),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryInto<char> for KeyStroke {
|
||||
type Error = ();
|
||||
|
||||
fn try_into(self) -> Result<char, Self::Error> {
|
||||
match self {
|
||||
Self::Char(c) => Ok(c),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for KeyStroke {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
Self::Char(c) => write!(f, "{}", c),
|
||||
Self::Ctrl => write!(f, "CTRL"),
|
||||
Self::RCtrl => write!(f, "RCtrl"),
|
||||
Self::Alt => write!(f, "ALT"),
|
||||
Self::RAlt => write!(f, "RAlt"),
|
||||
Self::Shift => write!(f, "SHIFT"),
|
||||
Self::RShift => write!(f, "RShift"),
|
||||
Self::Meta => write!(f, "META"),
|
||||
Self::RMeta => write!(f, "RMeta"),
|
||||
Self::Backspace => write!(f, "BACKSPACE"),
|
||||
Self::Left => write!(f, "LEFT"),
|
||||
Self::Right => write!(f, "RIGHT"),
|
||||
Self::Up => write!(f, "UP"),
|
||||
Self::Down => write!(f, "DOWN"),
|
||||
Self::Enter => write!(f, "ENTER"),
|
||||
Self::Escape => write!(f, "ESCAPE"),
|
||||
Self::None => write!(f, "NONE"),
|
||||
Self::Del => write!(f, "DEL"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
pub mod ascii;
|
||||
pub mod framebuffer;
|
||||
pub mod keyboard;
|
||||
pub mod port;
|
||||
pub mod serial;
|
||||
|
||||
// Re-exported macro definitions.
|
||||
|
||||
pub use crate::print;
|
||||
pub use crate::print_log;
|
||||
pub use crate::printerr;
|
||||
pub use crate::println;
|
||||
pub use crate::println_log;
|
||||
pub use crate::printlnerr;
|
||||
|
||||
pub use crate::serial_print;
|
||||
pub use crate::serial_println;
|
||||
@@ -0,0 +1,29 @@
|
||||
//! Functions for IO using ports.
|
||||
|
||||
use core::arch::asm;
|
||||
|
||||
#[inline]
|
||||
pub fn inb(port: u16) -> u8 {
|
||||
let value: u8;
|
||||
unsafe {
|
||||
asm!(
|
||||
"in al, dx",
|
||||
out("al") value,
|
||||
in("dx") port,
|
||||
options(nomem, nostack, preserves_flags)
|
||||
);
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn outb(port: u16, value: u8) {
|
||||
unsafe {
|
||||
asm!(
|
||||
"out dx, al",
|
||||
in("dx") port,
|
||||
in("al") value,
|
||||
options(nomem, nostack, preserves_flags)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
use core::{
|
||||
fmt,
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
};
|
||||
use spin::{Lazy, Mutex};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! serial_print {
|
||||
($($arg:tt)*) => ($crate::_serial_write(format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! serial_println {
|
||||
() => ($crate::serial_print!("\n"));
|
||||
($($arg:tt)*) => (serial_print!("{}\n", format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
use super::port::{inb, outb};
|
||||
|
||||
use x86_64::instructions::interrupts;
|
||||
|
||||
pub fn _serial_write(args: fmt::Arguments) {
|
||||
use core::fmt::Write;
|
||||
|
||||
interrupts::without_interrupts(|| {
|
||||
if let Some(writer) = WRITER.lock().as_mut() {
|
||||
writer.write_fmt(args).unwrap();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn serial_read() -> &'static str {
|
||||
serial_println!("getting value!");
|
||||
|
||||
interrupts::without_interrupts(|| {
|
||||
if let Some(reader) = READER.lock().as_mut() {
|
||||
serial_println!("stuff happnin.");
|
||||
reader.read_str_to_buffer();
|
||||
} else {
|
||||
serial_println!("failed to get writer");
|
||||
}
|
||||
});
|
||||
|
||||
serial_println!("eee");
|
||||
|
||||
let i = BUFFER_LEN.load(Ordering::SeqCst);
|
||||
|
||||
unsafe {
|
||||
if i != 0 {
|
||||
core::str::from_utf8(&BUFFER[..i - 1]).unwrap()
|
||||
} else {
|
||||
serial_println!("empty string");
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static PORT: u16 = 0x3f8;
|
||||
static mut BUFFER: [u8; 256] = [0; 256];
|
||||
static BUFFER_LEN: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
static READER: Lazy<Mutex<Option<Reader>>> = Lazy::new(|| Mutex::new(None));
|
||||
static WRITER: Lazy<Mutex<Option<Writer>>> = Lazy::new(|| Mutex::new(None));
|
||||
|
||||
struct Reader;
|
||||
|
||||
struct Writer;
|
||||
|
||||
impl fmt::Write for Writer {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
for c in s.chars() {
|
||||
self.write_byte(c as u8);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Writer {
|
||||
unsafe fn write_success(&self) -> bool {
|
||||
inb(PORT + 5) & 0x20 != 0
|
||||
}
|
||||
|
||||
pub fn write_byte(&self, data: u8) {
|
||||
unsafe {
|
||||
while !self.write_success() {}
|
||||
outb(PORT, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init() -> Result<(), &'static str> {
|
||||
test()?;
|
||||
|
||||
if READER.lock().is_none() {
|
||||
*READER.lock() = Some(Reader);
|
||||
}
|
||||
|
||||
if WRITER.lock().is_none() {
|
||||
*WRITER.lock() = Some(Writer);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn test() -> Result<(), &'static str> {
|
||||
outb(PORT + 1, 0x00); // Disable all interrupts
|
||||
outb(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor)
|
||||
outb(PORT, 0x03); // Set divisor to 3 (lo byte) 38400 baud
|
||||
outb(PORT + 1, 0x00); // (hi byte)
|
||||
outb(PORT + 3, 0x03); // 8 bits, no parity, one stop bit
|
||||
outb(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-bytethreshold
|
||||
outb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
|
||||
outb(PORT + 4, 0x1E); // Set in loopback mode, test the serial chip
|
||||
outb(PORT, 0xAE); // Test serial chip (send byte 0xAE and check if serial returns same byte)
|
||||
|
||||
if inb(PORT) != 0xAE {
|
||||
return Err("serial test failed");
|
||||
}
|
||||
|
||||
outb(PORT + 4, 0x0F);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl Reader {
|
||||
pub fn read_str_to_buffer(&mut self) {
|
||||
unsafe {
|
||||
while !self.read_ready() {}
|
||||
|
||||
BUFFER_LEN.store(0, Ordering::SeqCst);
|
||||
|
||||
while BUFFER_LEN.load(Ordering::SeqCst) < 256 {
|
||||
let c = self.read();
|
||||
BUFFER[BUFFER_LEN.load(Ordering::SeqCst)] = c;
|
||||
if c as char == '\r' {
|
||||
break;
|
||||
}
|
||||
BUFFER_LEN.fetch_add(1, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
serial_println!("returning")
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn read_ready(&self) -> bool {
|
||||
inb(PORT + 5) & 1 != 0
|
||||
}
|
||||
|
||||
pub fn read(&self) -> u8 {
|
||||
unsafe {
|
||||
while !self.read_ready() {}
|
||||
inb(PORT)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod async_io;
|
||||
pub mod io;
|
||||
pub mod pic;
|
||||
@@ -0,0 +1,146 @@
|
||||
use x86_64::instructions::port::Port;
|
||||
|
||||
const CMD_INIT: u8 = 0x11;
|
||||
const CMD_END_OF_INT: u8 = 0x20;
|
||||
const MODE_8086: u8 = 0x01;
|
||||
|
||||
struct Pic {
|
||||
offset: u8,
|
||||
data: Port<u8>,
|
||||
command: Port<u8>,
|
||||
}
|
||||
|
||||
impl Pic {
|
||||
/// Are we in charge of handling the specified interrupt?
|
||||
/// (Each PIC handles 8 interrupts.)
|
||||
const fn handles_interrupt(&self, interrupt_id: u8) -> bool {
|
||||
self.offset <= interrupt_id && interrupt_id < self.offset + 8
|
||||
}
|
||||
|
||||
/// Notify us that an interrupt has been handled and that we're ready
|
||||
/// for more.
|
||||
unsafe fn end_of_interrupt(&mut self) {
|
||||
unsafe { self.command.write(CMD_END_OF_INT) };
|
||||
}
|
||||
|
||||
/// Reads the interrupt mask of this PIC.
|
||||
unsafe fn read_mask(&mut self) -> u8 {
|
||||
unsafe { self.data.read() }
|
||||
}
|
||||
|
||||
/// Writes the interrupt mask of this PIC.
|
||||
unsafe fn write_mask(&mut self, mask: u8) {
|
||||
unsafe { self.data.write(mask) }
|
||||
}
|
||||
}
|
||||
|
||||
/// A pair of chained PICs. This is the standard setup on x86.
|
||||
pub struct ChainedPics {
|
||||
pics: [Pic; 2],
|
||||
}
|
||||
|
||||
impl ChainedPics {
|
||||
pub const fn new(offset1: u8, offset2: u8) -> Self {
|
||||
Self {
|
||||
pics: [
|
||||
Pic {
|
||||
offset: offset1,
|
||||
command: Port::new(0x20),
|
||||
data: Port::new(0x21),
|
||||
},
|
||||
Pic {
|
||||
offset: offset2,
|
||||
command: Port::new(0xA0),
|
||||
data: Port::new(0xA1),
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn new_contiguous(primary_offset: u8) -> Self {
|
||||
Self::new(primary_offset, primary_offset + 8)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
///
|
||||
/// This should be safe if called just once on initialisation, however
|
||||
/// sending data to IO ports tends to have side-effects.
|
||||
pub unsafe fn initialize(&mut self) {
|
||||
unsafe {
|
||||
let mut wait_port: Port<u8> = Port::new(0x80);
|
||||
let mut wait = || wait_port.write(0);
|
||||
|
||||
// Save our original interrupt masks, because I'm too lazy to
|
||||
// figure out reasonable values. We'll restore these when we're
|
||||
// done.
|
||||
let saved_masks = self.read_masks();
|
||||
|
||||
// Tell each PIC that we're going to send it a three-byte
|
||||
// initialization sequence on its data port.
|
||||
self.pics[0].command.write(CMD_INIT);
|
||||
wait();
|
||||
self.pics[1].command.write(CMD_INIT);
|
||||
wait();
|
||||
|
||||
// Byte 1: Set up our base offsets.
|
||||
self.pics[0].data.write(self.pics[0].offset);
|
||||
wait();
|
||||
self.pics[1].data.write(self.pics[1].offset);
|
||||
wait();
|
||||
|
||||
// Byte 2: Configure chaining between PIC1 and PIC2.
|
||||
self.pics[0].data.write(4);
|
||||
wait();
|
||||
self.pics[1].data.write(2);
|
||||
wait();
|
||||
|
||||
// Byte 3: Set our mode.
|
||||
self.pics[0].data.write(MODE_8086);
|
||||
wait();
|
||||
self.pics[1].data.write(MODE_8086);
|
||||
wait();
|
||||
|
||||
// Restore our saved masks.
|
||||
self.write_masks(saved_masks[0], saved_masks[1])
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads the interrupt masks of both PICs.
|
||||
pub fn read_masks(&mut self) -> [u8; 2] {
|
||||
unsafe { [self.pics[0].read_mask(), self.pics[1].read_mask()] }
|
||||
}
|
||||
|
||||
/// Writes the interrupt masks of both PICs.
|
||||
pub fn write_masks(&mut self, mask1: u8, mask2: u8) {
|
||||
unsafe {
|
||||
self.pics[0].write_mask(mask1);
|
||||
self.pics[1].write_mask(mask2);
|
||||
}
|
||||
}
|
||||
|
||||
/// Disables both PICs by masking all interrupts.
|
||||
pub fn disable(&mut self) {
|
||||
self.write_masks(u8::MAX, u8::MAX)
|
||||
}
|
||||
|
||||
/// Do we handle this interrupt?
|
||||
pub fn handles_interrupt(&self, interrupt_id: u8) -> bool {
|
||||
self.pics.iter().any(|p| p.handles_interrupt(interrupt_id))
|
||||
}
|
||||
|
||||
/// Figure out which (if any) PICs in our chain need to know about this
|
||||
/// interrupt. This is tricky, because all interrupts from `pics[1]`
|
||||
/// get chained through `pics[0]`.
|
||||
pub fn notify_end_of_interrupt(&mut self, interrupt_id: u8) {
|
||||
if self.handles_interrupt(interrupt_id) {
|
||||
if self.pics[1].handles_interrupt(interrupt_id) {
|
||||
unsafe {
|
||||
self.pics[1].end_of_interrupt();
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
self.pics[0].end_of_interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#![no_std]
|
||||
#![warn(
|
||||
clippy::correctness,
|
||||
clippy::nursery,
|
||||
clippy::unnecessary_cast,
|
||||
clippy::all,
|
||||
clippy::suspicious,
|
||||
clippy::perf,
|
||||
rustdoc::missing_errors_doc,
|
||||
rustdoc::missing_panics_doc,
|
||||
tail_expr_drop_order
|
||||
)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub mod drivers;
|
||||
pub mod resources;
|
||||
pub mod threads;
|
||||
pub mod util;
|
||||
|
||||
#[allow(unused)] // We aren't using much of this right now.
|
||||
pub mod std;
|
||||
|
||||
/// Re-exports most of the IO macros as well as standard allocation stuff
|
||||
#[allow(unused)]
|
||||
pub mod prelude {
|
||||
pub use crate::std::io::*;
|
||||
pub use alloc::{
|
||||
boxed::Box,
|
||||
string::{String, ToString},
|
||||
vec::Vec,
|
||||
};
|
||||
}
|
||||
|
||||
pub use crate::drivers::io::{
|
||||
ascii::{_print, _print_log},
|
||||
serial::_serial_write,
|
||||
};
|
||||
|
||||
pub type FoundryAllocator = linked_list_allocator::LockedHeap;
|
||||
|
||||
#[global_allocator]
|
||||
/// This is now Rust's global allocator, so we can use stuff requiring heap allocations.
|
||||
static ALLOCATOR: FoundryAllocator = FoundryAllocator::empty();
|
||||
|
||||
pub const HEAP_START: usize = 0x4444_4444_0000;
|
||||
pub const HEAP_SIZE: usize = 1024 * 1024 * 1024;
|
||||
@@ -0,0 +1,578 @@
|
||||
pub static FONT: [u8; 288 * 16] = [
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 0
|
||||
0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00,
|
||||
0x00, // 1
|
||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 2
|
||||
0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 3
|
||||
0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, // 4
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 5
|
||||
0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 6
|
||||
0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 7
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 8
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, // 9
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 10
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, // 11
|
||||
0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, // 12
|
||||
0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 13
|
||||
0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00,
|
||||
0x00, // 14
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 15
|
||||
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, // 16
|
||||
0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, // 17
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 18
|
||||
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00,
|
||||
0x00, // 19
|
||||
0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00,
|
||||
0x00, // 20
|
||||
0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00,
|
||||
0x00, // 21
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 22
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 23
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 24
|
||||
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 25
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 26
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 27
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 28
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 29
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 30
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 31
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 32
|
||||
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 33
|
||||
0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 34
|
||||
0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00,
|
||||
0x00, // 35
|
||||
0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00,
|
||||
0x00, // 36
|
||||
0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00,
|
||||
0x00, // 37
|
||||
0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 38
|
||||
0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 39
|
||||
0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00,
|
||||
0x00, // 40
|
||||
0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00,
|
||||
0x00, // 41
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 42
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 43
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00,
|
||||
0x00, // 44
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 45
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 46
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, // 47
|
||||
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xd6, 0xd6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00,
|
||||
0x00, // 48
|
||||
0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 49
|
||||
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 50
|
||||
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 51
|
||||
0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00,
|
||||
0x00, // 52
|
||||
0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 53
|
||||
0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 54
|
||||
0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00,
|
||||
0x00, // 55
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 56
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, // 57
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 58
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00,
|
||||
0x00, // 59
|
||||
0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00,
|
||||
0x00, // 60
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 61
|
||||
0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00,
|
||||
0x00, // 62
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 63
|
||||
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 64
|
||||
0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 65
|
||||
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00,
|
||||
0x00, // 66
|
||||
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 67
|
||||
0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00,
|
||||
0x00, // 68
|
||||
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 69
|
||||
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00,
|
||||
0x00, // 70
|
||||
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00,
|
||||
0x00, // 71
|
||||
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 72
|
||||
0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 73
|
||||
0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, // 74
|
||||
0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00,
|
||||
0x00, // 75
|
||||
0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 76
|
||||
0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 77
|
||||
0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 78
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 79
|
||||
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00,
|
||||
0x00, // 80
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00,
|
||||
0x00, // 81
|
||||
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00,
|
||||
0x00, // 82
|
||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 83
|
||||
0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 84
|
||||
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 85
|
||||
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, // 86
|
||||
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0xee, 0x6c, 0x00, 0x00, 0x00,
|
||||
0x00, // 87
|
||||
0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 88
|
||||
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 89
|
||||
0x00, 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 90
|
||||
0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 91
|
||||
0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, // 92
|
||||
0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 93
|
||||
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 94
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, // 95
|
||||
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 96
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 97
|
||||
0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 98
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 99
|
||||
0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 100
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 101
|
||||
0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00,
|
||||
0x00, // 102
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78,
|
||||
0x00, // 103
|
||||
0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00,
|
||||
0x00, // 104
|
||||
0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 105
|
||||
0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c,
|
||||
0x00, // 106
|
||||
0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00,
|
||||
0x00, // 107
|
||||
0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 108
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 109
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00,
|
||||
0x00, // 110
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 111
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0,
|
||||
0x00, // 112
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e,
|
||||
0x00, // 113
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00,
|
||||
0x00, // 114
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 115
|
||||
0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00,
|
||||
0x00, // 116
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 117
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 118
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00,
|
||||
0x00, // 119
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 120
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8,
|
||||
0x00, // 121
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 122
|
||||
0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00,
|
||||
0x00, // 123
|
||||
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 124
|
||||
0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, // 125
|
||||
0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 126
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 127
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 128
|
||||
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 129
|
||||
0x00, 0x18, 0x18, 0x3c, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3c, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 130
|
||||
0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00,
|
||||
0x00, // 131
|
||||
0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 132
|
||||
0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00,
|
||||
0x00, // 133
|
||||
0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 134
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 135
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 136
|
||||
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 137
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
|
||||
0x00, // 138
|
||||
0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 139
|
||||
0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00,
|
||||
0x00, // 140
|
||||
0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00,
|
||||
0x00, // 141
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 142
|
||||
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 143
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 144
|
||||
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x9e, 0x3e, 0x06, 0x06, 0x00,
|
||||
0x00, // 145
|
||||
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xdc, 0x86, 0x0c, 0x18, 0x3e, 0x00,
|
||||
0x00, // 146
|
||||
0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 147
|
||||
0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 148
|
||||
0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 149
|
||||
0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00,
|
||||
0x00, // 150
|
||||
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00,
|
||||
0x00, // 151
|
||||
0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 152
|
||||
0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 153
|
||||
0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 154
|
||||
0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 155
|
||||
0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00,
|
||||
0x00, // 156
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 157
|
||||
0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 158
|
||||
0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 159
|
||||
0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 160
|
||||
0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 161
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x76, 0x36, 0x7e, 0xd8, 0xd8, 0x6e, 0x00, 0x00, 0x00,
|
||||
0x00, // 162
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00,
|
||||
0x00, // 163
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 164
|
||||
0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 165
|
||||
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 166
|
||||
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 167
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 168
|
||||
0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 169
|
||||
0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 170
|
||||
0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 171
|
||||
0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00,
|
||||
0x00, // 172
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 173
|
||||
0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 174
|
||||
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 175
|
||||
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, // 176
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 177
|
||||
0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 178
|
||||
0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 179
|
||||
0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 180
|
||||
0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 181
|
||||
0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78,
|
||||
0x00, // 182
|
||||
0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00,
|
||||
0x00, // 183
|
||||
0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00,
|
||||
0x00, // 184
|
||||
0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00,
|
||||
0x00, // 185
|
||||
0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 186
|
||||
0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 187
|
||||
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00,
|
||||
0x00, // 188
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00,
|
||||
0x00, // 189
|
||||
0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 190
|
||||
0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00,
|
||||
0x00, // 191
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00,
|
||||
0x00, // 192
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, // 193
|
||||
0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 194
|
||||
0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00,
|
||||
0x00, // 195
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 196
|
||||
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00,
|
||||
0x00, // 197
|
||||
0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 198
|
||||
0x00, 0xf8, 0xcc, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0xcc, 0xcc, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 199
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 200
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 201
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 202
|
||||
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 203
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 204
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 205
|
||||
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 206
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 207
|
||||
0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00,
|
||||
0x00, // 208
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 209
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 210
|
||||
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00,
|
||||
0x00, // 211
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 212
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 213
|
||||
0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 214
|
||||
0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 215
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 216
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 217
|
||||
0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 218
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, // 219
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 220
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 221
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 222
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 223
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 224
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 225
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 226
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 227
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 228
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 229
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 230
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 231
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 232
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 233
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 234
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 235
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 236
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 237
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 238
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 239
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 240
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 241
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 242
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 243
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 244
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 245
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 246
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 247
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 248
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 249
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 250
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 251
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 252
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 253
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 254
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 255
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 256
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, // 257
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 258
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, // 259
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 260
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, // 261
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, // 262
|
||||
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
|
||||
0xf0, // 263
|
||||
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
|
||||
0x0f, // 264
|
||||
0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11,
|
||||
0x44, // 265
|
||||
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55,
|
||||
0xaa, // 266
|
||||
0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd,
|
||||
0x77, // 267
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 268
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, // 269
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 270
|
||||
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, // 271
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 272
|
||||
0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, // 273
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 274
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, // 275
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, // 276
|
||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 277
|
||||
0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00,
|
||||
0x00, // 278
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 279
|
||||
0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, // 280
|
||||
0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, // 281
|
||||
0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 282
|
||||
0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, // 283
|
||||
0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, // 284
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, // 285
|
||||
0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00,
|
||||
0x00, // 286
|
||||
0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00,
|
||||
0x00, // 287
|
||||
];
|
||||
@@ -0,0 +1,26 @@
|
||||
// use libm::include_font;
|
||||
|
||||
use libm::include_font;
|
||||
|
||||
pub mod ibm_vga_8x16;
|
||||
|
||||
pub static FONT_SPLEEN_8X16: Font =
|
||||
Font::new(include_font!("./libk/resources/font/spleen-8x16.psf"));
|
||||
|
||||
pub static FONT_CP850_8X16: Font = Font::new(include_font!("./libk/resources/font/cp850-8x16.psf"));
|
||||
|
||||
pub struct Font {
|
||||
pub glyphs: [[u8; 16]; 512],
|
||||
}
|
||||
|
||||
impl Default for Font {
|
||||
fn default() -> Self {
|
||||
Self::new([[0; 16]; 512])
|
||||
}
|
||||
}
|
||||
|
||||
impl Font {
|
||||
pub const fn new(glyphs: [[u8; 16]; 512]) -> Self {
|
||||
Self { glyphs }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod font;
|
||||
@@ -0,0 +1,21 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
mod frame;
|
||||
mod render;
|
||||
mod window;
|
||||
|
||||
pub trait Application {
|
||||
type Output;
|
||||
|
||||
fn run(
|
||||
&mut self,
|
||||
args: Vec<String>,
|
||||
) -> impl core::future::Future<Output = Result<Self::Output, Error>> + Send;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
UnknownCommand(String),
|
||||
ApplicationFailed(String),
|
||||
KernelError(String),
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
use super::{
|
||||
render::{ColouredChar, RenderError},
|
||||
window::Window,
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
pub struct Frame<'f> {
|
||||
data: Vec<Vec<ColouredChar>>,
|
||||
window: &'f Window,
|
||||
}
|
||||
|
||||
impl Frame<'_> {
|
||||
pub fn render(&self) -> Result<(), RenderError> {
|
||||
let data: Vec<&[ColouredChar]> = self.data.iter().map(|v| v.as_slice()).collect::<Vec<_>>();
|
||||
self.window
|
||||
.render(data.as_slice())
|
||||
.map_err(|_| RenderError::Generic)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
use core::fmt::Display;
|
||||
|
||||
use crate::drivers::io::framebuffer::colour::Colour;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum RenderError {
|
||||
Generic,
|
||||
}
|
||||
|
||||
impl Display for RenderError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
Self::Generic => write!(f, "Generic render error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for RenderError {}
|
||||
|
||||
pub struct ColouredChar {
|
||||
ch: u8,
|
||||
colour: Colour,
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
use crate::{prelude::*, std::maths::geometry::Vec2};
|
||||
|
||||
use super::render::{ColouredChar, RenderError};
|
||||
|
||||
pub struct Window {
|
||||
dimensions: Vec2<usize>,
|
||||
position: Vec2<usize>,
|
||||
bordered: bool,
|
||||
opened: bool,
|
||||
title: String,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
dimensions: Vec2::new(0, 0),
|
||||
position: Vec2::new(0, 0),
|
||||
bordered: true,
|
||||
opened: false,
|
||||
title: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(&self, _data: &[&[ColouredChar]]) -> Result<(), RenderError> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
pub const fn is_bordered(&self) -> bool {
|
||||
self.bordered
|
||||
}
|
||||
|
||||
pub const fn is_open(&self) -> bool {
|
||||
self.opened
|
||||
}
|
||||
|
||||
pub const fn open(&mut self) {
|
||||
self.opened = true;
|
||||
}
|
||||
|
||||
pub const fn close(&mut self) {
|
||||
self.opened = false;
|
||||
}
|
||||
|
||||
// some basic getters and setters for utility.
|
||||
pub fn title(&'static self) -> &'static str {
|
||||
self.title.as_str()
|
||||
}
|
||||
|
||||
pub const fn dimensions(&self) -> Vec2<usize> {
|
||||
self.dimensions
|
||||
}
|
||||
|
||||
pub const fn position(&self) -> Vec2<usize> {
|
||||
self.position
|
||||
}
|
||||
|
||||
pub fn set_title(&mut self, title: String) {
|
||||
self.title = title;
|
||||
}
|
||||
|
||||
pub fn move_window(&mut self, offset: Vec2<usize>) {
|
||||
self.position += offset;
|
||||
}
|
||||
|
||||
pub const fn set_position(&mut self, position: Vec2<usize>) {
|
||||
self.position = position;
|
||||
}
|
||||
|
||||
pub const fn set_dimensions(&mut self, dimensions: Vec2<usize>) {
|
||||
self.dimensions = dimensions;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Window {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Window {
|
||||
fn drop(&mut self) {
|
||||
if self.opened {
|
||||
self.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
pub use crate::drivers::io::{
|
||||
ascii::{_print, _print_err, _print_log},
|
||||
print, print_log, printerr, println, println_log, printlnerr,
|
||||
serial::_serial_write,
|
||||
serial_print, serial_println,
|
||||
};
|
||||
|
||||
pub mod stdin {
|
||||
use alloc::string::String;
|
||||
|
||||
use crate::drivers::io::{
|
||||
ascii::WRITER,
|
||||
keyboard::{KeyStroke, get_keystroke_async, get_keystroke_optional},
|
||||
};
|
||||
|
||||
/// Reads a line of input from standard input asynchronously, returning a `String` containing
|
||||
/// the input line. Does not include the newline character at the end of the line.
|
||||
///
|
||||
/// If the user presses the abort key (usually Ctrl+C), the returned string will be empty.
|
||||
///
|
||||
/// This function is currently unimplemented.
|
||||
pub async fn read_line() -> String {
|
||||
let mut writer = WRITER.lock();
|
||||
|
||||
let mut buff = String::new();
|
||||
loop {
|
||||
match get_keystroke_async().await {
|
||||
KeyStroke::Char(c) => match c {
|
||||
'\n' => {
|
||||
writer.write_glyph(c as u8);
|
||||
return buff;
|
||||
}
|
||||
'\r' => {
|
||||
writer.write_glyph(c as u8);
|
||||
return buff;
|
||||
}
|
||||
'\x08' => {
|
||||
if !buff.is_empty() {
|
||||
buff.pop();
|
||||
writer.backspace();
|
||||
}
|
||||
}
|
||||
|
||||
c => {
|
||||
writer.write_glyph(c as u8);
|
||||
buff.push(c)
|
||||
}
|
||||
},
|
||||
KeyStroke::Enter => {
|
||||
writer.write_glyph(b'\n');
|
||||
return buff;
|
||||
}
|
||||
KeyStroke::Backspace => {
|
||||
if !buff.is_empty() {
|
||||
buff.pop();
|
||||
writer.backspace();
|
||||
}
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads a character from standard input and blocks the current task until a character is
|
||||
/// available.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This function is not yet implemented.
|
||||
pub async fn async_keystroke() -> KeyStroke {
|
||||
get_keystroke_async().await
|
||||
}
|
||||
|
||||
/// Attempt to read a character from standard input without blocking the current task.
|
||||
///
|
||||
/// If no character is available, returns `None`.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This function is not yet implemented.
|
||||
pub fn keystroke() -> Option<KeyStroke> {
|
||||
get_keystroke_optional()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
use core::ops::{AddAssign, DivAssign, MulAssign, SubAssign};
|
||||
|
||||
pub trait Coordinate:
|
||||
Copy + Clone + PartialEq + AddAssign + MulAssign + SubAssign + DivAssign
|
||||
{
|
||||
}
|
||||
|
||||
impl Coordinate for usize {}
|
||||
impl Coordinate for isize {}
|
||||
impl Coordinate for u8 {}
|
||||
impl Coordinate for i8 {}
|
||||
impl Coordinate for u16 {}
|
||||
impl Coordinate for i16 {}
|
||||
impl Coordinate for u32 {}
|
||||
impl Coordinate for i32 {}
|
||||
impl Coordinate for u64 {}
|
||||
impl Coordinate for i64 {}
|
||||
impl Coordinate for u128 {}
|
||||
impl Coordinate for i128 {}
|
||||
impl Coordinate for f32 {}
|
||||
impl Coordinate for f64 {}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Debug)]
|
||||
pub struct Vec2<T: Coordinate> {
|
||||
x: T,
|
||||
y: T,
|
||||
}
|
||||
|
||||
impl<T: Coordinate> Vec2<T> {
|
||||
pub const fn new(x: T, y: T) -> Self {
|
||||
Self { x, y }
|
||||
}
|
||||
|
||||
pub fn into<S: Coordinate + From<T>>(&self) -> Vec2<S> {
|
||||
Vec2::new(self.x.into(), self.y.into())
|
||||
}
|
||||
|
||||
pub const fn x(&self) -> T {
|
||||
self.x
|
||||
}
|
||||
|
||||
pub const fn y(&self) -> T {
|
||||
self.y
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Coordinate> AddAssign for Vec2<T> {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
self.x += rhs.x;
|
||||
self.y += rhs.y;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Coordinate> SubAssign for Vec2<T> {
|
||||
fn sub_assign(&mut self, rhs: Self) {
|
||||
self.x -= rhs.x;
|
||||
self.y -= rhs.y;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Coordinate> MulAssign<T> for Vec2<T> {
|
||||
fn mul_assign(&mut self, rhs: T) {
|
||||
self.x *= rhs;
|
||||
self.y *= rhs;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Coordinate> DivAssign<T> for Vec2<T> {
|
||||
fn div_assign(&mut self, rhs: T) {
|
||||
self.x /= rhs;
|
||||
self.y /= rhs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod geometry;
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod application;
|
||||
pub mod io;
|
||||
pub mod maths;
|
||||
@@ -0,0 +1,113 @@
|
||||
use core::arch::asm;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Thread {
|
||||
id: usize,
|
||||
/// This shall be default before the program is interrupted, otherwise it will store
|
||||
/// CPU registers etc to be restored on context switch.
|
||||
ctx: ThreadContext,
|
||||
}
|
||||
|
||||
/// CPU state to be saved on context switches.
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct ThreadContext {
|
||||
/// Accumulator register.
|
||||
rax: u64,
|
||||
/// Base register.
|
||||
rbx: u64,
|
||||
/// Counter register.
|
||||
rcx: u64,
|
||||
/// Data register.
|
||||
rdx: u64,
|
||||
/// Source index register.
|
||||
rsi: u64,
|
||||
/// Destination index register.
|
||||
rdi: u64,
|
||||
/// Base pointer register.
|
||||
rbp: u64,
|
||||
/// Stack pointer register.
|
||||
rsp: u64,
|
||||
/// An extended register.
|
||||
r8: u64,
|
||||
/// An extended register.
|
||||
r9: u64,
|
||||
/// An extended register.
|
||||
r10: u64,
|
||||
/// An extended register.
|
||||
r11: u64,
|
||||
/// An extended register.
|
||||
r12: u64,
|
||||
/// An extended register.
|
||||
r13: u64,
|
||||
/// An extended register.
|
||||
r14: u64,
|
||||
/// An extended register.
|
||||
r15: u64,
|
||||
/// The instruction pointer.
|
||||
rip: u64,
|
||||
/// RFLAGS register.
|
||||
rflags: u64,
|
||||
}
|
||||
|
||||
impl ThreadContext {
|
||||
/// Saves the current registers of the CPU before a context switch
|
||||
/// to be restored later.
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
/// This function should ONLY be called in interrupt handlers such
|
||||
/// as that of the timer. This will then save registers as required
|
||||
///
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This function is unsafe because of the usage of inline ASM.
|
||||
#[inline(always)]
|
||||
pub unsafe fn save_registers() -> Self {
|
||||
let mut context = Self::default();
|
||||
unsafe {
|
||||
asm!(
|
||||
"mov {0}, rax",
|
||||
"mov {1}, rbx",
|
||||
"mov {2}, rcx",
|
||||
"mov {3}, rdx",
|
||||
"mov {4}, rsi",
|
||||
"mov {5}, rdi",
|
||||
"mov {6}, rbp",
|
||||
"mov {7}, rsp",
|
||||
"mov {8}, r8",
|
||||
"mov {9}, r9",
|
||||
"mov {10}, r10",
|
||||
"mov {11}, r11",
|
||||
"mov {12}, r12",
|
||||
"mov {13}, r13",
|
||||
"mov {14}, r14",
|
||||
"mov {15}, r15",
|
||||
"lea {16}, [rip]",
|
||||
"pushf",
|
||||
"pop {17}",
|
||||
out(reg) context.rax,
|
||||
out(reg) context.rbx,
|
||||
out(reg) context.rcx,
|
||||
out(reg) context.rdx,
|
||||
out(reg) context.rsi,
|
||||
out(reg) context.rdi,
|
||||
out(reg) context.rbp,
|
||||
out(reg) context.rsp,
|
||||
out(reg) context.r8,
|
||||
out(reg) context.r9,
|
||||
out(reg) context.r10,
|
||||
out(reg) context.r11,
|
||||
out(reg) context.r12,
|
||||
out(reg) context.r13,
|
||||
out(reg) context.r14,
|
||||
out(reg) context.r15,
|
||||
out(reg) context.rip,
|
||||
out(reg) context.rflags,
|
||||
);
|
||||
}
|
||||
|
||||
context
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod shell;
|
||||
@@ -0,0 +1,40 @@
|
||||
// use x86_64::registers::rflags::read;
|
||||
|
||||
use crate::{drivers::io::ascii::clear_screen, prelude::stdin::read_line, print, println};
|
||||
|
||||
static FETCH: &str = "
|
||||
$$$$$$$$\\ $$\\
|
||||
$$ _____| $$ |
|
||||
$$ | $$$$$$\\ $$\\ $$\\ $$$$$$$\\ $$$$$$$ | $$$$$$\\ $$\\ $$\\
|
||||
$$$$$\\ $$ __$$\\ $$ | $$ |$$ __$$\\ $$ __$$ |$$ __$$\\ $$ | $$ |
|
||||
$$ __|$$ / $$ |$$ | $$ |$$ | $$ |$$ / $$ |$$ | \\__|$$ | $$ |
|
||||
$$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | $$ |
|
||||
$$ | \\$$$$$$ |\\$$$$$$ |$$ | $$ |\\$$$$$$$ |$$ | \\$$$$$$$ |
|
||||
\\__| \\______/ \\______/ \\__| \\__| \\_______|\\__| \\____$$ |
|
||||
$$$$$$\\ $$$$$$\\ $$\\ $$\\ $$\\ $$\\ $$ |
|
||||
$$ __$$\\ $$ __$$\\ $$ | $$ |$$$$ | \\$$$$$$ |
|
||||
$$ / $$ |$$ / \\__| $$ | $$ |\\_$$ | \\______/
|
||||
$$ | $$ |\\$$$$$$\\ \\$$\\ $$ | $$ |
|
||||
$$ | $$ | \\____$$\\ \\$$\\$$ / $$ |
|
||||
$$ | $$ |$$\\ $$ | \\$$$ / $$ |
|
||||
$$$$$$ |\\$$$$$$ | \\$ / $$$$$$\\
|
||||
\\______/ \\______/ \\_/ \\______|
|
||||
";
|
||||
|
||||
pub async fn shell() {
|
||||
println!("{}", FETCH);
|
||||
|
||||
loop {
|
||||
print!(" Shell> ");
|
||||
let line = read_line().await;
|
||||
match line.as_str() {
|
||||
"fetch" => {
|
||||
println!("{}", FETCH);
|
||||
}
|
||||
"clear" => clear_screen(),
|
||||
_ => {
|
||||
println!("Unknown command: {}", line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "libm"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
[dependencies]
|
||||
darling = "0.20.10"
|
||||
proc-macro2 = "1.0.93"
|
||||
quote = "1.0.38"
|
||||
syn = "2.0.98"
|
||||
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
@@ -0,0 +1,99 @@
|
||||
#![warn(
|
||||
clippy::correctness,
|
||||
clippy::nursery,
|
||||
clippy::unnecessary_cast,
|
||||
clippy::all,
|
||||
clippy::suspicious,
|
||||
clippy::perf,
|
||||
rustdoc::missing_errors_doc,
|
||||
rustdoc::missing_panics_doc
|
||||
)]
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Seek, SeekFrom};
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{LitStr, parse_macro_input};
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
#[proc_macro]
|
||||
pub fn include_font(item: TokenStream) -> TokenStream {
|
||||
let filename = parse_macro_input!(item as LitStr);
|
||||
let file_path = filename.value();
|
||||
|
||||
println!("Loading font: [{}]", file_path);
|
||||
|
||||
let font_bytes = match load_file(file_path) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(why) => panic!("{}", why),
|
||||
};
|
||||
|
||||
let font_data = match Font::new(font_bytes) {
|
||||
Ok(font) => font.0,
|
||||
Err(why) => panic!("{}", why),
|
||||
};
|
||||
|
||||
quote!(
|
||||
[
|
||||
#(
|
||||
[#(#font_data),*]
|
||||
),*
|
||||
]
|
||||
)
|
||||
.into()
|
||||
}
|
||||
|
||||
struct Font([[u8; 16]; 512]);
|
||||
|
||||
impl Font {
|
||||
const MAGIC: u16 = 0x3604;
|
||||
|
||||
pub fn new(data: [u8; (32 + 2) * 512 + 4]) -> Result<Self, &'static str> {
|
||||
let magic: u16 = (data[0] as u16) << 8 | data[1] as u16;
|
||||
let mode = data[2];
|
||||
let size = data[3];
|
||||
|
||||
if magic != Self::MAGIC {
|
||||
return Err("Magic value is invalid!");
|
||||
}
|
||||
|
||||
let has_512_glyphs = (mode & 0x01) != 0;
|
||||
let mut glyphs = [[0; 16]; 512];
|
||||
let glyph_count = if has_512_glyphs { 512 } else { 256 };
|
||||
|
||||
for i in 0..(glyph_count as usize) {
|
||||
let mut buff: [u8; 16] = [0; 16];
|
||||
for j in 0..(size as usize) {
|
||||
buff[j] = data[4 + i * (size as usize) + j];
|
||||
}
|
||||
glyphs[i] = buff;
|
||||
}
|
||||
|
||||
Ok(Self(glyphs))
|
||||
}
|
||||
}
|
||||
|
||||
type FileContents = [u8; (32 + 2) * 512 + 4];
|
||||
fn load_file(filename: String) -> Result<FileContents, std::io::Error> {
|
||||
let mut buf = [0; (32 + 2) * 512 + 4];
|
||||
let mut f = File::open(filename).unwrap();
|
||||
f.seek(SeekFrom::Start(0)).unwrap();
|
||||
|
||||
loop {
|
||||
match f.read(&mut buf) {
|
||||
Ok(read) => {
|
||||
if read == 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(why) => {
|
||||
eprintln!("Failed to read PS1 font file: {}", why);
|
||||
return Err(why);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(buf)
|
||||
}
|
||||
@@ -13,8 +13,9 @@ set -e
|
||||
trap 'echo -e "${RED}${BOLD}error${NC}: build failed" >&2' ERR
|
||||
|
||||
# Get absolute path to project root
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
project_root=$(cd "$script_dir/.." &>/dev/null && pwd)
|
||||
build_dir="$project_root/build"
|
||||
iso_root="$build_dir/iso_root"
|
||||
|
||||
# Logging functions
|
||||
info() {
|
||||
@@ -47,13 +48,8 @@ copy_file() {
|
||||
cp "$1" "$2" || error $3
|
||||
}
|
||||
|
||||
build_dir="$project_root/build"
|
||||
iso_root="$build_dir/iso_root"
|
||||
|
||||
# Check if we're running tests
|
||||
is_test=0
|
||||
if [[ $1 == *"deps"* ]]; then
|
||||
is_test=1
|
||||
kernel_path="$1"
|
||||
else
|
||||
# Build the kernel normally
|
||||
@@ -111,76 +107,3 @@ xorriso -as mkisofs -R -r -J -b boot/limine/limine-bios-cd.bin \
|
||||
# Install Limine
|
||||
info "Installing Limine bootloader"
|
||||
"$build_dir/limine/limine" bios-install "$build_dir/image.iso" || error "failed to install limine"
|
||||
|
||||
# Check if KVM is available
|
||||
if [ "${KVM_FLAG:-enable}" = "disable" ]; then
|
||||
warning "KVM acceleration disabled by user"
|
||||
kvm_flag=""
|
||||
elif [ -c "/dev/kvm" ] && [ -w "/dev/kvm" ]; then
|
||||
info "KVM acceleration enabled"
|
||||
kvm_flag="-enable-kvm"
|
||||
else
|
||||
warning "KVM acceleration not available (is kvm module loaded?)"
|
||||
kvm_flag=""
|
||||
fi
|
||||
|
||||
# Check if we're running in debug mode
|
||||
if [[ "$(cargo metadata --format-version=1 | jq -r '.workspace_members[0]' | cut -d' ' -f2)" == "(debug)" ]]; then
|
||||
debug_flags="-s -S"
|
||||
else
|
||||
debug_flags=""
|
||||
fi
|
||||
|
||||
# Set up test-specific flags
|
||||
if [ $is_test -eq 1 ]; then
|
||||
test_flags="-device isa-debug-exit,iobase=0xf4,iosize=0x04 -display none"
|
||||
serial_flags="-serial stdio"
|
||||
else
|
||||
test_flags=""
|
||||
# serial_flags="-serial tcp:127.0.0.1:1234,server -monitor telnet:127.0.0.1:1235,server"
|
||||
serial_flags="-serial stdio"
|
||||
fi
|
||||
|
||||
# Run in QEMU
|
||||
if [[ ${QEMU_FLAGS} == *-S* ]]; then
|
||||
info "Running OS in QEMU with GDB debugging enabled"
|
||||
info "To connect GDB, run: gdb"
|
||||
info "At the GDB prompt, type: target remote localhost:1234"
|
||||
else
|
||||
info "Running OS in QEMU..."
|
||||
fi
|
||||
|
||||
check_test_res() {
|
||||
qemu_exit_code=$?
|
||||
if [ $qemu_exit_code -eq 33 ]; then
|
||||
# Success case (0x10 << 1) | 1 = 33
|
||||
info "All tests passed"
|
||||
exit 0
|
||||
elif [ $qemu_exit_code -eq 35 ]; then
|
||||
# Failure case (0x11 << 1) | 1 = 35
|
||||
warning "Some tests failed"
|
||||
exit 1
|
||||
else
|
||||
# Any other exit code is treated as a failure
|
||||
warning "Some tests failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
kvm_flag=""
|
||||
|
||||
trap 'check_test_res "tests completed"' ERR
|
||||
|
||||
cd "$project_root"
|
||||
qemu-system-x86_64 -M q35 \
|
||||
${kvm_flag} \
|
||||
-cdrom "$build_dir/image.iso" \
|
||||
-boot d \
|
||||
-m 2G \
|
||||
${serial_flags} \
|
||||
-no-reboot \
|
||||
${test_flags} \
|
||||
${debug_flags} \
|
||||
${QEMU_FLAGS:-}
|
||||
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
|
||||
source scripts/build.sh
|
||||
|
||||
warning "This script will OVERWRITE whatever media you throw at it\nwith the built ISO."
|
||||
|
||||
info "sudo ./hardware.sh /dev/yourdisk"
|
||||
|
||||
if ! echo "$1" | grep -q "/dev"; then
|
||||
error "invalid device"
|
||||
fi
|
||||
|
||||
read -p "Confirm (y/n): " confirmation
|
||||
if [ "$confirmation" != "y" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
dd if=./build/image.iso of="$1"
|
||||
Executable
+109
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script originally written by zxq5, I added separate scripts to remove `jq` dependency.
|
||||
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
|
||||
source $script_dir/build.sh
|
||||
|
||||
# Error handling
|
||||
set -e
|
||||
trap 'echo -e "${RED}${BOLD}error${NC}: build failed" >&2' ERR
|
||||
|
||||
echo -e "${GREEN}${BOLD} Running kernel in debug mode."
|
||||
|
||||
# Check if KVM is available
|
||||
if [ "${KVM_FLAG:-enable}" = "disable" ]; then
|
||||
warning "KVM acceleration disabled by user"
|
||||
kvm_flag=""
|
||||
elif [ -c "/dev/kvm" ] && [ -w "/dev/kvm" ]; then
|
||||
info "KVM acceleration enabled"
|
||||
kvm_flag="-enable-kvm"
|
||||
else
|
||||
warning "KVM acceleration not available (is kvm module loaded?)"
|
||||
kvm_flag=""
|
||||
fi
|
||||
|
||||
# Enable using GDB with $USE_GDB.
|
||||
if [ $USE_GDB ]; then
|
||||
debug_flags="-s -S"
|
||||
else
|
||||
debug_flags=""
|
||||
fi
|
||||
|
||||
# Set up test-specific flags
|
||||
if [ $is_test -eq 1 ]; then
|
||||
test_flags="-device isa-debug-exit,iobase=0xf4,iosize=0x04 -display none"
|
||||
serial_flags="-serial stdio"
|
||||
else
|
||||
test_flags=""
|
||||
# serial_flags="-serial tcp:127.0.0.1:1234,server -monitor telnet:127.0.0.1:1235,server"
|
||||
serial_flags="-serial stdio"
|
||||
fi
|
||||
|
||||
# Set up VM memory
|
||||
if [ $VM_MEMORY ]; then
|
||||
vm_memory_flag="-m $VM_MEMORY"
|
||||
else
|
||||
vm_memory_flag="-m 2G"
|
||||
fi
|
||||
|
||||
# Set up boot flags
|
||||
if [ $USE_LEGACY_BIOS ]; then
|
||||
boot_flags=""
|
||||
else
|
||||
# Check for the presence of the OVMF firmware.
|
||||
if [ ! -f $build_dir/RELEASEX64_OVMF_CODE.fd ]; then
|
||||
info "Downloading OVMF UEFI firmware for QEMU"
|
||||
info "To disable this, set USE_LEGACY_BIOS=1."
|
||||
pushd $build_dir
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_CODE.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_VARS.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
popd
|
||||
fi
|
||||
|
||||
boot_flags="-drive if=pflash,format=raw,readonly=on,file=$build_dir/RELEASEX64_OVMF_CODE.fd \
|
||||
-drive if=pflash,format=raw,file=$build_dir/RELEASEX64_OVMF_VARS.fd"
|
||||
fi
|
||||
|
||||
# Run in QEMU
|
||||
if [[ ${QEMU_FLAGS} == *-S* ]]; then
|
||||
info "Running OS in QEMU with GDB debugging enabled"
|
||||
info "To connect GDB, run: gdb"
|
||||
info "At the GDB prompt, type: target remote localhost:1234"
|
||||
else
|
||||
info "Running OS in QEMU..."
|
||||
fi
|
||||
|
||||
check_test_res() {
|
||||
qemu_exit_code=$?
|
||||
if [ $qemu_exit_code -eq 33 ]; then
|
||||
# Success case (0x10 << 1) | 1 = 33
|
||||
info "All tests passed"
|
||||
exit 0
|
||||
elif [ $qemu_exit_code -eq 35 ]; then
|
||||
# Failure case (0x11 << 1) | 1 = 35
|
||||
warning "Some tests failed"
|
||||
exit 1
|
||||
else
|
||||
# Any other exit code is treated as a failure
|
||||
warning "Some tests failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
trap 'check_test_res "tests completed"' ERR
|
||||
|
||||
cd "$project_root"
|
||||
qemu-system-x86_64 -M q35 \
|
||||
-cdrom "$build_dir/image.iso" \
|
||||
${kvm_flag} \
|
||||
-boot d \
|
||||
${vm_memory_flag} \
|
||||
${serial_flags} \
|
||||
-no-reboot \
|
||||
${test_flags} \
|
||||
${debug_flags} \
|
||||
${boot_flags} \
|
||||
${QEMU_FLAGS:-}
|
||||
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script originally written by zxq5, I added separate scripts to remove `jq` dependency.
|
||||
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
|
||||
source $script_dir/build.sh
|
||||
|
||||
# Error handling
|
||||
set -e
|
||||
trap 'echo -e "${RED}${BOLD}error${NC}: build failed" >&2' ERR
|
||||
|
||||
echo -e "${GREEN}${BOLD} Running kernel in release mode."
|
||||
|
||||
|
||||
if [ $VM_MEMORY ]; then
|
||||
vm_memory_flag="-m $VM_MEMORY"
|
||||
else
|
||||
vm_memory_flag="-m 2G"
|
||||
fi
|
||||
|
||||
# Check if KVM is available
|
||||
if [ "${KVM_FLAG:-enable}" = "disable" ]; then
|
||||
warning "KVM acceleration disabled by user"
|
||||
kvm_flag=""
|
||||
elif [ -c "/dev/kvm" ] && [ -w "/dev/kvm" ]; then
|
||||
info "KVM acceleration enabled"
|
||||
kvm_flag="-enable-kvm"
|
||||
else
|
||||
warning "KVM acceleration not available (is kvm module loaded?)"
|
||||
kvm_flag=""
|
||||
fi
|
||||
|
||||
if [ $USE_LEGACY_BIOS ]; then
|
||||
boot_flags=""
|
||||
else
|
||||
# Check for the presence of the OVMF firmware.
|
||||
if [ ! -f $build_dir/RELEASEX64_OVMF_CODE.fd ]; then
|
||||
info "Downloading OVMF UEFI firmware for QEMU"
|
||||
info "To disable this, set USE_LEGACY_BIOS=1."
|
||||
pushd $build_dir
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_CODE.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
curl https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF_VARS.fd -LO || error "failed to download OVMF firmware for UEFI"
|
||||
popd
|
||||
fi
|
||||
|
||||
boot_flags="-drive if=pflash,format=raw,readonly=on,file=$build_dir/RELEASEX64_OVMF_CODE.fd \
|
||||
-drive if=pflash,format=raw,file=$build_dir/RELEASEX64_OVMF_VARS.fd"
|
||||
fi
|
||||
|
||||
cd "$project_root"
|
||||
qemu-system-x86_64 -M q35 \
|
||||
${kvm_flag} \
|
||||
-cdrom "$build_dir/image.iso" \
|
||||
-boot d \
|
||||
${vm_memory_flag} \
|
||||
${serial_flags} \
|
||||
-no-reboot \
|
||||
${boot_flags}
|
||||
|
||||
Reference in New Issue
Block a user