Skip to content

Commit 1dd46ae

Browse files
committed
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.
1 parent 8a77f3f commit 1dd46ae

File tree

19 files changed

+1086
-29
lines changed

19 files changed

+1086
-29
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.

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 = []

kernel/build.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ fn main() -> anyhow::Result<()> {
256256

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

259-
if platform != "dummy" {
260-
gen_linker_script(&arch, platform.as_str(), smp.unwrap_or(1)).unwrap();
261-
}
259+
// if platform != "dummy" {
260+
// gen_linker_script(&arch, platform.as_str(), smp.unwrap_or(1)).unwrap();
261+
// }
262262

263263
let config_files = get_configs();
264264
let mut output_file = open_output_file();
@@ -299,8 +299,8 @@ fn main() -> anyhow::Result<()> {
299299
Ok(())
300300
}
301301

302-
fn gen_linker_script(arch: &str, platform: &str, smp: usize) -> io::Result<()> {
303-
let fname = format!("linker_{platform}.lds");
302+
fn gen_linker_script(arch: &str, _platform: &str, smp: usize) -> io::Result<()> {
303+
let fname = "link.x";
304304
let output_arch = if arch == "x86_64" {
305305
"i386:x86-64"
306306
} else if arch.contains("riscv") {
@@ -310,15 +310,16 @@ fn gen_linker_script(arch: &str, platform: &str, smp: usize) -> io::Result<()> {
310310
};
311311
let ld_content = std::fs::read_to_string("../scripts/lds/linker.lds.S")?;
312312
let ld_content = ld_content.replace("%ARCH%", output_arch);
313-
let ld_content = ld_content.replace("%KERNEL_BASE%", &format!("{:#x}", 0x800000000000usize));
313+
let ld_content = ld_content.replace("%KERNEL_BASE%", &format!("{:#x}", 0xffff800000200000usize));
314314
let ld_content = ld_content.replace("%SMP%", &format!("{smp}",));
315315

316-
// target/<target_triple>/<mode>/build/axvisor-xxxx/out
317316
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);
317+
println!("cargo:rerun-if-changed=../scripts/lds/linker.lds.S");
318+
println!("cargo:rustc-link-search={out_dir}");
319+
320+
let out_path = Path::new(&out_dir).join(fname);
320321

321322
println!("writing linker script to {}", out_path.display());
322-
std::fs::write(out_path, ld_content)?;
323+
// std::fs::write(out_path, ld_content)?;
323324
Ok(())
324325
}

platform/x86-qemu-q35/Cargo.toml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,36 @@ name = "axplat-x86-qemu-q35"
44
version = "0.1.0"
55

66
[features]
7-
fp-simd = ["axplat-x86-pc/fp-simd"]
8-
rtc = ["axplat-x86-pc/x86_rtc"]
7+
default = [
8+
"irq",
9+
"smp",
10+
"reboot-on-system-off",
11+
]
12+
fp-simd = []
13+
irq = ["axplat/irq"]
14+
reboot-on-system-off = []
15+
rtc = ["dep:x86_rtc"]
16+
smp = ["axplat/smp", "kspin/smp"]
917

1018
[dependencies]
11-
axplat-x86-pc = {git = "https://github.com/arceos-hypervisor/axplat_crates.git", tag = "vmm-v0.3.0", features = ["irq", "smp"]}
19+
axconfig-macros = "0.2"
20+
axcpu = "0.2"
21+
axplat = {workspace = true}
22+
bitflags = "2.6"
23+
heapless = "0.9"
24+
int_ratio = "0.1"
25+
kspin = "0.1"
26+
lazyinit = "0.2"
27+
log = "0.4"
28+
percpu = "0.2"
29+
30+
multiboot = "0.8"
31+
raw-cpuid = "11.5"
32+
uart_16550 = "0.4"
33+
x2apic = "0.5"
34+
x86 = "0.52"
35+
x86_64 = "0.15.2"
36+
x86_rtc = {version = "0.1", optional = true}
37+
38+
[package.metadata.docs.rs]
39+
targets = ["x86_64-unknown-none"]

platform/x86-qemu-q35/build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ fn main() {
99

1010
let ld_content = include_str!("linker.lds.S");
1111
let ld_content = ld_content.replace("%ARCH%", "i386:x86-64");
12-
let ld_content = ld_content.replace("%KERNEL_BASE%", &format!("{:#x}", 0x800000000000usize));
12+
let ld_content =
13+
ld_content.replace("%KERNEL_BASE%", &format!("{:#x}", 0xffff800000200000usize));
1314
let ld_content = ld_content.replace("%SMP%", &format!("{smp}",));
1415

1516
// target/<target_triple>/<mode>/build/axvisor-xxxx/out
1617
let out_dir = std::env::var("OUT_DIR").unwrap();
1718
let out_path = std::path::Path::new(&out_dir).join("link.x");
18-
19+
println!("cargo:rustc-link-search={out_dir}");
1920
std::fs::write(out_path, ld_content).unwrap();
2021
}

platform/x86-qemu-q35/linker.lds.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
OUTPUT_ARCH(%ARCH%)
22

33
BASE_ADDRESS = %KERNEL_BASE%;
4-
SMP = %SMP%
4+
SMP = %SMP%;
55

66
ENTRY(_start)
77
SECTIONS
@@ -30,6 +30,10 @@ SECTIONS
3030
_sdata = .;
3131
*(.data.boot_page_table)
3232
. = ALIGN(4K);
33+
__sdriver_register = .;
34+
KEEP(*(.driver.register*))
35+
__edriver_register = .;
36+
3337
*(.data .data.*)
3438
*(.sdata .sdata.*)
3539
*(.got .got.*)

0 commit comments

Comments
 (0)