]> git.sur5r.net Git - freertos/commitdiff
RISC-V work in progress:
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 10 Sep 2018 20:50:05 +0000 (20:50 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 10 Sep 2018 20:50:05 +0000 (20:50 +0000)
    + Initialise task stack.
    + Successfully jump to start of first task.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2582 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c
FreeRTOS/Source/portable/GCC/RISC-V-RV32/portmacro.h

index 3e65c4f9b3603acf896fa0fe897db9073fb60cdf..4fab2fd6a7fae41127274187ffcc67a60e727d33 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * FreeRTOS Kernel V10.1.0\r
+ * FreeRTOS Kernel V10.1.1\r
  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
@@ -90,18 +90,116 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
        pxTopOfStack--;\r
        *pxTopOfStack = ( StackType_t ) pxCode; /* X1 */\r
        pxTopOfStack--;\r
-       *pxTopOfStack =\r
-\r
+//     *pxTopOfStack = ( StackType_t ) 2; /* Stack pointer is handled separately. */\r
+//     pxTopOfStack--;\r
+//     *pxTopOfStack = ( StackType_t ) 3; /* Global pointer is not manipulated. */\r
+//     pxTopOfStack--;\r
+//     *pxTopOfStack = ( StackType_t ) 4; /* Thread pointer is not manipulated. */\r
+//     pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 5;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 6;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 7;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 8;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 9;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) pvParameters;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 11;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 12;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 13;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 14;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 15;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 16;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 17;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 18;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 19;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 20;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 21;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 22;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 23;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 24;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 25;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 26;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 27;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 28;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 29;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 30;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) 31;\r
 \r
-               return pxTopOfStack;\r
+       return pxTopOfStack;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 BaseType_t xPortStartScheduler( void )\r
 {\r
+       __asm volatile\r
+       (\r
+               ".extern pxCurrentTCB                   \r\n"\r
+               "lw             sp, pxCurrentTCB                \r\n" /* Load pxCurrentTCB. */\r
+               "lw             sp, 0x00( sp )                  \r\n" /* Read sp from first TCB member. */\r
+               "lw             x31, 0( sp )                    \r\n" /* X31 */\r
+               "lw             x30, 4( sp )                    \r\n" /* X30 */\r
+               "lw             x29, 8( sp )                    \r\n" /* X29 */\r
+               "lw             x28, 12( sp )                   \r\n" /* X28 */\r
+               "lw             x27, 16( sp )                   \r\n" /* X27 */\r
+               "lw             x26, 20( sp )                   \r\n" /* X26 */\r
+               "lw             x25, 24( sp )                   \r\n" /* X25 */\r
+               "lw             x24, 28( sp )                   \r\n" /* X24 */\r
+               "lw             x23, 32( sp )                   \r\n" /* X23 */\r
+               "lw             x22, 36( sp )                   \r\n" /* X22 */\r
+               "lw             x21, 40( sp )                   \r\n" /* X21 */\r
+               "lw             x20, 44( sp )                   \r\n" /* X20 */\r
+               "lw             x19, 48( sp )                   \r\n" /* X19 */\r
+               "lw             x18, 52( sp )                   \r\n" /* X18 */\r
+               "lw             x17, 56( sp )                   \r\n" /* X17 */\r
+               "lw             x16, 60( sp )                   \r\n" /* X16 */\r
+               "lw             x15, 64( sp )                   \r\n" /* X15 */\r
+               "lw             x14, 68( sp )                   \r\n" /* X14 */\r
+               "lw             x13, 72( sp )                   \r\n" /* X13 */\r
+               "lw             x12, 76( sp )                   \r\n" /* X12 */\r
+               "lw             x11, 80( sp )                   \r\n" /* X11 */\r
+               "lw             x10, 84( sp )                   \r\n" /* X10 */\r
+               "lw             x9, 88( sp )                    \r\n" /* X9 */\r
+               "lw             x8, 92( sp )                    \r\n" /* X8 */\r
+               "lw             x7, 96( sp )                    \r\n" /* X7 */\r
+               "lw             x6, 100( sp )                   \r\n" /* X6 */\r
+               "lw             x5, 104( sp )                   \r\n" /* X5 */\r
+               "lw             x1, 108( sp )                   \r\n" /* X1 */\r
+               "csrs   mstatus, 8                              \r\n" /* Enable interrupts. */\r
+               "ret                                                            "\r
+       );\r
+\r
        /*Should not get here*/\r
        return pdFALSE;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+void vPortYield( void )\r
+{\r
+}\r
+\r
 \r
index bc151b7970201a0aaad961807e3bfcbdef341bc6..5d18ba34a0728cb17c2670003476d5c8cbe1c7d6 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * FreeRTOS Kernel V10.1.0\r
+ * FreeRTOS Kernel V10.1.1\r
  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
@@ -70,7 +70,8 @@ not need to be guarded with a critical section. */
 \r
 \r
 /* Scheduler utilities. */\r
-#define portYIELD()\r
+extern void vPortYield( void );\r
+#define portYIELD()                                    vPortYield()\r
 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYield()\r
 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )\r
 /*-----------------------------------------------------------*/\r