Deleted Added
full compact
kern_intr.c (195249) kern_intr.c (198134)
1/*-
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/kern/kern_intr.c 195249 2009-07-01 17:20:07Z jhb $");
28__FBSDID("$FreeBSD: head/sys/kern/kern_intr.c 198134 2009-10-15 14:54:35Z jhb $");
29
30#include "opt_ddb.h"
31
32#include <sys/param.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/cpuset.h>
36#include <sys/rtprio.h>

--- 482 unchanged lines hidden (view full) ---

519 if (ie == NULL || name == NULL || (handler == NULL && filter == NULL))
520 return (EINVAL);
521
522 /* Allocate and populate an interrupt handler structure. */
523 ih = malloc(sizeof(struct intr_handler), M_ITHREAD, M_WAITOK | M_ZERO);
524 ih->ih_filter = filter;
525 ih->ih_handler = handler;
526 ih->ih_argument = arg;
29
30#include "opt_ddb.h"
31
32#include <sys/param.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/cpuset.h>
36#include <sys/rtprio.h>

--- 482 unchanged lines hidden (view full) ---

519 if (ie == NULL || name == NULL || (handler == NULL && filter == NULL))
520 return (EINVAL);
521
522 /* Allocate and populate an interrupt handler structure. */
523 ih = malloc(sizeof(struct intr_handler), M_ITHREAD, M_WAITOK | M_ZERO);
524 ih->ih_filter = filter;
525 ih->ih_handler = handler;
526 ih->ih_argument = arg;
527 ih->ih_name = name;
527 strlcpy(ih->ih_name, name, sizeof(ih->ih_name));
528 ih->ih_event = ie;
529 ih->ih_pri = pri;
530 if (flags & INTR_EXCL)
531 ih->ih_flags = IH_EXCLUSIVE;
532 if (flags & INTR_MPSAFE)
533 ih->ih_flags |= IH_MPSAFE;
534 if (flags & INTR_ENTROPY)
535 ih->ih_flags |= IH_ENTROPY;

--- 56 unchanged lines hidden (view full) ---

592 if (ie == NULL || name == NULL || (handler == NULL && filter == NULL))
593 return (EINVAL);
594
595 /* Allocate and populate an interrupt handler structure. */
596 ih = malloc(sizeof(struct intr_handler), M_ITHREAD, M_WAITOK | M_ZERO);
597 ih->ih_filter = filter;
598 ih->ih_handler = handler;
599 ih->ih_argument = arg;
528 ih->ih_event = ie;
529 ih->ih_pri = pri;
530 if (flags & INTR_EXCL)
531 ih->ih_flags = IH_EXCLUSIVE;
532 if (flags & INTR_MPSAFE)
533 ih->ih_flags |= IH_MPSAFE;
534 if (flags & INTR_ENTROPY)
535 ih->ih_flags |= IH_ENTROPY;

--- 56 unchanged lines hidden (view full) ---

592 if (ie == NULL || name == NULL || (handler == NULL && filter == NULL))
593 return (EINVAL);
594
595 /* Allocate and populate an interrupt handler structure. */
596 ih = malloc(sizeof(struct intr_handler), M_ITHREAD, M_WAITOK | M_ZERO);
597 ih->ih_filter = filter;
598 ih->ih_handler = handler;
599 ih->ih_argument = arg;
600 ih->ih_name = name;
600 strlcpy(ih->ih_name, name, sizeof(ih->ih_name));
601 ih->ih_event = ie;
602 ih->ih_pri = pri;
603 if (flags & INTR_EXCL)
604 ih->ih_flags = IH_EXCLUSIVE;
605 if (flags & INTR_MPSAFE)
606 ih->ih_flags |= IH_MPSAFE;
607 if (flags & INTR_ENTROPY)
608 ih->ih_flags |= IH_ENTROPY;

--- 51 unchanged lines hidden (view full) ---

660
661 if (cookiep != NULL)
662 *cookiep = ih;
663 return (0);
664}
665#endif
666
667/*
601 ih->ih_event = ie;
602 ih->ih_pri = pri;
603 if (flags & INTR_EXCL)
604 ih->ih_flags = IH_EXCLUSIVE;
605 if (flags & INTR_MPSAFE)
606 ih->ih_flags |= IH_MPSAFE;
607 if (flags & INTR_ENTROPY)
608 ih->ih_flags |= IH_ENTROPY;

--- 51 unchanged lines hidden (view full) ---

660
661 if (cookiep != NULL)
662 *cookiep = ih;
663 return (0);
664}
665#endif
666
667/*
668 * Append a description preceded by a ':' to the name of the specified
669 * interrupt handler.
670 */
671int
672intr_event_describe_handler(struct intr_event *ie, void *cookie,
673 const char *descr)
674{
675 struct intr_handler *ih;
676 size_t space;
677 char *start;
678
679 mtx_lock(&ie->ie_lock);
680#ifdef INVARIANTS
681 TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
682 if (ih == cookie)
683 break;
684 }
685 if (ih == NULL) {
686 mtx_unlock(&ie->ie_lock);
687 panic("handler %p not find in interrupt event %p", cookie, ie);
688 }
689#endif
690 ih = cookie;
691
692 /*
693 * Look for an existing description by checking for an
694 * existing ":". This assumes device names do not include
695 * colons. If one is found, prepare to insert the new
696 * description at that point. If one is not found, find the
697 * end of the name to use as the insertion point.
698 */
699 start = index(ih->ih_name, ':');
700 if (start == NULL)
701 start = index(ih->ih_name, 0);
702
703 /*
704 * See if there is enough remaining room in the string for the
705 * description + ":". The "- 1" leaves room for the trailing
706 * '\0'. The "+ 1" accounts for the colon.
707 */
708 space = sizeof(ih->ih_name) - (start - ih->ih_name) - 1;
709 if (strlen(descr) + 1 > space) {
710 mtx_unlock(&ie->ie_lock);
711 return (ENOSPC);
712 }
713
714 /* Append a colon followed by the description. */
715 *start = ':';
716 strcpy(start + 1, descr);
717 intr_event_update(ie);
718 mtx_unlock(&ie->ie_lock);
719 return (0);
720}
721
722/*
668 * Return the ie_source field from the intr_event an intr_handler is
669 * associated with.
670 */
671void *
672intr_handler_source(void *cookie)
673{
674 struct intr_handler *ih;
675 struct intr_event *ie;

--- 1107 unchanged lines hidden ---
723 * Return the ie_source field from the intr_event an intr_handler is
724 * associated with.
725 */
726void *
727intr_handler_source(void *cookie)
728{
729 struct intr_handler *ih;
730 struct intr_event *ie;

--- 1107 unchanged lines hidden ---