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/* eXtended System Descriptor Table "XSDT" */ 16typedef struct acpi_xsdt { 17 acpi_header_t header; 18 /* access via inline functions */ 19// uint64_t entry[]; 20} acpi_xsdt_t; 21 22#pragma pack(pop) 23 24/* retrieve the number of entries in an xsdt table */ 25static inline int 26acpi_xsdt_entry_count(acpi_xsdt_t* t) 27{ 28 return (t->header.length - sizeof(*t)) / sizeof(uint64_t); 29} 30 31/* Retrieve the location of the first item in the list */ 32static inline uint64_t* 33acpi_xsdt_first(acpi_xsdt_t* hdr) 34{ 35 return (uint64_t*)(hdr + 1); 36} 37 38/* Retrieve the location of the next item in the list */ 39static inline uint64_t* 40acpi_xsdt_next(acpi_xsdt_t* hdr, uint64_t* cur) 41{ 42 char* next = (char*)(cur + 1); 43 char* end = (char*)hdr + hdr->header.length; 44 if (next < end) { 45 return (uint64_t*)next; 46 } else { 47 return NULL; 48 } 49} 50