aboutsummaryrefslogtreecommitdiff
path: root/sys/etc/intr.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/etc/intr.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/etc/intr.x')
-rw-r--r--sys/etc/intr.x54
1 files changed, 54 insertions, 0 deletions
diff --git a/sys/etc/intr.x b/sys/etc/intr.x
new file mode 100644
index 00000000..e30d610c
--- /dev/null
+++ b/sys/etc/intr.x
@@ -0,0 +1,54 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <xwhen.h>
+
+define LEN_SAVE 10
+
+# INTR_DISABLE, INTR_ENABLE -- Disable interrupts to protect a critical
+# section of code. The interrupt handler is saved on a stack and restored
+# when interupts are reenabled.
+
+procedure intr_disable()
+
+int sp
+int save[LEN_SAVE]
+common /zintde/ sp, save
+
+begin
+ sp = sp + 1
+ if (sp > LEN_SAVE)
+ call sys_panic (1, "interrupt save stack overflow")
+
+ call zxwhen (X_INT, X_IGNORE, save[sp])
+end
+
+
+# INTR_ENABLE -- Reenable interrupts (restore saved interrupt handler).
+
+procedure intr_enable()
+
+int junk
+int sp
+int save[LEN_SAVE]
+common /zintde/ sp, save
+
+begin
+ if (sp <= 0)
+ call sys_panic (1, "interrupt save stack underflow")
+
+ call zxwhen (X_INT, save[sp], junk)
+ sp = sp - 1
+end
+
+
+# INTR_RESET -- Clear the interrupt handler save stack.
+
+procedure intr_reset()
+
+int sp
+int save[LEN_SAVE]
+common /zintde/ sp, save
+
+begin
+ sp = 0
+end