Skip to content

Commit 0166d8a

Browse files
authored
fix x86 (#306)
* Add QEMU x86_64 platform support and various enhancements - Introduced a new configuration file for QEMU x86_64 platform. - Updated build scripts to accommodate changes in linker script generation. - Enhanced Cargo.toml for x86-qemu-q35 platform with additional dependencies and features. - Implemented multi-processor booting with support for application processors. - Added APIC support for interrupt handling and timer management. - Created boot and console modules for kernel initialization and UART communication. - Developed memory management functionalities, including physical memory information retrieval. - Implemented time management using TSC as the clock source. - Added power management functionalities for system shutdown and CPU bootstrapping. - Updated linker script to include driver registration sections. - Created a new script for QEMU x86_64 execution with appropriate arguments. * refactor: update platform features and remove unused configurations
1 parent 8a77f3f commit 0166d8a

26 files changed

+1088
-129
lines changed

Cargo.lock

Lines changed: 110 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ axstd = {git = "https://github.com/arceos-hypervisor/arceos.git", tag = "hv-0.4.
3838
"irq",
3939
"multitask",
4040
"smp", # "page-alloc-64g",
41-
"myplat",
42-
"driver-dyn",
4341
]}
4442

4543
axalloc = {git = "https://github.com/arceos-hypervisor/arceos.git", tag = "hv-0.4.1"}

configs/board/orangepi-5-plus.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cargo_args = []
22
features = [
3-
# "ept-level-4",
4-
"axstd/myplat",
5-
"axstd/bus-mmio",
6-
"driver/sdmmc",
7-
"driver/rk3588-clk",
8-
"fs",
3+
# "ept-level-4",
4+
"dyn-plat",
5+
"axstd/bus-mmio",
6+
"driver/sdmmc",
7+
"driver/rk3588-clk",
8+
"fs",
99
]
1010
log = "Info"
1111
target = "aarch64-unknown-none-softfloat"
1212
to_bin = true
13-
vm_configs = []
13+
vm_configs = []

configs/board/phytiumpi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cargo_args = []
22
features = [
33
# "ept-level-4",
4-
"axstd/myplat",
4+
"dyn-plat",
55
"axstd/bus-mmio",
66
]
77
log = "Info"

configs/board/qemu-aarch64.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cargo_args = []
22
features = [
33
"ept-level-4",
4-
"axstd/myplat",
54
"axstd/bus-mmio",
5+
"dyn-plat",
66
]
77
log = "Info"
88
target = "aarch64-unknown-none-softfloat"

configs/board/qemu-x86_64.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cargo_args = []
2+
features = [
3+
"ept-level-4",
4+
]
5+
log = "Info"
6+
target = "x86_64-unknown-none"
7+
to_bin = false
8+
vm_configs = []

configs/board/roc-rk3568-pc.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cargo_args = []
22
features = [
33
# "ept-level-4",
4-
"axstd/myplat",
4+
"dyn-plat",
55
"axstd/bus-mmio",
66
]
77
log = "Info"

kernel/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ name = "axvisor"
77
[features]
88
ept-level-4 = ["axaddrspace/4-level-ept"]
99
fs = ["axstd/fs", "axruntime/fs"]
10+
dyn-plat = ["axstd/myplat", "axstd/driver-dyn", "axruntime/driver-dyn"]
1011

1112
[dependencies]
1213
bitflags.workspace = true
@@ -27,14 +28,12 @@ axstd = {workspace = true, features = [
2728
"irq",
2829
"multitask",
2930
"smp",
30-
"myplat",
31-
"driver-dyn",
3231
]}
3332

3433
# System dependent modules provided by ArceOS-Hypervisor.
3534
axaddrspace.workspace = true
3635
axhvc.workspace = true
37-
axruntime = {workspace = true, features = ["alloc", "irq", "paging", "smp", "driver-dyn", "multitask"]}
36+
axruntime = {workspace = true, features = ["alloc", "irq", "paging", "smp", "multitask"]}
3837
axvcpu.workspace = true
3938
axvm.workspace = true
4039

kernel/build.rs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::{
2626
env,
2727
ffi::OsString,
2828
fs,
29-
io::{self, Write},
29+
io::Write,
3030
path::{Path, PathBuf},
3131
};
3232

@@ -239,10 +239,6 @@ fn generate_guest_img_loading_functions(
239239

240240
fn main() -> anyhow::Result<()> {
241241
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
242-
let mut smp = None;
243-
if let Ok(s) = std::env::var("AXVISOR_SMP") {
244-
smp = Some(s.parse::<usize>().unwrap_or(1));
245-
}
246242

247243
// let platform = env::var("AX_PLATFORM").unwrap_or("".to_string());
248244

@@ -256,10 +252,6 @@ fn main() -> anyhow::Result<()> {
256252

257253
println!("cargo:rustc-cfg=platform=\"{platform}\"");
258254

259-
if platform != "dummy" {
260-
gen_linker_script(&arch, platform.as_str(), smp.unwrap_or(1)).unwrap();
261-
}
262-
263255
let config_files = get_configs();
264256
let mut output_file = open_output_file();
265257

@@ -298,27 +290,3 @@ fn main() -> anyhow::Result<()> {
298290
}
299291
Ok(())
300292
}
301-
302-
fn gen_linker_script(arch: &str, platform: &str, smp: usize) -> io::Result<()> {
303-
let fname = format!("linker_{platform}.lds");
304-
let output_arch = if arch == "x86_64" {
305-
"i386:x86-64"
306-
} else if arch.contains("riscv") {
307-
"riscv" // OUTPUT_ARCH of both riscv32/riscv64 is "riscv"
308-
} else {
309-
arch
310-
};
311-
let ld_content = std::fs::read_to_string("../scripts/lds/linker.lds.S")?;
312-
let ld_content = ld_content.replace("%ARCH%", output_arch);
313-
let ld_content = ld_content.replace("%KERNEL_BASE%", &format!("{:#x}", 0x800000000000usize));
314-
let ld_content = ld_content.replace("%SMP%", &format!("{smp}",));
315-
316-
// target/<target_triple>/<mode>/build/axvisor-xxxx/out
317-
let out_dir = std::env::var("OUT_DIR").unwrap();
318-
// target/<target_triple>/<mode>/linker_xxxx.lds
319-
let out_path = Path::new(&out_dir).join("../../../").join(fname);
320-
321-
println!("writing linker script to {}", out_path.display());
322-
std::fs::write(out_path, ld_content)?;
323-
Ok(())
324-
}

0 commit comments

Comments
 (0)