aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/include
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-13 18:19:47 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-13 18:19:47 +0100
commit7aafc22a01de5cabb99aed76782f6c0999b7de05 (patch)
tree8f20a49e463a145b0fed2ea3256407b5e6316ba4 /src/kernel/include
parentf67c0b7e20ef0816a2d9047fd20346e3ede98b75 (diff)
downloadkogata-7aafc22a01de5cabb99aed76782f6c0999b7de05.tar.gz
kogata-7aafc22a01de5cabb99aed76782f6c0999b7de05.zip
Add stubs for process-related functions.
Diffstat (limited to 'src/kernel/include')
-rw-r--r--src/kernel/include/paging.h5
-rw-r--r--src/kernel/include/process.h29
-rw-r--r--src/kernel/include/thread.h6
3 files changed, 28 insertions, 12 deletions
diff --git a/src/kernel/include/paging.h b/src/kernel/include/paging.h
index 56fa7fa..67f9fef 100644
--- a/src/kernel/include/paging.h
+++ b/src/kernel/include/paging.h
@@ -2,6 +2,7 @@
#include <sys.h>
#include <stdbool.h>
+#include <idt.h>
// Bits in the error code for page fault
#define PF_PRESENT_BIT (1<<0)
@@ -13,6 +14,8 @@
struct page_directory;
typedef struct page_directory pagedir_t;
+typedef void (*user_pf_handler_t)(void* handler_data, registers_t *regs, void* addr);
+
void paging_setup(void* kernel_data_end);
pagedir_t *get_current_pagedir();
@@ -31,7 +34,7 @@ void pd_unmap_page(void* vaddr); // does nothing if page not mapped
// case both might require the allocation of a new PT at the same location. These
// cases are well-handled (the pagedir_t type contains a mutex used for this)
-pagedir_t *create_pagedir(); // returns zero on error
+pagedir_t *create_pagedir(user_pf_handler_t pf, void* pf_handler_data); // returns zero on error
void delete_pagedir(pagedir_t *pd);
/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/src/kernel/include/process.h b/src/kernel/include/process.h
index d1914ef..30e24db 100644
--- a/src/kernel/include/process.h
+++ b/src/kernel/include/process.h
@@ -1,12 +1,25 @@
#pragma once
-// A process is a recipient for user code, as well as for mounting File Systems,
-// which allow access to features of the system.
+// A process is basically :
+// - a page directory and a list of segments mapped in user space
+// - a list of file systems each associated to a name
+// - some threads (currently, only one thread per process supported)
-#include <thread.h>
+// Notes on memory mapping :
+// - mmap creates an empty zone (zero-initialized)
+// - mmap_file increments the refcount of the file handle
+// - mchmap = change mode on already mapped zone (eg. after loading code)
#include <hashtbl.h>
+#include <thread.h>
+#include <vfs.h>
+
+
+// Modes for mmaping regions
+#define MM_READ (0x01)
+#define MM_WRITE (0x02)
+#define MM_EXEC (0x04)
struct process;
typedef struct process process_t;
@@ -14,14 +27,16 @@ typedef struct process process_t;
process_t *current_process();
process_t *new_process(process_t *parent);
-void delete_process(process_t *p);
+// void delete_process(process_t *p); // TODO define semantics for freeing stuff
-void start_process(process_t *p, entry_t entry, void* data);
+bool start_process(process_t *p, void* entry); // maps a region for user stack
bool proc_add_fs(process_t *p, fs_t *fs, const char* name);
fs_t *proc_find_fs(process_t *p, const char* name);
-bool mmap(process_t *proc, void* addr, size_t size, int type);
-bool mmap_file(process_t *proc, fs_handle_t *h, void* addr, size_t size, int mode);
+bool mmap(process_t *proc, void* addr, size_t size, int mode); // create empty zone
+bool mmap_file(process_t *proc, fs_handle_t *h, size_t offset, void* addr, size_t size, int mode);
+bool mchmap(process_t *proc, void* addr, int mode);
+bool munmap(process_t *proc, void* addr);
/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/src/kernel/include/thread.h b/src/kernel/include/thread.h
index 011067f..74499c6 100644
--- a/src/kernel/include/thread.h
+++ b/src/kernel/include/thread.h
@@ -13,8 +13,6 @@
#define TASK_SWITCH_FREQUENCY 50 // in herz
-typedef void (*user_pf_handler_t)(pagedir_t *pd, registers_t *regs, void* addr);
-
typedef struct saved_context {
uint32_t *esp;
void (*eip)();
@@ -29,8 +27,7 @@ typedef struct thread {
region_info_t *stack_region;
- struct process *proc; // process : L1 data structure
- user_pf_handler_t usermem_pf_handler; // page fault in user memory
+ struct process *proc;
isr_handler_t kmem_violation_handler; // page fault in kernel memory accessed by user code (violation)
struct thread *next_in_queue;
@@ -48,5 +45,6 @@ void pause();
void exit();
void resume_thread(thread_t *thread, bool run_at_once);
+void kill_thread(thread_t *thread);
/* vim: set ts=4 sw=4 tw=0 noet :*/