NAME | SYNOPSIS | FEATURES | API RESTRICTIONS | DESCRIPTION | EXTENDED DESCRIPTION | ATTRIBUTES | SEE ALSO
#include <ddi/keyboard/keyboard.h>
DDI
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
The keyboard device driver interface (asynchronous mode) defines the upper interface for keyboard device drivers.
typedef struct { int initialRepeatDelay; int repeatDelay; } KeyboardConfig;
When character repeating is supported by the hardware, this parameter specifies how long a key must remain pushed before the keyboard starts to send a continuous stream of characters. The unit is a millisecond.
This parameter sets the delay between two characters when the keyboard operates in repeat mode. The unit is a millisecond.
typedef enum { KEYBOARD_VERSION_INITIAL = 0 } KeyboardVersion; #define KEYBOARD_CLASS "keyboard" typedef uint32_f ScanCode;
The ScanCode is defined to support up to 32 bit scancodes. Note that the content of ScanCode is keyboard dependent, so the client of the driver must know the kind of keyboard device serviced by the driver.
typedef struct KeyboardCallBack { void (*scan_code_receive) (void* cookie); } KeyboardCallBack;
scan_code_receive notifies the client that a scancode is available for reading.
This call takes the following arguments:
The client cookie specified in open.
Specifies an event.
The scan_code_receive up-call is invoked with masked device interrupts. Typically, the scan_code_receive up-call is issued from the interrupt level. This function is invoked by the keyboard driver for each scancode sent by the keyboard.
typedef struct KeyboardDevOps { KeyboardVersion version; KnError (*open) (KeyboardId dev_id, KeyboardConfig* dev_cfg, KeyboardCallBack* cbops, void* cookie); void (*mask) (KeyboardId dev_id); void (*unmask) (KeyboardId dev_id); Bool (*scan_code_get) (KeyboardId dev_id, ScanCode* scanCode); void (*code_send) (KeyboardId dev_id, uint32_f command); void (*close) (KeyboardId dev_id); } KeyboardDevOps;
The open call takes the following arguments:
Device identifier.
Structure specifying the keyboard configuration.
Passed back to the client when a client call back handler is invoked.
Client call back handlers.
The open call returns the following:
Specifies that the line is successfully initialized.
Specifies that the line cannot be initialized with the given configuration (that is, the specified repeat rate is not supported).
open must be the first call to the device driver. When K_OK is returned, open puts the device into an interrupts-masked state. In order to start the device (enable interrupts), the unmask down-call must be invoked.
Note that the driver is supposed to be single-client; the client must not try to open the device again before calling close.
The mask call takes the following argument:
Device identifier.
The mask function disables ScanCode notification from the device. When mask is called, the client must disable preemption to prevent the current thread being preempted with masked device interrupts.
For more information on the mask function, see the unmask section below.
The unmask call takes the following argument:
Device identifier.
The unmask function enables the scanCode notification (scan_code_receive() call back). Typically, the mask/unmask pair would be used by the driver's client to implement a critical section of code which is synchronized with the call-back handlers.
The mask/unmask pair must not be called by the call-back handlers because the interrupts are already masked when a call-back handler is invoked.
The mask/unmask pair must not be nested.
The scan_code_get call takes the following arguments:
Device identifier.
Points to a scancode.
If one scancode has been received, the function returns 1 and initializes the data pointed to by the scanCode with the received scanCode. Otherwise it returns 0 and does not initialize the data pointed to by scanCode parameter. Note that scan_code_get must be invoked while interrupts are masked.
The code_send call takes the following arguments:
Device identifier.
Keyboard command parameter.
This method is used to send commands to the keyboard. The command is keyboard dependent. The code supported by a given keyboard must be specified by the client of the driver. For instance, this method can be used to switch LEDs on and off.
The close call takes the following argument:
Device identifier.
The close down-call releases the keyboard device. The close function must be called in the masked state. In other words, the mask down-call must be issued before the close down-call.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | API RESTRICTIONS | DESCRIPTION | EXTENDED DESCRIPTION | ATTRIBUTES | SEE ALSO