forked from AbleOS/ableos
Compare commits
10 commits
0bc757164f
...
dacd501eed
Author | SHA1 | Date | |
---|---|---|---|
Christian Westrom | dacd501eed | ||
Able | f64f654610 | ||
Able | 7d4b12a103 | ||
Able | 758629df0a | ||
Able | 04a449965b | ||
koniifer | 0bbc76124f | ||
Able | 6ad68dabac | ||
Able | 07c7d52b8c | ||
Able | 2edc8148ca | ||
5f59f05dce |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
target/
|
target/
|
||||||
|
.direnv
|
||||||
|
|
69
Cargo.lock
generated
69
Cargo.lock
generated
|
@ -142,15 +142,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.7.1"
|
version = "1.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
|
checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.1.20"
|
version = "1.1.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "45bcde016d64c21da4be18b655631e5ab6d3107607e71a73a9f53eb48aae23fb"
|
checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
@ -390,35 +390,24 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#ece9bb8bf21507b5d2a7c870f55aa2e9c5ab9f26"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0e9f4402cb686da817ef876abd764676e262759a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hbbytecode"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#4a9b9de87fd56a6bbd5d0ca2c622104d4807612b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#ece9bb8bf21507b5d2a7c870f55aa2e9c5ab9f26"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0e9f4402cb686da817ef876abd764676e262759a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
"hbbytecode",
|
||||||
|
"hbvm",
|
||||||
|
"regalloc2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#ece9bb8bf21507b5d2a7c870f55aa2e9c5ab9f26"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0e9f4402cb686da817ef876abd764676e262759a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
"hbbytecode",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hbvm"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#4a9b9de87fd56a6bbd5d0ca2c622104d4807612b"
|
|
||||||
dependencies = [
|
|
||||||
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes.git)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -597,7 +586,7 @@ dependencies = [
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"embedded-graphics",
|
"embedded-graphics",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"hbvm 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes.git)",
|
"hbvm",
|
||||||
"limine",
|
"limine",
|
||||||
"log",
|
"log",
|
||||||
"sbi",
|
"sbi",
|
||||||
|
@ -647,18 +636,18 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos"
|
name = "logos"
|
||||||
version = "0.14.1"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ff1ceb190eb9bdeecdd8f1ad6a71d6d632a50905948771718741b5461fb01e13"
|
checksum = "1c6b6e02facda28ca5fb8dbe4b152496ba3b1bd5a4b40bb2b1b2d8ad74e0f39b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos-derive",
|
"logos-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos-codegen"
|
name = "logos-codegen"
|
||||||
version = "0.14.1"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "90be66cb7bd40cb5cc2e9cfaf2d1133b04a3d93b72344267715010a466e0915a"
|
checksum = "b32eb6b5f26efacd015b000bfc562186472cd9b34bdba3f6b264e2a052676d10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"beef",
|
"beef",
|
||||||
"fnv",
|
"fnv",
|
||||||
|
@ -671,9 +660,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos-derive"
|
name = "logos-derive"
|
||||||
version = "0.14.1"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "45154231e8e96586b39494029e58f12f8ffcb5ecf80333a603a13aa205ea8cbd"
|
checksum = "3e5d0c5463c911ef55624739fc353238b4e310f0144be1f875dc42fec6bfd5ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos-codegen",
|
"logos-codegen",
|
||||||
]
|
]
|
||||||
|
@ -899,6 +888,16 @@ dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regalloc2"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "git+https://github.com/jakubDoka/regalloc2#52b2bbe908e78af1715de88f562f62a83e36ca96"
|
||||||
|
dependencies = [
|
||||||
|
"hashbrown",
|
||||||
|
"rustc-hash",
|
||||||
|
"smallvec",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
@ -1371,18 +1370,18 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-normalization"
|
name = "unicode-normalization"
|
||||||
version = "0.1.23"
|
version = "0.1.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
|
checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.5"
|
version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a"
|
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "untrusted"
|
name = "untrusted"
|
||||||
|
@ -1527,9 +1526,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webpki-roots"
|
name = "webpki-roots"
|
||||||
version = "0.26.5"
|
version = "0.26.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a"
|
checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
]
|
]
|
||||||
|
|
|
@ -22,3 +22,5 @@ For running AbleOS, `repbuild` uses QEMU.
|
||||||
|
|
||||||
# Developing
|
# Developing
|
||||||
There is a new work in progress developer tool for hblang.
|
There is a new work in progress developer tool for hblang.
|
||||||
|
|
||||||
|
There is also a flake you can run by typing `nix develop .`.
|
||||||
|
|
57
flake.lock
Normal file
57
flake.lock
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1726560853,
|
||||||
|
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 0,
|
||||||
|
"narHash": "sha256-6H95HGJHhEZtyYA3rIQpvamMKAGoa8Yh2rFV29QnuGw=",
|
||||||
|
"path": "/nix/store/nra828scc8qs92b9pxra5csqzffb6hpl-source",
|
||||||
|
"type": "path"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
62
flake.nix
Normal file
62
flake.nix
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
description = "ableos flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
# Just use whatever versions are already on the system for a devshell
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShell = pkgs.mkShell rec {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
clang
|
||||||
|
llvmPackages.bintools
|
||||||
|
rustup
|
||||||
|
qemu_full
|
||||||
|
# OMVFFull
|
||||||
|
# OMVF
|
||||||
|
];
|
||||||
|
extraCmds = '''';
|
||||||
|
RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain.toml;
|
||||||
|
# https://github.com/rust-lang/rust-bindgen#environment-variables
|
||||||
|
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
|
||||||
|
shellHook = ''
|
||||||
|
export REPBUILD_QEMU_FIRMWARE_PATH=${pkgs.OVMF.fd}/FV/OVMF.fd
|
||||||
|
|
||||||
|
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
|
||||||
|
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
|
||||||
|
'';
|
||||||
|
# Add precompiled library to rustc search path
|
||||||
|
RUSTFLAGS = (
|
||||||
|
builtins.map (a: "-L ${a}/lib") [
|
||||||
|
# add libraries here (e.g. pkgs.libvmi)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
# Add glibc, clang, glib and other headers to bindgen search path
|
||||||
|
BINDGEN_EXTRA_CLANG_ARGS =
|
||||||
|
# Includes with normal include path
|
||||||
|
(builtins.map (a: ''-I"${a}/include"'') [
|
||||||
|
# add dev libraries here (e.g. pkgs.libvmi.dev)
|
||||||
|
pkgs.glibc.dev
|
||||||
|
])
|
||||||
|
# Includes with special directory paths
|
||||||
|
++ [
|
||||||
|
''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
|
||||||
|
''-I"${pkgs.glib.dev}/include/glib-2.0"''
|
||||||
|
"-I${pkgs.glib.out}/lib/glib-2.0/include/"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ version = "0.2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embedded-graphics = "0.8"
|
embedded-graphics = "0.8"
|
||||||
hbvm.git = "https://git.ablecorp.us/ableos/holey-bytes.git"
|
hbvm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
spin = "0.9"
|
spin = "0.9"
|
||||||
slab = { version = "0.4", default-features = false }
|
slab = { version = "0.4", default-features = false }
|
||||||
|
|
|
@ -22,7 +22,7 @@ unsafe impl Send for SerialConsole {}
|
||||||
|
|
||||||
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||||||
SERIAL_CONSOLE.lock().write_fmt(args)?;
|
SERIAL_CONSOLE.lock().write_fmt(args)?;
|
||||||
TERMINAL_LOGGER.lock().write_fmt(args)?;
|
// TERMINAL_LOGGER.lock().write_fmt(args)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
35
kernel/src/exe_format.rs
Normal file
35
kernel/src/exe_format.rs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
enum Sections {
|
||||||
|
Header,
|
||||||
|
Code,
|
||||||
|
Data,
|
||||||
|
Debug,
|
||||||
|
Config,
|
||||||
|
Metadata,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 64 byte header
|
||||||
|
#[repr(packed)]
|
||||||
|
struct AbleOsExecutableHeader {
|
||||||
|
magic_number: [u8; 3],
|
||||||
|
executable_version: u32,
|
||||||
|
|
||||||
|
code_length: u64,
|
||||||
|
data_length: u64,
|
||||||
|
debug_length: u64,
|
||||||
|
config_length: u64,
|
||||||
|
metadata_length: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AbleOsExecutableHeader {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
magic_number: [0x15, 0x91, 0xD2],
|
||||||
|
executable_version: 0,
|
||||||
|
code_length: 0,
|
||||||
|
config_length: 0,
|
||||||
|
data_length: 0,
|
||||||
|
debug_length: 0,
|
||||||
|
metadata_length: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,7 +112,8 @@ pub fn handler(vm: &mut Vm) {
|
||||||
1 => unsafe {
|
1 => unsafe {
|
||||||
let size = msg_vec[1];
|
let size = msg_vec[1];
|
||||||
let addr = u16::from_le_bytes(msg_vec[2..4].try_into().unwrap());
|
let addr = u16::from_le_bytes(msg_vec[2..4].try_into().unwrap());
|
||||||
trace!("Setting address {}", addr);
|
// info!("Setting address {}", addr);
|
||||||
|
|
||||||
match size {
|
match size {
|
||||||
0 => x86_out(addr, msg_vec[4]),
|
0 => x86_out(addr, msg_vec[4]),
|
||||||
1 => x86_out(
|
1 => x86_out(
|
||||||
|
@ -211,7 +212,7 @@ pub fn handler(vm: &mut Vm) {
|
||||||
x86_64::instructions::port::Port::new(address).write(value);
|
x86_64::instructions::port::Port::new(address).write(value);
|
||||||
}
|
}
|
||||||
let x = hbvm::value::Value(unsafe { x86_in(r2 as u16) } as u64);
|
let x = hbvm::value::Value(unsafe { x86_in(r2 as u16) } as u64);
|
||||||
info!("Read {:?} from Port {:?}", x, r2);
|
// info!("Read {:?} from Port {:?}", x, r2);
|
||||||
vm.registers[3] = x
|
vm.registers[3] = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use {
|
||||||
hashbrown::HashMap,
|
hashbrown::HashMap,
|
||||||
hbvm::mem::Address,
|
hbvm::mem::Address,
|
||||||
limine::{Framebuffer, FramebufferRequest, NonNullPtr},
|
limine::{Framebuffer, FramebufferRequest, NonNullPtr},
|
||||||
log::{debug, trace},
|
log::{debug, error, trace},
|
||||||
spin::{Lazy, Mutex},
|
spin::{Lazy, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
|
||||||
|
|
||||||
disp.set_attribute("width", fb1.width);
|
disp.set_attribute("width", fb1.width);
|
||||||
disp.set_attribute("height", fb1.height);
|
disp.set_attribute("height", fb1.height);
|
||||||
disp.set_attribute("bits per pixel", fb1.bpp);
|
disp.set_attribute("bpp", fb1.bpp);
|
||||||
disp.set_attribute("pitch", fb1.pitch);
|
disp.set_attribute("pitch", fb1.pitch);
|
||||||
dt.devices.insert("Displays".to_string(), alloc::vec![disp]);
|
dt.devices.insert("Displays".to_string(), alloc::vec![disp]);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,28 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
|
||||||
|
|
||||||
log::info!("Spawning {} with arguments \"{}\"", module.path, cmd);
|
log::info!("Spawning {} with arguments \"{}\"", module.path, cmd);
|
||||||
|
|
||||||
let mut thr = ExecThread::new(&module.bytes, Address::new(0));
|
// decode AbleOS Executable format
|
||||||
|
let header = &module.bytes[0..46];
|
||||||
|
let magic_slice = &header[0..3];
|
||||||
|
if magic_slice != [0x15, 0x91, 0xD2] {
|
||||||
|
log::error!("Invalid magic number at the start of executable.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let executable_format_version = u32::from_le_bytes(header[3..7].try_into().unwrap());
|
||||||
|
let offset = if executable_format_version == 0 {
|
||||||
|
47
|
||||||
|
} else {
|
||||||
|
error!("Invalid executable format.");
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
let code_length = u64::from_le_bytes(header[7..15].try_into().unwrap());
|
||||||
|
let data_length = u64::from_le_bytes(header[15..23].try_into().unwrap());
|
||||||
|
let end = (code_length + data_length) as usize;
|
||||||
|
log::info!("{code_length} + {data_length} = {end}");
|
||||||
|
|
||||||
|
let mut thr = ExecThread::new(&module.bytes[offset..end], Address::new(0));
|
||||||
if cmd_len > 0 {
|
if cmd_len > 0 {
|
||||||
thr.set_arguments(cmd.as_ptr() as u64, cmd_len);
|
thr.set_arguments(cmd.as_ptr() as u64, cmd_len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ mod arch;
|
||||||
mod bootmodules;
|
mod bootmodules;
|
||||||
mod capabilities;
|
mod capabilities;
|
||||||
mod device_tree;
|
mod device_tree;
|
||||||
|
mod exe_format;
|
||||||
mod handle;
|
mod handle;
|
||||||
mod holeybytes;
|
mod holeybytes;
|
||||||
mod ipc;
|
mod ipc;
|
||||||
|
|
|
@ -345,11 +345,12 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
com.args([
|
com.args([
|
||||||
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||||
"-drive", "file=target/disk.img,format=raw",
|
"-drive", "file=target/disk.img,format=raw",
|
||||||
"-m", "4G",
|
"-device", "vmware-svga",
|
||||||
"-smp", "cores=4",
|
"-m", "2G",
|
||||||
"-enable-kvm",
|
"-smp", "1",
|
||||||
|
"-machine", "accel=kvm",
|
||||||
"-cpu", "host",
|
"-cpu", "host",
|
||||||
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04"
|
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
Target::Riscv64Virt => {
|
Target::Riscv64Virt => {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2024-07-27"
|
channel = "nightly-2024-07-27"
|
||||||
components = ["rust-src", "llvm-tools"]
|
components = ["rust-src", "llvm-tools", "rust-analyzer"]
|
||||||
|
|
41
shell.nix
41
shell.nix
|
@ -1,41 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> { } }:
|
|
||||||
pkgs.mkShell rec {
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
clang
|
|
||||||
llvmPackages.bintools
|
|
||||||
rustup
|
|
||||||
qemu_full
|
|
||||||
# OMVFFull
|
|
||||||
# OMVF
|
|
||||||
];
|
|
||||||
extraCmds = '''';
|
|
||||||
RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain.toml;
|
|
||||||
# https://github.com/rust-lang/rust-bindgen#environment-variables
|
|
||||||
LIBCLANG_PATH =
|
|
||||||
pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
|
|
||||||
shellHook = ''
|
|
||||||
export REPBUILD_QEMU_FIRMWARE_PATH=${pkgs.OVMF.fd}/FV/OVMF.fd
|
|
||||||
|
|
||||||
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
|
|
||||||
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
|
|
||||||
'';
|
|
||||||
# Add precompiled library to rustc search path
|
|
||||||
RUSTFLAGS = (builtins.map (a: "-L ${a}/lib") [
|
|
||||||
# add libraries here (e.g. pkgs.libvmi)
|
|
||||||
]);
|
|
||||||
# Add glibc, clang, glib and other headers to bindgen search path
|
|
||||||
BINDGEN_EXTRA_CLANG_ARGS =
|
|
||||||
# Includes with normal include path
|
|
||||||
(builtins.map (a: ''-I"${a}/include"'') [
|
|
||||||
# add dev libraries here (e.g. pkgs.libvmi.dev)
|
|
||||||
pkgs.glibc.dev
|
|
||||||
])
|
|
||||||
# Includes with special directory paths
|
|
||||||
++ [
|
|
||||||
''
|
|
||||||
-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
|
|
||||||
''-I"${pkgs.glib.dev}/include/glib-2.0"''
|
|
||||||
"-I${pkgs.glib.out}/lib/glib-2.0/include/"
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
stn := @use("rel:../../stn/src/lib.hb");
|
stn := @use("../../stn/src/lib.hb");
|
||||||
.{string, memory, buffer} := stn
|
.{string, memory, buffer} := stn
|
||||||
|
|
||||||
dt_get := fn(query: ^u8): int {
|
dt_get := fn(query: ^u8): int {
|
||||||
message_length := string.length(query)
|
message_length := string.length(query)
|
||||||
|
|
||||||
return @eca(int, 3, 5, query, message_length)
|
return @eca(3, 5, query, message_length)
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
stn := @use("rel:../../stn/src/lib.hb");
|
stn := @use("../../stn/src/lib.hb");
|
||||||
.{string, memory, buffer} := stn
|
.{string, memory, buffer} := stn
|
||||||
|
|
||||||
input := @use("rel:../../intouch/src/lib.hb")
|
input := @use("../../intouch/src/lib.hb")
|
||||||
|
|
||||||
WindowID := struct {
|
WindowID := struct {
|
||||||
host_id: int,
|
host_id: int,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
structures := @use("rel:structures.hb")
|
structures := @use("structures.hb")
|
||||||
version := @use("rel:version.hb")
|
version := @use("version.hb")
|
||||||
|
|
||||||
// Refer to here https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkApplicationInfo.html
|
// Refer to here https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkApplicationInfo.html
|
||||||
ApplicationInfo := struct {
|
ApplicationInfo := struct {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
application := @use("rel:application.hb");
|
application := @use("application.hb");
|
||||||
.{ApplicationInfo} := application
|
.{ApplicationInfo} := application
|
||||||
|
|
||||||
structures := @use("rel:structures.hb")
|
structures := @use("structures.hb")
|
||||||
errors := @use("rel:errors.hb")
|
errors := @use("errors.hb")
|
||||||
|
|
||||||
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkInstanceCreateInfo.html
|
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkInstanceCreateInfo.html
|
||||||
InstanceCreateInfo := struct {
|
InstanceCreateInfo := struct {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
application := @use("rel:application.hb")
|
application := @use("application.hb")
|
||||||
|
|
||||||
results := @use("rel:results.hb")
|
results := @use("results.hb")
|
||||||
errors := @use("rel:errors.hb")
|
errors := @use("errors.hb")
|
||||||
|
|
||||||
offsets := @use("rel:offset.hb")
|
offsets := @use("offset.hb")
|
||||||
extends := @use("rel:extends.hb")
|
extends := @use("extends.hb")
|
||||||
|
|
||||||
rect := @use("rel:rect.hb")
|
rect := @use("rect.hb")
|
||||||
structures := @use("rel:structures.hb")
|
structures := @use("structures.hb")
|
||||||
instance := @use("rel:instance.hb")
|
instance := @use("instance.hb")
|
||||||
|
|
||||||
version := @use("rel:version.hb")
|
version := @use("version.hb")
|
||||||
|
|
||||||
init_vulkan := fn(): int {
|
init_vulkan := fn(): int {
|
||||||
return errors.IncompatibleDriver
|
return errors.IncompatibleDriver
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
offsets := @use("rel:offset.hb")
|
offsets := @use("offset.hb")
|
||||||
extends := @use("rel:extends.hb")
|
extends := @use("extends.hb")
|
||||||
|
|
||||||
Rect2D := struct {
|
Rect2D := struct {
|
||||||
offset: offsets.Offset2D,
|
offset: offsets.Offset2D,
|
||||||
|
|
|
@ -6,3 +6,62 @@ Tab := KeyCode.(9)
|
||||||
Clear := KeyCode.(12)
|
Clear := KeyCode.(12)
|
||||||
Return := KeyCode.(13)
|
Return := KeyCode.(13)
|
||||||
Pause := KeyCode.(19)
|
Pause := KeyCode.(19)
|
||||||
|
Escape := KeyCode.(27)
|
||||||
|
Space := KeyCode.(32)
|
||||||
|
|
||||||
|
A := KeyCode.(97)
|
||||||
|
/*
|
||||||
|
ETC
|
||||||
|
*/
|
||||||
|
Z := KeyCode.(122)
|
||||||
|
|
||||||
|
Delete := KeyCode.(127)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ETC
|
||||||
|
*/
|
||||||
|
|
||||||
|
KeypadNumber0 := KeyCode.(256)
|
||||||
|
KeypadNumber1 := KeyCode.(257)
|
||||||
|
KeypadNumber2 := KeyCode.(258)
|
||||||
|
KeypadNumber3 := KeyCode.(259)
|
||||||
|
KeypadNumber4 := KeyCode.(260)
|
||||||
|
KeypadNumber5 := KeyCode.(261)
|
||||||
|
KeypadNumber6 := KeyCode.(262)
|
||||||
|
KeypadNumber7 := KeyCode.(263)
|
||||||
|
KeypadNumber8 := KeyCode.(264)
|
||||||
|
KeypadNumber9 := KeyCode.(265)
|
||||||
|
|
||||||
|
KeypadPeriod := KeyCode.(266)
|
||||||
|
KeypadDivide := KeyCode.(267)
|
||||||
|
KeypadMultiply := KeyCode.(268)
|
||||||
|
KeypadMinus := KeyCode.(269)
|
||||||
|
KeypadPlus := KeyCode.(270)
|
||||||
|
KeypadEnter := KeyCode.(271)
|
||||||
|
KeypadEquals := KeyCode.(272)
|
||||||
|
|
||||||
|
NumLock := KeyCode.(300)
|
||||||
|
CapsLock := KeyCode.(301)
|
||||||
|
ScrollLock := KeyCode.(302)
|
||||||
|
|
||||||
|
RightShift := KeyCode.(303)
|
||||||
|
LeftShift := KeyCode.(304)
|
||||||
|
|
||||||
|
RightControl := KeyCode.(305)
|
||||||
|
LeftControl := KeyCode.(306)
|
||||||
|
RightAlt := KeyCode.(307)
|
||||||
|
LeftAlt := KeyCode.(308)
|
||||||
|
RightMeta := KeyCode.(309)
|
||||||
|
LeftMeta := KeyCode.(310)
|
||||||
|
|
||||||
|
/* Left "Windows" key */
|
||||||
|
LeftSuper := KeyCode.(311)
|
||||||
|
|
||||||
|
/* Right "Windows" key */
|
||||||
|
RightSuper := KeyCode.(312)
|
||||||
|
|
||||||
|
/* "Alt Gr" key */
|
||||||
|
Mode := KeyCode.(313)
|
||||||
|
|
||||||
|
/* Multi-key compose key */
|
||||||
|
Compose := KeyCode.(314)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
keycodes := @use("rel:keycodes.hb");
|
keycodes := @use("keycodes.hb");
|
||||||
.{KeyCode} := keycodes
|
.{KeyCode} := keycodes
|
||||||
|
|
||||||
MouseEvent := struct {
|
MouseEvent := struct {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
stn := @use("rel:../../stn/src/lib.hb");
|
.{string, memory, buffer, log} := @use("../../stn/src/lib.hb")
|
||||||
.{string, memory, buffer} := stn
|
|
||||||
|
|
||||||
PCIAddress := struct {
|
PCIAddress := struct {
|
||||||
bus: u8,
|
bus: u8,
|
||||||
|
@ -10,6 +9,7 @@ PCIAddress := struct {
|
||||||
PCI_ID := struct {
|
PCI_ID := struct {
|
||||||
vendor: u16,
|
vendor: u16,
|
||||||
device: u16,
|
device: u16,
|
||||||
|
inner: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
get_ids := fn(bus: u8, device: u8, function: u8): PCI_ID {
|
get_ids := fn(bus: u8, device: u8, function: u8): PCI_ID {
|
||||||
|
@ -18,7 +18,7 @@ get_ids := fn(bus: u8, device: u8, function: u8): PCI_ID {
|
||||||
dev_id &= 0xFFFF
|
dev_id &= 0xFFFF
|
||||||
|
|
||||||
vnd_id := res & 0xFFFF
|
vnd_id := res & 0xFFFF
|
||||||
return PCI_ID.(dev_id, vnd_id)
|
return PCI_ID.(dev_id, vnd_id, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
PciDeviceInfo := struct {
|
PciDeviceInfo := struct {
|
||||||
|
@ -51,9 +51,9 @@ check_device := fn(bus: u8, device: u8): PciDeviceInfo {
|
||||||
pci_id := get_ids(bus, device, 0)
|
pci_id := get_ids(bus, device, 0)
|
||||||
|
|
||||||
if pci_id.vendor == 0xFFFF {
|
if pci_id.vendor == 0xFFFF {
|
||||||
stn.log.warn(":|\0")
|
log.warn(":|\0")
|
||||||
} else {
|
} else {
|
||||||
stn.log.info(":)\0")
|
log.info(":)\0")
|
||||||
}
|
}
|
||||||
address := calculate_address(bus, device, 0, 0x8)
|
address := calculate_address(bus, device, 0, 0x8)
|
||||||
reg2 := config_read32(bus, device, 0, 0x8)
|
reg2 := config_read32(bus, device, 0, 0x8)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
svga := @use("rel:svga.hb")
|
svga := @use("svga.hb")
|
||||||
software := @use("rel:software.hb")
|
software := @use("software.hb")
|
||||||
|
|
||||||
// default mode
|
// default mode
|
||||||
mode := software
|
mode := software
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.{math, memory} := @use("../../stn/src/lib.hb");
|
.{math, memory} := @use("../../stn/src/lib.hb");
|
||||||
.{dt_get} := @use("../../dt_api/src/lib.hb");
|
.{dt_get} := @use("../../dt_api/src/lib.hb");
|
||||||
.{IVec2} := @use("rel:lib.hb")
|
.{IVec2} := @use("lib.hb")
|
||||||
|
|
||||||
Color := struct {b: u8, g: u8, r: u8, a: u8}
|
Color := struct {b: u8, g: u8, r: u8, a: u8}
|
||||||
white := Color.(255, 255, 255, 255)
|
white := Color.(255, 255, 255, 255)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{IVec2} := @use("rel:lib.hb")
|
.{IVec2} := @use("lib.hb")
|
||||||
// .{pci, memory, string, log} := @use("../../stn/src/lib.hb");
|
// .{pci, memory, string, log} := @use("../../stn/src/lib.hb");
|
||||||
|
|
||||||
Color := struct {b: u8, g: u8, r: u8, a: u8}
|
Color := struct {b: u8, g: u8, r: u8, a: u8}
|
||||||
|
|
|
@ -1,16 +1,31 @@
|
||||||
//! This is a reserved file for use with the AbleOS Clustering System
|
//! This is a reserved file for use with the AbleOS Clustering System
|
||||||
|
|
||||||
HostID := int
|
HostID := int
|
||||||
|
ID := int
|
||||||
|
|
||||||
FileID := struct {
|
FileID := struct {
|
||||||
host_id: HostID,
|
host_id: HostID,
|
||||||
id: int,
|
id: ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
// A DeviceID points to a specific device in the ACS.
|
// A DeviceID points to a specific device in the ACS.
|
||||||
DeviceID := struct {
|
DeviceID := struct {
|
||||||
host_id: HostID,
|
host_id: HostID,
|
||||||
id: int,
|
id: ID,
|
||||||
|
}
|
||||||
|
DiskID := DeviceID
|
||||||
|
|
||||||
|
BufferID := struct {
|
||||||
|
host_id: HostID,
|
||||||
|
id: ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskID := DeviceID
|
ProcessID := struct {
|
||||||
|
host_id: HostID,
|
||||||
|
id: ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowID := struct {
|
||||||
|
host_id: HostID,
|
||||||
|
id: ID,
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
string := @use("rel:string.hb")
|
string := @use("string.hb")
|
||||||
|
|
||||||
receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 {
|
receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 {
|
||||||
return @eca(4, buffer_id, memory_map_location, length)
|
return @eca(4, buffer_id, memory_map_location, length)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
acs := @use("rel:acs.hb");
|
acs := @use("acs.hb");
|
||||||
.{DiskID, FileID} := acs
|
.{DiskID, FileID} := acs
|
||||||
|
|
||||||
// Paths without a node-disk component are to be treated as local files.
|
// Paths without a node-disk component are to be treated as local files.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
acs := @use("rel:acs.hb")
|
acs := @use("acs.hb")
|
||||||
|
|
||||||
string := @use("rel:string.hb")
|
string := @use("string.hb")
|
||||||
log := @use("rel:log.hb")
|
log := @use("log.hb")
|
||||||
memory := @use("rel:memory.hb")
|
memory := @use("memory.hb")
|
||||||
buffer := @use("rel:buffer.hb")
|
buffer := @use("buffer.hb")
|
||||||
math := @use("rel:math.hb")
|
math := @use("math.hb")
|
||||||
random := @use("rel:random.hb")
|
random := @use("random.hb")
|
||||||
file := @use("rel:file_io.hb")
|
file := @use("file_io.hb")
|
|
@ -1,5 +1,5 @@
|
||||||
string := @use("rel:string.hb")
|
string := @use("string.hb")
|
||||||
buffer := @use("rel:buffer.hb")
|
buffer := @use("buffer.hb")
|
||||||
|
|
||||||
log := fn(message: ^u8, level: u8): void {
|
log := fn(message: ^u8, level: u8): void {
|
||||||
message_length := @inline(string.length, message);
|
message_length := @inline(string.length, message);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
integer := fn(): int {
|
integer := fn(): int {
|
||||||
return @eca(int, 3, 4)
|
return @eca(3, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
integer_range := fn(min: int, max: int): int {
|
integer_range := fn(min: int, max: int): int {
|
||||||
return @eca(int, 3, 4) % (max - min + 1) + min
|
return @eca(3, 4) % (max - min + 1) + min
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
attributes := @use("rel:attributes.hb")
|
attributes := @use("attributes.hb")
|
||||||
datetime := @use("rel:datetime.hb")
|
datetime := @use("datetime.hb")
|
||||||
|
|
||||||
FileName := [u8; 11]
|
FileName := [u8; 11]
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
attributes := @use("rel:attributes.hb")
|
attributes := @use("attributes.hb")
|
||||||
datetime := @use("rel:datetime.hb")
|
datetime := @use("datetime.hb")
|
||||||
directory := @use("rel:file.hb")
|
directory := @use("file.hb")
|
||||||
bios_parameter_block := @use("rel:bios_parameter_block.hb");
|
bios_parameter_block := @use("bios_parameter_block.hb");
|
||||||
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
||||||
.{new_bpb, new_ebr, new_fs_info} := bios_parameter_block
|
.{new_bpb, new_ebr, new_fs_info} := bios_parameter_block
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
name = "pumpkin_print"
|
name = "pumpkin_print"
|
||||||
authors = [""]
|
authors = [""]
|
||||||
|
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
||||||
|
|
||||||
[dependants.binaries]
|
[dependants.binaries]
|
||||||
|
|
|
@ -25,7 +25,7 @@ main := fn(): int {
|
||||||
mem := memory.request_page(1)
|
mem := memory.request_page(1)
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
ptr := @eca(int, 4, a, mem, 0x1000)
|
ptr := @eca(4, a, mem, 0x1000)
|
||||||
if ptr == 0 {
|
if ptr == 0 {
|
||||||
serial_println("No message\0")
|
serial_println("No message\0")
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ log_info := fn(): void {
|
||||||
} else {
|
} else {
|
||||||
msg := "XABC\0"
|
msg := "XABC\0"
|
||||||
msg_length := @inline(string.length, msg)
|
msg_length := @inline(string.length, msg)
|
||||||
@eca(void, 3, a, msg, msg_length)
|
@eca(3, a, msg, msg_length)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,7 +2,25 @@ stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
pci := @use("../../../libraries/pci/src/lib.hb");
|
pci := @use("../../../libraries/pci/src/lib.hb");
|
||||||
.{PCIAddress} := pci
|
.{PCIAddress, get_ids, config_read32} := pci;
|
||||||
|
|
||||||
|
.{dt_get} := @use("../../../libraries/dt_api/src/lib.hb")
|
||||||
|
|
||||||
|
reg := @use("./reg.hb")
|
||||||
|
|
||||||
|
PCI_VENDOR_ID_VMWARE := 0x15AD
|
||||||
|
PCI_DEVICE_ID_VMWARE_SVGA2 := 1029
|
||||||
|
|
||||||
|
read_reg := fn(svga_dev: ^SVGADevice, index: u32): u32 {
|
||||||
|
memory.outl(svga_dev.ioBase, index)
|
||||||
|
return memory.inl(svga_dev.ioBase + 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
write_reg := fn(svga_dev: ^SVGADevice, index: u32, value: u32): void {
|
||||||
|
memory.outl(svga_dev.ioBase, index)
|
||||||
|
memory.outl(svga_dev.ioBase + 4, value)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
FIFO := struct {
|
FIFO := struct {
|
||||||
reserved_size: u32,
|
reserved_size: u32,
|
||||||
|
@ -52,3 +70,90 @@ svga_device := fn(): SVGADevice {
|
||||||
irq := new_irq()
|
irq := new_irq()
|
||||||
return SVGADevice.(pci_addr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, fifo, irq)
|
return SVGADevice.(pci_addr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, fifo, irq)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO : this function is broken
|
||||||
|
GetBARAddr := fn(addr: PCIAddress, index: int): u32 {
|
||||||
|
//bar := config_read32(addr, offsetof(PCIConfigSpace, BAR[index]));
|
||||||
|
bar := config_read32(0, 3, 0, 0)
|
||||||
|
PCI_CONF_BAR_IO := 0
|
||||||
|
|
||||||
|
mask := 0xF
|
||||||
|
|
||||||
|
/*
|
||||||
|
if bar & PCI_CONF_BAR_IO {
|
||||||
|
0x3
|
||||||
|
} else {
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return bar & (mask ^ 0xFFFFFFFF)
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_device := fn(svga_dev: ^SVGADevice): void {
|
||||||
|
// TODO: Fix this
|
||||||
|
// refer to https://git.ablecorp.us/able/vmware-svga/src/commit/eea7ddcd0d34702f8f0a33c1933718706c6318c5/lib/refdriver/svga.c#L55
|
||||||
|
|
||||||
|
svga_dev.pciAddr = PCIAddress.(0, 3, 0)
|
||||||
|
pci_dev := pci.check_device(0, 3)
|
||||||
|
|
||||||
|
if pci_dev.device_id.vendor != PCI_VENDOR_ID_VMWARE {
|
||||||
|
log.error("SVGA device not found\0")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//| pci_dev.device_id.device != PCI_DEVICE_ID_VMWARE_SVGA2 {
|
||||||
|
|
||||||
|
svga_dev.ioBase = config_read32(svga_dev.pciAddr.bus, svga_dev.pciAddr.device, svga_dev.pciAddr.function, 0x10) & 0xFFFFFFF0
|
||||||
|
write_reg(svga_dev, reg.SVGA_REG_ENABLE, reg.SVGA_REG_ENABLE_ENABLE)
|
||||||
|
svga_dev.capabilities = read_reg(svga_dev, 0x1)
|
||||||
|
svga_dev.deviceVersionId = read_reg(svga_dev, 0x2)
|
||||||
|
|
||||||
|
svga_dev.fbMem = GetBARAddr(svga_dev.pciAddr, 1)
|
||||||
|
|
||||||
|
// hardcode values for now
|
||||||
|
svga_dev.width = 1024
|
||||||
|
svga_dev.height = 768
|
||||||
|
svga_dev.bpp = 32
|
||||||
|
svga_dev.pitch = svga_dev.width * 4
|
||||||
|
|
||||||
|
svga_dev.fbSize = svga_dev.width * svga_dev.height * svga_dev.bpp / 8
|
||||||
|
|
||||||
|
svga_dev.vramSize = read_reg(svga_dev, 0x10)
|
||||||
|
log.info("SVGA device initialized successfully\0")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_framebuffer := fn(svga_dev: ^SVGADevice): void {
|
||||||
|
write_reg(svga_dev, reg.SVGA_REG_WIDTH, svga_dev.width)
|
||||||
|
write_reg(svga_dev, reg.SVGA_REG_HEIGHT, svga_dev.height)
|
||||||
|
write_reg(svga_dev, reg.SVGA_REG_BITS_PER_PIXEL, svga_dev.bpp)
|
||||||
|
|
||||||
|
log.info("Framebuffer setup complete\0")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
draw_pixel := fn(svga_dev: ^SVGADevice, x: int, y: int, color: u32): void {
|
||||||
|
/*
|
||||||
|
if x >= svga_dev.width || y >= svga_dev.height {
|
||||||
|
return // what happens if we write outside here : )
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
offset := y * svga_dev.pitch + x * svga_dev.bpp / 8
|
||||||
|
mem_addr := svga_dev.fbMem + offset
|
||||||
|
memory.outl(mem_addr, color)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
clear_screen := fn(svga_dev: ^SVGADevice, color: u32): void {
|
||||||
|
y := 0
|
||||||
|
loop if y == svga_dev.height break else {
|
||||||
|
x := 0
|
||||||
|
loop if x == svga_dev.width break else {
|
||||||
|
draw_pixel(svga_dev, x, y, color)
|
||||||
|
x += 1
|
||||||
|
}
|
||||||
|
y += 1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,22 +1,13 @@
|
||||||
device := @use("rel:device.hb")
|
device := @use("device.hb")
|
||||||
pci := @use("../../../libraries/pci/src/lib.hb")
|
pci := @use("../../../libraries/pci/src/lib.hb")
|
||||||
|
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
reg := @use("rel:reg.hb")
|
reg := @use("reg.hb")
|
||||||
|
|
||||||
PCI_VENDOR_ID_VMWARE := 0x15AD
|
PCI_VENDOR_ID_VMWARE := 0x15AD
|
||||||
PCI_DEVICE_ID_VMWARE_SVGA2 := 0x405
|
PCI_DEVICE_ID_VMWARE_SVGA2 := 0x405
|
||||||
|
|
||||||
init := fn(): void {
|
|
||||||
svga_struct := device.svga_device()
|
|
||||||
|
|
||||||
pci_dev := pci.check_device(0, 2)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
write_reg := fn(index: u32, value: u32): void {
|
write_reg := fn(index: u32, value: u32): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,13 +17,15 @@ SVGA_disable := fn(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
a := pci.config_read32(0, 2, 0, 0x8)
|
svga_dev := device.svga_device()
|
||||||
b := "\0\0\0\0\0\0\0"
|
|
||||||
|
|
||||||
string.display_int(a, b)
|
device.setup_device(&svga_dev)
|
||||||
stn.log.info(b)
|
device.setup_framebuffer(&svga_dev)
|
||||||
|
device.draw_pixel(&svga_dev, 100, 100, 0xFF00FFFF)
|
||||||
|
/*
|
||||||
|
|
||||||
init()
|
|
||||||
|
|
||||||
|
device.clear_screen(&svga_dev, 0xFF)
|
||||||
|
*/
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -2,3 +2,10 @@ SVGA_REG_ENABLE_DISABLE := 0
|
||||||
SVGA_REG_ENABLE_ENABLE := 1
|
SVGA_REG_ENABLE_ENABLE := 1
|
||||||
SVGA_REG_ENABLE_HIDE := 2
|
SVGA_REG_ENABLE_HIDE := 2
|
||||||
SVGA_REG_ENABLE_ENABLE_HIDE := SVGA_REG_ENABLE_ENABLE | SVGA_REG_ENABLE_HIDE
|
SVGA_REG_ENABLE_ENABLE_HIDE := SVGA_REG_ENABLE_ENABLE | SVGA_REG_ENABLE_HIDE
|
||||||
|
|
||||||
|
SVGA_REG_DISABLE := 0
|
||||||
|
SVGA_REG_ENABLE := 1
|
||||||
|
SVGA_REG_WIDTH := 2
|
||||||
|
SVGA_REG_HEIGHT := 3
|
||||||
|
SVGA_REG_BITS_PER_PIXEL := 7
|
||||||
|
SVGA_REG_BYTES_PER_LINE := 12
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
service_search := fn(): void {
|
service_search := fn(): void {
|
||||||
a := "\{01}\0"
|
a := "\{01}\0"
|
||||||
@eca(void, 3, 0, a, 2)
|
@eca(3, 0, a, 2)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,34 +20,35 @@ resolution = "1024x768x24"
|
||||||
# [boot.limine.ableos.modules.tests]
|
# [boot.limine.ableos.modules.tests]
|
||||||
# path = "boot:///tests.hbf"
|
# path = "boot:///tests.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.0serial_driver]
|
# [boot.limine.ableos.modules.serial_driver]
|
||||||
# path = "boot:///serial_driver.hbf"
|
# path = "boot:///serial_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.diskio_driver]
|
# [boot.limine.ableos.modules.diskio_driver]
|
||||||
# path = "boot:///diskio_driver.hbf"
|
# path = "boot:///diskio_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.render_example]
|
[boot.limine.ableos.modules.render_example]
|
||||||
# path = "boot:///render_example.hbf"
|
path = "boot:///render_example.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.serial_driver_test]
|
# [boot.limine.ableos.modules.serial_driver_test]
|
||||||
# path = "boot:///serial_driver_test.hbf"
|
# path = "boot:///serial_driver_test.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.horizon]
|
# [boot.limine.ableos.modules.horizon]
|
||||||
path = "boot:///horizon.hbf"
|
# path = "boot:///horizon.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.horizon_testing_program]
|
# [boot.limine.ableos.modules.horizon_testing_program]
|
||||||
path = "boot:///horizon_testing_program.hbf"
|
# path = "boot:///horizon_testing_program.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.dt_buffer_test]
|
# [boot.limine.ableos.modules.dt_buffer_test]
|
||||||
# path = "boot:///dt_buffer_test.hbf"
|
# path = "boot:///dt_buffer_test.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.svga_driver]
|
# [boot.limine.ableos.modules.svga_driver]
|
||||||
path = "boot:///svga_driver.hbf"
|
# path = "boot:///svga_driver.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.ps2_driver]
|
[boot.limine.ableos.modules.ps2_driver]
|
||||||
path = "boot:///ps2_driver.hbf"
|
path = "boot:///ps2_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.filesystem_fat32]
|
# [boot.limine.ableos.modules.filesystem_fat32]
|
||||||
# path = "boot:///filesystem_fat32.hbf"
|
# path = "boot:///filesystem_fat32.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.pumpkin_print]
|
# [boot.limine.ableos.modules.pumpkin_print]
|
||||||
# path = "boot:///pumpkin_print.hbf"
|
# path = "boot:///pumpkin_print.hbf"
|
||||||
|
|
Loading…
Reference in a new issue