diff -u -r -b -B linux-2.4.20.orig/drivers/char/keyboard.c linux-2.4.20/drivers/char/keyboard.c
--- linux-2.4.20.orig/drivers/char/keyboard.c	2003-04-06 21:22:14 +0300
+++ linux-2.4.20/drivers/char/keyboard.c	2003-04-06 21:54:01 +0300
@@ -63,6 +63,8 @@
 
 void (*kbd_ledfunc)(unsigned int led);
 EXPORT_SYMBOL(handle_scancode);
+EXPORT_SYMBOL(handle_scancode_generic);
+
 EXPORT_SYMBOL(kbd_ledfunc);
 EXPORT_SYMBOL(kbd_refresh_leds);
 
@@ -193,8 +195,12 @@
     return kbd_getkeycode(scancode);
 }
 
-void handle_scancode(unsigned char scancode, int down)
-{
+void handle_scancode(unsigned char scancode, int down){
+  handle_scancode_generic(scancode,down,0);
+}
+
+void handle_scancode_generic(unsigned char scancode, int down, int kbd_num)
+ {
 	unsigned char keycode;
 	char up_flag = down ? 0 : 0200;
 	char raw_mode;
@@ -202,7 +208,11 @@
 	pm_access(pm_kbd);
 	add_keyboard_randomness(scancode | up_flag);
 
-	tty = ttytab? ttytab[fg_console]: NULL;
+	/*
+	  Basil Evseenko
+	  Hack for multihead machine
+	*/
+	tty = ttytab? ttytab[ ( kbd_num ?  kbd_num  : fg_console ) ]: NULL;
 	if (tty && (!tty->driver_data)) {
 		/*
 		 * We touch the tty structure via the ttytab array
@@ -213,7 +223,12 @@
 		 */
 		tty = NULL;
 	}
-	kbd = kbd_table + fg_console;
+	/*
+	Basil Evseenko
+	Hack for multihead machine
+	*/
+	kbd = kbd_table +  ( kbd_num ?  kbd_num  : fg_console );
+
 	if ((raw_mode = (kbd->kbdmode == VC_RAW))) {
 		/*
 		 *	The following is a workaround for hardware
diff -u -r -b -B linux-2.4.20.orig/drivers/char/vt.c linux-2.4.20/drivers/char/vt.c
--- linux-2.4.20.orig/drivers/char/vt.c	2003-04-06 21:21:41 +0300
+++ linux-2.4.20/drivers/char/vt.c	2003-04-06 21:54:06 +0300
@@ -776,6 +776,13 @@
 			return -EPERM;
 		if (arg == 0 || arg > MAX_NR_CONSOLES)
 			return -ENXIO;
+		
+		if(arg==2 || arg==3){
+		  //printk("ZG: attemp to switch to %d\n",arg); 
+		  //Basil Evseenko: hack for framebuffer X  
+		  return 0;
+		}
+		
 		arg--;
 		i = vc_allocate(arg);
 		if (i)
@@ -791,6 +798,10 @@
 			return -EPERM;
 		if (arg == 0 || arg > MAX_NR_CONSOLES)
 			return -ENXIO;
+		if (arg == 2 || arg == 3 ) {
+		  //printk("ZG: VT_WAITACTIVE %d\n",arg);
+		  return 2;
+		}	
 		return vt_waitactive(arg-1);
 
 	/*
diff -u -r -b -B linux-2.4.20.orig/drivers/input/keybdev.c linux-2.4.20/drivers/input/keybdev.c
--- linux-2.4.20.orig/drivers/input/keybdev.c	2003-04-06 21:22:14 +0300
+++ linux-2.4.20/drivers/input/keybdev.c	2003-04-06 21:54:11 +0300
@@ -43,6 +43,10 @@
     defined(__arm__)
 
 static int x86_sysrq_alt = 0;
+
+int usbkbd_map[1024]={0};
+int zg_head_ismaped[3]={0};
+
 #ifdef CONFIG_SPARC64
 static int sparc_l1_a_state = 0;
 extern void batten_down_hatches(void);
@@ -91,7 +95,7 @@
 	  0,  0,  0,  0,  0, 94,  0, 93,  0,  0,  0,  0,  0,  0,104,102 };
 #endif	/* CONFIG_MAC_ADBKEYCODES || CONFIG_ADB_KEYBOARD */
  
-static int emulate_raw(unsigned int keycode, int down)
+static int emulate_raw(unsigned int keycode, int down, int kbd_num)
 {
 #ifdef CONFIG_MAC_EMUMOUSEBTN
 	if (mac_hid_mouse_emulate_buttons(1, keycode, down))
@@ -102,7 +106,7 @@
 		if (keycode > 255 || !mac_keycodes[keycode])
 			return -1;
        
-		handle_scancode((mac_keycodes[keycode] & 0x7f), down);
+		handle_scancode_generic((mac_keycodes[keycode] & 0x7f), down, kbd_num);
 		return 0;
 	}
 #endif	/* CONFIG_MAC_ADBKEYCODES || CONFIG_ADB_KEYBOARD */
@@ -111,14 +115,14 @@
 		return -1; 
 
 	if (keycode == KEY_PAUSE) {
-		handle_scancode(0xe1, 1);
-		handle_scancode(0x1d, down);
-		handle_scancode(0x45, down);
+	  handle_scancode_generic(0xe1, 1, kbd_num);
+	  handle_scancode_generic(0x1d, down, kbd_num);
+	  handle_scancode_generic(0x45, down, kbd_num);
 		return 0;
 	} 
 
 	if (keycode == KEY_SYSRQ && x86_sysrq_alt) {
-		handle_scancode(0x54, down);
+	  handle_scancode_generic(0xe0, 1, kbd_num);
 
 		return 0;
 	}
@@ -131,15 +135,16 @@
 #endif
 
 	if (x86_keycodes[keycode] & 0x100)
-		handle_scancode(0xe0, 1);
+		handle_scancode_generic(0xe0, 1, kbd_num);
 
-	handle_scancode(x86_keycodes[keycode] & 0x7f, down);
+	handle_scancode_generic(x86_keycodes[keycode] & 0x7f, down, kbd_num);
 
 	if (keycode == KEY_SYSRQ) {
-		handle_scancode(0xe0, 1);
-		handle_scancode(0x37, down);
+	  handle_scancode_generic(0xe0, 1, kbd_num);
+	  handle_scancode_generic(0x37, down, kbd_num);
 	}
 
+	
 	if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
 		x86_sysrq_alt = down;
 #ifdef CONFIG_SPARC64
@@ -171,7 +176,7 @@
 {
 	if (type != EV_KEY) return;
 
-	if (emulate_raw(code, down))
+	if (emulate_raw(code, down, usbkbd_map[handle->dev->number]))
 		printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", code);
 
 	tasklet_schedule(&keyboard_tasklet);
@@ -208,7 +213,14 @@
 
 static void keybdev_disconnect(struct input_handle *handle)
 {
-//	printk(KERN_INFO "keybdev.c: Removing keyboard: input%d\n", handle->dev->number);
+  //	printk(KERN_INFO "keybdev.c: Removing keyboard: input%d\n", handle->dev->number);
+
+
+  if(usbkbd_map[handle->dev->number] > 0 ){
+    zg_head_ismaped[usbkbd_map[handle->dev->number]]=0;
+    printk("ZG: Removing keyboard from head %d\n", usbkbd_map[handle->dev->number] );
+  }
+  
 	input_close_device(handle);
 	kfree(handle);
 }
diff -u -r -b -B linux-2.4.20.orig/drivers/usb/hid-core.c linux-2.4.20/drivers/usb/hid-core.c
--- linux-2.4.20.orig/drivers/usb/hid-core.c	2003-04-06 21:22:05 +0300
+++ linux-2.4.20/drivers/usb/hid-core.c	2003-04-06 21:54:13 +0300
@@ -1245,6 +1245,9 @@
 	return hid;
 }
 
+extern int usbkbd_map[];
+extern int zg_head_ismaped[];
+
 static void* hid_probe(struct usb_device *dev, unsigned int ifnum,
 		       const struct usb_device_id *id)
 {
@@ -1264,6 +1267,23 @@
 		hid->claimed |= HID_CLAIMED_INPUT;
 	if (!hiddev_connect(hid))
 		hid->claimed |= HID_CLAIMED_HIDDEV;
+
+	//ZG:  We only accepted USB Keyboards
+	for(i = 0; i < hid->maxapplication; i++)
+	  if((hid->application[i] & 0xffff) < ARRAY_SIZE(hid_types)){
+	    if((hid->application[i] & 0xffff) == 6){ 
+	      int j;
+	      for(j=1;j<3;j++){
+		if(zg_head_ismaped[j]==0){
+		  zg_head_ismaped[j]=1;
+		  usbkbd_map[  hid->input.number ] = j;
+		  printk("Connect keyboard input%d to ZG head %d\n", hid->input.number, j);
+		  break;
+		}
+	      }
+	    }
+	  }
+	
 	printk(KERN_INFO);
 
 	if (hid->claimed & HID_CLAIMED_INPUT)
diff -u -r -b -B linux-2.4.20.orig/drivers/usb/usbkbd.c linux-2.4.20/drivers/usb/usbkbd.c
--- linux-2.4.20.orig/drivers/usb/usbkbd.c	2002-11-29 01:53:15 +0200
+++ linux-2.4.20/drivers/usb/usbkbd.c	2003-09-06 18:31:34 +0300
@@ -170,6 +170,9 @@
 		usb_unlink_urb(&kbd->irq);
 }
 
+extern int usbkbd_map[];                                                              
+extern int zg_head_ismaped[];                                                         
+
 static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum,
 			   const struct usb_device_id *id)
 {
@@ -253,6 +256,17 @@
 	printk(KERN_INFO "input%d: %s on usb%d:%d.%d\n",
 		 kbd->dev.number, kbd->name, dev->bus->busnum, dev->devnum, ifnum);
 
+//	int j;                                                                  
+	for(i=1;i<8;i++){                                                       
+//		printk(KERN_INFO "ZG:usbkbd.c kbd->dev.number=%X\n", kbd->dev.number);
+		if(zg_head_ismaped[i]==0){                                            
+			zg_head_ismaped[i]=1;                                               
+			usbkbd_map[ kbd->dev.number ] = i;                               
+			printk("Connect keyboard input%d to ZG head %d\n", kbd->dev.number, i);
+			break;                                                              
+		}                                                                     
+	}
+
 	return kbd;
 }
 
diff -u -r -b -B linux-2.4.20.orig/include/linux/kbd_ll.h linux-2.4.20/include/linux/kbd_ll.h
--- linux-2.4.20.orig/include/linux/kbd_ll.h	1999-04-26 23:22:33 +0300
+++ linux-2.4.20/include/linux/kbd_ll.h	2003-04-06 21:54:16 +0300
@@ -8,5 +8,6 @@
 extern struct pt_regs *kbd_pt_regs;
 
 void handle_scancode(unsigned char scancode, int down);
+void handle_scancode_generic(unsigned char scancode, int down, int kbd_num);
 
 #endif	/* _KBD_LL_H */
