acpi_scan() is defined in
kernel/acpi/tables.c, and it works with any table that has a pointer within the RSDT. So it works with SSDTs but not with the DSDT, which is why I also clarified in my document that you need to pass a pointer to the DSDT as an argument when initializing the namespace. This function returns a void pointer and not a pointer to an ACPI AML table, because not all ACPI tables are AML-encoded.
When it does return an AML table (i.e. when scanning for an SSDT,) the data can be used with this structure:
Code:
typedef struct acpi_aml_t // AML tables, DSDT and SSDT
{
acpi_header_t header;
uint8_t data[];
}__attribute__((packed)) acpi_aml_t;
Notice that "data" is an array, not a pointer, because the AML tables don't have pointers.
BenLunt wrote:
Will the "acpi_scan()" function ever be called for something else?
From within the AML interpreter itself, no. It will only be used to find AML-encoded tables, but the remaining of the non-AML ACPI code (SMP/APIC, HPET, etc) needs this function still, which is why it returns a void pointer. That code, of course, is inside the kernel and not in the AML interpreter.
BenLunt wrote:
Also, it doesn't look like your code ever frees the memory used by both the acpi_aml_t structure, nor the data pointed to by "data". Is this the responsibility of the caller?
Data is not a pointer, and acpi_aml_t doesn't allocate memory, it simply maps the ACPI tables into the virtual address space, so this doesn't waste much space. Anyway there are a few memory leaks I am aware of, and they will be fixed before a stable release.