Drivers


KwikPeg includes a variety of device drivers for use with video controllers and input devices. Device drivers are described in the PEG Programming Manual which you can view in Acrobat PDF format.  Programming Manual

Screen Drivers
Keyboard Drivers
Mouse and Touch Panel Drivers
Low Level I/O Support


 Screen Drivers

KwikPeg is designed to be independent of the target system video display channel. KwikPeg can be used with display devices supporting any combination of pixel resolutions and color depths. KwikPeg includes a variety of video device drivers for use with video controllers which support any of the common video interfaces including LCD, HGA, CGA, VGA and SVGA devices.

KwikPeg is delivered with a wide range of video device drivers, also called screen drivers, ready for your use. The source code for each screen driver is located in the standard PEG installation directory PEG\SOURCE\SCRNDRV. Header files are in directory PEG\INCLUDE\SCRNDRV.

All KwikPeg screen drivers can draw lines, write text and transfer bitmap information into the video memory frame buffer. In fact, the software algorithms required to draw any KwikPeg object are provided with every KwikPeg screen driver.

It is unreasonable to expect KwikPeg to provide optimized video driver software for every high end video controller available. In fact, it is highly probable that a custom video device driver will be required to get best performance from a high end video controller. The key words are optimized and high end. KwikPeg strives to provide the best video performance possible by providing fully tuned and optimized driver templates for each video controller class.

There are a growing number of KwikPeg screen drivers for specific video controllers. Each screen driver is ready for use on the target hardware platform on which it was tested by Swell Software, Inc. A partial list of currently available screen drivers is presented in the following table.

  Source/Header Video Controller
VGASCRN.CPP,HPP DOS compatible 4-bpp VGA Controller
SVGASCRN.CPP,HPP DOS compatible 8-bpp SVGA Controller
SVGASCR8.CPP,HPP PC compatible 8-bpp SVGA Controller
(for 32-bit protected mode use)
8106SCRN.CPP,HPP EPSON SED8106 8-bpp VGA LCD/CRT Controller
1353SCR4.CPP,HPP EPSON SED1330 and SED1353 4-bpp LCD Controllers
1354SCRN.CPP,HPP EPSON SED1354 8-bpp LCD/CRT Controller
1355SCRN.CPP,HPP EPSON SED1355 8-bpp LCD/CRT Controller
1356SCRN.CPP,HPP EPSON SED1356 8-bpp LCD/CRT/TV Controller
CL54XPCI.CPP,HPP Cirrus Logic GD5430 8-bpp PCI Controller
CT545_4.CPP,HPP
CT545_8.CPP,HPP
Chips & Technology 65535 and 65545 Controllers
LH77MONO.CPP,HPP
LH77GRAY.CPP,HPP
Sharp LH77790 LCD Controller
PPC823_8.CPP,HPP Motorola MPC823 PowerPC LCD Controller

 
KwikPeg provides other screen drivers, called template drivers, which are ready for use with specific types of video controllers. These template drivers include generic support for each screen resolution and color depth handled by the video controller. The template drivers delivered with KwikPeg provide support for the following types of video output:

  Source/Header Video Controller
MONOSCRN.CPP,HPP Linear monochrome
L2SCRN.CPP,HPP Linear 2 bit-per-pixel grayscale or CGA
L4SCRN.CPP,HPP Linear 4 bit-per-pixel
L8SCRN.CPP,HPP Linear 8 bit-per-pixel
L16SCRN.CPP,HPP Linear 16 bit-per-pixel
L24SCRN.CPP,HPP Linear 24 bit-per-pixel

 
The following template drivers operate in profile mode to support the physical rotation of the display device. The direction of rotation, clockwise or counter-clockwise, is defined in the template driver header file. Unless altered by you, the rotation is clockwise.

  Source/Header Video Controller
