소스 검색

解决O3下,printk在ap处理器中打印的信息会出现滚动的bug

fslongjin 2 년 전
부모
커밋
aa7dc4daa5
3개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 1
      Makefile
  2. 1 1
      kernel/Makefile
  3. 4 4
      kernel/common/printk.c

+ 1 - 1
Makefile

@@ -7,7 +7,7 @@ export ARCH=__x86_64__
 export ROOT_PATH=$(shell pwd)
 
 export DEBUG=DEBUG
-export GLOBAL_CFLAGS := -mcmodel=large -fno-builtin -m64  -fno-stack-protector -D $(ARCH)
+export GLOBAL_CFLAGS := -mcmodel=large -fno-builtin -m64  -fno-stack-protector -D $(ARCH) -O1
 
 ifeq ($(DEBUG), DEBUG)
 GLOBAL_CFLAGS += -g 

+ 1 - 1
kernel/Makefile

@@ -10,7 +10,7 @@ LIB_FILES := $(foreach DIR,$(DIR_LIB),$(addprefix $(DIR)/,$(lib_patterns)))
 
 # 控制操作系统使用的中断控制器 _INTR_8259A_ _INTR_APIC_
 PIC := _INTR_APIC_
-CFLAGS = $(GLOBAL_CFLAGS) -D $(PIC) -I $(shell pwd)  -O3
+CFLAGS = $(GLOBAL_CFLAGS) -D $(PIC) -I $(shell pwd)
 
 export ASFLAGS := --64
 

+ 4 - 4
kernel/common/printk.c

@@ -10,8 +10,7 @@
 #include <driver/uart/uart.h>
 #include <driver/video/video.h>
 #include "math.h"
-#pragma GCC push_options
-#pragma GCC optimize("O0")
+
 struct printk_screen_info pos;
 extern ul VBE_FB_phys_addr; // 由bootloader传来的帧缓存区的物理地址
 static spinlock_t printk_lock;
@@ -46,6 +45,8 @@ static uint *get_pos_VBE_FB_addr();
  */
 static int cls();
 
+#pragma GCC push_options
+#pragma GCC optimize("O0")
 /**
  * @brief 滚动窗口(尚不支持向下滚动)
  *
@@ -54,7 +55,7 @@ static int cls();
  * @param animation 是否包含滑动动画
  */
 static int scroll(bool direction, int pixels, bool animation);
-
+#pragma GCC pop_options
 /**
  * @brief 将数字按照指定的要求转换成对应的字符串(2~36进制)
  *
@@ -960,4 +961,3 @@ int sprintk(char *buf, const char *fmt, ...)
     return count;
 }
 
-#pragma GCC pop_options