-
Notifications
You must be signed in to change notification settings - Fork 0
/
fs.h
59 lines (47 loc) · 1.1 KB
/
fs.h
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
/* File system */
#define OPEN 0xA0
#define READ 0xB0
#define WRITE 0xC0
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
typedef struct _hypercall_open {
char *fname;
int flags;
int fd;
} hypercall_open;
typedef struct _hypercall_read {
int fd;
void *buf;
size_t count;
size_t ret;
} hypercall_read;
typedef struct _hypercall_write {
int fd;
void *buf;
size_t count;
size_t ret;
} hypercall_write;
static hypercall_open hopen = { 0, };
static hypercall_read hread = { 0, };
static hypercall_write hwrite = { 0, };
static inline int open(const char *fname, int flags) {
hopen.fname = (char *) fname;
hopen.flags = flags;
outb(OPEN, (size_t) &hopen);
return hopen.fd;
};
static inline size_t read(int fd, void *buf, size_t count) {
hread.fd = fd;
hread.buf = buf;
hread.count = count;
outb(READ, (size_t) &hread);
return hread.ret;
};
static inline size_t write(int fd, const void *buf, size_t count) {
hwrite.fd = fd;
hwrite.buf = buf;
hwrite.count = count;
outb(WRITE, (size_t) &hwrite);
return hwrite.ret;
}