PROSCRN1.CPP,HPP Profile monochrome
PROSCRN2.CPP,HPP Profile 2 bit-per-pixel grayscale or CGA
PROSCRN4.CPP,HPP Profile 4 bit-per-pixel
PROSCRN8.CPP,HPP Profile 8 bit-per-pixel

Top of page


 Keyboard Drivers

Full keyboard support is available for navigation through menus, windows, and dialogs. Keyboard support may range from a full QWERTY keyboard to a small set of user defined membrane keys. Full navigation and operation can be accomplished with as few as three unique input keys. The KwikPeg Configuration Manager allows you to exclude keyboard support from the KwikPeg Library if it is not required, thereby minimizing your memory footprint.

KwikPeg includes device drivers for the keyboards listed below. Swell Software, Inc. also includes a number of keyboard drivers with the standard PEG distribution. To determine if your keyboard or keypad is supported, contact KADAK.



 PC compatible keyboard using 8042 keyboard interface
(source file: KPKB8042.C)

This driver fetches key codes and keyboard status information from a PC keyboard connected by an Intel 8042 compatible keyboard controller interface. The keyboard interface is assumed to use PC data port 0x60 and status/command port 0x64 and PC interrupt IRQ1 on the PC master 8259 interrupt controller. To change the device port or interrupt assignment or to use this driver with non-PC hardware, you must edit the relevant definitions in the driver source file.

 8-bit ASCII encoded characters from an 8250 UART interface
(source file: KPKB8250.C)

This driver fetches fetches 8-bit ASCII encoded key codes from an Intel 8250 or NS16550 compatible UART serial interface. The interface is assumed to be compatible with the PC COM2 serial port (port address 0x02F8) using PC interrupt IRQ3 on the PC master 8259 interrupt controller. To change the device port or interrupt assignment or to use this driver with non-PC hardware, you must edit the relevant definitions in the driver source file. This driver can be easily adapted by you for use with other UART interfaces, be they polled or interrupt driven.



Keyboard Driver Interface

The KwikPeg keyboard device drivers listed above provide the following functions to interact with your application. Other keyboard drivers provided with PEG will not necessarily provide equivalent services.

void kp_kbdopen(void);

This function must be called prior to any use of the keyboard. This function prepares the keyboard for use if it is not yet ready. Keyboard events are not directed to KwikPeg for service until this function has been called. You can call this function from your application ConfigurePegInput() hook.

void kp_kbdclose(void);

You must call this function when the GUI has been shut down and the keyboard is no longer required by KwikPeg. This function disables the keyboard or, at the very least, precludes subsequent keyboard events from being directed to KwikPeg for service. You can call this function from your application RestorePegInput() hook.

void kp_kbdpoll(void);

Most keyboard drivers are used in an interrupt driven fashion. However, the drivers can be configured to operate in a polled mode. If so, your application must call this function periodically to poll the keyboard to service pending keys. The task polling the keyboard is usually of higher priority than the KwikPeg Task.

int kp_kbdstate(void);

This function fetches keyboard state information such as Shift, Ctrl, Alt, Caps-lock, Num-lock and Scroll-lock (if available). This function can be called from a task or from an interrupt service routine. It can also be called from a mouse driver. This function returns the integer value 0 merged with zero or more of the following state masks:

  KF_RSHIFT Right shift key depressed
  KF_LSHIFT Left shift key depressed
  KF_SHIFT Either shift key depressed
(same as KF_RSHIFT|KF_LSHIFT)
  KF_CTRL Control key (Ctrl) depressed
  KF_ALT Alternate key (Alt) depressed
  KF_SCROLL Scroll-lock (Scroll Lock) is active
  KF_NUML Num-lock (Num Lock) is active
  KF_CAPS Caps-lock (Caps Lock) is active
  KF_INS Insert mode (Ins) is active

Top of page


 Mouse and Touch Panel Drivers

