Przeglądaj źródła

refactor(irq0): remove is_scheduler_ready

greatbridf 2 lat temu
rodzic
commit
56756566e1
4 zmienionych plików z 7 dodań i 25 usunięć
  1. 0 3
      include/asm/sys.h
  2. 0 4
      src/asm/sys.s
  3. 0 2
      src/kernel/interrupt.cpp
  4. 7 16
      src/kernel/process.cpp

+ 0 - 3
include/asm/sys.h

@@ -14,9 +14,6 @@ pptr_t current_pd(void);
 
 // the limit should be set on the higher 16bit
 // e.g. (n * sizeof(segment_descriptor) - 1) << 16
-// the lower bit off the limit is either 0 or 1
-// indicating whether or not to enable interrupt
-// after loading gdt
 void asm_load_gdt(uint32_t limit, pptr_t addr);
 
 void asm_load_tr(uint16_t index);

+ 0 - 4
src/asm/sys.s

@@ -38,10 +38,6 @@ asm_load_gdt:
     lgdt (%eax)
     ljmp $0x08, $_asm_load_gdt_fin
 _asm_load_gdt_fin:
-	movw 4(%esp), %ax
-	cmpw $0, %ax
-	je _asm_load_gdt_fin_ret
-_asm_load_gdt_fin_ret:
     ret
 
 .global asm_load_tr

+ 0 - 2
src/kernel/interrupt.cpp

@@ -81,8 +81,6 @@ void init_pic(void)
     SET_UP_IRQ(13, 0x08);
     SET_UP_IRQ(14, 0x08);
     SET_UP_IRQ(15, 0x08);
-
-    asm_sti();
 }
 
 extern "C" void int6_handler(

+ 7 - 16
src/kernel/process.cpp

@@ -21,7 +21,6 @@
 #include <types/stdint.h>
 #include <types/types.h>
 
-static bool is_scheduler_ready;
 static types::list<thread*>* ready_thds;
 static void (*volatile kthreadd_new_thd_func)(void*);
 static void* volatile kthreadd_new_thd_data;
@@ -169,11 +168,10 @@ void kernel_threadd_main(void)
 
 void NORETURN _kernel_init(void)
 {
-    {
-        kernel::no_irq_guard grd;
+    procs->emplace(kernel_threadd_main, 1);
+
+    asm_sti();
 
-        procs->emplace(kernel_threadd_main, 1);
-    }
     hw::init_ata();
 
     // TODO: parse kernel parameters
@@ -193,9 +191,7 @@ void NORETURN _kernel_init(void)
 
     assert(types::elf::elf32_load(&d) == GB_OK);
 
-    is_scheduler_ready = true;
-
-    asm volatile (
+    asm volatile(
         "movw $0x23, %%ax\n"
         "movw %%ax, %%ds\n"
         "movw %%ax, %%es\n"
@@ -211,8 +207,7 @@ void NORETURN _kernel_init(void)
         "iret\n"
         :
         : "c"(d.sp), "d"(d.eip)
-        : "eax", "memory"
-    );
+        : "eax", "memory");
 
     for (;;)
         assert(false);
@@ -259,7 +254,7 @@ void NORETURN init_scheduler()
         "xorl %%ebp, %%ebp\n"
         "xorl %%edx, %%edx\n"
 
-        "pushl $0x200\n"
+        "pushl $0x0\n"
         "popfl\n"
 
         "ret\n"
@@ -268,8 +263,7 @@ void NORETURN init_scheduler()
         "ud2"
         :
         : "a"(current_thread->esp), "c"(_kernel_init)
-        : "memory"
-    );
+        : "memory");
 
     for (;;)
         assert(false);
@@ -300,9 +294,6 @@ types::list<thread*>::iterator_type query_next_thread(void)
 extern "C" void asm_ctx_switch(uint32_t** curr_esp, uint32_t* next_esp);
 void schedule()
 {
-    if (unlikely(!is_scheduler_ready))
-        return;
-
     auto iter_thd = query_next_thread();
     auto thd = *iter_thd;