From 7b5823899918f931f461e13ebe0b5a1ba6503f7b Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 29 Jun 1993 22:53:56 +0000 Subject: [PATCH] Redefine the GLOBAL-2 interrupt bit to be the interrupt that is signalled after each GC. Change the interrupt code to allow the runtime system to specify what interrupt mask should be installed immediately before an interrupt handler is invoked. This allows the runtime system to override the simple prioritized masking being performed by the microcode. --- v7/src/microcode/boot.c | 13 ++- v7/src/microcode/fixobj.h | 11 ++- v7/src/microcode/intrpt.h | 9 +- v7/src/microcode/utils.c | 181 +++++++++++++++++++++++-------------- v7/src/microcode/version.h | 4 +- v8/src/microcode/fixobj.h | 11 ++- v8/src/microcode/version.h | 4 +- 7 files changed, 147 insertions(+), 86 deletions(-) diff --git a/v7/src/microcode/boot.c b/v7/src/microcode/boot.c index 8375ab9ca..f51c93346 100644 --- a/v7/src/microcode/boot.c +++ b/v7/src/microcode/boot.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: boot.c,v 9.80 1993/06/24 21:58:42 gjr Exp $ +$Id: boot.c,v 9.81 1993/06/29 22:53:46 cph Exp $ Copyright (c) 1988-1993 Massachusetts Institute of Technology @@ -188,7 +188,10 @@ DEFUN (main_name, (argc, argv), SCHEME_OBJECT DEFUN_VOID (make_fixed_objects_vector) { - extern SCHEME_OBJECT initialize_history (); + extern SCHEME_OBJECT EXFUN (initialize_history, (void)); + extern SCHEME_OBJECT EXFUN (initialize_interrupt_handler_vector, (void)); + extern SCHEME_OBJECT EXFUN (initialize_interrupt_mask_vector, (void)); + /* Create the fixed objects vector, with 4 extra slots for expansion and debugging. */ fast SCHEME_OBJECT fixed_objects_vector = @@ -199,7 +202,11 @@ DEFUN_VOID (make_fixed_objects_vector) FAST_VECTOR_SET (fixed_objects_vector, System_Interrupt_Vector, - (make_vector ((MAX_INTERRUPT_NUMBER + 2), SHARP_F, false))); + (initialize_interrupt_handler_vector ())); + FAST_VECTOR_SET + (fixed_objects_vector, + FIXOBJ_INTERRUPT_MASK_VECTOR, + (initialize_interrupt_mask_vector ())); /* Error vector is not needed at boot time */ FAST_VECTOR_SET (fixed_objects_vector, System_Error_Vector, SHARP_F); FAST_VECTOR_SET diff --git a/v7/src/microcode/fixobj.h b/v7/src/microcode/fixobj.h index 0ea578442..263f9ea1b 100644 --- a/v7/src/microcode/fixobj.h +++ b/v7/src/microcode/fixobj.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: fixobj.h,v 9.31 1993/06/24 07:08:32 gjr Exp $ +$Id: fixobj.h,v 9.32 1993/06/29 22:53:50 cph Exp $ Copyright (c) 1987-91 Massachusetts Institute of Technology @@ -36,12 +36,16 @@ MIT in each case. */ This should correspond to the file "utabmd.scm". */ #define Non_Object 0x00 /* Used for unassigned variables. */ -#define System_Interrupt_Vector 0x01 /* Handlers for interrups. */ +#define System_Interrupt_Vector 0x01 /* Handlers for interrupts. */ #define System_Error_Vector 0x02 /* Handlers for errors. */ #define OBArray 0x03 /* Array for interning symbols. */ #define Types_Vector 0x04 /* Type number -> Name map. */ #define Returns_Vector 0x05 /* Return code -> Name map. */ -#define Primitives_Vector 0x06 /* Primitive code -> Name map. */ + +/* For each interrupt, an interrupt mask to be set when invoking the + handler for that interrupt. */ +#define FIXOBJ_INTERRUPT_MASK_VECTOR 0x06 + #define Errors_Vector 0x07 /* Error code -> Name map. */ #define Identification_Vector 0x08 /* ID Vector index -> name map. */ #define FIXOBJ_SYSTEM_CALL_NAMES 0x09 /* System call index -> name */ @@ -100,6 +104,5 @@ MIT in each case. */ #define ARITY_DISPATCHER_TAG 0x33 - #define NFixed_Objects 0x34 diff --git a/v7/src/microcode/intrpt.h b/v7/src/microcode/intrpt.h index 2dc62683d..c8d0a23d9 100644 --- a/v7/src/microcode/intrpt.h +++ b/v7/src/microcode/intrpt.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: intrpt.h,v 1.11 1992/09/26 02:55:03 cph Exp $ +$Id: intrpt.h,v 1.12 1993/06/29 22:53:52 cph Exp $ -Copyright (c) 1987-92 Massachusetts Institute of Technology +Copyright (c) 1987-93 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -41,16 +41,15 @@ MIT in each case. */ #define INT_GC 4 /* Local interrupt */ #define INT_Global_1 8 #define INT_Character 16 /* Local interrupt */ -#define INT_Global_2 32 +#define INT_AFTER_GC 32 /* Local interrupt */ #define INT_Timer 64 /* Local interrupt */ #define INT_Global_3 128 #define INT_Suspend 256 /* Local interrupt */ #define INT_Global_Mask \ - (INT_Global_GC | INT_Global_1 | INT_Global_2 | INT_Global_3) + (INT_Global_GC | INT_Global_1 | INT_Global_3) #define Global_GC_Level 1 #define Global_1_Level 3 -#define Global_2_Level 5 #define Global_3_Level 7 #define MAX_INTERRUPT_NUMBER 8 diff --git a/v7/src/microcode/utils.c b/v7/src/microcode/utils.c index e74a55551..2e3a0e91e 100644 --- a/v7/src/microcode/utils.c +++ b/v7/src/microcode/utils.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: utils.c,v 9.58 1993/06/25 20:57:07 gjr Exp $ +$Id: utils.c,v 9.59 1993/06/29 22:53:54 cph Exp $ Copyright (c) 1987-1993 Massachusetts Institute of Technology @@ -40,89 +40,138 @@ MIT in each case. */ #include "history.h" #include "cmpint.h" -/* Set_Up_Interrupt is called from the Interrupt - macro to do all of the setup for calling the user's - interrupt routines. */ +/* Helper procedures for Setup_Interrupt, which follows. */ -void -DEFUN (Setup_Interrupt, (Masked_Interrupts), long Masked_Interrupts) +static long +DEFUN (compute_interrupt_number, (masked_interrupts), + long masked_interrupts) { - SCHEME_OBJECT Int_Vector, Handler; - long i, Int_Number, The_Int_Code, New_Int_Enb; + long interrupt_number = 0; + long bit_mask = 1; + while ((interrupt_number <= MAX_INTERRUPT_NUMBER) + && ((masked_interrupts & bit_mask) == 0)) + { + interrupt_number += 1; + bit_mask <<= 1; + } + return (interrupt_number); +} - The_Int_Code = (FETCH_INTERRUPT_CODE ()); - Int_Vector = SHARP_F; - if (Valid_Fixed_Obj_Vector ()) - Int_Vector = (Get_Fixed_Obj_Slot (System_Interrupt_Vector)); +/* This default is solely for compatibility with the previous behavior + of the microcode. It is not a good default and should be + overridden by the runtime system. */ +#define DEFAULT_INTERRUPT_HANDLER_MASK(interrupt_number) \ + ((1 << (interrupt_number)) - 1) - if (!(VECTOR_P (Int_Vector))) - { - outf_fatal ("\nInvalid handlers vector (0x%lx)\n", Int_Vector); -lose_big: - outf_fatal("Interrupts = 0x%08lx, Mask = 0x%08lx, Masked = 0x%08lx\n", - FETCH_INTERRUPT_CODE(), - FETCH_INTERRUPT_MASK(), - Masked_Interrupts); - Microcode_Termination (TERM_NO_INTERRUPT_HANDLER); - } +static long +DEFUN (compute_interrupt_handler_mask, (interrupt_masks, interrupt_number), + SCHEME_OBJECT interrupt_masks AND + long interrupt_number) +{ + if ((VECTOR_P (interrupt_masks)) + && (interrupt_number <= (VECTOR_LENGTH (interrupt_masks)))) + { + SCHEME_OBJECT mask = + (VECTOR_REF (interrupt_masks, interrupt_number)); + if ((INTEGER_P (mask)) && (integer_to_long_p (mask))) + /* Guarantee that the given interrupt is disabled. */ + return ((integer_to_long (mask)) &~ (1 << interrupt_number)); + } + return + ((interrupt_number <= MAX_INTERRUPT_NUMBER) + ? (DEFAULT_INTERRUPT_HANDLER_MASK (interrupt_number)) + : (FETCH_INTERRUPT_MASK ())); +} - /* The interrupt vector is normally of size (MAX_INTERRUPT_NUMBER + 1). - We signal all normal interrupts though the first MAX_INTERRUPT_NUMBER - slots, and any other (spurious) interrupts through the last slot. - */ +static void +DEFUN (terminate_no_interrupt_handler, (masked_interrupts), + long masked_interrupts) +{ + outf_fatal("\nInterrupts = 0x%08lx, Mask = 0x%08lx, Masked = 0x%08lx\n", + (FETCH_INTERRUPT_CODE ()), + (FETCH_INTERRUPT_MASK ()), + masked_interrupts); + Microcode_Termination (TERM_NO_INTERRUPT_HANDLER); +} - Int_Number = 0; - i = 1; - while (true) - { - if (Int_Number > MAX_INTERRUPT_NUMBER) +SCHEME_OBJECT +DEFUN_VOID (initialize_interrupt_handler_vector) +{ + return (make_vector ((MAX_INTERRUPT_NUMBER + 2), SHARP_F, false)); +} + +SCHEME_OBJECT +DEFUN_VOID (initialize_interrupt_mask_vector) +{ + SCHEME_OBJECT result = + (make_vector ((MAX_INTERRUPT_NUMBER + 2), SHARP_F, false)); + long interrupt_number; + + for (interrupt_number = 0; + (interrupt_number <= MAX_INTERRUPT_NUMBER); + interrupt_number += 1) + VECTOR_SET + (result, interrupt_number, + (long_to_integer (DEFAULT_INTERRUPT_HANDLER_MASK (interrupt_number)))); + return (result); +} + +/* Setup_Interrupt is called from the Interrupt macro to do all of the + setup for calling the user's interrupt routines. */ + +void +DEFUN (Setup_Interrupt, (masked_interrupts), long masked_interrupts) +{ + SCHEME_OBJECT interrupt_handlers = SHARP_F; + SCHEME_OBJECT interrupt_masks = SHARP_F; + long interrupt_number = (compute_interrupt_number (masked_interrupts)); + long interrupt_mask; + SCHEME_OBJECT interrupt_handler; + + if (! (Valid_Fixed_Obj_Vector ())) { - New_Int_Enb = (FETCH_INTERRUPT_MASK ()); - break; + outf_fatal ("\nInvalid fixed-objects vector."); + terminate_no_interrupt_handler (masked_interrupts); } - if ((Masked_Interrupts & i) != 0) + interrupt_handlers = (Get_Fixed_Obj_Slot (System_Interrupt_Vector)); + interrupt_masks = (Get_Fixed_Obj_Slot (FIXOBJ_INTERRUPT_MASK_VECTOR)); + if (! (VECTOR_P (interrupt_handlers))) { - New_Int_Enb = ((1 << Int_Number) - 1); - break; + outf_fatal ("\nInvalid handlers vector (0x%lx).", interrupt_handlers); + terminate_no_interrupt_handler (masked_interrupts); } - Int_Number += 1; - i = (i << 1); - } - - /* Handle case where interrupt vector is too small. */ - if (Int_Number >= (VECTOR_LENGTH (Int_Vector))) - { - outf_fatal("\nInterrupt out of range: %ld (vector length = %ld)\n", - Int_Number, (VECTOR_LENGTH (Int_Vector))); - goto lose_big; - } - + if (interrupt_number >= (VECTOR_LENGTH (interrupt_handlers))) + { + outf_fatal("\nInterrupt out of range: %ld (vector length = %ld).", + interrupt_number, + (VECTOR_LENGTH (interrupt_handlers))); + terminate_no_interrupt_handler (masked_interrupts); + } + interrupt_mask = + (compute_interrupt_handler_mask (interrupt_masks, interrupt_number)); Global_Interrupt_Hook (); - Handler = (VECTOR_REF (Int_Vector, Int_Number)); + interrupt_handler = (VECTOR_REF (interrupt_handlers, interrupt_number)); -Passed_Checks: /* This label may be used in Global_Interrupt_Hook */ + /* This label may be used in Global_Interrupt_Hook: */ + passed_checks: Stop_History (); preserve_interrupt_mask (); Will_Push (STACK_ENV_EXTRA_SLOTS + 3); -/* - There used to be some code here for gc checks, but that is done - uniformly now by RC_NORMAL_GC_DONE. - */ -/* Now make an environment frame for use in calling the - * user supplied interrupt routine. It will be given - * two arguments: the UNmasked interrupt requests, and - * the currently enabled interrupts. - */ + /* There used to be some code here for gc checks, but that is done + uniformly now by RC_NORMAL_GC_DONE. */ - STACK_PUSH (LONG_TO_FIXNUM(FETCH_INTERRUPT_MASK())); - STACK_PUSH (LONG_TO_FIXNUM(The_Int_Code)); - STACK_PUSH (Handler); + /* Now make an environment frame for use in calling the + user supplied interrupt routine. It will be given two arguments: + the UNmasked interrupt requests, and the currently enabled + interrupts. */ + STACK_PUSH (LONG_TO_FIXNUM (FETCH_INTERRUPT_MASK ())); + STACK_PUSH (LONG_TO_FIXNUM (FETCH_INTERRUPT_CODE ())); + STACK_PUSH (interrupt_handler); STACK_PUSH (STACK_FRAME_HEADER + 2); - Pushed(); - /* Turn off interrupts */ - SET_INTERRUPT_MASK(New_Int_Enb); - return; + Pushed (); + /* Turn off interrupts: */ + SET_INTERRUPT_MASK (interrupt_mask); } /* Error processing utilities */ diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index 8a8ad0049..256404a63 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: version.h,v 11.132 1993/06/24 08:13:43 gjr Exp $ +$Id: version.h,v 11.133 1993/06/29 22:53:56 cph Exp $ Copyright (c) 1988-1993 Massachusetts Institute of Technology @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 132 +#define SUBVERSION 133 #endif diff --git a/v8/src/microcode/fixobj.h b/v8/src/microcode/fixobj.h index 0ea578442..263f9ea1b 100644 --- a/v8/src/microcode/fixobj.h +++ b/v8/src/microcode/fixobj.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: fixobj.h,v 9.31 1993/06/24 07:08:32 gjr Exp $ +$Id: fixobj.h,v 9.32 1993/06/29 22:53:50 cph Exp $ Copyright (c) 1987-91 Massachusetts Institute of Technology @@ -36,12 +36,16 @@ MIT in each case. */ This should correspond to the file "utabmd.scm". */ #define Non_Object 0x00 /* Used for unassigned variables. */ -#define System_Interrupt_Vector 0x01 /* Handlers for interrups. */ +#define System_Interrupt_Vector 0x01 /* Handlers for interrupts. */ #define System_Error_Vector 0x02 /* Handlers for errors. */ #define OBArray 0x03 /* Array for interning symbols. */ #define Types_Vector 0x04 /* Type number -> Name map. */ #define Returns_Vector 0x05 /* Return code -> Name map. */ -#define Primitives_Vector 0x06 /* Primitive code -> Name map. */ + +/* For each interrupt, an interrupt mask to be set when invoking the + handler for that interrupt. */ +#define FIXOBJ_INTERRUPT_MASK_VECTOR 0x06 + #define Errors_Vector 0x07 /* Error code -> Name map. */ #define Identification_Vector 0x08 /* ID Vector index -> name map. */ #define FIXOBJ_SYSTEM_CALL_NAMES 0x09 /* System call index -> name */ @@ -100,6 +104,5 @@ MIT in each case. */ #define ARITY_DISPATCHER_TAG 0x33 - #define NFixed_Objects 0x34 diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index 8a8ad0049..256404a63 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: version.h,v 11.132 1993/06/24 08:13:43 gjr Exp $ +$Id: version.h,v 11.133 1993/06/29 22:53:56 cph Exp $ Copyright (c) 1988-1993 Massachusetts Institute of Technology @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 132 +#define SUBVERSION 133 #endif -- 2.25.1