diff --git a/.github/workflows/x86_64.yml b/.github/workflows/x86_64.yml index c8709c32..bd432e3b 100644 --- a/.github/workflows/x86_64.yml +++ b/.github/workflows/x86_64.yml @@ -30,8 +30,8 @@ jobs: apt-get -y install qemu-system-x86 - name: Run hello run: qemu-system-x86_64 -smp 1 -cpu qemu64,apic,fsgsbase,rdtscp,xsave,xsaveopt,fxsr,rdrand -display none -m 128M -serial stdio -kernel rusty-loader-x86_64 -initrd build/local_prefix/opt/hermit/x86_64-hermit/extra/tests/hello - - name: Run hellof - run: qemu-system-x86_64 -smp 1 -cpu qemu64,apic,fsgsbase,rdtscp,xsave,xsaveopt,fxsr,rdrand -display none -m 128M -serial stdio -kernel rusty-loader-x86_64 -initrd build/local_prefix/opt/hermit/x86_64-hermit/extra/tests/hellof + #- name: Run hellof + # run: qemu-system-x86_64 -smp 1 -cpu qemu64,apic,fsgsbase,rdtscp,xsave,xsaveopt,fxsr,rdrand -display none -m 128M -serial stdio -kernel rusty-loader-x86_64 -initrd build/local_prefix/opt/hermit/x86_64-hermit/extra/tests/hellof - name: Run thr_hello run: qemu-system-x86_64 -smp 1 -cpu qemu64,apic,fsgsbase,rdtscp,xsave,xsaveopt,fxsr,rdrand -display none -m 128M -serial stdio -kernel rusty-loader-x86_64 -initrd build/local_prefix/opt/hermit/x86_64-hermit/extra/tests/thr_hello - name: Run hello++ diff --git a/.gitmodules b/.gitmodules index 126641d0..5f19d6af 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "librs"] path = librs url = https://github.com/hermit-os/kernel.git -[submodule "lwip"] - path = lwip - url = https://github.com/hermit-os/LwIP.git diff --git a/cmake/HermitCore-librs.cmake b/cmake/HermitCore-librs.cmake index 9eb0d938..5b1f684d 100644 --- a/cmake/HermitCore-librs.cmake +++ b/cmake/HermitCore-librs.cmake @@ -4,76 +4,22 @@ add_custom_target(hermit_rs COMMAND cargo run --package=xtask --target-dir ${CMAKE_BINARY_DIR}/hermit_rs -- build --arch ${HERMIT_ARCH} --target-dir ${CMAKE_BINARY_DIR}/hermit_rs ${CARGO_BUILDTYPE_PARAMETER} - --no-default-features --features pci,smp,acpi,newlib + --no-default-features --features pci,smp,acpi,newlib,tcp,dhcpv4 WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../librs) -set(LWIP_SRC lwip/src) -add_kernel_module_sources("lwip" "${LWIP_SRC}/api/*.c") -add_kernel_module_sources("lwip" "${LWIP_SRC}/arch/*.c") -add_kernel_module_sources("lwip" "${LWIP_SRC}/core/*.c") -add_kernel_module_sources("lwip" "${LWIP_SRC}/core/ipv4/*.c") -add_kernel_module_sources("lwip" "${LWIP_SRC}/core/ipv6/*.c") -add_kernel_module_sources("lwip" "${LWIP_SRC}/netif/*.c") - -get_kernel_modules(KERNEL_MODULES) -foreach(MODULE ${KERNEL_MODULES}) - get_kernel_module_sources(SOURCES ${MODULE}) - - # maintain list of all objects that will end up in libhermit.a - list(APPEND KERNEL_OBJECTS $) - - add_library(${MODULE} OBJECT ${SOURCES}) - - # this is kernel code - target_compile_definitions(${MODULE} - PRIVATE -D__KERNEL__) - - target_compile_definitions(${MODULE} - PRIVATE -DMAX_ARGC_ENVC=${MAX_ARGC_ENVC}) - - target_compile_options(${MODULE} - PRIVATE ${HERMIT_KERNEL_FLAGS}) - - target_include_directories(${MODULE} - PUBLIC ${HERMIT_KERNEL_INCLUDES}) - - # suppress all LwIP compiler warnings. Not our code, so we cannot fix - if("${MODULE}" STREQUAL "lwip") - target_compile_options(${MODULE} - PRIVATE -w) - endif() -endforeach() - -# Build all kernel modules into a single static library. -add_library(hermit-bootstrap STATIC ${KERNEL_OBJECTS}) -set_target_properties(hermit-bootstrap PROPERTIES LINKER_LANGUAGE C) -add_dependencies(hermit-bootstrap hermit_rs) -set_target_properties(hermit-bootstrap PROPERTIES ARCHIVE_OUTPUT_NAME hermit) - -# Post-process the static library. -add_custom_command( - TARGET hermit-bootstrap POST_BUILD - - # Merge the Rust library into this static library. - COMMAND - ${CMAKE_AR} x ${HERMIT_RS} - COMMAND - ${CMAKE_AR} rcs $ *.o - COMMAND - ${CMAKE_COMMAND} -E remove *.o - - # Convert the combined library to osabi "Standalone" - COMMAND - ${CMAKE_ELFEDIT} --output-osabi Standalone $ +# Require hermit_rs to be built for hermit +add_custom_target(hermit + DEPENDS hermit_rs # Copy libhermit.a into local prefix directory so that all subsequent # targets can link against the freshly built version (as opposed to # linking against the one supplied by the toolchain) + COMMAND ${CMAKE_COMMAND} -E make_directory ${LOCAL_PREFIX_ARCH_LIB_DIR} COMMAND - ${CMAKE_COMMAND} -E copy_if_different $ ${LOCAL_PREFIX_ARCH_LIB_DIR}/ + ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/hermit_rs/${HERMIT_ARCH}/release/libhermit.a ${LOCAL_PREFIX_ARCH_LIB_DIR}/ # and also copy headers into local prefix COMMAND @@ -81,28 +27,24 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/include/hermit/*.h ${LOCAL_PREFIX_ARCH_INCLUDE_DIR}/hermit/) -# Deploy libhermit.a and headers for package creation -install(TARGETS hermit-bootstrap - DESTINATION ${HERMIT_ARCH}-hermit/lib - COMPONENT bootstrap) - -install(DIRECTORY include/hermit - DESTINATION ${HERMIT_ARCH}-hermit/include/ - COMPONENT bootstrap - FILES_MATCHING PATTERN *.h) - # Provide custom target to only install libhermit without its runtimes which is # needed during the compilation of the cross toolchain -add_custom_target(hermit-bootstrap-install +add_custom_target(hermit_rs-install DEPENDS - hermit-bootstrap + hermit_rs COMMAND ${CMAKE_COMMAND} - -DCMAKE_INSTALL_COMPONENT=bootstrap + -DCMAKE_INSTALL_COMPONENT=hermit_rs -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -P cmake_install.cmake) - -# The target 'hermit' includes the HermitCore kernel and several runtimes. -# Applications should depend on this target if they link against HermitCore. -add_custom_target(hermit - DEPENDS hermit-bootstrap) + -P cmake_install.cmake +) + +# Install libhermit.a and headers +install(FILES ${HERMIT_RS} + DESTINATION ${HERMIT_ARCH}-hermit/lib + COMPONENT bootstrap) + +install(DIRECTORY include/hermit + DESTINATION ${HERMIT_ARCH}-hermit/include/ + COMPONENT bootstrap + FILES_MATCHING PATTERN *.h) \ No newline at end of file diff --git a/cmake/HermitCore.cmake b/cmake/HermitCore.cmake index dfb4f1d7..0d338cb7 100644 --- a/cmake/HermitCore.cmake +++ b/cmake/HermitCore.cmake @@ -50,8 +50,7 @@ endif() set(HERMIT_KERNEL_INCLUDES ${CMAKE_BINARY_DIR}/include ${HERMIT_ROOT}/include - ${HERMIT_ROOT}/include/hermit/${HERMIT_ARCH} - ${HERMIT_ROOT}/lwip/src/include) + ${HERMIT_ROOT}/include/hermit/${HERMIT_ARCH}) # HACK: when CMake detects compilers it taints CMAKE_INSTALL_PREFIX, so in # order to rely on that variable (we redefine it), enable all languages diff --git a/include/hermit/mailbox.h b/include/hermit/mailbox.h deleted file mode 100644 index c0e69132..00000000 --- a/include/hermit/mailbox.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __MAILBOX_H__ -#define __MAILBOX_H__ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAILBOX(name, type) \ - inline static int mailbox_##name##_init(mailbox_##name##_t* m) { \ - if (BUILTIN_EXPECT(!m, 0)) \ - return -EINVAL; \ - \ - memset(m->buffer, 0x00, sizeof(type)*MAILBOX_SIZE); \ - m->wpos = m->rpos = 0; \ - sys_sem_init(&m->mails, 0); \ - sys_sem_init(&m->boxes, MAILBOX_SIZE); \ - sys_spinlock_init(&m->rlock); \ - sys_spinlock_init(&m->wlock); \ - \ - return 0; \ - }\ - \ - inline static int mailbox_##name##_destroy(mailbox_##name##_t* m) { \ - if (BUILTIN_EXPECT(!m, 0)) \ - return -EINVAL; \ - \ - sys_sem_destroy(m->mails); \ - sys_sem_destroy(m->boxes); \ - sys_spinlock_destroy(m->rlock); \ - sys_spinlock_destroy(m->wlock); \ - \ - return 0; \ - } \ - \ - inline static int mailbox_##name##_post(mailbox_##name##_t* m, type mail) { \ - if (BUILTIN_EXPECT(!m, 0)) \ - return -EINVAL; \ - \ - sys_sem_timedwait(m->boxes, 0); \ - sys_spinlock_lock(m->wlock); \ - m->buffer[m->wpos] = mail; \ - m->wpos = (m->wpos+1) % MAILBOX_SIZE; \ - sys_spinlock_unlock(m->wlock); \ - sys_sem_post(m->mails); \ - \ - return 0; \ - } \ - \ - inline static int mailbox_##name##_trypost(mailbox_##name##_t* m, type mail) { \ - if (BUILTIN_EXPECT(!m, 0)) \ - return -EINVAL; \ - \ - if (sys_sem_trywait(m->boxes)) \ - return -EBUSY; \ - sys_spinlock_lock(m->wlock); \ - m->buffer[m->wpos] = mail; \ - m->wpos = (m->wpos+1) % MAILBOX_SIZE; \ - sys_spinlock_unlock(m->wlock); \ - sys_sem_post(m->mails); \ - \ - return 0; \ - } \ - \ - inline static int mailbox_##name##_fetch(mailbox_##name##_t* m, type* mail, uint32_t ms) { \ - int err; \ - \ - if (BUILTIN_EXPECT(!m || !mail, 0)) \ - return -EINVAL; \ - \ - err = sys_sem_timedwait(m->mails, ms); \ - if (err) return SYS_ARCH_TIMEOUT; \ - sys_spinlock_lock(m->rlock); \ - *mail = m->buffer[m->rpos]; \ - m->rpos = (m->rpos+1) % MAILBOX_SIZE; \ - sys_spinlock_unlock(m->rlock); \ - sys_sem_post(m->boxes); \ - \ - return 0; \ - } \ - \ - inline static int mailbox_##name##_tryfetch(mailbox_##name##_t* m, type* mail) { \ - if (BUILTIN_EXPECT(!m || !mail, 0)) \ - return -EINVAL; \ - \ - if (sys_sem_trywait(m->mails) != 0) \ - return -EINVAL; \ - sys_spinlock_lock(m->rlock); \ - *mail = m->buffer[m->rpos]; \ - m->rpos = (m->rpos+1) % MAILBOX_SIZE; \ - sys_spinlock_unlock(m->rlock); \ - sys_sem_post(m->boxes); \ - \ - return 0; \ - }\ - -MAILBOX(ptr, void*) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/hermit/mailbox_types.h b/include/hermit/mailbox_types.h deleted file mode 100644 index 9783ef8c..00000000 --- a/include/hermit/mailbox_types.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @author Stefan Lankes - * @file include/hermit/mailbox_types.h - * @brief Message type structure definitions for various task return types - */ - -#ifndef __MAILBOX_TYPES_H__ -#define __MAILBOX_TYPES_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @brief Wait message structure - * - * This message struct keeps a recipient task id and the message itself */ -typedef struct { - /// The task id of the task which is waiting for this message - tid_t id; - /// The message payload - int32_t result; -} wait_msg_t; - -#define MAILBOX_TYPES(name, type) \ - typedef struct mailbox_##name { \ - type buffer[MAILBOX_SIZE]; \ - int wpos, rpos; \ - HermitSemaphore* mails; \ - HermitSemaphore* boxes; \ - HermitSpinlock* rlock; \ - HermitSpinlock* wlock; \ - } mailbox_##name##_t; - -MAILBOX_TYPES(ptr, void*) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/hermit/syscall.h b/include/hermit/syscall.h index 39f1e856..c958e7c2 100644 --- a/include/hermit/syscall.h +++ b/include/hermit/syscall.h @@ -61,8 +61,7 @@ typedef struct _HermitItimerval HermitItimerval; struct _HermitRecursiveMutex; typedef struct _HermitRecursiveMutex HermitRecursiveMutex; -struct _HermitSemaphore; -typedef struct _HermitSemaphore HermitSemaphore; +typedef void* HermitSemaphore; struct _HermitSpinlock; typedef struct _HermitSpinlock HermitSpinlock; @@ -108,9 +107,6 @@ int sys_close(int fd); void sys_acquire_putchar_lock(void); void sys_putchar(const unsigned char character); void sys_release_putchar_lock(void); -int sys_lwip_get_errno(); -void sys_lwip_register_tcpip_task(tid_t id); -void sys_lwip_set_errno(int errno); void sys_usleep(unsigned long usecs); int sys_nanosleep(const HermitTimespec* rqtp, HermitTimespec* rmtp); void sys_msleep(unsigned int ms); @@ -118,7 +114,7 @@ int sys_recmutex_init(HermitRecursiveMutex** recmutex); int sys_recmutex_destroy(HermitRecursiveMutex* recmutex); int sys_recmutex_lock(HermitRecursiveMutex* recmutex); int sys_recmutex_unlock(HermitRecursiveMutex* recmutex); -int sys_sem_init(HermitSemaphore** sem, unsigned int value); +int sys_sem_init(HermitSemaphore* sem, unsigned int pshared, unsigned int value); int sys_sem_destroy(HermitSemaphore* sem); int sys_sem_post(HermitSemaphore* sem); int sys_sem_trywait(HermitSemaphore* sem); diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h index 0aaa1dd0..20fa1994 100644 --- a/include/netinet/tcp.h +++ b/include/netinet/tcp.h @@ -11,6 +11,6 @@ #ifndef __NETINET_TCP_H__ #define __NETINET_TCP_H__ -#include +#include #endif /* __NETINET_TCP_H__ */ diff --git a/librs b/librs index a48fa825..285f28af 160000 --- a/librs +++ b/librs @@ -1 +1 @@ -Subproject commit a48fa8254995631f397bca46441f71df72da4355 +Subproject commit 285f28af2b077a85723376c82ad8e38f508716d1 diff --git a/lwip b/lwip deleted file mode 160000 index 473a1125..00000000 --- a/lwip +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 473a112544473e2dcc9fcc18adce330617132778 diff --git a/usr/benchmarks/CMakeLists.txt b/usr/benchmarks/CMakeLists.txt index f0902183..91c333c8 100644 --- a/usr/benchmarks/CMakeLists.txt +++ b/usr/benchmarks/CMakeLists.txt @@ -9,7 +9,7 @@ target_link_libraries(basic pthread) add_executable(hg hg.c hist.c rdtsc.c run.c init.c opt.c report.c setup.c) -add_executable(netio netio.c) +# add_executable(netio netio.c) # temporarily removed due to lack of select() support add_executable(stream stream.c) target_compile_options(stream PRIVATE -fopenmp) diff --git a/usr/benchmarks/basic.c b/usr/benchmarks/basic.c index 5fc31b7b..a4c346cc 100644 --- a/usr/benchmarks/basic.c +++ b/usr/benchmarks/basic.c @@ -101,16 +101,15 @@ int main(int argc, char** argv) printf("Average time for sched_yield: %lld cycles\n", (end - start) / N); sum = 0; - for(i=0; i<10000; i++) { - start = rdtsc(); + start = rdtsc(); + for(i=0; i<10000; i++) { pthread_create(&thr_handle, NULL, thread_func, NULL); sched_yield(); pthread_join(thr_handle, (void**)&start); - sum += rdtsc() - start; - } + end = rdtsc(); - printf("Average time to create a thread: %lld cycles\n", sum / 10000); + printf("Average time to create a thread: %lld cycles\n", (end - start) / 10000); #if 0 write(2, (const void *)str, len); diff --git a/usr/benchmarks/taskswitch.c b/usr/benchmarks/taskswitch.c index 027c7a62..38eadca1 100644 --- a/usr/benchmarks/taskswitch.c +++ b/usr/benchmarks/taskswitch.c @@ -6,13 +6,13 @@ // copied, modified, or distributed except according to those terms. /////////////////////////////////////// -//// HERMITCORE RUST-SPECIFIC CODE //// +//// HERMIT-OS RUST-SPECIFIC CODE //// #include inline static void create_second_task(void (*entry_point)(void*)) { - sys_spawn(NULL, entry_point, NULL, HIGH_PRIO, 0); + sys_spawn(NULL, entry_point, NULL, NORMAL_PRIO, 0); } inline static void consume_task_time(void) diff --git a/usr/tests/CMakeLists.txt b/usr/tests/CMakeLists.txt index 8e8a95e8..3bbc4f58 100644 --- a/usr/tests/CMakeLists.txt +++ b/usr/tests/CMakeLists.txt @@ -6,7 +6,7 @@ project(hermit_tests C CXX Fortran) add_executable(hello hello.c) add_executable(jacobi jacobi.c) add_executable(hello++ hello++.cpp) -add_executable(hellof hellof.f90) +#add_executable(hellof hellof.f90) Temporarily removing Fortran support #add_executable(pi pi.go) add_executable(test-malloc test-malloc.c) diff --git a/usr/tests/hello-tcp.c b/usr/tests/hello-tcp.c index 478224f6..7907a47a 100644 --- a/usr/tests/hello-tcp.c +++ b/usr/tests/hello-tcp.c @@ -8,6 +8,7 @@ #include #include #include +#include int main() { const int sfd = socket(AF_INET, SOCK_STREAM, 0); @@ -33,7 +34,7 @@ int main() { puts("listening for incoming connections"); for (;;) { - puts("awaitening connections"); + puts("awaiting connections"); struct sockaddr_in address; socklen_t addr_len = sizeof(address); int cfd; diff --git a/usr/tests/test-malloc-mt.c b/usr/tests/test-malloc-mt.c index 9e35d2de..f8f17dd6 100644 --- a/usr/tests/test-malloc-mt.c +++ b/usr/tests/test-malloc-mt.c @@ -10,11 +10,11 @@ #endif #ifndef NUM_ITER -#define NUM_ITER 10000 +#define NUM_ITER 1000 #endif #ifndef SIZE -#define SIZE 16384 +#define SIZE 16*1024 #endif __thread void* buf; diff --git a/usr/tests/test-malloc.c b/usr/tests/test-malloc.c index 1da64da2..27bea65a 100644 --- a/usr/tests/test-malloc.c +++ b/usr/tests/test-malloc.c @@ -4,7 +4,7 @@ #include #ifndef NUM_ITER -#define NUM_ITER 100000 +#define NUM_ITER 10000 #endif #ifndef SIZE @@ -26,5 +26,3 @@ int main(int argc, char** argv) return 0; } - -