summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-03-25 23:01:56 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-03-25 23:01:56 +0000
commita8d1690ffec4a67fdcb0836fd91989fd1dbf5a7a (patch)
treeffd2e99e3a61d03641e663c5574ed0adf30d8df0 /firmware/export
parent43bc2e586ae3194541bc5a835803750fcd2c1c0d (diff)
downloadrockbox-a8d1690ffec4a67fdcb0836fd91989fd1dbf5a7a.tar.gz
rockbox-a8d1690ffec4a67fdcb0836fd91989fd1dbf5a7a.zip
Make storage alignement use cache alignement macros
Introduce STORAGE_ALIGN_DOWN, STORAGE_PAD (using new CACHE_PAD) and STORAGE_OVERLAP (using new CACHE_OVERLAP), make them useful only when PROC_NEEDS_CACHEALIGN and STORAGE_NEEDS_ALIGN are defined Modify PP and nano2g system-target.h accordingly git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25336 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/config.h17
-rw-r--r--firmware/export/config/ipodnano2g.h1
-rw-r--r--firmware/export/system.h18
3 files changed, 18 insertions, 18 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index e678590b44..9d8dc41111 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -914,23 +914,6 @@ Lyre prototype 1 */
914 914
915#endif /* HAVE_USBSTACK */ 915#endif /* HAVE_USBSTACK */
916 916
917/* Storage alignment: the mask specifies a mask of bits which should be
918 * clear in addresses used for storage_{read,write}_sectors(). This is
919 * only relevant for buffers that will contain one or more whole sectors.
920 */
921
922/* PP502x DMA requires an alignment of at least 16 bytes */
923#ifdef HAVE_ATA_DMA
924#ifdef CPU_PP502x
925#define STORAGE_ALIGN_MASK 15
926#endif
927#endif /* HAVE_ATA_DMA */
928
929/* by default no alignment is required */
930#ifndef STORAGE_ALIGN_MASK
931#define STORAGE_ALIGN_MASK 0
932#endif
933
934/* This attribute can be used to enable to detection of plugin file handles leaks. 917/* This attribute can be used to enable to detection of plugin file handles leaks.
935 * When enabled, the plugin core will monitor open/close/creat and when the plugin exits 918 * When enabled, the plugin core will monitor open/close/creat and when the plugin exits
936 * will display an error message if the plugin leaked some file handles */ 919 * will display an error message if the plugin leaked some file handles */
diff --git a/firmware/export/config/ipodnano2g.h b/firmware/export/config/ipodnano2g.h
index 0b690416a7..989d56338d 100644
--- a/firmware/export/config/ipodnano2g.h
+++ b/firmware/export/config/ipodnano2g.h
@@ -219,6 +219,5 @@
219//#define IPOD_ACCESSORY_PROTOCOL 219//#define IPOD_ACCESSORY_PROTOCOL
220//#define HAVE_SERIAL 220//#define HAVE_SERIAL
221 221
222#define STORAGE_ALIGN_MASK 15
223#define USB_WRITE_BUFFER_SIZE (1024*64) 222#define USB_WRITE_BUFFER_SIZE (1024*64)
224 223
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 505b167af9..fee188802b 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -312,6 +312,16 @@ static inline void cpucache_flush(void)
312/* Aligns a buffer pointer and size to proper boundaries */ 312/* Aligns a buffer pointer and size to proper boundaries */
313#define CACHEALIGN_BUFFER(start, size) \ 313#define CACHEALIGN_BUFFER(start, size) \
314 ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE) 314 ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE)
315/* Pad a size so the buffer can be aligned later */
316#define CACHE_PAD(x) ((x) + CACHEALIGN_SIZE - 1)
317/* Number of bytes in the last cacheline assuming buffer of size x is aligned */
318#define CACHE_OVERLAP(x) (x & (CACHEALIGN_SIZE - 1))
319
320#ifdef NEEDS_STORAGE_ALIGN
321#define STORAGE_ALIGN_DOWN(x) CACHEALIGN_DOWN(x)
322#define STORAGE_PAD(x) CACHE_PAD(x)
323#define STORAGE_OVERLAP(x) CACHE_OVERLAP(x)
324#endif
315 325
316#else /* ndef PROC_NEEDS_CACHEALIGN */ 326#else /* ndef PROC_NEEDS_CACHEALIGN */
317 327
@@ -323,9 +333,17 @@ static inline void cpucache_flush(void)
323#define CACHEALIGN_DOWN(x) (x) 333#define CACHEALIGN_DOWN(x) (x)
324/* Make no adjustments */ 334/* Make no adjustments */
325#define CACHEALIGN_BUFFER(start, size) 335#define CACHEALIGN_BUFFER(start, size)
336#define CACHE_PAD(x) (x)
337#define CACHE_OVERLAP(x) 0
326 338
327#endif /* PROC_NEEDS_CACHEALIGN */ 339#endif /* PROC_NEEDS_CACHEALIGN */
328 340
341#if !defined(PROC_NEEDS_CACHEALIGN) || !defined(NEEDS_STORAGE_ALIGN)
342#define STORAGE_ALIGN_DOWN(x) (x)
343#define STORAGE_PAD(x) (x)
344#define STORAGE_OVERLAP(x) 0
345#endif
346
329/* Double-cast to avoid 'dereferencing type-punned pointer will 347/* Double-cast to avoid 'dereferencing type-punned pointer will
330 * break strict aliasing rules' B.S. */ 348 * break strict aliasing rules' B.S. */
331#define PUN_PTR(type, p) ((type)(intptr_t)(p)) 349#define PUN_PTR(type, p) ((type)(intptr_t)(p))