This commit is contained in:
fslongjin 2022-04-15 14:15:32 +08:00
parent c2d8e88617
commit be8ac71aa9
8 changed files with 15 additions and 11 deletions

View File

@ -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_

View File

@ -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;

View File

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

View File

@ -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, PICposition independent code
//lgdt $GDT_POINTER

View File

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

View File

@ -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;

View File

@ -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;
}

View File

@ -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)
{