custom messages for SHMAT, SHMDT
This commit is contained in:
parent
8627d33a42
commit
e57d31d331
4 changed files with 27 additions and 15 deletions
|
@ -828,12 +828,7 @@
|
||||||
/* Shared Memory */
|
/* Shared Memory */
|
||||||
#define IPC_SHMGET (IPC_BASE+1)
|
#define IPC_SHMGET (IPC_BASE+1)
|
||||||
#define IPC_SHMAT (IPC_BASE+2)
|
#define IPC_SHMAT (IPC_BASE+2)
|
||||||
# define SHMAT_ID m2_i1
|
|
||||||
# define SHMAT_ADDR m2_l1
|
|
||||||
# define SHMAT_FLAG m2_i2
|
|
||||||
# define SHMAT_RETADDR m2_l2
|
|
||||||
#define IPC_SHMDT (IPC_BASE+3)
|
#define IPC_SHMDT (IPC_BASE+3)
|
||||||
# define SHMDT_ADDR m2_l1
|
|
||||||
#define IPC_SHMCTL (IPC_BASE+4)
|
#define IPC_SHMCTL (IPC_BASE+4)
|
||||||
# define SHMCTL_ID m2_i1
|
# define SHMCTL_ID m2_i1
|
||||||
# define SHMCTL_CMD m2_i2
|
# define SHMCTL_CMD m2_i2
|
||||||
|
|
|
@ -1774,6 +1774,21 @@ typedef struct {
|
||||||
} mess_lc_ipc_shmget;
|
} mess_lc_ipc_shmget;
|
||||||
_ASSERT_MSG_SIZE(mess_lc_ipc_shmget);
|
_ASSERT_MSG_SIZE(mess_lc_ipc_shmget);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int id;
|
||||||
|
const void *addr;
|
||||||
|
int flag;
|
||||||
|
void *retaddr;
|
||||||
|
uint8_t padding[40];
|
||||||
|
} mess_lc_ipc_shmat;
|
||||||
|
_ASSERT_MSG_SIZE(mess_lc_ipc_shmat);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const void *addr;
|
||||||
|
uint8_t padding[52];
|
||||||
|
} mess_lc_ipc_shmdt;
|
||||||
|
_ASSERT_MSG_SIZE(mess_lc_ipc_shmdt);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
endpoint_t m_source; /* who sent the message */
|
endpoint_t m_source; /* who sent the message */
|
||||||
int m_type; /* what kind of message is it */
|
int m_type; /* what kind of message is it */
|
||||||
|
@ -2001,6 +2016,8 @@ typedef struct {
|
||||||
mess_lsys_vm_update m_lsys_vm_update;
|
mess_lsys_vm_update m_lsys_vm_update;
|
||||||
mess_lsys_vm_watch_exit m_lsys_vm_watch_exit;
|
mess_lsys_vm_watch_exit m_lsys_vm_watch_exit;
|
||||||
mess_lc_ipc_shmget m_lc_ipc_shmget;
|
mess_lc_ipc_shmget m_lc_ipc_shmget;
|
||||||
|
mess_lc_ipc_shmat m_lc_ipc_shmat;
|
||||||
|
mess_lc_ipc_shmdt m_lc_ipc_shmdt;
|
||||||
|
|
||||||
mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel;
|
mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel;
|
||||||
mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose;
|
mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose;
|
||||||
|
|
|
@ -33,14 +33,14 @@ void *shmat(int shmid, const void *shmaddr, int shmflg)
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&m, 0, sizeof(m));
|
memset(&m, 0, sizeof(m));
|
||||||
m.SHMAT_ID = shmid;
|
m.m_lc_ipc_shmat.id = shmid;
|
||||||
m.SHMAT_ADDR = (long) shmaddr;
|
m.m_lc_ipc_shmat.addr = shmaddr;
|
||||||
m.SHMAT_FLAG = shmflg;
|
m.m_lc_ipc_shmat.flag = shmflg;
|
||||||
|
|
||||||
r = _syscall(ipc_pt, IPC_SHMAT, &m);
|
r = _syscall(ipc_pt, IPC_SHMAT, &m);
|
||||||
if (r != OK)
|
if (r != OK)
|
||||||
return (void *) -1;
|
return (void *) -1;
|
||||||
return (void *) m.SHMAT_RETADDR;
|
return m.m_lc_ipc_shmat.retaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deattach shared memory segment. */
|
/* Deattach shared memory segment. */
|
||||||
|
@ -55,7 +55,7 @@ int shmdt(const void *shmaddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&m, 0, sizeof(m));
|
memset(&m, 0, sizeof(m));
|
||||||
m.SHMDT_ADDR = (long) shmaddr;
|
m.m_lc_ipc_shmdt.addr = shmaddr;
|
||||||
|
|
||||||
return _syscall(ipc_pt, IPC_SHMDT, &m);
|
return _syscall(ipc_pt, IPC_SHMDT, &m);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,9 @@ int do_shmat(message *m)
|
||||||
void *ret;
|
void *ret;
|
||||||
struct shm_struct *shm;
|
struct shm_struct *shm;
|
||||||
|
|
||||||
id = m->SHMAT_ID;
|
id = m->m_lc_ipc_shmat.id;
|
||||||
addr = (vir_bytes) m->SHMAT_ADDR;
|
addr = (vir_bytes) m->m_lc_ipc_shmat.addr;
|
||||||
flag = m->SHMAT_FLAG;
|
flag = m->m_lc_ipc_shmat.flag;
|
||||||
|
|
||||||
if (addr && (addr % PAGE_SIZE)) {
|
if (addr && (addr % PAGE_SIZE)) {
|
||||||
if (flag & SHM_RND)
|
if (flag & SHM_RND)
|
||||||
|
@ -141,7 +141,7 @@ int do_shmat(message *m)
|
||||||
shm->shmid_ds.shm_lpid = getnpid(who_e);
|
shm->shmid_ds.shm_lpid = getnpid(who_e);
|
||||||
/* nattach is updated lazily */
|
/* nattach is updated lazily */
|
||||||
|
|
||||||
m->SHMAT_RETADDR = (long) ret;
|
m->m_lc_ipc_shmat.retaddr = ret;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ int do_shmdt(message *m)
|
||||||
phys_bytes vm_id;
|
phys_bytes vm_id;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
addr = m->SHMDT_ADDR;
|
addr = (vir_bytes) m->m_lc_ipc_shmdt.addr;
|
||||||
|
|
||||||
if ((vm_id = vm_getphys(who_e, (void *) addr)) == 0)
|
if ((vm_id = vm_getphys(who_e, (void *) addr)) == 0)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
Loading…
Reference in a new issue