kernel 分析一
These codes defined in <machine/console.h>
----------------------------------------------------------------------------
--
#define KDGKBMODE _IOR('K', 6, int)
#define KDSKBMODE _IO('K', 7 /*, int */)
Get / Set keyboard mode:
Param: int * / int keyboard mode
Value: K_RAW - return scancodes...
K_XLATE - return the ascii values converted via keymaps
K_CODE - return keycodes...
----------------------------------------------------------------------------
--
#define KDMKTONE _IO('K', 8 /*, int */)
Create sounds:
Param: int. the high 16bit is the time (ms),
the low 16bit is the hz
== 0 default time/hz
----------------------------------------------------------------------------
--
--
#define KDGETMODE _IOR('K', 9, int)
#define KDSETMODE _IO('K', 10 /*, int */)
Get/Set mode:
Param: int * mode / int mode
Value: KD_TEXT - Set console mode to Text mode and restore font
s
KD_TEXT0 == KD_TEXT
KD_TEXT1 - Set console mode to Text mode and not restore
font
KD_GRAPHICS - Set console to graphics mode
KD_PIXEL - Set console to pixel mode
Comments: KD_TEXTx must be called after actually text video modes s
etting ioctl() called. i.e SW_TEXT_xxxx, SW_VGA_xxx, etc.
KD_GRAPHICS must be called after actually graphics mode s
etting ioctl() called, i.e. SW_CG640x480, etc.
KD_PIXEL has the same limitation as KD_GRAPHICS
----------------------------------------------------------------------------
---
#define KDSBORDER _IO('K', 13 /*, int */)
Set border color to int
Param: int color (color is the normal definition: BRGBIRGB)
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---
#define KDGKBSTATE _IOR('K', 19, int)
#define KDSKBSTATE _IO('K', 20 /*, int */)
Set keyboard lock state - the xxxx Lock key states
Param: int * / int
Value: only LOCK_MASK bitmask permitted
LOCK_MASK == (CLKED | NLKED | SLKED | ALKED)
CLKED : Caps Lock
NLKED : NumLock
SLKED : Scroll Lock
ALKED : AltGr - not in PC keyboard
----------------------------------------------------------------------------
---
#define KDENABIO _IO('K', 60)
#define KDDISABIO _IO('K', 61)
Enable Processor IO operations!
No Params. via Setting/Clear PSL_IOPL bit in MSW
----------------------------------------------------------------------------
---
#define KIOCSOUND _IO('K', 63 /*, int */)
Start / Stop tone
Param: int *
Param: int *
Value: != 0 start sound with hz
== 0 stop sound
----------------------------------------------------------------------------
---
#define KDGKBTYPE _IOR('K', 64, int)
Get Keyboard type:
Param: int *
Value: KB_84, KB_101, KB_OTHER
----------------------------------------------------------------------------
---
#define KDGETLED _IOR('K', 65, int)
#define KDSETLED _IO('K', 66 /*, int */)
Get / Set the LED State
Param: int * / int
Value: LED_MASK only
LED_MASK == (LED_CAP | LED_NUM | LED_SCR)
----------------------------------------------------------------------------
---
#define KDSETRAD _IO('K', 67 /*, int */) /* obsolete */
Old method to set repeat rates
Param: int
Value: high 3 bit: delay == 0 : 250ms, == 1: 500ms
Param: int *
Value: != 0 start sound with hz
== 0 stop sound
----------------------------------------------------------------------------
---
#define KDGKBTYPE _IOR('K', 64, int)
Get Keyboard type:
Param: int *
Value: KB_84, KB_101, KB_OTHER
----------------------------------------------------------------------------
---
#define KDGETLED _IOR('K', 65, int)
#define KDSETLED _IO('K', 66 /*, int */)
Get / Set the LED State
Param: int * / int
Value: LED_MASK only
LED_MASK == (LED_CAP | LED_NUM | LED_SCR)
----------------------------------------------------------------------------
---
#define KDSETRAD _IO('K', 67 /*, int */) /* obsolete */
Old method to set repeat rates
Param: int
Value: high 3 bit: delay == 0 : 250ms, == 1: 500ms
Param: int *
Value: != 0 start sound with hz
== 0 stop sound
----------------------------------------------------------------------------
---
#define KDGKBTYPE _IOR('K', 64, int)
Get Keyboard type:
Param: int *
Value: KB_84, KB_101, KB_OTHER
----------------------------------------------------------------------------
---
#define KDGETLED _IOR('K', 65, int)
#define KDSETLED _IO('K', 66 /*, int */)
Get / Set the LED State
Param: int * / int
Value: LED_MASK only
LED_MASK == (LED_CAP | LED_NUM | LED_SCR)
----------------------------------------------------------------------------
---
#define KDSETRAD _IO('K', 67 /*, int */) /* obsolete */
Old method to set repeat rates
Param: int
Value: high 3 bit: delay == 0 : 250ms, == 1: 500ms
character!
scrmap_t == char [256];
default is 0 - 0, 1 - 1,.. 255 - 255. without translations
----------------------------------------------------------------------------
---
#define GIO_KEYMAP _IOR('k', 6, keymap_t)
#define PIO_KEYMAP _IOW('k', 7, keymap_t)
Get / Set keyboard translation table... It's input translation table
keymap_t == struct keymap
struct keymap {
u_short n_keys;
struct keyent_t key[NUM_KEYS];
};
n_keys == number of keys in this map. The maximum number is NUM_KEYS
defined in console.h
key[] is the array for every key in keymap.
the keys ordered by their scancode, i.e. the 1st key in map has the
scancode 0, and so on....
struct keyent_t {
u_char map[NUM_STATES];
u_char spcl;
u_char flgs;
u_char flgs;
};
every key has NUM_STATES (8) states. The mapped value in state i is
stored in map.
The 8 States:
base: The normal state.
shift: shift pressed
cntrl: control pressed
cntrl shift: control+shift pressed
alt: alt pressed
alt shift: alt+shift pressed
alt control: alt+control pressed
alt control shift: alt+control+shift pressed
There is no symbol definition in console.h about these 8 states
The translated key value should be the value of map[state] normally.
The 8 bit of spcl fields represents the special case under every 8 st
ates. The order is from left to right, i.e. special bit value of state i is
(0x80 >>i)
if special bit is set, and the key value (i.e. map) equals to the
one of values below:
NOP, LSH, RSH, CLK, NLK, SLK, BTAB, LALT, LCTR, NEXT, RCTR, RALT,
RALT, ALK, ASH, META, RBT, DBG, SUSP, SPSC. These values defined i
n this file below.
if special bit is set, and the key value (i.e. map) equals to the
then it has the meaning of these symbol implicted.
Others, if special bit is set, and the key value is in the area betwe
en F_FN and L_FN (including), this represents a function key value. if speci
al bit is set and key value is in the area between F_SCR and L_SCR (includin
g), this represents a screen key value. if .... between F_ACC and L_ACC, thi
s represents a accent key value ( These Value defined below, too. from DGRA
to DCRA )
The flgs field indicated the Flag LOCK States....I don't know much ab
out what these LOCK states are till now...Anyone could tell me? Defined LOCK
States listed below:
#define FLAG_LOCK_O 0
#define FLAG_LOCK_C 1
#define FLAG_LOCK_N 2
#define FLAG_LOCK_B 3 // This doesn't occur in console.h but be
found in kbdcontrol.c