summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2020-06-23 01:40:03 +0000
committerdlg <dlg@openbsd.org>2020-06-23 01:40:03 +0000
commitf90eedca1997d2d936d5eda120168facc50b725b (patch)
tree39c6a2b58249a2275590ebf02dc04f897f502188
parentImplement pci_intr_establish_cpu() for pyro(4) and vpci(4) based sparc64 (diff)
downloadwireguard-openbsd-f90eedca1997d2d936d5eda120168facc50b725b.tar.xz
wireguard-openbsd-f90eedca1997d2d936d5eda120168facc50b725b.zip
add intrmap_one, some temp code to help us write pci_intr_establish_cpu.
it means we can do quick hacks to existing drivers to test interrupts on multiple cpus. emphasis on quick and hacks. ok jmatthew@, who will also ok the removal of it at the right time.
-rw-r--r--sys/kern/kern_intrmap.c16
-rw-r--r--sys/sys/intrmap.h3
2 files changed, 17 insertions, 2 deletions
diff --git a/sys/kern/kern_intrmap.c b/sys/kern/kern_intrmap.c
index 183531e20b1..4207456090c 100644
--- a/sys/kern/kern_intrmap.c
+++ b/sys/kern/kern_intrmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_intrmap.c,v 1.2 2020/06/17 03:01:26 dlg Exp $ */
+/* $OpenBSD: kern_intrmap.c,v 1.3 2020/06/23 01:40:03 dlg Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -345,3 +345,17 @@ intrmap_cpu(const struct intrmap *im, unsigned int ring)
" (intrmap %p)", icpu, ring, im);
return (ic->ic_cpumap[icpu]);
}
+
+struct cpu_info *
+intrmap_one(const struct device *dv)
+{
+ unsigned int unit = dv->dv_unit;
+ struct intrmap_cpus *ic;
+ struct cpu_info *ci;
+
+ ic = intrmap_cpus_get();
+ ci = ic->ic_cpumap[unit % ic->ic_count];
+ intrmap_cpus_put(ic);
+
+ return (ci);
+}
diff --git a/sys/sys/intrmap.h b/sys/sys/intrmap.h
index 7340121f0cc..f15711e2556 100644
--- a/sys/sys/intrmap.h
+++ b/sys/sys/intrmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intrmap.h,v 1.2 2020/06/17 03:01:26 dlg Exp $ */
+/* $OpenBSD: intrmap.h,v 1.3 2020/06/23 01:40:03 dlg Exp $ */
/*
* Copyright (c) 2020 David Gwynne <dlg@openbsd.org>
@@ -34,5 +34,6 @@ void intrmap_align(const struct device *,
unsigned int intrmap_count(const struct intrmap *);
struct cpu_info *intrmap_cpu(const struct intrmap *, unsigned int);
+struct cpu_info *intrmap_one(const struct device *);
#endif /* _SYS_INTRMAP_H_ */