ia64/xen-unstable

changeset 2950:74d1242bba95

bitkeeper revision 1.1159.172.1 (4194ce42z4ANVXzSMk0doSVOCKrA1g)

Add no-defer keyhandlers which get called from interrupt context and get
access to the registers saved on interrupt entry.
author cl349@freefall.cl.cam.ac.uk
date Fri Nov 12 14:52:50 2004 +0000 (2004-11-12)
parents 5d3097b7205b
children 9059b48a1f5f
files xen/common/keyhandler.c xen/drivers/char/console.c xen/include/xen/keyhandler.h
line diff
     1.1 --- a/xen/common/keyhandler.c	Fri Nov 12 02:27:12 2004 +0000
     1.2 +++ b/xen/common/keyhandler.c	Fri Nov 12 14:52:50 2004 +0000
     1.3 @@ -11,10 +11,13 @@
     1.4  #define STR_MAX  64
     1.5  
     1.6  static struct { 
     1.7 -    key_handler *handler; 
     1.8 +    key_handler *handler;
     1.9 +    int          flags;
    1.10      char         desc[STR_MAX]; 
    1.11  } key_table[KEY_MAX]; 
    1.12  
    1.13 +#define KEYHANDLER_NO_DEFER 0x1
    1.14 +
    1.15  static unsigned char keypress_key;
    1.16  
    1.17  void keypress_softirq(void)
    1.18 @@ -25,19 +28,33 @@ void keypress_softirq(void)
    1.19          (*h)(key);
    1.20  }
    1.21  
    1.22 -void handle_keypress(unsigned char key)
    1.23 +void handle_keypress(unsigned char key, struct xen_regs *regs)
    1.24  {
    1.25 +    key_handler  *h;
    1.26 +
    1.27      keypress_key = key;
    1.28 -    raise_softirq(KEYPRESS_SOFTIRQ);
    1.29 +    if ( (key_table[key].flags & KEYHANDLER_NO_DEFER) &&
    1.30 +         ((h = key_table[key].handler) != NULL) )
    1.31 +        ((void (*)(unsigned char, struct xen_regs *))*h)(key, regs);
    1.32 +    else
    1.33 +        raise_softirq(KEYPRESS_SOFTIRQ);
    1.34  }
    1.35  
    1.36  void add_key_handler(unsigned char key, key_handler *handler, char *desc)
    1.37  {
    1.38 -    key_table[key].handler = handler; 
    1.39 +    key_table[key].handler = handler;
    1.40 +    key_table[key].flags = 0;
    1.41      strncpy(key_table[key].desc, desc, STR_MAX);
    1.42      key_table[key].desc[STR_MAX-1] = '\0'; 
    1.43  }
    1.44  
    1.45 +void add_key_handler_no_defer(unsigned char key, key_handler *handler,
    1.46 +                              char *desc)
    1.47 +{
    1.48 +    add_key_handler(key, handler, desc);
    1.49 +    key_table[key].flags |= KEYHANDLER_NO_DEFER;
    1.50 +}
    1.51 +
    1.52  static void show_handlers(unsigned char key)
    1.53  {
    1.54      int i; 
     2.1 --- a/xen/drivers/char/console.c	Fri Nov 12 02:27:12 2004 +0000
     2.2 +++ b/xen/drivers/char/console.c	Fri Nov 12 14:52:50 2004 +0000
     2.3 @@ -247,7 +247,7 @@ static void __serial_rx(unsigned char c,
     2.4  {
     2.5      if ( xen_rx )
     2.6      {
     2.7 -        handle_keypress(c);
     2.8 +        handle_keypress(c, regs);
     2.9      }
    2.10      else if ( (serial_rx_prod-serial_rx_cons) != SERIAL_RX_SIZE )
    2.11      {
     3.1 --- a/xen/include/xen/keyhandler.h	Fri Nov 12 02:27:12 2004 +0000
     3.2 +++ b/xen/include/xen/keyhandler.h	Fri Nov 12 14:52:50 2004 +0000
     3.3 @@ -4,12 +4,13 @@
     3.4  ** debug flag, dump registers, reboot, etc) to be hooked in in a slightly
     3.5  ** nicer fashion than just editing the serial/keyboard drivers. 
     3.6  */
     3.7 -#include <xen/sched.h>
     3.8 +struct xen_regs;
     3.9  
    3.10  typedef void key_handler(unsigned char key);
    3.11  
    3.12  extern void add_key_handler(unsigned char key, 
    3.13  			    key_handler *handler, char *desc); 
    3.14 +extern void add_key_handler_no_defer(unsigned char key, 
    3.15 +                                     key_handler *handler, char *desc); 
    3.16  
    3.17 -extern void handle_keypress(unsigned char key);
    3.18 -
    3.19 +extern void handle_keypress(unsigned char key, struct xen_regs *regs);