Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
syscall.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <sys/syscall.h>
#include <syscall.h>
Include dependency graph for syscall.c:

Go to the source code of this file.

Functions

uint64_t syscall (int num,...)
 
uint64_t OSTime ()
 
void OSExit (int status)
 
uint64_t OSGetPID ()
 
uint64_t OSSpawn (const char *path, const char *argv[])
 
uint64_t OSWait (uint64_t pid)
 
void * OSMemMap (void *addr, uint64_t len, int flags)
 
int OSMemUnmap (void *addr, uint64_t len)
 
int OSMemProtect (void *addr, uint64_t len, int flags)
 
int OSRead (uint64_t fd, void *addr, uint64_t off, uint64_t length)
 
int OSWrite (uint64_t fd, const void *addr, uint64_t off, uint64_t length)
 
int OSFlush (uint64_t fd)
 
uint64_t OSOpen (const char *path, uint64_t flags)
 
int OSClose (uint64_t fd)
 
int OSStat (const char *path, struct stat *sb)
 
int OSReadDir (uint64_t fd, char *buf, size_t length, uint64_t *offset)
 
int OSPipe (uint64_t fd[2])
 
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)
 
int OSNICStat (uint64_t nicNo, NIC *nic)
 
int OSNICSend (uint64_t nicNo, MBuf *mbuf)
 
int OSNICRecv (uint64_t nicNo, MBuf *mbuf)
 
int OSSysCtl (const char *node, void *oldvar, void *newvar)
 
int OSFSMount (const char *mntpt, const char *device, uint64_t flags)
 
int OSFSUnmount (const char *mntpt)
 
int OSFSInfo (struct statfs *info, uint64_t max)
 

Function Documentation

◆ OSClose()

int OSClose ( uint64_t  fd)

Definition at line 83 of file syscall.c.

84{
85 return syscall(SYSCALL_CLOSE, fd);
86}
uint64_t syscall(int num,...)
#define SYSCALL_CLOSE
Definition: syscall.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSExit()

void OSExit ( int  status)

Definition at line 17 of file syscall.c.

18{
19 syscall(SYSCALL_EXIT, status);
20}
#define SYSCALL_EXIT
Definition: syscall.h:8
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSFlush()

int OSFlush ( uint64_t  fd)

Definition at line 71 of file syscall.c.

72{
73 return syscall(SYSCALL_FLUSH, fd);
74}
#define SYSCALL_FLUSH
Definition: syscall.h:20
Here is the call graph for this function:

◆ OSFSInfo()

int OSFSInfo ( struct statfs info,
uint64_t  max 
)

Definition at line 173 of file syscall.c.

174{
175 return syscall(SYSCALL_FSINFO, info, max);
176}
#define SYSCALL_FSINFO
Definition: syscall.h:50
Here is the call graph for this function:

◆ OSFSMount()

int OSFSMount ( const char *  mntpt,
const char *  device,
uint64_t  flags 
)

Definition at line 161 of file syscall.c.

162{
163 return syscall(SYSCALL_FSMOUNT, mntpt, device, flags);
164}
#define SYSCALL_FSMOUNT
Definition: syscall.h:48
Here is the call graph for this function:

◆ OSFSUnmount()

int OSFSUnmount ( const char *  mntpt)

Definition at line 167 of file syscall.c.

168{
169 return syscall(SYSCALL_FSUNMOUNT, mntpt);
170}
#define SYSCALL_FSUNMOUNT
Definition: syscall.h:49
Here is the call graph for this function:

◆ OSGetPID()

uint64_t OSGetPID ( )

Definition at line 23 of file syscall.c.

24{
25 return syscall(SYSCALL_GETPID);
26}
#define SYSCALL_GETPID
Definition: syscall.h:7
Here is the call graph for this function:

◆ OSGetTID()

int OSGetTID ( )

Definition at line 113 of file syscall.c.

114{
115 return syscall(SYSCALL_GETTID);
116}
#define SYSCALL_GETTID
Definition: syscall.h:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSMemMap()

void * OSMemMap ( void *  addr,
uint64_t  len,
int  flags 
)

Definition at line 41 of file syscall.c.

42{
43 return (void *)syscall(SYSCALL_MMAP, addr, len, flags);
44}
uint64_t addr
Definition: multiboot.h:1
uint64_t len
Definition: multiboot.h:2
#define SYSCALL_MMAP
Definition: syscall.h:13
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSMemProtect()

int OSMemProtect ( void *  addr,
uint64_t  len,
int  flags 
)

Definition at line 53 of file syscall.c.

54{
55 return syscall(SYSCALL_MPROTECT, addr, len, flags);
56}
#define SYSCALL_MPROTECT
Definition: syscall.h:15
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSMemUnmap()

int OSMemUnmap ( void *  addr,
uint64_t  len 
)

Definition at line 47 of file syscall.c.

48{
50}
#define SYSCALL_MUNMAP
Definition: syscall.h:14
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSNICRecv()

