Skip to content

Commit

Permalink
Merge pull request #42 from ToolmanP/main
Browse files Browse the repository at this point in the history
lab5: migrate to new architecture
  • Loading branch information
ToolmanP authored Oct 14, 2024
2 parents 7f68974 + e432a4f commit 9e81a8a
Show file tree
Hide file tree
Showing 408 changed files with 11,434 additions and 6,167 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Lab5/user/chcore-libc/musl-libc"]
path = Lab5/user/chcore-libc/musl-libc
url = git://git.musl-libc.org/musl
[submodule "Lab6/user/chcore-libc/musl-libc"]
path = Lab6/user/chcore-libc/musl-libc
url = git://git.musl-libc.org/musl
Expand Down
2 changes: 2 additions & 0 deletions Lab5/.clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
CompilationDatabase: ./
29 changes: 29 additions & 0 deletions Lab5/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "QEMU (cppdbg)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/kernel.img",
"args": [],
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"stopAtEntry": true,
"stopAtConnect": true,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
],
"MIMode": "gdb",
"targetArchitecture": "arm64",
"miDebuggerServerAddress": "localhost:1234",
"miDebuggerPath": "/usr/local/bin/gdb",
"preLaunchTask": "Setup QEMU"
}
]
}
6 changes: 6 additions & 0 deletions Lab5/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"clangd.arguments": [
"--compile-commands-dir=./"
],
"debug.allowBreakpointsEverywhere": true
}
21 changes: 21 additions & 0 deletions Lab5/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Setup QEMU",
"type": "shell",
"isBackground": true,
"command": "make qemu-gdb",
"problemMatcher": {
"pattern": {
"regexp": "^\\[QEMU\\] Waiting for GDB Connection"
},
"background": {
"activeOnStart": true,
"beginsPattern": "^\\[QEMU\\] Waiting for GDB Connection",
"endsPattern": "^\\[QEMU\\] Waiting for GDB Connection",
}
}
}
]
}
31 changes: 17 additions & 14 deletions Lab5/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 Expand Up @@ -63,6 +63,7 @@ chcore_add_subproject(
INSTALL_DIR ${_libc_install_dir}
CMAKE_ARGS
${_common_args}
${_cache_args}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
CMAKE_CACHE_ARGS ${_cache_args}
INSTALL_COMMAND echo "Performed in CMake"
Expand Down Expand Up @@ -166,15 +167,15 @@ chcore_add_subproject(
INSTALL_DIR ${_system_services_install_dir}
CMAKE_ARGS
${_common_args}
${_cache_args}
-DCHCORE_MUSL_LIBC_INSTALL_DIR=${_libc_install_dir} # used by user.cmake toolchain to find `musl-gcc`
-DCHCORE_RAMDISK_DIR=${build_ramdisk_dir}
# -DCHCORE_CI_CONFIG_DIR=${_ci_config_dir}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_TOOLCHAIN_FILE=${_cmake_script_dir}/Toolchains/user.cmake
CMAKE_CACHE_ARGS ${_cache_args}
INSTALL_COMMAND echo "Nothing to install"
DEPENDS tests system-services-clean-incbin
DEPENDS libc system-services-clean-incbin
DEPENDS libc system-services-clean-incbin tests
BUILD_ALWAYS TRUE)

# --- Kernel ---
Expand All @@ -199,13 +200,15 @@ chcore_add_subproject(
INSTALL_DIR ${_kernel_install_dir}
CMAKE_ARGS
${_common_args}
${_cache_args}
-DCHCORE_USER_INSTALL_DIR=${_system_services_install_dir} # used by kernel/CMakeLists.txt to incbin cpio files
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_TOOLCHAIN_FILE=${_cmake_script_dir}/Toolchains/kernel.cmake
CMAKE_CACHE_ARGS ${_cache_args}
DEPENDS system-services kernel-clean-incbin
BUILD_ALWAYS TRUE)


# Generate toolchain file
configure_file(${_cmake_script_dir}/Toolchains/toolchain_tpl.cmake
toolchain.cmake
Expand Down Expand Up @@ -234,17 +237,17 @@ add_dependencies(clean-all libc-clean-trigger system-services-clean-trigger)

# --- Update Submodules (always run in local env) ---

add_custom_target(update-submodules)

macro(_update_submodule _target _subproject_path _module_rel_path)
add_custom_target(
${_target}
WORKING_DIRECTORY ${_subproject_path}
COMMAND echo "Updating ${_subproject_path}/${_module_rel_path}..."
COMMAND git submodule update --init
--recursive --depth=1 ${_module_rel_path})
add_dependencies(update-submodules ${_target})
endmacro()
# add_custom_target(update-submodules)
#
# macro(_update_submodule _target _subproject_path _module_rel_path)
# add_custom_target(
# ${_target}
# WORKING_DIRECTORY ${_subproject_path}
# COMMAND echo "Updating ${_subproject_path}/${_module_rel_path}..."
# COMMAND git submodule update --init
# --recursive --depth=1 ${_module_rel_path})
# add_dependencies(update-submodules ${_target})
# endmacro()

# _update_submodule(update-musl-libc ${_system_services_source_dir} chcore-libc/musl-libc)

Expand Down
127 changes: 0 additions & 127 deletions Lab5/LICENSE

This file was deleted.

48 changes: 2 additions & 46 deletions Lab5/Makefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,4 @@
LAB := 5
TIMEOUT := 120

V := @
PROJECT_DIR := .
BUILD_DIR := $(PROJECT_DIR)/build
KERNEL_IMG := $(BUILD_DIR)/kernel.img
QEMU := qemu-system-aarch64
_QEMU := $(PROJECT_DIR)/scripts/qemu/qemu_wrapper.sh $(QEMU)
QEMU_GDB_PORT := 1234
QEMU_OPTS := -machine raspi3b -nographic -serial mon:stdio -m size=1G -kernel $(KERNEL_IMG)
GDB := gdb-multiarch
CHBUILD := $(PROJECT_DIR)/chbuild

.PHONY: all
all: build

.PHONY: defconfig build clean distclean

defconfig:
$(V)$(CHBUILD) defconfig

build:
$(V)test -f $(PROJECT_DIR)/.config || $(CHBUILD) defconfig
$(V)$(CHBUILD) build

clean:
$(V)$(CHBUILD) clean

distclean:
$(V)$(CHBUILD) distclean

.PHONY: qemu qemu-gdb gdb

qemu:
$(V)$(_QEMU) $(QEMU_OPTS)

qemu-gdb:
$(V)$(_QEMU) -S -gdb tcp::$(QEMU_GDB_PORT) $(QEMU_OPTS)

gdb:
$(V)$(GDB) -x $(PROJECT_DIR)/.gdbinit

.PHONY: grade

grade:
$(V)test -f $(PROJECT_DIR)/.config && cp $(PROJECT_DIR)/.config $(PROJECT_DIR)/.config.bak || true
$(V)$(PROJECT_DIR)/scripts/grade/lab$(LAB).sh
$(V)test -f $(PROJECT_DIR)/.config.bak && mv $(PROJECT_DIR)/.config.bak $(PROJECT_DIR)/.config || true
include $(CURDIR)/../Scripts/lab.mk
Loading

0 comments on commit 9e81a8a

Please sign in to comment.