RTEMS
percpudata.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2018 embedded brains GmbH. All rights reserved.
11  *
12  * embedded brains GmbH
13  * Dornierstr. 4
14  * 82178 Puchheim
15  * Germany
16  * <rtems@embedded-brains.de>
17  *
18  * The license and distribution terms for this file may be
19  * found in the file LICENSE in this distribution or at
20  * http://www.rtems.org/license/LICENSE.
21  */
22 
23 #ifndef _RTEMS_SCORE_PERCPUDATA_H
24 #define _RTEMS_SCORE_PERCPUDATA_H
25 
26 #include <rtems/score/percpu.h>
27 #include <rtems/linkersets.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32 
49 RTEMS_LINKER_RWSET_DECLARE( _Per_CPU_Data, char );
50 
59 #define PER_CPU_DATA_ITEM_DECLARE( type, item ) \
60  RTEMS_LINKER_RWSET_ITEM_DECLARE( _Per_CPU_Data, type, item )
61 
68 #define PER_CPU_DATA_ITEM( type, item ) \
69  RTEMS_LINKER_RWSET_ITEM( _Per_CPU_Data, type, item )
70 
77 #define PER_CPU_DATA_OFFSET( item ) \
78  ( (uintptr_t) &_Linker_set__Per_CPU_Data_##item \
79  - (uintptr_t) RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ) )
80 
89 #ifdef RTEMS_SMP
90 #define PER_CPU_DATA_GET_BY_OFFSET( cpu, type, offset ) \
91  (type *) ( cpu->data + offset )
92 #else
93 #define PER_CPU_DATA_GET_BY_OFFSET( cpu, type, offset ) \
94  (type *) ( (uintptr_t) RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ) + offset ), \
95  (void) cpu
96 #endif
97 
106 #ifdef RTEMS_SMP
107 #define PER_CPU_DATA_GET( cpu, type, item ) \
108  PER_CPU_DATA_GET_BY_OFFSET( cpu, type, PER_CPU_DATA_OFFSET( item ) )
109 #else
110 #define PER_CPU_DATA_GET( cpu, type, item ) \
111  &_Linker_set__Per_CPU_Data_##item, (void) cpu
112 #endif
113 
116 #ifdef __cplusplus
117 }
118 #endif /* __cplusplus */
119 
120 #endif /* _RTEMS_SCORE_PERCPUDATA_H */