1 #include <resources/acpi.h>
2 #include <utility/hooks.h>
10 static const struct HeaderData headers
[] =
12 {ACPI_MAKE_ID('A','P','I','C'), sizeof(struct ACPI_TABLE_TYPE_MADT
)},
16 /*****************************************************************************
19 #include <proto/acpi.h>
21 AROS_LH4(ULONG
, ACPI_ScanEntries
,
24 AROS_LHA(struct ACPI_TABLE_DEF_HEADER
*, table
, A0
),
25 AROS_LHA(WORD
, type
, D0
),
26 AROS_LHA(const struct Hook
*, hook
, A1
),
27 AROS_LHA(APTR
, userdata
, A2
),
30 struct ACPIBase
*, ACPIBase
, 2, Acpi
)
33 Scan entries with the given type in the given table.
34 The supplied hook will be called for each entry
37 table - a pointer to a table to scan
38 type - type of entries needed, or ACPI_ENTRY_TYPE_ALL to
40 hook - a hook to call. The hook will be called with 'object'
41 argument set to entry pointer, and 'paramPacket' set to
42 'userdata' argument. You can pass a NULL here in order just
43 to count the number of entries.
44 userdata - a user-supplied data to pass to the hook.
47 Total number of processed entries. The entry is considered processed if
48 either supplied hook returns nonzero value, or there's no hook supplied.
60 ******************************************************************************/
64 struct ACPI_TABLE_DEF_ENTRY_HEADER
*entry
= NULL
;
66 const struct HeaderData
*hdr
;
69 for (hdr
= headers
; hdr
->id
; hdr
++)
71 if (hdr
->id
== table
->signature
)
73 /* First entry follows table header */
74 entry
= (APTR
)table
+ hdr
->len
;
81 /* The given table doesn't have array of entries inside */
85 /* Get end of the table */
86 end
= (unsigned long)table
+ table
->length
;
88 /* Parse all entries looking for a match. */
89 while (((unsigned long)entry
) < end
)
91 if ((type
== ACPI_ENTRY_TYPE_ALL
) || (type
== entry
->type
))
95 BOOL res
= CALLHOOKPKT((struct Hook
*)hook
, entry
, userdata
);
103 entry
= (struct ACPI_TABLE_DEF_ENTRY_HEADER
*)((unsigned long)entry
+ entry
->length
);