]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c
Fix some build issues in older kernel demo projects.
[freertos] / FreeRTOS / Source / portable / GCC / RISC-V-RV32 / port.c
1 /*\r
2  * FreeRTOS Kernel V10.1.0\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /*-----------------------------------------------------------\r
29  * Implementation of functions defined in portable.h for the RISC-V RV32 port.\r
30  *----------------------------------------------------------*/\r
31 \r
32 /* Scheduler includes. */\r
33 #include "FreeRTOS.h"\r
34 #include "task.h"\r
35 #include "portmacro.h"\r
36 \r
37 /*\r
38  * Setup the timer to generate the tick interrupts.  The implementation in this\r
39  * file is weak to allow application writers to change the timer used to\r
40  * generate the tick interrupt.\r
41  */\r
42 void vPortSetupTimerInterrupt( void );\r
43 \r
44 /*\r
45  * Used to catch tasks that attempt to return from their implementing function.\r
46  */\r
47 static void prvTaskExitError( void );\r
48 \r
49 /*-----------------------------------------------------------*/\r
50 \r
51 void prvTaskExitError( void )\r
52 {\r
53 volatile uint32_t ulx = 0;\r
54 \r
55         /* A function that implements a task must not exit or attempt to return to\r
56         its caller as there is nothing to return to.  If a task wants to exit it\r
57         should instead call vTaskDelete( NULL ).\r
58 \r
59         Artificially force an assert() to be triggered if configASSERT() is\r
60         defined, then stop here so application writers can catch the error. */\r
61         configASSERT( ulx == ~0UL );\r
62         portDISABLE_INTERRUPTS();\r
63         for( ;; );\r
64 }\r
65 /*-----------------------------------------------------------*/\r
66 \r
67 /*\r
68  * See header file for description.\r
69  */\r
70 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
71 {\r
72         /*\r
73            X1 to X31 integer registers for the 'I' profile, X1 to X15 for the 'E' profile.\r
74 \r
75                 Register        ABI Name                Description                                     Saver\r
76                 x0                      zero                    Hard-wired zero                                 -\r
77                 x1                      ra                              Return address                                  Caller\r
78                 x2                      sp                              Stack pointer                                   Callee\r
79                 x3                      gp                              Global pointer                                  -\r
80                 x4                      tp                              Thread pointer                                  -\r
81                 x5-7            t0-2                    Temporaries                                     Caller\r
82                 x8                      s0/fp                   Saved register/Frame pointer    Callee\r
83                 x9                      s1                              Saved register                                  Callee\r
84                 x10-11          a0-1                    Function Arguments/return values Caller\r
85                 x12-17          a2-7                    Function arguments                              Caller\r
86                 x18-27          s2-11                   Saved registers                                 Callee\r
87                 x28-31          t3-6                    Temporaries                                     Caller\r
88         */\r
89 \r
90         pxTopOfStack--;\r
91         *pxTopOfStack = ( StackType_t ) pxCode; /* X1 */\r
92         pxTopOfStack--;\r
93         *pxTopOfStack =\r
94 \r
95 \r
96                 return pxTopOfStack;\r
97 }\r
98 /*-----------------------------------------------------------*/\r
99 \r
100 BaseType_t xPortStartScheduler( void )\r
101 {\r
102         /*Should not get here*/\r
103         return pdFALSE;\r
104 }\r
105 /*-----------------------------------------------------------*/\r
106 \r
107 \r