int OSNICRecv ( uint64_t  nicNo,
MBuf mbuf 
)

Definition at line 149 of file syscall.c.

150{
152}
static int nicNo
Definition: ethdump.c:9
static MBuf mbuf
Definition: ethdump.c:11
#define SYSCALL_NICRECV
Definition: syscall.h:44
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSNICSend()

int OSNICSend ( uint64_t  nicNo,
MBuf mbuf 
)

Definition at line 143 of file syscall.c.

144{
146}
#define SYSCALL_NICSEND
Definition: syscall.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSNICStat()

int OSNICStat ( uint64_t  nicNo,
NIC nic 
)

Definition at line 137 of file syscall.c.

138{
139 return syscall(SYSCALL_NICSTAT, nicNo, nic);
140}
#define SYSCALL_NICSTAT
Definition: syscall.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSOpen()

uint64_t OSOpen ( const char *  path,
uint64_t  flags 
)

Definition at line 77 of file syscall.c.

78{
79 return syscall(SYSCALL_OPEN, path, flags);
80}
#define SYSCALL_OPEN
Definition: syscall.h:23
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSPipe()

int OSPipe ( uint64_t  fd[2])

Definition at line 101 of file syscall.c.

102{
103 return syscall(SYSCALL_PIPE, &fd[0]);
104}
#define SYSCALL_PIPE
Definition: syscall.h:32
Here is the call graph for this function:

◆ OSRead()

int OSRead ( uint64_t  fd,
void *  addr,
uint64_t  off,
uint64_t  length 
)

Definition at line 59 of file syscall.c.

60{
61 return syscall(SYSCALL_READ, fd, addr, off, length);
62}
#define SYSCALL_READ
Definition: syscall.h:18
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSReadDir()

int OSReadDir ( uint64_t  fd,
char *  buf,
size_t  length,
uint64_t offset 
)

Definition at line 95 of file syscall.c.

96{
97 return syscall(SYSCALL_READDIR, fd, buf, length, offset);
98}
static char buf[4096]
Definition: ethdump.c:10
#define SYSCALL_READDIR
Definition: syscall.h:29
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSSpawn()

uint64_t OSSpawn ( const char *  path,
const char *  argv[] 
)

Definition at line 29 of file syscall.c.

30{
31 return syscall(SYSCALL_SPAWN, path, argv);
32}
#define SYSCALL_SPAWN
Definition: syscall.h:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSStat()

int OSStat ( const char *  path,
struct stat sb 
)

Definition at line 89 of file syscall.c.

90{
91 return syscall(SYSCALL_STAT, path, sb);
92}
#define SYSCALL_STAT
Definition: syscall.h:28
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSSysCtl()

int OSSysCtl ( const char *  node,
void *  oldvar,
void *  newvar 
)

Definition at line 155 of file syscall.c.

156{
157 return syscall(SYSCALL_SYSCTL, node, oldvar, newvar);
158}
#define SYSCALL_SYSCTL
Definition: syscall.h:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSThreadCreate()

int OSThreadCreate ( uint64_t  rip,
uint64_t  arg 
)

Definition at line 107 of file syscall.c.

108{
109 return syscall(SYSCALL_THREADCREATE, rip, arg);
110}
#define SYSCALL_THREADCREATE
Definition: syscall.h:35
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSThreadExit()

int OSThreadExit ( uint64_t  status)

Definition at line 119 of file syscall.c.

120{
121 return syscall(SYSCALL_THREADEXIT, status);
122}
#define SYSCALL_THREADEXIT
Definition: syscall.h:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSThreadSleep()

int OSThreadSleep ( uint64_t  time)

Definition at line 125 of file syscall.c.

126{
128}
time_t time(time_t *t)
Definition: time.c:20
#define SYSCALL_THREADSLEEP
Definition: syscall.h:38
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSThreadWait()

int OSThreadWait ( uint64_t  tid)

Definition at line 131 of file syscall.c.

132{
133 return syscall(SYSCALL_THREADWAIT, tid);
134}
#define SYSCALL_THREADWAIT
Definition: syscall.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSTime()

uint64_t OSTime ( )

Definition at line 11 of file syscall.c.

12{
13 return syscall(SYSCALL_TIME);
14}
#define SYSCALL_TIME
Definition: syscall.h:6
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSWait()

uint64_t OSWait ( uint64_t  pid)

Definition at line 35 of file syscall.c.

36{
37 return syscall(SYSCALL_WAIT, pid);
38}
#define SYSCALL_WAIT
Definition: syscall.h:10
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OSWrite()

int OSWrite ( uint64_t  fd,
const void *  addr,
uint64_t  off,
uint64_t  length 
)

Definition at line 65 of file syscall.c.

66{
67 return syscall(SYSCALL_WRITE, fd, addr, off, length);
68}
#define SYSCALL_WRITE
Definition: syscall.h:19
Here is the call graph for this function:
Here is the caller graph for this function:

◆ syscall()

uint64_t syscall ( int  num,
  ... 
)
Here is the caller graph for this function: