From 4151273dbd7db23ec76bca32cea158c5f181d241 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Sun, 5 Nov 2017 15:37:11 +0000 Subject: [PATCH] Add function "tasks_switch_to_user" --- arch/Makefile | 1 + arch/tasks.asm | 20 ++++++++++++++++++++ arch/tasks.h | 6 ++++++ 3 files changed, 27 insertions(+) create mode 100644 arch/tasks.asm create mode 100644 arch/tasks.h diff --git a/arch/Makefile b/arch/Makefile index bedcf42..a4af85e 100644 --- a/arch/Makefile +++ b/arch/Makefile @@ -19,6 +19,7 @@ OBJS += kprintf.c.o OBJS += protected.c.o protected.asm.cpp.o OBJS += tss.c.o tss.asm.cpp.o +OBJS += tasks.asm.cpp.o OBJS += interrupt.asm.cpp.o diff --git a/arch/tasks.asm b/arch/tasks.asm new file mode 100644 index 0000000..a6aa4f1 --- /dev/null +++ b/arch/tasks.asm @@ -0,0 +1,20 @@ +#include "config.h" + +[GLOBAL tasks_switch_to_user] + +tasks_switch_to_user: + mov ebx, [esp+4] + + mov ax, GDT_USER_DS_SELECTOR + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + + mov eax, esp + push GDT_USER_DS_SELECTOR + push eax + pushf + push GDT_USER_CS_SELECTOR + push ebx + iret diff --git a/arch/tasks.h b/arch/tasks.h new file mode 100644 index 0000000..3834adb --- /dev/null +++ b/arch/tasks.h @@ -0,0 +1,6 @@ +#ifndef KERNELMQ_INCLUDED_TASKS +#define KERNELMQ_INCLUDED_TASKS 1 + +void tasks_switch_to_user(unsigned long addr); + +#endif