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]
|
||||
# target = "./targets/x86_64-ableos.json"
|
||||
target = "./targets/aarch64-virt-ableos.json"
|
||||
target = "./targets/x86_64-ableos.json"
|
||||
|
||||
[target.'cfg(target_arch = "x86_64")']
|
||||
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"
|
||||
error-stack = "0.2"
|
||||
fatfs = "0.3"
|
||||
log = "0.4"
|
||||
log = "0.4" # remove me
|
||||
rpm = "0.11" # remove me
|
||||
zstd = "0.12" # remove me
|
||||
|
||||
|
|
|
@ -2,17 +2,10 @@ use {
|
|||
derive_more::Display,
|
||||
error_stack::{bail, report, Context, IntoReport, Result, ResultExt},
|
||||
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
|
||||
std::{
|
||||
fmt::Display,
|
||||
fs::File,
|
||||
io::{self, Write},
|
||||
path::Path,
|
||||
process::Command,
|
||||
},
|
||||
std::{fmt::Display, fs::File, io, path::Path, process::Command},
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
env_logger::init();
|
||||
let mut args = std::env::args();
|
||||
args.next();
|
||||
|
||||
|
@ -33,7 +26,7 @@ fn main() -> Result<(), Error> {
|
|||
release = true;
|
||||
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
||||
target = Target::Riscv64Virt;
|
||||
} else if arg == "aarch" || arg == "arm64" {
|
||||
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
||||
target = Target::Aarch64;
|
||||
} else {
|
||||
return Err(report!(Error::InvalidSubCom));
|
||||
|
@ -50,7 +43,7 @@ fn main() -> Result<(), Error> {
|
|||
release = true;
|
||||
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
||||
target = Target::Riscv64Virt;
|
||||
} else if arg == "aarch" || arg == "arm64" {
|
||||
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
||||
target = Target::Aarch64;
|
||||
} else {
|
||||
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> {
|
||||
fetch_ovmf().change_context(Error::OvmfFetch)?;
|
||||
|
||||
let fs = get_fs().change_context(Error::Io)?;
|
||||
let mut com = Command::new("cargo");
|
||||
com.current_dir("kernel");
|
||||
|
@ -168,14 +159,16 @@ fn build(release: bool, target: Target) -> Result<(), Error> {
|
|||
_ => (),
|
||||
}
|
||||
|
||||
if target != Target::Aarch64 {
|
||||
todo!()
|
||||
}
|
||||
let kernel_dir = match target {
|
||||
Target::X86_64 => "target/x86_64-ableos",
|
||||
Target::Riscv64Virt => "target/riscv64-virt-ableos",
|
||||
Target::Aarch64 => "target/aarch64-virt-ableos",
|
||||
};
|
||||
|
||||
(|| -> std::io::Result<_> {
|
||||
io::copy(
|
||||
&mut File::open(
|
||||
Path::new("target/aarch64-virt-ableos")
|
||||
Path::new(kernel_dir)
|
||||
.join(if release { "release" } else { "debug" })
|
||||
.join("kernel"),
|
||||
)?,
|
||||
|
@ -193,60 +186,45 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
|||
Target::Riscv64Virt => Command::new("qemu-system-riscv64"),
|
||||
Target::Aarch64 => Command::new("qemu-system-aarch64"),
|
||||
};
|
||||
let ovmf_path = fetch_ovmf(target);
|
||||
|
||||
if target == Target::X86_64 {
|
||||
#[rustfmt::skip]
|
||||
com.args([
|
||||
"-bios", "target/OVMF_CODE.fd",
|
||||
"-drive", "file=target/disk.img,format=raw",
|
||||
"-m", "4G",
|
||||
// "-serial", "stdio",
|
||||
"-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"]);
|
||||
match target {
|
||||
Target::X86_64 => {
|
||||
#[rustfmt::skip]
|
||||
com.args([
|
||||
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||
"-drive", "file=target/disk.img,format=raw",
|
||||
"-m", "4G",
|
||||
"-smp", "cores=4",
|
||||
]);
|
||||
}
|
||||
Target::Riscv64Virt => {
|
||||
#[rustfmt::skip]
|
||||
com.args([
|
||||
"-M", "virt",
|
||||
"-m", "128M",
|
||||
"-serial", "stdio",
|
||||
"-kernel",
|
||||
if release {
|
||||
"target/riscv64-virt-ableos/release/kernel"
|
||||
} else {
|
||||
"target/riscv64-virt-ableos/debug/kernel"
|
||||
}
|
||||
]);
|
||||
}
|
||||
Target::Aarch64 => {
|
||||
#[rustfmt::skip]
|
||||
com.args([
|
||||
"-M", "virt",
|
||||
"-cpu", "cortex-a72",
|
||||
"-device", "ramfb",
|
||||
"-device", "qemu-xhci",
|
||||
"-device", "usb-kbd",
|
||||
"-m", "2G",
|
||||
"-bios", &ovmf_path.change_context(Error::OvmfFetch)?,
|
||||
"-drive", "file=target/disk.img,format=raw",
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if target == Target::Riscv64Virt {
|
||||
#[rustfmt::skip]
|
||||
com.args([
|
||||
"-M", "virt",
|
||||
"-m", "128M",
|
||||
"-serial", "stdio",
|
||||
"-kernel",
|
||||
if release {
|
||||
"target/riscv64-virt-ableos/release/kernel"
|
||||
} else {
|
||||
"target/riscv64-virt-ableos/debug/kernel"
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
if target == Target::Aarch64 {
|
||||
#[rustfmt::skip]
|
||||
com.args([
|
||||
"-M", "virt",
|
||||
"-cpu", "cortex-a72",
|
||||
"-device", "ramfb",
|
||||
"-device", "qemu-xhci",
|
||||
"-device", "usb-kbd",
|
||||
"-m", "2G",
|
||||
"-bios", "target/AARCH64_OVMF.fd",
|
||||
"-drive", "file=target/disk.img,format=raw",
|
||||
]);
|
||||
}
|
||||
|
||||
match com
|
||||
|
@ -259,39 +237,48 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
|||
}
|
||||
}
|
||||
|
||||
fn fetch_ovmf() -> Result<(), OvmfFetchError> {
|
||||
const OVMF_AARCH64_URL: &str =
|
||||
"https://retrage.github.io/edk2-nightly/bin/RELEASEAARCH64_QEMU_EFI.fd";
|
||||
fn fetch_ovmf(target: Target) -> Result<String, OvmfFetchError> {
|
||||
let (ovmf_url, ovmf_path) = match target {
|
||||
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()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.read(true)
|
||||
.open("target/AARCH64_OVMF.fd")
|
||||
.open(ovmf_path)
|
||||
.into_report()
|
||||
.change_context(OvmfFetchError::Io)?,
|
||||
Ok(_) => return Ok(()),
|
||||
Ok(_) => return Ok(ovmf_path.to_owned()),
|
||||
Err(e) => return Err(report!(e).change_context(OvmfFetchError::Io)),
|
||||
};
|
||||
|
||||
log::info!("No OVMF found, downloading…");
|
||||
|
||||
let bytes = std::convert::identity((|| reqwest::blocking::get(OVMF_AARCH64_URL)?.bytes())())
|
||||
let mut bytes = reqwest::blocking::get(ovmf_url)
|
||||
.into_report()
|
||||
.change_context(OvmfFetchError::Fetch)?;
|
||||
|
||||
file.write_all(&bytes)
|
||||
bytes
|
||||
.copy_to(&mut file)
|
||||
.into_report()
|
||||
.change_context(OvmfFetchError::Io)?;
|
||||
|
||||
Ok(())
|
||||
Ok(ovmf_path.to_owned())
|
||||
}
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
enum OvmfFetchError {
|
||||
#[display(fmt = "Failed to fetch OVMF package")]
|
||||
Fetch,
|
||||
#[display(fmt = "No OVMF package available")]
|
||||
Empty,
|
||||
#[display(fmt = "IO Error")]
|
||||
Io,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue