From 7c958c9ef0cd25eb15abb21d0d3420aac1c67c88 Mon Sep 17 00:00:00 2001 From: Val213 <112376067+val213@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E6=A4=8Ddns=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=B7=A5=E5=85=B7dog=E7=9A=84--tcp=E5=8A=9F=E8=83=BD=20(#652)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add dog, modify user/Makefile and user.sysconfig * add dog, modify user/Makefile and user.sysconfig * fix tty unicode * 修正无法正确编译dog的问题 --------- Co-authored-by: val213 Co-authored-by: GnoCiYeH Co-authored-by: longjin --- env.mk | 43 ------------------ kernel/Makefile | 4 +- kernel/env.mk | 44 +++++++++++++++++++ .../tty/virtual_terminal/virtual_console.rs | 2 +- user/Makefile | 3 +- user/dadk/config/dog_0_1_0.dadk | 28 ++++++++++++ user/sysconfig/etc/reach/system/shell.service | 8 ++++ user/sysconfig/etc/resolv.conf | 2 + 8 files changed, 86 insertions(+), 48 deletions(-) create mode 100644 kernel/env.mk create mode 100644 user/dadk/config/dog_0_1_0.dadk create mode 100644 user/sysconfig/etc/reach/system/shell.service create mode 100644 user/sysconfig/etc/resolv.conf diff --git a/env.mk b/env.mk index 9d68ec88..8ca75bc3 100644 --- a/env.mk +++ b/env.mk @@ -8,46 +8,3 @@ endif ifeq ($(EMULATOR), ) export EMULATOR=__NO_EMULATION__ endif - -# 设置编译器 -ifeq ($(ARCH), x86_64) - -# 如果 x86_64时,DragonOS_GCC 为空,那么设置为默认值 -export DragonOS_GCC?=$(HOME)/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin - -export CC=$(DragonOS_GCC)/x86_64-elf-gcc -export LD=ld -export AS=$(DragonOS_GCC)/x86_64-elf-as -export NM=$(DragonOS_GCC)/x86_64-elf-nm -export AR=$(DragonOS_GCC)/x86_64-elf-ar -export OBJCOPY=$(DragonOS_GCC)/x86_64-elf-objcopy - -else ifeq ($(ARCH), riscv64) - -export CC=riscv64-unknown-elf-gcc -# binutils版本需要>=2.38 -# 而ubuntu的unknown-elf的版本比较旧,所以使用了riscv64-linux-gnu-ld -export LD=riscv64-linux-gnu-ld -export AS=riscv64-unknown-elf-as -export NM=riscv64-unknown-elf-nm -export AR=riscv64-unknown-elf-ar -export OBJCOPY=riscv64-unknown-elf-objcopy - -endif - - -export DEBUG=DEBUG - -export CFLAGS_DEFINE_ARCH="__$(ARCH)__" - -export GLOBAL_CFLAGS := -fno-builtin -fno-stack-protector -D $(CFLAGS_DEFINE_ARCH) -D $(EMULATOR) -O1 - -ifeq ($(ARCH), x86_64) -GLOBAL_CFLAGS += -mcmodel=large -m64 -else ifeq ($(ARCH), riscv64) -GLOBAL_CFLAGS += -mcmodel=medany -march=rv64imac -mabi=lp64 -endif - -ifeq ($(DEBUG), DEBUG) -GLOBAL_CFLAGS += -g -endif diff --git a/kernel/Makefile b/kernel/Makefile index 0cc9fa6b..ee56ef56 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,7 +1,7 @@ # 导入环境变量 -include ../env.mk +include ./env.mk -export ARCH ?= x86_64 +# export ARCH ?= x86_64 # 如果是x86_64, 则使用x86_64-unknown-none.json作为target ifeq ($(ARCH), x86_64) export TARGET_JSON=arch/x86_64/x86_64-unknown-none.json diff --git a/kernel/env.mk b/kernel/env.mk new file mode 100644 index 00000000..2b2d9eaf --- /dev/null +++ b/kernel/env.mk @@ -0,0 +1,44 @@ +include ../env.mk + +# 设置编译器 +ifeq ($(ARCH), x86_64) + +# 如果 x86_64时,DragonOS_GCC 为空,那么设置为默认值 +export DragonOS_GCC?=$(HOME)/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin + +export CC=$(DragonOS_GCC)/x86_64-elf-gcc +export LD=ld +export AS=$(DragonOS_GCC)/x86_64-elf-as +export NM=$(DragonOS_GCC)/x86_64-elf-nm +export AR=$(DragonOS_GCC)/x86_64-elf-ar +export OBJCOPY=$(DragonOS_GCC)/x86_64-elf-objcopy + +else ifeq ($(ARCH), riscv64) + +export CC=riscv64-unknown-elf-gcc +# binutils版本需要>=2.38 +# 而ubuntu的unknown-elf的版本比较旧,所以使用了riscv64-linux-gnu-ld +export LD=riscv64-linux-gnu-ld +export AS=riscv64-unknown-elf-as +export NM=riscv64-unknown-elf-nm +export AR=riscv64-unknown-elf-ar +export OBJCOPY=riscv64-unknown-elf-objcopy + +endif + + +export DEBUG=DEBUG + +export CFLAGS_DEFINE_ARCH="__$(ARCH)__" + +export GLOBAL_CFLAGS := -fno-builtin -fno-stack-protector -D $(CFLAGS_DEFINE_ARCH) -D $(EMULATOR) -O1 + +ifeq ($(ARCH), x86_64) +GLOBAL_CFLAGS += -mcmodel=large -m64 +else ifeq ($(ARCH), riscv64) +GLOBAL_CFLAGS += -mcmodel=medany -march=rv64imac -mabi=lp64 +endif + +ifeq ($(DEBUG), DEBUG) +GLOBAL_CFLAGS += -g +endif diff --git a/kernel/src/driver/tty/virtual_terminal/virtual_console.rs b/kernel/src/driver/tty/virtual_terminal/virtual_console.rs index e0019d93..1c85506a 100644 --- a/kernel/src/driver/tty/virtual_terminal/virtual_console.rs +++ b/kernel/src/driver/tty/virtual_terminal/virtual_console.rs @@ -347,7 +347,7 @@ impl VirtualConsoleData { /// !!! 注意,该函数返回true时,元组的第一个数据是无效数据(未转换完成) fn translate_unicode(&mut self, c: u32) -> (Option, bool) { // 收到的字符不是首个 - if (c & 0xc8) == 0x80 { + if (c & 0xc0) == 0x80 { // 已经不需要继续的字符了,说明这个字符是非法的 if self.utf_count == 0 { return (Some(0xfffd), false); diff --git a/user/Makefile b/user/Makefile index 76b92bb4..5d3c8518 100644 --- a/user/Makefile +++ b/user/Makefile @@ -60,8 +60,7 @@ all: @echo 用户态程序编译完成 copy_services: dadk_run - @mkdir -p $(ROOT_PATH)/bin/sysroot/etc/reach/system - cp -r services/* $(ROOT_PATH)/bin/sysroot/etc/reach/system/ + cp -r sysconfig/* $(ROOT_PATH)/bin/sysroot/ .PHONY: clean diff --git a/user/dadk/config/dog_0_1_0.dadk b/user/dadk/config/dog_0_1_0.dadk new file mode 100644 index 00000000..09d4a7d8 --- /dev/null +++ b/user/dadk/config/dog_0_1_0.dadk @@ -0,0 +1,28 @@ +{ + "name": "dog", + "version": "0.1.0", + "description": "dns client", + "rust_target": null, + "task_type": { + "BuildFromSource": { + "Git": { + "url": "https://git.mirrors.dragonos.org.cn/DragonOS-Community/dog.git", + "branch": null, + "revision": "4ad6075686" + } + } + }, + "depends": [], + "build": { + "build_command": "make install" + }, + "install": { + "in_dragonos_path": "/" + }, + "clean": { + "clean_command": "make clean" + }, + "envs": [], + "build_once": false, + "install_once": false +} \ No newline at end of file diff --git a/user/sysconfig/etc/reach/system/shell.service b/user/sysconfig/etc/reach/system/shell.service new file mode 100644 index 00000000..75bd9a40 --- /dev/null +++ b/user/sysconfig/etc/reach/system/shell.service @@ -0,0 +1,8 @@ +[Unit] +Description=Shell + +[Service] +Type=simple +ExecStart=/bin/NovaShell +Restart=always +ExecStartPre=-/bin/about.elf diff --git a/user/sysconfig/etc/resolv.conf b/user/sysconfig/etc/resolv.conf new file mode 100644 index 00000000..65c3e2a1 --- /dev/null +++ b/user/sysconfig/etc/resolv.conf @@ -0,0 +1,2 @@ +nameserver 8.8.8.8 +nameserver 8.8.8.4 \ No newline at end of file