From f90eedca1997d2d936d5eda120168facc50b725b Mon Sep 17 00:00:00 2001 From: dlg Date: Tue, 23 Jun 2020 01:40:03 +0000 Subject: 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. --- sys/kern/kern_intrmap.c | 16 +++++++++++++++- sys/sys/intrmap.h | 3 ++- 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 @@ -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_ */ -- cgit v1.2.3-59-g8ed1b