RTEMS  5.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
percpudata.h
1 /*
2  * Copyright (c) 2018 embedded brains GmbH. All rights reserved.
3  *
4  * embedded brains GmbH
5  * Dornierstr. 4
6  * 82178 Puchheim
7  * Germany
8  * <rtems@embedded-brains.de>
9  *
10  * The license and distribution terms for this file may be
11  * found in the file LICENSE in this distribution or at
12  * http://www.rtems.org/license/LICENSE.
13  */
14 
15 #ifndef _RTEMS_SCORE_PERCPUDATA_H
16 #define _RTEMS_SCORE_PERCPUDATA_H
17 
18 #include <rtems/score/percpu.h>
19 #include <rtems/linkersets.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
39 RTEMS_LINKER_RWSET_DECLARE( _Per_CPU_Data, char );
40 
49 #define PER_CPU_DATA_ITEM_DECLARE( type, item ) \
50  RTEMS_LINKER_RWSET_ITEM_DECLARE( _Per_CPU_Data, type, item ) \
51  RTEMS_SECTION( ".rtemsrwset._Per_CPU_Data.content.1" )
52 
59 #define PER_CPU_DATA_ITEM( type, item ) \
60  RTEMS_LINKER_RWSET_ITEM( _Per_CPU_Data, type, item )
61 
68 #define PER_CPU_DATA_OFFSET( item ) \
69  ( (uintptr_t) &_Linker_set__Per_CPU_Data_##item \
70  - (uintptr_t) RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ) )
71 
80 #ifdef RTEMS_SMP
81 #define PER_CPU_DATA_GET_BY_OFFSET( cpu, type, offset ) \
82  (type *) ( cpu->data + offset )
83 #else
84 #define PER_CPU_DATA_GET_BY_OFFSET( cpu, type, offset ) \
85  (type *) ( (uintptr_t) RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ) + offset ), \
86  (void) cpu
87 #endif
88 
97 #ifdef RTEMS_SMP
98 #define PER_CPU_DATA_GET( cpu, type, item ) \
99  PER_CPU_DATA_GET_BY_OFFSET( cpu, type, PER_CPU_DATA_OFFSET( item ) )
100 #else
101 #define PER_CPU_DATA_GET( cpu, type, item ) \
102  &_Linker_set__Per_CPU_Data_##item, (void) cpu
103 #endif
104 
107 #ifdef __cplusplus
108 }
109 #endif /* __cplusplus */
110 
111 #endif /* _RTEMS_SCORE_PERCPUDATA_H */