2 // Main public header file for our user-land support library,
3 // whose code lives in the lib directory.
4 // This library is roughly our OS's version of a standard C library,
5 // and is intended to be linked into all user-mode applications
6 // (NOT the kernel or boot loader).
11 #include <inc/types.h>
12 #include <inc/stdio.h>
13 #include <inc/stdarg.h>
14 #include <inc/string.h>
15 #include <inc/error.h>
16 #include <inc/assert.h>
19 #include <inc/syscall.h>
21 #define USED(x) (void)(x)
24 extern char *binaryname
;
25 extern struct Env
*env
;
26 extern struct Env envs
[NENV
];
27 extern struct Page pages
[];
31 void set_pgfault_handler(void(*)(u_int va
, u_int err
));
34 char * readline(const char *buf
);
37 void sys_cputs(char*);
39 u_int
sys_getenvid(void);
40 int sys_env_destroy(u_int
);
42 int sys_mem_alloc(u_int
, u_int
, u_int
);
43 int sys_mem_map(u_int
, u_int
, u_int
, u_int
, u_int
);
44 int sys_mem_unmap(u_int
, u_int
);
45 // int sys_env_alloc(void);
46 int sys_set_trapframe(u_int
, struct Trapframe
*);
47 int sys_set_status(u_int
, u_int
);
48 int sys_set_pgfault_entry(u_int
, u_int
);
49 int sys_ipc_can_send(u_int
, u_int
, u_int
, u_int
);
50 void sys_ipc_recv(u_int
);
52 // This must be inlined.
53 // Exercise for reader: why?
61 : "a" (SYS_env_alloc
),
68 void ipc_send(u_int whom
, u_int val
, u_int srcva
, u_int perm
);
69 u_int
ipc_recv(u_int
*whom
, u_int dstva
, u_int
*perm
);
72 #define PTE_LIBRARY 0x400
74 int sfork(void); // Challenge!
79 #define O_RDONLY 0x0000 /* open for reading only */
80 #define O_WRONLY 0x0001 /* open for writing only */
81 #define O_RDWR 0x0002 /* open for reading and writing */
82 #define O_ACCMODE 0x0003 /* mask for above modes */
84 #define O_CREAT 0x0100 /* create if nonexistent */
85 #define O_TRUNC 0x0200 /* truncate to zero length */
86 #define O_EXCL 0x0400 /* error if already exists */
87 #define O_MKDIR 0x0800 /* create directory, not regular file */
89 #endif // not _INC_LIB_H_