Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/pci refactor: change function names and move them.
details: https://anonhg.NetBSD.org/src/rev/704fa3b5245a
branches: trunk
changeset: 338225:704fa3b5245a
user: knakahara <knakahara%NetBSD.org@localhost>
date: Fri May 15 08:29:33 2015 +0000
description:
refactor: change function names and move them.
diffstat:
sys/arch/x86/pci/pci_intr_machdep.c | 32 ++--
sys/arch/x86/pci/pci_msi_machdep.c | 276 ++++++++++++++++++-----------------
2 files changed, 156 insertions(+), 152 deletions(-)
diffs (truncated from 438 to 300 lines):
diff -r aa5de6e0c47f -r 704fa3b5245a sys/arch/x86/pci/pci_intr_machdep.c
--- a/sys/arch/x86/pci/pci_intr_machdep.c Fri May 15 08:26:44 2015 +0000
+++ b/sys/arch/x86/pci/pci_intr_machdep.c Fri May 15 08:29:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_intr_machdep.c,v 1.31 2015/05/15 08:26:44 knakahara Exp $ */
+/* $NetBSD: pci_intr_machdep.c,v 1.32 2015/05/15 08:29:33 knakahara Exp $ */
/*-
* Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.31 2015/05/15 08:26:44 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.32 2015/05/15 08:29:33 knakahara Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -350,6 +350,20 @@
}
#if NIOAPIC > 0
+static void
+x86_pci_intx_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih)
+{
+ char intrstr_buf[INTRIDBUF];
+ const char *intrstr;
+
+ intrstr = pci_intr_string(NULL, *pih, intrstr_buf, sizeof(intrstr_buf));
+ mutex_enter(&cpu_lock);
+ intr_free_io_intrsource(intrstr);
+ mutex_exit(&cpu_lock);
+
+ kmem_free(pih, sizeof(*pih));
+}
+
int
pci_intx_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **pih)
{
@@ -390,20 +404,6 @@
return error;
}
-static void
-x86_pci_intx_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih)
-{
- char intrstr_buf[INTRIDBUF];
- const char *intrstr;
-
- intrstr = pci_intr_string(NULL, *pih, intrstr_buf, sizeof(intrstr_buf));
- mutex_enter(&cpu_lock);
- intr_free_io_intrsource(intrstr);
- mutex_exit(&cpu_lock);
-
- kmem_free(pih, sizeof(*pih));
-}
-
void
pci_intr_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih, int count)
{
diff -r aa5de6e0c47f -r 704fa3b5245a sys/arch/x86/pci/pci_msi_machdep.c
--- a/sys/arch/x86/pci/pci_msi_machdep.c Fri May 15 08:26:44 2015 +0000
+++ b/sys/arch/x86/pci/pci_msi_machdep.c Fri May 15 08:29:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_msi_machdep.c,v 1.3 2015/05/15 08:26:44 knakahara Exp $ */
+/* $NetBSD: pci_msi_machdep.c,v 1.4 2015/05/15 08:29:33 knakahara Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.3 2015/05/15 08:26:44 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.4 2015/05/15 08:29:33 knakahara Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -172,7 +172,7 @@
}
static int
-pci_msi_alloc_md_common(pci_intr_handle_t **ihps, int *count,
+pci_msi_alloc_common(pci_intr_handle_t **ihps, int *count,
const struct pci_attach_args *pa, bool exact)
{
struct pic *msi_pic;
@@ -226,35 +226,6 @@
return 0;
}
-static int
-pci_msi_alloc_md(pci_intr_handle_t **ihps, int *count,
- const struct pci_attach_args *pa)
-{
-
- return pci_msi_alloc_md_common(ihps, count, pa, false);
-}
-
-static int
-pci_msi_alloc_exact_md(pci_intr_handle_t **ihps, int count,
- const struct pci_attach_args *pa)
-{
-
- return pci_msi_alloc_md_common(ihps, &count, pa, true);
-}
-
-static void
-pci_msi_release_md(pci_intr_handle_t *pihs, int count)
-{
- struct pic *pic;
-
- pic = msipic_find_msi_pic(MSI_INT_DEV(pihs[0]));
- if (pic == NULL)
- return;
-
- pci_msi_free_vectors(pic, pihs, count);
- msipic_destruct_msi_pic(pic);
-}
-
static void *
pci_msi_common_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
int level, int (*func)(void *), void *arg, struct pic *pic)
@@ -280,7 +251,7 @@
}
static int
-pci_msix_alloc_md_common(pci_intr_handle_t **ihps, u_int *table_indexes,
+pci_msix_alloc_common(pci_intr_handle_t **ihps, u_int *table_indexes,
int *count, const struct pci_attach_args *pa, bool exact)
{
struct pic *msix_pic;
@@ -334,31 +305,60 @@
}
static int
-pci_msix_alloc_md(pci_intr_handle_t **ihps, int *count,
+x86_pci_msi_alloc(pci_intr_handle_t **ihps, int *count,
const struct pci_attach_args *pa)
{
- return pci_msix_alloc_md_common(ihps, NULL, count, pa, false);
+ return pci_msi_alloc_common(ihps, count, pa, false);
}
static int
-pci_msix_alloc_exact_md(pci_intr_handle_t **ihps, int count,
+x86_pci_msi_alloc_exact(pci_intr_handle_t **ihps, int count,
const struct pci_attach_args *pa)
{
- return pci_msix_alloc_md_common(ihps, NULL, &count, pa, true);
+ return pci_msi_alloc_common(ihps, &count, pa, true);
+}
+
+static void
+x86_pci_msi_release_internal(pci_intr_handle_t *pihs, int count)
+{
+ struct pic *pic;
+
+ pic = msipic_find_msi_pic(MSI_INT_DEV(pihs[0]));
+ if (pic == NULL)
+ return;
+
+ pci_msi_free_vectors(pic, pihs, count);
+ msipic_destruct_msi_pic(pic);
}
static int
-pci_msix_alloc_map_md(pci_intr_handle_t **ihps, u_int *table_indexes, int count,
+x86_pci_msix_alloc(pci_intr_handle_t **ihps, int *count,
+ const struct pci_attach_args *pa)
+{
+
+ return pci_msix_alloc_common(ihps, NULL, count, pa, false);
+}
+
+static int
+x86_pci_msix_alloc_exact(pci_intr_handle_t **ihps, int count,
const struct pci_attach_args *pa)
{
- return pci_msix_alloc_md_common(ihps, table_indexes, &count, pa, true);
+ return pci_msix_alloc_common(ihps, NULL, &count, pa, true);
+}
+
+static int
+x86_pci_msix_alloc_map(pci_intr_handle_t **ihps, u_int *table_indexes,
+ int count, const struct pci_attach_args *pa)
+{
+
+ return pci_msix_alloc_common(ihps, table_indexes, &count, pa, true);
}
static void
-pci_msix_release_md(pci_intr_handle_t *pihs, int count)
+x86_pci_msix_release_internal(pci_intr_handle_t *pihs, int count)
{
struct pic *pic;
@@ -372,6 +372,101 @@
/*****************************************************************************/
/*
+ * extern for pci_intr_machdep.c
+ */
+
+/*
+ * Release MSI handles.
+ */
+void
+x86_pci_msi_release(pci_chipset_tag_t pc, pci_intr_handle_t *pihs, int count)
+{
+
+ if (count < 1)
+ return;
+
+ return x86_pci_msi_release_internal(pihs, count);
+}
+
+/*
+ * Establish a MSI handle.
+ * If multiple MSI handle is requied to establish, device driver must call
+ * this function for each handle.
+ */
+void *
+x86_pci_msi_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
+ int level, int (*func)(void *), void *arg)
+{
+ struct pic *pic;
+
+ pic = msipic_find_msi_pic(MSI_INT_DEV(ih));
+ if (pic == NULL) {
+ DPRINTF(("pci_intr_handler has no msi_pic\n"));
+ return NULL;
+ }
+
+ return pci_msi_common_establish(pc, ih, level, func, arg, pic);
+}
+
+/*
+ * Disestablish a MSI handle.
+ * If multiple MSI handle is requied to disestablish, device driver must call
+ * this function for each handle.
+ */
+void
+x86_pci_msi_disestablish(pci_chipset_tag_t pc, void *cookie)
+{
+
+ pci_msi_common_disestablish(pc, cookie);
+}
+
+/*
+ * Release MSI-X handles.
+ */
+void
+x86_pci_msix_release(pci_chipset_tag_t pc, pci_intr_handle_t *pihs, int count)
+{
+
+ if (count < 1)
+ return;
+
+ return x86_pci_msix_release_internal(pihs, count);
+}
+
+/*
+ * Establish a MSI-X handle.
+ * If multiple MSI-X handle is requied to establish, device driver must call
+ * this function for each handle.
+ */
+void *
+x86_pci_msix_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
+ int level, int (*func)(void *), void *arg)
+{
+ struct pic *pic;
+
+ pic = msipic_find_msi_pic(MSI_INT_DEV(ih));
+ if (pic == NULL) {
+ DPRINTF(("pci_intr_handler has no msi_pic\n"));
+ return NULL;
+ }
+
+ return pci_msi_common_establish(pc, ih, level, func, arg, pic);
+}
+
+/*
+ * Disestablish a MSI-X handle.
+ * If multiple MSI-X handle is requied to disestablish, device driver must call
+ * this function for each handle.
+ */
+void
+x86_pci_msix_disestablish(pci_chipset_tag_t pc, void *cookie)
+{
+
+ pci_msi_common_disestablish(pc, cookie);
+}
+
+/*****************************************************************************/
+/*
* these APIs may be MI code.
Home |
Main Index |
Thread Index |
Old Index