]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/CORTUS_APS3/portmacro.h
Roll up the minor changes checked into svn since V10.0.0 into new V10.0.1 ready for...
[freertos] / FreeRTOS / Source / portable / GCC / CORTUS_APS3 / portmacro.h
1 /*\r
2  * FreeRTOS Kernel V10.0.1\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 #ifndef PORTMACRO_H\r
29 #define PORTMACRO_H\r
30 \r
31 #ifdef __cplusplus\r
32 extern "C" {\r
33 #endif\r
34 \r
35 #include <machine/cpu.h>\r
36 \r
37 /*-----------------------------------------------------------\r
38  * Port specific definitions.\r
39  *\r
40  * The settings in this file configure FreeRTOS correctly for the\r
41  * given hardware and compiler.\r
42  *\r
43  * These settings should not be altered.\r
44  *-----------------------------------------------------------\r
45  */\r
46 \r
47 /* Type definitions. */\r
48 #define portCHAR                char\r
49 #define portFLOAT               float\r
50 #define portDOUBLE              double\r
51 #define portLONG                long\r
52 #define portSHORT               short\r
53 #define portSTACK_TYPE  uint32_t\r
54 #define portBASE_TYPE   long\r
55 \r
56 typedef portSTACK_TYPE StackType_t;\r
57 typedef long BaseType_t;\r
58 typedef unsigned long UBaseType_t;\r
59 \r
60 #if( configUSE_16_BIT_TICKS == 1 )\r
61         typedef uint16_t TickType_t;\r
62         #define portMAX_DELAY ( TickType_t ) 0xffff\r
63 #else\r
64         typedef uint32_t TickType_t;\r
65         #define portMAX_DELAY ( TickType_t ) 0xffffffffUL\r
66 #endif\r
67 /*-----------------------------------------------------------*/\r
68 \r
69 /* Architecture specifics. */\r
70 #define portSTACK_GROWTH                                                        ( -1 )\r
71 #define portTICK_PERIOD_MS                                                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
72 #define portBYTE_ALIGNMENT                                                      4\r
73 #define portNOP()                                                                       __asm__ volatile ( "mov r0, r0" )\r
74 #define portCRITICAL_NESTING_IN_TCB                                     1\r
75 #define portIRQ_TRAP_YIELD                                                      31\r
76 /*-----------------------------------------------------------*/\r
77 \r
78 /* Task utilities. */\r
79 \r
80 extern void vPortYield( void );\r
81 \r
82 /*---------------------------------------------------------------------------*/\r
83 \r
84 #define portYIELD()             asm __volatile__( " trap #%0 "::"i"(portIRQ_TRAP_YIELD):"memory")\r
85 /*---------------------------------------------------------------------------*/\r
86 \r
87 extern void vTaskEnterCritical( void );\r
88 extern void vTaskExitCritical( void );\r
89 #define portENTER_CRITICAL()            vTaskEnterCritical()\r
90 #define portEXIT_CRITICAL()                     vTaskExitCritical()\r
91 /*---------------------------------------------------------------------------*/\r
92 \r
93 /* Critical section management. */\r
94 #define portDISABLE_INTERRUPTS()        cpu_int_disable()\r
95 #define portENABLE_INTERRUPTS()         cpu_int_enable()\r
96 \r
97 /*---------------------------------------------------------------------------*/\r
98 \r
99 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if( xHigherPriorityTaskWoken != pdFALSE ) vTaskSwitchContext()\r
100 \r
101 /*---------------------------------------------------------------------------*/\r
102 \r
103 #define portSAVE_CONTEXT()                              \\r
104         asm __volatile__                                                                                                                                                                                                \\r
105         (                                                                                                                                                                                                                               \\r
106                 "sub    r1, #68                                 \n" /* Make space on the stack for the context. */                                                      \\r
107                 "std    r2, [r1] +      0                       \n"                                                                                                                                                     \\r
108                 "stq    r4, [r1] +      8                       \n"                                                                                                                                                     \\r
109                 "stq    r8, [r1] +      24                      \n"                                                                                                                                                     \\r
110                 "stq    r12, [r1] +     40                      \n"                                                                                                                                                     \\r
111                 "mov    r6, rtt                                 \n"                                                                                                                                                     \\r
112                 "mov    r7, psr                                 \n"                                                                                                                                                     \\r
113                 "std    r6, [r1] +      56                      \n"                                                                                                                                                     \\r
114                 "movhi  r2, #16384                              \n"     /* Set the pointer to the IC. */                                                                                \\r
115                 "ldub   r3, [r2] + 2                    \n"     /* Load the current interrupt mask. */                                                                  \\r
116                 "st             r3, [r1]+ 64                    \n"     /* Store the interrupt mask on the stack. */                                                    \\r
117                 "ld             r2, [r0]+short(pxCurrentTCB)    \n"     /* Load the pointer to the TCB. */                                                              \\r
118                 "st             r1, [r2]                                \n"     /* Save the stack pointer into the TCB. */                                                              \\r
119                 "mov    r14, r1                                 \n"     /* Compiler expects r14 to be set to the function stack. */                             \\r
120         );\r
121 /*---------------------------------------------------------------------------*/\r
122 \r
123 #define portRESTORE_CONTEXT()                                                                                                                                                                           \\r
124         asm __volatile__(                                                                                                                                                                                               \\r
125                 "ld             r2, [r0]+short(pxCurrentTCB)    \n"     /* Load the TCB to find the stack pointer and context. */               \\r
126                 "ld             r1, [r2]                                \n"                                                                                                                                                     \\r
127                 "movhi  r2, #16384                              \n"     /* Set the pointer to the IC. */                                                                                \\r
128                 "ld             r3, [r1] + 64                   \n"     /* Load the previous interrupt mask. */                                                                 \\r
129                 "stb    r3, [r2] + 2                    \n"     /* Set the current interrupt mask to be the previous. */                                \\r
130                 "ldd    r6, [r1] + 56                   \n"     /* Restore context. */                                                                                                  \\r
131                 "mov    rtt, r6                                 \n"                                                                                                                                                     \\r
132                 "mov    psr, r7                                 \n"                                                                                                                                                     \\r
133                 "ldd    r2, [r1] + 0                    \n"                                                                                                                                                     \\r
134                 "ldq    r4, [r1] +      8                       \n"                                                                                                                                                     \\r
135                 "ldq    r8, [r1] +      24                      \n"                                                                                                                                                     \\r
136                 "ldq    r12, [r1] +     40                      \n"                                                                                                                                                     \\r
137                 "add    r1, #68                                 \n"                                                                                                                                                     \\r
138                 "rti                                                    \n"                                                                                                                                                     \\r
139          );\r
140 \r
141 /*---------------------------------------------------------------------------*/\r
142 \r
143 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
144 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
145 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
146 /*---------------------------------------------------------------------------*/\r
147 \r
148 #ifdef __cplusplus\r
149 }\r
150 #endif\r
151 \r
152 #endif /* PORTMACRO_H */\r