fix: passing intr_ctx to soft_iret corrupts the stack of next proccess when performin...
[lunaix-os.git] / lunaix-os / kernel / asm / x86 / prologue.S
index 0716b4898b76078ba2888be16882ced6d443d117..6cdab40490e2c0e08a524412ca6021d1f6f4d812 100644 (file)
@@ -1,5 +1,8 @@
 /* 高半核入口点 - 0xC0000000 */
 
+#define __ASM__
+#include <lunaix/common.h>
+
 .section .text
     .global hhk_entry_
     hhk_entry_:
@@ -24,7 +27,7 @@
         lgdt (%esp)
 
         /* 更新段寄存器 */
-        movw $0x10, %cx
+        movw $KDATA_SEG, %cx
         movw %cx, %es
         movw %cx, %ds
         movw %cx, %fs
         movw %cx, %ss
 
         /* 更新 CS:EIP */
-        pushw $0x08
+        pushw $KCODE_SEG
         pushl $_after_gdt
         retf
 
     _after_gdt:
 
-        movl $mb_info, (%esp)
-        call _kernel_init
+        movl $mb_info, _k_init_mb_info
 
-        /* 
-            加载新的栈指针,位于0xffbfffff,但因为16字节对齐的需求,低四位清零。
-            为什么不是0xffffffff? 因为0xffc00000 - 0xffffffff 这4MiB的空间用于
-            对页表与页目录的循环映射。
-        */
-        mov $0xffbffff0, %esp
-
-        call _kernel_post_init
+        call _kernel_pre_init
 
         subl $6, %esp
 
         movw %ax, (%esp)
         lidt (%esp)
 
+        /* 加载TSS段选择器 */
+        movw $TSS_SEG, %ax
+        ltr %ax
+
         addl $6, %esp
 
-        /* 进入内核 */  
-        call _kernel_main
+        call _kernel_init
 
-        cli
-    j_:
+    1:
         hlt
-        jmp j_
\ No newline at end of file
+        jmp 1b
\ No newline at end of file