From 36f7b8535d10884b8dd31f0e959b765ada1feb3c Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 21 Sep 2016 09:45:14 +0000 Subject: MFC 305285: Add a pc_clock pcpu field and use it to implement cpu_est_clockrate. This will allow drivers that manage the clock frequency to communicate this with the reset of the kernel. Sponsored by: ABT Systems Ltd --- sys/arm64/arm64/machdep.c | 11 ++++++++++- sys/arm64/include/pcpu.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'sys/arm64') diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 23839ff..dd2186b 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -407,8 +407,17 @@ cpu_flush_dcache(void *ptr, size_t len) int cpu_est_clockrate(int cpu_id, uint64_t *rate) { + struct pcpu *pc; - panic("ARM64TODO: cpu_est_clockrate"); + pc = pcpu_find(cpu_id); + if (pc == NULL || rate == NULL) + return (EINVAL); + + if (pc->pc_clock == 0) + return (EOPNOTSUPP); + + *rate = pc->pc_clock; + return (0); } void diff --git a/sys/arm64/include/pcpu.h b/sys/arm64/include/pcpu.h index 21b58db..53f4e7b 100644 --- a/sys/arm64/include/pcpu.h +++ b/sys/arm64/include/pcpu.h @@ -38,7 +38,8 @@ #define PCPU_MD_FIELDS \ u_int pc_acpi_id; /* ACPI CPU id */ \ u_int pc_midr; /* stored MIDR value */ \ - char __pad[121] + uint64_t pc_clock; \ + char __pad[113] #ifdef _KERNEL -- cgit v1.1