loongarch 3a6000 ivc通信
目录
hvisor 与ivc相关的加载步骤
rust_main(src/main.rs)--->primary_init_early(src/main.rs)--->zone_create(src/main.rs->src/zone.rs)--->arch_zone_pre_configuration(src/arch/loongarch64/zone.rs)--->ivc_init(src/arch/loongarch64/ivc.rs)
其中 platform_root_zone_config 读取 ROOT_ZONE_IVC_CONFIG 和 ROOT_ZONE_IRQS
pub struct Zone {
pub name: [u8; CONFIG_NAME_MAXLEN],
pub id: usize,
pub mmio: Vec<MMIOConfig>,
pub cpu_num: usize,
pub cpu_set: CpuSet,
pub irq_bitmap: [u32; 1024 / 32],
pub gpm: MemorySet<Stage2PageTable>,
pub pciroot: PciRoot,
pub iommu_pt: Option<MemorySet<Stage2PageTable>>,
pub is_err: bool,
}
pub struct HvZoneConfig {
pub zone_id: u32,
cpus: u64,
num_memory_regions: u32,
memory_regions: [HvConfigMemoryRegion; CONFIG_MAX_MEMORY_REGIONS],
num_interrupts: u32,
interrupts: [u32; CONFIG_MAX_INTERRUPTS],
num_ivc_configs: u32,
ivc_configs: [HvIvcConfig; CONFIG_MAX_IVC_CONFIGS],
pub entry_point: u64,
pub kernel_load_paddr: u64,
pub kernel_size: u64,
pub dtb_load_paddr: u64,
pub dtb_size: u64,
pub name: [u8; CONFIG_NAME_MAXLEN],
pub arch_config: HvArchZoneConfig,
pub pci_config: HvPciConfig,
pub num_pci_devs: u64,
pub alloc_pci_devs: [u64; CONFIG_MAX_PCI_DEV],
}
HvZoneConfig::new(
0,
ROOT_ZONE_CPUS,
ROOT_ZONE_MEMORY_REGIONS.len() as u32,
memory_regions,
ROOT_ZONE_IRQS.len() as u32,
interrupts,
_num_ivc_configs as _,
ivc_configs,
ROOT_ZONE_ENTRY,
ROOT_ZONE_KERNEL_ADDR,
INVALID_ADDRESS as _,
ROOT_ZONE_DTB_ADDR,
INVALID_ADDRESS as _,
name,
ROOT_ARCH_ZONE_CONFIG,
_root_pci_cfg,
_num_pci_devs,
pci_devs,
)
修改 ivc_driver.c
本来只有arm64架构的相关接口代码,添加了loongarch架构的代码
在 hvisor-tool 目录下执行:
make all ARCH=loongarch LOG=LOG_WARN KDIR=对应的linux源码目录
修改了linux1/2/3.dts的设备树
添加了如下
hvisor_ivc_device {
compatible = "hvisor";
interrupts = <0x00 0x22 0x01>;
};
ivc.ko 要用两个不同版本的 linux 源码来编译
修改board.rs
pub const ROOT_ZONE_IVC_CONFIG: [HvIvcConfig; 1] = [
HvIvcConfig {
ivc_id: 0,
peer_id: 0,
control_table_ipa: 0x1400_0000,
shared_mem_ipa: 0x1400_1000,
rw_sec_size: 0,
out_sec_size: 0x1000,
interrupt_num: 65,
max_peers: 4,
},
];
pub const ZONE1_IVC_CONFIG: [HvIvcConfig; 1] = [
HvIvcConfig {
ivc_id: 0,
peer_id: 1,
control_table_ipa: 0x1408_0000,
shared_mem_ipa: 0x1408_1000,
rw_sec_size: 0,
out_sec_size: 0x1000,
interrupt_num: 66,
max_peers: 4,
},
];
中断部分调用链
_hyp_trap_vector
trap_handler
handle_exception
handle_interrupt(is)
clear_hwi_injected_irq
gintc::set_hwis(0)
check_events
arch_check_events(event)
clear_hwi_injected_irq
gintc::set_hwis(0)

浙公网安备 33010602011771号