mirror of
https://github.com/systemd/systemd.git
synced 2025-03-09 12:58:26 +03:00
Merge pull request #25321 from poettering/acpi-timing-fix
acp-fpdt: minor tweaks/fixes
This commit is contained in:
commit
718e5d3f60
@ -61,10 +61,11 @@ struct acpi_fpdt_boot {
|
||||
uint64_t exit_services_exit;
|
||||
} _packed;
|
||||
|
||||
int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
|
||||
int acpi_get_boot_usec(usec_t *ret_loader_start, usec_t *ret_loader_exit) {
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
struct acpi_table_header *tbl;
|
||||
size_t l = 0;
|
||||
size_t l;
|
||||
ssize_t ll;
|
||||
struct acpi_fpdt_header *rec;
|
||||
int r;
|
||||
uint64_t ptr = 0;
|
||||
@ -88,7 +89,7 @@ int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
|
||||
|
||||
/* find Firmware Basic Boot Performance Pointer Record */
|
||||
for (rec = (struct acpi_fpdt_header *)(buf + sizeof(struct acpi_table_header));
|
||||
(char *)rec < buf + l;
|
||||
(char *)rec + offsetof(struct acpi_fpdt_header, revision) <= buf + l;
|
||||
rec = (struct acpi_fpdt_header *)((char *)rec + rec->length)) {
|
||||
if (rec->length <= 0)
|
||||
break;
|
||||
@ -109,8 +110,10 @@ int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
l = pread(fd, &hbrec, sizeof(struct acpi_fpdt_boot_header), ptr);
|
||||
if (l != sizeof(struct acpi_fpdt_boot_header))
|
||||
ll = pread(fd, &hbrec, sizeof(struct acpi_fpdt_boot_header), ptr);
|
||||
if (ll < 0)
|
||||
return -errno;
|
||||
if ((size_t) ll != sizeof(struct acpi_fpdt_boot_header))
|
||||
return -EINVAL;
|
||||
|
||||
if (memcmp(hbrec.signature, "FBPT", 4) != 0)
|
||||
@ -119,8 +122,10 @@ int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
|
||||
if (hbrec.length < sizeof(struct acpi_fpdt_boot_header) + sizeof(struct acpi_fpdt_boot))
|
||||
return -EINVAL;
|
||||
|
||||
l = pread(fd, &brec, sizeof(struct acpi_fpdt_boot), ptr + sizeof(struct acpi_fpdt_boot_header));
|
||||
if (l != sizeof(struct acpi_fpdt_boot))
|
||||
ll = pread(fd, &brec, sizeof(struct acpi_fpdt_boot), ptr + sizeof(struct acpi_fpdt_boot_header));
|
||||
if (ll < 0)
|
||||
return -errno;
|
||||
if ((size_t) ll != sizeof(struct acpi_fpdt_boot))
|
||||
return -EINVAL;
|
||||
|
||||
if (brec.length != sizeof(struct acpi_fpdt_boot))
|
||||
@ -138,10 +143,10 @@ int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
|
||||
if (brec.exit_services_exit > NSEC_PER_HOUR)
|
||||
return -EINVAL;
|
||||
|
||||
if (loader_start)
|
||||
*loader_start = brec.startup_start / 1000;
|
||||
if (loader_exit)
|
||||
*loader_exit = brec.exit_services_exit / 1000;
|
||||
if (ret_loader_start)
|
||||
*ret_loader_start = brec.startup_start / 1000;
|
||||
if (ret_loader_exit)
|
||||
*ret_loader_exit = brec.exit_services_exit / 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,4 +3,4 @@
|
||||
|
||||
#include <time-util.h>
|
||||
|
||||
int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit);
|
||||
int acpi_get_boot_usec(usec_t *ret_loader_start, usec_t *ret_loader_exit);
|
||||
|
Loading…
x
Reference in New Issue
Block a user