Placeholder for system calls
This commit is contained in:
parent
3aef9e4cd8
commit
0d1847269a
@ -41,6 +41,7 @@ src_common = [
|
||||
"kern/palloc.c",
|
||||
"kern/printf.c",
|
||||
"kern/spinlock.c",
|
||||
"kern/syscall.c",
|
||||
"kern/thread.c",
|
||||
"dev/ahci.c",
|
||||
"dev/console.c",
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <sys/kdebug.h>
|
||||
#include <sys/spinlock.h>
|
||||
#include <sys/irq.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include <machine/amd64.h>
|
||||
#include <machine/lapic.h>
|
||||
@ -147,7 +148,8 @@ trap_entry(TrapFrame *tf)
|
||||
Debug_Breakpoint(tf);
|
||||
return;
|
||||
case T_SYSCALL:
|
||||
kprintf("Userlevel syscall\n");
|
||||
kprintf("Syscall %016llx\n", tf->rdi);
|
||||
tf->rax = Syscall_Entry(tf->rdi, tf->rsi, tf->rdx, tf->rcx, tf->r8, tf->r9);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
|
44
sys/include/syscall.h
Normal file
44
sys/include/syscall.h
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
#ifndef __SYS_SYSCALL_H__
|
||||
#define __SYS_SYSCALL_H__
|
||||
|
||||
#define SYSCALL_NULL 0x00
|
||||
#define SYSCALL_TIME 0x01
|
||||
#define SYSCALL_EXIT 0x02
|
||||
#define SYSCALL_SPAWN 0x03
|
||||
#define SYSCALL_GETPID 0x04
|
||||
|
||||
// Memory
|
||||
#define SYSCALL_MMAP 0x08
|
||||
#define SYSCALL_MUNMAP 0x09
|
||||
#define SYSCALL_MPROTECT 0x0A
|
||||
|
||||
// Stream
|
||||
#define SYSCALL_READ 0x10
|
||||
#define SYSCALL_WRITE 0x11
|
||||
#define SYSCALL_FLUSH 0x12
|
||||
|
||||
// File
|
||||
#define SYSCALL_OPEN 0x18
|
||||
#define SYSCALL_CLOSE 0x19
|
||||
#define SYSCALL_MOVE 0x1A
|
||||
#define SYSCALL_DELETE 0x1B
|
||||
#define SYSCALL_SETLENGTH 0x1C
|
||||
|
||||
// Threading
|
||||
#define SYSCALL_THREADCREATE 0x30
|
||||
#define SYSCALL_THREADEXIT 0x31
|
||||
#define SYSCALL_THREADSLEEP 0x32
|
||||
|
||||
// Network
|
||||
#define SYSCALL_SOCKET 0x40
|
||||
#define SYSCALL_BIND 0x41
|
||||
#define SYSCALL_CONNECT 0x42
|
||||
#define SYSCALL_LISTEN 0x43
|
||||
#define SYSCALL_SHUTDOWN 0x44
|
||||
|
||||
uint64_t Syscall_Entry(uint64_t syscall, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5);
|
||||
|
||||
#endif /* __SYS_SYSCALL_H__ */
|
||||
|
97
sys/kern/syscall.c
Normal file
97
sys/kern/syscall.c
Normal file
@ -0,0 +1,97 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <sys/kassert.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
uint64_t
|
||||
Syscall_Time()
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_Exit(uint64_t status)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_Spawn(uint64_t path)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_GetPID()
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_MMap(uint64_t addr, uint64_t len, uint64_t prot)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_MUnmap(uint64_t addr, uint64_t len)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_MProtect(uint64_t addr, uint64_t len, uint64_t prot)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_Read(uint64_t fd, uint64_t addr, uint64_t length)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_Write(uint64_t fd, uint64_t addr, uint64_t length)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Syscall_Entry(uint64_t syscall, uint64_t a1, uint64_t a2,
|
||||
uint64_t a3, uint64_t a4, uint64_t a5)
|
||||
{
|
||||
switch (syscall)
|
||||
{
|
||||
case SYSCALL_NULL:
|
||||
return 0;
|
||||
case SYSCALL_TIME:
|
||||
return Syscall_Time();
|
||||
case SYSCALL_EXIT:
|
||||
return Syscall_Exit(a1);
|
||||
case SYSCALL_MMAP:
|
||||
return Syscall_MMap(a1, a2, a3);
|
||||
case SYSCALL_MUNMAP:
|
||||
return Syscall_MUnmap(a1, a2);
|
||||
case SYSCALL_MPROTECT:
|
||||
return Syscall_MProtect(a1, a2, a3);
|
||||
case SYSCALL_READ:
|
||||
return Syscall_Read(a1, a2, a3);
|
||||
case SYSCALL_WRITE:
|
||||
return Syscall_Write(a1, a2, a3);
|
||||
default:
|
||||
return (uint64_t)-1;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user