summaryrefslogtreecommitdiff
path: root/src/kernel/mem/seg.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/mem/seg.h')
-rw-r--r--src/kernel/mem/seg.h41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/kernel/mem/seg.h b/src/kernel/mem/seg.h
index ea95dfa..bec0d8c 100644
--- a/src/kernel/mem/seg.h
+++ b/src/kernel/mem/seg.h
@@ -8,14 +8,22 @@
struct segment_map;
struct segment {
- void* seg_data;
+ private:
+ // these functions must not be used directly by anyone
+ virtual segment_map* i_map(page_directory* pagedir, size_t offset) = 0;
+ virtual void i_unmap(segment_map*) = 0;
+
+ public:
int mappings;
- // these 4 functions must not be used directly by anyone
- segment_map* (*map)(segment* seg, page_directory* pagedir, size_t offset);
- void (*unmap)(segment_map*);
- void (*del)(segment* seg);
- int (*handle_fault)(segment_map* map, size_t addr, int write); //0 if ok, 1 if segfault
+ segment();
+ virtual ~segment();
+
+ virtual int handle_fault(segment_map* map, size_t addr, int write) = 0; //0 if ok, 1 if segfault
+ //parameter offset in seg_map doesn't need to be used
+ segment_map *map(page_directory* pagedir, size_t offset);
+ // When unmapping a segment, the segment is deleted if it is not mapped anywhere anymore.
+ void unmap(segment_map* map);
};
struct segment_map {
@@ -25,19 +33,22 @@ struct segment_map {
segment_map *next;
};
-//parameter offset in seg_map doesn't need to be used
-segment_map *seg_map(segment* seg, page_directory* pagedir, size_t offset);
-// When unmapping a segment, the segment is deleted if it is not mapped anywhere anymore.
-void seg_unmap(segment_map* map);
-
/// ************************************* SIMPLESEG stuff *****************
-struct simpleseg {
+struct simpleseg : segment {
int writable;
size_t start, len;
-};
-segment* simpleseg_make(size_t start, size_t len, int writable);
-int simpleseg_resize(segment_map *map, size_t len);
+ simpleseg(size_t start, size_t len, int writable);
+ virtual ~simpleseg();
+
+ virtual int handle_fault(segment_map* map, size_t addr, int write); //0 if ok, 1 if segfault
+
+ int resize(segment_map *map, size_t len);
+
+ private:
+ virtual segment_map* i_map(page_directory* pagedir, size_t offset);
+ virtual void i_unmap(segment_map*);
+};
#endif