readded with-enabled-interrupts
This commit is contained in:
parent
539638acbd
commit
6f15160aac
|
@ -64,7 +64,7 @@
|
|||
|
||||
(define *enabled-interrupts*
|
||||
(let lp ((i 0) (mask 0))
|
||||
(if (= i (number-of-interrupts))
|
||||
(if (= i number-of-interrupts)
|
||||
mask
|
||||
(lp (+ i 1) (interrupt-enable i mask)))))
|
||||
|
||||
|
@ -77,7 +77,6 @@
|
|||
;;;
|
||||
;;; I think you should...
|
||||
(define (set-enabled-interrupts new-enabled-interrupts)
|
||||
(let ((number-of-interrupts (number-of-interrupts)))
|
||||
(do ((int 0 (+ int 1)))
|
||||
((= int number-of-interrupts) new-enabled-interrupts)
|
||||
(let ((old-state (interrupt-enabled? int *enabled-interrupts*))
|
||||
|
@ -90,7 +89,7 @@
|
|||
(error "there was no blockade" int))
|
||||
(unblock-interrupt blockade)
|
||||
(vector-set! blockade-vector int #f)))
|
||||
(else 'unchanged)))))
|
||||
(else 'unchanged))))
|
||||
(set! *enabled-interrupts* new-enabled-interrupts))
|
||||
|
||||
;;; Enableing/Disableing = Unblocking/Blocking
|
||||
|
@ -118,7 +117,7 @@
|
|||
(pending? #f))
|
||||
|
||||
|
||||
(define blockade-vector (make-vector (number-of-interrupts) #f))
|
||||
(define blockade-vector (make-vector number-of-interrupts #f))
|
||||
|
||||
;;; do nothing in low-interrupt, the new handler will be recorded in the
|
||||
;;; interrupt-handler-vector however
|
||||
|
@ -150,80 +149,63 @@
|
|||
; install the handler that resides in the vector
|
||||
(let ((low-int-set! (blockade:low-int-set! blockade)))
|
||||
(low-int-set! handler)
|
||||
; resinstall the low-interrupt-setter
|
||||
; reinstall the low-interrupt-setter
|
||||
(set-cdr! (blockade:interrupt-vector-cell blockade)
|
||||
low-int-set!)
|
||||
(if (blockade:pending? blockade)
|
||||
(apply handler (blockade:pending? blockade))))))
|
||||
|
||||
|
||||
;(define-simple-syntax (with-enabled-interrupts mask body ...)
|
||||
; (with-interrupts mask (lambda () body ...)))
|
||||
(define-simple-syntax (with-enabled-interrupts mask body ...)
|
||||
(define-simple-syntax (with-enabled-interrupts interrupt-set body ...)
|
||||
(begin
|
||||
;(display "JMG: use of w-e-i")
|
||||
body ...))
|
||||
(with-enabled-interrupts* interrupt-set (lambda () body ...))))
|
||||
|
||||
(define (with-enabled-interrupts* thunk thunk)
|
||||
(warn "JMG: use of with-enabled-interrupts*")
|
||||
(thunk))
|
||||
(define (with-enabled-interrupts* interrupt-set thunk)
|
||||
(let ((before *enabled-interrupts*))
|
||||
(set-enabled-interrupts interrupt-set)
|
||||
(let ((return (thunk)))
|
||||
(set-enabled-interrupts before)
|
||||
return)))
|
||||
|
||||
|
||||
; Fakes vm vector
|
||||
;;; car is the actual handler, cdr is a proc to set handler in low-interrupt system
|
||||
;;; car is the actual handler, cdr is a proc to set handler in
|
||||
;;; low-interrupt system
|
||||
|
||||
(define *interrupt-handlers-vector*
|
||||
(make-vector (number-of-interrupts) (cons #f #f)))
|
||||
(make-vector number-of-interrupts (cons #f #f)))
|
||||
|
||||
(define (interrupt-handlers-vector)
|
||||
*interrupt-handlers-vector*)
|
||||
|
||||
(define (interrupt-handler-ref int)
|
||||
(if (or (< int 0) (>= int (number-of-interrupts)))
|
||||
(if (or (< int 0) (>= int number-of-interrupts))
|
||||
(error "ill signum in interrupt-handler-ref" int)
|
||||
(car (vector-ref *interrupt-handlers-vector* int))))
|
||||
|
||||
;;; the handler is not interested in the enabled interupts of the vm
|
||||
;;; but in those managed here
|
||||
(define (make-handler handler)
|
||||
(lambda (enabled-low)
|
||||
(handler (enabled-interrupts))))
|
||||
|
||||
(define (set-interrupt-handler! int handler)
|
||||
(if (or (< int 0) (>= int (number-of-interrupts)))
|
||||
(if (or (< int 0) (>= int number-of-interrupts))
|
||||
(error "ill signum in set-interrupt-handler!" int)
|
||||
(let ((old (vector-ref *interrupt-handlers-vector* int)))
|
||||
(if (not (cdr old)) ; not yet registered?
|
||||
(let ((handler-setter (vector-ref *interrupt-handlers-vector* int))
|
||||
(handler-enabled-here (make-handler handler)))
|
||||
(if (not (cdr handler-setter)) ; not yet registered?
|
||||
(let ((setter (low-interrupt-register
|
||||
int handler)))
|
||||
int handler-enabled-here)))
|
||||
(vector-set! *interrupt-handlers-vector*
|
||||
int
|
||||
(cons handler setter)))
|
||||
(begin
|
||||
((cdr old) handler) ; set it with setter
|
||||
((cdr handler-setter) handler-enabled-here) ; set it with setter
|
||||
(set-car! (vector-ref *interrupt-handlers-vector* int)
|
||||
handler))))))
|
||||
|
||||
|
||||
|
||||
|
||||
;(define (init-interrupt)
|
||||
; (do ((sig 32 (- sig 1)))
|
||||
; ((< sig 0))
|
||||
|
||||
|
||||
; (set-scsh-low-interrupt-handler!
|
||||
; sig
|
||||
; (lambda (x) #t)))
|
||||
; (set-interrupt-handler!
|
||||
; (enum interrupt os-signal)
|
||||
; (lambda (type arg enabled-interrupts)
|
||||
; (if (= type (enum scsh-os-signal chld))
|
||||
; (begin
|
||||
; (procobj-handler enabled-interrupts)))
|
||||
; ((scsh-os-signal-handler-ref type) enabled-interrupts)
|
||||
; ))
|
||||
; (display "sighandler installed")
|
||||
; #t)
|
||||
|
||||
|
||||
|
||||
|
||||
;;; Get/Set signal handlers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
@ -352,7 +334,7 @@
|
|||
|
||||
(define (%install-scsh-handlers)
|
||||
(do ((int 0 (+ int 1)))
|
||||
((= int (number-of-interrupts)))
|
||||
((= int number-of-interrupts))
|
||||
(set-interrupt-handler
|
||||
int
|
||||
(lambda a #f)))
|
||||
|
|
Loading…
Reference in New Issue