Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/xen/xen_intr.c
Show First 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | xen_intr_alloc_isrc(enum evtchn_type type) | ||||
struct xenisrc *isrc; | struct xenisrc *isrc; | ||||
unsigned int vector; | unsigned int vector; | ||||
KASSERT(mtx_owned(&xen_intr_isrc_lock), ("Evtchn alloc lock not held")); | KASSERT(mtx_owned(&xen_intr_isrc_lock), ("Evtchn alloc lock not held")); | ||||
if (xen_intr_auto_vector_count > NR_EVENT_CHANNELS) { | if (xen_intr_auto_vector_count > NR_EVENT_CHANNELS) { | ||||
if (!warned) { | if (!warned) { | ||||
warned = 1; | warned = 1; | ||||
printf("xen_intr_alloc: Event channels exhausted.\n"); | printf("%s: Event channels exhausted.\n", __func__); | ||||
} | } | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
vector = first_evtchn_irq + xen_intr_auto_vector_count; | vector = first_evtchn_irq + xen_intr_auto_vector_count; | ||||
xen_intr_auto_vector_count++; | xen_intr_auto_vector_count++; | ||||
KASSERT((intr_lookup_source(vector) == NULL), | KASSERT((intr_lookup_source(vector) == NULL), | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, | ||||
driver_intr_t handler, void *arg, enum intr_type flags, | driver_intr_t handler, void *arg, enum intr_type flags, | ||||
xen_intr_handle_t *port_handlep) | xen_intr_handle_t *port_handlep) | ||||
{ | { | ||||
struct xenisrc *isrc; | struct xenisrc *isrc; | ||||
int error; | int error; | ||||
*isrcp = NULL; | *isrcp = NULL; | ||||
if (port_handlep == NULL) { | if (port_handlep == NULL) { | ||||
printf("%s: xen_intr_bind_isrc: Bad event handle\n", | printf("%s: %s: Bad event handle\n", intr_owner, __func__); | ||||
intr_owner); | |||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
mtx_lock(&xen_intr_isrc_lock); | mtx_lock(&xen_intr_isrc_lock); | ||||
isrc = xen_intr_find_unused_isrc(type); | isrc = xen_intr_find_unused_isrc(type); | ||||
if (isrc == NULL) { | if (isrc == NULL) { | ||||
isrc = xen_intr_alloc_isrc(type); | isrc = xen_intr_alloc_isrc(type); | ||||
if (isrc == NULL) { | if (isrc == NULL) { | ||||
▲ Show 20 Lines • Show All 793 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
xen_intr_unbind(xen_intr_handle_t *port_handlep) | xen_intr_unbind(xen_intr_handle_t *port_handlep) | ||||
{ | { | ||||
struct xenisrc *isrc; | struct xenisrc *isrc; | ||||
KASSERT(port_handlep != NULL, | KASSERT(port_handlep != NULL, | ||||
("NULL xen_intr_handle_t passed to xen_intr_unbind")); | ("NULL xen_intr_handle_t passed to %s", __func__)); | ||||
isrc = xen_intr_isrc_from_handle(*port_handlep); | isrc = xen_intr_isrc_from_handle(*port_handlep); | ||||
*port_handlep = NULL; | *port_handlep = NULL; | ||||
if (isrc == NULL) | if (isrc == NULL) | ||||
return; | return; | ||||
mtx_lock(&xen_intr_isrc_lock); | mtx_lock(&xen_intr_isrc_lock); | ||||
if (refcount_release(&isrc->xi_refcount) == 0) { | if (refcount_release(&isrc->xi_refcount) == 0) { | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | xen_intr_add_handler(const char *name, driver_filter_t filter, | ||||
int error; | int error; | ||||
isrc = xen_intr_isrc_from_handle(handle); | isrc = xen_intr_isrc_from_handle(handle); | ||||
if (isrc == NULL || isrc->xi_cookie != NULL) | if (isrc == NULL || isrc->xi_cookie != NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
error = intr_add_handler(name, isrc->xi_vector,filter, handler, arg, | error = intr_add_handler(name, isrc->xi_vector,filter, handler, arg, | ||||
flags|INTR_EXCL, &isrc->xi_cookie, 0); | flags|INTR_EXCL, &isrc->xi_cookie, 0); | ||||
if (error != 0) { | if (error != 0) | ||||
printf( | printf("%s: %s: add handler failed: %d\n", name, __func__, | ||||
"%s: xen_intr_add_handler: intr_add_handler failed: %d\n", | error); | ||||
mhorne: FreeBSD's `style(9)` prefers `error != 0`. Dropping the braces is fine. | |||||
name, error); | |||||
} | |||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
xen_intr_get_evtchn_from_port(evtchn_port_t port, xen_intr_handle_t *handlep) | xen_intr_get_evtchn_from_port(evtchn_port_t port, xen_intr_handle_t *handlep) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |
FreeBSD's style(9) prefers error != 0. Dropping the braces is fine.