124,6 → 124,10 |
} |
} |
|
/** Free top-half pseudocode. |
* |
* @param code Pointer to the top-half pseudocode. |
*/ |
static void code_free(irq_code_t *code) |
{ |
if (code) { |
132,6 → 136,12 |
} |
} |
|
/** Copy top-half pseudocode from userspace into the kernel. |
* |
* @param ucode Userspace address of the top-half pseudocode. |
* |
* @return Kernel address of the copied pseudocode. |
*/ |
static irq_code_t * code_from_uspace(irq_code_t *ucode) |
{ |
irq_code_t *code; |
150,8 → 160,9 |
return NULL; |
} |
ucmds = code->cmds; |
code->cmds = malloc(sizeof(code->cmds[0]) * (code->cmdcount), 0); |
rc = copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount)); |
code->cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0); |
rc = copy_from_uspace(code->cmds, ucmds, |
sizeof(code->cmds[0]) * code->cmdcount); |
if (rc != 0) { |
free(code->cmds); |
free(code); |
164,7 → 175,7 |
/** Unregister task from IRQ notification. |
* |
* @param box Answerbox associated with the notification. |
* @param inr IRQ numbe. |
* @param inr IRQ number. |
* @param devno Device number. |
*/ |
void ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno) |
203,7 → 214,8 |
* |
* @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success. |
*/ |
int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, unative_t method, irq_code_t *ucode) |
int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, |
unative_t method, irq_code_t *ucode) |
{ |
ipl_t ipl; |
irq_code_t *code; |
213,8 → 225,9 |
code = code_from_uspace(ucode); |
if (!code) |
return EBADMEM; |
} else |
} else { |
code = NULL; |
} |
|
ipl = interrupts_disable(); |
irq = irq_find_and_lock(inr, devno); |
247,10 → 260,12 |
return 0; |
} |
|
/** Add call to proper answerbox queue. |
/** Add a call to the proper answerbox queue. |
* |
* Assume irq->lock is locked. |
* |
* @param irq IRQ structure referencing the target answerbox. |
* @param call IRQ notification call. |
*/ |
static void send_call(irq_t *irq, call_t *call) |
{ |
261,8 → 276,12 |
waitq_wakeup(&irq->notif_cfg.answerbox->wq, WAKEUP_FIRST); |
} |
|
/** Send notification message |
/** Send notification message. |
* |
* @param irq IRQ structure. |
* @param a1 Driver-specific payload argument. |
* @param a2 Driver-specific payload argument. |
* @param a3 Driver-specific payload argument. |
*/ |
void ipc_irq_send_msg(irq_t *irq, unative_t a1, unative_t a2, unative_t a3) |
{ |
289,9 → 308,11 |
spinlock_unlock(&irq->lock); |
} |
|
/** Notify task that an irq had occurred. |
/** Notify a task that an IRQ had occurred. |
* |
* We expect interrupts to be disabled and the irq->lock already held. |
* |
* @param irq IRQ structure. |
*/ |
void ipc_irq_send_notif(irq_t *irq) |
{ |