kernel/proc/interrupt.c
/*
 * Creates and adds an interrupt handler notification object for the
 * specified IRQ. Interrupt handler returns the event handle that will
 * be raised when an interrupt occurs.
 */
Creates and adds an interrupt handler notification object for the
specified IRQ. Interrupt handler returns the event handle that will
be raised when an interrupt occurs.
Creates and adds an interrupt handler notification object for the specified IRQ . Interrupt handler returns the event handle that will be raised when an interrupt occurs .
int CreateInterrupt(int irq, void (*callback)(int irq, struct InterruptAPI *api)) {
  struct Process *current;
  struct Filp *filp;
  struct SuperBlock *sb;
  struct VNode *vnode;
  int fd;
  int error;
  current = GetCurrentProcess();
  if (irq < 0) {
    return -EINVAL;
  }
  sb = AllocSuperBlock();
  if (sb == NULL) {
    error = -ENOMEM;
    goto exit;
  }
  vnode = VNodeNew(sb, -1);
  if (vnode == NULL) {
    error = -ENOMEM;
    goto exit;
  }
  fd = AllocHandle();
  if (fd < 0) {
    error = -ENOMEM;
    goto exit;
  }
  filp = GetFilp(fd);
  vnode->flags = V_VALID;
  vnode->reference_cnt = 1;
  vnode->mode = 0777 | _IFIRQ;    
  vnode->isr_irq = irq;
  vnode->isr_callback = callback;
  vnode->isr_process = current;
  filp->vnode = vnode;
  DisableInterrupts();
  LIST_ADD_TAIL(&isr_handler_list[irq], vnode,
                isr_handler_entry);
    UnmaskInterrupt(irq);
  irq_handler_cnt[irq]++;
  EnableInterrupts();  
  return fd;
exit:
  FreeHandle(fd);
  VNodeFree(vnode);
  FreeSuperBlock(sb);  
  return error;
}
int CreateInterrupt ( int irq , void ( * callback ) ( int irq , struct InterruptAPI * api ) ) { struct Process * current ; struct Filp * filp ; struct SuperBlock * sb ; struct VNode * vnode ; int fd ; int error ; current = GetCurrentProcess ( ) ; if ( irq < 0 ) { return - EINVAL ; } sb = AllocSuperBlock ( ) ; if ( sb == NULL ) { error = - ENOMEM ; goto exit ; } vnode = VNodeNew ( sb , -1 ) ; if ( vnode == NULL ) { error = - ENOMEM ; goto exit ; } fd = AllocHandle ( ) ; if ( fd < 0 ) { error = - ENOMEM ; goto exit ; } filp = GetFilp ( fd ) ; vnode -> flags = V_VALID ; vnode -> reference_cnt = 1 ; vnode -> mode = 0777 | _IFIRQ ; vnode -> isr_irq = irq ; vnode -> isr_callback = callback ; vnode -> isr_process = current ; filp -> vnode = vnode ; DisableInterrupts ( ) ; LIST_ADD_TAIL ( & isr_handler_list [ irq ] , vnode , isr_handler_entry ) ; UnmaskInterrupt ( irq ) ; irq_handler_cnt [ irq ] ++ ; EnableInterrupts ( ) ; return fd ; exit : FreeHandle ( fd ) ; VNodeFree ( vnode ) ; FreeSuperBlock ( sb ) ; return error ; }
Creates and adds an interrupt handler notification object for the
 specified IRQ.
Creates and adds an interrupt handler notification object for the specified IRQ .
/*
  if (!(current->flags & PROCF_ALLOW_IO)) {
    Info ("irq EPERM");
    return -EPERM;
  }
*/ // Server vnode set to -1.
 // FIXME:  read/write only user  (not used?)
 // Convert to list empty test
 //  if (irq_handler_cnt[irq] == 0) {
 //  }
