summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/rtems/cache.h
blob: e869769393642d476078f81bc7342c94e4797add (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
/* SPDX-License-Identifier: BSD-2-Clause */

/**
 * @file
 *
 * @ingroup RTEMSImplClassicCache
 *
 * @brief This header file defines the Cache Manager API.
 */

/*
 * Copyright (C) 2016 Pavel Pisa
 * Copyright (C) 2014, 2021 embedded brains GmbH (http://www.embedded-brains.de)
 * Copyright (C) 2000, 2008 On-Line Applications Research Corporation (OAR)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This file is part of the RTEMS quality process and was automatically
 * generated.  If you find something that needs to be fixed or
 * worded better please post a report or patch to an RTEMS mailing list
 * or raise a bug report:
 *
 * https://www.rtems.org/bugs.html
 *
 * For information on updating and regenerating please refer to the How-To
 * section in the Software Requirements Engineering chapter of the
 * RTEMS Software Engineering manual.  The manual is provided as a part of
 * a release.  For development sources please refer to the online
 * documentation at:
 *
 * https://docs.rtems.org
 */

/* Generated from spec:/rtems/cache/if/header */

#ifndef _RTEMS_RTEMS_CACHE_H
#define _RTEMS_RTEMS_CACHE_H

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Generated from spec:/rtems/cache/if/group */

/**
 * @defgroup RTEMSAPIClassicCache Cache Manager
 *
 * @ingroup RTEMSAPIClassic
 *
 * @brief The Cache Manager provides functions to perform maintenance
 *   operations for data and instruction caches.
 *
 * The actual actions of the Cache Manager operations depend on the hardware
 * and the implementation provided by the CPU architecture port or a board
 * support package.  Cache implementations tend to be highly hardware
 * dependent.
 */

/* Generated from spec:/rtems/cache/if/coherent-add-area */

/**
 * @brief Adds a cache coherent memory area to the cache coherent allocator.
 *
 * @param begin is the begin address of the cache coherent memory area to add.
 *
 * @param size is the size in bytes of the cache coherent memory area to add.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within device driver initialization
 *   context.
 *
 * * The directive may be called from within task context.
 *
 * * The directive may obtain and release the object allocator mutex.  This may
 *   cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_coherent_add_area( void *begin, uintptr_t size );

/* Generated from spec:/rtems/cache/if/coherent-allocate */

/**
 * @brief Allocates a memory area from cache coherent memory.
 *
 * @param size is the requested size in bytes of the memory area to allocate.
 *
 * @param alignment is the requested alignment in bytes of the memory area to
 *   allocate.  If the alignment parameter is not equal to zero, the allocated
 *   memory area will begin at an address aligned by this value.
 *
 * @param boundary is the requested boundary in bytes of the memory area to
 *   allocate.  If the boundary parameter is not equal to zero, the allocated
 *   memory area will comply with a boundary constraint.  The boundary value
 *   specifies the set of addresses which are aligned by the boundary value.
 *   The interior of the allocated memory area will not contain an element of
 *   this set.  The begin or end address of the area may be a member of the
 *   set.
 *
 * @retval NULL There is not enough memory available to satisfy the allocation
 *   request.
 *
 * @return Returns the begin address of the allocated memory.
 *
 * @par Notes
 * @parblock
 * A size value of zero will return a unique address which may be freed with
 * rtems_cache_coherent_free().
 *
 * The memory allocated by the directive may be released with a call to
 * rtems_cache_coherent_free().
 *
 * By default the C Program Heap allocator is used.  In case special memory
 * areas must be used, then the BSP or the application should add cache
 * coherent memory areas for the allocator via rtems_cache_coherent_add_area().
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within device driver initialization
 *   context.
 *
 * * The directive may be called from within task context.
 *
 * * The directive may obtain and release the object allocator mutex.  This may
 *   cause the calling task to be preempted.
 * @endparblock
 */
void *rtems_cache_coherent_allocate(
  size_t    size,
  uintptr_t alignment,
  uintptr_t boundary
);

/* Generated from spec:/rtems/cache/if/coherent-free */

/**
 * @brief Frees memory allocated by rtems_cache_coherent_allocate().
 *
 * @param ptr is a pointer returned by rtems_cache_coherent_allocate().
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within device driver initialization
 *   context.
 *
 * * The directive may be called from within task context.
 *
 * * The directive may obtain and release the object allocator mutex.  This may
 *   cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_coherent_free( void *ptr );

/* Generated from spec:/rtems/cache/if/freeze-data */

/**
 * @brief Freezes the data caches.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_freeze_data( void );

/* Generated from spec:/rtems/cache/if/freeze-instruction */

/**
 * @brief Freezes the instruction caches.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_freeze_instruction( void );

/* Generated from spec:/rtems/cache/if/unfreeze-data */

/**
 * @brief Unfreezes the data cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_unfreeze_data( void );

/* Generated from spec:/rtems/cache/if/unfreeze-instruction */

/**
 * @brief Unfreezes the instruction cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_unfreeze_instruction( void );

/* Generated from spec:/rtems/cache/if/flush-multiple-data-lines */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Flushes the data cache lines covering the memory area.
 *
 * @param begin is the begin address of the memory area to flush.
 *
 * @param size is the size in bytes of the memory area to flush.
 *
 * Dirty data cache lines covering the area are transfered to memory.
 * Depending on the cache implementation this may mark the lines as invalid.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_flush_multiple_data_lines( const void *begin, size_t size );

/* Generated from spec:/rtems/cache/if/invalidate-multiple-data-lines */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Invalidates the data cache lines covering the memory area.
 *
 * @param begin is the begin address of the memory area to invalidate.
 *
 * @param size is the size in bytes of the memory area to invalidate.
 *
 * The cache lines covering the area are marked as invalid.  A later read
 * access in the area will load the data from memory.
 *
 * @par Notes
 * @parblock
 * In case the area is not aligned on cache line boundaries, then this
 * operation may destroy unrelated data.
 *
 * On some systems, the cache lines may be flushed before they are invalidated.
 * @endparblock
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_invalidate_multiple_data_lines(
  const void *begin,
  size_t      size
);

/* Generated from spec:/rtems/cache/if/invalidate-multiple-instruction-lines */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Invalidates the instruction cache lines covering the memory area.
 *
 * @param begin is the begin address of the memory area to invalidate.
 *
 * @param size is the size in bytes of the memory area to invalidate.
 *
 * The cache lines covering the area are marked as invalid.  A later
 * instruction fetch from the area will result in a load from memory.
 *
 * @par Notes
 * In SMP configurations, on processors without instruction cache snooping,
 * this operation will invalidate the instruction cache lines on all
 * processors.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_invalidate_multiple_instruction_lines(
  const void *begin,
  size_t      size
);

/* Generated from spec:/rtems/cache/if/instruction-sync-after-code-change */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Ensures necessary synchronization required after code changes.
 *
 * @param begin is the begin address of the code area to synchronize.
 *
 * @param size is the size in bytes of the code area to synchronize.
 *
 * @par Notes
 * When code is loaded or modified, then most systems require synchronization
 * instructions to update the instruction caches so that the loaded or modified
 * code is fetched.  For example, systems with separate data and instruction
 * caches or systems without instruction cache snooping.  The directives should
 * be used by run time loader for example.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_instruction_sync_after_code_change(
  const void *begin,
  size_t      size
);

/* Generated from spec:/rtems/cache/if/get-maximal-line-size */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Gets the maximal cache line size in bytes of all caches (data,
 *   instruction, or unified).
 *
 * @retval 0 There is no cache present.
 *
 * @return Returns the maximal cache line size in bytes of all caches (data,
 *   instruction, or unified).
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
size_t rtems_cache_get_maximal_line_size( void );

/* Generated from spec:/rtems/cache/if/get-data-line-size */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Gets the data cache line size in bytes.
 *
 * @retval 0 There is no data cache present.
 *
 * @return Returns the data cache line size in bytes.  For multi-level caches
 *   this is the maximum of the cache line sizes of all levels.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
size_t rtems_cache_get_data_line_size( void );

/* Generated from spec:/rtems/cache/if/get-instruction-line-size */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Gets the instruction cache line size in bytes.
 *
 * @retval 0 There is no instruction cache present.
 *
 * @return Returns the instruction cache line size in bytes.  For multi-level
 *   caches this is the maximum of the cache line sizes of all levels.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
size_t rtems_cache_get_instruction_line_size( void );

/* Generated from spec:/rtems/cache/if/get-data-size */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Gets the data cache size in bytes for the cache level.
 *
 * @param level is the requested data cache level.  The cache level zero
 *   specifies the entire data cache.
 *
 * @retval 0 There is no data cache present at the requested cache level.
 *
 * @return Returns the data cache size in bytes of the requested cache level.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
size_t rtems_cache_get_data_cache_size( uint32_t level );

/* Generated from spec:/rtems/cache/if/get-instruction-size */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Gets the instruction cache size in bytes for the cache level.
 *
 * @param level is the requested instruction cache level.  The cache level zero
 *   specifies the entire instruction cache.
 *
 * @retval 0 There is no instruction cache present at the requested cache
 *   level.
 *
 * @return Returns the instruction cache size in bytes of the requested cache
 *   level.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
size_t rtems_cache_get_instruction_cache_size( uint32_t level );

/* Generated from spec:/rtems/cache/if/flush-entire-data */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Flushes the entire data cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_flush_entire_data( void );

/* Generated from spec:/rtems/cache/if/invalidate-entire-data */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Invalidates the entire data cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_invalidate_entire_data( void );

/* Generated from spec:/rtems/cache/if/invalidate-entire-instruction */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Invalidates the entire instruction cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_invalidate_entire_instruction( void );

/* Generated from spec:/rtems/cache/if/enable-data */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Enables the data cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_enable_data( void );

/* Generated from spec:/rtems/cache/if/disable-data */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Disables the data cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_disable_data( void );

/* Generated from spec:/rtems/cache/if/enable-instruction */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Enables the instruction cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_enable_instruction( void );

/* Generated from spec:/rtems/cache/if/disable-instruction */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Disables the instruction cache.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within any runtime context.
 *
 * * The directive will not cause the calling task to be preempted.
 * @endparblock
 */
void rtems_cache_disable_instruction( void );

/* Generated from spec:/rtems/cache/if/aligned-malloc */

/**
 * @ingroup RTEMSAPIClassicCache
 *
 * @brief Allocates memory from the C Program Heap which begins at a cache line
 *   boundary.
 *
 * @param size is the size in bytes of the memory area to allocate.
 *
 * @retval NULL There is not enough memory available to satisfy the allocation
 *   request.
 *
 * @return Returns the begin address of the allocated memory.  The begin
 *   address is on a cache line boundary.
 *
 * @par Constraints
 * @parblock
 * The following constraints apply to this directive:
 *
 * * The directive may be called from within device driver initialization
 *   context.
 *
 * * The directive may be called from within task context.
 *
 * * The directive may obtain and release the object allocator mutex.  This may
 *   cause the calling task to be preempted.
 * @endparblock
 */
void *rtems_cache_aligned_malloc( size_t size );

#ifdef __cplusplus
}
#endif

#endif /* _RTEMS_RTEMS_CACHE_H */