5
Last change
on this file since 0e507d55 was
0e507d55,
checked in by Pavel Pisa <pisa@…>, on 07/02/16 at 22:19:38
|
rtems+bsps/cache: Define cache manager operations for code synchronization and maximal alignment.
There is need for unambiguous named and defined cache function
which should be called when code is updated, loaded
or is self-modifying.
There should be function to obtain maximal cache line length
as well. This function can and should be used for allocations
which can be used for data and or code and ensures that
there are no partial cache lines overlaps on start and
end of allocated region.
|
-
Property mode set to
100644
|
File size:
677 bytes
|
Line | |
---|
1 | /* |
---|
2 | * RTEMS Cache Aligned Malloc |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.org/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | #include <rtems.h> |
---|
14 | #include <rtems/malloc.h> |
---|
15 | |
---|
16 | void *rtems_cache_aligned_malloc( size_t nbytes ) |
---|
17 | { |
---|
18 | size_t line_size = rtems_cache_get_maximal_line_size(); |
---|
19 | |
---|
20 | if ( line_size > 0 ) { |
---|
21 | /* Assume that the cache line size is a power of two */ |
---|
22 | size_t m = line_size - 1; |
---|
23 | |
---|
24 | nbytes = (nbytes + m) & ~m; |
---|
25 | } |
---|
26 | |
---|
27 | return rtems_heap_allocate_aligned_with_boundary( nbytes, line_size, 0 ); |
---|
28 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.