aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/elf.c5
-rw-r--r--common/proc.c16
-rw-r--r--common/tcb.c4
3 files changed, 21 insertions, 4 deletions
diff --git a/common/elf.c b/common/elf.c
index c73d56c..fafef00 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -15,7 +15,7 @@ static void __map_exec(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart, size
size_t vsz = program_header_prop(ei_c, runner, p_memsz);
vm_t start = 0;
- if(!(start = alloc_fixed_region(&t->sp_r, va, vsz, 0)))
+ if(!(start = alloc_fixed_region(&t->sp_r, va, vsz, &vsz)))
return; /* out of memory or something */
uint8_t vflags = VM_V | VM_U;
@@ -36,6 +36,9 @@ static void __map_exec(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart, size
memcpy((void *)va, (void *)vo, vfz);
/* skip while testing
+ * TODO: also fix, this fixes only the first region. Create new
+ * function?
+ *
pm_t paddr = 0;
stat_vmem(t->b_r, va, &paddr, 0, 0);
mod_vmem(t->b_r, va, paddr, vflags);
diff --git a/common/proc.c b/common/proc.c
new file mode 100644
index 0000000..5fdf413
--- /dev/null
+++ b/common/proc.c
@@ -0,0 +1,16 @@
+#include <apos/proc.h>
+
+/* TODO: add error checking */
+vm_t setup_call_stack(struct tcb *t, vm_t start, size_t bytes)
+{
+ pm_t offset = 0;
+ size_t pages = __pages(bytes);
+ uint8_t flags = VM_V | VM_R | VM_W | VM_U;
+ for(size_t i = 0; i < pages; ++i)
+ {
+ offset = alloc_page(BASE_PAGE, offset);
+ map_vmem(t->b_r, offset, start + BASE_PAGE_SIZE * i, flags, BASE_PAGE);
+ }
+
+ return start;
+}
diff --git a/common/tcb.c b/common/tcb.c
index 8a1e95e..1547d49 100644
--- a/common/tcb.c
+++ b/common/tcb.c
@@ -1,4 +1,5 @@
#include <apos/tcb.h>
+#include <apos/cpu.h>
#include <apos/utils.h>
#include <apos/sp_tree.h>
@@ -64,8 +65,5 @@ struct tcb *get_tcb(id_t pid)
struct tcb *cur_tcb()
{
- /* TODO: probably keep an array of processor ID's somewhere where each
- * ID has a corresponding 'currently executing thread ID' field, and
- * reutrn that. */
return __tcb_cache[cpu_id()];
}