Message type for TTY_FKEY_CONTROL

Change-Id: Ic7a8901089f14f65e840bd88b087b733c3e3bdee
This commit is contained in:
Lionel Sambuc 2014-06-04 17:23:50 +02:00
parent e2e57d387f
commit 4091fdf5c4
4 changed files with 38 additions and 22 deletions

View file

@ -435,11 +435,11 @@ message *m_ptr; /* pointer to the request message */
int s, i; int s, i;
int result = EINVAL; int result = EINVAL;
switch (m_ptr->FKEY_REQUEST) { /* see what we must do */ switch (m_ptr->m_lsys_tty_fkey_ctl.request) { /* see what we must do */
case FKEY_MAP: /* request for new mapping */ case FKEY_MAP: /* request for new mapping */
result = OK; /* assume everything will be ok*/ result = OK; /* assume everything will be ok*/
for (i=0; i < 12; i++) { /* check F1-F12 keys */ for (i=0; i < 12; i++) { /* check F1-F12 keys */
if (bit_isset(m_ptr->FKEY_FKEYS, i+1) ) { if (bit_isset(m_ptr->m_lsys_tty_fkey_ctl.fkeys, i+1) ) {
#if DEAD_CODE #if DEAD_CODE
/* Currently, we don't check if the slot is in use, so that IS /* Currently, we don't check if the slot is in use, so that IS
* can recover after a crash by overtaking its existing mappings. * can recover after a crash by overtaking its existing mappings.
@ -449,7 +449,7 @@ message *m_ptr; /* pointer to the request message */
#endif #endif
fkey_obs[i].proc_nr = m_ptr->m_source; fkey_obs[i].proc_nr = m_ptr->m_source;
fkey_obs[i].events = 0; fkey_obs[i].events = 0;
bit_unset(m_ptr->FKEY_FKEYS, i+1); bit_unset(m_ptr->m_lsys_tty_fkey_ctl.fkeys, i+1);
#if DEAD_CODE #if DEAD_CODE
} else { } else {
printf("WARNING, fkey_map failed F%d\n", i+1); printf("WARNING, fkey_map failed F%d\n", i+1);
@ -459,13 +459,13 @@ message *m_ptr; /* pointer to the request message */
} }
} }
for (i=0; i < 12; i++) { /* check Shift+F1-F12 keys */ for (i=0; i < 12; i++) { /* check Shift+F1-F12 keys */
if (bit_isset(m_ptr->FKEY_SFKEYS, i+1) ) { if (bit_isset(m_ptr->m_lsys_tty_fkey_ctl.sfkeys, i+1) ) {
#if DEAD_CODE #if DEAD_CODE
if (sfkey_obs[i].proc_nr == NONE) { if (sfkey_obs[i].proc_nr == NONE) {
#endif #endif
sfkey_obs[i].proc_nr = m_ptr->m_source; sfkey_obs[i].proc_nr = m_ptr->m_source;
sfkey_obs[i].events = 0; sfkey_obs[i].events = 0;
bit_unset(m_ptr->FKEY_SFKEYS, i+1); bit_unset(m_ptr->m_lsys_tty_fkey_ctl.sfkeys, i+1);
#if DEAD_CODE #if DEAD_CODE
} else { } else {
printf("WARNING, fkey_map failed Shift F%d\n", i+1); printf("WARNING, fkey_map failed Shift F%d\n", i+1);
@ -478,22 +478,22 @@ message *m_ptr; /* pointer to the request message */
case FKEY_UNMAP: case FKEY_UNMAP:
result = OK; /* assume everything will be ok*/ result = OK; /* assume everything will be ok*/
for (i=0; i < 12; i++) { /* check F1-F12 keys */ for (i=0; i < 12; i++) { /* check F1-F12 keys */
if (bit_isset(m_ptr->FKEY_FKEYS, i+1) ) { if (bit_isset(m_ptr->m_lsys_tty_fkey_ctl.fkeys, i+1) ) {
if (fkey_obs[i].proc_nr == m_ptr->m_source) { if (fkey_obs[i].proc_nr == m_ptr->m_source) {
fkey_obs[i].proc_nr = NONE; fkey_obs[i].proc_nr = NONE;
fkey_obs[i].events = 0; fkey_obs[i].events = 0;
bit_unset(m_ptr->FKEY_FKEYS, i+1); bit_unset(m_ptr->m_lsys_tty_fkey_ctl.fkeys, i+1);
} else { } else {
result = EPERM; /* report failure, but try rest */ result = EPERM; /* report failure, but try rest */
} }
} }
} }
for (i=0; i < 12; i++) { /* check Shift+F1-F12 keys */ for (i=0; i < 12; i++) { /* check Shift+F1-F12 keys */
if (bit_isset(m_ptr->FKEY_SFKEYS, i+1) ) { if (bit_isset(m_ptr->m_lsys_tty_fkey_ctl.sfkeys, i+1) ) {
if (sfkey_obs[i].proc_nr == m_ptr->m_source) { if (sfkey_obs[i].proc_nr == m_ptr->m_source) {
sfkey_obs[i].proc_nr = NONE; sfkey_obs[i].proc_nr = NONE;
sfkey_obs[i].events = 0; sfkey_obs[i].events = 0;
bit_unset(m_ptr->FKEY_SFKEYS, i+1); bit_unset(m_ptr->m_lsys_tty_fkey_ctl.sfkeys, i+1);
} else { } else {
result = EPERM; /* report failure, but try rest */ result = EPERM; /* report failure, but try rest */
} }
@ -502,17 +502,17 @@ message *m_ptr; /* pointer to the request message */
break; break;
case FKEY_EVENTS: case FKEY_EVENTS:
result = OK; /* everything will be ok*/ result = OK; /* everything will be ok*/
m_ptr->FKEY_FKEYS = m_ptr->FKEY_SFKEYS = 0; m_ptr->m_tty_lsys_fkey_ctl.fkeys = m_ptr->m_tty_lsys_fkey_ctl.sfkeys = 0;
for (i=0; i < 12; i++) { /* check (Shift+) F1-F12 keys */ for (i=0; i < 12; i++) { /* check (Shift+) F1-F12 keys */
if (fkey_obs[i].proc_nr == m_ptr->m_source) { if (fkey_obs[i].proc_nr == m_ptr->m_source) {
if (fkey_obs[i].events) { if (fkey_obs[i].events) {
bit_set(m_ptr->FKEY_FKEYS, i+1); bit_set(m_ptr->m_tty_lsys_fkey_ctl.fkeys, i+1);
fkey_obs[i].events = 0; fkey_obs[i].events = 0;
} }
} }
if (sfkey_obs[i].proc_nr == m_ptr->m_source) { if (sfkey_obs[i].proc_nr == m_ptr->m_source) {
if (sfkey_obs[i].events) { if (sfkey_obs[i].events) {
bit_set(m_ptr->FKEY_SFKEYS, i+1); bit_set(m_ptr->m_tty_lsys_fkey_ctl.sfkeys, i+1);
sfkey_obs[i].events = 0; sfkey_obs[i].events = 0;
} }
} }

View file

@ -955,16 +955,11 @@
#define TTY_RQ_BASE 0x1300 #define TTY_RQ_BASE 0x1300
#define TTY_FKEY_CONTROL (TTY_RQ_BASE + 1) /* control an F-key at TTY */ #define TTY_FKEY_CONTROL (TTY_RQ_BASE + 1) /* control an F-key at TTY */
# define FKEY_REQUEST m2_i1 /* request to perform at TTY */
# define FKEY_MAP 10 /* observe function key */ # define FKEY_MAP 10 /* observe function key */
# define FKEY_UNMAP 11 /* stop observing function key */ # define FKEY_UNMAP 11 /* stop observing function key */
# define FKEY_EVENTS 12 /* request open key presses */ # define FKEY_EVENTS 12 /* request open key presses */
# define FKEY_FKEYS m2_l1 /* F1-F12 keys pressed */
# define FKEY_SFKEYS m2_l2 /* Shift-F1-F12 keys pressed */
#define TTY_INPUT_UP (TTY_RQ_BASE + 2) /* input server is up */ #define TTY_INPUT_UP (TTY_RQ_BASE + 2) /* input server is up */
/* This message uses no message fields. */
#define TTY_INPUT_EVENT (TTY_RQ_BASE + 3) /* relayed input event */ #define TTY_INPUT_EVENT (TTY_RQ_BASE + 3) /* relayed input event */
/*===========================================================================* /*===========================================================================*

View file

@ -1067,6 +1067,23 @@ typedef struct {
} mess_lsys_svrctl; } mess_lsys_svrctl;
_ASSERT_MSG_SIZE(mess_lsys_svrctl); _ASSERT_MSG_SIZE(mess_lsys_svrctl);
typedef struct {
int request;
int fkeys;
int sfkeys;
uint8_t padding[44];
} mess_lsys_tty_fkey_ctl;
_ASSERT_MSG_SIZE(mess_lsys_tty_fkey_ctl);
typedef struct {
int fkeys;
int sfkeys;
uint8_t padding[48];
} mess_tty_lsys_fkey_ctl;
_ASSERT_MSG_SIZE(mess_tty_lsys_fkey_ctl);
typedef struct { typedef struct {
endpoint_t endpt; endpoint_t endpt;
cp_grant_id_t grant; cp_grant_id_t grant;
@ -1748,6 +1765,8 @@ typedef struct {
mess_lsys_svrctl m_lsys_svrctl; mess_lsys_svrctl m_lsys_svrctl;
mess_lsys_tty_fkey_ctl m_lsys_tty_fkey_ctl;
mess_lsys_vfs_checkperms m_lsys_vfs_checkperms; mess_lsys_vfs_checkperms m_lsys_vfs_checkperms;
mess_lsys_vfs_copyfd m_lsys_vfs_copyfd; mess_lsys_vfs_copyfd m_lsys_vfs_copyfd;
mess_lsys_vfs_mapdriver m_lsys_vfs_mapdriver; mess_lsys_vfs_mapdriver m_lsys_vfs_mapdriver;
@ -1784,6 +1803,8 @@ typedef struct {
mess_sched_lsys_scheduling_start m_sched_lsys_scheduling_start; mess_sched_lsys_scheduling_start m_sched_lsys_scheduling_start;
mess_tty_lsys_fkey_ctl m_tty_lsys_fkey_ctl;
mess_vfs_fs_breadwrite m_vfs_fs_breadwrite; mess_vfs_fs_breadwrite m_vfs_fs_breadwrite;
mess_vfs_fs_chmod m_vfs_fs_chmod; mess_vfs_fs_chmod m_vfs_fs_chmod;
mess_vfs_fs_chown m_vfs_fs_chown; mess_vfs_fs_chown m_vfs_fs_chown;

View file

@ -17,12 +17,12 @@ int *sfkeys; /* bit masks for Shift F1-F12 keys */
message m; message m;
int s; int s;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.FKEY_REQUEST = request; m.m_lsys_tty_fkey_ctl.request = request;
m.FKEY_FKEYS = (fkeys) ? *fkeys : 0; m.m_lsys_tty_fkey_ctl.fkeys = (fkeys) ? *fkeys : 0;
m.FKEY_SFKEYS = (sfkeys) ? *sfkeys : 0; m.m_lsys_tty_fkey_ctl.sfkeys = (sfkeys) ? *sfkeys : 0;
s = _taskcall(TTY_PROC_NR, TTY_FKEY_CONTROL, &m); s = _taskcall(TTY_PROC_NR, TTY_FKEY_CONTROL, &m);
if (fkeys) *fkeys = m.FKEY_FKEYS; if (fkeys) *fkeys = m.m_tty_lsys_fkey_ctl.fkeys;
if (sfkeys) *sfkeys = m.FKEY_SFKEYS; if (sfkeys) *sfkeys = m.m_tty_lsys_fkey_ctl.sfkeys;
return(s); return(s);
} }