diff --git a/CMakeLists.txt b/CMakeLists.txt index 294919b..cc656d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ include(settings.cmake) project(sel4webserver C ASM) - find_package(camkes-arm-vm REQUIRED) camkes_arm_vm_setup_arm_vm_environment() @@ -36,32 +35,77 @@ elseif("${PLATFORM}" STREQUAL "qemu-arm-virt") endif() elseif("${PLATFORM}" STREQUAL "odroidc2") set(cpp_flags "-DKERNELARMPLATFORM_ODROIDC2") - set(CAMKES_ROOT_DTB_FILE_PATH "${CAMKES_VM_IMAGES_DIR}/odroidc2/camkes-linux-dtb" CACHE STRING "") + set( + CAMKES_ROOT_DTB_FILE_PATH "${CAMKES_VM_IMAGES_DIR}/odroidc2/camkes-linux-dtb" + CACHE STRING "" + ) AddToFileServer("linux-dtb" "${CAMKES_VM_IMAGES_DIR}/odroidc2/linux_crossvm-dtb") elseif("${PLATFORM}" STREQUAL "tx2") set(cpp_flags "-DKERNELARMPLATFORM_TX2") set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs.cpio.gz") set(dtb_file "${CAMKES_VM_IMAGES_DIR}/tx2/linux-ethernet-dtb") set(CAMKES_ROOT_DTB_FILE_PATH "${CAMKES_VM_IMAGES_DIR}/tx2/linux-ethernet-dtb" CACHE STRING "") - AddFileToOverlayDir("connection.ko" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/connection.ko" "lib/modules/4.4.38L4T kernel 4.4.38/kernel/drivers/vmm" overlay) + AddFileToOverlayDir( + "connection.ko" + "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/connection.ko" + "lib/modules/4.4.38L4T kernel 4.4.38/kernel/drivers/vmm" + overlay + ) endif() if(MULTI_VM_LAN) # Setup our passthrough vm overlay - AddFileToOverlayDir("inittab" ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/inittab_hvc0 "etc" overlay_vm0) - AddFileToOverlayDir("S90bridge_setup" ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/vm0_bridge_setup.sh "etc/init.d" overlay_vm0) - AddOverlayDirToRootfs(overlay_vm0 ${rootfs_file} "buildroot" "rootfs_install" - vm0_output_overlayed_rootfs_location rootfs_target_vm0 - GZIP) + AddFileToOverlayDir( + "inittab" + ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/inittab_hvc0 + "etc" + overlay_vm0 + ) + AddFileToOverlayDir( + "S90bridge_setup" + ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/vm0_bridge_setup.sh + "etc/init.d" + overlay_vm0 + ) + AddOverlayDirToRootfs( + overlay_vm0 + ${rootfs_file} + "buildroot" + "rootfs_install" + vm0_output_overlayed_rootfs_location + rootfs_target_vm0 + GZIP + ) # Setup our client vm overlays - AddFileToOverlayDir("inittab" ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/inittab_hvc0 "etc" overlay_client_vm) + AddFileToOverlayDir( + "inittab" + ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/inittab_hvc0 + "etc" + overlay_client_vm + ) lighttpd_install_to_overlay(overlay_client_vm) docsite_install_to_overlay(overlay_client_vm) - AddOverlayDirToRootfs(overlay_client_vm ${rootfs_file} "buildroot" "rootfs_install" - client_output_overlayed_rootfs_location rootfs_target_client_vm - GZIP) - AddToFileServer("linux-initrd-vm0" "${vm0_output_overlayed_rootfs_location}" DEPENDS rootfs_target_vm0) - AddToFileServer("linux-initrd-vm-client" "${client_output_overlayed_rootfs_location}" DEPENDS rootfs_target_client_vm) + AddOverlayDirToRootfs( + overlay_client_vm + ${rootfs_file} + "buildroot" + "rootfs_install" + client_output_overlayed_rootfs_location + rootfs_target_client_vm + GZIP + ) + AddToFileServer( + "linux-initrd-vm0" + "${vm0_output_overlayed_rootfs_location}" + DEPENDS + rootfs_target_vm0 + ) + AddToFileServer( + "linux-initrd-vm-client" + "${client_output_overlayed_rootfs_location}" + DEPENDS + rootfs_target_client_vm + ) else() # Build crossvm kernel module for qemu @@ -91,13 +135,17 @@ else() "" CONFIGURE_COMMAND "" - USES_TERMINAL_DOWNLOAD TRUE + USES_TERMINAL_DOWNLOAD + TRUE SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/linux_out ) # Linux config and symvers are to be copied to unpacked archive set(linux_config "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux_configs/config") - set(linux_symvers "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux_configs/Module.symvers") + set( + linux_symvers + "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux_configs/Module.symvers" + ) # Configure unpacked archive with config and symvers ConfigureLinux( ${CMAKE_CURRENT_BINARY_DIR}/linux_out @@ -161,7 +209,8 @@ else() ON EXCLUDE_FROM_ALL CMAKE_ARGS - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_C_FLAGS=${BASE_C_FLAGS} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS=${BASE_C_FLAGS} ) AddExternalProjFilesToOverlay( @@ -174,7 +223,6 @@ else() ) endforeach() - # Generate overlayed rootfs AddOverlayDirToRootfs( overlay @@ -204,11 +252,15 @@ DefineCAmkESVMFileServer() CAmkESAddImportPath(${KernelARMPlatform}) - # Define our demo component that shares a dataport with the VM include(cpio) MakeCPIO(secure_file_archive.o ${CMAKE_CURRENT_SOURCE_DIR}/secure_file.html) -DeclareCAmkESComponent(LoggingFileserver SOURCES components/logging-fileserver/fileserver.c secure_file_archive.o) +DeclareCAmkESComponent( + LoggingFileserver + SOURCES + components/logging-fileserver/fileserver.c + secure_file_archive.o +) # Define our VM Component with out cross vm dataports glue code DeclareCAmkESComponent(VM SOURCES src/cross_vm_connections.c) diff --git a/apps/cgi-load-file/cgi-load-file.c b/apps/cgi-load-file/cgi-load-file.c index 5e9a499..a88bc64 100644 --- a/apps/cgi-load-file/cgi-load-file.c +++ b/apps/cgi-load-file/cgi-load-file.c @@ -17,21 +17,24 @@ #include #include -void block_event(int fd) { - int val; - /* Blocking read */ - int result = read(fd, &val, sizeof(val)); - if (result < 0) { - printf("Error: %s\n", strerror(errno)); - } +void block_event(int fd) +{ + int val; + /* Blocking read */ + int result = read(fd, &val, sizeof(val)); + if (result < 0) { + printf("Error: %s\n", strerror(errno)); + } } -void emit_event(char* emit) { - emit[0] = 1; +void emit_event(char *emit) +{ + emit[0] = 1; } -void memcpy_byte(void *dst, void *src, size_t size) { +void memcpy_byte(void *dst, void *src, size_t size) +{ char *dst_c = dst; char *src_c = src; for (int i = 0; i < size; i++) { diff --git a/components/logging-fileserver/fileserver.c b/components/logging-fileserver/fileserver.c index 758f3c6..3fb241c 100644 --- a/components/logging-fileserver/fileserver.c +++ b/components/logging-fileserver/fileserver.c @@ -20,7 +20,8 @@ extern void done_emit_underlying(void); #define MAX_FILENAME_LENGTH 200 -void pre_init() { +void pre_init() +{ /* install the _cpio_archive */ unsigned long cpio_size = _cpio_archive_end - _cpio_archive; muslcsys_install_cpio_interface(_cpio_archive, cpio_size, cpio_get_file); @@ -31,11 +32,11 @@ int run(void) { /* Zero out the data port */ memset(dest, '\0', 4096); - char* dest_c = (char*)dest; + char *dest_c = (char *)dest; char filename[MAX_FILENAME_LENGTH] = {0}; while (1) { ready_wait(); - strncpy(filename, dest_c+strlen("/"), MAX_FILENAME_LENGTH-1); + strncpy(filename, dest_c + strlen("/"), MAX_FILENAME_LENGTH - 1); int fd = open(filename, O_RDONLY); if (fd < 0) { snprintf(dest_c, 4, "404"); diff --git a/docsite/Finddocsite.cmake b/docsite/Finddocsite.cmake index b574c06..25b3492 100644 --- a/docsite/Finddocsite.cmake +++ b/docsite/Finddocsite.cmake @@ -24,7 +24,8 @@ macro(docsite_build_site_tar outfile) ON BUILD_IN_SOURCE TRUE - USES_TERMINAL_BUILD TRUE + USES_TERMINAL_BUILD + TRUE BUILD_COMMAND "make;build" INSTALL_COMMAND diff --git a/lighttpd/Findlighttpd.cmake b/lighttpd/Findlighttpd.cmake index f4589b4..90fb55c 100644 --- a/lighttpd/Findlighttpd.cmake +++ b/lighttpd/Findlighttpd.cmake @@ -10,7 +10,13 @@ set(LIGHTTPD_RUN_SCRIPT "${LIGHTTPD_DIR}/lighttpd.sh" CACHE STRING "") mark_as_advanced(LIGHTTPD_DIR LIGHTTPD_CONF LIGHTTPD_RUN_SCRIPT) macro(lighttpd_build_server outfile) - string(REGEX MATCH "^(.+)\-$" config_host "${CROSS_COMPILER_PREFIX}" ) + string( + REGEX + MATCH + "^(.+)\-$" + config_host + "${CROSS_COMPILER_PREFIX}" + ) set(config_host "${CMAKE_MATCH_1}") include(ExternalProject) # Static compile of pcre library @@ -26,12 +32,18 @@ macro(lighttpd_build_server outfile) SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/libprce-prefix/src/libpcre CONFIGURE_COMMAND - ./configure --host=${config_host} CC=${CMAKE_C_COMPILER} AR=${CMAKE_AR} STRIP=${DCMAKE_STRIP} - RANLIB=${CMAKE_RANLIB} --prefix=${CMAKE_CURRENT_BINARY_DIR}/libpcre/_install + ./configure + --host=${config_host} + CC=${CMAKE_C_COMPILER} + AR=${CMAKE_AR} + STRIP=${DCMAKE_STRIP} + RANLIB=${CMAKE_RANLIB} + --prefix=${CMAKE_CURRENT_BINARY_DIR}/libpcre/_install BUILD_COMMAND make INSTALL_COMMAND - make install + make + install ) # Force static linking of pthread symbols set(linker_flags -static\ -u\ pthread_mutex_lock\ -u\ pthread_mutex_unlock\ -lpthread) @@ -47,7 +59,10 @@ macro(lighttpd_build_server outfile) GIT_TAG lighttpd-1.4.55 PATCH_COMMAND - ${GIT_EXECUTABLE} apply ${LIGHTTPD_DIR}/lighttpd_cmake.patch ${LIGHTTPD_DIR}/lemon_cmake.patch + ${GIT_EXECUTABLE} + apply + ${LIGHTTPD_DIR}/lighttpd_cmake.patch + ${LIGHTTPD_DIR}/lemon_cmake.patch BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/lighttpd BUILD_ALWAYS diff --git a/settings.cmake b/settings.cmake index 72ca88e..530423a 100644 --- a/settings.cmake +++ b/settings.cmake @@ -25,7 +25,7 @@ include(application_settings) if("${PLATFORM}" STREQUAL "") set(PLATFORM "exynos5422") endif() -if (NOT "${PLATFORM}" IN_LIST supported) +if(NOT "${PLATFORM}" IN_LIST supported) message(FATAL_ERROR "PLATFORM: ${PLATFORM} not supported. Supported: ${supported}") endif() if("${PLATFORM}" STREQUAL "exynos5422") @@ -33,13 +33,18 @@ if("${PLATFORM}" STREQUAL "exynos5422") set(KernelARMPlatform exynos5422 CACHE STRING "" FORCE) endif() if("${PLATFORM}" STREQUAL "qemu-arm-virt") - if (MULTI_VM_LAN) - message(FATAL_ERROR "The Multi-VM configuration is not supported on the qemu-arm-virt platform") + if(MULTI_VM_LAN) + message( + FATAL_ERROR "The Multi-VM configuration is not supported on the qemu-arm-virt platform" + ) endif() set(KernelPlatform qemu-arm-virt CACHE STRING "" FORCE) set(KernelARMPlatform qemu-arm-virt CACHE STRING "" FORCE) set(QEMU_MEMORY "2048") - set(qemu_sim_extra_args "-netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no -device virtio-net,netdev=mynet0,mac=52:55:00:d1:55:01") + set( + qemu_sim_extra_args + "-netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no -device virtio-net,netdev=mynet0,mac=52:55:00:d1:55:01" + ) set(KernelArmCPU cortex-a53 CACHE STRING "" FORCE) set(KernelArmHypervisorSupport ON CACHE BOOL "" FORCE) endif()