Skip to content

Commit

Permalink
Merge pull request #27 from CarlWachter/no_lwip
Browse files Browse the repository at this point in the history
Removed lwip and updated to newest librs
  • Loading branch information
mkroening authored Jun 4, 2024
2 parents 615b7aa + 7679d31 commit 375dbcb
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 313 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
100 changes: 21 additions & 79 deletions cmake/HermitCore-librs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,105 +4,47 @@ 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 $<TARGET_OBJECTS:${MODULE}>)

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 $<TARGET_FILE:hermit-bootstrap> *.o
COMMAND
${CMAKE_COMMAND} -E remove *.o

# Convert the combined library to osabi "Standalone"
COMMAND
${CMAKE_ELFEDIT} --output-osabi Standalone $<TARGET_FILE:hermit-bootstrap>
# 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 $<TARGET_FILE:hermit-bootstrap> ${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
${CMAKE_COMMAND} -E make_directory ${LOCAL_PREFIX_ARCH_INCLUDE_DIR}/hermit
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)
3 changes: 1 addition & 2 deletions cmake/HermitCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
134 changes: 0 additions & 134 deletions include/hermit/mailbox.h

This file was deleted.

69 changes: 0 additions & 69 deletions include/hermit/mailbox_types.h

This file was deleted.

8 changes: 2 additions & 6 deletions include/hermit/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,17 +107,14 @@ 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);
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);
Expand Down
2 changes: 1 addition & 1 deletion include/netinet/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
#ifndef __NETINET_TCP_H__
#define __NETINET_TCP_H__

#include <lwip/tcp.h>
#include <tcp.h>

#endif /* __NETINET_TCP_H__ */
Loading

0 comments on commit 375dbcb

Please sign in to comment.