summaryrefslogtreecommitdiff
path: root/spec/syscall.h
blob: a40fc602d134c5a848e9b89c8adf533bb82fc1db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* The 15-410 kernel.
 * syscall.h
 *
 * Prototypes for the user-land C library interface
 * to system calls.
 *
 */

#ifndef _SYSCALL_H
#define _SYSCALL_H

#ifndef NORETURN
#define NORETURN __attribute__((__noreturn__))
#endif

#ifndef PAGE_SIZE
#define PAGE_SIZE 0x0001000 /* 4096 */
#endif

/* Life cycle */
int fork(void);
int exec(char *execname, char *argvec[]);
void set_status(int status);
void vanish(void) NORETURN;
int wait(int *status_ptr);
void task_vanish(int status) NORETURN;

/* Thread management */
int gettid(void);
int yield(int pid);
int deschedule(int *flag);
int make_runnable(int pid);
unsigned int get_ticks(void);
int sleep(int ticks);

/* Memory management */
int new_pages(void * addr, int len);
int remove_pages(void * addr);

/* Console I/O */
int getchar(void);
int readline(int size, char *buf);
int print(int size, char *buf);
int set_term_color(int color);
int set_cursor_pos(int row, int col);
int get_cursor_pos(int *row, int *col);

/* Color values for set_term_color() */
#define FGND_BLACK 0x0
#define FGND_BLUE  0x1
#define FGND_GREEN 0x2
#define FGND_CYAN  0x3
#define FGND_RED   0x4
#define FGND_MAG   0x5
#define FGND_BRWN  0x6
#define FGND_LGRAY 0x7 /* Light gray. */
#define FGND_DGRAY 0x8 /* Dark gray. */
#define FGND_BBLUE 0x9 /* Bright blue. */
#define FGND_BGRN  0xA /* Bright green. */
#define FGND_BCYAN 0xB /* Bright cyan. */
#define FGND_PINK  0xC
#define FGND_BMAG  0xD /* Bright magenta. */
#define FGND_YLLW  0xE
#define FGND_WHITE 0xF

#define BGND_BLACK 0x00
#define BGND_BLUE  0x10
#define BGND_GREEN 0x20
#define BGND_CYAN  0x30
#define BGND_RED   0x40
#define BGND_MAG   0x50
#define BGND_BRWN  0x60
#define BGND_LGRAY 0x70 /* Light gray. */

/* Miscellaneous */
void halt(void);
int readfile(char *filename, char *buf, int count, int offset);

/* "Special" */
void misbehave(int mode);

/* Project 4 F2010 */
#include <ureg.h> /* may be directly included by kernel guts */
typedef void (*swexn_handler_t)(void *arg, ureg_t *ureg);
int swexn(void *esp3, swexn_handler_t eip, void *arg, ureg_t *newureg);

/* Project 4 F2017 */
int new_console(void); 

/* Previous API */
/*
void exit(int status) NORETURN;
void task_exit(int status) NORETURN;
int cas2i_runflag(int tid, int *oldp, int ev1, int nv1, int ev2, int nv2);
int ls(int size, char *buf);
*/

#endif /* _SYSCALL_H */