1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! Configuration and definitions for specific boards on aarch64 systems.
//!
//! | Board Name | Num CPUs  | Interrupt Controller | Secondary CPU Startup Method |
//! | ---------- | --------- | -------------------- | ---------------------------- |
//! | qemu_virt  | 4         | GICv3                | PSCI                         |
//!

#![no_std]
#![feature(const_trait_impl)]

cfg_if::cfg_if! {
if #[cfg(target_arch = "aarch64")] {

use memory_structs::PhysicalAddress;

#[derive(Debug, Copy, Clone)]
pub struct GicV3InterruptControllerConfig {
    pub distributor_base_address: PhysicalAddress,
    pub redistributor_base_addresses: [PhysicalAddress; NUM_CPUS],
}

#[derive(Debug, Copy, Clone)]
pub struct PciEcamConfig {
    pub base_address: PhysicalAddress,
    pub size_bytes: usize,
}

/// This excludes GICv2 because there's no way to send IPIs
/// with GICv2 via the current driver API.
#[derive(Debug, Copy, Clone)]
pub enum InterruptControllerConfig {
    GicV3(GicV3InterruptControllerConfig),
}

/*
TODO: multicore_bringup: wake secondary cores based on this:
pub enum SecondaryCoresStartup {
    Psci,
}
*/

#[derive(Debug, Clone)]
pub struct BoardConfig {
    pub cpu_ids: [mpidr::DefinedMpidrValue; NUM_CPUS],
    pub interrupt_controller: InterruptControllerConfig,
    pub pl011_base_addresses: [PhysicalAddress; NUM_PL011_UARTS],

    /// The IRQ number reserved for the PL011 Single-Serial-Port Controller
    /// which Theseus currently uses for logging and UART console.
    pub pl011_rx_spi: u8,

    /// The IRQ number reserved for CPU-local timer interrupts,
    /// which Theseus currently uses for preemptive task switching.
    //
    // aarch64 manuals define the default timer IRQ number to be 30.
    pub cpu_local_timer_ppi: u8,

    /// The IRQ numbers reserved for legacy PCI interrupts: INTA, INTB, INTC and INTD.
    pub pci_intx: [u8; 4],

    pub pci_ecam: PciEcamConfig,
}

// by default & on x86_64, the default.rs file is used
#[cfg_attr(feature = "qemu_virt", path = "boards/qemu_virt.rs")]
#[cfg_attr(not(any(
    feature = "qemu_virt",
)), path = "boards/unselected.rs")]
mod board;

pub mod mpidr;

pub use board::{NUM_CPUS, NUM_PL011_UARTS, BOARD_CONFIG};


} // end of cfg(target_arch = "aarch64")
} // end of cfg_if