1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13#pragma pack(push,1)
14
15/* Root System Descriptor Table "RSDT" */
16typedef struct acpi_rsdt {
17    acpi_header_t  header;
18    /* access via inline functions */
19//    uint32_t        entry[];
20} acpi_rsdt_t;
21
22#pragma pack(pop)
23
24/* retrieve the number of entries in an rsdt table */
25static inline int
26acpi_rsdt_entry_count(acpi_rsdt_t* t)
27{
28    return (t->header.length - sizeof(*t)) / sizeof(uint32_t);
29}
30
31/* Retrieve the location of the first item in the list */
32static inline uint32_t*
33acpi_rsdt_first(acpi_rsdt_t* hdr)
34{
35    return (uint32_t*)(hdr + 1);
36}
37
38/* Retrieve the location of the next item in the list */
39static inline uint32_t*
40acpi_rsdt_next(acpi_rsdt_t* hdr, uint32_t* cur)
41{
42    char* next = (char*)(cur + 1);
43    char* end = (char*)hdr + hdr->header.length;
44    if (next < end) {
45        return (uint32_t*)next;
46    } else {
47        return NULL;
48    }
49}
50