summaryrefslogtreecommitdiff
path: root/arch/i386/boot/boot.s
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2022-01-15 16:20:52 -0600
committerDanny Holman <dholman@gymli.org>2022-01-15 16:22:58 -0600
commitacc73186bc3de78ceb0a54cbf2605dff1b9a6d62 (patch)
tree0b2b930e1e9ad4f96d6b91ff7400a14f7d0335c6 /arch/i386/boot/boot.s
parent5db084e3b478be1c9aa9caeeea94b949264aa853 (diff)
arch: i386: simplifiy GDT setup
Simplify the setup and definitions of GDT/TSS entries. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386/boot/boot.s')
-rw-r--r--arch/i386/boot/boot.s38
1 files changed, 33 insertions, 5 deletions
diff --git a/arch/i386/boot/boot.s b/arch/i386/boot/boot.s
index c62abbf..4b32ca2 100644
--- a/arch/i386/boot/boot.s
+++ b/arch/i386/boot/boot.s
@@ -25,7 +25,6 @@ boot_page_table0:
.section .multiboot.text, "a"
.global _start
.type _start, @function
-
_start:
movl $(boot_page_table0 - 0xC0000000), %edi
movl $0, %esi
@@ -73,6 +72,7 @@ _start:
call pic_remap
call kernel_main
+ call jump_userspace
cli
1: hlt
@@ -80,11 +80,9 @@ _start:
.global flush_gdt
.type flush_gdt, @function
-
flush_gdt:
cli
- movl 4(%esp), %eax
- lgdt (%eax)
+ lgdt (gp)
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
@@ -92,4 +90,34 @@ flush_gdt:
movw %ax, %gs
movw %ax, %ss
jmp $0x08, $.flush
-.flush: ret
+.flush:
+ ret
+
+.global flush_tss
+.type flush_tss, @function
+flush_tss:
+ movw $0x28, %ax
+ ltr %ax
+ ret
+
+.global jump_userspace
+.type jump_userspace, @function
+jump_userspace:
+ cli
+ movw $0x23, %ax
+ movw %ax, %ds
+ movw %ax, %es
+ movw %ax, %fs
+ movw %ax, %gs
+
+ pushl $0x23
+ pushl %esp
+ pushf
+ orl $0x200, (%esp)
+ pushl $0x8
+ pushl $test_user_function
+ iret
+
+test_user_function:
+ movl $1, %eax
+ int $0x80