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
2014-03-01 09:05:00 +01:00
committed by sambuc
parent efd3487bc5
commit 80bd109cd3
82 changed files with 477 additions and 544 deletions
-2
View File
@@ -44,5 +44,3 @@ void sem_process_vm_notify(void);
EXTERN int identifier;
EXTERN endpoint_t who_e;
EXTERN int call_type;
EXTERN endpoint_t SELF_E;
+1 -4
View File
@@ -3,7 +3,6 @@
int identifier = 0x1234;
endpoint_t who_e;
int call_type;
endpoint_t SELF_E;
static struct {
int type;
@@ -140,10 +139,8 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
{
/* Initialize the ipc server. */
SELF_E = getprocnr();
if(verbose)
printf("IPC: self: %d\n", SELF_E);
printf("IPC: self: %d\n", sef_self());
return(OK);
}
+5 -5
View File
@@ -312,7 +312,7 @@ int do_semctl(message *m)
ds = (struct semid_ds *) opt;
if (!ds)
return EFAULT;
r = sys_datacopy(SELF_E, (vir_bytes) &sem->semid_ds,
r = sys_datacopy(SELF, (vir_bytes) &sem->semid_ds,
who_e, (vir_bytes) ds, sizeof(struct semid_ds));
if (r != OK)
return EINVAL;
@@ -325,7 +325,7 @@ int do_semctl(message *m)
return EPERM;
ds = (struct semid_ds *) opt;
r = sys_datacopy(who_e, (vir_bytes) ds,
SELF_E, (vir_bytes) &tmp_ds, sizeof(struct semid_ds));
SELF, (vir_bytes) &tmp_ds, sizeof(struct semid_ds));
if (r != OK)
return EINVAL;
sem->semid_ds.sem_perm.uid = tmp_ds.sem_perm.uid;
@@ -357,7 +357,7 @@ int do_semctl(message *m)
return ENOMEM;
for (i = 0; i < sem->semid_ds.sem_nsems; i++)
buf[i] = sem->sems[i].semval;
r = sys_datacopy(SELF_E, (vir_bytes) buf,
r = sys_datacopy(SELF, (vir_bytes) buf,
who_e, (vir_bytes) opt,
sizeof(unsigned short) * sem->semid_ds.sem_nsems);
if (r != OK)
@@ -389,7 +389,7 @@ int do_semctl(message *m)
if (!buf)
return ENOMEM;
r = sys_datacopy(who_e, (vir_bytes) opt,
SELF_E, (vir_bytes) buf,
SELF, (vir_bytes) buf,
sizeof(unsigned short) * sem->semid_ds.sem_nsems);
if (r != OK)
return EINVAL;
@@ -470,7 +470,7 @@ int do_semop(message *m)
if (!sops)
goto out_free;
r = sys_datacopy(who_e, (vir_bytes) m->SEMOP_OPS,
SELF_E, (vir_bytes) sops,
SELF, (vir_bytes) sops,
sizeof(struct sembuf) * nsops);
if (r != OK) {
r = EINVAL;
+8 -8
View File
@@ -76,7 +76,7 @@ int do_shmget(message *m)
PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
if (shm->page == (vir_bytes) MAP_FAILED)
return ENOMEM;
shm->vm_id = vm_getphys(SELF_E, (void *) shm->page);
shm->vm_id = vm_getphys(sef_self(), (void *) shm->page);
memset((void *)shm->page, 0, size);
shm->shmid_ds.shm_perm.cuid =
@@ -132,7 +132,7 @@ int do_shmat(message *m)
if (!check_perm(&shm->shmid_ds.shm_perm, who_e, flag))
return EACCES;
ret = vm_remap(who_e, SELF_E, (void *)addr, (void *)shm->page,
ret = vm_remap(who_e, sef_self(), (void *)addr, (void *)shm->page,
shm->shmid_ds.shm_segsz);
if (ret == MAP_FAILED)
return ENOMEM;
@@ -155,7 +155,7 @@ void update_refcount_and_destroy(void)
for (i = 0, j = 0; i < shm_list_nr; i++) {
u8_t rc;
rc = vm_getrefcount(SELF_E, (void *) shm_list[i].page);
rc = vm_getrefcount(sef_self(), (void *) shm_list[i].page);
if (rc == (u8_t) -1) {
printf("IPC: can't find physical region.\n");
continue;
@@ -243,7 +243,7 @@ int do_shmctl(message *m)
/* check whether it has read permission */
if (!check_perm(&shm->shmid_ds.shm_perm, who_e, 0444))
return EACCES;
r = sys_datacopy(SELF_E, (vir_bytes)&shm->shmid_ds,
r = sys_datacopy(SELF, (vir_bytes)&shm->shmid_ds,
who_e, (vir_bytes)ds, sizeof(struct shmid_ds));
if (r != OK)
return EFAULT;
@@ -255,7 +255,7 @@ int do_shmctl(message *m)
uid != 0)
return EPERM;
r = sys_datacopy(who_e, (vir_bytes)ds,
SELF_E, (vir_bytes)&tmp_ds, sizeof(struct shmid_ds));
SELF, (vir_bytes)&tmp_ds, sizeof(struct shmid_ds));
if (r != OK)
return EFAULT;
shm->shmid_ds.shm_perm.uid = tmp_ds.shm_perm.uid;
@@ -282,7 +282,7 @@ int do_shmctl(message *m)
sinfo.shmmni = MAX_SHM_NR;
sinfo.shmseg = (unsigned long) -1;
sinfo.shmall = (unsigned long) -1;
r = sys_datacopy(SELF_E, (vir_bytes)&sinfo,
r = sys_datacopy(SELF, (vir_bytes)&sinfo,
who_e, (vir_bytes)ds, sizeof(struct shminfo));
if (r != OK)
return EFAULT;
@@ -302,7 +302,7 @@ int do_shmctl(message *m)
s_info.shm_swp = 0;
s_info.swap_attempts = 0;
s_info.swap_successes = 0;
r = sys_datacopy(SELF_E, (vir_bytes)&s_info,
r = sys_datacopy(SELF, (vir_bytes)&s_info,
who_e, (vir_bytes)ds, sizeof(struct shm_info));
if (r != OK)
return EFAULT;
@@ -314,7 +314,7 @@ int do_shmctl(message *m)
if (id < 0 || id >= shm_list_nr)
return EINVAL;
shm = &shm_list[id];
r = sys_datacopy(SELF_E, (vir_bytes)&shm->shmid_ds,
r = sys_datacopy(SELF, (vir_bytes)&shm->shmid_ds,
who_e, (vir_bytes)ds, sizeof(struct shmid_ds));
if (r != OK)
return EFAULT;