Autodoc formatting fixes.
[AROS.git] / arch / all-pc / acpi / findsdt.c
blobf08f980baf24d10fcb673b477a13ce6d961bdc5d
1 #include <aros/debug.h>
2 #include <resources/acpi.h>
4 /*****************************************************************************
6 NAME */
7 #include <proto/acpi.h>
9 AROS_LH1(APTR, ACPI_FindSDT,
11 /* SYNOPSIS */
12 AROS_LHA(ULONG, id, D0),
14 /* LOCATION */
15 struct ACPIBase *, ACPIBase, 1, Acpi)
17 /* FUNCTION
18 Locate a system description table with a given 4-character ID
20 INPUTS
21 id - a table ID (use ACPI_MAKE_ID() macro to get it)
23 RESULT
24 A pointer to a table or NULL if can't be found
26 NOTES
27 Some systems may include duplicating tables, often it's MADT.
28 In this case a table with the latest revision number will
29 be returned.
31 EXAMPLE
33 BUGS
35 SEE ALSO
37 INTERNALS
39 ******************************************************************************/
41 AROS_LIBFUNC_INIT
43 struct ACPI_TABLE_DEF_HEADER *found = NULL;
44 struct ACPI_TABLE_DEF_HEADER *header;
45 unsigned int i;
47 D(bug("[ACPI] acpi_LocateSDT('%4.4s')\n", &id));
49 /* Locate the table. */
50 for (i = 0; i < ACPIBase->ACPIB_SDT_Count; i++)
52 header = ACPIBase->ACPIB_SDT_Entry[i];
54 if (header->signature == id)
56 D(bug("[ACPI] acpi_LocateSDT: Table %4.4s pointer 0x%p rev %u\n", &header->signature, header, header->revision));
59 * Some firmwares have a strange thing - they contain multiple tables with the same signature
60 * and different revisions. A common example is MADT table.
61 * Here we select a table with the latest revision. ACPI specs don't say anything clear
62 * about this.
63 * Such behavior is exposed for example by MacMini EFI.
65 if ((found == NULL) || (header->revision > found->revision))
66 found = header;
70 return found;
72 AROS_LIBFUNC_EXIT