anchor.diff:    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)))))
  +  (with-place-spinlock ((irq-lock 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
  
positive.code:                     (irq-attachment-exclusive-p (first (irq-attachments irq))))
             (debug-print-line "Cannot attach to IRQ " irq " - in exclusive use")
             (return-from irq-attach nil))))
    (let ((attachment (make-irq-attachment :irq irq
                                           :device device
                                           :handler handler
                                           :exclusive-p exclusive)))
      (push-wired attachment (irq-attachments irq))
      ;; Unmask the IRQ if this is the first attachment.
      (when (endp (rest (irq-attachments irq)))
        (platform-unmask-irq (irq-platform-number irq)))
      attachment))
  
  (defun irq-eoi (attachment)
    (when (not (irq-attachment-pending-eoi attachment))
      (debug-print-line "Multiple EOI calls for attachment " attachment))
    (setf (irq-attachment-pending-eoi attachment) nil)
    ;; Unmask the IRQ if all attachments have EOI'd.
    (let ((irq (irq-attachment-irq attachment)))
      (when (dolist (a (irq-attachments irq) t)
              (when (irq-attachment-pending-eoi a)
                (return nil)))
        (platform-unmask-irq (irq-platform-number irq))))
    (values))
  
  ;;; Simple IRQ handler.
  
negative.code:   attachment
    latch
    event
    (state :masked)
    (lock (place-spinlock-initializer)))
  
  (defun make-simple-irq (irq-number &optional latch)
    (declare (sys.c::closure-allocation :wired))
  