minix/test/kernel/sys_vumap/vumaprelay.c
Lionel Sambuc c3fc9df84a Adding ipc_ prefix to ipc primitives
* Also change _orig to _intr for clarity
 * Cleaned up {IPC,KER}VEC
 * Renamed _minix_kernel_info_struct to get_minix_kerninfo
 * Merged _senda.S into _ipc.S
 * Moved into separate files get_minix_kerninfo and _do_kernel_call
 * Adapted do_kernel_call to follow same _ convention as ipc functions
 * Drop patches in libc/net/send.c and libc/include/namespace.h

Change-Id: If4ea21ecb65435170d7d87de6c826328e84c18d0
2014-03-01 09:05:01 +01:00

77 lines
1.4 KiB
C

/* Test for sys_vumap() - by D.C. van Moolenbroek */
#include <minix/drivers.h>
#include <assert.h>
#include "com.h"
static int do_request(message *m)
{
struct vumap_vir vvec[MAPVEC_NR + 3];
struct vumap_phys pvec[MAPVEC_NR + 3];
int r, r2, access, vcount, pcount;
size_t offset;
assert(m->m_type == VTR_RELAY);
vcount = m->VTR_VCOUNT;
pcount = m->VTR_PCOUNT;
offset = m->VTR_OFFSET;
access = m->VTR_ACCESS;
r2 = sys_safecopyfrom(m->m_source, m->VTR_VGRANT, 0, (vir_bytes) vvec,
sizeof(vvec[0]) * vcount);
assert(r2 == OK);
r = sys_vumap(m->m_source, vvec, vcount, offset, access, pvec,
&pcount);
if (pcount >= 1 && pcount <= MAPVEC_NR + 3) {
r2 = sys_safecopyto(m->m_source, m->VTR_PGRANT, 0,
(vir_bytes) pvec, sizeof(pvec[0]) * pcount);
assert(r2 == OK);
}
m->VTR_PCOUNT = pcount;
return r;
}
static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
{
return OK;
}
static void sef_cb_signal_handler(int sig)
{
if (sig == SIGTERM)
exit(0);
}
static void sef_local_startup(void)
{
sef_setcb_init_fresh(sef_cb_init_fresh);
sef_setcb_signal_handler(sef_cb_signal_handler);
sef_startup();
}
int main(int argc, char **argv)
{
message m;
int r;
env_setargs(argc, argv);
sef_local_startup();
for (;;) {
if ((r = sef_receive(ANY, &m)) != OK)
panic("sef_receive failed (%d)\n", r);
m.m_type = do_request(&m);
ipc_send(m.m_source, &m);
}
return 0;
}