]> granicus.if.org Git - esp-idf/commitdiff
Optimize xPortGetCoreID to 2-instruction inline assembly.
authorJeroen Domburg <git@j0h.nl>
Mon, 17 Oct 2016 10:09:15 +0000 (18:09 +0800)
committerJeroen Domburg <git@j0h.nl>
Mon, 17 Oct 2016 10:09:15 +0000 (18:09 +0800)
components/freertos/include/freertos/portable.h
components/freertos/include/freertos/xtensa_context.h
components/freertos/panic.c
components/freertos/portasm.S

index 4030ca0c03af4db3bc37f8928ab5d1e2187c5d64..58e6903664b824a26109d9310dc418e4159d7747 100644 (file)
@@ -192,8 +192,7 @@ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
 #endif
 
 /* Multi-core: get current core ID */
-int xPortGetCoreID( void );
-
+#define xPortGetCoreID() __extension__({int id; asm volatile("rsr.prid %0; extui %0,%0,13,1":"=r"(id)); id;})
 
 #ifdef __cplusplus
 }
index 3167c84726eb0a78d3d4a75eb9bbd3184c63d546..b748a0d1a7373d3de0b3b7f55ca231aa55f2a099 100644 (file)
@@ -322,12 +322,7 @@ STRUCT_END(XtSolFrame)
 #ifdef __ASSEMBLER__
        .macro getcoreid reg
        rsr.prid \reg
-       bbci \reg,1,1f
-       movi \reg,1
-       j 2f
-1:
-       movi \reg,0
-2:
+       extui \reg,\reg,13,1
        .endm
 #endif
 
index 94008673563de8c0ae82887a8a992f4a36774abc..6a87679d1344222d7a7db96f24aae4ea125bc698 100644 (file)
@@ -76,7 +76,6 @@ inline static void panicPutHex(int a) { }
 inline static void panicPutDec(int a) { }
 #endif
 
-int xPortGetCoreID();
 
 void  __attribute__((weak)) vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName ) {
        panicPutStr("***ERROR*** A stack overflow in task ");
index 65406b0b06a5ba78e1c6dc6ec628307cc7da4567..3a45b19a326339f18624deb612f5b15e799c3a84 100644 (file)
@@ -51,18 +51,6 @@ port_switch_flag:
 
     .text
 
-
-
-/* C function to get proc ID.*/
-       .global xPortGetCoreID
-       .type xPortGetCoreID,@function
-       .align 4
-xPortGetCoreID:
-       ENTRY(16)
-       getcoreid a2
-       RET(16)
-
-
 /*
 *******************************************************************************
 * _frxt_setup_switch