-
Notifications
You must be signed in to change notification settings - Fork 1
/
kern_io.c
89 lines (69 loc) · 2.35 KB
/
kern_io.c
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
#include "kern_io.h"
#include "driver/kern_stream.h"
#include "driver/kern_dir.h"
#define STREAM_HANDLE_SIZE 32
//#############################################################################
// driver lookup
//#############################################################################
int stream_handle_size = STREAM_HANDLE_SIZE;
struct stream_handle stream_handles[STREAM_HANDLE_SIZE] = {
{PROTOCOL_NULL},
{PROTOCOL_STREAM},
{PROTOCOL_STREAM},
{PROTOCOL_DIRECTORY}
};
struct driver_callback driver_callbacks[] = {
{0, 0},
{_stream_read, _stream_write},
{_stream_read, _stream_write},
{_dir_read, _dir_write}
};
//#############################################################################
// raw fs access
//#############################################################################
error_t _kern_read(streamh_t sh, void *buffer, k_size_t *read_byte_count) {
struct stream_handle *h = &stream_handles[sh];
struct driver_callback *callback = &driver_callbacks[h->protocol];
if(callback == 0) {
return ERROR_GENERIC;
}
return callback->read_fc(h, buffer, read_byte_count);
}
error_t _kern_write(streamh_t sh, void *buffer, k_size_t *write_byte_count) {
struct stream_handle *h = &stream_handles[sh];
struct driver_callback *callback = &driver_callbacks[h->protocol];
if(callback == 0) {
return ERROR_GENERIC;
}
return callback->write_fc(h, buffer, write_byte_count);
}
streamh_t _kern_open(streamh_t directory, char *name, mode_t mode) {
return ERROR_NONE;
}
error_t _kern_close(streamh_t sh) {
return ERROR_NONE;
}
streamh_t _kern_reopen(streamh_t sh) {
return ERROR_NONE;
}
error_t _kern_stat(streamh_t directory, char *name, struct stream_stat *stat_buffer, k_size_t buffer_size) {
return ERROR_NONE;
}
error_t _kern_stat_h(streamh_t sh, struct stream_stat *stat_buffer, k_size_t buffer_size) {
return ERROR_NONE;
}
//#############################################################################
// higher level fs access
//#############################################################################
error_t _kern_screate(char *path, protocol_t type) {
return ERROR_NONE;
}
error_t _kern_fwrite(streamh_t sh, void *buffer, k_size_t *write_byte_count) {
return ERROR_NONE;
}
error_t _kern_fread(streamh_t sh, void *buffer, k_size_t *read_byte_count) {
return ERROR_NONE;
}
error_t _kern_fopen(char *path, mode_t mode) {
return ERROR_NONE;
}