Prusa MINI Firmware overview
portable.h
Go to the documentation of this file.
1 /*
2  FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3  All rights reserved
4 
5  VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6 
7  This file is part of the FreeRTOS distribution.
8 
9  FreeRTOS is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License (version 2) as published by the
11  Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12 
13  ***************************************************************************
14  >>! NOTE: The modification to the GPL is included to allow you to !<<
15  >>! distribute a combined work that includes FreeRTOS without being !<<
16  >>! obliged to provide the source code for proprietary components !<<
17  >>! outside of the FreeRTOS kernel. !<<
18  ***************************************************************************
19 
20  FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. Full license text is available on the following
23  link: http://www.freertos.org/a00114.html
24 
25  ***************************************************************************
26  * *
27  * FreeRTOS provides completely free yet professionally developed, *
28  * robust, strictly quality controlled, supported, and cross *
29  * platform software that is more than just the market leader, it *
30  * is the industry's de facto standard. *
31  * *
32  * Help yourself get started quickly while simultaneously helping *
33  * to support the FreeRTOS project by purchasing a FreeRTOS *
34  * tutorial book, reference manual, or both: *
35  * http://www.FreeRTOS.org/Documentation *
36  * *
37  ***************************************************************************
38 
39  http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
40  the FAQ page "My application does not run, what could be wrong?". Have you
41  defined configASSERT()?
42 
43  http://www.FreeRTOS.org/support - In return for receiving this top quality
44  embedded software for free we request you assist our global community by
45  participating in the support forum.
46 
47  http://www.FreeRTOS.org/training - Investing in training allows your team to
48  be as productive as possible as early as possible. Now you can receive
49  FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50  Ltd, and the world's leading authority on the world's leading RTOS.
51 
52  http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53  including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54  compatible FAT file system, and our tiny thread aware UDP/IP stack.
55 
56  http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57  Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58 
59  http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60  Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
61  licenses offer ticketed support, indemnification and commercial middleware.
62 
63  http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64  engineered and independently SIL3 certified version for use in safety and
65  mission critical applications that require provable dependability.
66 
67  1 tab == 4 spaces!
68 */
69 
70 /*-----------------------------------------------------------
71  * Portable layer API. Each function must be defined for each port.
72  *----------------------------------------------------------*/
73 
74 #ifndef PORTABLE_H
75 #define PORTABLE_H
76 
77 /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
78 pre-processor definition was used to ensure the pre-processor found the correct
79 portmacro.h file for the port being used. That scheme was deprecated in favour
80 of setting the compiler's include path such that it found the correct
81 portmacro.h file - removing the need for the constant and allowing the
82 portmacro.h file to be located anywhere in relation to the port being used.
83 Purely for reasons of backward compatibility the old method is still valid, but
84 to make it clear that new projects should not use it, support for the port
85 specific constants has been moved into the deprecated_definitions.h header
86 file. */
87 #include "deprecated_definitions.h"
88 
89 /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
90 did not result in a portmacro.h header file being included - and it should be
91 included here. In this case the path to the correct portmacro.h header file
92 must be set in the compiler's include path. */
93 #ifndef portENTER_CRITICAL
94  #include "portmacro.h"
95 #endif
96 
97 #if portBYTE_ALIGNMENT == 32
98  #define portBYTE_ALIGNMENT_MASK ( 0x001f )
99 #endif
100 
101 #if portBYTE_ALIGNMENT == 16
102  #define portBYTE_ALIGNMENT_MASK ( 0x000f )
103 #endif
104 
105 #if portBYTE_ALIGNMENT == 8
106  #define portBYTE_ALIGNMENT_MASK ( 0x0007 )
107 #endif
108 
109 #if portBYTE_ALIGNMENT == 4
110  #define portBYTE_ALIGNMENT_MASK ( 0x0003 )
111 #endif
112 
113 #if portBYTE_ALIGNMENT == 2
114  #define portBYTE_ALIGNMENT_MASK ( 0x0001 )
115 #endif
116 
117 #if portBYTE_ALIGNMENT == 1
118  #define portBYTE_ALIGNMENT_MASK ( 0x0000 )
119 #endif
120 
121 #ifndef portBYTE_ALIGNMENT_MASK
122  #error "Invalid portBYTE_ALIGNMENT definition"
123 #endif
124 
125 #ifndef portNUM_CONFIGURABLE_REGIONS
126  #define portNUM_CONFIGURABLE_REGIONS 1
127 #endif
128 
129 #ifdef __cplusplus
130 extern "C" {
131 #endif
132 
133 #include "mpu_wrappers.h"
134 
135 /*
136  * Setup the stack of a new task so it is ready to be placed under the
137  * scheduler control. The registers have to be placed on the stack in
138  * the order that the port expects to find them.
139  *
140  */
141 #if( portUSING_MPU_WRAPPERS == 1 )
142  PRIVILEGED_FUNCTION StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) ;
143 #else
144  PRIVILEGED_FUNCTION StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) ;
145 #endif
146 
147 /* Used by heap_5.c. */
148 typedef struct HeapRegion
149 {
151  size_t xSizeInBytes;
152 } HeapRegion_t;
153 
154 /*
155  * Used to define multiple heap regions for use by heap_5.c. This function
156  * must be called before any calls to pvPortMalloc() - not creating a task,
157  * queue, semaphore, mutex, software timer, event group, etc. will result in
158  * pvPortMalloc being called.
159  *
160  * pxHeapRegions passes in an array of HeapRegion_t structures - each of which
161  * defines a region of memory that can be used as the heap. The array is
162  * terminated by a HeapRegions_t structure that has a size of 0. The region
163  * with the lowest start address must appear first in the array.
164  */
165 PRIVILEGED_FUNCTION void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions );
166 
167 
168 /*
169  * Map to the memory management routines required for the port.
170  */
171 PRIVILEGED_FUNCTION void *pvPortMalloc( size_t xSize );
172 PRIVILEGED_FUNCTION void vPortFree( void *pv );
176 
177 /*
178  * Setup the hardware ready for the scheduler to take control. This generally
179  * sets up a tick interrupt and sets timers for the correct tick frequency.
180  */
182 
183 /*
184  * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
185  * the hardware is left in its original condition after the scheduler stops
186  * executing.
187  */
189 
190 /*
191  * The structures and methods of manipulating the MPU are contained within the
192  * port layer.
193  *
194  * Fills the xMPUSettings structure with the memory region information
195  * contained in xRegions.
196  */
197 #if( portUSING_MPU_WRAPPERS == 1 )
198  struct xMEMORY_REGION;
199  PRIVILEGED_FUNCTION void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth );
200 #endif
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* PORTABLE_H */
HeapRegion::xSizeInBytes
size_t xSizeInBytes
Definition: portable.h:151
pvPortMalloc
PRIVILEGED_FUNCTION void * pvPortMalloc(size_t xSize)
Definition: heap_4.c:155
mpu_wrappers.h
vPortInitialiseBlocks
PRIVILEGED_FUNCTION void vPortInitialiseBlocks(void)
Definition: heap_4.c:365
xMEMORY_REGION
Definition: task.h:144
xPortGetFreeHeapSize
PRIVILEGED_FUNCTION size_t xPortGetFreeHeapSize(void)
Definition: heap_4.c:353
PRIVILEGED_FUNCTION
#define PRIVILEGED_FUNCTION
Definition: mpu_wrappers.h:204
xPortStartScheduler
PRIVILEGED_FUNCTION BaseType_t xPortStartScheduler(void)
Definition: port.c:312
StackType_t
portSTACK_TYPE StackType_t
Definition: portmacro.h:97
HeapRegion_t
struct HeapRegion HeapRegion_t
TaskFunction_t
void(* TaskFunction_t)(void *)
Definition: projdefs.h:77
uint8_t
const uint8_t[]
Definition: 404_html.c:3
deprecated_definitions.h
vPortEndScheduler
PRIVILEGED_FUNCTION void vPortEndScheduler(void)
Definition: port.c:399
BaseType_t
long BaseType_t
Definition: portmacro.h:98
vPortFree
PRIVILEGED_FUNCTION void vPortFree(void *pv)
Definition: heap_4.c:305
pxPortInitialiseStack
PRIVILEGED_FUNCTION StackType_t * pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters)
xPortGetMinimumEverFreeHeapSize
PRIVILEGED_FUNCTION size_t xPortGetMinimumEverFreeHeapSize(void)
Definition: heap_4.c:359
portmacro.h
HeapRegion::pucStartAddress
uint8_t * pucStartAddress
Definition: portable.h:150
HeapRegion
Definition: portable.h:148
vPortDefineHeapRegions
PRIVILEGED_FUNCTION void vPortDefineHeapRegions(const HeapRegion_t *const pxHeapRegions)