acpi-fpdt.c revision c51d84dc09476d9c06b8aac726220bf3c7d62e8d
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync This file is part of systemd.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync Copyright 2013 Kay Sievers
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync systemd is free software; you can redistribute it and/or modify it
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync under the terms of the GNU Lesser General Public License as published by
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync the Free Software Foundation; either version 2.1 of the License, or
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync (at your option) any later version.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync systemd is distributed in the hope that it will be useful, but
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync WITHOUT ANY WARRANTY; without even the implied warranty of
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync Lesser General Public License for more details.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync You should have received a copy of the GNU Lesser General Public License
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync along with systemd; If not, see <http://www.gnu.org/licenses/>.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync r = read_full_file("/sys/firmware/acpi/tables/FPDT", &buf, &l);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (l < sizeof(struct acpi_table_header) + sizeof(struct acpi_fpdt_header))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /* find Firmware Basic Boot Performance Pointer Record */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync for (rec = (struct acpi_fpdt_header *)(buf + sizeof(struct acpi_table_header));
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync rec = (struct acpi_fpdt_header *)((char *)rec + rec->length)) {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (rec->length != sizeof(struct acpi_fpdt_header))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /* read Firmware Basic Boot Performance Data Record */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync l = pread(fd, &hbrec, sizeof(struct acpi_fpdt_boot_header), ptr);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (l != sizeof(struct acpi_fpdt_boot_header))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (hbrec.length < sizeof(struct acpi_fpdt_boot_header) + sizeof(struct acpi_fpdt_boot))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync l = pread(fd, &brec, sizeof(struct acpi_fpdt_boot), ptr + sizeof(struct acpi_fpdt_boot_header));
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (l != sizeof(struct acpi_fpdt_boot))