anchor.diff:    attachment
     latch
     event
  -  (state :masked))
  +  (state :masked)
  +  (lock (place-spinlock-initializer)))
   
   (defun make-simple-irq (irq-number &optional latch)
     (declare (sys.c::closure-allocation :wired))
  
positive.code:   pending-eoi)
  
  (defun irq-deliver (interrupt-frame irq)
    (incf (irq-count irq))
    (let ((accept-count 0)
          (pending-count 0))
      (dolist (attachment (irq-attachments irq))
        (when (irq-attachment-pending-eoi attachment)
          (debug-print-line "Received IRQ " irq " masked by " attachment "?"))
        (let ((status (funcall (irq-attachment-handler attachment) interrupt-frame irq)))
          (case status
            (:rejected) ; Attachment was not expecting this interrupt.
            (:completed ; Attachment accepted the interrupt and has completed work.
             (incf accept-count))
            (:accepted ; Attachment accepted the interrupt, but has oustanding work and will issue a separate EOI.
             (incf accept-count)
             (incf pending-count)
             (setf (irq-attachment-pending-eoi attachment) t))
            (t
             (panic "Attachment " attachment " handler " (irq-attachment-handler attachment) " on IRQ " irq " returned invalid status " status)))))
      (when (zerop accept-count)
        (debug-print-line "No handler accepted IRQ " irq))
      (when (not (zerop pending-count))
        ;; Mask the IRQ until all EOIs are delivered.
        (platform-mask-irq (irq-platform-number irq)))))
  
  (defun irq-attach (irq handler device &key exclusive)
    (cond (exclusive
  
negative.code:          (event (make-event :name simple-irq))
           (fn (lambda (interrupt-frame irq)
                 (declare (ignore interrupt-frame))
                 (with-place-spinlock ((simple-irq-lock simple-irq))
                   (case (simple-irq-state simple-irq)
                     ((:masked :masked-eoi-pending)
                      :rejected)
                     (:unmasked
                      (setf (simple-irq-state simple-irq) :masked-eoi-pending)
                      (when (simple-irq-latch simple-irq)
                        (setf (event-state (simple-irq-latch simple-irq)) t))
                      (setf (event-state (simple-irq-event simple-irq)) t)
                      :accepted))))))
      (setf (simple-irq-event simple-irq) event
            (simple-irq-function simple-irq) fn
            (simple-irq-attachment simple-irq) (irq-attach irq fn simple-irq))
  