Exemple #1
0
void init_kbd()
{
    mode = 0;
    leds = 2;
    setleds();
    dmesg("Init keyboard driver completed!");
}
Exemple #2
0
/*
 * Toggle all of the LED's on and off, just for show.
 */
void
blinkleds(struct akbd_softc *sc)
{
	u_char origleds;

	origleds = getleds(sc->adbaddr);
	setleds(sc, LED_NUMLOCK | LED_CAPSLOCK | LED_SCROLL_LOCK);
	delay(400000);
	setleds(sc, origleds);

	if (origleds & LED_NUMLOCK)
		sc->sc_leds |= WSKBD_LED_NUM;
	if (origleds & LED_CAPSLOCK)
		sc->sc_leds |= WSKBD_LED_CAPS;
	if (origleds & LED_SCROLL_LOCK)
		sc->sc_leds |= WSKBD_LED_SCROLL;
}
Exemple #3
0
//按下caps
void caps(u8 scancode)
{
    if (!(mode & 0x80)) {
        leds ^= 0x4;
        mode ^= 0x40;
        mode |= 0x80;
        setleds();
    }
    return;
}
Exemple #4
0
static int cfe_console_setup(struct console *cons, char *str)
{
	char consdev[32];
	/* XXXKW think about interaction with 'console=' cmdline arg */
	/* If none of the console options are configured, the build will break. */
	if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) {
#ifdef CONFIG_SIBYTE_SB1250_DUART
		if (!strcmp(consdev, "uart0")) {
			setleds("u0cn");
		} else if (!strcmp(consdev, "uart1")) {
			setleds("u1cn");
#endif
#ifdef CONFIG_VGA_CONSOLE
		} else if (!strcmp(consdev, "pcconsole0")) {
			setleds("pccn");
#endif
		} else
			return -ENODEV;
	}
	return 0;
}
Exemple #5
0
void keyboard_enable()
{
    int i = 0;
    asm_disable_interrupt();
#ifdef _USE_GAZ
    /* This is for debugging purposes. */
    set_vector(keyb_ISR, M_VEC+1, D_PRESENT + D_INT + D_DPL3, KERNEL_CS);
    enable_irq(1);
#else /* Default - use OX driver logic. */
    printk("initializing Keyboard driver version 1.0\n");
    interrupt_install_handler(1,
                              IRQ_EXCL,
                              keyboard_handler,
                              keyboard_info);
    printk("done initializing Keyboard driver version 1.0\n");
    /* irq_enable(1); */
    enable_irq(1);
#endif
    led_status = 0; /* All leds off */
    setleds();
}
Exemple #6
0
void
akbd_set_leds(void *v, int on)
{
#ifdef notyet
	struct akbd_softc *sc = v;
	int leds;

	if (sc->sc_extended) {
		if (sc->sc_leds == on)
			return;

		leds = 0;
		if (on & WSKBD_LED_NUM)
			leds |= LED_NUMLOCK;
		if (on & WSKBD_LED_CAPS)
			leds |= LED_CAPSLOCK;
		if (on & WSKBD_LED_SCROLL)
			leds |= LED_SCROLL_LOCK;

		setleds(sc, leds);
	}
#endif
}
Exemple #7
0
// 
// keyboard_handler:
//
// This is the main handler, changed to use our io code.
// It should work, there is a trap to halt the cpu if
// ctrl+alt+del is hit.
//
irq_stat_t keyboard_handler(int irq)
{
	unsigned int key = io_inb(0x60);
	unsigned int key_ascii = 0;
	
#ifdef _DEBUG
    printk(" keyboard_handler := file %s line %d\n",__FILE__,__LINE__);
#endif
    // Control+ALT+DEL
	if((control_keys & (CK_CTRL+CK_ALT)) && key==0x53)
	{
		while(io_inb(0x64) & 2);
		io_outb(0x64, 0xFE);
		asm ("cli;hlt");
	}		
	
	/* 'LED Keys', ie, Scroll lock, Num lock, and Caps lock */
	if(key == 0x3A)	/* Caps Lock */
	{
		led_status ^= LED_CAPS_LOCK;
		setleds();
	}
	if(key == 0x45)	/* Num Lock */
	{
		led_status ^= LED_NUM_LOCK;
		setleds();
	}
	if(key == 0x46) /* Scroll Lock */
	{
		led_status ^= LED_SCROLL_LOCK;
		setleds();
	}


	if(key == 0x1D && !(control_keys & CK_CTRL))	/* Ctrl key */
		control_keys |= CK_CTRL;
	if(key == 0x80 + 0x1D)	/* Ctrl key depressed */
		control_keys &= (0xFF - CK_CTRL);
	if((key == 0x2A || key == 0x36) && !(control_keys & CK_SHIFT))	/* Shift key */
		control_keys |= CK_SHIFT;
	if((key == 0x80 + 0x2A) || (key == 0x80 + 0x36))	/* Shift key depressed */
		control_keys &= (0xFF - CK_SHIFT);
	if(key == 0x38 && (!(control_keys & CK_ALT)))
		control_keys |= CK_ALT;
	if(key == 0x80 + 0x38)
		control_keys &= (0xFF - CK_ALT);
		
	if((control_keys & CK_SHIFT) && (led_status & LED_CAPS_LOCK)) key_ascii = scan2ascii_table[key][6]; 
	else if(control_keys & CK_SHIFT) key_ascii = scan2ascii_table[key][1];
	else if(control_keys & CK_CTRL) key_ascii = scan2ascii_table[key][2];
	else if(control_keys & CK_ALT) key_ascii = scan2ascii_table[key][3];	
	else if((control_keys & CK_SHIFT) && (led_status & LED_NUM_LOCK)) key_ascii = scan2ascii_table[key][7];
	else if(led_status & LED_CAPS_LOCK) key_ascii = scan2ascii_table[key][5];
	else if(led_status & LED_NUM_LOCK) key_ascii = scan2ascii_table[key][4];
	else if(control_keys == 0) key_ascii = scan2ascii_table[key][0];

	if(key_ascii != 0)
	{
        if(key_ascii >= 0 && key_ascii <= 0xFF) {
		    keyboard_buffer[keyboard_buffer_size] = key_ascii;
		    keyboard_buffer_size++;
        }
#if 0
        // The following looks like code to handle multi-byte
        // input but this doesn't work with keyboard_getch() below
        // which only returns one byte at a time.
		if(key_ascii <= 0xFF)
		{
			keyboard_buffer[keyboard_buffer_size] = key_ascii;
			keyboard_buffer_size++;
		}
		else
		{
			keyboard_buffer[keyboard_buffer_size] = (key_ascii & 0xFF);
			keyboard_buffer[keyboard_buffer_size+1] = (key_ascii & 0xFF00);
			keyboard_buffer_size += 2;
		}
#endif
	}

#ifdef _DEBUG
    printk(" keyboard_handler := file %s line %d\n",__FILE__,__LINE__);
#endif
	io_outb(MASTER_PIC, EOI);
#ifdef _DEBUG
    printk(" keyboard_handler := file %s line %d\n",__FILE__,__LINE__);
#endif
    return IRQ_ENABLE;
}
Exemple #8
0
char cmpbuf(struct htx_data *ps, struct ruleinfo *pr, int loop,
            int *blkno, char wbuf[], char rbuf[])
{
  int           c, mis_flag = FALSE;
  char          s[3], ctime[9], path[128];
  char          work_str[512], msg1[MAX_TEXT_MSG];
  static int    cnt_flag = FALSE;
  register long i, j;
  static ushort cnt = 0, m2f2_cnt = 0;
  static struct {
     int     start_lba;
     int     offset;
     time_t  dtime;
     char    cpath[128];
     char    rpath[128];
  } m2f2[M2F2_MISCOM_THRESH];

  i = 0;
  while ( (mis_flag == FALSE) && (i < pr->dlen) ) {
     if ( wbuf[i] != rbuf[i] ) {
        if ( crash_on_mis && ( strcmp(pr->mode, "M2F2") != 0 ) ) {
		#ifndef __HTX_LINUX__  /* AIX */
	   		setleds( 0x2010 );
        		trap(0xBEEFDEAD, wbuf, rbuf, i, ps, pr);
	   	#else
                        do_trap_htx64( 0xBEEFDEAD, wbuf, rbuf, i, ps, pr );
	   	#endif
	   }
           /* crash_sys(0xBEEFDEAD, wbuf, rbuf, i, ps->sdev_id); */
        mis_flag = TRUE;
     } else
        i++;
  }

  if ( mis_flag == TRUE ) {
      ps->bad_others = ps->bad_others + 1;
      sprintf(msg1, "Miscompare at buffer offset %d (0x%x)  "
                    "\ncbuf (baseaddr 0x%x) ", i, i, wbuf);
      for ( j = i; ((j - i) < 20) && (j < pr->dlen); j++ ) {
          sprintf(s, "%0.2x", wbuf[j]);
          strcat(msg1, s);
      }
      sprintf(work_str, "\nrbuf (baseaddr 0x%x) ",rbuf);
      strcat(msg1, work_str);
      for ( j = i; ((j - i) < 20) && (j < pr->dlen); j++ ) {
          sprintf(s, "%0.2x", rbuf[j]);
          strcat(msg1, s);
      }
      strcat(msg1, "\n");
      if ( strcmp(pr->mode, "M2F2") != 0 ) {
          cnt++;
          if ( cnt < 10 ) {
             strcpy(path, DUMP_PATH);
             strcat(path, "htx");
             strcat(path, &(ps->sdev_id[5]));
             strcat(path, ".cbuf");
             sprintf(work_str, "%-d", cnt);
             strcat(path, work_str);
             hxfsbuf(wbuf, pr->dlen, path, ps);
             sprintf(work_str, "Compare buffer saved in %s\n", path);
             strcat(msg1, work_str);
             strcpy(path, DUMP_PATH);
             strcat(path, "htx");
             strcat(path, &(ps->sdev_id[5]));
             strcat(path, ".rbuf");
             sprintf(work_str, "%-d", cnt);
             strcat(path, work_str);
             hxfsbuf(rbuf, pr->dlen, path, ps);
             sprintf(work_str, "Read buffer saved in %s\n", path);
             strcat(msg1, work_str);
          } else {
             sprintf(work_str, "The maximum number of saved miscompare "
                               "buffers (10) have already\n been saved "
                               "The compare and read buffers for this "
                               "miscompare will\nnot be saved to disk");
             strcat(msg1, work_str);
          }
          /* prt_msg_asis(ps, pr, loop, blkno, 100, HARD, msg1); */
          prt_msg_asis(ps, pr, loop, blkno, 100, HTX_HE_MISCOMPARE, msg1);
          return(1);
      } else {
          if ( cnt_flag == TRUE ) {
             if ( m2f2_cnt == 1 ) {
                for ( c = 0; c < (M2F2_MISCOM_THRESH - 1); c++ ) {
                   unlink(m2f2[c].cpath);
                   unlink(m2f2[c].rpath);
                }
                rename(m2f2[2].cpath, m2f2[0].cpath);
                rename(m2f2[2].rpath, m2f2[0].rpath);
                m2f2[0].start_lba = m2f2[2].start_lba;
                m2f2[0].offset    = m2f2[2].offset;
                m2f2[0].dtime     = m2f2[2].dtime;
             } else {
                for ( c = 0; c < (M2F2_MISCOM_THRESH - 1); c++ ) {
                   unlink(m2f2[c].cpath);
                   unlink(m2f2[c].rpath);
                   rename(m2f2[c+1].cpath, m2f2[c].cpath);
                   rename(m2f2[c+1].rpath, m2f2[c].rpath);
                   m2f2[c].start_lba = m2f2[c+1].start_lba;
                   m2f2[c].offset    = m2f2[c+1].offset;
                   m2f2[c].dtime     = m2f2[c+1].dtime;
                }
             }
             cnt_flag = FALSE;
          }
          m2f2[m2f2_cnt].start_lba = blkno[0];
          m2f2[m2f2_cnt].offset = i;
          (void) time(&m2f2[m2f2_cnt].dtime);
          m2f2_cnt++;
          strcpy(path, DUMP_PATH);
          strcat(path, "m2f2");
          strcat(path, &(ps->sdev_id[5]));
          strcat(path, ".cbuf");
          sprintf(work_str, "%-d", m2f2_cnt);
          strcat(path, work_str);
          strcpy(m2f2[m2f2_cnt-1].cpath, path);
          hxfsbuf(wbuf, pr->dlen, path, ps);
          sprintf(work_str, "M2F2 Compare buffer saved in %s\n", path);
          strcat(msg1, work_str);
          strcpy(path, DUMP_PATH);
          strcat(path, "m2f2");
          strcat(path, &(ps->sdev_id[5]));
          strcat(path, ".rbuf");
          sprintf(work_str, "%-d", m2f2_cnt);
          strcat(path, work_str);
          strcpy(m2f2[m2f2_cnt-1].rpath, path);
          hxfsbuf(rbuf, pr->dlen, path, ps);
          sprintf(work_str, "M2F2 Read buffer saved in %s\n", path);
          strcat(msg1, work_str);
          if ( m2f2_cnt < M2F2_MISCOM_THRESH ) {
             strcat(msg1,"\n NOTE: The above miscompare is reported as a SOFT error because \n 3 miscompares are allowed in one hour for M2F2 data. \n We trap to kdb / xmon if the number of miscompares exceeds 3 in one hour.");
             prt_msg_asis(ps, pr, loop, blkno, 4, SOFT, msg1);
             return(0);
          } else {
             if ( m2f2[2].dtime > (m2f2[0].dtime + 3600) ) {
                if ( m2f2[2].dtime > (m2f2[1].dtime + 3600) )
                   m2f2_cnt = 1;
                else
                   m2f2_cnt--;
                cnt_flag = TRUE;
                prt_msg_asis(ps, pr, loop, blkno, 0, SOFT, msg1);
                return(0);
            } else {

				if ( crash_on_mis ) {
				#ifndef __HTX_LINUX__  /* AIX */
					setleds( 0x2010 );
						trap(0xBEEFDEAD, wbuf, rbuf, i, ps, pr);
				#else
								do_trap_htx64( 0xBEEFDEAD, wbuf, rbuf, i, ps, pr );
				#endif
			   }

                sprintf(work_str, "There have been %d M2F2 miscompares in"
                                  " the past HOUR!\n", M2F2_MISCOM_THRESH);
                strcat(msg1, work_str);
                strftime(&ctime, 9, "%T", localtime(&m2f2[0].dtime));
                sprintf(work_str, "Start LBA = %d  Offset = %d  Time = %s\n",
                        m2f2[0].start_lba, m2f2[0].offset, ctime);
                strcat(msg1, work_str);
                strftime(&ctime, 9, "%T", localtime(&m2f2[1].dtime));
                sprintf(work_str, "Start LBA = %d  Offset = %d  Time = %s\n",
                        m2f2[1].start_lba, m2f2[1].offset, ctime);
                strcat(msg1, work_str);
                strftime(&ctime, 9, "%T", localtime(&m2f2[2].dtime));
                sprintf(work_str, "Start LBA = %d  Offset = %d  Time = %s\n",
                        m2f2[2].start_lba, m2f2[2].offset, ctime);
                strcat(msg1, work_str);
                m2f2_cnt--;
                cnt_flag = TRUE;
                /* prt_msg_asis(ps, pr, loop, blkno, 100, HARD, msg1); */
                prt_msg_asis(ps, pr, loop, blkno, 100, HTX_HE_MISCOMPARE, msg1);
                return(-1);
            }
          }
      }
  }
  return(0);
}
Exemple #9
0
void num(u8 scancode)
{
    leds ^= 0x2;
    setleds();
    return;
}
Exemple #10
0
//取消scroll
void scroll(u8 scancode)
{
    leds ^= 0x1;
    setleds();
    return;
}