OBJECTS = boot.o debug.o init.o cpu.o cpu32.o entry.o interrupt.o paging.o apic.o i8259.o task.o \
- heap.o process.o
+ heap.o
OUTPUT = arch.o
LDFLAGS += -r
INCLUDES = -I../../include -I../include -I../..
+++ /dev/null
-#include <corax/types.h>
-#include <corax/errno.h>
-#include <corax/heap.h>
-#include <arch.h>
-#include <debug.h>
-#include <process.h>
-#include "paging.h"
-#include "cpu.h"
-
-struct process {
- struct pagedir *p_pgdir;
- struct task *p_tasks;
- u32_t p_privl;
-};
-
-int process_create(process_t **dst, u32_t ppl, void *entry)
-{
- int ret_val;
- process_t *proc;
-
- ret_val = -ENOMEM;
- proc = kmalloc(sizeof(*proc));
-
- if(proc) {
- void *pdbr;
- void *kstack;
- void *ustack;
-
- ret_val = pg_dir_create(&(proc->p_pgdir));
-
- if(ret_val < 0) {
- goto cleanup;
- }
-
- pdbr = proc->p_pgdir->pd_base;
- kstack = pg_dir_get_kstack(proc->p_pgdir);
- ustack = pg_dir_get_ustack(proc->p_pgdir);
-
- proc->p_tasks = kmalloc(sizeof(*(proc->p_tasks)));
-
- if(!proc->p_tasks) {
- ret_val = -ENOMEM;
- goto cleanup;
- }
-
- proc->p_privl = ppl;
-
- task_prepare(proc->p_tasks, (u32_t)pdbr, (u32_t)entry,
- (u32_t)kstack, (u32_t)ustack + PAGE_SIZE, ppl);
-
- proc->p_tasks->t_sp = (u32_t)(CONFIG_KERNEL_STACK_BASE +
- ((u32_t)proc->p_tasks->t_sp - (u32_t)kstack));
- }
-
-cleanup:
- if(ret_val < 0) {
- if(proc) {
- if(proc->p_pgdir) {
- /* cleanup pagedir */
- /* pg_dir_free(proc->p_pgdir): */
- proc->p_pgdir = NULL;
- }
-
- if(proc->p_tasks) {
- /* cleanup task */
-
- kfree(proc->p_tasks);
- proc->p_tasks = NULL;
- }
-
- kfree(proc);
- proc = NULL;
- }
- }
-
- *dst = proc;
- return(ret_val);
-}
-
-int process_switch(process_t *proc)
-{
- int ret_val;
-
- ret_val = task_switch(proc->p_tasks);
-
- return(ret_val);
-}
-OBJECTS = main.o
+OBJECTS = main.o process.o
OUTPUT = core.o
INCLUDES = -I../include -I../../include -I../..
CFLAGS += $(INCLUDES)
--- /dev/null
+#include <corax/types.h>
+#include <corax/errno.h>
+#include <corax/heap.h>
+#include <arch.h>
+#include <debug.h>
+#include <process.h>
+#include "paging.h"
+#include "cpu.h"
+
+struct process {
+ struct pagedir *p_pgdir;
+ struct task *p_tasks;
+ u32_t p_privl;
+};
+
+int process_create(process_t **dst, u32_t ppl, void *entry)
+{
+ int ret_val;
+ process_t *proc;
+
+ ret_val = -ENOMEM;
+ proc = kmalloc(sizeof(*proc));
+
+ if(proc) {
+ void *pdbr;
+ void *kstack;
+ void *ustack;
+
+ ret_val = pg_dir_create(&(proc->p_pgdir));
+
+ if(ret_val < 0) {
+ goto cleanup;
+ }
+
+ pdbr = proc->p_pgdir->pd_base;
+ kstack = pg_dir_get_kstack(proc->p_pgdir);
+ ustack = pg_dir_get_ustack(proc->p_pgdir);
+
+ proc->p_tasks = kmalloc(sizeof(*(proc->p_tasks)));
+
+ if(!proc->p_tasks) {
+ ret_val = -ENOMEM;
+ goto cleanup;
+ }
+
+ proc->p_privl = ppl;
+
+ task_prepare(proc->p_tasks, (u32_t)pdbr, (u32_t)entry,
+ (u32_t)kstack, (u32_t)ustack + PAGE_SIZE, ppl);
+
+ proc->p_tasks->t_sp = (u32_t)(CONFIG_KERNEL_STACK_BASE +
+ ((u32_t)proc->p_tasks->t_sp - (u32_t)kstack));
+ }
+
+cleanup:
+ if(ret_val < 0) {
+ if(proc) {
+ if(proc->p_pgdir) {
+ /* cleanup pagedir */
+ /* pg_dir_free(proc->p_pgdir): */
+ proc->p_pgdir = NULL;
+ }
+
+ if(proc->p_tasks) {
+ /* cleanup task */
+
+ kfree(proc->p_tasks);
+ proc->p_tasks = NULL;
+ }
+
+ kfree(proc);
+ proc = NULL;
+ }
+ }
+
+ *dst = proc;
+ return(ret_val);
+}
+
+int process_switch(process_t *proc)
+{
+ int ret_val;
+
+ ret_val = task_switch(proc->p_tasks);
+
+ return(ret_val);
+}
--- /dev/null
+/*
+ * This file is part of the Corax operating system.
+ * Copyright (C) 2016-2019 Matthias Kruk
+ *
+ * Corax is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Corax is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Corax. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __PROCESS_H
+#define __PROCESS_H
+
+#include <corax/types.h>
+
+typedef struct process process_t;
+
+int process_create(process_t**, u32_t, void*);
+int process_switch(process_t*);
+
+#endif /* __PROCESS_H */