📄 i8042kbdpep.c
字号:
/* i8042KbdPep.c - Intel 8042 keyboard driver routines *//* Copyright 2002 Kontron Modular Computers GmbH *//* Copyright 1993-2001 Wind River System, Inc. */#include "copyright_wrs.h"/*modification history--------------------01g,01aug02,phd support for german keyboard layout added01f,06dec01,jlb added option to send scan codes and set LEDs01e,11jun96,wlf doc: cleanup.01d,14jun95,hdn removed function declarations defined in sysLib.h.01c,27oct94,hdn rewritten the interface to the keyboard with WDOG.01b,05may94,hdn fixed a bug in kbdLedSet() by checking ACK in kbdIntr(). removed RESET command in kbdHrdInit() because ROMBIOS does it.01a,20oct93,vin created*//*DESCRIPTIONThis is the driver for the Intel 8042 Keyboard Controller Chip used on a personal computer 386 / 486. This driver handles the standard 101 key board.This driver does not change the defaults set by the BIOS. The BIOS initializesthe scan code set to 1 which make the PS/2 keyboard compatabile with the PCand PC XT keyboard. USER CALLABLE ROUTINESThe routines in this driver are accessed from external modulesthrough the hook routine, the pointer to which is initializedin the KBD_CON_DEV structure at the time of initialization.This makes the access to these routines more generic without declaringthese functions as external. The routines in this driver which are accessed from an external moduleare kbdIntr() and kbdHrdInit(). kbdIntr() is installed as an interruptservice routine through the intConnect call in sysHwInit2(). kbdHrdInit() is called to initialize the device descriptors and the key board. The kbdIntr() is the interrupt handler which handles the key board interruptand is responsible for the handing the character received to whicheverconsole the kbdDv.currCon is initialized to. By default this is initializedto PC_CONSOLE. If the user has to change the current console he will haveto make an ioctl call with the option CONIOCURCONSOLE and the argument as the console number which he wants to change to. To return to the consoleowned by the shell the user has to do an ioctl call back to the console numberowned the shell from his application. Before using the driver, it must be initialized by calling kbdHrdInit(). This routine should be called exactly once. Normally, it is called from a generic driver for eg. from tyCoDrv() which is called before tyCoDevCreate.SEE ALSOconLibNOTESThe following macros should be defined in <target>.h fileCOMMAND_8042, DATA_8042,STATUS_8042. These refer to the io base addressesof the various key board controller registers. The macros N_VIRTUAL_CONSOLESand PC_CONSOLE should be defined in config.h file.*//* includes */#include "vxWorks.h"#include "iv.h"#include "ioLib.h"#include "iosLib.h"#include "memLib.h"#include "tyLib.h"#include "errnoLib.h"#include "wdLib.h"#include "config.h"#include "versionPep.h"#include "drv/serial/pcConsolePep.h"/* defines */PEP_VERSION(i8042KbdPep_c,01g) /* version identifier *//* externals */IMPORT PC_CON_DEV pcConDv [N_VIRTUAL_CONSOLES] ;/* globals */int kbdIntCnt = 0;int kbdTimeoutCnt = 0;BOOL kbdTimeout = FALSE;/* locals */LOCAL WDOG_ID kbdWdid;LOCAL int kbdWdsec = 2;LOCAL KBD_CON_DEV kbdConDv; /* key board device descriptor */LOCAL UCHAR oldLedStat = 0;LOCAL BOOL kbdAcknowledge = FALSE;LOCAL unsigned char enhancedKeys[] = /* 16 extended keys */ { 0x1c, /* keypad enter */ 0x1d, /* right control */ 0x35, /* keypad slash */ 0x37, /* print screen */ 0x38, /* right alt */ 0x46, /* break (control-pause) */ 0x47, /* editpad home */ 0x48, /* editpad up */ 0x49, /* editpad pgup */ 0x4b, /* editpad left */ 0x4d, /* editpad right */ 0x4f, /* editpad end */ 0x50, /* editpad dn */ 0x51, /* editpad pgdn */ 0x52, /* editpad ins */ 0x53 /* editpad del */ };/* action table*/LOCAL UCHAR action [144] = { /* Action table for scanCode */ 0, AS, AS, AS, AS, AS, AS, AS, /* scan 0- 7 */ AS, AS, AS, AS, AS, AS, AS, AS, /* scan 8- F */ AS, AS, AS, AS, AS, AS, AS, AS, /* scan 10-17 */ AS, AS, AS, AS, AS, CN, AS, AS, /* scan 18-1F */ AS, AS, AS, AS, AS, AS, AS, AS, /* scan 20-27 */ AS, AS, SH, AS, AS, AS, AS, AS, /* scan 28-2F */ AS, AS, AS, AS, AS, AS, SH, AS, /* scan 30-37 */ AS, AS, CP, 0, 0, 0, 0, 0, /* scan 38-3F */ 0, 0, 0, 0, 0, NM, ST, ES, /* scan 40-47 */ ES, ES, ES, ES, ES, ES, ES, ES, /* scan 48-4F */ ES, ES, ES, ES, 0, 0, 0, 0, /* scan 50-57 */ 0, 0, 0, 0, 0, 0, 0, 0, /* scan 58-5F */ 0, 0, 0, 0, 0, 0, 0, 0, /* scan 60-67 */ 0, 0, 0, 0, 0, 0, 0, 0, /* scan 68-6F */ AS, 0, 0, AS, 0, 0, AS, 0, /* scan 70-77 */ 0, AS, 0, 0, 0, AS, 0, 0, /* scan 78-7F */ AS, CN, AS, AS, AGR, ST, EX, EX, /* enhanced */ AS, EX, EX, AS, EX, AS, EX, EX /* enhanced */ };/* key board Maps Japanese, english and german */LOCAL UCHAR keyMap [3][5][144] = { { /* Japanese Enhanced keyboard */ { /* unshift code */ 0, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 0- 7 */ '7', '8', '9', '0', '-', '^', 0x08, '\t', /* scan 8- F */ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', /* scan 10-17 */ 'o', 'p', '@', '[', '\r', CN, 'a', 's', /* scan 18-1F */ 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* scan 20-27 */ ':', 0, SH, ']', 'z', 'x', 'c', 'v', /* scan 28-2F */ 'b', 'n', 'm', ',', '.', '/', SH, '*', /* scan 30-37 */ ' ', ' ', CP, 0, 0, 0, 0, 0, /* scan 38-3F */ 0, 0, 0, 0, 0, NM, ST, '7', /* scan 40-47 */ '8', '9', '-', '4', '5', '6', '+', '1', /* scan 48-4F */ '2', '3', '0', '.', 0, 0, 0, 0, /* scan 50-57 */ 0, 0, 0, 0, 0, 0, 0, 0, /* scan 58-5F */ 0, 0, 0, 0, 0, 0, 0, 0, /* scan 60-67 */ 0, 0, 0, 0, 0, 0, 0, 0, /* scan 68-6F */ ' ', 0, 0, '\\', 0, 0, ' ', 0, /* scan 70-77 */ 0, ' ', 0, 0, 0, '\\', 0, 0, /* scan 78-7F */ '\r', CN, '/', '*', ' ', ST, 'F', 'A', /* extended */ 0, 'D', 'C', 0, 'B', 0, '@', 'P' /* extended */ }, { /* shift code */ 0, 0x1b, '!', '"', '#', '$', '%', '&', /* scan 0- 7 */ '\'', '(', ')', 0, '=', '~', 0x08, '\t', /* scan 8- F */ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', /* scan 10-17 */ 'O', 'P', '`', '{', '\r', CN, 'A', 'S', /* scan 18-1F */ 'D', 'F', 'G', 'H', 'J', 'K', 'L', '+', /* scan 20-27 */ '*', 0, SH, '}', 'Z', 'X', 'C', 'V', /* scan 28-2F */ 'B', 'N', 'M', '<', '>', '?', SH, '*', /* scan 30-37 */ ' ', ' ', CP, 0, 0, 0, 0, 0, /* scan 38-3F */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -