aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/include
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-20 15:47:51 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-20 15:47:51 +0100
commit9ba449a6e5f9db20923fb9802eefe0f090ba5fff (patch)
treef0f58bfa44a30e61e30caf08af1cdf03bef822f0 /src/kernel/include
parent2d4d64189501c253ed6a5b5ff5e27da1cb34407a (diff)
downloadkogata-9ba449a6e5f9db20923fb9802eefe0f090ba5fff.tar.gz
kogata-9ba449a6e5f9db20923fb9802eefe0f090ba5fff.zip
Change mode of operation for mmap_file (see readme)
Diffstat (limited to 'src/kernel/include')
-rw-r--r--src/kernel/include/process.h18
-rw-r--r--src/kernel/include/thread.h5
-rw-r--r--src/kernel/include/vfs.h13
3 files changed, 32 insertions, 4 deletions
diff --git a/src/kernel/include/process.h b/src/kernel/include/process.h
index 07cc14e..6e287e1 100644
--- a/src/kernel/include/process.h
+++ b/src/kernel/include/process.h
@@ -21,7 +21,22 @@
#define USERSTACK_ADDR 0xB8000000
#define USERSTACK_SIZE 0x00020000 // 32 KB
-struct user_region;
+typedef struct process process_t;
+
+typedef struct user_region {
+ process_t *proc;
+
+ void* addr;
+ size_t size;
+
+ int mode;
+
+ fs_handle_t *file; // null if not mmaped-file
+ size_t file_offset;
+
+ struct user_region *next;
+} user_region_t;
+
typedef struct process {
pagedir_t *pd;
struct user_region *regions;
@@ -32,6 +47,7 @@ typedef struct process {
int next_fd;
thread_t *thread;
+ uint64_t last_ran;
int pid;
struct process *parent;
diff --git a/src/kernel/include/thread.h b/src/kernel/include/thread.h
index 8ffbb3d..fa7dc6f 100644
--- a/src/kernel/include/thread.h
+++ b/src/kernel/include/thread.h
@@ -18,16 +18,17 @@ typedef struct saved_context {
void (*eip)();
} saved_context_t;
-struct process;
+typedef struct process process_t;
typedef struct thread {
saved_context_t ctx;
pagedir_t *current_pd_d;
uint32_t state;
+ uint64_t last_ran;
region_info_t *stack_region;
- struct process *proc;
+ process_t *proc;
isr_handler_t user_ex_handler; // page fault in kernel memory accessed by user code (violation)
struct thread *next_in_queue;
diff --git a/src/kernel/include/vfs.h b/src/kernel/include/vfs.h
index cca4952..82b02f4 100644
--- a/src/kernel/include/vfs.h
+++ b/src/kernel/include/vfs.h
@@ -41,15 +41,21 @@ struct fs;
struct fs_node;
struct fs_handle;
+typedef struct user_region user_region_t;
+
// -------------------------------------------
// Structure defining a handle to an open file
typedef struct {
+ // Standard read-write architecture
size_t (*read)(fs_handle_ptr f, size_t offset, size_t len, char* buf);
size_t (*write)(fs_handle_ptr f, size_t offset, size_t len, const char* buf);
bool (*readdir)(fs_handle_ptr f, dirent_t *d);
int (*ioctl)(fs_handle_ptr f, int command, void* data);
void (*close)(fs_handle_ptr f);
+ // Page cache architecture, must be implemented by all files opened with FM_MMAP
+ uint32_t (*get_page)(fs_handle_ptr f, size_t offset);
+ void (*commit_page)(fs_handle_ptr f, size_t offset, uint64_t time); // notifies change
} fs_handle_ops_t;
typedef struct fs_handle {
@@ -165,11 +171,16 @@ bool fs_stat(fs_t *fs, const char* file, stat_t *st);
fs_handle_t* fs_open(fs_t *fs, const char* file, int mode);
void ref_file(fs_handle_t *file);
void unref_file(fs_handle_t *file);
+
int file_get_mode(fs_handle_t *f);
+bool file_stat(fs_handle_t *f, stat_t *st);
+
size_t file_read(fs_handle_t *f, size_t offset, size_t len, char* buf);
size_t file_write(fs_handle_t *f, size_t offset, size_t len, const char* buf);
-bool file_stat(fs_handle_t *f, stat_t *st);
int file_ioctl(fs_handle_t *f, int command, void* data);
bool file_readdir(fs_handle_t *f, dirent_t *d);
+uint32_t file_get_page(fs_handle_t *f, size_t offset);
+void file_commit_page(fs_handle_t *f, size_t offset, uint64_t time);
+
/* vim: set ts=4 sw=4 tw=0 noet :*/