diff --git a/.bintray_descriptor.json b/.bintray_descriptor.json index 5d244a4f7..ff3e91669 100644 --- a/.bintray_descriptor.json +++ b/.bintray_descriptor.json @@ -13,7 +13,7 @@ }, "version": { - "name": "0.2.1", + "name": "0.2.2", "desc": "HermitCore's kernel as libOS", "gpgSign": false }, diff --git a/.travis.yml b/.travis.yml index d9c3418c7..29be05dd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,9 @@ dist: trusty git: submodules: true language: c -compiler: gcc +compiler: + - clang + - gcc before_install: - echo "deb https://dl.bintray.com/rwth-os/hermitcore vivid main" | sudo tee -a /etc/apt/sources.list - travis_retry sudo apt-get -qq update @@ -24,7 +26,9 @@ notifications: slack: hermitcore:UtcfeEXkbpx3WyIDK2Wm2beS deploy: - on: master + on: + branch: master + condition: "$CC = gcc" provider: bintray file: .bintray_descriptor.json user: diff --git a/CMakeLists.txt b/CMakeLists.txt index bea2e2ab7..ef41c0992 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ set(CPACK_SYSTEM_NAME all) set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 2) -set(CPACK_PACKAGE_VERSION_PATCH 1) +set(CPACK_PACKAGE_VERSION_PATCH 2) set(CPACK_PACKAGE_CONTACT "Stefan Lankes ") diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 1192490b8..f75d7fff7 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -905,12 +905,7 @@ extern int set_idle_task(void); #if MAX_CORES > 1 int smp_start(void) { - x2apic_enable(); - - // reset APIC and set id - lapic_reset(); - - LOG_DEBUG("Processor %d (local id %d) is entering its idle task\n", apic_cpu_id(), atomic_int32_read(¤t_boot_id)); + LOG_DEBUG("Try to initialize processor (local id %d)\n", atomic_int32_read(¤t_boot_id)); // use the same gdt like the boot processors gdt_flush(); @@ -921,6 +916,12 @@ int smp_start(void) // enable additional cpu features cpu_detection(); + x2apic_enable(); + + // reset APIC + lapic_reset(); + + LOG_DEBUG("Processor %d (local id %d) is entering its idle task\n", apic_cpu_id(), atomic_int32_read(¤t_boot_id)); LOG_DEBUG("CR0 of core %u: 0x%x\n", atomic_int32_read(¤t_boot_id), read_cr0()); online[atomic_int32_read(¤t_boot_id)] = 1; diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index 6375533da..5775dfbcc 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -121,10 +121,11 @@ SECTION .ktext align 4 start64: ; reset registers to kill any stale realmode selectors - xor eax, eax + mov eax, 0x10 mov ds, eax mov ss, eax mov es, eax + xor eax, eax mov fs, eax mov gs, eax @@ -263,7 +264,22 @@ extern gp ; C as 'extern void gdt_flush();' gdt_flush: lgdt [gp] - ret + ; reload the segment descriptors + mov eax, 0x10 + mov ds, eax + mov es, eax + mov ss, eax + xor eax, eax + mov fs, eax + mov gs, eax + ; create pseudo interrupt to set cs + push QWORD 0x10 ; SS + push rsp ; RSP + add QWORD [rsp], 0x08 ; => value of rsp before the creation of a pseudo interrupt + pushfq ; RFLAGS + push QWORD 0x08 ; CS + push QWORD rollback ; RIP + iretq ; The first 32 interrupt service routines (ISR) entries correspond to exceptions. ; Some exceptions will push an error code onto the stack which is specific to diff --git a/arch/x86/kernel/gdt.c b/arch/x86/kernel/gdt.c index 2eca34564..8c1149c9f 100644 --- a/arch/x86/kernel/gdt.c +++ b/arch/x86/kernel/gdt.c @@ -153,7 +153,7 @@ void gdt_install(void) task_state_segments[i].ist3 = (size_t) stack_table[i] + (3 /*IST number */ - 1) * KERNEL_STACK_SIZE - 0x10; task_state_segments[i].ist4 = (size_t) stack_table[i] + (4 /*IST number */ - 1) * KERNEL_STACK_SIZE - 0x10; - gdt_set_gate(num+i*2, (unsigned long) (task_state_segments+i), sizeof(tss_t)-1, + gdt_set_gate(num+i*2, (unsigned long) (task_state_segments+i), sizeof(tss_t), GDT_FLAG_PRESENT | GDT_FLAG_TSS | GDT_FLAG_RING0, 0); } diff --git a/arch/x86/loader/CMakeLists.txt b/arch/x86/loader/CMakeLists.txt index b9ea11d7e..99bc4081a 100644 --- a/arch/x86/loader/CMakeLists.txt +++ b/arch/x86/loader/CMakeLists.txt @@ -17,14 +17,33 @@ target_include_directories(arch_x86_loader target_compile_options(arch_x86_loader PRIVATE -O2 -Wall -m64 -std=gnu99 -ffreestanding -mno-red-zone - -fstrength-reduce -fomit-frame-pointer -finline-functions) + -fomit-frame-pointer -fno-builtin -nostdlib -nostdinc -mno-sse -mno-avx -mno-mmx -mno-3dnow) -target_link_libraries(arch_x86_loader - arch_x86_loader_asm - "-T ${CMAKE_CURRENT_LIST_DIR}/link.ld" - "-z max-page-size=4096" - -Wl,--build-id=none # required because CMake links with gcc, not ld - -nostdlib -static) +include(CheckCCompilerFlag) +check_c_compiler_flag(-fstrength-reduce HAS_STRENGTH_REDUCE) +if (HAS_STRENGTH_REDUCE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrength-reduce") +endif() + +check_c_compiler_flag(-finline-functions HAS_INLINE_FUNCTIONS) +if (HAS_INLINE_FUNCTIONS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -finline-functions") +endif() + +set(CMAKE_LINKER_NAME ld CACHE STRING "Name of the binutils linker") +mark_as_advanced(CMAKE_LINKER_NAME) + +find_program(CMAKE_LINKER ${CMAKE_LINKER_NAME}) +mark_as_advanced(CMAKE_LINKER) + +if(NOT CMAKE_LINKER) + message(FATAL_ERROR "Could not find the GNU LD linker: ${CMAKE_LINKER_NAME}") +endif() + +set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_LINKER} -o ") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${CMAKE_CURRENT_LIST_DIR}/link.ld -z max-page-size=4096 --build-id=none -nostdlib -static") + +target_link_libraries(arch_x86_loader arch_x86_loader_asm) # tools/proxy looks for `ldhermit.elf` set_target_properties(arch_x86_loader PROPERTIES diff --git a/arch/x86/loader/include/ctype.h b/arch/x86/loader/include/ctype.h index c5aa3915b..597c6d286 100644 --- a/arch/x86/loader/include/ctype.h +++ b/arch/x86/loader/include/ctype.h @@ -25,7 +25,7 @@ */ #ifndef __CTYPE_H_ -#define __CYTPE_H_ +#define __CTYPE_H_ /** Returns true if the value of 'c' is an ASCII-charater */ static inline int isascii(int c) diff --git a/arch/x86/loader/page.c b/arch/x86/loader/page.c index 0cab29437..80c4cdedd 100644 --- a/arch/x86/loader/page.c +++ b/arch/x86/loader/page.c @@ -56,12 +56,6 @@ static size_t * const self[PAGE_LEVELS] = { (size_t *) 0xFFC00000, (size_t *) 0xFFFFF000 }; - -/** An other self-reference for page_map_copy() */ -static size_t * const other[PAGE_LEVELS] = { - (size_t *) 0xFF800000, - (size_t *) 0xFFFFE000 -}; #elif defined(CONFIG_X86_64) /** A self-reference enables direct access to all page tables */ static size_t* const self[PAGE_LEVELS] = { @@ -70,14 +64,6 @@ static size_t* const self[PAGE_LEVELS] = { (size_t *) 0xFFFFFFFFFFE00000, (size_t *) 0xFFFFFFFFFFFFF000 }; - -/** An other self-reference for page_map_copy() */ -static size_t * const other[PAGE_LEVELS] = { - (size_t *) 0xFFFFFF0000000000, - (size_t *) 0xFFFFFFFF80000000, - (size_t *) 0xFFFFFFFFFFC00000, - (size_t *) 0xFFFFFFFFFFFFE000 -}; #endif /** @brief Flush a specific page entry in TLB diff --git a/arch/x86/loader/uart.c b/arch/x86/loader/uart.c index 5d0599843..2437fd2ff 100644 --- a/arch/x86/loader/uart.c +++ b/arch/x86/loader/uart.c @@ -96,7 +96,7 @@ size_t uartport = 0; static inline unsigned char read_from_uart(uint32_t off) { - uint8_t c; + uint8_t c = 0; if (uartport) c = inportb(uartport + off); diff --git a/cmake/HermitCore-Configuration.cmake b/cmake/HermitCore-Configuration.cmake index bd5753eef..c38566f8c 100644 --- a/cmake/HermitCore-Configuration.cmake +++ b/cmake/HermitCore-Configuration.cmake @@ -1,4 +1,4 @@ -set(PACKAGE_VERSION "0.2.1" CACHE STRING +set(PACKAGE_VERSION "0.2.2" CACHE STRING "HermitCore current version") set(MAX_CORES "512" CACHE STRING diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index c460f96f6..330c16f5c 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -45,6 +45,8 @@ #include #include +#if USE_E1000 + #define RX_BUF_LEN (2048) #define TX_BUF_LEN (1792) @@ -603,3 +605,5 @@ oom: return ERR_MEM; } + +#endif diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index 08f0d886f..49ade1225 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -32,6 +32,8 @@ #include #include +#ifdef USE_E1000 + #define NUM_RX_DESCRIPTORS 64 #define NUM_TX_DESCRIPTORS 64 @@ -324,3 +326,5 @@ typedef struct e1000if { err_t e1000if_init(struct netif* netif); #endif + +#endif diff --git a/kernel/main.c b/kernel/main.c index d2fe61327..b5c0bf214 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -206,8 +206,10 @@ static int init_netifs(void) goto success; if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, rtl8139if_init, ethernet_input)) == ERR_OK) goto success; +#ifdef USE_E1000 if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, e1000if_init, ethernet_input)) == ERR_OK) goto success; +#endif LOG_ERROR("Unable to add the network interface: err = %d\n", err); diff --git a/lwip b/lwip index 51d48fe0c..c21d911aa 160000 --- a/lwip +++ b/lwip @@ -1 +1 @@ -Subproject commit 51d48fe0c67131da346c9ef280b2019c77f6e607 +Subproject commit c21d911aa4f178563dc102f595d1d97dd8471458 diff --git a/tests.sh b/tests.sh index 3cabbadbe..a4e8f0639 100755 --- a/tests.sh +++ b/tests.sh @@ -9,6 +9,8 @@ PROXY=build/local_prefix/opt/hermit/bin/proxy for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done +for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=2 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done + # test echo server at port 8000 HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 HERMIT_APP_PORT=8000 $PROXY $TDIR/tests/server & sleep 10 diff --git a/tools/uhyve.c b/tools/uhyve.c index da84a3276..64298e1bf 100644 --- a/tools/uhyve.c +++ b/tools/uhyve.c @@ -591,7 +591,7 @@ static void show_registers(int id, struct kvm_regs* regs, struct kvm_sregs* sreg fprintf(stderr, "\n"); } -static int print_registers(void) +static void print_registers(void) { struct kvm_regs regs; struct kvm_sregs sregs;