From 622f017b6a636e7a29f672238de4336190795b68 Mon Sep 17 00:00:00 2001 From: pointer-to-bios Date: Mon, 26 Feb 2024 01:58:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=B8=80=E4=BA=9B=E4=B9=B1?= =?UTF-8?q?=E4=B8=83=E5=85=AB=E7=B3=9F=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/kernel/memm.h | 2 +- src/kernel/Makefile | 2 +- src/kernel/klog.rs | 2 +- src/kernel/tty/tty.rs | 13 +++++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/kernel/memm.h b/include/kernel/memm.h index e83bbaa..2ba8920 100644 --- a/include/kernel/memm.h +++ b/include/kernel/memm.h @@ -116,7 +116,7 @@ typedef void (*memm_free_t)(void *allocator, void *mem); typedef struct __allocator_t { #ifndef MEMM_ALLOCATOR_MAGIC -#define MEMM_ALLOCATOR_MAGIC 0x271fe441 +#define MEMM_ALLOCATOR_MAGIC ((u32)0x271fe441) #endif // 分配器有效性由此检验,不为`MEMM_ALLOCATOR_MAGIC_NUM`说明获得了一个错误的分配器地址。 // 此值在编译时通过各种方式确定,若 diff --git a/src/kernel/Makefile b/src/kernel/Makefile index e4ab8de..83c5271 100644 --- a/src/kernel/Makefile +++ b/src/kernel/Makefile @@ -7,7 +7,7 @@ CC = gcc CCFLAGS = -m64 -mcmodel=large -I ../../include \ -fno-stack-protector -fno-exceptions \ -fno-builtin -nostdinc -nostdlib \ - -DMEMM_ALLOCATOR_MAGIC=\"${ALLOCATOR_MAGIC}\" + -DMEMM_ALLOCATOR_MAGIC="(u32)(0x${ALLOCATOR_MAGIC})" ifdef release CCFLAGS := ${CCFLAGS} -O2 endif diff --git a/src/kernel/klog.rs b/src/kernel/klog.rs index 628c0ee..8c55f00 100644 --- a/src/kernel/klog.rs +++ b/src/kernel/klog.rs @@ -139,7 +139,7 @@ impl KernelLogger { return false; } } - return true; + true }; while !all_end(&indeces, &logs) { let mut min_ind = None; diff --git a/src/kernel/tty/tty.rs b/src/kernel/tty/tty.rs index aa3027a..f817e51 100644 --- a/src/kernel/tty/tty.rs +++ b/src/kernel/tty/tty.rs @@ -206,6 +206,19 @@ impl ToString for Message { /// .build(); /// ``` /// +/// 定义了`message!`宏,简化构造消息的代码: +/// +/// ```rust +/// use crate::kernel::tty::tty::BuilderFunctions::*; +/// +/// message!( +/// Msg("Hello, "), +/// Msg("Metaverse"), +/// FgColor(Color::GREEN), +/// Msg("!\n"), +/// ); +/// ``` +/// /// 对于特殊情况可以使用非链式调用: /// ```rust /// let mut msg = MessageBuilder::new();