打印中断控制器结构的信息

This commit is contained in:
fslongjin
2022-03-13 17:12:20 +08:00
parent 9dd1c65cae
commit 1f3c8bc204
6 changed files with 119 additions and 47 deletions

View File

@ -4,6 +4,7 @@
#include "../../../common/cpu.h"
#include "../../../common/glib.h"
#include "../../../exception/gate.h"
#include "../../acpi/acpi.h"
// 导出定义在irq.c中的中段门表
extern void (*interrupt_table[24])(void);
@ -13,6 +14,8 @@ bool flag_support_x2apic = false;
uint local_apic_version;
uint local_apic_max_LVT_entries;
static struct acpi_Multiple_APIC_Description_Table_t *madt;
/**
* @brief 初始化io_apic
*
@ -27,7 +30,28 @@ void apic_io_apic_init()
io_out8(0x21, 0xff);
io_out8(0xa1, 0xff);
kdebug("8259A Masked.");
ul madt_addr;
kdebug("madt_addr = %#018lx", (ul)madt_addr);
acpi_iter_SDT(acpi_get_MADT, &madt_addr);
madt = (struct acpi_Multiple_APIC_Description_Table_t *)madt_addr;
kdebug("MADT->local intr controller addr=%#018lx", madt->Local_Interrupt_Controller_Address);
kdebug("MADT->length= %d bytes", madt->header.Length);
void *ent = (void *)(madt_addr) + sizeof(struct acpi_Multiple_APIC_Description_Table_t);
struct apic_Interrupt_Controller_Structure_header_t *header;
for (int i = 0; i < 17; ++i)
{
header = (struct apic_Interrupt_Controller_Structure_header_t *)ent;
kdebug("[ %d ] type=%d, length=%d", i, header->type, header->length);
if (header->type == 1)
{
struct acpi_IO_APIC_Structure_t *t = (struct acpi_IO_APIC_Structure_t *)ent;
kdebug("IO apic addr = %#018lx", t->IO_APIC_Address);
}
ent += header->length;
}
apic_local_apic_init();
sti();
}

View File

@ -4,6 +4,18 @@
#include"../../../process/ptrace.h"
#include"../../../exception/irq.h"
struct apic_IO_APIC_map
{
// 间接访问寄存器的物理基地址
uint addr_phys;
// 索引寄存器虚拟地址
unsigned char* virtual_index_addr;
// 数据寄存器虚拟地址
uint* virtual_data_addr;
// EOI寄存器虚拟地址
uint* virtual_EOI_addr;
}apic_ioapic_map;
/**
* @brief 中断服务程序
*