forked from AbleOS/ableos
SUBMODULE: Removed it temporarily
This commit is contained in:
parent
2dcd096de9
commit
e7b46f639c
5
.gitmodules
vendored
5
.gitmodules
vendored
|
@ -1,5 +0,0 @@
|
||||||
[submodule "limine"]
|
|
||||||
path = limine
|
|
||||||
url = https://github.com/limine-bootloader/limine.git
|
|
||||||
branch = v5.x-branch-binary
|
|
||||||
shallow = true
|
|
|
@ -3,8 +3,7 @@ build-std = ["core", "compiler_builtins", "alloc"]
|
||||||
build-std-features = ["compiler-builtins-mem"]
|
build-std-features = ["compiler-builtins-mem"]
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
# target = "./targets/x86_64-ableos.json"
|
target = "./targets/x86_64-ableos.json"
|
||||||
target = "./targets/aarch64-virt-ableos.json"
|
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")']
|
[target.'cfg(target_arch = "x86_64")']
|
||||||
rustflags = ["-C", "target-feature=+rdrand"]
|
rustflags = ["-C", "target-feature=+rdrand"]
|
||||||
|
|
1
limine
1
limine
|
@ -1 +0,0 @@
|
||||||
Subproject commit 751e802e173392e8637759e2b3c96bbf59456f87
|
|
|
@ -9,7 +9,7 @@ derive_more = "0.99"
|
||||||
env_logger = "0.10"
|
env_logger = "0.10"
|
||||||
error-stack = "0.2"
|
error-stack = "0.2"
|
||||||
fatfs = "0.3"
|
fatfs = "0.3"
|
||||||
log = "0.4"
|
log = "0.4" # remove me
|
||||||
rpm = "0.11" # remove me
|
rpm = "0.11" # remove me
|
||||||
zstd = "0.12" # remove me
|
zstd = "0.12" # remove me
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,10 @@ use {
|
||||||
derive_more::Display,
|
derive_more::Display,
|
||||||
error_stack::{bail, report, Context, IntoReport, Result, ResultExt},
|
error_stack::{bail, report, Context, IntoReport, Result, ResultExt},
|
||||||
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
|
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
|
||||||
std::{
|
std::{fmt::Display, fs::File, io, path::Path, process::Command},
|
||||||
fmt::Display,
|
|
||||||
fs::File,
|
|
||||||
io::{self, Write},
|
|
||||||
path::Path,
|
|
||||||
process::Command,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
env_logger::init();
|
|
||||||
let mut args = std::env::args();
|
let mut args = std::env::args();
|
||||||
args.next();
|
args.next();
|
||||||
|
|
||||||
|
@ -33,7 +26,7 @@ fn main() -> Result<(), Error> {
|
||||||
release = true;
|
release = true;
|
||||||
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
||||||
target = Target::Riscv64Virt;
|
target = Target::Riscv64Virt;
|
||||||
} else if arg == "aarch" || arg == "arm64" {
|
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
||||||
target = Target::Aarch64;
|
target = Target::Aarch64;
|
||||||
} else {
|
} else {
|
||||||
return Err(report!(Error::InvalidSubCom));
|
return Err(report!(Error::InvalidSubCom));
|
||||||
|
@ -50,7 +43,7 @@ fn main() -> Result<(), Error> {
|
||||||
release = true;
|
release = true;
|
||||||
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
||||||
target = Target::Riscv64Virt;
|
target = Target::Riscv64Virt;
|
||||||
} else if arg == "aarch" || arg == "arm64" {
|
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
||||||
target = Target::Aarch64;
|
target = Target::Aarch64;
|
||||||
} else {
|
} else {
|
||||||
return Err(report!(Error::InvalidSubCom));
|
return Err(report!(Error::InvalidSubCom));
|
||||||
|
@ -145,8 +138,6 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(release: bool, target: Target) -> Result<(), Error> {
|
fn build(release: bool, target: Target) -> Result<(), Error> {
|
||||||
fetch_ovmf().change_context(Error::OvmfFetch)?;
|
|
||||||
|
|
||||||
let fs = get_fs().change_context(Error::Io)?;
|
let fs = get_fs().change_context(Error::Io)?;
|
||||||
let mut com = Command::new("cargo");
|
let mut com = Command::new("cargo");
|
||||||
com.current_dir("kernel");
|
com.current_dir("kernel");
|
||||||
|
@ -168,14 +159,16 @@ fn build(release: bool, target: Target) -> Result<(), Error> {
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
if target != Target::Aarch64 {
|
let kernel_dir = match target {
|
||||||
todo!()
|
Target::X86_64 => "target/x86_64-ableos",
|
||||||
}
|
Target::Riscv64Virt => "target/riscv64-virt-ableos",
|
||||||
|
Target::Aarch64 => "target/aarch64-virt-ableos",
|
||||||
|
};
|
||||||
|
|
||||||
(|| -> std::io::Result<_> {
|
(|| -> std::io::Result<_> {
|
||||||
io::copy(
|
io::copy(
|
||||||
&mut File::open(
|
&mut File::open(
|
||||||
Path::new("target/aarch64-virt-ableos")
|
Path::new(kernel_dir)
|
||||||
.join(if release { "release" } else { "debug" })
|
.join(if release { "release" } else { "debug" })
|
||||||
.join("kernel"),
|
.join("kernel"),
|
||||||
)?,
|
)?,
|
||||||
|
@ -193,34 +186,19 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
Target::Riscv64Virt => Command::new("qemu-system-riscv64"),
|
Target::Riscv64Virt => Command::new("qemu-system-riscv64"),
|
||||||
Target::Aarch64 => Command::new("qemu-system-aarch64"),
|
Target::Aarch64 => Command::new("qemu-system-aarch64"),
|
||||||
};
|
};
|
||||||
|
let ovmf_path = fetch_ovmf(target);
|
||||||
|
|
||||||
if target == Target::X86_64 {
|
match target {
|
||||||
|
Target::X86_64 => {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
com.args([
|
com.args([
|
||||||
"-bios", "target/OVMF_CODE.fd",
|
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||||
"-drive", "file=target/disk.img,format=raw",
|
"-drive", "file=target/disk.img,format=raw",
|
||||||
"-m", "4G",
|
"-m", "4G",
|
||||||
// "-serial", "stdio",
|
|
||||||
"-smp", "cores=4",
|
"-smp", "cores=4",
|
||||||
// "-vga", "cirrus",
|
|
||||||
// "-device", "ati-vga",
|
|
||||||
// "-device", "virtio-gpu-pci",
|
|
||||||
|
|
||||||
// "-device", "virtio-serial,id=virtio-serial0",
|
|
||||||
// "-chardev", "stdio,id=char0,mux=on",
|
|
||||||
// "-device", "virtconsole,chardev=char0",
|
|
||||||
// "-device", "virtio-mouse-pci",
|
|
||||||
|
|
||||||
// "-device", "ati-vga", "model=rage128p"
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
{
|
|
||||||
// com.args(["-enable-kvm", "-cpu", "host"]);
|
|
||||||
}
|
}
|
||||||
}
|
Target::Riscv64Virt => {
|
||||||
|
|
||||||
if target == Target::Riscv64Virt {
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
com.args([
|
com.args([
|
||||||
"-M", "virt",
|
"-M", "virt",
|
||||||
|
@ -234,8 +212,7 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Target::Aarch64 => {
|
||||||
if target == Target::Aarch64 {
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
com.args([
|
com.args([
|
||||||
"-M", "virt",
|
"-M", "virt",
|
||||||
|
@ -244,10 +221,11 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
"-device", "qemu-xhci",
|
"-device", "qemu-xhci",
|
||||||
"-device", "usb-kbd",
|
"-device", "usb-kbd",
|
||||||
"-m", "2G",
|
"-m", "2G",
|
||||||
"-bios", "target/AARCH64_OVMF.fd",
|
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||||
"-drive", "file=target/disk.img,format=raw",
|
"-drive", "file=target/disk.img,format=raw",
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match com
|
match com
|
||||||
.status()
|
.status()
|
||||||
|
@ -259,39 +237,48 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_ovmf() -> Result<(), OvmfFetchError> {
|
fn fetch_ovmf(target: Target) -> Result<String, OvmfFetchError> {
|
||||||
const OVMF_AARCH64_URL: &str =
|
let (ovmf_url, ovmf_path) = match target {
|
||||||
"https://retrage.github.io/edk2-nightly/bin/RELEASEAARCH64_QEMU_EFI.fd";
|
Target::X86_64 => (
|
||||||
|
"https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF.fd",
|
||||||
|
"target/RELEASEX64_OVMF.fd",
|
||||||
|
),
|
||||||
|
Target::Riscv64Virt => return Err(OvmfFetchError::Empty.into()),
|
||||||
|
Target::Aarch64 => (
|
||||||
|
"https://retrage.github.io/edk2-nightly/bin/RELEASEAARCH64_QEMU_EFI.fd",
|
||||||
|
"target/RELEASEAARCH64_QEMU_EFI.fd",
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
let mut file = match std::fs::metadata("target/AARCH64_OVMF.fd") {
|
let mut file = match std::fs::metadata(ovmf_path) {
|
||||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => std::fs::OpenOptions::new()
|
Err(e) if e.kind() == std::io::ErrorKind::NotFound => std::fs::OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.read(true)
|
.read(true)
|
||||||
.open("target/AARCH64_OVMF.fd")
|
.open(ovmf_path)
|
||||||
.into_report()
|
.into_report()
|
||||||
.change_context(OvmfFetchError::Io)?,
|
.change_context(OvmfFetchError::Io)?,
|
||||||
Ok(_) => return Ok(()),
|
Ok(_) => return Ok(ovmf_path.to_owned()),
|
||||||
Err(e) => return Err(report!(e).change_context(OvmfFetchError::Io)),
|
Err(e) => return Err(report!(e).change_context(OvmfFetchError::Io)),
|
||||||
};
|
};
|
||||||
|
let mut bytes = reqwest::blocking::get(ovmf_url)
|
||||||
log::info!("No OVMF found, downloading…");
|
|
||||||
|
|
||||||
let bytes = std::convert::identity((|| reqwest::blocking::get(OVMF_AARCH64_URL)?.bytes())())
|
|
||||||
.into_report()
|
.into_report()
|
||||||
.change_context(OvmfFetchError::Fetch)?;
|
.change_context(OvmfFetchError::Fetch)?;
|
||||||
|
|
||||||
file.write_all(&bytes)
|
bytes
|
||||||
|
.copy_to(&mut file)
|
||||||
.into_report()
|
.into_report()
|
||||||
.change_context(OvmfFetchError::Io)?;
|
.change_context(OvmfFetchError::Io)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(ovmf_path.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display)]
|
#[derive(Debug, Display)]
|
||||||
enum OvmfFetchError {
|
enum OvmfFetchError {
|
||||||
#[display(fmt = "Failed to fetch OVMF package")]
|
#[display(fmt = "Failed to fetch OVMF package")]
|
||||||
Fetch,
|
Fetch,
|
||||||
|
#[display(fmt = "No OVMF package available")]
|
||||||
|
Empty,
|
||||||
#[display(fmt = "IO Error")]
|
#[display(fmt = "IO Error")]
|
||||||
Io,
|
Io,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue