summaryrefslogtreecommitdiff
path: root/src/kernel/mem
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-03-30 19:22:23 +0200
committerAlexis211 <alexis211@gmail.com>2010-03-30 19:22:23 +0200
commitad1ec29070e1ffba7461687cd268e64be06aa78b (patch)
tree309ca65d46f1a6164c048d9ba2060275d6d63538 /src/kernel/mem
parent50152369119ffc92d7790ddcfd26f32613366ede (diff)
downloadTCE-ad1ec29070e1ffba7461687cd268e64be06aa78b.tar.gz
TCE-ad1ec29070e1ffba7461687cd268e64be06aa78b.zip
More work on IPC and userland tools.
Diffstat (limited to 'src/kernel/mem')
-rw-r--r--src/kernel/mem/paging.c1
-rw-r--r--src/kernel/mem/paging.h2
-rw-r--r--src/kernel/mem/seg.c21
-rw-r--r--src/kernel/mem/seg.h1
4 files changed, 23 insertions, 2 deletions
diff --git a/src/kernel/mem/paging.c b/src/kernel/mem/paging.c
index 8996162..9972b2a 100644
--- a/src/kernel/mem/paging.c
+++ b/src/kernel/mem/paging.c
@@ -22,7 +22,6 @@ void frame_free(uint32_t id) {
bitset_clear(&frames, id);
}
-
void paging_init(size_t totalRam) {
uint32_t i;
diff --git a/src/kernel/mem/paging.h b/src/kernel/mem/paging.h
index cb76cd6..ec10560 100644
--- a/src/kernel/mem/paging.h
+++ b/src/kernel/mem/paging.h
@@ -26,7 +26,7 @@ struct page_directory {
struct segment_map *mappedSegs;
};
-extern struct page_directory *kernel_pagedir;
+extern struct page_directory *kernel_pagedir, *current_pagedir;
uint32_t frame_alloc();
void frame_free(uint32_t id);
diff --git a/src/kernel/mem/seg.c b/src/kernel/mem/seg.c
index aa71564..ffaa84c 100644
--- a/src/kernel/mem/seg.c
+++ b/src/kernel/mem/seg.c
@@ -71,3 +71,24 @@ int simpleseg_handleFault(struct segment_map* sm, size_t addr, int write) {
void simpleseg_delete(struct segment* seg) {
}
+
+int simpleseg_resize(struct segment_map *map, size_t len) {
+ size_t i;
+
+ if (map == 0) return -1;
+ if (map->seg->delete != simpleseg_delete) return -2;
+
+ struct simpleseg *s = (struct simpleseg*)map->seg->seg_data;
+ if (len & 0xFFF) len = (len & 0xFFFFF000) + 0x1000;
+ if (len < map->len) {
+ for (i = map->start + len; i < map->start + map->len; i += 0x1000) {
+ page_unmapFree(pagedir_getPage(map->pagedir, i, 0));
+ }
+ map->len = len;
+ s->len = len;
+ } else if (len > map->len) {
+ map->len = len;
+ s->len = len;
+ }
+ return 0;
+}
diff --git a/src/kernel/mem/seg.h b/src/kernel/mem/seg.h
index 4d6660f..26664dc 100644
--- a/src/kernel/mem/seg.h
+++ b/src/kernel/mem/seg.h
@@ -37,5 +37,6 @@ struct segment_map* simpleseg_map(struct segment* seg, struct page_directory* pa
void simpleseg_unmap(struct segment_map*);
void simpleseg_delete(struct segment *seg);
int simpleseg_handleFault(struct segment_map* map, size_t addr, int write);
+int simpleseg_resize(struct segment_map *map, size_t len);
#endif