KwikPeg includes complete support for mouse input. The driver can be configured to draw various pointer bitmaps or to use hardware cursor capabilities if they exist. Mouse input drivers are provided for several different platforms. The KwikPeg Configuration Manager allows you to exclude mouse support from the KwikPeg Library if it is not required, thereby minimizing your memory footprint.

Touch screen input is also supported. When operating with a touch screen, KwikPeg can be configured to eliminate the drawing of the mouse pointer and the highlighting of the object that has input focus. These options minimize your memory footprint and reduce the drawing overhead when a touch screen is used. When used with a touch screen, KwikPeg eliminates all pointer movement tracking and restricts pointer events to simple touch and release operations.

KwikPeg supports the use of soft keys such as membrane keys placed at the perimeter of a display screen. When soft keys are used, touch and release events are generated. The event is correlated to the screen position adjacent to the membrane key which produced the event. KwikPeg is thereby fooled into operating as though a touch screen is being used. Other input devices can also be serviced using this technique.

KwikPeg includes device drivers for the mouse interfaces listed below. Swell Software, Inc. also includes a number of input device drivers for mouse, joystick and touch screen devices with the standard PEG distribution. To determine if your input pointing device is supported, contact KADAK.



 PC compatible mouse connected via a PS/2 port interface
(source file: KPMDPS2.C)

This driver provides interrupt driven support for a PC compatible mouse connected to a PS/2 keyboard/mouse interface port. The mouse interface is assumed to use PC data port 0x60 and status/command port 0x64 and PC interrupt IRQ12 on the PC slave 8259 interrupt controller. To change the device port or interrupt assignment or to use this driver with non-PC hardware, you must edit the relevant definitions in the driver source file.

 PC compatible mouse connected via an 8250 UART interface
(source file: KPMD8250.C)

This driver provides interrupt driven support for a PC compatible mouse connected to an Intel 8250 or NS16550 compatible serial interface. The interface is assumed to be compatible with the PC COM2 serial port (port address 0x02F8) using PC interrupt IRQ3 on the PC master 8259 interrupt controller. To change the device port or interrupt assignment or to use this driver with non-PC hardware, you must edit the relevant definitions in the driver source file.



Mouse Driver Interface

The KwikPeg mouse input device drivers listed above provide the following functions to interact with your application. Other mouse drivers provided with PEG will not necessarily provide equivalent services.

void kp_mpdopen(void);

This function must be called prior to any use of the mouse. This function prepares the mouse interface for use if it is not yet ready. Mouse events are not directed to KwikPeg for service until this function has been called. You can call this function from your application ConfigurePegInput() hook.

void kp_mpdclose(void);

You must call this function when the GUI has been shut down and the mouse is no longer required by KwikPeg. This function disables the mouse or, at the very least, precludes subsequent mouse events from being directed to KwikPeg for service. You can call this function from your application RestorePegInput() hook.

void kp_mpdpoll(void);

Most mouse drivers are used in an interrupt driven fashion. However, the drivers can be configured to operate in a polled mode. If so, your application must call this function periodically to poll the mouse interface to service pending mouse events. The task polling the mouse is usually of higher priority than the KwikPeg Task.

int kp_mpdbound(int xmin, int ymin,
  int xmax, int ymax,
  int xoffset, int yoffset);

Your application must call this function to establish the range of screen coordinates which the mouse driver can report to KwikPeg. The function receives the definition of a bounding rectangle (usually 0,0 to xmax,ymax) which defines the extremities of allowable mouse movement.

The mouse "locates" itself within the bounding rectangle at the point xoffset,yoffset measured relative to the top left coordinate xmin,ymin.

This function returns 0 if successful or -1 if the specified bounds and position parameters are unacceptable.

You can call this function from your application ConfigurePegInput() hook after the mouse driver kp_mpdopen() function has been called. In some cases you may wish to defer the call to this function until your application has generated its first screen image and the screen boundaries are well defined.


Top of page


 Low Level I/O Support

