Changeset View
Changeset View
Standalone View
Standalone View
head/sys/contrib/ncsw/user/env/xx.c
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
static struct mtx XX_MallocTrackLock; | static struct mtx XX_MallocTrackLock; | ||||
MTX_SYSINIT(XX_MallocSmartLockInit, &XX_MallocSmartLock, | MTX_SYSINIT(XX_MallocSmartLockInit, &XX_MallocSmartLock, | ||||
"NetCommSW MallocSmart Lock", MTX_DEF); | "NetCommSW MallocSmart Lock", MTX_DEF); | ||||
MTX_SYSINIT(XX_MallocTrackLockInit, &XX_MallocTrackLock, | MTX_SYSINIT(XX_MallocTrackLockInit, &XX_MallocTrackLock, | ||||
"NetCommSW MallocTrack Lock", MTX_DEF); | "NetCommSW MallocTrack Lock", MTX_DEF); | ||||
/* Interrupt info */ | /* Interrupt info */ | ||||
#define XX_INTR_FLAG_PREALLOCATED (1 << 0) | #define XX_INTR_FLAG_PREALLOCATED (1 << 0) | ||||
#define XX_INTR_FLAG_BOUND (1 << 1) | #define XX_INTR_FLAG_FMAN_FIX (1 << 1) | ||||
#define XX_INTR_FLAG_FMAN_FIX (1 << 2) | |||||
struct XX_IntrInfo { | struct XX_IntrInfo { | ||||
driver_intr_t *handler; | driver_intr_t *handler; | ||||
void *arg; | void *arg; | ||||
int cpu; | int cpu; | ||||
int flags; | int flags; | ||||
void *cookie; | void *cookie; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
XX_Dispatch(void *arg) | XX_Dispatch(void *arg) | ||||
{ | { | ||||
struct XX_IntrInfo *info; | struct XX_IntrInfo *info; | ||||
info = arg; | info = arg; | ||||
/* Bind this thread to proper CPU when SMP has been already started. */ | |||||
if ((info->flags & XX_INTR_FLAG_BOUND) == 0 && smp_started && | |||||
info->cpu >= 0) { | |||||
thread_lock(curthread); | |||||
sched_bind(curthread, info->cpu); | |||||
thread_unlock(curthread); | |||||
info->flags |= XX_INTR_FLAG_BOUND; | |||||
} | |||||
if (info->handler == NULL) { | if (info->handler == NULL) { | ||||
printf("%s(): IRQ handler is NULL!\n", __func__); | printf("%s(): IRQ handler is NULL!\n", __func__); | ||||
return; | return; | ||||
} | } | ||||
info->handler(info->arg); | info->handler(info->arg); | ||||
} | } | ||||
t_Error | t_Error | ||||
XX_PreallocAndBindIntr(uintptr_t irq, unsigned int cpu) | XX_PreallocAndBindIntr(device_t dev, uintptr_t irq, unsigned int cpu) | ||||
{ | { | ||||
struct resource *r; | struct resource *r; | ||||
unsigned int inum; | unsigned int inum; | ||||
t_Error error; | t_Error error; | ||||
r = (struct resource *)irq; | r = (struct resource *)irq; | ||||
inum = rman_get_start(r); | inum = rman_get_start(r); | ||||
error = XX_SetIntr(irq, XX_Dispatch, &XX_IntrInfo[inum]); | error = XX_SetIntr(irq, XX_Dispatch, &XX_IntrInfo[inum]); | ||||
if (error != 0) | |||||
return (error); | |||||
error = bus_bind_intr(dev, r, cpu); | |||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
XX_IntrInfo[inum].flags = XX_INTR_FLAG_PREALLOCATED; | XX_IntrInfo[inum].flags = XX_INTR_FLAG_PREALLOCATED; | ||||
XX_IntrInfo[inum].cpu = cpu; | XX_IntrInfo[inum].cpu = cpu; | ||||
return (E_OK); | return (E_OK); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 446 Lines • Show Last 20 Lines |