arch/x86: Cleanup ACPI structure attributes names

No need to mix super short version of names with other structures
having full name. Let's follow a more relevant naming where each and
every attribute name is self-documenting then. (such as s/id/apic_id
etc...)

Also make CONFIG_ACPI usable through IS_ENABLED by enclosing exposed
functions with ifdef CONFIG_ACPI.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-09-09 13:30:17 +02:00 committed by Andrew Boie
parent 0be8a91a73
commit c7787c623e
4 changed files with 37 additions and 27 deletions

View file

@ -31,7 +31,7 @@ static bool check_sum(struct acpi_sdt *t)
{
uint8_t sum = 0, *p = (uint8_t *)t;
for (int i = 0; i < t->len; i++) {
for (int i = 0; i < t->length; i++) {
sum += p[i];
}
return sum == 0;
@ -98,12 +98,12 @@ void *z_acpi_find_table(uint32_t signature)
struct acpi_rsdt *rsdt = (void *)(long)rsdp->rsdt_ptr;
if (rsdt && check_sum(&rsdt->sdt)) {
uint32_t *end = (uint32_t *)((char *)rsdt + rsdt->sdt.len);
uint32_t *end = (uint32_t *)((char *)rsdt + rsdt->sdt.length);
for (uint32_t *tp = &rsdt->table_ptrs[0]; tp < end; tp++) {
struct acpi_sdt *t = (void *)(long)*tp;
if (t->sig == signature && check_sum(t)) {
if (t->signature == signature && check_sum(t)) {
return t;
}
}
@ -116,12 +116,12 @@ void *z_acpi_find_table(uint32_t signature)
struct acpi_xsdt *xsdt = (void *)(long)rsdp->xsdt_ptr;
if (xsdt && check_sum(&xsdt->sdt)) {
uint64_t *end = (uint64_t *)((char *)xsdt + xsdt->sdt.len);
uint64_t *end = (uint64_t *)((char *)xsdt + xsdt->sdt.length);
for (uint64_t *tp = &xsdt->table_ptrs[0]; tp < end; tp++) {
struct acpi_sdt *t = (void *)(long)*tp;
if (t->sig == signature && check_sum(t)) {
if (t->signature == signature && check_sum(t)) {
return t;
}
}
@ -142,7 +142,7 @@ struct acpi_cpu *z_acpi_get_cpu(int n)
if (madt) {
offset = POINTER_TO_UINT(madt->entries) - base;
while (offset < madt->sdt.len) {
while (offset < madt->sdt.length) {
struct acpi_madt_entry *entry;
entry = (struct acpi_madt_entry *) (offset + base);

View file

@ -35,7 +35,7 @@ static void pcie_mm_init(void)
struct acpi_mcfg *m = z_acpi_find_table(ACPI_MCFG_SIGNATURE);
if (m != NULL) {
int n = (m->sdt.len - sizeof(*m)) / sizeof(m->pci_segs[0]);
int n = (m->sdt.length - sizeof(*m)) / sizeof(m->pci_segs[0]);
for (int i = 0; i < n && i < MAX_PCI_BUS_SEGMENTS; i++) {
size_t size;

View file

@ -8,19 +8,17 @@
#ifndef _ASMLANGUAGE
extern void *z_acpi_find_table(uint32_t signature);
/* Standard table header */
struct acpi_sdt {
uint32_t sig;
uint32_t len;
uint8_t rev;
uint8_t csum;
char oemid[6];
uint32_t signature;
uint32_t length;
uint8_t revision;
uint8_t chksum;
char oem_id[6];
char oem_table_id[8];
uint32_t oemrevision;
uint32_t oem_revision;
uint32_t creator_id;
uint32_t creator_rev;
uint32_t creator_revision;
} __packed;
/* MCFG table storing MMIO addresses for PCI configuration space */
@ -29,7 +27,7 @@ struct acpi_sdt {
struct acpi_mcfg {
struct acpi_sdt sdt;
uint64_t _rsvd;
uint64_t _reserved;
struct {
uint64_t base_addr;
uint16_t seg_group_num;
@ -42,31 +40,43 @@ struct acpi_mcfg {
#define ACPI_MADT_SIGNATURE 0x43495041 /* 'APIC' */
#define ACPI_MADT_FLAGS_PICS 0x01 /* legacy 8259s installed */
#define ACPI_MADT_ENTRY_CPU 0
struct acpi_madt_entry {
uint8_t type;
uint8_t type; /* See ACPI_MADT_ENTRY_* below */
uint8_t length;
} __packed;
#define ACPI_MADT_ENTRY_CPU 0
struct acpi_madt {
struct acpi_sdt sdt;
uint32_t lapic; /* local APIC MMIO address */
uint32_t loapic; /* local APIC MMIO address */
uint32_t flags; /* see ACPI_MADT_FLAGS_* below */
struct acpi_madt_entry entries[];
} __packed;
#define ACPI_MADT_FLAGS_PICS 0x01 /* legacy 8259s installed */
struct acpi_cpu {
struct acpi_madt_entry entry;
uint8_t dontcare;
uint8_t id; /* local APIC ID */
uint8_t flags; /* see ACPI_MADT_CPU_FLAGS_* */
uint8_t acpi_id;
uint8_t apic_id; /* local APIC ID */
uint8_t flags; /* see ACPI_CPU_FLAGS_* below */
} __packed;
#define ACPI_CPU_FLAGS_ENABLED 0x01
#if defined(CONFIG_ACPI)
void *z_acpi_find_table(uint32_t signature);
struct acpi_cpu *z_acpi_get_cpu(int n);
#define ACPI_CPU_FLAGS_ENABLED 0x01
#else /* CONFIG_ACPI */
#define z_acpi_find_table(...) NULL
#define z_acpi_get_cpu(...) NULL
#endif /* CONFIG_ACPI */
#endif /* _ASMLANGUAGE */

View file

@ -21,7 +21,7 @@ void acpi(void)
for (int i = 0; i < nr_cpus; ++i) {
struct acpi_cpu *cpu = z_acpi_get_cpu(i);
printk("\tCPU #%d: APIC ID 0x%02x\n", i, cpu->id);
printk("\tCPU #%d: APIC ID 0x%02x\n", i, cpu->apic_id);
}
}