diff --git a/Lab3/user/chcore-libc/CMakeLists.txt b/Lab3/user/chcore-libc/CMakeLists.txt index 5006139e..a1bd9f36 100644 --- a/Lab3/user/chcore-libc/CMakeLists.txt +++ b/Lab3/user/chcore-libc/CMakeLists.txt @@ -101,7 +101,7 @@ add_custom_target(libc-build ALL # Install libc as usual add_custom_target(libc-install ALL WORKING_DIRECTORY ${_libc_target_dir} - COMMAND make install + COMMAND make -j1 install DEPENDS libc-build) # clean target diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/Makefile b/Lab3/user/chcore-libc/libchcore/porting/overrides/Makefile index 9aba5347..76bfab90 100644 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/Makefile +++ b/Lab3/user/chcore-libc/libchcore/porting/overrides/Makefile @@ -151,11 +151,11 @@ CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $< ifeq ($(ADD_CFI),yes) AS_CMD = LC_ALL=C awk -f $(srcdir)/tools/add-cfi.common.awk -f $(srcdir)/tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL) -x assembler -c -o $@ - else - AS_CMD = $(CC_CMD) + AS_CMD = $(CC) $(CFLAGS_ALL) -x assembler-with-cpp -c -o $@ $< endif obj/%.o: $(srcdir)/%.s - $(AS_CMD) + ($(AS_CMD) 2> /dev/null) || $(CC_CMD) obj/%.o: $(srcdir)/%.S $(CC_CMD) @@ -164,7 +164,7 @@ obj/%.o: $(srcdir)/%.c $(GENH) $(IMPH) $(CC_CMD) obj/%.lo: $(srcdir)/%.s - $(AS_CMD) + ($(AS_CMD) 2> /dev/null) || $(CC_CMD) obj/%.lo: $(srcdir)/%.S $(CC_CMD) diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S deleted file mode 100644 index caefbfd0..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* This file references glibc/sysdeps/sparc/sparc32/__longjmp.S. */ - -/* - * TODO: FLUSH_WINDOWS_TRAP is not implemented. - * Currently setjmp and longjmp are not availeble. - */ - -#include - -/* void longjmp(jmpbuf, retval) */ -.global _longjmp -.global longjmp -.type _longjmp,@function -.type longjmp,@function -_longjmp: -longjmp: - ld [%o0 + 4], %g3 /* %g3 = fp stored in jmpbuf (target_fp). */ - mov %o0, %g1 /* jmpbuf in %g1. */ - orcc %o1, %g0, %g2 /* retval in %g2 (return value of setjmp). */ - be,a 0f - mov 1, %g2 /* Return value of setjmp can't be 0. */ -0: - xor %fp, %g3, %o0 - add %fp, 512, %o1 - andncc %o0, 0xfff, %o0 /* Is | fp - target_fp | < 4096 ? */ - bne .Lthread /* Too much gap between fp and target_fp. */ - cmp %o1, %g3 /* fp + 512 < target_fp. */ - bl .Lthread /* Too much gap between fp and target_fp. */ - -/* If fp < target_fp, we can restore windows to match them. */ -.Lloop: - cmp %fp, %g3 /* Have we reached the target frame? */ - bl,a .Lloop /* fp < target_fp, restore and continue. */ - restore - be,a .Lfound /* fp == target_fp, found target frame. */ - ld [%g1], %o0 /* Load sp stored in jmpbuf. */ - /* If fp > target_fp, go through and do trap. */ - -/* - * Unable (or too expensive) to match fp and target_fp by restoring windows. - * We will instead do a "flush register windows trap" to save all the - * register windows on their stack slots, and marks them all as invalid. - */ -.Lthread: - save %sp, -96, %sp - ta FLUSH_WINDOWS_TRAP - ld [%g1 + 8], %i7 /* Load returen address stored in jmpbuf. */ - ld [%g1], %fp /* Load sp stored in jmpbuf. */ - jmp %i7 + 8 - restore %g2, 0, %o0 /* Set return value. */ - -/* We match fp and target_fp successfully. */ -.Lfound: - mov %o0, %sp - ld [%g1 + 8], %o0 /* Load returen address stored in jmpbuf. */ - jmp %o0 + 8 - mov %g2, %o0 /* Set return value. */ diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S deleted file mode 100644 index f0f1d981..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -/* - * TODO: FLUSH_WINDOWS_TRAP is not implemented. - * Currently setjmp and longjmp are not availeble. - */ - -.global __setjmp -.global _setjmp -.global setjmp -.type __setjmp,@function -.type _setjmp,@function -.type setjmp,@function -__setjmp: -_setjmp: -setjmp: - ta FLUSH_WINDOWS_TRAP - st %sp, [%o0] - st %fp, [%o0 + 4] - st %o7, [%o0 + 8] - retl - mov 0, %o0 - diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt index 7cb95a82..16b6841f 100644 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt +++ b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt @@ -8,4 +8,4 @@ # PURPOSE. # See the Mulan PSL v2 for more details. -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file +target_sources(libchcore-porting-symbols PRIVATE __unmapself.s) diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.s similarity index 100% rename from Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.S rename to Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.s diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s similarity index 100% rename from Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.S rename to Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s.del b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s.del deleted file mode 100644 index e69de29b..00000000 diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt deleted file mode 100644 index 7cb95a82..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. - -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S deleted file mode 100644 index 52362ebe..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - li a7, CHCORE_SYS_thread_exit - ecall diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S deleted file mode 100644 index 3d925872..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __unmapself -.type __unmapself, %function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mv s2, a0 /* Save unmap addr. */ - mv s3, a1 /* Save unmap length. */ - jal chcore_lock_common_stack - mv sp, a0 /* Switch the stack. */ - - mv a0, s2 - mv a1, s3 - jal chcore_unmapself - - /* Release lock of common stack. */ - fence rw, rw - sw zero, 0(a0) - fence rw, rw - - li a7, CHCORE_SYS_thread_exit - ecall diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s deleted file mode 100644 index 348150c9..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - mov %o0, %g7 - retl - mov %g0, %o0 diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S deleted file mode 100644 index bc39015b..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - set CHCORE_SYS_thread_exit, %g1 - ta 0x10 diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S deleted file mode 100644 index 1f98c9dd..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -.global __unmapself -.type __unmapself,%function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mov %o0, %i0 /* Save unmap addr. */ - call chcore_lock_common_stack - mov %o1, %i1 /* Save unmap length (delay slot). */ - mov %o0, %sp /* Switch the stack. */ - - ta REVOKE_WINDOW_TRAP /* revoke windows */ - - mov %i0, %o0 - call chcore_unmapself - mov %i1, %o1 - - /* Release lock of common stack. */ - stbar - set 0, %o1 - st %o1, [%o0] - - set CHCORE_SYS_thread_exit, %g1 - ta 0x10 diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c deleted file mode 100644 index 0b943cce..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* For sparc architectures that do not provide cas instructions */ -volatile int cas_lock = 0; \ No newline at end of file diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S deleted file mode 100644 index 3599a69e..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __clone -.hidden __clone -.type __clone,%function -__clone: - /* Since we don't need this function in ChCore, just return -1 here. */ - set -1, %o0 - retl - nop - /* The following is the original implementation. */ - // save %sp, -96, %sp - // mov %i0, %g2 - // sub %i1, 96, %o1 - // mov %i2, %o0 - // mov %i3, %g3 - // mov %i4, %o2 - // mov %i5, %o3 - // ld [%fp + 92], %o4 - - // set 220, %g1 /* SYS_clone */ - // ta SYSCALL_TRAP - - // tst %o1 - // bne 1f - // nop - // jmpl %i7 + 8, %g0 - // restore %o0, %g0, %o0 -// 1: - // mov %g0, %fp /* terminate backtrace */ - // call %g2 - // mov %g3, %o0 - // set 93, %g1 /* SYS_exit */ - // ta SYSCALL_TRAP diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S deleted file mode 100644 index 044228f0..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,%function -__syscall_cp_asm: -__cp_begin: -__cp_end: -__cp_cancel: - /* Since we don't need this function in ChCore, just return -1 here. */ - set -1, %o0 - retl - nop - /* The following is the original implementation. */ - // ld [%o0], %g2 - // tst %g2 - // bne __cp_cancel - // nop - // mov %o1, %g1 - // mov %o2, %o0 - // mov %o3, %o1 - // mov %o4, %o2 - // mov %o5, %o3 - // ld [%sp + 92], %o4 - // ld [%sp + 96], %o5 - // ta SYSCALL_TRAP -// __cp_end: - // retl - // nop -// __cp_cancel: - // b __cancel diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt deleted file mode 100644 index e7bba9a0..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. - -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S __set_thread_area.s) \ No newline at end of file diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s deleted file mode 100644 index 1f5c2293..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ - -.extern chcore_x86_set_thread_area - -.text -.global __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - /* ChCore: current implementation is using wrfsbase */ - call chcore_x86_set_thread_area - ret - -#if 0 - mov %rdi,%rsi /* shift for syscall */ - movl $0x1002,%edi /* SET_FS register */ - movl $158,%eax /* set fs segment to */ - syscall /* arch_prctl(SET_FS, arg)*/ - ret -#endif diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S deleted file mode 100644 index ab1e168f..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - mov $CHCORE_SYS_thread_exit, %rax - syscall diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S deleted file mode 100644 index 2d9213ad..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ -#include - -.text -.global __unmapself -.type __unmapself,@function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mov %rdi, %r12 /* Save unmap addr. */ - mov %rsi, %r13 /* Save unmap length. */ - call chcore_lock_common_stack - mov %rax, %rsp /* Switch the stack. */ - - mov %r12, %rdi - mov %r13, %rsi - call chcore_unmapself - - /* Release lock of common stack. */ - endbr64 - movq $0, (%rax) - - mov $CHCORE_SYS_thread_exit, %rax - syscall - \ No newline at end of file diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c deleted file mode 100644 index d48074be..00000000 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -long chcore_x86_set_thread_area(long fs) -{ - /* - * TODO: wrfsbase may not be supported. - * If so, use system call for executing wrmsr instead. - */ - __asm__ __volatile__("wrfsbase %0"::"r"(fs)); - return 0; -} diff --git a/Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt b/Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt index 7cb95a82..16b6841f 100644 --- a/Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt +++ b/Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt @@ -8,4 +8,4 @@ # PURPOSE. # See the Mulan PSL v2 for more details. -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file +target_sources(libchcore-porting-symbols PRIVATE __unmapself.s) diff --git a/Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.S b/Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.s similarity index 100% rename from Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.S rename to Lab3/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.s diff --git a/Lab4/user/chcore-libc/CMakeLists.txt b/Lab4/user/chcore-libc/CMakeLists.txt index 5006139e..a1bd9f36 100644 --- a/Lab4/user/chcore-libc/CMakeLists.txt +++ b/Lab4/user/chcore-libc/CMakeLists.txt @@ -101,7 +101,7 @@ add_custom_target(libc-build ALL # Install libc as usual add_custom_target(libc-install ALL WORKING_DIRECTORY ${_libc_target_dir} - COMMAND make install + COMMAND make -j1 install DEPENDS libc-build) # clean target diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/Makefile b/Lab4/user/chcore-libc/libchcore/porting/overrides/Makefile index 9aba5347..76bfab90 100644 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/Makefile +++ b/Lab4/user/chcore-libc/libchcore/porting/overrides/Makefile @@ -151,11 +151,11 @@ CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $< ifeq ($(ADD_CFI),yes) AS_CMD = LC_ALL=C awk -f $(srcdir)/tools/add-cfi.common.awk -f $(srcdir)/tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL) -x assembler -c -o $@ - else - AS_CMD = $(CC_CMD) + AS_CMD = $(CC) $(CFLAGS_ALL) -x assembler-with-cpp -c -o $@ $< endif obj/%.o: $(srcdir)/%.s - $(AS_CMD) + ($(AS_CMD) 2> /dev/null) || $(CC_CMD) obj/%.o: $(srcdir)/%.S $(CC_CMD) @@ -164,7 +164,7 @@ obj/%.o: $(srcdir)/%.c $(GENH) $(IMPH) $(CC_CMD) obj/%.lo: $(srcdir)/%.s - $(AS_CMD) + ($(AS_CMD) 2> /dev/null) || $(CC_CMD) obj/%.lo: $(srcdir)/%.S $(CC_CMD) diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c index d19e1e71..c9a54430 100644 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c +++ b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c @@ -130,7 +130,9 @@ static int get_one_char(void) static void put(char buffer[], unsigned size) { - chcore_syscall2(CHCORE_SYS_putstr, (vaddr_t)buffer, size); + /* LAB 3 TODO BEGIN */ + + /* LAB 3 TODO END */ } #define MAX_LINE_SIZE 4095 @@ -342,4 +344,4 @@ struct fd_ops stderr_ops = { .poll = NULL, .ioctl = chcore_stdio_ioctl, .fcntl = chcore_stdio_fcntl, -}; \ No newline at end of file +}; diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S deleted file mode 100644 index caefbfd0..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* This file references glibc/sysdeps/sparc/sparc32/__longjmp.S. */ - -/* - * TODO: FLUSH_WINDOWS_TRAP is not implemented. - * Currently setjmp and longjmp are not availeble. - */ - -#include - -/* void longjmp(jmpbuf, retval) */ -.global _longjmp -.global longjmp -.type _longjmp,@function -.type longjmp,@function -_longjmp: -longjmp: - ld [%o0 + 4], %g3 /* %g3 = fp stored in jmpbuf (target_fp). */ - mov %o0, %g1 /* jmpbuf in %g1. */ - orcc %o1, %g0, %g2 /* retval in %g2 (return value of setjmp). */ - be,a 0f - mov 1, %g2 /* Return value of setjmp can't be 0. */ -0: - xor %fp, %g3, %o0 - add %fp, 512, %o1 - andncc %o0, 0xfff, %o0 /* Is | fp - target_fp | < 4096 ? */ - bne .Lthread /* Too much gap between fp and target_fp. */ - cmp %o1, %g3 /* fp + 512 < target_fp. */ - bl .Lthread /* Too much gap between fp and target_fp. */ - -/* If fp < target_fp, we can restore windows to match them. */ -.Lloop: - cmp %fp, %g3 /* Have we reached the target frame? */ - bl,a .Lloop /* fp < target_fp, restore and continue. */ - restore - be,a .Lfound /* fp == target_fp, found target frame. */ - ld [%g1], %o0 /* Load sp stored in jmpbuf. */ - /* If fp > target_fp, go through and do trap. */ - -/* - * Unable (or too expensive) to match fp and target_fp by restoring windows. - * We will instead do a "flush register windows trap" to save all the - * register windows on their stack slots, and marks them all as invalid. - */ -.Lthread: - save %sp, -96, %sp - ta FLUSH_WINDOWS_TRAP - ld [%g1 + 8], %i7 /* Load returen address stored in jmpbuf. */ - ld [%g1], %fp /* Load sp stored in jmpbuf. */ - jmp %i7 + 8 - restore %g2, 0, %o0 /* Set return value. */ - -/* We match fp and target_fp successfully. */ -.Lfound: - mov %o0, %sp - ld [%g1 + 8], %o0 /* Load returen address stored in jmpbuf. */ - jmp %o0 + 8 - mov %g2, %o0 /* Set return value. */ diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S deleted file mode 100644 index f0f1d981..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -/* - * TODO: FLUSH_WINDOWS_TRAP is not implemented. - * Currently setjmp and longjmp are not availeble. - */ - -.global __setjmp -.global _setjmp -.global setjmp -.type __setjmp,@function -.type _setjmp,@function -.type setjmp,@function -__setjmp: -_setjmp: -setjmp: - ta FLUSH_WINDOWS_TRAP - st %sp, [%o0] - st %fp, [%o0 + 4] - st %o7, [%o0 + 8] - retl - mov 0, %o0 - diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt index 7cb95a82..16b6841f 100644 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt +++ b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt @@ -8,4 +8,4 @@ # PURPOSE. # See the Mulan PSL v2 for more details. -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file +target_sources(libchcore-porting-symbols PRIVATE __unmapself.s) diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.s old mode 100755 new mode 100644 similarity index 100% rename from Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.S rename to Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.s diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s similarity index 100% rename from Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.S rename to Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s.del b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s.del deleted file mode 100644 index e69de29b..00000000 diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt deleted file mode 100644 index 7cb95a82..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. - -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S deleted file mode 100644 index 52362ebe..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - li a7, CHCORE_SYS_thread_exit - ecall diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S deleted file mode 100644 index 3d925872..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __unmapself -.type __unmapself, %function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mv s2, a0 /* Save unmap addr. */ - mv s3, a1 /* Save unmap length. */ - jal chcore_lock_common_stack - mv sp, a0 /* Switch the stack. */ - - mv a0, s2 - mv a1, s3 - jal chcore_unmapself - - /* Release lock of common stack. */ - fence rw, rw - sw zero, 0(a0) - fence rw, rw - - li a7, CHCORE_SYS_thread_exit - ecall diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s deleted file mode 100644 index 348150c9..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - mov %o0, %g7 - retl - mov %g0, %o0 diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S deleted file mode 100644 index bc39015b..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - set CHCORE_SYS_thread_exit, %g1 - ta 0x10 diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S deleted file mode 100644 index 1f98c9dd..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -.global __unmapself -.type __unmapself,%function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mov %o0, %i0 /* Save unmap addr. */ - call chcore_lock_common_stack - mov %o1, %i1 /* Save unmap length (delay slot). */ - mov %o0, %sp /* Switch the stack. */ - - ta REVOKE_WINDOW_TRAP /* revoke windows */ - - mov %i0, %o0 - call chcore_unmapself - mov %i1, %o1 - - /* Release lock of common stack. */ - stbar - set 0, %o1 - st %o1, [%o0] - - set CHCORE_SYS_thread_exit, %g1 - ta 0x10 diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c deleted file mode 100644 index 0b943cce..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* For sparc architectures that do not provide cas instructions */ -volatile int cas_lock = 0; \ No newline at end of file diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S deleted file mode 100644 index 3599a69e..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __clone -.hidden __clone -.type __clone,%function -__clone: - /* Since we don't need this function in ChCore, just return -1 here. */ - set -1, %o0 - retl - nop - /* The following is the original implementation. */ - // save %sp, -96, %sp - // mov %i0, %g2 - // sub %i1, 96, %o1 - // mov %i2, %o0 - // mov %i3, %g3 - // mov %i4, %o2 - // mov %i5, %o3 - // ld [%fp + 92], %o4 - - // set 220, %g1 /* SYS_clone */ - // ta SYSCALL_TRAP - - // tst %o1 - // bne 1f - // nop - // jmpl %i7 + 8, %g0 - // restore %o0, %g0, %o0 -// 1: - // mov %g0, %fp /* terminate backtrace */ - // call %g2 - // mov %g3, %o0 - // set 93, %g1 /* SYS_exit */ - // ta SYSCALL_TRAP diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S deleted file mode 100644 index 044228f0..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,%function -__syscall_cp_asm: -__cp_begin: -__cp_end: -__cp_cancel: - /* Since we don't need this function in ChCore, just return -1 here. */ - set -1, %o0 - retl - nop - /* The following is the original implementation. */ - // ld [%o0], %g2 - // tst %g2 - // bne __cp_cancel - // nop - // mov %o1, %g1 - // mov %o2, %o0 - // mov %o3, %o1 - // mov %o4, %o2 - // mov %o5, %o3 - // ld [%sp + 92], %o4 - // ld [%sp + 96], %o5 - // ta SYSCALL_TRAP -// __cp_end: - // retl - // nop -// __cp_cancel: - // b __cancel diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt deleted file mode 100644 index e7bba9a0..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. - -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S __set_thread_area.s) \ No newline at end of file diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s deleted file mode 100644 index 1f5c2293..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ - -.extern chcore_x86_set_thread_area - -.text -.global __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - /* ChCore: current implementation is using wrfsbase */ - call chcore_x86_set_thread_area - ret - -#if 0 - mov %rdi,%rsi /* shift for syscall */ - movl $0x1002,%edi /* SET_FS register */ - movl $158,%eax /* set fs segment to */ - syscall /* arch_prctl(SET_FS, arg)*/ - ret -#endif diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S deleted file mode 100644 index ab1e168f..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - mov $CHCORE_SYS_thread_exit, %rax - syscall diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S deleted file mode 100644 index 2d9213ad..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ -#include - -.text -.global __unmapself -.type __unmapself,@function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mov %rdi, %r12 /* Save unmap addr. */ - mov %rsi, %r13 /* Save unmap length. */ - call chcore_lock_common_stack - mov %rax, %rsp /* Switch the stack. */ - - mov %r12, %rdi - mov %r13, %rsi - call chcore_unmapself - - /* Release lock of common stack. */ - endbr64 - movq $0, (%rax) - - mov $CHCORE_SYS_thread_exit, %rax - syscall - \ No newline at end of file diff --git a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c b/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c deleted file mode 100644 index d48074be..00000000 --- a/Lab4/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -long chcore_x86_set_thread_area(long fs) -{ - /* - * TODO: wrfsbase may not be supported. - * If so, use system call for executing wrmsr instead. - */ - __asm__ __volatile__("wrfsbase %0"::"r"(fs)); - return 0; -} diff --git a/Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt b/Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt index 7cb95a82..16b6841f 100644 --- a/Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt +++ b/Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt @@ -8,4 +8,4 @@ # PURPOSE. # See the Mulan PSL v2 for more details. -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file +target_sources(libchcore-porting-symbols PRIVATE __unmapself.s) diff --git a/Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.S b/Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.s similarity index 100% rename from Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.S rename to Lab4/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.s diff --git a/Lab5/user/chcore-libc/CMakeLists.txt b/Lab5/user/chcore-libc/CMakeLists.txt index 5006139e..a1bd9f36 100644 --- a/Lab5/user/chcore-libc/CMakeLists.txt +++ b/Lab5/user/chcore-libc/CMakeLists.txt @@ -101,7 +101,7 @@ add_custom_target(libc-build ALL # Install libc as usual add_custom_target(libc-install ALL WORKING_DIRECTORY ${_libc_target_dir} - COMMAND make install + COMMAND make -j1 install DEPENDS libc-build) # clean target diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/Makefile b/Lab5/user/chcore-libc/libchcore/porting/overrides/Makefile index 9aba5347..76bfab90 100644 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/Makefile +++ b/Lab5/user/chcore-libc/libchcore/porting/overrides/Makefile @@ -151,11 +151,11 @@ CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $< ifeq ($(ADD_CFI),yes) AS_CMD = LC_ALL=C awk -f $(srcdir)/tools/add-cfi.common.awk -f $(srcdir)/tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL) -x assembler -c -o $@ - else - AS_CMD = $(CC_CMD) + AS_CMD = $(CC) $(CFLAGS_ALL) -x assembler-with-cpp -c -o $@ $< endif obj/%.o: $(srcdir)/%.s - $(AS_CMD) + ($(AS_CMD) 2> /dev/null) || $(CC_CMD) obj/%.o: $(srcdir)/%.S $(CC_CMD) @@ -164,7 +164,7 @@ obj/%.o: $(srcdir)/%.c $(GENH) $(IMPH) $(CC_CMD) obj/%.lo: $(srcdir)/%.s - $(AS_CMD) + ($(AS_CMD) 2> /dev/null) || $(CC_CMD) obj/%.lo: $(srcdir)/%.S $(CC_CMD) diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c index d19e1e71..c9a54430 100644 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c +++ b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/stdio.c @@ -130,7 +130,9 @@ static int get_one_char(void) static void put(char buffer[], unsigned size) { - chcore_syscall2(CHCORE_SYS_putstr, (vaddr_t)buffer, size); + /* LAB 3 TODO BEGIN */ + + /* LAB 3 TODO END */ } #define MAX_LINE_SIZE 4095 @@ -342,4 +344,4 @@ struct fd_ops stderr_ops = { .poll = NULL, .ioctl = chcore_stdio_ioctl, .fcntl = chcore_stdio_fcntl, -}; \ No newline at end of file +}; diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S deleted file mode 100644 index caefbfd0..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/longjmp.S +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* This file references glibc/sysdeps/sparc/sparc32/__longjmp.S. */ - -/* - * TODO: FLUSH_WINDOWS_TRAP is not implemented. - * Currently setjmp and longjmp are not availeble. - */ - -#include - -/* void longjmp(jmpbuf, retval) */ -.global _longjmp -.global longjmp -.type _longjmp,@function -.type longjmp,@function -_longjmp: -longjmp: - ld [%o0 + 4], %g3 /* %g3 = fp stored in jmpbuf (target_fp). */ - mov %o0, %g1 /* jmpbuf in %g1. */ - orcc %o1, %g0, %g2 /* retval in %g2 (return value of setjmp). */ - be,a 0f - mov 1, %g2 /* Return value of setjmp can't be 0. */ -0: - xor %fp, %g3, %o0 - add %fp, 512, %o1 - andncc %o0, 0xfff, %o0 /* Is | fp - target_fp | < 4096 ? */ - bne .Lthread /* Too much gap between fp and target_fp. */ - cmp %o1, %g3 /* fp + 512 < target_fp. */ - bl .Lthread /* Too much gap between fp and target_fp. */ - -/* If fp < target_fp, we can restore windows to match them. */ -.Lloop: - cmp %fp, %g3 /* Have we reached the target frame? */ - bl,a .Lloop /* fp < target_fp, restore and continue. */ - restore - be,a .Lfound /* fp == target_fp, found target frame. */ - ld [%g1], %o0 /* Load sp stored in jmpbuf. */ - /* If fp > target_fp, go through and do trap. */ - -/* - * Unable (or too expensive) to match fp and target_fp by restoring windows. - * We will instead do a "flush register windows trap" to save all the - * register windows on their stack slots, and marks them all as invalid. - */ -.Lthread: - save %sp, -96, %sp - ta FLUSH_WINDOWS_TRAP - ld [%g1 + 8], %i7 /* Load returen address stored in jmpbuf. */ - ld [%g1], %fp /* Load sp stored in jmpbuf. */ - jmp %i7 + 8 - restore %g2, 0, %o0 /* Set return value. */ - -/* We match fp and target_fp successfully. */ -.Lfound: - mov %o0, %sp - ld [%g1 + 8], %o0 /* Load returen address stored in jmpbuf. */ - jmp %o0 + 8 - mov %g2, %o0 /* Set return value. */ diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S deleted file mode 100644 index f0f1d981..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/setjump/sparc/setjmp.S +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -/* - * TODO: FLUSH_WINDOWS_TRAP is not implemented. - * Currently setjmp and longjmp are not availeble. - */ - -.global __setjmp -.global _setjmp -.global setjmp -.type __setjmp,@function -.type _setjmp,@function -.type setjmp,@function -__setjmp: -_setjmp: -setjmp: - ta FLUSH_WINDOWS_TRAP - st %sp, [%o0] - st %fp, [%o0 + 4] - st %o7, [%o0 + 8] - retl - mov 0, %o0 - diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt index 7cb95a82..16b6841f 100644 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt +++ b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/CMakeLists.txt @@ -8,4 +8,4 @@ # PURPOSE. # See the Mulan PSL v2 for more details. -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file +target_sources(libchcore-porting-symbols PRIVATE __unmapself.s) diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.s old mode 100755 new mode 100644 similarity index 100% rename from Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.S rename to Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__thread_exit.s diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s similarity index 100% rename from Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.S rename to Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s.del b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/aarch64/__unmapself.s.del deleted file mode 100644 index e69de29b..00000000 diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt deleted file mode 100644 index 7cb95a82..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. - -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S deleted file mode 100644 index 52362ebe..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - li a7, CHCORE_SYS_thread_exit - ecall diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S deleted file mode 100644 index 3d925872..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/riscv64/__unmapself.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __unmapself -.type __unmapself, %function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mv s2, a0 /* Save unmap addr. */ - mv s3, a1 /* Save unmap length. */ - jal chcore_lock_common_stack - mv sp, a0 /* Switch the stack. */ - - mv a0, s2 - mv a1, s3 - jal chcore_unmapself - - /* Release lock of common stack. */ - fence rw, rw - sw zero, 0(a0) - fence rw, rw - - li a7, CHCORE_SYS_thread_exit - ecall diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s deleted file mode 100644 index 348150c9..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__set_thread_area.s +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - mov %o0, %g7 - retl - mov %g0, %o0 diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S deleted file mode 100644 index bc39015b..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - set CHCORE_SYS_thread_exit, %g1 - ta 0x10 diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S deleted file mode 100644 index 1f98c9dd..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/__unmapself.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -.global __unmapself -.type __unmapself,%function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mov %o0, %i0 /* Save unmap addr. */ - call chcore_lock_common_stack - mov %o1, %i1 /* Save unmap length (delay slot). */ - mov %o0, %sp /* Switch the stack. */ - - ta REVOKE_WINDOW_TRAP /* revoke windows */ - - mov %i0, %o0 - call chcore_unmapself - mov %i1, %o1 - - /* Release lock of common stack. */ - stbar - set 0, %o1 - st %o1, [%o0] - - set CHCORE_SYS_thread_exit, %g1 - ta 0x10 diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c deleted file mode 100644 index 0b943cce..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/atomics.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* For sparc architectures that do not provide cas instructions */ -volatile int cas_lock = 0; \ No newline at end of file diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S deleted file mode 100644 index 3599a69e..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/clone.S +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __clone -.hidden __clone -.type __clone,%function -__clone: - /* Since we don't need this function in ChCore, just return -1 here. */ - set -1, %o0 - retl - nop - /* The following is the original implementation. */ - // save %sp, -96, %sp - // mov %i0, %g2 - // sub %i1, 96, %o1 - // mov %i2, %o0 - // mov %i3, %g3 - // mov %i4, %o2 - // mov %i5, %o3 - // ld [%fp + 92], %o4 - - // set 220, %g1 /* SYS_clone */ - // ta SYSCALL_TRAP - - // tst %o1 - // bne 1f - // nop - // jmpl %i7 + 8, %g0 - // restore %o0, %g0, %o0 -// 1: - // mov %g0, %fp /* terminate backtrace */ - // call %g2 - // mov %g3, %o0 - // set 93, %g1 /* SYS_exit */ - // ta SYSCALL_TRAP diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S deleted file mode 100644 index 044228f0..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/sparc/syscall_cp.S +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,%function -__syscall_cp_asm: -__cp_begin: -__cp_end: -__cp_cancel: - /* Since we don't need this function in ChCore, just return -1 here. */ - set -1, %o0 - retl - nop - /* The following is the original implementation. */ - // ld [%o0], %g2 - // tst %g2 - // bne __cp_cancel - // nop - // mov %o1, %g1 - // mov %o2, %o0 - // mov %o3, %o1 - // mov %o4, %o2 - // mov %o5, %o3 - // ld [%sp + 92], %o4 - // ld [%sp + 96], %o5 - // ta SYSCALL_TRAP -// __cp_end: - // retl - // nop -// __cp_cancel: - // b __cancel diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt deleted file mode 100644 index e7bba9a0..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. - -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S __set_thread_area.s) \ No newline at end of file diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s deleted file mode 100644 index 1f5c2293..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__set_thread_area.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ - -.extern chcore_x86_set_thread_area - -.text -.global __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - /* ChCore: current implementation is using wrfsbase */ - call chcore_x86_set_thread_area - ret - -#if 0 - mov %rdi,%rsi /* shift for syscall */ - movl $0x1002,%edi /* SET_FS register */ - movl $158,%eax /* set fs segment to */ - syscall /* arch_prctl(SET_FS, arg)*/ - ret -#endif diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S deleted file mode 100644 index ab1e168f..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__thread_exit.S +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -.global __thread_exit -.type __thread_exit,%function -__thread_exit: - mov $CHCORE_SYS_thread_exit, %rax - syscall diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S deleted file mode 100644 index 2d9213ad..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/__unmapself.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ -#include - -.text -.global __unmapself -.type __unmapself,@function -__unmapself: - /* - * We implement mmap/munmap in user space. But when a thread exit, it - * will call unmapself to recycle its tls and stack. So we need to switch - * the stack of the thread to a common stack, and then we release it's - * stack. When all the work is done, we release the common stack. - */ - mov %rdi, %r12 /* Save unmap addr. */ - mov %rsi, %r13 /* Save unmap length. */ - call chcore_lock_common_stack - mov %rax, %rsp /* Switch the stack. */ - - mov %r12, %rdi - mov %r13, %rsi - call chcore_unmapself - - /* Release lock of common stack. */ - endbr64 - movq $0, (%rax) - - mov $CHCORE_SYS_thread_exit, %rax - syscall - \ No newline at end of file diff --git a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c b/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c deleted file mode 100644 index d48074be..00000000 --- a/Lab5/user/chcore-libc/libchcore/porting/overrides/src/thread/x86_64/set_thread_area.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -long chcore_x86_set_thread_area(long fs) -{ - /* - * TODO: wrfsbase may not be supported. - * If so, use system call for executing wrmsr instead. - */ - __asm__ __volatile__("wrfsbase %0"::"r"(fs)); - return 0; -} diff --git a/Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt b/Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt index 7cb95a82..16b6841f 100644 --- a/Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt +++ b/Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/CMakeLists.txt @@ -8,4 +8,4 @@ # PURPOSE. # See the Mulan PSL v2 for more details. -target_sources(libchcore-porting-symbols PRIVATE __unmapself.S) \ No newline at end of file +target_sources(libchcore-porting-symbols PRIVATE __unmapself.s) diff --git a/Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.S b/Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.s similarity index 100% rename from Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.S rename to Lab5/user/chcore-libc/libchcore/porting/symbols/src/thread/aarch64/__unmapself.s diff --git a/Scripts/chbuild b/Scripts/chbuild index 88b3100b..6990f5de 100755 --- a/Scripts/chbuild +++ b/Scripts/chbuild @@ -279,6 +279,7 @@ _docker_run() { -u $(id -u ${USER}):$(id -g ${USER}) \ -v ${LABROOT}:${LABROOT} -w $(pwd) \ --security-opt=seccomp:unconfined \ + --platform=linux/amd64 \ ipads/oslab:24.09 \ $self $@ fi diff --git a/Scripts/kernel.mk b/Scripts/kernel.mk index 3cddf5a4..9732e9b4 100644 --- a/Scripts/kernel.mk +++ b/Scripts/kernel.mk @@ -16,7 +16,7 @@ _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 -SERIAL := $(shell tr -dc A-Za-z0-9