mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 20:14:10 +08:00
committed by
Joel Sherrill
parent
900f84197b
commit
c60f56c925
+49
-50
@@ -22,78 +22,77 @@
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ioctls
|
||||
0x46 is 'F' */
|
||||
#define FBIOGET_VSCREENINFO 0x4600
|
||||
#define FBIOPUT_VSCREENINFO 0x4601
|
||||
#define FBIOGET_FSCREENINFO 0x4602
|
||||
#define FBIOGETCMAP 0x4604
|
||||
#define FBIOPUTCMAP 0x4605
|
||||
#define FB_EXEC_FUNCTION 0x4606
|
||||
#define FBIOSWAPBUFFERS 0x4607
|
||||
#define FBIOSETBUFFERMODE 0x4608
|
||||
#define FBIOSETVIDEOMODE 0x4609
|
||||
#define FBIOGET_VSCREENINFO 0x4600
|
||||
#define FBIOPUT_VSCREENINFO 0x4601
|
||||
#define FBIOGET_FSCREENINFO 0x4602
|
||||
#define FBIOGETCMAP 0x4604
|
||||
#define FBIOPUTCMAP 0x4605
|
||||
#define FB_EXEC_FUNCTION 0x4606
|
||||
#define FBIOSWAPBUFFERS 0x4607
|
||||
#define FBIOSETBUFFERMODE 0x4608
|
||||
#define FBIOSETVIDEOMODE 0x4609
|
||||
|
||||
#define FB_SINGLE_BUFFERED 0
|
||||
#define FB_TRIPLE_BUFFERED 1
|
||||
#define FB_SINGLE_BUFFERED 0
|
||||
#define FB_TRIPLE_BUFFERED 1
|
||||
|
||||
#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
|
||||
#define FB_TYPE_PLANES 1 /* Non interleaved planes */
|
||||
#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */
|
||||
#define FB_TYPE_TEXT 3 /* Text/attributes */
|
||||
#define FB_TYPE_VGA_PLANES 4 /* EGA/VGA planes */
|
||||
#define FB_TYPE_VIRTUAL_BUFFER 5 /* Virtual Buffer */
|
||||
#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
|
||||
#define FB_TYPE_PLANES 1 /* Non interleaved planes */
|
||||
#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */
|
||||
#define FB_TYPE_TEXT 3 /* Text/attributes */
|
||||
#define FB_TYPE_VGA_PLANES 4 /* EGA/VGA planes */
|
||||
#define FB_TYPE_VIRTUAL_BUFFER 5 /* Virtual Buffer */
|
||||
|
||||
#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */
|
||||
#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */
|
||||
#define FB_VISUAL_TRUECOLOR 2 /* True color */
|
||||
#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */
|
||||
#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */
|
||||
#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */
|
||||
|
||||
#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */
|
||||
#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */
|
||||
#define FB_VISUAL_TRUECOLOR 2 /* True color */
|
||||
#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */
|
||||
#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */
|
||||
#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */
|
||||
|
||||
#define FB_ACCEL_NONE 0 /* no hardware accelerator */
|
||||
#define FB_ACCEL_NONE 0 /* no hardware accelerator */
|
||||
|
||||
struct fb_bitfield {
|
||||
uint32_t offset; /* beginning of bitfield */
|
||||
uint32_t length; /* length of bitfield */
|
||||
uint32_t msb_right; /* != 0 : Most significant bit is */
|
||||
/* right */
|
||||
uint32_t offset; /* beginning of bitfield */
|
||||
uint32_t length; /* length of bitfield */
|
||||
uint32_t msb_right; /* != 0 : Most significant bit is */
|
||||
/* right */
|
||||
};
|
||||
|
||||
struct fb_var_screeninfo {
|
||||
uint32_t xres; /* visible resolution */
|
||||
uint32_t yres;
|
||||
uint32_t bits_per_pixel; /* guess what */
|
||||
struct fb_bitfield red; /* bitfield in fb mem if true color, */
|
||||
struct fb_bitfield green; /* else only length is significant */
|
||||
struct fb_bitfield blue;
|
||||
struct fb_bitfield transp; /* transparency */
|
||||
uint32_t xres; /* visible resolution */
|
||||
uint32_t yres;
|
||||
uint32_t bits_per_pixel; /* guess what */
|
||||
struct fb_bitfield red; /* bitfield in fb mem if true color, */
|
||||
struct fb_bitfield green; /* else only length is significant */
|
||||
struct fb_bitfield blue;
|
||||
struct fb_bitfield transp; /* transparency */
|
||||
};
|
||||
|
||||
struct fb_fix_screeninfo {
|
||||
volatile char *smem_start; /* Start of frame buffer mem */
|
||||
/* (physical address) */
|
||||
uint32_t smem_len; /* Length of frame buffer mem */
|
||||
uint32_t type; /* see FB_TYPE_* */
|
||||
uint32_t visual; /* see FB_VISUAL_* */
|
||||
uint32_t line_length; /* number of chars per line */
|
||||
volatile char *smem_start; /* Start of frame buffer mem */
|
||||
/* (physical address) */
|
||||
uint32_t smem_len; /* Length of frame buffer mem */
|
||||
uint32_t type; /* see FB_TYPE_* */
|
||||
uint32_t visual; /* see FB_VISUAL_* */
|
||||
uint32_t line_length; /* number of chars per line */
|
||||
};
|
||||
|
||||
struct fb_cmap {
|
||||
uint32_t start; /* First entry */
|
||||
uint32_t len; /* Number of entries */
|
||||
uint16_t *red; /* Red values */
|
||||
uint16_t *green;
|
||||
uint16_t *blue;
|
||||
uint16_t *transp; /* transparency, can be NULL */
|
||||
uint32_t start; /* First entry */
|
||||
uint32_t len; /* Number of entries */
|
||||
uint16_t *red; /* Red values */
|
||||
uint16_t *green;
|
||||
uint16_t *blue;
|
||||
uint16_t *transp; /* transparency, can be NULL */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**@}*/
|
||||
|
||||
@@ -30,77 +30,76 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* 0x41XX -- IOCTL functions for the Micro Input Devices commands */
|
||||
#define MW_UID_REGISTER_DEVICE 0x4100
|
||||
#define MW_UID_UNREGISTER_DEVICE 0x4101
|
||||
#define MW_UID_REGISTER_DEVICE 0x4100
|
||||
#define MW_UID_UNREGISTER_DEVICE 0x4101
|
||||
|
||||
/* devices supported by MicroWindows */
|
||||
enum MW_INPUT_DEVICE_TYPE {
|
||||
MV_UID_INVALID = 0,
|
||||
MV_UID_REL_POS = 1, /* mouse */
|
||||
MV_UID_ABS_POS = 2, /* touch-screen */
|
||||
MV_UID_KBD = 3, /* keyboard */
|
||||
MV_UID_TIMER = 4 /* timer -- not used */
|
||||
MV_UID_INVALID = 0,
|
||||
MV_UID_REL_POS = 1, /* mouse */
|
||||
MV_UID_ABS_POS = 2, /* touch-screen */
|
||||
MV_UID_KBD = 3, /* keyboard */
|
||||
MV_UID_TIMER = 4 /* timer -- not used */
|
||||
};
|
||||
|
||||
/* matching MicroWindows */
|
||||
#define MV_BUTTON_RIGHT 0x01
|
||||
#define MV_BUTTON_CENTER 0x02
|
||||
#define MV_BUTTON_LEFT 0x04
|
||||
#define MV_BUTTON_RIGHT 0x01
|
||||
#define MV_BUTTON_CENTER 0x02
|
||||
#define MV_BUTTON_LEFT 0x04
|
||||
|
||||
/* modifiers of the keyboard type devices */
|
||||
#define MV_KEY_MODIFIER_SHIFT_DOWN 0x10
|
||||
#define MV_KEY_MODIFIER_ALT_DOWN 0x20
|
||||
#define MV_KEY_MODIFIER_SHIFT_DOWN 0x10
|
||||
#define MV_KEY_MODIFIER_ALT_DOWN 0x20
|
||||
|
||||
/* indication of the LEDS */
|
||||
#define MV_KEY_MODIFIER_CAPS_ON 0x04
|
||||
#define MV_KEY_MODIFIER_NUN_LOCK_ON 0x02
|
||||
#define MV_KEY_SCROLL_LOCK_ON 0x01
|
||||
#define MV_KEY_MODIFIER_CAPS_ON 0x04
|
||||
#define MV_KEY_MODIFIER_NUN_LOCK_ON 0x02
|
||||
#define MV_KEY_SCROLL_LOCK_ON 0x01
|
||||
|
||||
/* keyboard modes -- default ASCII */
|
||||
#define MV_KEY_MODE_ASCII 0x01
|
||||
#define MV_KEY_MODE_ASCII 0x01
|
||||
/*
|
||||
* This mode one event is sent when a key is pressed,
|
||||
* and another one is send when a key is released.
|
||||
*/
|
||||
#define MV_KEY_MODE_SCANCODE 0x00
|
||||
#define MV_KEY_MODE_SCANCODE 0x00
|
||||
|
||||
/* these defines match with the linux keyboard range
|
||||
* for ioctls functions for the keyboard interface.
|
||||
* 0x4BXX --- keyboard related functions
|
||||
*/
|
||||
#define MV_KDGKBMODE 0x4B44 /* gets current keyboard mode */
|
||||
#define MV_KDSKBMODE 0x4B45 /* sets current keyboard mode */
|
||||
#define MV_KDGKBMODE 0x4B44 /* gets current keyboard mode */
|
||||
#define MV_KDSKBMODE 0x4B45 /* sets current keyboard mode */
|
||||
|
||||
/*
|
||||
* Message generated by input devices controlled by MicroWindows.
|
||||
*/
|
||||
struct MW_UID_MESSAGE {
|
||||
enum MW_INPUT_DEVICE_TYPE type; /* device type */
|
||||
enum MW_INPUT_DEVICE_TYPE type; /* device type */
|
||||
union {
|
||||
/* fired when keyboard events are raised */
|
||||
struct kbd_t {
|
||||
unsigned short code; /* keycode or scancode */
|
||||
unsigned char modifiers; /* key modifiers */
|
||||
unsigned char mode; /* current Kbd mode */
|
||||
unsigned short code; /* keycode or scancode */
|
||||
unsigned char modifiers; /* key modifiers */
|
||||
unsigned char mode; /* current Kbd mode */
|
||||
} kbd;
|
||||
|
||||
/* fired when position events are raised, mouse, touch screen, etc */
|
||||
struct pos_t {
|
||||
unsigned short btns; /* indicates which buttons are pressed */
|
||||
short x; /* x location */
|
||||
short y; /* y location */
|
||||
short z; /* z location, 0 for 2D */
|
||||
short x; /* x location */
|
||||
short y; /* y location */
|
||||
short z; /* z location, 0 for 2D */
|
||||
} pos;
|
||||
|
||||
/* fired by a timer device periodically */
|
||||
struct timer_t {
|
||||
unsigned long frt; /* free running timer */
|
||||
unsigned long seq; /* sequence number */
|
||||
unsigned long frt; /* free running timer */
|
||||
unsigned long seq; /* sequence number */
|
||||
} tmr;
|
||||
} m;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* API for creating/closing/accessing the message queue used by the micro
|
||||
* input device interface. All functions in this interface returns a
|
||||
@@ -170,9 +169,7 @@ extern int uid_set_kbd_mode( int fd, int mode, int *old_mode );
|
||||
*
|
||||
* @param[in] uid points to the message to print
|
||||
*/
|
||||
void uid_print_message(
|
||||
struct MW_UID_MESSAGE *uid
|
||||
);
|
||||
void uid_print_message( struct MW_UID_MESSAGE *uid );
|
||||
|
||||
/**
|
||||
* This methods prints the specified UID message using your fprintf
|
||||
|
||||
@@ -26,29 +26,23 @@
|
||||
#include <rtems/mw_uid.h>
|
||||
#include <rtems/printer.h>
|
||||
|
||||
static const char *uid_buttons(
|
||||
unsigned short btns,
|
||||
char *buffer,
|
||||
size_t max
|
||||
)
|
||||
static const char *uid_buttons( unsigned short btns, char *buffer, size_t max )
|
||||
{
|
||||
snprintf(
|
||||
buffer,
|
||||
max,
|
||||
"LEFT=%s CENTER=%s RIGHT=%s",
|
||||
((btns & MV_BUTTON_LEFT) ? "down" : "up"),
|
||||
((btns & MV_BUTTON_CENTER) ? "down" : "up"),
|
||||
((btns & MV_BUTTON_RIGHT) ? "down" : "up")
|
||||
( ( btns & MV_BUTTON_LEFT ) ? "down" : "up" ),
|
||||
( ( btns & MV_BUTTON_CENTER ) ? "down" : "up" ),
|
||||
( ( btns & MV_BUTTON_RIGHT ) ? "down" : "up" )
|
||||
);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void uid_print_message(
|
||||
struct MW_UID_MESSAGE *uid
|
||||
)
|
||||
void uid_print_message( struct MW_UID_MESSAGE *uid )
|
||||
{
|
||||
rtems_printer printer;
|
||||
rtems_print_printer_printk(&printer);
|
||||
rtems_print_printer_printk( &printer );
|
||||
uid_print_message_with_plugin( &printer, uid );
|
||||
}
|
||||
|
||||
@@ -57,9 +51,9 @@ void uid_print_message_with_plugin(
|
||||
struct MW_UID_MESSAGE *uid
|
||||
)
|
||||
{
|
||||
char buttons[80];
|
||||
char buttons[ 80 ];
|
||||
|
||||
switch (uid->type) {
|
||||
switch ( uid->type ) {
|
||||
case MV_UID_INVALID:
|
||||
rtems_printf( printer, "MV_UID_INVALID\n" );
|
||||
break;
|
||||
@@ -67,36 +61,36 @@ void uid_print_message_with_plugin(
|
||||
rtems_printf(
|
||||
printer,
|
||||
"MV_UID_REL_POS - %s x=%d y=%d z=%d\n",
|
||||
uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
|
||||
uid->m.pos.x, /* x location */
|
||||
uid->m.pos.y, /* y location */
|
||||
uid->m.pos.z /* z location, 0 for 2D */
|
||||
uid_buttons( uid->m.pos.btns, buttons, sizeof( buttons ) ),
|
||||
uid->m.pos.x, /* x location */
|
||||
uid->m.pos.y, /* y location */
|
||||
uid->m.pos.z /* z location, 0 for 2D */
|
||||
);
|
||||
break;
|
||||
case MV_UID_ABS_POS:
|
||||
rtems_printf(
|
||||
printer,
|
||||
"MV_UID_ABS_POS - %s x=%d y=%d z=%d\n",
|
||||
uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
|
||||
uid->m.pos.x, /* x location */
|
||||
uid->m.pos.y, /* y location */
|
||||
uid->m.pos.z /* z location, 0 for 2D */
|
||||
uid_buttons( uid->m.pos.btns, buttons, sizeof( buttons ) ),
|
||||
uid->m.pos.x, /* x location */
|
||||
uid->m.pos.y, /* y location */
|
||||
uid->m.pos.z /* z location, 0 for 2D */
|
||||
);
|
||||
break;
|
||||
case MV_UID_KBD:
|
||||
rtems_printf( printer,
|
||||
rtems_printf(
|
||||
printer,
|
||||
"MV_UID_KBD - code=0x%04x modifiers=0x%02x mode=0x%02x\n",
|
||||
uid->m.kbd.code, /* keycode or scancode */
|
||||
uid->m.kbd.modifiers, /* key modifiers */
|
||||
uid->m.kbd.mode /* current Kbd mode */
|
||||
uid->m.kbd.code, /* keycode or scancode */
|
||||
uid->m.kbd.modifiers, /* key modifiers */
|
||||
uid->m.kbd.mode /* current Kbd mode */
|
||||
);
|
||||
break;
|
||||
case MV_UID_TIMER:
|
||||
case MV_UID_TIMER:
|
||||
rtems_printf( printer, "MV_UID_TIMER\n" );
|
||||
break;
|
||||
default:
|
||||
rtems_printf( printer, "Invalid device type\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+31
-27
@@ -27,8 +27,8 @@
|
||||
#include <rtems/mw_uid.h>
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
static rtems_id queue_id = 0;
|
||||
static int open_count = 0;
|
||||
static rtems_id queue_id = 0;
|
||||
static int open_count = 0;
|
||||
|
||||
/*
|
||||
#define MW_DEBUG_ON 1
|
||||
@@ -37,7 +37,7 @@ static int open_count = 0;
|
||||
/* open a message queue with the kernel */
|
||||
int uid_open_queue(
|
||||
const char *q_name,
|
||||
int flags RTEMS_UNUSED,
|
||||
int flags RTEMS_UNUSED,
|
||||
size_t max_msgs
|
||||
)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ int uid_open_queue(
|
||||
}
|
||||
|
||||
status = rtems_message_queue_create(
|
||||
rtems_build_name( q_name[0], q_name[1], q_name[2], q_name[3] ),
|
||||
rtems_build_name( q_name[ 0 ], q_name[ 1 ], q_name[ 2 ], q_name[ 3 ] ),
|
||||
max_msgs,
|
||||
sizeof( struct MW_UID_MESSAGE ),
|
||||
RTEMS_FIFO | RTEMS_LOCAL,
|
||||
@@ -62,18 +62,17 @@ int uid_open_queue(
|
||||
);
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
#ifdef MW_DEBUG_ON
|
||||
printk( "UID_Queue: error creating queue: %d\n", status );
|
||||
printk( "UID_Queue: error creating queue: %d\n", status );
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
#ifdef MW_DEBUG_ON
|
||||
printk( "UID_Queue: id=%X\n", queue_id );
|
||||
printk( "UID_Queue: id=%X\n", queue_id );
|
||||
#endif
|
||||
open_count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* close message queue */
|
||||
int uid_close_queue( void )
|
||||
{
|
||||
@@ -90,12 +89,12 @@ int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout )
|
||||
{
|
||||
rtems_status_code status;
|
||||
size_t size = 0;
|
||||
int wait = (timeout != 0);
|
||||
int ticks = RTEMS_MICROSECONDS_TO_TICKS(timeout * 1000);
|
||||
int wait = ( timeout != 0 );
|
||||
int ticks = RTEMS_MICROSECONDS_TO_TICKS( timeout * 1000 );
|
||||
|
||||
if (timeout == (unsigned long) -1) {
|
||||
if ( timeout == (unsigned long) -1 ) {
|
||||
ticks = RTEMS_NO_TIMEOUT;
|
||||
} else if (timeout && ticks == 0) {
|
||||
} else if ( timeout && ticks == 0 ) {
|
||||
/* if timeout greater than 0 and smaller than a tick, round up to avoid
|
||||
* unintentionally RTEMS_NO_TIMEOUT
|
||||
*/
|
||||
@@ -103,21 +102,23 @@ int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout )
|
||||
}
|
||||
|
||||
status = rtems_message_queue_receive(
|
||||
queue_id,
|
||||
(void*)m,
|
||||
&size,
|
||||
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
|
||||
ticks
|
||||
queue_id,
|
||||
(void *) m,
|
||||
&size,
|
||||
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
|
||||
ticks
|
||||
);
|
||||
|
||||
if( status == RTEMS_SUCCESSFUL ) {
|
||||
return size;
|
||||
} else if( ( status == RTEMS_UNSATISFIED ) || ( status == RTEMS_TIMEOUT ) ) {
|
||||
rtems_set_errno_and_return_minus_one( ETIMEDOUT );
|
||||
if ( status == RTEMS_SUCCESSFUL ) {
|
||||
return size;
|
||||
} else if (
|
||||
( status == RTEMS_UNSATISFIED ) || ( status == RTEMS_TIMEOUT )
|
||||
) {
|
||||
rtems_set_errno_and_return_minus_one( ETIMEDOUT );
|
||||
}
|
||||
/* Here we have one error condition */
|
||||
#ifdef MW_DEBUG_ON
|
||||
printk( "UID_Queue: error reading queue: %d\n", status );
|
||||
printk( "UID_Queue: error reading queue: %d\n", status );
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
@@ -131,8 +132,11 @@ int uid_send_message( struct MW_UID_MESSAGE *m )
|
||||
{
|
||||
rtems_status_code status;
|
||||
status = rtems_message_queue_send(
|
||||
queue_id, ( void * )m, sizeof( struct MW_UID_MESSAGE ) );
|
||||
return (status == RTEMS_SUCCESSFUL) ? 0 : -1;
|
||||
queue_id,
|
||||
(void *) m,
|
||||
sizeof( struct MW_UID_MESSAGE )
|
||||
);
|
||||
return ( status == RTEMS_SUCCESSFUL ) ? 0 : -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -153,11 +157,11 @@ int uid_unregister_device( int fd )
|
||||
/* set the keyboard */
|
||||
int uid_set_kbd_mode( int fd, int mode, int *old_mode )
|
||||
{
|
||||
if (ioctl( fd, MV_KDGKBMODE, old_mode) < 0) {
|
||||
return -1;
|
||||
if ( ioctl( fd, MV_KDGKBMODE, old_mode ) < 0 ) {
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, MV_KDSKBMODE, mode ) < 0 ) {
|
||||
return -1;
|
||||
if ( ioctl( fd, MV_KDSKBMODE, mode ) < 0 ) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user