source: rtems/cpukit/score/src/percpuasm.c @ 4a0e418

Last change on this file since 4a0e418 was 4a0e418, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 21:09:20

score/src/[n-s]*.c: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSScorePerCPU
7 *
8 * @brief This source file contains the static assertions for defines used in
9 *   assembler files.
10 */
11
12/*
13 * Copyright (c) 2012, 2016 embedded brains GmbH.  All rights reserved.
14 *
15 *  embedded brains GmbH
16 *  Dornierstr. 4
17 *  82178 Puchheim
18 *  Germany
19 *  <rtems@embedded-brains.de>
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 *    notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 *    notice, this list of conditions and the following disclaimer in the
28 *    documentation and/or other materials provided with the distribution.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
41 */
42
43#ifdef HAVE_CONFIG_H
44#include "config.h"
45#endif
46
47#include <rtems/score/cpu.h>
48
49#define _RTEMS_PERCPU_DEFINE_OFFSETS
50#include <rtems/score/percpu.h>
51
52#define PER_CPU_IS_POWER_OF_TWO( value ) \
53  ( ( ( ( value ) - 1 ) & ( value ) ) == 0 )
54
55/*
56 * The minimum alignment of two is due to the Heap Handler which uses the
57 * HEAP_PREV_BLOCK_USED flag to indicate that the previous block is used.
58 */
59
60RTEMS_STATIC_ASSERT(
61  CPU_ALIGNMENT >= 2 && PER_CPU_IS_POWER_OF_TWO( CPU_ALIGNMENT ),
62  CPU_ALIGNMENT
63);
64
65RTEMS_STATIC_ASSERT(
66  CPU_HEAP_ALIGNMENT >= 2 && PER_CPU_IS_POWER_OF_TWO( CPU_HEAP_ALIGNMENT ),
67  CPU_HEAP_ALIGNMENT_0
68);
69
70RTEMS_STATIC_ASSERT(
71  CPU_HEAP_ALIGNMENT >= CPU_ALIGNMENT,
72  CPU_HEAP_ALIGNMENT_1
73);
74
75RTEMS_STATIC_ASSERT(
76  CPU_STACK_ALIGNMENT >= CPU_HEAP_ALIGNMENT &&
77    PER_CPU_IS_POWER_OF_TWO( CPU_STACK_ALIGNMENT ),
78  CPU_STACK_ALIGNMENT
79);
80
81RTEMS_STATIC_ASSERT(
82  sizeof(void *) == CPU_SIZEOF_POINTER,
83  CPU_SIZEOF_POINTER
84);
85
86#if defined( __SIZEOF_POINTER__ )
87  RTEMS_STATIC_ASSERT(
88    CPU_SIZEOF_POINTER == __SIZEOF_POINTER__,
89    __SIZEOF_POINTER__
90  );
91#endif
92
93#if CPU_PER_CPU_CONTROL_SIZE > 0
94  RTEMS_STATIC_ASSERT(
95    sizeof( CPU_Per_CPU_control ) == CPU_PER_CPU_CONTROL_SIZE,
96    CPU_PER_CPU_CONTROL_SIZE
97  );
98#endif
99
100#if defined( RTEMS_SMP )
101  RTEMS_STATIC_ASSERT(
102    sizeof( Per_CPU_Control_envelope ) == PER_CPU_CONTROL_SIZE,
103    PER_CPU_CONTROL_SIZE
104  );
105#endif
106
107RTEMS_STATIC_ASSERT(
108  offsetof(Per_CPU_Control, isr_nest_level) == PER_CPU_ISR_NEST_LEVEL,
109  PER_CPU_ISR_NEST_LEVEL
110);
111
112RTEMS_STATIC_ASSERT(
113  offsetof(Per_CPU_Control, isr_dispatch_disable)
114    == PER_CPU_ISR_DISPATCH_DISABLE,
115  PER_CPU_ISR_DISPATCH_DISABLE
116);
117
118RTEMS_STATIC_ASSERT(
119  offsetof(Per_CPU_Control, thread_dispatch_disable_level)
120    == PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL,
121  PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL
122);
123
124RTEMS_STATIC_ASSERT(
125  offsetof(Per_CPU_Control, executing) == PER_CPU_OFFSET_EXECUTING,
126  PER_CPU_OFFSET_EXECUTING
127);
128
129RTEMS_STATIC_ASSERT(
130  offsetof(Per_CPU_Control, heir) == PER_CPU_OFFSET_HEIR,
131  PER_CPU_OFFSET_HEIR
132);
133
134RTEMS_STATIC_ASSERT(
135  offsetof(Per_CPU_Control, dispatch_necessary) == PER_CPU_DISPATCH_NEEDED,
136  PER_CPU_DISPATCH_NEEDED
137);
138
139#if defined(RTEMS_SMP)
140RTEMS_STATIC_ASSERT(
141  offsetof(Per_CPU_Control, Interrupt_frame) == PER_CPU_INTERRUPT_FRAME_AREA,
142  PER_CPU_INTERRUPT_FRAME_AREA
143);
144
145RTEMS_STATIC_ASSERT(
146  sizeof( CPU_Interrupt_frame ) == CPU_INTERRUPT_FRAME_SIZE,
147  CPU_INTERRUPT_FRAME_SIZE
148);
149#endif
150
151RTEMS_STATIC_ASSERT(
152  offsetof(Per_CPU_Control, interrupt_stack_low)
153    == PER_CPU_INTERRUPT_STACK_LOW,
154  PER_CPU_INTERRUPT_STACK_LOW
155);
156
157RTEMS_STATIC_ASSERT(
158  offsetof(Per_CPU_Control, interrupt_stack_high)
159    == PER_CPU_INTERRUPT_STACK_HIGH,
160  PER_CPU_INTERRUPT_STACK_HIGH
161);
Note: See TracBrowser for help on using the repository browser.