-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
285 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
*.bin | ||
qemu.log | ||
rusty-tags.vi | ||
/.project.toml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# How to run ArceOS on phytium pi | ||
|
||
First, we need `ostool` to build and upload the image to the board. It also supports windows. | ||
|
||
```bash | ||
cargo install ostool | ||
``` | ||
|
||
We also need to connect the board to the computer with serial port, and connect netwire to the board. The host pc and the board should be in the same network. | ||
|
||
Then, we can run it easily. | ||
|
||
```bash | ||
# cd arceos main dir. | ||
ostool run uboot | ||
``` | ||
|
||
![select](./figures/phytium_select_platform.png) | ||
|
||
Then, press `1` and `enter` to select phytium pi. | ||
|
||
![select](./figures/phytium_select_app.png) | ||
|
||
Then, select app you want to run. Item without `arceos-*` are not app and can not run. Here we select `arceos-helloworld` for test. | ||
|
||
![select](./figures/phytium_select_dtb.png) | ||
|
||
We can ignore select dtb step by pressing `enter` directly. ArceOS dose not support dtb yet. | ||
|
||
Then the cmdline will wait for you to put board power on or reset. | ||
|
||
You can modify config in `.project.toml` to change the default behavior. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,5 @@ ticks-per-sec = "100" | |
|
||
# Number of CPUs | ||
smp = "1" | ||
|
||
cpu-id-list = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::mem::*; | ||
use page_table_entry::{aarch64::A64PTE, GenericPTE, MappingFlags}; | ||
|
||
/// Returns platform-specific memory regions. | ||
pub(crate) fn platform_regions() -> impl Iterator<Item = MemRegion> { | ||
core::iter::once(MemRegion { | ||
paddr: 0x0.into(), | ||
size: 0x1000, | ||
flags: MemRegionFlags::RESERVED | MemRegionFlags::READ | MemRegionFlags::WRITE, | ||
name: "spintable", | ||
}) | ||
.chain(crate::mem::default_free_regions()) | ||
.chain(crate::mem::default_mmio_regions()) | ||
} | ||
|
||
pub(crate) unsafe fn init_boot_page_table( | ||
boot_pt_l0: *mut [A64PTE; 512], | ||
boot_pt_l1: *mut [A64PTE; 512], | ||
) { | ||
let boot_pt_l0 = &mut *boot_pt_l0; | ||
let boot_pt_l1 = &mut *boot_pt_l1; | ||
|
||
// 0x0000_0000_0000 ~ 0x0080_0000_0000, table | ||
boot_pt_l0[0] = A64PTE::new_table(pa!(boot_pt_l1.as_ptr() as usize)); | ||
// 0x0000_0000_0000..0x0000_8000_0000, 1G block, device memory | ||
boot_pt_l1[0] = A64PTE::new_page( | ||
pa!(0), | ||
MappingFlags::READ | MappingFlags::WRITE | MappingFlags::DEVICE, | ||
true, | ||
); | ||
// 0x0000_8000_0000..0x0000_C000_0000, 2G block, normal memory | ||
boot_pt_l1[2] = A64PTE::new_page( | ||
pa!(0x8000_0000), | ||
MappingFlags::READ | MappingFlags::WRITE | MappingFlags::EXECUTE, | ||
true, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
pub mod mem; | ||
|
||
#[cfg(feature = "smp")] | ||
pub mod mp; | ||
|
||
#[cfg(feature = "irq")] | ||
pub mod irq { | ||
pub use crate::platform::aarch64_common::gic::*; | ||
} | ||
|
||
pub mod console { | ||
pub use crate::platform::aarch64_common::pl011::*; | ||
} | ||
|
||
pub mod time { | ||
pub use crate::platform::aarch64_common::generic_timer::*; | ||
} | ||
|
||
pub mod misc { | ||
pub fn terminate() -> ! { | ||
info!("Shutting down..."); | ||
loop { | ||
crate::arch::halt(); | ||
} | ||
} | ||
} | ||
|
||
extern "C" { | ||
fn exception_vector_base(); | ||
fn rust_main(cpu_id: usize, dtb: usize); | ||
#[cfg(feature = "smp")] | ||
fn rust_main_secondary(cpu_id: usize); | ||
} | ||
|
||
pub(crate) unsafe extern "C" fn rust_entry(cpu_id: usize, dtb: usize) { | ||
crate::mem::clear_bss(); | ||
crate::arch::set_exception_vector_base(exception_vector_base as usize); | ||
crate::arch::write_page_table_root0(0.into()); // disable low address access | ||
crate::cpu::init_primary(cpu_id); | ||
super::aarch64_common::pl011::init_early(); | ||
super::aarch64_common::generic_timer::init_early(); | ||
rust_main(cpu_id, dtb); | ||
} | ||
|
||
#[cfg(feature = "smp")] | ||
pub(crate) unsafe extern "C" fn rust_entry_secondary(cpu_id: usize) { | ||
crate::arch::set_exception_vector_base(exception_vector_base as usize); | ||
crate::arch::write_page_table_root0(0.into()); // disable low address access | ||
crate::cpu::init_secondary(cpu_id); | ||
rust_main_secondary(cpu_id); | ||
} | ||
|
||
/// Initializes the platform devices for the primary CPU. | ||
/// | ||
/// For example, the interrupt controller and the timer. | ||
pub fn platform_init() { | ||
#[cfg(feature = "irq")] | ||
super::aarch64_common::gic::init_primary(); | ||
super::aarch64_common::generic_timer::init_percpu(); | ||
super::aarch64_common::pl011::init(); | ||
} | ||
|
||
/// Initializes the platform devices for secondary CPUs. | ||
#[cfg(feature = "smp")] | ||
pub fn platform_init_secondary() { | ||
#[cfg(feature = "irq")] | ||
super::aarch64_common::gic::init_secondary(); | ||
super::aarch64_common::generic_timer::init_percpu(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::mem::{virt_to_phys, PhysAddr}; | ||
|
||
extern "C" { | ||
fn _start_secondary(); | ||
} | ||
|
||
/// Starts the given secondary CPU with its boot stack. | ||
pub fn start_secondary_cpu(cpu_id: usize, stack_top: PhysAddr) { | ||
extern "C" { | ||
fn _start_secondary(); | ||
} | ||
let entry = virt_to_phys(va!(_start_secondary as usize)); | ||
crate::platform::aarch64_common::psci::cpu_on(cpu_id, entry.as_usize(), stack_top.as_usize()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Architecture identifier. | ||
arch = "aarch64" | ||
# Platform identifier. | ||
platform = "aarch64-phytium-pi" | ||
# Platform family. | ||
family = "aarch64-phytium-pi" | ||
|
||
# Base address of the whole physical memory. | ||
phys-memory-base = "0x8000_0000" | ||
# Size of the whole physical memory. | ||
phys-memory-size = "0x8000_0000" # 2G | ||
# Base physical address of the kernel image. | ||
kernel-base-paddr = "0x9000_0000" | ||
# Base virtual address of the kernel image. | ||
kernel-base-vaddr = "0xffff_0000_9000_0000" | ||
# Linear mapping offset, for quick conversions between physical and virtual | ||
# addresses. | ||
phys-virt-offset = "0xffff_0000_0000_0000" | ||
# MMIO regions with format (`base_paddr`, `size`). | ||
mmio-regions = [ | ||
["0x2800_C000", "0x1000"], # UART 0 | ||
["0x2800_D000", "0x1000"], # UART 1 | ||
["0x2800_E000", "0x1000"], # UART 2 | ||
["0x2800_F000", "0x1000"], # UART 3 | ||
# ["0x32a0_0000", "0x2_0000"], # usb0 | ||
# ["0x32a2_0000", "0x2_0000"], # usb0 | ||
# ["0x3200_C000", "0x2000"], #Ethernet1 | ||
# ["0x3200_E000", "0x2000"], #Ethernet2 | ||
# ["0x3080_0000", "0x8000"], # GICv2 | ||
["0x3000_0000", "0x800_0000"], #other devices | ||
["0x4000_0000", "0x1000_0000"], # pcie ecam | ||
|
||
["0x58000000", "0x7fffffff"], # 32-bit MMIO space | ||
|
||
["0x2801_4000", "0x2000"], # MIO0 - I2C | ||
["0x2801_6000", "0x2000"], # MIO1 - I2C | ||
["0x2801_8000", "0x2000"], # MIO2 - I2C | ||
["0x2801_A000", "0x2000"], # MIO3 - I2C | ||
["0x2801_C000", "0x2000"], # MIO4 - I2C | ||
|
||
["0x000_2803_4000", "0x1000"], # GPIO0 | ||
["0x000_2803_5000", "0x1000"], # GPIO1 | ||
["0x000_2803_6000", "0x1000"], # GPIO2 | ||
["0x000_2803_7000", "0x1000"], # GPIO3 | ||
["0x000_2803_8000", "0x1000"], # GPIO4 | ||
["0x000_2803_9000", "0x1000"], # GPIO5 | ||
|
||
# ["0x6_0000_0000", "0x4000_0000"] # pcie control | ||
] | ||
virtio-mmio-regions = [] | ||
# UART Address | ||
uart-paddr = "0x2800_D000" | ||
uart-irq = "24" | ||
|
||
# MIO0 I2C | ||
MIO0 = "0x2801_4000" | ||
|
||
# PSCI | ||
psci-method = "smc" | ||
|
||
# GIC Address | ||
gicc-paddr = "0xFF84_2000" | ||
gicd-paddr = "0xFF84_1000" | ||
|
||
# Base physical address of the PCIe ECAM space. | ||
pci-ecam-base = "0x40000000" | ||
# End PCI bus number. | ||
pci-bus-end = "0x2" | ||
# PCI device memory ranges. | ||
pci-ranges = [ | ||
["0x0", "0x50000000"], # PIO space | ||
["0x58000000", "0x7fffffff"], # 32-bit MMIO space | ||
["0x6_0000_0000", "0x6_3fff_ffff"], # 64-but MMIO space | ||
] | ||
|
||
cpu-id-list = ["0x0", "0x100", "0x200", "0x201"] |