mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-21 18:33:23 +00:00
打印中断控制器结构的信息
This commit is contained in:
@ -4,6 +4,9 @@
|
||||
#include "../multiboot2/multiboot2.h"
|
||||
#include "../../mm/mm.h"
|
||||
|
||||
// 获取RSDT entry的虚拟地址
|
||||
#define acpi_get_RSDT_entry_vaddr(phys_addr) (ACPI_DESCRIPTION_HEDERS_BASE + MASK_HIGH_32bit(phys_addr) - acpi_RSDT_entry_phys_base)
|
||||
|
||||
static struct acpi_RSDP_t *rsdpv1;
|
||||
static struct acpi_RSDP_2_t *rsdpv2;
|
||||
static struct acpi_RSDT_Structure_t *rsdt;
|
||||
@ -14,7 +17,6 @@ static struct multiboot_tag_new_acpi_t new_acpi;
|
||||
static ul acpi_RSDT_offset = 0;
|
||||
static uint acpi_RSDT_Entry_num = 0;
|
||||
|
||||
|
||||
// RSDT中的第一个entry所在物理页的基地址
|
||||
static ul acpi_RSDT_entry_phys_base = 0;
|
||||
|
||||
@ -23,15 +25,61 @@ static ul acpi_RSDT_entry_phys_base = 0;
|
||||
* @param _fun 迭代操作调用的函数
|
||||
* @param _data 数据
|
||||
*/
|
||||
void acpi_iter_SDT(bool (*_fun)(const struct acpi_iter_SDT_header_t *, void *),
|
||||
void acpi_iter_SDT(bool (*_fun)(const struct acpi_system_description_table_header_t *, void *),
|
||||
void *_data)
|
||||
{
|
||||
|
||||
struct acpi_system_description_table_header_t *sdt_header;
|
||||
uint *ent = &(rsdt->Entry);
|
||||
for (int i = 0; i < acpi_RSDT_Entry_num; ++i)
|
||||
{
|
||||
|
||||
sdt_header = (struct acpi_system_description_table_header_t *)(acpi_get_RSDT_entry_vaddr((ul)(*(ent + i))));
|
||||
|
||||
if (_fun(sdt_header, _data) == true)
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static ul acpi_get_RSDT_entry_vaddr(ul phys_addr)
|
||||
/**
|
||||
* @brief 获取MADT信息 Multiple APIC Description Table
|
||||
*
|
||||
* @param _iter_data 要被迭代的信息的结构体
|
||||
* @param _data 返回信息的结构体指针
|
||||
* @param count 返回数组的长度
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool acpi_get_MADT(const struct acpi_system_description_table_header_t *_iter_data, void *_data)
|
||||
{
|
||||
return ACPI_DESCRIPTION_HEDERS_BASE + MASK_HIGH_32bit(phys_addr) - acpi_RSDT_entry_phys_base;
|
||||
if (!(_iter_data->Signature[0] == 'A' && _iter_data->Signature[1] == 'P' && _iter_data->Signature[2] == 'I' && _iter_data->Signature[3] == 'C'))
|
||||
return false;
|
||||
//*(struct acpi_Multiple_APIC_Description_Table_t *)_data = *(struct acpi_Multiple_APIC_Description_Table_t *)_iter_data;
|
||||
*(ul*)_data = _iter_data;
|
||||
kdebug("_iter_data = %#018lx", (ul)_iter_data);
|
||||
kdebug("_data = %#018lx", (ul)_data);
|
||||
//_data = _iter_data;
|
||||
/*
|
||||
void *ent = (void *)(_iter_data) + 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;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化acpi模块
|
||||
*
|
||||
@ -63,13 +111,12 @@ void acpi_init()
|
||||
kdebug("Rsdt_v2_phys_Address=%#018lx", rsdpv2->rsdp1.RsdtAddress);
|
||||
kdebug("RSDP_v2_Revision=%d", rsdpv2->rsdp1.Revision);
|
||||
|
||||
rsdt = ACPI_RSDT_VIRT_ADDR_BASE + acpi_RSDT_offset;
|
||||
rsdt = (struct acpi_RSDT_Structure_t *)(ACPI_RSDT_VIRT_ADDR_BASE + acpi_RSDT_offset);
|
||||
|
||||
// 计算RSDT Entry的数量
|
||||
kdebug("offset=%d", sizeof(rsdt->header));
|
||||
acpi_RSDT_Entry_num = (rsdt->header.Length - 36) / 4;
|
||||
|
||||
printk_color(ORANGE, BLACK, "%s\n", rsdt->header.Signature);
|
||||
printk_color(ORANGE, BLACK, "RSDT Length=%dbytes.\n", rsdt->header.Length);
|
||||
printk_color(ORANGE, BLACK, "RSDT Entry num=%d\n", acpi_RSDT_Entry_num);
|
||||
|
||||
@ -78,26 +125,8 @@ void acpi_init()
|
||||
// 由于地址只是32bit的,并且存在脏数据,这里需要手动清除高32bit,否则会触发#GP
|
||||
acpi_RSDT_entry_phys_base = MASK_HIGH_32bit(acpi_RSDT_entry_phys_base);
|
||||
|
||||
|
||||
kdebug("entry=%#018lx", rsdt->Entry);
|
||||
kdebug("acpi_RSDT_entry_phys_base=%#018lx", acpi_RSDT_entry_phys_base);
|
||||
|
||||
// 映射RSDT ENTRY的物理地址
|
||||
mm_map_phys_addr(ACPI_DESCRIPTION_HEDERS_BASE, acpi_RSDT_entry_phys_base, PAGE_2M_SIZE, PAGE_KERNEL_PAGE | PAGE_PWT | PAGE_PCD);
|
||||
|
||||
// 设置第一个entry的虚拟地址
|
||||
struct acpi_system_description_table_header_t *sdt_header;
|
||||
uint* ent = &(rsdt->Entry);
|
||||
for (int i = 0; i < acpi_RSDT_Entry_num; ++i)
|
||||
{
|
||||
kdebug("entry_addr_phys[ %d ]= %#018lx", i, MASK_HIGH_32bit((ul)(*(ent+i))));
|
||||
sdt_header = (struct acpi_system_description_table_header_t *)(acpi_get_RSDT_entry_vaddr((ul)(*(ent+i))));
|
||||
if(i<7)
|
||||
{
|
||||
struct acpi_Multiple_APIC_Description_Table_t *madt = (struct acpi_Multiple_APIC_Description_Table_t*)sdt_header;
|
||||
for(int j=0;j<4;++j)
|
||||
printk_color(ORANGE, BLACK, "%c", madt->header.Signature[j]);
|
||||
printk("\n");
|
||||
kdebug("length=%d", madt->header.Length);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user