Skip to content

Commit

Permalink
Merge pull request #24 from ToolmanP/main
Browse files Browse the repository at this point in the history
refactor: move build scripts to top level
  • Loading branch information
ToolmanP authored Sep 7, 2024
2 parents 4c90ac9 + d441602 commit 3068ac1
Show file tree
Hide file tree
Showing 37 changed files with 26 additions and 67 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ RUN curl -SLO https://download.qemu.org/qemu-9.1.0.tar.xz && \
RUN apt-get install -y libglib2.0-dev
RUN apt-get clean

# install repo
RUN curl -SL https://storage.googleapis.com/git-repo-downloads/repo -o /usr/local/bin/repo && \
chmod +x /usr/local/bin/repo
RUN useradd -m -u $USER_UID -U -s /bin/bash stu
RUN usermod -aG sudo stu
RUN passwd -d stu
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"ms-vscode.hexeditor",
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.makefile-tools",
"twxs.cmake",
"dan-c-underwood.arm"
]
}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cscope.*
!/**/firmware/*.bin
!/**/firmware/*.elf

build
Lab*/build
simulate.sh
debug.sh
.config
Expand Down
2 changes: 1 addition & 1 deletion Lab1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cmake_minimum_required(VERSION 3.14)
project(ChCore)

set(_cmake_script_dir ${CMAKE_CURRENT_SOURCE_DIR}/scripts/build/cmake)
set(_cmake_script_dir ${CMAKE_CURRENT_SOURCE_DIR}/../Scripts/build/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_cmake_script_dir}/Modules)
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}/user)

Expand Down
9 changes: 0 additions & 9 deletions Lab1/kernel/arch/aarch64/boot/raspi3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,3 @@ set(init_objects

chcore_objcopy_binary(${kernel_target} kernel8.img)

# Note: `$basedir` is a shell variable in `emulate.tpl.sh`
set(_qemu_opts
"-machine raspi3b -nographic -serial mon:stdio -m size=1G -kernel \$basedir/kernel.img"
)
if(CHCORE_QEMU_SDCARD_IMG)
set(_qemu_opts
"${_qemu_opts} -drive if=sd,format=raw,file=${CHCORE_QEMU_SDCARD_IMG}")
endif()
chcore_generate_emulate_sh("qemu-system-aarch64" ${_qemu_opts})
28 changes: 0 additions & 28 deletions Lab1/scripts/qemu/emulate.tpl.sh

This file was deleted.

6 changes: 4 additions & 2 deletions Pages/Appendix/kernel-debugging.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# 调试指北

<!-- toc -->

> [!IMPORTANT]
> 调试占据着你的大部分做lab的时间,本节主要讲解实验当中你可能需要使用到的调试手段,以及对应的工具使用方法.
---

<!-- toc -->

## VSCode

在Lab0中我们学习并熟悉了GDB的使用方法,但是从Lab开始,Lab中的可调试文件就陡然增加了,使用GDB最麻烦的地方就是定位源文件进行单步调试,
Expand Down
2 changes: 1 addition & 1 deletion Pages/Getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ zypper install qemu qemu-linux-user python3 python3-psutil make gdb
## CI评分

在新实验中,我们特意准备了支持github actions以及gitlab ci的CI配置,你可以在你所使用的代码托管平台上自动运行脚本,为了确保你不会篡改预编译的`.obj`文件,我们会根据本仓库的主线的各个Lab中的`filelists.mk`(详细见贡献指南)的定义自动提取提交中所需要的文件与仓库主线的文件树进行合并,最终进行评分。
在新实验中,我们特意准备了支持github actions以及gitlab ci的CI配置,你可以在你所使用的代码托管平台上自动运行脚本,为了确保你不会篡改预编译的`.obj`文件,我们会根据本仓库的主线的各个Lab中的`filelist.mk`(详细见贡献指南)的定义自动提取提交中所需要的文件与当前仓库主线的文件树进行合并,最终进行评分。
11 changes: 8 additions & 3 deletions Pages/Lab1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

## 简介

本实验作为 ChCore 操作系统课程实验的第一个实验,分为两个部分:第一部分介绍实验所需的基础知识,第二部分熟悉并完成ChCore 内核的启动过程。
实验面向的硬件平台是树莓派3b+(AArch64)。你可以在QEMU模拟器上完成实验,也可以在树莓派开发板上完成。
本实验作为 ChCore 操作系统课程实验的第一个实验,分为三个部分,

1. [RTFSC](../Lab1/RTFSC.html): 代码导读,由于是Lab1,我们主要注重于Chcore的构建系统。
2. [机器启动](../Lab1/boot.html):介绍aarch64结构启动时的关键寄存器以及关键的启动函数。
3. [页表配置](../Lab1/pte.html):介绍aarch64页表结构,以及针对树莓派3平台的内存布局编写页表配置。

本实验你可以在QEMU模拟器上完成实验,也可以在树莓派开发板上完成。
本实验代码包含了基础的ChCore 微内核操作系统,除了练习题相关的源码以外,其余部分通过预先编译的二进制格式提供。

本实验代码包含了基础的ChCore 微内核操作系统,除了练习题相关的源码以外,其余部分通过二进制格式提供。
完成本实验的练习题之后,你可以进入 ChCore shell,运行命令或执行程序。
例如,可以在 shell 中输入 `hello_world.bin` 运行一个简单的用户态程序;
输入`ls` 查看目录内容。
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,3 @@ function(chcore_objcopy_binary _kernel_target _binary_name)
DESTINATION ${CMAKE_INSTALL_PREFIX})
endfunction()

