Index: trunk/src/os2ahci/ahci.c
===================================================================
--- trunk/src/os2ahci/ahci.c	(revision 144)
+++ trunk/src/os2ahci/ahci.c	(revision 145)
@@ -1305,15 +1305,53 @@
      * writes), we may be stacking interrupts on top of each other. If we
      * detect this, we'll pass this on to the engine context hook.
+     *
+     * Rousseau:
+     * The "Physycal Device Driver Reference" states that it's a good idea
+     * to disable interrupts before doing EOI so that it can proceed for this
+     * level without being interrupted, which could cause stacked interrupts,
+     * possibly exhausting the interrupt stack.
+     * (?:\IBMDDK\DOCS\PDDREF.INF->Device Helper (DevHlp) Services)->EOI)
+     *
+     * This is what seemed to happen when running in VirtualBox.
+     * Since in VBox the AHCI-controller is a software implementation, it is
+     * just not fast enough to handle a large bulk of requests, like when JFS
+     * flushes it's caches.
+     *
+     * Cross referencing with DANIS506 shows she does the same in the
+     * state-machine code in s506sm.c around line 244; disable interrupts
+     * before doing the EOI.
+     *
+     * Comments on the disable() function state that SMP systems should use
+     * a spinlock, but putting the EOI before spin_unlock() did not solve the
+     * VBox ussue. This is probably because spin_unlock() enables interrupts,
+     * which implies we need to return from this handler with interrupts
+     * disabled.
      */
     if ((u16) (u32) (void _far *) &irq_stat < 0xf000) {
       ddprintf("IRQ stack running low; arming engine context hook\n");
+      /* Rousseau:
+       * A context hook cannot be re-armed before it has completed.
+       * (?:\IBMDDK\DOCS\PDDREF.INF->Device Helper (DevHlp) Services)->ArmCtxHook)
+       * Also, it is executed at task-time, thus in the context of some
+       * application thread. Stacked interrupts with a stack below the
+       * threshold specified above, (0xf000), will repeatly try to arm the
+       * context hook, but since we are in an interrupted interrupt handler,
+       * it's highly unlikely the hook has completed.
+       * So, possibly only the first arming is succesful and subsequent armings
+       * will fail because no task-time thread has run between the stacked
+       * interrupts. One hint would be that if the dispatching truely worked,
+       * excessive stacked interrupts in VBox would not be a problem.
+       * This needs some more investigation.
+       */
       DevHelp_ArmCtxHook(0, engine_ctxhook_h);
-
+//      DevHelp_EOI(irq);
     } else {
       spin_lock(drv_lock);
       trigger_engine();
+//      DevHelp_EOI(irq);
       spin_unlock(drv_lock);
     }
-
+    /* disable interrupts to prevent stacking. (See comments above) */
+    disable();
     /* complete the interrupt */
     DevHelp_EOI(irq);
Index: trunk/src/os2ahci/os2ahci.h
===================================================================
--- trunk/src/os2ahci/os2ahci.h	(revision 144)
+++ trunk/src/os2ahci/os2ahci.h	(revision 145)
@@ -30,5 +30,5 @@
  * is controlled via compiler parameters. Thus, all stuctures in os2ahci.add
  * are expected to be byte-aligned without the need of explicit pragma pack()
- * directives. Where possible, the structures are layed out such that words
+ * directives. Where possible, the structures are laid out such that words
  * and dwords are aligned at least on 2-byte boundaries.
  */
Index: trunk/src/os2ahci/wmakefile
===================================================================
--- trunk/src/os2ahci/wmakefile	(revision 144)
+++ trunk/src/os2ahci/wmakefile	(revision 145)
@@ -74,11 +74,28 @@
 
 
+
+
+#
+# Specify Linker
+# Note: Using ALP with Wlink produces an oversized image, possibly due to
+#       the location of BSS segments. Putting the BSS segments after the CODE
+#       segments in init.asm and/or segment ordering in the Wlink response file
+#       seems not to work when using ALP.
+#
+
 #LINKER=ibm
 LINKER=watcom
 
+#
+# Specify Assembler
+# Note: This will only be of influence on assembling .asm files.
+#       C inline _asm statements will use Wasm.
+#
 
 #AS         = $(DDK)\tools\alp.exe
 #AS         = jwasm -Cp
 AS         = wasm
+
+
 CC         = wcc
 LD         = $(DDK)\base\tools\link.exe