KwikPeg provides a collection of service procedures which are of particular use when writing device drivers for the KwikPeg GUI. There are two general categories of services provided.

Prototypes for these functions are located in KwikPeg header file KP_API.H. This header file is automatically included by your KwikPeg Library Header File KP_LIB.H.



OS Services

Common operating system services are used by KwikPeg and device drivers. These procedures reside in the KwikPeg OS Interface Module KP_OSIF.C in the KwikPeg Library.

void *kp_osmemget(unsigned int memsize);

Get a pointer to a block of memsize bytes of memory.

void kp_osmemrls(void *memptr);

Release the block of memory referenced by memptr.



Board Services

Board services are used only by device drivers. These procedures are located in the board driver modules provided with KwikPeg. Each board driver module contains procedures which are both target hardware and operating system dependent. These procedures inevitably require modification by you for your particular application.

unsigned long kp_brdintlvl(
  unsigned long priority);

Change the current interrupt priority level. If parameter priority is 0L, all interrupts will be disabled. If parameter priority is 0xFFFFFFFFL, interrupts will be enabled. Return the previous interrupt priority level.

void kp_brdmodirq(int opcode, int irqid);

Enable (opcode == KP_DD_IRQENABLE) or disable (opcode == KP_DD_IRQDISABLE) the device interrupt source identified by interrupt number irqid.

unsigned long kp_brdvector(int irqid,
  void *newp, void *oldp);

This function installs a new interrupt handler or restores a previously saved interrupt handler for a particular device interrupt.

Parameter irqid is the KwikPeg interrupt identifier used by a KwikPeg device driver to specify its device interrupt vector. See the description in file KP_BOARD.C for a definition of the allowable values for KwikPeg interrupt identifiers.

Parameter newp is a pointer to storage containing the definition of the interrupt handler to be installed into the specified vector. The form of the interrupt handler definition is processor dependent. If newp is NULL, the interrupt vector will not be modified.

Parameter oldp is a pointer to storage for a copy of the current content of the specified vector. The vector content is saved in a format such that oldp can be used as parameter newp in a subsequent call to kp_brdvector to restore the original vector content. If the previous vector content does not have to be saved, set oldp to NULL.



Device I/O Services

Standard PEG device input and output operations are implemented as macros PINB(a), POUTB(a, b) and POUTW(a, b) in PEG configuration header file PCONFIG.HPP. These I/O macros are mapped to underlying I/O services offered by the KwikPeg OS Interface. This mapping permits PEG to be used with all versions of KADAK's AMX RTOS on a wide variety of target processors and boards without modification to PEG.

The low level I/O services provided by KwikPeg support port and memory mapped operations. They also allow memory mapped I/O addresses to be computed using base, offset and scaling factor values. Brief delays after I/O instructions can also be injected.

These low level I/O services are used only by KwikPeg board drivers and device drivers. These services are implemented as macros located in the KwikPeg device I/O access header file KP_DVCIO.H. The macros are target dependent and C/C++ compiler sensitive. The macros expand to inline assembly language statements, C/C++ code expansions or function calls. If functions are used, they reside in the board driver or in the C/C++ runtime library. The macros reference devices using port numbers or memory addresses according to the target processor selected.

** Note **
You should not need to modify the low level I/O macros or functions defined in header file KP_DVCIO.H. If the compiler, processor and board specific implementation provided with KwikPeg does not operate correctly in your environment, contact KADAK.

unsigned char kp_in8(addr);
unsigned short kp_in16(addr);
unsigned long kp_in32(addr);

Macros (or functions) kp_inX() read from an 8, 16 or 32 bit device port or memory address addr.

void kp_out8(addr, unsigned char val);
void kp_out16(addr, unsigned short val);
void kp_out32(addr, unsigned long val);

Macros (or functions) kp_outX() write value val to an 8, 16 or 32 bit device port or memory address addr.


Top of page



Drivers | Examples | Testing | Home        Copyright © 2000-2003
Support | Legal