Fix mmap and expose gettid system call
This commit is contained in:
parent
cfee2dd1e8
commit
8b45f56bf5
@ -30,6 +30,7 @@ int OSReadDir(uint64_t fd, char *buf, size_t length, uint64_t *offset);
|
||||
|
||||
// Threads
|
||||
int OSThreadCreate(uint64_t rip, uint64_t arg);
|
||||
int OSGetTID();
|
||||
int OSThreadExit(uint64_t status);
|
||||
int OSThreadSleep(uint64_t time);
|
||||
int OSThreadWait(uint64_t tid);
|
||||
|
@ -103,6 +103,12 @@ OSThreadCreate(uint64_t rip, uint64_t arg)
|
||||
return syscall(SYSCALL_THREADCREATE, rip, arg);
|
||||
}
|
||||
|
||||
int
|
||||
OSGetTID()
|
||||
{
|
||||
return syscall(SYSCALL_GETTID);
|
||||
}
|
||||
|
||||
int
|
||||
OSThreadExit(uint64_t status)
|
||||
{
|
||||
|
@ -30,9 +30,10 @@
|
||||
|
||||
// Threading
|
||||
#define SYSCALL_THREADCREATE 0x30
|
||||
#define SYSCALL_THREADEXIT 0x31
|
||||
#define SYSCALL_THREADSLEEP 0x32
|
||||
#define SYSCALL_THREADWAIT 0x33
|
||||
#define SYSCALL_GETTID 0x31
|
||||
#define SYSCALL_THREADEXIT 0x32
|
||||
#define SYSCALL_THREADSLEEP 0x33
|
||||
#define SYSCALL_THREADWAIT 0x34
|
||||
|
||||
// Network
|
||||
#define SYSCALL_NICSTAT 0x40
|
||||
|
@ -139,10 +139,9 @@ uint64_t
|
||||
Syscall_MMap(uint64_t addr, uint64_t len, uint64_t prot)
|
||||
{
|
||||
Thread *cur = Sched_Current();
|
||||
uint64_t pgs = (len + PGSIZE - 1) / PGSIZE;
|
||||
bool status;
|
||||
|
||||
status = PMap_AllocMap(cur->space, addr, pgs, PTE_W);
|
||||
status = PMap_AllocMap(cur->space, addr, len, PTE_W);
|
||||
Thread_Release(cur);
|
||||
if (!status) {
|
||||
// XXX: Need to unmap PMap_Unmap(cur->space, addr, pgs);
|
||||
@ -375,6 +374,17 @@ Syscall_ThreadCreate(uint64_t rip, uint64_t arg)
|
||||
return threadId;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_GetTID()
|
||||
{
|
||||
Thread *cur = Sched_Current();
|
||||
uint64_t tid = cur->tid;
|
||||
|
||||
Thread_Release(cur);
|
||||
|
||||
return tid;
|
||||
}
|
||||
|
||||
void
|
||||
Syscall_ThreadExit(uint64_t status)
|
||||
{
|
||||
@ -562,6 +572,8 @@ Syscall_Entry(uint64_t syscall, uint64_t a1, uint64_t a2,
|
||||
return Syscall_ReadDir(a1, (char *)a2, a3, a4);
|
||||
case SYSCALL_THREADCREATE:
|
||||
return Syscall_ThreadCreate(a1, a2);
|
||||
case SYSCALL_GETTID:
|
||||
return Syscall_GetTID();
|
||||
case SYSCALL_THREADEXIT:
|
||||
Syscall_ThreadExit(a1);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user