Interrupt system fixed up and installed.
This commit is contained in:
parent
7e66a68afa
commit
ea9745ee2f
|
@ -107,6 +107,7 @@ SCSHOBJS = \
|
|||
scsh/flock.o scsh/flock1.o \
|
||||
scsh/machine/stdio_dep.o \
|
||||
scsh/machine/time_dep1.o \
|
||||
scsh/machine/signals1.o \
|
||||
scsh/machine/libansi.o \
|
||||
scsh/network.o scsh/network1.o \
|
||||
scsh/putenv.o \
|
||||
|
@ -635,11 +636,13 @@ scsh/scsh.image: $(VM) $(SCHEME) $(CIG).image
|
|||
echo ",load $(srcdir)/scsh/scsh-interfaces.scm"; \
|
||||
echo ",load $(srcdir)/scsh/machine/packages.scm"; \
|
||||
echo ",load $(srcdir)/scsh/scsh-package.scm"; \
|
||||
echo ",user"; \
|
||||
echo ",load-package scsh"; \
|
||||
echo ",load-package scsh-here-string-hax"; \
|
||||
echo ",open scsh"; \
|
||||
echo ",translate =scheme48/ $(LIB)/"; \
|
||||
echo ",in scsh-level-0"; \
|
||||
echo "(%install-scsh-handlers)"; \
|
||||
echo ",user"; \
|
||||
echo ",open scsh"; \
|
||||
echo "(dump-scsh \"scsh/scsh.image\")") \
|
||||
| ./$(VM) -o ./$(VM) -i $(CIG).image
|
||||
|
||||
|
|
|
@ -28,3 +28,6 @@
|
|||
(usr1 30) ; user defined signal 1
|
||||
(usr2 31) ; user defined signal 2
|
||||
)
|
||||
|
||||
(define signals-ignored-by-default
|
||||
(list signal/chld signal/cont)) ; These are Posix.
|
||||
|
|
|
@ -707,7 +707,8 @@
|
|||
|
||||
(define (init-scsh-hindbrain relink-ff?)
|
||||
(if relink-ff? (lookup-all-externals)) ; Re-link C calls.
|
||||
(init-fdports!))
|
||||
(init-fdports!)
|
||||
(%install-unix-scsh-handlers))
|
||||
|
||||
|
||||
;;; Some globals:
|
||||
|
|
|
@ -59,6 +59,31 @@
|
|||
|
||||
(define with-enabled-interrupts* with-interrupts)
|
||||
|
||||
(define interrupt/alarm (enum interrupt alarm))
|
||||
(define interrupt/keyboard (enum interrupt keyboard))
|
||||
(define interrupt/memory-shortage (enum interrupt memory-shortage))
|
||||
(define interrupt/chld (enum interrupt chld))
|
||||
(define interrupt/cont (enum interrupt cont))
|
||||
(define interrupt/hup (enum interrupt hup))
|
||||
(define interrupt/quit (enum interrupt quit))
|
||||
(define interrupt/term (enum interrupt term))
|
||||
(define interrupt/tstp (enum interrupt tstp))
|
||||
(define interrupt/usr1 (enum interrupt usr1))
|
||||
(define interrupt/usr2 (enum interrupt usr2))
|
||||
(define interrupt/info (enum interrupt info))
|
||||
(define interrupt/io (enum interrupt io))
|
||||
(define interrupt/poll (enum interrupt poll))
|
||||
(define interrupt/prof (enum interrupt prof))
|
||||
(define interrupt/pwr (enum interrupt pwr))
|
||||
(define interrupt/urg (enum interrupt urg))
|
||||
(define interrupt/vtalrm (enum interrupt vtalrm))
|
||||
(define interrupt/winch (enum interrupt winch))
|
||||
(define interrupt/xcpu (enum interrupt xcpu))
|
||||
(define interrupt/xfsz (enum interrupt xfsz))
|
||||
|
||||
(define interrupt/int interrupt/keyboard)
|
||||
(define interrupt/alrm interrupt/alarm)
|
||||
|
||||
|
||||
;;; Get/Set signal handlers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -76,44 +101,42 @@
|
|||
(define-foreign %do-default-sigaction (do_default_sigaction (fixnum signal))
|
||||
ignore)
|
||||
|
||||
;;; This gives the default handler for each signal.
|
||||
(define default-handler-vec
|
||||
(initialize-vector 32 (lambda (sig)
|
||||
;; This is the guy to call when you want signal
|
||||
;; SIG handled in the default manner.
|
||||
(if (memv sig signals-ignored-by-default)
|
||||
(define default-int-handler-vec
|
||||
;; Non-Unix-signal interrupts just get their default values from
|
||||
;; the current value of I-H.
|
||||
(let ((v (copy-vector interrupt-handlers)))
|
||||
(do ((sig 31 (- sig 1))) ; For each Unix signal
|
||||
((< sig 0)) ; make & install a default
|
||||
(let ((i (%signal->interrupt sig))) ; signal handler.
|
||||
(if (>= i 0) ; Don't mess with non-signal interrupts.
|
||||
(vector-set! v i (if (memv sig signals-ignored-by-default)
|
||||
(lambda (enabled-interrupts) #f)
|
||||
(lambda (enabled-interrupts)
|
||||
(%do-default-sigaction sig))))))
|
||||
|
||||
(%do-default-sigaction sig)))))))
|
||||
v))
|
||||
|
||||
;;; HANDLER is #f (ignore), #t (default), or a procedure taking an integer
|
||||
;;; argument. The interrupt is delivered to a procedure by (1) setting the
|
||||
;;; ENABLED-INTERRUPTS register to 0 (i.e., blocking all interrupts), and (2)
|
||||
;;; applying the procedure to the previous value of the ENABLED-INTERRUPTS
|
||||
;;; register. If the procedure returns normally (i.e., it doesn't throw to a
|
||||
;;; continuation), the ENABLED-INTERRUPTS register will be restored to its
|
||||
;;; previous value.
|
||||
;;; register. If the procedure returns normally, the ENABLED-INTERRUPTS
|
||||
;;; register will be restored to its previous value.
|
||||
|
||||
;;; This handler does nothing -- used when the handler is #f.
|
||||
(define (noop-sig-handler enabled-interrupts) #f)
|
||||
|
||||
(define (set-signal-handler! sig handler)
|
||||
(let ((nhandler (case handler
|
||||
((#t) (vector-ref default-handler-vec sig))
|
||||
(define (set-interrupt-handler! int handler)
|
||||
(let ((ohandler (interrupt-handler int)))
|
||||
(vector-set! interrupt-handlers int
|
||||
(case handler
|
||||
((#t) (vector-ref default-int-handler-vec int))
|
||||
((#f) noop-sig-handler)
|
||||
(else handler)))
|
||||
(int (signal->interrupt sig)))
|
||||
(with-enabled-interrupts 0
|
||||
(let ((ohandler (vector-ref interrupt-handlers int)))
|
||||
(vector-set! interrupt-handlers int nhandler)
|
||||
(cond ((eq? ohandler (vector-ref default-handler-vec sig)) #t)
|
||||
((eq? ohandler noop-sig-handler) #f)
|
||||
(else ohandler))))))
|
||||
ohandler))
|
||||
|
||||
(define (signal-handler sig)
|
||||
(let ((handler (vector-ref interrupt-handlers (signal->interrupt sig))))
|
||||
(cond ((eq? handler (vector-ref default-handler-vec sig)) #t)
|
||||
(define (interrupt-handler int)
|
||||
(let ((handler (vector-ref interrupt-handlers int)))
|
||||
(cond ((eq? handler (vector-ref default-int-handler-vec int)) #t)
|
||||
((eq? handler noop-sig-handler) #f)
|
||||
(else handler))))
|
||||
|
||||
|
@ -166,6 +189,8 @@
|
|||
(do ((sig 32 (- sig 1)))
|
||||
((< sig 0))
|
||||
(let ((i (%signal->interrupt sig)))
|
||||
(if (not (or (= i -1) (= sig signal/int) (= sig signal/alrm)))
|
||||
(if (not (or (= i -1)
|
||||
(= sig signal/int) ; Leave ^c and
|
||||
(= sig signal/alrm))) ; alarm handlers alone.
|
||||
(vector-set! interrupt-handlers i
|
||||
(vector-ref default-handler-vec sig))))))
|
||||
(vector-ref default-int-handler-vec i))))))
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
/* Make sure our exports match up w/the implementation: */
|
||||
#include "sighandlers1.h"
|
||||
|
||||
/* Import the OS-dependent set of signals and their translations
|
||||
** to S48 vm interrupts.
|
||||
*/
|
||||
#include "signals1.h"
|
||||
|
||||
extern int errno;
|
||||
|
@ -63,7 +66,7 @@ int get_procmask(int *old_lo_p)
|
|||
|
||||
static void scm_handle_sig(int sig)
|
||||
{
|
||||
/* fprintf(stderr, "scm_handle_sig(%d)\n", sig); */
|
||||
/*fprintf(stderr, "scm_handle_sig(%d) = int %d\n", sig, sig2int[sig]);*/
|
||||
Spending_interruptsS |= (1<<sig2int[sig]);
|
||||
}
|
||||
|
||||
|
@ -169,6 +172,7 @@ void install_scsh_handlers(void)
|
|||
|
||||
sigemptyset(&new.sa_mask); /* WTF */
|
||||
new.sa_handler = scm_handle_sig;
|
||||
new.sa_flags = 0;
|
||||
|
||||
for(i=max_sig; i>=0; i--)
|
||||
if( sig2int[i] ) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Exports from signals1.c */
|
||||
|
||||
const int sig2int[];
|
||||
const int max_sig;
|
||||
extern const int sig2int[];
|
||||
extern const int max_sig;
|
||||
|
|
Loading…
Reference in New Issue