minix/servers/vm/queryexit.c
David van Moolenbroek 6b3f4dc157 Input infrastructure, INPUT server, PCKBD driver
This commit separates the low-level keyboard driver from TTY, putting
it in a separate driver (PCKBD). The commit also separates management
of raw input devices from TTY, and puts it in a separate server
(INPUT). All keyboard and mouse input from hardware is sent by drivers
to the INPUT server, which either sends it to a process that has
opened a raw input device, or otherwise forwards it to TTY for
standard processing.

Design by Dirk Vogt. Prototype by Uli Kastlunger.

Additional changes made to the prototype:

- the event communication is now based on USB HID codes; all input
  drivers have to use USB codes to describe events;
- all TTY keymaps have been converted to USB format, with the effect
  that a single keymap covers all keys; there is no (static) escaped
  keymap anymore;
- further keymap tweaks now allow remapping of literally all keys;
- input device renumbering and protocol rewrite;
- INPUT server rewrite, with added support for cancel and select;
- PCKBD reimplementation, including PC/AT-to-USB translation;
- support for manipulating keyboard LEDs has been added;
- keyboard and mouse multiplexer devices have been added to INPUT,
  primarily so that an X server need only open two devices;
- a new "libinputdriver" library abstracts away protocol details from
  input drivers, and should be used by all future input drivers;
- both INPUT and PCKBD can be restarted;
- TTY is now scheduled by KERNEL, so that it won't be punished for
  running a lot; without this, simply running "yes" on the console
  kills the system;
- the KIOCBELL IOCTL has been moved to /dev/console;
- support for the SCANCODES termios setting has been removed;
- obsolete keymap compression has been removed;
- the obsolete Olivetti M24 keymap has been removed.

Change-Id: I3a672fb8c4fd566734e4b46d3994b4b7fc96d578
2014-03-01 09:04:55 +01:00

144 lines
3 KiB
C

#define _SYSTEM 1
#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/ds.h>
#include <minix/endpoint.h>
#include <minix/minlib.h>
#include <minix/type.h>
#include <minix/ipc.h>
#include <minix/sysutil.h>
#include <minix/syslib.h>
#include <minix/safecopies.h>
#include <minix/bitmap.h>
#include <minix/vm.h>
#include <minix/ds.h>
#include <errno.h>
#include <string.h>
#include <env.h>
#include <stdio.h>
#include "glo.h"
#include "proto.h"
#include "util.h"
struct query_exit_struct {
int avail;
endpoint_t ep;
};
static struct query_exit_struct array[NR_PROCS];
/*===========================================================================*
* do_query_exit *
*===========================================================================*/
int do_query_exit(message *m)
{
int i, nr;
endpoint_t ep = NONE;
for (i = 0; i < NR_PROCS; i++) {
if (!array[i].avail) {
array[i].avail = 1;
ep = array[i].ep;
array[i].ep = 0;
break;
}
}
nr = 0;
for (i = 0; i < NR_PROCS; i++) {
if (!array[i].avail)
nr++;
}
m->VM_QUERY_RET_PT = ep;
m->VM_QUERY_IS_MORE = (nr > 0);
return OK;
}
/*===========================================================================*
* do_notify_sig *
*===========================================================================*/
int do_notify_sig(message *m)
{
int i, avails = 0;
endpoint_t ep = m->VM_NOTIFY_SIG_ENDPOINT;
endpoint_t ipc_ep = m->VM_NOTIFY_SIG_IPC;
int r;
struct vmproc *vmp;
int pslot;
if(vm_isokendpt(ep, &pslot) != OK) return ESRCH;
vmp = &vmproc[pslot];
/* Only record the event if we've been asked to report it. */
if(!(vmp->vm_flags & VMF_WATCHEXIT))
return OK;
for (i = 0; i < NR_PROCS; i++) {
/* its signal is already here */
if (!array[i].avail && array[i].ep == ep)
goto out;
if (array[i].avail)
avails++;
}
if (!avails) {
/* no slot for signals, unlikely */
printf("VM: no slot for signals!\n");
return ENOMEM;
}
for (i = 0; i < NR_PROCS; i++) {
if (array[i].avail) {
array[i].avail = 0;
array[i].ep = ep;
break;
}
}
out:
/* only care when IPC server starts up,
* and bypass the process to be signal is IPC itself.
*/
if (ipc_ep != 0 && ep != ipc_ep) {
r = notify(ipc_ep);
if (r != OK)
printf("VM: notify IPC error!\n");
}
return OK;
}
/*===========================================================================*
* do_watch_exit *
*===========================================================================*/
int do_watch_exit(message *m)
{
endpoint_t e = m->VM_WE_EP;
struct vmproc *vmp;
int p;
if(vm_isokendpt(e, &p) != OK) return ESRCH;
vmp = &vmproc[p];
vmp->vm_flags |= VMF_WATCHEXIT;
return OK;
}
/*===========================================================================*
* init_query_exit *
*===========================================================================*/
void init_query_exit(void)
{
int i;
for (i = 0; i < NR_PROCS; i++) {
array[i].avail = 1;
array[i].ep = 0;
}
}