Linux 版 (精华区)
发信人: tcpip (偶的昵称改了), 信区: Linux
标 题: holly大虾的内核分析报告(一)(转寄)
发信站: 哈工大紫丁香 (Sat Jan 22 16:30:18 2000), 转信
发信人: stable (xixi), 信区: FreeBSD
标 题: holly大虾的内核分析报告(一)
发信站: BBS 水木清华站 (Fri Jan 21 21:42:16 2000)
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 fon
ts
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
setting ioctl() called. i.e SW_TEXT_xxxx, SW_VGA_xxx, etc.
KD_GRAPHICS must be called after actually graphics mode
setting 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 *
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
== 2 : 750ms, == 3: 1000ms
low 5 bits: repeat rate: 0..31 represents 34..504 step by 4
Comment: Use KDSETREPEAT instead
---------------------------------------------------------------------------
----
#define KDRASTER _IOW('K', 100, scr_size_t)
Set pixel mode
Param: scr_size_t == struct { int [3] };
Value: [0] == xsize, [1] == ysize, [2] == fontsize
---------------------------------------------------------------------------
--
#define KDGKBINFO _IOR('K', 101, keyboard_info_t)
struct keyboard_info {
int kb_index; /* kbdio index# */ system keyboard
index
char kb_name[16]; /* driver name */
int kb_unit; /* unit# */
int kb_type; /* KB_84, KB_101, KB_OTHER,... */
int kb_config; /* device configuration flags */
}
---------------------------------------------------------------------------
----
#define KDSETREPEAT _IOW('K', 102, keyboard_delay_t)
Set repeat rate
Param: keyboard_delay_t == int [2]
Value: [0] == delay (250..1000 step by 250)
[1] == repeat rate(34..504 step by 4)
---------------------------------------------------------------------------
----
#define GETFKEY _IOWR('k', 0, fkeyarg_t)
#define SETFKEY _IOWR('k', 1, fkeyarg_t)
struct fkeyarg {
u_short keynum; // Function Key number. max is NUM_F
KEYS
char keydef[MAXFK]; // The representing string of this F
KEY
char flen; // The length of string
};
---------------------------------------------------------------------------
----
#define GIO_SCRNMAP _IOR('k', 2, scrmap_t)
#define PIO_SCRNMAP _IOW('k', 3, scrmap_t)
What's screen map? screen map is an output translate table for ever
y 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 tabl
e
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_KEY
S 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;
};
every key has NUM_STATES (8) states. The mapped value in state i is
stored in map[i].
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 s
tates. The order is from left to right, i.e. special bit value of state i i
s (0x80 >>i)
if special bit is set, and the key value (i.e. map[i]) 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
in this file below.
then it has the meaning of these symbol implicted.
Others, if special bit is set, and the key value is in the area betw
een F_FN and L_FN (including), this represents a function key value. if spe
cial bit is set and key value is in the area between F_SCR and L_SCR (inclu
ding), this represents a screen key value. if .... between F_ACC and L_ACC,
this 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 a
bout what these LOCK states are till now...Anyone could tell me? Defined LO
CK 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 b
e found in kbdcontrol.c
--
※ 来源:·BBS 水木清华站 smth.org·[FROM: ox2.ios.ac.cn]
--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: bin@mtlab.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:208.584毫秒