forked from Imagelibrary/rtems
2007-09-10 Joel Sherrill <joel.sherrill@OARcorp.com>
* console/vt.c: Changed tabs to spaces.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2007-09-10 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||||
|
|
||||||
|
* console/vt.c: Changed tabs to spaces.
|
||||||
|
|
||||||
2007-09-10 Joel Sherrill <joel.sherrill@OARcorp.com>
|
2007-09-10 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||||
|
|
||||||
* console/keyboard.c: Replaced tabs with spaces.
|
* console/keyboard.c: Replaced tabs with spaces.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* driver. Removed all stuff not required, such as VT_, Fonts, etc.
|
* driver. Removed all stuff not required, such as VT_, Fonts, etc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h> /* memcpy */
|
#include <string.h> /* memcpy */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@@ -60,9 +60,9 @@ unsigned char keyboard_type = KB_101;
|
|||||||
static void
|
static void
|
||||||
kd_nosound(unsigned long ignored)
|
kd_nosound(unsigned long ignored)
|
||||||
{
|
{
|
||||||
/* disable counter 2 */
|
/* disable counter 2 */
|
||||||
outb(inb_p(0x61)&0xFC, 0x61);
|
outb(inb_p(0x61)&0xFC, 0x61);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -71,31 +71,31 @@ _kd_mksound(unsigned int hz, unsigned int ticks)
|
|||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
int level;
|
int level;
|
||||||
|
|
||||||
if (hz > 20 && hz < 32767)
|
if (hz > 20 && hz < 32767)
|
||||||
count = 1193180 / hz;
|
count = 1193180 / hz;
|
||||||
|
|
||||||
_CPU_ISR_Disable(level);
|
_CPU_ISR_Disable(level);
|
||||||
/* del_timer(&sound_timer); */
|
/* del_timer(&sound_timer); */
|
||||||
if (count) {
|
if (count) {
|
||||||
/* enable counter 2 */
|
/* enable counter 2 */
|
||||||
outb_p(inb_p(0x61)|3, 0x61);
|
outb_p(inb_p(0x61)|3, 0x61);
|
||||||
/* set command for counter 2, 2 byte write */
|
/* set command for counter 2, 2 byte write */
|
||||||
outb_p(0xB6, 0x43);
|
outb_p(0xB6, 0x43);
|
||||||
/* select desired HZ */
|
/* select desired HZ */
|
||||||
outb_p(count & 0xff, 0x42);
|
outb_p(count & 0xff, 0x42);
|
||||||
outb((count >> 8) & 0xff, 0x42);
|
outb((count >> 8) & 0xff, 0x42);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (ticks) {
|
if (ticks) {
|
||||||
sound_timer.expires = jiffies+ticks;
|
sound_timer.expires = jiffies+ticks;
|
||||||
add_timer(&sound_timer);
|
add_timer(&sound_timer);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
} else
|
} else
|
||||||
kd_nosound(0);
|
kd_nosound(0);
|
||||||
|
|
||||||
_CPU_ISR_Enable (level);
|
_CPU_ISR_Enable (level);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -115,29 +115,29 @@ void (*kd_mksound)(unsigned int hz, unsigned int ticks) = _kd_mksound;
|
|||||||
static inline int
|
static inline int
|
||||||
do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kbd)
|
do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kbd)
|
||||||
{
|
{
|
||||||
struct kbentry tmp;
|
struct kbentry tmp;
|
||||||
ushort *key_map, val;
|
ushort *key_map, val;
|
||||||
|
|
||||||
tmp = *user_kbe;
|
tmp = *user_kbe;
|
||||||
if (i >= NR_KEYS) /* s cannot be >= MAX_NR_KEYMAPS */
|
if (i >= NR_KEYS) /* s cannot be >= MAX_NR_KEYMAPS */
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case KDGKBENT:
|
case KDGKBENT:
|
||||||
key_map = key_maps[s];
|
key_map = key_maps[s];
|
||||||
if (key_map) {
|
if (key_map) {
|
||||||
val = U(key_map[i]);
|
val = U(key_map[i]);
|
||||||
if (kbd->kbdmode != VC_UNICODE && KTYP(val) >= NR_TYPES)
|
if (kbd->kbdmode != VC_UNICODE && KTYP(val) >= NR_TYPES)
|
||||||
val = K_HOLE;
|
val = K_HOLE;
|
||||||
} else
|
} else
|
||||||
val = (i ? K_HOLE : K_NOSUCHMAP);
|
val = (i ? K_HOLE : K_NOSUCHMAP);
|
||||||
user_kbe->kb_value = val;
|
user_kbe->kb_value = val;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case KDSKBENT:
|
case KDSKBENT:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#undef i
|
#undef i
|
||||||
#undef s
|
#undef s
|
||||||
@@ -148,29 +148,29 @@ do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kb
|
|||||||
static inline int
|
static inline int
|
||||||
do_kbkeycode_ioctl(int cmd, struct kbkeycode *user_kbkc, int perm)
|
do_kbkeycode_ioctl(int cmd, struct kbkeycode *user_kbkc, int perm)
|
||||||
{
|
{
|
||||||
struct kbkeycode tmp;
|
struct kbkeycode tmp;
|
||||||
int kc = 0;
|
int kc = 0;
|
||||||
|
|
||||||
tmp = *user_kbkc;
|
tmp = *user_kbkc;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case KDGETKEYCODE:
|
case KDGETKEYCODE:
|
||||||
kc = getkeycode(tmp.scancode);
|
kc = getkeycode(tmp.scancode);
|
||||||
if (kc >= 0)
|
if (kc >= 0)
|
||||||
user_kbkc->keycode = kc;
|
user_kbkc->keycode = kc;
|
||||||
break;
|
break;
|
||||||
case KDSETKEYCODE:
|
case KDSETKEYCODE:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
kc = setkeycode(tmp.scancode, tmp.keycode);
|
kc = setkeycode(tmp.scancode, tmp.keycode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return kc;
|
return kc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
|
do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -179,169 +179,169 @@ do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
|
|||||||
*/
|
*/
|
||||||
int vt_ioctl( unsigned int cmd, unsigned long arg)
|
int vt_ioctl( unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int perm;
|
int perm;
|
||||||
unsigned int console;
|
unsigned int console;
|
||||||
unsigned char ucval;
|
unsigned char ucval;
|
||||||
struct kbd_struct * kbd;
|
struct kbd_struct * kbd;
|
||||||
|
|
||||||
console = 0;
|
console = 0;
|
||||||
/*
|
/*
|
||||||
* To have permissions to do most of the vt ioctls, we either have
|
* To have permissions to do most of the vt ioctls, we either have
|
||||||
* to be the owner of the tty, or super-user.
|
* to be the owner of the tty, or super-user.
|
||||||
*/
|
*/
|
||||||
perm = 1;
|
perm = 1;
|
||||||
kbd = kbd_table + console;
|
kbd = kbd_table + console;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case KIOCSOUND:
|
case KIOCSOUND:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (arg)
|
if (arg)
|
||||||
arg = 1193180 / arg;
|
arg = 1193180 / arg;
|
||||||
kd_mksound(arg, 0);
|
kd_mksound(arg, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case KDMKTONE:
|
case KDMKTONE:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
{
|
{
|
||||||
unsigned int ticks, count;
|
unsigned int ticks, count;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate the tone for the appropriate number of ticks.
|
* Generate the tone for the appropriate number of ticks.
|
||||||
* If the time is zero, turn off sound ourselves.
|
* If the time is zero, turn off sound ourselves.
|
||||||
*/
|
*/
|
||||||
ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
|
ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
|
||||||
count = ticks ? (arg & 0xffff) : 0;
|
count = ticks ? (arg & 0xffff) : 0;
|
||||||
if (count)
|
if (count)
|
||||||
count = 1193180 / count;
|
count = 1193180 / count;
|
||||||
kd_mksound(count, ticks);
|
kd_mksound(count, ticks);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case KDGKBTYPE:
|
case KDGKBTYPE:
|
||||||
/*
|
/*
|
||||||
* this is naive.
|
* this is naive.
|
||||||
*/
|
*/
|
||||||
ucval = keyboard_type;
|
ucval = keyboard_type;
|
||||||
goto setchar;
|
goto setchar;
|
||||||
|
|
||||||
case KDSETMODE:
|
case KDSETMODE:
|
||||||
case KDGETMODE:
|
case KDGETMODE:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
case KDSKBMODE:
|
case KDSKBMODE:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
switch(arg) {
|
switch(arg) {
|
||||||
case K_RAW:
|
case K_RAW:
|
||||||
kbd->kbdmode = VC_RAW;
|
kbd->kbdmode = VC_RAW;
|
||||||
break;
|
break;
|
||||||
case K_MEDIUMRAW:
|
case K_MEDIUMRAW:
|
||||||
kbd->kbdmode = VC_MEDIUMRAW;
|
kbd->kbdmode = VC_MEDIUMRAW;
|
||||||
break;
|
break;
|
||||||
case K_XLATE:
|
case K_XLATE:
|
||||||
kbd->kbdmode = VC_XLATE;
|
kbd->kbdmode = VC_XLATE;
|
||||||
compute_shiftstate();
|
compute_shiftstate();
|
||||||
break;
|
break;
|
||||||
case K_UNICODE:
|
case K_UNICODE:
|
||||||
kbd->kbdmode = VC_UNICODE;
|
kbd->kbdmode = VC_UNICODE;
|
||||||
compute_shiftstate();
|
compute_shiftstate();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case KDGKBMODE:
|
case KDGKBMODE:
|
||||||
ucval = ((kbd->kbdmode == VC_RAW) ? K_RAW :
|
ucval = ((kbd->kbdmode == VC_RAW) ? K_RAW :
|
||||||
(kbd->kbdmode == VC_MEDIUMRAW) ? K_MEDIUMRAW :
|
(kbd->kbdmode == VC_MEDIUMRAW) ? K_MEDIUMRAW :
|
||||||
(kbd->kbdmode == VC_UNICODE) ? K_UNICODE :
|
(kbd->kbdmode == VC_UNICODE) ? K_UNICODE :
|
||||||
K_XLATE);
|
K_XLATE);
|
||||||
goto setint;
|
goto setint;
|
||||||
|
|
||||||
/* this could be folded into KDSKBMODE, but for compatibility
|
/* this could be folded into KDSKBMODE, but for compatibility
|
||||||
reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */
|
reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */
|
||||||
case KDSKBMETA:
|
case KDSKBMETA:
|
||||||
switch(arg) {
|
switch(arg) {
|
||||||
case K_METABIT:
|
case K_METABIT:
|
||||||
clr_vc_kbd_mode(kbd, VC_META);
|
clr_vc_kbd_mode(kbd, VC_META);
|
||||||
break;
|
break;
|
||||||
case K_ESCPREFIX:
|
case K_ESCPREFIX:
|
||||||
set_vc_kbd_mode(kbd, VC_META);
|
set_vc_kbd_mode(kbd, VC_META);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case KDGKBMETA:
|
case KDGKBMETA:
|
||||||
ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT);
|
ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT);
|
||||||
setint:
|
setint:
|
||||||
*(int *)arg = ucval;
|
*(int *)arg = ucval;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case KDGETKEYCODE:
|
case KDGETKEYCODE:
|
||||||
case KDSETKEYCODE:
|
case KDSETKEYCODE:
|
||||||
return do_kbkeycode_ioctl(cmd, (struct kbkeycode *)arg, perm);
|
return do_kbkeycode_ioctl(cmd, (struct kbkeycode *)arg, perm);
|
||||||
|
|
||||||
case KDGKBENT:
|
case KDGKBENT:
|
||||||
case KDSKBENT:
|
case KDSKBENT:
|
||||||
return do_kdsk_ioctl(cmd, (struct kbentry *)arg, perm, kbd);
|
return do_kdsk_ioctl(cmd, (struct kbentry *)arg, perm, kbd);
|
||||||
|
|
||||||
case KDGKBDIACR:
|
case KDGKBDIACR:
|
||||||
{
|
{
|
||||||
struct kbdiacrs *a = (struct kbdiacrs *)arg;
|
struct kbdiacrs *a = (struct kbdiacrs *)arg;
|
||||||
a->kb_cnt = accent_table_size;
|
a->kb_cnt = accent_table_size;
|
||||||
memcpy( a->kbdiacr, accent_table, accent_table_size*sizeof(struct kbdiacr) );
|
memcpy( a->kbdiacr, accent_table, accent_table_size*sizeof(struct kbdiacr) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case KDSKBDIACR:
|
case KDSKBDIACR:
|
||||||
{
|
{
|
||||||
struct kbdiacrs *a = (struct kbdiacrs *)arg;
|
struct kbdiacrs *a = (struct kbdiacrs *)arg;
|
||||||
unsigned int ct;
|
unsigned int ct;
|
||||||
|
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
ct = a->kb_cnt;
|
ct = a->kb_cnt;
|
||||||
if (ct >= MAX_DIACR)
|
if (ct >= MAX_DIACR)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
accent_table_size = ct;
|
accent_table_size = ct;
|
||||||
memcpy(accent_table, a->kbdiacr, ct*sizeof(struct kbdiacr));
|
memcpy(accent_table, a->kbdiacr, ct*sizeof(struct kbdiacr));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the ioctls below read/set the flags usually shown in the leds */
|
/* the ioctls below read/set the flags usually shown in the leds */
|
||||||
/* don't use them - they will go away without warning */
|
/* don't use them - they will go away without warning */
|
||||||
case KDGKBLED:
|
case KDGKBLED:
|
||||||
ucval = kbd->ledflagstate | (kbd->default_ledflagstate << 4);
|
ucval = kbd->ledflagstate | (kbd->default_ledflagstate << 4);
|
||||||
goto setchar;
|
goto setchar;
|
||||||
|
|
||||||
case KDSKBLED:
|
case KDSKBLED:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (arg & ~0x77)
|
if (arg & ~0x77)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
kbd->ledflagstate = (arg & 7);
|
kbd->ledflagstate = (arg & 7);
|
||||||
kbd->default_ledflagstate = ((arg >> 4) & 7);
|
kbd->default_ledflagstate = ((arg >> 4) & 7);
|
||||||
set_leds();
|
set_leds();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* the ioctls below only set the lights, not the functions */
|
/* the ioctls below only set the lights, not the functions */
|
||||||
/* for those, see KDGKBLED and KDSKBLED above */
|
/* for those, see KDGKBLED and KDSKBLED above */
|
||||||
case KDGETLED:
|
case KDGETLED:
|
||||||
ucval = getledstate();
|
ucval = getledstate();
|
||||||
setchar:
|
setchar:
|
||||||
*(char*)arg = ucval;
|
*(char*)arg = ucval;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case KDSETLED:
|
case KDSETLED:
|
||||||
if (!perm)
|
if (!perm)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
setledstate(kbd, arg);
|
setledstate(kbd, arg);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user