mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-19 04:56:30 +00:00
测试IPI
This commit is contained in:
37
kernel/arch/x86_64/x86_64_ipi.c
Normal file
37
kernel/arch/x86_64/x86_64_ipi.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include "x86_64_ipi.h"
|
||||
|
||||
void ipi_send_IPI(uint32_t dest_mode, uint32_t deliver_status, uint32_t level, uint32_t trigger,
|
||||
uint32_t vector, uint32_t deliver_mode, uint32_t dest_shorthand, bool apic_type, uint32_t destination)
|
||||
{
|
||||
struct INT_CMD_REG icr_entry;
|
||||
icr_entry.dest_mode = dest_mode;
|
||||
icr_entry.deliver_status = deliver_status;
|
||||
icr_entry.res_1 = 0;
|
||||
icr_entry.level = level;
|
||||
icr_entry.trigger = trigger;
|
||||
icr_entry.res_2 = 0;
|
||||
icr_entry.res_3 = 0;
|
||||
|
||||
icr_entry.vector = vector;
|
||||
icr_entry.deliver_mode = deliver_mode;
|
||||
icr_entry.dest_shorthand = dest_shorthand;
|
||||
|
||||
// x2APIC下,ICR寄存器地址为0x830
|
||||
// xAPIC下则为0xfee00300(31-0) 0xfee00310 (63-32)
|
||||
if (apic_type) // x2APIC
|
||||
{
|
||||
icr_entry.destination.x2apic_destination = destination;
|
||||
wrmsr(0x830, *(unsigned long *)&icr_entry); // 发送ipi
|
||||
}
|
||||
else // xAPIC
|
||||
{
|
||||
|
||||
icr_entry.destination.apic_destination.dest_field = destination & 0xff;
|
||||
icr_entry.destination.apic_destination.res_4 = 0;
|
||||
// 先向高32bit写数据,然后再向低32bit写数据,不能调转
|
||||
*(uint32_t*)(APIC_LOCAL_APIC_VIRT_BASE_ADDR+0x310) = (uint32_t)(((*(ul*)&icr_entry)>>32)&0xffff);
|
||||
*(uint32_t*)(APIC_LOCAL_APIC_VIRT_BASE_ADDR+0x300) = (uint32_t)((*(ul*)&icr_entry)&0xffff);
|
||||
}
|
||||
|
||||
|
||||
}
|
31
kernel/arch/x86_64/x86_64_ipi.h
Normal file
31
kernel/arch/x86_64/x86_64_ipi.h
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @file ipi.h
|
||||
* @author fslongjin(longjin@RinGoTek.cn)
|
||||
* @brief 多核通信驱动
|
||||
* @version 0.1
|
||||
* @date 2022-04-07
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../common/kprint.h"
|
||||
#include "../../driver/interrupt/apic/apic.h"
|
||||
|
||||
/**
|
||||
* @brief 发送ipi消息
|
||||
*
|
||||
* @param dest_mode 目标模式
|
||||
* @param deliver_status 投递模式
|
||||
* @param level 信号驱动电平
|
||||
* @param trigger 触发模式
|
||||
* @param vector 中断向量
|
||||
* @param deliver_mode 投递模式
|
||||
* @param dest_shorthand 投递目标速记值
|
||||
* @param apic_type apic的类型 (0:xapic 1: x2apic)
|
||||
* @param destination 投递目标
|
||||
*/
|
||||
void ipi_send_IPI(uint32_t dest_mode, uint32_t deliver_status, uint32_t level, uint32_t trigger,
|
||||
uint32_t vector, uint32_t deliver_mode, uint32_t dest_shorthand, bool apic_type,uint32_t destination);
|
Reference in New Issue
Block a user