From e3ff2284df5315432d473a3ea11499ac88240543 Mon Sep 17 00:00:00 2001 From: tarberd Date: Thu, 19 Mar 2020 17:46:51 -0300 Subject: [PATCH 1/3] Fix missing escaping quotes on make debug. This fix enables other terminals to be used through the TERM variable. --- img/makefile | 6 +++--- makedefs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/img/makefile b/img/makefile index ba91610..f8703b0 100644 --- a/img/makefile +++ b/img/makefile @@ -82,17 +82,17 @@ endif debug: $(IMAGE) ifeq ($(NODES),1) $(EMULATOR)$(IMAGE) | $(TEE) $(OUTPUT) & - $(DEBUGGER) + $(TERM) '$(DEBUGGER)' else $(TERM) "$(EMULATOR)$(IMAGE) $(NETWORK) | $(TEE) $(OUTPUT) \ && $(TCPDUMP) $(APPLICATION).pcap > $(APPLICATION).net \ && read -p 'Press [Enter] key to close ...'" & - $(DEBUGGER) & + $(TERM) '$(DEBUGGER)' & sleep 2 $(TERM) "$(PEER_EMULATOR)$(PEER_IMAGE) $(PEER_NETWORK) | $(TEE) $(PEER_OUTPUT) \ && $(TCPDUMP) $(PEER).pcap > $(PEER).net \ && read -p 'Press [Enter] key to close ...'" & - $(PEER_DEBUGGER) & + $(TERM) '$(PEER_DEBUGGER)' & endif runall: FORCE diff --git a/makedefs b/makedefs index bce1403..58aef28 100644 --- a/makedefs +++ b/makedefs @@ -187,7 +187,7 @@ MACH_LD_FLAGS := $($(MACH)_LD_FLAGS) MACH_CODE_NAME := $($(MACH)_CODE_NAME) MACH_DATA_NAME := $($(MACH)_DATA_NAME) MACH_EMULATOR := $($(MACH)_EMULATOR) -MACH_DEBUGGER := $(TERM) $($(MACH)_DEBUGGER) -ex "target remote:1235" -ex "set confirm off" +MACH_DEBUGGER := $($(MACH)_DEBUGGER) -ex "target remote:1235" -ex "set confirm off" MACH_FLASHER := $($(MACH)_FLASHER) MACH_MAGIC := $($(MACH)_MAGIC) MACH_IMGSUFF := $($(MACH)_IMG_SUFFIX) From 758deba66e8001bb04f941947c3af6bd8c2c3984 Mon Sep 17 00:00:00 2001 From: tarberd Date: Fri, 3 Apr 2020 17:47:10 -0300 Subject: [PATCH 2/3] Fix preprocessor macro concatenation. Macro concatenation only worked on gcc, glang tool got pretty confused and changed the comments inside the macro to a single space, witch after some research I discovered it was the documented behaviour for a comment inside a macro and that gcc was doing the resolution wrong. --- include/system/config.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/system/config.h b/include/system/config.h index e75d5d0..5c4d1ad 100644 --- a/include/system/config.h +++ b/include/system/config.h @@ -49,9 +49,12 @@ namespace EPOS { } #endif -#define __HEADER_ARCH(X) -#define __HEADER_MACH(X) -#define __HEADER_MMOD(X) +#define __TOKEN_CONCATENATE_INDIRECTION(X, Y) X ## Y +#define __TOKEN_CONCATENATE(X, Y) __TOKEN_CONCATENATE_INDIRECTION(X, Y) + +#define __HEADER_ARCH(X) +#define __HEADER_MACH(X) +#define __HEADER_MMOD(X) #define __HEADER_TRAN(X) #define __APPL_TRAITS_T(X) <../app/X/X##_traits.h> #define __APPL_TRAITS(X) __APPL_TRAITS_T(X) From 22058c51df39cf43dca0a5633ff9d08b0f0c782b Mon Sep 17 00:00:00 2001 From: tarberd Date: Fri, 3 Apr 2020 17:51:25 -0300 Subject: [PATCH 3/3] Add support for cpp17 standant. --- include/architecture/armv7/armv7_cpu.h | 14 +++++++------- include/architecture/ia32/ia32_cpu.h | 10 +++++----- include/system/types.h | 5 ++++- makedefs | 2 +- src/machine/pc/pc_ic_entry.cc | 2 +- src/setup/setup_legacy_pc.cc | 8 ++++---- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/architecture/armv7/armv7_cpu.h b/include/architecture/armv7/armv7_cpu.h index b3fa054..b255067 100644 --- a/include/architecture/armv7/armv7_cpu.h +++ b/include/architecture/armv7/armv7_cpu.h @@ -58,8 +58,8 @@ class ARMv7: protected CPU_Common // Atomic operations template static T tsl(volatile T & lock) { - register T old; - register T one = 1; + T old; + T one = 1; ASM("1: ldrexb %0, [%1] \n" " strexb r3, %2, [%1] \n" " cmp r3, #0 \n" @@ -69,7 +69,7 @@ class ARMv7: protected CPU_Common template static T finc(volatile T & value) { - register T old; + T old; if(sizeof(T) == sizeof(Reg8)) ASM("1: ldrexb %0, [%1] \n" " add %0, #1 \n" @@ -93,7 +93,7 @@ class ARMv7: protected CPU_Common template static T fdec(volatile T & value) { - register T old; + T old; if(sizeof(T) == sizeof(Reg8)) ASM("1: ldrexb %0, [%1] \n" " sub %0, #1 \n" @@ -117,7 +117,7 @@ class ARMv7: protected CPU_Common template static T cas(volatile T & value, T compare, T replacement) { - register T old; + T old; if(sizeof(T) == sizeof(Reg8)) ASM("1: ldrexb %0, [%1] \n" " cmp %0, %2 \n" @@ -187,7 +187,7 @@ class ARMv7_M: public ARMv7 public: static Flags flags() { - register Reg32 value; + Reg32 value; ASM("mrs %0, xpsr" : "=r"(value) :); return value; } @@ -267,7 +267,7 @@ class ARMv7_A: public ARMv7 public: static Flags flags() { - register Reg32 value; + Reg32 value; ASM("mrs %0, cpsr_all" : "=r"(value) :); return value; } diff --git a/include/architecture/ia32/ia32_cpu.h b/include/architecture/ia32/ia32_cpu.h index ce06acf..e198530 100644 --- a/include/architecture/ia32/ia32_cpu.h +++ b/include/architecture/ia32/ia32_cpu.h @@ -367,21 +367,21 @@ class CPU: private CPU_Common template static T tsl(volatile T & lock) { - register T old = 1; + T old = 1; ASM("lock xchg %0, %2" : "=a"(old) : "a"(old), "m"(lock) : "memory"); return old; } template static T finc(volatile T & value) { - register T old = 1; + T old = 1; ASM("lock xadd %0, %2" : "=a"(old) : "a"(old), "m"(value) : "memory"); return old; } template static T fdec(volatile T & value) { - register T old = -1; + T old = -1; ASM("lock xadd %0, %2" : "=a"(old) : "a"(old), "m"(value) : "memory"); return old; } @@ -579,12 +579,12 @@ class CPU: private CPU_Common } static int bsf(Log_Addr addr) { - register unsigned int pos; + unsigned int pos; ASM("bsf %1,%0" : "=a"(pos) : "m"(addr) : ); return pos; } static int bsr(Log_Addr addr) { - register int pos = -1; + int pos = -1; ASM("bsr %1, %0" : "=a"(pos) : "m"(addr) : ); return pos; } diff --git a/include/system/types.h b/include/system/types.h index bd1da97..e17ffec 100644 --- a/include/system/types.h +++ b/include/system/types.h @@ -1,10 +1,13 @@ // EPOS Common Types and Type Management System -typedef __SIZE_TYPE__ size_t; #ifndef __types_h #define __types_h +#include + +typedef __SIZE_TYPE__ size_t; + __BEGIN_API // Memory allocators diff --git a/makedefs b/makedefs index 58aef28..62b62d1 100644 --- a/makedefs +++ b/makedefs @@ -181,7 +181,7 @@ atmega_DATA_NAME := .data atmega_IMG_SUFFIX := .hex MACH_CC_FLAGS := $($(MACH)_CC_FLAGS) -O -nostdinc -Wno-builtin-declaration-mismatch -Wno-array-bounds -fno-stack-protector -fno-pie -MACH_CXX_FLAGS := $($(MACH)_CC_FLAGS) -O -std=c++14 -nostdinc --no-exceptions --no-rtti --no-use-cxa-atexit --no-asynchronous-unwind-tables -fno-stack-protector -fdata-sections -ffunction-sections -Wall -Werror -Wno-builtin-declaration-mismatch -Wno-array-bounds -Wno-attribute-alias -Wno-placement-new -Wno-class-memaccess -fno-pie +MACH_CXX_FLAGS := $($(MACH)_CC_FLAGS) -O -std=c++17 -nostdinc --no-exceptions --no-rtti --no-use-cxa-atexit --no-asynchronous-unwind-tables -fno-stack-protector -fdata-sections -ffunction-sections -Wall -Werror -Wno-builtin-declaration-mismatch -Wno-array-bounds -Wno-attribute-alias -Wno-placement-new -Wno-class-memaccess -fno-pie MACH_AS_FLAGS := $($(MACH)_AS_FLAGS) MACH_LD_FLAGS := $($(MACH)_LD_FLAGS) MACH_CODE_NAME := $($(MACH)_CODE_NAME) diff --git a/src/machine/pc/pc_ic_entry.cc b/src/machine/pc/pc_ic_entry.cc index dac727d..ca522e2 100644 --- a/src/machine/pc/pc_ic_entry.cc +++ b/src/machine/pc/pc_ic_entry.cc @@ -806,7 +806,7 @@ void IC::exc_not(Reg32 eip, Reg32 cs, Reg32 eflags, Reg32 error) void IC::exc_pf(Reg32 eip, Reg32 cs, Reg32 eflags, Reg32 error) { - register Reg32 fr = CPU::fr(); + Reg32 fr = CPU::fr(); if(CPU::cr2() == reinterpret_cast(&__exit)) { db(INF) << "IC::exc_pf[address=" << reinterpret_cast(CPU::cr2()) << "]: final return!" << endl; diff --git a/src/setup/setup_legacy_pc.cc b/src/setup/setup_legacy_pc.cc index 6be51b0..b0aefdf 100644 --- a/src/setup/setup_legacy_pc.cc +++ b/src/setup/setup_legacy_pc.cc @@ -880,7 +880,7 @@ void PC_Setup::call_next() int cpu_id = CPU::id(); // Check for next stage and obtain the entry point - register Log_Addr ip; + Log_Addr ip; if(si->lm.has_ini) { db(TRC) << "Executing system's global constructors ..." << endl; reinterpret_cast((void *)si->lm.sys_entry)(); @@ -894,7 +894,7 @@ void PC_Setup::call_next() // Bootstrap CPU uses a full stack, while non-boot get reduced ones // The 2 integers on the stacks are room for return addresses used // in some EPOS architectures - register Log_Addr sp = SYS_STACK + Traits::STACK_SIZE * (cpu_id + 1) - 2 * sizeof(int); + Log_Addr sp = SYS_STACK + Traits::STACK_SIZE * (cpu_id + 1) - 2 * sizeof(int); db(TRC) << "PC_Setup::call_next(ip=" << ip << ",sp=" << sp << ") => "; if(si->lm.has_ini) @@ -1110,7 +1110,7 @@ void _start() // Move the boot image to after SETUP, so there will be nothing else below SETUP to be preserved // SETUP code + data + 1 stack per CPU - register char * dst = MMU::align_page(entry + size + Traits::CPUS * sizeof(MMU::Page)); + char * dst = MMU::align_page(entry + size + Traits::CPUS * sizeof(MMU::Page)); memcpy(dst, bi, si->bm.img_size); // Passes a pointer to the just allocated stack pool to other CPUs @@ -1159,7 +1159,7 @@ void _start() // SP = "entry" + "size" + #CPU * sizeof(Page) // Be careful: we'll loose our old stack now, so everything we still // need to reach PC_Setup() must be in regs or globals! - register char * sp = const_cast(Stacks) - sizeof(MMU::Page) * APIC::id(); + char * sp = const_cast(Stacks) - sizeof(MMU::Page) * APIC::id(); ASM("movl %0, %%esp" : : "r" (sp)); // Pass the boot image to SETUP