Changes in / [013b028:e67a82d]


Ignore:
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    r013b028 re67a82d  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 16 23:05:59 2020
    13 // Update Count     : 447
     12// Last Modified On : Thu Aug 20 23:43:59 2020
     13// Update Count     : 436
    1414//
    1515
     
    433433                args[nargs++] = "-Wl,--pop-state";
    434434                args[nargs++] = "-pthread";
    435                 #ifdef __x86_64__
     435                #if defined(  __x86_64__ ) || defined( __ARM_ARCH )
    436436                args[nargs++] = "-latomic";                                             // allow double-wide CAS
    437437                #endif // __x86_64__
  • libcfa/src/bits/locks.hfa

    r013b028 re67a82d  
    1010// Created On       : Tue Oct 31 15:14:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 13:03:19 2020
    13 // Update Count     : 11
     12// Last Modified On : Wed Aug 12 14:18:07 2020
     13// Update Count     : 13
    1414//
    1515
     
    2727
    2828// 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 )
    3230        #define Pause() __asm__ __volatile__ ( "pause" : : : )
    3331#elif defined( __ARM_ARCH )
    34         #define Pause() __asm__ __volatile__ ( "nop" : : : )
     32        #define Pause() __asm__ __volatile__ ( "YIELD" : : : )
    3533#else
    3634        #error unsupported architecture
  • libcfa/src/concurrency/invoke.c

    r013b028 re67a82d  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  9 16:37:42 2018
    13 // Update Count     : 5
     12// Last Modified On : Thu Aug 20 23:43:23 2020
     13// Update Count     : 31
    1414//
    1515
     
    114114
    115115        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 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
     116            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
    121121        };
    122122
     
    127127
    128128        fs->dummyReturn = NULL;
    129         fs->argument[0] = main;     // argument to invoke
    130         fs->argument[1] = this;     // argument to invoke
     129        fs->argument[0] = main;                                                         // argument to invoke
     130        fs->argument[1] = this;                                                         // argument to invoke
    131131        fs->rturn = invoke;
    132132
     
    134134
    135135        struct FakeStack {
    136                 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
     136                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
    143143
    144144        struct FakeStack *fs = (struct FakeStack *)cor->context.SP;
     
    146146        fs->dummyReturn = NULL;
    147147        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
    150150        fs->fixedRegisters[2] = invoke;
    151151
    152 #elif defined( __ARM_ARCH )
     152#elif defined( __ARM_ARCH_32 )
    153153#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)
    154154        // More details about the error:
     
    161161
    162162        struct FakeStack {
    163                 float fpRegs[16];                       // floating point registers
    164                 void *intRegs[9];                       // integer/pointer registers
    165                 void *arg[2];                           // placeholder for this pointer
     163                float fpRegs[16];                                                               // floating point registers
     164                void * intRegs[9];                                                              // integer/pointer registers
     165                void * arg[2];                                                                  // placeholder for this pointer
    166166        };
    167167
     
    175175        fs->arg[1] = invoke;
    176176
     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;
    177194#else
    178195        #error uknown hardware architecture
  • libcfa/src/concurrency/kernel.cfa

    r013b028 re67a82d  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  9 06:22:54 2020
    13 // Update Count     : 66
     12// Last Modified On : Fri Aug 14 15:23:00 2020
     13// Update Count     : 69
    1414//
    1515
     
    7474                )
    7575
    76 
    7776#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
    7894#else
    7995        #error unknown hardware architecture
  • libcfa/src/concurrency/kernel/fwd.hfa

    r013b028 re67a82d  
    9595        }
    9696
    97         #ifdef __ARM_ARCH
     97        #if 0 // def __ARM_ARCH
    9898                // function prototypes are only really used by these macros on ARM
    9999                void disable_global_interrupts();
  • libcfa/src/concurrency/kernel/startup.cfa

    r013b028 re67a82d  
    3333// Some assembly required
    3434#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        )
    4241#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        )
    5555#else
    5656        #error unknown hardware architecture
  • libcfa/src/concurrency/kernel_private.hfa

    r013b028 re67a82d  
    1010// Created On       : Mon Feb 13 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Nov 30 19:25:02 2019
    13 // Update Count     : 8
     12// Last Modified On : Wed Aug 12 08:21:33 2020
     13// Update Count     : 9
    1414//
    1515
     
    150150        while( __builtin_expect(__atomic_exchange_n(ll, (bool)true, __ATOMIC_SEQ_CST), false) ) {
    151151                while(__atomic_load_n(ll, (int)__ATOMIC_RELAXED))
    152                         asm volatile("pause");
     152                        Pause();
    153153        }
    154154        /* paranoid */ verify(*ll);
     
    204204        // Step 1 : make sure no writer are in the middle of the critical section
    205205        while(__atomic_load_n(&lock, (int)__ATOMIC_RELAXED))
    206                 asm volatile("pause");
     206                Pause();
    207207
    208208        // Fence needed because we don't want to start trying to acquire the lock
  • libcfa/src/concurrency/ready_queue.cfa

    r013b028 re67a82d  
    120120        __scheduler_lock_id_t * storage = (__scheduler_lock_id_t *)&data[n];
    121121        (*storage){ proc };
    122         while(true) {
     122        while() {
    123123                unsigned copy = n;
    124124                if( __atomic_load_n(&ready, __ATOMIC_RELAXED) == n
    125125                        && __atomic_compare_exchange_n(&ready, &copy, n + 1, true, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
    126126                        break;
    127                 asm volatile("pause");
     127                Pause();
    128128        }
    129129
  • libcfa/src/exception.c

    r013b028 re67a82d  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Jun 26 15:13:00 2017
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug 12 13:55:00 2020
    13 // Update Count     : 21
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Aug 20 23:45:45 2020
     13// Update Count     : 27
    1414//
    1515
     
    2121// Implementation of the secret header is hardware dependent.
    2222#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.
    2427#endif
    2528
     
    294297        abort();
    295298}
    296 
     299#if 0
    297300// This is our personality routine. For every stack frame annotated with
    298301// ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding.
     
    406409                                cur_ptr = read_uleb128(cur_ptr, &imatcher);
    407410
     411                                _Unwind_Word match_pos =
    408412#                               if defined( __x86_64 )
    409                                 _Unwind_Word match_pos = _Unwind_GetCFA(unwind_context) + 8;
     413                                    _Unwind_GetCFA(unwind_context) + 8;
    410414#                               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;
    412419#                               endif
    413420                                int (*matcher)(exception_t *) = *(int(**)(exception_t *))match_pos;
     
    600607
    601608#pragma GCC pop_options
     609#endif // 0
Note: See TracChangeset for help on using the changeset viewer.