?? pcconsolepep.c
字號:
/* pcConsolePep.c - Compaq DeskPro 386 console handler *//* Copyright 2002 Kontron Modular Computers GmbH *//* Copyright 1993-2001 Wind River System, Inc. */#include "copyright_wrs.h"/*modification history--------------------01f,26feb03,gko new function call to avoid typematic error by USB keyboard, because of a too low priority of the interrupt task of UHCI.01e,01aug02,phd support for USB keyboard added 01d,06dec01,jlb added option to send scan codes and set LEDs01c,11jun96,wlf doc: cleanup.01b,14jun95,hdn removed function declarations defined in sysLib.h.01a,09sep93,vin created.*//*DESCRIPTIONThis file is used to link the keyboard driver and the vga driver.USER CALLABLE ROUTINESMost of the routines in this driver are accessible only through the I/Osystem. Two routines, however, must be called directly: pcConDrv() toinitialize the driver, and pcConDevCreate() to create devices.Before using the driver, it must be initialized by calling pcConDrv ()This routine should be called exactly once, before any reads, writes, orcalls to pcConDevCreate(). Normally, it is called from usrRoot() in usrConfig.c.Before a console can be used, it must be created using pcConDevCreate().IOCTL FUNCTIONSThis driver responds to the same ioctl codes as a normal ty driver.SEE ALSO: tyLibNOTESThe macro N_VIRTUAL_CONSOLES should be defined in config.h file.The macro UHCI_INT_PRIORITY for USB keyboard should also be defined inconfig.h file.*//* includes */#include "vxWorks.h"#include "iv.h"#include "ioLib.h"#include "iosLib.h"#include "memLib.h"#include "tyLib.h"#include "intLib.h"#include "errnoLib.h"#include "config.h"#include "drv/serial/pcConsolePep.h"#include "versionPep.h"#if (PC_KBD_TYPE == USB_KBD)#include "drv/usb/usbKeyboardTyPep.h"#include "drv/usb/usbUhciHostPep.h"#endif/* defines */PEP_VERSION(pcConsolePep_c,01f) /* version identifier *//* globals */PC_CON_DEV pcConDv [N_VIRTUAL_CONSOLES] ; /* device descriptors *//* locals */LOCAL int pcConDrvNum; /* driver number assigned to this driver */#if (PC_KBD_TYPE == USB_KBD)TY_DEV_ID pUsbKeyboardTyDev = /* console descriptor */ (&(pcConDv [PC_CONSOLE].tyDev));#endif/* forward declarations */LOCAL int pcConDrvOpen ();LOCAL STATUS pcConDrvIoctl (PC_CON_DEV * pPcCoDv, int request, int arg);LOCAL void pcConDrvHrdInit ();/******************************************************************************** pcConDrv - initialize the console driver ** This routine initializes the console driver, sets up interrupt vectors,* and performs hardware initialization of the keybord and display.** RETURNS: OK, or ERROR if the driver cannot be installed.*/STATUS pcConDrv (void) { /* check if driver already installed */ if (pcConDrvNum > 0) return (OK); pcConDrvHrdInit (); pcConDrvNum = iosDrvInstall (pcConDrvOpen, (FUNCPTR) NULL, pcConDrvOpen, (FUNCPTR) NULL, tyRead, tyWrite, pcConDrvIoctl ); return (pcConDrvNum == ERROR ? ERROR : OK); }/******************************************************************************** pcConDevCreate - create a device for the on-board ports** This routine creates a device on one of the pcConsole ports. Each port* to be used should have only one device associated with it, by calling* this routine.** RETURNS: OK, or ERROR if there is no driver or one already exists for the* specified port.*/STATUS pcConDevCreate ( char * name, /* name to use for this device */ FAST int channel, /* virtual console number */ int rdBufSize, /* read buffer size, in bytes */ int wrtBufSize /* write buffer size in bytes */ ) { FAST PC_CON_DEV *pPcCoDv; if (pcConDrvNum <= 0) { errnoSet (S_ioLib_NO_DRIVER); return (ERROR); } /* if this device already exists, don't create it */ if (channel < 0 || channel >= N_VIRTUAL_CONSOLES) return (ERROR); pPcCoDv = &pcConDv [channel]; if (pPcCoDv->created) return (ERROR); if (tyDevInit (&pPcCoDv->tyDev, rdBufSize, wrtBufSize, vgaWriteString) != OK) { return (ERROR); } #if (PC_KBD_TYPE != USB_KBD) /* enable the keybord interrupt */ sysIntEnablePIC (KBD_INT_LVL);#endif /* mark the device as created, and add the device to the I/O system */ pPcCoDv->created = TRUE; return (iosDevAdd (&pPcCoDv->tyDev.devHdr, name, pcConDrvNum)); }/******************************************************************************** pcConDrvHrdInit - initialize the Keyboard and VGA*/LOCAL void pcConDrvHrdInit (void) { FAST int oldlevel; /* to hold the oldlevel of interrupt */ oldlevel= intLock (); /* Keyboard initialization */#if (PC_KBD_TYPE == USB_KBD) pcConDv[PC_CONSOLE].ks->kbdHook = usbKeyboardTyHook; usbUhciHostInit (); usbKeyboardTyInit (); usbChangeUhciIntPriority( UHCI_INT_PRIORITY ); /* new, due to typematic problem */#else kbdHrdInit ();#endif /* (VGA) Display initialization */ vgaHrdInit (); /* interrupt is masked out: the keyboard interrupt will be enabled * in the pcConDevCreate */ intUnlock (oldlevel); } /********************************************************************************* pcConDrvOpen - open file to Console**/LOCAL int pcConDrvOpen ( PC_CON_DEV * pPcCoDv, char * name, int mode ) { return ((int) pPcCoDv); }/********************************************************************************* pcConDrvIoctl - special device control** This routine handles FIOGETOPT requests and passes all others to tyIoctl.** RETURNS: OK or ERROR if invalid baud rate, or whatever tyIoctl returns.*/LOCAL STATUS pcConDrvIoctl ( PC_CON_DEV * pPcCoDv, /* device to control */ int request, /* request code */ int arg /* some argument */ ) { int status = OK; switch (request) { case CONIOSETATRB: pPcCoDv->vs->curAttrib = arg ; break; case CONIOGETATRB: status = pPcCoDv->vs->curAttrib; break;#if (PC_KBD_TYPE != USB_KBD) case CONIOSETKBD: if (arg == 0 || arg == 1) pPcCoDv->ks->kbdMode = arg; else status = ERROR; break;#endif case CONIOSCREENREV: pPcCoDv->vs->rev = (pPcCoDv->vs->rev) ? FALSE : TRUE; pPcCoDv->vs->vgaHook (pPcCoDv->vs, arg, 0); /* reverse screen */ break; case CONIOBEEP: pPcCoDv->vs->vgaHook (pPcCoDv->vs, arg, 1); /* produce beep */ break; case CONIOCURSORON: pPcCoDv->vs->vgaHook (pPcCoDv->vs, arg, 2); /* vgaCursor on */ break; case CONIOCURSOROFF: pPcCoDv->vs->vgaHook (pPcCoDv->vs, arg, 3); /* vgaCursor off */ break; case CONIOCURSORMOVE: pPcCoDv->vs->vgaHook (pPcCoDv->vs, arg, 4); /* position cursor */ break; #if (PC_KBD_TYPE != USB_KBD) case CONIOCURCONSOLE: /* change current console */ if ((arg >= 0) && (arg < N_VIRTUAL_CONSOLES)) pPcCoDv->ks->currCon = arg; break;#endif case CONIOCONVERTSCAN: /* send scan codes or ASCII */ pPcCoDv->ks->convertChar = arg; break; case CONIOLEDS: /* change LEDs */ pPcCoDv->ks->kbdFlags &= ~7; pPcCoDv->ks->kbdFlags |= (arg & 7); pPcCoDv->ks->kbdHook (1); break; default: status = tyIoctl (&pPcCoDv->tyDev, request, arg); break; } return (status); }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -