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