# Add target to generate qemu emulation script.
function(chcore_generate_emulate_sh _qemu _qemu_options)
set(qemu ${_qemu})
set(qemu_options ${_qemu_options})
configure_file(${CHCORE_PROJECT_DIR}/scripts/qemu/emulate.tpl.sh emulate.sh
@ONLY)
unset(qemu)
unset(qemu_options)

install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/emulate.sh
DESTINATION ${CMAKE_INSTALL_PREFIX})
install(
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/emulate.sh
DESTINATION ${CMAKE_INSTALL_PREFIX}
RENAME simulate.sh)
endfunction()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions Scripts/chbuild
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ clean_command="$self clean"
cmake_build_dir="build"
cmake_cache_file="build/CMakeCache.txt"

cmake_script_dir="scripts/build/cmake"
cmake_script_dir="$SCRIPTS/build/cmake"
cmake_init_cache_default="$cmake_script_dir/LoadConfigDefault.cmake"
cmake_init_cache_ask="$cmake_script_dir/LoadConfigAsk.cmake"
cmake_init_cache_abort="$cmake_script_dir/LoadConfigAbort.cmake"
cmake_init_cache_dump="$cmake_script_dir/DumpConfig.cmake"

config_file=".config"
defconfig_dir="scripts/build/defconfigs"
defconfig_dir="$SCRIPTS/build/defconfigs"

repo_tool_dir=".repo"
manifest_upstream="[email protected]:staros/staros-manifests.git"
Expand Down Expand Up @@ -275,10 +275,11 @@ _docker_run() {
echo "chbuild: use_cgroup: $use_cgroup, tags: $CI_RUNNER_TAGS"
test -t 1 && use_tty="-t"
docker run -i $use_tty --rm \
-e SCRIPTS=$SCRIPTS \
-u $(id -u ${USER}):$(id -g ${USER}) \
-v ${LABROOT}:${LABROOT} -w $(pwd) \
--security-opt=seccomp:unconfined \
ipads/chcore_builder:v1.8.3 \
ipads/chcore_builder:v1.9.0 \
$self $@
fi
}
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions Scripts/kernel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ endif

BUILDDIR := $(LABDIR)/build
KERNEL_IMG := $(BUILDDIR)/kernel.img
_QEMU := $(LABDIR)/scripts/qemu/qemu_wrapper.sh $(QEMU)
_QEMU := $(SCRIPTS)/qemu_wrapper.sh $(QEMU)
QEMU_GDB_PORT := 1234
QEMU_OPTS := -machine raspi3b -nographic -serial mon:stdio -m size=1G -kernel $(KERNEL_IMG)
CHBUILD := $(SCRIPTS)/chbuild

export LABROOT LABDIR LAB TIMEOUT
export LABROOT LABDIR SCRIPTS LAB TIMEOUT

all: build

Expand All @@ -37,7 +37,7 @@ qemu-gdb: build
$(Q)$(_QEMU) -S -gdb tcp::$(QEMU_GDB_PORT) $(QEMU_OPTS)

gdb:
$(Q)$(GDB) --nx -x $(LABDIR)/.gdbinit
$(Q)$(GDB) --nx -x $(SCRIPTS)/gdb/gdbinit

grade:
$(MAKE) distclean
Expand Down
File renamed without changes.

0 comments on commit 3068ac1

Please sign in to comment.