Changes in / [013b028:e67a82d]
- Files:
-
- 9 edited
-
driver/cfa.cc (modified) (2 diffs)
-
libcfa/src/bits/locks.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/invoke.c (modified) (7 diffs)
-
libcfa/src/concurrency/kernel.cfa (modified) (2 diffs)
-
libcfa/src/concurrency/kernel/fwd.hfa (modified) (1 diff)
-
libcfa/src/concurrency/kernel/startup.cfa (modified) (1 diff)
-
libcfa/src/concurrency/kernel_private.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/ready_queue.cfa (modified) (1 diff)
-
libcfa/src/exception.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
driver/cfa.cc
r013b028 re67a82d 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 16 23:05:59 202013 // Update Count : 4 4712 // Last Modified On : Thu Aug 20 23:43:59 2020 13 // Update Count : 436 14 14 // 15 15 … … 433 433 args[nargs++] = "-Wl,--pop-state"; 434 434 args[nargs++] = "-pthread"; 435 #if def __x86_64__435 #if defined( __x86_64__ ) || defined( __ARM_ARCH ) 436 436 args[nargs++] = "-latomic"; // allow double-wide CAS 437 437 #endif // __x86_64__ -
libcfa/src/bits/locks.hfa
r013b028 re67a82d 10 10 // Created On : Tue Oct 31 15:14:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:19202013 // Update Count : 1 112 // Last Modified On : Wed Aug 12 14:18:07 2020 13 // Update Count : 13 14 14 // 15 15 … … 27 27 28 28 // pause to prevent excess processor bus usage 29 #if defined( __sparc ) 30 #define Pause() __asm__ __volatile__ ( "rd %ccr,%g0" ) 31 #elif defined( __i386 ) || defined( __x86_64 ) 29 #if defined( __i386 ) || defined( __x86_64 ) 32 30 #define Pause() __asm__ __volatile__ ( "pause" : : : ) 33 31 #elif defined( __ARM_ARCH ) 34 #define Pause() __asm__ __volatile__ ( " nop" : : : )32 #define Pause() __asm__ __volatile__ ( "YIELD" : : : ) 35 33 #else 36 34 #error unsupported architecture -
libcfa/src/concurrency/invoke.c
r013b028 re67a82d 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 9 16:37:42 201813 // Update Count : 512 // Last Modified On : Thu Aug 20 23:43:23 2020 13 // Update Count : 31 14 14 // 15 15 … … 114 114 115 115 struct FakeStack { 116 void *fixedRegisters[3]; // fixed registers ebx, edi, esi (popped on 1st uSwitch, values unimportant)117 void *rturn; // where to go on return from uSwitch118 void *dummyReturn; // fake return compiler would have pushed on call to uInvoke119 void *argument[3]; // for 16-byte ABI, 16-byte alignment starts here120 void *padding; // padding to force 16-byte alignment, as "base" is 16-byte aligned116 void *fixedRegisters[3]; // fixed registers ebx, edi, esi (popped on 1st uSwitch, values unimportant) 117 void *rturn; // where to go on return from uSwitch 118 void *dummyReturn; // fake return compiler would have pushed on call to uInvoke 119 void *argument[3]; // for 16-byte ABI, 16-byte alignment starts here 120 void *padding; // padding to force 16-byte alignment, as "base" is 16-byte aligned 121 121 }; 122 122 … … 127 127 128 128 fs->dummyReturn = NULL; 129 fs->argument[0] = main; // argument to invoke130 fs->argument[1] = this; // argument to invoke129 fs->argument[0] = main; // argument to invoke 130 fs->argument[1] = this; // argument to invoke 131 131 fs->rturn = invoke; 132 132 … … 134 134 135 135 struct FakeStack { 136 void *fixedRegisters[5]; // fixed registers rbx, r12, r13, r14, r15137 void *rturn; // where to go on return from uSwitch138 void *dummyReturn; // NULL return address to provide proper alignment139 }; 140 141 cor->context.SP = (char *)stack->base - sizeof( struct FakeStack ); 142 cor->context.FP = NULL; // terminate stack with NULL fp136 void *fixedRegisters[5]; // fixed registers rbx, r12, r13, r14, r15 137 void *rturn; // where to go on return from uSwitch 138 void *dummyReturn; // NULL return address to provide proper alignment 139 }; 140 141 cor->context.SP = (char *)stack->base - sizeof( struct FakeStack ); 142 cor->context.FP = NULL; // terminate stack with NULL fp 143 143 144 144 struct FakeStack *fs = (struct FakeStack *)cor->context.SP; … … 146 146 fs->dummyReturn = NULL; 147 147 fs->rturn = __cfactx_invoke_stub; 148 fs->fixedRegisters[0] = main; 149 fs->fixedRegisters[1] = this; 148 fs->fixedRegisters[0] = main; // argument to invoke 149 fs->fixedRegisters[1] = this; // argument to invoke 150 150 fs->fixedRegisters[2] = invoke; 151 151 152 #elif defined( __ARM_ARCH )152 #elif defined( __ARM_ARCH_32 ) 153 153 #error ARM needs to be upgrade to use two parameters like X86/X64 (A.K.A. : I broke this and do not know how to fix it) 154 154 // More details about the error: … … 161 161 162 162 struct FakeStack { 163 float fpRegs[16]; // floating point registers164 void * intRegs[9];// integer/pointer registers165 void * arg[2];// placeholder for this pointer163 float fpRegs[16]; // floating point registers 164 void * intRegs[9]; // integer/pointer registers 165 void * arg[2]; // placeholder for this pointer 166 166 }; 167 167 … … 175 175 fs->arg[1] = invoke; 176 176 177 #elif defined( __ARM_ARCH ) 178 struct FakeStack { 179 void * intRegs[12]; // x19-x30 integer registers 180 double fpRegs[8]; // v8-v15 floating point 181 }; 182 183 cor->context.SP = (char *)stack->base - sizeof( struct FakeStack ); 184 cor->context.FP = NULL; 185 186 struct FakeStack *fs = (struct FakeStack *)cor->context.SP; 187 188 fs->intRegs[0] = main; // argument to invoke x19 => x0 189 fs->intRegs[1] = this; // argument to invoke x20 => x1 190 fs->intRegs[2] = invoke; 191 //for ( intptr_t i = 3; i < 12; i += 1 ) fs->intRegs[i] = (void *)i; 192 fs->intRegs[11] = __cfactx_invoke_stub; // link register x30 => ret moves to pc 193 //for ( int i = 0; i < 8; i += 1 ) fs->fpRegs[i] = i + 12; 177 194 #else 178 195 #error uknown hardware architecture -
libcfa/src/concurrency/kernel.cfa
r013b028 re67a82d 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 9 06:22:54202013 // Update Count : 6 612 // Last Modified On : Fri Aug 14 15:23:00 2020 13 // Update Count : 69 14 14 // 15 15 … … 74 74 ) 75 75 76 77 76 #elif defined( __ARM_ARCH ) 77 #define __x87_store \ 78 uint32_t __fpcntl[2]; \ 79 __asm__ volatile ( \ 80 "mrs x9, FPCR\n" \ 81 "mrs x10, FPSR\n" \ 82 "stp x9, x10, %0\n" \ 83 : "=m" (__fpcntl) : : "x9", "x10" \ 84 ) 85 86 #define __x87_load \ 87 __asm__ volatile ( \ 88 "ldp x9, x10, %0\n" \ 89 "msr FPSR, x10\n" \ 90 "msr FPCR, x9\n" \ 91 : "=m" (__fpcntl) : : "x9", "x10" \ 92 ) 93 78 94 #else 79 95 #error unknown hardware architecture -
libcfa/src/concurrency/kernel/fwd.hfa
r013b028 re67a82d 95 95 } 96 96 97 #if def __ARM_ARCH97 #if 0 // def __ARM_ARCH 98 98 // function prototypes are only really used by these macros on ARM 99 99 void disable_global_interrupts(); -
libcfa/src/concurrency/kernel/startup.cfa
r013b028 re67a82d 33 33 // Some assembly required 34 34 #if defined( __i386 ) 35 #define CtxGet( ctx ) \ 36 __asm__ volatile ( \ 37 "movl %%esp,%0\n"\ 38 "movl %%ebp,%1\n"\ 39 : "=rm" (ctx.SP),\ 40 "=rm" (ctx.FP) \ 41 ) 35 #define CtxGet( ctx ) __asm__ volatile ( \ 36 "movl %%esp,%0\n" \ 37 "movl %%ebp,%1\n" \ 38 : "=rm" (ctx.SP), \ 39 "=rm" (ctx.FP) \ 40 ) 42 41 #elif defined( __x86_64 ) 43 #define CtxGet( ctx ) \ 44 __asm__ volatile ( \ 45 "movq %%rsp,%0\n"\ 46 "movq %%rbp,%1\n"\ 47 : "=rm" (ctx.SP),\ 48 "=rm" (ctx.FP) \ 49 ) 50 #elif defined( __ARM_ARCH ) 51 #define CtxGet( ctx ) __asm__ ( \ 52 "mov %0,%%sp\n" \ 53 "mov %1,%%r11\n" \ 54 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 42 #define CtxGet( ctx ) __asm__ volatile ( \ 43 "movq %%rsp,%0\n" \ 44 "movq %%rbp,%1\n" \ 45 : "=rm" (ctx.SP), \ 46 "=rm" (ctx.FP) \ 47 ) 48 #elif defined( __aarch64__ ) 49 #define CtxGet( ctx ) __asm__ volatile ( \ 50 "mov %0, sp\n" \ 51 "mov %1, fp\n" \ 52 : "=rm" (ctx.SP), \ 53 "=rm" (ctx.FP) \ 54 ) 55 55 #else 56 56 #error unknown hardware architecture -
libcfa/src/concurrency/kernel_private.hfa
r013b028 re67a82d 10 10 // Created On : Mon Feb 13 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Nov 30 19:25:02 201913 // Update Count : 812 // Last Modified On : Wed Aug 12 08:21:33 2020 13 // Update Count : 9 14 14 // 15 15 … … 150 150 while( __builtin_expect(__atomic_exchange_n(ll, (bool)true, __ATOMIC_SEQ_CST), false) ) { 151 151 while(__atomic_load_n(ll, (int)__ATOMIC_RELAXED)) 152 asm volatile("pause");152 Pause(); 153 153 } 154 154 /* paranoid */ verify(*ll); … … 204 204 // Step 1 : make sure no writer are in the middle of the critical section 205 205 while(__atomic_load_n(&lock, (int)__ATOMIC_RELAXED)) 206 asm volatile("pause");206 Pause(); 207 207 208 208 // Fence needed because we don't want to start trying to acquire the lock -
libcfa/src/concurrency/ready_queue.cfa
r013b028 re67a82d 120 120 __scheduler_lock_id_t * storage = (__scheduler_lock_id_t *)&data[n]; 121 121 (*storage){ proc }; 122 while( true) {122 while() { 123 123 unsigned copy = n; 124 124 if( __atomic_load_n(&ready, __ATOMIC_RELAXED) == n 125 125 && __atomic_compare_exchange_n(&ready, ©, n + 1, true, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) 126 126 break; 127 asm volatile("pause");127 Pause(); 128 128 } 129 129 -
libcfa/src/exception.c
r013b028 re67a82d 9 9 // Author : Andrew Beach 10 10 // Created On : Mon Jun 26 15:13:00 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 12 13:55:00202013 // Update Count : 2 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 20 23:45:45 2020 13 // Update Count : 27 14 14 // 15 15 … … 21 21 // Implementation of the secret header is hardware dependent. 22 22 #if !( defined( __x86_64 ) || defined( __i386 ) ) 23 #error Exception Handling: No known architecture detected. 23 #elif defined( __ARM_ARCH ) 24 #warning FIX ME: check if anything needed for ARM 25 #else 26 #warning Exception Handling: No known architecture detected. 24 27 #endif 25 28 … … 294 297 abort(); 295 298 } 296 299 #if 0 297 300 // This is our personality routine. For every stack frame annotated with 298 301 // ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding. … … 406 409 cur_ptr = read_uleb128(cur_ptr, &imatcher); 407 410 411 _Unwind_Word match_pos = 408 412 # if defined( __x86_64 ) 409 _Unwind_Word match_pos =_Unwind_GetCFA(unwind_context) + 8;413 _Unwind_GetCFA(unwind_context) + 8; 410 414 # elif defined( __i386 ) 411 _Unwind_Word match_pos = _Unwind_GetCFA(unwind_context) + 24; 415 _Unwind_GetCFA(unwind_context) + 24; 416 # elif defined( __ARM_ARCH ) 417 # warning FIX ME: check if anything needed for ARM 418 42; 412 419 # endif 413 420 int (*matcher)(exception_t *) = *(int(**)(exception_t *))match_pos; … … 600 607 601 608 #pragma GCC pop_options 609 #endif // 0
Note:
See TracChangeset
for help on using the changeset viewer.