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