libsys: various updates

- move system calls for use by services from libminlib into libsys;
- move srv_fork(2) and srv_kill(2) from RS and into libsys;
- replace getprocnr(2) with sef_self(3);
- rename previous getnprocnr(2) to getprocnr(2);
- clean up getepinfo(2);
- change all libsys calls that used _syscall to use _taskcall, so as
  to avoid going through errno to pass errors; this is already how
  most calls work anyway, and many of the calls previously using
  _syscall were already assumed to return the actual error;
- initialize request messages to zero, for future compatibility
  (note that this does not include PCI calls, which are in need of a
  much bigger overhaul, nor kernel calls);
- clean up more of dead DS code as a side effect.

Change-Id: I8788f54c68598fcf58e23486e270c2d749780ebb
This commit is contained in:
David van Moolenbroek
2013-11-03 22:33:44 +01:00
committed by Lionel Sambuc
parent efd3487bc5
commit 80bd109cd3
82 changed files with 477 additions and 544 deletions

View File

@@ -10,8 +10,8 @@ How the test works
==================
`dstest` tests the new DS API (excluding ds_subscribe() and ds_check()).
test_u32, test_str, test_mem, test_label, and test_map test U32, STR, MEM, LABEL
and MAP type respectively.
test_u32, test_str, test_mem, and test_label test U32, STR, MEM, and LABEL
type respectively.
Invalid invokation is tested as well. Erroneous conditions are tested only once.
For example, publishing an entry with same label name, but without

View File

@@ -3,7 +3,6 @@
char *key_u32 = "test_u32";
char *key_str = "test_str";
char *key_mem = "test_mem";
char *key_map = "test_map";
char *key_label = "test_label";
/*===========================================================================*
@@ -128,10 +127,10 @@ void test_label(void)
endpoint_t endpoint;
/* Retrieve own label and endpoint. */
r = ds_retrieve_label_name(label, getprocnr());
r = ds_retrieve_label_name(label, sef_self());
assert(r == OK);
r = ds_retrieve_label_endpt(label, &endpoint);
assert(r == OK && endpoint == getprocnr());
assert(r == OK && endpoint == sef_self());
/* Publish and delete. */
r = ds_publish_label(label, endpoint, 0);
@@ -142,65 +141,6 @@ void test_label(void)
printf("DSTEST: LABEL test successful!\n");
}
/*===========================================================================*
* test_map *
*===========================================================================*/
void test_map(void)
{
char buf_buf[CLICK_SIZE * 2];
char buf_buf2[CLICK_SIZE * 2];
char *buf, *buf2;
char get_buf[CLICK_SIZE];
int *p;
volatile int *p2;
int *get_p;
size_t get_len;
int is;
int r;
buf = (char*) CLICK_CEIL(buf_buf);
buf2 = (char*) CLICK_CEIL(buf_buf2);
p = (int *)buf;
p2 = (int *)buf2;
get_p = (int *)get_buf;
*p = 1;
r = ds_publish_map(key_map, buf, CLICK_SIZE, 0);
assert(r == OK);
r = ds_snapshot_map(key_map, &is);
assert(r == OK);
/* Copy the mapped memory range.
* Set *p=2, then the mapped memory range should change too
* and *get_p should be 2.
*/
*p = 2;
get_len = CLICK_SIZE;
r = ds_retrieve_map(key_map, get_buf, &get_len, 0, DSMF_COPY_MAPPED);
assert(r == OK && get_len == CLICK_SIZE && *get_p == 2);
/* Copy snapshot, where *get_p should still be 1. */
get_len = CLICK_SIZE;
r = ds_retrieve_map(key_map, get_buf, &get_len, is, DSMF_COPY_SNAPSHOT);
assert(r == OK && get_len == CLICK_SIZE && *get_p == 1);
/* Map the mapped memory range to @buf2, then set *p=3, which
* in turn should let *p2=3.
*/
get_len = CLICK_SIZE;
r = ds_retrieve_map(key_map, buf2, &get_len, 0, DSMF_MAP_MAPPED);
assert(r == OK && get_len == CLICK_SIZE);
*p = 3;
assert(*p2 == 3);
r = ds_delete_map(key_map);
assert(r == OK);
printf("DSTEST: MAP test successful!\n");
}
/*===========================================================================*
* sef_cb_init_fresh *
*===========================================================================*/
@@ -210,7 +150,6 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
test_u32();
test_str();
test_mem();
test_map();
test_label();
return OK;

View File

@@ -72,8 +72,6 @@ int main(void)
if(r != OK)
printf("error in ds_retrieve_mem.\n");
break;
case DSF_TYPE_MAP:
break;
default:
printf("error in type! %d\n", type);
}

View File

@@ -32,13 +32,13 @@ int main(int argc, char **argv)
/* Get the requestor's endpoint. */
read(fid_get, &ep_requestor, sizeof(ep_requestor));
dprint("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor);
dprint(("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor));
/* Grant. */
gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE,
CPF_READ | CPF_WRITE);
ep_self = getprocnr();
dprint("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid);
ep_self = sef_self();
dprint(("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid));
write(fid_send, &ep_self, sizeof(ep_self));
write(fid_send, &gid, sizeof(gid));

View File

@@ -17,6 +17,7 @@
#include <minix/safecopies.h>
#include <minix/syslib.h>
#include <minix/sysutil.h>
#include <minix/minlib.h>
#include <errno.h>
/* TEST_PAGE_SHIFT =
@@ -44,8 +45,8 @@
#define DEBUG 0
#if DEBUG
# define dprint printf
# define dprint(x) printf x
#else
# define dprint (void)
# define dprint(x)
#endif

View File

@@ -63,15 +63,15 @@ int main(int argc, char **argv)
/* Sending the endpoint to the granter, in order to let him
* create the grant.
*/
ep_self = getprocnr();
ep_self = sef_self();
write(fid_send, &ep_self, sizeof(ep_self));
dprint("REQUESTOR: sending my endpoint: %d\n", ep_self);
dprint(("REQUESTOR: sending my endpoint: %d\n", ep_self));
/* Getting the granter's endpoint and gid. */
read(fid_get, &ep_granter, sizeof(ep_granter));
read(fid_get, &gid, sizeof(gid));
dprint("REQUESTOR: getting granter's endpoint %d and gid %d\n",
ep_granter, gid);
dprint(("REQUESTOR: getting granter's endpoint %d and gid %d\n",
ep_granter, gid));
/* Test SAFECOPY. */
for(i = 0; i <= TEST_PAGE_SHIFT; i++) {