mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 15:39:19 +08:00
2000-08-26 Rosimildo da Silva <rdasilva@connecttel.com>
* Major rework of the "/dev/console" driver. * Added termios support for stdin ( keyboard ). * Added ioctls() to support modes similar to Linux( XLATE, RAW, MEDIUMRAW ). * Added Keyboard mapping and handling of the keyboard's leds. * Added Micro FrameBuffer driver ( "/dev/fb0" ) for bare VGA controller ( 16 colors ). * Added PS/2 and Serial mouse support for PC386 BSP. * console/defkeymap.c: New file. * console/fb_vga.c: New file. * console/fb_vga.h: New file. * console/i386kbd.h: New file. * console/kd.h: New file. * console/keyboard.c: New file. * console/keyboard.h: New file. * console/mouse_parser.c: New file. * console/mouse_parser.h: New file. * console/pc_keyb.c: New file. * console/ps2_drv.h: New file. * console/ps2_mouse.c: New file. * console/ps2_mouse.h: New file. * console/serial_mouse.c: New file. * console/serial_mouse.h: New file. * console/vgainit.c: New file. * console/vt.c: New file. * console/Makefile.am: Reflect new files. * console/console.c, console/inch.c, console/outch.c: Console functionality modifications. * startup/Makefile.am: Pick up tty_drv.c and gdb_glue.c
This commit is contained in:
@@ -1,3 +1,35 @@
|
||||
2000-08-26 Rosimildo da Silva <rdasilva@connecttel.com>
|
||||
|
||||
* Major rework of the "/dev/console" driver.
|
||||
* Added termios support for stdin ( keyboard ).
|
||||
* Added ioctls() to support modes similar to Linux( XLATE,
|
||||
RAW, MEDIUMRAW ).
|
||||
* Added Keyboard mapping and handling of the keyboard's leds.
|
||||
* Added Micro FrameBuffer driver ( "/dev/fb0" ) for bare VGA
|
||||
controller ( 16 colors ).
|
||||
* Added PS/2 and Serial mouse support for PC386 BSP.
|
||||
* console/defkeymap.c: New file.
|
||||
* console/fb_vga.c: New file.
|
||||
* console/fb_vga.h: New file.
|
||||
* console/i386kbd.h: New file.
|
||||
* console/kd.h: New file.
|
||||
* console/keyboard.c: New file.
|
||||
* console/keyboard.h: New file.
|
||||
* console/mouse_parser.c: New file.
|
||||
* console/mouse_parser.h: New file.
|
||||
* console/pc_keyb.c: New file.
|
||||
* console/ps2_drv.h: New file.
|
||||
* console/ps2_mouse.c: New file.
|
||||
* console/ps2_mouse.h: New file.
|
||||
* console/serial_mouse.c: New file.
|
||||
* console/serial_mouse.h: New file.
|
||||
* console/vgainit.c: New file.
|
||||
* console/vt.c: New file.
|
||||
* console/Makefile.am: Reflect new files.
|
||||
* console/console.c, console/inch.c, console/outch.c: Console
|
||||
functionality modifications.
|
||||
* startup/Makefile.am: Pick up tty_drv.c and gdb_glue.c
|
||||
|
||||
2000-08-10 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* ChangeLog: New file.
|
||||
|
||||
@@ -8,7 +8,10 @@ VPATH = @srcdir@:@srcdir@/../../shared/io
|
||||
|
||||
PGM = $(ARCH)/console.rel
|
||||
|
||||
C_FILES = console.c inch.c outch.c
|
||||
RTEMS_H_FILES = keyboard.h kd.h serial_mouse.h ps2_drv.h fb_vga.h
|
||||
|
||||
C_FILES = console.c inch.c outch.c defkeymap.c fb_vga.c keyboard.c \
|
||||
mouse_parser.c pc_keyb.c ps2_mouse.c serial_mouse.c vgainit.c vt.c
|
||||
S_FILES = videoAsm.S
|
||||
|
||||
console_rel_OBJECTS = $(C_FILES:%.c=$(ARCH)/%.o) $(S_FILES:%.S=$(ARCH)/%.o)
|
||||
@@ -16,6 +19,10 @@ console_rel_OBJECTS = $(C_FILES:%.c=$(ARCH)/%.o) $(S_FILES:%.S=$(ARCH)/%.o)
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../../../../../../automake/lib.am
|
||||
|
||||
|
||||
PREINSTALL_FILES = $(PROJECT_INCLUDE) \
|
||||
$(RTEMS_H_FILES:%.h=$(PROJECT_INCLUDE)/rtems/%.h)
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
@@ -23,13 +30,19 @@ include $(top_srcdir)/../../../../../../automake/lib.am
|
||||
$(PGM): $(console_rel_OBJECTS)
|
||||
$(make-rel)
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems:
|
||||
$(mkinstalldirs) $@
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems/%.h: %.h
|
||||
$(INSTALL_DATA) $< $@
|
||||
|
||||
# the .rel file built here will be put into libbsp.a by
|
||||
# ../wrapup/Makefile
|
||||
|
||||
all-local: $(ARCH) $(console_rel_OBJECTS) $(PGM)
|
||||
all-local: $(PREINSTALL_FILES) $(ARCH) $(console_rel_OBJECTS) $(PGM)
|
||||
|
||||
.PRECIOUS: $(PGM)
|
||||
|
||||
EXTRA_DIST = console.c inch.c outch.c videoAsm.S
|
||||
EXTRA_DIST = $(C_FILES) $(RTEMS_H_FILES) $(S_FILES)
|
||||
|
||||
include $(top_srcdir)/../../../../../../automake/local.am
|
||||
|
||||
@@ -44,6 +44,9 @@ void __assert (const char *file, int line, const char *msg);
|
||||
#include <uart.h>
|
||||
#include <libcpu/cpuModel.h>
|
||||
|
||||
#include <rtems/mw_uid.h>
|
||||
#include "mouse_parser.h"
|
||||
|
||||
/*
|
||||
* Possible value for console input/output :
|
||||
* BSP_CONSOLE_PORT_CONSOLE
|
||||
@@ -65,12 +68,13 @@ int BSPPrintkPort = BSP_CONSOLE_PORT_CONSOLE;
|
||||
int BSPBaseBaud = 115200;
|
||||
|
||||
extern BSP_polling_getchar_function_type BSP_poll_char;
|
||||
extern int getch( void );
|
||||
extern void kbd_init( void );
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| External Prototypes
|
||||
+--------------------------------------------------------------------------*/
|
||||
extern void _IBMPC_keyboard_isr(void);
|
||||
extern rtems_boolean _IBMPC_scankey(char *); /* defined in 'inch.c' */
|
||||
extern void keyboard_interrupt(void);
|
||||
extern char BSP_wait_polled_input(void);
|
||||
extern void _IBMPC_initVideo(void);
|
||||
|
||||
@@ -79,9 +83,10 @@ static void isr_on(const rtems_irq_connect_data *);
|
||||
static void isr_off(const rtems_irq_connect_data *);
|
||||
static int isr_is_on(const rtems_irq_connect_data *);
|
||||
|
||||
extern int rtems_kbpoll( void );
|
||||
|
||||
static rtems_irq_connect_data console_isr_data = {BSP_KEYBOARD,
|
||||
_IBMPC_keyboard_isr,
|
||||
keyboard_interrupt,
|
||||
isr_on,
|
||||
isr_off,
|
||||
isr_is_on};
|
||||
@@ -104,6 +109,44 @@ isr_is_on(const rtems_irq_connect_data *irq)
|
||||
return BSP_irq_enabled_at_i8259s(irq->name);
|
||||
}
|
||||
|
||||
extern char _IBMPC_inch(void);
|
||||
extern int rtems_kbpoll( void );
|
||||
|
||||
static int
|
||||
ibmpc_console_write(int minor, const char *buf, int len)
|
||||
{
|
||||
int count;
|
||||
for (count = 0; count < len; count++)
|
||||
{
|
||||
_IBMPC_outch( buf[ count ] );
|
||||
if( buf[ count ] == '\n')
|
||||
_IBMPC_outch( '\r' ); /* LF = LF + CR */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int kbd_poll_read( int minor )
|
||||
{
|
||||
if( rtems_kbpoll() )
|
||||
{
|
||||
int c = getch();
|
||||
return c;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
static void* termios_ttyp_console = NULL;
|
||||
void enq_key( char key )
|
||||
{
|
||||
if( termios_ttyp_console )
|
||||
{
|
||||
rtems_termios_enqueue_raw_characters(termios_ttyp_console, &key,1 );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void __assert (const char *file, int line, const char *msg)
|
||||
{
|
||||
static char exit_msg[] = "EXECUTIVE SHUTDOWN! Any key to reboot...";
|
||||
@@ -144,18 +187,26 @@ console_initialize(rtems_device_major_number major,
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
|
||||
/* Initialize the KBD interface */
|
||||
kbd_init();
|
||||
|
||||
/*
|
||||
* Set up TERMIOS
|
||||
*/
|
||||
rtems_termios_initialize ();
|
||||
|
||||
/*
|
||||
* The video was initialized in the start.s code and does not need
|
||||
* to be reinitialized.
|
||||
*/
|
||||
|
||||
|
||||
if(BSPConsolePort == BSP_CONSOLE_PORT_CONSOLE)
|
||||
{
|
||||
/* Install keyboard interrupt handler */
|
||||
status = BSP_install_rtems_irq_handler(&console_isr_data);
|
||||
|
||||
if (!status)
|
||||
if (!status)
|
||||
{
|
||||
printk("Error installing keyboard interrupt handler!\n");
|
||||
rtems_fatal_error_occurred(status);
|
||||
@@ -171,33 +222,26 @@ console_initialize(rtems_device_major_number major,
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Set up TERMIOS
|
||||
*/
|
||||
rtems_termios_initialize ();
|
||||
|
||||
/*
|
||||
* Do device-specific initialization
|
||||
*/
|
||||
|
||||
/* 9600-8-N-1 */
|
||||
BSP_uart_init(BSPConsolePort, 9600, 0);
|
||||
|
||||
|
||||
/* Set interrupt handler */
|
||||
if(BSPConsolePort == BSP_UART_COM1)
|
||||
{
|
||||
console_isr_data.name = BSP_UART_COM1_IRQ;
|
||||
console_isr_data.hdl = BSP_uart_termios_isr_com1;
|
||||
{
|
||||
console_isr_data.name = BSP_UART_COM1_IRQ;
|
||||
console_isr_data.hdl = BSP_uart_termios_isr_com1;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
assert(BSPConsolePort == BSP_UART_COM2);
|
||||
console_isr_data.name = BSP_UART_COM2_IRQ;
|
||||
console_isr_data.hdl = BSP_uart_termios_isr_com2;
|
||||
}
|
||||
|
||||
console_isr_data.name = BSP_UART_COM2_IRQ;
|
||||
console_isr_data.hdl = BSP_uart_termios_isr_com2;
|
||||
}
|
||||
status = BSP_install_rtems_irq_handler(&console_isr_data);
|
||||
|
||||
if (!status){
|
||||
@@ -269,7 +313,7 @@ console_open(rtems_device_major_number major,
|
||||
{
|
||||
NULL, /* firstOpen */
|
||||
console_last_close, /* lastClose */
|
||||
NULL, /* pollRead */
|
||||
NULL, /* pollRead */
|
||||
BSP_uart_termios_write_com1, /* write */
|
||||
conSetAttr, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
@@ -279,8 +323,23 @@ console_open(rtems_device_major_number major,
|
||||
|
||||
if(BSPConsolePort == BSP_CONSOLE_PORT_CONSOLE)
|
||||
{
|
||||
|
||||
/* Let's set the routines for termios to poll the
|
||||
* Kbd queue for data
|
||||
*/
|
||||
cb.pollRead = kbd_poll_read;
|
||||
cb.outputUsesInterrupts = 0;
|
||||
/* write the "echo" if it is on */
|
||||
cb.write = ibmpc_console_write;
|
||||
|
||||
cb.setAttributes = NULL;
|
||||
++console_open_count;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
status = rtems_termios_open (major, minor, arg, &cb);
|
||||
if(status != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
printk("Error openning console device\n");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
if(BSPConsolePort == BSP_UART_COM2)
|
||||
@@ -316,19 +375,7 @@ console_close(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
rtems_device_driver res = RTEMS_SUCCESSFUL;
|
||||
|
||||
if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE)
|
||||
{
|
||||
res = rtems_termios_close (arg);
|
||||
}
|
||||
else {
|
||||
if (--console_open_count == 0) {
|
||||
console_last_close(major, minor, arg);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
return rtems_termios_close (arg);
|
||||
} /* console_close */
|
||||
|
||||
|
||||
@@ -342,38 +389,7 @@ console_read(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
|
||||
char *buffer = rw_args->buffer;
|
||||
int count, maximum = rw_args->count;
|
||||
|
||||
if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE)
|
||||
{
|
||||
return rtems_termios_read (arg);
|
||||
}
|
||||
|
||||
for (count = 0; count < maximum; count++)
|
||||
{
|
||||
/* Get character */
|
||||
buffer[count] = _IBMPC_inch_sleep();
|
||||
|
||||
/* Echo character to screen */
|
||||
_IBMPC_outch(buffer[count]);
|
||||
if (buffer[count] == '\r')
|
||||
{
|
||||
_IBMPC_outch('\n'); /* CR = CR + LF */
|
||||
}
|
||||
|
||||
if (buffer[count] == '\n' || buffer[count] == '\r')
|
||||
{
|
||||
/* What if this goes past the end of the buffer? We're hosed. [bhc] */
|
||||
buffer[count++] = '\n';
|
||||
buffer[count] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rw_args->bytes_moved = count;
|
||||
return ((count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED);
|
||||
return rtems_termios_read( arg );
|
||||
} /* console_read */
|
||||
|
||||
|
||||
@@ -389,25 +405,21 @@ console_write(rtems_device_major_number major,
|
||||
{
|
||||
rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
|
||||
char *buffer = rw_args->buffer;
|
||||
int count, maximum = rw_args->count;
|
||||
int maximum = rw_args->count;
|
||||
|
||||
if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE)
|
||||
{
|
||||
return rtems_termios_write (arg);
|
||||
}
|
||||
|
||||
for (count = 0; count < maximum; count++)
|
||||
{
|
||||
_IBMPC_outch(buffer[count]);
|
||||
if (buffer[count] == '\n')
|
||||
_IBMPC_outch('\r'); /* LF = LF + CR */
|
||||
}
|
||||
|
||||
/* write data to VGA */
|
||||
ibmpc_console_write( minor, buffer, maximum );
|
||||
rw_args->bytes_moved = maximum;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
} /* console_write */
|
||||
|
||||
|
||||
extern int vt_ioctl( unsigned int cmd, unsigned long arg);
|
||||
|
||||
/*
|
||||
* Handle ioctl request.
|
||||
@@ -418,12 +430,25 @@ console_control(rtems_device_major_number major,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
if(BSPConsolePort != BSP_CONSOLE_PORT_CONSOLE)
|
||||
{
|
||||
return rtems_termios_ioctl (arg);
|
||||
}
|
||||
rtems_libio_ioctl_args_t *args = arg;
|
||||
switch (args->command)
|
||||
{
|
||||
default:
|
||||
if( vt_ioctl( args->command, (unsigned long)args->buffer ) != 0 )
|
||||
return rtems_termios_ioctl (arg);
|
||||
break;
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
case MW_UID_REGISTER_DEVICE:
|
||||
printk( "SerialMouse: reg=%s\n", args->buffer );
|
||||
register_kbd_msg_queue( args->buffer, 0 );
|
||||
break;
|
||||
|
||||
case MW_UID_UNREGISTER_DEVICE:
|
||||
unregister_kbd_msg_queue( 0 );
|
||||
break;
|
||||
}
|
||||
args->ioctl_return = 0;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
/* Do not edit this file! It was automatically generated by */
|
||||
/* loadkeys --mktable defkeymap.map > defkeymap.c */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/keyboard.h>
|
||||
#include <rtems/kd.h>
|
||||
|
||||
u_short plain_map[NR_KEYS] = {
|
||||
0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,
|
||||
0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009,
|
||||
0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69,
|
||||
0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73,
|
||||
0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b,
|
||||
0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76,
|
||||
0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c,
|
||||
0xf703, 0xf020, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104,
|
||||
0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307,
|
||||
0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
|
||||
0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a,
|
||||
0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
|
||||
0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
|
||||
0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
};
|
||||
|
||||
u_short shift_map[NR_KEYS] = {
|
||||
0xf200, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e,
|
||||
0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009,
|
||||
0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49,
|
||||
0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53,
|
||||
0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a,
|
||||
0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56,
|
||||
0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c,
|
||||
0xf703, 0xf020, 0xf207, 0xf10a, 0xf10b, 0xf10c, 0xf10d, 0xf10e,
|
||||
0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf213, 0xf203, 0xf307,
|
||||
0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
|
||||
0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf10a,
|
||||
0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
|
||||
0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116,
|
||||
0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
};
|
||||
|
||||
u_short altgr_map[NR_KEYS] = {
|
||||
0xf200, 0xf200, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200,
|
||||
0xf07b, 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200,
|
||||
0xfb71, 0xfb77, 0xf918, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69,
|
||||
0xfb6f, 0xfb70, 0xf200, 0xf07e, 0xf201, 0xf702, 0xf914, 0xfb73,
|
||||
0xf917, 0xf919, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf200,
|
||||
0xf200, 0xf200, 0xf700, 0xf200, 0xfb7a, 0xfb78, 0xf916, 0xfb76,
|
||||
0xf915, 0xfb6e, 0xfb6d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
|
||||
0xf703, 0xf200, 0xf207, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510,
|
||||
0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf202, 0xf911,
|
||||
0xf912, 0xf913, 0xf30b, 0xf90e, 0xf90f, 0xf910, 0xf30a, 0xf90b,
|
||||
0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516,
|
||||
0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
|
||||
0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
|
||||
0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
};
|
||||
|
||||
u_short ctrl_map[NR_KEYS] = {
|
||||
0xf200, 0xf200, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e,
|
||||
0xf01f, 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf200,
|
||||
0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009,
|
||||
0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf201, 0xf702, 0xf001, 0xf013,
|
||||
0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
|
||||
0xf007, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016,
|
||||
0xf002, 0xf00e, 0xf00d, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c,
|
||||
0xf703, 0xf000, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104,
|
||||
0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf204, 0xf307,
|
||||
0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
|
||||
0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf10a,
|
||||
0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
|
||||
0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
|
||||
0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
};
|
||||
|
||||
u_short shift_ctrl_map[NR_KEYS] = {
|
||||
0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200,
|
||||
0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009,
|
||||
0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013,
|
||||
0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
|
||||
0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016,
|
||||
0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
|
||||
0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307,
|
||||
0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
|
||||
0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
|
||||
0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
|
||||
0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
};
|
||||
|
||||
u_short alt_map[NR_KEYS] = {
|
||||
0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836,
|
||||
0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809,
|
||||
0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869,
|
||||
0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873,
|
||||
0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b,
|
||||
0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876,
|
||||
0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c,
|
||||
0xf703, 0xf820, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504,
|
||||
0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf907,
|
||||
0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901,
|
||||
0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a,
|
||||
0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
|
||||
0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
|
||||
0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
};
|
||||
|
||||
u_short ctrl_alt_map[NR_KEYS] = {
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809,
|
||||
0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813,
|
||||
0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200,
|
||||
0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816,
|
||||
0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
|
||||
0xf703, 0xf200, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504,
|
||||
0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf200, 0xf307,
|
||||
0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
|
||||
0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf50a,
|
||||
0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
|
||||
0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c,
|
||||
0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
|
||||
0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
|
||||
};
|
||||
|
||||
ushort *key_maps[MAX_NR_KEYMAPS] = {
|
||||
plain_map, shift_map, altgr_map, 0,
|
||||
ctrl_map, shift_ctrl_map, 0, 0,
|
||||
alt_map, 0, 0, 0,
|
||||
ctrl_alt_map, 0
|
||||
};
|
||||
|
||||
unsigned int keymap_count = 7;
|
||||
|
||||
/*
|
||||
* Philosophy: most people do not define more strings, but they who do
|
||||
* often want quite a lot of string space. So, we statically allocate
|
||||
* the default and allocate dynamically in chunks of 512 bytes.
|
||||
*/
|
||||
|
||||
char func_buf[] = {
|
||||
'\033', '[', '[', 'A', 0,
|
||||
'\033', '[', '[', 'B', 0,
|
||||
'\033', '[', '[', 'C', 0,
|
||||
'\033', '[', '[', 'D', 0,
|
||||
'\033', '[', '[', 'E', 0,
|
||||
'\033', '[', '1', '7', '~', 0,
|
||||
'\033', '[', '1', '8', '~', 0,
|
||||
'\033', '[', '1', '9', '~', 0,
|
||||
'\033', '[', '2', '0', '~', 0,
|
||||
'\033', '[', '2', '1', '~', 0,
|
||||
'\033', '[', '2', '3', '~', 0,
|
||||
'\033', '[', '2', '4', '~', 0,
|
||||
'\033', '[', '2', '5', '~', 0,
|
||||
'\033', '[', '2', '6', '~', 0,
|
||||
'\033', '[', '2', '8', '~', 0,
|
||||
'\033', '[', '2', '9', '~', 0,
|
||||
'\033', '[', '3', '1', '~', 0,
|
||||
'\033', '[', '3', '2', '~', 0,
|
||||
'\033', '[', '3', '3', '~', 0,
|
||||
'\033', '[', '3', '4', '~', 0,
|
||||
'\033', '[', '1', '~', 0,
|
||||
'\033', '[', '2', '~', 0,
|
||||
'\033', '[', '3', '~', 0,
|
||||
'\033', '[', '4', '~', 0,
|
||||
'\033', '[', '5', '~', 0,
|
||||
'\033', '[', '6', '~', 0,
|
||||
'\033', '[', 'M', 0,
|
||||
'\033', '[', 'P', 0,
|
||||
};
|
||||
|
||||
char *funcbufptr = func_buf;
|
||||
int funcbufsize = sizeof(func_buf);
|
||||
int funcbufleft = 0; /* space left */
|
||||
|
||||
char *func_table[MAX_NR_FUNC] = {
|
||||
func_buf + 0,
|
||||
func_buf + 5,
|
||||
func_buf + 10,
|
||||
func_buf + 15,
|
||||
func_buf + 20,
|
||||
func_buf + 25,
|
||||
func_buf + 31,
|
||||
func_buf + 37,
|
||||
func_buf + 43,
|
||||
func_buf + 49,
|
||||
func_buf + 55,
|
||||
func_buf + 61,
|
||||
func_buf + 67,
|
||||
func_buf + 73,
|
||||
func_buf + 79,
|
||||
func_buf + 85,
|
||||
func_buf + 91,
|
||||
func_buf + 97,
|
||||
func_buf + 103,
|
||||
func_buf + 109,
|
||||
func_buf + 115,
|
||||
func_buf + 120,
|
||||
func_buf + 125,
|
||||
func_buf + 130,
|
||||
func_buf + 135,
|
||||
func_buf + 140,
|
||||
func_buf + 145,
|
||||
0,
|
||||
0,
|
||||
func_buf + 149,
|
||||
0,
|
||||
};
|
||||
|
||||
struct kbdiacr accent_table[MAX_DIACR] = {
|
||||
{'`', 'A', '\300'}, {'`', 'a', '\340'},
|
||||
{'\'', 'A', '\301'}, {'\'', 'a', '\341'},
|
||||
{'^', 'A', '\302'}, {'^', 'a', '\342'},
|
||||
{'~', 'A', '\303'}, {'~', 'a', '\343'},
|
||||
{'"', 'A', '\304'}, {'"', 'a', '\344'},
|
||||
{'O', 'A', '\305'}, {'o', 'a', '\345'},
|
||||
{'0', 'A', '\305'}, {'0', 'a', '\345'},
|
||||
{'A', 'A', '\305'}, {'a', 'a', '\345'},
|
||||
{'A', 'E', '\306'}, {'a', 'e', '\346'},
|
||||
{',', 'C', '\307'}, {',', 'c', '\347'},
|
||||
{'`', 'E', '\310'}, {'`', 'e', '\350'},
|
||||
{'\'', 'E', '\311'}, {'\'', 'e', '\351'},
|
||||
{'^', 'E', '\312'}, {'^', 'e', '\352'},
|
||||
{'"', 'E', '\313'}, {'"', 'e', '\353'},
|
||||
{'`', 'I', '\314'}, {'`', 'i', '\354'},
|
||||
{'\'', 'I', '\315'}, {'\'', 'i', '\355'},
|
||||
{'^', 'I', '\316'}, {'^', 'i', '\356'},
|
||||
{'"', 'I', '\317'}, {'"', 'i', '\357'},
|
||||
{'-', 'D', '\320'}, {'-', 'd', '\360'},
|
||||
{'~', 'N', '\321'}, {'~', 'n', '\361'},
|
||||
{'`', 'O', '\322'}, {'`', 'o', '\362'},
|
||||
{'\'', 'O', '\323'}, {'\'', 'o', '\363'},
|
||||
{'^', 'O', '\324'}, {'^', 'o', '\364'},
|
||||
{'~', 'O', '\325'}, {'~', 'o', '\365'},
|
||||
{'"', 'O', '\326'}, {'"', 'o', '\366'},
|
||||
{'/', 'O', '\330'}, {'/', 'o', '\370'},
|
||||
{'`', 'U', '\331'}, {'`', 'u', '\371'},
|
||||
{'\'', 'U', '\332'}, {'\'', 'u', '\372'},
|
||||
{'^', 'U', '\333'}, {'^', 'u', '\373'},
|
||||
{'"', 'U', '\334'}, {'"', 'u', '\374'},
|
||||
{'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
|
||||
{'T', 'H', '\336'}, {'t', 'h', '\376'},
|
||||
{'s', 's', '\337'}, {'"', 'y', '\377'},
|
||||
{'s', 'z', '\337'}, {'i', 'j', '\377'},
|
||||
};
|
||||
|
||||
unsigned int accent_table_size = 68;
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// $Header$
|
||||
//
|
||||
// Copyright (c) 2000 - Rosimildo da Silva ( rdasilva@connecttel.com )
|
||||
//
|
||||
// MODULE DESCRIPTION:
|
||||
// This module implements the micro FB driver for "Bare VGA". It uses the
|
||||
// routines for "bare hardware" that comes with MicroWindows.
|
||||
//
|
||||
// MODIFICATION/HISTORY:
|
||||
//
|
||||
// $Log$
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <irq.h>
|
||||
#include <rtems/libio.h>
|
||||
|
||||
#include <rtems/mw_fb.h>
|
||||
|
||||
/* these routines are defined in the microwindows code. This
|
||||
driver is here more as an example of how to implement and
|
||||
use the micro FB interface
|
||||
*/
|
||||
extern void ega_hwinit( void );
|
||||
extern void ega_hwterm( void );
|
||||
|
||||
|
||||
/* screen information for the VGA driver */
|
||||
static struct fb_screeninfo fb_info =
|
||||
{
|
||||
640, 480, /* screen size x, y */
|
||||
4, /* bits per pixel */
|
||||
80, /* chars per line */
|
||||
(volatile char *)0xA0000, /* buffer pointer */
|
||||
0x10000, /* buffer size */
|
||||
FB_TYPE_VGA_PLANES, /* type of dsplay */
|
||||
FB_VISUAL_PSEUDOCOLOR /* color scheme used */
|
||||
};
|
||||
|
||||
|
||||
static __u16 red16[] = {
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa,
|
||||
0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff
|
||||
};
|
||||
static __u16 green16[] = {
|
||||
0x0000, 0x0000, 0xaaaa, 0xaaaa, 0x0000, 0x0000, 0x5555, 0xaaaa,
|
||||
0x5555, 0x5555, 0xffff, 0xffff, 0x5555, 0x5555, 0xffff, 0xffff
|
||||
};
|
||||
static __u16 blue16[] = {
|
||||
0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa,
|
||||
0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff
|
||||
};
|
||||
|
||||
/*
|
||||
* fbvga device driver INITIALIZE entry point.
|
||||
*/
|
||||
rtems_device_driver
|
||||
fbvga_initialize( rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
printk( "FBVGA -- driver initializing..\n" );
|
||||
/*
|
||||
* Register the device
|
||||
*/
|
||||
status = rtems_io_register_name ("/dev/fb0", major, 0);
|
||||
if (status != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
printk("Error registering FBVGA device!\n");
|
||||
rtems_fatal_error_occurred( status );
|
||||
}
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fbvga device driver OPEN entry point
|
||||
*/
|
||||
rtems_device_driver
|
||||
fbvga_open( rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
/* rtems_status_code status; */
|
||||
printk( "FBVGA open called.\n" );
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/*
|
||||
* fbvga device driver CLOSE entry point
|
||||
*/
|
||||
rtems_device_driver
|
||||
fbvga_close(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
printk( "FBVGA close called.\n" );
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fbvga device driver READ entry point.
|
||||
* Read characters from the PS/2 mouse.
|
||||
*/
|
||||
rtems_device_driver
|
||||
fbvga_read( rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
|
||||
printk( "FBVGA read called.\n" );
|
||||
rw_args->bytes_moved = 0;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fbvga device driver WRITE entry point.
|
||||
* Write characters to the PS/2 mouse.
|
||||
*/
|
||||
rtems_device_driver
|
||||
fbvga_write( rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg)
|
||||
{
|
||||
rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
|
||||
printk( "FBVGA write called.\n" );
|
||||
rw_args->bytes_moved = 0;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
static int get_screen_info( struct fb_screeninfo *info )
|
||||
{
|
||||
*info = fb_info;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int get_palette( struct fb_cmap *cmap )
|
||||
{
|
||||
__u32 i;
|
||||
|
||||
if( cmap->start + cmap->len >= 16 )
|
||||
return 1;
|
||||
|
||||
for( i = 0; i < cmap->len; i++ )
|
||||
{
|
||||
cmap->red[ cmap->start + i ] = red16[ cmap->start + i ];
|
||||
cmap->green[ cmap->start + i ] = green16[ cmap->start + i ];
|
||||
cmap->blue[ cmap->start + i ] = blue16[ cmap->start + i ];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int set_palette( struct fb_cmap *cmap )
|
||||
{
|
||||
__u32 i;
|
||||
|
||||
if( cmap->start + cmap->len >= 16 )
|
||||
return 1;
|
||||
|
||||
for( i = 0; i < cmap->len; i++ )
|
||||
{
|
||||
red16[ cmap->start + i ] = cmap->red[ cmap->start + i ];
|
||||
green16[ cmap->start + i ] = cmap->green[ cmap->start + i ];
|
||||
blue16[ cmap->start + i ] = cmap->blue[ cmap->start + i ];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* IOCTL entry point -- This method is called to carry
|
||||
* all services of this interface.
|
||||
*/
|
||||
rtems_device_driver
|
||||
fbvga_control( rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
rtems_libio_ioctl_args_t *args = arg;
|
||||
printk( "FBVGA ioctl called, cmd=%x\n", args->command );
|
||||
switch( args->command )
|
||||
{
|
||||
case FB_SCREENINFO:
|
||||
args->ioctl_return = get_screen_info( args->buffer );
|
||||
break;
|
||||
case FB_GETPALETTE:
|
||||
args->ioctl_return = get_palette( args->buffer );
|
||||
break;
|
||||
case FB_SETPALETTE:
|
||||
args->ioctl_return = set_palette( args->buffer );
|
||||
break;
|
||||
|
||||
/* this function would execute one of the routines of the
|
||||
* interface based on the operation requested
|
||||
*/
|
||||
case FB_EXEC_FUNCTION:
|
||||
{
|
||||
struct fb_exec_function *env = args->buffer;
|
||||
switch( env->func_no )
|
||||
{
|
||||
case FB_FUNC_ENTER_GRAPHICS:
|
||||
/* enter graphics mode*/
|
||||
ega_hwinit();
|
||||
break;
|
||||
|
||||
case FB_FUNC_EXIT_GRAPHICS:
|
||||
/* leave graphics mode*/
|
||||
ega_hwterm();
|
||||
break;
|
||||
|
||||
case FB_FUNC_IS_DIRTY:
|
||||
break;
|
||||
|
||||
case FB_FUNC_GET_MODE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* no break on purpose */
|
||||
default:
|
||||
args->ioctl_return = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#ifndef __fbvga_drv__
|
||||
#define __fbvga_drv__
|
||||
/***************************************************************************
|
||||
*
|
||||
* $Header$
|
||||
*
|
||||
* Copyright (c) 2000 -- Rosimildo da Silva.
|
||||
*
|
||||
* MODULE DESCRIPTION:
|
||||
* Prototype routines for the fbvga driver.
|
||||
*
|
||||
* by: Rosimildo da Silva:
|
||||
* rdasilva@connecttel.com
|
||||
* http://www.connecttel.com
|
||||
*
|
||||
* MODIFICATION/HISTORY:
|
||||
*
|
||||
* $Log$
|
||||
****************************************************************************/
|
||||
|
||||
/* functions */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* fbvga prototype entry points */
|
||||
rtems_device_driver fbvga_initialize(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver fbvga_open(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver fbvga_control(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver fbvga_close(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
|
||||
rtems_device_driver fbvga_read(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver fbvga_write(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver fbvga_control(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
#define FBVGA_DRIVER_TABLE_ENTRY \
|
||||
{ fbvga_initialize, fbvga_open, fbvga_close, \
|
||||
fbvga_read, fbvga_write, fbvga_control }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* end of include file */
|
||||
|
||||
#endif /* __fbvga_drv__ */
|
||||
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* linux/include/asm-i386/keyboard.h
|
||||
*
|
||||
* Created 3 Nov 1996 by Geert Uytterhoeven
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the i386 architecture specific keyboard definitions
|
||||
*/
|
||||
|
||||
#ifndef _I386_KEYBOARD_H
|
||||
#define _I386_KEYBOARD_H
|
||||
|
||||
#include <i386_io.h>
|
||||
|
||||
#define KEYBOARD_IRQ 1
|
||||
#define DISABLE_KBD_DURING_INTERRUPTS 0
|
||||
|
||||
extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
|
||||
extern int pckbd_getkeycode(unsigned int scancode);
|
||||
extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
|
||||
char raw_mode);
|
||||
extern char pckbd_unexpected_up(unsigned char keycode);
|
||||
extern void pckbd_leds(unsigned char leds);
|
||||
extern void pckbd_init_hw(void);
|
||||
extern unsigned char pckbd_sysrq_xlate[128];
|
||||
|
||||
#define kbd_setkeycode pckbd_setkeycode
|
||||
#define kbd_getkeycode pckbd_getkeycode
|
||||
#define kbd_translate pckbd_translate
|
||||
#define kbd_unexpected_up pckbd_unexpected_up
|
||||
#define kbd_leds pckbd_leds
|
||||
#define kbd_init_hw pckbd_init_hw
|
||||
#define kbd_sysrq_xlate pckbd_sysrq_xlate
|
||||
|
||||
#define SYSRQ_KEY 0x54
|
||||
|
||||
/* resource allocation */
|
||||
#define kbd_request_region() /* request_region(0x60, 16, "keyboard") */
|
||||
#define kbd_request_irq(handler) /* request_irq(KEYBOARD_IRQ, handler, 0, "keyboard", NULL) */
|
||||
|
||||
/* How to access the keyboard macros on this platform. */
|
||||
#define kbd_read_input() inb(KBD_DATA_REG)
|
||||
#define kbd_read_status() inb(KBD_STATUS_REG)
|
||||
#define kbd_write_output(val) outb(val, KBD_DATA_REG)
|
||||
#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
|
||||
|
||||
/* Some stoneage hardware needs delays after some operations. */
|
||||
#define kbd_pause() do { } while(0)
|
||||
|
||||
/*
|
||||
* Machine specific bits for the PS/2 driver
|
||||
*/
|
||||
|
||||
#define AUX_IRQ 12
|
||||
|
||||
#define aux_request_irq(hand, dev_id) /* request_irq(AUX_IRQ, hand, SA_SHIRQ, "PS/2 Mouse", dev_id) */
|
||||
|
||||
#define aux_free_irq(dev_id) /* free_irq(AUX_IRQ, dev_id) */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* include/linux/pc_keyb.h
|
||||
*
|
||||
* PC Keyboard And Keyboard Controller
|
||||
*
|
||||
* (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configuration Switches
|
||||
*/
|
||||
|
||||
#undef KBD_REPORT_ERR /* Report keyboard errors */
|
||||
#define KBD_REPORT_UNKN /* Report unknown scan codes */
|
||||
#define KBD_REPORT_TIMEOUTS /* Report keyboard timeouts */
|
||||
#undef KBD_IS_FOCUS_9000 /* We have the brain-damaged FOCUS-9000 keyboard */
|
||||
#undef INITIALIZE_MOUSE /* Define if your PS/2 mouse needs initialization. */
|
||||
|
||||
|
||||
|
||||
#define KBD_INIT_TIMEOUT 1000 /* Timeout in ms for initializing the keyboard */
|
||||
#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
|
||||
#define KBD_TIMEOUT 1000 /* Timeout in ms for keyboard command acknowledge */
|
||||
|
||||
/*
|
||||
* Internal variables of the driver
|
||||
*/
|
||||
|
||||
extern unsigned char pckbd_read_mask;
|
||||
extern unsigned char aux_device_present;
|
||||
|
||||
/*
|
||||
* Keyboard Controller Registers on normal PCs.
|
||||
*/
|
||||
|
||||
#define KBD_STATUS_REG 0x64 /* Status register (R) */
|
||||
#define KBD_CNTL_REG 0x64 /* Controller command register (W) */
|
||||
#define KBD_DATA_REG 0x60 /* Keyboard data register (R/W) */
|
||||
|
||||
/*
|
||||
* Keyboard Controller Commands
|
||||
*/
|
||||
|
||||
#define KBD_CCMD_READ_MODE 0x20 /* Read mode bits */
|
||||
#define KBD_CCMD_WRITE_MODE 0x60 /* Write mode bits */
|
||||
#define KBD_CCMD_GET_VERSION 0xA1 /* Get controller version */
|
||||
#define KBD_CCMD_MOUSE_DISABLE 0xA7 /* Disable mouse interface */
|
||||
#define KBD_CCMD_MOUSE_ENABLE 0xA8 /* Enable mouse interface */
|
||||
#define KBD_CCMD_TEST_MOUSE 0xA9 /* Mouse interface test */
|
||||
#define KBD_CCMD_SELF_TEST 0xAA /* Controller self test */
|
||||
#define KBD_CCMD_KBD_TEST 0xAB /* Keyboard interface test */
|
||||
#define KBD_CCMD_KBD_DISABLE 0xAD /* Keyboard interface disable */
|
||||
#define KBD_CCMD_KBD_ENABLE 0xAE /* Keyboard interface enable */
|
||||
#define KBD_CCMD_WRITE_AUX_OBUF 0xD3 /* Write to output buffer as if
|
||||
initiated by the auxiliary device */
|
||||
#define KBD_CCMD_WRITE_MOUSE 0xD4 /* Write the following byte to the mouse */
|
||||
|
||||
/*
|
||||
* Keyboard Commands
|
||||
*/
|
||||
|
||||
#define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */
|
||||
#define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */
|
||||
#define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
|
||||
#define KBD_CMD_DISABLE 0xF5 /* Disable scanning */
|
||||
#define KBD_CMD_RESET 0xFF /* Reset */
|
||||
|
||||
/*
|
||||
* Keyboard Replies
|
||||
*/
|
||||
|
||||
#define KBD_REPLY_POR 0xAA /* Power on reset */
|
||||
#define KBD_REPLY_ACK 0xFA /* Command ACK */
|
||||
#define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */
|
||||
|
||||
/*
|
||||
* Status Register Bits
|
||||
*/
|
||||
|
||||
#define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */
|
||||
#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
|
||||
#define KBD_STAT_SELFTEST 0x04 /* Self test successful */
|
||||
#define KBD_STAT_CMD 0x08 /* Last write was a command write (0=data) */
|
||||
#define KBD_STAT_UNLOCKED 0x10 /* Zero if keyboard locked */
|
||||
#define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */
|
||||
#define KBD_STAT_GTO 0x40 /* General receive/xmit timeout */
|
||||
#define KBD_STAT_PERR 0x80 /* Parity error */
|
||||
|
||||
#define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
|
||||
|
||||
/*
|
||||
* Controller Mode Register Bits
|
||||
*/
|
||||
|
||||
#define KBD_MODE_KBD_INT 0x01 /* Keyboard data generate IRQ1 */
|
||||
#define KBD_MODE_MOUSE_INT 0x02 /* Mouse data generate IRQ12 */
|
||||
#define KBD_MODE_SYS 0x04 /* The system flag (?) */
|
||||
#define KBD_MODE_NO_KEYLOCK 0x08 /* The keylock doesn't affect the keyboard if set */
|
||||
#define KBD_MODE_DISABLE_KBD 0x10 /* Disable keyboard interface */
|
||||
#define KBD_MODE_DISABLE_MOUSE 0x20 /* Disable mouse interface */
|
||||
#define KBD_MODE_KCC 0x40 /* Scan code conversion to PC format */
|
||||
#define KBD_MODE_RFU 0x80
|
||||
|
||||
/*
|
||||
* Mouse Commands
|
||||
*/
|
||||
|
||||
#define AUX_SET_RES 0xE8 /* Set resolution */
|
||||
#define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */
|
||||
#define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */
|
||||
#define AUX_GET_SCALE 0xE9 /* Get scaling factor */
|
||||
#define AUX_SET_STREAM 0xEA /* Set stream mode */
|
||||
#define AUX_SET_SAMPLE 0xF3 /* Set sample rate */
|
||||
#define AUX_ENABLE_DEV 0xF4 /* Enable aux device */
|
||||
#define AUX_DISABLE_DEV 0xF5 /* Disable aux device */
|
||||
#define AUX_RESET 0xFF /* Reset aux device */
|
||||
#define AUX_ACK 0xFA /* Command byte ACK. */
|
||||
|
||||
#define AUX_BUF_SIZE 2048 /* This might be better divisible by
|
||||
three to make overruns stay in sync
|
||||
but then the read function would need
|
||||
a lock etc - ick */
|
||||
|
||||
#define mark_bh(x)
|
||||
|
||||
#endif /* _I386_KEYBOARD_H */
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
| With the following copyright notice:
|
||||
| With the following copyright notice:
|
||||
| **************************************************************************
|
||||
| * COPYRIGHT (c) 1989-1999.
|
||||
| * COPYRIGHT (c) 1989-1998.
|
||||
| * On-Line Applications Research Corporation (OAR).
|
||||
| * Copyright assigned to U.S. Government, 1994.
|
||||
| *
|
||||
| * The license and distribution terms for this file may be
|
||||
| * found in found in the file LICENSE in this distribution or at
|
||||
@@ -35,38 +36,9 @@
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Constants
|
||||
+--------------------------------------------------------------------------*/
|
||||
#define KBD_CTL 0x61 /* -------------------------------- */
|
||||
#define KBD_DATA 0x60 /* Ports for PC keyboard controller */
|
||||
#define KBD_STATUS 0x64 /* -------------------------------- */
|
||||
#define KBD_BUF_SIZE 256
|
||||
|
||||
#define KBD_BUF_SIZE 256
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Global Variables
|
||||
+--------------------------------------------------------------------------*/
|
||||
static char key_map[] =
|
||||
{
|
||||
0,033,'1','2','3','4','5','6','7','8','9','0','-','=','\b','\t',
|
||||
'q','w','e','r','t','y','u','i','o','p','[',']',015,0x80,
|
||||
'a','s','d','f','g','h','j','k','l',';',047,0140,0x80,
|
||||
0134,'z','x','c','v','b','n','m',',','.','/',0x80,
|
||||
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,'0',0177
|
||||
}; /* Keyboard scancode -> character map with no modifiers. */
|
||||
|
||||
static char shift_map[] =
|
||||
{
|
||||
0,033,'!','@','#','$','%','^','&','*','(',')','_','+','\b','\t',
|
||||
'Q','W','E','R','T','Y','U','I','O','P','{','}',015,0x80,
|
||||
'A','S','D','F','G','H','J','K','L',':',042,'~',0x80,
|
||||
'|','Z','X','C','V','B','N','M','<','>','?',0x80,
|
||||
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0x80,0x80,0x80,0x80,'7','8','9',0x80,'4','5','6',0x80,
|
||||
'1','2','3','0',177
|
||||
}; /* Keyboard scancode -> character map with SHIFT key modifier. */
|
||||
|
||||
static char kbd_buffer[KBD_BUF_SIZE];
|
||||
static unsigned short kbd_buffer[KBD_BUF_SIZE];
|
||||
static rtems_unsigned16 kbd_first = 0;
|
||||
static rtems_unsigned16 kbd_last = 0;
|
||||
static rtems_unsigned16 kbd_end = KBD_BUF_SIZE - 1;
|
||||
@@ -84,249 +56,43 @@ void rtemsReboot(void)
|
||||
outport_byte(0x64, 0xFE); /* use keyboard controler to do the job... */
|
||||
} /* rtemsReboot */
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Function: _IBMPC_scankey
|
||||
| Description: This function can be called during a poll for input, or by
|
||||
| an ISR. Basically any time you want to process a keypress.
|
||||
| Global Variables: key_map, shift_map.
|
||||
| Arguments: outChar - character read in case of a valid reading,
|
||||
| otherwise unchanged.
|
||||
| Returns: TRUE in case a valid character has been read,
|
||||
| FALSE otherwise.
|
||||
+--------------------------------------------------------------------------*/
|
||||
rtems_boolean
|
||||
_IBMPC_scankey(char *outChar)
|
||||
|
||||
|
||||
#define disable __asm__ __volatile__("cli")
|
||||
#define enable __asm__ __volatile__("sti");
|
||||
/*
|
||||
* Check if a key has been pressed. This is a non-destructive
|
||||
* call, meaning, it keeps the key in the buffer.
|
||||
*/
|
||||
int rtems_kbpoll( void )
|
||||
{
|
||||
unsigned char inChar;
|
||||
static int alt_pressed = 0;
|
||||
static int ctrl_pressed = 0;
|
||||
static int shift_pressed = 0;
|
||||
static int caps_pressed = 0;
|
||||
static int extended = 0;
|
||||
int rc;
|
||||
disable;
|
||||
rc = ( kbd_first != kbd_last ) ? TRUE : FALSE;
|
||||
enable;
|
||||
return rc;
|
||||
}
|
||||
|
||||
*outChar = NULL; /* default value if we return FALSE */
|
||||
|
||||
/* Read keyboard controller, toggle enable */
|
||||
inport_byte(KBD_CTL, inChar);
|
||||
outport_byte(KBD_CTL, inChar & ~0x80);
|
||||
outport_byte(KBD_CTL, inChar | 0x80);
|
||||
outport_byte(KBD_CTL, inChar & ~0x80);
|
||||
|
||||
/* See if it has data */
|
||||
inport_byte(KBD_STATUS, inChar);
|
||||
if ((inChar & 0x01) == 0)
|
||||
return FALSE;
|
||||
|
||||
/* Read the data. Handle nonsense with shift, control, etc. */
|
||||
inport_byte(KBD_DATA, inChar);
|
||||
|
||||
if (extended)
|
||||
extended--;
|
||||
|
||||
switch (inChar)
|
||||
int getch( void )
|
||||
{
|
||||
int c;
|
||||
while( kbd_first == kbd_last )
|
||||
{
|
||||
case 0xe0:
|
||||
extended = 2;
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case 0x38:
|
||||
alt_pressed = 1;
|
||||
return FALSE;
|
||||
break;
|
||||
case 0xb8:
|
||||
alt_pressed = 0;
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case 0x1d:
|
||||
ctrl_pressed = 1;
|
||||
return FALSE;
|
||||
break;
|
||||
case 0x9d:
|
||||
ctrl_pressed = 0;
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case 0x2a:
|
||||
if (extended)
|
||||
return FALSE;
|
||||
case 0x36:
|
||||
shift_pressed = 1;
|
||||
return FALSE;
|
||||
break;
|
||||
case 0xaa:
|
||||
if (extended)
|
||||
return FALSE;
|
||||
case 0xb6:
|
||||
shift_pressed = 0;
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case 0x3a:
|
||||
caps_pressed = 1;
|
||||
return FALSE;
|
||||
break;
|
||||
case 0xba:
|
||||
caps_pressed = 0;
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case 0x53:
|
||||
if (ctrl_pressed && alt_pressed)
|
||||
rtemsReboot(); /* ctrl+alt+del -> reboot */
|
||||
break;
|
||||
|
||||
/*
|
||||
* Ignore unrecognized keys--usually arrow and such
|
||||
*/
|
||||
default:
|
||||
if ((inChar & 0x80) || (inChar > 0x39))
|
||||
/* High-bit on means key is being released, not pressed */
|
||||
return FALSE;
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
/* Strip high bit, look up in our map */
|
||||
inChar &= 0x7f;
|
||||
if (ctrl_pressed)
|
||||
{
|
||||
*outChar = key_map[inChar];
|
||||
*outChar &= 037;
|
||||
rtems_task_wake_after( 10 );
|
||||
}
|
||||
else
|
||||
{
|
||||
*outChar = shift_pressed ? shift_map[inChar] : key_map[inChar];
|
||||
if (caps_pressed)
|
||||
{
|
||||
if (*outChar >= 'A' && *outChar <= 'Z')
|
||||
*outChar += 'a' - 'A';
|
||||
else if (*outChar >= 'a' && *outChar <= 'z')
|
||||
*outChar -= 'a' - 'A';
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} /* _IBMPC_scankey */
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Function: _IBMPC_keyboard_isr
|
||||
| Description: Interrupt Service Routine for keyboard (0x01) IRQ.
|
||||
| Global Variables: kbd_buffer, kbd_first, kbd_last.
|
||||
| Arguments: vector - standard RTEMS argument - see documentation.
|
||||
| Returns: standard return value - see documentation.
|
||||
+--------------------------------------------------------------------------*/
|
||||
void _IBMPC_keyboard_isr()
|
||||
{
|
||||
if (_IBMPC_scankey(&kbd_buffer[kbd_last]))
|
||||
{
|
||||
/* Got one; save it if there is enough room in buffer. */
|
||||
unsigned int next = (kbd_last == kbd_end) ? 0 : kbd_last + 1;
|
||||
|
||||
if (next != kbd_first)
|
||||
{
|
||||
kbd_last = next;
|
||||
}
|
||||
}
|
||||
} /* _IBMPC_keyboard_isr */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Function: _IBMPC_chrdy
|
||||
| Description: Check keyboard ISR buffer and return character if not empty.
|
||||
| Global Variables: kbd_buffer, kbd_first, kbd_last.
|
||||
| Arguments: c - character read if keyboard buffer not empty, otherwise
|
||||
| unchanged.
|
||||
| Returns: TRUE if keyboard buffer not empty, FALSE otherwise.
|
||||
+--------------------------------------------------------------------------*/
|
||||
rtems_boolean
|
||||
_IBMPC_chrdy(char *c)
|
||||
{
|
||||
/* FIX ME!!! It doesn't work without something like the following line.
|
||||
Find out why! */
|
||||
printk("");
|
||||
|
||||
/* Check buffer our ISR builds */
|
||||
if (kbd_first != kbd_last)
|
||||
{
|
||||
*c = kbd_buffer[kbd_first];
|
||||
|
||||
kbd_first = (kbd_first + 1) % KBD_BUF_SIZE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
} /* _IBMPC_chrdy */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Function: _IBMPC_inch
|
||||
| Description: Poll keyboard until a character is ready and return it.
|
||||
| Global Variables: None.
|
||||
| Arguments: None.
|
||||
| Returns: character read from keyboard.
|
||||
+--------------------------------------------------------------------------*/
|
||||
char
|
||||
_IBMPC_inch(void)
|
||||
{
|
||||
char c;
|
||||
while (!_IBMPC_chrdy(&c))
|
||||
continue;
|
||||
|
||||
return c;
|
||||
} /* _IBMPC_inch */
|
||||
|
||||
|
||||
/*
|
||||
* Routine that can be used before interrupt management is initialized.
|
||||
*/
|
||||
|
||||
char
|
||||
BSP_wait_polled_input(void)
|
||||
{
|
||||
char c;
|
||||
while (!_IBMPC_scankey(&c))
|
||||
continue;
|
||||
|
||||
c = kbd_buffer[ kbd_first ];
|
||||
kbd_first = (kbd_first + 1) % KBD_BUF_SIZE;
|
||||
return c;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Function: _IBMPC_inch_sleep
|
||||
| Description: If charcter is ready return it, otherwise sleep until
|
||||
| it is ready
|
||||
| Global Variables: None.
|
||||
| Arguments: None.
|
||||
| Returns: character read from keyboard.
|
||||
+--------------------------------------------------------------------------*/
|
||||
char
|
||||
_IBMPC_inch_sleep(void)
|
||||
void add_to_queue( unsigned short b )
|
||||
{
|
||||
char c;
|
||||
rtems_interval ticks_per_second;
|
||||
|
||||
ticks_per_second = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(_IBMPC_chrdy(&c))
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
if(ticks_per_second == 0)
|
||||
{
|
||||
rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND,
|
||||
&ticks_per_second);
|
||||
}
|
||||
rtems_task_wake_after((ticks_per_second+24)/25);
|
||||
}
|
||||
|
||||
return c;
|
||||
} /* _IBMPC_inch */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int next;
|
||||
kbd_buffer[ kbd_last ] = b;
|
||||
next = (kbd_last == kbd_end) ? 0 : kbd_last + 1;
|
||||
if( next != kbd_first )
|
||||
{
|
||||
kbd_last = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// $Header$
|
||||
//
|
||||
// MODULE DESCRIPTION:
|
||||
//
|
||||
// This module was based on the Linux version kd.h
|
||||
//
|
||||
// by: Rosimildo da Silva: rdasilva@connecttel.com
|
||||
//
|
||||
// MODIFICATION/HISTORY:
|
||||
// $Log$
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_KD_H
|
||||
#define _LINUX_KD_H
|
||||
#include <sys/types.h>
|
||||
|
||||
/* 0x4B is 'K', to avoid collision with termios and vt */
|
||||
|
||||
#define KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
|
||||
#define KDMKTONE 0x4B30 /* generate tone */
|
||||
|
||||
#define KDGETLED 0x4B31 /* return current led state */
|
||||
#define KDSETLED 0x4B32 /* set led state [lights, not flags] */
|
||||
#define LED_SCR 0x01 /* scroll lock led */
|
||||
#define LED_CAP 0x04 /* caps lock led */
|
||||
#define LED_NUM 0x02 /* num lock led */
|
||||
|
||||
#define KDGKBTYPE 0x4B33 /* get keyboard type */
|
||||
#define KB_84 0x01
|
||||
#define KB_101 0x02 /* this is what we always answer */
|
||||
#define KB_OTHER 0x03
|
||||
|
||||
#define KDSETMODE 0x4B3A /* set text/graphics mode */
|
||||
#define KD_TEXT 0x00
|
||||
#define KD_GRAPHICS 0x01
|
||||
#define KD_TEXT0 0x02 /* obsolete */
|
||||
#define KD_TEXT1 0x03 /* obsolete */
|
||||
#define KDGETMODE 0x4B3B /* get current mode */
|
||||
|
||||
#define K_RAW 0x00
|
||||
#define K_XLATE 0x01
|
||||
#define K_MEDIUMRAW 0x02
|
||||
#define K_UNICODE 0x03
|
||||
#define KDGKBMODE 0x4B44 /* gets current keyboard mode */
|
||||
#define KDSKBMODE 0x4B45 /* sets current keyboard mode */
|
||||
|
||||
#define K_METABIT 0x03
|
||||
#define K_ESCPREFIX 0x04
|
||||
#define KDGKBMETA 0x4B62 /* gets meta key handling mode */
|
||||
#define KDSKBMETA 0x4B63 /* sets meta key handling mode */
|
||||
|
||||
#define K_SCROLLLOCK 0x01
|
||||
#define K_CAPSLOCK 0x02
|
||||
#define K_NUMLOCK 0x04
|
||||
#define KDGKBLED 0x4B64 /* get led flags (not lights) */
|
||||
#define KDSKBLED 0x4B65 /* set led flags (not lights) */
|
||||
|
||||
struct kbentry {
|
||||
unsigned char kb_table;
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
#define K_NORMTAB 0x00
|
||||
#define K_SHIFTTAB 0x01
|
||||
#define K_ALTTAB 0x02
|
||||
#define K_ALTSHIFTTAB 0x03
|
||||
|
||||
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
|
||||
#define KDSKBENT 0x4B47 /* sets one entry in translation table */
|
||||
|
||||
struct kbsentry {
|
||||
unsigned char kb_func;
|
||||
unsigned char kb_string[512];
|
||||
};
|
||||
|
||||
|
||||
struct kbdiacr {
|
||||
unsigned char diacr, base, result;
|
||||
};
|
||||
struct kbdiacrs {
|
||||
unsigned int kb_cnt; /* number of entries in following array */
|
||||
struct kbdiacr kbdiacr[256]; /* MAX_DIACR from keyboard.h */
|
||||
};
|
||||
#define KDGKBDIACR 0x4B4A /* read kernel accent table */
|
||||
#define KDSKBDIACR 0x4B4B /* write kernel accent table */
|
||||
|
||||
struct kbkeycode {
|
||||
unsigned int scancode, keycode;
|
||||
};
|
||||
#define KDGETKEYCODE 0x4B4C /* read kernel keycode table entry */
|
||||
#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
|
||||
|
||||
#define KDSIGACCEPT 0x4B4E /* accept kbd generated signals */
|
||||
|
||||
#define KDGHWCLK 0x4B50 /* get hardware clock */
|
||||
#define KDSHWCLK 0x4B51 /* set hardware clock */
|
||||
|
||||
struct kbd_repeat {
|
||||
int delay; /* in msec; <= 0: don't change */
|
||||
int rate; /* in msec; <= 0: don't change */
|
||||
};
|
||||
|
||||
#define KDKBDREP 0x4B52 /* set keyboard delay/repeat rate;
|
||||
* actually used values are returned */
|
||||
|
||||
/* note: 0x4B00-0x4B4E all have had a value at some time;
|
||||
don't reuse for the time being */
|
||||
/* note: 0x4B60-0x4B6D, 0x4B70-0x4B72 used above */
|
||||
|
||||
#endif /* _LINUX_KD_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
|
||||
* Portions Copyright (c) 1991 David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* UNIX Serial Port Mouse Driver
|
||||
*
|
||||
* This driver opens a serial port directly, and interprets serial data.
|
||||
* Microsoft, PC, Logitech and PS/2 mice are supported.
|
||||
* The PS/2 mouse is only supported if the OS runs the mouse
|
||||
* byte codes through the serial port.
|
||||
*
|
||||
* The following environment variables control the mouse type expected
|
||||
* and the serial port to open.
|
||||
*
|
||||
* Environment Var Default Allowed
|
||||
* MOUSE_TYPE pc ms, pc, logi, ps2
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include "keyboard.h"
|
||||
#include "mouse_parser.h"
|
||||
#include "serial_mouse.h"
|
||||
|
||||
|
||||
/* NOTE NOTE NOTE NOTE:
|
||||
Select here the mouse type !!!!!
|
||||
*/
|
||||
#ifndef MOUSE_TYPE
|
||||
#define MOUSE_TYPE "ms" /* default mouse type "ms","pc","ps2" */
|
||||
#endif
|
||||
|
||||
/* states for the mouse*/
|
||||
#define IDLE 0 /* start of byte sequence */
|
||||
#define XSET 1 /* setting x delta */
|
||||
#define YSET 2 /* setting y delta */
|
||||
#define XADD 3 /* adjusting x delta */
|
||||
#define YADD 4 /* adjusting y delta */
|
||||
|
||||
/* values in the bytes returned by the mouse for the buttons*/
|
||||
#define PC_LEFT_BUTTON 4
|
||||
#define PC_MIDDLE_BUTTON 2
|
||||
#define PC_RIGHT_BUTTON 1
|
||||
|
||||
#define MS_LEFT_BUTTON 2
|
||||
#define MS_RIGHT_BUTTON 1
|
||||
|
||||
#define PS2_CTRL_BYTE 0x08
|
||||
#define PS2_LEFT_BUTTON 1
|
||||
#define PS2_RIGHT_BUTTON 2
|
||||
|
||||
/* Bit fields in the bytes sent by the mouse.*/
|
||||
#define TOP_FIVE_BITS 0xf8
|
||||
#define BOTTOM_THREE_BITS 0x07
|
||||
#define TOP_BIT 0x80
|
||||
#define SIXTH_BIT 0x40
|
||||
#define BOTTOM_TWO_BITS 0x03
|
||||
#define THIRD_FOURTH_BITS 0x0c
|
||||
#define BOTTOM_SIX_BITS 0x3f
|
||||
|
||||
/* local data*/
|
||||
static int state; /* IDLE, XSET, ... */
|
||||
static BUTTON buttons; /* current mouse buttons pressed*/
|
||||
static BUTTON availbuttons; /* which buttons are available */
|
||||
static COORD xd; /* change in x */
|
||||
static COORD yd; /* change in y */
|
||||
|
||||
static int left; /* because the button values change */
|
||||
static int middle; /* between mice, the buttons are */
|
||||
static int right; /* redefined */
|
||||
|
||||
static int (*parse)( int ); /* parse routine */
|
||||
|
||||
/* local routines*/
|
||||
static int ParsePC(int); /* routine to interpret PC mouse */
|
||||
static int ParseMS(int); /* routine to interpret MS mouse */
|
||||
static int ParsePS2(int); /* routine to interpret PS/2 mouse */
|
||||
|
||||
extern void uart_set_driver_handler( int port, void ( *handler )( void *, char *, int ) );
|
||||
extern void kbd_set_driver_handler( void ( *handler )( void *, unsigned short, unsigned long ) );
|
||||
extern void ps2_set_driver_handler( int port, void ( *handler )( void *, char *, int ) );
|
||||
|
||||
/*
|
||||
* Open up the mouse device.
|
||||
* Returns the fd if successful, or negative if unsuccessful.
|
||||
*/
|
||||
int MOU_Init()
|
||||
{
|
||||
char *type;
|
||||
|
||||
/* get mouse type and port*/
|
||||
type = MOUSE_TYPE;
|
||||
|
||||
/* set button bits and parse procedure*/
|
||||
if(!strcmp(type, "pc") || !strcmp(type, "logi")) {
|
||||
/* pc or logitech mouse*/
|
||||
left = PC_LEFT_BUTTON;
|
||||
middle = PC_MIDDLE_BUTTON;
|
||||
right = PC_RIGHT_BUTTON;
|
||||
parse = ParsePC;
|
||||
} else if (strcmp(type, "ms") == 0) {
|
||||
/* microsoft mouse*/
|
||||
left = MS_LEFT_BUTTON;
|
||||
right = MS_RIGHT_BUTTON;
|
||||
middle = 0;
|
||||
parse = ParseMS;
|
||||
} else if (strcmp(type, "ps2") == 0) {
|
||||
/* PS/2 mouse*/
|
||||
left = PS2_LEFT_BUTTON;
|
||||
right = PS2_RIGHT_BUTTON;
|
||||
middle = 0;
|
||||
parse = ParsePS2;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
printk("Device: /dev/mouse -- mouse type is: %s\n", MOUSE_TYPE );
|
||||
|
||||
/* initialize data*/
|
||||
availbuttons = left | middle | right;
|
||||
state = IDLE;
|
||||
buttons = 0;
|
||||
xd = 0;
|
||||
yd = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to read bytes from the mouse and interpret them.
|
||||
* Returns -1 on error, 0 if either no bytes were read or not enough
|
||||
* was read for a complete state, or 1 if the new state was read.
|
||||
* When a new state is read, the current buttons and x and y deltas
|
||||
* are returned. This routine does not block.
|
||||
*/
|
||||
int MOU_Data( int ch, COORD *dx, COORD *dy, COORD *dz, BUTTON *bptr)
|
||||
{
|
||||
int b;
|
||||
|
||||
/*
|
||||
* Loop over all the bytes read in the buffer, parsing them.
|
||||
* When a complete state has been read, return the results,
|
||||
* leaving further bytes in the buffer for later calls.
|
||||
*/
|
||||
if( (*parse)( ch ) )
|
||||
{
|
||||
*dx = xd;
|
||||
*dy = yd;
|
||||
*dz = 0;
|
||||
b = 0;
|
||||
if(buttons & left)
|
||||
b |= LBUTTON;
|
||||
if(buttons & right)
|
||||
b |= RBUTTON;
|
||||
if(buttons & middle)
|
||||
b |= MBUTTON;
|
||||
*bptr = b;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Input routine for PC mouse.
|
||||
* Returns nonzero when a new mouse state has been completed.
|
||||
*/
|
||||
static int ParsePC(int byte)
|
||||
{
|
||||
int sign; /* sign of movement */
|
||||
|
||||
switch (state) {
|
||||
case IDLE:
|
||||
if ((byte & TOP_FIVE_BITS) == TOP_BIT) {
|
||||
buttons = ~byte & BOTTOM_THREE_BITS;
|
||||
state = XSET;
|
||||
}
|
||||
break;
|
||||
|
||||
case XSET:
|
||||
sign = 1;
|
||||
if (byte > 127) {
|
||||
byte = 256 - byte;
|
||||
sign = -1;
|
||||
}
|
||||
xd = byte * sign;
|
||||
state = YSET;
|
||||
break;
|
||||
|
||||
case YSET:
|
||||
sign = 1;
|
||||
if (byte > 127) {
|
||||
byte = 256 - byte;
|
||||
sign = -1;
|
||||
}
|
||||
yd = -byte * sign;
|
||||
state = XADD;
|
||||
break;
|
||||
|
||||
case XADD:
|
||||
sign = 1;
|
||||
if (byte > 127) {
|
||||
byte = 256 - byte;
|
||||
sign = -1;
|
||||
}
|
||||
xd += byte * sign;
|
||||
state = YADD;
|
||||
break;
|
||||
|
||||
case YADD:
|
||||
sign = 1;
|
||||
if (byte > 127) {
|
||||
byte = 256 - byte;
|
||||
sign = -1;
|
||||
}
|
||||
yd -= byte * sign;
|
||||
state = IDLE;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Input routine for Microsoft mouse.
|
||||
* Returns nonzero when a new mouse state has been completed.
|
||||
*/
|
||||
static int ParseMS(int byte)
|
||||
{
|
||||
switch (state) {
|
||||
case IDLE:
|
||||
if (byte & SIXTH_BIT) {
|
||||
buttons = (byte >> 4) & BOTTOM_TWO_BITS;
|
||||
yd = ((byte & THIRD_FOURTH_BITS) << 4);
|
||||
xd = ((byte & BOTTOM_TWO_BITS) << 6);
|
||||
state = XADD;
|
||||
}
|
||||
break;
|
||||
|
||||
case XADD:
|
||||
xd |= (byte & BOTTOM_SIX_BITS);
|
||||
state = YADD;
|
||||
break;
|
||||
|
||||
case YADD:
|
||||
yd |= (byte & BOTTOM_SIX_BITS);
|
||||
state = IDLE;
|
||||
if (xd > 127)
|
||||
xd -= 256;
|
||||
if (yd > 127)
|
||||
yd -= 256;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Input routine for PS/2 mouse.
|
||||
* Returns nonzero when a new mouse state has been completed.
|
||||
*/
|
||||
static int ParsePS2(int byte)
|
||||
{
|
||||
switch (state) {
|
||||
case IDLE:
|
||||
if (byte & PS2_CTRL_BYTE) {
|
||||
buttons = byte &
|
||||
(PS2_LEFT_BUTTON|PS2_RIGHT_BUTTON);
|
||||
state = XSET;
|
||||
}
|
||||
break;
|
||||
|
||||
case XSET:
|
||||
if(byte > 127)
|
||||
byte -= 256;
|
||||
xd = byte;
|
||||
state = YSET;
|
||||
break;
|
||||
|
||||
case YSET:
|
||||
if(byte > 127)
|
||||
byte -= 256;
|
||||
yd = -byte;
|
||||
state = IDLE;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rtems_id queue_id = 0;
|
||||
|
||||
/* generic keyboard parser */
|
||||
static void mouse_parser( void *ptr, char *buffer, int size )
|
||||
{
|
||||
COORD dx;
|
||||
COORD dy;
|
||||
COORD dz;
|
||||
BUTTON bptr;
|
||||
while( size-- )
|
||||
{
|
||||
if( MOU_Data( *buffer++, &dx, &dy, &dz, &bptr ) )
|
||||
{
|
||||
struct MW_UID_MESSAGE m;
|
||||
m.type = MV_UID_REL_POS;
|
||||
/* buttons definitons have been selected to match */
|
||||
m.m.pos.btns = bptr;
|
||||
m.m.pos.x = dx;
|
||||
m.m.pos.y = dy;
|
||||
m.m.pos.z = dz;
|
||||
/* printk( "Mouse: msg: dx=%d, dy=%d, btn=%X\n", dx, dy, bptr ); */
|
||||
rtems_message_queue_send( queue_id, ( void * )&m, sizeof( struct MW_UID_MESSAGE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* enable the mouse to add messages to the queue */
|
||||
void register_mou_msg_queue( char * q_name, int port )
|
||||
{
|
||||
rtems_name queue_name;
|
||||
rtems_status_code status;
|
||||
queue_name = rtems_build_name( q_name[0],
|
||||
q_name[1],
|
||||
q_name[2],
|
||||
q_name[3] );
|
||||
status = rtems_message_queue_ident( queue_name, RTEMS_LOCAL, &queue_id );
|
||||
if( status != RTEMS_SUCCESSFUL )
|
||||
{
|
||||
printk( "UID_Queue: error open queue: %d\n", status );
|
||||
return;
|
||||
}
|
||||
MOU_Init();
|
||||
if( port == -1 )
|
||||
{
|
||||
/* we know the mouse type in this case, let's initialize everything */
|
||||
left = PS2_LEFT_BUTTON;
|
||||
right = PS2_RIGHT_BUTTON;
|
||||
middle = 0;
|
||||
parse = ParsePS2;
|
||||
ps2_set_driver_handler( port, mouse_parser );
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_set_driver_handler( port, mouse_parser );
|
||||
}
|
||||
}
|
||||
|
||||
/* stop the mouse from adding messages to the queue */
|
||||
void unregister_mou_msg_queue( int port )
|
||||
{
|
||||
if( port == -1 )
|
||||
{
|
||||
ps2_set_driver_handler( port, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_set_driver_handler( port, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/* adds a kbd message to the queue */
|
||||
static void kbd_parser( void *ptr, unsigned short keycode, unsigned long mods )
|
||||
{
|
||||
struct MW_UID_MESSAGE m;
|
||||
struct kbd_struct * kbd = ( struct kbd_struct *)ptr;
|
||||
|
||||
m.type = MV_UID_KBD;
|
||||
m.m.kbd.code = keycode;
|
||||
m.m.kbd.modifiers = kbd->ledflagstate;
|
||||
m.m.kbd.mode = kbd->kbdmode;
|
||||
/* printk( "kbd: msg: keycode=%X, mod=%X\n", keycode, mods ); */
|
||||
rtems_message_queue_send( queue_id, ( void * )&m,
|
||||
sizeof( struct MW_UID_MESSAGE ) );
|
||||
}
|
||||
|
||||
void register_kbd_msg_queue( char *q_name, int port )
|
||||
{
|
||||
rtems_name queue_name;
|
||||
rtems_status_code status;
|
||||
|
||||
queue_name = rtems_build_name( q_name[0],
|
||||
q_name[1],
|
||||
q_name[2],
|
||||
q_name[3] );
|
||||
status = rtems_message_queue_ident( queue_name, RTEMS_LOCAL, &queue_id );
|
||||
if( status != RTEMS_SUCCESSFUL )
|
||||
{
|
||||
printk( "UID_Queue: error open queue: %d\n", status );
|
||||
return;
|
||||
}
|
||||
kbd_set_driver_handler( kbd_parser );
|
||||
}
|
||||
|
||||
|
||||
void unregister_kbd_msg_queue( int port )
|
||||
{
|
||||
kbd_set_driver_handler( NULL );
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef __mouse_parser_h__
|
||||
#define __mouse_parser_h__
|
||||
|
||||
#include <rtems/mw_uid.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Use the same definitions as the user interface */
|
||||
#define RBUTTON MV_BUTTON_RIGHT
|
||||
#define MBUTTON MV_BUTTON_CENTER
|
||||
#define LBUTTON MV_BUTTON_LEFT
|
||||
|
||||
typedef int COORD; /* device coordinates*/
|
||||
typedef unsigned int BUTTON; /* mouse button mask*/
|
||||
|
||||
/* local routines */
|
||||
int MOU_Init();
|
||||
int MOU_Data( int ch, COORD *dx, COORD *dy, COORD *dz, BUTTON *bptr );
|
||||
|
||||
/* Mouse Interface */
|
||||
void register_mou_msg_queue( char * qname, int port );
|
||||
void unregister_mou_msg_queue( int port );
|
||||
|
||||
/* KBD Interface */
|
||||
void register_kbd_msg_queue( char *qname, int port );
|
||||
void unregister_kbd_msg_queue( int port );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __mouse_parser_h__ */
|
||||
|
||||
@@ -179,3 +179,24 @@ _IBMPC_initVideo(void)
|
||||
videoPrintf("maxCol = %d, maxRow = %d\n", (unsigned) maxCol, (unsigned) maxRow);
|
||||
#endif
|
||||
} /* _IBMPC_initVideo */
|
||||
|
||||
|
||||
/* for old DOS compatibility n-curses type of applications */
|
||||
void gotoxy( int x, int y )
|
||||
{
|
||||
row = x;
|
||||
column = y;
|
||||
wr_cursor(row * maxCol + column, ioCrtBaseAddr);
|
||||
}
|
||||
|
||||
|
||||
int whereX( void )
|
||||
{
|
||||
return row;
|
||||
}
|
||||
|
||||
int whereY( void )
|
||||
{
|
||||
return column;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,80 @@
|
||||
#ifndef __paux_drv__
|
||||
#define __paux_drv__
|
||||
/***************************************************************************
|
||||
*
|
||||
* $Header$
|
||||
*
|
||||
* Copyright (c) 1999 ConnectTel, Inc. All Rights Reserved.
|
||||
*
|
||||
* MODULE DESCRIPTION: Prototype routines for the paux driver.
|
||||
*
|
||||
* by: Rosimildo da Silva:
|
||||
* rdasilva@connecttel.com
|
||||
* http://www.connecttel.com
|
||||
*
|
||||
* MODIFICATION/HISTORY:
|
||||
*
|
||||
* $Log$
|
||||
****************************************************************************/
|
||||
|
||||
/* functions */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* paux prototype entry points */
|
||||
rtems_device_driver paux_initialize(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver paux_open(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver paux_control(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver paux_close(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
|
||||
rtems_device_driver paux_read(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver paux_write(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver paux_control(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
#define PAUX_DRIVER_TABLE_ENTRY \
|
||||
{ paux_initialize, paux_open, paux_close, \
|
||||
paux_read, paux_write, paux_control }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* end of include file */
|
||||
|
||||
#endif /* __paux_drv__ */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* include/linux/pc_keyb.h
|
||||
* PC Keyboard And Keyboard Controller
|
||||
* (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
||||
*
|
||||
* RTEMS port: by Rosimildo da Silva.
|
||||
*
|
||||
* This module was ported from Linux.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configuration Switches
|
||||
*/
|
||||
|
||||
#undef KBD_REPORT_ERR /* Report keyboard errors */
|
||||
#define KBD_REPORT_UNKN /* Report unknown scan codes */
|
||||
#define KBD_REPORT_TIMEOUTS /* Report keyboard timeouts */
|
||||
#undef KBD_IS_FOCUS_9000 /* We have the brain-damaged FOCUS-9000 keyboard */
|
||||
#undef INITIALIZE_MOUSE /* Define if your PS/2 mouse needs initialization. */
|
||||
|
||||
|
||||
|
||||
#define KBD_INIT_TIMEOUT 1000 /* Timeout in ms for initializing the keyboard */
|
||||
#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
|
||||
#define KBD_TIMEOUT 1000 /* Timeout in ms for keyboard command acknowledge */
|
||||
|
||||
/*
|
||||
* Internal variables of the driver
|
||||
*/
|
||||
|
||||
extern unsigned char pckbd_read_mask;
|
||||
extern unsigned char aux_device_present;
|
||||
|
||||
/*
|
||||
* Keyboard Controller Registers on normal PCs.
|
||||
*/
|
||||
|
||||
#define KBD_STATUS_REG 0x64 /* Status register (R) */
|
||||
#define KBD_CNTL_REG 0x64 /* Controller command register (W) */
|
||||
#define KBD_DATA_REG 0x60 /* Keyboard data register (R/W) */
|
||||
|
||||
/*
|
||||
* Keyboard Controller Commands
|
||||
*/
|
||||
|
||||
#define KBD_CCMD_READ_MODE 0x20 /* Read mode bits */
|
||||
#define KBD_CCMD_WRITE_MODE 0x60 /* Write mode bits */
|
||||
#define KBD_CCMD_GET_VERSION 0xA1 /* Get controller version */
|
||||
#define KBD_CCMD_MOUSE_DISABLE 0xA7 /* Disable mouse interface */
|
||||
#define KBD_CCMD_MOUSE_ENABLE 0xA8 /* Enable mouse interface */
|
||||
#define KBD_CCMD_TEST_MOUSE 0xA9 /* Mouse interface test */
|
||||
#define KBD_CCMD_SELF_TEST 0xAA /* Controller self test */
|
||||
#define KBD_CCMD_KBD_TEST 0xAB /* Keyboard interface test */
|
||||
#define KBD_CCMD_KBD_DISABLE 0xAD /* Keyboard interface disable */
|
||||
#define KBD_CCMD_KBD_ENABLE 0xAE /* Keyboard interface enable */
|
||||
#define KBD_CCMD_WRITE_AUX_OBUF 0xD3 /* Write to output buffer as if
|
||||
initiated by the auxiliary device */
|
||||
#define KBD_CCMD_WRITE_MOUSE 0xD4 /* Write the following byte to the mouse */
|
||||
|
||||
/*
|
||||
* Keyboard Commands
|
||||
*/
|
||||
|
||||
#define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */
|
||||
#define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */
|
||||
#define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
|
||||
#define KBD_CMD_DISABLE 0xF5 /* Disable scanning */
|
||||
#define KBD_CMD_RESET 0xFF /* Reset */
|
||||
|
||||
/*
|
||||
* Keyboard Replies
|
||||
*/
|
||||
|
||||
#define KBD_REPLY_POR 0xAA /* Power on reset */
|
||||
#define KBD_REPLY_ACK 0xFA /* Command ACK */
|
||||
#define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */
|
||||
|
||||
/*
|
||||
* Status Register Bits
|
||||
*/
|
||||
|
||||
#define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */
|
||||
#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
|
||||
#define KBD_STAT_SELFTEST 0x04 /* Self test successful */
|
||||
#define KBD_STAT_CMD 0x08 /* Last write was a command write (0=data) */
|
||||
#define KBD_STAT_UNLOCKED 0x10 /* Zero if keyboard locked */
|
||||
#define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */
|
||||
#define KBD_STAT_GTO 0x40 /* General receive/xmit timeout */
|
||||
#define KBD_STAT_PERR 0x80 /* Parity error */
|
||||
|
||||
#define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
|
||||
|
||||
/*
|
||||
* Controller Mode Register Bits
|
||||
*/
|
||||
|
||||
#define KBD_MODE_KBD_INT 0x01 /* Keyboard data generate IRQ1 */
|
||||
#define KBD_MODE_MOUSE_INT 0x02 /* Mouse data generate IRQ12 */
|
||||
#define KBD_MODE_SYS 0x04 /* The system flag (?) */
|
||||
#define KBD_MODE_NO_KEYLOCK 0x08 /* The keylock doesn't affect the keyboard if set */
|
||||
#define KBD_MODE_DISABLE_KBD 0x10 /* Disable keyboard interface */
|
||||
#define KBD_MODE_DISABLE_MOUSE 0x20 /* Disable mouse interface */
|
||||
#define KBD_MODE_KCC 0x40 /* Scan code conversion to PC format */
|
||||
#define KBD_MODE_RFU 0x80
|
||||
|
||||
/*
|
||||
* Mouse Commands
|
||||
*/
|
||||
|
||||
#define AUX_SET_RES 0xE8 /* Set resolution */
|
||||
#define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */
|
||||
#define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */
|
||||
#define AUX_GET_SCALE 0xE9 /* Get scaling factor */
|
||||
#define AUX_SET_STREAM 0xEA /* Set stream mode */
|
||||
#define AUX_SET_SAMPLE 0xF3 /* Set sample rate */
|
||||
#define AUX_ENABLE_DEV 0xF4 /* Enable aux device */
|
||||
#define AUX_DISABLE_DEV 0xF5 /* Disable aux device */
|
||||
#define AUX_RESET 0xFF /* Reset aux device */
|
||||
#define AUX_ACK 0xFA /* Command byte ACK. */
|
||||
|
||||
#define AUX_BUF_SIZE 512 /* This might be better divisible by
|
||||
three to make overruns stay in sync
|
||||
but then the read function would need
|
||||
a lock etc - ick */
|
||||
|
||||
struct aux_queue {
|
||||
unsigned long head;
|
||||
unsigned long tail;
|
||||
struct wait_queue *proc_list;
|
||||
struct fasync_struct *fasync;
|
||||
unsigned char buf[AUX_BUF_SIZE];
|
||||
};
|
||||
|
||||
/* How to access the keyboard macros on this platform. */
|
||||
#define kbd_read_input() inb(KBD_DATA_REG)
|
||||
#define kbd_read_status() inb(KBD_STATUS_REG)
|
||||
#define kbd_write_output(val) outb(val, KBD_DATA_REG)
|
||||
#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
|
||||
|
||||
/*
|
||||
* Machine specific bits for the PS/2 driver
|
||||
*/
|
||||
|
||||
#define AUX_IRQ 12
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* $Header$
|
||||
*
|
||||
* MODULE DESCRIPTION:
|
||||
* This module implements the RTEMS drivers for the PC serial ports
|
||||
* as /dev/ttyS1 for COM1 and /dev/ttyS2 as COM2. If one of the ports
|
||||
* is used as the console, this driver would fail to initialize.
|
||||
*
|
||||
* This code was based on the console driver. It is based on the
|
||||
* current termios framework. This is just a shell around the
|
||||
* termios support.
|
||||
*
|
||||
* by: Rosimildo da Silva:
|
||||
* rdasilva@connecttel.com
|
||||
* http://www.connecttel.com
|
||||
*
|
||||
* MODIFICATION/HISTORY:
|
||||
*
|
||||
* $Log$
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <irq.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <termios.h>
|
||||
#include <uart.h>
|
||||
#include <libcpu/cpuModel.h>
|
||||
|
||||
int BSP_poll_read(int);
|
||||
|
||||
#include <rtems/mw_uid.h>
|
||||
#include "serial_mouse.h"
|
||||
#include "mouse_parser.h"
|
||||
|
||||
/* Internal routines */
|
||||
static int serial_mouse_conSetAttr( int minor, const struct termios *t);
|
||||
static void isr_on(const rtems_irq_connect_data *);
|
||||
static void isr_off(const rtems_irq_connect_data *);
|
||||
static int isr_is_on(const rtems_irq_connect_data *);
|
||||
|
||||
|
||||
extern BSP_polling_getchar_function_type BSP_poll_char;
|
||||
extern int BSPConsolePort;
|
||||
|
||||
/* Select Default to be COM1 */
|
||||
#if !defined( SERIAL_MOUSE_COM1 ) && !defined( SERIAL_MOUSE_COM2 )
|
||||
#define SERIAL_MOUSE_COM1 1
|
||||
#endif
|
||||
|
||||
/* select which serial port the mouse is connected to */
|
||||
#ifdef SERIAL_MOUSE_COM1
|
||||
#define BSP_UART_PORT BSP_UART_COM1
|
||||
#define BSP_UART_IRQ BSP_UART_COM1_IRQ
|
||||
#define BSP_ISR_FUNC BSP_uart_termios_isr_com1
|
||||
#define BSP_WRITE_FUNC BSP_uart_termios_write_com1
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_MOUSE_COM2
|
||||
#define BSP_UART_PORT BSP_UART_COM2
|
||||
#define BSP_UART_IRQ BSP_UART_COM2_IRQ
|
||||
#define BSP_ISR_FUNC BSP_uart_termios_isr_com2
|
||||
#define BSP_WRITE_FUNC BSP_uart_termios_write_com2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Interrupt structure for serial_mouse
|
||||
*/
|
||||
static rtems_irq_connect_data serial_mouse_isr_data =
|
||||
{
|
||||
BSP_UART_IRQ,
|
||||
BSP_ISR_FUNC,
|
||||
isr_on,
|
||||
isr_off,
|
||||
isr_is_on};
|
||||
|
||||
static void isr_on(const rtems_irq_connect_data *unused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void isr_off(const rtems_irq_connect_data *unused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int isr_is_on(const rtems_irq_connect_data *irq)
|
||||
{
|
||||
return BSP_irq_enabled_at_i8259s(irq->name);
|
||||
}
|
||||
|
||||
void serial_mouse_reserve_resources(rtems_configuration_table *conf)
|
||||
{
|
||||
rtems_termios_reserve_resources(conf, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Serial Mouse - device driver INITIALIZE entry point.
|
||||
*/
|
||||
rtems_device_driver
|
||||
serial_mouse_initialize(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
/* Check if this port is not been used as console */
|
||||
if( BSPConsolePort == BSP_UART_PORT )
|
||||
{
|
||||
status = -1;
|
||||
printk("SERIAL MOUSE: port selected as console.( %d )\n", BSP_UART_PORT );
|
||||
rtems_fatal_error_occurred( status );
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up TERMIOS
|
||||
*/
|
||||
rtems_termios_initialize();
|
||||
|
||||
/*
|
||||
* Do device-specific initialization
|
||||
*/
|
||||
/* 9600-8-N-1, without hardware flow control */
|
||||
BSP_uart_init( BSP_UART_PORT, 1200, 0 );
|
||||
status = BSP_install_rtems_irq_handler( &serial_mouse_isr_data );
|
||||
if( !status )
|
||||
{
|
||||
printk("Error installing serial mouse interrupt handler!\n");
|
||||
rtems_fatal_error_occurred(status);
|
||||
}
|
||||
/*
|
||||
* Register the device
|
||||
*/
|
||||
status = rtems_io_register_name ("/dev/mouse", major, 0);
|
||||
if (status != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
printk("Error registering /dev/mouse device!\n");
|
||||
rtems_fatal_error_occurred (status);
|
||||
}
|
||||
printk("Device: /dev/mouse on COM%d -- ok \n", BSP_UART_PORT );
|
||||
return RTEMS_SUCCESSFUL;
|
||||
} /* tty_initialize */
|
||||
|
||||
|
||||
static int serial_mouse_last_close(int major, int minor, void *arg)
|
||||
{
|
||||
BSP_remove_rtems_irq_handler( &serial_mouse_isr_data );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* serial_mouse - device driver OPEN entry point
|
||||
*/
|
||||
rtems_device_driver
|
||||
serial_mouse_open(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
rtems_status_code status;
|
||||
static rtems_termios_callbacks cb =
|
||||
{
|
||||
NULL, /* firstOpen */
|
||||
serial_mouse_last_close, /* lastClose */
|
||||
NULL, /* poll read */
|
||||
BSP_WRITE_FUNC, /* write */
|
||||
serial_mouse_conSetAttr, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
1 /* outputUsesInterrupts */
|
||||
};
|
||||
|
||||
status = rtems_termios_open( major, minor, arg, &cb );
|
||||
if(status != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
printk("Error openning serial_mouse device\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pass data area info down to driver
|
||||
*/
|
||||
BSP_uart_termios_set( BSP_UART_PORT,
|
||||
((rtems_libio_open_close_args_t *)arg)->iop->data1 );
|
||||
/* Enable interrupts on channel */
|
||||
BSP_uart_intr_ctrl( BSP_UART_PORT, BSP_UART_INTR_CTRL_TERMIOS);
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/*
|
||||
* TTY - device driver CLOSE entry point
|
||||
*/
|
||||
rtems_device_driver
|
||||
serial_mouse_close(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
|
||||
return (rtems_termios_close (arg));
|
||||
|
||||
} /* tty_close */
|
||||
|
||||
|
||||
/*
|
||||
* TTY device driver READ entry point.
|
||||
* Read characters from the tty device.
|
||||
*/
|
||||
rtems_device_driver
|
||||
serial_mouse_read(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
return rtems_termios_read (arg);
|
||||
} /* tty_read */
|
||||
|
||||
|
||||
/*
|
||||
* TTY device driver WRITE entry point.
|
||||
* Write characters to the tty device.
|
||||
*/
|
||||
rtems_device_driver
|
||||
serial_mouse_write(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg)
|
||||
{
|
||||
return rtems_termios_write (arg);
|
||||
|
||||
} /* tty_write */
|
||||
|
||||
/*
|
||||
* Handle ioctl request. This is a generic internal
|
||||
* routine to handle both devices.
|
||||
*/
|
||||
static rtems_device_driver serial_mouse_control_internal( int port, void *arg )
|
||||
{
|
||||
rtems_libio_ioctl_args_t *args = arg;
|
||||
switch( args->command )
|
||||
{
|
||||
default:
|
||||
return rtems_termios_ioctl (arg);
|
||||
break;
|
||||
|
||||
case MW_UID_REGISTER_DEVICE:
|
||||
printk( "SerialMouse: reg=%s\n", args->buffer );
|
||||
register_mou_msg_queue( args->buffer, BSP_UART_PORT );
|
||||
break;
|
||||
|
||||
case MW_UID_UNREGISTER_DEVICE:
|
||||
unregister_mou_msg_queue( BSP_UART_PORT );
|
||||
break;
|
||||
|
||||
}
|
||||
args->ioctl_return = 0;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle ioctl request for ttyS1.
|
||||
*/
|
||||
rtems_device_driver
|
||||
serial_mouse_control(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return serial_mouse_control_internal( BSP_UART_PORT, arg );
|
||||
}
|
||||
|
||||
static int
|
||||
conSetAttr(int port, int minor, const struct termios *t)
|
||||
{
|
||||
int baud;
|
||||
|
||||
switch (t->c_cflag & CBAUD)
|
||||
{
|
||||
case B50:
|
||||
baud = 50;
|
||||
break;
|
||||
case B75:
|
||||
baud = 75;
|
||||
break;
|
||||
case B110:
|
||||
baud = 110;
|
||||
break;
|
||||
case B134:
|
||||
baud = 134;
|
||||
break;
|
||||
case B150:
|
||||
baud = 150;
|
||||
break;
|
||||
case B200:
|
||||
baud = 200;
|
||||
break;
|
||||
case B300:
|
||||
baud = 300;
|
||||
break;
|
||||
case B600:
|
||||
baud = 600;
|
||||
break;
|
||||
case B1200:
|
||||
baud = 1200;
|
||||
break;
|
||||
case B1800:
|
||||
baud = 1800;
|
||||
break;
|
||||
case B2400:
|
||||
baud = 2400;
|
||||
break;
|
||||
case B4800:
|
||||
baud = 4800;
|
||||
break;
|
||||
case B9600:
|
||||
baud = 9600;
|
||||
break;
|
||||
case B19200:
|
||||
baud = 19200;
|
||||
break;
|
||||
case B38400:
|
||||
baud = 38400;
|
||||
break;
|
||||
case B57600:
|
||||
baud = 57600;
|
||||
break;
|
||||
case B115200:
|
||||
baud = 115200;
|
||||
break;
|
||||
default:
|
||||
baud = 0;
|
||||
rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
printk("Mouse baud, port=%X, baud=%d\n", port, baud );
|
||||
BSP_uart_set_baud( port, baud );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle ioctl request for ttyS2.
|
||||
*/
|
||||
static int
|
||||
serial_mouse_conSetAttr( int minor, const struct termios *t)
|
||||
{
|
||||
return conSetAttr( BSP_UART_PORT, minor, t );
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef __serial_mouse_drv__
|
||||
#define __serial_mouse_drv__
|
||||
/***************************************************************************
|
||||
*
|
||||
* $Header$
|
||||
*
|
||||
* Copyright (c) 1999 ConnectTel, Inc. All Rights Reserved.
|
||||
*
|
||||
* MODULE DESCRIPTION: Prototype routines for the /dev/mouse driver.
|
||||
*
|
||||
* by: Rosimildo da Silva:
|
||||
* rdasilva@connecttel.com
|
||||
* http://www.connecttel.com
|
||||
*
|
||||
* MODIFICATION/HISTORY:
|
||||
*
|
||||
* $Log$
|
||||
****************************************************************************/
|
||||
|
||||
/* functions */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* ttyS1 entry points */
|
||||
rtems_device_driver serial_mouse_initialize(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver serial_mouse_open(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver serial_mouse_control(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
|
||||
/* serial_mouse entry points */
|
||||
rtems_device_driver serial_mouse_close(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
|
||||
rtems_device_driver serial_mouse_read(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
rtems_device_driver serial_mouse_write(
|
||||
rtems_device_major_number,
|
||||
rtems_device_minor_number,
|
||||
void *
|
||||
);
|
||||
|
||||
|
||||
/* Select the mouse type: "ms","pc","ps2" */
|
||||
#define MOUSE_TYPE "ms"
|
||||
|
||||
/* Select the serial port for the serial mouse driver */
|
||||
#define SERIAL_MOUSE_COM1 1
|
||||
/* #define SERIAL_MOUSE_COM2 1 */
|
||||
|
||||
|
||||
#define SERIAL_MOUSE_DRIVER_TABLE_ENTRY \
|
||||
{ serial_mouse_initialize, serial_mouse_open, serial_mouse_close, \
|
||||
serial_mouse_read, serial_mouse_write, serial_mouse_control }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* end of include file */
|
||||
|
||||
#endif /* __tty_drv__ */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
* linux/drivers/char/vt.c
|
||||
*
|
||||
* Copyright (C) 1992 obz under the linux copyright
|
||||
*
|
||||
* Dynamic diacritical handling - aeb@cwi.nl - Dec 1993
|
||||
* Dynamic keymap and string allocation - aeb@cwi.nl - May 1994
|
||||
* Restrict VT switching via ioctl() - grif@cs.ucr.edu - Dec 1995
|
||||
* Some code moved for less code duplication - Andi Kleen - Mar 1997
|
||||
*
|
||||
*
|
||||
* by: Rosimildo da Silva --
|
||||
* Ported to RTEMS to provide the basic interface to the console
|
||||
* driver. Removed all stuff not required, such as VT_, Fonts, etc.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <i386_io.h>
|
||||
#include <rtems/kd.h>
|
||||
#include <rtems/keyboard.h>
|
||||
|
||||
/*
|
||||
* Console (vt and kd) routines, as defined by USL SVR4 manual, and by
|
||||
* experimentation and study of X386 SYSV handling.
|
||||
*
|
||||
* One point of difference: SYSV vt's are /dev/vtX, which X >= 0, and
|
||||
* /dev/console is a separate ttyp. Under Linux, /dev/tty0 is /dev/console,
|
||||
* and the vc start at /dev/ttyX, X >= 1. We maintain that here, so we will
|
||||
* always treat our set of vt as numbered 1..MAX_NR_CONSOLES (corresponding to
|
||||
* ttys 0..MAX_NR_CONSOLES-1). Explicitly naming VT 0 is illegal, but using
|
||||
* /dev/tty0 (fg_console) as a target is legal, since an implicit aliasing
|
||||
* to the current console is done by the main ioctl code.
|
||||
*/
|
||||
|
||||
struct vt_struct *vt_cons[MAX_NR_CONSOLES];
|
||||
|
||||
/* Keyboard type: Default is KB_101, but can be set by machine
|
||||
* specific code.
|
||||
*/
|
||||
unsigned char keyboard_type = KB_101;
|
||||
|
||||
/*
|
||||
* Generates sound of some frequency for some number of clock ticks
|
||||
*
|
||||
* If freq is 0, will turn off sound, else will turn it on for that time.
|
||||
* If msec is 0, will return immediately, else will sleep for msec time, then
|
||||
* turn sound off.
|
||||
*
|
||||
* We also return immediately, which is what was implied within the X
|
||||
* comments - KDMKTONE doesn't put the process to sleep.
|
||||
*/
|
||||
|
||||
#if defined(__i386__) || defined(__alpha__) || defined(__powerpc__) \
|
||||
|| (defined(__mips__) && !defined(CONFIG_SGI))
|
||||
|
||||
static void
|
||||
kd_nosound(unsigned long ignored)
|
||||
{
|
||||
/* disable counter 2 */
|
||||
outb(inb_p(0x61)&0xFC, 0x61);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
_kd_mksound(unsigned int hz, unsigned int ticks)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
|
||||
if (hz > 20 && hz < 32767)
|
||||
count = 1193180 / hz;
|
||||
|
||||
cli();
|
||||
/* del_timer(&sound_timer); */
|
||||
if (count) {
|
||||
/* enable counter 2 */
|
||||
outb_p(inb_p(0x61)|3, 0x61);
|
||||
/* set command for counter 2, 2 byte write */
|
||||
outb_p(0xB6, 0x43);
|
||||
/* select desired HZ */
|
||||
outb_p(count & 0xff, 0x42);
|
||||
outb((count >> 8) & 0xff, 0x42);
|
||||
|
||||
/*
|
||||
if (ticks) {
|
||||
sound_timer.expires = jiffies+ticks;
|
||||
add_timer(&sound_timer);
|
||||
}
|
||||
*/
|
||||
} else
|
||||
kd_nosound(0);
|
||||
|
||||
sti();
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
_kd_mksound(unsigned int hz, unsigned int ticks)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void (*kd_mksound)(unsigned int hz, unsigned int ticks) = _kd_mksound;
|
||||
|
||||
|
||||
#define i (tmp.kb_index)
|
||||
#define s (tmp.kb_table)
|
||||
#define v (tmp.kb_value)
|
||||
static inline int
|
||||
do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kbd)
|
||||
{
|
||||
struct kbentry tmp;
|
||||
ushort *key_map, val;
|
||||
|
||||
tmp = *user_kbe;
|
||||
if (i >= NR_KEYS || s >= MAX_NR_KEYMAPS)
|
||||
return -EINVAL;
|
||||
|
||||
switch (cmd) {
|
||||
case KDGKBENT:
|
||||
key_map = key_maps[s];
|
||||
if (key_map) {
|
||||
val = U(key_map[i]);
|
||||
if (kbd->kbdmode != VC_UNICODE && KTYP(val) >= NR_TYPES)
|
||||
val = K_HOLE;
|
||||
} else
|
||||
val = (i ? K_HOLE : K_NOSUCHMAP);
|
||||
user_kbe->kb_value = val;
|
||||
return 0;
|
||||
|
||||
case KDSKBENT:
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#undef i
|
||||
#undef s
|
||||
#undef v
|
||||
|
||||
|
||||
#define HZ 100
|
||||
|
||||
static inline int
|
||||
do_kbkeycode_ioctl(int cmd, struct kbkeycode *user_kbkc, int perm)
|
||||
{
|
||||
struct kbkeycode tmp;
|
||||
int kc = 0;
|
||||
|
||||
tmp = *user_kbkc;
|
||||
switch (cmd) {
|
||||
case KDGETKEYCODE:
|
||||
kc = getkeycode(tmp.scancode);
|
||||
if (kc >= 0)
|
||||
user_kbkc->keycode = kc;
|
||||
break;
|
||||
case KDSETKEYCODE:
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
kc = setkeycode(tmp.scancode, tmp.keycode);
|
||||
break;
|
||||
}
|
||||
return kc;
|
||||
}
|
||||
|
||||
static inline int
|
||||
do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* We handle the console-specific ioctl's here. We allow the
|
||||
* capability to modify any console, not just the fg_console.
|
||||
*/
|
||||
int vt_ioctl( unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
int perm;
|
||||
unsigned int console;
|
||||
unsigned char ucval;
|
||||
struct kbd_struct * kbd;
|
||||
|
||||
console = 0;
|
||||
/*
|
||||
* To have permissions to do most of the vt ioctls, we either have
|
||||
* to be the owner of the tty, or super-user.
|
||||
*/
|
||||
perm = 1;
|
||||
kbd = kbd_table + console;
|
||||
switch (cmd) {
|
||||
case KIOCSOUND:
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
if (arg)
|
||||
arg = 1193180 / arg;
|
||||
kd_mksound(arg, 0);
|
||||
return 0;
|
||||
|
||||
case KDMKTONE:
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
{
|
||||
unsigned int ticks, count;
|
||||
|
||||
/*
|
||||
* Generate the tone for the appropriate number of ticks.
|
||||
* If the time is zero, turn off sound ourselves.
|
||||
*/
|
||||
ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
|
||||
count = ticks ? (arg & 0xffff) : 0;
|
||||
if (count)
|
||||
count = 1193180 / count;
|
||||
kd_mksound(count, ticks);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case KDGKBTYPE:
|
||||
/*
|
||||
* this is naive.
|
||||
*/
|
||||
ucval = keyboard_type;
|
||||
goto setchar;
|
||||
|
||||
case KDSETMODE:
|
||||
case KDGETMODE:
|
||||
return -EINVAL;
|
||||
|
||||
case KDSKBMODE:
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
switch(arg) {
|
||||
case K_RAW:
|
||||
kbd->kbdmode = VC_RAW;
|
||||
break;
|
||||
case K_MEDIUMRAW:
|
||||
kbd->kbdmode = VC_MEDIUMRAW;
|
||||
break;
|
||||
case K_XLATE:
|
||||
kbd->kbdmode = VC_XLATE;
|
||||
compute_shiftstate();
|
||||
break;
|
||||
case K_UNICODE:
|
||||
kbd->kbdmode = VC_UNICODE;
|
||||
compute_shiftstate();
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case KDGKBMODE:
|
||||
ucval = ((kbd->kbdmode == VC_RAW) ? K_RAW :
|
||||
(kbd->kbdmode == VC_MEDIUMRAW) ? K_MEDIUMRAW :
|
||||
(kbd->kbdmode == VC_UNICODE) ? K_UNICODE :
|
||||
K_XLATE);
|
||||
goto setint;
|
||||
|
||||
/* this could be folded into KDSKBMODE, but for compatibility
|
||||
reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */
|
||||
case KDSKBMETA:
|
||||
switch(arg) {
|
||||
case K_METABIT:
|
||||
clr_vc_kbd_mode(kbd, VC_META);
|
||||
break;
|
||||
case K_ESCPREFIX:
|
||||
set_vc_kbd_mode(kbd, VC_META);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case KDGKBMETA:
|
||||
ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT);
|
||||
setint:
|
||||
*(int *)arg = ucval;
|
||||
return 0;
|
||||
|
||||
case KDGETKEYCODE:
|
||||
case KDSETKEYCODE:
|
||||
return do_kbkeycode_ioctl(cmd, (struct kbkeycode *)arg, perm);
|
||||
|
||||
case KDGKBENT:
|
||||
case KDSKBENT:
|
||||
return do_kdsk_ioctl(cmd, (struct kbentry *)arg, perm, kbd);
|
||||
|
||||
case KDGKBDIACR:
|
||||
{
|
||||
struct kbdiacrs *a = (struct kbdiacrs *)arg;
|
||||
a->kb_cnt = accent_table_size;
|
||||
memcpy( a->kbdiacr, accent_table, accent_table_size*sizeof(struct kbdiacr) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
case KDSKBDIACR:
|
||||
{
|
||||
struct kbdiacrs *a = (struct kbdiacrs *)arg;
|
||||
unsigned int ct;
|
||||
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
ct = a->kb_cnt;
|
||||
if (ct >= MAX_DIACR)
|
||||
return -EINVAL;
|
||||
accent_table_size = ct;
|
||||
memcpy(accent_table, a->kbdiacr, ct*sizeof(struct kbdiacr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* the ioctls below read/set the flags usually shown in the leds */
|
||||
/* don't use them - they will go away without warning */
|
||||
case KDGKBLED:
|
||||
ucval = kbd->ledflagstate | (kbd->default_ledflagstate << 4);
|
||||
goto setchar;
|
||||
|
||||
case KDSKBLED:
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
if (arg & ~0x77)
|
||||
return -EINVAL;
|
||||
kbd->ledflagstate = (arg & 7);
|
||||
kbd->default_ledflagstate = ((arg >> 4) & 7);
|
||||
set_leds();
|
||||
return 0;
|
||||
|
||||
/* the ioctls below only set the lights, not the functions */
|
||||
/* for those, see KDGKBLED and KDSKBLED above */
|
||||
case KDGETLED:
|
||||
ucval = getledstate();
|
||||
setchar:
|
||||
*(char*)arg = ucval;
|
||||
return 0;
|
||||
|
||||
case KDSETLED:
|
||||
if (!perm)
|
||||
return -EPERM;
|
||||
setledstate(kbd, arg);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ PGM = $(ARCH)/startup.rel
|
||||
|
||||
C_FILES = bsplibc.c bsppost.c bspstart.c exit.c irq.c irq_init.c bootcard.c \
|
||||
main.c sbrk.c i386-stub.c i386-stub-glue.c uart.c pcibios.c \
|
||||
gnatinstallhandler.c
|
||||
gnatinstallhandler.c gdb_glue.c tty_drv.c
|
||||
|
||||
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
|
||||
|
||||
S_FILES = ldsegs.S irq_asm.S
|
||||
|
||||
Reference in New Issue
Block a user