1
0
Fork 0
forked from koniifer/ableos

reorganization

This commit is contained in:
able 2024-01-18 02:36:24 -06:00
parent 195192db8a
commit d8cb4d4e64
8 changed files with 197 additions and 38 deletions

19
Cargo.lock generated
View file

@ -190,7 +190,7 @@ source = "git+https://git.ablecorp.us/ableos/ableos_userland#c990d072981b3076fa3
dependencies = [
"hashbrown 0.14.2",
"log",
"toml",
"toml 0.5.9",
]
[[package]]
@ -837,6 +837,8 @@ dependencies = [
"fatfs",
"hbasm",
"reqwest",
"str-reader",
"toml 0.5.11",
]
[[package]]
@ -1110,6 +1112,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "str-reader"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6aa20b89aec46e0bffbb8756e089beb4c43bbec53d0667de34212f048bdab10"
[[package]]
name = "syn"
version = "1.0.109"
@ -1226,6 +1234,15 @@ dependencies = [
"serde",
]
[[package]]
name = "toml"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
dependencies = [
"serde",
]
[[package]]
name = "tower-service"
version = "0.3.2"

View file

@ -1,31 +0,0 @@
[boot]
# This package must be installed system wide
init = "init_server"
[boot.limine]
default_entry = 1
timeout = 0
verbose = true
interface_resolution = "1024x768x24"
# Terminal related settings
term_wallpaper = "boot:///background.bmp"
term_background = "008080"
[boot.limine.ableos]
comment = "Default AbleOS boot entry."
protocol = "limine"
kernel_path = "boot:///kernel"
kernel_cmdline = "baka=false foobles=true"
resolution = "1024x768x24"
[repositories]
core = "https://git.ablecorp.us/AbleOS/core"
userspace = "https://git.ablecorp.us/AbleOS/ableos_userland"
[packages]
[packages.init_server]
version = "1.0"
hash = ""
repo = "core"

View file

@ -4,11 +4,14 @@ version = "0.2.0"
edition = "2021"
[dependencies]
str-reader = "0.1.2"
derive_more = "0.99"
error-stack = "0.4"
fatfs = "0.3"
toml = "0.5.2"
hbasm.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
[dependencies.reqwest]
version = "0.11"
default-features = false

View file

