fslongjin 2 years ago
parent
commit
be8ac71aa9
8 changed files with 15 additions and 11 deletions
  1. 1 1
      kernel/Makefile
  2. 1 0
      kernel/common/printk.c
  3. 0 2
      kernel/exception/entry.S
  4. 2 1
      kernel/head.S
  5. 6 1
      kernel/link.lds
  6. 3 4
      kernel/main.c
  7. 1 1
      kernel/sched/sched.c
  8. 1 1
      kernel/smp/smp.c

+ 1 - 1
kernel/Makefile

@@ -7,7 +7,7 @@ DIR_LIB=lib
 lib_patterns := *.a
 LIB_FILES := $(foreach DIR,$(DIR_LIB),$(addprefix $(DIR)/,$(lib_patterns)))
 
-CFLAGS := -mcmodel=large -fno-builtin -m64 -g -O0 -I .
+CFLAGS := -mcmodel=large -fno-builtin -m64 -g -O0 -I . -fno-stack-protector
 ARCH=x86_64
 # 控制操作系统使用的中断控制器 _INTR_8259A_ _INTR_APIC_
 PIC := _INTR_APIC_

+ 1 - 0
kernel/common/printk.c

@@ -27,6 +27,7 @@ int printk_init(const int char_size_x, const int char_size_y)
 {
     struct multiboot_tag_framebuffer_info_t info;
     int reserved;
+    
     multiboot2_iter(multiboot2_get_Framebuffer_info, &info, &reserved);
 
     pos.width = info.framebuffer_width;

+ 0 - 2
kernel/exception/entry.S

@@ -350,5 +350,3 @@ ENTRY(syscall_int)
     jmp Err_Code
 */
 
-ENTRY(_stack_start)
-    .quad initial_proc_union + 32768

+ 2 - 1
kernel/head.S

@@ -202,6 +202,7 @@ multiboot_header_end:
 ENTRY(_start)
     // 关中断
     cli
+    
     // multiboot2_info 结构体指针
     mov %ebx, mb2_info
     //mov %ebx, %e8
@@ -308,7 +309,7 @@ ENTRY(_start64)
     mov %ax, %fs
     mov %ax, %ss
     mov $0x7e00, %esp
-
+    
 // === 加载GDTR ====
     lgdt GDT_POINTER(%rip) //这里我没搞明白rip相对寻址, 看了文档,大概是用来实现PIC的(position independent code)
     //lgdt $GDT_POINTER

+ 6 - 1
kernel/link.lds

@@ -34,7 +34,7 @@ SECTIONS
 	{
 		_data = .;
 		*(.data)
-		
+
 		_edata = .;
 	}
 	rodata_start_pa = .;
@@ -60,4 +60,9 @@ SECTIONS
 	}
 
 	_end = .;
+
+	/DISCARD/ : {
+		*(.eh_frame)
+		
+	}
 }

+ 3 - 4
kernel/main.c

@@ -82,12 +82,12 @@ void system_initialize()
 {
 
     // 初始化printk
-
     printk_init(8, 16);
     kinfo("Kernel Starting...");
     // 重新加载gdt和idt
     
     ul tss_item_addr = (ul)phys_2_virt(0x7c00);
+    
     _stack_start = head_stack_start;    // 保存init proc的栈基地址(由于之后取消了地址重映射,因此必须在这里重新保存)
     kdebug("_stack_start=%#018lx", _stack_start);
 
@@ -158,7 +158,7 @@ void system_initialize()
 //操作系统内核从这里开始执行
 void Start_Kernel(void)
 {
-
+    
     // 获取multiboot2的信息
     uint64_t mb2_info, mb2_magic;
     __asm__ __volatile__("movq %%r15, %0    \n\t"
@@ -174,8 +174,7 @@ void Start_Kernel(void)
 
     mb2_info &= 0xffffffff;
     mb2_magic &= 0xffffffff;
-
-    multiboot2_magic = mb2_magic;
+    multiboot2_magic = (uint)mb2_magic;
     multiboot2_boot_info_addr = mb2_info + PAGE_OFFSET;
 
     

+ 1 - 1
kernel/sched/sched.c

@@ -12,7 +12,7 @@ struct process_control_block *sched_cfs_dequeue()
 {
     if (list_empty(&sched_cfs_ready_queue[proc_current_cpu_id].proc_queue.list))
     {
-        kdebug("list empty");
+        kdebug("list empty, count=%d", sched_cfs_ready_queue[proc_current_cpu_id].count);
         return &initial_proc_union.pcb;
     }
 

+ 1 - 1
kernel/smp/smp.c

@@ -153,7 +153,7 @@ void smp_ap_start()
     current_pcb->preempt_count = 0;
     sti();
 
-    if (proc_current_cpu_id == 2)
+    if (proc_current_cpu_id == 1)
         process_init();
     while (1)
     {