diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-06-07 20:50:25 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-06-07 20:50:25 +0000 |
commit | 87ecf9799ac2c6fe85c6ef6d4d4a9a7204cd8ef2 (patch) | |
tree | 6c4ab9daf74e18fe27cd854296c84808d0364b81 /sys/arch | |
parent | 0d8919e17ff3afde68bc0150db174180c39fb297 (diff) |
Implement delay(9).
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/powerpc64/powerpc64/cpu.c | 17 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/machdep.c | 8 |
2 files changed, 17 insertions, 8 deletions
diff --git a/sys/arch/powerpc64/powerpc64/cpu.c b/sys/arch/powerpc64/powerpc64/cpu.c index d8e5bc85228..e768f032323 100644 --- a/sys/arch/powerpc64/powerpc64/cpu.c +++ b/sys/arch/powerpc64/powerpc64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.4 2020/06/07 13:17:24 kettenis Exp $ */ +/* $OpenBSD: cpu.c,v 1.5 2020/06/07 20:50:24 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -28,6 +28,7 @@ #include <dev/ofw/fdt.h> char cpu_model[64]; +uint64_t tb_freq = 512000000; /* POWER8, POWER9 */ struct cpu_info cpu_info_primary; @@ -72,4 +73,18 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) } printf("\n"); + + /* Update timebase frequency to reflect reality. */ + tb_freq = OF_getpropint(faa->fa_node, "timebase-frequency", tb_freq); +} + +void +delay(u_int us) +{ + uint64_t tb; + + tb = mftb(); + tb += (us * tb_freq + 999999) / 1000000; + while (tb > mftb()) + continue; } diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c index 6a2b046666c..86cf067aaf7 100644 --- a/sys/arch/powerpc64/powerpc64/machdep.c +++ b/sys/arch/powerpc64/powerpc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.16 2020/06/07 17:19:04 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.17 2020/06/07 20:50:24 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -416,12 +416,6 @@ need_resched(struct cpu_info *ci) } void -delay(u_int us) -{ - printf("%s\n", __func__); -} - -void cpu_startup(void) { paddr_t pa, epa; |