@ -1,3 +1,5 @@
use std::{fs, io::Write, process::exit};
use {
derive_more::Display,
error_stack::{bail, report, Context, Report, Result, ResultExt},
@ -116,6 +118,113 @@ fn assemble() -> Result<(), Error> {
}
fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
let filename = "sysdata/system_config.toml";
// Read the contents of the file using a `match` block
// to return the `data: Ok(c)` as a `String`
// or handle any `errors: Err(_)`.
let contents = match fs::read_to_string(filename) {
// If successful return the files text as `contents`.
// `c` is a local variable.
Ok(c) => c,
// Handle the `error` case.
Err(_) => {
// Write `msg` to `stderr`.
eprintln!("Could not read file `{}`", filename);
// Exit the program with exit code `1`.
exit(1);
}
};
use toml::Value;
let mut limine_str = String::new();
let mut data: Value = toml::from_str(&contents).unwrap();
let boot_table = data.get_mut("boot");
let limine_table = boot_table.unwrap().get_mut("limine").unwrap();
let default_entry = limine_table.get("default_entry").unwrap();
let timeout = limine_table.get("timeout").unwrap();
let interface_resolution = limine_table.get("interface_resolution").unwrap();
let verbose = limine_table.get("verbose").unwrap();
let term_wallpaper = limine_table.get("term_wallpaper").unwrap();
let vb_post = match verbose.as_bool().unwrap() {
true => "yes",
false => "no",
};
let term_background = limine_table
.get("term_backdrop")
.unwrap_or(&Value::Integer(0));
let base = format!(
"DEFAULT_ENTRY={}
TIMEOUT={}
VERBOSE={}
INTERFACE_RESOLUTION={}
# Terminal related settings
TERM_WALLPAPER={}
TERM_BACKDROP={}
",
default_entry,
timeout,
vb_post,
interface_resolution,
term_wallpaper.as_str().unwrap(),
term_background
);
limine_str.push_str(&base);
let boot_entries = limine_table.as_table_mut().unwrap();
let mut real_boot_entries = boot_entries.clone();
for (key, value) in boot_entries.into_iter() {
if !value.is_table() {
real_boot_entries.remove(key);
}
}
for (name, mut value) in real_boot_entries {
let comment = value.get("comment").unwrap();
let protocol = value.get("protocol").unwrap();
let resolution = value.get("resolution").unwrap();
let kernel_path = value.get("kernel_path").unwrap();
let kernel_cmdline = value.get("kernel_cmdline").unwrap();
let text_entry = format!(
"
:{}
COMMENT={}
PROTOCOL={}
RESOLUTION={}
KERNEL_PATH={}
KERNEL_CMDLINE={}
",
name,
comment.as_str().unwrap(),
protocol.as_str().unwrap(),
resolution.as_str().unwrap(),
kernel_path.as_str().unwrap(),
kernel_cmdline,
);
limine_str.push_str(&text_entry);
let modules = value.get_mut("modules").unwrap().as_table_mut().unwrap();
// let mut real_modules = modules.clone();
for (key, value) in modules.into_iter() {
if value.is_table() {
let path = value.get("path").unwrap();
let cmd_line = value.get("cmd_line").unwrap();
let a = format!(
" MODULE_PATH={}
MODULE_CMDLINE={}\n\n",
path.as_str().unwrap(),
cmd_line
);
limine_str.push_str(&a);
}
}
}
let mut img = File::options()
.read(true)
.write(true)
@ -127,8 +236,13 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
fatfs::format_volume(&mut img, FormatVolumeOptions::new())?;
let fs = FileSystem::new(img, FsOptions::new())?;
let bootdir = fs.root_dir().create_dir("efi")?.create_dir("boot")?;
let mut f = fs.root_dir().create_file("limine.cfg")?;
let a = f.write(limine_str.as_bytes())?;
drop(f);
io::copy(
&mut File::open("limine/BOOTX64.EFI")
.map_err(Report::from)
@ -144,7 +258,6 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
)?;
for fpath in [
"sysdata/limine.cfg",
"sysdata/background.bmp",
"target/test-programs/failure.hbf",
"target/test-programs/ecall.hbf",

10
sysdata/config.format Normal file
View file

@ -0,0 +1,10 @@
Boolean
UTF8 String
Date Time (U128 seconds since the beginning of the universe)
Binary Blob
List<T>
Ordered/Unordered
Bound/Unbound

View file

@ -12,7 +12,7 @@ TERM_BACKDROP=008080
:AbleOS
COMMENT=Default AbleOS boot entry.
PROTOCOL=limine
KERNEL_PATH=${ABLEOS_KERNEL}_${ARCH}
KERNEL_PATH=boot:///kernel_${ARCH}
# execute is an array of boot modules to execute
KERNEL_CMDLINE=""
# Setting a default resolution for the framebuffer

View file

@ -0,0 +1,46 @@
[boot]
[boot.limine]
default_entry = 1
timeout = 0
verbose = true
interface_resolution = "1024x768x24"
# Terminal related settings
term_wallpaper = "boot:///background.bmp"
term_background = "008080"
[boot.limine.ableos]
comment = "Default AbleOS boot entry."
protocol = "limine"
kernel_path = "boot:///kernel_${ARCH}"
kernel_cmdline = ""
resolution = "1024x768x24"
[boot.limine.ableos.modules]
[boot.limine.ableos.modules.failure]
path = "boot:///failure.hbf"
cmd_line = ""
[boot.limine.ableos.modules.ecall]
path = "boot:///ecall.hbf"
cmd_line = ""
[boot.limine.ableos.modules.main]
path = "boot:///main.hbf"
cmd_line = ""
[boot.limine.ableos.modules.keyboard_driver]
path = "boot:///keyboard_driver.hbf"
cmd_line = "arch=${ARCH}"
[boot.limine.ableos.modules.vfs_test]
path = "boot:///vfs_test.hbf"
cmd_line = ""
[boot.limine.ableos.modules.limine_framebuffer_driver]
path = "boot:///limine_framebuffer_driver.hbf"
cmd_line = "height=10 width=10 arch=${ARCH}"
[boot.limine.ableos.modules.serial_driver]
path = "boot:///serial_driver.hbf"
cmd_line = "arch=${ARCH}"

View file

@ -56,6 +56,7 @@ fn clear() {
// rect(r0, r0, 1024, 768, 0xff222222);
let BUFFER = 0xFFFF8000C0000000;
// let BUFFER = 0xFFFF8000BC430000;
// on arm the FB is at 0xFFFF8000BC430000
// FIXME: get the framebuffer pointer from the starting arguments